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

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

[nongnu] elpa/caml 9fda737890 4/4: Merge pull request #14 from monnier/s


From: ELPA Syncer
Subject: [nongnu] elpa/caml 9fda737890 4/4: Merge pull request #14 from monnier/scratch/modernize
Date: Tue, 3 Oct 2023 13:00:06 -0400 (EDT)

branch: elpa/caml
commit 9fda737890e91e2eddca6b43b6582d35d27a4d0b
Merge: b36fe93e05 fce969c5a6
Author: monnier <monnier@iro.umontreal.ca>
Commit: GitHub <noreply@github.com>

    Merge pull request #14 from monnier/scratch/modernize
    
    Adapt code to various changes in ELisp
---
 caml-font-old.el |  11 +--
 caml-font.el     |   4 +-
 caml-help.el     |   2 +-
 caml.el          | 218 +++++++++++++++++++++++++------------------------------
 camldebug.el     | 147 ++++++++++++++++++++-----------------
 5 files changed, 185 insertions(+), 197 deletions(-)

diff --git a/caml-font-old.el b/caml-font-old.el
index b9d46377e2..dc5821002d 100644
--- a/caml-font-old.el
+++ b/caml-font-old.el
@@ -21,10 +21,7 @@
   (make-face 'Stop)
   (set-face-foreground 'Stop "White")
   (set-face-background 'Stop "Red")
-  (make-face 'Doc)
-  (set-face-foreground 'Doc "Red")
-  (setq font-lock-stop-face 'Stop)
-  (setq font-lock-doccomment-face 'Doc)
+  (defvar font-lock-stop-face 'Stop)
 ))
 
 ; The same definition is in caml.el:
@@ -39,7 +36,7 @@
      2 font-lock-stop-face)
 ;doccomments
    '("\\(^\\|[^\"]\\)\\((\\*\\*[^*]*\\([^)*][^*]*\\*+\\)*)\\)"
-     2 font-lock-doccomment-face)
+     2 font-lock-doc-face)
 ;comments
    '("\\(^\\|[^\"]\\)\\((\\*[^*]*\\*+\\([^)*][^*]*\\*+\\)*)\\)"
      2 font-lock-comment-face)
@@ -96,7 +93,7 @@
   (setq font-lock-keywords-only t)
   (font-lock-mode 1))
 
-(add-hook 'caml-mode-hook 'caml-mode-font-hook)
+(add-hook 'caml-mode-hook #'caml-mode-font-hook)
 
 (defun inferior-caml-mode-font-hook ()
   (cond
@@ -111,6 +108,6 @@
   (setq font-lock-keywords-only t)
   (font-lock-mode 1))
 
-(add-hook 'inferior-caml-mode-hooks 'inferior-caml-mode-font-hook)
+(add-hook 'inferior-caml-mode-hooks #'inferior-caml-mode-font-hook)
 
 (provide 'caml-font)
diff --git a/caml-font.el b/caml-font.el
index 71f0eb7c42..0024b0bd2e 100644
--- a/caml-font.el
+++ b/caml-font.el
@@ -407,7 +407,7 @@
   (caml-font-extend-after-change (point-min) (point-max) 0)
   (font-lock-mode 1)
 )
-(add-hook 'caml-mode-hook 'caml-font-set-font-lock)
+(add-hook 'caml-mode-hook #'caml-font-set-font-lock)
 
 
 
@@ -432,6 +432,6 @@
   (caml-font-extend-after-change (point-min) (point-max) 0)
   (font-lock-mode 1)
 )
-(add-hook 'inferior-caml-mode-hooks 'inferior-caml-set-font-lock)
+(add-hook 'inferior-caml-mode-hooks #'inferior-caml-set-font-lock)
 
 (provide 'caml-font)
diff --git a/caml-help.el b/caml-help.el
index 845196382e..8adc2e5b57 100644
--- a/caml-help.el
+++ b/caml-help.el
@@ -758,7 +758,7 @@ buffer positions."
 
 (defvar ocaml-link-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [mouse-2] 'ocaml-link-goto)
+    (define-key map [mouse-2] #'ocaml-link-goto)
     map))
 
 (defun ocaml-help-show (arg)
diff --git a/caml.el b/caml.el
index 012cc9389e..641e9b2dae 100644
--- a/caml.el
+++ b/caml.el
@@ -7,7 +7,7 @@
 ;;         Damien Doligez <damien.doligez@inria.fr>
 ;; Maintainer: Christophe Troestler <Christophe.Troestler@umons.ac.be>
 ;; Created: July 1993
-;; Package-Requires: ((emacs "24.3"))
+;; Package-Requires: ((emacs "24.4"))
 ;; Version: 4.10-snapshot
 ;; Keywords: OCaml
 ;; Homepage: https://github.com/ocaml/caml-mode
@@ -295,52 +295,52 @@ have `caml-electric-indent' on, which see.")
 
 (defvar caml-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map "|" 'caml-electric-pipe)
-    (define-key map "}" 'caml-electric-pipe)
-    (define-key map "]" 'caml-electric-rb)
-    (define-key map "\t" 'caml-indent-command)
-    (define-key map [backtab] 'caml-unindent-command)
+    (define-key map "|" #'caml-electric-pipe)
+    (define-key map "}" #'caml-electric-pipe)
+    (define-key map "]" #'caml-electric-rb)
+    (define-key map "\t" #'caml-indent-command)
+    (define-key map [backtab] #'caml-unindent-command)
 
     ;;itz 04-21-96 instead of defining a new function, use defadvice
     ;;that way we get out effect even when we do \C-x` in compilation buffer
     ;;  (define-key map "\C-x`" 'caml-next-error)
 
     ;; caml-types
-    (define-key map [?\C-c?\C-t] 'caml-types-show-type)  ; "type"
-    (define-key map [?\C-c?\C-f] 'caml-types-show-call)  ; "function"
-    (define-key map [?\C-c?\C-l] 'caml-types-show-ident) ; "let"
+    (define-key map [?\C-c?\C-t] #'caml-types-show-type)  ; "type"
+    (define-key map [?\C-c?\C-f] #'caml-types-show-call)  ; "function"
+    (define-key map [?\C-c?\C-l] #'caml-types-show-ident) ; "let"
     ;; must be a mouse-down event. Can be any button and any prefix
-    (define-key map [?\C-c down-mouse-1] 'caml-types-explore)
+    (define-key map [?\C-c down-mouse-1] #'caml-types-explore)
     ;; caml-help
-    (define-key map [?\C-c?i] 'ocaml-add-path)
-    (define-key map [?\C-c?\]] 'ocaml-close-module)
-    (define-key map [?\C-c?\[] 'ocaml-open-module)
-    (define-key map [?\C-c?\C-h] 'caml-help)
-    (define-key map [?\C-c?\t] 'caml-complete)
+    (define-key map [?\C-c?i] #'ocaml-add-path)
+    (define-key map [?\C-c?\]] #'ocaml-close-module)
+    (define-key map [?\C-c?\[] #'ocaml-open-module)
+    (define-key map [?\C-c?\C-h] #'caml-help)
+    (define-key map [?\C-c?\t] #'caml-complete)
     ;; others
-    (define-key map "\C-cb" 'caml-insert-begin-form)
-    (define-key map "\C-cf" 'caml-insert-for-form)
-    (define-key map "\C-ci" 'caml-insert-if-form)
-    (define-key map "\C-cl" 'caml-insert-let-form)
-    (define-key map "\C-cm" 'caml-insert-match-form)
-    (define-key map "\C-ct" 'caml-insert-try-form)
-    (define-key map "\C-cw" 'caml-insert-while-form)
-    (define-key map "\C-c`" 'caml-goto-phrase-error)
-    (define-key map "\C-c\C-a" 'caml-find-alternate-file)
-    (define-key map "\C-c\C-c" 'compile)
-    (define-key map "\C-c\C-e" 'caml-eval-phrase)
-    (define-key map "\C-c\C-[" 'caml-backward-to-less-indent)
-    (define-key map "\C-c\C-]" 'caml-forward-to-less-indent)
-    (define-key map "\C-c\C-q" 'caml-indent-phrase)
-    (define-key map "\C-c\C-r" 'caml-eval-region)
-    (define-key map "\C-c\C-s" 'caml-show-subshell)
-    (define-key map "\M-\C-h" 'caml-mark-phrase)
-    (define-key map "\M-\C-q" 'caml-indent-phrase)
-    (define-key map "\M-\C-x" 'caml-eval-phrase)
+    (define-key map "\C-cb" #'caml-insert-begin-form)
+    (define-key map "\C-cf" #'caml-insert-for-form)
+    (define-key map "\C-ci" #'caml-insert-if-form)
+    (define-key map "\C-cl" #'caml-insert-let-form)
+    (define-key map "\C-cm" #'caml-insert-match-form)
+    (define-key map "\C-ct" #'caml-insert-try-form)
+    (define-key map "\C-cw" #'caml-insert-while-form)
+    (define-key map "\C-c`" #'caml-goto-phrase-error)
+    (define-key map "\C-c\C-a" #'caml-find-alternate-file)
+    (define-key map "\C-c\C-c" #'compile)
+    (define-key map "\C-c\C-e" #'caml-eval-phrase)
+    (define-key map "\C-c\C-[" #'caml-backward-to-less-indent)
+    (define-key map "\C-c\C-]" #'caml-forward-to-less-indent)
+    (define-key map "\C-c\C-q" #'caml-indent-phrase)
+    (define-key map "\C-c\C-r" #'caml-eval-region)
+    (define-key map "\C-c\C-s" #'caml-show-subshell)
+    (define-key map "\M-\C-h" #'caml-mark-phrase)
+    (define-key map "\M-\C-q" #'caml-indent-phrase)
+    (define-key map "\M-\C-x" #'caml-eval-phrase)
 
     (let ((menu (make-sparse-keymap "Caml"))
           (forms (make-sparse-keymap "Forms")))
-      (define-key map "\C-c\C-d" 'caml-show-imenu)
+      (define-key map "\C-c\C-d" #'caml-show-imenu)
       (define-key map [menu-bar] (make-sparse-keymap))
       (define-key map [menu-bar caml] (cons "Caml" menu))
       ;; caml-help
@@ -408,13 +408,11 @@ have `caml-electric-indent' on, which see.")
     st)
   "Syntax table in use in Caml mode buffers.")
 
-(defvar caml-mode-abbrev-table nil
+(define-abbrev-table 'caml-mode-abbrev-table
+  (mapcar (lambda (keyword)
+            `(,keyword ,keyword caml-abbrev-hook nil t))
+          '("and" "do" "done" "else" "end" "in" "then" "with"))
   "Abbrev table used for Caml mode buffers.")
-(if caml-mode-abbrev-table nil
-  (define-abbrev-table 'caml-mode-abbrev-table
-    (mapcar (lambda (keyword)
-              `(,keyword ,keyword caml-abbrev-hook nil t))
-            '("and" "do" "done" "else" "end" "in" "then" "with"))))
 
 ;; Other internal variables
 
@@ -435,9 +433,6 @@ have `caml-electric-indent' on, which see.")
   (require 'imenu))
 
 ;;
-(defvar caml-mode-hook nil
-  "Hook for `caml-mode'.")
-
 (define-derived-mode caml-mode prog-mode "caml"
   "Major mode for editing OCaml code."
   (setq local-abbrev-table caml-mode-abbrev-table)
@@ -646,7 +641,7 @@ See `imenu-create-index-function'."
            (setq menu-alist
                  (cons
                   (cons (car pair)
-                        (sort (cdr pair) 'imenu--sort-by-name))
+                        (sort (cdr pair) #'imenu--sort-by-name))
                   menu-alist))))
      `(("Values" . ,value-alist)
        ("Types" . ,type-alist)
@@ -786,55 +781,54 @@ error message produced by ocamlc.")
 ;itz 04-21-96 instead of defining a new function, use defadvice
 ;that way we get our effect even when we do \C-x` in compilation buffer
 
-(defadvice next-error (after caml-next-error activate)
+(advice-add 'next-error :after #'caml--next-error-highlight)
+
+(defun caml--next-error-highlight (&rest _)
+  ;; FIXME: Is this advice still needed?
   "Read the extra positional information provided by the OCaml compiler.
 
 Puts the point and the mark exactly around the erroneous program
 fragment.  The erroneous fragment is also temporarily highlighted if
 possible."
-
- (if (eq major-mode 'caml-mode)
-     (let (skip bol beg end)
-       (save-excursion
-         (with-current-buffer
-             (if (boundp 'compilation-last-buffer)
-                 compilation-last-buffer   ;Emacs 19
-               "*compilation*")           ;Emacs 18
-           (save-excursion
-             (goto-char (window-point (get-buffer-window (current-buffer))))
-             (if (looking-at caml-error-chars-regexp)
-                 (setq beg
-                       (string-to-number
-                        (buffer-substring (match-beginning 1) (match-end 1)))
-                       end
-                       (string-to-number
-                        (buffer-substring (match-beginning 2) (match-end 2)))))
-             (forward-line 1)
-             (beginning-of-line)
-             (if (and (looking-at "Warning")
-                      caml-next-error-skip-warnings-flag)
-                 (setq skip 't)))))
-       (cond
-        (skip (next-error))
-        (beg
-              (setq end (- end beg))
-              (beginning-of-line)
-              (forward-char beg)
-              (setq beg (point))
-              (forward-char end)
-              (setq end (point))
-              (goto-char beg)
-              (push-mark end t)
-              (cond ((fboundp 'make-overlay)
-                     (if caml-error-overlay ()
-                       (setq caml-error-overlay (make-overlay 1 1))
-                       (overlay-put caml-error-overlay 'face 'region))
-                     (unwind-protect
-                         (progn
-                           (move-overlay caml-error-overlay
-                                         beg end (current-buffer))
-                           (sit-for 60))
-                       (delete-overlay caml-error-overlay)))))))))
+  (when (derived-mode-p 'caml-mode)
+    (let (skip beg end)
+      (save-excursion ;; FIXME: Redundant?
+        (with-current-buffer next-error-last-buffer
+          (save-excursion
+            (goto-char (window-point (get-buffer-window (current-buffer))))
+            (if (looking-at caml-error-chars-regexp)
+                (setq beg
+                      (string-to-number
+                       (buffer-substring (match-beginning 1) (match-end 1)))
+                      end
+                      (string-to-number
+                       (buffer-substring (match-beginning 2) (match-end 2)))))
+            (forward-line 1)
+            (beginning-of-line)
+            (if (and (looking-at "Warning")
+                     caml-next-error-skip-warnings-flag)
+                (setq skip 't)))))
+      (cond
+       (skip (next-error))
+       (beg
+        (setq end (- end beg))
+        (beginning-of-line)
+        (forward-char beg)
+        (setq beg (point))
+        (forward-char end)
+        (setq end (point))
+        (goto-char beg)
+        (push-mark end t)
+        (cond ((fboundp 'make-overlay)
+               (if caml-error-overlay ()
+                 (setq caml-error-overlay (make-overlay 1 1))
+                 (overlay-put caml-error-overlay 'face 'region))
+               (unwind-protect
+                   (progn
+                     (move-overlay caml-error-overlay
+                                   beg end (current-buffer))
+                     (sit-for 60))
+                 (delete-overlay caml-error-overlay)))))))))
 
 (defun caml-next-error-skip-warnings (&rest args)
   "Same as `next-error' but skip warnings.
@@ -1570,40 +1564,18 @@ matching nodes to determine KEYWORD's final 
indentation.")
   (insert-before-markers "\"^\"")
   (backward-char 1))
 
-(defadvice indent-new-comment-line (around
-                                    caml-indent-new-comment-line
-                                    activate)
-
-  "Handle multi-line strings in caml mode."
-
-;this advice doesn't make sense in other modes. I wish there were a
-;cleaner way to do this: I haven't found one.
-
-  (let ((hooked (and (eq major-mode 'caml-mode) (caml-in-literal-p)))
-        (split-mark))
-    (if (not hooked) nil
-      (setq split-mark (set-marker (make-marker) (point)))
-      (caml-split-string))
-    ad-do-it
-    (if (not hooked) nil
-      (goto-char split-mark)
-      (set-marker split-mark nil))))
-
-(defadvice newline-and-indent (around
-                               caml-newline-and-indent
-                               activate)
-
+(defun caml--split-string (orig-fun &rest args)
   "Handle multi-line strings in caml mode."
+  ;; This advice doesn't make sense in other modes.  I wish there were a
+  ;; cleaner way to do this: I haven't found one.
+  (if (not (and (derived-mode-p 'caml-mode) (caml-in-literal-p)))
+      (apply orig-fun args)
+    (save-excursion
+      (caml-split-string)
+      (apply orig-fun args))))
 
-    (let ((hooked (and (eq major-mode 'caml-mode) (caml-in-literal-p)))
-        (split-mark))
-    (if (not hooked) nil
-      (setq split-mark (set-marker (make-marker) (point)))
-      (caml-split-string))
-    ad-do-it
-    (if (not hooked) nil
-      (goto-char split-mark)
-      (set-marker split-mark nil))))
+(advice-add 'indent-new-comment-line :around #'caml--split-string)
+(advice-add 'newline-and-indent :around #'caml--split-string)
 
 (defun caml-electric-pipe ()
   "If inserting a | or } operator at beginning of line, reindent the line.
@@ -1848,6 +1820,10 @@ current phrase."
   "Show the type of expression or pattern at point." t)
 (autoload 'caml-types-explore "caml-types"
   "Explore type annotations by mouse dragging." t)
+(autoload 'caml-types-show-ident "caml-types"
+  "Show the binding of identifier at point." t)
+(autoload 'caml-types-show-call "caml-types"
+  "Show the kind of call at point." t)
 
 (autoload 'caml-help "caml-help"
   "Show documentation for qualified OCaml identifier." t)
diff --git a/camldebug.el b/camldebug.el
index febc27d275..5644a0d060 100644
--- a/camldebug.el
+++ b/camldebug.el
@@ -12,13 +12,13 @@
 ;*                                                                        *
 ;**************************************************************************
 
-;;; Run camldebug under Emacs
-;;; Derived from gdb.el.
-;;; gdb.el is Copyright (C) 1988 Free Software Foundation, Inc, and is part
-;;; of GNU Emacs
-;;; Modified by Jerome Vouillon, 1994.
-;;; Modified by Ian T. Zimmerman, 1996.
-;;; Modified by Xavier Leroy, 1997.
+;; Run camldebug under Emacs
+;; Derived from gdb.el.
+;; gdb.el is Copyright (C) 1988 Free Software Foundation, Inc, and is part
+;; of GNU Emacs
+;; Modified by Jerome Vouillon, 1994.
+;; Modified by Ian T. Zimmerman, 1996.
+;; Modified by Xavier Leroy, 1997.
 
 ;; This file is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
@@ -101,8 +101,8 @@ The following commands are available:
 the last line referred to in the camldebug buffer.
 
 \\[camldebug-step], \\[camldebug-back] and \\[camldebug-next], in the camldebug
-window, call camldebug to step, backstep or next and then update the other 
window
-with the current file and position.
+window, call camldebug to step, backstep or next and then update the other
+window with the current file and position.
 
 If you are in a source file, you may select a point to break
 at, by doing \\[camldebug-break].
@@ -127,7 +127,7 @@ C-x SPACE sets break point at current line."
    comint-prompt-regexp camldebug-prompt-pattern
    paragraph-start comint-prompt-regexp
    camldebug-last-frame-displayed-p t)
-  (add-hook 'comint-dynamic-complete-functions #'camldebug-complete nil t)
+  (add-hook 'comint-dynamic-complete-functions #'camldebug-capf nil t)
   (make-local-variable 'shell-dirtrackp)
   (setq shell-dirtrackp t)
   (setq comint-input-sentinel #'shell-directory-tracker))
@@ -161,19 +161,15 @@ If a numeric is present, it overrides any ARGS flags and 
its string
 representation is simply concatenated with the COMMAND."
 
   (let* ((fun (intern (format "camldebug-%s" name))))
-    (list 'progn
-          (if doc
-              (list 'defun fun '(arg)
-                    doc
-                    '(interactive "P")
-                    (list 'camldebug-call name args
-                          '(camldebug-numeric-arg arg))))
-          (list 'define-key 'camldebug-mode-map
-                (concat "\C-c" key)
-                (list 'quote fun))
-          (list 'define-key 'caml-mode-map
-                (concat "\C-x\C-a" key)
-                (list 'quote fun)))))
+    `(progn
+       ,(when doc
+          `(defun ,fun (arg)
+             ,doc
+             (interactive "P")
+             (camldebug-call ,name ,args
+                             (camldebug-numeric-arg arg))))
+       (define-key camldebug-mode-map ,(concat "\C-c" key) #',fun)
+       (define-key caml-mode-map ,(concat "\C-x\C-a" key) #',fun))))
 
 (def-camldebug "step"   "\C-s"  "Step one event forward.")
 (def-camldebug "backstep" "\C-k" "Step one event backward.")
@@ -204,7 +200,7 @@ representation is simply concatenated with the COMMAND."
       (if (string-match "^\\$[0-9]+$" symb)
           (camldebug-call "display" symb)))))
 
-(define-key camldebug-mode-map [mouse-2] 'camldebug-mouse-display)
+(define-key camldebug-mode-map [mouse-2] #'camldebug-mouse-display)
 
 (defvar camldebug-kill-output)
 
@@ -454,48 +450,65 @@ around point."
   "")
 
 (defun camldebug-complete ()
-
   "Perform completion on the camldebug command preceding point."
-
+  (declare (obsolete completion-at-point "24.1"))
   (interactive)
+  (let* ((capf-data (camldebug-capf))
+         (command-word (buffer-substring (nth 0 capf-data) (nth 1 capf-data))))
+    (completion-in-region (nth 0 capf-data) (nth 1 capf-data)
+                          (sort (all-completions command-word (nth 2 
capf-data))
+                                #'string-lessp))))
+
+(defun camldebug-capf ()
   (let* ((end (point))
-         (command (save-excursion
+         (cmd-start (save-excursion
                     (beginning-of-line)
                     (and (looking-at comint-prompt-regexp)
                          (goto-char (match-end 0)))
-                    (buffer-substring (point) end)))
-         (camldebug-complete-list nil) (command-word))
-
-    ;; Find the word break.  This match will always succeed.
-    (string-match "\\(\\`\\| \\)\\([^ ]*\\)\\'" command)
-    (setq command-word (match-string 2 command))
-
-    ;itz 04-21-96 if we are trying to complete a word of nonzero
-    ;length, chop off the last character. This is a nasty hack, but it
-    ;works - in general, not just for this set of words: the comint
-    ;call below will weed out false matches - and it avoids further
-    ;mucking with camldebug's lexer.
-    (if (> (length command-word) 0)
-        (setq command (substring command 0 (1- (length command)))))
+                    (point)))
+         (command (buffer-substring cmd-start end))
+         ;; Find the word break.  This match will always succeed.
+         (_ (string-match "\\(\\`\\| \\)\\([^ ]*\\)\\'" command))
+         (command-word (match-string 2 command))
+         (word-end end)
+         (word-beg (- word-end (length command-word))))
+
+    `(,word-beg ,word-end
+                ,(completion-table-dynamic
+                  (apply-partially
+                   #'camldebug--get-completions
+                   (buffer-substring cmd-start word-beg))))))
+
+(defun camldebug--get-completions (command-prefix command-word)
+  (let ((camldebug-complete-list nil))
+    ;;itz 04-21-96 if we are trying to complete a word of nonzero
+    ;;length, chop off the last character. This is a nasty hack, but it
+    ;;works - in general, not just for this set of words: the comint
+    ;;call below will weed out false matches - and it avoids further
+    ;;mucking with camldebug's lexer.
+    ;; FIXME: Which problem is this trying to fix/avoid/circumvent?
+    (when (> (length command-word) 0)
+      (setq command-word (substring command-word 0 (1- (length 
command-word)))))
 
     (let ((camldebug-filter-function #'camldebug-complete-filter))
-      (camldebug-call-1 (concat "complete " command))
+      (camldebug-call-1 (concat "complete " command-prefix command-word))
       (set-marker camldebug-delete-prompt-marker nil)
       (while (not (and camldebug-complete-list
                        (zerop (length camldebug-filter-accumulator))))
         (accept-process-output (get-buffer-process
                                 (current-buffer)))))
     (if (eq camldebug-complete-list 'fail)
-        (setq camldebug-complete-list nil))
-    (setq camldebug-complete-list
-          (sort camldebug-complete-list 'string-lessp))
-    (comint-dynamic-simple-complete command-word camldebug-complete-list)))
+        nil
+      (sort camldebug-complete-list #'string-lessp))))
 
-(define-key camldebug-mode-map "\C-l" 'camldebug-refresh)
-(define-key camldebug-mode-map "\t" 'comint-dynamic-complete)
-(define-key camldebug-mode-map "\M-?" 'comint-dynamic-list-completions)
+(define-key camldebug-mode-map "\C-l" #'camldebug-refresh)
+;; This is already the default anyway!
+;;(define-key camldebug-mode-map "\t" #'comint-dynamic-complete)
+;; FIXME: This binding is wrong since `comint-dynamic-list-completions'
+;; is a function, not a command.
+;;(define-key camldebug-mode-map "\M-?" #'comint-dynamic-list-completions)
 
-(define-key caml-mode-map "\C-x " 'camldebug-break)
+(define-key caml-mode-map "\C-x " #'camldebug-break)
 
 
 ;;;###autoload
@@ -503,27 +516,29 @@ around point."
   "*Pathname for executing camldebug.")
 
 ;;;###autoload
-(defun camldebug (path)
+(defun camldebug (file)
   "Run camldebug on program FILE in buffer *camldebug-FILE*.
 The directory containing FILE becomes the initial working directory
 and source-file directory for camldebug.  If you wish to change this, use
 the camldebug commands `cd DIR' and `directory'."
   (interactive "fRun ocamldebug on file: ")
-  (setq path (expand-file-name path))
-  (let ((file (file-name-nondirectory path)))
-    (pop-to-buffer (concat "*camldebug-" file "*"))
-    (setq default-directory (file-name-directory path))
-    (message "Current directory is %s" default-directory)
-    (make-comint (concat "camldebug-" file)
-                 (substitute-in-file-name camldebug-command-name)
-                 nil
-                 "-emacs" "-cd" default-directory file)
-    (set-process-filter (get-buffer-process (current-buffer))
-                        'camldebug-filter)
-    (set-process-sentinel (get-buffer-process (current-buffer))
-                          'camldebug-sentinel)
-    (camldebug-mode)
-    (camldebug-set-buffer)))
+  (setq file (expand-file-name file))
+  (let* ((dir (file-name-directory file))
+         (file (file-name-nondirectory file))
+         (buf
+          (let ((default-directory dir))
+            (message "Current directory is %s" default-directory)
+            (make-comint (concat "camldebug-" file)
+                         (substitute-in-file-name camldebug-command-name)
+                         nil
+                         "-emacs" "-cd" default-directory file)))
+         (proc (get-buffer-process buf)))
+    (with-current-buffer buf
+      (set-process-filter proc #'camldebug-filter)
+      (set-process-sentinel proc #'camldebug-sentinel)
+      (camldebug-mode)
+      (camldebug-set-buffer)
+      (pop-to-buffer (current-buffer)))))
 
 (defun camldebug-set-buffer ()
   (if (eq major-mode 'camldebug-mode)



reply via email to

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