bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#22335: 24.2; Documentation of shell-command-on-region incorrect?


From: Eli Zaretskii
Subject: bug#22335: 24.2; Documentation of shell-command-on-region incorrect?
Date: Sat, 09 Jan 2016 11:49:18 +0200

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]