selectrum
selectrum copied to clipboard
Using this-command for selectrum-repeat is unreliable
For example after read-string
, this-command
is exit-minibuffer
. You can call the following command to test this:
(defun example-command ()
(interactive)
(read-string "Example: ")
(message "%s" this-command))
That means any completing-read
called after read-string
will save exit-minibuffer
as selectrum--last-command
but it should have saved example-command
. This breaks selectrum-repeat
and also other commands which want to make use of selectrum--last-command
.
Maybe we can just save every command in pre-command-hook
as long as there isn't an active minibuffer. Then when selecturm-read
gets called use that saved command as selectrum--last-command
.
Yes, that sounds reasonable. Thank you for the report.
In Emacs 28 there will be minibuffer-this-command
which we can use, this will also useful for command based configuration.
Another this command 💩
Yes, but it makes sense because this is a value you just had no access to before.
I guess it makes some sense. But still - the design around this-command feels fundamentally flawed.
Yes, all those this/that/last commands are hard to get right...
Oh, I got the name wrong above, too :laughing: It will be called current-minibuffer-command
:see_no_evil:
I think that name is actually a good choice, less confusing and pretty intuitive.
Okay, that's actually pretty helpful. I seem to recall spending several hours trying to work around the problem you pointed out with your read-string
example above, and I was unable to figure out anything that would be even remotely robust. Perhaps with this new variable we can solve the issue.
I've found the previous issue, which has more details and examples: https://github.com/raxod502/selectrum/issues/219