Subject: 24.2.50; js2-mode freezes on current trunk

From: Dmitry Gutov <[email-masked]>
Date: Sun, 02 Sep 2012 01:57:34 +0400

js2-mode freezes during editing in some buffers.

This has been a long-standing complaint on Mac OS X port, but now it
affect Linux and Windows users too, see
https://github.com/mooz/js2-mode/issues/49

Bisecting the Bazaar history (on a Windows machine) points to the
month-old commit no 109470, which adds one line in `timer_check_2'.

Here's the timer-scheduling function from js2-mode:

(defun js2-mode-reset-timer ()
   "Cancel any existing parse timer and schedule a new one."
   (if js2-mode-parse-timer
       (cancel-timer js2-mode-parse-timer))
   (setq js2-mode-parsing nil)
   (setq js2-mode-parse-timer
         (run-with-idle-timer js2-idle-timer-delay nil
                              #'js2-mode-idle-reparse (current-buffer))))

It's only called from an after-change function and from a
`js2-mode-idle-reparse' callee, in case parsing has been interrupted.
To handle interruptions, the parser code periodically calls
(input-pending-p), and when it's true, aborts and reschedules.

Any ideas?

In GNU Emacs 24.2.50.1 (i386-mingw-nt6.1.7601)
  of 2012-09-01 on SOL
Bzr revision: 109843 [email-masked]
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
  `configure --with-gcc (3.4) --cflags -IJ:/Apps/system/gnuwin32/include'

Important settings:
   value of $EMACSDATA: C:/Users/gutov/vc/emacs-bzr/trunk/etc
   value of $EMACSDOC: C:/Users/gutov/vc/emacs-bzr/trunk/etc
   value of $EMACSLOADPATH: 
C:/Users/gutov/vc/emacs-bzr/trunk/site-lisp;C:/Users/gutov/vc/emacs-bzr/trunk/../site-lisp;C:/Users/gutov/vc/emacs-bzr/trunk/lisp;C:/Users/gutov/vc/emacs-bzr/trunk/leim
   value of $EMACSPATH: C:/Users/gutov/vc/emacs-bzr/trunk/bin
   value of $LANG: RUS
   locale-coding-system: cp1251
   default enable-multibyte-characters: t

Major mode: Bzr-Log-View

Minor modes in effect:
   recentf-mode: t
   helm-dired-mode: Enable helm completion in Dired functions.
Bindings affected are C, R, S, H.
This is deprecated for Emacs24+ users, use `helm-mode' instead.
   shell-dirtrack-mode: t
   helm-match-plugin-mode: t
   global-undo-tree-mode: t
   undo-tree-mode: t
   global-diff-hl-mode: t
   diff-auto-refine-mode: t
   savehist-mode: t
   yas/global-mode: t
   yas/minor-mode: t
   global-auto-revert-mode: t
   cua-mode: t
   global-ethan-wspace-mode: t
   global-auto-complete-mode: t
   autopair-global-mode: t
   ido-ubiquitous-mode: t
   ido-everywhere: t
   show-paren-mode: t
   mouse-wheel-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   buffer-read-only: t
   column-number-mode: t
   line-number-mode: t
   transient-mark-mode: t

Recent input:
<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-up>
<double-wheel-up> <triple-wheel-up> <triple-wheel-up>
<help-echo> <down-mouse-1> <mouse-1> <help-echo> <help-echo>
<down-mouse-1> <mouse-1> <wheel-down> <wheel-up> <double-wheel-up>
<wheel-up> <double-wheel-up> <triple-wheel-up> <triple-wheel-up>
<wheel-up> <double-wheel-up> <triple-wheel-up> <triple-wheel-up>
<triple-wheel-up> <wheel-up> <double-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> <help-echo> <help-echo> <help-echo>
<help-echo> <down-mouse-1> <mouse-1> C-x 3 C-; \ .
e r b <return> <down> <down> <down> <end> SPC <backspace>
SPC <backspace> SPC <backspace> SPC <backspace> SPC
<backspace> <home> <delete> SPC <backspace> <delete>
SPC C-z SPC C-z <down> SPC <backspace> <up> <down>
<end> <up> <up> <up> <backspace> % <backspace> % <backspace>
% <backspace> % <backspace> ? % <backspace> <backspace>
% <backspace> % <backspace> % <backspace> % <down>
<down> <down> <down> C-x 0 <wheel-down> <double-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> <wheel-up> <double-wheel-up> <triple-wheel-up>
<triple-wheel-up> <help-echo> <down-mouse-1> <mouse-1>
<wheel-down> <double-wheel-down> <triple-wheel-down>
<help-echo> <help-echo> <down-mouse-1> <mouse-1> <wheel-up>
<double-wheel-up> <triple-wheel-up> <triple-wheel-up>
<triple-wheel-up> <wheel-down> <double-wheel-down>
<triple-wheel-down> C-c <left> C-c <left> C-c <left>
C-c <left> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <prior> <next> <next> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <up> <up> <up> <up> <up> <up> <up> <up> <up>
<up> <up> <up> <up> <up> <up> <up> <up> <up> <up> <down>
<down> <down> <left> C-x 3 M-x r e p o r t - e m a
c s <right> <return>

Recent messages:
Winner undo (1 / 8)
Finding changes in c:/Users/gutov/vc/emacs-bzr/trunk/src/keyboard.c...
byte-code: End of buffer [8 times]
byte-code: Beginning of buffer [7 times]

Undo branch point!
Winner undo (1 / 15)
Winner undo (2 / 15)
Winner undo (3 / 15)
Winner undo (4 / 14)

Load-path shadows:
c:/Users/gutov/.emacs.d/elpa/magit-20120616/.dir-locals hides 
c:/Users/gutov/.emacs.d/elpa/sunrise-commander-20120705/.dir-locals
c:/Users/gutov/.emacs.d/elpa/magit-20120616/.dir-locals hides 
c:/Users/gutov/vc/emacs-bzr/trunk/lisp/gnus/.dir-locals

Features:
(shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mail-utils js json imenu css-mode
ruby-electric ruby-tools inf-ruby ruby-mode mmm-mode mmm-univ mmm-class
subword mmm-erb derived mmm-region mmm-utils sgml-mode whitespace
add-log log-view pcvs-util vc-bzr cc-langs cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs unsafep
flyspell ispell recentf tree-widget wid-edit bow helm-files image-dired
tramp tramp-compat tramp-loaddefs shell pcomplete format-spec dired-x
dired-aux thingatpt helm-tags helm-locate helm-help helm-grep
helm-regexp grep helm-external helm-bookmark helm-buffers helm-elscreen
helm-utils compile comint ansi-color helm-match-plugin helm helm-config
elisp-slime-nav etags paredit saveplace undo-tree diff diff-hl
face-remap vc-hg vc-git vc ediff-merg ediff-diff ediff-wind ediff-help
ediff-util ediff-mult ediff-init ediff vc-dispatcher diff-mode savehist
yasnippet autorevert cua-base winner point-stack .emacs-loaddefs
cyril-util devenv ethan-wspace pos-tip ac-slime auto-complete-config
auto-complete popup eproject-extras ibuf-macs ibuf-ext ibuffer iswitchb
eproject esh-var esh-io esh-cmd esh-opt esh-ext esh-proc esh-arg eldoc
esh-groups eshell esh-module esh-mode esh-util progmodes dropdown-list
mmm mmm-auto mmm-vars mmm-compat autopair easy-mmode keys switch-window
quail help-mode easymenu hippie dired winring ring transpose-frame
iflipb misc prefs defuns birds-of-paradise-plus-theme-autoloads
coffee-mode-autoloads eldoc-eval-autoloads findr-autoloads
gist-autoloads gh-autoloads inf-ruby-autoloads inflections-autoloads
iy-go-to-char-autoloads logito-autoloads move-text-autoloads
pcache-autoloads finder-inf rainbow-mode-autoloads
ruby-electric-autoloads ruby-tools-autoloads
starter-kit-bindings-autoloads windmove starter-kit-lisp-autoloads
cl-macs gv elisp-slime-nav-autoloads starter-kit-autoloads edmacro
kmacro smex cl cl-lib starter-kit-misc warnings ffap url-parse
auth-source eieio byte-opt bytecomp byte-compile cconv macroexp
gnus-util mm-util mail-prsvr password-cache url-vars ido-ubiquitous ido
paren starter-kit-defuns uniquify advice help-fns advice-preload
magit-autoloads ido-ubiquitous-autoloads smex-autoloads
find-file-in-project-autoloads idle-highlight-mode-autoloads
paredit-autoloads sunrise-commander-autoloads switch-window-autoloads
tango-2-theme-autoloads twilight-bright-theme-autoloads typing-autoloads
undo-tree-autoloads volatile-highlights-autoloads wgrep-autoloads
yaml-mode-autoloads package time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel dos-w32 disp-table ls-lisp w32-win w32-vars
tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
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
minibuffer button faces cus-face files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process multi-tty emacs)