summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2015-07-16 20:04:07 +0200
committerMichael Albinus <michael.albinus@gmx.de>2015-07-16 20:04:07 +0200
commitfa5a880f733cbbe3b0d515ed3e1cf7c6fd54cfd8 (patch)
tree60653bdeb82fddff7664cd8cfe3e2740f36857ef
parent572cd26f3f03995dbb3689b8a6f0a575ec9b9cb6 (diff)
downloademacs-fa5a880f733cbbe3b0d515ed3e1cf7c6fd54cfd8.tar.gz
Fix Bug#20943.
* lisp/autorevert.el (auto-revert-handler): Do not check for `buffer-modified-p'. * lisp/files.el (buffer-stale--default-function): Check for `buffer-modified-p'. * test/automated/auto-revert-tests.el (auto-revert-test02-auto-revert-mode-dired): Adapt test.
-rw-r--r--lisp/autorevert.el115
-rw-r--r--lisp/files.el1
-rw-r--r--test/automated/auto-revert-tests.el6
3 files changed, 61 insertions, 61 deletions
diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 2ff7c0115f3..0081419acbf 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -615,64 +615,63 @@ no more reverts are possible until the next call of
(defun auto-revert-handler ()
"Revert current buffer, if appropriate.
This is an internal function used by Auto-Revert Mode."
- (when (or auto-revert-tail-mode (not (buffer-modified-p)))
- (let* ((buffer (current-buffer)) size
- ;; Tramp caches the file attributes. Setting
- ;; `remote-file-name-inhibit-cache' forces Tramp to reread
- ;; the values.
- (remote-file-name-inhibit-cache t)
- (revert
- (if buffer-file-name
- (and (or auto-revert-remote-files
- (not (file-remote-p buffer-file-name)))
- (or (not auto-revert-use-notify)
- auto-revert-notify-modified-p)
- (if auto-revert-tail-mode
- (and (file-readable-p buffer-file-name)
- (/= auto-revert-tail-pos
- (setq size
- (nth 7 (file-attributes
- buffer-file-name)))))
- (funcall (or buffer-stale-function
- #'buffer-stale--default-function)
- t)))
- (and (or auto-revert-mode
- global-auto-revert-non-file-buffers)
- (funcall (or buffer-stale-function
- #'buffer-stale--default-function)
- t))))
- eob eoblist)
- (setq auto-revert-notify-modified-p nil)
- (when revert
- (when (and auto-revert-verbose
- (not (eq revert 'fast)))
- (message "Reverting buffer `%s'." (buffer-name)))
- ;; If point (or a window point) is at the end of the buffer,
- ;; we want to keep it at the end after reverting. This allows
- ;; to tail a file.
- (when buffer-file-name
- (setq eob (eobp))
- (walk-windows
- (lambda (window)
- (and (eq (window-buffer window) buffer)
- (= (window-point window) (point-max))
- (push window eoblist)))
- 'no-mini t))
- (if auto-revert-tail-mode
- (auto-revert-tail-handler size)
- ;; Bind buffer-read-only in case user has done C-x C-q,
- ;; so as not to forget that. This gives undesirable results
- ;; when the file's mode changes, but that is less common.
- (let ((buffer-read-only buffer-read-only))
- (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes)))
- (when buffer-file-name
- (when eob (goto-char (point-max)))
- (dolist (window eoblist)
- (set-window-point window (point-max)))))
- ;; `preserve-modes' avoids changing the (minor) modes. But we
- ;; do want to reset the mode for VC, so we do it manually.
- (when (or revert auto-revert-check-vc-info)
- (vc-find-file-hook)))))
+ (let* ((buffer (current-buffer)) size
+ ;; Tramp caches the file attributes. Setting
+ ;; `remote-file-name-inhibit-cache' forces Tramp to reread
+ ;; the values.
+ (remote-file-name-inhibit-cache t)
+ (revert
+ (if buffer-file-name
+ (and (or auto-revert-remote-files
+ (not (file-remote-p buffer-file-name)))
+ (or (not auto-revert-use-notify)
+ auto-revert-notify-modified-p)
+ (if auto-revert-tail-mode
+ (and (file-readable-p buffer-file-name)
+ (/= auto-revert-tail-pos
+ (setq size
+ (nth 7 (file-attributes
+ buffer-file-name)))))
+ (funcall (or buffer-stale-function
+ #'buffer-stale--default-function)
+ t)))
+ (and (or auto-revert-mode
+ global-auto-revert-non-file-buffers)
+ (funcall (or buffer-stale-function
+ #'buffer-stale--default-function)
+ t))))
+ eob eoblist)
+ (setq auto-revert-notify-modified-p nil)
+ (when revert
+ (when (and auto-revert-verbose
+ (not (eq revert 'fast)))
+ (message "Reverting buffer `%s'." (buffer-name)))
+ ;; If point (or a window point) is at the end of the buffer, we
+ ;; want to keep it at the end after reverting. This allows to
+ ;; tail a file.
+ (when buffer-file-name
+ (setq eob (eobp))
+ (walk-windows
+ (lambda (window)
+ (and (eq (window-buffer window) buffer)
+ (= (window-point window) (point-max))
+ (push window eoblist)))
+ 'no-mini t))
+ (if auto-revert-tail-mode
+ (auto-revert-tail-handler size)
+ ;; Bind buffer-read-only in case user has done C-x C-q, so as
+ ;; not to forget that. This gives undesirable results when
+ ;; the file's mode changes, but that is less common.
+ (let ((buffer-read-only buffer-read-only))
+ (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes)))
+ (when buffer-file-name
+ (when eob (goto-char (point-max)))
+ (dolist (window eoblist)
+ (set-window-point window (point-max)))))
+ ;; `preserve-modes' avoids changing the (minor) modes. But we do
+ ;; want to reset the mode for VC, so we do it manually.
+ (when (or revert auto-revert-check-vc-info)
+ (vc-find-file-hook))))
(defun auto-revert-tail-handler (size)
(let ((modified (buffer-modified-p))
diff --git a/lisp/files.el b/lisp/files.el
index 9e04b9c7cea..a371344d116 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5424,6 +5424,7 @@ This function only handles buffers that are visiting files.
Non-file buffers need a custom function"
(and buffer-file-name
(file-readable-p buffer-file-name)
+ (not (buffer-modified-p (current-buffer)))
(not (verify-visited-file-modtime (current-buffer)))))
(defvar buffer-stale-function #'buffer-stale--default-function
diff --git a/test/automated/auto-revert-tests.el b/test/automated/auto-revert-tests.el
index a98428f7d89..204e03d423d 100644
--- a/test/automated/auto-revert-tests.el
+++ b/test/automated/auto-revert-tests.el
@@ -173,8 +173,8 @@
(null
(string-match name (substring-no-properties (buffer-string)))))
- ;; When the dired buffer is modified, it shall not be
- ;; reverted. This is questionable, see Bug#20943.
+ ;; Make dired buffer modified. Check, that the buffer has
+ ;; been still reverted.
(with-current-buffer (get-buffer-create "*Messages*")
(narrow-to-region (point-max) (point-max)))
(set-buffer-modified-p t)
@@ -189,7 +189,7 @@
(format "Reverting buffer `%s'." (buffer-name buf))
(buffer-string)))
(read-event nil nil 0.1))))
- (should-not
+ (should
(string-match name (substring-no-properties (buffer-string))))))
;; Exit.