GNU bug report logs - #5805
23.1; abbrev-insert does not protext itself with save-excursion

Previous Next

Package: emacs;

Reported by: "Maguire, Andrew (GE Infra, Energy)" <andrew.maguire <at> ge.com>

Date: Tue, 30 Mar 2010 16:37:02 UTC

Severity: normal

Tags: patch

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #31 received at 5805 <at> debbugs.gnu.org (full text, mbox):

From: Bob Nnamtrop <bobnnamtrop <at> gmail.com>
To: 5805 <at> debbugs.gnu.org
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)




This bug report was last modified 13 years and 322 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.