From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 5b5f441: read_key_sequence: correct the handling of raw_keybuf in recursive calls Date: Mon, 20 Nov 2017 16:43:52 -0500 Message-ID: References: <20171120181209.23553.97060@vcs0.savannah.gnu.org> <20171120181210.7946F20416@vcs0.savannah.gnu.org> <20171120195918.GB3917@ACM> <20171120203004.GC3917@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1511214291 3655 195.159.176.226 (20 Nov 2017 21:44:51 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 20 Nov 2017 21:44:51 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 20 22:44:45 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eGtru-0000Pz-Fc for ged-emacs-devel@m.gmane.org; Mon, 20 Nov 2017 22:44:42 +0100 Original-Received: from localhost ([::1]:59903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGts1-0003Ab-V8 for ged-emacs-devel@m.gmane.org; Mon, 20 Nov 2017 16:44:49 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGtrW-0003AL-4B for emacs-devel@gnu.org; Mon, 20 Nov 2017 16:44:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGtrT-0004Uq-0w for emacs-devel@gnu.org; Mon, 20 Nov 2017 16:44:18 -0500 Original-Received: from [195.159.176.226] (port=40350 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eGtrS-0004UO-Pt for emacs-devel@gnu.org; Mon, 20 Nov 2017 16:44:14 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eGtrG-0006QH-B7 for emacs-devel@gnu.org; Mon, 20 Nov 2017 22:44:02 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 35 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:X12zkfGm0+LWIBgpClOTel6k6tI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:220315 Archived-At: >> But this `read_char` is within read_key_sequence: this read_key_sequence >> may have been called from anywhere, .... > read_key_sequence is static in keyboard.c, and is called from precisely > three places: command_loop_1, read_key_sequence_vs, and > read_menu_command. Right: the middle one corresponds to `read-key-sequence` which can be called from "anywhere" (i.e. Elisp). >> .... so after we exit it (non-locally), we may end up running >> arbitrary Elisp code before we return to command_loop_1, can't we? > Is it possible to exit non-locally from read_char (or one of its called > subroutines)? `read_char` will run timers and process filters. See for example `read-key` which calls `read-key-sequence` with a timer that makes it exit by throwing `read-key` as soon as one key is detected. > You have a point, here. Perhaps it would be better to get storage from > the Emacs heap rather than using the stack. I like using the stack, here, actually. Maybe another option is to make raw_keybuf local to read_key_sequence, and to *copy* it into the global raw_keybuf_buffer just before exiting. Stefan PS: Of course, even better would be to provide another way to get what `this-single-command-raw-keys` returns, so we don't need to use a global variable for it. E.g. have `read-key-sequence` return both the key sequence and the raw key sequence. But we'd still have to support `this-single-command-raw-keys` for the foreseeable future anyway.