This generally improves handling of vc-dir headers.
U4ORTSFJV24RHAT6FQ6OVLZXXN3W2CPG7KG4RSNG7U3N6DTAAJEQC
(defun vc-pijul-get-remote (dir)
"Get the remote repository location, if any."
;; Currently, there is not an easy way to tell the default remote from the other
;; remotes (other than parsing the config file), the oldest one the default, and;; order the list chronologically.
(defun vc-pijul-get-remotes (dir)
"Get the remote repository locations, if any. The default remote will
_probably_ be the first in the list."
(defun vc-pijul-dir-header (k v)
(list
(concat
(propertize k 'face 'font-lock-type-face)
" "
(propertize v 'face 'font-lock-variable-name-face))))
(defun vc-pijul--dir-header (width k v)
"Creates a string, stylized as a vc-dir header from a K (a string) and V
(either a string or a list of strings). K will be truncated if it is longer than
the provided width."
(concat
(propertize (concat (truncate-string-to-width k width nil ?\s t t) ": ")
'face
'vc-dir-header)
(propertize (cond ((listp v)
(mapconcat 'identity
v
(concat "\n" (make-string (+ 2 width) ?\s))))
(t
v))
'face
'vc-dir-header-value)))
(mapconcat
#'identity
(nconc
(let ((root (vc-pijul-root dir)))
(and root (not (equal (file-truename dir) (file-truename root)))
(vc-pijul-dir-header "Repository :" root)))
(let ((remote (vc-pijul-get-remote dir)))
(and remote (vc-pijul-dir-header "Remote :" remote))))
"\n"))
(let ((width 11)) ; the width of a header key in vc-dir
(mapconcat
'identity
(nconc
(let ((root (vc-pijul-root dir)))
(and root (not (equal (file-truename dir) (file-truename root)))
(list (vc-pijul--dir-header width "Repository" root))))
(let ((remotes (vc-pijul-get-remotes dir)))
(and remotes (list (vc-pijul--dir-header width "Remotes" remotes)))))
"\n")))