Subject: 23.1.94; (forward-sexp N) at the very end of large latex-mode buffer takes time proportional to N

From: [email-masked] (Joao Tavora)
Date: Wed, 17 Mar 2010 23:04:18 +0100

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)