From: tomas@tuxteam.de
To: Dan Davison <davison@stats.ox.ac.uk>
Cc: help-gnu-emacs@gnu.org
Subject: Re: behaviour of shell-command-on-region
Date: Mon, 22 Feb 2010 10:16:37 +0100 [thread overview]
Message-ID: <20100222091637.GA21836@tomas> (raw)
In-Reply-To: <87vddqcwvx.fsf@stats.ox.ac.uk>
-----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 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).
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ás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFLgkt1Bcgs9XrR2kYRAqcsAJ9Aqf6PLaRQU8rj/csS2cG++McnaQCdGdJp
cGMTjXgIeMVYA1eCznO7qwI=
=Qguz
-----END PGP SIGNATURE-----
next parent reply other threads:[~2010-02-22 9:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87vddqcwvx.fsf@stats.ox.ac.uk>
2010-02-22 9:16 ` tomas [this message]
2010-02-22 9:27 ` behaviour of shell-command-on-region tomas
2010-02-24 6:20 ` tomas
[not found] ` <mailman.1633.1266830128.14305.help-gnu-emacs@gnu.org>
2010-02-22 10:05 ` Pascal J. Bourguignon
2010-02-22 16:47 ` tomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100222091637.GA21836@tomas \
--to=tomas@tuxteam.de \
--cc=davison@stats.ox.ac.uk \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).