Skip to content
Commits on Source (26)
*.elc
*.test
*-autoloads.el
*-pkg.el
*~
*.tar.gz
tuareg.*/
packages
/tuareg.*/
ChangeLog
# Inspired by http://sachachua.com/blog/2015/02/continuous-integration-code-coverage-emacs-packages-travis-coveralls/
language: emacs-lisp
sudo: false
env:
matrix:
- EVM_EMACS=emacs-24.3
- EVM_EMACS=emacs-24.4
- EVM_EMACS=emacs-24.5
- EVM_EMACS=emacs-25.1
before_install:
- export PATH="$HOME/.evm/bin:$PATH"
- git clone https://github.com/rejeep/evm.git $HOME/.evm
- evm config path /tmp
- evm install ${EVM_EMACS}-travis --use --skip
script:
- emacs --version
- make elc
- make indent-test
notifications:
email: true
2.0.9 (master):
* Do not activate Tuareg for .mll and .mly files.
* Toplevel prompt is readonly.
* Font-lock code completely rewritten (avoids several hangs). New faces
`tuareg-font-lock-module-face', `tuareg-font-lock-constructor-face',
and `tuareg-font-lock-line-number-face'.
* Non-closed comment does not cause M-q to hang.
* New variables `caml-types-build-dirs' and `caml-types-annot-dir' for
a more versatile specification of .annot files. (Submitted back to
caml-mode.)
* Fix toplevel highlighting of output and errors.
2.1.0 2017-11-10
----------------
* Let <kbd>M-q</kbd> reformat strings (and use only SMIE).
* Do not indent an expression after `;;` (issue #106).
* New face `tuareg-font-double-colon-face` to highlight `;;`.
* For `type … and …`, left-align `and` with `type`.
* Fix indentation of some GADT type definitions.
* Use `prettify-symbols-mode` to turn `+.` into `∔`,… and add a menu
entry to toggle it.
* Properly indent `type 'a foo = 'a bla = …` (issue #98).
* Properly indent (issue #7):
module … with module X = Z
and type t := C.t
* Support `let exception E in expr` (issue #102).
* Improved highlighting of `val` and `module` in first class module
expressions.
* Warn if a file inside a `_build` is edited and propose to switch.
* Add a custom face `tuareg-font-lock-label-face` for labels.
* Add option `tuareg-match-patterns-aligned` to allow to choose
between the two styles:
function v.s. function
| A | A
| B -> ... | B -> ...
| C -> ... | C -> ... "
* Highlight attributes and extension nodes.
* Disable by default and improve the compilation advice—see the new
variable `tuareg-opam-insinuate` (issue #97).
* New keybinding <kbd>C-cC-w</kbd> and function `tuareg-opam-update-env`
to update the environment to an opam switch (offering completion).
* Improved highlighting of quoted strings `{|…|}` (issue #89).
* Move after `;;` when evaluating a phrase in the toploop (issue #96).
* ocamldebug:
- Add support for `completion-at-point`.
- Highlight the right location even in presence of non-ascii chars
(issue #80).
- Make possible to pass argument to ocamldebug (say, paths with `-I`).
- Make possible to pass argument to the program being debugged (issue #66).
- Warn if SMIE is disabled.
* New modes `tuareg-jbuild` and `tuareg-opam` with syntax
highlighting, indentation, and skeletons.
2.0.10
------
* New indentation config var for SMIE: tuareg-indent-align-with-first-arg.
* Many indentation improvements.
* Fixed point jumping in ocamldebug completion (by Darius Foo).
* Improved (var: t) syntax highlighting.
* Color all predefined exceptions with font-lock-builtin-face
* Syntax highlight cppo preprocessor directives.
2.0.9
-----
* Do not activate Tuareg for .mll and .mly files.
* Toplevel prompt is readonly.
* Font-lock code completely rewritten (avoids several hangs). New faces
`tuareg-font-lock-module-face', `tuareg-font-lock-constructor-face',
and `tuareg-font-lock-line-number-face'.
* Non-closed comment does not cause M-q to hang.
* New variables `caml-types-build-dirs' and `caml-types-annot-dir' for
a more versatile specification of .annot files. (Submitted back to
caml-mode.)
* Fix toplevel highlighting of output and errors.
......@@ -6,23 +6,31 @@ REQUIREMENTS = $(shell grep ';; Package-Requires:' tuareg.el \
| sed 's/;; Package-Requires: *\(.*\)/\1/')
DIST_NAME = tuareg-$(VERSION)
TARBALL = $(DIST_NAME).tar.gz
OPAM_DIR = tuareg.$(VERSION)
OPAM_DIR = packages/tuareg/tuareg.$(VERSION)
SOURCES = tuareg.el tuareg_indent.el ocamldebug.el
SOURCES = tuareg.el ocamldebug.el tuareg-opam.el \
tuareg-jbuild.el
ELS = $(SOURCES) tuareg-site-file.el
ELC = $(ELS:.el=.elc)
INSTALL_FILES = $(ELS) $(ELC)
INSTALL_DIR ?= $(shell opam config var share)/emacs/site-lisp
DIST_FILES += $(ELS) Makefile README.md
DIST_FILES += $(ELS) Makefile README.md tuareg.install
EMACSFORMACOSX = /Applications/Emacs.app/Contents/MacOS/Emacs
AQUAMACS = $(shell test -d /Applications \
&& find /Applications -type f | grep 'Aquamacs$$')
ifeq ($(wildcard $(EMACSFORMACOSX)),$(EMACSFORMACOSX))
EMACS ?= $(EMACSFORMACOSX)
else
EMACS ?= emacs
ifneq ($(strip $(AQUAMACS)),)
ifeq ($(wildcard $(AQUAMACS)),$(AQUAMACS))
EMACS ?= $(AQUAMACS)
endif
endif
endif
EMACS ?= emacs
#ENABLE_SMIE = --eval '(setq tuareg-use-smie t)'
RM ?= rm -f
......@@ -34,12 +42,13 @@ INSTALL_RM_R = $(RM) -r
INSTALL_MKDIR = mkdir -p
INSTALL_CP = $(CP)
all : elc tuareg-site-file.el
all : tuareg-site-file.el
elc : $(ELC)
%.elc : %.el
$(EMACS) --batch -L . --no-init-file -f batch-byte-compile $<
@echo "Files byte-compiled using $(EMACS)"
install : $(INSTALL_FILES)
$(INSTALL_MKDIR) $(INSTALL_DIR)
......@@ -59,7 +68,7 @@ check : sample.ml.test
@echo ====Indent $*====
-$(RM) $@
$(EMACS) --batch -q --no-site-file $(ENABLE_SMIE) \
--load tuareg.elc $< \
--load tuareg-site-file.el $< \
--eval '(setq indent-tabs-mode nil)' \
--eval '(defun ask-user-about-lock (file opponent) nil)' \
--eval '(indent-region (point-min) (point-max) nil)' \
......@@ -67,6 +76,8 @@ check : sample.ml.test
--eval '(write-region (point-min) (point-max) "$@")'
$(DIFF) $< $@ || true
indent-test: indent-test.ml.test
tuareg-site-file.el: $(SOURCES)
(echo ";;; $@ --- Automatically extracted autoloads.";\
echo ";;; Code:";\
......@@ -87,7 +98,7 @@ $(TARBALL): $(DIST_FILES)
opam: $(TARBALL)
$(INSTALL_MKDIR) $(OPAM_DIR)
$(CP) -a $(filter-out %~, $(wildcard opam/*)) $(OPAM_DIR)
echo "archive: \"`pwd`/$(TARBALL)\"" > $(OPAM_DIR)/url
echo "archive: \"https://github.com/ocaml/tuareg/releases/download/$(VERSION)/$(TARBALL)\"" > $(OPAM_DIR)/url
echo "checksum: \"`md5sum $(TARBALL) | cut -d ' ' -f 1`\"" \
>> $(OPAM_DIR)/url
......
[![MELPA](https://melpa.org/packages/tuareg-badge.svg)](https://melpa.org/#/tuareg)
[![LGPL v2](https://img.shields.io/badge/licence-lgpl2-blue.svg)](COPYING)
[![Build Status](https://travis-ci.org/ocaml/tuareg.svg?branch=master)](https://travis-ci.org/ocaml/tuareg)
Tuareg: an Emacs OCaml mode
===========================
This archive contains files to help editing [OCaml](http://ocaml.org/)
code, to highlight important parts of the code, to run an OCaml
toplevel, and to run the OCaml debugger within Emacs.
[REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)
(also called *toplevel*),
and to run the OCaml debugger within Emacs.
Contents
--------
`README` — This file.
`README.md` — This file.
`HISTORY` — Differences with previous versions.
`tuareg.el` — A major mode for editing OCaml code in Emacs.
`ocamldebug.el` — To run the OCaml debugger under Emacs.
......@@ -17,36 +23,130 @@ Contents
Install
-------
See `tuareg.el`.
The easier way to install Tuareg is though
[`opam`](http://opam.ocaml.org/):
opam install tuareg
and follow the instructions given at the end of the `opam`
installation.
There are versions of Tuareg in [Melpa](https://melpa.org/) and
in [Marmalade](https://marmalade-repo.org/) but they may be older.
If you want to install from the Git checkout, just add to your
[Init File][]the line:
Configuration
-------------
(load "path-to-git-checkout-dir/tuareg-site-file")
Add the following line near the beginning of your ~/.emacs file:
If you want to byte compile the files, issue `make elc`. If you do
this in Darwin, make sure that the version of Emacs displayed at the
end of `make elc` is the sole that you use (the `.elc` files may not
be compatible with other versions of Emacs installed on your system).
(load "/where/ever/you/put/tuareg-mode/tuareg-site-file")
Usage & Configuration
---------------------
The Tuareg major mode is triggered by visiting a file with extension
.ml, .mli, .mly, .mll, and .mlp or manually by M-x tuareg-mode. It
gives you the correct syntax table for the OCaml language.
`.ml`, `.mli`, `.mly`, `.mll`, and `.mlp` or manually by
<kbd>M-x tuareg-mode</kbd>.
Start the OCaml REPL with <kbd>M-x run-ocaml</kbd>.
To evaluate a
phrase, simply type <kbd>S-⟨return⟩</kbd> (<kbd>shift</kbd> and
<kbd>return</kbd>). You can also evaluate a
phrase in a different buffer by typing <kbd>C-c C-e</kbd> when the
cursor is on it (it
will start the OCaml REPL if needed).
Run the OCaml debugger with <kbd>M-x ocamldebug FILE</kbd>.
Tips & customization
--------------------
- You can comment/uncomment a single line with <kbd>M-;</kbd>.
- By default, Tuareg will align the arguments of functions as follows:
function_name arg1
arg2
This is what most OCaml programmers expect and is convenient if you
use the following style:
function_name (fun x ->
do_something
)
arg2
If you prefer the “lisp style” indentation in which arguments on the
second line are aligned with the arguments on the first line as in
function_name arg1
arg2
put `(setq tuareg-indent-align-with-first-arg t)` in your [Init File][].
Thanks to the work of Stefan Monnier, a new indentation engine based
on SMIE was written. To deactivate it, add (setq tuareg-use-smie nil)
to the top-level of your `.emacs` file.
In both cases, if there are no argument on the line following the
function name, the indentation will be:
Usage
-----
function_name
arg1
arg2
See `tuareg.el`.
- To make easier to distinguish pattern-match cases containing several
patterns, sub-patterns are slightly indented as in
Customization
-------------
match x with
| A
| B -> ...
| C -> ...
The standard Emacs customization tool can be used to configure
Tuareg options. It is available from the Options menu and Tuareg's
Customize sub-menu.
If you prefer all pipes to be aligned as
match x with
| A
| B -> ...
| C -> ...
use `(setq tuareg-match-patterns-aligned t)`.
- Emacs ≥ 24.4 turned on [electric-indent-mode][] mode by default. If
you do not like it, call `(electric-indent-mode 0)` in
`tuareg-mode-hook`.
[electric-indent-mode]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Indent-Convenience.html
- You can turn on and off the rendering of certain sequences of
characters as symbols (such as `∔` and `∧` instead of `+.`and `&&`),
use `prettify-symbols-mode` or use the check box in the _Tuareg
Options_ menu. To enable it by default when you start Tuareg, add
the following to your [Init File][]:
(add-hook 'tuareg-mode-hook
(lambda()
(when (functionp 'prettify-symbols-mode)
(prettify-symbols-mode))))
If you want more symbols to be prettified (such as `->` being
displayed as `→`) at the expense of modifying the indentation in
incompatible ways with those not using that option, add `(setq
tuareg-prettify-symbols-full t)` to your [Init File][].
Thanks to the work of Stefan Monnier, a new indentation engine based on
[SMIE](https://www.gnu.org/software/emacs/manual/html_node/elisp/SMIE.html)
was written. This changes the indentation somewhat w.r.t. the
previous versions of `tuareg`. If the indentation does not correspond
to what you expect, please submit a
[motivated issue](https://github.com/ocaml/tuareg/issues/).
The standard Emacs customization tool can be used to configure Tuareg
options. It is available from the Options menu and Tuareg's Customize
sub-menu. Note that, at the moment, both customization options
pertaining to the SMIE indentation mode and the old one are present.
You may also customize the appearance of OCaml code by twiddling the
variables listed at the start of tuareg.el (preferably using
......@@ -56,23 +156,17 @@ You should then add to your configuration file something like:
(add-hook 'tuareg-mode-hook
(lambda () ... ; your customization code ))
Sample Customizations
---------------------
Here are random examples of customization you might like to put in
your ~/.emacs file:
;; Indent `=' like a standard keyword.
(setq tuareg-lazy-= t)
;; Indent [({ like standard keywords.
(setq tuareg-lazy-paren t)
;; No indentation after `in' keywords.
(setq tuareg-in-indent 0)
For example:
(add-hook 'tuareg-mode-hook
;; Turn on auto-fill minor mode.
(lambda () (auto-fill-mode 1)))
See [dot-emacs.el](dot-emacs.el) for some examples.
[Init File]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html
Features, Known Bugs
--------------------
......@@ -118,7 +212,7 @@ Reporting
---------
The official Tuareg home page is located at:
<https://forge.ocamlcore.org/projects/tuareg/>.
<https://github.com/ocaml/tuareg>.
Bug reports & patches: use the tracker:
<https://forge.ocamlcore.org/tracker/?group_id=43>.
<https://github.com/ocaml/tuareg/issues>.
tuareg-mode (1:2.1.0-2) unstable; urgency=medium
* Update Vcs-* to salsa
* Standards-Version 4.2.0 (no change)
* d/copyright: https in url of format specification
* debhelper compatibility level 11 (no change)
* as-installed test (closes: #906226)
- depend on emacs
- test with tuareg.el instead of tuareg.elc (to be undone when the
package is converted to dh-elpa)
-- Ralf Treinen <treinen@debian.org> Wed, 15 Aug 2018 18:22:37 +0200
tuareg-mode (1:2.1.0-1) unstable; urgency=medium
* New upstream version
- refresh patch ocaml-path
- drop patch opam, issue is resolved by upstream
* debian/gbp.conf: drop field cleaner
* debhelper compat level 10
* Standards-Version 4.1.1 (no change)
-- Ralf Treinen <treinen@debian.org> Wed, 22 Nov 2017 21:24:45 +0100
tuareg-mode (1:2.0.10-1) unstable; urgency=medium
* new upstream release.
* emacsen-startup: autoload tuareg-run-ocaml. Thanks to Sameer Bagwhat
for the patch (closes: #522058)
* patch opam: set tuareg-interactive-program to opam only when opam is
installed, and the user has an .opam directory (closes: #788456)
* emacsen-startup: activate SMIE, since issues seem to be fixed.
* d/rules: install all tuareg*.el files
* standards-version 3.9.8 (no change)
* d/control: dropped depricated XS-Testsuite
* d/control: updated Vcs-Git and Vcs-Browser
* d/control: capitalisation in short description
* d/control: updated Homepage
-- Ralf Treinen <treinen@debian.org> Sun, 17 Jul 2016 21:15:00 +0200
tuareg-mode (1:2.0.9-2) unstable; urgency=low
* debian/control: fix url in Vcs fields.
-- Ralf Treinen <treinen@debian.org> Tue, 05 May 2015 18:20:03 +0200
tuareg-mode (1:2.0.9-1) experimental; urgency=medium
* New upstream release. This release fixes a bad interaction with
......
......@@ -6,19 +6,18 @@ Uploaders:
Ralf Treinen <treinen@debian.org>,
Samuel Mimram <smimram@debian.org>,
Stéphane Glondu <glondu@debian.org>
Build-Depends: debhelper (>= 7.0.50~)
Standards-Version: 3.9.6
Vcs-Git: git://git.debian.org/git/pkg-ocaml-maint/packages/tuareg-mode.git
Vcs-Browser: http://git.debian.org/?p=pkg-ocaml-maint/packages/tuareg-mode.git
Homepage: http://tuareg.forge.ocamlcore.org/
XS-Testsuite: autopkgtest
Build-Depends: debhelper (>= 11)
Standards-Version: 4.2.0
Vcs-Browser: https://salsa.debian.org/ocaml-team/tuareg-mode
Vcs-Git: https://salsa.debian.org/ocaml-team/tuareg-mode.git
Homepage: https://github.com/ocaml/tuareg
Package: tuareg-mode
Architecture: all
Depends: emacs | emacsen, ${misc:Depends}, emacsen-common (>= 2.0.8)
Recommends: ocaml-interp, ocaml-mode
Enhances: ocaml-interp
Description: emacs-mode for ocaml programs
Description: emacs-mode for OCaml programs
It handles automatic indentation of Objective Caml and Caml-Light
code. Key parts of the code are highlighted using Font-Lock. It
provides support to run an interactive OCaml toplevel and debugger.
......
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: tuareg
Upstream-Contact: tuareg@janestreet.com
Source: https://forge.ocamlcore.org/projects/tuareg/
......
(add-to-list 'auto-mode-alist '("\\.ml[iylp]?\\'" . tuareg-mode))
(autoload 'tuareg-mode "tuareg" "Major mode for editing Caml code" t)
(autoload 'camldebug "ocamldebug-tuareg" "Run the Caml debugger" t)
(autoload 'tuareg-run-ocaml "tuareg"
"Run an OCaml toplevel process. I/O via buffer `*ocaml-toplevel*'."
t)
(defalias 'run-ocaml 'tuareg-run-ocaml)
(dolist (ext '(".cmo" ".cmx" ".cma" ".cmxa" ".cmi"))
(add-to-list 'completion-ignored-extensions ext))
(debian-pkg-add-load-path-item
(concat "/usr/share/"
(symbol-name debian-emacs-flavor)
"/site-lisp/tuareg-mode"))
;; SMIE turned off due to upstream bug #1167
(setq tuareg-use-smie nil)
[DEFAULT]
pristine-tar = True
cleaner = debuild clean && dh_quilt_unpatch && dh_clean
......@@ -3,9 +3,9 @@ Description: fix path of ocaml libraries to conform with debian
Index: tuareg-mode/tuareg.el
===================================================================
--- tuareg-mode.orig/tuareg.el 2012-05-28 21:24:46.000000000 +0200
+++ tuareg-mode/tuareg.el 2012-05-28 21:25:46.000000000 +0200
@@ -441,7 +441,7 @@
--- tuareg-mode.orig/tuareg.el 2017-11-22 21:10:18.131827060 +0100
+++ tuareg-mode/tuareg.el 2017-11-22 21:10:18.127827042 +0100
@@ -312,7 +312,7 @@
Valid names are `browse-url', `browse-url-firefox', etc."
:group 'tuareg)
......
......@@ -10,7 +10,7 @@ export TUAREGELDIR=debian/tuareg-mode/usr/share/emacs/site-lisp/tuareg-mode
override_dh_auto_install:
mkdir -p $(TUAREGELDIR)
cp tuareg.el tuareg_indent.el tuareg-light.el $(TUAREGELDIR)
cp tuareg*.el $(TUAREGELDIR)
cp ocamldebug.el $(TUAREGELDIR)/ocamldebug-tuareg.el
override_dh_installemacsen:
......
Tests: upstream
Depends: @
Depends: @, emacs
Restrictions: allow-stderr
\ No newline at end of file
......@@ -12,7 +12,7 @@ mkdir -p ${outdir}
outfile=${outdir}/sample.ml.out
${emacs} --batch -q --no-site-file \
--load tuareg.elc ${infile} \
--load tuareg.el ${infile} \
--eval '(setq indent-tabs-mode nil)' \
--eval '(defun ask-user-about-lock (file opponent) nil)' \
--eval '(indent-region (point-min) (point-max) nil)' \
......
(require 'tuareg)
;; See README
(setq tuareg-indent-align-with-first-arg nil)
(add-hook
'tuareg-mode-hook
(lambda()
(setq show-trailing-whitespace t)
(setq indicate-empty-lines t)
;; Enable the representation of some keywords using fonts
(when (functionp 'prettify-symbols-mode)
(prettify-symbols-mode))
(when (functionp 'flyspell-prog-mode)
(flyspell-prog-mode))
;; See README
;;(setq tuareg-match-patterns-aligned t)
;;(electric-indent-mode 0)
))
;; Easy keys to navigate errors after compilation:
(define-key tuareg-mode-map [(f12)] 'next-error)
(define-key tuareg-mode-map [(shift f12)] 'previous-error)
;; Use Merlin if available
(when (require 'merlin nil t)
(setq merlin-command 'opam)
(add-to-list 'auto-mode-alist '("/\\.merlin\\'" . conf-mode))
(when (functionp 'merlin-document)
(define-key tuareg-mode-map (kbd "\C-c\C-h") 'merlin-document))
;; Run Merlin if a .merlin file in the parent dirs is detected
(add-hook 'tuareg-mode-hook
(lambda()
(let ((fn (buffer-file-name)))
(if (and fn (locate-dominating-file fn ".merlin"))
(merlin-mode))))))
;; Choose modes for related config. files
(setq auto-mode-alist
(append '(("_oasis\\'" . conf-mode)
("_tags\\'" . conf-mode)
("_log\\'" . conf-mode))
auto-mode-alist))
This diff is collapsed.
......@@ -80,7 +80,7 @@
(unless (face-differs-from-default-p 'ocamldebug-event)
(invert-face 'ocamldebug-event))
(unless (face-differs-from-default-p 'ocamldebug-underline)
(set-face-underline-p 'ocamldebug-underline t))
(set-face-underline 'ocamldebug-underline t))
(setq ocamldebug-overlay-event (make-overlay 1 1))
(overlay-put ocamldebug-overlay-event 'face 'ocamldebug-event)
(setq ocamldebug-overlay-under (make-overlay 1 1))
......@@ -91,8 +91,14 @@
;;; OCamldebug mode.
(defvar ocamldebug-prefix-map (make-sparse-keymap)
"Keymap bound to prefix keys in `ocamldebug-mode' and `tuareg-mode'.")
(define-key tuareg-mode-map "\C-x\C-a" ocamldebug-prefix-map)
(defvar ocamldebug-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-c" ocamldebug-prefix-map)
(define-key map "\C-l" 'ocamldebug-refresh)
;; This is already the default anyway!
;;(define-key map "\t" 'comint-dynamic-complete)
......@@ -127,17 +133,19 @@ Additionally we have:
\\[ocamldebug-display-frame] display frames file in other window
\\[ocamldebug-step] advance one line in program
C-x SPACE sets break point at current line."
(set (make-local-variable 'ocamldebug-last-frame) nil)
(set (make-local-variable 'ocamldebug-delete-prompt-marker) (make-marker))
(set (make-local-variable 'ocamldebug-filter-accumulator) "")
(set (make-local-variable 'ocamldebug-filter-function)
#'ocamldebug-marker-filter)
(set (make-local-variable 'comint-prompt-regexp) ocamldebug-prompt-pattern)
(set (make-local-variable 'comint-dynamic-complete-functions)
(cons #'ocamldebug-complete comint-dynamic-complete-functions))
(set (make-local-variable 'paragraph-start) comint-prompt-regexp)
(set (make-local-variable 'ocamldebug-last-frame-displayed-p) t)
(set (make-local-variable 'shell-dirtrackp) t)
(setq-local ocamldebug-last-frame nil)
(setq-local ocamldebug-delete-prompt-marker (make-marker))
(setq-local ocamldebug-filter-accumulator "")
(setq-local ocamldebug-filter-function #'ocamldebug-marker-filter)
(setq-local comint-prompt-regexp ocamldebug-prompt-pattern)
(setq-local comint-dynamic-complete-functions
(cons (if (boundp 'completion-at-point-functions)
#'ocamldebug-capf #'ocamldebug-complete)
comint-dynamic-complete-functions))
(setq-local comint-prompt-read-only t)
(setq-local paragraph-start comint-prompt-regexp)
(setq-local ocamldebug-last-frame-displayed-p t)
(setq-local shell-dirtrackp t)
(add-hook 'comint-input-filter-functions 'shell-directory-tracker nil t))
;;; Keymaps.
......@@ -176,8 +184,7 @@ representation is simply concatenated with the COMMAND."
(interactive "P")
(ocamldebug-call ,name ,args
(ocamldebug-numeric-arg arg))))
(define-key ocamldebug-mode-map ,(concat "\C-c" key) ',fun)
(define-key tuareg-mode-map ,(concat "\C-x\C-a" key) ',fun))))
(define-key ocamldebug-prefix-map ,key ',fun))))
(def-ocamldebug "step" "\C-s" "Step one source line with display.")
(def-ocamldebug "run" "\C-r" "Run the program.")
......@@ -221,7 +228,7 @@ representation is simply concatenated with the COMMAND."
(let ((ocamldebug-kill-output))
(with-current-buffer ocamldebug-current-buffer
(let ((proc (get-buffer-process (current-buffer)))
(ocamldebug-filter-function 'ocamldebug-kill-filter))
(ocamldebug-filter-function #'ocamldebug-kill-filter))
(ocamldebug-call "kill")
(while (not (and ocamldebug-kill-output
(zerop (length ocamldebug-filter-accumulator))))
......@@ -301,7 +308,7 @@ buffer, then try to obtain the time from context around point."
;get a list of all events in the current module
(with-current-buffer ocamldebug-current-buffer
(let* ((proc (get-buffer-process (current-buffer)))
(ocamldebug-filter-function 'ocamldebug-goto-filter))
(ocamldebug-filter-function #'ocamldebug-goto-filter))
(ocamldebug-call-1 (concat "info events " module))
(while (not (and ocamldebug-goto-output
(zerop (length ocamldebug-filter-accumulator))))
......@@ -311,7 +318,8 @@ buffer, then try to obtain the time from context around point."
(concat "^Time : \\([0-9]+\\) - pc : "
ocamldebug-goto-output
" - module "
module "$") nil t)
module "$")
nil t)
(match-string 1)))))
(if address (ocamldebug-call "goto" nil (string-to-number address))
(error "No time at %s at %s" module ocamldebug-goto-position))))))
......@@ -382,7 +390,7 @@ around point."
(ocamldebug-delete-position (ocamldebug-format-command "%c")))
(with-current-buffer ocamldebug-current-buffer
(let ((proc (get-buffer-process (current-buffer)))
(ocamldebug-filter-function 'ocamldebug-delete-filter)
(ocamldebug-filter-function #'ocamldebug-delete-filter)
(ocamldebug-delete-output))
(ocamldebug-call-1 "info break")
(while (not (and ocamldebug-delete-output
......@@ -418,72 +426,99 @@ around point."
"")
(defun ocamldebug-complete ()
"Perform completion on the ocamldebug command preceding point."
(interactive)
(let* ((capf-data (ocamldebug-capf))
(command-word (buffer-substring (nth 0 capf-data) (nth 1 capf-data))))
(completion-in-region (nth 0 capf-data) (nth 1 capf-data)
(sort (all-completions command-word (nth 2 capf-data))
#'string-lessp))))
(when (fboundp 'completion-at-point)
(make-obsolete 'ocamldebug-complete 'completion-at-point "24.1"))
(defun ocamldebug-capf ()
;; FIXME: Use an `end' after point when applicable.
(let* ((end (point))
(command (save-excursion
(cmd-start (save-excursion
(beginning-of-line)
(and (looking-at comint-prompt-regexp)
(goto-char (match-end 0)))
(buffer-substring (point) end)))
(ocamldebug-complete-list nil) (command-word))
;; Find the word break. This match will always succeed.
(string-match "\\(\\`\\| \\)\\([^ ]*\\)\\'" command)
(setq command-word (match-string 2 command))
;itz 04-21-96 if we are trying to complete a word of nonzero
;length, chop off the last character. This is a nasty hack, but it
;works - in general, not just for this set of words: the comint
;call below will weed out false matches - and it avoids further
;mucking with ocamldebug's lexer.
(when (> (length command-word) 0)
(setq command (substring command 0 (1- (length command)))))
(let ((ocamldebug-filter-function 'ocamldebug-complete-filter))
(ocamldebug-call-1 (concat "complete " command))
(if (looking-at comint-prompt-regexp)
(match-end 0) (point))))
(start (save-excursion
(skip-chars-backward "^ \n" cmd-start)
(point))))
`(,start ,end
,(completion-table-dynamic
(apply-partially #'ocamldebug--get-completions
(buffer-substring cmd-start start))))))
(defun ocamldebug--get-completions (command-prefix str)
;; FIXME: Add some caching?
(let ((ocamldebug-complete-list nil))
;; itz 04-21-96 If we are trying to complete a word of nonzero
;; length, chop off the last character. This is a nasty hack, but it
;; works - in general, not just for this set of words: the completion
;; code will weed out false matches - and it avoids further
;; mucking with ocamldebug's lexer.
;; FIXME: Which problem is this trying to fix/avoid/circumvent?
(when (> (length str) 0)
(setq str (substring str 0 (1- (length str)))))
(let ((ocamldebug-filter-function #'ocamldebug-complete-filter))
(ocamldebug-call-1 (concat "complete " command-prefix str))
(set-marker ocamldebug-delete-prompt-marker nil)
(while (not (and ocamldebug-complete-list
(zerop (length ocamldebug-filter-accumulator))))
(accept-process-output (get-buffer-process
(current-buffer)))))
(when (eq ocamldebug-complete-list 'fail)
(setq ocamldebug-complete-list nil))
(setq ocamldebug-complete-list
(sort ocamldebug-complete-list 'string-lessp))
(comint-dynamic-simple-complete command-word ocamldebug-complete-list)))
(if (eq ocamldebug-complete-list 'fail)
nil
ocamldebug-complete-list)))
(define-key tuareg-mode-map "\C-x " 'ocamldebug-break)
(defvar ocamldebug-command-name "ocamldebug"
"Pathname for executing the OCaml debugger.")
(defvar ocamldebug-debuggee-args ""
"Default arguments to the program being debugged (space
separated and possibly quoted as they would be passed on the
command line).")
;;;###autoload
(defun ocamldebug (path)
(defun ocamldebug (pgm-path)
"Run ocamldebug on program FILE in buffer *ocamldebug-FILE*.
The directory containing FILE becomes the initial working directory
and source-file directory for ocamldebug. If you wish to change this, use
the ocamldebug commands `cd DIR' and `directory'."
(interactive "fRun ocamldebug on file: ")
(setq path (expand-file-name path))
(let ((file (file-name-nondirectory path)))
(pop-to-buffer (concat "*ocamldebug-" file "*"))
(setq default-directory (file-name-directory path))
(message "Current directory is %s" default-directory)
(setq pgm-path (expand-file-name pgm-path))
(let* ((file (file-name-nondirectory pgm-path))
(name (concat "ocamldebug-" file))
(buffer-name (concat "*" name "*")))
(pop-to-buffer buffer-name)
(unless (comint-check-proc buffer-name)
(setq default-directory (file-name-directory pgm-path))
(setq ocamldebug-debuggee-args
(read-from-minibuffer (format "Args for %s: " file)
ocamldebug-debuggee-args))
(setq ocamldebug-command-name
(read-from-minibuffer "OCaml debugguer to run: "
(read-from-minibuffer "OCaml debugger to run: "
ocamldebug-command-name))
(make-comint (concat "ocamldebug-" file)
(substitute-in-file-name ocamldebug-command-name)
(message "Current directory is %s" default-directory)
(let* ((args (tuareg--split-args ocamldebug-debuggee-args))
(cmdlist (tuareg--split-args ocamldebug-command-name))
(cmdlist (mapcar #'substitute-in-file-name cmdlist)))
(apply #'make-comint name
(car cmdlist)
nil
"-emacs" "-cd" default-directory path)
"-emacs" "-cd" default-directory
(append (cdr cmdlist) (cons pgm-path args)))
(set-process-filter (get-buffer-process (current-buffer))
'ocamldebug-filter)
(set-process-sentinel (get-buffer-process (current-buffer))
'ocamldebug-sentinel)
(ocamldebug-mode)
(ocamldebug-mode)))
(ocamldebug-set-buffer)))
;;;###autoload
......@@ -643,8 +678,12 @@ Obeying it means displaying in another window the specified file and line."
(with-current-buffer buffer
(save-restriction
(widen)
(setq spos (+ (point-min) schar))
(setq epos (+ (point-min) echar))
(setq spos (if (fboundp 'filepos-to-bufferpos)
(filepos-to-bufferpos schar 'approximate)
(+ (point-min) schar)))
(setq epos (if (fboundp 'filepos-to-bufferpos)
(filepos-to-bufferpos echar 'approximate)
(+ (point-min) echar)))
(setq pos (if kind spos epos))
(ocamldebug-set-current-event spos epos pos (current-buffer) kind))
(cond ((or (< pos (point-min)) (> pos (point-max)))
......@@ -747,10 +786,11 @@ representation is simply concatenated with the COMMAND."
(defun ocamldebug-call-1 (command &optional fmt arg)
;; Record info on the last prompt in the buffer and its position.
(with-current-buffer ocamldebug-current-buffer
(save-excursion
(goto-char (process-mark (get-buffer-process ocamldebug-current-buffer)))
(beginning-of-line)
(when (looking-at comint-prompt-regexp)
(set-marker ocamldebug-delete-prompt-marker (point))))
(set-marker ocamldebug-delete-prompt-marker (point)))))
(let ((cmd (cond
(arg (concat command " " (int-to-string arg)))
(fmt (ocamldebug-format-command
......