diff options
| author | Michael Albinus | 2015-07-16 20:04:07 +0200 |
|---|---|---|
| committer | Michael Albinus | 2015-07-16 20:04:07 +0200 |
| commit | fa5a880f733cbbe3b0d515ed3e1cf7c6fd54cfd8 (patch) | |
| tree | 60653bdeb82fddff7664cd8cfe3e2740f36857ef | |
| parent | 572cd26f3f03995dbb3689b8a6f0a575ec9b9cb6 (diff) | |
| download | emacs-fa5a880f733cbbe3b0d515ed3e1cf7c6fd54cfd8.tar.gz emacs-fa5a880f733cbbe3b0d515ed3e1cf7c6fd54cfd8.zip | |
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.el | 115 | ||||
| -rw-r--r-- | lisp/files.el | 1 | ||||
| -rw-r--r-- | test/automated/auto-revert-tests.el | 6 |
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 | |||
| 615 | (defun auto-revert-handler () | 615 | (defun auto-revert-handler () |
| 616 | "Revert current buffer, if appropriate. | 616 | "Revert current buffer, if appropriate. |
| 617 | This is an internal function used by Auto-Revert Mode." | 617 | This is an internal function used by Auto-Revert Mode." |
| 618 | (when (or auto-revert-tail-mode (not (buffer-modified-p))) | 618 | (let* ((buffer (current-buffer)) size |
| 619 | (let* ((buffer (current-buffer)) size | 619 | ;; Tramp caches the file attributes. Setting |
| 620 | ;; Tramp caches the file attributes. Setting | 620 | ;; `remote-file-name-inhibit-cache' forces Tramp to reread |
| 621 | ;; `remote-file-name-inhibit-cache' forces Tramp to reread | 621 | ;; the values. |
| 622 | ;; the values. | 622 | (remote-file-name-inhibit-cache t) |
| 623 | (remote-file-name-inhibit-cache t) | 623 | (revert |
| 624 | (revert | 624 | (if buffer-file-name |
| 625 | (if buffer-file-name | 625 | (and (or auto-revert-remote-files |
| 626 | (and (or auto-revert-remote-files | 626 | (not (file-remote-p buffer-file-name))) |
| 627 | (not (file-remote-p buffer-file-name))) | 627 | (or (not auto-revert-use-notify) |
| 628 | (or (not auto-revert-use-notify) | 628 | auto-revert-notify-modified-p) |
| 629 | auto-revert-notify-modified-p) | 629 | (if auto-revert-tail-mode |
| 630 | (if auto-revert-tail-mode | 630 | (and (file-readable-p buffer-file-name) |
| 631 | (and (file-readable-p buffer-file-name) | 631 | (/= auto-revert-tail-pos |
| 632 | (/= auto-revert-tail-pos | 632 | (setq size |
| 633 | (setq size | 633 | (nth 7 (file-attributes |
| 634 | (nth 7 (file-attributes | 634 | buffer-file-name))))) |
| 635 | buffer-file-name))))) | 635 | (funcall (or buffer-stale-function |
| 636 | (funcall (or buffer-stale-function | 636 | #'buffer-stale--default-function) |
| 637 | #'buffer-stale--default-function) | 637 | t))) |
| 638 | t))) | 638 | (and (or auto-revert-mode |
| 639 | (and (or auto-revert-mode | 639 | global-auto-revert-non-file-buffers) |
| 640 | global-auto-revert-non-file-buffers) | 640 | (funcall (or buffer-stale-function |
| 641 | (funcall (or buffer-stale-function | 641 | #'buffer-stale--default-function) |
| 642 | #'buffer-stale--default-function) | 642 | t)))) |
| 643 | t)))) | 643 | eob eoblist) |
| 644 | eob eoblist) | 644 | (setq auto-revert-notify-modified-p nil) |
| 645 | (setq auto-revert-notify-modified-p nil) | 645 | (when revert |
| 646 | (when revert | 646 | (when (and auto-revert-verbose |
| 647 | (when (and auto-revert-verbose | 647 | (not (eq revert 'fast))) |
| 648 | (not (eq revert 'fast))) | 648 | (message "Reverting buffer `%s'." (buffer-name))) |
| 649 | (message "Reverting buffer `%s'." (buffer-name))) | 649 | ;; If point (or a window point) is at the end of the buffer, we |
| 650 | ;; If point (or a window point) is at the end of the buffer, | 650 | ;; want to keep it at the end after reverting. This allows to |
| 651 | ;; we want to keep it at the end after reverting. This allows | 651 | ;; tail a file. |
| 652 | ;; to tail a file. | 652 | (when buffer-file-name |
| 653 | (when buffer-file-name | 653 | (setq eob (eobp)) |
| 654 | (setq eob (eobp)) | 654 | (walk-windows |
| 655 | (walk-windows | 655 | (lambda (window) |
| 656 | (lambda (window) | 656 | (and (eq (window-buffer window) buffer) |
| 657 | (and (eq (window-buffer window) buffer) | 657 | (= (window-point window) (point-max)) |
| 658 | (= (window-point window) (point-max)) | 658 | (push window eoblist))) |
| 659 | (push window eoblist))) | 659 | 'no-mini t)) |
| 660 | 'no-mini t)) | 660 | (if auto-revert-tail-mode |
| 661 | (if auto-revert-tail-mode | 661 | (auto-revert-tail-handler size) |
| 662 | (auto-revert-tail-handler size) | 662 | ;; Bind buffer-read-only in case user has done C-x C-q, so as |
| 663 | ;; Bind buffer-read-only in case user has done C-x C-q, | 663 | ;; not to forget that. This gives undesirable results when |
| 664 | ;; so as not to forget that. This gives undesirable results | 664 | ;; the file's mode changes, but that is less common. |
| 665 | ;; when the file's mode changes, but that is less common. | 665 | (let ((buffer-read-only buffer-read-only)) |
| 666 | (let ((buffer-read-only buffer-read-only)) | 666 | (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes))) |
| 667 | (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes))) | 667 | (when buffer-file-name |
| 668 | (when buffer-file-name | 668 | (when eob (goto-char (point-max))) |
| 669 | (when eob (goto-char (point-max))) | 669 | (dolist (window eoblist) |
| 670 | (dolist (window eoblist) | 670 | (set-window-point window (point-max))))) |
| 671 | (set-window-point window (point-max))))) | 671 | ;; `preserve-modes' avoids changing the (minor) modes. But we do |
| 672 | ;; `preserve-modes' avoids changing the (minor) modes. But we | 672 | ;; want to reset the mode for VC, so we do it manually. |
| 673 | ;; do want to reset the mode for VC, so we do it manually. | 673 | (when (or revert auto-revert-check-vc-info) |
| 674 | (when (or revert auto-revert-check-vc-info) | 674 | (vc-find-file-hook)))) |
| 675 | (vc-find-file-hook))))) | ||
| 676 | 675 | ||
| 677 | (defun auto-revert-tail-handler (size) | 676 | (defun auto-revert-tail-handler (size) |
| 678 | (let ((modified (buffer-modified-p)) | 677 | (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. | |||
| 5424 | Non-file buffers need a custom function" | 5424 | Non-file buffers need a custom function" |
| 5425 | (and buffer-file-name | 5425 | (and buffer-file-name |
| 5426 | (file-readable-p buffer-file-name) | 5426 | (file-readable-p buffer-file-name) |
| 5427 | (not (buffer-modified-p (current-buffer))) | ||
| 5427 | (not (verify-visited-file-modtime (current-buffer))))) | 5428 | (not (verify-visited-file-modtime (current-buffer))))) |
| 5428 | 5429 | ||
| 5429 | (defvar buffer-stale-function #'buffer-stale--default-function | 5430 | (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 @@ | |||
| 173 | (null | 173 | (null |
| 174 | (string-match name (substring-no-properties (buffer-string))))) | 174 | (string-match name (substring-no-properties (buffer-string))))) |
| 175 | 175 | ||
| 176 | ;; When the dired buffer is modified, it shall not be | 176 | ;; Make dired buffer modified. Check, that the buffer has |
| 177 | ;; reverted. This is questionable, see Bug#20943. | 177 | ;; been still reverted. |
| 178 | (with-current-buffer (get-buffer-create "*Messages*") | 178 | (with-current-buffer (get-buffer-create "*Messages*") |
| 179 | (narrow-to-region (point-max) (point-max))) | 179 | (narrow-to-region (point-max) (point-max))) |
| 180 | (set-buffer-modified-p t) | 180 | (set-buffer-modified-p t) |
| @@ -189,7 +189,7 @@ | |||
| 189 | (format "Reverting buffer `%s'." (buffer-name buf)) | 189 | (format "Reverting buffer `%s'." (buffer-name buf)) |
| 190 | (buffer-string))) | 190 | (buffer-string))) |
| 191 | (read-event nil nil 0.1)))) | 191 | (read-event nil nil 0.1)))) |
| 192 | (should-not | 192 | (should |
| 193 | (string-match name (substring-no-properties (buffer-string)))))) | 193 | (string-match name (substring-no-properties (buffer-string)))))) |
| 194 | 194 | ||
| 195 | ;; Exit. | 195 | ;; Exit. |