unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#8036: [PATCH] Prevent hide-show mode from getting confused by braces in comments
@ 2011-02-14  7:02 Dima Kogan
       [not found] ` <handler.8036.B.129767263825636.ack@debbugs.gnu.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Dima Kogan @ 2011-02-14  7:02 UTC (permalink / raw)
  To: 8036

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

Emacs bug #700 (http://debbugs.gnu.org/cgi/bugreport.cgi?bug=700)
contained a patch by Dmitry Bolshakov addressing 2 issues in hide-show
minor mode. The fix to one of the issues got integrated into the code
base, but the other one fell through the cracks, I think. The issue it
fixes is to prevent hide-show mode from parsing braces inside comments.
These braces can confuse the parser, since they don't necessarily match
up.

I'm attaching Dmitry's test case that demonstrates the issue, and his patch to
fix it.

dima

[-- Attachment #2: unbalanced-braces-test.pl --]
[-- Type: application/x-perl, Size: 155 bytes --]

[-- Attachment #3: hs.patch --]
[-- Type: text/x-patch, Size: 1258 bytes --]

--- hideshow.el.original_emacs_22.2	2008-01-10 12:15:42.000000000 -0800
+++ hideshow_my.el	2008-08-12 15:39:12.000000000 -0700
@@ -541,7 +541,10 @@
              (q
               ;; `q' is the point at the end of the block
               (progn (hs-forward-sexp mdata 1)
-                     (end-of-line)
+					 ;; see http://www.emacswiki.org/cgi-bin/wiki/HideShow and search page for "hs-block-includes-last-line"
+					 ;(forward-line -1)
+                     ;(end-of-line)
+					 (backward-char 1) ; better
                      (point)))
              ov)
         (when (and (< p (point)) (> (count-lines p q) 1))
@@ -672,10 +675,13 @@
            (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 (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)

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

end of thread, other threads:[~2011-02-19 22:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-14  7:02 bug#8036: [PATCH] Prevent hide-show mode from getting confused by braces in comments Dima Kogan
     [not found] ` <handler.8036.B.129767263825636.ack@debbugs.gnu.org>
2011-02-15  4:20   ` bug#8036: Acknowledgement ([PATCH] Prevent hide-show mode from getting confused by braces in comments) Dima Kogan
2011-02-16  5:01   ` bug#8036: [PATCH] Prevent hide-show mode from getting confused by braces in comments Dima Kogan
2011-02-19 22:20     ` 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).