[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to make M-x TAB not work on (interactive) declaration?
From: |
Tassilo Horn |
Subject: |
Re: How to make M-x TAB not work on (interactive) declaration? |
Date: |
Sun, 08 Jan 2023 09:34:28 +0100 |
User-agent: |
mu4e 1.9.12; emacs 30.0.50 |
Jean Louis <bugs@gnu.support> writes:
Hi Jean,
> Reference:
> (describe-function 'interactive)
>
> If MODES is present, it should be a list of mode names (symbols) that
> this command is applicable for. The main effect of this is that ‘M-x
> TAB’ (by default) won’t list this command if the current buffer’s mode
> doesn’t match the list. That is, if either the major mode isn’t
> derived from them, or (when it’s a minor mode) the mode isn’t in
> effect.
MODES is a &rest argument and the mode symbols shouldn't be quoted, so
you use it like so:
(defun my-function ()
(interactive nil text-mode some-other-mode)
(message "Hello"))
> For this example here I can still see it in M-x TAB expansion in any
> mode.
You also have to set
(setq read-extended-command-predicate
#'command-completion-default-include-p)
I've added that to my init.el when the feature was built, see the info
docs at (info "(emacs) M-x"):
--8<---------------cut here---------------start------------->8---
In addition, ‘M-x’ completion can exclude commands that are not
relevant to, and generally cannot work with, the current buffer’s major
mode (*note Major Modes::) and minor modes (*note Minor Modes::). By
default, no commands are excluded, but you can customize the option
‘read-extended-command-predicate’ to exclude those irrelevant commands
from completion results.
--8<---------------cut here---------------end--------------->8---
You are right that this is feature is probably not documented good
enough. It seems `command-completion-default-include-p' isn't
documented at all (but customize knows about it) and the `interactive'
docstring is missing references to that and
`read-extended-command-predicate', too. I'd suggest to write a bug
report.
Bye,
Tassilo
- Re: How to make M-x TAB not work on (interactive) declaration?, (continued)
Re: How to make M-x TAB not work on (interactive) declaration?,
Tassilo Horn <=
- Re: How to make M-x TAB not work on (interactive) declaration?, Eli Zaretskii, 2023/01/08
- Re: How to make M-x TAB not work on (interactive) declaration?, Jean Louis, 2023/01/08
- RE: [External] : Re: How to make M-x TAB not work on (interactive) declaration?, Drew Adams, 2023/01/08
- Re: [External] : Re: How to make M-x TAB not work on (interactive) declaration?, Emanuel Berg, 2023/01/09
- Re: [External] : Re: How to make M-x TAB not work on (interactive) declaration?, Jean Louis, 2023/01/09
- Re: [External] : Re: How to make M-x TAB not work on (interactive) declaration?, Emanuel Berg, 2023/01/12
- (*)->1, Jean Louis, 2023/01/13
- Re: (*)->1, Michael Heerdegen, 2023/01/14
- Re: (*)->1, Michael Heerdegen, 2023/01/14