From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: behaviour of shell-command-on-region Date: Mon, 22 Feb 2010 11:05:31 +0100 Organization: Informatimago Message-ID: <87vddp60wk.fsf@galatea.lan.informatimago.com> References: <87vddqcwvx.fsf@stats.ox.ac.uk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1266838935 12990 80.91.229.12 (22 Feb 2010 11:42:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 22 Feb 2010 11:42:15 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Feb 22 12:42:11 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 1NjVki-0002VY-JK for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Feb 2010 11:43:00 +0100 Original-Received: from localhost ([127.0.0.1]:43695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjVkg-0008Gy-Tk for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Feb 2010 05:42:59 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 58 Original-X-Trace: individual.net NSEk0uuYaJOKRHCzKRwBtgyaDwT4ufwNsMa+cIyH7e7ORf5jcY Cancel-Lock: sha1:MmE3NGRjYWUyMzczNWUzMTFiZDY5ODI5NDVmMzgxY2RkMjMxNTM4NQ== sha1:+fgy5DbAqzshOAwfYwrHAQpUyA4= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (darwin) Original-Xref: news.stanford.edu gnu.emacs.help:176966 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:72010 Archived-At: tomas@tuxteam.de writes: > On Sun, Feb 21, 2010 at 12:38:10PM -0500, Dan Davison wrote: >> I'm having trouble understanding the output-buffer and replace arguments >> to shell-command-on-region: >> >> The argument list and docstring are reproduced below. >> >> 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: >> >> (shell-command-on-region (point-min) (point-max) "date" 'current-buffer) >> >> It's seeming to me that the docstring and behaviour don't match. Where >> am I going wrong? >> >> Dan >> >> emacs-version 23.1.1 ubuntu 9.10 >> >> >> The argument list for shell-command-on-region is: >> >> (shell-command-on-region start end command &optional output-buffer >> replace error-buffer display-error-buffer) >> >> The docstring says: >> >> 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 after it). >> >> If replace, the optional fifth argument, is non-nil, that means insert >> the output in place of text from start to end, putting point and mark >> 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). You're only surprized because you cannot read. >> If output-buffer is not a buffer and not nil, >> insert output in the current buffer. -- __Pascal Bourguignon__