From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Date: Wed, 24 Aug 2016 13:05:56 -0400 Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1472101337 19597 195.159.176.226 (25 Aug 2016 05:02:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 25 Aug 2016 05:02:17 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cc: 22679@debbugs.gnu.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 25 07:02:13 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcmnt-0004f1-E2 for geb-bug-gnu-emacs@m.gmane.org; Thu, 25 Aug 2016 07:02:13 +0200 Original-Received: from localhost ([::1]:54508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcmnu-00037c-3p for geb-bug-gnu-emacs@m.gmane.org; Thu, 25 Aug 2016 01:02:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcmnj-00034e-1k for bug-gnu-emacs@gnu.org; Thu, 25 Aug 2016 01:02:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bcmni-0000MK-2X for bug-gnu-emacs@gnu.org; Thu, 25 Aug 2016 01:02:03 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42103) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bcmnh-0000MC-Vb for bug-gnu-emacs@gnu.org; Thu, 25 Aug 2016 01:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bcmnh-0000cH-Nh for bug-gnu-emacs@gnu.org; Thu, 25 Aug 2016 01:02:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Aug 2016 05:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22679 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.14721012842324 (code B ref 22679); Thu, 25 Aug 2016 05:02:01 +0000 Original-Received: (at 22679) by debbugs.gnu.org; 25 Aug 2016 05:01:24 +0000 Original-Received: from localhost ([127.0.0.1]:39815 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcmn5-0000bQ-Qc for submit@debbugs.gnu.org; Thu, 25 Aug 2016 01:01:24 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:42647) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcmn0-0000b7-Gt for 22679@debbugs.gnu.org; Thu, 25 Aug 2016 01:01:23 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BRCACJI6tX/6jjSC1dHAEkgwSES4VQhGSreYF9hhcEAgKBXTkUAQEBAQEBAV0nhF8BAQRWIxALDiYSFBgNJIhEwVwBAQEBAQUCJYp3ihsFjhmLI5hZhXyQLB42hBYgh14BAQE X-IPAS-Result: A0BRCACJI6tX/6jjSC1dHAEkgwSES4VQhGSreYF9hhcEAgKBXTkUAQEBAQEBAV0nhF8BAQRWIxALDiYSFBgNJIhEwVwBAQEBAQUCJYp3ihsFjhmLI5hZhXyQLB42hBYgh14BAQE X-IronPort-AV: E=Sophos;i="5.28,500,1464667200"; d="scan'208";a="269065722" Original-Received: from 45-72-227-168.cpe.teksavvy.com (HELO pastel.home) ([45.72.227.168]) by smtp.teksavvy.com with ESMTP; 25 Aug 2016 01:01:13 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 1FD6764553; Wed, 24 Aug 2016 13:05:56 -0400 (EDT) In-Reply-To: (Tino Calancha's message of "Wed, 24 Aug 2016 00:08:57 +0900 (JST)") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:122623 Archived-At: > - (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