all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: behaviour of shell-command-on-region
       [not found] <87vddqcwvx.fsf@stats.ox.ac.uk>
@ 2010-02-22  9:16 ` tomas
  2010-02-22  9:27   ` tomas
  2010-02-24  6:20   ` tomas
       [not found] ` <mailman.1633.1266830128.14305.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 5+ messages in thread
From: tomas @ 2010-02-22  9:16 UTC (permalink / raw)
  To: Dan Davison; +Cc: help-gnu-emacs

-----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-----




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: behaviour of shell-command-on-region
  2010-02-22  9:16 ` behaviour of shell-command-on-region tomas
@ 2010-02-22  9:27   ` tomas
  2010-02-24  6:20   ` tomas
  1 sibling, 0 replies; 5+ messages in thread
From: tomas @ 2010-02-22  9:27 UTC (permalink / raw)
  To: tomas; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Feb 22, 2010 at 10:16:37AM +0100, tomas@tuxteam.de wrote:
> On Sun, Feb 21, 2010 at 12:38:10PM -0500, Dan Davison wrote:
> > I'm having trouble understanding the output-buffer and replace arguments

[...]

> This won't work when the external command wants real input, though :-(

A workaround would be to use the more basic "call-process-region". This
works:

  (call-process-region (point) (+ 10 (point)) "/bin/date" nil (current-buffer))

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFLgk3rBcgs9XrR2kYRAldjAJ46cy7RRU9UnxkK34mmn2hA8DnJRQCfa8eG
Tha10OKgxTozawO4PL+diAc=
=bLh2
-----END PGP SIGNATURE-----




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: behaviour of shell-command-on-region
       [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
  0 siblings, 1 reply; 5+ messages in thread
From: Pascal J. Bourguignon @ 2010-02-22 10:05 UTC (permalink / raw)
  To: help-gnu-emacs

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__


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: behaviour of shell-command-on-region
  2010-02-22 10:05   ` Pascal J. Bourguignon
@ 2010-02-22 16:47     ` tomas
  0 siblings, 0 replies; 5+ messages in thread
From: tomas @ 2010-02-22 16:47 UTC (permalink / raw)
  To: Pascal J. Bourguignon; +Cc: help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Feb 22, 2010 at 11:05:31AM +0100, Pascal J. Bourguignon wrote:
> tomas@tuxteam.de writes:

[...]

> > (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.

Heh. Thanks for sticking my nose into it ;^)

Regards
- -- tomas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFLgrUsBcgs9XrR2kYRAmcGAJ9W9gJ1qtCG7RUVoe/2HVD54/3nyQCfQUVH
q+zQEk+SYHICpTwf9mo+B1w=
=ysri
-----END PGP SIGNATURE-----




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: behaviour of shell-command-on-region
  2010-02-22  9:16 ` behaviour of shell-command-on-region tomas
  2010-02-22  9:27   ` tomas
@ 2010-02-24  6:20   ` tomas
  1 sibling, 0 replies; 5+ messages in thread
From: tomas @ 2010-02-24  6:20 UTC (permalink / raw)
  To: tomas; +Cc: Dan Davison, help-gnu-emacs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Feb 22, 2010 at 10:16:37AM +0100, tomas@tuxteam.de wrote:

[...]

> I'll try to file a bug.

i actually managed. It's here:

    <http://debbugs.gnu.org/5618>

Feel free to chime in.

Turns out that looks very much a duplicate of

    <http://debbugs.gnu.org/4891>

thus they will most probably be merged.

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFLhMUWBcgs9XrR2kYRAlh3AJ9odf+JTgQEcJF9TK8Ma6rKU4VaCgCdFNyu
a4DHx/zqO/q/9yesBEUKvCM=
=4J98
-----END PGP SIGNATURE-----




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-24  6:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <87vddqcwvx.fsf@stats.ox.ac.uk>
2010-02-22  9:16 ` behaviour of shell-command-on-region tomas
2010-02-22  9:27   ` 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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.