From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#22679: 25.0.91; ibuffer-do-shell-command-pipe truncate output Date: Mon, 22 Aug 2016 12:06:59 -0400 Message-ID: References: <7oa66k9es.fsf@fencepost.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1471882111 5038 195.159.176.226 (22 Aug 2016 16:08:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 22 Aug 2016 16:08:31 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) Cc: 22679@debbugs.gnu.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 22 18:08:25 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bbrlu-0000gL-Gj for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Aug 2016 18:08:22 +0200 Original-Received: from localhost ([::1]:42198 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbrlr-0007Yu-Sz for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Aug 2016 12:08:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbrlf-0007Tz-5M for bug-gnu-emacs@gnu.org; Mon, 22 Aug 2016 12:08:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bbrla-0000Oo-2R for bug-gnu-emacs@gnu.org; Mon, 22 Aug 2016 12:08:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:39342) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bbrlZ-0000Ok-V4 for bug-gnu-emacs@gnu.org; Mon, 22 Aug 2016 12:08:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bbrlZ-00041w-Qu for bug-gnu-emacs@gnu.org; Mon, 22 Aug 2016 12:08:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: 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 Original-Received: via spool by 22679-submit@debbugs.gnu.org id=B22679.147188203615439 (code B ref 22679); Mon, 22 Aug 2016 16:08:01 +0000 Original-Received: (at 22679) by debbugs.gnu.org; 22 Aug 2016 16:07:16 +0000 Original-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 Original-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 Original-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 Original-Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 414E2AE0EA; Mon, 22 Aug 2016 12:06:59 -0400 (EDT) In-Reply-To: (Tino Calancha's message of "Sun, 21 Aug 2016 23:37:26 +0900 (JST)") 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:122503 Archived-At: >> 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