Subject: Re: bug#6037: 24.0.50; menu-bar-mode function doesn't toggle

From: Stefan Monnier <[email-masked]>
Date: Mon, 26 Apr 2010 23:05:18 -0400

> You're of the opinion that using "nil" to turn on a minor-mode is actually
> correct behavior?

Yes.

> And the important justification for breaking long-standing behavior
> was... ?

It fixes a lot of

  (add-hook 'foo-mode 'toto-minor-mode)

where the coder assumed unconsciously that toto-minor-mode was not
yet enabled.

>> If you really want to toggle (I've never seen such a case from Elisp),
>> just do (menu-bar-mode 'toggle).
> Okay, thanks for the hint.  Is that documented anywhere?

Not yet.

> If you'd like a use-case in elisp, I've been doing this in some form
> of or another for quite some time:

>   ;------------
>   ; luddite mode
>   (tool-bar-mode -1)
>   (global-set-key [f12] '(lambda ()
>                            (interactive)
>                            (menu-bar-mode -1)
>                            (scroll-bar-mode)
>                            (setq use-dialog-box nil)
>                            ))

I don't know what this is meant to do, so I don't see where you need the
toggle behavior.

Note that in Emacs-23, when calling a minor-mode with nil (or no)
argument to turn it off, it usually outputted a warning (because
practice showed that such calls are usually erroneous).

> Allow me to quote the documentation for menu-bar-mode:
>   "Toggle display of a menu bar on each frame."
> And again for scroll-bar-mode:
>   "Toggle display of vertical scroll bars on all frames."

And indeed M-x menu-bar-mode toggles, just like M-x scroll-bar-mode.
Only the non-interactive calls are affected.

        Stefan