emacs-diffs
[Top][All Lists]
Advanced

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

master 2945fe7 2/4: Hide the common parent directory, if any


From: Dmitry Gutov
Subject: master 2945fe7 2/4: Hide the common parent directory, if any
Date: Fri, 4 Dec 2020 20:02:09 -0500 (EST)

branch: master
commit 2945fe74a9fcb09c5fa832ae678d0d7f0b2bb448
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Hide the common parent directory, if any
    
    * lisp/progmodes/xref.el (xref--show-defs-minibuffer):
    Hide the common parent directory, if any.
---
 lisp/progmodes/xref.el | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 363d118..e304a7b 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -935,7 +935,15 @@ local keymap that binds `RET' to 
`xref-quit-and-goto-xref'."
   (let* ((xrefs (funcall fetcher))
          (xref-alist (xref--analyze xrefs))
          xref-alist-with-line-info
-         xref)
+         xref
+         (group-prefix-length
+          ;; FIXME: Groups are not always file names, but they often
+          ;; are.  At least this shouldn't make the other kinds of
+          ;; groups look worse.
+          (let ((common-prefix (try-completion "" xref-alist)))
+            (if (> (length common-prefix) 0)
+                (length (file-name-directory common-prefix))
+              0))))
 
     (cl-loop for ((group . xrefs) . more1) on xref-alist
              do
@@ -944,10 +952,11 @@ local keymap that binds `RET' to 
`xref-quit-and-goto-xref'."
                         (with-slots (summary location) xref
                           (let* ((line (xref-location-line location))
                                  (line-fmt (if line (format "%s:" line) ""))
+                                 (group-fmt (substring group 
group-prefix-length))
                                  (candidate
                                   (if show-summary
-                                      (format "%s:%s%s" group line-fmt summary)
-                                    (format "%s" group))))
+                                      (format "%s:%s%s" group-fmt line-fmt 
summary)
+                                    (format "%s" group-fmt))))
                             (push (cons candidate xref) 
xref-alist-with-line-info))))))
 
     (setq xref (if (not (cdr xrefs))



reply via email to

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