[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
find-file-noselect-1 bug
From: |
David Ponce |
Subject: |
find-file-noselect-1 bug |
Date: |
Tue, 25 May 2004 16:07:05 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040116 |
Hi All,
Since this change:
2004-05-20 Luc Teirlinck <address@hidden>
* 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'.
`find-file-noselect-1' fails with error "Cannot do file visiting in a
non-empty buffer" when the RAWFILE argument is non-nil. In the
following patch, that corresponds to the above change, it looks that
the else clause of the first `(if rawfile ...)' statement is now
executed unconditionally, so that, when RAWFILE is non-nil, the first
`insert-file-contents-literally' is followed by a second
`insert-file-contents' which obviously fails with the above error.
Any idea on a correct fix?
David
Index: files.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/files.el,v
retrieving revision 1.693
retrieving revision 1.694
diff -c -r1.693 -r1.694
*** files.el 19 May 2004 00:30:43 -0000 1.693
--- files.el 20 May 2004 23:29:24 -0000 1.694
***************
*** 1357,1397 ****
rawfile truename number))))))
(defun find-file-noselect-1 (buf filename nowarn rawfile truename number)
! (let ((inhibit-read-only t)
! 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.
(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)
--- 1357,1398 ----
rawfile truename number))))))
(defun find-file-noselect-1 (buf filename nowarn rawfile truename number)
! (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)
! (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)
- find-file-noselect-1 bug,
David Ponce <=