diff options
| author | Richard M. Stallman | 2001-11-01 19:33:52 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2001-11-01 19:33:52 +0000 |
| commit | e554eeb7eee3748d2e51f8526a1ea42e59298b28 (patch) | |
| tree | 8ad34769229fe8c0ba3b03d58b05a86f797efbaa | |
| parent | 6a0d92d35debd0244c413bc5b2787a436a2c9023 (diff) | |
| download | emacs-e554eeb7eee3748d2e51f8526a1ea42e59298b28.tar.gz emacs-e554eeb7eee3748d2e51f8526a1ea42e59298b28.zip | |
(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.
| -rw-r--r-- | lisp/files.el | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lisp/files.el b/lisp/files.el index 167514efcf0..75937f7a86d 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -197,6 +197,10 @@ If the buffer is visiting a new file, the value is nil.") | |||
| 197 | (defvar buffer-file-numbers-unique (not (memq system-type '(windows-nt))) | 197 | (defvar buffer-file-numbers-unique (not (memq system-type '(windows-nt))) |
| 198 | "Non-nil means that buffer-file-number uniquely identifies files.") | 198 | "Non-nil means that buffer-file-number uniquely identifies files.") |
| 199 | 199 | ||
| 200 | (defvar buffer-file-read-only nil | ||
| 201 | "Non-nil if visited file was read-only when visited.") | ||
| 202 | (make-variable-buffer-local 'buffer-file-read-only) | ||
| 203 | |||
| 200 | (defvar file-name-invalid-regexp | 204 | (defvar file-name-invalid-regexp |
| 201 | (cond ((and (eq system-type 'ms-dos) (not (msdos-long-file-names))) | 205 | (cond ((and (eq system-type 'ms-dos) (not (msdos-long-file-names))) |
| 202 | (concat "^\\([^A-Z[-`a-z]\\|..+\\)?:\\|" ; colon except after drive | 206 | (concat "^\\([^A-Z[-`a-z]\\|..+\\)?:\\|" ; colon except after drive |
| @@ -1071,16 +1075,19 @@ that are visiting the various files." | |||
| 1071 | (with-current-buffer buf | 1075 | (with-current-buffer buf |
| 1072 | 1076 | ||
| 1073 | ;; Check if a formerly read-only file has become | 1077 | ;; Check if a formerly read-only file has become |
| 1074 | ;; writable and vice versa. | 1078 | ;; writable and vice versa, but if the buffer agrees |
| 1079 | ;; with the new state of the file, that is ok too. | ||
| 1075 | (let ((read-only (not (file-writable-p buffer-file-name)))) | 1080 | (let ((read-only (not (file-writable-p buffer-file-name)))) |
| 1076 | (unless (eq read-only buffer-read-only) | 1081 | (unless (or (eq read-only buffer-file-read-only) |
| 1082 | (eq read-only buffer-read-only)) | ||
| 1077 | (when (or nowarn | 1083 | (when (or nowarn |
| 1078 | (let ((question | 1084 | (let ((question |
| 1079 | (format "File %s is %s on disk. Change buffer mode? " | 1085 | (format "File %s is %s on disk. Change buffer mode? " |
| 1080 | buffer-file-name | 1086 | buffer-file-name |
| 1081 | (if read-only "read-only" "writable")))) | 1087 | (if read-only "read-only" "writable")))) |
| 1082 | (y-or-n-p question))) | 1088 | (y-or-n-p question))) |
| 1083 | (setq buffer-read-only read-only)))) | 1089 | (setq buffer-read-only read-only))) |
| 1090 | (setq buffer-file-read-only read-only)) | ||
| 1084 | 1091 | ||
| 1085 | (when (not (eq (not (null rawfile)) | 1092 | (when (not (eq (not (null rawfile)) |
| 1086 | (not (null find-file-literally)))) | 1093 | (not (null find-file-literally)))) |