mirror of
https://github.com/vale981/apheleia
synced 2025-03-05 09:31:40 -05:00
Restore scroll position
This commit is contained in:
parent
86753a0e14
commit
758540c45e
1 changed files with 13 additions and 3 deletions
16
apheleia.el
16
apheleia.el
|
@ -124,11 +124,13 @@ for documentation on the RCS patch format."
|
||||||
CONTENT-BUFFER contains the text to be patched, and PATCH-BUFFER
|
CONTENT-BUFFER contains the text to be patched, and PATCH-BUFFER
|
||||||
contains the patch."
|
contains the patch."
|
||||||
(let ((commands nil)
|
(let ((commands nil)
|
||||||
(point-list nil))
|
(point-list nil)
|
||||||
|
(window-line-list nil))
|
||||||
(with-current-buffer content-buffer
|
(with-current-buffer content-buffer
|
||||||
(push (cons nil (point)) point-list)
|
(push (cons nil (point)) point-list)
|
||||||
(dolist (w (get-buffer-window-list nil nil t))
|
(dolist (w (get-buffer-window-list nil nil t))
|
||||||
(push (cons w (window-point w)) point-list)))
|
(push (cons w (window-point w)) point-list)
|
||||||
|
(push (cons w (count-lines (window-start w) (point))) window-line-list)))
|
||||||
(with-current-buffer patch-buffer
|
(with-current-buffer patch-buffer
|
||||||
(apheleia--map-rcs-patch
|
(apheleia--map-rcs-patch
|
||||||
(lambda (command)
|
(lambda (command)
|
||||||
|
@ -212,7 +214,15 @@ contains the patch."
|
||||||
(set-window-point w new-point)
|
(set-window-point w new-point)
|
||||||
(setq move-to new-point)))))))
|
(setq move-to new-point)))))))
|
||||||
(when move-to
|
(when move-to
|
||||||
(goto-char move-to))))))
|
(goto-char move-to))))
|
||||||
|
;; Restore the scroll position of each window displaying the
|
||||||
|
;; buffer.
|
||||||
|
(dolist (entry window-line-list)
|
||||||
|
(cl-destructuring-bind (w . old-window-line) entry
|
||||||
|
(let ((new-window-line
|
||||||
|
(count-lines (window-start w) (point))))
|
||||||
|
(with-selected-window w
|
||||||
|
(scroll-down (- old-window-line new-window-line))))))))
|
||||||
|
|
||||||
(provide 'apheleia)
|
(provide 'apheleia)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue