emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104406: More fixes to prevent hide-s


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104406: More fixes to prevent hide-show from being confused by commented-out braces (Bug#8279).
Date: Sat, 28 May 2011 14:35:29 -0400
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104406
author: Dima Kogan <address@hidden>
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sat 2011-05-28 14:35:29 -0400
message:
  More fixes to prevent hide-show from being confused by commented-out braces 
(Bug#8279).
  
  * progmodes/hideshow.el (hs-looking-at-block-start-p): New fun.
  (hs-hide-block-at-point, hs-find-block-beginning)
  (hs-already-hidden-p, hs-hide-block, hs-show-block): Use it.
modified:
  lisp/ChangeLog
  lisp/progmodes/hideshow.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-05-28 17:47:45 +0000
+++ b/lisp/ChangeLog    2011-05-28 18:35:29 +0000
@@ -1,3 +1,10 @@
+2011-05-28  Dima Kogan  <address@hidden>  (tiny change)
+
+       * progmodes/hideshow.el (hs-looking-at-block-start-p): New fun.
+       (hs-hide-block-at-point, hs-find-block-beginning)
+       (hs-already-hidden-p, hs-hide-block, hs-show-block): Use it
+       (Bug#8279).
+
 2011-05-28  Glenn Morris  <address@hidden>
 
        * startup.el (fancy-about-screen): Use standard mode line.  (Bug#8740)

=== modified file 'lisp/progmodes/hideshow.el'
--- a/lisp/progmodes/hideshow.el        2011-04-22 18:44:26 +0000
+++ b/lisp/progmodes/hideshow.el        2011-05-28 18:35:29 +0000
@@ -536,6 +536,11 @@
         (overlay-put ov 'display nil))))
   (overlay-put ov 'invisible (and hide-p 'hs)))
 
+(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))))))
+
 (defun hs-forward-sexp (match-data arg)
   "Adjust point based on MATCH-DATA and call `hs-forward-sexp-func' w/ ARG.
 Original match data is restored upon return."
@@ -564,7 +569,7 @@
 and then further adjusted to be at the end of the line."
   (if comment-reg
       (hs-hide-comment-region (car comment-reg) (cadr comment-reg) end)
-    (when (looking-at hs-block-start-regexp)
+    (when (hs-looking-at-block-start-p)
       (let ((mdata (match-data t))
             (header-end (match-end 0))
             p q ov)
@@ -684,16 +689,16 @@
   (let ((done nil)
         (here (point)))
     ;; look if current line is block start
-    (if (looking-at hs-block-start-regexp)
+    (if (hs-looking-at-block-start-p)
         (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)
-                                       (point)))))))
+                 ;; go again if in a comment
+                 (or (save-match-data (nth 4 (syntax-ppss)))
+                     (not (setq done
+                                (< here (save-excursion
+                                          (hs-forward-sexp (match-data t) 1)
+                                          (point))))))))
       (if done
           (point)
         (goto-char here)
@@ -750,7 +755,7 @@
         (end-of-line)
         (when (and (not c-reg)
                    (hs-find-block-beginning)
-                   (looking-at hs-block-start-regexp))
+                  (hs-looking-at-block-start-p))
           ;; point is inside a block
           (goto-char (match-end 0)))))
     (end-of-line)
@@ -835,7 +840,7 @@
                       (<= (count-lines (car c-reg) (nth 1 c-reg)) 1)))
        (message "(not enough comment lines to hide)"))
       ((or c-reg
-           (looking-at hs-block-start-regexp)
+          (hs-looking-at-block-start-p)
            (hs-find-block-beginning))
        (hs-hide-block-at-point end c-reg)
        (run-hooks 'hs-hide-hook))))))
@@ -867,7 +872,7 @@
                      q (cadr c-reg))))
             ((and (hs-find-block-beginning)
                   ;; ugh, fresh match-data
-                  (looking-at hs-block-start-regexp))
+                  (hs-looking-at-block-start-p))
              (setq p (point)
                    q (progn (hs-forward-sexp (match-data t) 1) (point)))))
       (when (and p q)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]