mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
revert: refactor(magit): reduce pollution of global namespace
This refactor was premature. It still worked, but only by accident.
This is not a *full* revert; +magit--pos has been renamed for clarity.
Revert: d4c02bcd08
This commit is contained in:
@ -65,16 +65,18 @@ Only has an effect in GUI Emacs.")
|
||||
;; Prevent sudden window position resets when staging/unstaging/discarding/etc
|
||||
;; hunks in `magit-status-mode' buffers. It's disorienting, especially on
|
||||
;; larger projects.
|
||||
(let (magit--pos)
|
||||
(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)))))
|
||||
(defvar +magit--refreshed-buffer nil)
|
||||
(add-hook! 'magit-pre-refresh-hook
|
||||
(defun +magit--set-window-state-h ()
|
||||
(setq-local +magit--refreshed-buffer
|
||||
(list (current-buffer) (point) (window-start)))))
|
||||
(add-hook! 'magit-post-refresh-hook
|
||||
(defun +magit--restore-window-state-h ()
|
||||
(cl-destructuring-bind (&optional buf pt beg) +magit--refreshed-buffer
|
||||
(when (and buf (eq (current-buffer) buf))
|
||||
(goto-char pt)
|
||||
(set-window-start nil beg t)
|
||||
(kill-local-variable '+magit--refreshed-buffer)))))
|
||||
|
||||
;; Magit uses `magit-display-buffer-traditional' to display windows, by
|
||||
;; default, which is a little primitive. `+magit-display-buffer' marries
|
||||
|
Reference in New Issue
Block a user