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

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

bug#60381: [PATCH] Preserve Window Position with Proced


From: Laurence Warne
Subject: bug#60381: [PATCH] Preserve Window Position with Proced
Date: Thu, 5 Jan 2023 15:59:57 +0000

Hi,

Minor update, whilst working on the first case, I've come across some strange behaviour which causes the window position to be reset to (point-min) in some circumstances.  To reproduce this with a more minimal setup than proced-update (I've also asked here: https://emacs.stackexchange.com/questions/75165/window-point-reset-after-update):

(defun example ()
  (interactive)
  (let* ((buf (get-buffer-create "*Example*"))
         (w-points (mapcar (lambda (win)
                             `(,win . ,(window-point win)))
                           (get-buffer-window-list buf))))
    (with-current-buffer buf
      (let ((buf-point (point)))
        (erase-buffer)
        (insert "line1\nline2\nline3\nline4\nline5")
        (goto-char buf-point)
        (mapc (lambda (wp) (set-window-point (car wp) (cdr wp))) w-points)))
    (message "Ran update")))

(setq example-timer (run-at-time t 5 #'example))

Now with a configuration of two windows, switch to the example buffer in one of them, and move down a few lines. Switch to the other window, you should see the window point stay the same after every update.

If you then invoke M-x, wait for an update to occur, and then cancel the invocation using C-g, then you should see the point in the window displaying the example buffer go back to the start of the window. I've created a video here: https://user-images.githubusercontent.com/17688577/210167335-f7a4d50f-dbaf-4ffc-b1e0-38c5612ed2e3.mp4.  I'm a bit confused by this, any pointers would be greatly appreciated.

On the upside, I've managed to put together a test which won't pass without the patch.

In terms of the difference between this patch and the original, the new patch maintains the window point for all windows which display a proced buffer.  The original just set the window point for one, as a consequence all windows displaying the proced buffer in question would have their point set to the most recently visited window displaying the buffer.   I've had to extract out some logic from proced-update to separate functions, and so this patch is a bit more invasive.

Thanks, Laurence

Attachment: 0001-Preserve-the-window-position-with-proced.patch
Description: Text Data


reply via email to

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