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

Re: [21.5] call-process-region problem



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

> It is because call-process-region of that version uses
> call-process which inserts the output of a process in the point.
> And it deletes the region which is pointed to by markers, after
> a process is finished.  Markers function rightly.  Therefore,
> they will be erased if the output of a process is inserted
> within limits which markers point to.

Oops!  Using markers is needless if the points aren't changed
while processing.  Here is a new patch:
--- 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.
Probably, another function should be made if Ben wanted to write
that code for the particular purpose.
-- 
Katsumi Yamaoka <yamaoka@jpl.org>