emacs-devel
[Top][All Lists]
Advanced

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

limit length of xref file header line


From: Stephen Leake
Subject: limit length of xref file header line
Date: Sun, 19 May 2019 09:57:39 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (windows-nt)

In my Android projects, the directory part of filenames is very long,
and overflows the screen length in an *xref* buffer. For example:

c:/Projects/Android/org.stephe_leake.music_player.java/app/src/main/java/org/stephe_leake/android/stephes_music/activity.java
652: artistTitle.setTextSize(scale * defaultTextViewTextSize);
651: albumArtistTitle.setTextSize(scale * defaultTextViewTextSize);


(the real display has colors to distinguish the fields)

So I'd like to shorten the filename line (called the "group" in xref).

One option is to simply drop the directory part; then the display is:

activity.java
652: artistTitle.setTextSize(scale * defaultTextViewTextSize);
651: albumArtistTitle.setTextSize(scale * defaultTextViewTextSize);


xref stores the fill filename in a text property, so no information is lost.

But that might be confusing in a project where files have the same name
in different directories.

The patch below adds a new user option 'xref-display-filename' to
control this. 

Ok to commit?

--
-- Stephe

index d70cda179e..93f4049de9 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -364,6 +364,10 @@ in tooltips, as it is not useful there.
 There are 2 new buffer local variables and 1 face to customize this
 mode they are described in the manual "(emacs) 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 bf999aeb0d..864d604b75 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -444,6 +444,12 @@ xref--pop-to-location
 
 ;;; XREF buffer (part of the UI)
 
+(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")
+
 ;; The xref buffer is used to display a set of xrefs.
 (defconst xref-buffer-name "*xref*"
   "The name of the buffer to show xrefs.")
@@ -750,7 +756,11 @@ xref--insert-xrefs
            for line-format = (and max-line-width
                                   (format "%%%dd: " max-line-width))
            do
-           (xref--insert-propertized '(face xref-file-header) group "\n")
+           (xref--insert-propertized '(face xref-file-header)
+                                     (cl-ecase xref-file-name-display
+                                       (abs group)
+                                       (nondirectory (file-name-nondirectory 
group)))
+                                     "\n")
            (cl-loop for (xref . more2) on xrefs do
                     (with-slots (summary location) xref
                       (let* ((line (xref-location-line location))



reply via email to

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