about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2024-10-10 16:51:22 +0100
committerDavid Morgan <djm_uk@protonmail.com>2024-10-10 16:51:22 +0100
commit58107f90cb7f58571a96751026c7beb9d58e4eb5 (patch)
tree32cf9e391a6cf14afe55a6940a2adf364bfef0a8
parent2e1df93a8d7665cae945b6095b045f0c32aae8c6 (diff)
downloaddotfiles-58107f90cb7f58571a96751026c7beb9d58e4eb5.tar.gz
Add xref-find-definitions-current-list-function
-rw-r--r--.emacs.d/lisp/init-editor.el10
1 files changed, 10 insertions, 0 deletions
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))