Skip to content

Aligning windows #1

Description

@lerouxrgd

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 ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions