annotate lisp/progmodes/hideshow.el @ 21433:25b02305130b

(Man-getpage-in-background): Bind inhibit-eol-conversion to t before calling start-process or call-process.
author Karl Heuer <kwzh@gnu.org>
date Wed, 08 Apr 1998 18:53:13 +0000
parents 0507d774e769
children 3e53877b4a08
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
1 ;;; hideshow.el --- minor mode cmds to selectively display blocks of code
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
2
19233
520a7d40d75c Correct the autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents: 18867
diff changeset
3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
4
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
5 ;; Author: Thien-Thi Nguyen <ttn@netcom.com>
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
6 ;; Maintainer: Dan Nicolaescu <done@ece.arizona.edu>
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
7 ;; Version: 4.0
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
8 ;; Keywords: C C++ java lisp tools editing comments blocks hiding outlines
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
9 ;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
10
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
11 ;; This file is part of GNU Emacs.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
12
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
16 ;; any later version.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
17
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
21 ;; GNU General Public License for more details.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
22
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
23 ;; You should have received a copy of the GNU General Public License
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
26 ;; Boston, MA 02111-1307, USA.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
27
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
28 ;; LCD Archive Entry:
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
29 ;; hideshow|Thien-Thi Nguyen|ttn@netcom.com|
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
30 ;; minor mode commands to selectively display blocks of code|
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
31 ;; 18-Oct-1994|3.4|~/modes/hideshow.el.Z|
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
32
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
33 ;;; Commentary:
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
34
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
35 ;; This file provides `hs-minor-mode'. When active, six commands:
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
36 ;; hs-{hide,show}-{all,block}, hs-show-region and hs-minor-mode
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
37 ;; are available. They implement block hiding and showing. Blocks are
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
38 ;; defined in mode-specific way. In c-mode or c++-mode, they are simply
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
39 ;; curly braces, while in lisp-ish modes they are parens. Multi-line
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
40 ;; comments (c-mode) can also be hidden. The command M-x hs-minor-mode
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
41 ;; toggles the minor mode or sets it (similar to outline minor mode).
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
42 ;; See documentation for each command for more info.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
43 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
44 ;; The variable `hs-unbalance-handler-method' controls hideshow's behavior
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
45 ;; in the case of "unbalanced parentheses". See doc for more info.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
46
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
47 ;; Suggested usage:
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
48
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
49 ;; (load-library "hideshow")
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
50 ;; (add-hook 'X-mode-hook 'hs-minor-mode) ; other modes similarly
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
51 ;;
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
52 ;; where X = {emacs-lisp,c,c++,perl,...}. See the doc for the variable
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
53 ;; `hs-special-modes-alist' if you'd like to use hideshow w/ other modes.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
54
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
55 ;; Etc:
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
56
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
57 ;; Bug reports and fixes welcome (comments, too). Thanks go to
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
58 ;; Dean Andrews <adahome@ix.netcom.com>
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
59 ;; Preston F. Crow <preston.f.crow@dartmouth.edu>
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
60 ;; Gael Marziou <gael@gnlab030.grenoble.hp.com>
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
61 ;; Keith Sheffield <sheff@edcsgw2.cr.usgs.gov>
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
62 ;; Jan Djarv <jan.djarv@sa.erisoft.se>
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
63 ;; Lars Lindberg <qhslali@aom.ericsson.se>
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
64 ;; Alf-Ivar Holm <alfh@ifi.uio.no>
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
65 ;; for valuable feedback, code and bug reports.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
66
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
67 ;;; Code:
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
68
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
69
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
70 ;;;----------------------------------------------------------------------------
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
71 ;;; user-configurable variables
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
72
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
73 (defgroup hideshow nil
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
74 "Minor mode for hiding and showing program and comment blocks."
18237
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
75 :prefix "hs-"
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
76 :group 'languages)
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
77
19233
520a7d40d75c Correct the autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents: 18867
diff changeset
78 ;;;###autoload
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
79 (defcustom hs-hide-comments-when-hiding-all t
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
80 "Hide the comments too when you do an `hs-hide-all'."
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
81 :type 'boolean
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
82 :group 'hideshow)
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
83
19233
520a7d40d75c Correct the autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents: 18867
diff changeset
84 ;;;###autoload
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
85 (defcustom hs-show-hidden-short-form t
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
86 "Leave only the first line visible in a hidden block.
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
87 If t only the first line is visible when a block is in the hidden state,
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
88 else both the first line and the last line are showed. Also if t and
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
89 `hs-adjust-block-beginning' is set, it is used also.
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
90
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
91 An example of how this works: (in c-mode)
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
92 original:
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
93
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
94 /* My function main
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
95 some more stuff about main
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
96 */
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
97 int
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
98 main(void)
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
99 {
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
100 int x=0;
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
101 return 0;
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
102 }
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
103
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
104
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
105 hidden and hs-show-hidden-short-form is nil
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
106 /* My function main...
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
107 */
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
108 int
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
109 main(void)
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
110 {...
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
111 }
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
112
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
113 hidden and hs-show-hidden-short-form is t
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
114 /* My function main...
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
115 int
18093
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
116 main(void)...
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
117
18093
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
118 For latest you have to be on the line containing the ellipsis when
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
119 you do `hs-show-block'."
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
120 :type 'boolean
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
121 :group 'hideshow)
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
122
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
123 (defcustom hs-minor-mode-hook 'hs-hide-initial-comment-block
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
124 "Hook called when `hs-minor-mode' is installed.
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
125 A good value for this would be `hs-hide-initial-comment-block' to
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
126 hide all the comments at the beginning of the file."
19833
fdcd167cb293 (hs-minor-mode-hook): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19233
diff changeset
127 :type 'hook
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
128 :group 'hideshow)
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
129
18237
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
130 (defcustom hs-isearch-open 'block
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
131 "What kind of hidden blocks to open when doing `isearch'.
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
132 It can have the following values:
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
133 `block' open only blocks
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
134 `comment' open only comments
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
135 t open all of them
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
136 nil don't open any.
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
137 This only has effect iff `search-invisible' is set to `open'."
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
138 :type '(choice (const :tag "open only blocks" block)
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
139 (const :tag "open only comments" comment)
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
140 (const :tag "open both blocks and comments" t)
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
141 (const :tag "don't open any of them" nil))
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
142 :group 'hideshow)
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
143
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
144 (defvar hs-unbalance-handler-method 'top-level
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
145 "*Symbol representing how \"unbalanced parentheses\" should be handled.
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
146 This error is usually signaled by `hs-show-block'. One of four values:
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
147 `top-level', `next-line', `signal' or `ignore'. Default is `top-level'.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
148
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
149 - `top-level' -- Show top-level block containing the currently troublesome
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
150 block.
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
151 - `next-line' -- Use the fact that, for an already hidden block, its end
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
152 will be on the next line. Attempt to show this block.
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
153 - `signal' -- Pass the error through, stopping execution.
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
154 - `ignore' -- Ignore the error, continuing execution.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
155
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
156 Values other than these four will be interpreted as `signal'.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
157
19233
520a7d40d75c Correct the autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents: 18867
diff changeset
158 ;;;###autoload
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
159 (defvar hs-special-modes-alist
18093
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
160 '((c-mode "{" "}" nil nil hs-c-like-adjust-block-beginning)
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
161 (c++-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning)
20820
0507d774e769 (hs-special-modes-alist): Improved the regexp for java.
Dan Nicolaescu <done@ece.arizona.edu>
parents: 20811
diff changeset
162 (java-mode "\\(\\(\\([ \t]*\\(\\(abstract\\|final\\|native\\|p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\|s\\(tatic\\|ynchronized\\)\\)[ \t\n]+\\)*[.a-zA-Z0-9_:]+[ \t\n]*\\(\\[[ \t\n]*\\][ \t\n]*\\)?\\([a-zA-Z0-9_:]+[ \t\n]*\\)([^)]*)\\([ \n\t]+throws[ \t\n][^{]+\\)?\\)\\|\\([ \t]*static[^{]*\\)\\)[ \t\n]*{\\)" "}" "/[*/]" java-hs-forward-sexp hs-c-like-adjust-block-beginning))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
163 ; I tested the java regexp using the following:
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
164 ;(defvar hsj-public)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
165 ;(defvar hsj-type)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
166 ;(defvar hsj-fname)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
167 ;(defvar hsj-par)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
168 ;(defvar hsj-throws)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
169 ;(defvar hsj-static)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
170
18867
b6e4c4c2a3ef (hs-special-modes-alist): Use a regexp generated by regexp-opt.
Richard M. Stallman <rms@gnu.org>
parents: 18428
diff changeset
171 ;(setq hsj-public
b6e4c4c2a3ef (hs-special-modes-alist): Use a regexp generated by regexp-opt.
Richard M. Stallman <rms@gnu.org>
parents: 18428
diff changeset
172 ; (concat "[ \t]*\\("
b6e4c4c2a3ef (hs-special-modes-alist): Use a regexp generated by regexp-opt.
Richard M. Stallman <rms@gnu.org>
parents: 18428
diff changeset
173 ; (regexp-opt '("public" "private" "protected" "abstract"
20811
1e07c8543929 (hs-special-modes-alist): Improved the regexp for java.
Richard M. Stallman <rms@gnu.org>
parents: 20050
diff changeset
174 ; "synchronized" "static" "final" "native") 1)
20820
0507d774e769 (hs-special-modes-alist): Improved the regexp for java.
Dan Nicolaescu <done@ece.arizona.edu>
parents: 20811
diff changeset
175 ; "[ \t\n]+\\)*"))
18867
b6e4c4c2a3ef (hs-special-modes-alist): Use a regexp generated by regexp-opt.
Richard M. Stallman <rms@gnu.org>
parents: 18428
diff changeset
176
20811
1e07c8543929 (hs-special-modes-alist): Improved the regexp for java.
Richard M. Stallman <rms@gnu.org>
parents: 20050
diff changeset
177 ;(setq hsj-type "[.a-zA-Z0-9_:]+[ \t\n]*\\(\\[[ \t\n]*\\][ \t\n]*\\)?")
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
178 ;(setq hsj-fname "\\([a-zA-Z0-9_:]+[ \t\n]*\\)")
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
179 ;(setq hsj-par "([^)]*)")
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
180 ;(setq hsj-throws "\\([ \n\t]+throws[ \t\n][^{]+\\)?")
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
181
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
182 ;(setq hsj-static "[ \t]*static[^{]*")
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
183
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
184
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
185 ;(setq hs-block-start-regexp (concat
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
186 ; "\\("
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
187 ; "\\("
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
188 ; "\\("
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
189 ; hsj-public
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
190 ; hsj-type
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
191 ; hsj-fname
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
192 ; hsj-par
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
193 ; hsj-throws
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
194 ; "\\)"
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
195 ; "\\|"
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
196 ; "\\("
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
197 ; hsj-static
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
198 ; "\\)"
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
199 ; "\\)"
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
200 ; "[ \t\n]*{"
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
201 ; "\\)"
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
202 ; ))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
203
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
204 "*Alist for initializing the hideshow variables for different modes.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
205 It has the form
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
206 (MODE START-RE END-RE COMMENT-START-RE FORWARD-SEXP-FUNC ADJUST-BEG-FUNC).
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
207 If present, hideshow will use these values for the start and end regexps,
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
208 respectively. Since Algol-ish languages do not have single-character
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
209 block delimiters, the function `forward-sexp' which is used by hideshow
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
210 doesn't work. In this case, if a similar function is provided, you can
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
211 register it and have hideshow use it instead of `forward-sexp'. To add
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
212 more values, use
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
213
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
214 \t(pushnew '(new-mode st-re end-re function-name)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
215 \t hs-special-modes-alist :test 'equal)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
216
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
217 For example:
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
218
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
219 \t(pushnew '(simula-mode \"begin\" \"end\" \"!\" simula-next-statement)
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
220 \t hs-special-modes-alist :test 'equal)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
221
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
222 See the documentation for `hs-adjust-block-beginning' to see what
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
223 is the use of ADJUST-BEG-FUNC.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
224
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
225 If any of those is left nil, hideshow will try to guess some values, see
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
226 `hs-grok-mode-type' for this.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
227
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
228 Note that the regexps should not contain leading or trailing whitespace.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
229
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
230 (defvar hs-hide-hook nil
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
231 "*Hooks called at the end of `hs-hide-all' and `hs-hide-block'.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
232
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
233 (defvar hs-show-hook nil
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
234 "*Hooks called at the end of commands to show text.
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
235 These commands include `hs-show-all', `hs-show-block' and `hs-show-region'.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
236
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
237 (defvar hs-minor-mode-prefix "\C-c"
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
238 "*Prefix key to use for hideshow commands in hideshow minor mode.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
239
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
240 ;;;----------------------------------------------------------------------------
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
241 ;;; internal variables
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
242
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
243 (defvar hs-minor-mode nil
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
244 "Non-nil if using hideshow mode as a minor mode of some other mode.
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
245 Use the command `hs-minor-mode' to toggle this variable.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
246
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
247 (defvar hs-minor-mode-map nil
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
248 "Mode map for hideshow minor mode.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
249
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
250 ;(defvar hs-menu-bar nil
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
251 ; "Menu bar for hideshow minor mode (Xemacs only).")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
252
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
253 (defvar hs-c-start-regexp nil
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
254 "Regexp for beginning of comments.
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
255 Differs from mode-specific comment regexps in that
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
256 surrounding whitespace is stripped.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
257
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
258 (defvar hs-block-start-regexp nil
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
259 "Regexp for beginning of block.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
260
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
261 (defvar hs-block-end-regexp nil
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
262 "Regexp for end of block.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
263
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
264 (defvar hs-forward-sexp-func 'forward-sexp
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
265 "Function used to do a forward-sexp.
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
266 Should change for Algol-ish modes. For single-character block
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
267 delimiters -- ie, the syntax table regexp for the character is
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
268 either `(' or `)' -- `hs-forward-sexp-func' would just be `forward-sexp'.
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
269 For other modes such as simula, a more specialized function
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
270 is necessary.")
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
271
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
272 (defvar hs-adjust-block-beginning nil
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
273 "Function used to tweak the block beginning.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
274 It has effect only if `hs-show-hidden-short-form' is t. The block it
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
275 is hidden from the point returned by this function, as opposed to
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
276 hiding it from the point returned when searching
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
277 `hs-block-start-regexp'. In c-like modes, if we wish to also hide the
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
278 curly braces (if you think they occupy too much space on the screen),
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
279 this function should return the starting point (at the end of line) of
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
280 the hidden region.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
281
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
282 It is called with a single argument ARG which is the the position in
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
283 buffer after the block beginning.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
284
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
285 It should return the position from where we should start hiding.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
286
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
287 It should not move the point.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
288
18093
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
289 See `hs-c-like-adjust-block-beginning' for an example of using this.")
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
290
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
291 ;(defvar hs-emacs-type 'fsf
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
292 ; "Used to support both Emacs and Xemacs.")
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
293
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
294 ;(eval-when-compile
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
295 ; (if (string-match "xemacs\\|lucid" emacs-version)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
296 ; (progn
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
297 ; (defvar current-menubar nil "")
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
298 ; (defun set-buffer-menubar (arg1))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
299 ; (defun add-menu (arg1 arg2 arg3)))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
300
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
301 ;;;----------------------------------------------------------------------------
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
302 ;;; support funcs
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
303
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
304 ;; snarfed from outline.el;
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
305 (defun hs-flag-region (from to flag)
18237
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
306 "Hides or shows lines from FROM to TO, according to FLAG. If FLAG
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
307 is nil then text is shown, while if FLAG is non-nil the text is
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
308 hidden. Actualy flag is realy either `comment' or `block' depending on
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
309 what kind of block it is suppose to hide."
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
310 (save-excursion
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
311 (goto-char from)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
312 (end-of-line)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
313 (hs-discard-overlays (point) to 'invisible 'hs)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
314 (if flag
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
315 (let ((overlay (make-overlay (point) to)))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
316 ;; Make overlay hidden and intangible.
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
317 (overlay-put overlay 'invisible 'hs)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
318 (overlay-put overlay 'hs t)
18237
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
319 (when (or (eq hs-isearch-open t) (eq hs-isearch-open flag))
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
320 (overlay-put overlay 'isearch-open-invisible
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
321 'hs-isearch-open-invisible))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
322 (overlay-put overlay 'intangible t)))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
323
18237
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
324 ;; This is set as an `isearch-open-invisible' property to hidden
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
325 ;; overlays.
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
326 (defun hs-isearch-open-invisible (ov)
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
327 (save-excursion
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
328 (goto-char (overlay-start ov))
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
329 (hs-show-block)))
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
330
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
331 ;; Remove from the region BEG ... END all overlays
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
332 ;; with a PROP property equal to VALUE.
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
333 ;; Overlays with a PROP property different from VALUE are not touched.
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
334 (defun hs-discard-overlays (beg end prop value)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
335 (if (< end beg)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
336 (setq beg (prog1 end (setq end beg))))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
337 (save-excursion
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
338 (goto-char beg)
18428
5ec58687160a (hs-discard-overlays): Use overlays-in to
Richard M. Stallman <rms@gnu.org>
parents: 18237
diff changeset
339 (let ((overlays (overlays-in beg end))
5ec58687160a (hs-discard-overlays): Use overlays-in to
Richard M. Stallman <rms@gnu.org>
parents: 18237
diff changeset
340 o)
5ec58687160a (hs-discard-overlays): Use overlays-in to
Richard M. Stallman <rms@gnu.org>
parents: 18237
diff changeset
341 (while overlays
5ec58687160a (hs-discard-overlays): Use overlays-in to
Richard M. Stallman <rms@gnu.org>
parents: 18237
diff changeset
342 (setq o (car overlays))
5ec58687160a (hs-discard-overlays): Use overlays-in to
Richard M. Stallman <rms@gnu.org>
parents: 18237
diff changeset
343 (if (eq (overlay-get o prop) value)
5ec58687160a (hs-discard-overlays): Use overlays-in to
Richard M. Stallman <rms@gnu.org>
parents: 18237
diff changeset
344 (delete-overlay o))
5ec58687160a (hs-discard-overlays): Use overlays-in to
Richard M. Stallman <rms@gnu.org>
parents: 18237
diff changeset
345 (setq overlays (cdr overlays))))))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
346
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
347 (defun hs-hide-block-at-point (&optional end comment-reg)
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
348 "Hide block iff on block beginning, optional END means reposition at end.
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
349 COMMENT-REG is a list of the form (BEGIN . END) and specifies the limits
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
350 of the comment, or nil if the block is not a comment."
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
351 (if comment-reg
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
352 (progn
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
353 ;; goto the end of line at the end of the comment
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
354 (goto-char (nth 1 comment-reg))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
355 (unless hs-show-hidden-short-form (forward-line -1))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
356 (end-of-line)
18237
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
357 (hs-flag-region (car comment-reg) (point) 'comment)
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
358 (goto-char (if end (nth 1 comment-reg) (car comment-reg))))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
359 (if (looking-at hs-block-start-regexp)
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
360 (let* ((p ;; p is the point at the end of the block beginning
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
361 (if (and hs-show-hidden-short-form
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
362 hs-adjust-block-beginning)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
363 ;; we need to adjust the block beginning
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
364 (funcall hs-adjust-block-beginning (match-end 0))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
365 (match-end 0)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
366 ;; q is the point at the end of the block
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
367 (q (progn (funcall hs-forward-sexp-func 1) (point))))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
368 ;; position the point so we can call `hs-flag-region'
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
369 (unless hs-show-hidden-short-form (forward-line -1))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
370 (end-of-line)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
371 (if (and (< p (point)) (> (count-lines p q)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
372 (if hs-show-hidden-short-form 1 2)))
18237
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
373 (hs-flag-region p (point) 'block))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
374 (goto-char (if end q p))))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
375
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
376 (defun hs-show-block-at-point (&optional end comment-reg)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
377 "Show block iff on block beginning. Optional END means reposition at end.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
378 COMMENT-REG is a list of the forme (BEGIN . END) and specifies the limits
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
379 of the comment. It should be nil when hiding a block."
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
380 (if comment-reg
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
381 (when (car comment-reg)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
382 (hs-flag-region (car comment-reg) (nth 1 comment-reg) nil)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
383 (goto-char (if end (nth 1 comment-reg) (car comment-reg))))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
384 (if (looking-at hs-block-start-regexp)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
385 (let* ((p (point))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
386 (q
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
387 (condition-case error ; probably unbalanced paren
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
388 (progn
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
389 (funcall hs-forward-sexp-func 1)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
390 (point))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
391 (error
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
392 (cond
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
393 ((eq hs-unbalance-handler-method 'ignore)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
394 ;; just ignore this block
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
395 (point))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
396 ((eq hs-unbalance-handler-method 'top-level)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
397 ;; try to get out of rat's nest and expose the whole func
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
398 (if (/= (current-column) 0) (beginning-of-defun))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
399 (setq p (point))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
400 (re-search-forward (concat "^" hs-block-start-regexp)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
401 (point-max) t 2)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
402 (point))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
403 ((eq hs-unbalance-handler-method 'next-line)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
404 ;; assumption is that user knows what s/he's doing
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
405 (beginning-of-line) (setq p (point))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
406 (end-of-line 2) (point))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
407 (t
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
408 ;; pass error through -- this applies to `signal', too
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
409 (signal (car error) (cdr error))))))))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
410 (hs-flag-region p q nil)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
411 (goto-char (if end (1+ (point)) p))))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
412
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
413 (defun hs-safety-is-job-n ()
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
414 "Warn `buffer-invisibility-spec' does not contain hs."
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
415 (if (or buffer-invisibility-spec (assq 'hs buffer-invisibility-spec) )
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
416 nil
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
417 (message "Warning: `buffer-invisibility-spec' does not contain hs!!")
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
418 (sit-for 2)))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
419
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
420 (defun hs-hide-initial-comment-block ()
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
421 (interactive)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
422 "Hides the first block of comments in a file.
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
423 The best usage is in `hs-minor-mode-hook', it hides all the comments at the
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
424 file beginning, so if you have huge RCS logs you won't see them!"
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
425 (let ((p (point))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
426 c-reg)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
427 (goto-char (point-min))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
428 (skip-chars-forward " \t\n^L")
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
429 (setq c-reg (hs-inside-comment-p))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
430 ;; see if we have enough comment lines to hide
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
431 (if (and c-reg (> (count-lines (car c-reg) (nth 1 c-reg))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
432 (if hs-show-hidden-short-form 1 2)))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
433 (hs-hide-block)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
434 (goto-char p))))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
435
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
436 (defun hs-inside-comment-p ()
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
437 "Returns non-nil if point is inside a comment, otherwise nil.
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
438 Actually, returns a list containing the buffer position of the start
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
439 and the end of the comment. A comment block can be hided only if on its
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
440 starting line there are only white spaces preceding the actual comment
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
441 beginning, if we are inside of a comment but this condition is not
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
442 we return a list having a nil as its car and the end of comment position
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
443 as cdr."
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
444 (save-excursion
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
445 ;; the idea is to look backwards for a comment start regexp, do a
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
446 ;; forward comment, and see if we are inside, then extend extend
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
447 ;; forward and backward as long as we have comments
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
448 (let ((q (point)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
449 (when (or (looking-at hs-c-start-regexp)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
450 (re-search-backward hs-c-start-regexp (point-min) t))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
451 (forward-comment (- (buffer-size)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
452 (skip-chars-forward " \t\n ")
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
453 (let ((p (point))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
454 (not-hidable nil))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
455 (beginning-of-line)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
456 (unless (looking-at (concat "[ \t]*" hs-c-start-regexp))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
457 ;; we are in this situation: (example)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
458 ;; (defun bar ()
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
459 ;; (foo)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
460 ;; ) ; comment
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
461 ;; ^
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
462 ;; the point was here before doing (beginning-of-line)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
463 ;; here we should advance till the next comment which
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
464 ;; eventually has only white spaces preceding it on the same
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
465 ;; line
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
466 (goto-char p)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
467 (forward-comment 1)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
468 (skip-chars-forward " \t\n ")
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
469 (setq p (point))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
470 (while (and (< (point) q)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
471 (> (point) p)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
472 (not (looking-at hs-c-start-regexp)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
473 (setq p (point)) ;; use this to avoid an infinit cycle.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
474 (forward-comment 1)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
475 (skip-chars-forward " \t\n "))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
476 (if (or (not (looking-at hs-c-start-regexp))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
477 (> (point) q))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
478 ;; we cannot hide this comment block
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
479 (setq not-hidable t)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
480 ;; goto the end of the comment
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
481 (forward-comment (buffer-size))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
482 (skip-chars-backward " \t\n ")
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
483 (end-of-line)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
484 (if (>= (point) q)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
485 (list (if not-hidable nil p) (point))))))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
486
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
487 (defun hs-grok-mode-type ()
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
488 "Setup variables for new buffers where applicable."
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
489 (when (and (boundp 'comment-start)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
490 (boundp 'comment-end))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
491 (let ((lookup (assoc major-mode hs-special-modes-alist)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
492 (setq hs-block-start-regexp (or (nth 1 lookup) "\\s\(")
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
493 hs-block-end-regexp (or (nth 2 lookup) "\\s\)")
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
494 hs-c-start-regexp (or (nth 3 lookup)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
495 (let ((c-start-regexp
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
496 (regexp-quote comment-start)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
497 (if (string-match " +$" c-start-regexp)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
498 (substring c-start-regexp 0 (1- (match-end 0)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
499 c-start-regexp)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
500 hs-forward-sexp-func (or (nth 4 lookup) 'forward-sexp)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
501 hs-adjust-block-beginning (nth 5 lookup)))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
502
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
503 (defun hs-find-block-beginning ()
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
504 "Repositions point at block-start.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
505 Return point, or nil if top-level."
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
506 (let (done
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
507 (try-again t)
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
508 (here (point))
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
509 (both-regexps (concat "\\(" hs-block-start-regexp "\\)\\|\\("
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
510 hs-block-end-regexp "\\)"))
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
511 (buf-size (buffer-size)))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
512 (beginning-of-line)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
513 ;; A block beginning can span on multiple lines, if the point
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
514 ;; is on one of those lines, trying a regexp search from
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
515 ;; that point would fail to find the block beginning, so we look
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
516 ;; backwards for the block beginning, or a block end.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
517 (while try-again
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
518 (setq try-again nil)
18093
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
519 (if (and (re-search-backward both-regexps (point-min) t)
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
520 (match-beginning 1)) ; found a block beginning
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
521 (if (save-match-data (hs-inside-comment-p))
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
522 ;;but it was inside a comment, so we have to look for
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
523 ;;it again
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
524 (setq try-again t)
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
525 ;; that's what we were looking for
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
526 (setq done (match-beginning 0)))
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
527 ;; we found a block end, or we reached the beginning of the
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
528 ;; buffer look to see if we were on a block beginning when we
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
529 ;; started
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
530 (if (and
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
531 (re-search-forward hs-block-start-regexp (point-max) t)
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
532 (or
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
533 (and (>= here (match-beginning 0)) (< here (match-end 0)))
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
534 (and hs-show-hidden-short-form hs-adjust-block-beginning
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
535 (save-match-data
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
536 (= 1 (count-lines
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
537 (funcall hs-adjust-block-beginning
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
538 (match-end 0)) here))))))
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
539 (setq done (match-beginning 0)))))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
540 (goto-char here)
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
541 (while (and (not done)
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
542 ;; This had problems because the regexp can match something
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
543 ;; inside of a comment!
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
544 ;; Since inside a comment we can have incomplete sexps
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
545 ;; this would have signaled an error.
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
546 (or (forward-comment (- buf-size)) t); `or' is a hack to
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
547 ; make it return t
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
548 (re-search-backward both-regexps (point-min) t))
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
549 (if (match-beginning 1) ; start of start-regexp
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
550 (setq done (match-beginning 0))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
551 (goto-char (match-end 0)) ; end of end-regexp
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
552 (funcall hs-forward-sexp-func -1)))
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
553 (goto-char (or done here))
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
554 done))
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
555
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
556 (defmacro hs-life-goes-on (&rest body)
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
557 "Executes optional BODY iff variable `hs-minor-mode' is non-nil."
18867
b6e4c4c2a3ef (hs-special-modes-alist): Use a regexp generated by regexp-opt.
Richard M. Stallman <rms@gnu.org>
parents: 18428
diff changeset
558 (` (let ((inhibit-point-motion-hooks t))
b6e4c4c2a3ef (hs-special-modes-alist): Use a regexp generated by regexp-opt.
Richard M. Stallman <rms@gnu.org>
parents: 18428
diff changeset
559 (when hs-minor-mode
b6e4c4c2a3ef (hs-special-modes-alist): Use a regexp generated by regexp-opt.
Richard M. Stallman <rms@gnu.org>
parents: 18428
diff changeset
560 (,@ body)))))
b6e4c4c2a3ef (hs-special-modes-alist): Use a regexp generated by regexp-opt.
Richard M. Stallman <rms@gnu.org>
parents: 18428
diff changeset
561
b6e4c4c2a3ef (hs-special-modes-alist): Use a regexp generated by regexp-opt.
Richard M. Stallman <rms@gnu.org>
parents: 18428
diff changeset
562 (put 'hs-life-goes-on 'edebug-form-spec '(&rest form))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
563
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
564 (defun hs-already-hidden-p ()
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
565 "Return non-nil if point is in an already-hidden block, otherwise nil."
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
566 (save-excursion
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
567 (let ((c-reg (hs-inside-comment-p)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
568 (if (and c-reg (nth 0 c-reg))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
569 ;; point is inside a comment, and that comment is hidable
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
570 (goto-char (nth 0 c-reg))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
571 (if (and (not c-reg) (hs-find-block-beginning)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
572 (looking-at hs-block-start-regexp))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
573 ;; point is inside a block
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
574 (goto-char (match-end 0)))))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
575 (end-of-line)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
576 (let ((overlays (overlays-at (point)))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
577 (found nil))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
578 (while (and (not found) (overlayp (car overlays)))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
579 (setq found (overlay-get (car overlays) 'hs)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
580 overlays (cdr overlays)))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
581 found)))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
582
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
583 (defun java-hs-forward-sexp (arg)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
584 "Function used by `hs-minor-mode' for `forward-sexp' in Java mode."
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
585 (if (< arg 0)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
586 (backward-sexp 1)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
587 (if (looking-at hs-block-start-regexp)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
588 (progn
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
589 (goto-char (match-end 0))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
590 (forward-char -1)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
591 (forward-sexp 1))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
592 (forward-sexp 1))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
593
18093
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
594 (defun hs-c-like-adjust-block-beginning (arg)
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
595 "Function to be assigned to `hs-adjust-block-beginning' for C like modes.
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
596 Arg is a position in buffer just after {. This goes back to the end of
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
597 the function header. The purpose is to save some space on the screen
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
598 when displaying hidden blocks."
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
599 (save-excursion
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
600 (goto-char arg)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
601 (forward-char -1)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
602 (forward-comment (- (buffer-size)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
603 (point)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
604
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
605 ;;;----------------------------------------------------------------------------
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
606 ;;; commands
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
607
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
608 ;;;###autoload
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
609 (defun hs-hide-all ()
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
610 "Hides all top-level blocks, displaying only first and last lines.
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
611 It moves point to the beginning of the line, and it runs the normal hook
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
612 `hs-hide-hook'. See documentation for `run-hooks'.
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
613 If `hs-hide-comments-when-hiding-all' is t also hides the comments."
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
614 (interactive)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
615 (hs-life-goes-on
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
616 (message "Hiding all blocks ...")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
617 (save-excursion
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
618 (hs-flag-region (point-min) (point-max) nil) ; eliminate weirdness
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
619 (goto-char (point-min))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
620 (if hs-hide-comments-when-hiding-all
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
621 (let (c-reg
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
622 (count 0)
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
623 (block-and-comment-re ;; this should match
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
624 (concat "\\(^" ;; the block beginning and comment start
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
625 hs-block-start-regexp
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
626 "\\)\\|\\(" hs-c-start-regexp "\\)")))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
627 (while (re-search-forward block-and-comment-re (point-max) t)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
628 (if (match-beginning 1) ;; we have found a block beginning
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
629 (progn
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
630 (goto-char (match-beginning 1))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
631 (hs-hide-block-at-point t)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
632 (message "Hiding ... %d" (setq count (1+ count))))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
633 ;;found a comment
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
634 (setq c-reg (hs-inside-comment-p))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
635 (if (and c-reg (car c-reg))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
636 (if (> (count-lines (car c-reg) (nth 1 c-reg))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
637 (if hs-show-hidden-short-form 1 2))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
638 (progn
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
639 (hs-hide-block-at-point t c-reg)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
640 (message "Hiding ... %d" (setq count (1+ count))))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
641 (goto-char (nth 1 c-reg)))))))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
642 (let ((count 0)
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
643 (top-level-re (concat "^" hs-block-start-regexp))
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
644 (buf-size (buffer-size)))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
645 (while
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
646 (progn
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
647 (forward-comment buf-size)
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
648 (re-search-forward top-level-re (point-max) t))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
649 (goto-char (match-beginning 0))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
650 (hs-hide-block-at-point t)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
651 (message "Hiding ... %d" (setq count (1+ count))))))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
652 (hs-safety-is-job-n))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
653 (beginning-of-line)
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
654 (message "Hiding all blocks ... done")
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
655 (run-hooks 'hs-hide-hook)))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
656
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
657 (defun hs-show-all ()
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
658 "Shows all top-level blocks.
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
659 This does not change point; it runs the normal hook `hs-show-hook'.
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
660 See documentation for `run-hooks'."
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
661 (interactive)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
662 (hs-life-goes-on
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
663 (message "Showing all blocks ...")
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
664 (hs-flag-region (point-min) (point-max) nil)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
665 (message "Showing all blocks ... done")
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
666 (run-hooks 'hs-show-hook)))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
667
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
668 (defun hs-hide-block (&optional end)
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
669 "Selects a block and hides it.
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
670 With prefix arg, reposition at end. Block is defined as a sexp for
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
671 lispish modes, mode-specific otherwise. Comments are blocks, too.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
672 Upon completion, point is at repositioned and the normal hook
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
673 `hs-hide-hook' is run. See documentation for `run-hooks'."
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
674 (interactive "P")
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
675 (hs-life-goes-on
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
676 (let ((c-reg (hs-inside-comment-p)))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
677 (cond
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
678 ((and c-reg (or (null (nth 0 c-reg))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
679 (<= (count-lines (car c-reg) (nth 1 c-reg))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
680 (if hs-show-hidden-short-form 1 2))))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
681 (message "Not enough comment lines to hide!"))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
682 ((or c-reg (looking-at hs-block-start-regexp)
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
683 (hs-find-block-beginning))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
684 (hs-hide-block-at-point end c-reg)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
685 (hs-safety-is-job-n)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
686 (run-hooks 'hs-hide-hook))))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
687
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
688 (defun hs-show-block (&optional end)
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
689 "Selects a block and shows it.
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
690 With prefix arg, reposition at end. Upon completion, point is
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
691 repositioned and the normal hook `hs-show-hook' is run.
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
692 See documentation for `hs-hide-block' and `run-hooks'."
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
693 (interactive "P")
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
694 (hs-life-goes-on
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
695 (let ((c-reg (hs-inside-comment-p)))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
696 (if (or c-reg
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
697 (looking-at hs-block-start-regexp)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
698 (hs-find-block-beginning))
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
699 (progn
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
700 (hs-show-block-at-point end c-reg)
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
701 (hs-safety-is-job-n)
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
702 (run-hooks 'hs-show-hook))))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
703
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
704 (defun hs-show-region (beg end)
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
705 "Shows all lines from BEG to END, without doing any block analysis.
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
706 Note:`hs-show-region' is intended for use when `hs-show-block' signals
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
707 `unbalanced parentheses' and so is an emergency measure only. You may
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
708 become very confused if you use this command indiscriminately."
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
709 (interactive "r")
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
710 (hs-life-goes-on
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
711 (hs-flag-region beg end nil)
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
712 (hs-safety-is-job-n)
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
713 (run-hooks 'hs-show-hook)))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
714
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
715 ;;;###autoload
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
716 (defun hs-mouse-toggle-hiding (e)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
717 "Toggles hiding/showing of a block.
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
718 Should be bound to a mouse key."
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
719 (interactive "@e")
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
720 (mouse-set-point e)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
721 (if (hs-already-hidden-p)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
722 (hs-show-block)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
723 (hs-hide-block)))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
724
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
725 ;;;###autoload
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
726 (defun hs-minor-mode (&optional arg)
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
727 "Toggle hideshow minor mode.
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
728 With ARG, turn hideshow minor mode on if ARG is positive, off otherwise.
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
729 When hideshow minor mode is on, the menu bar is augmented with hideshow
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
730 commands and the hideshow commands are enabled.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
731 The value '(hs . t) is added to `buffer-invisibility-spec'.
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
732 Last, the normal hook `hs-minor-mode-hook' is run; see the doc
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
733 for `run-hooks'.
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
734
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
735 The main commands are: `hs-hide-all', `hs-show-all', `hs-hide-block'
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
736 and `hs-show-block'.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
737 Also see the documentation for the variable `hs-show-hidden-short-form'.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
738
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
739 Turning hideshow minor mode off reverts the menu bar and the
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
740 variables to default values and disables the hideshow commands.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
741
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
742 Key bindings:
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
743 \\{hs-minor-mode-map}"
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
744
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
745 (interactive "P")
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
746 (setq hs-minor-mode
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
747 (if (null arg)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
748 (not hs-minor-mode)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
749 (> (prefix-numeric-value arg) 0)))
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
750 (if hs-minor-mode
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
751 (progn
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
752 ; (if (eq hs-emacs-type 'lucid)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
753 ; (progn
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
754 ; (set-buffer-menubar (copy-sequence current-menubar))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
755 ; (add-menu nil (car hs-menu-bar) (cdr hs-menu-bar))))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
756 (make-variable-buffer-local 'line-move-ignore-invisible)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
757 (setq line-move-ignore-invisible t)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
758 (add-to-invisibility-spec '(hs . t)) ;;hs invisible
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
759 (hs-grok-mode-type)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
760 (run-hooks 'hs-minor-mode-hook))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
761 ; (if (eq hs-emacs-type 'lucid)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
762 ; (set-buffer-menubar (delete hs-menu-bar current-menubar)))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
763 (remove-from-invisibility-spec '(hs . t))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
764
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
765
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
766 ;;;----------------------------------------------------------------------------
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
767 ;;; load-time setup routines
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
768
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
769 ;; which emacs being used?
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
770 ;(setq hs-emacs-type
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
771 ; (if (string-match "xemacs\\|lucid" emacs-version)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
772 ; 'lucid
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
773 ; 'fsf))
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
774
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
775 ;; keymaps and menus
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
776 (if hs-minor-mode-map
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
777 nil
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
778 (setq hs-minor-mode-map (make-sparse-keymap))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
779 ;; I beleive there is nothing bound on this keys
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
780 (define-key hs-minor-mode-map "\C-ch" 'hs-hide-block)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
781 (define-key hs-minor-mode-map "\C-cs" 'hs-show-block)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
782 (define-key hs-minor-mode-map "\C-cH" 'hs-hide-all)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
783 (define-key hs-minor-mode-map "\C-cS" 'hs-show-all)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
784 (define-key hs-minor-mode-map "\C-cR" 'hs-show-region)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
785
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
786 (define-key hs-minor-mode-map [S-mouse-2] 'hs-mouse-toggle-hiding)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
787
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
788 ;; should we use easymenu here?
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
789 (define-key hs-minor-mode-map [menu-bar Hide/Show]
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
790 (cons "Hide/Show" (make-sparse-keymap "Hide/Show")))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
791 (define-key hs-minor-mode-map [menu-bar Hide/Show hs-show-region]
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
792 '("Show Region" . hs-show-region))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
793 (define-key hs-minor-mode-map [menu-bar Hide/Show hs-show-all]
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
794 '("Show All" . hs-show-all))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
795 (define-key hs-minor-mode-map [menu-bar Hide/Show hs-hide-all]
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
796 '("Hide All" . hs-hide-all))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
797 (define-key hs-minor-mode-map [menu-bar Hide/Show hs-show-block]
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
798 '("Show Block" . hs-show-block))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
799 (define-key hs-minor-mode-map [menu-bar Hide/Show hs-hide-block]
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
800 '("Hide Block" . hs-hide-block)))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
801
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
802 ;; some housekeeping
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
803 (or (assq 'hs-minor-mode minor-mode-map-alist)
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
804 (setq minor-mode-map-alist
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
805 (cons (cons 'hs-minor-mode hs-minor-mode-map)
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
806 minor-mode-map-alist)))
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
807 (or (assq 'hs-minor-mode minor-mode-alist)
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
808 (setq minor-mode-alist (append minor-mode-alist
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
809 (list '(hs-minor-mode " hs")))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
810
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
811 ;; make some variables buffer-local
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
812 (make-variable-buffer-local 'hs-minor-mode)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
813 (make-variable-buffer-local 'hs-c-start-regexp)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
814 (make-variable-buffer-local 'hs-block-start-regexp)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
815 (make-variable-buffer-local 'hs-block-end-regexp)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
816 (make-variable-buffer-local 'hs-forward-sexp-func)
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
817 (make-variable-buffer-local 'hs-adjust-block-beginning)
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
818 (put 'hs-minor-mode 'permanent-local t)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
819 (put 'hs-c-start-regexp 'permanent-local t)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
820 (put 'hs-block-start-regexp 'permanent-local t)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
821 (put 'hs-block-end-regexp 'permanent-local t)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
822 (put 'hs-forward-sexp-func 'permanent-local t)
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
823 (put 'hs-adjust-block-beginning 'permanent-local t)
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
824
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
825
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
826 ;;;----------------------------------------------------------------------------
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
827 ;;; that's it
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
828
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
829 (provide 'hideshow)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
830
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
831 ;;; hideshow.el ends here