From f46d6080afa591833934b3c62a1c515b7acd4113 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Sun, 22 May 2022 22:06:26 -0700 Subject: [PATCH] Better goto-definition when the function is verbatim --- ha-programming-elisp.org | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/ha-programming-elisp.org b/ha-programming-elisp.org index d31843b..0d98dda 100644 --- a/ha-programming-elisp.org +++ b/ha-programming-elisp.org @@ -65,24 +65,27 @@ I love packages that add functionality but I don’t have to learn anything. How (defun ha-org-code-block-jump (str pos) "Go to a literate org file containing a symbol, STR. The POS is ignored." + ;; Sometimes I wrap a function name in `=' characters, and these should be removed: + (when (string-match (rx "=" (group (one-or-more any)) "=") str) + (setq str (match-string 1 str))) (ignore-errors (let* ((default-directory (projectile-project-root)) (command (format "rg --json '\\(def[^ ]+ %s ' *.org" str)) (results (thread-last command - shell-command-to-list - second - json-parse-string)) + shell-command-to-list + second + json-parse-string)) (file (thread-last results - (gethash "data") - (gethash "path") - (gethash "text"))) + (gethash "data") + (gethash "path") + (gethash "text"))) (line (thread-last results - (gethash "data") - (gethash "line_number")))) + (gethash "data") + (gethash "line_number")))) (find-file file) (goto-line line)))) - (add-to-list 'evil-goto-definition-functions ' ha-org-code-block-jump) + (add-to-list 'evil-goto-definition-functions 'ha-org-code-block-jump) #+END_SRC ** Clever Parenthesis We need to make sure we keep the [[https://github.com/Fuco1/smartparens][smartparens]] project always in /strict mode/, because who wants to worry about paren-matching: