[Emacs] Add imalison:jq-replace

This commit is contained in:
Ivan Malison 2023-06-23 16:56:27 -06:00
parent b24c85aa80
commit f32dcb1504
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -731,6 +731,13 @@ This interactive functions allows the user the select a function to invoke using
(kill-ring-save min max)
(buffer-substring min max))))))
(defun region-if-active-otherwise-buffer ()
(if (region-active-p)
(list (region-beginning) (region-end))
(list (buffer-end -1) (buffer-end 1))))
(region-if-active-otherwise-buffer)
(defun imalison:shell-command-on-region-replace (start end command)
(interactive (list (region-beginning) (region-end)
(read-shell-command "Shell command on region: ")))
@ -738,7 +745,13 @@ This interactive functions allows the user the select a function to invoke using
(emit-prefix-selector imalison:shell-command-on-region
imalison:copy-shell-command-on-region
imalison:shell-command-on-region-replace)
imalison:shell-command-on-region-replace
imalison:jq-replace)
(defun imalison:jq-replace (start end)
(interactive (region-if-active-otherwise-buffer))
(imalison:shell-command-on-region-replace start end "jq ."))
#+END_SRC
** Copy/Yank String Functions
A macro for composing functions together to build an interactive command to copy a string to the kill ring.