From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Feb 2016 13:19:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22679 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 22679@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.145554231120898 (code B ref -1); Mon, 15 Feb 2016 13:19:01 +0000 Received: (at submit) by debbugs.gnu.org; 15 Feb 2016 13:18:31 +0000 Received: from localhost ([127.0.0.1]:39491 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aVJ2t-0005R0-KL for submit@debbugs.gnu.org; Mon, 15 Feb 2016 08:18:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48889) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aVJ2s-0005Qm-F9 for submit@debbugs.gnu.org; Mon, 15 Feb 2016 08:18:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVJ2m-0004V2-Gv for submit@debbugs.gnu.org; Mon, 15 Feb 2016 08:18:25 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:47446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVJ2m-0004Uv-EJ for submit@debbugs.gnu.org; Mon, 15 Feb 2016 08:18:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVJ2h-0000Ww-Mr for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2016 08:18:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVJ2c-0004Qv-MV for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2016 08:18:19 -0500 Received: from calancha-ilc.kek.jp ([130.87.234.234]:50413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVJ2c-0004QN-4V for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2016 08:18:14 -0500 Received: by calancha-ilc.kek.jp (Postfix, from userid 500) id F3FA5DA69; Mon, 15 Feb 2016 22:21:29 +0900 (JST) Received: from localhost (localhost [127.0.0.1]) by calancha-ilc.kek.jp (Postfix) with ESMTP id E016D88AB for ; Mon, 15 Feb 2016 22:21:29 +0900 (JST) Date: Mon, 15 Feb 2016 22:21:29 +0900 (JST) From: Tino Calancha X-X-Sender: calancha@calancha-ilc.kek.jp Message-ID: User-Agent: Alpine 2.20 (LRH 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="1468197610-740882629-1455542489=:7937" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --1468197610-740882629-1455542489=:7937 Content-Type: text/plain; format=flowed; charset=US-ASCII Only the output of the last processed buffer is shown. Maybe better if it is shown the concatenation of the output of all of them. emacs -Q --eval="(mapc (lambda(x) (switch-to-buffer x) (insert x)) '(\"foo\" \"bar\"))" --eval='(ibuffer)' % n ^\(foo\|bar\)$ RET | cat RET g C-x b * ibuffer-shell-output* ;;just show one word In GNU Emacs 25.0.91.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.29) Repository revision: 23ca48d3d867cfff9f49ef600e2aad7a26c7a870 --1468197610-740882629-1455542489=:7937 Content-Type: text/plain; charset=US-ASCII; name=ibuf-ext.patch2 Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=ibuf-ext.patch2 ZGlmZiAtLWdpdCBhL2xpc3AvaWJ1Zi1leHQuZWwgYi9saXNwL2lidWYtZXh0 LmVsDQppbmRleCBmNTM3NTYxLi44YjFkNGQyIDEwMDY0NA0KLS0tIGEvbGlz cC9pYnVmLWV4dC5lbA0KKysrIGIvbGlzcC9pYnVmLWV4dC5lbA0KQEAgLTMy Myw5ICszMjMsMTUgQEAgc2hlbGwtY29tbWFuZC1waXBlDQogICAoOmludGVy YWN0aXZlICJzUGlwZSB0byBzaGVsbCBjb21tYW5kOiAiDQogICAgOm9wc3Ry aW5nICJTaGVsbCBjb21tYW5kIGV4ZWN1dGVkIG9uIg0KICAgIDptb2RpZmll ci1wIG5pbCkNCi0gIChzaGVsbC1jb21tYW5kLW9uLXJlZ2lvbg0KLSAgIChw b2ludC1taW4pIChwb2ludC1tYXgpIGNvbW1hbmQNCi0gICAoZ2V0LWJ1ZmZl ci1jcmVhdGUgIiogaWJ1ZmZlci1zaGVsbC1vdXRwdXQqIikpKQ0KKyAgKGxl dCogKChvdXQtYnVmIChnZXQtYnVmZmVyLWNyZWF0ZSAiKiBpYnVmZmVyLXNo ZWxsLW91dHB1dCoiKSkNCisgICAgICAgICAoYnVmZmVycyAod2l0aC1jdXJy ZW50LWJ1ZmZlciAiKklidWZmZXIqIiAoaWJ1ZmZlci1nZXQtbWFya2VkLWJ1 ZmZlcnMpKSkpDQorICAgIChsZXQgKChzdHJpbmcgKHdpdGgtdGVtcC1idWZm ZXINCisgICAgICAgICAgICAgICAgICAgIChpbnNlcnQtYnVmZmVyLXN1YnN0 cmluZyBidWYpDQorICAgICAgICAgICAgICAgICAgICAoc2hlbGwtY29tbWFu ZC1vbi1yZWdpb24gKHBvaW50LW1pbikgKHBvaW50LW1heCkgY29tbWFuZCBu aWwgdCkNCisgICAgICAgICAgICAgICAgICAgIChidWZmZXItc3Vic3RyaW5n LW5vLXByb3BlcnRpZXMgKHBvaW50LW1pbikgKHBvaW50LW1heCkpKSkpDQor ICAgICAgKHdpdGgtY3VycmVudC1idWZmZXIgb3V0LWJ1Zg0KKyAgICAgICAg KHdoZW4gKGVxIGJ1ZiAoY2FyIGJ1ZmZlcnMpKSAoZXJhc2UtYnVmZmVyKSkN CisgICAgICAgIChpbnNlcnQgc3RyaW5nKSkpKSkNCiANCiA7OzsjIyNhdXRv bG9hZCAoYXV0b2xvYWQgJ2lidWZmZXItZG8tc2hlbGwtY29tbWFuZC1waXBl LXJlcGxhY2UgImlidWYtZXh0IikNCiAoZGVmaW5lLWlidWZmZXItb3Agc2hl bGwtY29tbWFuZC1waXBlLXJlcGxhY2UgKGNvbW1hbmQpDQpAQCAtMzQ1LDEy ICszNTEsMTkgQEAgc2hlbGwtY29tbWFuZC1maWxlDQogICAoOmludGVyYWN0 aXZlICJzU2hlbGwgY29tbWFuZCBvbiBidWZmZXIncyBmaWxlOiAiDQogICAg Om9wc3RyaW5nICJTaGVsbCBjb21tYW5kIGV4ZWN1dGVkIG9uIg0KICAgIDpt b2RpZmllci1wIG5pbCkNCi0gIChzaGVsbC1jb21tYW5kIChjb25jYXQgY29t bWFuZCAiICINCi0JCQkgKHNoZWxsLXF1b3RlLWFyZ3VtZW50DQotCQkJICAo aWYgYnVmZmVyLWZpbGUtbmFtZQ0KLQkJCSAgICAgIGJ1ZmZlci1maWxlLW5h bWUNCi0JCQkgICAgKG1ha2UtdGVtcC1maWxlDQotCQkJICAgICAoc3Vic3Ry aW5nIChidWZmZXItbmFtZSkgMCAobWluIDEwIChsZW5ndGggKGJ1ZmZlci1u YW1lKSkpKSkpKSkpKQ0KKyAgKGxldCogKChvdXQtYnVmIChnZXQtYnVmZmVy LWNyZWF0ZSAiKlNoZWxsIENvbW1hbmQgT3V0cHV0KiIpKSA7IFRoaXMgZnVu Y3Rpb24gYW5kIHNoZWxsLWNvbW1hbmQtcGlwZQ0KKyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICA7IHNob3VsZCBoYXZlIHNhbWUgb3V0IGJ1ZmZlciBuYW1lLg0KKyAg ICAgICAgIChidWZmZXJzICh3aXRoLWN1cnJlbnQtYnVmZmVyICIqSWJ1ZmZl cioiIChpYnVmZmVyLWdldC1tYXJrZWQtYnVmZmVycykpKSkNCisgICAgKGxl dCogKChmbmFtZSAgKG9yIGJ1ZmZlci1maWxlLW5hbWUNCisgICAgICAgICAg ICAgICAgICAgICAgIChsZXQgKChmaWxlIChtYWtlLXRlbXAtZmlsZQ0KKyAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChzdWJzdHJpbmcg KGJ1ZmZlci1uYW1lKSAwIChtaW4gMTAgKGxlbmd0aCAoYnVmZmVyLW5hbWUp KSkpKSkpDQorICAgICAgICAgICAgICAgICAgICAgICAgICh3cml0ZS1yZWdp b24gKHBvaW50LW1pbikgKHBvaW50LW1heCkgZmlsZSkgZmlsZSkpKQ0KKyAg ICAgICAgICAgKGNtZCAgICAoZm9ybWF0ICIlcyAlcyIgY29tbWFuZCAoc2hl bGwtcXVvdGUtYXJndW1lbnQgZm5hbWUpKSkNCisgICAgICAgICAgIChzdHJp bmcgKHNoZWxsLWNvbW1hbmQtdG8tc3RyaW5nIGNtZCkpKQ0KKw0KKyAgICAg ICh3aXRoLWN1cnJlbnQtYnVmZmVyIG91dC1idWYNCisgICAgICAgICh3aGVu IChlcSBidWYgKGNhciBidWZmZXJzKSkgKGVyYXNlLWJ1ZmZlcikpDQorICAg ICAgICAoaW5zZXJ0IHN0cmluZykpKSkpDQogDQogOzs7IyMjYXV0b2xvYWQg KGF1dG9sb2FkICdpYnVmZmVyLWRvLWV2YWwgImlidWYtZXh0IikNCiAoZGVm aW5lLWlidWZmZXItb3AgZXZhbCAoZm9ybSkNCg== --1468197610-740882629-1455542489=:7937-- From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Jun 2016 05:03: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 To: Tino Calancha Cc: 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.146553495832496 (code B ref 22679); Fri, 10 Jun 2016 05:03:01 +0000 Received: (at 22679) by debbugs.gnu.org; 10 Jun 2016 05:02:38 +0000 Received: from localhost ([127.0.0.1]:35067 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bBEac-0008S4-8i for submit@debbugs.gnu.org; Fri, 10 Jun 2016 01:02:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42323) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bBEab-0008Rt-27 for 22679@debbugs.gnu.org; Fri, 10 Jun 2016 01:02:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bBEaV-0004FG-CD for 22679@debbugs.gnu.org; Fri, 10 Jun 2016 01:02:32 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_20,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bBEaT-0004Eh-Sy; Fri, 10 Jun 2016 01:02:29 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1bBEaR-0004GB-Ln; Fri, 10 Jun 2016 01:02:27 -0400 From: Glenn Morris References: X-Spook: doctrine event security Vaccine Disaster management Area X-Ran: "]^cU/5O5bFwnI%TbCTcvX@S>I>ex[2~}%}+B8;MO8p@~1,]L(JLgM~HUNf}3%U&/t]1qG X-Hue: magenta X-Attribution: GM Date: Fri, 10 Jun 2016 01:02:27 -0400 In-Reply-To: (Tino Calancha's message of "Mon, 15 Feb 2016 22:21:29 +0900 (JST)") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.4 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.4 (------) This seems like it would be a lot simpler if shell-command(-on-region) did not unconditionally erase its output buffer. Although that behaviour is long-standing, it seems unfriendly. It would be easier for callers that wanted that to erase their own output buffers. It's less simple for callers that want to preserve existing output to do so with the current system. From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 10 Jun 2016 09:09: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 To: 22679@debbugs.gnu.org, Tino Calancha Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.146554971723141 (code B ref 22679); Fri, 10 Jun 2016 09:09:01 +0000 Received: (at 22679) by debbugs.gnu.org; 10 Jun 2016 09:08:37 +0000 Received: from localhost ([127.0.0.1]:35124 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bBIQe-000619-TS for submit@debbugs.gnu.org; Fri, 10 Jun 2016 05:08:37 -0400 Received: from mail-yw0-f170.google.com ([209.85.161.170]:33483) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bBIQc-00060n-PA for 22679@debbugs.gnu.org; Fri, 10 Jun 2016 05:08:35 -0400 Received: by mail-yw0-f170.google.com with SMTP id g20so61185660ywb.0 for <22679@debbugs.gnu.org>; Fri, 10 Jun 2016 02:08:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Vz2YM3/P5kegpDMqOKhVJgs66TN2iHjqOkhyY/in7tQ=; b=ykRcq38HeK3Ew38kmS5In0KPVYPB4bQ9ojgwscbivkJRdZa/PKvWS/cgG7M+YRQNAG fAcZBp85rfjJBlGEPxfKy0s4gUecM4UYh0+iJmcqyirWD5KMgmNdf78T7zCdJBzXjDPv 7DUr3mJ3pP5gws3ubx83c7SGbKEO1SqyL+JDA7aRD+mNUi67aaZxj0RbPYimDLggfeaA lgMOW3Q4dngZycv1qqQKCwOmj+CLgmjK/tpHjAf2f05bIChA2xfOS1TIBEMIEluoLb2H B0TfrY1MB/IIuGoeno3jgZM8J20bbcKydMtBLWe0HQcXYYkgXi2NXJgGw8vVDlzw/wx6 Eoew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Vz2YM3/P5kegpDMqOKhVJgs66TN2iHjqOkhyY/in7tQ=; b=hLD8k2+CliDYerox+7MXNipJAOxGVyr5yTI7yFPgiBv+S7Mq4bMYxqfxZdykzCHQpQ BozTy7P3fqq3Bza1wV3RpMDuxF6G8rucnETwoC/ks2x8aATiXhRlCOmP8/6b1vbbO65s zMNezrHr7WpWnNjRvWfvyIQydSgWSeHNgHwdNNYlg9V1jnPTgo/JVNhAf8MouP0HOUun WWFhptqY+cbJhRKAqpoI0kTb9CvIqyrTj0/2ya8ydMP8L0Mb3iQqCIpVKXg1rq2T8xKQ LtjttmYlKAgtp2YFKasDx3c3CdO8YdzFNdjt9MotxhXbs8KtqzjYEsBnmVMZCrb56bCi ldfg== X-Gm-Message-State: ALyK8tLBrAyBG0X7pNd86CmHcfk0sxs6rOfok3KE5UX3p5VGrtvUGH7wnM7+2hXcKt3uXMxxZwvl9og6N7chmA== X-Received: by 10.13.224.5 with SMTP id j5mr400489ywe.195.1465549709101; Fri, 10 Jun 2016 02:08:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.215.216 with HTTP; Fri, 10 Jun 2016 02:08:28 -0700 (PDT) In-Reply-To: References: From: Tino Calancha Date: Fri, 10 Jun 2016 18:08:28 +0900 Message-ID: Content-Type: multipart/alternative; boundary=94eb2c077704cfcf340534e8e15f X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) --94eb2c077704cfcf340534e8e15f Content-Type: text/plain; charset=UTF-8 >This seems like it would be a lot simpler if shell-command(-on-region) >did not unconditionally erase its output buffer. Although that behaviour >is long-standing, it seems unfriendly. It would be easier for callers >that wanted that to erase their own output buffers. It's less simple for >callers that want to preserve existing output to do so with the current >system. Adding an extra optional arg KEEP to shell-command family would do the job straightforward (see below patch). Maybe someone may complaint about one function having 9 (***) arguments (shell-command-on-region) inside a file called 'simple'. (***) I have noticed arg REGION-NONCONTIGUOUS-P is not mentioned in the doc string. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From b14efc632dfafbbc61863c060b9840a752704320 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Fri, 10 Jun 2016 17:44:48 +0900 Subject: [PATCH 1/2] Allow not erasing output buffer on shell-command * lisp/simple.el (async-shell-command) (shell-command, shell-command-on-region): Added optional arg KEEP (Bug#22679). --- lisp/simple.el | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index 6c30929..59fa851 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3187,7 +3187,7 @@ async-shell-command-buffer :group 'shell :version "24.3") -(defun async-shell-command (command &optional output-buffer error-buffer) +(defun async-shell-command (command &optional output-buffer error-buffer keep) "Execute string COMMAND asynchronously in background. Like `shell-command', but adds `&' at the end of COMMAND @@ -3218,9 +3218,9 @@ async-shell-command shell-command-default-error-buffer)) (unless (string-match "&[ \t]*\\'" command) (setq command (concat command " &"))) - (shell-command command output-buffer error-buffer)) + (shell-command command output-buffer error-buffer keep)) -(defun shell-command (command &optional output-buffer error-buffer) +(defun shell-command (command &optional output-buffer error-buffer keep) "Execute string COMMAND in inferior shell; display output, if any. With prefix argument, insert the COMMAND's output at point. @@ -3274,6 +3274,9 @@ shell-command In an interactive call, the variable `shell-command-default-error-buffer' specifies the value of ERROR-BUFFER. +If the optional fourth argument KEEP is non-nil, the output buffer +is not erased before inserting the output. + In Elisp, you will often be better served by calling `call-process' or `start-process' directly, since it offers more control and does not impose the use of a shell (with its need to quote arguments)." @@ -3391,7 +3394,7 @@ shell-command ;; if some text has a non-nil read-only property, ;; which comint sometimes adds for prompts. (let ((inhibit-read-only t)) - (erase-buffer)) + (or keep (erase-buffer))) (display-buffer buffer '(nil (allow-no-window . t))) (setq default-directory directory) (setq proc (start-process "Shell" buffer shell-file-name @@ -3405,7 +3408,7 @@ shell-command )) ;; Otherwise, command is executed synchronously. (shell-command-on-region (point) (point) command - output-buffer nil error-buffer))))))) + output-buffer nil error-buffer nil nil keep))))))) (defun display-message-or-buffer (message &optional buffer-name action frame) "Display MESSAGE in the echo area if possible, otherwise in a pop-up buffer. @@ -3485,7 +3488,7 @@ shell-command-sentinel (defun shell-command-on-region (start end command &optional output-buffer replace error-buffer display-error-buffer - region-noncontiguous-p) + region-noncontiguous-p keep) "Execute string COMMAND in inferior shell with region as input. Normally display output (if any) in temp buffer `*Shell Command Output*'; Prefix arg means replace the region with it. Return the exit code of @@ -3533,7 +3536,10 @@ shell-command-on-region Optional seventh arg DISPLAY-ERROR-BUFFER, if non-nil, means to display the error buffer if there were any errors. When called -interactively, this is t." +interactively, this is t. + +Optional nineth arg KEEP, if non-nil, then the output buffer is +not erased before inserting the output." (interactive (let (string) (unless (mark) (user-error "The mark is not set now, so there is no region")) @@ -3618,7 +3624,9 @@ shell-command-on-region (setq buffer-read-only nil) (if (not output-buffer) (setq default-directory directory)) - (erase-buffer))) + (if keep + (goto-char (point-max)) + (erase-buffer)))) (setq exit-status (call-process-region start end shell-file-name nil (if error-file -- 2.8.1 >From 56f57e6321a7e37389329c6f8c54c340d12ee419 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Fri, 10 Jun 2016 17:56:30 +0900 Subject: [PATCH 2/2] Do not truncate output (Bug#22679) * lisp/ibuf-ext.el (shell-command-pipe, shell-command-file): --- lisp/ibuf-ext.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 0baab6b..9dd1eea 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -325,7 +325,8 @@ shell-command-pipe :modifier-p nil) (shell-command-on-region (point-min) (point-max) command - (get-buffer-create "* ibuffer-shell-output*"))) + (get-buffer-create "* ibuffer-shell-output*") + nil nil nil nil 'keep)) ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe-replace "ibuf-ext") (define-ibuffer-op shell-command-pipe-replace (command) @@ -354,7 +355,7 @@ shell-command-file (buffer-name) 0 (min 10 (length (buffer-name))))))) (write-region nil nil file nil 0) - file)))))) + file)))) nil nil 'keep)) ;;;###autoload (autoload 'ibuffer-do-eval "ibuf-ext") (define-ibuffer-op eval (form) -- 2.8.1 On Fri, Jun 10, 2016 at 6:04 PM, Tino Calancha wrote: > >This seems like it would be a lot simpler if shell-command(-on-region) > >did not unconditionally erase its output buffer. Although that behaviour > >is long-standing, it seems unfriendly. It would be easier for callers > >that wanted that to erase their own output buffers. It's less simple for > >callers that want to preserve existing output to do so with the current > >system. > > Adding an extra optional arg KEEP to shell-command family would do the job > straightforward (see below patch). Maybe someone may complaint about one > function having 9 (***) arguments (shell-command-on-region) inside a file > called > 'simple'. > > (***) I have noticed arg REGION-NONCONTIGUOUS-P is not mentioned in the > doc string. > > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > From b14efc632dfafbbc61863c060b9840a752704320 Mon Sep 17 00:00:00 2001 > From: Tino Calancha > Date: Fri, 10 Jun 2016 17:44:48 +0900 > Subject: [PATCH 1/2] Allow not erasing output buffer on shell-command > > * lisp/simple.el (async-shell-command) > (shell-command, shell-command-on-region): Added optional > arg KEEP (Bug#22679). > --- > lisp/simple.el | 24 ++++++++++++++++-------- > 1 file changed, 16 insertions(+), 8 deletions(-) > > diff --git a/lisp/simple.el b/lisp/simple.el > index 6c30929..59fa851 100644 > --- a/lisp/simple.el > +++ b/lisp/simple.el > @@ -3187,7 +3187,7 @@ async-shell-command-buffer > :group 'shell > :version "24.3") > > -(defun async-shell-command (command &optional output-buffer error-buffer) > +(defun async-shell-command (command &optional output-buffer error-buffer > keep) > "Execute string COMMAND asynchronously in background. > > Like `shell-command', but adds `&' at the end of COMMAND > @@ -3218,9 +3218,9 @@ async-shell-command > shell-command-default-error-buffer)) > (unless (string-match "&[ \t]*\\'" command) > (setq command (concat command " &"))) > - (shell-command command output-buffer error-buffer)) > + (shell-command command output-buffer error-buffer keep)) > > -(defun shell-command (command &optional output-buffer error-buffer) > +(defun shell-command (command &optional output-buffer error-buffer keep) > "Execute string COMMAND in inferior shell; display output, if any. > With prefix argument, insert the COMMAND's output at point. > > @@ -3274,6 +3274,9 @@ shell-command > In an interactive call, the variable `shell-command-default-error-buffer' > specifies the value of ERROR-BUFFER. > > +If the optional fourth argument KEEP is non-nil, the output buffer > +is not erased before inserting the output. > + > In Elisp, you will often be better served by calling `call-process' or > `start-process' directly, since it offers more control and does not impose > the use of a shell (with its need to quote arguments)." > @@ -3391,7 +3394,7 @@ shell-command > ;; if some text has a non-nil read-only property, > ;; which comint sometimes adds for prompts. > (let ((inhibit-read-only t)) > - (erase-buffer)) > + (or keep (erase-buffer))) > (display-buffer buffer '(nil (allow-no-window . t))) > (setq default-directory directory) > (setq proc (start-process "Shell" buffer shell-file-name > @@ -3405,7 +3408,7 @@ shell-command > )) > ;; Otherwise, command is executed synchronously. > (shell-command-on-region (point) (point) command > - output-buffer nil error-buffer))))))) > + output-buffer nil error-buffer nil nil keep))))))) > > (defun display-message-or-buffer (message &optional buffer-name action > frame) > "Display MESSAGE in the echo area if possible, otherwise in a pop-up > buffer. > @@ -3485,7 +3488,7 @@ shell-command-sentinel > (defun shell-command-on-region (start end command > &optional output-buffer replace > error-buffer display-error-buffer > - region-noncontiguous-p) > + region-noncontiguous-p keep) > "Execute string COMMAND in inferior shell with region as input. > Normally display output (if any) in temp buffer `*Shell Command Output*'; > Prefix arg means replace the region with it. Return the exit code of > @@ -3533,7 +3536,10 @@ shell-command-on-region > > Optional seventh arg DISPLAY-ERROR-BUFFER, if non-nil, means to > display the error buffer if there were any errors. When called > -interactively, this is t." > +interactively, this is t. > + > +Optional nineth arg KEEP, if non-nil, then the output buffer is > +not erased before inserting the output." > (interactive (let (string) > (unless (mark) > (user-error "The mark is not set now, so there is no region")) > @@ -3618,7 +3624,9 @@ shell-command-on-region > (setq buffer-read-only nil) > (if (not output-buffer) > (setq default-directory directory)) > - (erase-buffer))) > + (if keep > + (goto-char (point-max)) > + (erase-buffer)))) > (setq exit-status > (call-process-region start end shell-file-name nil > (if error-file > -- > 2.8.1 > > From 56f57e6321a7e37389329c6f8c54c340d12ee419 Mon Sep 17 00:00:00 2001 > From: Tino Calancha > Date: Fri, 10 Jun 2016 17:56:30 +0900 > Subject: [PATCH 2/2] Do not truncate output (Bug#22679) > > * lisp/ibuf-ext.el (shell-command-pipe, shell-command-file): > --- > lisp/ibuf-ext.el | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el > index 0baab6b..9dd1eea 100644 > --- a/lisp/ibuf-ext.el > +++ b/lisp/ibuf-ext.el > @@ -325,7 +325,8 @@ shell-command-pipe > :modifier-p nil) > (shell-command-on-region > (point-min) (point-max) command > - (get-buffer-create "* ibuffer-shell-output*"))) > + (get-buffer-create "* ibuffer-shell-output*") > + nil nil nil nil 'keep)) > > ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe-replace > "ibuf-ext") > (define-ibuffer-op shell-command-pipe-replace (command) > @@ -354,7 +355,7 @@ shell-command-file > (buffer-name) 0 > (min 10 (length (buffer-name))))))) > (write-region nil nil file nil 0) > - file)))))) > + file)))) nil nil 'keep)) > > ;;;###autoload (autoload 'ibuffer-do-eval "ibuf-ext") > (define-ibuffer-op eval (form) > -- > 2.8.1 > > > > On Fri, Jun 10, 2016 at 2:02 PM, Glenn Morris wrote: > >> >> This seems like it would be a lot simpler if shell-command(-on-region) >> did not unconditionally erase its output buffer. Although that behaviour >> is long-standing, it seems unfriendly. It would be easier for callers >> that wanted that to erase their own output buffers. It's less simple for >> callers that want to preserve existing output to do so with the current >> system. >> > > --94eb2c077704cfcf340534e8e15f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

>This seems like it would be a lot simpler if shell= -command(-on-region)
>did not unconditionally erase its output buffer= . Although that behaviour
>is long-standing, it seems unfriendly. It = would be easier for callers
>that wanted that to erase their own outp= ut buffers. It's less simple for
>callers that want to preserve e= xisting output to do so with the current
>system.

Adding an ex= tra optional arg KEEP to shell-command family would do the job
straightf= orward (see below patch).=C2=A0 Maybe someone may complaint about one
fu= nction having 9 (***) arguments (shell-command-on-region) inside a file cal= led
'simple'.

(***) I have noticed arg REGION-NONCONTIGUO= US-P is not mentioned in the doc string.

;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

From b14efc632d= fafbbc61863c060b9840a752704320 Mon Sep 17 00:00:00 2001
From: Tino Calan= cha <f92capac@gmail.com>Date: Fri, 10 Jun 2016 17:44:48 +0900
Subject: [PATCH 1/2] Allow not er= asing output buffer on shell-command

* lisp/simple.el (async-shell-c= ommand)
(shell-command, shell-command-on-region): Added optional
arg = KEEP (Bug#22679).
---
=C2=A0lisp/simple.el | 24 ++++++++++++++++-----= ---
=C2=A01 file changed, 16 insertions(+), 8 deletions(-)

diff -= -git a/lisp/simple.el b/lisp/simple.el
index 6c30929..59fa851 100644
= --- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3187,7 +3187,7 @@ async= -shell-command-buffer
=C2=A0=C2=A0 :group 'shell
=C2=A0=C2=A0 :ve= rsion "24.3")
=C2=A0
-(defun async-shell-command (command &= amp;optional output-buffer error-buffer)
+(defun async-shell-command (co= mmand &optional output-buffer error-buffer keep)
=C2=A0=C2=A0 "= Execute string COMMAND asynchronously in background.
=C2=A0
=C2=A0Lik= e `shell-command', but adds `&' at the end of COMMAND
@@ -32= 18,9 +3218,9 @@ async-shell-command
=C2=A0=C2=A0=C2=A0=C2=A0 shell-comma= nd-default-error-buffer))
=C2=A0=C2=A0 (unless (string-match "&= [ \t]*\\'" command)
=C2=A0=C2=A0=C2=A0=C2=A0 (setq command (con= cat command " &")))
-=C2=A0 (shell-command command output-= buffer error-buffer))
+=C2=A0 (shell-command command output-buffer error= -buffer keep))
=C2=A0
-(defun shell-command (command &optional ou= tput-buffer error-buffer)
+(defun shell-command (command &optional o= utput-buffer error-buffer keep)
=C2=A0=C2=A0 "Execute string COMMAN= D in inferior shell; display output, if any.
=C2=A0With prefix argument,= insert the COMMAND's output at point.
=C2=A0
@@ -3274,6 +3274,9 = @@ shell-command
=C2=A0In an interactive call, the variable `shell-comma= nd-default-error-buffer'
=C2=A0specifies the value of ERROR-BUFFER.<= br>=C2=A0
+If the optional fourth argument KEEP is non-nil, the output b= uffer
+is not erased before inserting the output.
+
=C2=A0In Elisp= , you will often be better served by calling `call-process' or
=C2= =A0`start-process' directly, since it offers more control and does not = impose
=C2=A0the use of a shell (with its need to quote arguments)."= ;
@@ -3391,7 +3394,7 @@ shell-command
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 =C2=A0 ;; if some text has a non-nil read-only property,
= =C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 ;; which comint sometime= s adds for prompts.
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (= let ((inhibit-read-only t))
-=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 (erase-buffer))
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 (or keep (erase-buffer)))
=C2=A0=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0 (display-buffer buffer '(nil (allow-no-window= . t)))
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (setq default= -directory directory)
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= (setq proc (start-process "Shell" buffer shell-file-name
@@ -= 3405,7 +3408,7 @@ shell-command
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0 ))
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ;; Otherwise, = command is executed synchronously.
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0 (shell-command-on-region (point) (point) command
-=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0 output-buffer nil error-buffer)))))))
+=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0 output-buffer nil error-buffer nil nil keep)))))))
=C2=A0
=C2= =A0(defun display-message-or-buffer (message &optional buffer-name acti= on frame)
=C2=A0=C2=A0 "Display MESSAGE in the echo area if possibl= e, otherwise in a pop-up buffer.
@@ -3485,7 +3488,7 @@ shell-command-sen= tinel
=C2=A0(defun shell-command-on-region (start end command
=C2=A0= =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &optional output-buffer replace
=C2= =A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 error-buffer display-error-buffer
-= =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 region-noncontiguous-p)
+=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 region-noncontiguous-p keep)
=C2=A0=C2=A0 "Execu= te string COMMAND in inferior shell with region as input.
=C2=A0Normally= display output (if any) in temp buffer `*Shell Command Output*';
= =C2=A0Prefix arg means replace the region with it.=C2=A0 Return the exit co= de of
@@ -3533,7 +3536,10 @@ shell-command-on-region
=C2=A0
=C2=A0= Optional seventh arg DISPLAY-ERROR-BUFFER, if non-nil, means to
=C2=A0di= splay the error buffer if there were any errors.=C2=A0 When called
-inte= ractively, this is t."
+interactively, this is t.
+
+Optional= nineth arg KEEP, if non-nil, then the output buffer is
+not erased befo= re inserting the output."
=C2=A0=C2=A0 (interactive (let (string)=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0(unless (mark)
=C2= =A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 (user-error "The= mark is not set now, so there is no region"))
@@ -3618,7 +3624,9 @= @ shell-command-on-region
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= (setq buffer-read-only nil)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 (if (not output-buffer)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq default-directory directory))
-=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (erase-buffer)))
+=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (if keep
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 (goto-char (point-max))
+=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (erase-buffer))))
=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= (setq exit-status
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 (call-process-region start end shell-file-name nil
=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (if error-file
--
2.8.1

From 56f57e6321= a7e37389329c6f8c54c340d12ee419 Mon Sep 17 00:00:00 2001
From: Tino Calan= cha <f92capac@gmail.com>Date: Fri, 10 Jun 2016 17:56:30 +0900
Subject: [PATCH 2/2] Do not trunc= ate output (Bug#22679)

* lisp/ibuf-ext.el (shell-command-pipe, shell= -command-file):
---
=C2=A0lisp/ibuf-ext.el | 5 +++--
=C2=A01 file = changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/ibuf-ext.= el b/lisp/ibuf-ext.el
index 0baab6b..9dd1eea 100644
--- a/lisp/ibuf-e= xt.el
+++ b/lisp/ibuf-ext.el
@@ -325,7 +325,8 @@ shell-command-pipe=C2=A0=C2=A0=C2=A0 :modifier-p nil)
=C2=A0=C2=A0 (shell-command-on-reg= ion
=C2=A0=C2=A0=C2=A0 (point-min) (point-max) command
-=C2=A0=C2=A0 = (get-buffer-create "* ibuffer-shell-output*")))
+=C2=A0=C2=A0 = (get-buffer-create "* ibuffer-shell-output*")
+=C2=A0=C2=A0 ni= l nil nil nil 'keep))
=C2=A0
=C2=A0;;;###autoload (autoload '= ibuffer-do-shell-command-pipe-replace "ibuf-ext")
=C2=A0(defin= e-ibuffer-op shell-command-pipe-replace (command)
@@ -354,7 +355,7 @@ sh= ell-command-file
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (buffer-n= ame) 0
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (min 10 (length (bu= ffer-name)))))))
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 (write-region nil nil file nil 0)
-=C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 file)= )))))
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0 file)))) nil nil 'keep))
=C2=A0
=C2=A0;;;###autoload= (autoload 'ibuffer-do-eval "ibuf-ext")
=C2=A0(define-ibuf= fer-op eval (form)
--
2.8.1



On Fri, Jun 10, 2016 at 6:04 PM, Tino Ca= lancha <f92capac@gmail.com> wrote:
>This seems like i= t would be a lot simpler if shell-command(-on-region)
>did not uncond= itionally erase its output buffer. Although that behaviour
>is long-s= tanding, it seems unfriendly. It would be easier for callers
>that wa= nted that to erase their own output buffers. It's less simple for
&g= t;callers that want to preserve existing output to do so with the current>system.

Adding an extra optional arg KEEP to shell= -command family would do the job
straightforward (see below patch).=C2= =A0 Maybe someone may complaint about one
function having 9 (***) argume= nts (shell-command-on-region) inside a file called
'simple'.
=
(***) I have noticed arg REGION-NONCONTIGUOUS-P is not mentioned in the= doc string.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;= ;;;;;;;;;;;;;;;;;;;;;;;;

From b14efc632dfafbbc61863c060b9840a7527043= 20 Mon Sep 17 00:00:00 2001
From: Tino Calancha <f92capac@gmail.com>
Date: Fri= , 10 Jun 2016 17:44:48 +0900
Subject: [PATCH 1/2] Allow not erasing outp= ut buffer on shell-command

* lisp/simple.el (async-shell-command)(shell-command, shell-command-on-region): Added optional
arg KEEP (Bug#= 22679).
---
=C2=A0lisp/simple.el | 24 ++++++++++++++++--------
=C2= =A01 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/lis= p/simple.el b/lisp/simple.el
index 6c30929..59fa851 100644
--- a/lisp= /simple.el
+++ b/lisp/simple.el
@@ -3187,7 +3187,7 @@ async-shell-com= mand-buffer
=C2=A0=C2=A0 :group 'shell
=C2=A0=C2=A0 :version &quo= t;24.3")
=C2=A0
-(defun async-shell-command (command &option= al output-buffer error-buffer)
+(defun async-shell-command (command &= ;optional output-buffer error-buffer keep)
=C2=A0=C2=A0 "Execute st= ring COMMAND asynchronously in background.
=C2=A0
=C2=A0Like `shell-c= ommand', but adds `&' at the end of COMMAND
@@ -3218,9 +3218= ,9 @@ async-shell-command
=C2=A0=C2=A0=C2=A0=C2=A0 shell-command-default= -error-buffer))
=C2=A0=C2=A0 (unless (string-match "&[ \t]*\\&#= 39;" command)
=C2=A0=C2=A0=C2=A0=C2=A0 (setq command (concat comman= d " &")))
-=C2=A0 (shell-command command output-buffer err= or-buffer))
+=C2=A0 (shell-command command output-buffer error-buffer ke= ep))
=C2=A0
-(defun shell-command (command &optional output-buffe= r error-buffer)
+(defun shell-command (command &optional output-buff= er error-buffer keep)
=C2=A0=C2=A0 "Execute string COMMAND in infer= ior shell; display output, if any.
=C2=A0With prefix argument, insert th= e COMMAND's output at point.
=C2=A0
@@ -3274,6 +3274,9 @@ shell-c= ommand
=C2=A0In an interactive call, the variable `shell-command-default= -error-buffer'
=C2=A0specifies the value of ERROR-BUFFER.
=C2=A0<= br>+If the optional fourth argument KEEP is non-nil, the output buffer
+= is not erased before inserting the output.
+
=C2=A0In Elisp, you will= often be better served by calling `call-process' or
=C2=A0`start-pr= ocess' directly, since it offers more control and does not impose
= =C2=A0the use of a shell (with its need to quote arguments)."
@@ -3= 391,7 +3394,7 @@ shell-command
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 =C2=A0 ;; if some text has a non-nil read-only property,
=C2=A0=C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 ;; which comint sometimes adds fo= r prompts.
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (let ((inh= ibit-read-only t))
-=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0 (erase-buffer))
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 (or keep (erase-buffer)))
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0 (display-buffer buffer '(nil (allow-no-window . t)))=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (setq default-director= y directory)
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (setq pr= oc (start-process "Shell" buffer shell-file-name
@@ -3405,7 +3= 408,7 @@ shell-command
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0 ))
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ;; Otherwise, command= is executed synchronously.
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = (shell-command-on-region (point) (point) command
-=C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2= =A0 output-buffer nil error-buffer)))))))
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 ou= tput-buffer nil error-buffer nil nil keep)))))))
=C2=A0
=C2=A0(defun = display-message-or-buffer (message &optional buffer-name action frame)<= br>=C2=A0=C2=A0 "Display MESSAGE in the echo area if possible, otherwi= se in a pop-up buffer.
@@ -3485,7 +3488,7 @@ shell-command-sentinel
= =C2=A0(defun shell-command-on-region (start end command
=C2=A0=C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 &optional output-buffer replace
=C2=A0=C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 error-buffer display-error-buffer
-=C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 region-noncontiguous-p)
+=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 region-noncontiguous-p keep)
=C2=A0=C2=A0 "Execute str= ing COMMAND in inferior shell with region as input.
=C2=A0Normally displ= ay output (if any) in temp buffer `*Shell Command Output*';
=C2=A0Pr= efix arg means replace the region with it.=C2=A0 Return the exit code of@@ -3533,7 +3536,10 @@ shell-command-on-region
=C2=A0
=C2=A0Optional= seventh arg DISPLAY-ERROR-BUFFER, if non-nil, means to
=C2=A0display th= e error buffer if there were any errors.=C2=A0 When called
-interactivel= y, this is t."
+interactively, this is t.
+
+Optional nineth = arg KEEP, if non-nil, then the output buffer is
+not erased before inser= ting the output."
=C2=A0=C2=A0 (interactive (let (string)
=C2=A0= =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0(unless (mark)
=C2=A0=C2=A0= =C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 (user-error "The mark is = not set now, so there is no region"))
@@ -3618,7 +3624,9 @@ shell-c= ommand-on-region
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq bu= ffer-read-only nil)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (if (= not output-buffer)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 (setq default-directory directory))
-=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 (erase-buffer)))
+=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 (if keep
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 (goto-char (point-max))
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (erase-buffer))))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq ex= it-status
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (c= all-process-region start end shell-file-name nil
=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 (if error-file
--
2.8.1

From 56f57e6321a7e373893= 29c6f8c54c340d12ee419 Mon Sep 17 00:00:00 2001
From: Tino Calancha <<= a href=3D"mailto:f92capac@gmail.com" target=3D"_blank">f92capac@gmail.com>
Date: Fri, 10 Jun 2016 17:56:30 +0900
Subject: [PATCH 2/2] Do = not truncate output (Bug#22679)

* lisp/ibuf-ext.el (shell-command-pi= pe, shell-command-file):
---
=C2=A0lisp/ibuf-ext.el | 5 +++--
=C2= =A01 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp= /ibuf-ext.el b/lisp/ibuf-ext.el
index 0baab6b..9dd1eea 100644
--- a/l= isp/ibuf-ext.el
+++ b/lisp/ibuf-ext.el
@@ -325,7 +325,8 @@ shell-comm= and-pipe
=C2=A0=C2=A0=C2=A0 :modifier-p nil)
=C2=A0=C2=A0 (shell-comm= and-on-region
=C2=A0=C2=A0=C2=A0 (point-min) (point-max) command
-=C2= =A0=C2=A0 (get-buffer-create "* ibuffer-shell-output*")))
+=C2= =A0=C2=A0 (get-buffer-create "* ibuffer-shell-output*")
+=C2= =A0=C2=A0 nil nil nil nil 'keep))
=C2=A0
=C2=A0;;;###autoload (au= toload 'ibuffer-do-shell-command-pipe-replace "ibuf-ext")
= =C2=A0(define-ibuffer-op shell-command-pipe-replace (command)
@@ -354,7 = +355,7 @@ shell-command-file
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= (buffer-name) 0
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (min 10 (= length (buffer-name)))))))
=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (write-region nil nil file nil 0)
= -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2= =A0 file))))))
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 file)))) nil nil 'keep))
=C2=A0
=C2=A0;;;###a= utoload (autoload 'ibuffer-do-eval "ibuf-ext")
=C2=A0(defi= ne-ibuffer-op eval (form)--
2.8.1



On Fri,= Jun 10, 2016 at 2:02 PM, Glenn Morris <rgm@gnu.org> wrote:

This seems like it would be a lot simpler if shell-command(-on-region)
did not unconditionally erase its output buffer. Although that behaviour is long-standing, it seems unfriendly. It would be easier for callers
that wanted that to erase their own output buffers. It's less simple fo= r
callers that want to preserve existing output to do so with the current
system.


--94eb2c077704cfcf340534e8e15f-- From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: "C. Calancha" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Jun 2016 03:49:02 +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 To: 22679@debbugs.gnu.org Cc: Tino Calancha , rgm@gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.146561689922521 (code B ref 22679); Sat, 11 Jun 2016 03:49:02 +0000 Received: (at 22679) by debbugs.gnu.org; 11 Jun 2016 03:48:19 +0000 Received: from localhost ([127.0.0.1]:36369 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bBZuF-0005rA-Bb for submit@debbugs.gnu.org; Fri, 10 Jun 2016 23:48:19 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:34466) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bBZuC-0005qx-NN for 22679@debbugs.gnu.org; Fri, 10 Jun 2016 23:48:17 -0400 Received: by mail-pf0-f176.google.com with SMTP id 62so28847896pfd.1 for <22679@debbugs.gnu.org>; Fri, 10 Jun 2016 20:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=Y1f7Z+tQIlbkYm/SwDmqpujTybG5fiGbIBukTQ9HDLc=; b=rVEF1r+h9AT2lKO0wvqc/bwdB+qVRv01Vapaw/5z5B7bN2jg5vz98wfWZFb6FmhWFU +Z9sW4QspEQlrijDdU5ws+Ud2qGd6oQvrpB+SEXdVbEdLvdVGRfStCENZ7B+Yir51y+v +j/iOZq/Czfuodno6T+J/CIKSpGjFODvh0G2iZv5swvgtisAE+y8TLN4EWSOd641I2/3 3zXFQCznhNK3FABmjHjxDT+oStaQBgZD9T7+bNYcjsq0NWQPlWL781TtM0tMTsB+kBwI wl+XkAM7dJUMLhB99iUBwxAPWcOUIf5/7nJILmSSyIi3uJsRKaC5Km8Imc/NHsgwxlrV nJXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=Y1f7Z+tQIlbkYm/SwDmqpujTybG5fiGbIBukTQ9HDLc=; b=REKzO6LTUwfiDt/b6ne8HQkNSO2vfz/8itdTCMAHt54cZjqT13iWzAr3/j2EP2PyQv SPaZAsS3DilK7+WAVLOkUv0k4RawmST5LmRIMRlRfi4g460Oq2r7GHW8vMw5AFDn4wEX YwwzFSgcFH8yc2FRnZXm95L2b4MhqhBdvIVQqACWoHD+SPcOBnxvvAEP4I0T0MESkhEY Zcp+hJ/l/eD7DMUedq0qgfys/uJ4vDWcUnAJYh5S0SQQ+Wr3w/Qe18N3QShtV3q4o4hp WM5NdQ96uKEkv9BivcZsvaCQZr2C2fKVhpKbKlqbU5G5jKXYsrYEKDwCqKpFEIYxckae GAAQ== X-Gm-Message-State: ALyK8tLXRWgeludM9ArD09oMARSWxkTf/Yq0Bmwep9z6UxTOLysNMwrgIs5jZM4hcmHA9A== X-Received: by 10.98.7.154 with SMTP id 26mr5991091pfh.2.1465616890835; Fri, 10 Jun 2016 20:48:10 -0700 (PDT) Received: from calancha-pc ([240f:6e:c00e:1:6875:2e94:598b:96cb]) by smtp.gmail.com with ESMTPSA id s65sm8254827pfd.23.2016.06.10.20.48.08 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 10 Jun 2016 20:48:10 -0700 (PDT) From: "C. Calancha" X-Google-Original-From: "C. Calancha" Date: Sat, 11 Jun 2016 12:48:07 +0900 (JST) In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Note: Sorry, i made previous patch over the Emacs master branch: In GNU Emacs 25.1.50 (x86_64-pc-linux-gnu, GTK+ Version 3.20.6) Repository revision: f9af5eddc835bbed2ca100838f8f294901b60c2d From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Jul 2016 15:59:02 +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 To: Tino Calancha Cc: 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.146773432722793 (code B ref 22679); Tue, 05 Jul 2016 15:59:02 +0000 Received: (at 22679) by debbugs.gnu.org; 5 Jul 2016 15:58:47 +0000 Received: from localhost ([127.0.0.1]:38438 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKSkI-0005vZ-V1 for submit@debbugs.gnu.org; Tue, 05 Jul 2016 11:58:47 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56143) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKSkH-0005vN-2h for 22679@debbugs.gnu.org; Tue, 05 Jul 2016 11:58:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bKSkA-0002Ah-WE for 22679@debbugs.gnu.org; Tue, 05 Jul 2016 11:58:39 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:47259) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bKSk9-00029g-I2; Tue, 05 Jul 2016 11:58:37 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1bKSk7-0003X6-CL; Tue, 05 Jul 2016 11:58:35 -0400 From: Glenn Morris References: X-Spook: Leuken-Baden TB World Trade Center Biological weapon X-Ran: b.e-'(9)AnalNX2o@fU9LQ#RN+6hSOWjjMC;UOgA)/L_/[6S (Tino Calancha's message of "Fri, 10 Jun 2016 18:08:28 +0900") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.3 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.3 (------) Tino Calancha wrote: > Adding an extra optional arg KEEP to shell-command family would do the > job straightforward (see below patch). Maybe someone may complaint > about one function having 9 (***) arguments (shell-command-on-region) > inside a file called 'simple'. Yes, I don't know if it is worth adding such an argument. I was really just complaining about how the function works. :) From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Jul 2016 16:28: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 To: Glenn Morris Cc: Tino Calancha , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.146773605825704 (code B ref 22679); Tue, 05 Jul 2016 16:28:01 +0000 Received: (at 22679) by debbugs.gnu.org; 5 Jul 2016 16:27:38 +0000 Received: from localhost ([127.0.0.1]:38462 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKTCD-0006gW-Qz for submit@debbugs.gnu.org; Tue, 05 Jul 2016 12:27:37 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:35974) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKTCC-0006gK-HA for 22679@debbugs.gnu.org; Tue, 05 Jul 2016 12:27:36 -0400 Received: by mail-pa0-f44.google.com with SMTP id uj8so8920894pab.3 for <22679@debbugs.gnu.org>; Tue, 05 Jul 2016 09:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=MbtId16POhg0MXtV4UFzEJMNmtPhVWhoSHXJ7HGexBA=; b=rNeGygvf4MI4UiS3I1/vCVGTsGwngz79glqeFAZwobbzuA/ez8Ocorx8Sav5m4Bn5Y 1dVFgCdt9eT72E7vYuDRFA/LGOgmHRUw2NEgA4HDB3jvBsPeTFTmR3tscMqIR6a9M6MB am8Ea05DJyqFN6NBBexHxKjJRqTWS6GEZ+6whPTW5HGkqYp4pol7FjY15dCFYrZld3T2 7qNobLiOpsUegTh4Kf7D8m6iW6yVL92UvaqUDfNIddjWTT8wN5kO1qdTr2/RMLd7FHho gyQaXKLAODyP/NGMowSVd++3ARKg5KStFH0VId6dbaVlmOKlSHPt06dOtBdz6o0f2Dad RnHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=MbtId16POhg0MXtV4UFzEJMNmtPhVWhoSHXJ7HGexBA=; b=QFKw1Qcv/2G6GFsAPhIzAx4KUKCO82kT3UCnOnZPjW2xnXZy+mRzVZxe76oSpVnP/H LwijKx17qMPDJgRcI3YgZWD+0QjXwj2sgIzzO+Z+778jxl219jO9M2T1mN+XgmmQc+Bv 11qkIhkpS0Cguori36BQcmlz+LJTKE3ZLMjhBV64S3ItCkFdD8JkbMLtqgLCYMwYqaG3 ocUH7zi8NkajTMLgnc+Kuim8DjloNJPr6kB2tMOt2pm6aEWML0fgi7mvVApvkLNY1r7G DV14tcvzhRRSthOT/GMP82z/1BOdeAS/ydvWqAycDNJnW0DBAoSU1rSGA5zKoM1v98Gl zwHw== X-Gm-Message-State: ALyK8tLHWyz6klq5nMpBsPXkHg/KGeP698gXqc3bir5Je+G30YJEmr7CPqkBX0U/ra/52w== X-Received: by 10.66.48.133 with SMTP id l5mr33264705pan.151.1467736050724; Tue, 05 Jul 2016 09:27:30 -0700 (PDT) Received: from calancha-pc (softbank126103139048.bbtec.net. [126.103.139.48]) by smtp.gmail.com with ESMTPSA id j5sm6022687pfj.71.2016.07.05.09.27.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jul 2016 09:27:29 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Wed, 6 Jul 2016 01:27:27 +0900 (JST) X-X-Sender: calancha@calancha-pc In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Tue, 5 Jul 2016, Glenn Morris wrote: > Yes, I don't know if it is worth adding such an argument. > I was really just complaining about how the function works. :) I like your proposal: it simplifies the code and it reads much better. But i am quite new here as to modify that stuff in simple.el: some people may not understand why to change `shell-command' just to fix one marginal command that just few people use. Of course the priority is to make the command works as it should. If i need to fix this i think i would find less resistance if my patch just modify the offending command, possibly with an ugly code. Once the bug is fixed, then someone with much credits may think to write a more elegant solution. From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Glenn Morris Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Jul 2016 17:30:02 +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 To: Tino Calancha Cc: 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.146808535713793 (code B ref 22679); Sat, 09 Jul 2016 17:30:02 +0000 Received: (at 22679) by debbugs.gnu.org; 9 Jul 2016 17:29:17 +0000 Received: from localhost ([127.0.0.1]:44367 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLw45-0003aN-CE for submit@debbugs.gnu.org; Sat, 09 Jul 2016 13:29:17 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35688) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLw43-0003Ze-Do for 22679@debbugs.gnu.org; Sat, 09 Jul 2016 13:29:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLw3x-0006Ik-DM for 22679@debbugs.gnu.org; Sat, 09 Jul 2016 13:29:10 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:44425) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLw3v-0006Hf-Vj; Sat, 09 Jul 2016 13:29:08 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.82) (envelope-from ) id 1bLw3q-00069e-Hx; Sat, 09 Jul 2016 13:29:02 -0400 From: Glenn Morris References: X-Spook: Peking Chemical weapon blackjack Security Council X-Ran: M&]{e=UFS7/[teiK[-3fWiRNJ{Al/!q3H*O'&E#<=orUf8b%5i=]`f(Wa},S?M?4l4ipXd X-Hue: magenta X-Attribution: GM Date: Sat, 09 Jul 2016 13:28:59 -0400 In-Reply-To: (Tino Calancha's message of "Wed, 6 Jul 2016 01:27:27 +0900 (JST)") Message-ID: <7oa66k9es.fsf@fencepost.gnu.org> User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -6.3 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.3 (------) Tino Calancha wrote: > On Tue, 5 Jul 2016, Glenn Morris wrote: > >> Yes, I don't know if it is worth adding such an argument. >> I was really just complaining about how the function works. :) > I like your proposal: it simplifies the code and it reads much better. > But i am quite new here as to modify that stuff in simple.el: > some people may not understand why to change `shell-command' just > to fix one marginal command that just few people use. You could ask on emacs-devel (though that is often unproductive). Frankly my own preference would be to change the function so that it does not erase the output buffer, and change the callers instead; but that may be totally unfeasible. > Of course the priority is to make the command works as it should. > If i need to fix this i think i would find less resistance if my patch > just modify the offending command, possibly with an ugly code. You should feel free to just change ibuffer if that is what you prefer. It will certainly be less hassle for you. From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Jul 2016 15:28:02 +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 To: Glenn Morris Cc: Tino Calancha , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.146842365917267 (code B ref 22679); Wed, 13 Jul 2016 15:28:02 +0000 Received: (at 22679) by debbugs.gnu.org; 13 Jul 2016 15:27:39 +0000 Received: from localhost ([127.0.0.1]:49993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNM4Z-0004UR-ER for submit@debbugs.gnu.org; Wed, 13 Jul 2016 11:27:39 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:57190) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNM4X-0004UE-Ug for 22679@debbugs.gnu.org; Wed, 13 Jul 2016 11:27:38 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0A2FgA731xV/3mcpUVcgxCEAoVVu0CEfoJNBAICgTw6EwEBAQEBAQGBCkEFg10BAQMBViMFCwsOJhIUGA0kiDcIzyMBAQEBAQEEAQEBAR6LOoUFB4QtBbM/gUUjhBQigngBAQE X-IPAS-Result: A0A2FgA731xV/3mcpUVcgxCEAoVVu0CEfoJNBAICgTw6EwEBAQEBAQGBCkEFg10BAQMBViMFCwsOJhIUGA0kiDcIzyMBAQEBAQEEAQEBAR6LOoUFB4QtBbM/gUUjhBQigngBAQE X-IronPort-AV: E=Sophos;i="5.13,465,1427774400"; d="scan'208";a="247769208" Received: from 69-165-156-121.dsl.teksavvy.com (HELO pastel.home) ([69.165.156.121]) by ironport2-out.teksavvy.com with ESMTP; 13 Jul 2016 11:27:32 -0400 Received: by pastel.home (Postfix, from userid 20848) id 16ECE64CB1; Wed, 13 Jul 2016 11:27:32 -0400 (EDT) From: Stefan Monnier Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> Date: Wed, 13 Jul 2016 11:27:32 -0400 In-Reply-To: <7oa66k9es.fsf@fencepost.gnu.org> (Glenn Morris's message of "Sat, 09 Jul 2016 13:28:59 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > You could ask on emacs-devel (though that is often unproductive). > Frankly my own preference would be to change the function so that it > does not erase the output buffer, and change the callers instead; but > that may be totally unfeasible. shell-command is designed for interactive use. In 90% of the cases, Elisp code that uses shell-command would be just as well, if not better, served by start/call-process. Maybe the better change is to create a new function (partly extracted from shell-command) which would be halfway between shell-command and start-process: i.e. designed for use from Elisp, but specifically tailored to running shell code rather than some other executable. Then use that function in shell-command and ibuffer-do-shell-command-pipe. >> Of course the priority is to make the command works as it should. >> If i need to fix this i think i would find less resistance if my patch >> just modify the offending command, possibly with an ugly code. If the new function is well designed, the new ibuffer-do-shell-command-pipe code shouldn't be ugly. Stefan From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 Aug 2016 08:34:02 +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 To: Stefan Monnier Cc: Tino Calancha , Glenn Morris , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.147159559225016 (code B ref 22679); Fri, 19 Aug 2016 08:34:02 +0000 Received: (at 22679) by debbugs.gnu.org; 19 Aug 2016 08:33:12 +0000 Received: from localhost ([127.0.0.1]:33823 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bafEm-0006VQ-Dt for submit@debbugs.gnu.org; Fri, 19 Aug 2016 04:33:12 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35070) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bafEk-0006V8-Ok for 22679@debbugs.gnu.org; Fri, 19 Aug 2016 04:33:11 -0400 Received: by mail-pf0-f195.google.com with SMTP id h186so1134596pfg.2 for <22679@debbugs.gnu.org>; Fri, 19 Aug 2016 01:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=VZlC5i0xJRupbl6Aj+QlmSEXbl3B0L+rwYWNdv8DOg0=; b=PFvn5z8aQmiSi3XFTLjhW8jzhzzWb0G/F4TCnmlgBKJ1+Of7qEpIMj2qCBNNJxxRMI mZcZ6gPKFEba31k3S/Dog0eD5C2xkNBMvaw1mA3mEGXresGstl9R2vLQGDza3jo4LjxJ BH6uYTLbgiDB9tEbLllujf+WTaCzrlmINoOyxmKkRXcxeHNZ6LJu1DjzT2gBTNQE1OUy fTSpQZg9Pw5Ru1xuKfDnJ5wT0877KsCVvj2+G7lNz7vocSaUVFT+0tNQzEoZahHZ7iuA f+Vvfewihb0pBLXZOaiGCyV2k5NPQ1WxbVqo/d7JJS4Vo1/ThY96zsIErbsHZ48doGyu FE0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=VZlC5i0xJRupbl6Aj+QlmSEXbl3B0L+rwYWNdv8DOg0=; b=FhKFk7q360fFPjOziHTJR6Y3PqB/U1vLbH1u7wlhd57WDCjE7MvC0w98I1+v+TxLrR bwTmpAanVESzj/tDcIKWe9FqBvgz7FbzoC5nhC5pRHzRXGZbFns+bt4evE/M2Owfr0u/ mQXFmYtTMnoIjhhshAQD6TI3t4MXitaulKMsBb6oBLzyb75SX3atb7L4xqFlyFcHo+0s 4YqvJMuhSBmGugIEB7U18N3ur1/wiko9ZmCTwNggUsU2InWE1yN6zZHQbPq/roBUeJOz gFmdU8d6+cTjTPWwIPVmP0Cmb+7rMkN3GjBUrdGjUNlMqY/WVYzkrzzakbPo/roaxKrA VLfQ== X-Gm-Message-State: AEkoouvCiZ5HQsjthJRi5qjGzvG4sh00EH5cU1PtO35Ah5C35JKFAI89Lqg74PlU+2tEVA== X-Received: by 10.98.36.134 with SMTP id k6mr11932860pfk.116.1471595584961; Fri, 19 Aug 2016 01:33:04 -0700 (PDT) Received: from calancha-pc (214018171106.wi-fi.kddi.com. [106.171.18.214]) by smtp.gmail.com with ESMTPSA id m5sm9316018paw.40.2016.08.19.01.33.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Aug 2016 01:33:04 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Fri, 19 Aug 2016 17:33:00 +0900 (JST) X-X-Sender: calancha@calancha-pc In-Reply-To: Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Wed, 13 Jul 2016, Stefan Monnier wrote: > shell-command is designed for interactive use. > > In 90% of the cases, Elisp code that uses shell-command would be just as > well, if not better, served by start/call-process. > > Maybe the better change is to create a new function (partly extracted > from shell-command) which would be halfway between shell-command and > start-process: i.e. designed for use from Elisp, but specifically > tailored to running shell code rather than some other executable. > > Then use that function in shell-command and ibuffer-do-shell-command-pipe. Hi Stefan, thanks for the indications. I would like to apply following patch, which avoid using 'shell-command': ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From 49a77e617b26044c84f193753f1eb7ec4ccea5d8 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Fri, 19 Aug 2016 16:46:14 +0900 Subject: [PATCH] ibuffer-do-shell-command-pipe: Do not truncate output Fix Bug#22679 * lisp/ibuf-macs.el (define-ibuffer-op): Added optional args 'before' and 'after'. 'before' is a form to evaluate before the operation. 'after' is a form to evaluate after the operation. * lisp/ibuf-ext.el (ibuffer--after-shell-command-pos): New defvar; store a buffer position where to set the point in the output buffer after operation complete. (ibuffer--before-shell-command): New defun; erase output buffer if 'shell-command-not-erase-buffer' is nil and set 'ibuffer--after-shell-command-pos'. (ibuffer--after-shell-command): New defun; set point in the output buffer after operation complete. (ibuffer-do-shell-command-pipe, ibuffer-do-shell-command-file): Bind 'shell-command-not-erase-buffer' to non-nil while processing the buffers; use 'ibuffer--after-shell-command' to set the point in the output buffer. --- lisp/ibuf-ext.el | 83 +++++++++++++++++++++++++++++++++++++++++++------------ lisp/ibuf-macs.el | 8 +++++- 2 files changed, 72 insertions(+), 19 deletions(-) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index f93957e..333104d 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -346,14 +346,58 @@ ibuffer-backward-filter-group (ibuffer-backward-filter-group 1)) (ibuffer-forward-line 0)) +;; The value `beg-last-out' in `shell-command-not-erase-buffer' +;; set the point at the beginning of the output of the first +;; buffer processed. +(defvar ibuffer--after-shell-command-pos) + +(defun ibuffer--before-shell-command () + (let ((obuf (get-buffer-create "*Shell Command Output*")) + (sym shell-command-not-erase-buffer) + final-pos) + (when (buffer-live-p obuf) + (with-current-buffer obuf + (unless sym + (setq buffer-read-only nil) + (let ((inhibit-read-only t)) + (erase-buffer))) + (setq final-pos + (cond ((or (not sym) (eq sym 'beg-last-out)) + (point-max)) + ((eq sym 'save-point) + (point)))) + (setq ibuffer--after-shell-command-pos + final-pos))))) + +(defun ibuffer--after-shell-command () + (let* ((obuf (get-buffer-create "*Shell Command Output*")) + (pos ibuffer--after-shell-command-pos) + (win (car (get-buffer-window-list obuf)))) + (setq ibuffer--after-shell-command-pos nil) + (with-current-buffer obuf + (unless pos (setq pos (point-max))) + (goto-char pos) + ;; Set point in the window displaying obuf, if any; otherwise + ;; display buf temporary in selected frame and set the point. + (if win + (set-window-point win pos) + (save-window-excursion + (let ((win (display-buffer obuf '(nil (inhibit-switch-frame . t))))) + (set-window-point win pos))))))) + ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe "ibuf-ext") (define-ibuffer-op shell-command-pipe (command) "Pipe the contents of each marked buffer to shell command COMMAND." (:interactive "sPipe to shell command: " :opstring "Shell command executed on" - :modifier-p nil) - (shell-command-on-region - (point-min) (point-max) command)) + :modifier-p nil + :opstring "Shell command executed on" + :modifier-p nil + :before (funcall #'ibuffer--before-shell-command) + :after (funcall #'ibuffer--after-shell-command)) + (let ((out-buf (get-buffer "*Shell Command Output*"))) + (with-current-buffer out-buf (goto-char (point-max))) + (call-process-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) @@ -363,26 +407,29 @@ shell-command-pipe-replace :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-process-region (point-min) (point-max) command t buf)) ;;;###autoload (autoload 'ibuffer-do-shell-command-file "ibuf-ext") (define-ibuffer-op shell-command-file (command) "Run shell command COMMAND separately on files of marked buffers." (: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)))))) + :opstring "Shell command executed on" + :modifier-p nil + :before (funcall #'ibuffer--before-shell-command) + :after (funcall #'ibuffer--after-shell-command)) + (let ((file (and (not (buffer-modified-p)) + buffer-file-name)) + (out-buf (get-buffer "*Shell Command Output*"))) + (unless 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))) ;;;###autoload (autoload 'ibuffer-do-eval "ibuf-ext") (define-ibuffer-op eval (form) diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el index 27e7af9..8bb05ec 100644 --- a/lisp/ibuf-macs.el +++ b/lisp/ibuf-macs.el @@ -169,6 +169,8 @@ ibuffer-save-marks dangerous (opstring "operated on") (active-opstring "Operate on") + before + after complex) &rest body) "Generate a function which operates on a buffer. @@ -198,6 +200,8 @@ ibuffer-save-marks ACTIVE-OPSTRING is a string which will be displayed to the user in a confirmation message, in the form: \"Really ACTIVE-OPSTRING x buffers?\" +BEFORE is a form to evaluate before start the operation. +AFTER is a form to evaluate once the operation is complete. COMPLEX means this function is special; if COMPLEX is nil BODY evaluates once for each marked buffer, MBUF, with MBUF current and saving the point. If COMPLEX is non-nil, BODY evaluates @@ -206,7 +210,7 @@ ibuffer-save-marks marked buffer. BODY is evaluated with `buf' bound to the buffer object. -\(fn OP ARGS DOCUMENTATION (&key INTERACTIVE MARK MODIFIER-P DANGEROUS OPSTRING ACTIVE-OPSTRING COMPLEX) &rest BODY)" +\(fn OP ARGS DOCUMENTATION (&key INTERACTIVE MARK MODIFIER-P DANGEROUS OPSTRING ACTIVE-OPSTRING BEFORE AFTER COMPLEX) &rest BODY)" (declare (indent 2) (doc-string 3)) `(progn (defun ,(intern (concat (if (string-match "^ibuffer-do" (symbol-name op)) @@ -233,11 +237,13 @@ ibuffer-save-marks 'ibuffer-deletion-char) (_ 'ibuffer-marked-char)))) + ,before ; pre-operation form. ,(let* ((finish (append '(progn) (if (eq modifier-p t) '((setq ibuffer-did-modification t)) ()) + (and after `(,after)) ; post-operation form. `((ibuffer-redisplay t) (message ,(concat "Operation finished; " opstring " %s buffers") count)))) (inner-body (if complex -- 2.8.1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.20.7) of 2016-08-18 built on calancha-pc Repository revision: a4fa31150f186611ad083c3387e3cb2c5d25f991 From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 19 Aug 2016 13:53: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 To: Tino Calancha Cc: Glenn Morris , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.147161474127508 (code B ref 22679); Fri, 19 Aug 2016 13:53:01 +0000 Received: (at 22679) by debbugs.gnu.org; 19 Aug 2016 13:52:21 +0000 Received: from localhost ([127.0.0.1]:33976 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bakDc-00079c-Nl for submit@debbugs.gnu.org; Fri, 19 Aug 2016 09:52:20 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:60254) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bakDb-00079V-Eb for 22679@debbugs.gnu.org; Fri, 19 Aug 2016 09:52:19 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id u7JDqk05018925; Fri, 19 Aug 2016 09:52:48 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 004CDAE0E7; Fri, 19 Aug 2016 09:52:09 -0400 (EDT) From: Stefan Monnier Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> Date: Fri, 19 Aug 2016 09:52:09 -0400 In-Reply-To: (Tino Calancha's message of "Fri, 19 Aug 2016 17:33:00 +0900 (JST)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5771=0 X-NAI-Spam-Version: 2.3.0.9418 : core <5771> : inlines <5121> : streams <1686657> : uri <2270057> X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.9 (-) > - :modifier-p nil) > - (shell-command-on-region > - (point-min) (point-max) command)) > + :modifier-p nil > + :opstring "Shell command executed on" > + :modifier-p nil > + :before (funcall #'ibuffer--before-shell-command) > + :after (funcall #'ibuffer--after-shell-command)) > + (let ((out-buf (get-buffer "*Shell Command Output*"))) > + (with-current-buffer out-buf (goto-char (point-max))) > + (call-process-region (point-min) (point-max) command nil out-buf))) I haven't looked at the rest of your patch but this part looks wrong: the docstring indicates that `command' is expected to be a shell command whereas call-process-region expects an executable. Stefan From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Aug 2016 03:29:02 +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 To: Stefan Monnier Cc: Glenn Morris , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.147166373617564 (code B ref 22679); Sat, 20 Aug 2016 03:29:02 +0000 Received: (at 22679) by debbugs.gnu.org; 20 Aug 2016 03:28:56 +0000 Received: from localhost ([127.0.0.1]:34605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bawxs-0004ZE-8W for submit@debbugs.gnu.org; Fri, 19 Aug 2016 23:28:56 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:35425) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bawxr-0004Yz-3M for 22679@debbugs.gnu.org; Fri, 19 Aug 2016 23:28:55 -0400 Received: by mail-pf0-f176.google.com with SMTP id x72so14777991pfd.2 for <22679@debbugs.gnu.org>; Fri, 19 Aug 2016 20:28:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=eW6f1Oqav6nxjhICJ7XTWEjdx2AAIR0XHL0WNQ+SI/A=; b=uYzyPJrZBrd/HF+8aioAYTFuOfje8zAU+dAmOg/6wLYCuGmmBXd/boSP0tq6314asd /kAKAWIDNwUblLwzR08Mz3K32QYn45mxLLZ50csGm9SbGB0XE8HZ3G46l6QoXa9mbN62 kpQPJGWvH92q9wnsdTGpnjxCLI0svQ/FRvpf3dyJNE1v264VyroNdfkBv8UwLYfEl6PY RKqHNs7fc7GLHbTweodDd5CSpOXD8QISGt833GOB20BSDPGMN27eO/JzhjLWr0nDfuHo NtqWRaiezifxdi8E5jjYDPJqHSjsbdag4puBWFazz5owcFsCH/91uIEPDtmbCyqLJx6c jRgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=eW6f1Oqav6nxjhICJ7XTWEjdx2AAIR0XHL0WNQ+SI/A=; b=kU0ACHbVyH9GzfgsWz7YtFRB/t+rUEx0S+tMBIR9zqpYk2DmAc/PyFcMdgFipirQh4 wjbur06/al726gHjkvxZYn2LfbZN+FIeHlvhg/C468sS2TJ41YrjPi+hLatnt6NTmiyj XirTkwsjElANOcgtPxuRLhpTIqdAOgertoyYzAeHGCBJ/JUL8j4rlMy2BCcU8g/wU9PJ a+b6OeGhgzV5HI3jekPcCtbFJAObuTg1jygMtkDD1zQkNvT6pzrDdHDWmKYJjOXZyr5j ueCOHAU/LIHP8X0Zj7jJKvkuZRxnTNE3K4d2CQ/2X7SDH658nG0Ylp8gqXBGcXkJsqTt 6bXQ== X-Gm-Message-State: AEkooutijvAx1XLCsAjjJAWAzXq5CWAtsOwL6sVcdy8W9BAOvbE+mWJ3bpcRBVEzSAR8pA== X-Received: by 10.98.93.25 with SMTP id r25mr20374932pfb.122.1471663729553; Fri, 19 Aug 2016 20:28:49 -0700 (PDT) Received: from [10.248.6.9] ([210.160.37.24]) by smtp.gmail.com with ESMTPSA id f84sm9647110pfd.87.2016.08.19.20.28.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Aug 2016 20:28:48 -0700 (PDT) References: <7oa66k9es.fsf@fencepost.gnu.org> From: Tino Calancha Message-ID: Date: Sat, 20 Aug 2016 12:28:46 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On 08/19/2016 10:52 PM, Stefan Monnier wrote: >> - :modifier-p nil) >> - (shell-command-on-region >> - (point-min) (point-max) command)) >> + :modifier-p nil >> + :opstring "Shell command executed on" >> + :modifier-p nil >> + :before (funcall #'ibuffer--before-shell-command) >> + :after (funcall #'ibuffer--after-shell-command)) >> + (let ((out-buf (get-buffer "*Shell Command Output*"))) >> + (with-current-buffer out-buf (goto-char (point-max))) >> + (call-process-region (point-min) (point-max) command nil out-buf))) > I haven't looked at the rest of your patch but this part looks wrong: > the docstring indicates that `command' is expected to be a shell command > whereas call-process-region expects an executable. > > > Stefan Thank you very much. I didn't notice this because i was testing with and executable (cat) as the command. I will start working in a new patch. From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Aug 2016 10:29: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 To: Stefan Monnier Cc: Tino Calancha , Glenn Morris , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.147168890625636 (code B ref 22679); Sat, 20 Aug 2016 10:29:01 +0000 Received: (at 22679) by debbugs.gnu.org; 20 Aug 2016 10:28:26 +0000 Received: from localhost ([127.0.0.1]:34766 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bb3Vp-0006fQ-FT for submit@debbugs.gnu.org; Sat, 20 Aug 2016 06:28:25 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:36652) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bb3Vn-0006fD-KM for 22679@debbugs.gnu.org; Sat, 20 Aug 2016 06:28:24 -0400 Received: by mail-pa0-f67.google.com with SMTP id ez1so4765020pab.3 for <22679@debbugs.gnu.org>; Sat, 20 Aug 2016 03:28:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=4Ektt97FusaYBoSxjJbGZ9BViwgXZLIx1H7I4s4+i1A=; b=ddj1+ypEQ1aUZQ6XNlHhybEhDcfXyZNt9VgSWxYRZtxltwycr7DlA+CDQzJNT0Lk// EltpNvPv6OYyQ8tex/tuYVn5jcNmxyuWkKO6tsnSs77KQbBGc5kSarnc9uvbj8OzpEe+ tulzccZMKbe8SpHKC5v0IDn5OAE0lKqL4kxxK7WqFaUY6T8HbtiQZSTYhRf2ZvyrEw7w HhrPSM2zZz9cKDHf2E7v3lGXtlnC7hZ6jS9uHObkG1kHKr7Rg9E3z1lmg+YU0yuJi0NM RSFDuZVdPCWMU8zgy8pDr7GWqu2W2aI4nVn1hGcjhmXKWUOuoNHVrQckHHpS62p33Ckb wmbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=4Ektt97FusaYBoSxjJbGZ9BViwgXZLIx1H7I4s4+i1A=; b=iaZyap13i6jJJrL9vzGNEvXDGIECpdx3XjI7VlTEkxIl/8NNBzTtWNZlGcAN2KYXYZ mTpKx6ZwaPeaV3uHS4se9XE0ZwVHP0vs1Wa98NKCxenVZcYIU/vjoDQboESdYGNwuNJy YPPnv5W3wk/sCB+9mAszVTEHr7qbwiiGg6Cdli/R2b9tsboeZDNqg0LiPfGTS3jeHohZ /mwVoWTc/ppQsH0ai0Ho+4mVoTqKoaGlCD9bXLMNjLOxT/tIe5CcEHOAR2u/TAAgvWrB UIb4SaNnruvoIqmmzWXlQa2zwPueQIh566tdVUjmY5E++sYA3UzJrJHJ0fwNa7yOzDLg LzKA== X-Gm-Message-State: AEkoous8TN3WXQYOM/P0VhahTtKyWrLtzMiBCVTKXTELqCLrsZ+THw6g+QY7OFHpQ9umMg== X-Received: by 10.66.12.102 with SMTP id x6mr22234934pab.48.1471688897820; Sat, 20 Aug 2016 03:28:17 -0700 (PDT) Received: from calancha-pc ([103.5.140.170]) by smtp.gmail.com with ESMTPSA id j2sm17841841paa.46.2016.08.20.03.28.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Aug 2016 03:28:17 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Sat, 20 Aug 2016 19:28:13 +0900 (JST) X-X-Sender: calancha@calancha-pc In-Reply-To: Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Fri, 19 Aug 2016, Stefan Monnier wrote: >> - :modifier-p nil) >> - (shell-command-on-region >> - (point-min) (point-max) command)) >> + :modifier-p nil >> + :opstring "Shell command executed on" >> + :modifier-p nil >> + :before (funcall #'ibuffer--before-shell-command) >> + :after (funcall #'ibuffer--after-shell-command)) >> + (let ((out-buf (get-buffer "*Shell Command Output*"))) >> + (with-current-buffer out-buf (goto-char (point-max))) >> + (call-process-region (point-min) (point-max) command nil out-buf))) > > I haven't looked at the rest of your patch but this part looks wrong: > the docstring indicates that `command' is expected to be a shell command > whereas call-process-region expects an executable. I have corrected the call to `call-process-region': now it uses 'shell-file-name' as the executable. I have also added one test for this bug that the new patch pass. This test is just for documentation: i don't want to push it to the master branch because it assumes the machine has an 'awk' executable in 'exec-path'. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From b3fe9fe795d317d1798a1ad2d116ff52131f6612 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Sat, 20 Aug 2016 15:46:27 +0900 Subject: [PATCH 1/2] Fix Bug#22679 * lisp/ibuf-macs.el (define-ibuffer-op): Added optional args 'before' and 'after'. 'before' is a form to evaluate before the operation. 'after' is a form to evaluate after the operation. * lisp/ibuf-ext.el (ibuffer--after-shell-command-pos): New defvar; store a buffer position where to set the point in the output buffer after operation complete. (ibuffer--before-shell-command): New defun; erase output buffer if 'shell-command-not-erase-buffer' is nil and set 'ibuffer--after-shell-command-pos'. (ibuffer--after-shell-command): New defun; set point in the output buffer after operation complete. (ibuffer-do-shell-command-pipe, ibuffer-do-shell-command-file): Bind 'shell-command-not-erase-buffer' to non-nil while processing the buffers; use 'ibuffer--after-shell-command' to set the point in the output buffer. --- lisp/ibuf-ext.el | 87 +++++++++++++++++++++++++++++++++++++++++++------------ lisp/ibuf-macs.el | 8 ++++- 2 files changed, 76 insertions(+), 19 deletions(-) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index f93957e..0d79617 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -346,14 +346,60 @@ ibuffer-backward-filter-group (ibuffer-backward-filter-group 1)) (ibuffer-forward-line 0)) +;; The value `beg-last-out' in `shell-command-not-erase-buffer' +;; set the point at the beginning of the output of the first +;; buffer processed. +(defvar ibuffer--after-shell-command-pos) + +(defun ibuffer--before-shell-command () + (let ((obuf (get-buffer-create "*Shell Command Output*")) + (sym shell-command-not-erase-buffer) + final-pos) + (when (buffer-live-p obuf) + (with-current-buffer obuf + (unless sym + (setq buffer-read-only nil) + (let ((inhibit-read-only t)) + (erase-buffer))) + (setq final-pos + (cond ((or (not sym) (eq sym 'beg-last-out)) + (point-max)) + ((eq sym 'save-point) + (point)))) + (setq ibuffer--after-shell-command-pos + final-pos))))) + +(defun ibuffer--after-shell-command () + (let* ((obuf (get-buffer-create "*Shell Command Output*")) + (pos ibuffer--after-shell-command-pos) + (win (car (get-buffer-window-list obuf)))) + (setq ibuffer--after-shell-command-pos nil) + (with-current-buffer obuf + (unless pos (setq pos (point-max))) + (goto-char pos) + ;; Set point in the window displaying obuf, if any; otherwise + ;; display buf temporary in selected frame and set the point. + (if win + (set-window-point win pos) + (save-window-excursion + (let ((win (display-buffer obuf '(nil (inhibit-switch-frame . t))))) + (set-window-point win pos))))))) + ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe "ibuf-ext") (define-ibuffer-op shell-command-pipe (command) "Pipe the contents of each marked buffer to shell command COMMAND." (:interactive "sPipe to shell command: " :opstring "Shell command executed on" - :modifier-p nil) - (shell-command-on-region - (point-min) (point-max) command)) + :modifier-p nil + :opstring "Shell command executed on" + :modifier-p nil + :before (funcall #'ibuffer--before-shell-command) + :after (funcall #'ibuffer--after-shell-command)) + (let ((out-buf (get-buffer "*Shell Command Output*"))) + (with-current-buffer out-buf (goto-char (point-max))) + (call-process-region (point-min) (point-max) + shell-file-name nil out-buf nil + shell-command-switch command))) ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe-replace "ibuf-ext") (define-ibuffer-op shell-command-pipe-replace (command) @@ -363,26 +409,31 @@ shell-command-pipe-replace :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-process-region (point-min) (point-max) + shell-file-name t buf nil + shell-command-switch command)) ;;;###autoload (autoload 'ibuffer-do-shell-command-file "ibuf-ext") (define-ibuffer-op shell-command-file (command) "Run shell command COMMAND separately on files of marked buffers." (: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)))))) + :opstring "Shell command executed on" + :modifier-p nil + :before (funcall #'ibuffer--before-shell-command) + :after (funcall #'ibuffer--after-shell-command)) + (let ((file (and (not (buffer-modified-p)) + buffer-file-name)) + (out-buf (get-buffer "*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))) ;;;###autoload (autoload 'ibuffer-do-eval "ibuf-ext") (define-ibuffer-op eval (form) diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el index 27e7af9..8bb05ec 100644 --- a/lisp/ibuf-macs.el +++ b/lisp/ibuf-macs.el @@ -169,6 +169,8 @@ ibuffer-save-marks dangerous (opstring "operated on") (active-opstring "Operate on") + before + after complex) &rest body) "Generate a function which operates on a buffer. @@ -198,6 +200,8 @@ ibuffer-save-marks ACTIVE-OPSTRING is a string which will be displayed to the user in a confirmation message, in the form: \"Really ACTIVE-OPSTRING x buffers?\" +BEFORE is a form to evaluate before start the operation. +AFTER is a form to evaluate once the operation is complete. COMPLEX means this function is special; if COMPLEX is nil BODY evaluates once for each marked buffer, MBUF, with MBUF current and saving the point. If COMPLEX is non-nil, BODY evaluates @@ -206,7 +210,7 @@ ibuffer-save-marks marked buffer. BODY is evaluated with `buf' bound to the buffer object. -\(fn OP ARGS DOCUMENTATION (&key INTERACTIVE MARK MODIFIER-P DANGEROUS OPSTRING ACTIVE-OPSTRING COMPLEX) &rest BODY)" +\(fn OP ARGS DOCUMENTATION (&key INTERACTIVE MARK MODIFIER-P DANGEROUS OPSTRING ACTIVE-OPSTRING BEFORE AFTER COMPLEX) &rest BODY)" (declare (indent 2) (doc-string 3)) `(progn (defun ,(intern (concat (if (string-match "^ibuffer-do" (symbol-name op)) @@ -233,11 +237,13 @@ ibuffer-save-marks 'ibuffer-deletion-char) (_ 'ibuffer-marked-char)))) + ,before ; pre-operation form. ,(let* ((finish (append '(progn) (if (eq modifier-p t) '((setq ibuffer-did-modification t)) ()) + (and after `(,after)) ; post-operation form. `((ibuffer-redisplay t) (message ,(concat "Operation finished; " opstring " %s buffers") count)))) (inner-body (if complex -- 2.8.1 >From 156c63d38a78555fbdd8e04038ad96898a904019 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Sat, 20 Aug 2016 18:47:04 +0900 Subject: [PATCH 2/2] Add test for Bug#22679 * test/lisp/ibuffer-tests.el (ibuffer-test-bug22679): --- test/lisp/ibuffer-tests.el | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/test/lisp/ibuffer-tests.el b/test/lisp/ibuffer-tests.el index de281c0..5442bd2 100644 --- a/test/lisp/ibuffer-tests.el +++ b/test/lisp/ibuffer-tests.el @@ -30,5 +30,63 @@ (symbol-function 'ibuffer-mark-unsaved-buffers)))) +(ert-deftest ibuffer-test-bug22679 () + "Test for http://debbugs.gnu.org/22679 ." + :expected-result :failed + (let* ((nums (generate-new-buffer "nums")) + (letters (generate-new-buffer "letters")) + (nums-file "/tmp/nums-file") + (letters-file "/tmp/letters-file") + (str-nums "1 2 3 4 5\n6 7 8\n") + (str-letters "a b c d e\nf g h\n") + (str1 "1 2 3\n6 7 8\n") + (str2 "a b c\nf g h\n") + (buffer (get-buffer-create "*Shell Command Output*")) + (command "awk '{print $1 FS $2 FS $3}'") + (check-input-buffers (lambda () + (with-current-buffer nums + (should (string= (buffer-string) str1))) + (with-current-buffer letters + (should (string= (buffer-string) str2))))) + (check-output-buffer (lambda () + (with-current-buffer buffer + (should (or (string= (buffer-string) (concat str1 str2)) + (string= (buffer-string) (concat str2 str1))))))) + ;; Erase output buffer before each test. + (shell-command-not-erase-buffer nil) + ;; Don't ask for confimation to replace buffer content. + (ibuffer-expert t)) + (with-current-buffer nums (insert str-nums)) + (with-current-buffer letters (insert str-letters)) + (with-temp-file nums-file (insert str-nums)) + (with-temp-file letters-file (insert str-letters)) + (unwind-protect + (save-current-buffer + (mapc 'find-file (list nums-file letters-file)) + (ibuffer) + ;; Test ibuffer-do-shell-command-pipe[-replace] + (mapc (lambda (x) + (ibuffer-mark-by-name-regexp (format "\\`%s\\'" x))) + (mapcar 'buffer-name (list nums letters))) + (ibuffer-do-shell-command-pipe command) + (funcall check-output-buffer) + (ibuffer-do-shell-command-pipe-replace command) + (funcall check-input-buffers) + ;; Test ibuffer-do-shell-command-file + (ibuffer-unmark-all-marks) + (mapc (lambda (x) + (ibuffer-mark-by-name-regexp (format "\\`%s\\'" x))) + (mapcar 'buffer-name (list (get-file-buffer nums-file) + (get-file-buffer letters-file)))) + (ibuffer-do-shell-command-file command) + (funcall check-output-buffer)) + ;; Clean up. + (switch-to-buffer (current-buffer)) + (mapc 'kill-buffer (list nums + letters + (get-file-buffer nums-file) + (get-file-buffer letters-file))) + (mapc 'delete-file (list nums-file letters-file))))) + (provide 'ibuffer-tests) ;; ibuffer-tests.el ends here -- 2.8.1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 25.1.50.14 (x86_64-pc-linux-gnu, GTK+ Version 3.20.7) of 2016-08-20 built on calancha-pc Repository revision: a4ba426d25bd6a5cbe11d81b82a789b8a2c948ed From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Aug 2016 12:48:02 +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 To: Tino Calancha Cc: Glenn Morris , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.147169722412284 (code B ref 22679); Sat, 20 Aug 2016 12:48:02 +0000 Received: (at 22679) by debbugs.gnu.org; 20 Aug 2016 12:47:04 +0000 Received: from localhost ([127.0.0.1]:34814 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bb5g0-0003C4-BN for submit@debbugs.gnu.org; Sat, 20 Aug 2016 08:47:04 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]:35633) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bb5fy-0003Bw-UW for 22679@debbugs.gnu.org; Sat, 20 Aug 2016 08:47:03 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id u7KClUxX005751; Sat, 20 Aug 2016 08:47:32 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 25D6BAE0EA; Sat, 20 Aug 2016 08:46:54 -0400 (EDT) From: Stefan Monnier Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> Date: Sat, 20 Aug 2016 08:46:54 -0400 In-Reply-To: (Tino Calancha's message of "Sat, 20 Aug 2016 19:28:13 +0900 (JST)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5772=0 X-NAI-Spam-Version: 2.3.0.9418 : core <5772> : inlines <5123> : streams <1687150> : uri <2270752> X-Spam-Score: -1.9 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.9 (-) > I have corrected the call to `call-process-region': now it uses > 'shell-file-name' as the executable. Thanks. Now that I looked at the rest of the patch I see that you use some kind of after/before hooks, so this approach doesn't really lend itself to extracting into a more generally useful function which could be used by shell-command (and others). Could you explain what made you use this approach, to see if there might be some way to solve the problem while still making the code more generally useful (and reduce redundancy rather than augment it)? Stefan From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 21 Aug 2016 14:38: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 To: Stefan Monnier Cc: Tino Calancha , Glenn Morris , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.147179025926245 (code B ref 22679); Sun, 21 Aug 2016 14:38:01 +0000 Received: (at 22679) by debbugs.gnu.org; 21 Aug 2016 14:37:39 +0000 Received: from localhost ([127.0.0.1]:35921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bbTsY-0006pE-Sg for submit@debbugs.gnu.org; Sun, 21 Aug 2016 10:37:39 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:33938) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bbTsX-0006oz-1v for 22679@debbugs.gnu.org; Sun, 21 Aug 2016 10:37:37 -0400 Received: by mail-pa0-f68.google.com with SMTP id hh10so6500735pac.1 for <22679@debbugs.gnu.org>; Sun, 21 Aug 2016 07:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=tVmhLJLQ5T/y5hQOGuIreG3g5krgYpxchQb5QC76B5s=; b=Cd868JrfdOsnsOYgSn1rM4MyaBfv6mFQ6KmZk/6llFf4EIIJCba3n1kSuSl2CvwxHf 8qqwzg4VyvwB/SwnDpogDlUfPUkjKMrpofpPJ5do8wsUrT0EfxsNtwDgIGfQLo8xLydv ErjRJKiCbStvXIZ2IcT7yjajmcZQPHGTCuPK55v1a1osc2Bwno28xEcxH5qR6/qWJuuI kYBMUlLqxyKrUBkis60ewZI8wvJ9npKRVsxeppiN5g7D/ZpM3pOM6KIz+f3S7KgLMxVQ AJxIWmIjAK/8QUyi9lkp6RE9pNyGXeOTB/wE1hiL+Lh+Kuc8uxW+Y23OJQF88eSdFoFv 6w2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=tVmhLJLQ5T/y5hQOGuIreG3g5krgYpxchQb5QC76B5s=; b=VA7eHvJSJbX7ZB5fmivLzaPXES69UbKIBoZmJEoMVkBcqg/Y7r2m2bsUmLfrs5LBj7 b3mZlckX4ZcEl9LOPJumh6PuEye/MTaQTs8UHxVzsv845paGo09ILCdN2fruiMfp8NAX 2bz9NtgxC2rnN4qr5HqAeGSYGUFG9KDw1cTAkp1s4RByibiZ6+agMSdiPTTiusO4Jukj u6e0+A/WecTKkawKTVqqv0o5bIyN+X1xEYsFVTNtfZUuqqxCfxyJ37xRdnncppGf4OXA w+JFx8NurxiuMfkkHYzMMa1FcZO8ZGDzJWrN+QtSuNZ8pKJbbEfKXGvIrA3XNNXrMppf QHCQ== X-Gm-Message-State: AEkooutev++Zou2cshML2qdc2XNsAgi8StGHJjvU1cKDPfYg+tQ6yUCJaWL9sXRz6jkihQ== X-Received: by 10.66.0.231 with SMTP id 7mr33475255pah.118.1471790251087; Sun, 21 Aug 2016 07:37:31 -0700 (PDT) Received: from calancha-pc (mail.family-wifi.jp. [180.42.51.5]) by smtp.gmail.com with ESMTPSA id k9sm20541471pfj.63.2016.08.21.07.37.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Aug 2016 07:37:30 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Sun, 21 Aug 2016 23:37:26 +0900 (JST) X-X-Sender: calancha@calancha-pc In-Reply-To: Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Sat, 20 Aug 2016, Stefan Monnier wrote: Thank you very much for your time reviewing my patch. >Thanks. Now that I looked at the rest of the patch I see that you use >some kind of after/before hooks, so this approach doesn't really lend >itself to extracting into a more generally useful function which could >be used by shell-command (and others). Improving `shell-command' is out of the scope of my patch. The goal is to avoid that these commands truncate the output: currently the output buffer just show the output for the last processed buffer. The reason to that is that original implementation uses `shell-command', which used to erase the output buffer between two calls. That raised the question about if it would have sense to allow not erasing the output buffer between 2 `shell-comand' calls. In fact, following your proposal to not use `shell-command' at all, it would also prevent erasing the output buffer: that would be a cleaner patch (see below). >Could you explain what made you use this approach, to see if there might >be some way to solve the problem while still making the code more >generally useful (and reduce redundancy rather than augment it)? I used the hooks (*) because at some point i thought that one user setting 'shell-command-not-erase-buffer' to a non-nil value, may expect that these ibuffer commands also set the point in the output buffer according with 'shell-command-not-erase-buffer'. If we decide that the behaviour of these commands should not depend on 'shell-command-not-erase-buffer', then a cleaner fix could be as follows: (*) Even if adding the hooks for fixing this bug is not well motivated, i think `define-ibuffer-op' results a more flexible macro with the addition of BEFORE and AFTER. Maybe it could simplify some other parts of the code or future extensions. This is something i may study separately. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From 2d2908b33b14a47b2afb077538f6f14735b30a54 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Sun, 21 Aug 2016 23:20:52 +0900 Subject: [PATCH] Fix Bug#22679 * lisp/ibuf-ext.el (shell-command-pipe) (shell-command-pipe-replace): Use 'call-process-region' instead of 'shell-command' or 'shell-command-on-region'. (shell-command-file): Use 'call-process-shell-command' instead of 'shell-command'. If FILE, the file that the buffer object is visiting, exists and the buffer object is up-to-date, then use FILE instead of creating a temporary file. --- lisp/ibuf-ext.el | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index f93957e..99ae400 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -352,8 +352,11 @@ 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)) + (let ((out-buf (get-buffer-create "*Shell Command Output*"))) + (with-current-buffer out-buf (goto-char (point-max))) + (call-process-region (point-min) (point-max) + shell-file-name nil out-buf nil + shell-command-switch command))) ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe-replace "ibuf-ext") (define-ibuffer-op shell-command-pipe-replace (command) @@ -363,9 +366,9 @@ shell-command-pipe-replace :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-process-region (point-min) (point-max) + shell-file-name t buf nil + shell-command-switch command)) ;;;###autoload (autoload 'ibuffer-do-shell-command-file "ibuf-ext") (define-ibuffer-op shell-command-file (command) @@ -373,16 +376,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 - (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))) ;;;###autoload (autoload 'ibuffer-do-eval "ibuf-ext") (define-ibuffer-op eval (form) -- 2.8.1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 25.1.50 (x86_64-pc-linux-gnu, GTK+ Version 3.20.7) of 2016-08-21 built on calancha-pc Repository revision: f0ee3ca5a92d5503268da7f9e0d71a1a58893c8a Tino From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Aug 2016 16:08: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 To: Tino Calancha Cc: Glenn Morris , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.147188203615439 (code B ref 22679); Mon, 22 Aug 2016 16:08:01 +0000 Received: (at 22679) by debbugs.gnu.org; 22 Aug 2016 16:07:16 +0000 Received: from localhost ([127.0.0.1]:37054 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bbrkq-00040x-Gt for submit@debbugs.gnu.org; Mon, 22 Aug 2016 12:07:16 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:42950) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bbrko-00040p-QH for 22679@debbugs.gnu.org; Mon, 22 Aug 2016 12:07:15 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id u7MG71He028040; Mon, 22 Aug 2016 12:07:06 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 414E2AE0EA; Mon, 22 Aug 2016 12:06:59 -0400 (EDT) From: Stefan Monnier Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> Date: Mon, 22 Aug 2016 12:06:59 -0400 In-Reply-To: (Tino Calancha's message of "Sun, 21 Aug 2016 23:37:26 +0900 (JST)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5774=0 X-NAI-Spam-Version: 2.3.0.9418 : core <5774> : inlines <5124> : streams <1688289> : uri <2272333> X-Spam-Score: -1.6 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.6 (-) >> Thanks. Now that I looked at the rest of the patch I see that you use >> some kind of after/before hooks, so this approach doesn't really lend >> itself to extracting into a more generally useful function which could >> be used by shell-command (and others). > Improving `shell-command' is out of the scope of my patch. The goal is > to avoid that these commands truncate the output: currently the output > buffer just show the output for the last processed buffer. The reason > to that is that original implementation uses `shell-command', which used > to erase the output buffer between two calls. I understand. I do not suggest to improve shell-command. I suggest instead to extract from shell-command a new Elisp function which includes the part of shell-command that you need, and then rewrite shell-command by making it use the new function. So shell-command would still work exactly as before, but its implementation would now be spread over 2 functions, the inner one of which would be useful to other Elisp libraries such as ibuffer. >> Could you explain what made you use this approach, to see if there might >> be some way to solve the problem while still making the code more >> generally useful (and reduce redundancy rather than augment it)? > I used the hooks (*) because at some point i thought that one user > setting 'shell-command-not-erase-buffer' to a non-nil value, may > expect that these ibuffer commands also set the point in the output > buffer according with 'shell-command-not-erase-buffer'. Hmm... I now see this new variable. It has several problems indeed. The "set the point" part is weird and I'm not sure it makes much sense to fold it this way into the same var as the "don-t erase" part. > If we decide that the behaviour of these commands should not depend > on 'shell-command-not-erase-buffer', then a cleaner fix could be > as follows: I think we should first aim at a simple and clean fix, yes. > - (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-process-region (point-min) (point-max) > + shell-file-name nil out-buf nil > + shell-command-switch command))) Here, for example, I'd expect maybe something like (new-shell-command-on-region (point-min) (point-max) command)) Maybe with one or two new additional args. Or maybe (let ((out-buf (get-buffer-create shell-command-buffer-name))) (with-current-buffer out-buf (goto-char (point-max))) (call-shell-on-region (point-min) (point-max) out-buf command))) -- Stefan From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 23 Aug 2016 15:10:02 +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 To: Stefan Monnier Cc: Tino Calancha , Glenn Morris , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.147196495812596 (code B ref 22679); Tue, 23 Aug 2016 15:10:02 +0000 Received: (at 22679) by debbugs.gnu.org; 23 Aug 2016 15:09:18 +0000 Received: from localhost ([127.0.0.1]:38057 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcDKD-0003Gz-Sr for submit@debbugs.gnu.org; Tue, 23 Aug 2016 11:09:18 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:32841) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcDK8-0003Gd-Am for 22679@debbugs.gnu.org; Tue, 23 Aug 2016 11:09:12 -0400 Received: by mail-pf0-f194.google.com with SMTP id i6so8455196pfe.0 for <22679@debbugs.gnu.org>; Tue, 23 Aug 2016 08:09:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=hjff9df3hzByiK9ZjH7SKTGt+93IJAJ5XjF8qX31XeU=; b=HfzuugdqPzwbe6P+9piz7UetyzE14rttWHT86KHZI11V+CPAEW2n1p0WCejsyEnWxQ ZamIPM5T1bcsa+/CRXeLqqA3HZ2SjQUY1FkfzbU1zA5vKaBIPAAijehPT00iCqmXLfcv 4Wtq6zCZrRGa+U1A4U9XDaSfOCkAVdG274ngsW0+BTmTJfukpL7CQlJcIk6l5bepyQRu 5/nMsa4itQmnfK0+AydKy01YieeZiy3ACuAON3+UJ/kEvlSSCfEoNiQ33aqScWKEAIIR cuI9CkHryPgRh4g/Vq+0CbLBmpIAvVdsMc7zSwnUWaqYE2kBS+qbFVmdAt0NsxnJ8eyV qpLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=hjff9df3hzByiK9ZjH7SKTGt+93IJAJ5XjF8qX31XeU=; b=iulli5TTRE7Wz5Sk73WFozWCxFyoSIy3+rk2TfQsHNQnGRj5YV457hFz2UXpYGGjgS XOGSDmJX6VorfKuasKJBq557MoTjKQb6C/9qLlWl4PGeOO0mH6n1h0FWKWvAjmZcsPpY jQA9CHSkan+8F9okrVnZV/eZNfvrTr8gDT1h9yqdeKS+TIv1N33qfCgO04G5dawNLei7 3/i3fpf5XjEC8A8wdpxAgaBbeMx8DllPml1QocYgCuDzq0xZA9poDqK09JniUWlkEF5k U7gfqQQf7k/CN5VKhqIKJeKfCrB1ygD0bAaQeqOhCQL5FOOFZYkJUviKR5ctsApThL6v EA1A== X-Gm-Message-State: AEkoouuf+DKOjyW64lLE90IcaWJRH8lHG8+f6iBKaTUOnOuiKIS8QPRdWLEOXePTfQaVjw== X-Received: by 10.98.22.212 with SMTP id 203mr54477668pfw.74.1471964942395; Tue, 23 Aug 2016 08:09:02 -0700 (PDT) Received: from calancha-pc ([240f:6e:c00e:1:6875:2e94:598b:96cb]) by smtp.gmail.com with ESMTPSA id xx7sm6585242pac.3.2016.08.23.08.08.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Aug 2016 08:09:01 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Wed, 24 Aug 2016 00:08:57 +0900 (JST) X-X-Sender: calancha@calancha-pc In-Reply-To: Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) On Mon, 22 Aug 2016, Stefan Monnier wrote: > I understand. I do not suggest to improve shell-command. > I suggest instead to extract from shell-command a new Elisp function > which includes the part of shell-command that you need, and then rewrite > shell-command by making it use the new function. > > So shell-command would still work exactly as before, but its > implementation would now be spread over 2 functions, the inner one of > which would be useful to other Elisp libraries such as ibuffer. Thank you Stefan, i understand now. Its a good idea. See the patch below. > Hmm... I now see this new variable. It has several problems indeed. > The "set the point" part is weird and I'm not sure it makes much sense > to fold it this way into the same var as the "don-t erase" part. If you could write a few lines with yor main concerns about this option here: http://lists.gnu.org/archive/html/emacs-devel/2016-07/msg00610.html i guess it might encourage others to give their opinion helping to decide if we keep the option, discard it, or implement it in a better way. > Here, for example, I'd expect maybe something like > > (new-shell-command-on-region > (point-min) (point-max) command)) > > Maybe with one or two new additional args. Or maybe > > (let ((out-buf (get-buffer-create shell-command-buffer-name))) > (with-current-buffer out-buf (goto-char (point-max))) > (call-shell-on-region (point-min) (point-max) > out-buf command))) I have called the new function: call-shell-region in analogy with call-process-region; but call-shell-on-region seems a little more descriptive. How should i call it? Do you thing the call-shell-region discussion should move to emacs-devel list? > I think we should first aim at a simple and clean fix, yes. Following patch, concerning just the lisp/ibuf-ext, (the call-shell-command part eventually should go to a separated commit) looks quite simple (compared with my first patch in this report): ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From 9ba85fdf3c5543e87a7b1905b2404a334891581f Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Tue, 23 Aug 2016 23:46:37 +0900 Subject: [PATCH] call-shell-region: New defun Fix Bug#22679 * lisp/subr.el (call-shell-region): New defun; execute a command in an inferior shell with the buffer region as input. * lisp/ibuf-ext.el (shell-command-pipe, shell-command-pipe-replace): Use it (Bug#22679). * lisp/simple.el (shell-command-on-region): Idem. * lisp/ibuf-ext.el (shell-command-file): Use call-process-shell-command instead of shell-command. If FILE, the file that the buffer object is visiting, exists and the buffer object is up-to-date, then use FILE instead of creating a temporary file (Bug#22679). * doc/lispref/processes.texi: Document call-shell-region in the manual. ;* etc/NEWS: Add entry for this new function. --- doc/lispref/processes.texi | 20 +++++++++++++------- etc/NEWS | 4 ++++ lisp/ibuf-ext.el | 33 +++++++++++++++++++-------------- lisp/simple.el | 36 +++++++++++++++--------------------- lisp/subr.el | 22 ++++++++++++++++++++++ 5 files changed, 73 insertions(+), 42 deletions(-) diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index cd12012..e043578 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -492,20 +492,17 @@ Synchronous Processes @end smallexample For example, the @code{shell-command-on-region} command uses -@code{call-process-region} in a manner similar to this: +@code{call-shell-region} in a manner similar to this: @smallexample @group -(call-process-region +(call-shell-region start end - shell-file-name ; @r{name of program} + command ; @r{shell command} nil ; @r{do not delete region} - buffer ; @r{send output to @code{buffer}} - nil ; @r{no redisplay during output} - "-c" command) ; @r{arguments for the shell} + buffer) ; @r{send output to @code{buffer}} @end group @end smallexample -@c It actually uses shell-command-switch, but no need to mention that here. @end defun @defun call-process-shell-command command &optional infile destination display @@ -525,6 +522,15 @@ Synchronous Processes supported, but strongly discouraged. @end defun +@defun call-shell-region start end command &optional delete destination +This function sends the text from @var{start} to @var{end} as +standard input to an inferior shell running @var{command}. This function +is similar than @code{call-process-region}, with process being a shell. +The arguments @code{delete}, @code{destination} and the return value +are like in @code{call-process-region}. +Note that this funtion doesn't accept additional arguments. +@end defun + @defun shell-command-to-string command This function executes @var{command} (a string) as a shell command, then returns the command's output as a string. diff --git a/etc/NEWS b/etc/NEWS index 494a091..d30d1fa 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -56,6 +56,10 @@ affected by this, as SGI stopped supporting IRIX in December 2013. * Changes in Emacs 25.2 +++ +** The new funtion 'call-shell-region' executes a command in an +inferior shell with the buffer region as input. + ++++ ** The new user option 'shell-command-not-erase-buffer' controls if the output buffer is erased between shell commands; if non-nil, the output buffer is not erased; this variable also controls where diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index f93957e..a34c264 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -352,8 +352,10 @@ 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)) + (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) @@ -364,8 +366,8 @@ shell-command-pipe-replace :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) @@ -373,16 +375,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 - (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))) ;;;###autoload (autoload 'ibuffer-do-eval "ibuf-ext") (define-ibuffer-op eval (form) diff --git a/lisp/simple.el b/lisp/simple.el index 51b24bb..dbfaae3 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3651,10 +3651,7 @@ shell-command-on-region output) (with-temp-buffer (insert input) - (call-process-region (point-min) (point-max) - shell-file-name t t - nil shell-command-switch - command) + (call-shell-region (point-min) (point-max) command 'delete t) (setq output (split-string (buffer-string) "\n"))) (goto-char start) (funcall region-insert-function output)) @@ -3667,11 +3664,10 @@ shell-command-on-region (goto-char start) (and replace (push-mark (point) 'nomsg)) (setq exit-status - (call-process-region start end shell-file-name replace - (if error-file - (list t error-file) - t) - nil shell-command-switch command)) + (call-shell-region start end command replace + (if error-file + (list t error-file) + t))) ;; It is rude to delete a buffer which the command is not using. ;; (let ((shell-buffer (get-buffer "*Shell Command Output*"))) ;; (and shell-buffer (not (eq shell-buffer (current-buffer))) @@ -3694,13 +3690,12 @@ shell-command-on-region (delete-region (max start end) (point-max)) (delete-region (point-min) (min start end)) (setq exit-status - (call-process-region (point-min) (point-max) - shell-file-name t - (if error-file - (list t error-file) - t) - nil shell-command-switch - command))) + (call-shell-region (point-min) (point-max) + command 'delete + (if error-file + (list t error-file) + t) + ))) ;; Clear the output buffer, then run the command with ;; output there. (let ((directory default-directory)) @@ -3709,11 +3704,10 @@ shell-command-on-region (setq default-directory directory)) (shell-command--save-pos-or-erase))) (setq exit-status - (call-process-region start end shell-file-name nil - (if error-file - (list buffer error-file) - buffer) - nil shell-command-switch command))) + (call-shell-region start end command nil + (if error-file + (list buffer error-file) + buffer)))) ;; Report the output. (with-current-buffer buffer (setq mode-line-process diff --git a/lisp/subr.el b/lisp/subr.el index 8ab1178..a33f997 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3078,6 +3078,28 @@ process-file-shell-command infile buffer display (if (file-remote-p default-directory) "-c" shell-command-switch) (mapconcat 'identity (cons command args) " "))) + +(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)) ;;;; Lisp macros to do various things temporarily. -- 2.8.1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 25.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.20.7) of 2016-08-23 built on calancha-pc Repository revision: f345fdd7e64064194a9235406971f62b9da09ae2 Tino From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output 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 To: Tino Calancha Cc: Glenn Morris , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.14721012842324 (code B ref 22679); Thu, 25 Aug 2016 05:02:01 +0000 Received: (at 22679) by debbugs.gnu.org; 25 Aug 2016 05:01:24 +0000 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 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" 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 Received: by pastel.home (Postfix, from userid 20848) id 1FD6764553; Wed, 24 Aug 2016 13:05:56 -0400 (EDT) From: Stefan Monnier Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> Date: Wed, 24 Aug 2016 13:05:56 -0400 In-Reply-To: (Tino Calancha's message of "Wed, 24 Aug 2016 00:08:57 +0900 (JST)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: > - (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))) [...] Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [206.248.154.181 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [206.248.154.181 listed in wl.mailspike.net] 1.1 DATE_IN_PAST_06_12 Date: is 6 to 12 hours before Received: date 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.4 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: > - (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))) [...] Content analysis details: (1.4 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [206.248.154.181 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [206.248.154.181 listed in wl.mailspike.net] 1.1 DATE_IN_PAST_06_12 Date: is 6 to 12 hours before Received: date 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders > - (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 From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Aug 2016 09:40: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 To: Stefan Monnier Cc: Tino Calancha , Glenn Morris , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.147211798228201 (code B ref 22679); Thu, 25 Aug 2016 09:40:01 +0000 Received: (at 22679) by debbugs.gnu.org; 25 Aug 2016 09:39:42 +0000 Received: from localhost ([127.0.0.1]:40008 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcr8Q-0007Km-IR for submit@debbugs.gnu.org; Thu, 25 Aug 2016 05:39:42 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34244) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcr8O-0007KZ-Ol for 22679@debbugs.gnu.org; Thu, 25 Aug 2016 05:39:41 -0400 Received: by mail-pf0-f193.google.com with SMTP id g202so2930138pfb.1 for <22679@debbugs.gnu.org>; Thu, 25 Aug 2016 02:39:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=+hMONxGXL/4xeppUMnhmH+nwDoxhP7yCsM6ouz+JFTw=; b=dwyi+iajeWUicB1Wll/Nlf5r3qFkAzZxqzCJaoxSE80Eg+WInm6Hw6PBwjUv4IKIZt bKJAM5XhjlwvBU7FpB+gUWJsvKJyTSEyd9vlubXxeWu74XrGLWduNlsX3MomcHj7O2ru +P1W8gpP76FYlnRVFPLDZQJpOobV79z8SkEQC8F8HgWskAZ1Epe1URVmfaip5/6k7z4h YNh8BVp6ievRHPIF5FCxYkVXvA25iFkSpcv8zHELvmIFGTBcwDEPXBnS0DP8a199i2F9 ckoxF0j/gcX4QVKdP4b1e25kdcJETPzvFfPK4jQgPWjyJDgoHsWEAUt1XsxQOLm38qaz MF3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=+hMONxGXL/4xeppUMnhmH+nwDoxhP7yCsM6ouz+JFTw=; b=H6hjmgbZ7OrJBPRc5ktAhzlc6cgi13O1nVe0Oupfbes4zLaq4DPi/W3xKB8+pwbeRF gXkBuh9f0JFr3SBjQ2xYu/JM7Gf8hR9MMjP6Jvaar8icovvEQwUiy58yP37UrZpEtnbo H0WP8Nu6Q9lktYy86zZIpW8rMLLVraPPwV17douoUG/3zMFP2b/0whffZXPj5glt1imr 9MTrYNkRm5K738qZt088iHxIRUxHZoPC+xPiKFb1O1+9nTadDW/RToCRYpFQt58IbmOO CUqQeaGuq/8oVtkLdgfQLFJJPaVvV3ApcKPhWCXMI1GZDZLBc4bSAPmoZafei+TaG0wb TyxQ== X-Gm-Message-State: AE9vXwO2OZ23BPWE7LpNO8San702ugjluKLh05DFwC2GhkOIYf8VbuZJk9egimo/onwI9g== X-Received: by 10.98.68.148 with SMTP id m20mr14488566pfi.0.1472117974862; Thu, 25 Aug 2016 02:39:34 -0700 (PDT) Received: from calancha-pc ([103.5.140.139]) by smtp.gmail.com with ESMTPSA id cp11sm19485618pac.28.2016.08.25.02.39.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Aug 2016 02:39:34 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Thu, 25 Aug 2016 18:39:30 +0900 (JST) X-X-Sender: calancha@calancha-pc In-Reply-To: Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) > Indentation looks wrong, but other than that, looks OK. Thanks. Do you thing we should support PROGRAM being nil? For instance in, * lisp/emacs-lisp/chart.el (chart-space-usage) it first inserts a command in the buffer, and then calls `call-process-region' with 6 arguments. My previous implementation cannot handle that, i.e., fails if PROGRAM is nil. In fact, that task maybe fit better with `call-process'/ `call-process-shell-command': i would just not write the command in the buffer, and pass it as argument to `call-process'. Following patch handle COMMAND being nil. What implementation do you prefer? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From c572c4a4e625648016dea192c3234dfc2128ce46 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Thu, 25 Aug 2016 18:27:42 +0900 Subject: [PATCH] * lisp/subr.el (call-shell-region): Handle COMMAND being nil --- lisp/subr.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index 96917b9..7b7f204 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -3097,9 +3097,12 @@ call-shell-region 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)) + (apply #'call-process-region + (append (list start end + shell-file-name delete buffer nil) + (if command + (list shell-command-switch command) + '())))) ;;;; Lisp macros to do various things temporarily. -- 2.9.3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Aug 2016 12:37:02 +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 To: Tino Calancha Cc: Glenn Morris , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.147212857025495 (code B ref 22679); Thu, 25 Aug 2016 12:37:02 +0000 Received: (at 22679) by debbugs.gnu.org; 25 Aug 2016 12:36:10 +0000 Received: from localhost ([127.0.0.1]:40080 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcttC-0006d8-2v for submit@debbugs.gnu.org; Thu, 25 Aug 2016 08:36:10 -0400 Received: from pruche.dit.umontreal.ca ([132.204.246.22]:43129) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcttA-0006d0-Bn for 22679@debbugs.gnu.org; Thu, 25 Aug 2016 08:36:09 -0400 Received: from fmsmemgm.homelinux.net (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id u7PCa5aq012448; Thu, 25 Aug 2016 08:36:06 -0400 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id D5473AE0A5; Thu, 25 Aug 2016 08:36:05 -0400 (EDT) From: Stefan Monnier Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> Date: Thu, 25 Aug 2016 08:36:05 -0400 In-Reply-To: (Tino Calancha's message of "Thu, 25 Aug 2016 18:39:30 +0900 (JST)") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV5777=0 X-NAI-Spam-Version: 2.3.0.9418 : core <5777> : inlines <5138> : streams <1689795> : uri <2274387> X-Spam-Score: -1.6 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.6 (-) > Do you thing we should support PROGRAM being nil? No. > * lisp/emacs-lisp/chart.el (chart-space-usage) > it first inserts a command in the buffer, and then calls > `call-process-region' with 6 arguments. Then it can keep using call-process-region if it so prefers. > Following patch handle COMMAND being nil. What implementation do > you prefer? The more straightforward (and restrictive) one. Stefan From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Aug 2016 13:27: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 To: Stefan Monnier Cc: Tino Calancha , Glenn Morris , 22679@debbugs.gnu.org Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.147213161430036 (code B ref 22679); Thu, 25 Aug 2016 13:27:01 +0000 Received: (at 22679) by debbugs.gnu.org; 25 Aug 2016 13:26:54 +0000 Received: from localhost ([127.0.0.1]:40101 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcugI-0007oO-51 for submit@debbugs.gnu.org; Thu, 25 Aug 2016 09:26:54 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:36524) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bcugG-0007oB-BZ for 22679@debbugs.gnu.org; Thu, 25 Aug 2016 09:26:52 -0400 Received: by mail-pa0-f45.google.com with SMTP id di2so17003831pad.3 for <22679@debbugs.gnu.org>; Thu, 25 Aug 2016 06:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=HNjg1StKUidlIxXhMtNUeeU1YyCT5D4NtJQ2JF3R3CY=; b=BERHCNCSfGTg3gxC95jr4sEAWGeG77ZgRfTdr/L98E/xNBxg+TxIRNGlJ+MNwycqml VoIGWD771kHPZVroEnWOd6tq4A28m3v00Sezg0qN8C3knWwqC1uQKd/TxNkrEqwWCZgw 4ohi9RUryYXkQ2uou3QthY6jXoz/v+NDMojkCM654E4NzDoT5QM1BAu/Z6W2tTx6VgC1 Pbh54jcxcZ2e2kiNfTnzMN/nrNoGqKrUPV6HpOuhS9/SBGP/u/52u4fsHB5rBEf9U3UH iKlK9xpYNYAUhc0DWYxfiH2DAvmM6Jpmf2lMmQGnDrPZnQiFYLU/vU0F9csZIG0SS2gV 6TOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=HNjg1StKUidlIxXhMtNUeeU1YyCT5D4NtJQ2JF3R3CY=; b=iPH/0/wcpXnQ/o66za31V4FOZJHZOyzMxCnxlvgjn7sQAx+/7SsTgWwTo+PEP6I2tt s5geRb6IOnG/Tj3q6KQv+MzT4YdlJy5S03oS7Cue+DSdj3jq39zoLkQb8uA8wxjKar2V q1/0HvuUZ9p5WX/RN6ipVpBQyEh7G4Ty4r5v+YXBelbhvqoYKELPkqa2gyMiisdXILlX jIvxccfjwvsxjcg7dacKtOai4ECivlT3CYqLlX35psqppp6lB7FFDetByyAMH7m9diUe 5gevxYBQQlTe+O9eFJIM5jZ8aOyOHKKtslrqnceSFSlJKh8idEGrSQtGH79AiLBv2PAU IDQw== X-Gm-Message-State: AE9vXwOX22W/XJS3JaTZEMlJlvx9jUnfTGnBuPOh/OnXocKeZ4wTzhk3iQjyNWX5LKb6wQ== X-Received: by 10.66.53.234 with SMTP id e10mr16494293pap.28.1472131606488; Thu, 25 Aug 2016 06:26:46 -0700 (PDT) Received: from calancha-pc ([103.5.140.143]) by smtp.gmail.com with ESMTPSA id s89sm21049601pfi.83.2016.08.25.06.26.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Aug 2016 06:26:45 -0700 (PDT) From: Tino Calancha X-Google-Original-From: Tino Calancha Date: Thu, 25 Aug 2016 22:26:42 +0900 (JST) X-X-Sender: calancha@calancha-pc In-Reply-To: Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) >> Do you thing we should support PROGRAM being nil? > > No. > >> * lisp/emacs-lisp/chart.el (chart-space-usage) >> it first inserts a command in the buffer, and then calls >> `call-process-region' with 6 arguments. > > Then it can keep using call-process-region if it so prefers. > >> Following patch handle COMMAND being nil. What implementation do >> you prefer? > > The more straightforward (and restrictive) one. Cool. Thanks for your expert advices. I appreciate them a lot. I have pushed to master the one you like. From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 27 Jan 2017 06:27:02 +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 To: Stefan Monnier Cc: Glenn Morris , 22679@debbugs.gnu.org, tino.calancha@gmail.com Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.14854984076452 (code B ref 22679); Fri, 27 Jan 2017 06:27:02 +0000 Received: (at 22679) by debbugs.gnu.org; 27 Jan 2017 06:26:47 +0000 Received: from localhost ([127.0.0.1]:46864 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWzzi-0001fz-Gg for submit@debbugs.gnu.org; Fri, 27 Jan 2017 01:26:46 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35142) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWzzg-0001fm-U7 for 22679@debbugs.gnu.org; Fri, 27 Jan 2017 01:26:45 -0500 Received: by mail-pg0-f67.google.com with SMTP id 204so24243810pge.2 for <22679@debbugs.gnu.org>; Thu, 26 Jan 2017 22:26:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=jj2KCOatyhGxASe4hYAVWzUr2nV8BQDD9jb5VqsVCM8=; b=uDduN/BH7UDA2MClUnJfwRFIw+K1RWH8T8WsPYMrPOqmkhSpeX8OpthHH/NVezTWEE b6luR83I+eRG/83d0hKW7knYP1baersjWJ8xPBcQRkpUWML6WhmnJ2rV/1nkaSuEDb7e Ua3EiafDt/iHq6vvjW/NdDkCkcZnoU1XUezKGQ0yHOzL79iAB5Stymke4HMpTNpvFvIG PMtmUr78pMV0+9AiEFBs0RrhK8e45ZB6gyTEJ3wriGfHxAuG58Ick3H25d9n8BKJT2tl yUBVD2o+xeTzQmPvTUqI7vWDxyJjCLFnMBG90Moo78UGXpaA+vO04rbNy1PIAqUL/DNj 4y9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=jj2KCOatyhGxASe4hYAVWzUr2nV8BQDD9jb5VqsVCM8=; b=lyKe82mE/mXeprFaN7+FWAHLCTjGWx58TOCOVXP5a8k8CL9iS/i/gJZ9r3LxcUR0ca kLCSnIbFk+ftw4XvfYuo7r/imtgYt5MNjDQaG7x9ids3sMW4Dvo+FQ7cYf7nkUhH3i2r R8Gac7c4Hrz1LfFIYXT9iN75Y6Ev7jPgUFWiWK4z/QNcN75D7gFdGctRlCvfLnfWRgN2 jKqxGT9jKcOWeqDsohTvxiSsfadv8EN2YozZpuTxPKVznBNvDXll8VyGCDN6RWJZCsjA CkQOFU1+4WKSlbrvleVaF6GtLPaqJDAx2c7qEn76SKHkva55t4e+khkMIXNZC+yfyXj5 uSGA== X-Gm-Message-State: AIkVDXKKlL56AlKy40po3GAYeHdtDQD0mxVEuvg8GG6D1fbO81reG0l9NrIakR6s4+Y0dw== X-Received: by 10.84.136.7 with SMTP id 7mr10053400plk.100.1485498399176; Thu, 26 Jan 2017 22:26:39 -0800 (PST) Received: from calancha-pc (33.94.100.220.dy.bbexcite.jp. [220.100.94.33]) by smtp.gmail.com with ESMTPSA id w25sm7803093pge.9.2017.01.26.22.26.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Jan 2017 22:26:38 -0800 (PST) From: Tino Calancha References: <7oa66k9es.fsf@fencepost.gnu.org> Date: Fri, 27 Jan 2017 15:26:32 +0900 In-Reply-To: (Stefan Monnier's message of "Wed, 24 Aug 2016 13:05:56 -0400") Message-ID: <87o9ytuig7.fsf@calancha-pc> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) Stefan Monnier writes: >> - (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))) > > Doesn't look simple enough, tho: you dropped the shell-quote-argument. OK, i will use it. The following patch is divided in two parts. 1) First one fix this bug: avoid truncation of the output, i.e., the output from all processed buffers is kept. 2) Erase *Shell Command Output* before `ibuffer-do-shell-command-pipe', `ibuffer-do-shell-command-pipe-replace' and `ibuffer-do-shell-command-file' if shell-command-dont-erase-buffer is nil. How do you think? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From d8b9c18d1693e30a07b2559aae89459a4fce0a4a Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Fri, 27 Jan 2017 15:22:41 +0900 Subject: [PATCH 1/2] 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). --- lisp/ibuf-ext.el | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 058eaecb36..00cbf051d2 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -512,8 +512,10 @@ 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)) + (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 @@ shell-command-pipe-replace :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 @@ 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 - (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) -- 2.11.0 >From 905a263a86340ad739b9e8816d36f596ae00b65b Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Fri, 27 Jan 2017 15:22:53 +0900 Subject: [PATCH 2/2] Ibuffer: Erase output buffer before shell commands * lisp/ibuf-macs.el (define-ibuffer-op): Add keyword arguments BEFORE and AFTER; they are forms to run before/after BODY. * lisp/ibuf-ext.el (ibuffer--maybe-erase-shell-cmd-output): New defsubst; if shell-command-dont-erase-buffer is nil, then erase shell command output buffer. (ibuffer-do-shell-command-pipe, ibuffer-do-shell-command-file): Use it. --- lisp/ibuf-ext.el | 9 ++++++++- lisp/ibuf-macs.el | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 00cbf051d2..04a3d84f58 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -506,11 +506,18 @@ ibuffer-backward-filter-group (ibuffer-backward-filter-group 1)) (ibuffer-forward-line 0)) +(defsubst ibuffer--maybe-erase-shell-cmd-output (&optional buffer) + (let ((buf (or buffer (get-buffer "*Shell Command Output*")))) + (when (and (buffer-live-p buf) + (not shell-command-dont-erase-buffer)) + (with-current-buffer buf (erase-buffer))))) + ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe "ibuf-ext") (define-ibuffer-op shell-command-pipe (command) "Pipe the contents of each marked buffer to shell command COMMAND." (:interactive "sPipe to shell command: " :opstring "Shell command executed on" + :before (ibuffer--maybe-erase-shell-cmd-output) :modifier-p nil) (let ((out-buf (get-buffer-create "*Shell Command Output*"))) (with-current-buffer out-buf (goto-char (point-max))) @@ -533,6 +540,7 @@ shell-command-file "Run shell command COMMAND separately on files of marked buffers." (:interactive "sShell command on buffer's file: " :opstring "Shell command executed on" + :before (ibuffer--maybe-erase-shell-cmd-output) :modifier-p nil) (let ((file (and (not (buffer-modified-p)) buffer-file-name)) @@ -551,7 +559,6 @@ shell-command-file (shell-quote-argument file)) nil out-buf nil))) - ;;;###autoload (autoload 'ibuffer-do-eval "ibuf-ext") (define-ibuffer-op eval (form) "Evaluate FORM in each of the buffers. diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el index 05e568efeb..1ee157aac7 100644 --- a/lisp/ibuf-macs.el +++ b/lisp/ibuf-macs.el @@ -169,6 +169,8 @@ ibuffer-save-marks dangerous (opstring "operated on") (active-opstring "Operate on") + before + after complex) &rest body) "Generate a function which operates on a buffer. @@ -198,6 +200,8 @@ ibuffer-save-marks ACTIVE-OPSTRING is a string which will be displayed to the user in a confirmation message, in the form: \"Really ACTIVE-OPSTRING x buffers?\" +BEFORE is a form to evaluate before start the operation. +AFTER is a form to evaluate once the operation is complete. COMPLEX means this function is special; if COMPLEX is nil BODY evaluates once for each marked buffer, MBUF, with MBUF current and saving the point. If COMPLEX is non-nil, BODY evaluates @@ -206,7 +210,7 @@ ibuffer-save-marks marked buffer. BODY is evaluated with `buf' bound to the buffer object. -\(fn OP ARGS DOCUMENTATION (&key INTERACTIVE MARK MODIFIER-P DANGEROUS OPSTRING ACTIVE-OPSTRING COMPLEX) &rest BODY)" +\(fn OP ARGS DOCUMENTATION (&key INTERACTIVE MARK MODIFIER-P DANGEROUS OPSTRING ACTIVE-OPSTRING BEFORE AFTER COMPLEX) &rest BODY)" (declare (indent 2) (doc-string 3)) `(progn (defun ,(intern (concat (if (string-match "^ibuffer-do" (symbol-name op)) @@ -233,11 +237,13 @@ ibuffer-save-marks 'ibuffer-deletion-char) (_ 'ibuffer-marked-char)))) + ,before ; pre-operation form. ,(let* ((finish (append '(progn) (if (eq modifier-p t) '((setq ibuffer-did-modification t)) ()) + (and after `(,after)) ; post-operation form. `((ibuffer-redisplay t) (message ,(concat "Operation finished; " opstring " %s buffers") count)))) (inner-body (if complex -- 2.11.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.6) of 2017-01-27 Repository revision: 7cb7a582f44db94292709d35f4f5474f891f03b0 From unknown Tue Aug 19 14:22:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 03 Feb 2017 04:26:02 +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 To: 22679@debbugs.gnu.org Cc: Glenn Morris , Stefan Monnier , Tino Calancha Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.148609593924925 (code B ref 22679); Fri, 03 Feb 2017 04:26:02 +0000 Received: (at 22679) by debbugs.gnu.org; 3 Feb 2017 04:25:39 +0000 Received: from localhost ([127.0.0.1]:54399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZVRL-0006Tw-2y for submit@debbugs.gnu.org; Thu, 02 Feb 2017 23:25:39 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33155) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZVRK-0006Tj-0e for 22679@debbugs.gnu.org; Thu, 02 Feb 2017 23:25:38 -0500 Received: by mail-pf0-f193.google.com with SMTP id e4so677041pfg.0 for <22679@debbugs.gnu.org>; Thu, 02 Feb 2017 20:25:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=7q7Yn82sIDo92LNw8Tip7FykSA+/pdg8bhgbzVSexgU=; b=G2tTvNY/gtBUdKBZDShpW4GuEAdHzh66MWUEYG916OlWJDslF1OYDDVt4+ZZl/kX4w SkbX29yDxXCryZb+cMeG18n6Y0bDB2gckwyarbWyBDC5wMGsFtu101xaoBRhcS0avOPu Hi6u+TJp4NVXiJplWp4ZMjL4ZYjqvK1nL4VvMCMF+y0xrCjIdKtowm0c490pLj9HmnbS HJ30wPEMoUOtOgMAiYb7cZ9VvG4BB7gCJ6qkgJLlR7sSne+janHt5bFdReGtr8lRFFi5 Mf5dN+3CFQInMOFuFAlEhGb1zx+gZB0+zjL1b5GC0VeAk+wL+pLFhBYTht7p7g8JeafI SZTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=7q7Yn82sIDo92LNw8Tip7FykSA+/pdg8bhgbzVSexgU=; b=t62l9Y5ipf0X50N4vtUfSBUvEug0ib9RiPRk3tJERwaVoXSrWfKFcDpBWVGqgM371i ple9bO+OIb/i93hp2tj3aUB6YRtoNVZ16KI/rWKKBu1VIU0H1xuCS6YliQ/CQGrElCvl r3pg9bV3Lq4TdOoXX+0zQ5k2hHhM2osVvuYKdKro5FuzgPP11CfNHWtT/MaMl0Maddup mxkYJQb/x7eel9K9ZgXTmiZjKFEGt5wzHxbozUF99N4Z0nZU97uPPqw8jFGFV4y1IO2h WdSijzv6gdddfOEaQBti1CxEzpLgxWP4kWYAMOjSTU63k8PKQRh+VM2qOQrDBCDNfa9q /6Qg== X-Gm-Message-State: AIkVDXKxhgA+nk2e3+OheZ48ZUG6gh/UJ5TjpVcGo1lUoiPywMN18OTu+tQDHYUyiCHklg== X-Received: by 10.98.8.11 with SMTP id c11mr15384884pfd.135.1486095931804; Thu, 02 Feb 2017 20:25:31 -0800 (PST) Received: from calancha-pc (104.81.147.124.dy.bbexcite.jp. [124.147.81.104]) by smtp.gmail.com with ESMTPSA id k78sm62293064pfb.93.2017.02.02.20.25.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Feb 2017 20:25:31 -0800 (PST) From: Tino Calancha References: <7oa66k9es.fsf@fencepost.gnu.org> <87o9ytuig7.fsf@calancha-pc> Date: Fri, 03 Feb 2017 13:25:25 +0900 In-Reply-To: <87o9ytuig7.fsf@calancha-pc> (Tino Calancha's message of "Fri, 27 Jan 2017 15:26:32 +0900") Message-ID: <87poiz2956.fsf@calancha-pc> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -1.1 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.1 (-) Tino Calancha writes: >> Doesn't look simple enough, tho: you dropped the shell-quote-argument. > OK, i will use it. > The following patch is divided in two parts. > 1) First one fix this bug: avoid truncation of the output, i.e., the > output from all processed buffers is kept. > > 2) Erase *Shell Command Output* before `ibuffer-do-shell-command-pipe', > `ibuffer-do-shell-command-pipe-replace' and > `ibuffer-do-shell-command-file' > if shell-command-dont-erase-buffer is nil. I have updated 2): BEFORE form must be executed once, right before the operation; previous patch run it inside the loop. Following is the updated patch. I'd like to push it into master branch in a few days if there is no objections. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From f01155c426e83fd69ec0b9ecdd697bc973b78197 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Fri, 3 Feb 2017 12:37:25 +0900 Subject: [PATCH 1/2] 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). --- lisp/ibuf-ext.el | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 058eaecb36..00cbf051d2 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -512,8 +512,10 @@ 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)) + (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 @@ shell-command-pipe-replace :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 @@ 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 - (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) -- 2.11.0 >From 196c1dc5984c3b0f6842201ef86bc34b71d4a440 Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Fri, 3 Feb 2017 13:10:08 +0900 Subject: [PATCH 2/2] Ibuffer: Erase output buffer before shell commands * lisp/ibuf-macs.el (define-ibuffer-op): Add keyword arguments BEFORE and AFTER; they are forms to run before/after the operation. * lisp/ibuf-ext.el (ibuffer--maybe-erase-shell-cmd-output): New defun; if shell-command-dont-erase-buffer is nil, then erase shell command output buffer. (ibuffer-do-shell-command-pipe, ibuffer-do-shell-command-file): Use it. --- lisp/ibuf-ext.el | 10 +++++++++- lisp/ibuf-macs.el | 10 ++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 00cbf051d2..2a68f777d9 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -506,11 +506,19 @@ ibuffer-backward-filter-group (ibuffer-backward-filter-group 1)) (ibuffer-forward-line 0)) +(defun ibuffer--maybe-erase-shell-cmd-output () + (let ((buf (get-buffer "*Shell Command Output*"))) + (when (and (buffer-live-p buf) + (not shell-command-dont-erase-buffer) + (not (zerop (buffer-size buf)))) + (with-current-buffer buf (erase-buffer))))) + ;;;###autoload (autoload 'ibuffer-do-shell-command-pipe "ibuf-ext") (define-ibuffer-op shell-command-pipe (command) "Pipe the contents of each marked buffer to shell command COMMAND." (:interactive "sPipe to shell command: " :opstring "Shell command executed on" + :before (ibuffer--maybe-erase-shell-cmd-output) :modifier-p nil) (let ((out-buf (get-buffer-create "*Shell Command Output*"))) (with-current-buffer out-buf (goto-char (point-max))) @@ -533,6 +541,7 @@ shell-command-file "Run shell command COMMAND separately on files of marked buffers." (:interactive "sShell command on buffer's file: " :opstring "Shell command executed on" + :before (ibuffer--maybe-erase-shell-cmd-output) :modifier-p nil) (let ((file (and (not (buffer-modified-p)) buffer-file-name)) @@ -551,7 +560,6 @@ shell-command-file (shell-quote-argument file)) nil out-buf nil))) - ;;;###autoload (autoload 'ibuffer-do-eval "ibuf-ext") (define-ibuffer-op eval (form) "Evaluate FORM in each of the buffers. diff --git a/lisp/ibuf-macs.el b/lisp/ibuf-macs.el index 05e568efeb..8457599899 100644 --- a/lisp/ibuf-macs.el +++ b/lisp/ibuf-macs.el @@ -169,6 +169,8 @@ ibuffer-save-marks dangerous (opstring "operated on") (active-opstring "Operate on") + before + after complex) &rest body) "Generate a function which operates on a buffer. @@ -198,6 +200,8 @@ ibuffer-save-marks ACTIVE-OPSTRING is a string which will be displayed to the user in a confirmation message, in the form: \"Really ACTIVE-OPSTRING x buffers?\" +BEFORE is a form to evaluate before start the operation. +AFTER is a form to evaluate once the operation is complete. COMPLEX means this function is special; if COMPLEX is nil BODY evaluates once for each marked buffer, MBUF, with MBUF current and saving the point. If COMPLEX is non-nil, BODY evaluates @@ -206,7 +210,7 @@ ibuffer-save-marks marked buffer. BODY is evaluated with `buf' bound to the buffer object. -\(fn OP ARGS DOCUMENTATION (&key INTERACTIVE MARK MODIFIER-P DANGEROUS OPSTRING ACTIVE-OPSTRING COMPLEX) &rest BODY)" +\(fn OP ARGS DOCUMENTATION (&key INTERACTIVE MARK MODIFIER-P DANGEROUS OPSTRING ACTIVE-OPSTRING BEFORE AFTER COMPLEX) &rest BODY)" (declare (indent 2) (doc-string 3)) `(progn (defun ,(intern (concat (if (string-match "^ibuffer-do" (symbol-name op)) @@ -238,6 +242,7 @@ ibuffer-save-marks (if (eq modifier-p t) '((setq ibuffer-did-modification t)) ()) + (and after `(,after)) ; post-operation form. `((ibuffer-redisplay t) (message ,(concat "Operation finished; " opstring " %s buffers") count)))) (inner-body (if complex @@ -247,7 +252,8 @@ ibuffer-save-marks (save-excursion ,@body)) t))) - (body `(let ((count + (body `(let ((_before ,before) ; pre-operation form. + (count (,(pcase mark (:deletion 'ibuffer-map-deletion-lines) -- 2.11.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.6) of 2017-02-02 Repository revision: ce88155d83ba84e84321ed69a39c82f40117dd1f From unknown Tue Aug 19 14:22:21 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Tino Calancha Subject: bug#22679: closed (Re: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output) Message-ID: References: <87bmubzpgm.fsf@calancha-pc> X-Gnu-PR-Message: they-closed 22679 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 22679@debbugs.gnu.org Date: Thu, 09 Feb 2017 09:25:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1486632301-7997-1" This is a multi-part message in MIME format... ------------=_1486632301-7997-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 22679@debbugs.gnu.org. --=20 22679: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D22679 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1486632301-7997-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 22679-done) by debbugs.gnu.org; 9 Feb 2017 09:24:54 +0000 Received: from localhost ([127.0.0.1]:60872 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbkyE-00024d-3j for submit@debbugs.gnu.org; Thu, 09 Feb 2017 04:24:54 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36089) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbkyC-00024L-Du for 22679-done@debbugs.gnu.org; Thu, 09 Feb 2017 04:24:52 -0500 Received: by mail-pf0-f196.google.com with SMTP id 19so13454772pfo.3 for <22679-done@debbugs.gnu.org>; Thu, 09 Feb 2017 01:24:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:references:date:in-reply-to:message-id:user-agent :mime-version; bh=iWeLrq7z1Zcv2AAHClVZ1Yhwdu358YWbtwn+qUSBwBk=; b=GaKM9PoY7/je41VKv20WPoZFF6wo99aImV812qn7F43eNr1Osuv6db70ZIwzWZS+DB 9c3jgBxsj1m9O9+jkbMDWjXypbKa1Hx5J38T7AbBG88igJtRNX24aq06myW9FqkqdwaR mjgozGuFFabQ9viKjPgu1wRqqx0/hBFFca1S7M1u5aGfgWms/46aisLrZXNgs+RLkWAF errhpUvtP7rF6qYoni8BFfHMhGyb1oy7U3Hvuz8MROU9q1YkOxFP4K8C1aOWFq2lxxEY K4uO6YEvifpbWO+U2+hsqUXECubgBbeGovuA/VZ1EUaXr31g3P8a3SVwfIW1zxi7B+p/ iaJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=iWeLrq7z1Zcv2AAHClVZ1Yhwdu358YWbtwn+qUSBwBk=; b=mxCIRFcaxC0SI8ox0RPGlmZdtNPIP8X4UnyZ9TLJhivKJXGGn0seGr+pmNYUrbhZBD 86hRxBj13rURvFkTLShQ0liEU1YjAOSr1gYD/FH3n4nvPX9TAKX8vumz7fgDFJqK5dLR CURNcOvfyDwdGI4Y2+V5MUsEiYS6POioyhq7CGYmU/+ny+nEjOo7/cpbI0ftNUF/11c6 5xspbo0GWCmzKKLoJzeP5b8AuzAH9HaQEi8GMz1JRZGhFN2w2QNPHGFx7GTPpLMgTPQ7 L+etGEEvshVoXGGYPBqAnSXoQTKuCnkYOL0mOEfQkU2sGHaRErBftfTrpbJTLy+xMXXj Tbqw== X-Gm-Message-State: AMke39kYZ2UyQWaOi0HEjT1rLtLeUb25jsK+R9Yn4DGMYI+6kHYN4+eWfCf2wsYSbCyS+w== X-Received: by 10.84.213.9 with SMTP id f9mr2974256pli.138.1486632286468; Thu, 09 Feb 2017 01:24:46 -0800 (PST) Received: from calancha-pc (104.81.147.124.dy.bbexcite.jp. [124.147.81.104]) by smtp.gmail.com with ESMTPSA id 19sm26977218pft.46.2017.02.09.01.24.44 for <22679-done@debbugs.gnu.org> (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Feb 2017 01:24:45 -0800 (PST) From: Tino Calancha To: 22679-done@debbugs.gnu.org Subject: Re: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output References: <7oa66k9es.fsf@fencepost.gnu.org> <87o9ytuig7.fsf@calancha-pc> <87poiz2956.fsf@calancha-pc> Date: Thu, 09 Feb 2017 18:24:41 +0900 In-Reply-To: <87poiz2956.fsf@calancha-pc> (Tino Calancha's message of "Fri, 03 Feb 2017 13:25:25 +0900") Message-ID: <87bmubzpgm.fsf@calancha-pc> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 22679-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) Tino Calancha writes: > Following is the updated patch. I'd like to push it into master > branch in a few days if there is no objections. Pushed fix to master branch as commits: 1e23bf5c513fafb9d14a8e07232101515386a912 d9fd1d32632816aa7833bcfcc116a0a01a53a4b7 ------------=_1486632301-7997-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 15 Feb 2016 13:18:31 +0000 Received: from localhost ([127.0.0.1]:39491 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aVJ2t-0005R0-KL for submit@debbugs.gnu.org; Mon, 15 Feb 2016 08:18:31 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48889) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aVJ2s-0005Qm-F9 for submit@debbugs.gnu.org; Mon, 15 Feb 2016 08:18:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVJ2m-0004V2-Gv for submit@debbugs.gnu.org; Mon, 15 Feb 2016 08:18:25 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:47446) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVJ2m-0004Uv-EJ for submit@debbugs.gnu.org; Mon, 15 Feb 2016 08:18:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVJ2h-0000Ww-Mr for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2016 08:18:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aVJ2c-0004Qv-MV for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2016 08:18:19 -0500 Received: from calancha-ilc.kek.jp ([130.87.234.234]:50413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aVJ2c-0004QN-4V for bug-gnu-emacs@gnu.org; Mon, 15 Feb 2016 08:18:14 -0500 Received: by calancha-ilc.kek.jp (Postfix, from userid 500) id F3FA5DA69; Mon, 15 Feb 2016 22:21:29 +0900 (JST) Received: from localhost (localhost [127.0.0.1]) by calancha-ilc.kek.jp (Postfix) with ESMTP id E016D88AB for ; Mon, 15 Feb 2016 22:21:29 +0900 (JST) Date: Mon, 15 Feb 2016 22:21:29 +0900 (JST) From: Tino Calancha X-X-Sender: calancha@calancha-ilc.kek.jp To: bug-gnu-emacs@gnu.org Subject: 25.0.91; ibuffer-do-shell-command-pipe truncate output Message-ID: User-Agent: Alpine 2.20 (LRH 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="1468197610-740882629-1455542489=:7937" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) --1468197610-740882629-1455542489=:7937 Content-Type: text/plain; format=flowed; charset=US-ASCII Only the output of the last processed buffer is shown. Maybe better if it is shown the concatenation of the output of all of them. emacs -Q --eval="(mapc (lambda(x) (switch-to-buffer x) (insert x)) '(\"foo\" \"bar\"))" --eval='(ibuffer)' % n ^\(foo\|bar\)$ RET | cat RET g C-x b * ibuffer-shell-output* ;;just show one word In GNU Emacs 25.0.91.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.29) Repository revision: 23ca48d3d867cfff9f49ef600e2aad7a26c7a870 --1468197610-740882629-1455542489=:7937 Content-Type: text/plain; charset=US-ASCII; name=ibuf-ext.patch2 Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=ibuf-ext.patch2 ZGlmZiAtLWdpdCBhL2xpc3AvaWJ1Zi1leHQuZWwgYi9saXNwL2lidWYtZXh0 LmVsDQppbmRleCBmNTM3NTYxLi44YjFkNGQyIDEwMDY0NA0KLS0tIGEvbGlz cC9pYnVmLWV4dC5lbA0KKysrIGIvbGlzcC9pYnVmLWV4dC5lbA0KQEAgLTMy Myw5ICszMjMsMTUgQEAgc2hlbGwtY29tbWFuZC1waXBlDQogICAoOmludGVy YWN0aXZlICJzUGlwZSB0byBzaGVsbCBjb21tYW5kOiAiDQogICAgOm9wc3Ry aW5nICJTaGVsbCBjb21tYW5kIGV4ZWN1dGVkIG9uIg0KICAgIDptb2RpZmll ci1wIG5pbCkNCi0gIChzaGVsbC1jb21tYW5kLW9uLXJlZ2lvbg0KLSAgIChw b2ludC1taW4pIChwb2ludC1tYXgpIGNvbW1hbmQNCi0gICAoZ2V0LWJ1ZmZl ci1jcmVhdGUgIiogaWJ1ZmZlci1zaGVsbC1vdXRwdXQqIikpKQ0KKyAgKGxl dCogKChvdXQtYnVmIChnZXQtYnVmZmVyLWNyZWF0ZSAiKiBpYnVmZmVyLXNo ZWxsLW91dHB1dCoiKSkNCisgICAgICAgICAoYnVmZmVycyAod2l0aC1jdXJy ZW50LWJ1ZmZlciAiKklidWZmZXIqIiAoaWJ1ZmZlci1nZXQtbWFya2VkLWJ1 ZmZlcnMpKSkpDQorICAgIChsZXQgKChzdHJpbmcgKHdpdGgtdGVtcC1idWZm ZXINCisgICAgICAgICAgICAgICAgICAgIChpbnNlcnQtYnVmZmVyLXN1YnN0 cmluZyBidWYpDQorICAgICAgICAgICAgICAgICAgICAoc2hlbGwtY29tbWFu ZC1vbi1yZWdpb24gKHBvaW50LW1pbikgKHBvaW50LW1heCkgY29tbWFuZCBu aWwgdCkNCisgICAgICAgICAgICAgICAgICAgIChidWZmZXItc3Vic3RyaW5n LW5vLXByb3BlcnRpZXMgKHBvaW50LW1pbikgKHBvaW50LW1heCkpKSkpDQor ICAgICAgKHdpdGgtY3VycmVudC1idWZmZXIgb3V0LWJ1Zg0KKyAgICAgICAg KHdoZW4gKGVxIGJ1ZiAoY2FyIGJ1ZmZlcnMpKSAoZXJhc2UtYnVmZmVyKSkN CisgICAgICAgIChpbnNlcnQgc3RyaW5nKSkpKSkNCiANCiA7OzsjIyNhdXRv bG9hZCAoYXV0b2xvYWQgJ2lidWZmZXItZG8tc2hlbGwtY29tbWFuZC1waXBl LXJlcGxhY2UgImlidWYtZXh0IikNCiAoZGVmaW5lLWlidWZmZXItb3Agc2hl bGwtY29tbWFuZC1waXBlLXJlcGxhY2UgKGNvbW1hbmQpDQpAQCAtMzQ1LDEy ICszNTEsMTkgQEAgc2hlbGwtY29tbWFuZC1maWxlDQogICAoOmludGVyYWN0 aXZlICJzU2hlbGwgY29tbWFuZCBvbiBidWZmZXIncyBmaWxlOiAiDQogICAg Om9wc3RyaW5nICJTaGVsbCBjb21tYW5kIGV4ZWN1dGVkIG9uIg0KICAgIDpt b2RpZmllci1wIG5pbCkNCi0gIChzaGVsbC1jb21tYW5kIChjb25jYXQgY29t bWFuZCAiICINCi0JCQkgKHNoZWxsLXF1b3RlLWFyZ3VtZW50DQotCQkJICAo aWYgYnVmZmVyLWZpbGUtbmFtZQ0KLQkJCSAgICAgIGJ1ZmZlci1maWxlLW5h bWUNCi0JCQkgICAgKG1ha2UtdGVtcC1maWxlDQotCQkJICAgICAoc3Vic3Ry aW5nIChidWZmZXItbmFtZSkgMCAobWluIDEwIChsZW5ndGggKGJ1ZmZlci1u YW1lKSkpKSkpKSkpKQ0KKyAgKGxldCogKChvdXQtYnVmIChnZXQtYnVmZmVy LWNyZWF0ZSAiKlNoZWxsIENvbW1hbmQgT3V0cHV0KiIpKSA7IFRoaXMgZnVu Y3Rpb24gYW5kIHNoZWxsLWNvbW1hbmQtcGlwZQ0KKyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICA7IHNob3VsZCBoYXZlIHNhbWUgb3V0IGJ1ZmZlciBuYW1lLg0KKyAg ICAgICAgIChidWZmZXJzICh3aXRoLWN1cnJlbnQtYnVmZmVyICIqSWJ1ZmZl cioiIChpYnVmZmVyLWdldC1tYXJrZWQtYnVmZmVycykpKSkNCisgICAgKGxl dCogKChmbmFtZSAgKG9yIGJ1ZmZlci1maWxlLW5hbWUNCisgICAgICAgICAg ICAgICAgICAgICAgIChsZXQgKChmaWxlIChtYWtlLXRlbXAtZmlsZQ0KKyAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChzdWJzdHJpbmcg KGJ1ZmZlci1uYW1lKSAwIChtaW4gMTAgKGxlbmd0aCAoYnVmZmVyLW5hbWUp KSkpKSkpDQorICAgICAgICAgICAgICAgICAgICAgICAgICh3cml0ZS1yZWdp b24gKHBvaW50LW1pbikgKHBvaW50LW1heCkgZmlsZSkgZmlsZSkpKQ0KKyAg ICAgICAgICAgKGNtZCAgICAoZm9ybWF0ICIlcyAlcyIgY29tbWFuZCAoc2hl bGwtcXVvdGUtYXJndW1lbnQgZm5hbWUpKSkNCisgICAgICAgICAgIChzdHJp bmcgKHNoZWxsLWNvbW1hbmQtdG8tc3RyaW5nIGNtZCkpKQ0KKw0KKyAgICAg ICh3aXRoLWN1cnJlbnQtYnVmZmVyIG91dC1idWYNCisgICAgICAgICh3aGVu IChlcSBidWYgKGNhciBidWZmZXJzKSkgKGVyYXNlLWJ1ZmZlcikpDQorICAg ICAgICAoaW5zZXJ0IHN0cmluZykpKSkpDQogDQogOzs7IyMjYXV0b2xvYWQg KGF1dG9sb2FkICdpYnVmZmVyLWRvLWV2YWwgImlidWYtZXh0IikNCiAoZGVm aW5lLWlidWZmZXItb3AgZXZhbCAoZm9ybSkNCg== --1468197610-740882629-1455542489=:7937-- ------------=_1486632301-7997-1--