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

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

[nongnu] externals/caml 91865b8 055/197: simplify electric


From: Stefan Monnier
Subject: [nongnu] externals/caml 91865b8 055/197: simplify electric
Date: Sat, 21 Nov 2020 01:19:37 -0500 (EST)

branch: externals/caml
commit 91865b8ca19dee9683c54c0f2e9c17cef54a4fd6
Author: Jacques Garrigue <garrigue at math.nagoya-u.ac.jp>
Commit: Jacques Garrigue <garrigue at math.nagoya-u.ac.jp>

    simplify electric
    
    
    git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4913 
f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
---
 caml.el | 54 ++++++++++++++++--------------------------------------
 1 file changed, 16 insertions(+), 38 deletions(-)

diff --git a/caml.el b/caml.el
index 1d31316..bfe1b59 100644
--- a/caml.el
+++ b/caml.el
@@ -1565,17 +1565,7 @@ followed by |."
                        (caml-in-indentation)
                        (not (caml-in-comment-p)))))
     (self-insert-command 1)
-    (if electric
-        (let ((indent
-               (save-excursion
-                 (backward-char 1)
-                 (caml-indent-command)
-                 (current-column))))
-          (indent-to (- indent
-                        (symbol-value
-                         (nth 1 (assoc
-                                 (char-to-string last-command-char)
-                                 caml-leading-kwops-alist)))))))))
+    (if electric (save-excursion (caml-indent-command)))))
 
 (defun caml-electric-rb ()
   "If inserting a ] operator at beginning of line, reindent the line.
@@ -1585,38 +1575,26 @@ by |, insert one."
 
   (interactive "*")
   (let* ((prec (preceding-char))
-         (look-pipe (and caml-electric-close-vector
-                         (not (caml-in-comment-p))
-                         (not (caml-in-literal-p))
-                         (or (not (numberp prec))
-                             (not (char-equal ?| prec)))
-                         (set-marker (make-marker) (point))))
+         (use-pipe (and caml-electric-close-vector
+                        (not (caml-in-comment-p))
+                        (not (caml-in-literal-p))
+                        (or (not (numberp prec))
+                            (not (char-equal ?| prec)))))
          (electric (and caml-electric-indent
                         (caml-in-indentation)
                         (not (caml-in-comment-p)))))
     (self-insert-command 1)
-    (if electric
-        (let ((indent
-               (save-excursion
-                 (backward-char 1)
-                 (caml-indent-command)
-                 (current-column))))
-          (indent-to (- indent
-                        (symbol-value
-                         (nth 1 (assoc
-                                 (char-to-string last-command-char)
-                                 caml-leading-kwops-alist)))))))
-    (if look-pipe
-        (save-excursion
-          (let ((insert-pipe
-                 (condition-case nil
-                     (prog2
+    (if electric (save-excursion (caml-indent-command)))
+    (if (and use-pipe
+             (save-excursion
+               (condition-case nil
+                   (prog2
                        (backward-list 1)
-                       (if (looking-at "\\[|") "|" ""))
-                   (error ""))))
-            (goto-char look-pipe)
-            (insert insert-pipe))
-          (set-marker look-pipe nil)))))
+                       (looking-at "\\[|"))
+                 (error ""))))
+        (save-excursion
+          (backward-char 1)
+          (insert "|")))))
 
 (defun caml-abbrev-hook ()
   "If inserting a leading keyword at beginning of line, reindent the line."



reply via email to

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