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

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

[nongnu] externals/caml 1991236 046/197: improve indentation


From: Stefan Monnier
Subject: [nongnu] externals/caml 1991236 046/197: improve indentation
Date: Sat, 21 Nov 2020 01:19:35 -0500 (EST)

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

    improve indentation
    
    
    git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@4165 
f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
---
 caml.el | 58 +++++++++++++++++++++++++++++-----------------------------
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/caml.el b/caml.el
index d97e625..632271e 100644
--- a/caml.el
+++ b/caml.el
@@ -1022,10 +1022,10 @@ Used to distinguish it from toplevel let construct.")
              (aref caml-kwop-regexps caml-max-indent-priority)))
     (cond
      ; special case for ;;
-     ((and (= (preceding-char) ?\;) (= (following-char) ?\;))
+     ((and (> (point) 1) (= (preceding-char) ?\;) (= (following-char) ?\;))
       (setq in-expr nil))
      ((looking-at caml-before-expr-prefix)
-      (goto-char (match-end 0))
+      (if (not (looking-at "(\\*")) (goto-char (match-end 0)))
       (skip-chars-forward " \t\n")
       (while (looking-at "(\\*")
         (forward-char)
@@ -1051,19 +1051,18 @@ keywords."
 
   (let ((start-literal (concat "[\"" caml-quote-char "]"))
         found kwop)
-    (progn
-      (while (and (not found)
-                  (re-search-backward kwop-regexp nil t))
-        (setq kwop (caml-match-string 0))
-        (cond
-         ((looking-at "(\\*")
-          (backward-char))
-         ((caml-in-comment-p)
-          (search-backward "(" nil 'move))
-         ((looking-at start-literal))
-         ((caml-in-literal-p)
-          (re-search-backward start-literal))  ;ugly hack
-         ((setq found t)))))
+    (while (and (> (point) 1) (not found)
+                (re-search-backward kwop-regexp nil 'move))
+      (setq kwop (caml-match-string 0))
+      (cond
+       ((looking-at "(\\*")
+        (if (> (point) 1) (backward-char)))
+       ((caml-in-comment-p)
+        (search-backward "(" nil 'move))
+       ((looking-at start-literal))
+       ((caml-in-literal-p)
+        (re-search-backward start-literal nil 'move))  ;ugly hack
+       ((setq found t))))
     (if found
         (if (not (string-match "\\`[^|[]|[^]|]?\\'" kwop)) ;arrrrgh!!
             kwop
@@ -1342,8 +1341,9 @@ the line where the governing keyword occurs.")
        ((not kwop) (setq done t))
        ((caml-at-sexp-close-p)
         (caml-find-paren-match (following-char)))
-       ((and (string= kwop ";") (= (preceding-char) ?\;))
-        (goto-char 0)
+       ((or (string= kwop ";;")
+            (and (string= kwop ";") (= (preceding-char) ?\;)))
+        (forward-line 1)
         (setq kwop ";;")
         (setq done t))
        ((and (>= prio 2) (string= kwop "|")) (setq done t))
@@ -1461,7 +1461,7 @@ matching nodes to determine KEYWORD's final indentation.")
   (save-excursion
     (back-to-indentation)
     (cond
-     ((looking-at comment-start-skip) (current-column))
+     ((and (bolp) (looking-at comment-start-skip)) (current-column))
      ((caml-in-comment-p)
       (let ((closing (looking-at "\\*)"))
             (comment-mark (looking-at "\\*")))
@@ -1612,18 +1612,18 @@ by |, insert one."
                              0)
                             abbrev-correct)))))))
 
-; (defun caml-indent-phrase ()
-;   (interactive "*")
-;   (let ((bounds (caml-mark-phrase)))
-;     (indent-region (car bounds) (cdr bounds) nil)))
+(defun caml-indent-phrase ()
+  (interactive "*")
+  (let ((bounds (caml-mark-phrase)))
+    (indent-region (car bounds) (cdr bounds) nil)))
 
-(defun caml-indent-phrase (arg)
-  (interactive "p")
-  (save-excursion
-    (let ((beg (caml-find-phrase)))
-    (while (progn (setq arg (- arg 1)) (> arg 0))
-      (caml-find-region))
-    (indent-region beg (point) nil))))
+; (defun caml-indent-phrase (arg)
+;   (interactive "p")
+;   (save-excursion
+;     (let ((beg (caml-find-phrase)))
+;     (while (progn (setq arg (- arg 1)) (> arg 0))
+;       (caml-find-region))
+;     (indent-region beg (point) nil))))
 
 (defun caml-indent-buffer ()
   (interactive)



reply via email to

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