unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* limit length of xref file header line
@ 2019-05-19 17:57 Stephen Leake
  2019-05-21  1:16 ` Dmitry Gutov
  0 siblings, 1 reply; 6+ messages in thread
From: Stephen Leake @ 2019-05-19 17:57 UTC (permalink / raw)
  To: emacs-devel

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.
+
 \f
 * 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
 \f
 ;;; 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))



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-12 22:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-19 17:57 limit length of xref file header line Stephen Leake
2019-05-21  1:16 ` Dmitry Gutov
2019-05-21  9:47   ` Dmitry Gutov
2019-05-24 22:38   ` Stephen Leake
2019-05-25 21:22     ` Dmitry Gutov
2021-09-12 22:47       ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).