]> git.eshelyaron.com Git - emacs.git/commitdiff
Ibuffer: Don't truncate shell command output
authorTino Calancha <tino.calancha@gmail.com>
Thu, 9 Feb 2017 09:13:59 +0000 (18:13 +0900)
committerTino Calancha <tino.calancha@gmail.com>
Thu, 9 Feb 2017 09:13:59 +0000 (18:13 +0900)
* 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).

lisp/ibuf-ext.el

index 058eaecb3658445fceab552e6238639aae902737..00cbf051d2e3ce6d598d3089e6b8442c7d5f69a0 100644 (file)
@@ -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)