1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-03 11:33:37 +00:00

(ispell-process-line): Add local var line-offset to adjust for the change

in positions within the line, due to previous replacements.
This commit is contained in:
Richard M. Stallman 1999-12-28 05:37:52 +00:00
parent d7e110e479
commit 2765768780
2 changed files with 17 additions and 2 deletions

View File

@ -1,3 +1,9 @@
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):

View File

@ -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)))))))