commit 7800fe233d69bf2bed1f4e6a1841e660e46f2583
parent 50a1a641afb4054fac6996f2d954bfa399d46cec
Author: Lou Woell <lou.woell@posteo.de>
Date:   Fri,  5 Sep 2025 02:24:57 +0200

[haredoc.el] normalize names

Diffstat:
MREADME.md | 2+-
Mharedoc.el | 57++++++++++++++++++++++++++++++---------------------------
2 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/README.md b/README.md @@ -53,4 +53,4 @@ $ harehelper list <module> ### emacs integration `haredoc.el` provides an emacs interface using harehelper. The main entry points -are `hare/goto-definition`, `haredoc` and `haredoc-describe-thing-at-point`. +are `haredoc/goto-definition`, `haredoc` and `haredoc/describe-thing-at-point`. diff --git a/haredoc.el b/haredoc.el @@ -34,38 +34,40 @@ (require 'thingatpt) (require 'ansi-color) -(defvar hare/helperbindir (f-dirname (macroexp-file-name))) -(defvar hare/helperbin (concat hare/helperbindir "/harehelper")) +(defvar haredoc-helperbindir (f-dirname (macroexp-file-name))) +(defvar haredoc-helperbin (concat haredoc-helperbindir "/harehelper")) -(defun hare/root-dir () +(defun haredoc/root-dir () (interactive) (if-let ((p (project-current nil))) (project-root p) ".")) -(defun hh/exec (strings) +(defun haredoc/exec (strings) (let ((res (shell-command-to-string (string-join strings " ")))) (if (string= res "") nil res))) -(defun hare/get-modules () +(defun haredoc/get-modules () "Return list of Hare modules." - (string-split (hh/exec (list hare/helperbin "-p" (hare/root-dir) - "list-modules")) "\n")) + (string-split (haredoc/exec (list haredoc-helperbin "-p" (haredoc/root-dir) + "list-modules")) "\n")) -(defun hare/read-module (&optional init) - (completing-read "Pick Module: " (hare/get-modules) nil nil init)) +(defun haredoc/read-module (&optional init) + (completing-read "Pick Module: " (haredoc/get-modules) nil nil init)) -(defun hare/identifier-at-point () +(defun haredoc/identifier-at-point () (let ((id (cond ((use-region-p) ;; Use region or the current word (buffer-substring-no-properties (region-beginning) (region-end))) - (t (progn (thing-at-point-looking-at - "\\**\\(\\(\\(\\sw\\|\\s_\\)+::\\)*\\(\\sw\\|\\s_\\)+\\)") - (match-string 1)))))) + (t (progn + (thing-at-point-looking-at + "\\**\\(\\(\\(\\sw\\|\\s_\\)+::\\)*\\(\\sw\\|\\s_\\)+\\)") + (match-string 1)))))) ;; resolve identifier - (or (hh/exec (list hare/helperbin "-p" (hare/root-dir) "resolve" id - (buffer-file-name))) + (or (haredoc/exec (list haredoc-helperbin "-p" (haredoc/root-dir) + "resolve" id + (buffer-file-name))) id))) ;; Shows haredoc for the selected or word. @@ -75,12 +77,13 @@ the results in a new buffer." (interactive) (let* ((current-word (cond (sign sign) - (t (hare/read-module)))) + (t (haredoc/read-module)))) (output (with-environment-variables - (("HAREPATH" (hh/exec (list hare/helperbin - "-p" (hare/root-dir) - "-P")))) - (hh/exec (list "haredoc" "-a" "-F" "tty" current-word)))) + (("HAREPATH" (haredoc/exec (list haredoc-helperbin + "-p" (haredoc/root-dir) + "-P")))) + (haredoc/exec + (list "haredoc" "-a" "-F" "tty" current-word)))) (buffer-name "*haredoc*")) (with-output-to-temp-buffer buffer-name (with-current-buffer buffer-name @@ -90,17 +93,17 @@ the results in a new buffer." (haredoc-mode))))) ;;;###autoload -(defun haredoc-describe-thing-at-point () +(defun haredoc/describe-thing-at-point () (interactive) - (haredoc (hare/identifier-at-point))) + (haredoc (haredoc/identifier-at-point))) ;;;###autoload -(defun hare/goto-defintion () +(defun haredoc/goto-defintion () (interactive) - (when-let* ((name (hare/identifier-at-point)) - (loc (split-string (hh/exec (list hare/helperbin "-p" - (hare/root-dir) - "locate" name)) + (when-let* ((name (haredoc/identifier-at-point)) + (loc (split-string (haredoc/exec (list haredoc-helperbin "-p" + (haredoc/root-dir) + "locate" name)) ":")) (file (nth 0 loc)) (line (string-to-number (nth 1 loc)))