diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index f537561..8b1d4d2 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -323,9 +323,15 @@ shell-command-pipe (:interactive "sPipe to shell command: " :opstring "Shell command executed on" :modifier-p nil) - (shell-command-on-region - (point-min) (point-max) command - (get-buffer-create "* ibuffer-shell-output*"))) + (let* ((out-buf (get-buffer-create "* ibuffer-shell-output*")) + (buffers (with-current-buffer "*Ibuffer*" (ibuffer-get-marked-buffers)))) + (let ((string (with-temp-buffer + (insert-buffer-substring buf) + (shell-command-on-region (point-min) (point-max) command nil t) + (buffer-substring-no-properties (point-min) (point-max))))) + (with-current-buffer out-buf + (when (eq buf (car buffers)) (erase-buffer)) + (insert string))))) ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe-replace "ibuf-ext") (define-ibuffer-op shell-command-pipe-replace (command) @@ -345,12 +351,19 @@ shell-command-file (:interactive "sShell command on buffer's file: " :opstring "Shell command executed on" :modifier-p nil) - (shell-command (concat command " " - (shell-quote-argument - (if buffer-file-name - buffer-file-name - (make-temp-file - (substring (buffer-name) 0 (min 10 (length (buffer-name)))))))))) + (let* ((out-buf (get-buffer-create "*Shell Command Output*")) ; This function and shell-command-pipe + ; should have same out buffer name. + (buffers (with-current-buffer "*Ibuffer*" (ibuffer-get-marked-buffers)))) + (let* ((fname (or buffer-file-name + (let ((file (make-temp-file + (substring (buffer-name) 0 (min 10 (length (buffer-name))))))) + (write-region (point-min) (point-max) file) file))) + (cmd (format "%s %s" command (shell-quote-argument fname))) + (string (shell-command-to-string cmd))) + + (with-current-buffer out-buf + (when (eq buf (car buffers)) (erase-buffer)) + (insert string))))) ;;;###autoload (autoload 'ibuffer-do-eval "ibuf-ext") (define-ibuffer-op eval (form)