emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: find-file-not-found-functions


From: Luc Teirlinck
Subject: Re: find-file-not-found-functions
Date: Thu, 27 May 2004 17:08:31 -0500 (CDT)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]