]> git.eshelyaron.com Git - emacs.git/commitdiff
(find-file-noselect): If file's read-only status has
authorGerd Moellmann <gerd@gnu.org>
Fri, 5 Oct 2001 12:10:57 +0000 (12:10 +0000)
committerGerd Moellmann <gerd@gnu.org>
Fri, 5 Oct 2001 12:10:57 +0000 (12:10 +0000)
changed on disk, ask if buffer's read-only status should be
changed, unless NOWARN is set.

lisp/files.el

index bdd5604417d17551c981e865ff21506892450ea3..84c167f756bba3c2d61fa378e2b10220a4bafbf3 100644 (file)
@@ -1069,6 +1069,19 @@ that are visiting the various files."
                         (with-current-buffer buf
                           (revert-buffer t t)))))
              (with-current-buffer buf
+
+               ;; Check if a formerly read-only file has become
+               ;; writable and vice versa.
+               (let ((read-only (not (file-writable-p buffer-file-name))))
+                 (unless (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))))
+
                (when (not (eq (not (null rawfile))
                               (not (null find-file-literally))))
                  (if (buffer-modified-p)