From b3256bdcac9f257e5ad2bd52c770691e64a36105 Mon Sep 17 00:00:00 2001 From: Howard Abrams Date: Tue, 9 Aug 2022 09:59:47 -0700 Subject: [PATCH] Digging on dwim-shell-command Nice and interesting idea. Not crazy about the <> format, but it seems to be a nice replacement. --- ha-config.org | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ha-config.org b/ha-config.org index 9e25afe..cd6df29 100644 --- a/ha-config.org +++ b/ha-config.org @@ -88,10 +88,8 @@ And some Mac-specific settings: (add-to-list 'default-frame-alist '(ns-appearance . dark))) #+end_src * Support Packages -** Piper - +** Piper and DWIM Shell Commands Rewriting my shell scripts in Emacs Lisp uses my [[https://gitlab.com/howardabrams/emacs-piper][emacs-piper project]], and this code spills into my configuration code, so let's load it now: - #+begin_src emacs-lisp (use-package piper :straight (:host gitlab :repo "howardabrams/emacs-piper") @@ -100,6 +98,16 @@ Rewriting my shell scripts in Emacs Lisp uses my [[https://gitlab.com/howardabra ("C-M-|" . piper) ("C-|" . piper-user-interface))) #+end_src +Interested in the [[https://github.com/xenodium/dwim-shell-command][DWIM Shell Command]] project from [[https://xenodium.com/emacs-dwim-shell-command/][Álvaro Ramírez]]. It acts like the regular [[help:shell-command][shell-command]], but the ~q~ closes the results. A command with =<>= operates on the filename of the current buffer, so =chmod a+x <>= works as expected. More useful in [[help:dired][dired]] where you can mark a bunch of files and then operate on all files with such syntax. +#+begin_src emacs-lisp + (use-package dwim-shell-command + :straight (:host github :repo "xenodium/dwim-shell-command") + :bind (("M-!" . dwim-shell-command) + :map dired-mode-map + ([remap dired-do-async-shell-command] . dwim-shell-command) + ([remap dired-do-shell-command] . dwim-shell-command) + ([remap dired-smart-shell-command] . dwim-shell-command))) +#+end_src ** Yet Another Snippet System (YASnippets) Using [[https://github.com/joaotavora/yasnippet][yasnippet]] to convert templates into text: @@ -471,7 +479,8 @@ Let's try this general "space" prefix by defining some top-level operations, inc (ha-leader "SPC" '("M-x" . execute-extended-command) "." '("repeat" . repeat) - "!" 'shell-command + "!" '("shell command" . dwim-shell-command) + "|" 'piper "X" '("org capture" . org-capture) "L" '("store org link" . org-store-link) "RET" 'bookmark-jump