From 58107f90cb7f58571a96751026c7beb9d58e4eb5 Mon Sep 17 00:00:00 2001 From: David Morgan Date: Thu, 10 Oct 2024 16:51:22 +0100 Subject: Add xref-find-definitions-current-list-function --- .emacs.d/lisp/init-editor.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.emacs.d/lisp/init-editor.el b/.emacs.d/lisp/init-editor.el index c8a2709..fcd1f5a 100644 --- a/.emacs.d/lisp/init-editor.el +++ b/.emacs.d/lisp/init-editor.el @@ -180,6 +180,15 @@ (interactive) (xref-backend-identifier-completion-table (xref-find-backend)) (xref-find-references (which-function))) + (defun xref-find-definitions-current-list-function () + "`xref-find-definitions' for the function at the beginning of the current list. +With a prefix argument, moves up `current-prefix-arg' sexps first." + (interactive) + (let ((fn-name (save-excursion + (when current-prefix-arg + (sp-backward-up-sexp current-prefix-arg)) + (sp-beginning-of-sexp) (thing-at-point 'symbol)))) + (xref-find-definitions fn-name))) (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: "))) @@ -198,6 +207,7 @@ (add-to-list 'xref-prompt-for-identifier 'xref-find-references-other-frame t) :bind ("C-c q" . xref-find-references-current-defun) + ("C-c C-M-." . xref-find-definitions-current-list-function) ;; Make sure xref-find-definitions doesn't override this embark binding (unless https://github.com/oantolin/embark/issues/732 can be fixed) ("M-." . embark-dwim)) -- cgit 1.4.1-2-gfad0