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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8613: "mode:" for minor-mode breaks set-visited-file-name


From: Glenn Morris
Subject: bug#8613: "mode:" for minor-mode breaks set-visited-file-name
Date: Wed, 04 May 2011 22:20:00 -0400
User-agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)

Stefan Monnier wrote:

> Not a bad idea, tho I'd much rather add
> a (run-hook-with-args-until-success 'safe-local-eval-functions) instead
> rather than rely on regexps.

Regexps were the only way I could think of that did not require changes
to the definition of each minor mode, however...

> Another option is to let define-minor-mode place
> a `safe-local-eval-function' property on the minor-mode's symbol.

... that's nice and simple (I didn't know `safe-local-eval-function'
existed); but I had to tweak make-autoload to get it to work right with
autoloaded minor-modes (eg outline-minor).


*** lisp/emacs-lisp/autoload.el      2011-05-04 15:38:41 +0000
--- lisp/emacs-lisp/autoload.el      2011-05-05 02:14:30 +0000
***************
*** 190,195 ****
--- 190,197 ----
             (if (member ',file loads) nil
               (put ',groupname 'custom-loads (cons ',file loads))))))
  
+      ((eq car 'put) form)
+ 
       ;; nil here indicates that this is not a special autoload form.
       (t nil))))
  

*** lisp/emacs-lisp/easy-mmode.el       2011-01-25 04:08:28 +0000
--- lisp/emacs-lisp/easy-mmode.el       2011-05-05 00:44:36 +0000
***************
*** 115,120 ****
--- 115,122 ----
  :lighter SPEC Same as the LIGHTER argument.
  :keymap MAP   Same as the KEYMAP argument.
  :require SYM  Same as in `defcustom'.
+ :safe PROP    Set the MODE function's `safe-local-eval-function' property
+               to PROP (default t).
  :variable PLACE       The location (as can be used with `setf') to use instead
                of the variable MODE to store the state of the mode.  PLACE
                can also be of the form (GET . SET) where GET is an expression
***************
*** 156,161 ****
--- 158,164 ----
           (setter nil)            ;The function (if any) to set the mode var.
           (modefun mode)          ;The minor mode function name we're defining.
         (require t)
+        (safe t)
         (hook (intern (concat mode-name "-hook")))
         (hook-on (intern (concat mode-name "-on-hook")))
         (hook-off (intern (concat mode-name "-off-hook")))
***************
*** 174,179 ****
--- 177,183 ----
        (:group (setq group (nconc group (list :group (pop body)))))
        (:type (setq type (list :type (pop body))))
        (:require (setq require (pop body)))
+       (:safe (setq safe (pop body)))
        (:keymap (setq keymap (pop body)))
          (:variable (setq variable (pop body))
           (if (not (functionp (cdr-safe variable)))
***************
*** 264,269 ****
--- 268,275 ----
         ;; Return the new setting.
         ,mode)
  
+        (put ',modefun 'safe-local-eval-function ,safe)
+ 
         ;; Autoloading a define-minor-mode autoloads everything
         ;; up-to-here.
         :autoload-end






reply via email to

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