From: Alan Mackenzie <acm@muc.de>
To: Michael Welsh Duggan <mwd@md5i.com>
Cc: 18749@debbugs.gnu.org
Subject: bug#18749: 24.3.94; CC Mode 5.32.5 (C/l); cc-mode state cache failure leading to bad indentation
Date: Fri, 17 Oct 2014 20:12:05 +0000 [thread overview]
Message-ID: <20141017201205.GA2766@acm.acm> (raw)
In-Reply-To: <20141017181950.4855.qmail@acm.muc.de>
Hello, Michael.
On Fri, Oct 17, 2014 at 06:19:50PM -0000, Alan Mackenzie wrote:
> > A consistent c-mode indentation error that causes bad indentation, much
> > cursing, and gnashing of teeth. This occurs in the latest emacs-24
> > branch (and trunk).
[ .... ]
> > M-x c-toggle-parse-state-debug
> > C-x C-f rwuniqsetup.c.before.2
> > C-s ipaddr_rec_to_bin RET
> > C-v
> > At this point, indentation is having problems. Try hitting TAB on line
> > 1371, for example. Or line 1374 for a complete failure to indent at
> > all.
[ .... ]
> Look forward to a patch soon!
OK, Could you try this, please, and get back to me ASAP. Thanks!
diff -r a785658eaedb cc-engine.el
--- a/cc-engine.el Thu Oct 02 20:17:43 2014 +0000
+++ b/cc-engine.el Fri Oct 17 19:58:19 2014 +0000
@@ -254,6 +254,24 @@
(setq c-macro-cache-start-pos beg
c-macro-cache-syntactic nil))))
+(defun c-macro-is-genuine-p ()
+ ;; Check that the ostensible CPP construct at point is a real one. In
+ ;; particular, if point is on the first line of a narrowed buffer, make sure
+ ;; that the "#" isn't, say, the second character of a "##" operator. Return
+ ;; t when the macro is real, nil otherwise.
+ (let ((here (point)))
+ (beginning-of-line)
+ (prog1
+ (if (and (eq (point) (point-min))
+ (/= (point) 1))
+ (save-restriction
+ (widen)
+ (beginning-of-line)
+ (and (looking-at c-anchored-cpp-prefix)
+ (eq (match-beginning 1) here)))
+ t)
+ (goto-char here))))
+
(defun c-beginning-of-macro (&optional lim)
"Go to the beginning of a preprocessor directive.
Leave point at the beginning of the directive and return t if in one,
@@ -284,7 +302,8 @@
(forward-line -1))
(back-to-indentation)
(if (and (<= (point) here)
- (looking-at c-opt-cpp-start))
+ (looking-at c-opt-cpp-start)
+ (c-macro-is-genuine-p))
(progn
(setq c-macro-cache (cons (point) nil)
c-macro-cache-start-pos here)
> > --
> > Michael Welsh Duggan
> > (md5i@md5i.com)
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2014-10-17 20:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-16 21:12 bug#18749: 24.3.94; CC Mode 5.32.5 (C/l); cc-mode state cache failure leading to bad indentation Michael Welsh Duggan
2014-10-17 18:19 ` Alan Mackenzie
2014-10-17 19:35 ` Stefan Monnier
2014-10-18 8:48 ` Alan Mackenzie
2014-10-18 19:11 ` Stefan Monnier
2014-10-17 20:12 ` Alan Mackenzie [this message]
[not found] ` <mailman.11430.1413622526.1147.bug-gnu-emacs@gnu.org>
2015-12-24 19:41 ` Alan Mackenzie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141017201205.GA2766@acm.acm \
--to=acm@muc.de \
--cc=18749@debbugs.gnu.org \
--cc=mwd@md5i.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.