aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThien-Thi Nguyen2001-08-27 22:23:09 +0000
committerThien-Thi Nguyen2001-08-27 22:23:09 +0000
commit26d654ec0d48fa8287f44bbb2b643e33ec8f5c78 (patch)
tree3aa879197d0b907b5e91b516ea40da96f26ff66b
parent3452efc2c84dc2288ca7dca352c921ac8638781f (diff)
downloademacs-26d654ec0d48fa8287f44bbb2b643e33ec8f5c78.tar.gz
emacs-26d654ec0d48fa8287f44bbb2b643e33ec8f5c78.zip
Update first-line description.
Sync comments w/ maintainer version 5.31. (hs-isearch-open): Default value now `code'. Fix docstring to use "code blocks" vs "comment blocks", as opposed to "block" vs "comment". (hs-flag-region): Accept `hs-isearch-open' value of `block' as synonymous w/ `code'. (hs-hide-block-at-point): For code blocks, pass `code' to `hs-flag-region' instead of `block'.
-rw-r--r--lisp/progmodes/hideshow.el105
1 files changed, 73 insertions, 32 deletions
diff --git a/lisp/progmodes/hideshow.el b/lisp/progmodes/hideshow.el
index e4ab3826e8b..346f59f1937 100644
--- a/lisp/progmodes/hideshow.el
+++ b/lisp/progmodes/hideshow.el
@@ -1,11 +1,11 @@
1;;; hideshow.el --- minor mode cmds to selectively display blocks of code 1;;; hideshow.el --- minor mode cmds to selectively display code/comment blocks
2 2
3;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01 Free Software Foundation 3;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01 Free Software Foundation
4 4
5;; Author: Thien-Thi Nguyen <ttn@gnu.org> 5;; Author: Thien-Thi Nguyen <ttn@gnu.org>
6;; Dan Nicolaescu <dann@ics.uci.edu> 6;; Dan Nicolaescu <dann@ics.uci.edu>
7;; Keywords: C C++ java lisp tools editing comments blocks hiding outlines 7;; Keywords: C C++ java lisp tools editing comments blocks hiding outlines
8;; Maintainer-Version: 5.26 8;; Maintainer-Version: 5.31
9;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning 9;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning
10 10
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
@@ -39,7 +39,7 @@
39;; hs-show-all C-c @ C-M-s 39;; hs-show-all C-c @ C-M-s
40;; hs-hide-level C-c @ C-l 40;; hs-hide-level C-c @ C-l
41;; hs-toggle-hiding C-c @ C-c 41;; hs-toggle-hiding C-c @ C-c
42;; hs-mouse-toggle-hiding [(shift button-2)] 42;; hs-mouse-toggle-hiding [(shift mouse-2)]
43;; hs-hide-initial-comment-block 43;; hs-hide-initial-comment-block
44;; 44;;
45;; Blocks are defined per mode. In c-mode, c++-mode and java-mode, they 45;; Blocks are defined per mode. In c-mode, c++-mode and java-mode, they
@@ -50,6 +50,37 @@
50;; The command `M-x hs-minor-mode' toggles the minor mode or sets it 50;; The command `M-x hs-minor-mode' toggles the minor mode or sets it
51;; (similar to other minor modes). 51;; (similar to other minor modes).
52 52
53;; * Suggested usage
54;;
55;; First make sure hideshow.el is in a directory in your `load-path'.
56;; You can optionally byte-compile it using `M-x byte-compile-file'.
57;; Then, add the following to your ~/.emacs:
58;;
59;; (load-library "hideshow")
60;; (add-hook 'X-mode-hook ; other modes similarly
61;; '(lambda () (hs-minor-mode 1)))
62;;
63;; where X = {emacs-lisp,c,c++,perl,...}. You can also manually toggle
64;; hideshow minor mode by typing `M-x hs-minor-mode'. After hideshow is
65;; activated or deactivated, `hs-minor-mode-hook' is run w/ `run-hooks'.
66;;
67;; Additionally, Joseph Eydelnant writes:
68;; I enjoy your package hideshow.el Ver. 5.24 2001/02/13
69;; a lot and I've been looking for the following functionality:
70;; toggle hide/show all with a single key.
71;; Here are a few lines of code that lets me do just that.
72;;
73;; (defvar my-hs-hide nil "Current state of hideshow for toggling all.")
74;; ;;;###autoload
75;; (defun my-toggle-hideshow-all () "Toggle hideshow all."
76;; (interactive)
77;; (setq my-hs-hide (not my-hs-hide))
78;; (if my-hs-hide
79;; (hs-hide-all)
80;; (hs-show-all)))
81;;
82;; [Your hideshow hacks here!]
83
53;; * Customization 84;; * Customization
54;; 85;;
55;; You can use `M-x customize-variable' on the following variables: 86;; You can use `M-x customize-variable' on the following variables:
@@ -111,20 +142,6 @@
111;; submitting it for inclusion in hideshow.el. See docstring for 142;; submitting it for inclusion in hideshow.el. See docstring for
112;; `hs-special-modes-alist' for more info on the entry format. 143;; `hs-special-modes-alist' for more info on the entry format.
113 144
114;; * Suggested usage
115;;
116;; First make sure hideshow.el is in a directory in your `load-path'.
117;; You can optionally byte-compile it using `M-x byte-compile-file'.
118;; Then, add the following to your ~/.emacs:
119;;
120;; (load-library "hideshow")
121;; (add-hook 'X-mode-hook ; other modes similarly
122;; '(lambda () (hs-minor-mode 1)))
123;;
124;; where X = {emacs-lisp,c,c++,perl,...}. You can also manually toggle
125;; hideshow minor mode by typing `M-x hs-minor-mode'. After hideshow is
126;; activated or deactivated, `hs-minor-mode-hook' is run w/ `run-hooks'.
127
128;; * Bugs 145;; * Bugs
129;; 146;;
130;; (1) Hideshow does not work w/ emacs 18 because emacs 18 lacks the 147;; (1) Hideshow does not work w/ emacs 18 because emacs 18 lacks the
@@ -132,10 +149,10 @@
132;; writes this, please send me a copy. 149;; writes this, please send me a copy.
133;; 150;;
134;; (2) Sometimes `hs-headline' can become out of sync. To reset, type 151;; (2) Sometimes `hs-headline' can become out of sync. To reset, type
135;; `M-x hs-minor-mode' twice (that is, deactivate then activate 152;; `M-x hs-minor-mode' twice (that is, deactivate then re-activate
136;; hideshow). 153;; hideshow).
137;; 154;;
138;; (3) Hideshow 5.x is developed and tested on GNU Emacs 20.4. 155;; (3) Hideshow 5.x is developed and tested on GNU Emacs 20.7.
139;; XEmacs compatibility may have bitrotted since 4.29. 156;; XEmacs compatibility may have bitrotted since 4.29.
140;; 157;;
141;; (4) Some buffers can't be `byte-compile-file'd properly. This is because 158;; (4) Some buffers can't be `byte-compile-file'd properly. This is because
@@ -152,7 +169,26 @@
152;; act) 169;; act)
153;; (let ((hs-minor-mode-hook nil)) 170;; (let ((hs-minor-mode-hook nil))
154;; ad-do-it)) 171;; ad-do-it))
172;;
173;; (5) Hideshow interacts badly with Ediff and `vc-diff'. At the moment, the
174;; suggested workaround is to turn off hideshow entirely, for example:
175;;
176;; (defun turn-off-hideshow () (hs-minor-mode -1))
177;; (add-hook 'ediff-prepare-buffer-hook 'turn-off-hideshow)
178;; (add-hook 'vc-before-checkin-hook 'turn-off-hideshow)
179;;
180;; In the case of `vc-diff', here is a less invasive workaround:
181;;
182;; (add-hook 'vc-before-checkin-hook
183;; '(lambda ()
184;; (goto-char (point-min))
185;; (hs-show-block)))
186;;
187;; Unfortunately, these workarounds do not restore hideshow state.
188;; If someone figures out a better way, please let me know.
155 189
190;; * Correspondance
191;;
156;; Correspondance welcome; please indicate version number. Send bug 192;; Correspondance welcome; please indicate version number. Send bug
157;; reports and inquiries to <ttn@gnu.org>. 193;; reports and inquiries to <ttn@gnu.org>.
158 194
@@ -164,7 +200,8 @@
164;; Dean Andrews, Alf-Ivar Holm, Holger Bauer, Christoph Conrad, Dave 200;; Dean Andrews, Alf-Ivar Holm, Holger Bauer, Christoph Conrad, Dave
165;; Love, Dirk Herrmann, Gael Marziou, Jan Djarv, Guillaume Leray, 201;; Love, Dirk Herrmann, Gael Marziou, Jan Djarv, Guillaume Leray,
166;; Moody Ahmad, Preston F. Crow, Lars Lindberg, Reto Zimmermann, 202;; Moody Ahmad, Preston F. Crow, Lars Lindberg, Reto Zimmermann,
167;; Keith Sheffield, Chew Meng Kuan, Tony Lam, Pete Ware, François Pinard 203;; Keith Sheffield, Chew Meng Kuan, Tony Lam, Pete Ware, François
204;; Pinard, Stefan Monnier, Joseph Eydelnant
168;; 205;;
169;; Special thanks go to Dan Nicolaescu, who reimplemented hideshow using 206;; Special thanks go to Dan Nicolaescu, who reimplemented hideshow using
170;; overlays (rather than selective display), added isearch magic, folded 207;; overlays (rather than selective display), added isearch magic, folded
@@ -207,19 +244,19 @@
207 :group 'hideshow 244 :group 'hideshow
208 :version "21.1") 245 :version "21.1")
209 246
210(defcustom hs-isearch-open 'block 247(defcustom hs-isearch-open 'code
211 "*What kind of hidden blocks to open when doing `isearch'. 248 "*What kind of hidden blocks to open when doing `isearch'.
212One of the following symbols: 249One of the following symbols:
213 250
214 block -- open only blocks 251 code -- open only code blocks
215 comment -- open only comments 252 comment -- open only comment blocks
216 t -- open both blocks and comments 253 t -- open both code and comment blocks
217 nil -- open neither blocks nor comments 254 nil -- open neither code nor comment blocks
218 255
219This has effect iff `search-invisible' is set to `open'." 256This has effect iff `search-invisible' is set to `open'."
220 :type '(choice (const :tag "open only blocks" block) 257 :type '(choice (const :tag "open only code blocks" code)
221 (const :tag "open only comments" comment) 258 (const :tag "open only comment blocks" comment)
222 (const :tag "open both blocks and comments" t) 259 (const :tag "open both code and comment blocks" t)
223 (const :tag "don't open any of them" nil)) 260 (const :tag "don't open any of them" nil))
224 :group 'hideshow) 261 :group 'hideshow)
225 262
@@ -411,8 +448,8 @@ property of an overlay."
411(defun hs-flag-region (from to flag) 448(defun hs-flag-region (from to flag)
412 "Hide or show lines from FROM to TO, according to FLAG. 449 "Hide or show lines from FROM to TO, according to FLAG.
413If FLAG is nil then text is shown, while if FLAG is non-nil the text is 450If FLAG is nil then text is shown, while if FLAG is non-nil the text is
414hidden. Actually flag is really either `comment' or `block' depending 451hidden. FLAG must be one of the symbols `code' or `comment', depending
415on what kind of block it is supposed to hide." 452on what kind of block is to be hidden."
416 (save-excursion 453 (save-excursion
417 ;; first clear it all out 454 ;; first clear it all out
418 (hs-discard-overlays from to) 455 (hs-discard-overlays from to)
@@ -421,7 +458,11 @@ on what kind of block it is supposed to hide."
421 (let ((overlay (make-overlay from to))) 458 (let ((overlay (make-overlay from to)))
422 (overlay-put overlay 'invisible 'hs) 459 (overlay-put overlay 'invisible 'hs)
423 (overlay-put overlay 'hs flag) 460 (overlay-put overlay 'hs flag)
424 (when (or (eq hs-isearch-open t) (eq hs-isearch-open flag)) 461 (when (or (eq hs-isearch-open t)
462 (eq hs-isearch-open flag)
463 ;; deprecated backward compatibility -- `block'<=>`code'
464 (and (eq 'block hs-isearch-open)
465 (eq 'code flag)))
425 (overlay-put overlay 'isearch-open-invisible 'hs-isearch-show) 466 (overlay-put overlay 'isearch-open-invisible 'hs-isearch-show)
426 (overlay-put overlay 467 (overlay-put overlay
427 'isearch-open-invisible-temporary 468 'isearch-open-invisible-temporary
@@ -474,7 +515,7 @@ and then further adjusted to be at the end of the line."
474 (end-of-line) 515 (end-of-line)
475 (point)))) 516 (point))))
476 (if (and (< p (point)) (> (count-lines p q) 1)) 517 (if (and (< p (point)) (> (count-lines p q) 1))
477 (overlay-put (hs-flag-region p q 'block) 518 (overlay-put (hs-flag-region p q 'code)
478 'hs-ofs 519 'hs-ofs
479 (- pure-p p))) 520 (- pure-p p)))
480 (goto-char (if end q (min p pure-p))))))) 521 (goto-char (if end q (min p pure-p)))))))