From 41d382c9da9a84ab5391ee906e24f7126d03bd53 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Tue, 16 Jul 2024 12:44:03 +0200 Subject: [PATCH] consult-xref: Let-bind this-command --- consult-xref.el | 37 +++++++++++++++++-------------------- consult.el | 6 +++--- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/consult-xref.el b/consult-xref.el index 639feaf0..028c27bd 100644 --- a/consult-xref.el +++ b/consult-xref.el @@ -88,31 +88,28 @@ See `xref-show-xrefs-function' for the description of the FETCHER and ALIST arguments." (let* ((consult-xref--fetcher fetcher) (candidates (consult-xref--candidates)) - (display (alist-get 'display-action alist))) + (display (alist-get 'display-action alist)) + (this-command #'consult-xref)) (unless candidates (user-error "No xref locations")) (xref-pop-to-location (if (cdr candidates) - (apply - #'consult--read + (consult--read candidates - (append - (consult--customize-get #'consult-xref) - (list - :prompt "Go to xref: " - :history 'consult-xref--history - :require-match t - :sort nil - :category 'consult-xref - :group #'consult--prefix-group - :state - ;; do not preview other frame - (when-let (fun (pcase-exhaustive display - ('frame nil) - ('window #'switch-to-buffer-other-window) - ('nil #'switch-to-buffer))) - (consult-xref--preview fun)) - :lookup (apply-partially #'consult--lookup-prop 'consult-xref)))) + :prompt "Go to xref: " + :history 'consult-xref--history + :require-match t + :sort nil + :category 'consult-xref + :group #'consult--prefix-group + :state + ;; do not preview other frame + (when-let (fun (pcase-exhaustive display + ('frame nil) + ('window #'switch-to-buffer-other-window) + ('nil #'switch-to-buffer))) + (consult-xref--preview fun)) + :lookup (apply-partially #'consult--lookup-prop 'consult-xref)) (get-text-property 0 'consult-xref (car candidates))) display))) diff --git a/consult.el b/consult.el index 578465ca..5e46dfee 100644 --- a/consult.el +++ b/consult.el @@ -2995,10 +2995,10 @@ corresponding customization options." (setq args (cddr args))))) (macroexp-progn setter))) -(defun consult--customize-get (&optional cmd) - "Get configuration from `consult--customize-alist' for CMD." +(defun consult--customize-get () + "Get configuration from `consult--customize-alist' for `this-command'." (mapcar (lambda (x) (eval x 'lexical)) - (alist-get (or cmd this-command) consult--customize-alist))) + (alist-get this-command consult--customize-alist))) ;;;; Commands