emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] externals/caml dbaedc7 086/197: added caml-emacs.el


From: Stefan Monnier
Subject: [nongnu] externals/caml dbaedc7 086/197: added caml-emacs.el
Date: Sat, 21 Nov 2020 01:19:43 -0500 (EST)

branch: externals/caml
commit dbaedc7e5b80cee992140f5489aa97b6dd803481
Author: Didier Rémy <Didier.Remy@inria.fr>
Commit: Didier Rémy <Didier.Remy@inria.fr>

    added caml-emacs.el
    
    
    git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5753 
f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
---
 caml-emacs.el  | 15 +++++++++++++++
 caml-help.el   | 13 +++++++------
 caml-types.el  | 21 ++++++++++++---------
 caml-xemacs.el | 17 ++++++++---------
 4 files changed, 42 insertions(+), 24 deletions(-)

diff --git a/caml-emacs.el b/caml-emacs.el
new file mode 100644
index 0000000..aa35c7c
--- /dev/null
+++ b/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/caml-help.el b/caml-help.el
index f67ed1a..69e5b1c 100644
--- a/caml-help.el
+++ b/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/caml-types.el b/caml-types.el
index 9cf3490..643125f 100644
--- a/caml-types.el
+++ b/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/caml-xemacs.el b/caml-xemacs.el
index 9c1aaa6..fae561c 100644
--- a/caml-xemacs.el
+++ b/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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]