From: Alan Mackenzie <acm@muc.de>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 18826@debbugs.gnu.org
Subject: bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table
Date: 25 Oct 2014 23:24:49 -0000 [thread overview]
Message-ID: <20141025232449.90894.qmail@mail.muc.de> (raw)
In-Reply-To: <mailman.12048.1414277182.1147.bug-gnu-emacs@gnu.org>
Hello, Dmitry.
In article <mailman.12048.1414277182.1147.bug-gnu-emacs@gnu.org> you wrote:
> On 10/26/2014 02:34 AM, Alan Mackenzie wrote:
>> Why do you think it should be harmless?
> Because the syntax table change is temporary and its effect should be
> limited to my code?
It's no so limited. The before-change-functions and after-change-functions
hooks will be run with that syntax table active. This is not good.
>> . The c-in-sws and c-is-sws indicate that the semicolon has been
>> recognised and marked as syntactic whitespace. The second line thus gets
>> parsed as "statement-cont", i.e. a continued statement, so it gets
>> indented an extra level.
> Yes, I see that. But how does this happen?
Somewhere in a before- or after-change-functions, c-backward-sws is being
called, to go backward over syntactic whitespace. Somehow it gets
horribly confused, because the syntax table isn't correct. I don't think
the exact details matter too much here.
>> If you cripple C++ Mode by substituting a wrong syntax table, you
>> shouldn't be too surprised when things go "wrong". This seems like one of
>> these "well, don't do that, then" bugs.
>> Question: why do you want to play around with the syntax table in this
>> manner? What are you trying to achieve?
> I'm using a different syntax table for sexp movement, where it's
> necessary for both parens and angle brackets to have paren syntax class.
> In the actual code I modify the text after it's inserted, and
> `backward-sexp' is used two times to find necessary search bounds.
OK. Can I suggest an alternative? In C++ (and Java) Modes, the template
(generic) delimiters are marked with syntax-table text properties.
Unfortunately, at the moment this is done as part of font-locking, so
isn't done until you display. However, if you put "(sit-for 0)" into
your code after inserting "< ... >", this will cause a redisplay,
allowing subsequent code to use the text properties, and a backward-sexp
will then work.
In the medium future (several weeks away), I'm hoping to fix CC Mode so
that the text properties are applied to < ... > on an after-change
function rather than at redisplay.
> https://github.com/company-mode/company-mode/blob/42012730da15ffaef7c61722475040babed15332/company-template.el#L155-L173
-- Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2014-10-25 23:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-25 14:25 bug#18826: 24.3.94; c++-mode bad indentation after programmatic insert with locally changed syntax table Dmitry Gutov
[not found] ` <mailman.12024.1414247237.1147.bug-gnu-emacs@gnu.org>
2014-10-25 19:34 ` Alan Mackenzie
2014-10-25 22:45 ` Dmitry Gutov
[not found] ` <mailman.12048.1414277182.1147.bug-gnu-emacs@gnu.org>
2014-10-25 23:24 ` Alan Mackenzie [this message]
2014-10-26 15:09 ` Dmitry Gutov
2014-10-26 17:07 ` Stefan Monnier
2014-10-25 23:25 ` Stefan Monnier
[not found] ` <jwv61f7ohq0.fsf-monnier+emacsbugs@gnu.org>
2014-10-26 14:56 ` Dmitry Gutov
2014-10-26 14:56 ` Dmitry Gutov
2014-10-26 17:03 ` Stefan Monnier
[not found] ` <mailman.12080.1414336227.1147.bug-gnu-emacs@gnu.org>
2014-10-26 17:38 ` Alan Mackenzie
2014-10-27 1:06 ` Dmitry Gutov
2014-10-27 8:53 ` Alan Mackenzie
2014-10-27 10:21 ` Dmitry Gutov
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=20141025232449.90894.qmail@mail.muc.de \
--to=acm@muc.de \
--cc=18826@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
/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.