GNU bug report logs - #9502
23.3; [PATCH] hideshow no longer gets confused by characters in strings

Previous Next

Package: emacs;

Reported by: Dima Kogan <dkogan <at> secretsauce.net>

Date: Wed, 14 Sep 2011 08:24:02 UTC

Severity: normal

Tags: patch

Found in version 23.3

Fixed in version 24.1

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Dima Kogan <dkogan <at> secretsauce.net>
To: 9502 <at> debbugs.gnu.org
Subject: bug#9502: 23.3; [PATCH] hideshow no longer gets confused by characters in strings
Date: Wed, 14 Sep 2011 00:38:31 -0700
[Message part 1 (text/plain, inline)]
An earlier patch (bug 8279) made hideshow robust to various characters
appearing in comments. Here's a small patch that extends this, so that
hideshow becomes robust to various characters in strings also.

[0001-hideshow-now-doesn-t-get-confused-by-characters-in-c.patch (text/x-diff, inline)]
From d85459ad47b23dfc8fe2689cd3cc059e9c956544 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima <at> secretsauce.net>
Date: Wed, 14 Sep 2011 00:29:01 -0700
Subject: [PATCH] hideshow now doesn't get confused by characters in comments
 OR strings

Signed-off-by: Dima Kogan <dima <at> secretsauce.net>
---
 lisp/progmodes/hideshow.el |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el
index 49202ab..ca8be01 100644
--- a/lisp/progmodes/hideshow.el
+++ b/lisp/progmodes/hideshow.el
@@ -539,7 +539,7 @@ property of an overlay."
 (defun hs-looking-at-block-start-p ()
   "Return non-nil if the point is at the block start."
   (and (looking-at hs-block-start-regexp)
-       (save-match-data (not (nth 4 (syntax-ppss))))))
+       (save-match-data (not (nth 8 (syntax-ppss))))))
 
 (defun hs-forward-sexp (match-data arg)
   "Adjust point based on MATCH-DATA and call `hs-forward-sexp-func' w/ ARG.
@@ -693,8 +693,8 @@ Return point, or nil if original point was not in a block."
         (point)
       ;; look backward for the start of a block that contains the cursor
       (while (and (re-search-backward hs-block-start-regexp nil t)
-		  ;; go again if in a comment
-		  (or (save-match-data (nth 4 (syntax-ppss)))
+		  ;; go again if in a comment or a string
+		  (or (save-match-data (nth 8 (syntax-ppss)))
 		      (not (setq done
 				 (< here (save-excursion
 					   (hs-forward-sexp (match-data t) 1)
@@ -718,7 +718,7 @@ Return point, or nil if original point was not in a block."
            (and (< (point) maxp)
                 (re-search-forward hs-block-start-regexp maxp t)))
     (when (save-match-data
-	    (not (nth 4 (syntax-ppss)))) ; not inside comments
+	    (not (nth 8 (syntax-ppss)))) ; not inside comments or strings
       (if (> arg 1)
 	  (hs-hide-level-recursive (1- arg) minp maxp)
 	(goto-char (match-beginning hs-block-start-mdata-select))
-- 
1.7.5.4


This bug report was last modified 13 years and 301 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.