[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/shell-command+ b5398d1 34/36: use eshell handler if ava
From: |
Stefan Monnier |
Subject: |
[elpa] externals/shell-command+ b5398d1 34/36: use eshell handler if available |
Date: |
Fri, 25 Sep 2020 11:01:27 -0400 (EDT) |
branch: externals/shell-command+
commit b5398d1f7cb56e2a2b799b8d125afd7838bf5ce5
Author: Philip K <philipk@posteo.net>
Commit: Philip K <philipk@posteo.net>
use eshell handler if available
---
bang.el | 39 +++++++++++++++++++++++++++------------
1 file changed, 27 insertions(+), 12 deletions(-)
diff --git a/bang.el b/bang.el
index 6f282b9..5fc4678 100644
--- a/bang.el
+++ b/bang.el
@@ -30,6 +30,15 @@
;;; Code:
+(defgroup bang nil
+ "An extended `shell-command'"
+ :group 'external
+ :prefix "bang-")
+
+(defcustom bang-use-eshell t
+ "Check if there is an eshell-handler for each command."
+ :type 'boolean)
+
(defconst bang--command-regexp
(rx bos (* space)
(? (group (or (: ?. (not (any "/"))) ?/ ?~)
@@ -37,7 +46,9 @@
(+ space))
(or (group ?<) (group ?>) (group ?|) ?! "")
(* space)
- (group (+ not-newline))
+ (group (: (group (* (any alnum ?_ ?-)))
+ (? space))
+ (+ not-newline))
eos))
(defun bang-expand-path (path)
@@ -81,17 +92,19 @@ between BEG and END. Otherwise the whole buffer is
processed."
(save-match-data
(unless (string-match bang--command-regexp command)
(error "Invalid command"))
- (let ((path (match-string-no-properties 1 command))
- (has-< (match-string-no-properties 2 command))
- (has-> (match-string-no-properties 3 command))
- (has-| (match-string-no-properties 4 command))
- (rest (condition-case nil
- (replace-regexp-in-string
- (rx (* ?\\ ?\\) (or ?\\ (group "%")))
- buffer-file-name
- (match-string-no-properties 5 command)
- nil nil 1)
- (error (match-string-no-properties 5 command)))))
+ (let* ((path (match-string-no-properties 1 command))
+ (has-< (match-string-no-properties 2 command))
+ (has-> (match-string-no-properties 3 command))
+ (has-| (match-string-no-properties 4 command))
+ (cmd (match-string-no-properties 6 command))
+ (can-eshell (intern-soft (concat "eshell/" cmd)))
+ (rest (condition-case nil
+ (replace-regexp-in-string
+ (rx (* ?\\ ?\\) (or ?\\ (group "%")))
+ buffer-file-name
+ (match-string-no-properties 5 command)
+ nil nil 1)
+ (error (match-string-no-properties 5 command)))))
(let ((default-directory (bang-expand-path (or path "."))))
(cond (has-< (delete-region beg end)
(shell-command rest t shell-command-default-error-buffer)
@@ -102,6 +115,8 @@ between BEG and END. Otherwise the whole buffer is
processed."
(has-| (shell-command-on-region
beg end rest t t
shell-command-default-error-buffer t))
+ ((and bang-use-eshell can-eshell)
+ (eshell-command rest (if current-prefix-arg t nil)))
(t (shell-command rest (if current-prefix-arg t nil)
shell-command-default-error-buffer))))
(when has->
- [elpa] externals/shell-command+ ee9e3e6 17/36: added `.' command, (continued)
- [elpa] externals/shell-command+ ee9e3e6 17/36: added `.' command, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 11e121a 25/36: added support for bang--command-regexp to start with ~, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ a47986d 32/36: updated commentary section, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ f004dfb 23/36: require at least one non-whitespace character in command, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 55f3e2a 16/36: emulated insert-into-buffer feature from shell-command, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ f80c7c3 29/36: autoload bang command, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 8758933 24/36: removed trailing whitespace, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ ab6bb0e 18/36: reworked `.' command, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 87b5ad3 21/36: version bump, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 339931d 36/36: rename bang to shell-command+, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ b5398d1 34/36: use eshell handler if available,
Stefan Monnier <=
- [elpa] externals/shell-command+ 9b28c60 12/36: added melpa link, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 49f3686 08/36: fixed package-lint issues, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 5c01598 09/36: fixed minor checkdoc complaints, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 5e3def9 04/36: Fixed packaging issues and mistakes, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 423c2af 15/36: updated README, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 3fcab36 20/36: only execute real command, not bang modifiers, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ c395408 05/36: Re-added % substitution, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 77989cf 26/36: renamed "Bang command" to "Shell command", Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ d60c01f 22/36: required rx while compiling, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 1fb0162 27/36: bumped version, Stefan Monnier, 2020/09/25