From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Maguire, Andrew (GE Infra, Energy)" Newsgroups: gmane.emacs.bugs Subject: bug#5805: 23.1; abbrev-insert does not protext itself with save-excursion Date: Sat, 10 Apr 2010 19:06:46 +0200 Message-ID: References: <87vdbzjnuq.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1270920570 13608 80.91.229.12 (10 Apr 2010 17:29:30 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 10 Apr 2010 17:29:30 +0000 (UTC) Cc: 5805@debbugs.gnu.org To: "Chong Yidong" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 10 19:29:27 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O0eUk-0005OK-Pu for geb-bug-gnu-emacs@m.gmane.org; Sat, 10 Apr 2010 19:29:23 +0200 Original-Received: from localhost ([127.0.0.1]:43825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O0eUe-0007sJ-Nq for geb-bug-gnu-emacs@m.gmane.org; Sat, 10 Apr 2010 13:29:16 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O0eUD-0007d7-1C for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2010 13:28:49 -0400 Original-Received: from [140.186.70.92] (port=36422 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O0eUA-0007bL-G8 for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2010 13:28:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O0eU8-0004ZJ-Vo for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2010 13:28:46 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:48059) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0eU8-0004ZB-TK for bug-gnu-emacs@gnu.org; Sat, 10 Apr 2010 13:28:44 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1O0e98-0002hI-6E; Sat, 10 Apr 2010 13:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Maguire, Andrew (GE Infra, Energy)" Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Apr 2010 17:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5805 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5805-submit@debbugs.gnu.org id=B5805.127091921610362 (code B ref 5805); Sat, 10 Apr 2010 17:07:02 +0000 Original-Received: (at 5805) by debbugs.gnu.org; 10 Apr 2010 17:06:56 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0e92-0002h5-7A for submit@debbugs.gnu.org; Sat, 10 Apr 2010 13:06:56 -0400 Original-Received: from exprod5og106.obsmtp.com ([64.18.0.182]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0e90-0002h0-On for 5805@debbugs.gnu.org; Sat, 10 Apr 2010 13:06:55 -0400 Original-Received: from source ([12.71.149.1]) (using TLSv1) by exprod5ob106.postini.com ([64.18.4.12]) with SMTP ID DSNKS8CwK75YTUBmxkLJZddazhk/ZAiFUdHb@postini.com; Sat, 10 Apr 2010 10:06:57 PDT Original-Received: from unknown (HELO ALPMLEF02.e2k.ad.ge.com) ([3.159.18.11]) by Cinmlip07.e2k.ad.ge.com with ESMTP; 10 Apr 2010 13:06:50 -0400 Original-Received: from BUDMLVEM09.e2k.ad.ge.com ([3.159.52.69]) by ALPMLEF02.e2k.ad.ge.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 10 Apr 2010 13:06:50 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message In-Reply-To: <87vdbzjnuq.fsf@stupidchicken.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: 23.1; abbrev-insert does not protext itself with save-excursion Thread-Index: AcrYx3ze7M1jXnCBRkeUpfdyX0PpwAABlH7A X-OriginalArrivalTime: 10 Apr 2010 17:06:50.0828 (UTC) FILETIME=[363D88C0:01CAD8D0] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 10 Apr 2010 13:07:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:36165 Archived-At: Create a global abbrev, abbrv =3D> 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=20 ;; 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]=20 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?