unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* find-file-noselect-1 bug
@ 2004-05-25 14:07 David Ponce
  2004-05-25 17:47 ` Luc Teirlinck
  2004-05-25 18:56 ` Luc Teirlinck
  0 siblings, 2 replies; 4+ messages in thread
From: David Ponce @ 2004-05-25 14:07 UTC (permalink / raw)


Hi All,

Since this change:

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'.

`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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: find-file-noselect-1 bug
  2004-05-25 14:07 find-file-noselect-1 bug David Ponce
@ 2004-05-25 17:47 ` Luc Teirlinck
  2004-05-25 18:56 ` Luc Teirlinck
  1 sibling, 0 replies; 4+ messages in thread
From: Luc Teirlinck @ 2004-05-25 17:47 UTC (permalink / raw)
  Cc: emacs-devel

David Ponce wrote:

   Since this change:

   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'.

   `find-file-noselect-1' fails with error "Cannot do file visiting in a
   non-empty buffer" when the RAWFILE argument is non-nil.

Yes, I messed this up.  I will install a fix soon.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: find-file-noselect-1 bug
  2004-05-25 14:07 find-file-noselect-1 bug David Ponce
  2004-05-25 17:47 ` Luc Teirlinck
@ 2004-05-25 18:56 ` Luc Teirlinck
  2004-05-25 20:21   ` David Ponce
  1 sibling, 1 reply; 4+ messages in thread
From: Luc Teirlinck @ 2004-05-25 18:56 UTC (permalink / raw)
  Cc: emacs-devel

David Ponce wrote:

   Since this change:

   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'.

   `find-file-noselect-1' fails with error "Cannot do file visiting in a
   non-empty buffer" when the RAWFILE argument is non-nil.

Should be fixed now.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: find-file-noselect-1 bug
  2004-05-25 18:56 ` Luc Teirlinck
@ 2004-05-25 20:21   ` David Ponce
  0 siblings, 0 replies; 4+ messages in thread
From: David Ponce @ 2004-05-25 20:21 UTC (permalink / raw)
  Cc: emacs-devel

>    `find-file-noselect-1' fails with error "Cannot do file visiting in a
>    non-empty buffer" when the RAWFILE argument is non-nil.
> 
> Should be fixed now.

It is.  Thanks!

David

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-05-25 20:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-25 14:07 find-file-noselect-1 bug David Ponce
2004-05-25 17:47 ` Luc Teirlinck
2004-05-25 18:56 ` Luc Teirlinck
2004-05-25 20:21   ` David Ponce

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).