summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDidier Rémy <Didier.Remy@inria.fr>2003-07-29 06:54:28 +0000
committerDidier Rémy <Didier.Remy@inria.fr>2003-07-29 06:54:28 +0000
commit066b0b1391b948325bdd76d068709ee2c982bd41 (patch)
treeea7d396f62281b2b70d16fe0b506bb29b6ec5198
parent7403b73fb9cea0c25ddad90e285b0fc23d28c3d2 (diff)
added caml-emacs.el
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5753 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--emacs/caml-emacs.el15
-rw-r--r--emacs/caml-help.el13
-rw-r--r--emacs/caml-types.el21
-rw-r--r--emacs/caml-xemacs.el17
4 files changed, 42 insertions, 24 deletions
diff --git a/emacs/caml-emacs.el b/emacs/caml-emacs.el
new file mode 100644
index 000000000..aa35c7c2c
--- /dev/null
+++ b/emacs/caml-emacs.el
@@ -0,0 +1,15 @@
+;; for caml-help.el
+(defalias 'caml-info-other-window 'info-other-window)
+
+;; for caml-types.el
+
+(defalias 'caml-line-beginning-position 'line-beginning-position)
+
+(defun caml-event-window (e) (event-window (event-start e)))
+(defun caml-event-point-start (e) (posn-point (event-stact e)))
+(defun caml-event-point-end (e) (posn-point (event-end e)))
+(defmacro caml-track-mouse (el) (track-mouse el))
+(defalias 'caml-read-event 'read-event)
+(defun caml-mouse-movement-p mouse-mouvement)
+
+(provide 'caml-emacs)
diff --git a/emacs/caml-help.el b/emacs/caml-help.el
index f67ed1a51..69e5b1c9f 100644
--- a/emacs/caml-help.el
+++ b/emacs/caml-help.el
@@ -27,8 +27,10 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(if (and (boundp 'running-xemacs) running-xemacs)
- (require 'caml-xemacs))
+(eval-and-compile
+ (if (and (boundp 'running-xemacs) running-xemacs)
+ (require 'caml-xemacs)
+ (require 'caml-emacs)))
;; Loading or building databases.
;;
@@ -566,7 +568,7 @@ current buffer using \\[ocaml-qualified-identifier]."
(let ((window (selected-window))
(info-section (assoc module (ocaml-info-alist))))
(if info-section
- (info-other-window (cdr info-section))
+ (caml-info-other-window (cdr info-section))
(ocaml-visible-modules)
(let* ((module-info
(or (assoc module (ocaml-module-alist))
@@ -717,9 +719,8 @@ buffer positions."
(defun ocaml-link-goto (click)
(interactive "e")
- (let* ((start (event-start click))
- (pos (posn-point start))
- (buf (window-buffer (posn-window start)))
+ (let* ((pos (caml-event-point-start click))
+ (buf (caml-event-window click))
(window (selected-window))
(link))
(setq link
diff --git a/emacs/caml-types.el b/emacs/caml-types.el
index 9cf34908e..643125f54 100644
--- a/emacs/caml-types.el
+++ b/emacs/caml-types.el
@@ -15,9 +15,11 @@
; An emacs-lisp complement to the "-dtypes" option of ocamlc and ocamlopt.
;; XEmacs compatibility
-(if (and (boundp 'running-xemacs) running-xemacs)
- (require 'caml-xemacs))
+(eval-and-compile
+ (if (and (boundp 'running-xemacs) running-xemacs)
+ (require 'caml-xemacs)
+ (require 'caml-emacs)))
(defvar caml-types-location-re nil "Regexp to parse *.annot files.
@@ -108,8 +110,9 @@ See `caml-types-location-re' for annotation file format.
(interactive "p")
(let* ((target-buf (current-buffer))
(target-file (file-name-nondirectory (buffer-file-name)))
- (target-line (1+ (count-lines (point-min) (line-beginning-position))))
- (target-bol (line-beginning-position))
+ (target-line (1+ (count-lines (point-min)
+ (caml-line-beginning-position))))
+ (target-bol (caml-line-beginning-position))
(target-cnum (point))
(type-file (concat (file-name-sans-extension (buffer-file-name))
".annot")))
@@ -362,7 +365,7 @@ See `caml-types-location-re' for annotation file format.
The expression under the mouse is highlighted
and its type is displayed in the minibuffer, until the move is released."
(interactive "e")
- (set-buffer (window-buffer (posn-window (event-start event))))
+ (set-buffer (window-buffer (caml-event-window event)))
(let* ((target-buf (current-buffer))
(target-file (file-name-nondirectory (buffer-file-name)))
(type-file (concat (file-name-sans-extension (buffer-file-name))
@@ -377,15 +380,15 @@ and its type is displayed in the minibuffer, until the move is released."
(setq caml-types-buffer (get-buffer-create caml-types-buffer-name)))
; (message "Drag the mouse to explore types")
(unwind-protect
- (track-mouse
+ (caml-track-mouse
(while (and event
(integer-or-marker-p
- (setq cnum (posn-point (event-end event)))))
+ (setq cnum (caml-event-point-end event))))
(if (and limits (>= cnum (car limits)) (< cnum (cdr limits)))
(message mes)
(setq target-bol
(save-excursion (goto-char cnum)
- (line-beginning-position)))
+ (caml-line-beginning-position)))
(setq target-line
(1+ (count-lines (point-min) target-bol)))
(setq target-pos (vector target-file target-line target-bol cnum))
@@ -411,7 +414,7 @@ and its type is displayed in the minibuffer, until the move is released."
(message (format "type: %s" type))
(insert type)
))
- (setq event (read-event))
+ (setq event (caml-read-event))
(unless (mouse-movement-p event) (setq event nil))
)
)
diff --git a/emacs/caml-xemacs.el b/emacs/caml-xemacs.el
index 9c1aaa64c..fae561c3f 100644
--- a/emacs/caml-xemacs.el
+++ b/emacs/caml-xemacs.el
@@ -1,20 +1,19 @@
(require 'overlay)
;; for caml-help.el
-(defun info-other-window (arg)
+(defun caml-info-other-window (arg)
(save-excursion (info arg))
(view-buffer-other-window "*info*"))
;; for caml-types.el
-(defun event-start (e) e)
-(defun event-end (e) e)
-(defun line-beginning-position ()
+(defun caml-line-beginning-position ()
(save-excursion (beginning-of-line) (point)))
-(defvar last-mouse-position t)
-(defun posn-point (e) (event-closest-point e))
-(defmacro track-mouse (el) (progn el))
-(defun read-event () (let ((e (next-event))) e))
+
+(defun caml-event-window (e) (event-window e))
+(defun caml-event-point-start (e) (event-closest-point e))
+(defun caml-event-point-end (e) (event-closest-point e))
+(defmacro caml-track-mouse (el) (progn el))
+(defalias 'caml-read-event 'next-event)
(defun mouse-movement-p (e) (equal (event-type e) 'motion))
-(defun posn-window (e) (event-window e))
(provide 'caml-xemacs)