unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kalle Olavi Niemitalo <kon@iki.fi>
To: Emacs developers <emacs-devel@gnu.org>
Subject: Re: Why is `after-change-functions' reset?
Date: Tue, 18 Feb 2014 00:11:49 +0200	[thread overview]
Message-ID: <87bny58k4a.fsf@Niukka.kon.iki.fi> (raw)
In-Reply-To: <878ut9r3ik.fsf@web.de> (Michael Heerdegen's message of "Mon, 17 Feb 2014 19:35:31 +0100")

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Evaluate it and hit tab (for completion) and C-g C-g in succession.
> When you repeat this a few times, you get "Why does this happen?".

I debugged this a bit, with my custom Emacs 23.0.51.  I don't
know how much this machinery has changed in later versions.
Emacs set Vquit_flag at:

  handle_interrupt
  tty_read_avail_input
  read_avail_input
  handle_async_input
  input_available_signal
  <signal handler called>
  mark_object
  Fgarbage_collect
  Ffuncall
  run_hook_list_with_args
  signal_after_change
  Fadd_text_properties
  Fput_text_property
  Fdisplay_completion_list
  internal_with_output_to_temp_buffer
  Fminibuffer_completion_help
  do_completion
  Fminibuffer_complete
  Ffuncall
  Fcall_interactively

After Fgarbage_collect returned, Ffuncall called funcall_lambda,
in which the QUIT macro detected the non-nil value of Vquit_flag
and called Fsignal (Qquit, Qnil).  Because the quit was signaled
within signal_after_change, after-change-functions were not
restored.

I don't see any reasonable way to prevent after-change-functions
from being reset like this.

> In my original situation, quitting was not involved, the above
> recipe was just the first reproducible program I had discovered.

Perhaps you could change your Emacs to break when the reset
happens, and always run it in a debugger.  Make
signal_before_change and signal_after_change maintain some kind
of flag or nesting counter, and set conditional breakpoints in
Fthrow and Fsignal.  That will get a false positive if the error
is caught within the hook; but I don't think it happens often.



  reply	other threads:[~2014-02-17 22:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-17 18:35 Why is `after-change-functions' reset? Michael Heerdegen
2014-02-17 22:11 ` Kalle Olavi Niemitalo [this message]
2014-02-18 17:50   ` Michael Heerdegen
2014-02-17 23:49 ` Stefan Monnier
2014-02-17 23:57   ` Michael Heerdegen

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=87bny58k4a.fsf@Niukka.kon.iki.fi \
    --to=kon@iki.fi \
    --cc=emacs-devel@gnu.org \
    /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).