Subject: Re: bug#4148: mode: for a minor mode should turn on, not toggle the mode

From: Dan Nicolaescu <[email-masked]>
Date: Sat, 15 Aug 2009 11:54:28 -0700 (PDT)

Chong Yidong <[email-masked]> writes:

  > > A well known long standing problem:
  > > using 
  > > mode: SOME_MINOR_MODE
  > 
  > > in a local variable section (or in .dir-locals.el) toggles the minor
  > > mode, it should turn it on.
  > 
  > > So if the user sets a hook to turn on the minor mode in her emacs, when
  > > using a file that sets the same minor mode, the minor mode ends up being
  > > disable.
  > 
  > Does this patch DTRT?
  > 
  > *** trunk/lisp/files.el.~1.1066.~	2009-08-14 19:37:09.000000000 -0400
  > --- trunk/lisp/files.el	2009-08-15 13:37:24.000000000 -0400
  > ***************
  > *** 3189,3195 ****
  >   				     "-mode"))))
  >   	   (unless (eq (indirect-function mode)
  >   		       (indirect-function major-mode))
  > ! 	     (funcall mode))))
  >   	((eq var 'eval)
  >   	 (save-excursion (eval val)))
  >   	(t
  > --- 3189,3199 ----
  >   				     "-mode"))))
  >   	   (unless (eq (indirect-function mode)
  >   		       (indirect-function major-mode))
  > ! 	     (if (memq mode minor-mode-list)
  > ! 		 ;; For a minor mode, enable unconditionally instead
  > ! 		 ;; of toggling (since the mode may already be on).
  > ! 		 (funcall mode 1)
  > ! 	       (funcall mode)))))
  >   	((eq var 'eval)
  >   	 (save-excursion (eval val)))
  >   	(t

Thanks, it seems to work fine.

After this gets checked in, we can re-add (mode . bug-reference) to emacs/.dir-locals.el

Any chance this patch can get onto the next release branch?