[Top][All Lists]

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

Re: limit length of xref file header line

From: Dmitry Gutov
Subject: Re: limit length of xref file header line
Date: Tue, 21 May 2019 04:16:20 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

Hi Stephen,

On 19.05.2019 20:57, Stephen Leake wrote:
In my Android projects, the directory part of filenames is very long,
and overflows the screen length in an *xref* buffer. For example:

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

This is not exactly right. The group attribute can contain the filename, but it doesn't have to. Or else we'd have called in differently.

BTW, check out the three definitions of

  (cl-defmethod xref-location-group ...

for the built-in classes.

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

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.

I don't imagine the user wants to change this variable's value whenever they switch projects.

But if you're fine with that, I guess the appropriate place to change the "display" would instead be in

  (cl-defmethod xref-location-group ((l xref-file-location))
    (oref l file))

Here, we're fairly sure that FILE is a file name, and it would make sense to call file-name-nondirectory on it.

Another option would be to see the place where the xref-file-location instances are created, and uniquify the file names before the entries are created. That would require a new optional 'group' field in the class, though.

Given your Android example, though, here's one thing we can probably do safely either way: make the file names relative to default-directory. We should make sure it's set either to the directory that's being searched, or the project root, though.

So, if c:/Projects/Android/org.stephe_leake.music_player.java/app/src/main/java/org/stephe_leake/android/stephes_music/activity.java

was just


would that solve your problem as well, for this particular project?

reply via email to

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