selectrum icon indicating copy to clipboard operation
selectrum copied to clipboard

Using this-command for selectrum-repeat is unreliable

Open clemera opened this issue 4 years ago • 11 comments

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.

clemera avatar May 25 '20 12:05 clemera

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.

clemera avatar May 25 '20 16:05 clemera

Yes, that sounds reasonable. Thank you for the report.

raxod502 avatar Jun 03 '20 13:06 raxod502

In Emacs 28 there will be minibuffer-this-command which we can use, this will also useful for command based configuration.

clemera avatar Dec 15 '20 08:12 clemera

Another this command 💩

minad avatar Dec 15 '20 11:12 minad

Yes, but it makes sense because this is a value you just had no access to before.

clemera avatar Dec 15 '20 11:12 clemera

I guess it makes some sense. But still - the design around this-command feels fundamentally flawed.

minad avatar Dec 15 '20 11:12 minad

Yes, all those this/that/last commands are hard to get right...

clemera avatar Dec 15 '20 12:12 clemera

Oh, I got the name wrong above, too :laughing: It will be called current-minibuffer-command

clemera avatar Dec 15 '20 12:12 clemera

:see_no_evil:

minad avatar Dec 15 '20 12:12 minad

I think that name is actually a good choice, less confusing and pretty intuitive.

clemera avatar Dec 15 '20 12:12 clemera

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

raxod502 avatar Dec 21 '20 22:12 raxod502