bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#12274: 24.2; awk-mode indentation failure


From: Alan Mackenzie
Subject: bug#12274: 24.2; awk-mode indentation failure
Date: Fri, 25 Jan 2013 08:44:44 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hello, Leo.

On Fri, Jan 25, 2013 at 09:20:19AM +0800, Leo Liu wrote:

[ .... ]

> Alan, I also have another seemingly buglet about indentation.

As Glenn remarked, this is bug #12274.

> Every line after a pattern-action pair like the following one (where
> action is omitted) is indented to column 4, i.e. it doesn't recognise a
> newline terminates a pattern.

> $0 == "Emacs"
>     |
>     all following lines indented here

> (this might be regression, I seem to recall reporting something along
> these lines some while ago.)

No, not a regression, rather a bug which has been there since 4004 BC.
It's actually the "=" sign which triggers it, confusing the parsing
algortihm into thinking it's a C initialisation statement.

The solution is to move the pertinent AWK parsing clause earlier on in
the enclosing cond form.

Glenn, this is not a regression.  Should I nevertheless commit it to the
emacs-24 branch?

Here's the patch:


diff -r 0d641a4d3e7c cc-engine.el
--- a/cc-engine.el      Wed Jan 23 18:17:40 2013 +0000
+++ b/cc-engine.el      Fri Jan 25 08:27:12 2013 +0000
@@ -9880,6 +9880,18 @@
            ;; contains any class offset
            )))
 
+        ;; CASE 5P: AWK pattern or function or continuation
+        ;; thereof.
+        ((c-major-mode-is 'awk-mode)
+         (setq placeholder (point))
+         (c-add-stmt-syntax
+          (if (and (eq (c-beginning-of-statement-1) 'same)
+                   (/= (point) placeholder))
+              'topmost-intro-cont
+            'topmost-intro)
+          nil nil
+          containing-sexp paren-state))
+
         ;; CASE 5D: this could be a top-level initialization, a
         ;; member init list continuation, or a template argument
         ;; list continuation.
@@ -10039,18 +10051,6 @@
              (goto-char (point-min)))
          (c-add-syntax 'objc-method-intro (c-point 'boi)))
 
-        ;; CASE 5P: AWK pattern or function or continuation
-        ;; thereof.
-        ((c-major-mode-is 'awk-mode)
-         (setq placeholder (point))
-         (c-add-stmt-syntax
-          (if (and (eq (c-beginning-of-statement-1) 'same)
-                   (/= (point) placeholder))
-              'topmost-intro-cont
-            'topmost-intro)
-          nil nil
-          containing-sexp paren-state))
-
         ;; CASE 5N: At a variable declaration that follows a class
         ;; definition or some other block declaration that doesn't
         ;; end at the closing '}'.  C.f. case 5D.5.

> Leo

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

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