comparison lisp/code-process.el @ 2356:0b060ef35789

[xemacs-hg @ 2004-10-28 11:31:09 by stephent] fix and tests for call-process-region bug <87fz3z2ic0.fsf_-_@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Thu, 28 Oct 2004 11:31:23 +0000
parents f32f3ddaf534
children 91b3aa59f49b
comparison
equal deleted inserted replaced
2355:61aaa5e258b0 2356:0b060ef35789
163 or a signal description string. If you quit, the process is first killed 163 or a signal description string. If you quit, the process is first killed
164 with SIGINT, then with SIGKILL if you quit again before the process exits. 164 with SIGINT, then with SIGKILL if you quit again before the process exits.
165 165
166 The read/write coding systems used for process I/O on the process are 166 The read/write coding systems used for process I/O on the process are
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
169 ;; a temporary file was used to pass the text to call-process. Now that 169 ;; We can't delete the region before feeding it to `call-process', so we
170 ;; we don't do that, we delete the text afterward; if it's being inserted 170 ;; take care not to delete the insertion when we delete the region. START
171 ;; in the same buffer, make sure we track the insertion, and don't get 171 ;; and END may not be markers; copy them. (point) will end up after the
172 ;; any of it in the deleted region. We keep marker s before the 172 ;; insertion. A copy of (point) tracks the beginning of the insertion.
173 ;; insertion and e afterward. Finally we delete the regions before 173
174 ;; and after the insertion. 174 (let ((s (and deletep (copy-marker start))) ; Only YOU can
175 (let ((s (and deletep (copy-marker (point)))) 175 (e (and deletep (copy-marker end t))) ; prevent
176 (e (and deletep (copy-marker (point) t)))) 176 (p (and deletep (copy-marker (point)))) ; excess consing!
177 (let ((retval 177 (retval
178 (apply #'call-process program (list (current-buffer) start end) 178 (apply #'call-process program (list (current-buffer) start end)
179 buffer displayp args))) 179 buffer displayp args)))
180 ;; If start and end were the same originally, e will be beyond s now 180 (when deletep
181 (when (and deletep (> e s)) 181 (if (<= s p e)
182 ;; APA: Is it always correct to honor narrowing, which affects 182 ;; region was split by insertion
183 ;; (point-min) and (point-max)? 183 ;; the order checks are gilt lilies
184 ;; Delete region before insertion. 184 (progn (when (< (point) e) (delete-region (point) e))
185 (delete-region (point-min) s) 185 (when (< s p) (delete-region s p)))
186 ;; Delete region after insertion. 186 ;; insertion was outside of region
187 (delete-region e (point-max))) 187 (delete-region s e)))
188 retval))) 188 retval))
189 189
190 (defun start-process (name buffer program &rest program-args) 190 (defun start-process (name buffer program &rest program-args)
191 "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.
192 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.
193 BUFFER is the buffer or (buffer-name) to associate with the process. 193 BUFFER is the buffer or (buffer-name) to associate with the process.