+1999-12-28 Richard M. Stallman <rms@caffeine.ai.mit.edu>
+
+ * textmodes/ispell.el (ispell-process-line):
+ Add local var line-offset to adjust for the change
+ in positions within the line, due to previous replacements.
+
1999-12-27 Richard M. Stallman <rms@caffeine.ai.mit.edu>
* lpr.el (lpr-buffer, print-buffer, lpr-region, print-region):
(defun ispell-process-line (string)
;;(declare special start end)
- (let (poss)
+ (let (poss
+ ;; line-offset is the change so far in the size of the line.
+ ;; The position values we get from ispell reflect the original
+ ;; text, and correction of previous words may have shifted the
+ ;; current word within the line.
+ (line-offset 0))
;; send string to spell process and get input.
(process-send-string ispell-process string)
(while (progn
;; Markers can move with highlighting! This destroys
;; end of region markers line-end and ispell-region-end
(let ((word-start
- (copy-marker (+ start ispell-offset (car (cdr poss)))))
+ (copy-marker (+ start ispell-offset line-offset
+ (car (cdr poss)))))
(word-len (length (car poss)))
(line-end (copy-marker end))
(line-start (copy-marker start))
recheck-region t)
(delete-region (point) (+ word-len (point)))
(insert (car replace))
+ (setq line-offset (+ line-offset (- line-end end)))
;; Only typed-in replacements need to be re-checked.
(if (not (eq 'query-replace (car (cdr replace))))
(backward-char (length (car replace))))
(replace ; STRING REPLACEMENT for this word.
(delete-region (point) (+ word-len (point)))
(insert replace)
+ (setq line-offset (+ line-offset (- line-end end)))
+
(set-marker line-start (+ line-start
(- (length replace)
(length (car poss)))))))