branch: externals/objed
commit 85941b8825bf2b6d9647bff39004b80efed9ca86
Author: Clemens Radermacher <[email protected]>
Commit: Clemens Radermacher <[email protected]>
Add objed-execute command
---
README.asc | 2 +-
objed.el | 21 +++++++++++++++++++--
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/README.asc b/README.asc
index 36a54f2..3291dc5 100644
--- a/README.asc
+++ b/README.asc
@@ -325,7 +325,7 @@ once you can mark them first (see the "Misc commands"
below):
|Replace object with inner part (raise).
|kbd:[!]
-|Replace object(s) with minibuffer input.
+|Run object contents as shell commands.
|kbd:[&]
|Pipe object region through shell command.
diff --git a/objed.el b/objed.el
index 39b5e77..eec64df 100644
--- a/objed.el
+++ b/objed.el
@@ -790,6 +790,8 @@ to the selected one."
(define-key map (kbd "<M-return>")
'objed-insert-new-object)
(define-key map "^" 'objed-raise)
+ (define-key map "!" 'objed-execute)
+
map)
"Keymap for commands when `objed' is active.")
@@ -830,15 +832,15 @@ Other single character keys are bound to
`objed-undefined'."
(define-key map "c"
;; upcase, downcase, capitalize, reformat
(objed-define-op nil objed-case-op))
+ ;; (define-key map "q" 'objed-reformat-object)
(define-key map "e" 'objed-eval)
- (define-key map "d" 'dired-jump)
- ;; remove restrictions
(define-key map "r" ctl-x-r-map)
(define-key map "n" 'objed-narrow)
;; TODO: undo propose integration
(define-key map "u" (objed--call-and-switch undo char))
+ (define-key map "d" 'dired-jump)
;; (define-key map "z" 'objed-repeat)
;; actions analog to C-x C-KEY which exit
(define-key map "s" 'save-buffer)
@@ -3175,6 +3177,21 @@ If nil ‘eval-region’ is used instead.")
(insert istring))))
+(defun objed-execute ()
+ "Execute object contents as shell commands."
+ (interactive)
+ (let* ((beg (objed--beg))
+ (end (objed--end))
+ (str (concat (buffer-substring beg end) "\n"))
+ (lines (split-string str "[\r\n]" t)))
+ (objed--reset)
+ (dolist (line lines)
+ (when (y-or-n-p (concat (format "$ %s" line)
+ "?"))
+ (shell-command line)))
+ (objed--init objed--object)))
+
+
;; * Exit active state
(defun objed--line-p (text)