summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2020-12-05 02:36:04 +0200
committerDmitry Gutov <dgutov@yandex.ru>2020-12-05 03:01:34 +0200
commit2945fe74a9fcb09c5fa832ae678d0d7f0b2bb448 (patch)
tree854cb1b8fbcd032e0977314511a81150abf5ee45
parent469f0a65167d004ddbd7b9634c29f42079ebe963 (diff)
downloademacs-2945fe74a9fcb09c5fa832ae678d0d7f0b2bb448.tar.gz
emacs-2945fe74a9fcb09c5fa832ae678d0d7f0b2bb448.tar.bz2
emacs-2945fe74a9fcb09c5fa832ae678d0d7f0b2bb448.zip
Hide the common parent directory, if any
* lisp/progmodes/xref.el (xref--show-defs-minibuffer): Hide the common parent directory, if any.
-rw-r--r--lisp/progmodes/xref.el15
1 files changed, 12 insertions, 3 deletions
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 363d118cf7d..e304a7beae2 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))