summaryrefslogtreecommitdiff
path: root/lisp/files-x.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2011-02-24 00:45:25 -0800
committerGlenn Morris <rgm@gnu.org>2011-02-24 00:45:25 -0800
commit6a88f031c8a895c87143da01201502e966aa7641 (patch)
tree2646f7cd332679c445763dfe7024454fc763e9ca /lisp/files-x.el
parent303f9ae0146c9bc42985e98a07b86be0cb1c6eca (diff)
downloademacs-6a88f031c8a895c87143da01201502e966aa7641.tar.gz
Yet more directory-local variables fixes.
* lisp/files-x.el (modify-dir-local-variable): Handle dir-locals from the cache, and from non-file sources.
Diffstat (limited to 'lisp/files-x.el')
-rw-r--r--lisp/files-x.el22
1 files changed, 16 insertions, 6 deletions
diff --git a/lisp/files-x.el b/lisp/files-x.el
index a3cb5331e67..a9c32477155 100644
--- a/lisp/files-x.el
+++ b/lisp/files-x.el
@@ -360,18 +360,28 @@ from the MODE alist ignoring the input argument VALUE."
(catch 'exit
(unless enable-local-variables
(throw 'exit (message "Directory-local variables are disabled")))
-
(let ((variables-file (or (and (buffer-file-name)
(not (file-remote-p (buffer-file-name)))
(dir-locals-find-file (buffer-file-name)))
dir-locals-file))
variables)
-
+ (if (consp variables-file) ; result from cache
+ ;; If cache element has an mtime, assume it came from a file.
+ ;; Otherwise, assume it was set directly.
+ (setq variables-file (if (nth 2 variables-file)
+ (expand-file-name dir-locals-file
+ (car variables-file))
+ (cadr variables-file))))
+ ;; I can't be bothered to handle this case right now.
+ ;; Dir locals were set directly from a class. You need to
+ ;; directly modify the class in dir-locals-class-alist.
+ (and variables-file (not (stringp variables-file))
+ (throw 'exit (message "Directory locals were not set from a file")))
;; Don't create ".dir-locals.el" for the deletion operation.
- (when (and (eq op 'delete)
- (not (file-exists-p variables-file)))
- (throw 'exit (message "File .dir-locals.el not found")))
-
+ (and (eq op 'delete)
+ (or (not variables-file)
+ (not (file-exists-p variables-file)))
+ (throw 'exit (message "No .dir-locals.el file was found")))
(let ((auto-insert nil))
(find-file variables-file))
(widen)