branch: externals/shell-command+ commit cb6a66ea171a9f5243f6db7e0946bb257d456909 Merge: 984dc25 0c42623 Author: Stefan Monnier <monn...@iro.umontreal.ca> Commit: Stefan Monnier <monn...@iro.umontreal.ca>
Merge remote-tracking branch 'shell-command+/shell-command+' into externals/shell-command+ --- README.md | 23 +++++++++++++++++++++++ shell-command+.el | 26 ++++++++++++++++++-------- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1a51bf8..9140eb5 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,29 @@ Neukirchen][leah]. Features -------- +Usually `shell-command+` acts just like `shell-command`, but in +certain cases, `shell-command+` pre-processes the input. Here are a +few examples of what that might look like: + + > wc -l + +Count all lines in a buffer, and display the result in the +minibuffer. + + .. < ls -l + +Replace the current region (or buffer in no region is selected) +with a directory listing of the parent directory. + + | tr -d a-z + +Delete all instances of the charachters a, b, c, ..., z, in the +selected region (or buffer, if no region was selected). + + .../src make + +Run Eshell's make (via `compile`) in the parent's parent +directory, and then in `src`. How to use diff --git a/shell-command+.el b/shell-command+.el index e8fcba6..ff93cc7 100644 --- a/shell-command+.el +++ b/shell-command+.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2020 Free Software Foundation, Inc. ;; Author: Philip K. <phil...@posteo.net> -;; Version: 1.0.3 +;; Version: 2.0.0 ;; Keywords: unix, processes, convenience ;; Package-Requires: ((emacs "24.1")) ;; URL: http://elpa.gnu.org/packages/shell-command+.html @@ -24,7 +24,10 @@ ;;; Commentary: ;; ;; `shell-command+' is a `shell-command' substitute, that extends the -;; regular Emacs command with several features. +;; regular Emacs command with several features. After installed, +;; configure the package as follows: +;; +;; (global-set-key (kbd "M-!") #'shell-command+) ;; ;; A few examples of what `shell-command+' can do: ;; @@ -49,8 +52,11 @@ ;; ;; ... make ;; -;; Run Eshell's make (i.e. `compile') in the parent's parent +;; Run Eshell's make (via `compile') in the parent's parent ;; directory. +;; +;; See `shell-command+'s docstring for more details on how it's input +;; is interpreted.. (eval-when-compile (require 'rx)) (require 'eshell) @@ -63,8 +69,11 @@ :prefix "shell-command+-") (defcustom shell-command+-use-eshell t - "Check if there is an eshell-handler for each command." - :type 'boolean) + "Check for eshell handlers. +If t, always invoke eshell handlers. If a list, only invoke +handlers if the symbol (eg. `man') is contained in the list." + :type '(choice (boolean :tag "Always active?") + (repeat :tag "Selected commands" symbol))) (defconst shell-command+--command-regexp (rx bos @@ -79,8 +88,8 @@ ;; allow whitespace after indicator (* space) ;; actual command (and command name) - (group (: (group (*? not-newline)) - (? space)) + (group (? (group (+ not-newline)) + (+ space)) (+ not-newline)) eos) "Regular expression to parse `shell-command+' input.") @@ -149,7 +158,8 @@ between BEG and END. Otherwise the whole buffer is processed." (shell-command-on-region beg end rest t t shell-command-default-error-buffer t)) - ((and shell-command+-use-eshell + ((and (or (eq shell-command+-use-eshell t) + (memq (intern cmd) shell-command+-use-eshell)) (intern-soft (concat "eshell/" cmd))) (eshell-command rest (and current-prefix-arg t))) (t (shell-command rest (and current-prefix-arg t)