diff options
| -rw-r--r-- | lisp/progmodes/hideshow.el | 35 |
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) |
