bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#5805: 23.3 abbrev-insert needs a limited save-excursion


From: Bob Nnamtrop
Subject: bug#5805: 23.3 abbrev-insert needs a limited save-excursion
Date: Thu, 7 Jul 2011 08:48:36 -0600

I agree with the original poster that a save-excursion is needed in
abbrev-expand and by making its scope limited (see below) it will not
interfere with abbrevs that want to change point. The reason I find it
annoying the way it is now is that some modes (e.g., idlwave) use
abbrev's extensively to change keywords (e.g. capitalize them). These
are defined without the leading "\". So if I am any number of lines
with only whitespace below a keyword defined in this way (e.g. endfor)
and run expand-abbrev then the point moves even if no visible change
takes place. This is a VERY common occurrence for me since in viper
mode changing from insert to vi mode runs expand-abbrev! Placing the
save-excursion just around the part of abbrev-insert that actually
expands the abbrev fixes this problem and does not limit abbrev's from
moving the point (idlwave does this extensively as well and I've
tested that it is not impacted). Here is the diff against the
abbrev.el in emacs 23.3 (note that whitespace not adjusted).

Thanks much,
Bob

--- 23.3/abbrev.el      2011-07-07 08:16:16.000000000 -0600
+++ 23.3.fix/abbrev.el  2011-07-07 08:43:24.000000000 -0600
@@ -713,6 +713,7 @@
     ;; If this abbrev has an expansion, delete the abbrev
     ;; and insert the expansion.
     (when (stringp (symbol-value abbrev))
+      (save-excursion
       (goto-char wordstart)
       ;; Insert at beginning so that markers at the end (e.g. point)
       ;; are preserved.
@@ -741,7 +742,7 @@
               (skip-syntax-forward "^w" (1- end))
               ;; Change just that.
               (upcase-initials-region (point) (1+ (point)))
-              (goto-char end))))))
+              (goto-char end)))))))
     ;; Now point is at the end of the expansion and the beginning is
     ;; in last-abbrev-location.
     (when (symbol-function abbrev)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]