* set-transient-map and a question @ 2023-07-11 1:12 T.V Raman 2023-07-11 8:03 ` Robert Pluim 0 siblings, 1 reply; 19+ messages in thread From: T.V Raman @ 2023-07-11 1:12 UTC (permalink / raw) To: emacs-devel set-transient-map is used in text-scale-adjust here: https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/face-remap.el?h=master#n423... But it looks like it passes nil as the keep-pressed arg which sounds counter to the documentation for set-transient-map; but text-scale-adjust does work as intended -- so am I reading the set-transient-map doc incorrectly? -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮 -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-11 1:12 set-transient-map and a question T.V Raman @ 2023-07-11 8:03 ` Robert Pluim 2023-07-11 14:09 ` T.V Raman 0 siblings, 1 reply; 19+ messages in thread From: Robert Pluim @ 2023-07-11 8:03 UTC (permalink / raw) To: T.V Raman; +Cc: emacs-devel >>>>> On Mon, 10 Jul 2023 18:12:18 -0700, "T.V Raman" <raman@google.com> said: T> set-transient-map is used in text-scale-adjust here: T> https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/face-remap.el?h=master#n423... T> But it looks like it passes nil as the keep-pressed arg which sounds T> counter to the documentation for set-transient-map; but T> text-scale-adjust does work as intended -- so am I reading the T> set-transient-map doc incorrectly? All the bindings in that map in `text-scale-adjust' call `text-scale-adjust', which then results in `set-transient-mapʼ being called again, which means you donʼt need any logic to de-activate the transient keymap when someone presses a non-text-scale-adjust key. (Iʼve just realized `text-scale-adjust' actually uses a minor-mode, which seems like overkill, but it works) Robert -- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-11 8:03 ` Robert Pluim @ 2023-07-11 14:09 ` T.V Raman 2023-07-11 16:08 ` Robert Pluim 0 siblings, 1 reply; 19+ messages in thread From: T.V Raman @ 2023-07-11 14:09 UTC (permalink / raw) To: rpluim; +Cc: raman, emacs-devel interesting; so what is the point of keep-pressed as an argument to set-transient-map? Robert Pluim writes: > >>>>> On Mon, 10 Jul 2023 18:12:18 -0700, "T.V Raman" <raman@google.com> said: > > T> set-transient-map is used in text-scale-adjust here: > T> https://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/face-remap.el?h=master#n423... > > T> But it looks like it passes nil as the keep-pressed arg which sounds > T> counter to the documentation for set-transient-map; but > T> text-scale-adjust does work as intended -- so am I reading the > T> set-transient-map doc incorrectly? > > All the bindings in that map in `text-scale-adjust' call > `text-scale-adjust', which then results in `set-transient-mapʼ being > called again, which means you donʼt need any logic to de-activate the > transient keymap when someone presses a non-text-scale-adjust key. > > (Iʼve just realized `text-scale-adjust' actually uses a minor-mode, > which seems like overkill, but it works) > > Robert > -- -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮 -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-11 14:09 ` T.V Raman @ 2023-07-11 16:08 ` Robert Pluim 2023-07-11 17:16 ` T.V Raman 0 siblings, 1 reply; 19+ messages in thread From: Robert Pluim @ 2023-07-11 16:08 UTC (permalink / raw) To: T.V Raman; +Cc: emacs-devel >>>>> On Tue, 11 Jul 2023 07:09:13 -0700, "T.V Raman" <raman@google.com> said: T> interesting; so what is the point of keep-pressed as an argument to T> set-transient-map? As far as I can tell itʼs used for things related to mouse-dragging and modal commands like `indent-rigidly', where keys not in the transient map exit the mode. Robert -- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-11 16:08 ` Robert Pluim @ 2023-07-11 17:16 ` T.V Raman 2023-07-11 17:44 ` Robert Pluim 0 siblings, 1 reply; 19+ messages in thread From: T.V Raman @ 2023-07-11 17:16 UTC (permalink / raw) To: rpluim; +Cc: raman, emacs-devel Interesting. I played with it a bit more, and setting keep-pressed to t in my code got the other part that was failing for me, the on-exit arg being passed as a function. It works now, ie I have it playing a sound on exit and that now works; earlier it was playing even when the transient hadn't exitted. Robert Pluim writes: > >>>>> On Tue, 11 Jul 2023 07:09:13 -0700, "T.V Raman" <raman@google.com> said: > > T> interesting; so what is the point of keep-pressed as an argument to > T> set-transient-map? > > As far as I can tell itʼs used for things related to mouse-dragging > and modal commands like `indent-rigidly', where keys not in the > transient map exit the mode. > > Robert > -- -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮 -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-11 17:16 ` T.V Raman @ 2023-07-11 17:44 ` Robert Pluim 2023-07-11 17:53 ` T.V Raman 0 siblings, 1 reply; 19+ messages in thread From: Robert Pluim @ 2023-07-11 17:44 UTC (permalink / raw) To: T.V Raman; +Cc: emacs-devel >>>>> On Tue, 11 Jul 2023 10:16:56 -0700, "T.V Raman" <raman@google.com> said: T> Interesting. I played with it a bit more, and setting keep-pressed to T> t in my code got the other part that was failing for me, the on-exit T> arg being passed as a function. Based on glancing at the implementation, `on-exit' requires `keep-pred' non-nil, which isnʼt 100% clear from the docstring. And I think the `keep-pred' as a function logic is inverted. But thatʼs not something I have time to look at right noww. Robert -- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-11 17:44 ` Robert Pluim @ 2023-07-11 17:53 ` T.V Raman 2023-07-11 18:10 ` Bob Rogers 0 siblings, 1 reply; 19+ messages in thread From: T.V Raman @ 2023-07-11 17:53 UTC (permalink / raw) To: rpluim; +Cc: raman, emacs-devel Thanks; I have it doing what I want now -- but perhaps it might be worth logging a bug for the docs? I live purely in emacs -- but can report the bug using email, but it might be clearer if filed directly in the bug-tracker? (not sure) Robert Pluim writes: > >>>>> On Tue, 11 Jul 2023 10:16:56 -0700, "T.V Raman" <raman@google.com> said: > > T> Interesting. I played with it a bit more, and setting keep-pressed to > T> t in my code got the other part that was failing for me, the on-exit > T> arg being passed as a function. > > Based on glancing at the implementation, `on-exit' requires > `keep-pred' non-nil, which isnʼt 100% clear from the docstring. > > And I think the `keep-pred' as a function logic is inverted. But > thatʼs not something I have time to look at right noww. > > Robert > -- -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮 -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-11 17:53 ` T.V Raman @ 2023-07-11 18:10 ` Bob Rogers 2023-07-11 20:29 ` Robert Pluim 0 siblings, 1 reply; 19+ messages in thread From: Bob Rogers @ 2023-07-11 18:10 UTC (permalink / raw) To: T.V Raman; +Cc: rpluim, emacs-devel From: "T.V Raman" <raman@google.com> Date: Tue, 11 Jul 2023 10:53:20 -0700 Thanks; I have it doing what I want now -- but perhaps it might be worth logging a bug for the docs? I live purely in emacs -- but can report the bug using email, but it might be clearer if filed directly in the bug-tracker? (not sure) Filing a bug via email is 100% equivalent; that's the way I always do it. -- Bob Rogers http://www.rgrjr.com/ ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-11 18:10 ` Bob Rogers @ 2023-07-11 20:29 ` Robert Pluim 2023-07-11 20:53 ` T.V Raman 2023-07-12 1:28 ` Michael Heerdegen 0 siblings, 2 replies; 19+ messages in thread From: Robert Pluim @ 2023-07-11 20:29 UTC (permalink / raw) To: Bob Rogers; +Cc: T.V Raman, emacs-devel >>>>> On Tue, 11 Jul 2023 11:10:10 -0700, Bob Rogers <rogers@rgrjr.com> said: Bob> From: "T.V Raman" <raman@google.com> Bob> Date: Tue, 11 Jul 2023 10:53:20 -0700 Bob> Thanks; I have it doing what I want now -- but perhaps it might be Bob> worth logging a bug for the docs? I live purely in emacs -- but can Bob> report the bug using email, but it might be clearer if filed directly Bob> in the bug-tracker? (not sure) Bob> Filing a bug via email is 100% equivalent; that's the way I always do Bob> it. I donʼt think a bug is needed here. How does this sound: diff --git a/lisp/subr.el b/lisp/subr.el index fac5fd58092..6ac040fe5d3 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -6343,7 +6343,8 @@ set-transient-map if it returns non-nil, then MAP stays active. Optional arg ON-EXIT, if non-nil, specifies a function that is -called, with no arguments, after MAP is deactivated. +called, with no arguments, after MAP is deactivated (this happens +only if KEEP-PRED or TIMEOUT are non-nil). Optional arg MESSAGE, if non-nil, requests display of an informative message after activating the transient map. If MESSAGE is a string, Robert -- ^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-11 20:29 ` Robert Pluim @ 2023-07-11 20:53 ` T.V Raman 2023-07-12 8:51 ` Robert Pluim 2023-07-12 1:28 ` Michael Heerdegen 1 sibling, 1 reply; 19+ messages in thread From: T.V Raman @ 2023-07-11 20:53 UTC (permalink / raw) To: rpluim; +Cc: rogers, raman, emacs-devel this is perfect, Thanks Robert! Robert Pluim writes: > >>>>> On Tue, 11 Jul 2023 11:10:10 -0700, Bob Rogers <rogers@rgrjr.com> said: > > Bob> From: "T.V Raman" <raman@google.com> > Bob> Date: Tue, 11 Jul 2023 10:53:20 -0700 > > Bob> Thanks; I have it doing what I want now -- but perhaps it might be > Bob> worth logging a bug for the docs? I live purely in emacs -- but can > Bob> report the bug using email, but it might be clearer if filed directly > Bob> in the bug-tracker? (not sure) > > Bob> Filing a bug via email is 100% equivalent; that's the way I always do > Bob> it. > > I donʼt think a bug is needed here. How does this sound: > > diff --git a/lisp/subr.el b/lisp/subr.el > index fac5fd58092..6ac040fe5d3 100644 > --- a/lisp/subr.el > +++ b/lisp/subr.el > @@ -6343,7 +6343,8 @@ set-transient-map > if it returns non-nil, then MAP stays active. > > Optional arg ON-EXIT, if non-nil, specifies a function that is > -called, with no arguments, after MAP is deactivated. > +called, with no arguments, after MAP is deactivated (this happens > +only if KEEP-PRED or TIMEOUT are non-nil). > > Optional arg MESSAGE, if non-nil, requests display of an informative > message after activating the transient map. If MESSAGE is a string, > > Robert > -- -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮 -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-11 20:53 ` T.V Raman @ 2023-07-12 8:51 ` Robert Pluim 2023-07-12 13:49 ` T.V Raman 0 siblings, 1 reply; 19+ messages in thread From: Robert Pluim @ 2023-07-12 8:51 UTC (permalink / raw) To: T.V Raman; +Cc: rogers, emacs-devel >>>>> On Tue, 11 Jul 2023 13:53:03 -0700, "T.V Raman" <raman@google.com> said: T> this is perfect, Thanks Robert! Except, based on testing, itʼs not true :-) Iʼll work on the docstring some more. Robert -- ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-12 8:51 ` Robert Pluim @ 2023-07-12 13:49 ` T.V Raman 0 siblings, 0 replies; 19+ messages in thread From: T.V Raman @ 2023-07-12 13:49 UTC (permalink / raw) To: rpluim; +Cc: raman, rogers, emacs-devel :-) I didn't test that because I wasn't binding the modifier letters; one of my current goals with emacs/emacspeak is to minimize chording -- if interested, see the article on xcape in the Emacspeak blog: https://emacspeak.blogspot.com/2023/02/enhance-emacs-ergonomics-under-x-happy.html Robert Pluim writes: > >>>>> On Tue, 11 Jul 2023 13:53:03 -0700, "T.V Raman" <raman@google.com> said: > > T> this is perfect, Thanks Robert! > > Except, based on testing, itʼs not true :-) > > Iʼll work on the docstring some more. > > Robert > -- -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮 -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) ♉ Id: kg:/m/0285kf1 🦮 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-11 20:29 ` Robert Pluim 2023-07-11 20:53 ` T.V Raman @ 2023-07-12 1:28 ` Michael Heerdegen 2023-07-12 1:58 ` T.V Raman 1 sibling, 1 reply; 19+ messages in thread From: Michael Heerdegen @ 2023-07-12 1:28 UTC (permalink / raw) To: emacs-devel Robert Pluim <rpluim@gmail.com> writes: > Optional arg ON-EXIT, if non-nil, specifies a function that is > -called, with no arguments, after MAP is deactivated. > +called, with no arguments, after MAP is deactivated (this happens > +only if KEEP-PRED or TIMEOUT are non-nil). Doesn't CLEARFUN call ON-EXIT even when KEEP-PRED and TIMEOUT are both nil? Michael. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-12 1:28 ` Michael Heerdegen @ 2023-07-12 1:58 ` T.V Raman 2023-07-12 2:32 ` Michael Heerdegen 0 siblings, 1 reply; 19+ messages in thread From: T.V Raman @ 2023-07-12 1:58 UTC (permalink / raw) To: Michael Heerdegen; +Cc: emacs-devel [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=gb18030, Size: 478 bytes --] From my experimentation, it appeared (needs confirmation) that if kee-pressed was nil, the exit-func never got called -- even though the function called itself recursively -- ie if keep-pressed is nil, and it calls itself, the behavior is indistinguishable from keep-pressed = t. I fell in this hole by mimicking the implementation of text-scale-adjust as a starter. -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) 7©4 Id: kg:/m/0285kf1 0Ü8 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-12 1:58 ` T.V Raman @ 2023-07-12 2:32 ` Michael Heerdegen 2023-07-12 2:49 ` Michael Heerdegen 0 siblings, 1 reply; 19+ messages in thread From: Michael Heerdegen @ 2023-07-12 2:32 UTC (permalink / raw) To: emacs-devel "T.V Raman" <raman@google.com> writes: > From my experimentation, it appeared (needs confirmation) that if > kee-pressed was nil, the exit-func never got called The code says that EXIT-FUN is always called. Here is a simple test case: (set-transient-map emacs-lisp-mode-map nil (lambda () (message "!!!"))) Works as expected here: after hitting a random key I get the expected `message' > -- even though the function called itself recursively -- ie if > keep-pressed is nil, and it calls itself, the behavior is > indistinguishable from keep-pressed = t. Note that nested transient maps are handled specially: the first (or "outer") ones wait until the newest one is gone. Maybe you hit that case. Michael. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-12 2:32 ` Michael Heerdegen @ 2023-07-12 2:49 ` Michael Heerdegen 2023-07-12 3:21 ` T.V Raman 0 siblings, 1 reply; 19+ messages in thread From: Michael Heerdegen @ 2023-07-12 2:49 UTC (permalink / raw) To: emacs-devel Michael Heerdegen <michael_heerdegen@web.de> writes: > Note that nested transient maps are handled specially: the first (or > "outer") ones wait until the newest one is gone. Maybe you hit that > case. Note that this doesn't happen for `eq' maps. But if your recursive calls install a new transient map that is only `equal' to the first one it's treated as an additional transient map hiding the old one. Michael. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-12 2:49 ` Michael Heerdegen @ 2023-07-12 3:21 ` T.V Raman 2023-07-12 3:39 ` Michael Heerdegen 0 siblings, 1 reply; 19+ messages in thread From: T.V Raman @ 2023-07-12 3:21 UTC (permalink / raw) To: Michael Heerdegen; +Cc: emacs-devel [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=gb18030, Size: 786 bytes --] Michael Heerdegen <michael_heerdegen@web.de> writes: For me, hitting c-x c-e at the end of that code while in the gnus article buffer did not appear to work, it continued to call keys in the buffer-local gnus article mode. > Michael Heerdegen <michael_heerdegen@web.de> writes: > >> Note that nested transient maps are handled specially: the first (or >> "outer") ones wait until the newest one is gone. Maybe you hit that >> case. > > Note that this doesn't happen for `eq' maps. But if your recursive > calls install a new transient map that is only `equal' to the first one > it's treated as an additional transient map hiding the old one. > > Michael. > > -- Thanks, --Raman(I Search, I Find, I Misplace, I Research) 7©4 Id: kg:/m/0285kf1 0Ü8 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-12 3:21 ` T.V Raman @ 2023-07-12 3:39 ` Michael Heerdegen 2023-07-12 8:55 ` Robert Pluim 0 siblings, 1 reply; 19+ messages in thread From: Michael Heerdegen @ 2023-07-12 3:39 UTC (permalink / raw) To: emacs-devel "T.V Raman" <raman@google.com> writes: > For me, hitting c-x c-e at the end of that code while in the gnus > article buffer did not appear to work, it continued to call keys in the > buffer-local gnus article mode. Works for me. C-c C-e C-c C-b tries to compile the article buffer, for example. It was a silly example, of course, but it should work. There are not many bindings in `emacs-lisp-mode-map'. You really tried one of those keys _immediately_ after evaluating the `set-transient-map' expression (note that the transient map is gone after one entering one key binding not present in the map)? Michael. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: set-transient-map and a question 2023-07-12 3:39 ` Michael Heerdegen @ 2023-07-12 8:55 ` Robert Pluim 0 siblings, 0 replies; 19+ messages in thread From: Robert Pluim @ 2023-07-12 8:55 UTC (permalink / raw) To: Michael Heerdegen; +Cc: emacs-devel >>>>> On Wed, 12 Jul 2023 05:39:48 +0200, Michael Heerdegen <michael_heerdegen@web.de> said: Michael> "T.V Raman" <raman@google.com> writes: >> For me, hitting c-x c-e at the end of that code while in the gnus >> article buffer did not appear to work, it continued to call keys in the >> buffer-local gnus article mode. Michael> Works for me. C-c C-e C-c C-b tries to compile the article buffer, for Michael> example. It was a silly example, of course, but it should work. Michael> There are not many bindings in `emacs-lisp-mode-map'. You really tried Michael> one of those keys _immediately_ after evaluating the `set-transient-map' Michael> expression (note that the transient map is gone after one entering one Michael> key binding not present in the map)? I tried the following in "*scratch*", and I get "deactivated" in *Messages* after hitting "+" (or indeed any key). (set-transient-map (let ((map (make-sparse-keymap))) (define-key map "+" (lambda () (interactive) (message "whoohoo"))) map) nil (lambda () (message "deactivated"))) which means my proposed doc update is wrong. Moral: test before documenting, not after :-) Robert -- ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2023-07-12 13:49 UTC | newest] Thread overview: 19+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-07-11 1:12 set-transient-map and a question T.V Raman 2023-07-11 8:03 ` Robert Pluim 2023-07-11 14:09 ` T.V Raman 2023-07-11 16:08 ` Robert Pluim 2023-07-11 17:16 ` T.V Raman 2023-07-11 17:44 ` Robert Pluim 2023-07-11 17:53 ` T.V Raman 2023-07-11 18:10 ` Bob Rogers 2023-07-11 20:29 ` Robert Pluim 2023-07-11 20:53 ` T.V Raman 2023-07-12 8:51 ` Robert Pluim 2023-07-12 13:49 ` T.V Raman 2023-07-12 1:28 ` Michael Heerdegen 2023-07-12 1:58 ` T.V Raman 2023-07-12 2:32 ` Michael Heerdegen 2023-07-12 2:49 ` Michael Heerdegen 2023-07-12 3:21 ` T.V Raman 2023-07-12 3:39 ` Michael Heerdegen 2023-07-12 8:55 ` Robert Pluim
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).