Subject: 24.0.92; hideshow get stucked [Patch included]

From: [email-masked] (Sébastien Gross)
Date: Fri, 13 Jan 2012 19:52:39 +0100

Hi there

Sometimes `hs-hide-all' get stucked for an unknown reason.

I happens with el-get.el file (found at github:
https://raw.github.com/dimitri/el-get/master/el-get.el)

To reproduce the bug simply:

  1. run emacs: "emacs -Q"
  2. Put that in the scratch buffer:

(progn
  (require 'hideshow)
  (find-file "~/.emacs.d/el-get/el-get/el-get.el")
  (require 'hideshow)
  (hs-minor-mode)
  (hs-hide-all))

  3. Execute that code (C-x C-e)

I put a little debugging in hide-show.el (line 806):
             (progn
               (goto-char (match-beginning 1))
	       (message (format "%d %S %d:%S %d:%S %S"
				(point)
				re
				(match-beginning 0) (match-string-no-properties 0)
				(match-beginning 1) (match-string-no-properties 1)
				(match-data)))
                                ...

And I got something like:

8096 "\\(\\s(\\)\\|\\(;\\)" 8096:"(" 8096:"(" (#<marker at 8096 in emacs.d:el-get/el-get/el-get.el> #<marker at 8097 in emacs.d:el-get/el-get/el-get.el> #<marker at 8096 in emacs.d:el-get/el-get/el-get.el> #<marker at 8097 in emacs.d:el-get/el-get/el-get.el>)
8145 "\\(\\s(\\)\\|\\(;\\)" 8145:"(" 8145:"(" (#<marker at 8145 in emacs.d:el-get/el-get/el-get.el> #<marker at 8146 in emacs.d:el-get/el-get/el-get.el> #<marker at 8145 in emacs.d:el-get/el-get/el-get.el> #<marker at 8146 in emacs.d:el-get/el-get/el-get.el>) [3639 times]
Quit

The line @8146 is:
(require 'el-get-notify)		; notification support (dbus, growl...)
                                         ^
point @8146 is just after the semi-colon

I wrote a small patch that fix the bug (you can find it in attachment).

Hope that helps.
Hope that does not break anything.

Cheers

diff -Nu -L /usr/share/emacs/24.0.92/lisp/progmodes/hideshow.el.gz -L /tmp/buffer-content-28178nSw /tmp/jka-com281780c2 /tmp/buffer-content-28178nSw
--- /usr/share/emacs/24.0.92/lisp/progmodes/hideshow.el.gz
+++ /tmp/buffer-content-28178nSw
@@ -804,9 +804,13 @@
              ;; we have found a block beginning
              (progn
                (goto-char (match-beginning 1))
-               (if hs-hide-all-non-comment-function
-                   (funcall hs-hide-all-non-comment-function)
-                 (hs-hide-block-at-point t)))
+	       (unless
+		   (if hs-hide-all-non-comment-function
+		       (funcall hs-hide-all-non-comment-function)
+		     (hs-hide-block-at-point t))
+		 ;; Go to end of matched data to prevent from getting stuck
+		 ;; with an endless loop.
+		 (goto-char (match-end 0))))
            ;; found a comment, probably
            (let ((c-reg (hs-inside-comment-p)))
              (when (and c-reg (car c-reg))

In GNU Emacs 24.0.92.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1)
 of 2012-01-11 on cw-bkp0, modified by Debian
 (emacs-snapshot package, version 1:20120111-1+squeeze)
Windowing system distributor `The X.Org Foundation', version 11.0.11004000
configured using `configure  '--build' 'x86_64-linux-gnu' '--host' 'x86_64-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.0.92/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.0.92/site-lisp:/usr/share/emacs/site-lisp' '--without-compress-info' '--with-crt-dir=/usr/lib//' '--with-x=yes' '--with-x-toolkit=gtk' '--with-imagemagick=yes' 'build_alias=x86_64-linux-gnu' 'host_alias=x86_64-linux-gnu' 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g -Wl,--as-needed' 'CPPFLAGS=''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: en_US.UTF-8
  value of $LC_CTYPE: en_US.UTF-8
  value of $LC_MESSAGES: en_US.UTF-8
  value of $LC_MONETARY: fr_FR.UTF-8
  value of $LC_NUMERIC: en_US.UTF-8
  value of $LC_TIME: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  hs-minor-mode: t

Recent input:
<down-mouse-2> <mouse-2> C-x C-e n <escape> x r e p 
o r t <tab> <return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
el-get.el has auto save data; consider M-x recover-this-file
Please type y, n, or !: n
Loading vc-git...done
Hiding all blocks...
Quit

Load-path shadows:
/usr/share/emacs/24.0.92/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup

Features:
(shadow sort gnus-util mail-extr message format-spec rfc822 mml mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mailabbrev mail-utils gmm-utils mailheader
emacsbug vc-git hideshow easymenu time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image fringe
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 loaddefs 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 dbusbind
dynamic-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)

-- 
Sébastien Gross