unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* find-file-not-found-functions
@ 2004-05-25 20:58 Luc Teirlinck
  2004-05-27 12:46 ` find-file-not-found-functions Richard Stallman
  0 siblings, 1 reply; 4+ messages in thread
From: Luc Teirlinck @ 2004-05-25 20:58 UTC (permalink / raw)


A little while ago, I made a change to find-file-noselect-1 that
limited the scope of the `inhibit-read-only' binding in such a way
that `inhibit-read-only' became nil during the execution of
`find-file-not-found-functions' and `find-file-hook'.  Before, it was
bound to t.  The reason for the change was that the t binding was not
documented and that, in the case of `find-file-hook', it caused a bug.

As a side effect of fixing a bug in my previous change,
`inhibit-read-only' is back to t during the execution of
`find-file-not-found-functions'.  I now believe that, while my
previous change made sense for `find-file-hook', it might have been a
bad idea for `find-file-not-found-functions'.  I have the impression
that PC-look-for-include-file and maybe other functions rely on
inhibit-read-only being t.

What about just _documenting_ the fact that `inhibit-read-only' is t
during the execution of `find-file-not-found-functions'?  I could do
this, if desired (docstring and Elisp manual).

Sincerely,

Luc.

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

* Re: find-file-not-found-functions
  2004-05-25 20:58 find-file-not-found-functions Luc Teirlinck
@ 2004-05-27 12:46 ` Richard Stallman
  2004-05-27 22:08   ` find-file-not-found-functions Luc Teirlinck
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Stallman @ 2004-05-27 12:46 UTC (permalink / raw)
  Cc: emacs-devel

      I now believe that, while my
    previous change made sense for `find-file-hook', it might have been a
    bad idea for `find-file-not-found-functions'.  I have the impression
    that PC-look-for-include-file and maybe other functions rely on
    inhibit-read-only being t.

It is cleaner not to set the flag over a large area.
I think the hook functions should be fixed instead.

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

* Re: find-file-not-found-functions
  2004-05-27 12:46 ` find-file-not-found-functions Richard Stallman
@ 2004-05-27 22:08   ` Luc Teirlinck
  2004-05-29  1:44     ` find-file-not-found-functions Richard Stallman
  0 siblings, 1 reply; 4+ messages in thread
From: Luc Teirlinck @ 2004-05-27 22:08 UTC (permalink / raw)
  Cc: emacs-devel

Richard Stallman wrote:

   It is cleaner not to set the flag over a large area.
   I think the hook functions should be fixed instead.

So what about the following patch?  It makes inhibit-read-only nil
again during execution of `find-file-not-found-functions'.  At second
look, inhibit-read-only does not need to be set to t in
PC-look-for-include-file, because it calls erase-buffer and
insert-file-contents in a buffer returned by create-file-buffer,
which, unless I misunderstand, is guaranteed to return a new, empty,
writable buffer (which makes one wonder why erase-buffer is called in
the first place).

===File ~/files-diff========================================
*** files.el	25 May 2004 12:57:44 -0500	1.696
--- files.el	27 May 2004 14:40:56 -0500	
***************
*** 1365,1397 ****
        (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 ()
! 	      (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)
--- 1365,1399 ----
        (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 ()
! 	      (let ((inhibit-read-only t))
! 		(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-not-found-functions
  2004-05-27 22:08   ` find-file-not-found-functions Luc Teirlinck
@ 2004-05-29  1:44     ` Richard Stallman
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2004-05-29  1:44 UTC (permalink / raw)
  Cc: emacs-devel

This patch looks like the right thing.

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

end of thread, other threads:[~2004-05-29  1:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-25 20:58 find-file-not-found-functions Luc Teirlinck
2004-05-27 12:46 ` find-file-not-found-functions Richard Stallman
2004-05-27 22:08   ` find-file-not-found-functions Luc Teirlinck
2004-05-29  1:44     ` find-file-not-found-functions Richard Stallman

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