[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] externals/caml ac2a0b2 064/197: ajout option -stypes; depend
From: |
Stefan Monnier |
Subject: |
[nongnu] externals/caml ac2a0b2 064/197: ajout option -stypes; depend |
Date: |
Sat, 21 Nov 2020 01:19:39 -0500 (EST) |
branch: externals/caml
commit ac2a0b274d353b6ef8ef6ce0d6b385faa262daab
Author: Damien Doligez <damien.doligez-inria.fr>
Commit: Damien Doligez <damien.doligez-inria.fr>
ajout option -stypes; depend
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5478
f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
---
caml-types.el | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 89 insertions(+)
diff --git a/caml-types.el b/caml-types.el
new file mode 100644
index 0000000..7841ba5
--- /dev/null
+++ b/caml-types.el
@@ -0,0 +1,89 @@
+;(***********************************************************************)
+;(* *)
+;(* Objective Caml *)
+;(* *)
+;(* Damien Doligez, projet Moscova, INRIA Rocquencourt *)
+;(* *)
+;(* Copyright 2003 Institut National de Recherche en Informatique et *)
+;(* en Automatique. All rights reserved. This file is distributed *)
+;(* under the terms of the Q Public License version 1.0. *)
+;(* *)
+;(***********************************************************************)
+
+;(* $Id$ *)
+
+; WARNING:
+; This code is experimental. Everything may change at any time.
+
+; An emacs-lisp complement to the "-stypes" option of ocamlc and ocamlopt.
+; Load this file in your emacs, then C-c C-t will show you the
+; type of the expression that contains the cursor.
+; The expression is highlighted in the current buffer.
+; The type is highlighted in "foo.types" (if your file is "foo.ml"),
+; which is convenient if the type doesn't fit on a line.
+; (doesn't work very well).
+
+; TO DO:
+; - make emacs scroll the .types file when we move the point there,
+; even if the file is already displayed
+; - emit a warning when the .ml file is more recent than the .types
+; - make the command work only in caml-mode
+; - integrate this file into caml.el (?)
+; - write a proper documentation string for caml-types-show-type
+
+(setq caml-types-filename-re "\"\\([^\\\"]\\|\\\\.\\)*\"")
+(setq caml-types-number-re "\\([0-9]*\\)")
+(setq caml-types-position-re
+ (concat caml-types-filename-re " "
+ caml-types-number-re " "
+ caml-types-number-re " "
+ caml-types-number-re))
+(setq caml-types-location-re
+ (concat "^" caml-types-position-re " " caml-types-position-re))
+(setq caml-types-expr-ov (make-overlay 1 1))
+(overlay-put caml-types-expr-ov 'face 'region)
+(setq caml-types-type-ov (make-overlay 1 1))
+(overlay-put caml-types-type-ov 'face 'region)
+
+(defun caml-types-show-type ()
+ "blah"
+ (interactive)
+ (let* (type-point
+ (target (point))
+ (targetbuf (current-buffer))
+ (typefile (concat (file-name-sans-extension (buffer-file-name))
+ ".types"))
+ (tbuf (or (get-file-buffer typefile)
+ (find-file-noselect typefile))))
+ (save-excursion
+ (set-buffer tbuf)
+ (goto-char (point-min))
+ (let ((loc (caml-types-find-location target)))
+ (if (null loc)
+ (progn
+ (move-overlay caml-types-expr-ov 1 1)
+ (move-overlay caml-types-type-ov 1 1)
+ (message "The cursor is not within an expression."))
+ (move-overlay caml-types-expr-ov (car loc) (cdr loc) targetbuf)
+ (forward-line 2)
+ (re-search-forward " \\(\\([^\n)]\\|.)\\|\n[^)]\\)*\\)\n)")
+ (move-overlay caml-types-type-ov (match-beginning 1) (match-end 1)
+ (current-buffer))
+ (message (concat "type: " (match-string 1)))
+ (setq type-point (match-beginning 1)))))
+ (if (null type-point)
+ ()
+ (set-buffer tbuf)
+ (goto-char type-point)
+ (set-buffer targetbuf))))
+
+(defun caml-types-find-location (target)
+ (let (left right found)
+ (catch 'exit
+ (while (re-search-forward caml-types-location-re () t)
+ (setq left (1+ (string-to-int (match-string 4))))
+ (setq right (1+ (string-to-int (match-string 8))))
+ (if (and (<= left target) (< target right))
+ (throw 'exit (cons left right)))))))
+
+(global-set-key "\C-c\C-t" 'caml-types-show-type)
- [nongnu] externals/caml 49653b2 148/197: remove all $Id keywords, (continued)
- [nongnu] externals/caml 49653b2 148/197: remove all $Id keywords, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 9b0544f 154/197: fix whitespace and over-long lines, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml da654aa 179/197: Emacs: Modernise font face definitions, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml cd1142f 187/197: Change camlc → ocamlc, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 3fb0de6 188/197: Add octal character literals, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 6e0e050 134/197: PR#5455: .emacs instructions, add lines to recognize ocaml scripts, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 56e93b6 151/197: fix a few problems with whitespace and over-long lines, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml f4c7308 168/197: caml.el: Reduce byte-compilation warnings, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml a0d389f 058/197: skip structs in let module ... in, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 442bd24 059/197: prepare snapshot, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml ac2a0b2 064/197: ajout option -stypes; depend,
Stefan Monnier <=
- [nongnu] externals/caml faa1c81 065/197: ajout choses a faire, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 76f4e2b 116/197: amelioration des annotations, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 64cecd3 128/197: merge changes from 3.12.0 to 3.12.1, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 64a3c02 166/197: Fixing some Emacs startup warnings., Stefan Monnier, 2020/11/21
- [nongnu] externals/caml bce861f 181/197: Emacs: Use built-in detection of comments, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml ac5d007 047/197: caml-indent-phrase, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 3d7f47c 066/197: amelioration .mly .mll, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 099dbf5 067/197: -stypes -> -dtypes; meilleur mode emacs, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 1991236 046/197: improve indentation, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 5ac4447 133/197: correct syntax highlighting in emacs (continued), Stefan Monnier, 2020/11/21