comparison lisp/code-process.el @ 1978:f32f3ddaf534

[xemacs-hg @ 2004-04-03 20:00:24 by adrian] [PATCH] xemacs-21.5: Proposed fix for `call-process-region' bug <isgwwgt3.fsf@smtpmail.t-online.de>
author adrian
date Sat, 03 Apr 2004 20:00:26 +0000
parents 13305f7e85f0
children 0b060ef35789
comparison
equal deleted inserted replaced
1977:1a5f3b515d03 1978:f32f3ddaf534
167 the same as for `call-process'." 167 the same as for `call-process'."
168 ;; We used to delete the text before calling call-process; that was when 168 ;; We used to delete the text before calling call-process; that was when
169 ;; a temporary file was used to pass the text to call-process. Now that 169 ;; a temporary file was used to pass the text to call-process. Now that
170 ;; we don't do that, we delete the text afterward; if it's being inserted 170 ;; we don't do that, we delete the text afterward; if it's being inserted
171 ;; in the same buffer, make sure we track the insertion, and don't get 171 ;; in the same buffer, make sure we track the insertion, and don't get
172 ;; any of it in the deleted region if insertion happens at either end 172 ;; any of it in the deleted region. We keep marker s before the
173 ;; of the region. 173 ;; insertion and e afterward. Finally we delete the regions before
174 (let ((s (and deletep (copy-marker start t))) 174 ;; and after the insertion.
175 (e (and deletep (copy-marker end)))) 175 (let ((s (and deletep (copy-marker (point))))
176 (e (and deletep (copy-marker (point) t))))
176 (let ((retval 177 (let ((retval
177 (apply #'call-process program (list (current-buffer) start end) 178 (apply #'call-process program (list (current-buffer) start end)
178 buffer displayp args))) 179 buffer displayp args)))
179 ;; If start and end were the same originally, s will be beyond e now 180 ;; If start and end were the same originally, e will be beyond s now
180 (if (and deletep (> e s)) 181 (when (and deletep (> e s))
181 (delete-region s e)) 182 ;; APA: Is it always correct to honor narrowing, which affects
183 ;; (point-min) and (point-max)?
184 ;; Delete region before insertion.
185 (delete-region (point-min) s)
186 ;; Delete region after insertion.
187 (delete-region e (point-max)))
182 retval))) 188 retval)))
183 189
184 (defun start-process (name buffer program &rest program-args) 190 (defun start-process (name buffer program &rest program-args)
185 "Start a program in a subprocess. Return the process object for it. 191 "Start a program in a subprocess. Return the process object for it.
186 NAME is name for process. It is modified if necessary to make it unique. 192 NAME is name for process. It is modified if necessary to make it unique.