aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2011-07-08 10:42:36 -0400
committerStefan Monnier2011-07-08 10:42:36 -0400
commit856b2f11d8373374d9ddf7e89f6512b39e4071e3 (patch)
tree782a4b069af15cfe8a2bbc4b26115069f2cf51b5
parentafae1d6821cbc2bf97c27fe99ec75ca9d40fd458 (diff)
downloademacs-856b2f11d8373374d9ddf7e89f6512b39e4071e3.tar.gz
emacs-856b2f11d8373374d9ddf7e89f6512b39e4071e3.zip
* lisp/abbrev.el (expand-abbrev): Try to preserve point.
Fixes: debbugs:5805
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/abbrev.el35
2 files changed, 26 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0c912db74d9..4a9dd27b840 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12011-07-08 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * abbrev.el (expand-abbrev): Try to preserve point (bug#5805).
4
12011-07-08 Michael Albinus <michael.albinus@gmx.de> 52011-07-08 Michael Albinus <michael.albinus@gmx.de>
2 6
3 * net/tramp-sh.el (tramp-sh-handle-start-file-process): Use a 7 * net/tramp-sh.el (tramp-sh-handle-start-file-process): Use a
diff --git a/lisp/abbrev.el b/lisp/abbrev.el
index 2122f43bbad..3795dd46010 100644
--- a/lisp/abbrev.el
+++ b/lisp/abbrev.el
@@ -814,19 +814,28 @@ Returns the abbrev symbol, if expansion took place."
814 (destructuring-bind (&optional sym name wordstart wordend) 814 (destructuring-bind (&optional sym name wordstart wordend)
815 (abbrev--before-point) 815 (abbrev--before-point)
816 (when sym 816 (when sym
817 (unless (or ;; executing-kbd-macro 817 (let ((startpos (copy-marker (point) t))
818 noninteractive 818 (endmark (copy-marker wordend t)))
819 (window-minibuffer-p (selected-window))) 819 (unless (or ;; executing-kbd-macro
820 ;; Add an undo boundary, in case we are doing this for 820 noninteractive
821 ;; a self-inserting command which has avoided making one so far. 821 (window-minibuffer-p (selected-window)))
822 (undo-boundary)) 822 ;; Add an undo boundary, in case we are doing this for
823 ;; Now sym is the abbrev symbol. 823 ;; a self-inserting command which has avoided making one so far.
824 (setq last-abbrev-text name) 824 (undo-boundary))
825 (setq last-abbrev sym) 825 ;; Now sym is the abbrev symbol.
826 (setq last-abbrev-location wordstart) 826 (setq last-abbrev-text name)
827 ;; If this abbrev has an expansion, delete the abbrev 827 (setq last-abbrev sym)
828 ;; and insert the expansion. 828 (setq last-abbrev-location wordstart)
829 (abbrev-insert sym name wordstart wordend))))) 829 ;; If this abbrev has an expansion, delete the abbrev
830 ;; and insert the expansion.
831 (prog1
832 (abbrev-insert sym name wordstart wordend)
833 ;; Yuck!! If expand-abbrev is called with point slightly
834 ;; further than the end of the abbrev, move point back to
835 ;; where it started.
836 (if (and (> startpos endmark)
837 (= (point) endmark)) ;Obey skeletons that move point.
838 (goto-char startpos))))))))
830 839
831(defun unexpand-abbrev () 840(defun unexpand-abbrev ()
832 "Undo the expansion of the last abbrev that expanded. 841 "Undo the expansion of the last abbrev that expanded.