(defun xref--add-log-current-defun ()
"Return the string used to group a set of locations.
This function is used as a value for `add-log-current-defun-function'."
- (let ((project-root (xref--project-root (project-current))))
- (xref--group-name-for-display
- (if-let (item (xref--item-at-point))
- (xref-location-group (xref-match-item-location item))
- (xref--imenu-extract-index-name))
- project-root
- (and
- (string-prefix-p project-root default-directory)
- (substring default-directory (length project-root))))))
+ (xref--group-name-for-display
+ (if-let (item (xref--item-at-point))
+ (xref-location-group (xref-match-item-location item))
+ (xref--imenu-extract-index-name))
+ (xref--project-root (project-current))))
(defun xref--next-error-function (n reset?)
(when reset?
(xref--apply-truncation)))
(run-hooks 'xref-after-update-hook))
-(defun xref--group-name-for-display (group project-root dd-suffix)
+(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.
-
-PROJECT-ROOT is the root of the current project, if any. DD-SUFFIX is
-the relative name of `default-directory' relative to the project root."
+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
(nondirectory
(file-name-nondirectory group))
(project-relative
- (cond
- ((not (file-name-absolute-p group))
- (concat dd-suffix group))
- ((and project-root
- (string-prefix-p project-root group))
- (substring group (length project-root)))
- ;; Default to absolute when there's not project around.
- (t
- (expand-file-name group))))))
+ (if (and project-root
+ (string-prefix-p project-root group))
+ (substring group (length project-root))
+ group))))
(defun xref--analyze (xrefs)
"Find common groups in XREFS and format group names.
(eq xref-file-name-display 'project-relative)
(project-current)))
(project-root (and project
- (expand-file-name (xref--project-root project))))
- (dd-suffix (and project-root
- (string-prefix-p project-root default-directory)
- (substring default-directory (length project-root)))))
+ (expand-file-name (xref--project-root project)))))
(mapcar
(lambda (pair)
- (cons (xref--group-name-for-display (car pair) project-root dd-suffix)
+ (cons (xref--group-name-for-display (car pair) project-root)
(cdr pair)))
alist)))