Integrate with read-extended-command-predicate
#61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation: Since Emacs 28.1 (I think) we have the option to add modes to
interactive
, say(interactive nil haskell-mode emacs-lisp-mode)
. The Emacs variableread-extended-command-predicate
(when set to some predicate, for instancecommand-completion-default-include-p
) then leads to those commands only being shown inM-x
completion when the current buffer is in one of those modes.I've added the
:interactive-modes
keyword, taking a list of those modes that are then passed tointeractive
, and tested it accordingly.Some points/questions:
:modes
would (I think) suggest something regarding the created minor mode, or similar to the:hooks
behaviour inuse-package
, so I opted for a longer name giving theinteractive
context.:interactive-modes
expects an unquoted list of modes. It was easiest to implement it this way, as we can just splice it intointeractive
, which takes them as&rest
. Is this fine?I personally find it very handy and nice to have my custom commands automatically narrowed down like this; just the ones defined with
reformatter-define
"stick out" a little bit, hence this PR. I'd be glad if you considered this in some way or other :)