From: Richard M. Stallman Date: Tue, 28 Dec 1999 05:37:52 +0000 (+0000) Subject: (ispell-process-line): Add local var line-offset to adjust for the change X-Git-Tag: emacs-pretest-21.0.90~5616 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2765768780bdde267d82ad59496b12b492871eb3;p=emacs.git (ispell-process-line): Add local var line-offset to adjust for the change in positions within the line, due to previous replacements. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 848346086ef..3b6c66175b4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +1999-12-28 Richard M. Stallman + + * 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 * lpr.el (lpr-buffer, print-buffer, lpr-region, print-region): diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 4f7c7e1288e..691c29b5d18 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -2252,7 +2252,12 @@ otherwise, the current line is skipped." (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 @@ -2270,7 +2275,8 @@ otherwise, the current line is skipped." ;; 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)) @@ -2323,6 +2329,7 @@ otherwise, the current line is skipped." 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)))) @@ -2355,6 +2362,8 @@ otherwise, the current line is skipped." (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)))))))