unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#5734: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N
@ 2010-03-17 22:04 ` Joao Tavora
  2010-03-25 19:17   ` Chong Yidong
  2010-03-25 19:54   ` bug#5734: Fwd: " João Távora
  0 siblings, 2 replies; 4+ messages in thread
From: Joao Tavora @ 2010-03-17 22:04 UTC (permalink / raw)
  To: 5734

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:
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<wheel-down> <double-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <wheel-up> <double-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <triple-wheel-up> <triple-wheel-up> 
<wheel-down> <double-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <wheel-down> <double-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <wheel-up> <double-wheel-up> <triple-wheel-up> 
<triple-wheel-up> <down-mouse-1> <mouse-1> <wheel-down> 
<double-wheel-down> <triple-wheel-down> <triple-wheel-down> 
<triple-wheel-down> <triple-wheel-down> <down-mouse-1> 
<mouse-1> 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 <tab> r e p o <tab> <backspace> 
<backspace> <backspace> <backspace> b u <tab> <tab> 
<tab> <backspace> <backspace> <tab> C-g M-x b C-g M-x 
a p r o p o s RET b u g <tab> <backspace> 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 <tab> 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)







^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#5734: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N
  2010-03-17 22:04 ` bug#5734: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N Joao Tavora
@ 2010-03-25 19:17   ` Chong Yidong
  2010-03-25 19:54   ` bug#5734: Fwd: " João Távora
  1 sibling, 0 replies; 4+ messages in thread
From: Chong Yidong @ 2010-03-25 19:17 UTC (permalink / raw)
  To: Joao Tavora; +Cc: 5734

> 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.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#5734: Fwd: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N
  2010-03-17 22:04 ` bug#5734: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N Joao Tavora
  2010-03-25 19:17   ` Chong Yidong
@ 2010-03-25 19:54   ` João Távora
  2012-08-03  2:30     ` Chong Yidong
  1 sibling, 1 reply; 4+ messages in thread
From: João Távora @ 2010-03-25 19:54 UTC (permalink / raw)
  To: 5734

[-- Attachment #1: Type: text/plain, Size: 3512 bytes --]

Forgot to cc the bug db.

Begin forwarded message:

> From: João Távora <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 :-)
> 
> === 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 (/= arg 0)
> +	(while (and (not (eq prev-pos (point)))
> +                    (/= 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ão
> 
> 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)                     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.
> 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)                     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.
> 


[-- Attachment #2: Type: text/html, Size: 7305 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#5734: Fwd: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N
  2010-03-25 19:54   ` bug#5734: Fwd: " João Távora
@ 2012-08-03  2:30     ` Chong Yidong
  0 siblings, 0 replies; 4+ messages in thread
From: Chong Yidong @ 2012-08-03  2:30 UTC (permalink / raw)
  To: João Távora; +Cc: 5734

João Távora <joaotavora@gmail.com> 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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-03  2:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <72E45B8A-4496-440D-9D38-F9280DE76397@gmail.com>
2010-03-17 22:04 ` bug#5734: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N Joao Tavora
2010-03-25 19:17   ` Chong Yidong
2010-03-25 19:54   ` bug#5734: Fwd: " João Távora
2012-08-03  2:30     ` Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).