@@ -54,13 +54,18 @@ For the moment, the only possible keyword is \"type\"."
54
54
caml-types-number-re " "
55
55
caml-types-number-re " "
56
56
caml-types-number-re)))
57
- (setq caml-types-location-re
58
- (concat " ^" caml-types-position-re " " caml-types-position-re)
59
- ))
57
+ (setq caml-types-location-re
58
+ (concat " ^" caml-types-position-re " " caml-types-position-re)))
59
+
60
60
(defvar caml-types-expr-ovl (make-overlay 1 1 ))
61
- (overlay-put caml-types-expr-ovl 'face 'region )
62
- (defvar caml-types-type-ovl (make-overlay 1 1 ))
63
- (overlay-put caml-types-type-ovl 'face 'region )
61
+
62
+ (make-face 'caml-types-face )
63
+ (set-face-doc-string 'caml-types-face
64
+ " face for hilighting expressions and types" )
65
+ (if (not (face-differs-from-default-p 'caml-types-face ))
66
+ (set-face-background 'caml-types-face " #88FF44" ))
67
+
68
+ (overlay-put caml-types-expr-ovl 'face 'caml-types-face )
64
69
65
70
(defun caml-types-show-type (arg )
66
71
" Show the type of expression or pattern at point.
@@ -104,36 +109,21 @@ See `caml-types-location-re' for annotation file format.
104
109
(if (null loc)
105
110
(progn
106
111
(delete-overlay caml-types-expr-ovl)
107
- (delete-overlay caml-types-type-ovl)
108
112
(message
109
113
" Point is not within a typechecked expression or pattern." )
110
- (narrow-to-region 1 1 )
111
- )
114
+ (narrow-to-region 1 1 ))
112
115
(let ((left (caml-types-get-pos target-buf (nth 0 loc) (nth 1 loc)))
113
116
(right (caml-types-get-pos target-buf
114
117
(nth 2 loc) (nth 3 loc))))
115
118
(move-overlay caml-types-expr-ovl left right target-buf))
116
119
; ; not strictly correct
117
120
(re-search-forward
118
121
" ^type(\n \\ (\\ ([^\n )]\\ |.)\\ |\n [^)]\\ )*\\ )\n )" )
119
- ; ; (move-overlay caml-types-type-ovl
120
- ; ; (match-beginning 1) (match-end 1)
121
- ; ; type-buf)
122
122
(message (format " type: %s " (match-string 1 )))
123
- (narrow-to-region (match-beginning 0 ) (match-end 0 ))
124
- ; (set-mark (match-beginning 1))
125
- )))
123
+ (narrow-to-region (match-beginning 1 ) (match-end 1 )))))
126
124
(if (and (= arg 4 )
127
125
(not (window-live-p (get-buffer-window type-buf))))
128
126
(display-buffer type-buf))
129
- ; (let
130
- ; ((window (get-buffer-window type-buf))
131
- ; (this-window (selected-window)))
132
- ; (if window
133
- ; (progn
134
- ; (select-window window)
135
- ; (goto-char (mark))
136
- ; (select-window this-window))))
137
127
(unwind-protect
138
128
(sit-for 60 )
139
129
(delete-overlay caml-types-expr-ovl)))))
@@ -320,23 +310,4 @@ and its type is displayed in the minibuffer, until the move is released."
320
310
(delete-overlay caml-types-expr-ovl))
321
311
))
322
312
323
-
324
-
325
- ; ; bindings
326
-
327
- ; ; now in caml.el
328
- ; (and
329
- ; (boundp 'caml-mode-map)
330
- ; (keymapp caml-mode-map)
331
- ; (progn
332
- ; (define-key caml-mode-map [?\C-c?\C-t] 'caml-types-show-type)
333
- ; (define-key caml-mode-map [down-mouse-2] 'caml-types-explore)
334
- ; (let ((map (lookup-key caml-mode-map [menu-bar caml])))
335
- ; (and
336
- ; (keymapp map)
337
- ; (progn
338
- ; (define-key map [separator-types] '("---"))
339
- ; (define-key map [show-type]
340
- ; '("Show type at point" . caml-types-show-type )))))))
341
-
342
313
(provide 'caml-types )
0 commit comments