emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r99647: Add .dir-locals.el support fo


From: Dan Nicolaescu
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r99647: Add .dir-locals.el support for file-less buffers.
Date: Fri, 12 Mar 2010 00:04:54 -0800
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 99647
committer: Dan Nicolaescu <address@hidden>
branch nick: trunk
timestamp: Fri 2010-03-12 00:04:54 -0800
message:
  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.
modified:
  etc/NEWS
  lisp/ChangeLog
  lisp/diff-mode.el
  lisp/files.el
  lisp/log-edit.el
  lisp/log-view.el
  lisp/vc-annotate.el
  lisp/vc-dir.el
=== modified file 'etc/NEWS'
--- a/etc/NEWS  2010-03-12 01:29:30 +0000
+++ b/etc/NEWS  2010-03-12 08:04:54 +0000
@@ -40,6 +40,11 @@
 
 *** vc-dir for Bzr supports viewing shelve contents and shelving snapshots.
 
+** Directory local variables can apply to file-less buffers.
+For example, adding "(diff-mode . ((mode . whitespace)))" to your
+.dir-locals.el file, will turn on `whitespace-mode' for *vc-diff*
+buffers.
+
 
 * New Modes and Packages in Emacs 24.1
 

=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-03-12 01:29:30 +0000
+++ b/lisp/ChangeLog    2010-03-12 08:04:54 +0000
@@ -1,3 +1,21 @@
+2010-03-12    <address@hidden>
+
+
+2010-03-12  Dan Nicolaescu  <address@hidden>
+
+       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.
+
 2010-03-12  Dan Nicolaescu  <address@hidden>
 
        Add support for shelving snapshots and for showing shelves.

=== modified file 'lisp/diff-mode.el'
--- a/lisp/diff-mode.el 2010-01-13 08:35:10 +0000
+++ b/lisp/diff-mode.el 2010-03-12 08:04:54 +0000
@@ -1287,7 +1287,9 @@
   (set (make-local-variable 'add-log-current-defun-function)
        'diff-current-defun)
   (set (make-local-variable 'add-log-buffer-file-name-function)
-       (lambda () (diff-find-file-name nil 'noprompt))))
+       (lambda () (diff-find-file-name nil 'noprompt)))
+  (unless (buffer-file-name)
+    (hack-dir-local-variables-non-file-buffer)))
 
 ;;;###autoload
 (define-minor-mode diff-minor-mode

=== modified file 'lisp/files.el'
--- a/lisp/files.el     2010-03-12 01:29:30 +0000
+++ b/lisp/files.el     2010-03-12 08:04:54 +0000
@@ -3112,14 +3112,17 @@
          ;; 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 @@
 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 @@
              (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.

=== modified file 'lisp/log-edit.el'
--- a/lisp/log-edit.el  2010-01-28 05:19:23 +0000
+++ b/lisp/log-edit.el  2010-03-12 08:04:54 +0000
@@ -368,7 +368,8 @@
 \\{log-edit-mode-map}"
   (set (make-local-variable 'font-lock-defaults)
        '(log-edit-font-lock-keywords t))
-  (make-local-variable 'log-edit-comment-ring-index))
+  (make-local-variable 'log-edit-comment-ring-index)
+  (hack-dir-local-variables-non-file-buffer))
 
 (defun log-edit-hide-buf (&optional buf where)
   (when (setq buf (get-buffer (or buf log-edit-files-buf)))

=== modified file 'lisp/log-view.el'
--- a/lisp/log-view.el  2010-01-15 03:59:04 +0000
+++ b/lisp/log-view.el  2010-03-12 08:04:54 +0000
@@ -255,7 +255,8 @@
        'log-view-beginning-of-defun)
   (set (make-local-variable 'end-of-defun-function)
        'log-view-end-of-defun)
-  (set (make-local-variable 'cvs-minor-wrap-function) 'log-view-minor-wrap))
+  (set (make-local-variable 'cvs-minor-wrap-function) 'log-view-minor-wrap)
+  (hack-dir-local-variables-non-file-buffer))
 
 ;;;;
 ;;;; Navigation

=== modified file 'lisp/vc-annotate.el'
--- a/lisp/vc-annotate.el       2010-01-25 09:04:59 +0000
+++ b/lisp/vc-annotate.el       2010-03-12 08:04:54 +0000
@@ -162,7 +162,8 @@
   (remove-from-invisibility-spec 'foo)
   (set (make-local-variable 'truncate-lines) t)
   (set (make-local-variable 'font-lock-defaults)
-       '(vc-annotate-font-lock-keywords t)))
+       '(vc-annotate-font-lock-keywords t))
+  (hack-dir-local-variables-non-file-buffer))
 
 (defun vc-annotate-toggle-annotation-visibility ()
   "Toggle whether or not the annotation is visible."

=== modified file 'lisp/vc-dir.el'
--- a/lisp/vc-dir.el    2010-01-17 20:36:21 +0000
+++ b/lisp/vc-dir.el    2010-03-12 08:04:54 +0000
@@ -938,6 +938,7 @@
     ;; Make sure that if the directory buffer is killed, the update
     ;; process running in the background is also killed.
     (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t)
+    (hack-dir-local-variables-non-file-buffer)
     (vc-dir-refresh)))
 
 (defun vc-dir-headers (backend dir)


reply via email to

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