From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: Re: find-file-not-found-functions Date: Thu, 27 May 2004 17:08:31 -0500 (CDT) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200405272208.i4RM8Vt21099@raven.dms.auburn.edu> References: <200405252058.i4PKwZH25711@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1085704617 19189 80.91.224.253 (28 May 2004 00:36:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 28 May 2004 00:36:57 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Fri May 28 02:36:45 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BTVMb-0003M1-00 for ; Fri, 28 May 2004 02:36:45 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BTVMb-0007gc-00 for ; Fri, 28 May 2004 02:36:45 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BTTUk-0007VV-Dd for emacs-devel@quimby.gnus.org; Thu, 27 May 2004 18:37:02 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BTTTj-0007Ke-C9 for emacs-devel@gnu.org; Thu, 27 May 2004 18:35:59 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BTT4M-00030u-Nb for emacs-devel@gnu.org; Thu, 27 May 2004 18:10:19 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BTT3p-0002re-Jd; Thu, 27 May 2004 18:09:13 -0400 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id i4RM9CuE017801; Thu, 27 May 2004 17:09:13 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.6+Sun/8.11.6) id i4RM8Vt21099; Thu, 27 May 2004 17:08:31 -0500 (CDT) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: rms@gnu.org In-reply-to: (message from Richard Stallman on Thu, 27 May 2004 08:46:17 -0400) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:24044 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:24044 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) ============================================================