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: Mon, 12 Apr 2010 17:02:30 +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 1271086184 30910 80.91.229.12 (12 Apr 2010 15:29:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 12 Apr 2010 15:29:44 +0000 (UTC) Cc: Chong Yidong , 5805@debbugs.gnu.org To: "Stefan Monnier" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Apr 12 17:29:36 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 1O1LZv-0008G2-RP for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Apr 2010 17:29:36 +0200 Original-Received: from localhost ([127.0.0.1]:55284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1LZv-0004oa-53 for geb-bug-gnu-emacs@m.gmane.org; Mon, 12 Apr 2010 11:29:35 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O1LZP-0004a1-6m for bug-gnu-emacs@gnu.org; Mon, 12 Apr 2010 11:29:03 -0400 Original-Received: from [140.186.70.92] (port=35681 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O1LZN-0004Ym-2S for bug-gnu-emacs@gnu.org; Mon, 12 Apr 2010 11:29:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O1LZG-0007xU-JM for bug-gnu-emacs@gnu.org; Mon, 12 Apr 2010 11:29:00 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39632) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1LZG-0007xJ-5q for bug-gnu-emacs@gnu.org; Mon, 12 Apr 2010 11:28:54 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1O1LAE-0007Wr-Hp; Mon, 12 Apr 2010 11:03: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: Mon, 12 Apr 2010 15:03: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.127108456428934 (code B ref 5805); Mon, 12 Apr 2010 15:03:02 +0000 Original-Received: (at 5805) by debbugs.gnu.org; 12 Apr 2010 15:02:44 +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 1O1L9v-0007Wc-B2 for submit@debbugs.gnu.org; Mon, 12 Apr 2010 11:02:43 -0400 Original-Received: from exprod5og103.obsmtp.com ([64.18.0.145]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1L9t-0007WX-GK for 5805@debbugs.gnu.org; Mon, 12 Apr 2010 11:02:42 -0400 Original-Received: from source ([12.71.149.1]) (using TLSv1) by exprod5ob103.postini.com ([64.18.4.12]) with SMTP ID DSNKS8M2C9gAbGR7dDL7ZIhQ6qiAGlzAusjp@postini.com; Mon, 12 Apr 2010 08:02:41 PDT Original-Received: from unknown (HELO alpmlef01.e2k.ad.ge.com) ([3.159.18.10]) by Cinmlip06.e2k.ad.ge.com with ESMTP; 12 Apr 2010 11:02:34 -0400 Original-Received: from BUDMLVEM09.e2k.ad.ge.com ([3.159.52.69]) by alpmlef01.e2k.ad.ge.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 12 Apr 2010 11:02:34 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: bug#5805: 23.1; abbrev-insert does not protext itself with save-excursion Thread-Index: AcraRHOmsrXZIikTTsuW1xRCHE/fCgACqqgQ X-OriginalArrivalTime: 12 Apr 2010 15:02:34.0206 (UTC) FILETIME=[2E92CFE0:01CADA51] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 12 Apr 2010 11:03: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:36208 Archived-At: The workaround I have locally is using advice to place a save-excursion around the non-interactive function abbrev-insert. Please check to see whether abbrev-insert should be allowed to not preserve point. ;; 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." (save-excursion ad-do-it))) Thanks for your prompt replies :-) Andrew -----Original Message----- From: Stefan Monnier [mailto:monnier@iro.umontreal.ca]=20 Sent: 12 April 2010 14:31 To: Maguire, Andrew (GE Infra, Energy) Cc: Chong Yidong; 5805@debbugs.gnu.org Subject: Re: bug#5805: 23.1; abbrev-insert does not protext itself with save-excursion > I do appreciate the need for some abbrevs to move point and that I am > reporting a perceived change in behaviour. > However, the question is whether the change in behaviour is deliberate > or not. The change was not deliberate, no. > If a user wishes to create an abbrev that requires point to move > presumably they have to create the abbrev in a certain way. > The example you give below would still require user code to move point > to between the LaTeX statements. > i.e If I created a simple global abbrev to expand "begi" point would be > left after the \end{itemize}^ Yes, the abbrev would need to be defined differently, but the point-movement would be done by the abbrev itself, i.e. the caller would still just call expand-abbrev. > So how should I fix my code that uses expand-abbrev to work in Emacs 23? > It currently works as is in Emacs 20, 21 and 22. I think you need to add a save-excursion around the call to expand-abbrev to make it clear that you don't want this call to move point. This will also save you in the case where the user has setup an abbrev like "begi", which is a case that could also happen in previous Emacsen. But that really depends on what behavior you expect in the case where your code encounters a "begi"-like abbrev. Stefan > Thanks, > Andrew > -----Original Message----- > From: Stefan Monnier [mailto:monnier@iro.umontreal.ca]=20 > Sent: 10 April 2010 20:10 > To: Maguire, Andrew (GE Infra, Energy) > Cc: Chong Yidong; 5805@debbugs.gnu.org > Subject: Re: bug#5805: 23.1; abbrev-insert does not protext itself with > save-excursion >> 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. > Right. The question now is: why is that a problem? > I ask because for some abbrevs, moving point isa feature, e.g. an abbrev > that uses skeletons to expand > begi > ^ > into > \begin{itemize} \end{itemize} > ^ > so maybe the problem is that your code makes unwarranted assumptions > about what abbrevs can do, or maybe your code knows that it won't > encounter such abbreviations or that it wouldn't care about their > point-placement feature, so it could/should use save-excursion. >> ;; Emacs 23 has a lisp implementation for abbrevs. > BTW, the problem is not that the implementation is in Lisp, but that it > behaves differently. > Stefan