Open
Description
The side by side windows can become unaligned depending on how we navigate the buffers.
I came up with this function to solve this:
(defun diffview-align-windows ()
(interactive)
(let ((align-to-line (line-number-at-pos))
(align-from-top (- (line-number-at-pos (point))
(line-number-at-pos (window-start)))))
(when
(cond
((string= (buffer-name (current-buffer))
diffview--minus-bufname)
(switch-to-buffer-other-window diffview--plus-bufname))
((string= (buffer-name (current-buffer))
diffview--plus-bufname)
(switch-to-buffer-other-window diffview--minus-bufname)))
(goto-char (point-min))
(forward-line (1- align-to-line))
(recenter align-from-top)
(other-window 1))))
It could be added to diffview-mode-map
on a key such as l
, what do you think ?
Metadata
Metadata
Assignees
Labels
No labels