From 43bd950c674a11d285084e5d7da2c63ba899c724 Mon Sep 17 00:00:00 2001 From: David Morgan Date: Tue, 1 Oct 2024 15:53:10 +0100 Subject: Add function to find references to the current defun --- .emacs.d/lisp/init-editor.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to '.emacs.d') diff --git a/.emacs.d/lisp/init-editor.el b/.emacs.d/lisp/init-editor.el index 925b05d..850ddab 100644 --- a/.emacs.d/lisp/init-editor.el +++ b/.emacs.d/lisp/init-editor.el @@ -172,6 +172,11 @@ :ensure `(xref :build ,(+elpaca-xref-build-steps)) :custom (xref-search-program 'ripgrep) :config + (defun xref-find-references-current-defun () + "`xref-find-references' for the enclosing defun." + (interactive) + (xref-backend-identifier-completion-table (xref-find-backend)) + (xref-find-references (which-function))) (defun xref-find-references-other-window (identifier) "Like `xref-find-references' but switch to the other window." (interactive (list (xref--read-identifier "Find references of: "))) @@ -187,7 +192,8 @@ ;; there is no value at point that can be used (add-to-list 'xref-prompt-for-identifier 'xref-find-references t) (add-to-list 'xref-prompt-for-identifier 'xref-find-references-other-window t) - (add-to-list 'xref-prompt-for-identifier 'xref-find-references-other-frame t)) + (add-to-list 'xref-prompt-for-identifier 'xref-find-references-other-frame t) + :bind ("C-c q" . xref-find-references-current-defun)) (use-package ws-butler :diminish -- cgit 1.4.1-2-gfad0