[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] externals/caml d213e6d 076/197: integration de caml-types a cam
From: |
Stefan Monnier |
Subject: |
[nongnu] externals/caml d213e6d 076/197: integration de caml-types a caml.el |
Date: |
Sat, 21 Nov 2020 01:19:41 -0500 (EST) |
branch: externals/caml
commit d213e6d4168dc5c18f7e2156dad9a13ad9b9b476
Author: Damien Doligez <damien.doligez-inria.fr>
Commit: Damien Doligez <damien.doligez-inria.fr>
integration de caml-types a caml.el
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5725
f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
---
Makefile | 3 ++-
caml-types.el | 87 +++++++++++++++++++++++++++--------------------------------
caml.el | 2 ++
3 files changed, 43 insertions(+), 49 deletions(-)
diff --git a/Makefile b/Makefile
index ab0dbd2..7a1b70b 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ include ../config/Makefile
# Files to install
FILES= caml-font.el caml-hilit.el caml.el camldebug.el \
- inf-caml.el caml-compat.el caml-help.el
+ inf-caml.el caml-compat.el caml-help.el caml-types.el
# Where to install. If empty, automatically determined.
#EMACSDIR=
@@ -21,6 +21,7 @@ COMPILECMD=(progn \
(byte-compile-file "caml.el") \
(byte-compile-file "inf-caml.el") \
(byte-compile-file "caml-help.el") \
+ (byte-compile-file "caml-types.el") \
(byte-compile-file "camldebug.el"))
install:
diff --git a/caml-types.el b/caml-types.el
index 386e5ba..277d8e6 100644
--- a/caml-types.el
+++ b/caml-types.el
@@ -12,39 +12,8 @@
;(* $Id$ *)
-; WARNING:
-; This code is experimental. Everything may change at any time.
; An emacs-lisp complement to the "-dtypes" option of ocamlc and ocamlopt.
-; Load this file in your emacs, then C-c C-t will show you the
-; type of the expression (or pattern) that contains the cursor.
-; The expression is highlighted in the current buffer.
-; The type is highlighted in "foo.annot" (if your file is "foo.ml"),
-; which is convenient when the type doesn't fit on a line.
-
-
-; Hints on using the type display:
-
-; . If you want the type of an identifier, put the cursor in any
-; occurrence of this identifier (as expression or as pattern) and
-; type C-c C-t
-; . If you want the result type of a function application, put the
-; cursor at the first space after the function name
-; . If you want the type of a list, put the cursor on a bracket,
-; or on a semicolon, or on the :: constructor
-; . Even if type checking fails, you can still look at the types
-; in the file, up to where the type checker failed.
-; . To get rid of the highlighting, put the cursor in a comment
-; and type C-c C-t.
-; . The mark in the foo.annot file is set to the beginning of the
-; type, so you can type C-x C-x in that file to view the type.
-
-
-
-; TO DO:
-; - make emacs scroll the foo.annot file to show the type
-; - (?) integrate this file into caml.el
-
; Format of the *.annot files:
@@ -73,9 +42,6 @@
; For the moment, the only possible keyword is "type".
-; (global-set-key "\C-c\C-t" 'caml-types-show-type)
-
-
(let* ((caml-types-filename-re "\"\\(\\([^\\\"]\\|\\\\.\\)*\\)\"")
(caml-types-number-re "\\([0-9]*\\)")
(caml-types-position-re
@@ -92,8 +58,21 @@
(overlay-put caml-types-type-ovl 'face 'region)
(defun caml-types-show-type ()
- "Highlight the smallest expression that contains the cursor,
- and display its type in the minibuffer."
+ "Show the type of expression or pattern at point.
+ The smallest expression or pattern that contains point is
+ temporarily highlighted. Its type is highlighted in the .annot
+ file and the mark is set to the beginning of the type.
+ The type is also displayed in the mini-buffer.
+
+ Hints on using the type display:
+ . If you want the type of an identifier, put point within any
+ occurrence of this identifier.
+ . If you want the result type of a function application, put point
+ at the first space after the function name.
+ . If you want the type of a list, put point on a bracket, on a
+ semicolon, or on the :: constructor.
+ . Even if type checking fails, you can still look at the types
+ in the file, up to where the type checker failed."
(interactive)
(let* ((target-buf (current-buffer))
(target-file (file-name-nondirectory (buffer-file-name)))
@@ -114,9 +93,9 @@
target-bol target-cnum)))
(if (null loc)
(progn
- (move-overlay caml-types-expr-ovl 1 1)
- (move-overlay caml-types-type-ovl 1 1)
- (message "The cursor is not within a typechecked expression or
pattern."))
+ (delete-overlay caml-types-expr-ovl)
+ (delete-overlay caml-types-type-ovl)
+ (message "Point is not within a typechecked expression or
pattern."))
(let ((left (caml-types-get-pos target-buf (nth 0 loc) (nth 1
loc)))
(right (caml-types-get-pos target-buf
(nth 2 loc) (nth 3 loc))))
@@ -127,24 +106,18 @@
(move-overlay caml-types-type-ovl (match-beginning 1) (match-end 1)
type-buf)
(message (format "type: %s" (match-string 1)))
- ; *** this doesn't seem to work, I
don't know why...
- ; *** (goto-char type-point)
- ; *** workaround: set the mark instead
- (set-mark (match-beginning 1))
- )))
+ (set-mark (match-beginning 1)))))
(let
((window (get-buffer-window type-buf))
(this-window (selected-window)))
-
(if window
(progn
(select-window window)
(goto-char (mark))
(select-window this-window))))
(unwind-protect
- (sit-for 3)
- (delete-overlay caml-types-expr-ovl))
- )))
+ (sit-for 60)
+ (delete-overlay caml-types-expr-ovl)))))
(defun caml-types-date< (date1 date2)
(or (< (car date1) (car date2))
@@ -207,3 +180,21 @@
(set-buffer buf)
(toggle-read-only 1))
buf)))
+
+
+;; bindings
+
+(and
+ (boundp 'caml-mode-map)
+ (keymapp caml-mode-map)
+ (progn
+ (define-key caml-mode-map [?\C-c?\C-t] 'caml-types-show-type)
+ (let ((map (lookup-key caml-mode-map [menu-bar caml])))
+ (and
+ (keymapp map)
+ (progn
+ (define-key map [separator-types] '("---"))
+ (define-key map [show-type]
+ '("Show type at point" . caml-types-show-type )))))))
+
+(provide 'caml-types)
diff --git a/caml.el b/caml.el
index 09df480..752db2d 100644
--- a/caml.el
+++ b/caml.el
@@ -1835,6 +1835,8 @@ with prefix arg, indent that many phrases starting with
the current phrase."
(autoload 'run-caml "inf-caml" "Run an inferior Caml process." t)
+(load "caml-types")
+
;;; caml.el ends here
(provide 'caml)
- [nongnu] externals/caml a94bd19 083/197: hash-table des annotations, (continued)
- [nongnu] externals/caml a94bd19 083/197: hash-table des annotations, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml d7bde19 088/197: Modified `caml-types-explore' so that all well-typed subexpressions of the, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 570c595 089/197: installer caml-emacs.el, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml ab2d4cc 107/197: fusion des modifs de 3.08.4, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 347ceba 108/197: PR#3767 features 1 and 2: display full location of events instead of one position, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 4238e85 110/197: fusion des changements 3.09.3 -> release309_merge310, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 074d219 106/197: fusion des changements jusqu'a 3.08.3, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 8fc9a47 117/197: amelioration des annotations, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml bcceb79 122/197: fixes bug 0005016, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 55b8c79 124/197: fixes bug 0004997, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml d213e6d 076/197: integration de caml-types a caml.el,
Stefan Monnier <=
- [nongnu] externals/caml d287472 095/197: petits bugs, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml eddf5e0 099/197: camldebug-command-name should be user-settable, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 901e8dd 103/197: Fusion des modifs de la branche release308 entre 3.08.0 et 3.08.1, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml afff6d2 040/197: Adding file caml-help.el, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml b060e59 041/197: indentation autour de "; ; ", Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 4759555 044/197: Amelioration de caml-help, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 05d89fc 061/197: added menu entries for caml-help and caml-complete, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml bf460c2 062/197: interactions bizarres de with, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml f45af82 063/197: - Fixed bugs + improved caml-help.el, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 5e6f8b6 071/197: value obsolete, Stefan Monnier, 2020/11/21