[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/shell-command+ c0129cc 02/36: converted all tabs to spa
From: |
Stefan Monnier |
Subject: |
[elpa] externals/shell-command+ c0129cc 02/36: converted all tabs to spaced |
Date: |
Fri, 25 Sep 2020 11:01:21 -0400 (EDT) |
branch: externals/shell-command+
commit c0129cc8113890ac1939168822761b4cf59cf11d
Author: Philip K <philip@warpmail.net>
Commit: Philip K <philip@warpmail.net>
converted all tabs to spaced
---
.dir-locals.el | 5 +++
bang.el | 122 ++++++++++++++++++++++++++++-----------------------------
2 files changed, 66 insertions(+), 61 deletions(-)
diff --git a/.dir-locals.el b/.dir-locals.el
new file mode 100644
index 0000000..3bcda92
--- /dev/null
+++ b/.dir-locals.el
@@ -0,0 +1,5 @@
+;;; Directory Local Variables
+;;; For more information see (info "(emacs) Directory Variables")
+
+((emacs-lisp-mode
+ (indent-tabs-mode . nil)))
diff --git a/bang.el b/bang.el
index 8658ab6..2c29a76 100644
--- a/bang.el
+++ b/bang.el
@@ -8,15 +8,15 @@
(defconst bang--command-regexp
(rx bos (* space)
- (or (seq (group "!" )
- (or (group (+ digit))
- (group (+ alnum))))
- (group "<") (group ">") (group "|") "")
- (? (* space)
- (group (* not-newline)
- (not space)
- (*? not-newline)))
- eos)
+ (or (seq (group "!" )
+ (or (group (+ digit))
+ (group (+ alnum))))
+ (group "<") (group ">") (group "|") "")
+ (? (* space)
+ (group (* not-newline)
+ (not space)
+ (*? not-newline)))
+ eos)
"Regular expression to parse input to `bang'.")
(defvar bang--last-commands '()
@@ -28,39 +28,39 @@
(defun bang--remember-command (command)
(push command bang--last-commands)
(let ((overflow (- (length bang--last-commands)
- bang-history-size)))
- (when (> overflow 0)
- (setq bang--last-commands
- (nbutlast bang--last-commands overflow)))))
+ bang-history-size)))
+ (when (> overflow 0)
+ (setq bang--last-commands
+ (nbutlast bang--last-commands overflow)))))
(defun bang--find-last-command (prefix)
(catch 'found
- (dolist (cmd bang--last-commands)
- (when (string-prefix-p prefix cmd)
- (throw 'found cmd)))
- (error "no such command in history")))
+ (dolist (cmd bang--last-commands)
+ (when (string-prefix-p prefix cmd)
+ (throw 'found cmd)))
+ (error "no such command in history")))
(defun bang--get-command-number (arg rest)
(let* ((num (string-to-number arg))
- (pos (- (length bang--last-commands)
- (1- num)))
- (cmd (nth pos bang--last-commands)))
- (concat cmd " " rest)))
+ (pos (- (length bang--last-commands)
+ (1- num)))
+ (cmd (nth pos bang--last-commands)))
+ (concat cmd " " rest)))
(defun bang-history ()
"Display a buffer with overview of previous bang commands."
(interactive)
(let ((buf (get-buffer-create "*bang-history*"))
- (i (length bang--last-commands)))
- (with-current-buffer buf
- (setq buffer-read-only nil)
- (delete-region (goto-char (point-min))
- (point-max))
- (dolist (cmd bang--last-commands)
- (insert (format "%d\t%s\n" i cmd))
- (setq i (1- i)))
- (special-mode))
- (pop-to-buffer buf)))
+ (i (length bang--last-commands)))
+ (with-current-buffer buf
+ (setq buffer-read-only nil)
+ (delete-region (goto-char (point-min))
+ (point-max))
+ (dolist (cmd bang--last-commands)
+ (insert (format "%d\t%s\n" i cmd))
+ (setq i (1- i)))
+ (special-mode))
+ (pop-to-buffer buf)))
(defun bang (command beg end)
"Intelligently execute string COMMAND in inferior shell, like
@@ -78,36 +78,36 @@ Without any argument, `bang' will behave like
`shell-command'.
Inside COMMAND, % is replaced with the current file name. To
insert a literal % quote it using a backslash."
(interactive (list (read-shell-command "Bang command: ")
- (if mark-active (region-beginning)
(point-min))
- (if mark-active (region-end)
(point-max))))
+ (if mark-active (region-beginning) (point-min))
+ (if mark-active (region-end) (point-max))))
(save-match-data
- (unless (string-match bang--command-regexp command)
- (error "Invalid command"))
- (let ((has-! (match-string-no-properties 1 command))
- (num-! (match-string-no-properties 2 command))
- (arg-! (match-string-no-properties 3 command))
- (has-< (match-string-no-properties 4 command))
- (has-> (match-string-no-properties 5 command))
- (has-| (match-string-no-properties 6 command))
- (rest (match-string-no-properties 7 command)))
- (cond (arg-! (bang (bang--find-last-command arg-!)
- beg end))
- (num-! (bang (bang--get-command-number num-! rest)
- beg end))
- (has-< (delete-region beg end)
- (shell-command rest t
shell-command-default-error-buffer)
- (exchange-point-and-mark))
- (has-> (shell-command-on-region
- beg end rest nil nil
- shell-command-default-error-buffer t))
- (has-| (shell-command-on-region
- beg end rest t t
- shell-command-default-error-buffer t))
- (t (shell-command command nil
shell-command-default-error-buffer)))
- (when (or has-! has->)
- (with-current-buffer "*Shell Command Output*"
- (kill-ring-save (point-min) (point-max))))
- (unless (or num-! arg-!)
- (bang--remember-command command)))))
+ (unless (string-match bang--command-regexp command)
+ (error "Invalid command"))
+ (let ((has-! (match-string-no-properties 1 command))
+ (num-! (match-string-no-properties 2 command))
+ (arg-! (match-string-no-properties 3 command))
+ (has-< (match-string-no-properties 4 command))
+ (has-> (match-string-no-properties 5 command))
+ (has-| (match-string-no-properties 6 command))
+ (rest (match-string-no-properties 7 command)))
+ (cond (arg-! (bang (bang--find-last-command arg-!)
+ beg end))
+ (num-! (bang (bang--get-command-number num-! rest)
+ beg end))
+ (has-< (delete-region beg end)
+ (shell-command rest t shell-command-default-error-buffer)
+ (exchange-point-and-mark))
+ (has-> (shell-command-on-region
+ beg end rest nil nil
+ shell-command-default-error-buffer t))
+ (has-| (shell-command-on-region
+ beg end rest t t
+ shell-command-default-error-buffer t))
+ (t (shell-command command nil shell-command-default-error-buffer)))
+ (when (or has-! has->)
+ (with-current-buffer "*Shell Command Output*"
+ (kill-ring-save (point-min) (point-max))))
+ (unless (or num-! arg-!)
+ (bang--remember-command command)))))
(provide 'bang)
- [elpa] branch externals/shell-command+ created (now 339931d), Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 57afacb 01/36: initial export, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 3eed583 10/36: fixed typo on the first line, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ ac4ec3c 07/36: added initial readme, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ bed12c8 11/36: minor code cleanup, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 0931b93 03/36: added cc0 as license, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ c0129cc 02/36: converted all tabs to spaced,
Stefan Monnier <=
- [elpa] externals/shell-command+ aecad16 13/36: added link to public inbox, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 64c0fcf 06/36: delete shell output instead of killing it, Stefan Monnier, 2020/09/25
- [elpa] externals/shell-command+ 253d4bc 14/36: removed history code, Stefan Monnier, 2020/09/25
- [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