From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kalle Olavi Niemitalo Newsgroups: gmane.emacs.devel Subject: Re: Why is `after-change-functions' reset? Date: Tue, 18 Feb 2014 00:11:49 +0200 Message-ID: <87bny58k4a.fsf@Niukka.kon.iki.fi> References: <878ut9r3ik.fsf@web.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1392682688 24551 80.91.229.3 (18 Feb 2014 00:18:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Feb 2014 00:18:08 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 18 01:18:15 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WFYO7-0006kL-8H for ged-emacs-devel@m.gmane.org; Tue, 18 Feb 2014 01:18:15 +0100 Original-Received: from localhost ([::1]:45088 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFYO6-0004b1-Ma for ged-emacs-devel@m.gmane.org; Mon, 17 Feb 2014 19:18:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFWON-0006Wa-9Z for emacs-devel@gnu.org; Mon, 17 Feb 2014 17:10:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFWOD-0001Q1-Pv for emacs-devel@gnu.org; Mon, 17 Feb 2014 17:10:23 -0500 Original-Received: from sirokuusama.dnainternet.net ([83.102.40.133]:53946) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFWOD-0001GV-Ia for emacs-devel@gnu.org; Mon, 17 Feb 2014 17:10:13 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by sirokuusama.dnainternet.net (Postfix) with ESMTP id A99C4401B6 for ; Tue, 18 Feb 2014 00:10:03 +0200 (EET) X-Virus-Scanned: DNA Postiturva at dnainternet.net Original-Received: from sirokuusama.dnainternet.net ([83.102.40.133]) by localhost (sirokuusama.dnainternet.net [127.0.0.1]) (DNA Postiturva, port 10041) with ESMTP id 1NQfnuGeX3Ns for ; Tue, 18 Feb 2014 00:10:03 +0200 (EET) Original-Received: from kirsikkapuu.dnainternet.net (kirsikkapuu.dnainternet.net [83.102.40.214]) by sirokuusama.dnainternet.net (Postfix) with ESMTP id 4DCCF3FBA3 for ; Tue, 18 Feb 2014 00:10:03 +0200 (EET) Original-Received: from Niukka.Niemitalo.private (85-23-27-133.bb.dnainternet.fi [85.23.27.133]) by kirsikkapuu.dnainternet.net (Postfix) with ESMTP id 313855FA99 for ; Tue, 18 Feb 2014 00:10:02 +0200 (EET) User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.51 (gnu/linux) X-Accept-Language: fi;q=1.0, en;q=0.9, sv;q=0.5, de;q=0.1 In-Reply-To: <878ut9r3ik.fsf@web.de> (Michael Heerdegen's message of "Mon, 17 Feb 2014 19:35:31 +0100") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 83.102.40.133 X-Mailman-Approved-At: Mon, 17 Feb 2014 19:18:12 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:169728 Archived-At: Michael Heerdegen 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 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.