diff options
author | Luc Teirlinck <teirllm@auburn.edu> | 2004-05-20 23:32:27 +0000 |
---|---|---|
committer | Luc Teirlinck <teirllm@auburn.edu> | 2004-05-20 23:32:27 +0000 |
commit | 4edcfd1772d0f58c6000a41b9ae3ab7796266e47 (patch) | |
tree | 3a04932e212512c5af10ff879a51f43a60428cc8 /lisp | |
parent | 931285e29dea839234cb8276fea6c621c8163a96 (diff) | |
download | emacs-4edcfd1772d0f58c6000a41b9ae3ab7796266e47.tar.gz emacs-4edcfd1772d0f58c6000a41b9ae3ab7796266e47.tar.bz2 emacs-4edcfd1772d0f58c6000a41b9ae3ab7796266e47.zip |
(find-file-noselect-1): Limit the scope of the
`inhibit-read-only' binding. Make sure that `inhibit-read-only'
is, by default, nil during the execution of
`find-file-not-found-functions' and `find-file-hook'.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ChangeLog | 7 | ||||
-rw-r--r-- | lisp/files.el | 57 |
2 files changed, 36 insertions, 28 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index a6271544405..00e75ded5ec 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2004-05-20 Luc Teirlinck <teirllm@auburn.edu> + + * files.el (find-file-noselect-1): Limit the scope of the + `inhibit-read-only' binding. Make sure that `inhibit-read-only' + is, by default, nil during the execution of + `find-file-not-found-functions' and `find-file-hook'. + 2004-05-20 Michael Mauger <mmaug@yahoo.com> * facemenu.el (facemenu-color-name-equal): New function. diff --git a/lisp/files.el b/lisp/files.el index 99cad16cf5b..dd3a45e09e1 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -1357,41 +1357,42 @@ that are visiting the various files." rawfile truename number)))))) (defun find-file-noselect-1 (buf filename nowarn rawfile truename number) - (let ((inhibit-read-only t) - error) + (let (error) (with-current-buffer buf (kill-local-variable 'find-file-literally) ;; Needed in case we are re-visiting the file with a different ;; text representation. (kill-local-variable 'buffer-file-coding-system) (kill-local-variable 'cursor-type) - (erase-buffer) - (and (default-value 'enable-multibyte-characters) - (not rawfile) - (set-buffer-multibyte t)) - (if rawfile - (condition-case () - (insert-file-contents-literally filename t) - (file-error - (when (and (file-exists-p filename) - (not (file-readable-p filename))) - (kill-buffer buf) - (signal 'file-error (list "File is not readable" - filename))) - ;; Unconditionally set error - (setq error t))) - (condition-case () - (insert-file-contents filename t) - (file-error - (when (and (file-exists-p filename) - (not (file-readable-p filename))) - (kill-buffer buf) - (signal 'file-error (list "File is not readable" - filename))) - ;; Run find-file-not-found-hooks until one returns non-nil. - (or (run-hook-with-args-until-success 'find-file-not-found-functions) - ;; If they fail too, set error. + (let ((inhibit-read-only t)) + (erase-buffer) + (and (default-value 'enable-multibyte-characters) + (not rawfile) + (set-buffer-multibyte t)) + (if rawfile + (condition-case () + (insert-file-contents-literally filename t) + (file-error + (when (and (file-exists-p filename) + (not (file-readable-p filename))) + (kill-buffer buf) + (signal 'file-error (list "File is not readable" + filename))) + ;; Unconditionally set error (setq error t))))) + (condition-case () + (let ((inhibit-read-only t)) + (insert-file-contents filename t)) + (file-error + (when (and (file-exists-p filename) + (not (file-readable-p filename))) + (kill-buffer buf) + (signal 'file-error (list "File is not readable" + filename))) + ;; Run find-file-not-found-hooks until one returns non-nil. + (or (run-hook-with-args-until-success 'find-file-not-found-functions) + ;; If they fail too, set error. + (setq error t)))) ;; Record the file's truename, and maybe use that as visited name. (if (equal filename buffer-file-name) (setq buffer-file-truename truename) |