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

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

bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline


From: Alan Mackenzie
Subject: bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline
Date: Sat, 18 Aug 2012 19:57:55 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hello, Leo.

On Thu, Aug 16, 2012 at 06:44:27AM +0800, Leo wrote:
> On 2012-08-15 22:42 +0800, Alan Mackenzie wrote:
> > The current assumption is that the "{" starts the action for the pattern
> > "NR==3".

> syntax after NR==3 is not recognised as `defun-open' which causes { to
> be inserted in a new line. I think there is a bug somewhere (probably
> c-guess-basic-syntax) regarding this.

It wasn't as bad as I thought.  Other patterns (not involving "==")
correctly insert a newline _after_ (not before) a "{" is typed.
c-guess-basic-syntax was mis-parsing the "==" as an equals sign, hence
parsed the "{" as a brace-block opener rather than defun-open.

This patch should fix it.  Would you try it out, please, and report back.
Thanks!



diff -r 1adcc48506f9 cc-cmds.el
--- a/cc-cmds.el        Sun Apr 22 09:42:29 2012 +0000
+++ b/cc-cmds.el        Sat Aug 18 19:41:01 2012 +0000
@@ -495,13 +495,16 @@
       (insert-char ?\n 1)
       ;; In AWK (etc.) or in a macro, make sure this CR hasn't changed
       ;; the syntax.  (There might already be an escaped NL there.)
-      (when (or (c-at-vsemi-p (1- (point)))
-               (let ((pt (point)))
-                 (save-excursion
-                   (backward-char)
-                   (and (c-beginning-of-macro)
-                        (progn (c-end-of-macro)
-                               (< (point) pt))))))
+      (when (or
+            (save-excursion
+              (c-skip-ws-backward (c-point 'bopl))
+              (c-at-vsemi-p))
+            (let ((pt (point)))
+              (save-excursion
+                (backward-char)
+                (and (c-beginning-of-macro)
+                     (progn (c-end-of-macro)
+                            (< (point) pt))))))
        (backward-char)
        (insert-char ?\\ 1)
        (forward-char))
diff -r 1adcc48506f9 cc-engine.el
--- a/cc-engine.el      Sun Apr 22 09:42:29 2012 +0000
+++ b/cc-engine.el      Sat Aug 18 19:41:01 2012 +0000
@@ -9606,12 +9606,12 @@
                             (setq tmpsymbol nil)
                             (while (and (> (point) placeholder)
                                         (zerop (c-backward-token-2 1 t))
-                                        (/= (char-after) ?=))
+                                        (not (looking-at "=\\([^=]\\|$\\)")))
                               (and c-opt-inexpr-brace-list-key
                                    (not tmpsymbol)
                                    (looking-at c-opt-inexpr-brace-list-key)
                                    (setq tmpsymbol 'topmost-intro-cont)))
-                            (eq (char-after) ?=))
+                            (looking-at "=\\([^=]\\|$\\)"))
                           (looking-at c-brace-list-key))
                       (save-excursion
                         (while (and (< (point) indent-point)



> Leo

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

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