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: Thu, 29 Nov 2018 01:45:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

>> 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.
>
> You mean the 'restore_window_points' mechanism?  Then we would have to
> make its information available in Lisp.  Certainly worthwhile.

I understand better now where is the root of the problem.
The same problem exists for example in vc-annotate.
I wasted too much time waiting while each vc-annotate invocation
finishes its long-running process and sets the window point.
Usually when running a long-running process, I can switch to another
buffer in the window with the buffer where process is not yet finished,
or switch to another window configuration/state to do other work,
but I can't hide the annotation window because then it will fail
to set window point to the line corresponding to the source file.
So I have to do nothing, just wait when it finishes.
Is it possible to fix this annoyance?  In vc-annotate this problem
is explained as:

       ;; Ideally, we'd rather not move point if the user has already
       ;; moved it elsewhere, but really point here is not the position
       ;; of the user's cursor :-(
       (when current-line           ;(and (bobp))
         (goto-char (point-min))
         (forward-line (1- current-line))
         (setq vc-sentinel-movepoint (point)))

and in vc--process-sentinel:

          ;; But sometimes the sentinels really want to move point.
          (when vc-sentinel-movepoint
            (let ((win (get-buffer-window (current-buffer) 0)))
              (if (not win)
                  (goto-char vc-sentinel-movepoint)
                (with-selected-window win
                  (goto-char vc-sentinel-movepoint)))))

so when the buffer is not displayed in a window, it calls
`(goto-char vc-sentinel-movepoint)'.

The main question: why the result of setting point with goto-char
is ignored when the buffer's display is restored in a window?

Maybe we should introduce a new buffer-local variable with a name like
window-point, to set it like (setq window-point vc-sentinel-movepoint)
or in dired-revert like (setq window-point dired-point)
Then window functions that display the buffer in a window should
obey this variable and set the window point to the requested value.





reply via email to

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