From d590b27ee4c43ba000172b4ad15762863d78aba1 Mon Sep 17 00:00:00 2001 From: Stephen Leake Date: Wed, 17 Jul 2019 09:17:36 -0700 Subject: Add xref-file-name-display * lisp/progmodes/xref.el (xref-file-name-display): New user variable. (xref-location-group): Use it. * etc/NEWS: Mention it. --- etc/NEWS | 3 +++ lisp/progmodes/xref.el | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/etc/NEWS b/etc/NEWS index 76ea1df8213..afdcf56b6c0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -397,6 +397,9 @@ mode they are described in the manual "(emacs) Display". +++ ** 'progress-reporter-update' accepts a suffix string to display. +--- +** New variable 'xref-file-name-display' controls the display of file +names in xref buffers. * Editing Changes in Emacs 27.1 diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el index 44934d44ebd..8dc4f3c4714 100644 --- a/lisp/progmodes/xref.el +++ b/lisp/progmodes/xref.el @@ -98,6 +98,12 @@ This is typically the filename.") ;;;; Commonly needed location classes are defined here: +(defcustom xref-file-name-display 'abs + "Style of file name display in *xref* buffers." + :type '(choice (const :tag "absolute file name" abs) + (const :tag "nondirectory file name" nondirectory)) + :version "27.1") + ;; FIXME: might be useful to have an optional "hint" i.e. a string to ;; search for in case the line number is slightly out of date. (defclass xref-file-location (xref-location) @@ -126,7 +132,9 @@ Line numbers start from 1 and columns from 0.") (point-marker)))))) (cl-defmethod xref-location-group ((l xref-file-location)) - (oref l file)) + (cl-ecase xref-file-name-display + (abs (oref l file)) + (nondirectory (file-name-nondirectory (oref l file))))) (defclass xref-buffer-location (xref-location) ((buffer :type buffer :initarg :buffer) -- cgit v1.2.1