Received: (at 76669) by debbugs.gnu.org; 2 Mar 2025 18:14:52 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 02 13:14:52 2025 Received: from localhost ([127.0.0.1]:34864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tonpz-00065r-0D for submit <at> debbugs.gnu.org; Sun, 02 Mar 2025 13:14:51 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34611) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1tonpw-00065I-6Z for 76669 <at> debbugs.gnu.org; Sun, 02 Mar 2025 13:14:48 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id E17BA44163E; Sun, 2 Mar 2025 13:14:40 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1740939279; bh=aEHd3AYx3YHRvPdQ27VxqihVjsCglRGfA01ry1fHaxY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=XNQwZmTgiCidFMCnFKtjAfkbtRgakgMpLUj51x89woO9rvmfIVToQbc4mGy0XxxRD WxhwlMePAqPOnxSLRrrd1My2TX7pIN/tl9Ythmr7gRTvYw61o2HsXI76soIKXxTu0k lje1ZQiFP5y8TP7mzJ9G2K+IcAscIbrXvV8NGP0uqT9xGYTsdlGXCS4jp4A8aFcECV GvSPS+ykUjVpLH4dvDesNWjINoq6SVB8v3w5VLhXqsLEx9AFB9B+vAdO1K4oNZhfVs sSqq+eSaBmj3GP1lSuGG4VmeP/OZHVDIkJ3Wq+PHcWo+p2pVZC9M12AWpInEk5sGLD 6DuQ13V7NgZSA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 8642D44102E; Sun, 2 Mar 2025 13:14:39 -0500 (EST) Received: from alfajor (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 56FEB12037B; Sun, 2 Mar 2025 13:14:39 -0500 (EST) From: Stefan Monnier <monnier@HIDDEN> To: Daniel Colascione <dancol@HIDDEN> Subject: Re: bug#76669: read_key_sequence discards events without attempting remapping In-Reply-To: <m1r03f5p69.fsf@HIDDEN> Message-ID: <jwv34fv5n5h.fsf-monnier+emacs@HIDDEN> References: <m1o6ykiat8.fsf@HIDDEN> <86r03gnfo8.fsf@HIDDEN> <m1h64b7w4l.fsf@HIDDEN> <jwv5xkr7cnd.fsf-monnier+emacs@HIDDEN> <m1r03f5p69.fsf@HIDDEN> Date: Sun, 02 Mar 2025 13:14:38 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.367 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76669 Cc: Eli Zaretskii <eliz@HIDDEN>, 76669 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) [...] >> FWIW, I have several times wished the `function-key-map`-style "remap if >> there's no binding" was applied repeatedly. [...] > No --- I meant we'd have the remapping code *do* the dropping. > Apply the remapping in a loop until we reach a fixed point. That's what I meant by "applied repeatedly", yes. `function-key-map` is *defined* as not being applied again after itself, so we'd need to introduce a new keymap (or equivalent). > Remapping phases: > > 1. [s-down-mouse-1 s-mouse-1] > 2. [down-mouse-1 mouse-1] > 3. [mouse-1] [ Of course, there are other remapping steps and orders possible. =F0=9F= =99=81 ] >> In my wildest dreams, `read_key_sequence` has an `input-fallback-map` >> which is applied repeatedly, and keymaps can be functions so that they >> can do things like remap anything that looks like `FOO-mouse-1` to >> `FOO-mouse-2` (without having to list the hundreds of possible FOO) or >> remap anything that looks like `down-FOO` to `FOO`. >> Then `read_key_sequence` doesn't treat shift and `down` specially, >> instead that can be moved out to `input-fallback-map`. > Keymap entries can already be functions, and I think the function entry > would work with the fallback finding t too. Indeed, we have things which cover various parts (there are also those `:filter` functions in `menu-item`s), but not well enough to be usable in practice. > There's no good way to compose such functions, though --- not without > just clobbering them with add-function and such. Child keymap > fallback entries will shadow those of the parents. Maybe we only need this flexibility for key remapping and not for normal keymaps, so we could have a "sequence of remapping thingies" where each thingy can be a keymap or a function so we don't add any special functionality to keymaps? >> But, yeah, that still leaves open the question of whether we should drop >> `shift` before we drop `down` or the reverse, and whether the >> `FOO-mouse-1` to `FOO-mouse-2` remapping should happen before or after >> dropping `down`. The only "principled" way to solve this problem, >> AFAICT, would be to consider those remapping and returning all the >> possibilities (as a set of possible keysequences) and then when we do >> the corresponding key lookup, we'd have to decide what to do if there's >> more than one binding for those keysequences. > > If we're going to fix this, we might as well move read-key-sequence to > Lisp, where it's easier to express the right algorithm. That could be nice, yes. Tho some of the complexity is not just in the fact that it's written in C but in the details of the semantics (especially the various remapping keymaps and their interactions, as well as their interaction with the decision of when exactly to stop waiting for more input). > (cl-loop > with want-lookahead =3D nil > for keymap in all-keymaps > for binding =3D (keymap-try-get-binding keymap candidate-keys) > if (eq binding :want-lookahead) > do (setf want-lookahead :want-lookahead) > else if binding return binding > finally return want-lookahead)) I think this can be replaced with just (lookup-key all-keymaps candidate-keys) where `integerp` tells us if we "want-lookahead". Stefan
bug-gnu-emacs@HIDDEN
:bug#76669
; Package emacs
.
Full text available.Received: (at 76669) by debbugs.gnu.org; 2 Mar 2025 17:16:13 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 02 12:16:13 2025 Received: from localhost ([127.0.0.1]:34199 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tomvF-0000Ky-29 for submit <at> debbugs.gnu.org; Sun, 02 Mar 2025 12:16:13 -0500 Received: from dancol.org ([2600:3c01:e000:3d8::1]:36784) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <dancol@HIDDEN>) id 1tomv8-0000KC-Iy for 76669 <at> debbugs.gnu.org; Sun, 02 Mar 2025 12:16:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=HrxUkJ5njbEDe6CK6c2lBHUj9qIbXQcOnlcv7boK/WA=; b=CughJvvJlCG5tQ8WPVWEX+/TcZ 930lCBsAIbby5A0nilpQnv8iheseJEfb1mjdjjRNTQMfkjrEl8Pm4IQ4rwc5biKWCAX3YUqCYScYm HrYp9/BbOQGzSedgLnZdDAiGsq9bdzIDhDSQpraRoccIXPsYUH4JqBTS73bM32bO+PUoDDisbOrRl 2/KGkSQKb/nJqkKLpXcTZLIhOq8xrITwcpwb8I2SNPCZyuiVCz3pEYCh7nd83PXwNf+2IhhKiIH6R lAjs8I6qcbdtFf+tcfX8gzhbHRnjmznBV5xYC6aDKTpRNDeXV6CrrHtBH2NnDSy161Ke5Da1zzpGJ 3Rohr39Q==; Received: from dancol by dancol.org with local (Exim 4.96) (envelope-from <dancol@HIDDEN>) id 1tomut-001cr3-0L; Sun, 02 Mar 2025 12:15:51 -0500 From: Daniel Colascione <dancol@HIDDEN> To: Stefan Monnier <monnier@HIDDEN> Subject: Re: bug#76669: read_key_sequence discards events without attempting remapping In-Reply-To: <jwv5xkr7cnd.fsf-monnier+emacs@HIDDEN> References: <m1o6ykiat8.fsf@HIDDEN> <86r03gnfo8.fsf@HIDDEN> <m1h64b7w4l.fsf@HIDDEN> <jwv5xkr7cnd.fsf-monnier+emacs@HIDDEN> User-Agent: mu4e 1.12.8; emacs 31.0.50 Date: Sun, 02 Mar 2025 12:15:58 -0500 Message-ID: <m1r03f5p69.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76669 Cc: Eli Zaretskii <eliz@HIDDEN>, 76669 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Stefan Monnier <monnier@HIDDEN> writes: >>>> Suppose we want to use local-function-key-map to translate >>>> s-<down-mouse-3> to <down-mouse-3>. If we don't have a concrete binding >>>> for s-<down-mouse-3>, we never attempt to translate it: instead, >>>> read_key_sequence discards the down event and skips right to >>>> s-<mouse-3>, which we *can* translate. > > Hmm... to be honest, I'm surprised that this is what happens, because my > recollection of the code was that dropping down/double/drag (and shift) > is done "as late as possible". > > Maybe this is just a bug? > >>> I think it's ambiguous which one should come first: the discarding of >>> 'down' modifier or translation via that map. The ELisp manual says: > > Given that translation is "customizable" it's desirable to go through > translation before deciding to drop `down`, but it's also desirable to > go through translation after dropping `down`. > > FWIW, I have several times wished the `function-key-map`-style "remap if > there's no binding" was applied repeatedly. > >> Wouldn't it be simpler and more powerful to get the modifier-munging >> stuff out of the main read_key_sequence loop and implement the down >> event dropping in access_keymap_keyremap? > > That would prevent applying remapping after the `down` thingy > was dropped. No --- I meant we'd have the remapping code *do* the dropping. Apply the remapping in a loop until we reach a fixed point. Remapping phases: 1. [s-down-mouse-1 s-mouse-1] 2. [down-mouse-1 mouse-1] 3. [mouse-1] > In my wildest dreams, `read_key_sequence` has an `input-fallback-map` > which is applied repeatedly, and keymaps can be functions so that they > can do things like remap anything that looks like `FOO-mouse-1` to > `FOO-mouse-2` (without having to list the hundreds of possible FOO) or > remap anything that looks like `down-FOO` to `FOO`. > Then `read_key_sequence` doesn't treat shift and `down` specially, > instead that can be moved out to `input-fallback-map`. Keymap entries can already be functions, and I think the function entry would work with the fallback finding t too. There's no good way to compose such functions, though --- not without just clobbering them with add-function and such. Child keymap fallback entries will shadow those of the parents. > But, yeah, that still leaves open the question of whether we should drop > `shift` before we drop `down` or the reverse, and whether the > `FOO-mouse-1` to `FOO-mouse-2` remapping should happen before or after > dropping `down`. The only "principled" way to solve this problem, > AFAICT, would be to consider those remapping and returning all the > possibilities (as a set of possible keysequences) and then when we do > the corresponding key lookup, we'd have to decide what to do if there's > more than one binding for those keysequences. If we're going to fix this, we might as well move read-key-sequence to Lisp, where it's easier to express the right algorithm. We can model the raw input event stream as a lazy infinite sequence with lookahead. The access-keymap operation would do another physical event read if it wanted lookahead and we didn't have the physical event yet. We can model key remapping with recursion, yes? A remapping keymap would just recursively try the whole key mapping sequence with its new binding. Here's a sketch. (Real code would have much better style.) (defvar all-keymaps ...) ; global-map local-map function-key-map etc. (def-defstruct candidate-keys ;; (- (length keys) nr-committed) is the ;; amount of lookahead we have (keys :type vector) (nr-committed :type integer)) (defun try-match-key-sequence (candidate-keys) ;; Go through all our keymaps. If any of them returns ;; a concrete binding, use it immediately. Otherwise, ;; return :want-lookahead if any keymap wants more lookahead. (cl-loop with want-lookahead = nil for keymap in all-keymaps for binding = (keymap-try-get-binding keymap candidate-keys) if (eq binding :want-lookahead) do (setf want-lookahead :want-lookahead) else if binding return binding finally return want-lookahead)) (defun keymap-try-get-binding (keymap candidate-keys) ;; See whether keymap has a binding for candidate-keys ;; If definitely no binding, return nil. If we're not ;; sure and need to see more input (e.g. because ;; the committed part of candidate-keys names a non-empty prefix map) ;; returns :want-lookahead. (pcase (access-keymap keymap candidate-keys) (':want-lookahead ; need more input :want-lookahead) (`(:remap ,translated-candidate-keys) ;; just retry the whole matching step with the ;; new candidate keys (try-match-key-sequence translated-candidate-keys)) (r r))) (defun read-key-sequence (...) ;; Match the shortest bound sequence. ;; Leave any remaining lookahead in ;; raw-event-queue to get picked up next time. (cl-loop with raw-event-queue = () for nr-keys upfrom 0 for binding = (cl-loop for maybe-binding = (try-match-key-sequence (make-candidate-keys :keys raw-event-queue :nr nr-keys)) while (eq maybe-binding :want-lookahead) ;; Yes, I know appendf doesn't exist do (appendf raw-event-queue (read-char)) finally return maybe-binding) until binding finally return (progn ;; Put any unconsumed readahead in the queue for the next ;; event. BINDING here is (translated-keys . command) or ;; something like that (setf unread-command-events (seq-subseq raw-event-queue nr-keys)) (setf this-command-keys (car binding)) ; translated (cdr binding)))
bug-gnu-emacs@HIDDEN
:bug#76669
; Package emacs
.
Full text available.Received: (at 76669) by debbugs.gnu.org; 2 Mar 2025 14:23:51 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 02 09:23:51 2025 Received: from localhost ([127.0.0.1]:56489 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tokER-0001KO-Cx for submit <at> debbugs.gnu.org; Sun, 02 Mar 2025 09:23:51 -0500 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:39683) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <monnier@HIDDEN>) id 1tokEO-0001JX-UR for 76669 <at> debbugs.gnu.org; Sun, 02 Mar 2025 09:23:49 -0500 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A5CA44409D8; Sun, 2 Mar 2025 09:23:42 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1740925421; bh=Da+Dj3qHNIEAp0a1facqBnWFqDWfLWPN7keQPpoEPxE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Qfmb3Fli0l0QZ3mFP5xqWLQ2VKS2ApwSfVSKV+Hp8y0suxfGQcLJ45cQr2OHaeAS2 HdRzzgHMlREy0N5fu13BdQcOqLq2PtrtGk1dadoFy5GFGTE+1JEXAUessWzcaedpaW hPDaUhCNJxfpLA3s0ySUuYzDVY3jiaVQ/i9oIjkBla/j2DnM8Jbkcq1jKzAymwT03v 5snjOb7+K6KYUbx5LgGFds6GDQ/g3kD/Nyfmdz+HFfBROO/fnPJnmWq7Ak9oJH83sM nrSxzqT2+YU2EumkkIa1v89d0Ras2BCUoGQ5NJN8M2H+5AiPVi8k5GX66OsTJbLC6F NIP+YYfyVg7Fw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 189334406CB; Sun, 2 Mar 2025 09:23:41 -0500 (EST) Received: from alfajor (unknown [104.247.242.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D9B68120602; Sun, 2 Mar 2025 09:23:40 -0500 (EST) From: Stefan Monnier <monnier@HIDDEN> To: Daniel Colascione <dancol@HIDDEN> Subject: Re: bug#76669: read_key_sequence discards events without attempting remapping In-Reply-To: <m1h64b7w4l.fsf@HIDDEN> Message-ID: <jwv5xkr7cnd.fsf-monnier+emacs@HIDDEN> References: <m1o6ykiat8.fsf@HIDDEN> <86r03gnfo8.fsf@HIDDEN> <m1h64b7w4l.fsf@HIDDEN> Date: Sun, 02 Mar 2025 09:23:39 -0500 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL -0.376 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76669 Cc: Eli Zaretskii <eliz@HIDDEN>, 76669 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) >>> Suppose we want to use local-function-key-map to translate >>> s-<down-mouse-3> to <down-mouse-3>. If we don't have a concrete binding >>> for s-<down-mouse-3>, we never attempt to translate it: instead, >>> read_key_sequence discards the down event and skips right to >>> s-<mouse-3>, which we *can* translate. Hmm... to be honest, I'm surprised that this is what happens, because my recollection of the code was that dropping down/double/drag (and shift) is done "as late as possible". Maybe this is just a bug? >> I think it's ambiguous which one should come first: the discarding of >> 'down' modifier or translation via that map. The ELisp manual says: Given that translation is "customizable" it's desirable to go through translation before deciding to drop `down`, but it's also desirable to go through translation after dropping `down`. FWIW, I have several times wished the `function-key-map`-style "remap if there's no binding" was applied repeatedly. > Wouldn't it be simpler and more powerful to get the modifier-munging > stuff out of the main read_key_sequence loop and implement the down > event dropping in access_keymap_keyremap? That would prevent applying remapping after the `down` thingy was dropped. In my wildest dreams, `read_key_sequence` has an `input-fallback-map` which is applied repeatedly, and keymaps can be functions so that they can do things like remap anything that looks like `FOO-mouse-1` to `FOO-mouse-2` (without having to list the hundreds of possible FOO) or remap anything that looks like `down-FOO` to `FOO`. Then `read_key_sequence` doesn't treat shift and `down` specially, instead that can be moved out to `input-fallback-map`. But, yeah, that still leaves open the question of whether we should drop `shift` before we drop `down` or the reverse, and whether the `FOO-mouse-1` to `FOO-mouse-2` remapping should happen before or after dropping `down`. The only "principled" way to solve this problem, AFAICT, would be to consider those remapping and returning all the possibilities (as a set of possible keysequences) and then when we do the corresponding key lookup, we'd have to decide what to do if there's more than one binding for those keysequences. Stefan
bug-gnu-emacs@HIDDEN
:bug#76669
; Package emacs
.
Full text available.Received: (at 76669) by debbugs.gnu.org; 2 Mar 2025 07:02:59 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 02 02:02:59 2025 Received: from localhost ([127.0.0.1]:51796 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1todLn-00064h-1t for submit <at> debbugs.gnu.org; Sun, 02 Mar 2025 02:02:59 -0500 Received: from dancol.org ([2600:3c01:e000:3d8::1]:53888) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <dancol@HIDDEN>) id 1todLk-00064V-GU for 76669 <at> debbugs.gnu.org; Sun, 02 Mar 2025 02:02:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date: References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ccImzbIR0cngdx0tK9BE3LGai3GlTHxOFqhW6bbZSt0=; b=NEVWfmIIuGh/svzfjY1b6sdbDT XRqY7VX3GVAAd4DaFjInGv5GWeqZMsRMm66R4RFGimXPLoDiLXvt7HHg7mnPzumMLJDwsnt5jlFlu KWPVg5+hr9Cfa/lvVkE3ZN8lt+HXrCoCxIXxVLbFvMca3xYFy61PI7M1Rly9E3u05JCALYd8m7ekR OS0/OpttNOhPWCyGFo9l/+1J0Fdmpq5l4sxDC3g8JSnp/UbFryRQLOYIYRaZAz0GpIqdLDKt1O/zW JAP0sBFbvbDox1f49LzMrFXc1HjpPgBLrS4yLActOt2wNlhyRfnFv2a/IeMmDMCHdQ3Ony1pzWqCD QCD8ulpQ==; Received: from dancol by dancol.org with local (Exim 4.96) (envelope-from <dancol@HIDDEN>) id 1todLX-001ZSd-1j; Sun, 02 Mar 2025 02:02:43 -0500 From: Daniel Colascione <dancol@HIDDEN> To: Eli Zaretskii <eliz@HIDDEN> Subject: Re: bug#76669: read_key_sequence discards events without attempting remapping In-Reply-To: <86r03gnfo8.fsf@HIDDEN> References: <m1o6ykiat8.fsf@HIDDEN> <86r03gnfo8.fsf@HIDDEN> User-Agent: mu4e 1.12.8; emacs 31.0.50 Date: Sun, 02 Mar 2025 02:02:50 -0500 Message-ID: <m1h64b7w4l.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76669 Cc: Stefan Monnier <monnier@HIDDEN>, 76669 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Eli Zaretskii <eliz@HIDDEN> writes: >> From: Daniel Colascione <dancol@HIDDEN> >> Date: Sat, 01 Mar 2025 18:35:31 -0500 >>=20 >> Suppose we want to use local-function-key-map to translate >> s-<down-mouse-3> to <down-mouse-3>. If we don't have a concrete binding >> for s-<down-mouse-3>, we never attempt to translate it: instead, >> read_key_sequence discards the down event and skips right to >> s-<mouse-3>, which we *can* translate. > > I think it's ambiguous which one should come first: the discarding of > 'down' modifier or translation via that map. The ELisp manual says: > > The function =E2=80=98read-key-sequence=E2=80=99 ignores any button-= down events that > don't have command bindings; therefore, the Emacs command loop ignores > them too. This means that you need not worry about defining button-down > events unless you want them to do something. The usual reason to define > a button-down event is so that you can track mouse motion (by reading > motion events) until the button is released. *Note Motion Events::. > > And also: > > If an input character is upper-case (or has the shift modifier) and > has no key binding, but its lower-case equivalent has one, then > =E2=80=98read-key-sequence=E2=80=99 converts the character to lower cas= e. (This > behavior can be disabled by setting the > =E2=80=98translate-upper-case-key-bindings=E2=80=99 user option to =E2= =80=98nil=E2=80=99.) Note that > =E2=80=98lookup-key=E2=80=99 does not perform case conversion in this w= ay. > > When reading input results in such a =E2=80=9Cshift-translation=E2= =80=9D, Emacs sets > the variable =E2=80=98this-command-keys-shift-translated=E2=80=99 to a = non-=E2=80=98nil=E2=80=99 value. > Lisp programs can examine this variable if they need to modify their > behavior when invoked by shift-translated keys. For example, the > function =E2=80=98handle-shift-selection=E2=80=99 examines the value of= this variable to > determine how to activate or deactivate the region (*note > handle-shift-selection: The Mark.). > > The function =E2=80=98read-key-sequence=E2=80=99 also transforms som= e mouse events. > It converts unbound drag events into click events, and discards unbound > button-down events entirely. It also reshuffles focus events and > miscellaneous window events so that they never appear in a key sequence > with any other events. > > Adding Stefan to the discussion. Ambiguity aside, it's useful to translate down-mouse and other discardable events like other events. Consider trying to make a local-function-key-map that translates super-modified mouse events to unmodified mouse events without overriding explicit super-modified bindings. This translation can't translate s-down-mouse-1 to down-mouse-1 unless there's a binding for down-mouse-1 (which defeats the purpose of a translation). Wouldn't it be simpler and more powerful to get the modifier-munging stuff out of the main read_key_sequence loop and implement the down event dropping in access_keymap_keyremap?
bug-gnu-emacs@HIDDEN
:bug#76669
; Package emacs
.
Full text available.Received: (at 76669) by debbugs.gnu.org; 2 Mar 2025 05:51:49 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 02 00:51:49 2025 Received: from localhost ([127.0.0.1]:50972 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tocEu-000799-NN for submit <at> debbugs.gnu.org; Sun, 02 Mar 2025 00:51:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48794) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tocEq-00078P-NP for 76669 <at> debbugs.gnu.org; Sun, 02 Mar 2025 00:51:47 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1tocEk-0005W9-4W; Sun, 02 Mar 2025 00:51:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=/rupg5h4nk1ueogr+u2aY2kj5G+FWJXOBq/k4e92vnI=; b=fHxxsl2xECinS38Aj3np k0922c2v82002uHZ9TbRdDA/fmslDiN46ARTkbe9C4S94fgKA3Yh4u+QomXNCbXJrmUgcusduJtl6 /MbbRZb/pt9cC7ZsBz1KHZeZNlnqrYPR+ga9p22S+4EB7SHk31s+6nzkCRcUEaOp3riqJsoFc/ypi XcP+bgwlZLKDluX9TwmKrqmSz40n62S2mz1imdKnPxB4WlCY6WZwPErM3LGIPa54pEmOXJrQ4F6vq Fqpb6xvUmK11/brjEGxtcpvv8lvGgKwHXF1ccA16FKEi2du8LsHGDr0qJsWyyXCwL6bEPRlVcIVx+ Sfo3xDfMslxZAg==; Date: Sun, 02 Mar 2025 07:51:35 +0200 Message-Id: <86r03gnfo8.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Daniel Colascione <dancol@HIDDEN>, Stefan Monnier <monnier@HIDDEN> In-Reply-To: <m1o6ykiat8.fsf@HIDDEN> (message from Daniel Colascione on Sat, 01 Mar 2025 18:35:31 -0500) Subject: Re: bug#76669: read_key_sequence discards events without attempting remapping References: <m1o6ykiat8.fsf@HIDDEN> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76669 Cc: 76669 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Daniel Colascione <dancol@HIDDEN> > Date: Sat, 01 Mar 2025 18:35:31 -0500 > > Suppose we want to use local-function-key-map to translate > s-<down-mouse-3> to <down-mouse-3>. If we don't have a concrete binding > for s-<down-mouse-3>, we never attempt to translate it: instead, > read_key_sequence discards the down event and skips right to > s-<mouse-3>, which we *can* translate. I think it's ambiguous which one should come first: the discarding of 'down' modifier or translation via that map. The ELisp manual says: The function ‘read-key-sequence’ ignores any button-down events that don't have command bindings; therefore, the Emacs command loop ignores them too. This means that you need not worry about defining button-down events unless you want them to do something. The usual reason to define a button-down event is so that you can track mouse motion (by reading motion events) until the button is released. *Note Motion Events::. And also: If an input character is upper-case (or has the shift modifier) and has no key binding, but its lower-case equivalent has one, then ‘read-key-sequence’ converts the character to lower case. (This behavior can be disabled by setting the ‘translate-upper-case-key-bindings’ user option to ‘nil’.) Note that ‘lookup-key’ does not perform case conversion in this way. When reading input results in such a “shift-translation”, Emacs sets the variable ‘this-command-keys-shift-translated’ to a non-‘nil’ value. Lisp programs can examine this variable if they need to modify their behavior when invoked by shift-translated keys. For example, the function ‘handle-shift-selection’ examines the value of this variable to determine how to activate or deactivate the region (*note handle-shift-selection: The Mark.). The function ‘read-key-sequence’ also transforms some mouse events. It converts unbound drag events into click events, and discards unbound button-down events entirely. It also reshuffles focus events and miscellaneous window events so that they never appear in a key sequence with any other events. Adding Stefan to the discussion.
bug-gnu-emacs@HIDDEN
:bug#76669
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 1 Mar 2025 23:35:52 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 01 18:35:52 2025 Received: from localhost ([127.0.0.1]:46616 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1toWN6-0003NY-Cb for submit <at> debbugs.gnu.org; Sat, 01 Mar 2025 18:35:52 -0500 Received: from lists.gnu.org ([2001:470:142::17]:35380) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <dancol@HIDDEN>) id 1toWN1-0003MO-JY for submit <at> debbugs.gnu.org; Sat, 01 Mar 2025 18:35:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <dancol@HIDDEN>) id 1toWMs-0000gq-I7 for bug-gnu-emacs@HIDDEN; Sat, 01 Mar 2025 18:35:40 -0500 Received: from dancol.org ([2600:3c01:e000:3d8::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <dancol@HIDDEN>) id 1toWMq-0007uH-Lg for bug-gnu-emacs@HIDDEN; Sat, 01 Mar 2025 18:35:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From:Sender: Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=jSHDkTM7bZzYAYPA6kz5B26MUxsRs4Of9hbQGP2AnBY=; b=KB4YMNl7lcAyDdVKrbDjQOY1+9 pKlCtefmTtjqa/Fnj79ZG4rOWB+wYbo0Mzj2hu3YOdAZ+jmW9MW25U/ZTOIX2FnALvh/DJF15cFpa FW7+M7RrsuSWSa9Ag6C8VXb+wIgVFh+jiFUWVLKB8J6ZjyHwe0GoxH6Z3ZpjRLpyplY/SKM7SufVO cnG863IBNIz8ifMeL2AG2E2s5r1MhxFs79/VCvFwToihCrrvGx2fS8quRnsGh3pKkTv9VlvYjnAnq qL3Q0Imj5xp+bQW9cWrucL4lopKUw7ixxjU+d5JRBvzJHgCE8FkCCAOZO64ZFH5NffrjWLdf7vPuJ /CF+oB2A==; Received: from dancol by dancol.org with local (Exim 4.96) (envelope-from <dancol@HIDDEN>) id 1toWMe-001WYc-12 for bug-gnu-emacs@HIDDEN; Sat, 01 Mar 2025 18:35:24 -0500 From: Daniel Colascione <dancol@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: read_key_sequence discards events without attempting remapping User-Agent: mu4e 1.12.8; emacs 31.0.50 Date: Sat, 01 Mar 2025 18:35:31 -0500 Message-ID: <m1o6ykiat8.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2600:3c01:e000:3d8::1; envelope-from=dancol@HIDDEN; helo=dancol.org X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.1 (/) Suppose we want to use local-function-key-map to translate s-<down-mouse-3> to <down-mouse-3>. If we don't have a concrete binding for s-<down-mouse-3>, we never attempt to translate it: instead, read_key_sequence discards the down event and skips right to s-<mouse-3>, which we *can* translate.
Daniel Colascione <dancol@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#76669
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.