unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: JD Smith <jdtsmith@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Problematic unexpand-abbrev behavior: 23.X
Date: Thu, 05 Jun 2008 01:12:02 -0400	[thread overview]
Message-ID: <jwvwsl4eah5.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <A13253E3-9059-4B0A-9FD7-35F451AC1351@gmail.com> (JD Smith's message of "Wed, 4 Jun 2008 18:22:57 -0400")

> 	(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	other threads:[~2008-06-05  5:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-04 22:22 Problematic unexpand-abbrev behavior: 23.X JD Smith
2008-06-05  5:12 ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvwsl4eah5.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=jdtsmith@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).