bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#33458: 27.0.50; dired loses position when reverted from outside plac


From: Juri Linkov
Subject: bug#33458: 27.0.50; dired loses position when reverted from outside place
Date: Wed, 28 Nov 2018 02:06:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

>> Maybe marker-position should allow to call a function?
>> For example, like 'isearch-push-state-function' remembers
>> an additional state as a lambda, and when an old state is
>> restored, a pop-fun lambda is called.  The function that
>> restores the buffer in the window could be the same.
>
> The problem we face here is almost exclusively restricted to reverting
> buffers and 'marker-position' is too heavily used as to be affected by
> that.  Now, if we talk about dired buffers only, they have a very
> helpful restriction that invariably permeates all file systems: The
> file names in a directory must be unique.  So if a marker is on the
> line of a file name it can quite easily return to that name after
> reversal (provided the file still exists).  A similar argument should
> hold for non-file visiting buffers like Buffer List buffers.  Finally,
> in quite a number of cases 'auto-revert-tail-mode' should take care of
> markers in the unchanged initial part of a file.

While 'isearch-push-state-function' could be used for example to save
and restore window start positions on returning to previous search hits:

(setq isearch-push-state-function
      (lambda ()
        `(lambda (cmd)
           (when isearch-success
             (set-window-start nil ,(window-start))))))

wouldn't it be possible to use something like this to
restore Dired point from the saved dired-filename.

And in non-dired buffers maybe at least when a window is restored from
the window configuration or from the window state, then simply restore
window point from the saved point when the saved point-marker is
invalidated (its value is 1).  Currently window-state-get when not used
with the WRITABLE arg, saves only point-marker, but maybe should save
both: point and point-marker, for the case when point-marker invalidates
after the buffer is reverted.

> Do we have many other auto-reverted buffers?

See for example how point is preserved in an intelligent way at the end
of revert-buffer-insert-file-contents--default-function that uses
insert-file-contents to preserve some marker positions.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]