From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Barry OReilly <gundaetiapo@gmail.com>
Cc: 14281@debbugs.gnu.org
Subject: bug#14281: 24.3; replace-match leaves point at wrong place
Date: Thu, 09 May 2013 17:27:10 -0400 [thread overview]
Message-ID: <jwvppwz6gz1.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CAFM41H0Z_R-2M7v-_PDqubOiwc5k-79HOtkgq5FN6d1phU488Q@mail.gmail.com> (Barry OReilly's message of "Thu, 9 May 2013 15:07:51 -0400")
> I reproduced the issue again and investigated. Since I'm unsure how to
> determine information about the Lisp system within GDB, I used debug
> statements in C and Lisp to arrive at the following description of what
> happens, additive to my previous description:
> My after-change-functions, in order, are:
> semantic-change-function
> c-after-change
> jit-lock-after-change
> search_regs.start[0] first takes on the incorrect value inside
> c-after-change's call to save-match-data. Since c-after-change code seems
> correct, I determined that the match-data function begins returning the
> incorrect value during semantic-change-function. I am using CEDET r8557.
Not sure what CEDET r8557 does, but at least the CEDET code in Emacs's
trunk is pretty simple in this respect: semantic-change-function only
runs the semantic-change-functions hook, and grep seems to indicate that
this hook is never modified, so the whole thing should never get
anywhere near the match-data.
Note that there are other change functions than after-change-functions.
There's also before-change-functions and there are overlays's
modification-hooks. You might like to check those as well.
>>> I suppose that caveat would pin the bug on one of the third party
>>> packages I use. However, why couldn't Emacs save off the match-data
>>> itself and restore it after the after-change-functions? Is there any
>>> legit situation where a change hook would want to change the
>>> match-data in effect after the change hook returns?
Stefan> There are many cases where an after-change-function won't use regular
Stefan> expressions at all.
> The answer doesn't seem to fit the question, so I'll rephrase: Why does
> Emacs allow after-change-functions to change the match-data beyond its
> scope? Or: why doesn't the signal_after_change C function do like
> set-match-data instead of leaving it to client change hooks to do so?
Because it wastes time in most cases (when after-change-functions
won't use regular expressions at all).
Maybe we could add code that saves just the (match-beginning 0) and
signals an error if it was not properly preserved. This would still
require change-functions to save the match-data if they use it, but it
might catch the offenders earlier.
Stefan
next prev parent reply other threads:[~2013-05-09 21:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-27 1:19 bug#14281: 24.3; replace-match leaves point at wrong place Barry OReilly
2013-05-09 19:07 ` Barry OReilly
2013-05-09 21:27 ` Stefan Monnier [this message]
2013-05-10 13:27 ` Barry OReilly
2013-05-10 18:19 ` Barry OReilly
2013-05-10 20:56 ` Stefan Monnier
2013-05-14 17:01 ` Barry OReilly
2013-05-15 15:03 ` Barry OReilly
2013-05-15 19:18 ` Stefan Monnier
2013-05-15 20:44 ` Barry OReilly
2013-05-15 20:58 ` Barry OReilly
2013-05-21 21:49 ` Stefan Monnier
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvppwz6gz1.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=14281@debbugs.gnu.org \
--cc=gundaetiapo@gmail.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 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).