aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2010-03-12 00:04:54 -0800
committerDan Nicolaescu2010-03-12 00:04:54 -0800
commit8117868f0ce67b6db33081f77b6715a6c10e45b8 (patch)
treeaa88ce85bb40558a9d726141b2bf9a3cebccba5e
parent49a62e8aad8eee350511104415062f6b82f51973 (diff)
downloademacs-8117868f0ce67b6db33081f77b6715a6c10e45b8.tar.gz
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.
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/ChangeLog18
-rw-r--r--lisp/diff-mode.el4
-rw-r--r--lisp/files.el30
-rw-r--r--lisp/log-edit.el3
-rw-r--r--lisp/log-view.el3
-rw-r--r--lisp/vc-annotate.el3
-rw-r--r--lisp/vc-dir.el1
8 files changed, 51 insertions, 16 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 82c63f4449b..fcc08e7b6e5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -40,6 +40,11 @@ so we will look at it and add it to the manual.
40 40
41*** vc-dir for Bzr supports viewing shelve contents and shelving snapshots. 41*** vc-dir for Bzr supports viewing shelve contents and shelving snapshots.
42 42
43** Directory local variables can apply to file-less buffers.
44For example, adding "(diff-mode . ((mode . whitespace)))" to your
45.dir-locals.el file, will turn on `whitespace-mode' for *vc-diff*
46buffers.
47
43 48
44* New Modes and Packages in Emacs 24.1 49* New Modes and Packages in Emacs 24.1
45 50
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e7f4f17d549..1e54ed03a90 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,21 @@
12010-03-12 <dann@ics.uci.edu>
2
3
42010-03-12 Dan Nicolaescu <dann@ics.uci.edu>
5
6 Add .dir-locals.el support for file-less buffers.
7 * files.el (hack-local-variables): Split out code to apply local
8 variable settings ...
9 (hack-local-variables-apply): ... here. New function.
10 (hack-dir-local-variables): Use the default directory for when the
11 buffer does not have an associated file.
12 (hack-dir-local-variables-non-file-buffer): New function.
13 * diff-mode.el (diff-mode):
14 * vc-annotate.el (vc-annotate-mode):
15 * vc-dir.el (vc-dir-mode):
16 * log-edit.el (log-edit-mode):
17 * log-view.el (log-view-mode): Call hack-dir-local-variables-non-file-buffer.
18
12010-03-12 Dan Nicolaescu <dann@ics.uci.edu> 192010-03-12 Dan Nicolaescu <dann@ics.uci.edu>
2 20
3 Add support for shelving snapshots and for showing shelves. 21 Add support for shelving snapshots and for showing shelves.
diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el
index 27f8318f91c..75ea98ba911 100644
--- a/lisp/diff-mode.el
+++ b/lisp/diff-mode.el
@@ -1287,7 +1287,9 @@ a diff with \\[diff-reverse-direction].
1287 (set (make-local-variable 'add-log-current-defun-function) 1287 (set (make-local-variable 'add-log-current-defun-function)
1288 'diff-current-defun) 1288 'diff-current-defun)
1289 (set (make-local-variable 'add-log-buffer-file-name-function) 1289 (set (make-local-variable 'add-log-buffer-file-name-function)
1290 (lambda () (diff-find-file-name nil 'noprompt)))) 1290 (lambda () (diff-find-file-name nil 'noprompt)))
1291 (unless (buffer-file-name)
1292 (hack-dir-local-variables-non-file-buffer)))
1291 1293
1292;;;###autoload 1294;;;###autoload
1293(define-minor-mode diff-minor-mode 1295(define-minor-mode diff-minor-mode
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."
3112 ;; Otherwise, set the variables. 3112 ;; Otherwise, set the variables.
3113 (enable-local-variables 3113 (enable-local-variables
3114 (hack-local-variables-filter result nil) 3114 (hack-local-variables-filter result nil)
3115 (when file-local-variables-alist 3115 (hack-local-variables-apply)))))
3116 ;; Any 'evals must run in the Right sequence. 3116
3117 (setq file-local-variables-alist 3117(defun hack-local-variables-apply ()
3118 (nreverse file-local-variables-alist)) 3118 (when file-local-variables-alist
3119 (run-hooks 'before-hack-local-variables-hook) 3119 ;; Any 'evals must run in the Right sequence.
3120 (dolist (elt file-local-variables-alist) 3120 (setq file-local-variables-alist
3121 (hack-one-local-variable (car elt) (cdr elt)))) 3121 (nreverse file-local-variables-alist))
3122 (run-hooks 'hack-local-variables-hook))))) 3122 (run-hooks 'before-hack-local-variables-hook)
3123 (dolist (elt file-local-variables-alist)
3124 (hack-one-local-variable (car elt) (cdr elt))))
3125 (run-hooks 'hack-local-variables-hook))
3123 3126
3124(defun safe-local-variable-p (sym val) 3127(defun safe-local-variable-p (sym val)
3125 "Non-nil if SYM is safe as a file-local variable with value VAL. 3128 "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."
3413Store the directory-local variables in `dir-local-variables-alist' 3416Store the directory-local variables in `dir-local-variables-alist'
3414and `file-local-variables-alist', without applying them." 3417and `file-local-variables-alist', without applying them."
3415 (when (and enable-local-variables 3418 (when (and enable-local-variables
3416 (buffer-file-name) 3419 (not (file-remote-p (or (buffer-file-name) default-directory))))
3417 (not (file-remote-p (buffer-file-name))))
3418 ;; Find the variables file. 3420 ;; Find the variables file.
3419 (let ((variables-file (dir-locals-find-file (buffer-file-name))) 3421 (let ((variables-file (dir-locals-find-file (or (buffer-file-name) default-directory)))
3420 (class nil) 3422 (class nil)
3421 (dir-name nil)) 3423 (dir-name nil))
3422 (cond 3424 (cond
3423 ((stringp variables-file) 3425 ((stringp variables-file)
3424 (setq dir-name (file-name-directory (buffer-file-name))) 3426 (setq dir-name (if (buffer-file-name) (file-name-directory (buffer-file-name)) default-directory))
3425 (setq class (dir-locals-read-from-file variables-file))) 3427 (setq class (dir-locals-read-from-file variables-file)))
3426 ((consp variables-file) 3428 ((consp variables-file)
3427 (setq dir-name (nth 0 variables-file)) 3429 (setq dir-name (nth 0 variables-file))
@@ -3438,6 +3440,10 @@ and `file-local-variables-alist', without applying them."
3438 (push elt dir-local-variables-alist)) 3440 (push elt dir-local-variables-alist))
3439 (hack-local-variables-filter variables dir-name))))))) 3441 (hack-local-variables-filter variables dir-name)))))))
3440 3442
3443(defun hack-dir-local-variables-non-file-buffer ()
3444 (hack-dir-local-variables)
3445 (hack-local-variables-apply))
3446
3441 3447
3442(defcustom change-major-mode-with-file-name t 3448(defcustom change-major-mode-with-file-name t
3443 "Non-nil means \\[write-file] should set the major mode from the file name. 3449 "Non-nil means \\[write-file] should set the major mode from the file name.
diff --git a/lisp/log-edit.el b/lisp/log-edit.el
index 10c6d480d23..e26521642da 100644
--- a/lisp/log-edit.el
+++ b/lisp/log-edit.el
@@ -368,7 +368,8 @@ commands (under C-x v for VC, for example).
368\\{log-edit-mode-map}" 368\\{log-edit-mode-map}"
369 (set (make-local-variable 'font-lock-defaults) 369 (set (make-local-variable 'font-lock-defaults)
370 '(log-edit-font-lock-keywords t)) 370 '(log-edit-font-lock-keywords t))
371 (make-local-variable 'log-edit-comment-ring-index)) 371 (make-local-variable 'log-edit-comment-ring-index)
372 (hack-dir-local-variables-non-file-buffer))
372 373
373(defun log-edit-hide-buf (&optional buf where) 374(defun log-edit-hide-buf (&optional buf where)
374 (when (setq buf (get-buffer (or buf log-edit-files-buf))) 375 (when (setq buf (get-buffer (or buf log-edit-files-buf)))
diff --git a/lisp/log-view.el b/lisp/log-view.el
index 6fbe8429671..5c454ead5fc 100644
--- a/lisp/log-view.el
+++ b/lisp/log-view.el
@@ -255,7 +255,8 @@ The match group number 1 should match the revision number itself.")
255 'log-view-beginning-of-defun) 255 'log-view-beginning-of-defun)
256 (set (make-local-variable 'end-of-defun-function) 256 (set (make-local-variable 'end-of-defun-function)
257 'log-view-end-of-defun) 257 'log-view-end-of-defun)
258 (set (make-local-variable 'cvs-minor-wrap-function) 'log-view-minor-wrap)) 258 (set (make-local-variable 'cvs-minor-wrap-function) 'log-view-minor-wrap)
259 (hack-dir-local-variables-non-file-buffer))
259 260
260;;;; 261;;;;
261;;;; Navigation 262;;;; Navigation
diff --git a/lisp/vc-annotate.el b/lisp/vc-annotate.el
index 71839443553..1878fe8740f 100644
--- a/lisp/vc-annotate.el
+++ b/lisp/vc-annotate.el
@@ -162,7 +162,8 @@ menu items."
162 (remove-from-invisibility-spec 'foo) 162 (remove-from-invisibility-spec 'foo)
163 (set (make-local-variable 'truncate-lines) t) 163 (set (make-local-variable 'truncate-lines) t)
164 (set (make-local-variable 'font-lock-defaults) 164 (set (make-local-variable 'font-lock-defaults)
165 '(vc-annotate-font-lock-keywords t))) 165 '(vc-annotate-font-lock-keywords t))
166 (hack-dir-local-variables-non-file-buffer))
166 167
167(defun vc-annotate-toggle-annotation-visibility () 168(defun vc-annotate-toggle-annotation-visibility ()
168 "Toggle whether or not the annotation is visible." 169 "Toggle whether or not the annotation is visible."
diff --git a/lisp/vc-dir.el b/lisp/vc-dir.el
index 2f661e8becf..a0350eb3013 100644
--- a/lisp/vc-dir.el
+++ b/lisp/vc-dir.el
@@ -938,6 +938,7 @@ the *vc-dir* buffer.
938 ;; Make sure that if the directory buffer is killed, the update 938 ;; Make sure that if the directory buffer is killed, the update
939 ;; process running in the background is also killed. 939 ;; process running in the background is also killed.
940 (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t) 940 (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t)
941 (hack-dir-local-variables-non-file-buffer)
941 (vc-dir-refresh))) 942 (vc-dir-refresh)))
942 943
943(defun vc-dir-headers (backend dir) 944(defun vc-dir-headers (backend dir)