GNU bug report logs - #5618
23.1.91; shell-command-on-region unexpectedly erases buffer

Previous Next

Package: emacs;

Reported by: tomas <at> tuxteam.de

Date: Mon, 22 Feb 2010 12:13:01 UTC

Severity: minor

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 5618 in the body.
You can then email your comments to 5618 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5618; Package emacs. (Mon, 22 Feb 2010 12:13:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to tomas <at> tuxteam.de:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 22 Feb 2010 12:13:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: tomas <at> tuxteam.de
To: emacs-pretest-bug <at> gnu.org
Cc: rfrancoise <at> debian.org
Subject: 23.1.91; shell-command-on-region unexpectedly erases buffer
Date: Mon, 22 Feb 2010 10:44:13 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English if possible, because the Emacs maintainers
usually do not have translators to read other languages for them.

Your bug report will be posted to the emacs-pretest-bug <at> gnu.org mailing list,
and to the gnu.emacs.bug news group.

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug.  If you can, give
a recipe starting from `emacs -Q':

- - Start with some buffer with text in it. *scratch* will do fine.
- - Put point somewhere in text
- - evaluate (shell-command-on-region (point) (point) "/bin/date" (current-buffer) nil)

(The actual values of START and END are irrelevant, though).

The whole content of the buffer gets replaced by output of
command. According to the doc, I'd expect the ouput to be inserted
before point.

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/usr/share/emacs/23.1.91/etc/DEBUG.


In GNU Emacs 23.1.91.1 (i486-pc-linux-gnu, GTK+ Version 2.12.12)
 of 2010-01-11 on elegiac, modified by Debian
 (emacs-snapshot package, version 1:20100111-1~lenny1)
Windowing system distributor `The X.Org Foundation', version 11.0.10402000
configured using `configure  '--build' 'i486-linux-gnu' '--host' 'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/23.1.91/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1.91/site-lisp:/usr/share/emacs/site-lisp' '--with-x=yes' '--with-x-toolkit=gtk' 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_ZW.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Help

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: (only . t)
  view-mode: t

Recent input:
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up> 
<up> <up> <up> <up> <up> <up> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> C-x 
b <return> C-x u C-h f c a l l - p r o c e s s <tab> 
<tab> - r e <tab> <return> M-x <up> <return> <up> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> c a l l - p r o 
c e s s <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> n i l SPC <return> M-x <up> <return> 
<up> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <down-mouse-1> <mouse-movement> 
<mouse-movement> <mouse-movement> <mouse-movement> 
<mouse-movement> <mouse-movement> <help-echo> <mouse-movement> 
<mouse-movement> <mouse-movement> <mouse-movement> 
<mouse-movement> <mouse-movement> <mouse-movement> 
<mouse-movement> <mouse-movement> <drag-mouse-1> C-g 
C-x o M-x r e p o <tab> r <tab> <return>

Recent messages:
uncompressing simple.el.gz...done
Note: file is write protected
0 (#o0, #x0)
Mark saved where search started
Undo!
Making completion list...
Type C-x 1 to delete the help window.
0 (#o0, #x0)
Quit
Making completion list...

Load-path shadows:
/usr/share/emacs/23.1.91/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup

Features:
(shadow sort mail-extr message sendmail ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils mailheader canlock sha1 hex-util
hashcash mail-utils emacsbug multi-isearch jka-compr find-func debug
help-mode easymenu view cc-styles cc-align cc-engine cc-vars cc-defs
uniquify advice help-fns advice-preload markerpen am-mode easy-mmode
am-files diredz regexp-opt wid-edit edmacro kmacro tooltip ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd font-setting tool-bar dnd
fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer
select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu
font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan
thai tai-viet lao korean japanese hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces
cus-face files text-properties overlay md5 base64 format env code-pages
mule custom widget hashtable-print-readable backquote
make-network-process dbusbind font-render-setting gtk x-toolkit x
multi-tty emacs)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFLglHtBcgs9XrR2kYRAgd7AJ4gD7sTtf0hIhR7T7wLHIaPQlR9QwCfUr68
P6oq/qRMBtsYCsNF9/eUl4M=
=79DJ
-----END PGP SIGNATURE-----




Severity set to 'minor' from 'normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 22 Feb 2010 18:02:02 GMT) Full text and rfc822 format available.

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5618; Package emacs. (Tue, 23 Feb 2010 18:09:02 GMT) Full text and rfc822 format available.

Message #10 received at 5618 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: tomas <at> tuxteam.de
Cc: 5618 <at> debbugs.gnu.org, rfrancoise <at> debian.org
Subject: Re: bug#5618: 23.1.91;
	shell-command-on-region unexpectedly erases buffer
Date: Tue, 23 Feb 2010 13:08:37 -0500
tomas <at> tuxteam.de wrote:

> The whole content of the buffer gets replaced by output of
> command. According to the doc, I'd expect the ouput to be inserted
> before point.

I guess this is a documentation bug, in the same way as was

http://debbugs.gnu.org/4891

I'm not sure that the installed doc fix for that bug is actually
correct. The suggestion in

http://debbugs.gnu.org/4891#10

seems correct to me.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5618; Package emacs. (Wed, 24 Feb 2010 05:58:01 GMT) Full text and rfc822 format available.

Message #13 received at 5618 <at> debbugs.gnu.org (full text, mbox):

From: tomas <at> tuxteam.de
To: Glenn Morris <rgm <at> gnu.org>
Cc: 5618 <at> debbugs.gnu.org, rfrancoise <at> debian.org
Subject: Re: bug#5618: 23.1.91; shell-command-on-region unexpectedly erases
	buffer
Date: Wed, 24 Feb 2010 06:58:29 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks, Glenn for looking into it.

On Tue, Feb 23, 2010 at 01:08:37PM -0500, Glenn Morris wrote:
> tomas <at> tuxteam.de wrote:
> 
> > The whole content of the buffer gets replaced by output of
> > command. According to the doc, I'd expect the ouput to be inserted
> > before point.
> 
> I guess this is a documentation bug, in the same way as was
> 
> http://debbugs.gnu.org/4891

Yes, I think it's the same "bug". Now if I knew how to merge that...

> I'm not sure that the installed doc fix for that bug is actually
> correct. The suggestion in
> 
> http://debbugs.gnu.org/4891#10

Except that in our case, even if it's the current buffer, the whole
content of the buffer is overwritten as well, rendering the above
mentioned doc fix incorrect:

    "If OUTPUT-BUFFER is not a buffer and not nil,
       insert output in current buffer.  (This cannot be done
       asynchronously.)  In the latter case, the output is inserted
       after point (leaving mark after it)"

Besides, the behaviour in the current documentation seems way more
useful (i.e. _not_ erasing the buffer whenever REPLACE is non-nil).

What do you think?

> seems correct to me.

Half of it, yes, see above.

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

iD8DBQFLhMAFBcgs9XrR2kYRAghcAJ97B90JiuOcu8Ck+Yt0iCPtRQcw1gCePIY8
XYLgohnxDDQjrsn1OPJf6mY=
=4Z+h
-----END PGP SIGNATURE-----




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5618; Package emacs. (Fri, 26 Feb 2010 09:21:02 GMT) Full text and rfc822 format available.

Message #16 received at 5618 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: tomas <at> tuxteam.de
Cc: 5618 <at> debbugs.gnu.org, Glenn Morris <rgm <at> gnu.org>, rfrancoise <at> debian.org
Subject: Re: bug#5618: 23.1.91;
	shell-command-on-region unexpectedly erases buffer
Date: Fri, 26 Feb 2010 11:17:19 +0200
>> I'm not sure that the installed doc fix for that bug is actually
>> correct. The suggestion in
>>
>> http://debbugs.gnu.org/4891#10
>
> Except that in our case, even if it's the current buffer, the whole
> content of the buffer is overwritten as well, rendering the above
> mentioned doc fix incorrect:
>
>     "If OUTPUT-BUFFER is not a buffer and not nil,
>        insert output in current buffer.  (This cannot be done
>        asynchronously.)  In the latter case, the output is inserted
>        after point (leaving mark after it)"
>
> Besides, the behaviour in the current documentation seems way more
> useful (i.e. _not_ erasing the buffer whenever REPLACE is non-nil).
>
> What do you think?

Are you sure that changing its long-time behaviour won't break
some existing packages?

>> seems correct to me.
>
> Half of it, yes, see above.

-- 
Juri Linkov
http://www.jurta.org/emacs/




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5618; Package emacs. (Fri, 26 Feb 2010 10:12:02 GMT) Full text and rfc822 format available.

Message #19 received at 5618 <at> debbugs.gnu.org (full text, mbox):

From: tomas <at> tuxteam.de
To: Juri Linkov <juri <at> jurta.org>
Cc: 5618 <at> debbugs.gnu.org, Glenn Morris <rgm <at> gnu.org>, rfrancoise <at> debian.org
Subject: Re: bug#5618: 23.1.91; shell-command-on-region unexpectedly erases
	buffer
Date: Fri, 26 Feb 2010 11:12:17 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Feb 26, 2010 at 11:17:19AM +0200, Juri Linkov wrote:

[...]

> > Besides, the behaviour in the current documentation seems way more
> > useful (i.e. _not_ erasing the buffer whenever REPLACE is non-nil).
> >
> > What do you think?
> 
> Are you sure that changing its long-time behaviour won't break
> some existing packages?

No, of course not. Taking into account that the doc has stated tthis
behaviour one might venture to guess that packages wouldn't rely on the
"actual" (as opposed to the "documented") behaviour.

Still it's a judgement call, and I haven't the insight/experience to
perform that.

I'd try to offer a patch for the function if consensus arises that this
is desirable (but not this week).

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

iD8DBQFLh56BBcgs9XrR2kYRAgt7AJ9IJD6LDEt5Gc4JL83mLUNNvxd65gCfUVOq
uvqlUAuKKiAiRj2xhrcR1zA=
=QCCG
-----END PGP SIGNATURE-----




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#5618; Package emacs. (Sat, 06 Mar 2010 17:35:02 GMT) Full text and rfc822 format available.

Message #22 received at 5618 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: tomas <at> tuxteam.de
Cc: 5618 <at> debbugs.gnu.org, Glenn Morris <rgm <at> gnu.org>, rfrancoise <at> debian.org
Subject: Re: bug#5618: 23.1.91;
	shell-command-on-region unexpectedly erases buffer
Date: Sat, 06 Mar 2010 12:34:33 -0500
> Besides, the behaviour in the current documentation seems way more
> useful (i.e. _not_ erasing the buffer whenever REPLACE is non-nil).

Agreed.  We should try and fix the code to obey the doc more than the
converse.  If that can introduce backward compatibility problems, then
it just means we need to do it more carefully.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#5618; Package emacs. (Thu, 27 Jan 2022 18:32:01 GMT) Full text and rfc822 format available.

Message #25 received at 5618 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: tomas <at> tuxteam.de
Cc: 5618 <at> debbugs.gnu.org, rfrancoise <at> debian.org
Subject: Re: bug#5618: 23.1.91; shell-command-on-region unexpectedly erases
 buffer
Date: Thu, 27 Jan 2022 19:31:08 +0100
tomas <at> tuxteam.de writes:

> - Start with some buffer with text in it. *scratch* will do fine.
> - Put point somewhere in text
> - evaluate (shell-command-on-region (point) (point) "/bin/date" (current-buffer) nil)
>
> (The actual values of START and END are irrelevant, though).
>
> The whole content of the buffer gets replaced by output of
> command. According to the doc, I'd expect the ouput to be inserted
> before point.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

The behaviour has now been documented as such:

----
Optional fourth arg OUTPUT-BUFFER specifies where to put the
command's output.  If the value is a buffer or buffer name,
erase that buffer and insert the output there; a non-nil value of
`shell-command-dont-erase-buffer' prevent to erase the buffer.
If the value is nil, use the buffer specified by `shell-command-buffer-name'.
Any other non-nil value means to insert the output in the
current buffer after START.
----

And we've grown an extra user option (that's...  pretty confusing in
itself, I think).  So while the semantics here are far less than ideal,
I don't think there's anything further to do here, and I'm closing this
bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 5618 <at> debbugs.gnu.org and tomas <at> tuxteam.de Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 27 Jan 2022 18:32:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 25 Feb 2022 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 66 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.