help-gnu-emacs
[Top][All Lists]
Advanced

[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: Ruijie Yu
Subject: Re: How to make M-x TAB not work on (interactive) declaration?
Date: Sat, 07 Jan 2023 15:11:24 -0600
User-agent: mu4e 1.8.13; emacs 29.0.60

Jean Louis <bugs@gnu.support> writes:

> 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.
>
> For this example here I can still see it in M-x TAB expansion in any
> mode.
>
> (defun my-function ()
>   (interactive nil '(text-mode))
>   (message "Hello"))
>
>
> And I expect not to see it.
>
> What am I doing wrong?

Can confirm on both 29 and 28.  Although I think you missed the `&rest'
in the argument list, so you would only need to say

    (interactive nil #'text-mode)

In my testing, I tried to define:

    (defun foo () (interactive nil #'text-mode) 2)

Running M-x fo TAB while inside an `ielm' buffer completes the `foo'
command, which should not happen according to the quoted documentation.

On a slight tangent, I tried to use M-X (M-S-x,
`execute-extended-command-for-buffer'), and regardless of what major
modes I am in, I cannot find or call the `foo' command.

Best,


RY



reply via email to

[Prev in Thread] Current Thread [Next in Thread]