karthink / gptel

A simple LLM client for Emacs
GNU General Public License v3.0
1.04k stars 111 forks source link

Please remove transient commands from M-x menu #241

Closed tusharhero closed 3 months ago

tusharhero commented 3 months ago

image These commands are very annoying because they keep messing with my searches by auto completing I think adding double dashes should make Fido ignore it.

karthink commented 3 months ago

gptel-menu is intended to be a user command, so I cannot change it to gptel--menu. I suggest asking @tarsius if there is any way to hide transient commands from the M-x menu.

I'm also not sure why they would show up at the top of M-x, unless you're searching for something with the word transient in it.

tarsius commented 3 months ago

Transient tries to hide these commands by setting read-extended-command-predicate, if that isn't already non-nil. If it is non-nil, then that's probably because one of the default functions is used, which also work. (The Emacs maintainers unfortunately have made this opt-in; I recommend you use command-completion-default-include-p. The function that Transient uses instead only affects commands that were defined with its help.)

This requires Emacs 28.1.

This only affects infixes/arguments (not regular suffixes that "do" something), and suffixes that are defined inline (that is within the prefix definition). Other suffixes can be hidden explicitly using:

(put COMMAND 'completion-predicate #'transient--suffix-only)
karthink commented 3 months ago

Thanks for the help @tarsius! Much appreciated. Learnt about read-extended-command-predicate today as a result.

@tusharhero: Transient infixes are excluded from the M-x completion automatically -- you just need to update transient since it looks to be a recent addition.

If you don't want to update transient for some reason, you can set read-extended-command-predicate to command-completion-default-include-p, as indicated by tarsius above. This has the added benefit of filtering out several other irrelevant commands in M-x.

tusharhero commented 3 months ago

Yeah, updating transient fixed it for me.