diff options
author | Tino Calancha <tino.calancha@gmail.com> | 2017-02-09 18:13:59 +0900 |
---|---|---|
committer | Tino Calancha <tino.calancha@gmail.com> | 2017-02-09 18:13:59 +0900 |
commit | 1e23bf5c513fafb9d14a8e07232101515386a912 (patch) | |
tree | 58e1cf95d689cfd9a0682b3f0d49e539d8775c2a /lisp/ibuf-ext.el | |
parent | 2bfe83fcd3575d03f371a7d0e6b8c5d661bc5ac7 (diff) | |
download | emacs-1e23bf5c513fafb9d14a8e07232101515386a912.tar.gz |
Ibuffer: Don't truncate shell command output
* lisp/ibuf-ext.el (ibuffer-do-shell-command-pipe)
(ibuffer-do-shell-command-pipe-replace)
Use 'call-shell-region' (Bug#22679).
(ibuffer-do-shell-command-file): Use call-process-shell-command.
If FILE, the file that the buffer object is visiting,
exists and the buffer is up-to-date, then use
FILE instead of creating a temporary file (Bug#22679).
Diffstat (limited to 'lisp/ibuf-ext.el')
-rw-r--r-- | lisp/ibuf-ext.el | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 058eaecb365..00cbf051d2e 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -512,8 +512,10 @@ the mode if ARG is omitted or nil." (:interactive "sPipe to shell command: " :opstring "Shell command executed on" :modifier-p nil) - (shell-command-on-region - (point-min) (point-max) command)) + (let ((out-buf (get-buffer-create "*Shell Command Output*"))) + (with-current-buffer out-buf (goto-char (point-max))) + (call-shell-region (point-min) (point-max) + command nil out-buf))) ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe-replace "ibuf-ext") (define-ibuffer-op shell-command-pipe-replace (command) @@ -523,9 +525,8 @@ the mode if ARG is omitted or nil." :active-opstring "replace buffer contents in" :dangerous t :modifier-p t) - (with-current-buffer buf - (shell-command-on-region (point-min) (point-max) - command nil t))) + (call-shell-region (point-min) (point-max) + command 'delete buf)) ;;;###autoload (autoload 'ibuffer-do-shell-command-file "ibuf-ext") (define-ibuffer-op shell-command-file (command) @@ -533,16 +534,23 @@ the mode if ARG is omitted or nil." (:interactive "sShell command on buffer's file: " :opstring "Shell command executed on" :modifier-p nil) - (shell-command (concat command " " - (shell-quote-argument - (or buffer-file-name - (let ((file - (make-temp-file - (substring - (buffer-name) 0 - (min 10 (length (buffer-name))))))) - (write-region nil nil file nil 0) - file)))))) + (let ((file (and (not (buffer-modified-p)) + buffer-file-name)) + (out-buf (get-buffer-create "*Shell Command Output*"))) + (unless (and file (file-exists-p file)) + (setq file + (make-temp-file + (substring + (buffer-name) 0 + (min 10 (length (buffer-name)))))) + (write-region nil nil file nil 0)) + (with-current-buffer out-buf (goto-char (point-max))) + (call-process-shell-command + (format "%s %s" + command + (shell-quote-argument file)) + nil out-buf nil))) + ;;;###autoload (autoload 'ibuffer-do-eval "ibuf-ext") (define-ibuffer-op eval (form) |