Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a dedicated symbol to hide from read-extended-command
By using a dedicated symbol, which uses our package prefix, we ensure that we can set `read-extended-command-predicate', without affecting any unrelated package. `transient-command-completion-not-suffix-only-p' only prevents "anonymously defined" transient suffix commands from being offered as `read-extended-command' completion candidates. Furthermore, because we only set `read-extended-command-predicate' iff it is non-nil, this does not mess with any user customization of this option. Also note that if the user uses `command-completion-default-include-p' instead, then the suffix-only commands are also filtered out. IMO it is reasonable for a package to use this feature to declare that certain commands should absolutely never be offered as completion candidates. The interface of this feature is not optimized for this use-case, but I predict that `read-extended-command-predicate' will one day be a hook, at which point I would not have to write this explanation in the hope that it convincingly makes the case for why daring to us it to achieve the goal that it was designed to achieve is not Wrong™, not even if it is a library that does it, as opposed to a user. It has been suggested that Transient should instead avoid `intern'ing any symbols for these (admittedly not fully) anonymous suffix commands. The proposed patch does not actually work, because these symbols *have to be* interned, and for backward compatibility reasons `transient--init-suffix' ensures that they are. So initially (at load-time) these suffix command symbols would not be interned but as the user invokes transient commands, more and more of them would become interned. We could avoid interning anonymously defined suffix commands altogether, but that would have unfortunate consequences. In fact Transient used to do that because `read-extended-command-predicate' did not exist yet. But I sure wished it did, and I was considering implementing something like that myself. So of course once that feature appear, I was happy to take advantage, in [1: 226db67]. Going back to not binding every suffix command to an interned symbol, would complicate matters considerably. It would lead to bugs, and would slow down development, because I would constantly have to double check changes, to reduce the risk of introducing such bugs. The code would be more difficult to understand. Frankly, doing so would mean intentionally adding accidental complexity. I very much want to avoid that oxymoron. Furthermore, not interning anonymously defined suffixes, would do nothing to hide infix arguments that are explicitly defined using `transient-define-infix', but those should also not be offered as completion candidates. The approach I have chosen does. Instead of #273. 1: 2023-08-12 226db67 All suffix commands now must be accessed through fbound symbols
- Loading branch information