branch: externals/consult commit a96ec24784291153cff731deb4024dd3d3bd9967 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
consult-xref: Use completion category `consult-xref' (Fix #557) The xref marker is attached to the `consult-xref' text property. --- consult-xref.el | 8 ++++---- consult.el | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/consult-xref.el b/consult-xref.el index 223e8283c5..263d6d6ad5 100644 --- a/consult-xref.el +++ b/consult-xref.el @@ -45,7 +45,7 @@ (or (xref-location-line loc) 0) (xref-item-summary xref)))) (add-text-properties - 0 1 `(consult--candidate ,xref consult-xref--group ,group) cand) + 0 1 `(consult-xref ,xref consult-xref--group ,group) cand) cand)) xrefs))) @@ -102,7 +102,7 @@ FETCHER and ALIST arguments." :history 'consult-xref--history :require-match t :sort nil - :category 'xref-location + :category 'consult-xref :group #'consult-xref--group :state ;; do not preview other frame @@ -111,8 +111,8 @@ FETCHER and ALIST arguments." ('window #'switch-to-buffer-other-window) ('nil #'switch-to-buffer))) (consult-xref--preview fun)) - :lookup #'consult--lookup-candidate))) - (get-text-property 0 'consult--candidate (car candidates))) + :lookup (apply-partially #'consult--lookup-prop 'consult-xref)))) + (get-text-property 0 'consult-xref (car candidates))) display))) (provide 'consult-xref) diff --git a/consult.el b/consult.el index 2f8faecffc..fb1d961f90 100644 --- a/consult.el +++ b/consult.el @@ -971,10 +971,14 @@ Return the location marker." (when-let (found (member selected candidates)) (car (consult--get-location (car found))))) +(defun consult--lookup-prop (prop selected candidates &rest _) + "Lookup SELECTED in CANDIDATES list and return PROP value." + (when-let (found (member selected candidates)) + (get-text-property 0 prop (car found)))) + (defun consult--lookup-candidate (selected candidates &rest _) "Lookup SELECTED in CANDIDATES list and return property `consult--candidate'." - (when-let (found (member selected candidates)) - (get-text-property 0 'consult--candidate (car found)))) + (consult--lookup-prop 'consult--candidate selected candidates)) (defun consult--forbid-minibuffer () "Raise an error if executed from the minibuffer."