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

Re: [21.5] call-process-region problem



Ben?

>>>>> "KY" == Katsumi Yamaoka <yamaoka@jpl.org> writes:

Maintainers,
Could you please clarify whether it is a bug or specification?
If it is not a bug, it is necessary to add notes, isn't it?

>>>>> In <b9y65hez0yf.fsf@jpl.org> Katsumi Yamaoka wrote:

> Hi,

> Although it may be a known problem, I think it is evil that the
> call-process-region function requires the point to have to be in
> the beginning or the end position when the 4th arg DELETEP is t.
> It simply erases the buffer's contents when that requirement is
> not satisfied.  For instance:

> (with-temp-buffer
>   (insert "Hello World")
>   (goto-char 2)
>   (call-process-region (point-min) (point-max) "cat" t t)
>   (buffer-string))
>  => ""

> Such an accident does not happen in Emacs or XEmacs 21.4.

>>>>> In <b9y7k1uqaz3.fsf@jpl.org>  Katsumi Yamaoka wrote:

--- code-process.el~	2002-11-10 22:07:29 +0000
+++ code-process.el	2003-11-21 10:14:54 +0000
@@ -171,15 +171,13 @@
   ;; in the same buffer, make sure we track the insertion, and don't get
   ;; any of it in the deleted region if insertion happens at either end
   ;; of the region.
-  (let ((s (and deletep (copy-marker start t)))
-	(e (and deletep (copy-marker end))))
-    (let ((retval
-	   (apply #'call-process program (list (current-buffer) start end)
-		  buffer displayp args)))
-      ;; If start and end were the same originally, s will be beyond e now
-      (if (and deletep (> e s))
-	  (delete-region s e))
-      retval)))
+  (if deletep
+      (goto-char end))
+  (prog1
+      (apply #'call-process program (list (current-buffer) start end)
+	     buffer displayp args)
+    (if deletep
+	(delete-region start end))))

 (defun start-process (name buffer program &rest program-args)
   "Start a program in a subprocess.  Return the process object for it.


-- 
Institute of Policy and Planning Sciences     http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.