emacs-devel
[Top][All Lists]
Advanced

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

Re: Problematic unexpand-abbrev behavior: 23.X


From: Stefan Monnier
Subject: Re: Problematic unexpand-abbrev behavior: 23.X
Date: Thu, 05 Jun 2008 01:12:02 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>       (define-abbrev global-abbrev-table "foo" "bar"
>                      (lambda () (unexpand-abbrev)))

> unexpand-abbrev in this context has a different behavior from 22.2 to 23.X.
> The latter incorrectly leaves point before the expanded (and  subsequently
> unexpanded) text.  At some point, unexpand-abbrev was re- 
> implemented in lisp, and its save-excursion seems to cause this.

I've installed the patch below which should fix it.

> This impacts modes which unexpand abbrevs during the abbrev hook in quoted
> text or comments, where they shouldn't be expanded.

Note that part of the motivation for the rewrite was to eliminate the
need for such hacks.  E.g. abbrev-tables (and individual abbrevs) can
now be enabled/disabled dynamically, using the :enable-function property.
E.g. python.el sets it to (lambda () (not (python-in-string/comment)).


        Stefan


--- abbrev.el.~1.75.~   2008-05-11 17:49:13.000000000 -0400
+++ abbrev.el   2008-06-05 01:06:08.000000000 -0400
@@ -824,10 +824,11 @@
         ;; to do the expansion.
         (let ((val (symbol-value last-abbrev)))
           (unless (stringp val)
-            (error "value of abbrev-symbol must be a string"))
-          (delete-region (point) (+ (point) (length val)))
+            (error "Value of abbrev-symbol must be a string"))
           ;; Don't inherit properties here; just copy from old contents.
           (insert last-abbrev-text)
+          ;; Delete after inserting, to better preserve markers.
+          (delete-region (point) (+ (point) (length val)))
           (setq last-abbrev-text nil))))))
 
 (defun abbrev--write (sym)




reply via email to

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