1 |
;;; hideshow.el --- minor mode cmds to selectively display code/comment blocks |
;;; hideshow.el --- minor mode cmds to selectively display code/comment blocks |
2 |
|
|
3 |
;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 |
;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 |
4 |
;; 2004, 2005 Free Software Foundation |
;; 2004, 2005 Free Software Foundation, Inc. |
5 |
|
|
6 |
;; Author: Thien-Thi Nguyen <ttn@gnu.org> |
;; Author: Thien-Thi Nguyen <ttn@gnu.org> |
7 |
;; Dan Nicolaescu <dann@ics.uci.edu> |
;; Dan Nicolaescu <dann@ics.uci.edu> |
8 |
;; Keywords: C C++ java lisp tools editing comments blocks hiding outlines |
;; Keywords: C C++ java lisp tools editing comments blocks hiding outlines |
9 |
;; Maintainer-Version: 5.58.2.4 |
;; Maintainer-Version: |
10 |
;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning |
;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning |
11 |
|
|
12 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
208 |
;; Thanks go to the following people for valuable ideas, code and |
;; Thanks go to the following people for valuable ideas, code and |
209 |
;; bug reports. |
;; bug reports. |
210 |
;; |
;; |
211 |
;; Dean Andrews, Alf-Ivar Holm, Holger Bauer, Christoph Conrad, Dave |
;; Dean Andrews, Alf-Ivar Holm, Holger Bauer, Christoph Conrad, Dave Love, |
212 |
;; Love, Dirk Herrmann, Gael Marziou, Jan Djarv, Guillaume Leray, |
;; Dirk Herrmann, Gael Marziou, Jan Djarv, Guillaume Leray, Moody Ahmad, |
213 |
;; Moody Ahmad, Preston F. Crow, Lars Lindberg, Reto Zimmermann, |
;; Preston F. Crow, Lars Lindberg, Reto Zimmermann, Keith Sheffield, |
214 |
;; Keith Sheffield, Chew Meng Kuan, Tony Lam, Pete Ware, François |
;; Chew Meng Kuan, Tony Lam, Pete Ware, François Pinard, Stefan Monnier, |
215 |
;; Pinard, Stefan Monnier, Joseph Eydelnant, Michael Ernst |
;; Joseph Eydelnant, Michael Ernst, Peter Heslin |
216 |
;; |
;; |
217 |
;; Special thanks go to Dan Nicolaescu, who reimplemented hideshow using |
;; Special thanks go to Dan Nicolaescu, who reimplemented hideshow using |
218 |
;; overlays (rather than selective display), added isearch magic, folded |
;; overlays (rather than selective display), added isearch magic, folded |
587 |
(while (and (< (point) q) |
(while (and (< (point) q) |
588 |
(> (point) p) |
(> (point) p) |
589 |
(not (looking-at hs-c-start-regexp))) |
(not (looking-at hs-c-start-regexp))) |
590 |
(setq p (point)) ;; use this to avoid an infinite cycle |
;; avoid an infinite cycle |
591 |
|
(setq p (point)) |
592 |
(forward-comment 1) |
(forward-comment 1) |
593 |
(skip-chars-forward " \t\n\f")) |
(skip-chars-forward " \t\n\f")) |
594 |
(when (or (not (looking-at hs-c-start-regexp)) |
(when (or (not (looking-at hs-c-start-regexp)) |
747 |
(funcall hs-hide-all-non-comment-function) |
(funcall hs-hide-all-non-comment-function) |
748 |
(hs-hide-block-at-point t))) |
(hs-hide-block-at-point t))) |
749 |
;; found a comment, probably |
;; found a comment, probably |
750 |
(let ((c-reg (hs-inside-comment-p))) ; blech! |
(let ((c-reg (hs-inside-comment-p))) |
751 |
(when (and c-reg (car c-reg)) |
(when (and c-reg (car c-reg)) |
752 |
(if (> (count-lines (car c-reg) (nth 1 c-reg)) 1) |
(if (> (count-lines (car c-reg) (nth 1 c-reg)) 1) |
753 |
(hs-hide-block-at-point t c-reg) |
(hs-hide-block-at-point t c-reg) |
813 |
(setq p (car c-reg) |
(setq p (car c-reg) |
814 |
q (cadr c-reg)))) |
q (cadr c-reg)))) |
815 |
((and (hs-find-block-beginning) |
((and (hs-find-block-beginning) |
816 |
(looking-at hs-block-start-regexp)) ; fresh match-data, ugh |
;; ugh, fresh match-data |
817 |
|
(looking-at hs-block-start-regexp)) |
818 |
(setq p (point) |
(setq p (point) |
819 |
q (progn (hs-forward-sexp (hs-match-data t) 1) (point))))) |
q (progn (hs-forward-sexp (hs-match-data t) 1) (point))))) |
820 |
(when (and p q) |
(when (and p q) |