From unknown Mon Jun 23 18:33:52 2025 X-Loop: bug-gnu-emacs@gnu.org Subject: bug#5734: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N Resent-From: joaotavora@gmail.com (Joao Tavora) Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 17 Mar 2010 22:11:02 +0000 Resent-Message-ID: Resent-Sender: bug-gnu-emacs@gnu.org X-GNU-PR-Message: report 5734 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 5734@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.126886381310529 (code B ref -1); Wed, 17 Mar 2010 22:11:02 +0000 Received: (at submit) by debbugs.gnu.org; 17 Mar 2010 22:10:13 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ns1RM-0002jm-Ld for submit@debbugs.gnu.org; Wed, 17 Mar 2010 18:10:13 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ns1Ly-0002hJ-Ji for submit@debbugs.gnu.org; Wed, 17 Mar 2010 18:04:52 -0400 Received: from lists.gnu.org ([199.232.76.165]:37224) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Ns1Lu-0002YT-AS for submit@debbugs.gnu.org; Wed, 17 Mar 2010 18:04:34 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ns1Lu-0001eL-36 for bug-gnu-emacs@gnu.org; Wed, 17 Mar 2010 18:04:34 -0400 Received: from [140.186.70.92] (port=33242 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ns1Ls-0001aU-8F for bug-gnu-emacs@gnu.org; Wed, 17 Mar 2010 18:04:33 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.0 (2010-01-18) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID, T_FRT_BELOW2, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.0 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ns1Lp-00079g-3L for bug-gnu-emacs@gnu.org; Wed, 17 Mar 2010 18:04:31 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:57932) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ns1Lo-00079b-ON for bug-gnu-emacs@gnu.org; Wed, 17 Mar 2010 18:04:29 -0400 Received: by wyf22 with SMTP id 22so775577wyf.0 for ; Wed, 17 Mar 2010 15:04:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:user-agent :date:message-id:mime-version:content-type; bh=XvZMUEt+5u5dzcLItjvNCfl7DcXezSNPLmEiuSdTAx4=; b=aCk14p7g9+BK81H8xsuQVUQSfZcPIQmd5QiNPPFpgP3b1iSjYjzV95CbudK6jfxXhC EQbgIVS4ruqvuJadPUF7H8kd3iBTNwLzbu75La5TUj8rHPJ1hATN4JKmZaZel7xLUeFB zv1R6AlyG+5PPPjJZdMvceAL5QKk/36M+V/vM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:user-agent:date:message-id:mime-version :content-type; b=pRCbVrzGk6bNARPqG4QvWoVxmPJ+I1UGSCh04/hQzh+XgKmPbBMLZxF1g96k0TGzX+ pmXvoEakVUNFwgC1MLgj1673V5OJ3X57D/j8+/L6CUeDVqeBKIiMk7K+ySJWmzowrNSu xQmFysutvUWX4UznOUxQMMYcvv+4vycxQLWCY= Received: by 10.216.157.149 with SMTP id o21mr890935wek.4.1268863466028; Wed, 17 Mar 2010 15:04:26 -0700 (PDT) Received: from king.local.holyhandgrenade.com (83.155.218.87.dynamic.jazztel.es [87.218.155.83]) by mx.google.com with ESMTPS id t2sm2657190gve.19.2010.03.17.15.04.23 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 17 Mar 2010 15:04:24 -0700 (PDT) From: joaotavora@gmail.com (Joao Tavora) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.94 (darwin) Date: Wed, 17 Mar 2010 23:04:18 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -3.3 (---) X-Mailman-Approved-At: Wed, 17 Mar 2010 18:10:11 -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: -4.6 (----) Hi, This originated in http://code.google.com/p/autopair/issues/detail?id=21: 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 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). The purpose I use these kind of calls to `forward-sexp' is to check if the buffer is sexp-balanced, as in autopair.el. Now I think I can work around this in my lisp code without using this kind of call, but still... When point reaches the end of the buffer, scan_lists in syntax.c can just return right? Thanks in advance, Joao Tavora In GNU Emacs 23.1.94.5 (x86_64-apple-darwin10.2.0, NS apple-appkit-1038.25) of 2010-03-16 on king.local Windowing system distributor `Apple', version 10.3.1038 configured using `configure '--with-ns'' 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: nil value of $XMODIFIERS: nil locale-coding-system: nil default enable-multibyte-characters: t Major mode: Apropos Minor modes in effect: shell-dirtrack-mode: t yas/global-mode: t display-time-mode: t cua-mode: t autopair-mode: t autopair-global-mode: t global-hl-line-mode: t recentf-mode: t show-paren-mode: t ido-everywhere: t global-hs-mode: t heretic/mode: 0 tooltip-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: s-x M-< C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n M-x e m a c r e p o b u C-g M-x b C-g M-x a p r o p o s RET b u g RET C-x o C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n C-s e m a c s C-s C-s C-s C-p C-b C-b C-b C-b C-b C-b RET C-n C-n C-n C-n C-n C-n C-n C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-n C-n C-n C-n C-n C-n M-x r e p o r t SPC e m a c RET Recent messages: 1293422 (#o4736156, #x13bc6e) nil [2 times] byte-code: End of buffer [2 times] byte-code: Beginning of buffer [2 times] byte-code: End of buffer [7 times] Mark set Making completion list... Quit [2 times] Mark saved where search started Type M-x display-buffer RET to restore the other window. Load-path shadows: /Applications/Emacs - 23.app/Contents/Resources/lisp/progmodes/flymake hides /Volumes/home/capitaomorte/holy/share/emacs/common/site-lisp/10hacks/flymake /Applications/Emacs - 23.app/Contents/Resources/lisp/linum hides /Volumes/home/capitaomorte/holy/share/emacs/common/site-lisp/20misc/linum /Volumes/home/capitaomorte/holy/share/emacs/common/site-lisp/yasnippet/extras/imported/html-mode/.yas-setup hides /Volumes/home/capitaomorte/holy/share/emacs/common/site-lisp/yasnippet/extras/imported/objc-mode/.yas-setup /Volumes/home/capitaomorte/holy/share/emacs/common/site-lisp/yasnippet/extras/imported/html-mode/.yas-setup hides /Volumes/home/capitaomorte/holy/share/emacs/common/site-lisp/yasnippet/extras/imported/rails-mode/.yas-setup /Volumes/home/capitaomorte/holy/share/emacs/common/site-lisp/yasnippet/extras/imported/html-mode/.yas-setup hides /Volumes/home/capitaomorte/holy/share/emacs/common/site-lisp/yasnippet/extras/imported/ruby-mode/.yas-setup Features: (shadow sort mail-extr gnus-msg emacsbug apropos ispell tex-mode yasnippet tramp-imap tramp-gw tramp-fish tramp-smb tramp-cache tramp-ftp tramp-cmds tramp auth-source shell tramp-compat trampver jka-compr find-func help-mode debug vc-svn ffap multi-isearch cedet dropdown-list woman man assoc highlight-regexp ruby-mode flymake perl-find-library cperl-mode sgml-mode nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc xmltok time imenu cua-base autopair hl-line windmove uniquify recentf tree-widget paren ido hideshowvis hideshow ediff-merg ediff-diff ediff-wind ediff-help ediff-util ediff-mult ediff-init ediff vc vc-dispatcher gnus-cite gnus-art mm-uu mml2015 pgg pgg-parse pgg-def epg-config mm-view smime dig gnus-sum nnoo gnus-group gnus-undo nnmail mail-source format-spec gnus-start gnus-spec gnus-int message ecomplete rfc822 mml mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev gmm-utils mailheader canlock sha1 hex-util hashcash gnus-win gnus-range gnus gnus-ems nnheader gnus-util netrc time-date mail-utils mm-util mail-prsvr em-cmpl em-term term disp-table ehelp electric em-prompt esh-var esh-io esh-cmd esh-ext esh-proc esh-arg eldoc esh-groups eshell esh-module esh-mode esh-util server idle-highlight vc-ediff dired-details+ dired-details dired-x dired-aux dired view thingatpt rcompile cc-mode cc-fonts cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs regexp-opt advice help-fns advice-preload ibuffer package reporter zenburn color-theme edmacro kmacro wid-edit heretic heretic-project ack derived grep compile comint ring easy-mmode holy cl cl-19 tooltip ediff-hook vc-hooks lisp-float-type mwheel ns-win easymenu tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces cus-face files text-properties overlay md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process ns multi-tty emacs) From unknown Mon Jun 23 18:33:52 2025 X-Loop: bug-gnu-emacs@gnu.org Subject: bug#5734: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N References: In-Reply-To: Resent-From: Chong Yidong 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:18: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: To: joaotavora@gmail.com (Joao Tavora) Cc: 5734@debbugs.gnu.org Received: via spool by 5734-submit@debbugs.gnu.org id=B5734.126954463920553 (code B ref 5734); Thu, 25 Mar 2010 19:18:02 +0000 Received: (at 5734) by debbugs.gnu.org; 25 Mar 2010 19:17:19 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NusYR-0005LS-A1 for submit@debbugs.gnu.org; Thu, 25 Mar 2010 15:17:19 -0400 Received: from pantheon-po33.its.yale.edu ([130.132.50.94]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NusYO-0005LN-VS for 5734@debbugs.gnu.org; Thu, 25 Mar 2010 15:17:17 -0400 Received: from furry (dhcp128036014175.central.yale.edu [128.36.14.175]) (authenticated bits=0) by pantheon-po33.its.yale.edu (8.12.11.20060308/8.12.11) with ESMTP id o2PJHCOq013889 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 25 Mar 2010 15:17:12 -0400 Received: by furry (Postfix, from userid 1000) id A9865C011; Thu, 25 Mar 2010 15:17:12 -0400 (EDT) From: Chong Yidong Date: Thu, 25 Mar 2010 15:17:12 -0400 Message-ID: <8739zoi53b.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.8 (--) 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.8 (--) > 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 > 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. From unknown Mon Jun 23 18:33:52 2025 X-Loop: bug-gnu-emacs@gnu.org Subject: bug#5734: Fwd: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N 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: To: 5734@debbugs.gnu.org Received: via spool by 5734-submit@debbugs.gnu.org id=B5734.126954685721432 (code B ref 5734); Thu, 25 Mar 2010 19:55:02 +0000 Received: (at 5734) by debbugs.gnu.org; 25 Mar 2010 19:54: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 1Nut8C-0005Zd-KL for submit@debbugs.gnu.org; Thu, 25 Mar 2010 15:54:17 -0400 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 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= Received: by 10.216.85.143 with SMTP id u15mr1542780wee.205.1269546849742; Thu, 25 Mar 2010 12:54:09 -0700 (PDT) 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) From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Content-Type: multipart/alternative; boundary=Apple-Mail-1--818129441 Date: Thu, 25 Mar 2010 20:54:06 +0100 References: <72E45B8A-4496-440D-9D38-F9280DE76397@gmail.com> Message-Id: <1D21EF7D-A103-48F3-93DF-239440762783@gmail.com> Mime-Version: 1.0 (Apple Message framework v1077) X-Mailer: Apple Mail (2.1077) X-Spam-Score: -2.4 (--) 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 (--) --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-- From unknown Mon Jun 23 18:33:52 2025 X-Loop: help-debbugs@gnu.org Subject: bug#5734: Fwd: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N Resent-From: Chong Yidong Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 03 Aug 2012 02:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5734 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Cc: 5734@debbugs.gnu.org Received: via spool by 5734-submit@debbugs.gnu.org id=B5734.134396150330310 (code B ref 5734); Fri, 03 Aug 2012 02:39:01 +0000 Received: (at 5734) by debbugs.gnu.org; 3 Aug 2012 02:38:23 +0000 Received: from localhost ([127.0.0.1]:57853 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Sx7mR-0007sp-HJ for submit@debbugs.gnu.org; Thu, 02 Aug 2012 22:38:23 -0400 Received: from mail-yx0-f172.google.com ([209.85.213.172]:43022) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Sx7mP-0007si-Ve for 5734@debbugs.gnu.org; Thu, 02 Aug 2012 22:38:22 -0400 Received: by yenq13 with SMTP id q13so266381yen.3 for <5734@debbugs.gnu.org>; Thu, 02 Aug 2012 19:30:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type:content-transfer-encoding; bh=jgacF0I2qnkw1Y4pXBPx8iSnNsv705Lqi38X9a1TpPo=; b=eeEptggQiOiPjocnlePGUUk9BSeEh7bXawikqWuCNNAY5zoO+41G3cuzRK6K9KRrvS EaRtUZJJnQxSN56Y0vDCHaRYqPGV9mDL3yi5sptmbZF6oybRj/7hDlePULsLZM5rtwu/ WydK9Cc9dMRzCSLwzt7naWRnzNY42lo6qnJvDn0pmMtdMa9t+K60FiUJGNsONtkw4N1a IOgHpT5elu4qgcas6Sy9N+P7UT0PQUbhBWk69hlaPv85QDkwSPKaZ8hLaMVhw8NRfTEd 6NuH1rDUhAV1pstgKoGaVLqURMktdA1yEeY4Jnf6gtJIc9L5pJjaE0XpJ+zDKhNBJ0Ge ticA== Received: by 10.60.13.228 with SMTP id k4mr392155oec.28.1343961048032; Thu, 02 Aug 2012 19:30:48 -0700 (PDT) Received: from ulysses ([155.69.17.245]) by mx.google.com with ESMTPS id hc9sm8095166obc.15.2012.08.02.19.30.45 (version=SSLv3 cipher=OTHER); Thu, 02 Aug 2012 19:30:47 -0700 (PDT) From: Chong Yidong References: <72E45B8A-4496-440D-9D38-F9280DE76397@gmail.com> <1D21EF7D-A103-48F3-93DF-239440762783@gmail.com> Date: Fri, 03 Aug 2012 10:30:42 +0800 In-Reply-To: <1D21EF7D-A103-48F3-93DF-239440762783@gmail.com> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Thu, 25 Mar 2010 20:54:06 +0100") Message-ID: <874nokyael.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 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.6 (--) Jo=C3=A3o T=C3=A1vora writes: > 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 :-) I've committed this patch to trunk. From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 02 22:38:34 2012 Received: (at control) by debbugs.gnu.org; 3 Aug 2012 02:38:35 +0000 Received: from localhost ([127.0.0.1]:57856 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Sx7mc-0007tB-Nl for submit@debbugs.gnu.org; Thu, 02 Aug 2012 22:38:34 -0400 Received: from mail-ob0-f172.google.com ([209.85.214.172]:57752) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Sx7mb-0007t4-7g for control@debbugs.gnu.org; Thu, 02 Aug 2012 22:38:33 -0400 Received: by obbwc20 with SMTP id wc20so339588obb.3 for ; Thu, 02 Aug 2012 19:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:mime-version:content-type; bh=r4xGyLgiLSif3lcPDVaViwwxrrthFp9z2ZrGqW23sp4=; b=aoCANp9etpokPcFswq7QsznGmgqkmv071nHbBEPqb70u3Z+FBEOQQMoFiUPITcV8d8 pWOYB2993TTL0z87lwIDze1lzbVnIAdOH4/1qm5ml0GHJDG2shfGNxPBHuJ1z70HcZNP qQnNCyZXXG5ncZtDYXy1MFG7S2i8yfjat6X8/7ahmh+fMXdY7wi6W8lvgJOA0ueXLHsO gFRs9fMJtuSkPY4S2lMaH9xWwZJ66aLDPgNdngNzf6PnxKNbuueUO0rfR3QywI1LNv2h 30TfTqknVJ2C9OqoJAdf0b+pStgBKsDW+Z349IUz32ar1I5Cxbphw+3S5h/caA+COAew zYxA== Received: by 10.182.110.37 with SMTP id hx5mr319443obb.48.1343961059344; Thu, 02 Aug 2012 19:30:59 -0700 (PDT) Received: from ulysses ([155.69.17.245]) by mx.google.com with ESMTPS id o9sm6409876oeg.5.2012.08.02.19.30.57 (version=SSLv3 cipher=OTHER); Thu, 02 Aug 2012 19:30:58 -0700 (PDT) From: Chong Yidong To: control@debbugs.gnu.org Subject: close 5734 Date: Fri, 03 Aug 2012 10:30:54 +0800 Message-ID: <87k3xgd7vl.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 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.6 (--) close 5734 thanks