Mercurial > emacs
changeset 55709:166093a56a5b
(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'.
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Thu, 20 May 2004 23:29:24 +0000 |
parents | 7be5e286a97a |
children | 23826e112618 |
files | lisp/files.el |
diffstat | 1 files changed, 29 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/files.el Thu May 20 17:33:35 2004 +0000 +++ b/lisp/files.el Thu May 20 23:29:24 2004 +0000 @@ -1357,41 +1357,42 @@ 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)