emacs-devel
[Top][All Lists]
Advanced

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

Re: file local variables


From: Juri Linkov
Subject: Re: file local variables
Date: Mon, 14 Dec 2009 23:29:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.90 (x86_64-pc-linux-gnu)

> File local variables doesn't work as expected. If you 'emacs -Q' a file with
>
> Local Variables:
> mode: text
> mode: auto-fill
> End:
>
> or with any other combination of a major and a minor mode, then the major
> mode is ignored. Is this a bug? This works fine with emacs-23.1, where both
> modes are activated...

(info "(emacs) Specifying File Variables") says:

     You can use the `mode' "variable" to set minor modes as well as the
  major modes; in fact, you can use it more than once, first to set the
  major mode and then to set minor modes which are specific to particular
  buffers.  But most minor modes should not be specified in the file at
  all, because they represent user preferences.

Since the user should be able to specify minor modes more than once,
the following patch fixes this by allowing duplicate modes:

=== modified file 'lisp/files.el'
--- lisp/files.el       2009-11-25 17:11:29 +0000
+++ lisp/files.el       2009-12-14 21:28:58 +0000
@@ -2978,8 +2978,8 @@
                 (or (eq enable-local-eval t)
                     (hack-one-local-variable-eval-safep (eval (quote val)))
                     (push elt unsafe-vars))))
-             ;; Ignore duplicates in the present list.
-             ((assq var all-vars) nil)
+             ;; Ignore duplicates (except `mode') in the present list.
+             ((and (assq var all-vars) (not (eq var 'mode))) nil)
              ;; Accept known-safe variables.
              ((or (memq var '(mode unibyte coding))
                   (safe-local-variable-p var val))
@@ -2999,7 +2999,7 @@
             (hack-local-variables-confirm all-vars unsafe-vars
                                           risky-vars dir-name))
         (dolist (elt all-vars)
-          (unless (eq (car elt) 'eval)
+          (unless (memq (car elt) '(eval mode))
             (unless dir-name
               (setq dir-local-variables-alist
                     (assq-delete-all (car elt) dir-local-variables-alist)))
@@ -3427,7 +3427,7 @@
                (dir-locals-get-class-variables class) dir-name nil)))
          (when variables
            (dolist (elt variables)
-             (unless (eq (car elt) 'eval)
+             (unless (memq (car elt) '(eval mode))
                (setq dir-local-variables-alist
                      (assq-delete-all (car elt) dir-local-variables-alist)))
              (push elt dir-local-variables-alist))

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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