* Explanation Request for the Function set-transient-map in subr.el
@ 2021-11-11 18:10 xenodasein--- via Users list for the GNU Emacs text editor
2021-11-12 14:41 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-14 12:08 ` FWD: " xenodasein--- via Users list for the GNU Emacs text editor
0 siblings, 2 replies; 14+ messages in thread
From: xenodasein--- via Users list for the GNU Emacs text editor @ 2021-11-11 18:10 UTC (permalink / raw)
To: help-gnu-emacs
What does this section do? In what situations this-command gets called using keys of the transient map but it is not equal to itself? What does mc mean?
((eq t keep-pred)
(let ((mc (lookup-key map (this-command-keys-vector))))
;; If the key is unbound `this-command` is
;; nil and so is `mc`.
(and mc (eq this-command mc))))
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Explanation Request for the Function set-transient-map in subr.el
2021-11-11 18:10 Explanation Request for the Function set-transient-map in subr.el xenodasein--- via Users list for the GNU Emacs text editor
@ 2021-11-12 14:41 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-14 12:08 ` FWD: " xenodasein--- via Users list for the GNU Emacs text editor
1 sibling, 0 replies; 14+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-11-12 14:41 UTC (permalink / raw)
To: help-gnu-emacs
> What does this section do? In what situations this-command gets called using
> keys of the transient map but it is not equal to itself? What does mc mean?
>
> ((eq t keep-pred)
> (let ((mc (lookup-key map (this-command-keys-vector))))
> ;; If the key is unbound `this-command` is
> ;; nil and so is `mc`.
> (and mc (eq this-command mc))))
It checks whether the user used one of the bindings from the `map` as
opposed to one of the bindings from other active keymaps (e.g. the
global map).
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* FWD: Explanation Request for the Function set-transient-map in subr.el
2021-11-11 18:10 Explanation Request for the Function set-transient-map in subr.el xenodasein--- via Users list for the GNU Emacs text editor
2021-11-12 14:41 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2021-11-14 12:08 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-14 13:04 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-28 18:12 ` xenodasein--- via Users list for the GNU Emacs text editor
1 sibling, 2 replies; 14+ messages in thread
From: xenodasein--- via Users list for the GNU Emacs text editor @ 2021-11-14 12:08 UTC (permalink / raw)
To: Monnier; +Cc: help-gnu-emacs
Date: Nov 11, 2021, 21:10
From: xenodasein@tutanota.de
To: help-gnu-emacs@gnu.org
Subject: Explanation Request for the Function set-transient-map in subr.el
> What does this section do? In what situations this-command gets called using keys of the transient map but it is not equal to itself? What does mc mean?
>
> ((eq t keep-pred)
> (let ((mc (lookup-key map (this-command-keys-vector))))
> ;; If the key is unbound `this-command` is
> ;; nil and so is `mc`.
> (and mc (eq this-command mc))))
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: FWD: Explanation Request for the Function set-transient-map in subr.el
2021-11-14 12:08 ` FWD: " xenodasein--- via Users list for the GNU Emacs text editor
@ 2021-11-14 13:04 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-14 23:13 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-28 18:12 ` xenodasein--- via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 14+ messages in thread
From: xenodasein--- via Users list for the GNU Emacs text editor @ 2021-11-14 13:04 UTC (permalink / raw)
To: Monnier; +Cc: Help Gnu Emacs
I'm sorry I just saw your answer on this post.
> It checks whether the user used one of the bindings from the `map` as> opposed to one of the bindings from other active keymaps (e.g. the> global map).
set-transient-map uses interal-push-map to modify overriding-terminal-local-map, so I assume you can call another command that uses set-transient map on top of a previous one and they stack? Should isearch also use that function to modify o-t-l-m? Because is currently uses setq nil on the map while exiting and nukes the whole thing...
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: FWD: Explanation Request for the Function set-transient-map in subr.el
2021-11-14 13:04 ` xenodasein--- via Users list for the GNU Emacs text editor
@ 2021-11-14 23:13 ` Stefan Monnier via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-11-14 23:13 UTC (permalink / raw)
To: help-gnu-emacs
>> It checks whether the user used one of the bindings from the `map` as
>> opposed to one of the bindings from other active keymaps (e.g. the> global
>> map).
> set-transient-map uses interal-push-map to modify
> overriding-terminal-local-map, so I assume you can call another command that
> uses set-transient-map on top of a previous one and they stack?
Indeed, tho it's rather uncommon.
> Should isearch also use that function to modify o-t-l-m? Because is
> currently uses setq nil on the map while exiting and nukes the whole
> thing...
You can try, but interaction between different `set-transient-map` can
be tricky. IIRC it works better is they nest properly, and since
Isearch tends to run for a long time it's probably fine to nest
a `set-transient-map` during Isearch, but nesting an Isearch during
another `set-transient-map` is likely to work rather poorly.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Explanation Request for the Function set-transient-map in subr.el
2021-11-14 12:08 ` FWD: " xenodasein--- via Users list for the GNU Emacs text editor
2021-11-14 13:04 ` xenodasein--- via Users list for the GNU Emacs text editor
@ 2021-11-28 18:12 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-28 19:17 ` Michael Heerdegen
2021-11-28 19:45 ` Stefan Monnier
1 sibling, 2 replies; 14+ messages in thread
From: xenodasein--- via Users list for the GNU Emacs text editor @ 2021-11-28 18:12 UTC (permalink / raw)
To: Monnier; +Cc: Help Gnu Emacs
Thanks for your clarification on isearch issue.
>> ((eq t keep-pred)
>> (let ((mc (lookup-key map (this-command-keys-vector))))
>> ;; If the key is unbound `this-command` is
>> ;; nil and so is `mc`.
>> (and mc (eq this-command mc))))
>>
I'm still not clear why exactly this expression is used though: (eq this-command mc).
What are the possible values of mc here on the last line?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Explanation Request for the Function set-transient-map in subr.el
2021-11-28 18:12 ` xenodasein--- via Users list for the GNU Emacs text editor
@ 2021-11-28 19:17 ` Michael Heerdegen
2021-11-28 19:45 ` Stefan Monnier
1 sibling, 0 replies; 14+ messages in thread
From: Michael Heerdegen @ 2021-11-28 19:17 UTC (permalink / raw)
To: help-gnu-emacs
xenodasein--- via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> Thanks for your clarification on isearch issue.
>
> >> ((eq t keep-pred)
> >> (let ((mc (lookup-key map (this-command-keys-vector))))
> >> ;; If the key is unbound `this-command` is
> >> ;; nil and so is `mc`.
> >> (and mc (eq this-command mc))))
> >>
>
> I'm still not clear why exactly this expression is used though: (eq
> this-command mc).
As Stefan and the comment tried to describe: this checks whether the
execution of current command happened using a key binding from the
transient MAP.
> What are the possible values of mc here on the last line?
This test is done to fullfill this part of the docstring:
| [...] if the optional argument KEEP-PRED is t, MAP stays active if a
| key from MAP is used
If this is the case, it's as you described, and the test succeeds. But
when the current command has not been invoked using a binding in the
transient map, mc is `nil' and the `eq'ality test fails as we want to
disable the transient map.
Michael.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Explanation Request for the Function set-transient-map in subr.el
2021-11-28 18:12 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-28 19:17 ` Michael Heerdegen
@ 2021-11-28 19:45 ` Stefan Monnier
2021-11-28 20:48 ` xenodasein--- via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2021-11-28 19:45 UTC (permalink / raw)
To: xenodasein; +Cc: Help Gnu Emacs
xenodasein@tutanota.de [2021-11-28 19:12:56] wrote:
> Thanks for your clarification on isearch issue.
>>> ((eq t keep-pred)
>>> (let ((mc (lookup-key map (this-command-keys-vector))))
>>> ;; If the key is unbound `this-command` is
>>> ;; nil and so is `mc`.
>>> (and mc (eq this-command mc))))
>
> I'm still not clear why exactly this expression is used though: (eq this-command mc).
> What are the possible values of mc here on the last line?
This tests whether the user typed a key-sequence from `map` as opposed
to some other one.
E.g. when you use `text-scale-adjust`, you want to "stay" in the
transient map as long as the user uses one of the keys in the `map`
(basically, +, -, or 0) and if the user types some other key, we
immediately/automatically exit from this transient map.
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Explanation Request for the Function set-transient-map in subr.el
2021-11-28 19:45 ` Stefan Monnier
@ 2021-11-28 20:48 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-28 21:07 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-28 22:29 ` xenodasein--- via Users list for the GNU Emacs text editor
0 siblings, 2 replies; 14+ messages in thread
From: xenodasein--- via Users list for the GNU Emacs text editor @ 2021-11-28 20:48 UTC (permalink / raw)
To: Stefan Monnier, michael_heerdegen; +Cc: Help Gnu Emacs
> This tests whether the user typed a key-sequence from `map` as opposed
> to some other one.
>
> E.g. when you use `text-scale-adjust`, you want to "stay" in the
> transient map as long as the user uses one of the keys in the `map`
> (basically, +, -, or 0) and if the user types some other key, we
> immediately/automatically exit from this transient map.
>
> Stefan
> As Stefan and the comment tried to describe: this checks whether the
> execution of current command happened using a key binding from the
> transient MAP.
> What are the possible values of mc here on the last line?
> This test is done to fullfill this part of the docstring:
>| [...] if the optional argument KEEP-PRED is t, MAP stays active if a
>| key from MAP is used
> If this is the case, it's as you described, and the test succeeds. But
> when the current command has not been invoked using a binding in the
> transient map, mc is `nil' and the `eq'ality test fails as we want to
> disable the transient map.
But then, isn't that second expression redundant? Lookup key is already looking
in our transient map, if it succeeds mc will be non-nil and equal this-command,
if it does not, 'and' will return nil anyway?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Explanation Request for the Function set-transient-map in subr.el
2021-11-28 20:48 ` xenodasein--- via Users list for the GNU Emacs text editor
@ 2021-11-28 21:07 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-28 21:24 ` Michael Heerdegen
2021-11-28 22:29 ` xenodasein--- via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 14+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2021-11-28 21:07 UTC (permalink / raw)
To: help-gnu-emacs
> But then, isn't that second expression redundant? Lookup key is already looking
> in our transient map, if it succeeds mc will be non-nil and equal this-command,
> if it does not, 'and' will return nil anyway?
It's somewhat redundant but tries to protect from cases where some other
keymap was used instead (presumably a keymap with higher precedence).
Stefan
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Explanation Request for the Function set-transient-map in subr.el
2021-11-28 21:07 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2021-11-28 21:24 ` Michael Heerdegen
0 siblings, 0 replies; 14+ messages in thread
From: Michael Heerdegen @ 2021-11-28 21:24 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> It's somewhat redundant but tries to protect from cases where some
> other keymap was used instead (presumably a keymap with higher
> precedence).
But since `this-command' is never bound to nil, the `mc` part in the
`and' is redundant...or not?
Michael.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Explanation Request for the Function set-transient-map in subr.el
2021-11-28 20:48 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-28 21:07 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2021-11-28 22:29 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-28 22:44 ` xenodasein--- via Users list for the GNU Emacs text editor
1 sibling, 1 reply; 14+ messages in thread
From: xenodasein--- via Users list for the GNU Emacs text editor @ 2021-11-28 22:29 UTC (permalink / raw)
To: Help Gnu Emacs
Come to think of it, I imagine a scenario where mc is non-nil and this-command is not eq mc;
the command changes it's own binding. I wonder if this is an undesirable effect as it will dismiss
the transient map.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Explanation Request for the Function set-transient-map in subr.el
2021-11-28 22:29 ` xenodasein--- via Users list for the GNU Emacs text editor
@ 2021-11-28 22:44 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-29 10:28 ` Michael Heerdegen
0 siblings, 1 reply; 14+ messages in thread
From: xenodasein--- via Users list for the GNU Emacs text editor @ 2021-11-28 22:44 UTC (permalink / raw)
To: Help Gnu Emacs
> Come to think of it, I imagine a scenario where mc is non-nil and this-command is not eq mc; the command changes it's own binding. I wonder if this is an undesirable effect as it will dismiss the transient map.
>
Sorry, I forgot this thing is being called in pre-command-hook; in that case what I said before does not completely apply. However, if what changes this-command's binding to some other command is yet another pre-command-hook, then we arrive at the same situation?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Explanation Request for the Function set-transient-map in subr.el
2021-11-28 22:44 ` xenodasein--- via Users list for the GNU Emacs text editor
@ 2021-11-29 10:28 ` Michael Heerdegen
0 siblings, 0 replies; 14+ messages in thread
From: Michael Heerdegen @ 2021-11-29 10:28 UTC (permalink / raw)
To: help-gnu-emacs
xenodasein--- via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> writes:
> However, if what changes this-command's binding to some other command
> is yet another pre-command-hook, then we arrive at the same situation?
I think so... but this sounds like a bad thing to do, and the problem
you describe is probably one of the smaller issues this might cause.
Michael.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2021-11-29 10:28 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-11 18:10 Explanation Request for the Function set-transient-map in subr.el xenodasein--- via Users list for the GNU Emacs text editor
2021-11-12 14:41 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-14 12:08 ` FWD: " xenodasein--- via Users list for the GNU Emacs text editor
2021-11-14 13:04 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-14 23:13 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-28 18:12 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-28 19:17 ` Michael Heerdegen
2021-11-28 19:45 ` Stefan Monnier
2021-11-28 20:48 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-28 21:07 ` Stefan Monnier via Users list for the GNU Emacs text editor
2021-11-28 21:24 ` Michael Heerdegen
2021-11-28 22:29 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-28 22:44 ` xenodasein--- via Users list for the GNU Emacs text editor
2021-11-29 10:28 ` Michael Heerdegen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.