bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output


From: Stefan Monnier
Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output
Date: Wed, 24 Aug 2016 13:05:56 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

> -  (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*")))
> +    (when (or (null file) (not (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 file)
> +                                nil out-buf nil)))

Oh, indeed, we already have `call-process-shell-command'.  Great.

Doesn't look simple enough, tho: you dropped the shell-quote-argument.

> +(defun call-shell-region (start end command &optional delete buffer)
> +"Send text from START to END as input to an inferior shell running COMMAND.
> +Delete the text if fourth arg DELETE is non-nil.
> +
> +Insert output in BUFFER before point; t means current buffer; nil for
> + BUFFER means discard it; 0 means discard and don't wait; and `(:file
> + FILE)', where FILE is a file name string, means that it should be
> + written to that file (if the file already exists it is overwritten).
> +BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
> +REAL-BUFFER says what to do with standard output, as above,
> +while STDERR-FILE says what to do with standard error in the child.
> +STDERR-FILE may be nil (discard standard error output),
> +t (mix it with ordinary output), or a file name string.
> +
> +If BUFFER is 0, `call-shell-region' returns immediately with value nil.
> +Otherwise it waits for COMMAND to terminate
> +and returns a numeric exit status or a signal description string.
> +If you quit, the process is killed with SIGINT, or SIGKILL if you
> quit again."
> +(call-process-region start end
> +                     shell-file-name delete buffer nil
> +                     shell-command-switch command))

Indentation looks wrong, but other than that, looks OK.  Thanks.


        Stefan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]