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