diff lisp/progmodes/hideshow.el @ 18237:69bb3a2c95b3

(hideshow): Added a :prefix. (hs-isearch-open): New variable. (hs-flag-region): Use that variable. Changed the semantics of the FLAG parameter and updated the docs. (hs-isearch-open-invisible): New function to be set as a `isearch-pent-invisible' property for hidden overlays, so that isearch can use it. (hs-hide-block-at-point): Tell if we are hiding a comment or a block.
author Richard M. Stallman <rms@gnu.org>
date Fri, 13 Jun 1997 21:31:25 +0000
parents 1e53ce338e0d
children 5ec58687160a
line wrap: on
line diff
--- a/lisp/progmodes/hideshow.el	Fri Jun 13 21:30:38 1997 +0000
+++ b/lisp/progmodes/hideshow.el	Fri Jun 13 21:31:25 1997 +0000
@@ -72,6 +72,7 @@
 
 (defgroup hideshow nil
   "Minor mode for hiding and showing program and comment blocks."
+  :prefix "hs-"
   :group 'languages)
 
 ;;;#autoload
@@ -126,6 +127,20 @@
   :type 'integer
   :group 'hideshow)
 
+(defcustom hs-isearch-open 'block
+"What kind of hidden blocks to open when doing `isearch'.
+It can have the following values:
+    `block'     open only  blocks
+    `comment'   open only comments
+    t           open all of them
+    nil         don't open any.
+This only has effect iff `search-invisible' is set to `open'."
+  :type '(choice (const :tag "open only  blocks" block)
+	         (const :tag "open only comments" comment)
+	         (const :tag "open both blocks and comments" t)
+	         (const :tag "don't open any of them" nil))
+  :group 'hideshow)
+
 (defvar hs-unbalance-handler-method 'top-level
   "*Symbol representing how \"unbalanced parentheses\" should be handled.
 This error is usually signaled by `hs-show-block'.  One of four values:
@@ -286,8 +301,10 @@
 
 ;; snarfed from outline.el;
 (defun hs-flag-region (from to flag)
-  "Hides or shows lines from FROM to TO, according to FLAG.
-If FLAG is nil then text is shown, while if FLAG is t the text is hidden."
+  "Hides or shows lines from FROM to TO, according to FLAG.  If FLAG
+is nil then text is shown, while if FLAG is non-nil the text is
+hidden. Actualy flag is realy either `comment' or `block' depending on
+what kind of block it is suppose to hide."
     (save-excursion
       (goto-char from)
       (end-of-line)
@@ -297,8 +314,18 @@
 	    ;; Make overlay hidden and intangible.
 	    (overlay-put overlay 'invisible 'hs)
 	    (overlay-put overlay 'hs t)
+	    (when (or (eq hs-isearch-open t) (eq hs-isearch-open flag)) 
+		(overlay-put overlay 'isearch-open-invisible 
+			     'hs-isearch-open-invisible))
 	    (overlay-put overlay 'intangible t)))))
 
+;; This is set as an `isearch-open-invisible' property to hidden
+;; overlays.
+(defun hs-isearch-open-invisible (ov)
+  (save-excursion
+    (goto-char (overlay-start ov))
+    (hs-show-block)))
+
 ;; Remove from the region BEG ... END all overlays
 ;; with a PROP property equal to VALUE.
 ;; Overlays with a PROP property different from VALUE are not touched.
@@ -326,7 +353,7 @@
 	(goto-char (nth 1 comment-reg))
 	(unless hs-show-hidden-short-form (forward-line -1))
 	(end-of-line)
-	(hs-flag-region (car comment-reg)  (point) t) 
+	(hs-flag-region (car comment-reg)  (point) 'comment) 
 	(goto-char (if end (nth 1 comment-reg) (car comment-reg))))
       (if (looking-at hs-block-start-regexp)
 	  (let* ((p ;; p is the point at the end of the block beginning
@@ -342,7 +369,7 @@
 	    (end-of-line)
 	    (if (and (< p (point)) (> (count-lines p q) 
 				      (if hs-show-hidden-short-form 1 2)))
-		(hs-flag-region p (point) t))
+		(hs-flag-region p (point) 'block))
 	    (goto-char (if end q p))))))
 
 (defun hs-show-block-at-point (&optional end comment-reg)