From ec4ee61669a88728cc0469c9a310423aefe01769 Mon Sep 17 00:00:00 2001 From: David Morgan Date: Sat, 26 Oct 2024 05:50:42 +0100 Subject: Add consult-recent-xref --- .emacs.d/lisp/init-minibuffer.el | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.emacs.d/lisp/init-minibuffer.el b/.emacs.d/lisp/init-minibuffer.el index 66aabf8..3c8dd99 100644 --- a/.emacs.d/lisp/init-minibuffer.el +++ b/.emacs.d/lisp/init-minibuffer.el @@ -496,7 +496,29 @@ See `+become' and the functions that call it (e.g. `+become-consult-line')." (let ((consult-buffer-sources '(consult--project-source-project-buffer consult--project-source-project-file-recentf consult--project-source-project-file-all))) - (consult-buffer)))) + (consult-buffer))) + + ;; https://takeonrules.com/2024/06/08/adding-a-consult-function-for-visualizing-xref/ + (defvar consult--xref-history nil + "History for the `consult-recent-xref' results.") + (defun consult-recent-xref (&optional markers) + "Jump to a marker in MARKERS list (defaults to `xref--history'. + +The command supports preview of the currently selected marker position. +The symbol at point is added to the future history." + (interactive) + (consult--read + (consult--global-mark-candidates + (or markers (flatten-list xref--history))) + :prompt "Go to Xref: " + :annotate (consult--line-prefix) + :category 'consult-location + :sort nil + :require-match t + :lookup #'consult--lookup-location + :history '(:input consult--xref-history) + :add-history (thing-at-point 'symbol) + :state (consult--jump-state)))) (use-package consult-flycheck) -- cgit 1.4.1-2-gfad0