Last active
June 22, 2024 18:03
-
-
Save grafov/30a4dd6c81ea2526710e16ce1f79e2b9 to your computer and use it in GitHub Desktop.
Revisions
-
grafov revised this gist
Jun 22, 2024 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,17 @@ (require 'ansi-color) ;; Shows haredoc for the selected or word. (defun haredoc () "Run the haredoc with the current word under the cursor and display the results in a new buffer." (interactive) (let* ((current-word (if (use-region-p) ;; Use region or the current word (setq current-word (buffer-substring-no-properties (region-beginning) (region-end))) (setq current-word (thing-at-point 'word t)))) ;; Get the current word (command (concat "haredoc -a -F tty " current-word)) ;; Create the command string (output (shell-command-to-string command)) ;; Run the command and capture the output (buffer-name (concat "*haredoc: " current-word "*"))) ;; Name for the output buffer (with-output-to-temp-buffer buffer-name ;; Create and display the buffer (with-current-buffer buffer-name (insert output) (ansi-color-apply-on-region (point-min) (point-max)))))) -
grafov created this gist
Jun 22, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ (require 'ansi-color) ;; Shows haredoc for the current word. (defun haredoc () "Run the haredoc with the current word under the cursor and display the results in a new buffer." (interactive) (let* ((current-word (thing-at-point 'word t)) ;; Get the current word (command (concat "haredoc -a -F tty " current-word)) ;; Create the command string (output (shell-command-to-string command)) ;; Run the command and capture the output (buffer-name (concat "*haredoc: " current-word "*"))) ;; Name for the output buffer (with-output-to-temp-buffer buffer-name ;; Create and display the buffer (with-current-buffer buffer-name (insert output) ;; Insert as binary due escape seqs (ansi-color-apply-on-region (point-min) (point-max)))))) ;; Finally add coloring