diff --git a/acm/acm-backend-elisp.el b/acm/acm-backend-elisp.el index eafacea6c1..db94db2d01 100644 --- a/acm/acm-backend-elisp.el +++ b/acm/acm-backend-elisp.el @@ -152,6 +152,26 @@ (t "variable"))) +(defun acm-backend-elisp-open-feature-file (feature-string) + "Open the file that defines the given FEATURE-STRING." + (let ((library-path (locate-library feature-string))) + (if library-path + (find-file library-path) + (message "Feature not found: %s" feature-string)))) + +(defun acm-backend-elisp-find-def () + (let* ((symbol-string (thing-at-point 'symbol t)) + (symbol (intern symbol-string))) + (pcase (acm-backend-elisp-symbol-type symbol) + ("feature" (acm-backend-elisp-open-feature-file symbol-string)) + ("special form" (find-variable symbol)) + ("function" (find-function symbol)) + ("macro" (find-function symbol)) + ("face" (find-face-definition symbol)) + ("custom" (find-variable symbol)) + ("constant" (find-variable symbol)) + ("variable" (find-variable symbol))))) + (defun acm-backend-elisp-global-symbols () (all-completions "" obarray diff --git a/lsp-bridge.el b/lsp-bridge.el index f7a66bd357..ba93dcece2 100644 --- a/lsp-bridge.el +++ b/lsp-bridge.el @@ -1471,13 +1471,21 @@ So we build this macro to restore postion after code format." (defun lsp-bridge-find-def () (interactive) - (setq-local lsp-bridge-jump-to-def-in-other-window nil) - (lsp-bridge-call-file-api "find_define" (lsp-bridge--position))) + (cond + ((acm-is-elisp-mode-p) + (acm-backend-elisp-find-def)) + (t + (setq-local lsp-bridge-jump-to-def-in-other-window nil) + (lsp-bridge-call-file-api "find_define" (lsp-bridge--position))))) (defun lsp-bridge-find-def-other-window () (interactive) - (setq-local lsp-bridge-jump-to-def-in-other-window t) - (lsp-bridge-call-file-api "find_define" (lsp-bridge--position))) + (cond + ((acm-is-elisp-mode-p) + (acm-backend-elisp-find-def)) + (t + (setq-local lsp-bridge-jump-to-def-in-other-window t) + (lsp-bridge-call-file-api "find_define" (lsp-bridge--position))))) (defun lsp-bridge-find-def-return () "Pop off lsp-bridge-mark-ring and jump to the top location."