Subject: Re: bug#8036: [PATCH] Prevent hide-show mode from getting confused by braces in comments

From: Dima Kogan <[email-masked]>
Date: Tue, 15 Feb 2011 21:01:59 -0800

I have discovered a case where the previous patch causes an infinite
loop. The new patch I'm attaching resolves that issue

--- hideshow.orig.el	2011-02-13 23:01:07.000000000 -0800
+++ hideshow.el	2011-02-15 20:58:14.000000000 -0800
@@ -690,6 +690,7 @@
         (point)
       ;; look backward for the start of a block that contains the cursor
       (while (and (re-search-backward hs-block-start-regexp nil t)
+                  (save-match-data (not (nth 4 (syntax-ppss)))) ; not inside comments
                   (not (setq done
                              (< here (save-excursion
                                        (hs-forward-sexp (match-data t) 1)
@@ -712,10 +713,11 @@
            (forward-comment (buffer-size))
            (and (< (point) maxp)
                 (re-search-forward hs-block-start-regexp maxp t)))
-    (if (> arg 1)
-        (hs-hide-level-recursive (1- arg) minp maxp)
-      (goto-char (match-beginning hs-block-start-mdata-select))
-      (hs-hide-block-at-point t)))
+    (when (save-match-data (not (nth 4 (syntax-ppss)))) ; not inside comments
+      (if (> arg 1)
+          (hs-hide-level-recursive (1- arg) minp maxp)
+        (goto-char (match-beginning hs-block-start-mdata-select))
+        (hs-hide-block-at-point t))))
   (goto-char maxp))
 
 (defmacro hs-life-goes-on (&rest body)