From 3e214b503eaf5c8a02b7153e5ddaf40a2d6efb13 Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Wed, 6 Apr 2011 21:38:46 +0200 Subject: [PATCH] New variable `revert-buffer-in-progress-p'. * lisp/files.el (after-find-file-from-revert-buffer): Remove variable. (after-find-file): Dont' bind it. (revert-buffer-in-progress-p): New variable. (revert-buffer): Bind it. Pass nil for `after-find-file-from-revert-buffer'. * lisp/saveplace.el (save-place-find-file-hook): Use new variable `rever-buffer-in-progress-p', not `after-find-file-from-revert-buffer'. * etc/NEWS: New variable `revert-buffer-in-progress-p'. --- etc/ChangeLog | 4 ++++ etc/NEWS | 3 +++ lisp/ChangeLog | 11 +++++++++++ lisp/files.el | 20 ++++++++++++-------- lisp/saveplace.el | 2 +- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/etc/ChangeLog b/etc/ChangeLog index 50d0acf3931..b9e409e8783 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog @@ -1,3 +1,7 @@ +2011-04-06 Juanma Barranquero + + * NEWS: New variable `revert-buffer-in-progress-p'. + 2011-03-22 Sebastian Hermida * themes/misterioso-theme.el: New file. diff --git a/etc/NEWS b/etc/NEWS index 6b7fd303dde..b416e98de0c 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -886,6 +886,9 @@ time you call `progress-reporter-update' on that progress reporter, with a nil or omitted VALUE argument, the reporter message is displayed with a "spinning bar". +** New variable `revert-buffer-in-progress-p' is true while a buffer is +being reverted, even if the buffer has a local `revert-buffer-function'. + * Changes in Emacs 24.1 on non-free operating systems diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ca163104e0a..5bd55902b40 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,14 @@ +2011-04-06 Juanma Barranquero + + * files.el (after-find-file-from-revert-buffer): Remove variable. + (after-find-file): Dont' bind it. + (revert-buffer-in-progress-p): New variable. + (revert-buffer): Bind it. + Pass nil for `after-find-file-from-revert-buffer'. + + * saveplace.el (save-place-find-file-hook): Use new variable + `rever-buffer-in-progress-p', not `after-find-file-from-revert-buffer'. + 2011-04-06 Glenn Morris * Makefile.in (AUTOGEN_VCS): New variable. diff --git a/lisp/files.el b/lisp/files.el index e87c25f3575..6bfb4f00d32 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2100,10 +2100,8 @@ the file contents into it using `insert-file-contents-literally'." (confirm-nonexistent-file-or-buffer)))) (switch-to-buffer (find-file-noselect filename nil t))) -(defvar after-find-file-from-revert-buffer nil) - (defun after-find-file (&optional error warn noauto - after-find-file-from-revert-buffer + _after-find-file-from-revert-buffer nomodes) "Called after finding a file and by the default revert function. Sets buffer mode, parses local variables. @@ -2111,8 +2109,8 @@ Optional args ERROR, WARN, and NOAUTO: ERROR non-nil means there was an error in reading the file. WARN non-nil means warn if there exists an auto-save file more recent than the visited file. NOAUTO means don't mess with auto-save mode. -Fourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER non-nil - means this call was from `revert-buffer'. +Fourth arg AFTER-FIND-FILE-FROM-REVERT-BUFFER is ignored +\(see `revert-buffer-in-progress-p' for similar functionality). Fifth arg NOMODES non-nil means don't alter the file's modes. Finishes by calling the functions in `find-file-hook' unless NOMODES is non-nil." @@ -5004,6 +5002,10 @@ hook functions. If `revert-buffer-function' is used to override the normal revert mechanism, this hook is not used.") +(defvar revert-buffer-in-progress-p nil + "Non-nil if a `revert-buffer' operation is in progress, nil otherwise. +This is true even if a `revert-buffer-function' is being used.") + (defvar revert-buffer-internal-hook) (defun revert-buffer (&optional ignore-auto noconfirm preserve-modes) @@ -5046,10 +5048,12 @@ non-nil, it is called instead of rereading visited file contents." ;; interface, but leaving the programmatic interface the same. (interactive (list (not current-prefix-arg))) (if revert-buffer-function - (funcall revert-buffer-function ignore-auto noconfirm) + (let ((revert-buffer-in-progress-p t)) + (funcall revert-buffer-function ignore-auto noconfirm)) (with-current-buffer (or (buffer-base-buffer (current-buffer)) (current-buffer)) - (let* ((auto-save-p (and (not ignore-auto) + (let* ((revert-buffer-in-progress-p t) + (auto-save-p (and (not ignore-auto) (recent-auto-save-p) buffer-auto-save-file-name (file-readable-p buffer-auto-save-file-name) @@ -5140,7 +5144,7 @@ non-nil, it is called instead of rereading visited file contents." ;; have changed the truename. (setq buffer-file-truename (abbreviate-file-name (file-truename buffer-file-name))) - (after-find-file nil nil t t preserve-modes) + (after-find-file nil nil t nil preserve-modes) ;; Run after-revert-hook as it was before we reverted. (setq-default revert-buffer-internal-hook global-hook) (if local-hook diff --git a/lisp/saveplace.el b/lisp/saveplace.el index c10b5cbb7ec..2d1586d895a 100644 --- a/lisp/saveplace.el +++ b/lisp/saveplace.el @@ -285,7 +285,7 @@ may have changed\) back to `save-place-alist'." (let ((cell (assoc buffer-file-name save-place-alist))) (if cell (progn - (or after-find-file-from-revert-buffer + (or revert-buffer-in-progress-p (goto-char (cdr cell))) ;; and make sure it will be saved again for later (setq save-place t))))) -- 2.11.4.GIT