[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] externals/caml c0b7050 163/197: caml-types.el: Cosmetic changes
From: |
Stefan Monnier |
Subject: |
[nongnu] externals/caml c0b7050 163/197: caml-types.el: Cosmetic changes. |
Date: |
Sat, 21 Nov 2020 01:19:59 -0500 (EST) |
branch: externals/caml
commit c0b705055e2be527e29dac77c347c6241fe196cb
Author: nathan moreau <nathan.moreau@m4x.org>
Commit: Gabriel Scherer <gabriel.scherer@gmail.com>
caml-types.el: Cosmetic changes.
---
caml-types.el | 152 +++++++++++++++++++++++-----------------------------------
1 file changed, 61 insertions(+), 91 deletions(-)
diff --git a/caml-types.el b/caml-types.el
index 7ecc5d4..47d840a 100644
--- a/caml-types.el
+++ b/caml-types.el
@@ -65,8 +65,7 @@ Their format is:
and second nums.
The current list of keywords is:
-type call ident"
-)
+type call ident")
(defvar caml-types-position-re nil)
@@ -127,33 +126,33 @@ type call ident"
(make-variable-buffer-local 'caml-types-annotation-date)
(defvar caml-types-buffer-name "*caml-types*"
- "Name of buffer for displaying caml types")
+ "Name of buffer for displaying caml types.")
(defvar caml-types-buffer nil
- "buffer for displaying caml types")
+ "Buffer for displaying caml types.")
(defun caml-types-show-type (arg)
"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.
+
+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.
Types are also displayed in the buffer *caml-types*, which is
displayed when the command is called with Prefix argument 4.
See also `caml-types-explore' for exploration by mouse dragging.
-See `caml-types-location-re' for annotation file format.
-"
+See `caml-types-location-re' for annotation file format."
(interactive "p")
(let* ((target-buf (current-buffer))
(target-file (file-name-nondirectory (buffer-file-name)))
@@ -178,28 +177,26 @@ See `caml-types-location-re' for annotation file format.
(with-current-buffer caml-types-buffer
(erase-buffer)
(insert type)
- (message (format "type: %s" type)))
- ))))
+ (message (format "type: %s" type)))))))
(if (and (= arg 4)
(not (window-live-p (get-buffer-window caml-types-buffer))))
(display-buffer caml-types-buffer))
(unwind-protect
(caml-sit-for 60)
- (delete-overlay caml-types-expr-ovl)
- )))
+ (delete-overlay caml-types-expr-ovl))))
(defun caml-types-show-call (arg)
"Show the kind of call at point.
- The smallest function call that contains point is
- temporarily highlighted. Its kind is highlighted in the .annot
- file and the mark is set to the beginning of the kind.
- The kind is also displayed in the mini-buffer.
+
+The smallest function call that contains point is temporarily
+highlighted. Its kind is highlighted in the .annot file and the
+mark is set to the beginning of the kind. The kind is also
+displayed in the mini-buffer.
The kind is also displayed in the buffer *caml-types*, which is
displayed when the command is called with Prefix argument 4.
-See `caml-types-location-re' for annotation file format.
-"
+See `caml-types-location-re' for annotation file format."
(interactive "p")
(let* ((target-buf (current-buffer))
(target-file (file-name-nondirectory (buffer-file-name)))
@@ -224,28 +221,26 @@ See `caml-types-location-re' for annotation file format.
(with-current-buffer caml-types-buffer
(erase-buffer)
(insert kind)
- (message (format "%s call" kind)))
- ))))
+ (message (format "%s call" kind)))))))
(if (and (= arg 4)
(not (window-live-p (get-buffer-window caml-types-buffer))))
(display-buffer caml-types-buffer))
(unwind-protect
(caml-sit-for 60)
- (delete-overlay caml-types-expr-ovl)
- )))
+ (delete-overlay caml-types-expr-ovl))))
(defun caml-types-show-ident (arg)
"Show the binding of identifier at point.
- The identifier that contains point is
- temporarily highlighted. Its binding is highlighted in the .annot
- file and the mark is set to the beginning of the binding.
- The binding is also displayed in the mini-buffer.
+
+The identifier that contains point is temporarily highlighted.
+Its binding is highlighted in the .annot file and the mark is set
+to the beginning of the binding. The binding is also displayed
+in the mini-buffer.
The binding is also displayed in the buffer *caml-types*, which is
displayed when the command is called with Prefix argument 4.
-See `caml-types-location-re' for annotation file format.
-"
+See `caml-types-location-re' for annotation file format."
(interactive "p")
(let* ((target-buf (current-buffer))
(target-file (file-name-nondirectory (buffer-file-name)))
@@ -324,8 +319,7 @@ See `caml-types-location-re' for annotation file format.
(with-current-buffer caml-types-buffer
(erase-buffer)
(insert fullname)
- (message (format "external ident: %s" fullname)))))))
- ))))
+ (message (format "external ident: %s" fullname)))))))))))
(if (and (= arg 4)
(not (window-live-p (get-buffer-window caml-types-buffer))))
(display-buffer caml-types-buffer))
@@ -333,8 +327,7 @@ See `caml-types-location-re' for annotation file format.
(caml-sit-for 60)
(delete-overlay caml-types-expr-ovl)
(delete-overlay caml-types-def-ovl)
- (delete-overlay caml-types-scope-ovl)
- )))
+ (delete-overlay caml-types-scope-ovl))))
(defun caml-types-preprocess (target-path)
(let* ((type-path (caml-types-locate-type-file target-path))
@@ -357,14 +350,13 @@ See `caml-types-location-re' for annotation file format.
(setq caml-types-annotation-tree tree
caml-types-annotation-date type-date)
(kill-buffer type-buf)
- (message "done"))
- )))
+ (message "done")))))
(defun caml-types-parent-dir (d) (file-name-directory (directory-file-name d)))
(defun caml-types-locate-type-file (target-path)
- "Given the path to an OCaml file, this function tries to locate
-and return the corresponding .annot file."
+ "Given the path to an OCaml file, try to locate and return the
+corresponding .annot file."
(let ((sibling (concat (file-name-sans-extension target-path) ".annot")))
(if (file-exists-p sibling)
sibling
@@ -414,8 +406,7 @@ and return the corresponding .annot file."
(if (re-search-forward "^[a-z\"]" () t)
(forward-char -1)
(goto-char (point-max)))
- (looking-at "[a-z]")
-)
+ (looking-at "[a-z]"))
; tree of intervals
; each node is a vector
@@ -456,7 +447,7 @@ and return the corresponding .annot file."
accu)))
(setq stack (cons node stack))))))
(if (null stack)
- (error "no annotations found for this source file")
+ (error "No annotations found for this source file")
(let* ((left-pos (elt (car (last stack)) 0))
(right-pos (elt (car stack) 1)))
(if (null (cdr stack))
@@ -594,15 +585,12 @@ and return the corresponding .annot file."
(unless (verify-visited-file-modtime buf)
(if (buffer-modified-p buf)
(find-file-noselect name)
- (with-current-buffer buf (revert-buffer t t)))
- ))
+ (with-current-buffer buf (revert-buffer t t)))))
((and (file-readable-p name)
(setq buf (find-file-noselect name)))
- (with-current-buffer buf (toggle-read-only 1))
- )
+ (with-current-buffer buf (toggle-read-only 1)))
(t
- (error (format "Can't read the annotation file `%s'" name)))
- )
+ (error (format "Can't read the annotation file `%s'" name))))
buf))
(defun caml-types-mouse-ignore (event)
@@ -624,8 +612,7 @@ The function uses two overlays.
. One overlay delimits the largest region whose all subnodes
are well-typed.
. Another overlay delimits the current node under the mouse (whose type
- annotation is being displayed).
-"
+ annotation is being displayed)."
(interactive "e")
(set-buffer (window-buffer (caml-event-window event)))
(let* ((target-buf (current-buffer))
@@ -638,8 +625,7 @@ The function uses two overlays.
target-tree
(speed 100)
(last-time (caml-types-time))
- (original-event event)
- )
+ (original-event event))
(select-window window)
(unwind-protect
(progn
@@ -665,15 +651,13 @@ The function uses two overlays.
(top (nth 1 win))
(bottom (- (nth 3 win) 1))
mouse
- time
- )
+ time)
(while (and
(caml-sit-for 0 (/ 500 speed))
(setq time (caml-types-time))
(> (- time last-time) (/ 500 speed))
(setq mouse (caml-mouse-vertical-position))
- (or (< mouse top) (>= mouse bottom))
- )
+ (or (< mouse top) (>= mouse bottom)))
(setq last-time time)
(cond
((< mouse top)
@@ -685,10 +669,8 @@ The function uses two overlays.
(setq speed (+ 1 (- mouse bottom)))
(condition-case nil
(scroll-up 1)
- (error (message "End of buffer!"))))
- )
- (setq speed (* speed speed))
- )))
+ (error (message "End of buffer!")))))
+ (setq speed (* speed speed)))))
;; main action, when the motion is inside the window
;; or on orginal button down event
((or (caml-mouse-movement-p event)
@@ -737,23 +719,15 @@ The function uses two overlays.
(setq limits
(caml-types-find-interval target-buf
target-pos node)
- type (cdr (assoc "type" (elt node 2))))
- ))
- )
+ type (cdr (assoc "type" (elt node 2)))))))
(setq mes (format "type: %s" type))
- (insert type)
- ))
- (message mes)
- )
- )
+ (insert type)))
+ (message mes)))
;; we read next event, unless it is nil, and loop back.
- (if event (setq event (caml-read-event)))
- )
- )
+ (if event (setq event (caml-read-event)))))
;; delete overlays at end of exploration
(delete-overlay caml-types-expr-ovl)
- (delete-overlay caml-types-typed-ovl)
- ))
+ (delete-overlay caml-types-typed-ovl)))
;; When an error occurs, the mouse release event has not been read.
;; We could wait for mouse release to prevent execution of
;; a binding of mouse release, such as cut or paste.
@@ -763,8 +737,7 @@ The function uses two overlays.
;; Not sure it is robust to loop for mouse release after an error
;; occured, as is done for exploration.
;; So far, we just ignore next event. (Next line also be uncommenting.)
- (if event (caml-read-event))
- )))
+ (if event (caml-read-event)))))
(defun caml-types-typed-make-overlay (target-buf pos)
(interactive "p")
@@ -776,20 +749,17 @@ The function uses two overlays.
(if (and (equal target-buf (current-buffer))
(setq left (caml-types-get-pos target-buf (elt node 0))
right (caml-types-get-pos target-buf (elt node 1)))
- (<= left pos) (> right pos)
- )
+ (<= left pos) (> right pos))
(setq start (min start left)
- end (max end right))
- ))
+ end (max end right))))
(move-overlay caml-types-typed-ovl
(max (point-min) (- start 1))
(min (point-max) (+ end 1)) target-buf)
(cons start end)))
(defun caml-types-version ()
- "internal version number of caml-types.el"
+ "Internal version number of caml-types.el."
(interactive)
- (message "4")
-)
+ (message "4"))
(provide 'caml-types)
- [nongnu] externals/caml f6cd0b9 078/197: petit nettoyage, (continued)
- [nongnu] externals/caml f6cd0b9 078/197: petit nettoyage, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 474e6ee 102/197: only set type faces where needed, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml b1eaaab 115/197: merge changes 3.10.0 -> 3.10.1, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 43a83dc 118/197: bug string-to-number, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml c525bf8 121/197: clean up spaces and tabs, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 73599dd 129/197: uniform .ignore system, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml eec3351 144/197: do byte-compile file caml-font.el, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml b1139bc 146/197: merge version/4.00 at revision 12866, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml b5bf207 160/197: update caml-font.el to deal with the quoted string syntax, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml d3bc724 167/197: caml.el: Pass the `system` flag when defining abbrevs, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml c0b7050 163/197: caml-types.el: Cosmetic changes.,
Stefan Monnier <=
- [nongnu] externals/caml f9a4fd4 177/197: makefiles: turn the 'install' command into a variable, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 2bc0b92 178/197: factorize common makefile definitions in Makefile.common, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 78b3169 182/197: Move config/Makefile to Makefile.config, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 9288416 183/197: Introduce and use ROOTDIR in more makefiles, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 1756296 140/197: PR#5137: caml-types-explore does not work, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 02303ea 147/197: PR#5727: emacs caml-mode indents shebang line in toplevel scripts, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 2c3dbdb 157/197: merge branch 4.02 from 4.02.1 (rev 15540) to a few fixes after 4.02.2 (rev 16205), Stefan Monnier, 2020/11/21
- [nongnu] externals/caml ed94de1 159/197: simplify .gitignore; remove .ignore files and tools/setignore; adjust tools/check-typo, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 66c8274 050/197: run caml directly, Stefan Monnier, 2020/11/21
- [nongnu] externals/caml 6b7bd5d 073/197: changement .types -> .annot + format, Stefan Monnier, 2020/11/21