branch: externals/consult commit 1680f26f1c692743d3c9a38cfd33fcd5d943550f Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
consult-xref--preview: Simplify --- consult-xref.el | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/consult-xref.el b/consult-xref.el index 2fb8883ce9..6a0dc03bc2 100644 --- a/consult-xref.el +++ b/consult-xref.el @@ -61,21 +61,22 @@ (funcall preview action (when-let (loc (and cand (eq action 'preview) (xref-item-location cand))) - ;; Only preview file and buffer markers - (pcase (type-of loc) - ('xref-buffer-location - (xref-location-marker loc)) - ((and type (or 'xref-file-location 'xref-etags-location)) - (consult--position-marker - (funcall open - ;; xref-location-group returns the file name - (let ((xref-file-name-display 'abs)) - (xref-location-group loc))) - (xref-location-line loc) - (if (eq type 'xref-file-location) - (xref-file-location-column loc) - 0))) - (_ (message "No preview for %s" (type-of loc)) nil)))))))) + (let ((type (type-of loc))) + ;; Only preview file and buffer markers + (pcase type + ('xref-buffer-location + (xref-location-marker loc)) + ((or 'xref-file-location 'xref-etags-location) + (consult--position-marker + (funcall open + ;; xref-location-group returns the file name + (let ((xref-file-name-display 'abs)) + (xref-location-group loc))) + (xref-location-line loc) + (if (eq type 'xref-file-location) + (xref-file-location-column loc) + 0))) + (_ (message "No preview for %s" type) nil))))))))) (defun consult-xref--group (cand transform) "Return title for CAND or TRANSFORM the candidate."