]> git.eshelyaron.com Git - emacs.git/commitdiff
CC Mode: In brace lists, anchor an elt on its predecessor, not on first elt
authorAlan Mackenzie <acm@muc.de>
Sat, 9 Jun 2018 17:34:46 +0000 (17:34 +0000)
committerAlan Mackenzie <acm@muc.de>
Sat, 9 Jun 2018 17:34:46 +0000 (17:34 +0000)
* lisp/progmodes/cc-engine.el (c-beginning-of-statement-1): At the end, accept
"." as a unary operator (which it now is in brace lists in, e.g., C Mode).
(c-guess-basic-syntax): Just before CASE 9C, move back to the previous brace
list entry in the block, rather than to the first one.

lisp/progmodes/cc-engine.el

index d1380ff6f6965ef4463357a5e83fb29359841162..3d9e4fa0d3563ef1dfc27b6c86fc83434e210d14 100644 (file)
@@ -1282,7 +1282,7 @@ comment at the start of cc-engine.el for more info."
               (c-backward-syntactic-ws)
               ;; protect AWK post-inc/decrement operators, etc.
               (and (not (c-at-vsemi-p (point)))
-                   (/= (skip-chars-backward "-+!*&~@`#") 0)))
+                   (/= (skip-chars-backward "-.+!*&~@`#") 0)))
        (setq pos (point)))
       (goto-char pos)
       ret)))
@@ -12608,18 +12608,21 @@ comment at the start of cc-engine.el for more info."
            (c-add-stmt-syntax 'brace-list-close nil t lim paren-state)))
 
         (t
-         ;; Prepare for the rest of the cases below by going to the
-         ;; token following the opening brace
-         (if (consp special-brace-list)
-             (progn
-               (goto-char (car (car special-brace-list)))
-               (c-forward-token-2 1 nil indent-point))
-           (goto-char containing-sexp))
-         (forward-char)
-         (let ((start (point)))
-           (c-forward-syntactic-ws indent-point)
-           (goto-char (max start (c-point 'bol))))
-         (c-skip-ws-forward indent-point)
+         ;; Prepare for the rest of the cases below by going back to the
+         ;; previous entry, or BOI before that, providing that this is
+         ;; inside the enclosing brace.
+         (goto-char indent-point)
+         (c-beginning-of-statement-1 containing-sexp nil nil t)
+         (when (/= (point) indent-point)
+           (if (> (c-point 'boi) containing-sexp)
+               (goto-char (c-point 'boi))
+             (if (consp special-brace-list)
+                 (progn
+                   (goto-char (caar special-brace-list))
+                   (c-forward-token-2 1 nil indent-point))
+               (goto-char containing-sexp))
+             (forward-char)
+             (c-skip-ws-forward indent-point)))
          (cond
 
           ;; CASE 9C: we're looking at the first line in a brace-list