From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#5734: Fwd: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N Date: Thu, 25 Mar 2010 20:54:06 +0100 Message-ID: <1D21EF7D-A103-48F3-93DF-239440762783@gmail.com> References: <72E45B8A-4496-440D-9D38-F9280DE76397@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: multipart/alternative; boundary=Apple-Mail-1--818129441 X-Trace: dough.gmane.org 1269550913 5624 80.91.229.12 (25 Mar 2010 21:01:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 25 Mar 2010 21:01:53 +0000 (UTC) To: 5734@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Mar 25 22:01:49 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 1NuuBY-0003O3-7i for geb-bug-gnu-emacs@m.gmane.org; Thu, 25 Mar 2010 22:01:49 +0100 Original-Received: from localhost ([127.0.0.1]:55545 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NuuBX-0002Ie-FJ for geb-bug-gnu-emacs@m.gmane.org; Thu, 25 Mar 2010 17:01:47 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nut9T-0003z3-IK for bug-gnu-emacs@gnu.org; Thu, 25 Mar 2010 15:55:35 -0400 Original-Received: from [140.186.70.92] (port=56463 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nut9N-0003xZ-US for bug-gnu-emacs@gnu.org; Thu, 25 Mar 2010 15:55:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nut9F-00020D-Gv for bug-gnu-emacs@gnu.org; Thu, 25 Mar 2010 15:55:27 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51313) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nut9F-000207-EB for bug-gnu-emacs@gnu.org; Thu, 25 Mar 2010 15:55:21 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Nut8w-0005Zr-6y; Thu, 25 Mar 2010 15:55:02 -0400 X-Loop: bug-gnu-emacs@gnu.org In-Reply-To: Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Mar 2010 19:55:02 +0000 Resent-Message-ID: Resent-Sender: bug-gnu-emacs@gnu.org X-GNU-PR-Message: followup 5734 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5734-submit@debbugs.gnu.org id=B5734.126954685721432 (code B ref 5734); Thu, 25 Mar 2010 19:55:02 +0000 Original-Received: (at 5734) by debbugs.gnu.org; 25 Mar 2010 19:54:17 +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 1Nut8C-0005Zd-KL for submit@debbugs.gnu.org; Thu, 25 Mar 2010 15:54:17 -0400 Original-Received: from mail-ww0-f44.google.com ([74.125.82.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nut8B-0005ZY-EA for 5734@debbugs.gnu.org; Thu, 25 Mar 2010 15:54:16 -0400 Original-Received: by wwb31 with SMTP id 31so386084wwb.3 for <5734@debbugs.gnu.org>; Thu, 25 Mar 2010 12:54:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:content-type:subject :date:references:to:message-id:mime-version:x-mailer; bh=orEqwmq1mwRxLTQMfUcBe/hdJYm5QdT/IRwcq3ImLdQ=; b=fl2ELR4Gx7seOSiiIl6hvU2RRpG5pRKYfJUDC88wRyN77w1A8Z+7ZxrVS/Wklu8fK2 hbNaMVDCorAWt/4PlohBPyUCUO1ZaplJwYS4ewI48f6j83LvJE9A4iDFAPATxPxeTBWn r4Pv6M0k+L3VKvs/gX8zR1uB6RLMXWQK3+0fU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:content-type:subject:date:references:to:message-id :mime-version:x-mailer; b=Vp27vVVWSdZOdtelY3tv3DfMUC/J+UMgClalHce0yvgmlJ378QOoMo73kfJP3id40R /cjKzNHX099oS8XDfCn7hwM3QHgNCscTtiJUjNZszHadgxBgzG3Mmxv6myXIak/AfDEp H4ukWOUtuaHGJQJ1ZSDcDBKRbeHYdGQiTzC6g= Original-Received: by 10.216.85.143 with SMTP id u15mr1542780wee.205.1269546849742; Thu, 25 Mar 2010 12:54:09 -0700 (PDT) Original-Received: from [192.168.1.128] (109.154.218.87.dynamic.jazztel.es [87.218.154.109]) by mx.google.com with ESMTPS id q9sm4097927gve.29.2010.03.25.12.54.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 25 Mar 2010 12:54:08 -0700 (PDT) X-Mailer: Apple Mail (2.1077) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 25 Mar 2010 15:55: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:35757 Archived-At: --Apple-Mail-1--818129441 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 Forgot to cc the bug db. Begin forwarded message: > From: Jo=E3o T=E1vora > Date: March 25, 2010 8:52:47 PM GMT+01:00 > To: Chong Yidong > Subject: Re: 23.1.94; (forward-sexp N) at the very end of large = latex-mode buffer takes time proportional to N >=20 > What about this? This was the workaround I used in autopair.el. The > idea behind is that if one `latex-forward-sexp-1' went nowhere, the > next one probably isn't going to. I may be wrong :-) >=20 > =3D=3D=3D modified file 'lisp/textmodes/tex-mode.el' > --- lisp/textmodes/tex-mode.el 2010-02-16 02:42:03 +0000 > +++ lisp/textmodes/tex-mode.el 2010-03-25 19:42:59 +0000 > @@ -1651,9 +1651,12 @@ > "Like `forward-sexp' but aware of multi-char elements and escaped = parens." > (interactive "P") > (unless arg (setq arg 1)) > - (let ((pos (point))) > + (let ((pos (point)) > + (prev-pos 0)) > (condition-case err > - (while (/=3D arg 0) > + (while (and (not (eq prev-pos (point))) > + (/=3D arg 0)) > + (setq prev-pos (point)) > (setq arg > (if (> arg 0) > (progn (latex-forward-sexp-1) (1- arg)) >=20 > PS: I hadn't realised that `tex-mode' defines a = `forward-sexp-function' > hence my ignorant comment about the problem being in syntax.c's = scan_list. >=20 > Bye, > Jo=E3o >=20 > On Mar 25, 2010, at 8:17 PM, Chong Yidong wrote: >=20 > start with `emacs -Q' > M-x eval-expression RET (insert (make-string 100000 ?a)) RET > M-x eval-expression RET (latex-mode) RET > M-x eval-expression RET (forward-sexp 200) RET > M-x eval-expression RET (forward-sexp 500) RET > M-x eval-expression RET (forward-sexp (point-max)) RET >=20 > In some versions of emacs this does not happen, notably my earlier > Carbon Emacs "GNU Emacs 22.3.1 (i386-apple-darwin9.7.0, Carbon Version > 1.6.0) of 2009-07-26 on gs674-seijiz.local" after loading some lisp > libraries (don't know which), like the ones I have bellow (autopair, > yasnippet). >=20 > I can reproduce this slowness even on Emacs 22.3. It arises because > tex-mode wants to be able to signal an error if point is in a = containing > expression that ends prematurely, so it does a bit of backtracking. > (This is the `skip-syntax-backward' call in latex-forward-sexp-1). >=20 > I'm not sure what the best way to fix this is, though. > On Mar 25, 2010, at 8:17 PM, Chong Yidong wrote: >=20 >>> start with `emacs -Q' >>> M-x eval-expression RET (insert (make-string 100000 ?a)) RET >>> M-x eval-expression RET (latex-mode) RET >>> M-x eval-expression RET (forward-sexp 200) RET >>> M-x eval-expression RET (forward-sexp 500) RET >>> M-x eval-expression RET (forward-sexp (point-max)) RET >>=20 >>> In some versions of emacs this does not happen, notably my earlier >>> Carbon Emacs "GNU Emacs 22.3.1 (i386-apple-darwin9.7.0, Carbon = Version >>> 1.6.0) of 2009-07-26 on gs674-seijiz.local" after loading some lisp >>> libraries (don't know which), like the ones I have bellow (autopair, >>> yasnippet). >>=20 >> I can reproduce this slowness even on Emacs 22.3. It arises because >> tex-mode wants to be able to signal an error if point is in a = containing >> expression that ends prematurely, so it does a bit of backtracking. >> (This is the `skip-syntax-backward' call in latex-forward-sexp-1). >>=20 >> I'm not sure what the best way to fix this is, though. >=20 --Apple-Mail-1--818129441 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=iso-8859-1
From: Jo=E3o T=E1vora <joaotavora@gmail.com>
Date: March 25, 2010 = 8:52:47 PM GMT+01:00
To: Chong Yidong <cyd@stupidchicken.com>
Subject: Re: 23.1.94; (forward-sexp N) at the very end of = large latex-mode buffer takes time proportional to = N

What about this? This was the workaround = I used in autopair.el. The
idea behind is that if one = `latex-forward-sexp-1' went nowhere, the
next one probably isn't = going to. I may be wrong :-)

=3D=3D=3D modified file = 'lisp/textmodes/tex-mode.el'
--- lisp/textmodes/tex-mode.el = 2010-02-16 02:42:03 +0000
+++ lisp/textmodes/tex-mode.el = 2010-03-25 19:42:59 +0000
@@ -1651,9 +1651,12 @@
=   "Like `forward-sexp' but aware of multi-char elements and = escaped parens."
  (interactive "P")
=   (unless arg (setq arg 1))
-  (let ((pos = (point)))
+  (let ((pos (point))
+ =        (prev-pos 0))
=     (condition-case err
- (while = (/=3D arg 0)
+= (while (and (not (eq prev-pos (point)))
+ =             &n= bsp;      (/=3D arg 0))
+ =          (setq prev-pos = (point))
=  (setq arg
(if (> arg 0)
=    (progn (latex-forward-sexp-1) (1- arg))

PS: I = hadn't realised that `tex-mode' defines a = `forward-sexp-function'
hence my ignorant comment about the problem = being in syntax.c's scan_list.

Bye,
Jo=E3o

On Mar 25, = 2010, at 8:17 PM, Chong Yidong wrote:

start with `emacs = -Q'
M-x eval-expression RET (insert (make-string 100000 ?a)) = RET
M-x eval-expression RET (latex-mode) =             &n= bsp;       RET
M-x eval-expression = RET (forward-sexp 200) =             &n= bsp; RET
M-x eval-expression RET (forward-sexp 500) =             &n= bsp; RET
M-x eval-expression RET (forward-sexp (point-max)) =       RET

In some versions of emacs = this does not happen, notably my earlier
Carbon Emacs "GNU Emacs = 22.3.1 (i386-apple-darwin9.7.0, Carbon Version
1.6.0) of 2009-07-26 = on gs674-seijiz.local" after loading some lisp
libraries (don't know = which), like the ones I have bellow (autopair,
yasnippet).

I = can reproduce this slowness even on Emacs 22.3.  It arises = because
tex-mode wants to be able to signal an error if point is in a = containing
expression that ends prematurely, so it does a bit of = backtracking.
(This is the `skip-syntax-backward' call in = latex-forward-sexp-1).

I'm not sure what the best way to fix this = is, though.
On Mar 25, 2010, at 8:17 PM, Chong Yidong = wrote:

start = with `emacs -Q'
M-x eval-expression RET (insert = (make-string 100000 ?a)) RET
M-x eval-expression RET = (latex-mode) =             &n= bsp;       RET
M-x = eval-expression RET (forward-sexp 200) =             &n= bsp; RET
M-x eval-expression RET = (forward-sexp 500) =             &n= bsp; RET
M-x eval-expression RET = (forward-sexp (point-max)) =       RET

In some versions of emacs this = does not happen, notably my = earlier
Carbon Emacs "GNU Emacs 22.3.1 (i386-apple-darwin9.7.0, = Carbon Version
1.6.0) of 2009-07-26 on = gs674-seijiz.local" after loading some = lisp
libraries (don't know which), like the ones I have bellow = (autopair,
yasnippet).

I can reproduce = this slowness even on Emacs 22.3.  It arises = because
tex-mode wants to be = able to signal an error if point is in a = containing
expression that = ends prematurely, so it does a bit of = backtracking.
(This is the = `skip-syntax-backward' call in = latex-forward-sexp-1).

I'm not sure = what the best way to fix this is, = though.


= --Apple-Mail-1--818129441--