* bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline
@ 2012-08-13 0:32 Leo
2012-08-15 14:42 ` Alan Mackenzie
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Leo @ 2012-08-13 0:32 UTC (permalink / raw)
To: 12188; +Cc: bug-cc-mode
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline
2012-08-13 0:32 bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline Leo
@ 2012-08-15 14:42 ` Alan Mackenzie
2012-08-15 17:41 ` Glenn Morris
[not found] ` <20120815144233.GA4016__1127.2007170648$1345042054$gmane$org@acm.acm>
2012-09-16 22:44 ` Leo
2 siblings, 1 reply; 8+ messages in thread
From: Alan Mackenzie @ 2012-08-15 14:42 UTC (permalink / raw)
To: Leo; +Cc: 12188
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).
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline
2012-08-15 14:42 ` Alan Mackenzie
@ 2012-08-15 17:41 ` Glenn Morris
0 siblings, 0 replies; 8+ messages in thread
From: Glenn Morris @ 2012-08-15 17:41 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: Leo, 12188
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"
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline
[not found] ` <20120815144233.GA4016__1127.2007170648$1345042054$gmane$org@acm.acm>
@ 2012-08-15 22:44 ` Leo
2012-08-17 21:05 ` Alan Mackenzie
2012-08-18 19:57 ` Alan Mackenzie
0 siblings, 2 replies; 8+ messages in thread
From: Leo @ 2012-08-15 22:44 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: 12188
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline
2012-08-15 22:44 ` Leo
@ 2012-08-17 21:05 ` Alan Mackenzie
2012-08-18 19:57 ` Alan Mackenzie
1 sibling, 0 replies; 8+ messages in thread
From: Alan Mackenzie @ 2012-08-17 21:05 UTC (permalink / raw)
To: Leo; +Cc: 12188
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).
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline
2012-08-15 22:44 ` Leo
2012-08-17 21:05 ` Alan Mackenzie
@ 2012-08-18 19:57 ` Alan Mackenzie
2012-08-19 0:54 ` Leo
1 sibling, 1 reply; 8+ messages in thread
From: Alan Mackenzie @ 2012-08-18 19:57 UTC (permalink / raw)
To: Leo; +Cc: 12188
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).
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline
2012-08-18 19:57 ` Alan Mackenzie
@ 2012-08-19 0:54 ` Leo
0 siblings, 0 replies; 8+ messages in thread
From: Leo @ 2012-08-19 0:54 UTC (permalink / raw)
To: Alan Mackenzie; +Cc: 12188
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline
2012-08-13 0:32 bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline Leo
2012-08-15 14:42 ` Alan Mackenzie
[not found] ` <20120815144233.GA4016__1127.2007170648$1345042054$gmane$org@acm.acm>
@ 2012-09-16 22:44 ` Leo
2 siblings, 0 replies; 8+ messages in thread
From: Leo @ 2012-09-16 22:44 UTC (permalink / raw)
To: 12188-done
Already fixed; closing.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-09-16 22:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-13 0:32 bug#12188: 24.1; awk-mode eletric { incorrectly inserts newline Leo
2012-08-15 14:42 ` Alan Mackenzie
2012-08-15 17:41 ` Glenn Morris
[not found] ` <20120815144233.GA4016__1127.2007170648$1345042054$gmane$org@acm.acm>
2012-08-15 22:44 ` Leo
2012-08-17 21:05 ` Alan Mackenzie
2012-08-18 19:57 ` Alan Mackenzie
2012-08-19 0:54 ` Leo
2012-09-16 22:44 ` Leo
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).