changeset 72130:c7889d24e9d7

(ispell-word): If we replace the word, move point to the end. Insert before deleting.
author Richard M. Stallman <rms@gnu.org>
date Wed, 26 Jul 2006 17:11:07 +0000
parents b5439b7a1ef1
children 3cc6bfe3a15d
files lisp/textmodes/ispell.el
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/ispell.el	Wed Jul 26 09:55:10 2006 +0000
+++ b/lisp/textmodes/ispell.el	Wed Jul 26 17:11:07 2006 +0000
@@ -1650,9 +1650,15 @@
 					     cursor-location))
 		    (if (not (equal new-word (car poss)))
 			(progn
-			  (delete-region start end)
-			  (setq start (point))
+			  (goto-char start)
+			  ;; Insert first and then delete,
+			  ;; to avoid collapsing markers before and after
+			  ;; into a single place.
 			  (ispell-insert-word new-word)
+			  (delete-region (point) (+ (point) (- end start)))
+			  ;; It is meaningless to preserve the cursor position
+			  ;; inside a word that has changed.
+			  (setq cursor-location (point))
 			  (setq end (point))))
 		    (if (not (atom replace)) ;recheck spelling of replacement
 			(progn