Function: xref--group-name-for-display
xref--group-name-for-display is a byte-compiled function defined in
xref.el.gz.
Signature
(xref--group-name-for-display GROUP PROJECT-ROOT)
Documentation
Return GROUP formatted in the preferred style.
The style is determined by the value of xref-file-name-display.
If GROUP looks like a file name, its value is formatted according
to that style. Otherwise it is returned unchanged.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/xref.el.gz
(defun xref--group-name-for-display (group project-root)
"Return GROUP formatted in the preferred style.
The style is determined by the value of `xref-file-name-display'.
If GROUP looks like a file name, its value is formatted according
to that style. Otherwise it is returned unchanged."
;; XXX: The way we verify that it's indeed a file name and not some
;; other kind of string, e.g. Java package name or TITLE from
;; `tags-apropos-additional-actions', is pretty lax. But we don't
;; want to use `file-exists-p' for performance reasons. If this
;; ever turns out to be a problem, some other alternatives are to
;; either have every location type which uses file names format the
;; values themselves (e.g. by piping through some public function),
;; or adding a new accessor to locations, like GROUP-TYPE.
(cl-ecase xref-file-name-display
(abs group)
(nondirectory
(if (string-match-p "\\`~?/" group)
(file-name-nondirectory group)
group))
(project-relative
(if (and project-root
(string-prefix-p project-root group))
(substring group (length project-root))
group))))