Last active
February 23, 2018 00:34
-
-
Save rplevy/a14282a51cbc02e454a5897241b9a07c to your computer and use it in GitHub Desktop.
defshell, defshellonreg, defregexp
This file contains 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 characters
(defmacro defshell (name cmd) | |
`(defun ,name () | |
(interactive) | |
(insert (shell-command-to-string ,cmd)))) | |
(defmacro defshellonreg (name cmd &optional replace) | |
`(defun ,name (beg end) | |
(interactive "r") | |
(shell-command-on-region beg end ,cmd | |
(if ,replace (current-buffer) nil) | |
,replace))) | |
(defmacro defregexp (name a b) | |
`(defun ,name () | |
(interactive) | |
(replace-regexp ,a ,b | |
nil | |
(if (use-region-p) (region-beginning)) | |
(if (use-region-p) (region-end)) | |
nil))) | |
(defshellonreg pbcopy-region "pbcopy") | |
(defshellonreg xml->clj-region "xmlclj" t) | |
(defshellonreg htm2clj-region "html2clj" t) | |
(defshellonreg edn->json "edn2json" t) | |
(defshell uuid "uuidgen | awk '{print tolower($0)}' | tr -d '\n'") | |
(defshell ls "ls") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment