unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Stephen Leake <stephen_leake@stephe-leake.org>,
	emacs-devel <emacs-devel@gnu.org>
Subject: Re: limit length of xref file header line
Date: Tue, 21 May 2019 04:16:20 +0300	[thread overview]
Message-ID: <db0c7ef0-4544-1948-1425-600c813be99e@yandex.ru> (raw)
In-Reply-To: <86sgtawcmk.fsf@stephe-leake.org>

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

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

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

app/src/main/java/org/stephe_leake/android/stephes_music/activity.java

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



  reply	other threads:[~2019-05-21  1:16 UTC|newest]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=db0c7ef0-4544-1948-1425-600c813be99e@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=stephen_leake@stephe-leake.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 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).