emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master d590b27: Add xref-file-name-display


From: Stephen Leake
Subject: [Emacs-diffs] master d590b27: Add xref-file-name-display
Date: Wed, 17 Jul 2019 12:18:01 -0400 (EDT)

branch: master
commit d590b27ee4c43ba000172b4ad15762863d78aba1
Author: Stephen Leake <address@hidden>
Commit: Stephen Leake <address@hidden>

    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 76ea1df..afdcf56 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 44934d4..8dc4f3c 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]