From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.emacs.help Subject: Re: behaviour of shell-command-on-region Date: Mon, 22 Feb 2010 10:16:37 +0100 Message-ID: <20100222091637.GA21836@tomas> References: <87vddqcwvx.fsf@stats.ox.ac.uk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; x-action=pgp-signed Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1266835042 1139 80.91.229.12 (22 Feb 2010 10:37:22 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 22 Feb 2010 10:37:22 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Dan Davison Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Feb 22 11:37:18 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NjUOS-00065Z-4d for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Feb 2010 10:15:56 +0100 Original-Received: from localhost ([127.0.0.1]:46373 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjUOR-0003qV-GV for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Feb 2010 04:15:55 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NjUNx-0003p9-OZ for help-gnu-emacs@gnu.org; Mon, 22 Feb 2010 04:15:26 -0500 Original-Received: from [140.186.70.92] (port=40422 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjUNw-0003oa-EM for help-gnu-emacs@gnu.org; Mon, 22 Feb 2010 04:15:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NjUNv-0006EC-GM for help-gnu-emacs@gnu.org; Mon, 22 Feb 2010 04:15:24 -0500 Original-Received: from alextrapp1.equinoxe.de ([217.22.192.104]:37759 helo=www.elogos.de) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NjUNv-0006E7-3Z for help-gnu-emacs@gnu.org; Mon, 22 Feb 2010 04:15:23 -0500 Original-Received: by www.elogos.de (Postfix, from userid 1000) id 0279B90050; Mon, 22 Feb 2010 10:16:38 +0100 (CET) Content-Disposition: inline In-Reply-To: <87vddqcwvx.fsf@stats.ox.ac.uk> User-Agent: Mutt/1.5.15+20070412 (2007-04-11) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:72006 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sun, Feb 21, 2010 at 12:38:10PM -0500, Dan Davison wrote: > I'm having trouble understanding the output-buffer and replace argument= s > to shell-command-on-region: >=20 > The argument list and docstring are reproduced below. >=20 > If I put point on the last parenthesis and do C-x C-e I was expecting > this to insert the date after point. However, it erases the current > buffer and inserts the date: >=20 > (shell-command-on-region (point-min) (point-max) "date" 'current-buffer= ) >=20 > It's seeming to me that the docstring and behaviour don't match. Where > am I going wrong? >=20 > Dan >=20 > emacs-version 23.1.1 ubuntu 9.10 >=20 >=20 > The argument list for shell-command-on-region is: >=20 > (shell-command-on-region start end command &optional output-buffer > replace error-buffer display-error-buffer) >=20 > The docstring says: >=20 > If the optional fourth argument output-buffer is non-nil, > that says to put the output in some other buffer. > If output-buffer is a buffer or buffer name, put the output there. > If output-buffer is not a buffer and not nil, > insert output in the current buffer. > In either case, the output is inserted after point (leaving mark af= ter it). > =20 > If replace, the optional fifth argument, is non-nil, that means ins= ert > the output in place of text from start to end, putting point and ma= rk > around it. You are right -- this looks like a bug. When the argument is nil, the whole buffer gets replaced, regardless of the args START and END. But when the arg is t, the region gets respected, so this might be a workaround: (shell-command-on-region (point) (point) "date" 'current-buffer t) (I'm somewhat surprised that the symbol 'current-buffer works there: I'd use (current-buffer) instead -- but this seems to work). Of course, you can replace (point) by whatever buffer position suits you. This won't work when the external command wants real input, though :-( I'll try to file a bug. Regards - -- tom=C3=A1s -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFLgkt1Bcgs9XrR2kYRAqcsAJ9Aqf6PLaRQU8rj/csS2cG++McnaQCdGdJp cGMTjXgIeMVYA1eCznO7qwI=3D =3DQguz -----END PGP SIGNATURE-----