unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Hilfinger@CS.Berkeley.EDU
Cc: 22335@debbugs.gnu.org
Subject: bug#22335: 24.2; Documentation of shell-command-on-region incorrect?
Date: Sat, 09 Jan 2016 11:49:18 +0200	[thread overview]
Message-ID: <83d1tbnkv5.fsf@gnu.org> (raw)
In-Reply-To: <13699.1452311051@tully.CS.Berkeley.EDU> (message from Paul Hilfinger on Fri, 08 Jan 2016 19:44:11 -0800)

> Date: Fri, 08 Jan 2016 19:44:11 -0800
> From: Paul Hilfinger <hilfingr@eecs.berkeley.edu>
> 
> The current documentation for shell-command-on-region says that 
> 
>     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.
> 
> This seems to suggest that if REPLACE is nil, the initial contents of
> OUTPUT-BUFFER are retained.  However, this does not seem to be the
> behavior of the command at all.  Indeed, in the defun for
> shell-command-on-region, there appears:
> 
>     (if (or replace
> 	    (and output-buffer
> 		 (not (or (bufferp output-buffer) (stringp output-buffer)))))
> 	;; Replace specified region with output from command.
> 	(let ((swap (and replace (< start end))))
> 	  ;; Don't muck with mark unless REPLACE says we should.
> 	  (goto-char start)
> 	  (and replace (push-mark (point) 'nomsg))
> 	  (setq exit-status
> 		(call-process-region start end shell-file-name t
> 				     (if error-file
> 					 (list t error-file)
> 				       t)
> 				     nil shell-command-switch command))
> 
> which would indeed seem to delete the existing text unconditionally.

The argument 't' to call-process-region was changed to 'replace' in
Emacs 24.4, so this appears to be fixed already.  I suggest to upgrade
to a newer Emacs version.

Thanks.





      reply	other threads:[~2016-01-09  9:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-09  3:44 bug#22335: 24.2; Documentation of shell-command-on-region incorrect? Paul Hilfinger
2016-01-09  9:49 ` Eli Zaretskii [this message]

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=83d1tbnkv5.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=22335@debbugs.gnu.org \
    --cc=Hilfinger@CS.Berkeley.EDU \
    /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.
Code repositories for project(s) associated with this public inbox

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

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