summaryrefslogtreecommitdiff
path: root/lisp/progmodes/hideshow.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-06-13 21:31:25 +0000
committerRichard M. Stallman <rms@gnu.org>1997-06-13 21:31:25 +0000
commit12e36cdba6e04be2ef6aeb76f5419a620ba0eac4 (patch)
treeeb28a092cd4fea11efc2aa65e3948d4d8f5403ae /lisp/progmodes/hideshow.el
parent0352b205714e1c7ab97c1b6dc7678f6b51ebe089 (diff)
downloademacs-12e36cdba6e04be2ef6aeb76f5419a620ba0eac4.tar.gz
(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.
Diffstat (limited to 'lisp/progmodes/hideshow.el')
-rw-r--r--lisp/progmodes/hideshow.el35
1 files changed, 31 insertions, 4 deletions
diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el
index 92de8914fed..f9608a0d7c9 100644
--- a/lisp/progmodes/hideshow.el
+++ b/lisp/progmodes/hideshow.el
@@ -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 @@ hide all the comments at the beginning of the file."
: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 @@ See `hs-c-like-adjust-block-beginning' for an example of using this.")
;; 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 @@ If FLAG is nil then text is shown, while if FLAG is t the text is hidden."
;; 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 @@ of the comment, or nil if the block is not a comment."
(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 @@ of the comment, or nil if the block is not a comment."
(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)