diff options
| author | Richard M. Stallman | 1997-06-13 21:31:25 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-06-13 21:31:25 +0000 |
| commit | 12e36cdba6e04be2ef6aeb76f5419a620ba0eac4 (patch) | |
| tree | eb28a092cd4fea11efc2aa65e3948d4d8f5403ae | |
| parent | 0352b205714e1c7ab97c1b6dc7678f6b51ebe089 (diff) | |
| download | emacs-12e36cdba6e04be2ef6aeb76f5419a620ba0eac4.tar.gz emacs-12e36cdba6e04be2ef6aeb76f5419a620ba0eac4.zip | |
(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.
| -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 @@ | |||
| 72 | 72 | ||
| 73 | (defgroup hideshow nil | 73 | (defgroup hideshow nil |
| 74 | "Minor mode for hiding and showing program and comment blocks." | 74 | "Minor mode for hiding and showing program and comment blocks." |
| 75 | :prefix "hs-" | ||
| 75 | :group 'languages) | 76 | :group 'languages) |
| 76 | 77 | ||
| 77 | ;;;#autoload | 78 | ;;;#autoload |
| @@ -126,6 +127,20 @@ hide all the comments at the beginning of the file." | |||
| 126 | :type 'integer | 127 | :type 'integer |
| 127 | :group 'hideshow) | 128 | :group 'hideshow) |
| 128 | 129 | ||
| 130 | (defcustom hs-isearch-open 'block | ||
| 131 | "What kind of hidden blocks to open when doing `isearch'. | ||
| 132 | It can have the following values: | ||
| 133 | `block' open only blocks | ||
| 134 | `comment' open only comments | ||
| 135 | t open all of them | ||
| 136 | nil don't open any. | ||
| 137 | This only has effect iff `search-invisible' is set to `open'." | ||
| 138 | :type '(choice (const :tag "open only blocks" block) | ||
| 139 | (const :tag "open only comments" comment) | ||
| 140 | (const :tag "open both blocks and comments" t) | ||
| 141 | (const :tag "don't open any of them" nil)) | ||
| 142 | :group 'hideshow) | ||
| 143 | |||
| 129 | (defvar hs-unbalance-handler-method 'top-level | 144 | (defvar hs-unbalance-handler-method 'top-level |
| 130 | "*Symbol representing how \"unbalanced parentheses\" should be handled. | 145 | "*Symbol representing how \"unbalanced parentheses\" should be handled. |
| 131 | This error is usually signaled by `hs-show-block'. One of four values: | 146 | 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.") | |||
| 286 | 301 | ||
| 287 | ;; snarfed from outline.el; | 302 | ;; snarfed from outline.el; |
| 288 | (defun hs-flag-region (from to flag) | 303 | (defun hs-flag-region (from to flag) |
| 289 | "Hides or shows lines from FROM to TO, according to FLAG. | 304 | "Hides or shows lines from FROM to TO, according to FLAG. If FLAG |
| 290 | If FLAG is nil then text is shown, while if FLAG is t the text is hidden." | 305 | is nil then text is shown, while if FLAG is non-nil the text is |
| 306 | hidden. Actualy flag is realy either `comment' or `block' depending on | ||
| 307 | what kind of block it is suppose to hide." | ||
| 291 | (save-excursion | 308 | (save-excursion |
| 292 | (goto-char from) | 309 | (goto-char from) |
| 293 | (end-of-line) | 310 | (end-of-line) |
| @@ -297,8 +314,18 @@ If FLAG is nil then text is shown, while if FLAG is t the text is hidden." | |||
| 297 | ;; Make overlay hidden and intangible. | 314 | ;; Make overlay hidden and intangible. |
| 298 | (overlay-put overlay 'invisible 'hs) | 315 | (overlay-put overlay 'invisible 'hs) |
| 299 | (overlay-put overlay 'hs t) | 316 | (overlay-put overlay 'hs t) |
| 317 | (when (or (eq hs-isearch-open t) (eq hs-isearch-open flag)) | ||
| 318 | (overlay-put overlay 'isearch-open-invisible | ||
| 319 | 'hs-isearch-open-invisible)) | ||
| 300 | (overlay-put overlay 'intangible t))))) | 320 | (overlay-put overlay 'intangible t))))) |
| 301 | 321 | ||
| 322 | ;; This is set as an `isearch-open-invisible' property to hidden | ||
| 323 | ;; overlays. | ||
| 324 | (defun hs-isearch-open-invisible (ov) | ||
| 325 | (save-excursion | ||
| 326 | (goto-char (overlay-start ov)) | ||
| 327 | (hs-show-block))) | ||
| 328 | |||
| 302 | ;; Remove from the region BEG ... END all overlays | 329 | ;; Remove from the region BEG ... END all overlays |
| 303 | ;; with a PROP property equal to VALUE. | 330 | ;; with a PROP property equal to VALUE. |
| 304 | ;; Overlays with a PROP property different from VALUE are not touched. | 331 | ;; 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." | |||
| 326 | (goto-char (nth 1 comment-reg)) | 353 | (goto-char (nth 1 comment-reg)) |
| 327 | (unless hs-show-hidden-short-form (forward-line -1)) | 354 | (unless hs-show-hidden-short-form (forward-line -1)) |
| 328 | (end-of-line) | 355 | (end-of-line) |
| 329 | (hs-flag-region (car comment-reg) (point) t) | 356 | (hs-flag-region (car comment-reg) (point) 'comment) |
| 330 | (goto-char (if end (nth 1 comment-reg) (car comment-reg)))) | 357 | (goto-char (if end (nth 1 comment-reg) (car comment-reg)))) |
| 331 | (if (looking-at hs-block-start-regexp) | 358 | (if (looking-at hs-block-start-regexp) |
| 332 | (let* ((p ;; p is the point at the end of the block beginning | 359 | (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." | |||
| 342 | (end-of-line) | 369 | (end-of-line) |
| 343 | (if (and (< p (point)) (> (count-lines p q) | 370 | (if (and (< p (point)) (> (count-lines p q) |
| 344 | (if hs-show-hidden-short-form 1 2))) | 371 | (if hs-show-hidden-short-form 1 2))) |
| 345 | (hs-flag-region p (point) t)) | 372 | (hs-flag-region p (point) 'block)) |
| 346 | (goto-char (if end q p)))))) | 373 | (goto-char (if end q p)))))) |
| 347 | 374 | ||
| 348 | (defun hs-show-block-at-point (&optional end comment-reg) | 375 | (defun hs-show-block-at-point (&optional end comment-reg) |