all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Leake <stephen_leake@stephe-leake.org>
To: emacs-devel <emacs-devel@gnu.org>
Subject: limit length of xref file header line
Date: Sun, 19 May 2019 09:57:39 -0800	[thread overview]
Message-ID: <86sgtawcmk.fsf@stephe-leake.org> (raw)

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))



             reply	other threads:[~2019-05-19 17:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-19 17:57 Stephen Leake [this message]
2019-05-21  1:16 ` limit length of xref file header line 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86sgtawcmk.fsf@stephe-leake.org \
    --to=stephen_leake@stephe-leake.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.