From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Leake Newsgroups: gmane.emacs.devel Subject: limit length of xref file header line Date: Sun, 19 May 2019 09:57:39 -0800 Message-ID: <86sgtawcmk.fsf@stephe-leake.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="181193"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (windows-nt) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun May 19 20:12:46 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSQIg-000l0f-66 for ged-emacs-devel@m.gmane.org; Sun, 19 May 2019 20:12:46 +0200 Original-Received: from localhost ([127.0.0.1]:51816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSQIf-00080x-58 for ged-emacs-devel@m.gmane.org; Sun, 19 May 2019 14:12:45 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60210) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSQIR-0007xq-GQ for emacs-devel@gnu.org; Sun, 19 May 2019 14:12:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSQ4C-0002yR-8m for emacs-devel@gnu.org; Sun, 19 May 2019 13:57:49 -0400 Original-Received: from gproxy8-pub.mail.unifiedlayer.com ([67.222.33.93]:55842) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hSQ4C-0002xn-1q for emacs-devel@gnu.org; Sun, 19 May 2019 13:57:48 -0400 Original-Received: from cmgw12.unifiedlayer.com (unknown [10.9.0.12]) by gproxy8.mail.unifiedlayer.com (Postfix) with ESMTP id 4D3241AB103 for ; Sun, 19 May 2019 11:57:42 -0600 (MDT) Original-Received: from host114.hostmonster.com ([74.220.207.114]) by cmsmtp with ESMTP id SQ46haKhbmds9SQ46hBCxz; Sun, 19 May 2019 11:57:42 -0600 X-Authority-Reason: nr=8 X-Authority-Analysis: $(_cmae_reason Original-Received: from [76.77.182.20] (port=50874 helo=Takver4) by host114.hostmonster.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1hSQ46-0038OI-04 for emacs-devel@gnu.org; Sun, 19 May 2019 11:57:42 -0600 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - host114.hostmonster.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stephe-leake.org X-BWhitelist: no X-Source-IP: 76.77.182.20 X-Source-L: No X-Exim-ID: 1hSQ46-0038OI-04 X-Source-Sender: (Takver4) [76.77.182.20]:50874 X-Source-Auth: stephen_leake@stephe-leake.org X-Email-Count: 1 X-Source-Cap: c3RlcGhlbGU7c3RlcGhlbGU7aG9zdDExNC5ob3N0bW9uc3Rlci5jb20= X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 67.222.33.93 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:236759 Archived-At: 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))