Skip to content

Commit

Permalink
magit--insert-worktree: New function
Browse files Browse the repository at this point in the history
This makes it possible for a user to override the function using
advice.

Mark the function as private to avoid other users trying to add
it to a section hook directly.
  • Loading branch information
tarsius committed Apr 24, 2023
1 parent 4a21f4d commit 4030e6a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions lisp/magit-worktree.el
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,21 @@ If there is only one worktree, then insert nothing."
worktrees))
(align (1+ (-max (--map (string-width (car it)) cols)))))
(pcase-dolist (`(,head . ,path) cols)
(magit-insert-section (worktree path)
(insert head)
(insert (make-string (- align (length head)) ?\s))
(insert (let ((r (file-relative-name path))
(a (abbreviate-file-name path)))
(if (or (> (string-width r) (string-width a))
(equal r "./"))
a
r)))
(insert ?\n))))
(magit--insert-worktree path head align)))
(insert ?\n)))))

(defun magit--insert-worktree (path head align)
(magit-insert-section (worktree path)
(insert head)
(insert (make-string (- align (length head)) ?\s))
(insert (let ((r (file-relative-name path))
(a (abbreviate-file-name path)))
(if (or (> (string-width r) (string-width a))
(equal r "./"))
a
r)))
(insert ?\n)))

;;; _
(provide 'magit-worktree)
;;; magit-worktree.el ends here

0 comments on commit 4030e6a

Please sign in to comment.