diff options
author | Kenny Ballou <kb@devnulllabs.io> | 2022-12-08 10:06:33 -0700 |
---|---|---|
committer | Kenny Ballou <kb@devnulllabs.io> | 2022-12-08 10:06:33 -0700 |
commit | 06e8546fd2f4e194557fd2a405ffed2ad81045b6 (patch) | |
tree | 4f7b5ebefc741b8d2f4a95cc5796ac5444ce8dc2 /config | |
parent | e48062d618c69fe69aee5238da46a3c793fc7c68 (diff) | |
download | dotfiles-06e8546fd2f4e194557fd2a405ffed2ad81045b6.tar.gz dotfiles-06e8546fd2f4e194557fd2a405ffed2ad81045b6.tar.xz |
emacs: eshell: add `do` map over files command
Signed-off-by: Kenny Ballou <kb@devnulllabs.io>
Diffstat (limited to 'config')
-rw-r--r-- | config/emacs/emacs.d/emacs.org | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/config/emacs/emacs.d/emacs.org b/config/emacs/emacs.d/emacs.org index 48b31dfd..c470f6f8 100644 --- a/config/emacs/emacs.d/emacs.org +++ b/config/emacs/emacs.d/emacs.org @@ -2357,6 +2357,29 @@ Call `FN2' on all remaining elements in `ARGS'." (defalias 'eshell/more #'eshell/less) +;;; https://github.com/howardabrams/hamacs/blob/main/ha-eshell.org#map-over-files +(defun eshell/do (&rest args) + "Execute a command sequence over a collection of file elements. +Separate the sequence and the elements with a `::' string. +For instance: + + do chown _ angela :: *.org(u'oscar') + +The function substitutes the `_' sequence to a single filename +element, and if not specified, it appends the file name to the +command. So the following works as expected: + + do chmod a+x :: *.org" + (seq-let (forms elements) (-split-on "::" args) + (dolist (element (-flatten (-concat elements))) + (message "Working on %s ... %s" element forms) + (let* ((form (if (-contains? forms "_") + (-replace "_" element forms) + (-snoc forms element))) + (cmd (car form)) + (args (cdr form))) + (eshell-named-command cmd args))))) + (defun eshell/make (&rest args) "Open make with ARGS process into compilation output Buffer." (let ((command (concat "make" " " (string-join args " ")))) |