Last active
June 30, 2018 10:38
-
-
Save tom-seddon/002bfe6c3fb0fc5871ff9ce28bf6a213 to your computer and use it in GitHub Desktop.
DWIM find-function kind of affair.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Interactively invoke tom/find-definition-of-elisp-symbol with point on an elisp symbol. | |
(defvar tom/find-definition-of-elisp-symbol-history '()) | |
(defvar tom/find-definition-of-elisp-symbol-old-marker nil) | |
(defun tom/find-definition-of-elisp-symbol-add-marker () | |
(when tom/find-definition-of-elisp-symbol-old-marker | |
(ring-insert find-tag-marker-ring tom/find-definition-of-elisp-symbol-old-marker) | |
(setq tom/find-definition-of-elisp-symbol-old-marker nil))) | |
(defun tom/find-definition-of-elisp-symbol () | |
(interactive) | |
(let* ((unksym (grep-tag-default)) | |
(funsym (function-called-at-point)) | |
(varsym (variable-at-point))) | |
(add-hook 'find-function-after-hook 'tom/find-definition-of-elisp-symbol-add-marker) | |
(setq tom/find-definition-of-elisp-symbol-old-marker (point-marker)) | |
(cond | |
((equal (symbol-name funsym) unksym) | |
(find-function-do-it funsym nil 'switch-to-buffer)) | |
((not (equal varsym 0)) | |
(find-function-do-it varsym 'defvar 'switch-to-buffer))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment