diff options
author | Dan Nicolaescu <dann@ics.uci.edu> | 2010-03-12 00:04:54 -0800 |
---|---|---|
committer | Dan Nicolaescu <dann@ics.uci.edu> | 2010-03-12 00:04:54 -0800 |
commit | 8117868f0ce67b6db33081f77b6715a6c10e45b8 (patch) | |
tree | aa88ce85bb40558a9d726141b2bf9a3cebccba5e /lisp/files.el | |
parent | 49a62e8aad8eee350511104415062f6b82f51973 (diff) | |
download | emacs-8117868f0ce67b6db33081f77b6715a6c10e45b8.tar.gz emacs-8117868f0ce67b6db33081f77b6715a6c10e45b8.tar.bz2 emacs-8117868f0ce67b6db33081f77b6715a6c10e45b8.zip |
Add .dir-locals.el support for file-less buffers.
* files.el (hack-local-variables): Split out code to apply local
variable settings ...
(hack-local-variables-apply): ... here. New function.
(hack-dir-local-variables): Use the default directory for when the
buffer does not have an associated file.
(hack-dir-local-variables-non-file-buffer): New function.
* diff-mode.el (diff-mode):
* vc-annotate.el (vc-annotate-mode):
* vc-dir.el (vc-dir-mode):
* log-edit.el (log-edit-mode):
* log-view.el (log-view-mode): Call hack-dir-local-variables-non-file-buffer.
Diffstat (limited to 'lisp/files.el')
-rw-r--r-- | lisp/files.el | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lisp/files.el b/lisp/files.el index 99fa7ddf1b5..07442d4ba14 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3112,14 +3112,17 @@ is specified, returning t if it is specified." ;; Otherwise, set the variables. (enable-local-variables (hack-local-variables-filter result nil) - (when file-local-variables-alist - ;; Any 'evals must run in the Right sequence. - (setq file-local-variables-alist - (nreverse file-local-variables-alist)) - (run-hooks 'before-hack-local-variables-hook) - (dolist (elt file-local-variables-alist) - (hack-one-local-variable (car elt) (cdr elt)))) - (run-hooks 'hack-local-variables-hook))))) + (hack-local-variables-apply))))) + +(defun hack-local-variables-apply () + (when file-local-variables-alist + ;; Any 'evals must run in the Right sequence. + (setq file-local-variables-alist + (nreverse file-local-variables-alist)) + (run-hooks 'before-hack-local-variables-hook) + (dolist (elt file-local-variables-alist) + (hack-one-local-variable (car elt) (cdr elt)))) + (run-hooks 'hack-local-variables-hook)) (defun safe-local-variable-p (sym val) "Non-nil if SYM is safe as a file-local variable with value VAL. @@ -3413,15 +3416,14 @@ is found. Returns the new class name." Store the directory-local variables in `dir-local-variables-alist' and `file-local-variables-alist', without applying them." (when (and enable-local-variables - (buffer-file-name) - (not (file-remote-p (buffer-file-name)))) + (not (file-remote-p (or (buffer-file-name) default-directory)))) ;; Find the variables file. - (let ((variables-file (dir-locals-find-file (buffer-file-name))) + (let ((variables-file (dir-locals-find-file (or (buffer-file-name) default-directory))) (class nil) (dir-name nil)) (cond ((stringp variables-file) - (setq dir-name (file-name-directory (buffer-file-name))) + (setq dir-name (if (buffer-file-name) (file-name-directory (buffer-file-name)) default-directory)) (setq class (dir-locals-read-from-file variables-file))) ((consp variables-file) (setq dir-name (nth 0 variables-file)) @@ -3438,6 +3440,10 @@ and `file-local-variables-alist', without applying them." (push elt dir-local-variables-alist)) (hack-local-variables-filter variables dir-name))))))) +(defun hack-dir-local-variables-non-file-buffer () + (hack-dir-local-variables) + (hack-local-variables-apply)) + (defcustom change-major-mode-with-file-name t "Non-nil means \\[write-file] should set the major mode from the file name. |