diff options
author | Stefan Monnier <[email protected]> | 2011-01-24 15:34:44 -0500 |
---|---|---|
committer | Stefan Monnier <[email protected]> | 2011-01-24 15:34:44 -0500 |
commit | 10e1d5f30f7ccb099106a3644776ed68db98b2d7 (patch) | |
tree | b262a31b2816b68efbd02740503b32efbd60f4ae | |
parent | 01739ccca08a95973b11e95a2d7a1fccfc63791a (diff) |
* files.el (file-name-non-special): Only change buffer-file-name after
insert-file-contents if it's `visit'ing the file.
Fixes: debbugs:7854
-rw-r--r-- | lisp/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/files.el | 27 |
2 files changed, 17 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4a8efcde0f..820a54fd2f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2011-01-24 Stefan Monnier <[email protected]> + + * files.el (file-name-non-special): Only change buffer-file-name after + insert-file-contents if it's `visit'ing the file (bug#7854). + 2011-01-23 Chong Yidong <[email protected]> * dired.el (dired-revert): Doc fix (Bug#7758). diff --git a/lisp/files.el b/lisp/files.el index 92029b470f..ee77975e38 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6041,8 +6041,7 @@ only these files will be asked to be saved." (substitute-in-file-name identity) ;; `add' means add "/:" to the result. (file-truename add 0) - ;; `quote' means add "/:" to buffer-file-name. - (insert-file-contents quote 0) + (insert-file-contents insert-file-contents 0) ;; `unquote-then-quote' means set buffer-file-name ;; temporarily to unquoted filename. (verify-visited-file-modtime unquote-then-quote) @@ -6073,20 +6072,18 @@ only these files will be asked to be saved." "/" (substring (car pair) 2))))) (setq file-arg-indices (cdr file-arg-indices)))) - (cond ((eq method 'identity) - (car arguments)) - ((eq method 'add) - (concat "/:" (apply operation arguments))) - ((eq method 'quote) - (unwind-protect + (case method + (identity (car arguments)) + (add (concat "/:" (apply operation arguments))) + (insert-file-contents + (let ((visit (nth 1 arguments))) + (prog1 (apply operation arguments) - (setq buffer-file-name (concat "/:" buffer-file-name)))) - ((eq method 'unquote-then-quote) - (let (res) - (setq buffer-file-name (substring buffer-file-name 2)) - (setq res (apply operation arguments)) - (setq buffer-file-name (concat "/:" buffer-file-name)) - res)) + (when (and visit buffer-file-name) + (setq buffer-file-name (concat "/:" buffer-file-name)))))) + (unquote-then-quote + (let ((buffer-file-name (substring buffer-file-name 2))) + (apply operation arguments))) (t (apply operation arguments))))) |