Subject: Re: bug#60645: 30.0.50; interactive MODES not detected properly

From: Eli Zaretskii <[email-masked]>
Date: Sun, 08 Jan 2023 14:11:08 +0200

> Date: Sun, 8 Jan 2023 14:26:18 +0300
> From: Jean Louis <[email-masked]>
> Cc: [email-masked]
> 
> * Eli Zaretskii <[email-masked]> [2023-01-08 12:15]:
> > Maybe one of the inconsistencies is your expectations.  What did you
> > expect to happen in each case, and why?
> 
> For this function:
> 
> (defun my-function ()
>   (interactive nil '(text-mode mail-mode))
>   (message "Hello"))
> 
> > 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.
> 
> I expect that M-x TAB shows it in this mail-mode, but it does not show
> it this time. That is one of expectations, among several.
> 
> In general, I would like to setup functions NOT to show in modes where
> they should not be shown.
> 
> I feel this function does not work.
> 
> If you have working example, show me.

The interactive form is wrong.  It should be this:

 (defun my-function ()
   (interactive nil text-mode mail-mode)
   (message "Hello"))

IOW, no quoting and no explicit list.  The documentation clearly says

  (interactive &optional ARG-DESCRIPTOR &rest MODES)

"&rest MODES" means zero or more symbols, not a quoted list.