GNU bug report logs -
#12188
24.1; awk-mode eletric { incorrectly inserts newline
Previous Next
Reported by: Leo <sdl.web <at> gmail.com>
Date: Mon, 13 Aug 2012 00:42:01 UTC
Severity: minor
Found in version 24.1
Done: Leo <sdl.web <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12188 in the body.
You can then email your comments to 12188 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-cc-mode <at> gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#12188
; Package
emacs
.
(Mon, 13 Aug 2012 00:42:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Leo <sdl.web <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-cc-mode <at> gnu.org, bug-gnu-emacs <at> gnu.org
.
(Mon, 13 Aug 2012 00:42:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
1. emacs -q x.awk
2. C-c C-a to enable auto-newline mode
3. Type: NR==3 {
You should see { starts at a new line instead of following NR==3, i.e. {
helps creating incorrect awk programs.
Leo
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#12188
; Package
emacs,cc-mode
.
(Wed, 15 Aug 2012 14:56:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 12188 <at> debbugs.gnu.org (full text, mbox):
Hello, Leo,
On Mon, Aug 13, 2012 at 08:32:18AM +0800, Leo wrote:
> 1. emacs -q x.awk
> 2. C-c C-a to enable auto-newline mode
> 3. Type: NR==3 {
> You should see { starts at a new line instead of following NR==3, i.e. {
> helps creating incorrect awk programs.
The current assumption is that the "{" starts the action for the pattern
"NR==3".
Although the implicit action (i.e., print the line) isn't rare, having
such a line followed by the implicit pattern (i.e., match everything) is
surely uncommon enough not to make it the default assumption.
I think this default is fine as it is. It is, of course, possible to
configure auto newlines to behave as you suggest.
> Leo
--
Alan Mackenzie (Nuremberg, Germany).
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#12188
; Package
emacs,cc-mode
.
(Wed, 15 Aug 2012 17:51:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 12188 <at> debbugs.gnu.org (full text, mbox):
Alan Mackenzie wrote:
> The current assumption is that the "{" starts the action for the pattern
> "NR==3".
I think that's his point (it sure would be helpful to get less terse bug
reports). awk-mode is not consistent with that assumption.
cat foo.awk:
#!/usr/bin/gawk -f
NF == 3
{
print "three fields"
}
chmod 755 foo.awk
echo "1 2" | ./foo.awk
-> three fields
To work correctly, it needs to be either:
NF == 3 \
{
print "three fields"
}
or
NF == 3 {
print "three fields"
}
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#12188
; Package
emacs,cc-mode
.
(Wed, 15 Aug 2012 22:54:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 12188 <at> debbugs.gnu.org (full text, mbox):
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.
Leo
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#12188
; Package
emacs,cc-mode
.
(Fri, 17 Aug 2012 21:19:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 12188 <at> debbugs.gnu.org (full text, mbox):
Hello, Leo and Glenn.
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".
I got confused by the "should" in your original report. Sorry. Yes, it
is a bug, and thanks for the report.
> 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.
In AWK Mode, the recognition of a beginning-of-defun (for C-M-a) is done
heuristically. c-guess-b-s can't detect an AWK defun-open.
Which all means the solution will be messy and heuristic too. <sigh>.
> Leo
--
Alan Mackenzie (Nuremberg, Germany).
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#12188
; Package
emacs,cc-mode
.
(Sat, 18 Aug 2012 20:03:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 12188 <at> debbugs.gnu.org (full text, mbox):
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).
Information forwarded
to
bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org
:
bug#12188
; Package
emacs,cc-mode
.
(Sun, 19 Aug 2012 00:55:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 12188 <at> debbugs.gnu.org (full text, mbox):
On 2012-08-19 03:57 +0800, Alan Mackenzie wrote:
> This patch should fix it. Would you try it out, please, and report back.
> Thanks!
It worked. Thanks.
Leo
Reply sent
to
Leo <sdl.web <at> gmail.com>
:
You have taken responsibility.
(Sun, 16 Sep 2012 22:46:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Leo <sdl.web <at> gmail.com>
:
bug acknowledged by developer.
(Sun, 16 Sep 2012 22:46:03 GMT)
Full text and
rfc822 format available.
Message #28 received at 12188-done <at> debbugs.gnu.org (full text, mbox):
Already fixed; closing.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 15 Oct 2012 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 12 years and 204 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.