* Problematic unexpand-abbrev behavior: 23.X
@ 2008-06-04 22:22 JD Smith
2008-06-05 5:12 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: JD Smith @ 2008-06-04 22:22 UTC (permalink / raw)
To: emacs-devel
Consider:
(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. This
impacts modes which unexpand abbrevs during the abbrev hook in quoted
text or comments, where they shouldn't be expanded.
JD
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Problematic unexpand-abbrev behavior: 23.X
2008-06-04 22:22 Problematic unexpand-abbrev behavior: 23.X JD Smith
@ 2008-06-05 5:12 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2008-06-05 5:12 UTC (permalink / raw)
To: JD Smith; +Cc: emacs-devel
> (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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-06-05 5:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-04 22:22 Problematic unexpand-abbrev behavior: 23.X JD Smith
2008-06-05 5:12 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).