From 1449012d63a2c88424625a24198f092173b3f542 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Sun, 4 Nov 2007 02:57:52 +0000 Subject: [PATCH] (expand-abbrev): Move point back to expansion's end. --- lisp/ChangeLog | 12 ++++++++---- lisp/abbrev.el | 11 ++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 97cb6f7425a..4964ad5732e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,7 @@ +2007-11-04 Stefan Monnier + + * abbrev.el (expand-abbrev): Move point back to expansion's end. + 2007-11-04 Glenn Morris * net/tls.el: Don't require rx when compiling. @@ -18,8 +22,8 @@ 2007-11-03 Michael Olson - * textmodes/remember.el (remember-buffer): Use - define-obsolete-function-alias rather than defalias. + * textmodes/remember.el (remember-buffer): + Use define-obsolete-function-alias rather than defalias. 2007-11-03 Ulrich Mueller (tiny change) @@ -35,8 +39,8 @@ uncomment-region-function and comment-insert-comment-function. (fortran-uncomment-region): New function. - * textmodes/nroff-mode.el (nroff-mode): Set - comment-insert-comment-function rather than indent-line-function. + * textmodes/nroff-mode.el (nroff-mode): + Set comment-insert-comment-function rather than indent-line-function. (nroff-indent-line-function): Remove. (nroff-insert-comment-function): New function. diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 87a31df8112..74a0bbf29b9 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -753,9 +753,11 @@ Returns the abbrev symbol, if expansion took place." ;; If this abbrev has an expansion, delete the abbrev ;; and insert the expansion. (when (stringp (symbol-value sym)) - (goto-char wordend) + (goto-char wordstart) + ;; Insert at beginning so that markers at the end (e.g. point) + ;; are preserved. (insert (symbol-value sym)) - (delete-region wordstart wordend) + (delete-char (- wordend wordstart)) (let ((case-fold-search nil)) ;; If the abbrev's name is different from the buffer text (the ;; only difference should be capitalization), then we may want @@ -778,7 +780,10 @@ Returns the abbrev symbol, if expansion took place." (goto-char wordstart) (skip-syntax-forward "^w" (1- end)) ;; Change just that. - (upcase-initials-region (point) (1+ (point)))))))) + (upcase-initials-region (point) (1+ (point))) + (goto-char end)))))) + ;; Now point is at the end of the expansion and the beginning is + ;; in last-abbrev-location. (when (symbol-function sym) (let* ((hook (symbol-function sym)) (expanded -- 2.39.2