GNU bug report logs - #4891
23.1; shell-command overwrites whole buffer

Previous Next

Package: emacs;

Reported by: Adam Spiers <bug-gnu-emacs <at> adamspiers.org>

Date: Mon, 9 Nov 2009 11:20:04 UTC

Severity: normal

Done: Chong Yidong <cyd <at> stupidchicken.com>

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 4891 in the body.
You can then email your comments to 4891 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 bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4891; Package emacs. (Mon, 09 Nov 2009 11:20:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Adam Spiers <bug-gnu-emacs <at> adamspiers.org>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Mon, 09 Nov 2009 11:20:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Adam Spiers <bug-gnu-emacs <at> adamspiers.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.1; shell-command overwrites whole buffer
Date: Mon,  9 Nov 2009 11:14:14 +0000 (UTC)
Starting emacs 23.1.1 with the '-q' argument and typing:

  M-: (shell-command "date" (get-buffer "*scratch*"))

results in the prior contents of the *scratch* buffer being
overwritten.  This seems to contradict the last sentence in the
following paragraph of the docstring for shell-command:

    The optional second argument output-buffer, if non-nil, 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 current buffer.  (This cannot
    be done asynchronously.)  In either case, the output is inserted
    after point (leaving mark after it).

In GNU Emacs 23.1.1 (i386-redhat-linux-gnu, GTK+ Version 2.16.6)
 of 2009-09-29 on x86-7.fedora.phx.redhat.com
Windowing system distributor `The X.Org Foundation', version 11.0.10603901
configured using `configure  '--build=i386-redhat-linux-gnu' '--host=i386-redhat-linux-gnu' '--target=i586-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--with-dbus' '--with-gif' '--with-jpeg' '--with-png' '--with-rsvg' '--with-tiff' '--with-xft' '--with-xpm' '--with-x-toolkit=gtk' 'build_alias=i386-redhat-linux-gnu' 'host_alias=i386-redhat-linux-gnu' 'target_alias=i586-redhat-linux-gnu' 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i586 -mtune=generic -fasynchronous-unwind-tables''

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_GB.utf8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default-enable-multibyte-characters: t

Major mode: Lisp Interaction

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
  line-number-mode: t
  transient-mark-mode: t

Recent input:
M-: ( s h e l l - c o m m a n d SPC " d a t e " S-SPC 
( g e t - b u f f e r SPC " * s c r a t c h * " ) ) 
<return> C-x b <return> M-x r e p o r <tab> 
<return>

Recent messages:
Loading /usr/share/emacs/site-lisp/site-start.d/muse-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/php-mode-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/po-mode-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/rpm-spec-mode-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/rpmdev-init.el (source)...done
Loading /usr/share/emacs/site-lisp/site-start.d/ruby-mode-init.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Mon Nov  9 10:38:11 GMT 2009
0 (#o0, #x0)
Making completion list...




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4891; Package emacs. (Wed, 11 Nov 2009 11:05:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Wed, 11 Nov 2009 11:05:05 GMT) Full text and rfc822 format available.

Message #10 received at 4891 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Juri Linkov <juri <at> jurta.org>
To: Adam Spiers <bug-gnu-emacs <at> adamspiers.org>
Cc: 4891 <at> debbugs.gnu.org
Subject: Re: bug#4891: 23.1; shell-command overwrites whole buffer
Date: Wed, 11 Nov 2009 12:47:21 +0200
> Starting emacs 23.1.1 with the '-q' argument and typing:
>
>   M-: (shell-command "date" (get-buffer "*scratch*"))
>
> results in the prior contents of the *scratch* buffer being
> overwritten.  This seems to contradict the last sentence in the
> following paragraph of the docstring for shell-command:
>
>     The optional second argument output-buffer, if non-nil, 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 current buffer.  (This cannot
>     be done asynchronously.)  In either case, the output is inserted
>     after point (leaving mark after it).

Is the following description more precise?

    The optional second argument OUTPUT-BUFFER, if non-nil,
    says to put the output in some other buffer.
    If OUTPUT-BUFFER is a buffer or buffer name, put the output there
      replacing the old contents of that buffer.
    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).

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



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4891; Package emacs. (Thu, 12 Nov 2009 01:25:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Adam Spiers <bug-gnu-emacs <at> adamspiers.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 12 Nov 2009 01:25:06 GMT) Full text and rfc822 format available.

Message #15 received at 4891 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Adam Spiers <bug-gnu-emacs <at> adamspiers.org>
To: Juri Linkov <juri <at> jurta.org>
Cc: 4891 <at> debbugs.gnu.org
Subject: Re: bug#4891: 23.1; shell-command overwrites whole buffer
Date: Thu, 12 Nov 2009 01:15:48 +0000
On Wed, Nov 11, 2009 at 12:47:21PM +0200, Juri Linkov wrote:
> > Starting emacs 23.1.1 with the '-q' argument and typing:
> >
> >   M-: (shell-command "date" (get-buffer "*scratch*"))
> >
> > results in the prior contents of the *scratch* buffer being
> > overwritten.  This seems to contradict the last sentence in the
> > following paragraph of the docstring for shell-command:
> >
> >     The optional second argument output-buffer, if non-nil, 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 current buffer.  (This cannot
> >     be done asynchronously.)  In either case, the output is inserted
> >     after point (leaving mark after it).
> 
> Is the following description more precise?
> 
>     The optional second argument OUTPUT-BUFFER, if non-nil,
>     says to put the output in some other buffer.
>     If OUTPUT-BUFFER is a buffer or buffer name, put the output there
>       replacing the old contents of that buffer.
>     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).

Thanks for the quick reply!  Yes, that does make more sense now - but
what if I want to asynchronously insert output into an existing
buffer?  I think it would be more useful if the code was changed to
match the docstring, rather than the other way around :-)

Regards,
Adam



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4891; Package emacs. (Thu, 12 Nov 2009 04:30:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 12 Nov 2009 04:30:08 GMT) Full text and rfc822 format available.

Message #20 received at 4891 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Adam Spiers <bug-gnu-emacs <at> adamspiers.org>
Cc: 4891 <at> debbugs.gnu.org, Juri Linkov <juri <at> jurta.org>
Subject: Re: bug#4891: 23.1; shell-command overwrites whole buffer
Date: Wed, 11 Nov 2009 23:23:44 -0500
> Thanks for the quick reply!  Yes, that does make more sense now - but
> what if I want to asynchronously insert output into an existing
> buffer?

Then switch to that buffer before starting the command and pass t as the
OUTPUT-BUFFER.


        Stefan



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4891; Package emacs. (Thu, 12 Nov 2009 06:50:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kevin Rodgers <kevin.d.rodgers <at> gmail.com>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 12 Nov 2009 06:50:04 GMT) Full text and rfc822 format available.

Message #25 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Kevin Rodgers <kevin.d.rodgers <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Re: bug#4891: 23.1; shell-command overwrites whole buffer
Date: Wed, 11 Nov 2009 23:42:25 -0700
Stefan Monnier wrote:
>> Thanks for the quick reply!  Yes, that does make more sense now - but
>> what if I want to asynchronously insert output into an existing
>> buffer?
> 
> Then switch to that buffer before starting the command and pass t as the
> OUTPUT-BUFFER.

But why is the distinction between append and replace conflated with the
OUTPUT-BUFFER argument in the first place?

-- 
Kevin Rodgers
Denver, Colorado, USA





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4891; Package emacs. (Thu, 12 Nov 2009 09:40:06 GMT) Full text and rfc822 format available.

Acknowledgement sent to Adam Spiers <bug-gnu-emacs <at> adamspiers.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Thu, 12 Nov 2009 09:40:06 GMT) Full text and rfc822 format available.

Message #30 received at 4891 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Adam Spiers <bug-gnu-emacs <at> adamspiers.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 4891 <at> debbugs.gnu.org, Juri Linkov <juri <at> jurta.org>
Subject: Re: bug#4891: 23.1; shell-command overwrites whole buffer
Date: Thu, 12 Nov 2009 09:33:33 +0000
On Wed, Nov 11, 2009 at 11:23:44PM -0500, Stefan Monnier wrote:
> > Thanks for the quick reply!  Yes, that does make more sense now - but
> > what if I want to asynchronously insert output into an existing
> > buffer?
> 
> Then switch to that buffer before starting the command and pass t as the
> OUTPUT-BUFFER.

That's exactly what I tried yesterday - but that's synchronous ...



Reply sent to Chong Yidong <cyd <at> stupidchicken.com>:
You have taken responsibility. (Sat, 14 Nov 2009 16:15:05 GMT) Full text and rfc822 format available.

Notification sent to Adam Spiers <bug-gnu-emacs <at> adamspiers.org>:
bug acknowledged by developer. (Sat, 14 Nov 2009 16:15:05 GMT) Full text and rfc822 format available.

Message #35 received at 4891-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Chong Yidong <cyd <at> stupidchicken.com>
To: Adam Spiers <bug-gnu-emacs <at> adamspiers.org>
Cc: 4891-done <at> debbugs.gnu.org
Subject: Re: 23.1; shell-command overwrites whole buffer
Date: Sat, 14 Nov 2009 11:09:30 -0500
>   M-: (shell-command "date" (get-buffer "*scratch*"))
>
> results in the prior contents of the *scratch* buffer being
> overwritten.  This seems to contradict the last sentence in the
> following paragraph of the docstring for shell-command:
>
>     The optional second argument output-buffer, if non-nil, 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 current buffer.  (This cannot
>     be done asynchronously.)  In either case, the output is inserted
>     after point (leaving mark after it).

Thanks for the bug report.  This is really a documentation bug, because
shell-command has always erased the buffer since the first version of
Emacs, and other code depends on this behavior.  I've amended the
docstring to mention that the buffer is erased.



bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> emacsbugs.donarmstrong.com. (Sun, 13 Dec 2009 15:24:15 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 109 days ago.

Previous Next


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