From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: read_char() does not detect, handle special-event-map buffer changes Date: Mon, 11 Feb 2013 14:22:06 -0500 Message-ID: References: <87r4kwjx11.fsf@priss.frightenedpiglet.com> <87lib01vlp.fsf@priss.frightenedpiglet.com> <87k3qk18m6.fsf@priss.frightenedpiglet.com> <87haln1ks1.fsf@priss.frightenedpiglet.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1360610534 2650 80.91.229.3 (11 Feb 2013 19:22:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 Feb 2013 19:22:14 +0000 (UTC) Cc: emacs-devel@gnu.org To: Derek Upham Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 11 20:22:35 2013 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 1U4yxX-0007ad-C5 for ged-emacs-devel@m.gmane.org; Mon, 11 Feb 2013 20:22:35 +0100 Original-Received: from localhost ([::1]:36470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4yxD-0001e0-Pi for ged-emacs-devel@m.gmane.org; Mon, 11 Feb 2013 14:22:15 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:42997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4yxB-0001dv-93 for emacs-devel@gnu.org; Mon, 11 Feb 2013 14:22:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U4yx9-0005sg-UT for emacs-devel@gnu.org; Mon, 11 Feb 2013 14:22:13 -0500 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:54697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4yx9-0005sE-Px for emacs-devel@gnu.org; Mon, 11 Feb 2013 14:22:11 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EABK/CFFFpZnt/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtjQ+DewOIYZZ7hR6BXoMVgVE X-IPAS-Result: Av4EABK/CFFFpZnt/2dsb2JhbABEvw4Xc4IeAQEEAVYjBQsLDiYSFBgNJIgeBsEtjQ+DewOIYZZ7hR6BXoMVgVE X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="997709" Original-Received: from 69-165-153-237.dsl.teksavvy.com (HELO pastel.home) ([69.165.153.237]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 11 Feb 2013 14:22:07 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 6692B59255; Mon, 11 Feb 2013 14:22:06 -0500 (EST) In-Reply-To: <87haln1ks1.fsf@priss.frightenedpiglet.com> (Derek Upham's message of "Thu, 07 Feb 2013 20:39:42 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 206.248.154.182 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:156971 Archived-At: > Did you see my comment in the original email? read_char() is already > trying to detect changed keymaps. > if (current_buffer != prev_buffer) > { > /* The command may have changed the keymaps. Pretend there > is input in another keyboard and return. This will > recalculate keymaps. */ > c = make_number (-2); > goto exit; > } > else > goto retry; > The bug is happening because the test is flawed: current_buffer and > prev_buffer are the same, so Emacs doesn't think it needs to recalculate > anything. It loops back to the top of read_char() and reads another > character with the same keymap. I know, but I'm still weary of the possible side-effects. The change I was proposing (to delay computation of the set of active keymaps to after we got the first event) also has the advantage that it is not specific to special-event-map, so it's desirable in any case. > This removes a flawed optimization and returns a documented value. The main issue is that it's not clear what should happen if you switch buffers in the middle (rather than before the beginning) of a key sequence. And I'd rather not have to think about it ;-) > It doesn't touch read_key_sequence, so that risk goes away. I've just installed a patch (in trunk) which touches read_key_sequence intrusively (in case you still had doubts whether I was a masochist). This should hopefully fix your problem (at least it fixes the sigusr1-handler test case you sent). It also cleans up the code a bit. Hopefully it doesn't introduce too many new problems. Stefan