Prevent scrolling on magit refresh & toc-org
This commit is contained in:
parent
a381f59261
commit
2ceac53421
2 changed files with 26 additions and 1 deletions
|
@ -42,6 +42,20 @@
|
|||
"~/.cache/")
|
||||
"git/credential/socket")))
|
||||
|
||||
;; Prevent scrolling when manipulating magit-status hunks. Otherwise you must
|
||||
;; reorient yourself every time you stage/unstage/discard/etc a hunk.
|
||||
;; Especially so on larger projects."
|
||||
(defvar +magit--pos nil)
|
||||
(add-hook! 'magit-pre-refresh-hook
|
||||
(defun +magit--set-window-state-h ()
|
||||
(setq-local +magit--pos (list (current-buffer) (point) (window-start)))))
|
||||
(add-hook! 'magit-post-refresh-hook
|
||||
(defun +magit--restore-window-state-h ()
|
||||
(when (and +magit--pos (eq (current-buffer) (car +magit--pos)))
|
||||
(goto-char (cadr +magit--pos))
|
||||
(set-window-start nil (caddr +magit--pos) t)
|
||||
(kill-local-variable '+magit--pos))))
|
||||
|
||||
;; Magit uses `magit-display-buffer-traditional' to display windows, by
|
||||
;; default, which is a little primitive. `+magit-display-buffer' marries
|
||||
;; `magit-display-buffer-fullcolumn-most-v1' with
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue