commit 2cf2546e4093bd00f62179f4e77443b34cb986ff
parent ceb99a3bb69539ebe3e3520a7cb8c562cecb7a6b
Author: Lou Woell <lou.woell@posteo.de>
Date:   Sun, 14 Sep 2025 14:14:58 +0200

[haredoc.el] cleanup

Diffstat:
Mharedoc.el | 29++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/haredoc.el b/haredoc.el @@ -131,46 +131,45 @@ "Run haredoc with the current word under the cursor and display the results in a new buffer." (interactive) - (let* ((current-word (string-trim-right (or sign (haredoc/read-module)) - "::")) - (components (string-split current-word "::" t)) - (location (haredoc/get-location current-word)) + (let* ((id (string-trim-right (or sign (haredoc/read-module)) "::")) + (components (string-split id "::" t)) + (location (haredoc/get-location id)) (location (string-split location ":" t)) (path (nth 0 location)) - (line (string-to-number (nth 1 location))) - (col (string-to-number (nth 2 location))) - (namespace (if (length> components 1) + (parent-ns (if (length> components 1) (string-join (butlast components) "::") (car components))) - (module? (= line col 0))) + (current-ns (if (f-directory? path) + id + parent-ns))) (when haredoc-stack-item (push haredoc-stack-item haredoc-backward-stack) (setq haredoc-forward-stack nil)) - (setq haredoc-stack-item current-word) + (setq haredoc-stack-item id) (let ((buffer (get-buffer-create "*haredoc*")) (inhibit-read-only t)) (with-current-buffer buffer (erase-buffer) - (setq haredoc-current-path current-word - haredoc-current-ns (if module? current-word namespace) - haredoc-parent-ns namespace) + (setq haredoc-current-path id + haredoc-current-ns current-ns + haredoc-parent-ns parent-ns) (ensure-empty-lines 1) (with-environment-variables (("HAREPATH" (car (process-lines haredoc-helperbin "-p" (haredoc/root-dir) "-P")))) - (call-process "haredoc" nil t nil "-a" "-F" "tty" current-word)) + (call-process "haredoc" nil t nil "-a" "-F" "tty" id)) (ansi-color-apply-on-region (point-min) (point-max)) (save-excursion (goto-char (point-min)) (while (re-search-forward "\\[\\[\\(.*?\\)\\]\\]" nil t) - (haredoc/make-button 1 (if module? current-word namespace)))) + (haredoc/make-button 1 current-ns)) - (save-excursion + (goto (point-max)) (when (or (length> components 1) haredoc-backward-stack haredoc-forward-stack) (ensure-empty-lines 2) (when haredoc-backward-stack