[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: after-find-file-from-revert-buffer
From: |
Juanma Barranquero |
Subject: |
Re: after-find-file-from-revert-buffer |
Date: |
Wed, 6 Apr 2011 17:18:33 +0200 |
> Removing the variable sounds like the best option. So the question is
> how to get the same behavior in saveplace without using this variable.
> Maybe saveplace could setup a local revert-buffer-function instead.
The issue is that saveplace does not need or want a
revert-buffer-function. What it wants is to piggyback on
find-file-hook to restore the point in other buffers, but detect the
cases where that's caused by revert-buffer, to avoid unexpectedly
moving the point.
If the (before|after)-revert-hooks were always run, we could try to
use these (though it would be ugly); but a `revert-buffer-function' is
free to ignore them.
On the other hand, if the `revert-buffer-function' does not call
`after-find-file', or if it does but does not pass the
AFTER-FIND-FILE-FROM-REVERT-BUFFER parameter, the saveplace hook isn't
detecting the revert-buffer call anyway...
The only answer I can think is having something like
after-find-file-from-revert-buffer, but explicitly for revert-buffer:
(defvar revert-buffer-in-progress-p nil
"This variable is non-nil whenever a `revert-buffer' operation is
in progress, nil otherwise.")
(defun revert-buffer (...)
(let ((revert-buffer-in-progress t))
...))
which isn't not much better that which we have today, but at least is
better focused: it's cleaner to have a flag to signal use of
revert-buffer, than one to signal use of after-find-file inside
revert-buffer...
Juanma
P.S. Well, it would be more like
@@ -5047,8 +5048,10 @@
(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