Subject: Re: bug#4455: 23.1.50; Can't turn off auto-fill-mode via mouse-minor-mode-menu

From: Stefan Monnier <[email-masked]>
Date: Wed, 16 Sep 2009 21:33:15 -0400

> 2. Click mouse-3 over the major mode indicator in the mode line and
>    select Auto fill from the pop-up menu.
> 3. Click mouse-1 over "Fill" in the mode line and select "Turn Off[sic]
>    minor mode" from the pop-up menu.
> => Auto Fill mode remains enabled.

> I traced this problem to auto-fill-function from simple.el, which is the
> value of cmd in the last when-sexp of popup-menu from mouse.el: since
> auto-fill-function is not interactive, (commandp cmd) is nil and the
> body of the when-clause, containing a call to cmd, is not evaluated.

Thank you for tracking it down.  I've installed the patch below which
should fix it.

        Stefan

--- mouse.el.~1.357.~	2009-07-21 17:38:12.000000000 -0400
+++ mouse.el	2009-09-16 21:30:41.000000000 -0400
@@ -158,7 +158,8 @@
    (list (completing-read
 	  "Minor mode indicator: "
 	  (describe-minor-mode-completion-table-for-indicator))))
-  (let ((minor-mode (lookup-minor-mode-from-indicator indicator)))
+  (let* ((minor-mode (lookup-minor-mode-from-indicator indicator))
+         (mm-fun (or (get minor-mode :minor-mode-function) minor-mode)))
     (unless minor-mode (error "Cannot find minor mode for `%s'" indicator))
     (let* ((map (cdr-safe (assq minor-mode minor-mode-map-alist)))
            (menu (and (keymapp map) (lookup-key map [menu-bar]))))
@@ -167,10 +168,10 @@
                 (mouse-menu-non-singleton menu)
 	      `(keymap
                 ,indicator
-                (turn-off menu-item "Turn Off minor mode" ,minor-mode)
+                (turn-off menu-item "Turn Off minor mode" ,mm-fun)
                 (help menu-item "Help for minor mode"
                       (lambda () (interactive)
-                        (describe-function ',minor-mode))))))
+                        (describe-function ',mm-fun))))))
       (popup-menu menu))))
 
 (defun mouse-minor-mode-menu (event)