all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Dietrich Epp <dietrich@zdome.net>
Cc: 13244@debbugs.gnu.org
Subject: bug#13244: cc-mode indentation fails depending on the phase of the moon
Date: Thu, 27 Dec 2012 16:20:54 +0000	[thread overview]
Message-ID: <20121227162054.GA3235@acm.acm> (raw)
In-Reply-To: <7067FC50-22E1-4FF5-B634-A9062EF2849A@zdome.net>

Hello, Dietrich.

>This bug is weird.  I couldn't use auto-indentation in a certain file.
>I tried restarting Emacs, behavior persists.  I upgraded to the latest
>version from Bzr, behavior persists.  I created a new account with no
>.emacs file and tried from there, behavior persists.  In comparison,
>indentation works correctly in the Emacs that in the current Debian
>Wheezy repository, which is 24.3.50.1.

>Trying to automatically indent code inside the last function in the
>attached file fails.  It succeeds if I make almost any modification to
>code above the last function in the file -- it could be something as
>minor as adding a space on an empty line, but changing text in the
>comments seems to have no effect.  Indentation works in every function
>but the last one (or any one you create below it).

>The point at which indentation breaks is somewhere very close to the
>bottom of the file, I deleted code from the bottom of the file until I
>found the location where it breaks.

What is happening is this: CC Mode maintains a cache of "safe positions"
(i.e. positions not in a string or comment) approximately every 3000
bytes.  By pure chance, one of these supposed positions in your file is
at pos. 21002, which happens to be between the "/" and the "*" of the
comment opener on L836.  This position isn't safe at all, and is found
due to a bug in a low level scanning routine (`parse-partial-sexp') in
Emacs.

Furthermore, that comment contains an "unbalanced" "'".  So when CC Mode
scans forward from that supposed safe position, it finds the "'" and
thinks it's inside a string.  This is why indentation isn't working in
your file after that comment.

As you've noted, the slightest change to the buffer and the error no
longer happens (since the "safe" position is no longer inside the
comment opener).

Thank you very much indeed for taking the trouble to report this arcane
bug.  We actually noticed the possibility of this bug in December 2011
and discussed it a bit, but nobody actually got around to fixing it
then.  Maybe we should now.

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2012-12-27 16:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-21  1:06 bug#13244: cc-mode indentation fails depending on the phase of the moon Dietrich Epp
2012-12-27 16:20 ` Alan Mackenzie [this message]
2013-03-11 20:57   ` 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=20121227162054.GA3235@acm.acm \
    --to=acm@muc.de \
    --cc=13244@debbugs.gnu.org \
    --cc=dietrich@zdome.net \
    /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.