From unknown Sat Jun 21 10:19:28 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#5805 <5805@debbugs.gnu.org> To: bug#5805 <5805@debbugs.gnu.org> Subject: Status: 23.1; abbrev-insert does not protext itself with save-excursion Reply-To: bug#5805 <5805@debbugs.gnu.org> Date: Sat, 21 Jun 2025 17:19:28 +0000 retitle 5805 23.1; abbrev-insert does not protext itself with save-excursion reassign 5805 emacs submitter 5805 "Maguire, Andrew (GE Infra, Energy)" severity 5805 normal tag 5805 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 30 12:36:53 2010 Received: (at submit) by debbugs.gnu.org; 30 Mar 2010 16:36:53 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NweQu-0002R6-7p for submit@debbugs.gnu.org; Tue, 30 Mar 2010 12:36:53 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NweNf-0002Ov-Dp for submit@debbugs.gnu.org; Tue, 30 Mar 2010 12:33:32 -0400 Received: from lists.gnu.org ([199.232.76.165]:45571) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NweNa-0007qU-Ej for submit@debbugs.gnu.org; Tue, 30 Mar 2010 12:33:26 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NweNZ-0006g6-KR for bug-gnu-emacs@gnu.org; Tue, 30 Mar 2010 12:33:25 -0400 Received: from [140.186.70.92] (port=32821 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NweNX-0006ca-MK for bug-gnu-emacs@gnu.org; Tue, 30 Mar 2010 12:33:25 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NweNT-0003za-EP for bug-gnu-emacs@gnu.org; Tue, 30 Mar 2010 12:33:22 -0400 Received: from exprod5og105.obsmtp.com ([64.18.0.180]:38999) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NweNS-0003yX-V1 for bug-gnu-emacs@gnu.org; Tue, 30 Mar 2010 12:33:19 -0400 Received: from source ([4.78.218.129]) (using TLSv1) by exprod5ob105.postini.com ([64.18.4.12]) with SMTP ID DSNKS7InylppJy+x53knoGUbXlvAP0TrqP9d@postini.com; Tue, 30 Mar 2010 09:33:18 PDT Received: from unknown (HELO alpmlef08.e2k.ad.ge.com) ([3.159.18.17]) by Cinmlip08.e2k.ad.ge.com with ESMTP; 30 Mar 2010 12:33:10 -0400 Received: from BUDMLVEM09.e2k.ad.ge.com ([3.159.52.69]) by alpmlef08.e2k.ad.ge.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 30 Mar 2010 12:33:09 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Subject: RE: Returned mail: Cannot send message within 3 days Date: Tue, 30 Mar 2010 18:33:07 +0200 Message-ID: In-Reply-To: <201003291206.NAA17706@ultimate.Smallworld.co.uk> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Returned mail: Cannot send message within 3 days Thread-Index: AcrPOwh0mgJbrNgNTTGQF1AbaTzuTwA65cJA References: <201003291206.NAA17706@ultimate.Smallworld.co.uk> From: "Maguire, Andrew (GE Infra, Energy)" To: X-OriginalArrivalTime: 30 Mar 2010 16:33:09.0918 (UTC) FILETIME=[AF23E3E0:01CAD026] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Tue, 30 Mar 2010 12:36:50 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.3 (-----) Try again... -----Original Message----- From: Mail Delivery Subsystem [mailto:Mailer-Daemon@Smallworld.co.uk]=20 Sent: 29 March 2010 13:07 To: andrewma@Smallworld.co.uk Subject: Returned mail: Cannot send message within 3 days The original message was received at Fri, 26 Mar 2010 12:06:32 +0100 (BST) from shark [193.128.11.12] ----- The following addresses had permanent fatal errors ----- ----- Transcript of session follows ----- ... while talking to eggs.gnu.org.: >>> RCPT To: <<< 451 Could not complete sender verify callout ... Deferred: 451 Could not complete sender verify callout Message could not be delivered for 3 days Message will be deleted from queue ----- Original message follows ----- Return-Path: Received: from MAGUIRAN-CBG.smallworld.co.uk by ultimate.Smallworld.co.uk (8.8.8+Sun/SWW-2.8-Gateway) id MAA03728; Fri, 26 Mar 2010 12:06:32 GMT Date: Fri, 26 Mar 2010 12:25:49 +0000 Message-Id: From: andrew.maguire@ge.com To: bug-gnu-emacs@gnu.org Subject: 23.1; abbrev-insert does not protext itself with save-excursion Reply-to: andrew.maguire@ge.com I believe there is a regression/change of behaviour with the lisp implementation of the abbrev package compared with earlier Emacsen. 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? Thanks for you advice, Andrwe Maguire In GNU Emacs 23.1.1 (i386-mingw-nt5.1.2600) of 2009-07-30 on SOFT-MJASON Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (4.4)' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: ENG value of $XMODIFIERS: nil locale-coding-system: cp1252 default-enable-multibyte-characters: t Major mode: Gis Minor modes in effect: shell-dirtrack-mode: t diff-auto-refine-mode: t show-paren-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t global-auto-composition-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t abbrev-mode: t Recent input: ! C-c C-c C-x C-f c b . e l C-s M-p M-p M-p=20 M-p M-p M-p M-p M-p M-p M-p C-g C-x 2 C-x b =20 =20 =20 C-s C-w C-w C-w C-w C-w =20 C-s C-s M-x SPC C-x v v SPC=20 SPC C-k =20 =20 =20 =20 =20 =20 =20 2 C-a =20 C-x o M-x =20 =20 =20 C-k C-k =20 =20 =20 =20 =20 C-w C-x C-s =20 =20 C-x v v C-x b C-M-b=20 C-g C-x o =20 M-x C-x v v M-p=20 C-k c b =20 - m a g i k - e d i f f - m e t h o d s :=20 SPC r e t a i n SPC w i n d o w SPC c o n f i g u r=20 a t i o n SPC i f SPC m e t h o d SPC n o t SPC f o=20 u n d C-c C-c C-x k=20 M-x e=20 r a s e SPC b C-x k =20 =20 Recent messages: Press C-c C-c when you are done editing. Enter a change comment. Type C-c C-c when done Quit Mark set [2 times] Press C-c C-c when you are done editing. Enter a change comment. Type C-c C-c when done Comment 1 Checking in u:/tools/general/emacs/smallworld_lisp/smallworld/swlisp/cb.el...done Mark set Type y, n, ! or SPC (the space bar):=20 From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 30 13:41:07 2010 Received: (at control) by debbugs.gnu.org; 30 Mar 2010 17:41:08 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NwfR5-00035P-3Q for submit@debbugs.gnu.org; Tue, 30 Mar 2010 13:41:07 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NwfR3-000354-F9 for control@debbugs.gnu.org; Tue, 30 Mar 2010 13:41:05 -0400 Received: from rgm by fencepost.gnu.org with local (Exim 4.69) (envelope-from ) id 1NwfQy-0007Bl-JT; Tue, 30 Mar 2010 13:41:00 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <19378.14252.392658.716585@fencepost.gnu.org> Date: Tue, 30 Mar 2010 13:41:00 -0400 From: Glenn Morris To: control Subject: control X-Attribution: GM X-Mailer: VM (www.wonderworks.com/vm), GNU Emacs (www.gnu.org/software/emacs) X-Hue: green X-Ran: vZgOltzD&160:Gh/m:nmg,l&]]B]uvh?m.C:`luA*Gk)+A%L:QVg1eH[&|)S&(U}/M;|iR X-Debbugs-No-Ack: yes X-Spam-Score: -5.1 (-----) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.1 (-----) retitle 5805 23.1; abbrev-insert does not protext itself with save-excursion severity 5798 minor reassign 5786 emacs,cc-mode severity 5787 minor severity 5772 minor severity 5770 minor severity 5774 minor From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 10 12:04:17 2010 Received: (at 5805) by debbugs.gnu.org; 10 Apr 2010 16:04:17 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0dAP-0002AY-7p for submit@debbugs.gnu.org; Sat, 10 Apr 2010 12:04:17 -0400 Received: from pantheon-po34.its.yale.edu ([130.132.50.80]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0dAN-0002AT-QQ for 5805@debbugs.gnu.org; Sat, 10 Apr 2010 12:04:16 -0400 Received: from furry (173-14-147-246-NewEngland.hfc.comcastbusiness.net [173.14.147.246]) (authenticated bits=0) by pantheon-po34.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id o3AG4Dex007686 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 10 Apr 2010 12:04:13 -0400 Received: by furry (Postfix, from userid 1000) id 5E93CC055; Sat, 10 Apr 2010 12:04:13 -0400 (EDT) From: Chong Yidong To: "Maguire\, Andrew \(GE Infra\, Energy\)" Subject: Re: 23.1; abbrev-insert does not protext itself with save-excursion Date: Sat, 10 Apr 2010 12:04:13 -0400 Message-ID: <87vdbzjnuq.fsf@stupidchicken.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-YaleITSMailFilter: Version 1.2c (attachment(s) not renamed) X-Spam-Score: -2.9 (--) X-Debbugs-Envelope-To: 5805 Cc: 5805@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.9 (--) > 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? From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 10 13:06:56 2010 Received: (at 5805) by debbugs.gnu.org; 10 Apr 2010 17:06:56 +0000 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 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 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 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 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 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Subject: RE: 23.1; abbrev-insert does not protext itself with save-excursion Date: Sat, 10 Apr 2010 19:06:46 +0200 Message-ID: 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 References: <87vdbzjnuq.fsf@stupidchicken.com> From: "Maguire, Andrew (GE Infra, Energy)" To: "Chong Yidong" X-OriginalArrivalTime: 10 Apr 2010 17:06:50.0828 (UTC) FILETIME=[363D88C0:01CAD8D0] X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 5805 Cc: 5805@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) 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? From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 10 15:10:23 2010 Received: (at 5805) by debbugs.gnu.org; 10 Apr 2010 19:10:23 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0g4U-0003Xh-PF for submit@debbugs.gnu.org; Sat, 10 Apr 2010 15:10:23 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0g4S-0003Xc-Ue for 5805@debbugs.gnu.org; Sat, 10 Apr 2010 15:10:21 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAF5qwEtMCqWu/2dsb2JhbACbRXK5QoUMBItG X-IronPort-AV: E=Sophos;i="4.52,182,1270440000"; d="scan'208";a="60599553" Received: from 76-10-165-174.dsl.teksavvy.com (HELO pastel.home) ([76.10.165.174]) by ironport2-out.pppoe.ca with ESMTP; 10 Apr 2010 15:10:18 -0400 Received: by pastel.home (Postfix, from userid 20848) id 0ADFE7F1B; Sat, 10 Apr 2010 15:10:13 -0400 (EDT) From: Stefan Monnier To: "Maguire\, Andrew \(GE Infra\, Energy\)" Subject: Re: bug#5805: 23.1; abbrev-insert does not protext itself with save-excursion Message-ID: References: <87vdbzjnuq.fsf@stupidchicken.com> Date: Sat, 10 Apr 2010 15:10:13 -0400 In-Reply-To: (Andrew Maguire's message of "Sat, 10 Apr 2010 19:06:46 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 5805 Cc: Chong Yidong , 5805@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) > 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. 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 12 07:29:21 2010 Received: (at 5805) by debbugs.gnu.org; 12 Apr 2010 11:29:21 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1HpP-00050D-Ve for submit@debbugs.gnu.org; Mon, 12 Apr 2010 07:29:20 -0400 Received: from exprod5og109.obsmtp.com ([64.18.0.188]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1HpO-000507-5Z for 5805@debbugs.gnu.org; Mon, 12 Apr 2010 07:29:18 -0400 Received: from source ([4.79.213.129]) (using TLSv1) by exprod5ob109.postini.com ([64.18.4.12]) with SMTP ID DSNKS8MEBwU3InEZ1JWvriPAlOR9Xkk8jL+V@postini.com; Mon, 12 Apr 2010 04:29:18 PDT Received: from unknown (HELO ALPMLEF02.e2k.ad.ge.com) ([3.159.18.11]) by Alpmlip08.e2k.ad.ge.com with ESMTP; 12 Apr 2010 07:29:11 -0400 Received: from BUDMLVEM09.e2k.ad.ge.com ([3.159.52.69]) by ALPMLEF02.e2k.ad.ge.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 12 Apr 2010 07:29:11 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Subject: RE: bug#5805: 23.1; abbrev-insert does not protext itself with save-excursion Date: Mon, 12 Apr 2010 13:28:50 +0200 Message-ID: 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: AcrY4XhOQO0Oo/IGSKGdLE/wI60b6QBUL/vA References: <87vdbzjnuq.fsf@stupidchicken.com> From: "Maguire, Andrew (GE Infra, Energy)" To: "Stefan Monnier" X-OriginalArrivalTime: 12 Apr 2010 11:29:11.0152 (UTC) FILETIME=[5F5BCF00:01CADA33] X-Spam-Score: -5.1 (-----) X-Debbugs-Envelope-To: 5805 Cc: Chong Yidong , 5805@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.0 (------) 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. 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}^ 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. 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 12 09:31:24 2010 Received: (at 5805) by debbugs.gnu.org; 12 Apr 2010 13:31:24 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1JjY-0006N2-7l for submit@debbugs.gnu.org; Mon, 12 Apr 2010 09:31:24 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1JjW-0006Mu-Q3 for 5805@debbugs.gnu.org; Mon, 12 Apr 2010 09:31:23 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEALS9wktMCqWu/2dsb2JhbACbMXK6Z4UMBItG X-IronPort-AV: E=Sophos;i="4.52,190,1270440000"; d="scan'208";a="60664448" Received: from 76-10-165-174.dsl.teksavvy.com (HELO pastel.home) ([76.10.165.174]) by ironport2-out.pppoe.ca with ESMTP; 12 Apr 2010 09:31:17 -0400 Received: by pastel.home (Postfix, from userid 20848) id 41FC57F1B; Mon, 12 Apr 2010 09:31:17 -0400 (EDT) From: Stefan Monnier To: "Maguire\, Andrew \(GE Infra\, Energy\)" Subject: Re: bug#5805: 23.1; abbrev-insert does not protext itself with save-excursion Message-ID: References: <87vdbzjnuq.fsf@stupidchicken.com> Date: Mon, 12 Apr 2010 09:31:17 -0400 In-Reply-To: (Andrew Maguire's message of "Mon, 12 Apr 2010 13:28:50 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 5805 Cc: Chong Yidong , 5805@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > 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] > 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 => 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 12 11:02:44 2010 Received: (at 5805) by debbugs.gnu.org; 12 Apr 2010 15:02:44 +0000 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 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 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 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 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 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Subject: RE: bug#5805: 23.1; abbrev-insert does not protext itself with save-excursion Date: Mon, 12 Apr 2010 17:02:30 +0200 Message-ID: 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 References: <87vdbzjnuq.fsf@stupidchicken.com> From: "Maguire, Andrew (GE Infra, Energy)" To: "Stefan Monnier" X-OriginalArrivalTime: 12 Apr 2010 15:02:34.0206 (UTC) FILETIME=[2E92CFE0:01CADA51] X-Spam-Score: -6.1 (------) X-Debbugs-Envelope-To: 5805 Cc: Chong Yidong , 5805@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 12 14:13:41 2010 Received: (at 5805) by debbugs.gnu.org; 12 Apr 2010 18:13:41 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1O8i-0000RI-CP for submit@debbugs.gnu.org; Mon, 12 Apr 2010 14:13:40 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O1O8g-0000RB-CC for 5805@debbugs.gnu.org; Mon, 12 Apr 2010 14:13:38 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEAE//wktMCqWu/2dsb2JhbACbOnK8R4UMBItG X-IronPort-AV: E=Sophos;i="4.52,192,1270440000"; d="scan'208";a="60692599" Received: from 76-10-165-174.dsl.teksavvy.com (HELO pastel.home) ([76.10.165.174]) by ironport2-out.pppoe.ca with ESMTP; 12 Apr 2010 14:13:30 -0400 Received: by pastel.home (Postfix, from userid 20848) id 7288B7F1B; Mon, 12 Apr 2010 14:13:30 -0400 (EDT) From: Stefan Monnier To: "Maguire\, Andrew \(GE Infra\, Energy\)" Subject: Re: bug#5805: 23.1; abbrev-insert does not protext itself with save-excursion Message-ID: References: <87vdbzjnuq.fsf@stupidchicken.com> Date: Mon, 12 Apr 2010 14:13:30 -0400 In-Reply-To: (Andrew Maguire's message of "Mon, 12 Apr 2010 17:02:30 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 5805 Cc: Chong Yidong , 5805@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.9 (-) > The workaround I have locally is using advice to place a save-excursion > around the non-interactive function abbrev-insert. As explained already, some abbrevs will want to move point and that is done within abbrev-insert. Please give us more information about your particular use. I.e. I can't help you much further until you answer the question I asked at the very beginning: >> Observe that point ^ is now before the ()s. > Right. The question now is: why is that a problem? Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 07 10:48:44 2011 Received: (at 5805) by debbugs.gnu.org; 7 Jul 2011 14:48:44 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qepsh-0006sg-Mm for submit@debbugs.gnu.org; Thu, 07 Jul 2011 10:48:43 -0400 Received: from mail-vx0-f172.google.com ([209.85.220.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qepsg-0006sU-7p for 5805@debbugs.gnu.org; Thu, 07 Jul 2011 10:48:42 -0400 Received: by vxi40 with SMTP id 40so728587vxi.3 for <5805@debbugs.gnu.org>; Thu, 07 Jul 2011 07:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=7clhw2PgHRKhs2YedSir5K1E00+xw7gqjD0LdhZKUps=; b=O5Py+swzyoZm/uXQYcSZmbpb8cz7QtKogZC+/F2lbLheDBUFxnOP+z3QLsraYq6vQl E/ZOaOz3PSn8qr/2vazR38q+LVIRMtkDQTvJLYVNbFizldNlnKB/Bk3Ly9fiLvNqAnG8 LT4RpsKVDbcNZv3bMw1ROy8lFqQMFQXk9LAko= MIME-Version: 1.0 Received: by 10.52.108.231 with SMTP id hn7mr1195458vdb.283.1310050116782; Thu, 07 Jul 2011 07:48:36 -0700 (PDT) Received: by 10.52.184.34 with HTTP; Thu, 7 Jul 2011 07:48:36 -0700 (PDT) Date: Thu, 7 Jul 2011 08:48:36 -0600 Message-ID: Subject: bug#5805 23.3 abbrev-insert needs a limited save-excursion From: Bob Nnamtrop To: 5805@debbugs.gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -3.9 (---) X-Debbugs-Envelope-To: 5805 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.9 (---) I agree with the original poster that a save-excursion is needed in abbrev-expand and by making its scope limited (see below) it will not interfere with abbrevs that want to change point. The reason I find it annoying the way it is now is that some modes (e.g., idlwave) use abbrev's extensively to change keywords (e.g. capitalize them). These are defined without the leading "\". So if I am any number of lines with only whitespace below a keyword defined in this way (e.g. endfor) and run expand-abbrev then the point moves even if no visible change takes place. This is a VERY common occurrence for me since in viper mode changing from insert to vi mode runs expand-abbrev! Placing the save-excursion just around the part of abbrev-insert that actually expands the abbrev fixes this problem and does not limit abbrev's from moving the point (idlwave does this extensively as well and I've tested that it is not impacted). Here is the diff against the abbrev.el in emacs 23.3 (note that whitespace not adjusted). Thanks much, Bob --- 23.3/abbrev.el 2011-07-07 08:16:16.000000000 -0600 +++ 23.3.fix/abbrev.el 2011-07-07 08:43:24.000000000 -0600 @@ -713,6 +713,7 @@ ;; If this abbrev has an expansion, delete the abbrev ;; and insert the expansion. (when (stringp (symbol-value abbrev)) + (save-excursion (goto-char wordstart) ;; Insert at beginning so that markers at the end (e.g. point) ;; are preserved. @@ -741,7 +742,7 @@ (skip-syntax-forward "^w" (1- end)) ;; Change just that. (upcase-initials-region (point) (1+ (point))) - (goto-char end)))))) + (goto-char end))))))) ;; Now point is at the end of the expansion and the beginning is ;; in last-abbrev-location. (when (symbol-function abbrev) From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 07 16:59:59 2011 Received: (at 5805) by debbugs.gnu.org; 7 Jul 2011 21:00:00 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qevfz-0002Pv-H2 for submit@debbugs.gnu.org; Thu, 07 Jul 2011 16:59:59 -0400 Received: from chene.dit.umontreal.ca ([132.204.246.20]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qevfj-0002Ol-SX; Thu, 07 Jul 2011 16:59:57 -0400 Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id p67KxDns009224; Thu, 7 Jul 2011 16:59:14 -0400 Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id D3BCAB4177; Thu, 7 Jul 2011 16:59:13 -0400 (EDT) From: Stefan Monnier To: Bob Nnamtrop Subject: Re: bug#5805: 23.3 abbrev-insert needs a limited save-excursion Message-ID: References: Date: Thu, 07 Jul 2011 16:59:13 -0400 In-Reply-To: (Bob Nnamtrop's message of "Thu, 7 Jul 2011 08:48:36 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV3911=0 X-NAI-Spam-Version: 2.2.0.9286 : core <3911> : streams <658563> : uri <909078> X-Spam-Score: -2.0 (--) X-Debbugs-Envelope-To: 5805 Cc: 5805@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.0 (--) tags 5805 patch thanks > I agree with the original poster that a save-excursion is needed in > abbrev-expand and by making its scope limited (see below) it will not > interfere with abbrevs that want to change point. The reason I find it > annoying the way it is now is that some modes (e.g., idlwave) use > abbrev's extensively to change keywords (e.g. capitalize them). These > are defined without the leading "\". So if I am any number of lines > with only whitespace below a keyword defined in this way (e.g. endfor) > and run expand-abbrev then the point moves even if no visible change > takes place. This is a VERY common occurrence for me since in viper > mode changing from insert to vi mode runs expand-abbrev! Placing the > save-excursion just around the part of abbrev-insert that actually > expands the abbrev fixes this problem and does not limit abbrev's from > moving the point (idlwave does this extensively as well and I've > tested that it is not impacted). Hmm... sounds like an interesting solution. I'll take a closer look and get back to you. Thank you. > Here is the diff against the > abbrev.el in emacs 23.3 (note that whitespace not adjusted). Highly appreciated. Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 07 17:46:11 2011 Received: (at 5805) by debbugs.gnu.org; 7 Jul 2011 21:46:12 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QewOg-0004fR-Ok for submit@debbugs.gnu.org; Thu, 07 Jul 2011 17:46:11 -0400 Received: from mail-vw0-f44.google.com ([209.85.212.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QewOe-0004f9-CP for 5805@debbugs.gnu.org; Thu, 07 Jul 2011 17:46:09 -0400 Received: by vws12 with SMTP id 12so1042928vws.3 for <5805@debbugs.gnu.org>; Thu, 07 Jul 2011 14:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=EcY1ix+DL5av49AFWmyz2Ij5LIRtH3xQuYSoXfPWQG8=; b=j9M0uFupsbP1z7dkVWj7erLDRRJhaMja3ietYO7f6+eAEkGP9FfI/C9fTUvv1VoUqZ Vv6l+yMdaa4Tf+2yWBH7O/BasByQxBoDgxWGE/DoWpwvem8A4Yb0Q2U0sEk1VOhUQNvX e/8MYPQ23FbclleKgTyHu/4vpv34PVE9g354A= MIME-Version: 1.0 Received: by 10.52.108.231 with SMTP id hn7mr1816118vdb.283.1310075162341; Thu, 07 Jul 2011 14:46:02 -0700 (PDT) Received: by 10.52.184.34 with HTTP; Thu, 7 Jul 2011 14:46:02 -0700 (PDT) In-Reply-To: References: Date: Thu, 7 Jul 2011 15:46:02 -0600 Message-ID: Subject: Re: bug#5805: 23.3 abbrev-insert needs a limited save-excursion From: Bob Nnamtrop To: Stefan Monnier Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.8 (---) X-Debbugs-Envelope-To: 5805 Cc: 5805@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.8 (---) On Thu, Jul 7, 2011 at 2:59 PM, Stefan Monnier w= rote: > tags 5805 patch > thanks > >> I agree with the original poster that a save-excursion is needed in >> abbrev-expand and by making its scope limited (see below) it will not >> interfere with abbrevs that want to change point. The reason I find it >> annoying the way it is now is that some modes (e.g., idlwave) use >> abbrev's extensively to change keywords (e.g. capitalize them). These >> are defined without the leading "\". So if I am any number of lines >> with only whitespace below a keyword defined in this way (e.g. endfor) >> and run expand-abbrev then the point moves even if no visible change >> takes place. This is a VERY common occurrence for me since in viper >> mode changing from insert to vi mode runs expand-abbrev! Placing the >> save-excursion just around the part of abbrev-insert that actually >> expands the abbrev fixes this problem and does not limit abbrev's from >> moving the point (idlwave does this extensively as well and I've >> tested that it is not impacted). > > Hmm... sounds like an interesting solution. =A0I'll take a closer look an= d > get back to you. =A0Thank you. > >> Here is the diff against the >> abbrev.el in emacs 23.3 (note that whitespace not adjusted). > > Highly appreciated. > > > =A0 =A0 =A0 =A0Stefan > I've been thinking about this some more and while I think the save-excursion solution mentioned above is not a bad idea, perhaps fixing this at the heart of the problem would be better. The basic problem is that changing state from viper insert state to viper vi state causes abbrev's to be expanded if there is any amount of white space between the point and an abbrev. This differs from the rules of e.g. "space" causing an abbrev to be expanded. A space (or comma, ret, etc) will only cause an abbrev to expand if it is immediately after an abbrev. If changing state from viper insert to vi state followed the same rules then everything would work nicer. For example, what commonly happens to me is I type an abbrev (say \ef) then return. In idlwave mode this causes \ef to be expanded to endfor and the cursor blinks to the corresponding begin and back. Now if I type a return and a tab to indent and then exit viper insert state abbrev-expand is run again (since endfor is also an abbrev, for itself) and the cursor again blinks to the begin and the cursor is left on the endfor. The save-excursion fix only fixes where the cursor is left. The blinking still occurs. Thus it is only a partial fix. The rule should be "if a space (or any other non-word character) would not cause an abbrev to expand then exiting from viper insert state should not cause an abbrev to expand". And vise-versa. This would fix all the issues I have with abbrev. I've been trying to implement this today but without success. I know why changing viper state causes abbrev to run. There is a line (if abbrev-mode (expand-abbrev)) in viper-change-state-to-vi in viper-cmd.el which causes it. What I cannot figure out is what causes a normal space (or comma, ret, etc) to make an abbrev expand when one is directly after an abbrev (and when the point is one space past the abbrev another space does not cause an expansion, unlike the code above). Maybe you could give me a hint. Is there a "abbrev-pending" or something like that. Thanks, Bob From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 07 20:02:24 2011 Received: (at 5805) by debbugs.gnu.org; 8 Jul 2011 00:02:24 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QeyWV-0000wC-D7 for submit@debbugs.gnu.org; Thu, 07 Jul 2011 20:02:24 -0400 Received: from mail-vx0-f172.google.com ([209.85.220.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QeyWS-0000vw-W4 for 5805@debbugs.gnu.org; Thu, 07 Jul 2011 20:02:22 -0400 Received: by vxi40 with SMTP id 40so1073323vxi.3 for <5805@debbugs.gnu.org>; Thu, 07 Jul 2011 17:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=xCVXv+Ekv1WDQ/G4OVbVZ+JimTBxpnHJR6MLmThJqCY=; b=bqq3GtCSjqfbMbNk5N9xeBTaFw60f1aSsKW+Nqt1Lku/YfycNsH8HUAVB7Z3R3j208 vsVzirRfdhTHQ922/kznLThpE4dwJxyhtzFVnA8wJe/r3fqEIVrKrtyBWIuwTNgUw+Bt rkbpPtf2lUmGyCjGhdHkCC6pdxa06lBk7yrts= MIME-Version: 1.0 Received: by 10.52.108.231 with SMTP id hn7mr1964197vdb.283.1310083335248; Thu, 07 Jul 2011 17:02:15 -0700 (PDT) Received: by 10.52.184.34 with HTTP; Thu, 7 Jul 2011 17:02:15 -0700 (PDT) In-Reply-To: References: Date: Thu, 7 Jul 2011 18:02:15 -0600 Message-ID: Subject: Re: bug#5805: 23.3 abbrev-insert needs a limited save-excursion From: Bob Nnamtrop To: Stefan Monnier Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.8 (---) X-Debbugs-Envelope-To: 5805 Cc: 5805@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.7 (---) On Thu, Jul 7, 2011 at 3:46 PM, Bob Nnamtrop wrote: > On Thu, Jul 7, 2011 at 2:59 PM, Stefan Monnier = wrote: >> tags 5805 patch >> thanks >> >>> I agree with the original poster that a save-excursion is needed in >>> abbrev-expand and by making its scope limited (see below) it will not >>> interfere with abbrevs that want to change point. The reason I find it >>> annoying the way it is now is that some modes (e.g., idlwave) use >>> abbrev's extensively to change keywords (e.g. capitalize them). These >>> are defined without the leading "\". So if I am any number of lines >>> with only whitespace below a keyword defined in this way (e.g. endfor) >>> and run expand-abbrev then the point moves even if no visible change >>> takes place. This is a VERY common occurrence for me since in viper >>> mode changing from insert to vi mode runs expand-abbrev! Placing the >>> save-excursion just around the part of abbrev-insert that actually >>> expands the abbrev fixes this problem and does not limit abbrev's from >>> moving the point (idlwave does this extensively as well and I've >>> tested that it is not impacted). >> >> Hmm... sounds like an interesting solution. =A0I'll take a closer look a= nd >> get back to you. =A0Thank you. >> >>> Here is the diff against the >>> abbrev.el in emacs 23.3 (note that whitespace not adjusted). >> >> Highly appreciated. >> >> >> =A0 =A0 =A0 =A0Stefan >> > > (SNIP) > The rule should be "if a space (or any other non-word character) would > not cause an abbrev to expand then exiting from viper insert state > should not cause an abbrev to expand". And vise-versa. This would fix > all the issues I have with abbrev. > (SNIP) Here are two patches that do what I explained above. I am new to elisp so be kind :-) Note that these apply against the trunk (sorry to be switching back of forth). I left in the save-excursion fix but it is not absolutely necessary at this point but I still think it is the right thing to do. Let me know what you think. Bob --- trunk/lisp/emulation/viper-cmd.el 2011-07-07 13:00:22.000000000 -0600 +++ local-fixes/lisp/emulation/viper-cmd.el 2011-07-07 17:45:14.000000000 -0600 @@ -617,7 +617,7 @@ (or (viper-overlay-p viper-replace-overlay) (viper-set-replace-overlay (point-min) (point-min))) (viper-hide-replace-overlay) - (if abbrev-mode (expand-abbrev)) + (if abbrev-mode (expand-abbrev t)) (if (and auto-fill-function (> (current-column) fill-column)) (funcall auto-fill-function)) ;; don't leave whitespace lines around --- trunk/lisp/abbrev.el 2011-07-07 13:00:22.000000000 -0600 +++ local-fixes/lisp/abbrev.el 2011-07-07 17:49:26.000000000 -0600 @@ -752,6 +752,7 @@ ;; If this abbrev has an expansion, delete the abbrev ;; and insert the expansion. (when (stringp (symbol-value abbrev)) + (save-excursion (goto-char wordstart) ;; Insert at beginning so that markers at the end (e.g. point) ;; are preserved. @@ -780,7 +781,7 @@ (skip-syntax-forward "^w" (1- end)) ;; Change just that. (upcase-initials-region (point) (1+ (point))) - (goto-char end)))))) + (goto-char end))))))) ;; Now point is at the end of the expansion and the beginning is ;; in last-abbrev-location. (when (symbol-function abbrev) @@ -804,16 +805,18 @@ a function that performs the abbrev expansion. It should return the abbrev symbol if expansion took place.") -(defun expand-abbrev () +(defun expand-abbrev (&optional strict) "Expand the abbrev before point, if there is an abbrev there. Effective when explicitly called even when `abbrev-mode' is nil. +If strict is t then point must be directly after then end of the +abbrev for the expansion to take place. (interactive) (run-hooks 'pre-abbrev-expand-hook) (with-wrapper-hook abbrev-expand-functions () (destructuring-bind (&optional sym name wordstart wordend) (abbrev--before-point) - (when sym + (when (and sym (or (not strict) (=3D wordend (point)))) (unless (or ;; executing-kbd-macro noninteractive (window-minibuffer-p (selected-window))) From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 07 21:03:25 2011 Received: (at 5805) by debbugs.gnu.org; 8 Jul 2011 01:03:25 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QezTY-0002cS-RI for submit@debbugs.gnu.org; Thu, 07 Jul 2011 21:03:25 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QezTX-0002cD-8V for 5805@debbugs.gnu.org; Thu, 07 Jul 2011 21:03:24 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EADpXFk5MCqt8/2dsb2JhbABTpz14iHvDS4Y4BJ5xhC8 X-IronPort-AV: E=Sophos;i="4.65,496,1304308800"; d="scan'208";a="123480958" Received: from 76-10-171-124.dsl.teksavvy.com (HELO pastel.home) ([76.10.171.124]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 07 Jul 2011 21:03:04 -0400 Received: by pastel.home (Postfix, from userid 20848) id 570D759006; Thu, 7 Jul 2011 21:03:03 -0400 (EDT) From: Stefan Monnier To: Bob Nnamtrop Subject: Re: bug#5805: 23.3 abbrev-insert needs a limited save-excursion Message-ID: References: Date: Thu, 07 Jul 2011 21:03:03 -0400 In-Reply-To: (Bob Nnamtrop's message of "Thu, 7 Jul 2011 18:02:15 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 5805 Cc: 5805@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) > Here are two patches that do what I explained above. I am new to elisp > so be kind :-) Note that these apply against the trunk (sorry to be > switching back of forth). I still haven't thought about the save-excursion issue, but for the other, I think the fix should be complete in viper without changing expand-abbrev. The way it work in "normal Emacs" is the self-insert-command only calls expand-abbrev if (as its docstring explains) the char inserted doesn't have word syntax and the previous one does. The corresponding code (it's in C): if (!NILP (BVAR (current_buffer, abbrev_mode)) && synt != Sword && NILP (BVAR (current_buffer, read_only)) && PT > BEGV && (SYNTAX (!NILP (BVAR (current_buffer, enable_multibyte_characters)) ? XFASTINT (Fprevious_char ()) : UNIBYTE_TO_CHAR (XFASTINT (Fprevious_char ()))) == Sword)) { -- Stefan From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 08 10:43:34 2011 Received: (at 5805-done) by debbugs.gnu.org; 8 Jul 2011 14:43:34 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfCHF-0001U5-WB for submit@debbugs.gnu.org; Fri, 08 Jul 2011 10:43:34 -0400 Received: from ironport2-out.teksavvy.com ([206.248.154.181] helo=ironport2-out.pppoe.ca) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfCHD-0001Tt-HI for 5805-done@debbugs.gnu.org; Fri, 08 Jul 2011 10:43:32 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EAFgXF05MCqt8/2dsb2JhbABTp0V4y2qGOASefYQv X-IronPort-AV: E=Sophos;i="4.65,499,1304308800"; d="scan'208";a="123777448" Received: from 76-10-171-124.dsl.teksavvy.com (HELO pastel.home) ([76.10.171.124]) by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA; 08 Jul 2011 10:43:18 -0400 Received: by pastel.home (Postfix, from userid 20848) id 29BFE59160; Fri, 8 Jul 2011 10:43:18 -0400 (EDT) From: Stefan Monnier To: Bob Nnamtrop Subject: Re: bug#5805: 23.3 abbrev-insert needs a limited save-excursion Message-ID: References: Date: Fri, 08 Jul 2011 10:43:18 -0400 In-Reply-To: (Bob Nnamtrop's message of "Thu, 7 Jul 2011 08:48:36 -0600") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 5805-done Cc: 5805-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.1 (--) > --- 23.3/abbrev.el 2011-07-07 08:16:16.000000000 -0600 > +++ 23.3.fix/abbrev.el 2011-07-07 08:43:24.000000000 -0600 > @@ -713,6 +713,7 @@ > ;; If this abbrev has an expansion, delete the abbrev > ;; and insert the expansion. > (when (stringp (symbol-value abbrev)) > + (save-excursion > (goto-char wordstart) > ;; Insert at beginning so that markers at the end (e.g. point) > ;; are preserved. > @@ -741,7 +742,7 @@ > (skip-syntax-forward "^w" (1- end)) > ;; Change just that. > (upcase-initials-region (point) (1+ (point))) > - (goto-char end)))))) > + (goto-char end))))))) > ;; Now point is at the end of the expansion and the beginning is > ;; in last-abbrev-location. This can't be right, as can be seen in the comment right here: after this (goto-char end), the rest of the code expects point to be "at the end of the expansion". I installed the ugly patch below instead. Stefan === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2011-07-08 14:25:25 +0000 +++ lisp/ChangeLog 2011-07-08 14:41:48 +0000 @@ -5,6 +5,8 @@ 2011-07-08 Stefan Monnier + * abbrev.el (expand-abbrev): Try to preserve point (bug#5805). + * vc/vc-bzr.el (vc-bzr-revision-keywords): Remove svn, it's only provided by a particular plugin. === modified file 'lisp/abbrev.el' --- lisp/abbrev.el 2011-07-05 15:31:22 +0000 +++ lisp/abbrev.el 2011-07-08 14:41:16 +0000 @@ -814,6 +814,8 @@ (destructuring-bind (&optional sym name wordstart wordend) (abbrev--before-point) (when sym + (let ((startpos (copy-marker (point) t)) + (endmark (copy-marker wordend t))) (unless (or ;; executing-kbd-macro noninteractive (window-minibuffer-p (selected-window))) @@ -826,7 +828,14 @@ (setq last-abbrev-location wordstart) ;; If this abbrev has an expansion, delete the abbrev ;; and insert the expansion. - (abbrev-insert sym name wordstart wordend))))) + (prog1 + (abbrev-insert sym name wordstart wordend) + ;; Yuck!! If expand-abbrev is called with point slightly + ;; further than the end of the abbrev, move point back to + ;; where it started. + (if (and (> startpos endmark) + (= (point) endmark)) ;Obey skeletons that move point. + (goto-char startpos)))))))) (defun unexpand-abbrev () "Undo the expansion of the last abbrev that expanded. From debbugs-submit-bounces@debbugs.gnu.org Sat Jul 09 00:03:36 2011 Received: (at 5805-done) by debbugs.gnu.org; 9 Jul 2011 04:03:36 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfOlU-0001IF-3m for submit@debbugs.gnu.org; Sat, 09 Jul 2011 00:03:36 -0400 Received: from mail-vw0-f44.google.com ([209.85.212.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfOlR-0001I3-Jb for 5805-done@debbugs.gnu.org; Sat, 09 Jul 2011 00:03:34 -0400 Received: by vws12 with SMTP id 12so1831503vws.3 for <5805-done@debbugs.gnu.org>; Fri, 08 Jul 2011 21:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=mQ7qZdcjE1tXiv1bp9zLC78BzkL546RAaFstnv9vRA4=; b=uazC9siHjakSEdh+coBpV9s0XMv9pLebwoM7FuvRc/vK8LGNah0BJlM44isfxIG1as LD0i+9yCAgZ2scm0nUpd7ioUb9DjwWgKq2fZ7Lgms68ifm0ZqFBfznrRLA8E6jmzXTet Nx7nL0rC0iWcj7eiINudNHJ7DI/0X2lI48sZs= MIME-Version: 1.0 Received: by 10.52.109.1 with SMTP id ho1mr3634985vdb.140.1310184207850; Fri, 08 Jul 2011 21:03:27 -0700 (PDT) Received: by 10.52.184.34 with HTTP; Fri, 8 Jul 2011 21:03:27 -0700 (PDT) In-Reply-To: References: Date: Fri, 8 Jul 2011 22:03:27 -0600 Message-ID: Subject: Re: bug#5805: 23.3 abbrev-insert needs a limited save-excursion From: Bob Nnamtrop To: Stefan Monnier Content-Type: text/plain; charset=ISO-8859-1 X-Spam-Score: -3.7 (---) X-Debbugs-Envelope-To: 5805-done Cc: 5805-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.7 (---) On Fri, Jul 8, 2011 at 8:43 AM, Stefan Monnier wrote: > I installed the ugly patch below instead. > This works great. I'll look into fixing viper and start a new bug report. Thanks much, Bob From unknown Sat Jun 21 10:19:28 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 06 Aug 2011 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator