mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-10 14:10:51 +00:00
Slight simplificaiton
* lisp/progmodes/xref.el (xref--insert-xrefs): Compute log only once. Use 'dolist'.
This commit is contained in:
parent
e139dd1b1e
commit
bbcd8cc1a9
1 changed files with 26 additions and 28 deletions
|
@ -956,13 +956,11 @@ GROUP is a string for decoration purposes and XREF is an
|
||||||
`xref-item' object."
|
`xref-item' object."
|
||||||
(require 'compile) ; For the compilation faces.
|
(require 'compile) ; For the compilation faces.
|
||||||
(cl-loop for (group . xrefs) in xref-alist
|
(cl-loop for (group . xrefs) in xref-alist
|
||||||
for max-line-width =
|
for max-line = (cl-loop for xref in xrefs
|
||||||
(cl-loop for xref in xrefs
|
maximize (xref-location-line
|
||||||
maximize (let ((line (xref-location-line
|
(xref-item-location xref)))
|
||||||
(xref-item-location xref))))
|
for line-format = (and max-line
|
||||||
(and line (1+ (floor (log line 10))))))
|
(format "%%%dd: " (1+ (floor (log max-line 10)))))
|
||||||
for line-format = (and max-line-width
|
|
||||||
(format "%%%dd: " max-line-width))
|
|
||||||
with item-text-props = (list 'mouse-face 'highlight
|
with item-text-props = (list 'mouse-face 'highlight
|
||||||
'keymap xref--button-map
|
'keymap xref--button-map
|
||||||
'help-echo
|
'help-echo
|
||||||
|
@ -973,27 +971,27 @@ GROUP is a string for decoration purposes and XREF is an
|
||||||
do
|
do
|
||||||
(xref--insert-propertized '(face xref-file-header xref-group t)
|
(xref--insert-propertized '(face xref-file-header xref-group t)
|
||||||
group "\n")
|
group "\n")
|
||||||
(cl-loop for xref in xrefs do
|
(dolist (xref xrefs)
|
||||||
(pcase-let (((cl-struct xref-item summary location) xref))
|
(pcase-let (((cl-struct xref-item summary location) xref))
|
||||||
(let* ((line (xref-location-line location))
|
(let* ((line (xref-location-line location))
|
||||||
(prefix
|
(prefix
|
||||||
(cond
|
(cond
|
||||||
((not line) " ")
|
((not line) " ")
|
||||||
((and (equal line prev-line)
|
((and (equal line prev-line)
|
||||||
(equal prev-group group))
|
(equal prev-group group))
|
||||||
"")
|
"")
|
||||||
(t (propertize (format line-format line)
|
(t (propertize (format line-format line)
|
||||||
'face 'xref-line-number)))))
|
'face 'xref-line-number)))))
|
||||||
;; Render multiple matches on the same line, together.
|
;; Render multiple matches on the same line, together.
|
||||||
(when (and (equal prev-group group)
|
(when (and (equal prev-group group)
|
||||||
(or (null line)
|
(or (null line)
|
||||||
(not (equal prev-line line))))
|
(not (equal prev-line line))))
|
||||||
(insert "\n"))
|
(insert "\n"))
|
||||||
(xref--insert-propertized (nconc (list 'xref-item xref)
|
(xref--insert-propertized (nconc (list 'xref-item xref)
|
||||||
item-text-props)
|
item-text-props)
|
||||||
prefix summary)
|
prefix summary)
|
||||||
(setq prev-line line
|
(setq prev-line line
|
||||||
prev-group group))))
|
prev-group group))))
|
||||||
(insert "\n"))
|
(insert "\n"))
|
||||||
(add-to-invisibility-spec '(ellipsis . t))
|
(add-to-invisibility-spec '(ellipsis . t))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue