Mercurial > emacs
changeset 40623:c9d3bb2a90e4
(find-file-noselect): Offer to change buffer-read-only
only when the file's read-only status has changed from before
as well as disagreeing with the buffer's current status.
(buffer-file-read-only): New var, local in all buffers.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 01 Nov 2001 19:33:52 +0000 |
parents | d2bfc00496d7 |
children | eae4ef246746 |
files | lisp/files.el |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/files.el Thu Nov 01 19:32:39 2001 +0000 +++ b/lisp/files.el Thu Nov 01 19:33:52 2001 +0000 @@ -197,6 +197,10 @@ (defvar buffer-file-numbers-unique (not (memq system-type '(windows-nt))) "Non-nil means that buffer-file-number uniquely identifies files.") +(defvar buffer-file-read-only nil + "Non-nil if visited file was read-only when visited.") +(make-variable-buffer-local 'buffer-file-read-only) + (defvar file-name-invalid-regexp (cond ((and (eq system-type 'ms-dos) (not (msdos-long-file-names))) (concat "^\\([^A-Z[-`a-z]\\|..+\\)?:\\|" ; colon except after drive @@ -1071,16 +1075,19 @@ (with-current-buffer buf ;; Check if a formerly read-only file has become - ;; writable and vice versa. + ;; writable and vice versa, but if the buffer agrees + ;; with the new state of the file, that is ok too. (let ((read-only (not (file-writable-p buffer-file-name)))) - (unless (eq read-only buffer-read-only) + (unless (or (eq read-only buffer-file-read-only) + (eq read-only buffer-read-only)) (when (or nowarn (let ((question (format "File %s is %s on disk. Change buffer mode? " buffer-file-name (if read-only "read-only" "writable")))) (y-or-n-p question))) - (setq buffer-read-only read-only)))) + (setq buffer-read-only read-only))) + (setq buffer-file-read-only read-only)) (when (not (eq (not (null rawfile)) (not (null find-file-literally))))