all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Maguire, Andrew (GE Infra, Energy)" <andrew.maguire@ge.com>
To: "Chong Yidong" <cyd@stupidchicken.com>
Cc: 5805@debbugs.gnu.org
Subject: bug#5805: 23.1; abbrev-insert does not protext itself with save-excursion
Date: Sat, 10 Apr 2010 19:06:46 +0200	[thread overview]
Message-ID: <A6A1CC87D715C143988ED94326B583D301F7B5AD@BUDMLVEM09.e2k.ad.ge.com> (raw)
In-Reply-To: <87vdbzjnuq.fsf@stupidchicken.com>

Create a global abbrev, abbrv => abbrev

Type the following, ^ indicating point location.

  abbrv ()
          ^
Then press C-x ' to expand the abbrev on the line.
  abbrev ()
        ^
Observe that point ^ is now before the ()s.
In the C version of abbrev expansion in all earlier Emacsen, point is
not affected by expansion,
i.e. it would be left after the ()s which is where the user pressed C-x
'

My current fix is 
;; Emacs 23 has a lisp implementation for abbrevs.
(if (fboundp 'abbrev-insert)
    (defadvice abbrev-insert (around
save-excursion-around-advice-insertion activate)
      "Lisp implementation of advice insertion does not save point
location afterwards.
When looking back over non-word characters to find a word that may be an
abbreviation
if it finds something to replace, it does not save its position."
      (save-excursion
	ad-do-it)))

Thanks,
Andrew


-----Original Message-----
From: Chong Yidong [mailto:cyd@stupidchicken.com] 
Sent: 10 April 2010 17:04
To: Maguire, Andrew (GE Infra, Energy)
Cc: 5805@debbugs.gnu.org
Subject: Re: 23.1; abbrev-insert does not protext itself with
save-excursion

> In our code we use abbrev to dynamically expand certain
> keywords. However, the new lisp implementation is more eager in
> finding things to check, ie. it is able to look back past non-word
> characters to see if an abbrev is to be found.  In this situation it
> is essential to do save-excursion.
>
> Ideally, either insert-abbrev should do a save-excursion itself or all
> calls to it should.  In our code, expand-abbrev is call which
> internally calls abbrev-insert.
>
> Alternatively, is it the recommendation for user code to surround all
> "abbrev" calls with save-excursion now?

Do you have a recipe for reproducing a bug?  By default, the abbrev code
is not supposed to change point, so there should be no advantage adding
a save-excursion.  I don't see why we should constrain the ability of
user-defined functions in `abbrev-expand-functions' to change point, if
they want to.

Or do you mean save-match-data?






  reply	other threads:[~2010-04-10 17:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201003291206.NAA17706@ultimate.Smallworld.co.uk>
2010-03-30 16:33 ` bug#5805: Returned mail: Cannot send message within 3 days Maguire, Andrew (GE Infra, Energy)
2010-04-10 16:04   ` bug#5805: 23.1; abbrev-insert does not protext itself with save-excursion Chong Yidong
2010-04-10 17:06     ` Maguire, Andrew (GE Infra, Energy) [this message]
2010-04-10 19:10       ` Stefan Monnier
2010-04-12 11:28         ` Maguire, Andrew (GE Infra, Energy)
2010-04-12 13:31           ` Stefan Monnier
2010-04-12 15:02             ` Maguire, Andrew (GE Infra, Energy)
2010-04-12 18:13               ` Stefan Monnier
2011-07-07 14:48   ` bug#5805: 23.3 abbrev-insert needs a limited save-excursion Bob Nnamtrop
2011-07-07 20:59     ` Stefan Monnier
2011-07-07 21:46       ` Bob Nnamtrop
2011-07-08  0:02         ` Bob Nnamtrop
2011-07-08  1:03           ` Stefan Monnier
2011-07-08 14:43     ` Stefan Monnier

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

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

  git send-email \
    --in-reply-to=A6A1CC87D715C143988ED94326B583D301F7B5AD@BUDMLVEM09.e2k.ad.ge.com \
    --to=andrew.maguire@ge.com \
    --cc=5805@debbugs.gnu.org \
    --cc=cyd@stupidchicken.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.