summaryrefslogtreecommitdiff
path: root/lisp/progmodes/xref.el
diff options
context:
space:
mode:
authorJuri Linkov <juri@linkov.net>2020-12-21 03:22:23 +0200
committerDmitry Gutov <dgutov@yandex.ru>2020-12-21 03:22:23 +0200
commitc3ad28c29098e3dd7c14dc2a8399d08e06d77f51 (patch)
treef956015237e6222326f65841f8f7d71fe6846ae9 /lisp/progmodes/xref.el
parent174607e5ff014fb68bea4945f6199e8da1261788 (diff)
downloademacs-c3ad28c29098e3dd7c14dc2a8399d08e06d77f51.tar.gz
emacs-c3ad28c29098e3dd7c14dc2a8399d08e06d77f51.tar.bz2
emacs-c3ad28c29098e3dd7c14dc2a8399d08e06d77f51.zip
De-duplicate lines in Xref buffers
* lisp/progmodes/xref.el (xref--insert-xrefs): Render matches coming from the same line together (bug#36967). (xref--item-at-point): Account for the above.
Diffstat (limited to 'lisp/progmodes/xref.el')
-rw-r--r--lisp/progmodes/xref.el22
1 files changed, 18 insertions, 4 deletions
diff --git a/lisp/progmodes/xref.el b/lisp/progmodes/xref.el
index 6e99e9d8ace..f33dfb4f5de 100644
--- a/lisp/progmodes/xref.el
+++ b/lisp/progmodes/xref.el
@@ -613,9 +613,9 @@ SELECT is `quit', also quit the *xref* window."
(xref-show-location-at-point))
(defun xref--item-at-point ()
- (save-excursion
- (back-to-indentation)
- (get-text-property (point) 'xref-item)))
+ (get-text-property
+ (if (eolp) (1- (point)) (point))
+ 'xref-item))
(defun xref-goto-xref (&optional quit)
"Jump to the xref on the current line and select its window.
@@ -853,17 +853,30 @@ GROUP is a string for decoration purposes and XREF is an
(length (and line (format "%d" line)))))
for line-format = (and max-line-width
(format "%%%dd: " max-line-width))
+ with prev-line-key = nil
do
(xref--insert-propertized '(face xref-file-header xref-group t)
group "\n")
(cl-loop for (xref . more2) on xrefs do
(with-slots (summary location) xref
(let* ((line (xref-location-line location))
+ (new-summary summary)
+ (line-key (list (xref-location-group location) line))
(prefix
(if line
(propertize (format line-format line)
'face 'xref-line-number)
" ")))
+ ;; Render multiple matches on the same line, together.
+ (when (and line (equal prev-line-key line-key))
+ (let ((column (xref-file-location-column location)))
+ (delete-region
+ (save-excursion
+ (forward-line -1)
+ (move-to-column (+ (length prefix) column))
+ (point))
+ (point))
+ (setq new-summary (substring summary column) prefix "")))
(xref--insert-propertized
(list 'xref-item xref
'mouse-face 'highlight
@@ -871,7 +884,8 @@ GROUP is a string for decoration purposes and XREF is an
'help-echo
(concat "mouse-2: display in another window, "
"RET or mouse-1: follow reference"))
- prefix summary)))
+ prefix new-summary)
+ (setq prev-line-key line-key)))
(insert "\n"))))
(defun xref--analyze (xrefs)