[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: vc-follow-symlinks confirm message is not read only
From: |
Luc Teirlinck |
Subject: |
Re: vc-follow-symlinks confirm message is not read only |
Date: |
Mon, 10 May 2004 22:05:39 -0500 (CDT) |
Stefan Monnier wrote:
> find-file-noselect-1 binds inhibit-read-only to t, probably for very
> good reasons.
Well, the reasons aren't good enough to keep it bound that long.
> ! (let ((inhibit-read-only nil))
> ! (run-hooks 'find-file-hook))))
That's just very ugly. We should instead change the scope of the binding
such that it only covers the place where inhibit-read-only should indeed
be t.
What about the following patch? I had to bind inhibit-read-only in
two different places, since otherwise inhibit-read-only would have
been bound to t during the execution of find-file-not-found-functions.
It _is_ currently bound to t during that execution, but since this is
nowhere mentioned in the documentation, I would guess that this is
more of a bug than a feature. (Patch made using diff -b -c)
===File ~/files-newdiff=====================================
*** files.el.~1.690.~ Sat May 1 10:36:39 2004
--- files.el Mon May 10 21:20:00 2004
***************
*** 1358,1371 ****
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)
--- 1358,1371 ----
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)
***************
*** 1380,1388 ****
(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)))
--- 1380,1389 ----
(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)))
***************
*** 1392,1398 ****
;; 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)
--- 1393,1399 ----
;; 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)
============================================================