diff --git a/ha-org.org b/ha-org.org index 9e84997..b3ef3f0 100644 --- a/ha-org.org +++ b/ha-org.org @@ -357,6 +357,38 @@ And turn on ALL the languages: (css . t) (plantuml . t))) #+end_src +*** Searching Literate Files +A noweb definition, e.g. =<>= could /jump/ to the =#name= definition. +Since [[https://github.com/BurntSushi/ripgrep][ripgrep]] is pretty fast, I’ll call it instead of attempting to build a [[https://stackoverflow.com/questions/41933837/understanding-the-ctags-file-format][CTAGS]] table. Oooh, the =rg= takes a =—json= option, which makes it easier to parse. + +#+begin_src emacs-lisp + (defun ha-org-noweb-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 --ignore-case --json '#\\+name: +%s' *.org" str)) + + (results (thread-last command + shell-command-to-list + second + json-parse-string)) + (file (thread-last results + (gethash "data") + (gethash "path") + (gethash "text"))) + (line (thread-last results + (gethash "data") + (gethash "line_number")))) + (find-file file) + (goto-line line)))) + + (add-to-list 'evil-goto-definition-functions 'ha-org-noweb-block-jump) +#+end_src + *** REST Web Services Emacs has two ways to query and investigate REST-oriented web services. The [[https://github.com/zweifisch/ob-http][ob-http]] adds HTTP calls to standard org blocks. #+begin_src emacs-lisp diff --git a/ha-programming-elisp.org b/ha-programming-elisp.org index 4d4a9dc..baa7a3d 100644 --- a/ha-programming-elisp.org +++ b/ha-programming-elisp.org @@ -83,6 +83,9 @@ While I love packages that add functionality and I don’t have to learn anythin ;; 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))) + ;; In an org-file, a function may pick up the initial #' + (when (string-match (rx (optional "#") "'" (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))