branch: elpa/magit commit bafac417b5a9c3dd3f9e9af5fa3c16f75b4afe1d Author: Jonas Bernoulli <jo...@bernoul.li> Commit: Jonas Bernoulli <jo...@bernoul.li>
magit--insert-related-refs: Use a single section Use one section per category, instead of one section per ref on the line. This is the only place where we violated the rule that there is only ever one section per line. I always found it annoying that moving over these headers took more key presses than expected when using `magit-next-section', and I never developed an intuition for not using that command here, because it so convincingly looks like using that is efficient enough. An upcoming refactoring to section highlighting would break for these sections, so let's address it now. It is also simply unnecessary to use a section per branch. Nowadays commands that act on the branch at point, need no section, a painted ref will do. A small tweak to `magit-branch-at-point' will do. --- lisp/magit-diff.el | 18 +++++++++--------- lisp/magit-git.el | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lisp/magit-diff.el b/lisp/magit-diff.el index 74bc4ddece..431d8606c8 100644 --- a/lisp/magit-diff.el +++ b/lisp/magit-diff.el @@ -2942,18 +2942,18 @@ Refer to user option `magit-revision-insert-related-refs-display-alist'." (defun magit--insert-related-refs (rev arg title remote) (when-let ((refs (magit-list-related-branches arg rev (and remote "-a")))) - (insert title ":" (make-string (- 10 (length title)) ?\s)) - (dolist (branch refs) - (if (<= (+ (current-column) 1 (length branch)) - (window-width)) - (insert ?\s) - (insert ?\n (make-string 12 ?\s))) - (magit-insert-section (branch branch) + (magit-insert-section (related-refs) + (insert title ":" (make-string (- 10 (length title)) ?\s)) + (dolist (branch refs) + (if (<= (+ (current-column) 1 (length branch)) + (window-width)) + (insert ?\s) + (insert ?\n (make-string 12 ?\s))) (insert (propertize branch 'font-lock-face (if (string-prefix-p "remotes/" branch) 'magit-branch-remote - 'magit-branch-local))))) - (insert ?\n))) + 'magit-branch-local)))) + (insert ?\n)))) (defun magit-insert-revision-gravatars (rev beg) (when (and magit-revision-show-gravatars diff --git a/lisp/magit-git.el b/lisp/magit-git.el index abd8f2b132..2e6a14c520 100644 --- a/lisp/magit-git.el +++ b/lisp/magit-git.el @@ -1527,6 +1527,7 @@ to, or to some other symbolic-ref that points to the same ref." (pullreq (and (fboundp 'forge--pullreq-branch) (magit-branch-p (forge--pullreq-branch (oref it value))))) + (related-refs (magit--painted-branch-at-point)) ((unpulled unpushed) (magit-ref-abbrev (replace-regexp-in-string "\\.\\.\\.?" "" (oref it value))))))