0
|
1 ;;; hideshow.el --- minor mode cmds to selectively display blocks of code
|
|
2
|
2
|
3 ;; Copyright (C) 1994,1995,1996 Free Software Foundation
|
|
4
|
|
5 ;; Author: Thien-Thi Nguyen <ttn@netcom.com>
|
|
6 ;; Version: 3.4
|
|
7 ;; Keywords: C C++ lisp tools editing
|
|
8 ;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning
|
0
|
9
|
2
|
10 ;; This file is part of XEmacs.
|
0
|
11
|
2
|
12 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
13 ;; under the terms of the GNU General Public License as published by
|
|
14 ;; the Free Software Foundation; either version 2 of the License, or
|
|
15 ;; (at your option) any later version.
|
0
|
16
|
2
|
17 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 ;; General Public License for more details.
|
0
|
21
|
2
|
22 ;; You should have received a copy of the GNU General Public License
|
|
23 ;; along with XEmacs; see the file COPYING. If not, write to the Free
|
|
24 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
25 ;; 02111-1307, USA.
|
|
26
|
|
27 ;;; Synched up with: FSF 19.34.
|
|
28
|
|
29 ;; LCD Archive Entry:
|
|
30 ;; hideshow|Thien-Thi Nguyen|ttn@netcom.com|
|
|
31 ;; minor mode commands to selectively display blocks of code|
|
|
32 ;; 18-Oct-1994|3.4|~/modes/hideshow.el.Z|
|
0
|
33
|
|
34 ;;; Commentary:
|
|
35
|
2
|
36 ;; This file provides `hs-minor-mode'. When active, six commands:
|
|
37 ;; hs-{hide,show}-{all,block}, hs-show-region and hs-minor-mode
|
|
38 ;; are available. They implement block hiding and showing. Blocks are
|
|
39 ;; defined in mode-specific way. In c-mode or c++-mode, they are simply
|
|
40 ;; curly braces, while in lisp-ish modes they are parens. Multi-line
|
|
41 ;; comments (c-mode) can also be hidden. The command M-x hs-minor-mode
|
|
42 ;; toggles the minor mode or sets it (similar to outline minor mode).
|
|
43 ;; See documentation for each command for more info.
|
|
44 ;;
|
|
45 ;; The variable `hs-unbalance-handler-method' controls hideshow's behavior
|
|
46 ;; in the case of "unbalanced parentheses". See doc for more info.
|
0
|
47
|
2
|
48 ;; Suggested usage:
|
0
|
49
|
2
|
50 ;; (load-library "hideshow")
|
|
51 ;; (defun my-hs-setup () "enables hideshow and binds some commands"
|
|
52 ;; (hs-minor-mode 1)
|
|
53 ;; (define-key hs-minor-mode-map "\C-ch" 'hs-hide-block)
|
|
54 ;; (define-key hs-minor-mode-map "\C-cs" 'hs-show-block)
|
|
55 ;; (define-key hs-minro-mode-map "\C-cH" 'hs-hide-all)
|
|
56 ;; (define-key hs-minro-mode-map "\C-cS" 'hs-show-all)
|
|
57 ;; (define-key hs-minor-mode-map "\C-cR" 'hs-show-region))
|
|
58 ;; (add-hook 'X-mode-hook 'my-hs-setup t) ; other modes similarly
|
|
59 ;;
|
|
60 ;; where X = {emacs-lisp,c,c++,perl,...}. See the doc for the variable
|
|
61 ;; `hs-special-modes-alist' if you'd like to use hideshow w/ other modes.
|
0
|
62
|
2
|
63 ;; Etc:
|
0
|
64
|
2
|
65 ;; Bug reports and fixes welcome (comments, too). Thanks go to
|
|
66 ;; Dean Andrews <adahome@ix.netcom.com>
|
|
67 ;; Preston F. Crow <preston.f.crow@dartmouth.edu>
|
|
68 ;; Gael Marziou <gael@gnlab030.grenoble.hp.com>
|
|
69 ;; Keith Sheffield <sheff@edcsgw2.cr.usgs.gov>
|
|
70 ;; Jan Djarv <jan.djarv@sa.erisoft.se>
|
|
71 ;; Lars Lindberg <qhslali@aom.ericsson.se>
|
|
72 ;; Alf-Ivar Holm <alfh@ifi.uio.no>
|
|
73 ;; for valuable feedback, code and bug reports.
|
0
|
74
|
|
75 ;;; Code:
|
|
76
|
|
77
|
|
78 ;;;----------------------------------------------------------------------------
|
|
79 ;;; user-configurable variables
|
|
80
|
|
81 (defvar hs-unbalance-handler-method 'top-level
|
|
82 "*Symbol representing how \"unbalanced parentheses\" should be handled.
|
2
|
83 This error is usually signaled by `hs-show-block'. One of four values:
|
0
|
84 `top-level', `next-line', `signal' or `ignore'. Default is `top-level'.
|
|
85
|
|
86 - `top-level' -- Show top-level block containing the currently troublesome
|
2
|
87 block.
|
0
|
88 - `next-line' -- Use the fact that, for an already hidden block, its end
|
2
|
89 will be on the next line. Attempt to show this block.
|
0
|
90 - `signal' -- Pass the error through, stopping execution.
|
|
91 - `ignore' -- Ignore the error, continuing execution.
|
|
92
|
|
93 Values other than these four will be interpreted as `signal'.")
|
|
94
|
|
95 (defvar hs-special-modes-alist '((c-mode "{" "}")
|
|
96 (c++-mode "{" "}"))
|
|
97 "*Alist of the form (MODE START-RE END-RE FORWARD-SEXP-FUNC).
|
|
98 If present, hideshow will use these values for the start and end regexps,
|
|
99 respectively. Since Algol-ish languages do not have single-character
|
|
100 block delimiters, the function `forward-sexp' which is used by hideshow
|
|
101 doesn't work. In this case, if a similar function is provided, you can
|
|
102 register it and have hideshow use it instead of `forward-sexp'. To add
|
|
103 more values, use
|
|
104
|
|
105 \t(pushnew '(new-mode st-re end-re function-name)
|
|
106 \t hs-special-modes-alist :test 'equal)
|
|
107
|
|
108 For example:
|
|
109
|
|
110 \t(pushnew '(simula-mode \"begin\" \"end\" simula-next-statement)
|
|
111 \t hs-special-modes-alist :test 'equal)
|
|
112
|
|
113 Note that the regexps should not contain leading or trailing whitespace.")
|
|
114
|
2
|
115 (defvar hs-hide-hook nil
|
|
116 "*Hooks called at the end of `hs-hide-all' and `hs-hide-block'.")
|
0
|
117
|
2
|
118 (defvar hs-show-hook nil
|
|
119 "*Hooks called at the end of commands to show text.
|
|
120 These commands include `hs-show-all', `hs-show-block' and `hs-show-region'.")
|
0
|
121
|
|
122 (defvar hs-minor-mode-prefix "\C-c"
|
|
123 "*Prefix key to use for hideshow commands in hideshow minor mode.")
|
|
124
|
|
125
|
|
126 ;;;----------------------------------------------------------------------------
|
|
127 ;;; internal variables
|
|
128
|
|
129 ;;;###autoload
|
|
130 (defvar hs-minor-mode nil
|
|
131 "Non-nil if using hideshow mode as a minor mode of some other mode.
|
|
132 Use the command `hs-minor-mode' to toggle this variable.")
|
|
133
|
|
134 (defvar hs-minor-mode-map nil
|
|
135 "Mode map for hideshow minor mode.")
|
|
136
|
|
137 (defvar hs-menu-bar nil
|
|
138 "Menu bar for hideshow minor mode (Xemacs only).")
|
|
139
|
|
140 (defvar hs-c-start-regexp nil
|
|
141 "Regexp for beginning of comments. Buffer-local.
|
|
142 Differs from mode-specific comment regexps in that surrounding
|
|
143 whitespace is stripped.")
|
|
144
|
|
145 (defvar hs-c-end-regexp nil
|
|
146 "Regexp for end of comments. Buffer-local.
|
|
147 See `hs-c-start-regexp'.")
|
|
148
|
|
149 (defvar hs-block-start-regexp nil
|
|
150 "Regexp for beginning of block. Buffer-local.")
|
|
151
|
|
152 (defvar hs-block-end-regexp nil
|
|
153 "Regexp for end of block. Buffer-local.")
|
|
154
|
|
155 (defvar hs-forward-sexp-func 'forward-sexp
|
|
156 "Function used to do a forward-sexp. Should change for Algol-ish modes.
|
|
157 For single-character block delimiters -- ie, the syntax table regexp for the
|
|
158 character is either `(' or `)' -- `hs-forward-sexp-func' would just be
|
|
159 `forward-sexp'. For other modes such as simula, a more specialized function
|
|
160 is necessary.")
|
|
161
|
|
162 (defvar hs-emacs-type 'fsf
|
|
163 "Used to support both FSF Emacs and Xemacs.")
|
|
164
|
|
165 (eval-when-compile
|
|
166 (if (string-match "xemacs\\|lucid" emacs-version)
|
|
167 (progn
|
|
168 (defvar current-menubar nil "")
|
|
169 (defun set-buffer-menubar (arg1))
|
|
170 (defun add-menu (arg1 arg2 arg3)))))
|
|
171
|
|
172
|
|
173 ;;;----------------------------------------------------------------------------
|
|
174 ;;; support funcs
|
|
175
|
|
176 ;; snarfed from outline.el, but added buffer-read-only
|
|
177 (defun hs-flag-region (from to flag)
|
|
178 "Hides or shows lines from FROM to TO, according to FLAG.
|
2
|
179 If FLAG is `?\\n' (the newline character) then show the text;
|
|
180 if FLAG is `?\\^M' \(control-M) then hide the text."
|
0
|
181 (let ((modp (buffer-modified-p))
|
|
182 buffer-read-only) ; nothing is immune
|
|
183 (unwind-protect (progn
|
|
184 (subst-char-in-region
|
|
185 from to
|
|
186 (if (= flag ?\n) ?\C-m ?\n)
|
|
187 flag t))
|
|
188 (set-buffer-modified-p modp))))
|
|
189
|
|
190 (defun hs-hide-block-at-point (&optional end)
|
|
191 "Hide block iff on block beginning, optional END means reposition at end."
|
|
192 (if (looking-at hs-block-start-regexp)
|
|
193 (let* ((p (point))
|
|
194 (q (progn (funcall hs-forward-sexp-func 1) (point))))
|
|
195 (forward-line -1) (end-of-line)
|
|
196 (if (and (< p (point)) (> (count-lines p q) 1))
|
|
197 (hs-flag-region p (point) ?\C-m))
|
|
198 (goto-char (if end q p)))))
|
|
199
|
|
200 (defun hs-show-block-at-point (&optional end)
|
|
201 "Show block iff on block beginning. Optional END means reposition at end."
|
|
202 (if (looking-at hs-block-start-regexp)
|
|
203 (let* ((p (point))
|
|
204 (q
|
|
205 (condition-case error ; probably unbalanced paren
|
|
206 (progn
|
|
207 (funcall hs-forward-sexp-func 1)
|
|
208 (point))
|
|
209 (error
|
|
210 (cond
|
|
211 ((eq hs-unbalance-handler-method 'ignore)
|
|
212 ;; just ignore this block
|
|
213 (point))
|
|
214 ((eq hs-unbalance-handler-method 'top-level)
|
|
215 ;; try to get out of rat's nest and expose the whole func
|
|
216 (if (/= (current-column) 0) (beginning-of-defun))
|
|
217 (setq p (point))
|
|
218 (re-search-forward (concat "^" hs-block-start-regexp)
|
|
219 (point-max) t 2)
|
|
220 (point))
|
|
221 ((eq hs-unbalance-handler-method 'next-line)
|
|
222 ;; assumption is that user knows what s/he's doing
|
|
223 (beginning-of-line) (setq p (point))
|
|
224 (end-of-line 2) (point))
|
|
225 (t
|
|
226 ;; pass error through -- this applies to `signal', too
|
|
227 (signal (car error) (cdr error))))))))
|
|
228 (hs-flag-region p q ?\n)
|
|
229 (goto-char (if end (1+ (point)) p)))))
|
|
230
|
|
231 (defun hs-safety-is-job-n ()
|
2
|
232 "Warn if `selective-display' or `selective-display-ellipses' is nil."
|
0
|
233 (let ((str ""))
|
|
234 (or selective-display
|
|
235 (setq str "selective-display nil "))
|
|
236 (or selective-display-ellipses
|
|
237 (setq str (concat str "selective-display-ellipses nil")))
|
|
238 (if (= (length str) 0)
|
|
239 nil
|
|
240 (message "warning: %s" str)
|
|
241 (sit-for 2))))
|
|
242
|
|
243 (defun hs-inside-comment-p ()
|
|
244 "Returns non-nil if point is inside a comment, otherwise nil.
|
|
245 Actually, for multi-line-able comments, returns a list containing
|
|
246 the buffer position of the start and the end of the comment."
|
|
247 ;; is it single-line-only or multi-line-able?
|
|
248 (save-excursion
|
|
249 (let ((p (point))
|
|
250 q)
|
|
251 (if (string= comment-end "") ; single line
|
|
252 (let (found)
|
|
253 (beginning-of-line)
|
|
254 (setq found (re-search-forward hs-c-start-regexp p t))
|
|
255 (and found (not (search-forward "\"" p t))))
|
|
256 (re-search-forward hs-c-end-regexp (point-max) 1)
|
|
257 (setq q (point))
|
|
258 (forward-comment -1)
|
|
259 (re-search-forward hs-c-start-regexp (point-max) 1)
|
|
260 (if (< (- (point) (length comment-start)) p)
|
|
261 (list (match-beginning 0) q))))))
|
|
262
|
|
263 (defun hs-grok-mode-type ()
|
|
264 "Setup variables for new buffers where applicable."
|
|
265 (if (and (boundp 'comment-start)
|
|
266 (boundp 'comment-end))
|
|
267 (progn
|
|
268 (setq hs-c-start-regexp (regexp-quote comment-start))
|
|
269 (if (string-match " +$" hs-c-start-regexp)
|
|
270 (setq hs-c-start-regexp
|
|
271 (substring hs-c-start-regexp 0 (1- (match-end 0)))))
|
|
272 (setq hs-c-end-regexp (if (string= "" comment-end) "\n"
|
|
273 (regexp-quote comment-end)))
|
|
274 (if (string-match "^ +" hs-c-end-regexp)
|
|
275 (setq hs-c-end-regexp
|
|
276 (substring hs-c-end-regexp (match-end 0))))
|
|
277 (let ((lookup (assoc major-mode hs-special-modes-alist)))
|
|
278 (setq hs-block-start-regexp (or (nth 1 lookup) "\\s\(")
|
|
279 hs-block-end-regexp (or (nth 2 lookup) "\\s\)")
|
|
280 hs-forward-sexp-func (or (nth 3 lookup) 'forward-sexp))))))
|
|
281
|
|
282 (defun hs-find-block-beginning ()
|
|
283 "Repositions point at block-start. Return point, or nil if top-level."
|
|
284 (let (done
|
|
285 (here (point))
|
|
286 (both-regexps (concat "\\(" hs-block-start-regexp "\\)\\|\\("
|
|
287 hs-block-end-regexp "\\)")))
|
|
288 (while (and (not done)
|
|
289 (re-search-backward both-regexps (point-min) t))
|
|
290 (if (match-beginning 1) ; start of start-regexp
|
|
291 (setq done (match-beginning 1))
|
|
292 (goto-char (match-end 2)) ; end of end-regexp
|
|
293 (funcall hs-forward-sexp-func -1)))
|
|
294 (goto-char (or done here))
|
|
295 done))
|
|
296
|
|
297 (defmacro hs-life-goes-on (&rest body)
|
|
298 "Executes optional BODY iff variable `hs-minor-mode' is non-nil."
|
|
299 (list 'if 'hs-minor-mode (cons 'progn body)))
|
|
300
|
|
301
|
|
302 ;;;----------------------------------------------------------------------------
|
|
303 ;;; commands
|
|
304
|
|
305 ;;;###autoload
|
|
306 (defun hs-hide-all ()
|
|
307 "Hides all top-level blocks, displaying only first and last lines.
|
2
|
308 It moves point to the beginning of the line, and it runs the normal hook
|
|
309 `hs-hide-hook'. See documentation for `run-hooks'."
|
0
|
310 (interactive)
|
|
311 (hs-life-goes-on
|
|
312 (message "hiding all blocks ...")
|
|
313 (save-excursion
|
|
314 (hs-flag-region (point-min) (point-max) ?\n) ; eliminate weirdness
|
|
315 (goto-char (point-min))
|
|
316 (let ((count 0)
|
|
317 (top-level-re (concat "^" hs-block-start-regexp)))
|
|
318 (while (progn
|
|
319 (forward-comment (buffer-size))
|
|
320 (re-search-forward top-level-re (point-max) t))
|
|
321 (goto-char (match-beginning 0))
|
|
322 (hs-hide-block-at-point t)
|
|
323 (message "hiding ... %d" (setq count (1+ count)))))
|
|
324 (hs-safety-is-job-n))
|
|
325 (beginning-of-line)
|
|
326 (message "hiding all blocks ... done")
|
2
|
327 (run-hooks 'hs-hide-hook)))
|
0
|
328
|
|
329 (defun hs-show-all ()
|
|
330 "Shows all top-level blocks.
|
2
|
331 This does not change point; it runs the normal hook `hs-show-hook'.
|
|
332 See documentation for `run-hooks'."
|
0
|
333 (interactive)
|
|
334 (hs-life-goes-on
|
|
335 (message "showing all blocks ...")
|
|
336 (hs-flag-region (point-min) (point-max) ?\n)
|
|
337 (message "showing all blocks ... done")
|
2
|
338 (run-hooks 'hs-show-hook)))
|
0
|
339
|
|
340 ;;;###autoload
|
|
341 (defun hs-hide-block (&optional end)
|
|
342 "Selects a block and hides it. With prefix arg, reposition at end.
|
|
343 Block is defined as a sexp for lispish modes, mode-specific otherwise.
|
|
344 Comments are blocks, too. Upon completion, point is at repositioned and
|
2
|
345 the normal hook `hs-hide-hook' is run. See documentation for `run-hooks'."
|
0
|
346 (interactive "P")
|
|
347 (hs-life-goes-on
|
|
348 (let ((c-reg (hs-inside-comment-p)))
|
|
349 (if c-reg
|
|
350 (cond ((string= comment-end "")
|
|
351 (message "can't hide a single-line comment"))
|
|
352 ((< (count-lines (car c-reg) (nth 1 c-reg)) 2)
|
2
|
353 (message "not enough comment lines to hide"))
|
0
|
354 (t
|
|
355 (goto-char (nth 1 c-reg))
|
|
356 (forward-line -1)
|
|
357 (hs-flag-region (car c-reg) (point) ?\C-m)
|
|
358 (goto-char (if end (nth 1 c-reg) (car c-reg)))
|
|
359 (hs-safety-is-job-n)
|
2
|
360 (run-hooks 'hs-hide-hook)))
|
0
|
361 (if (or (looking-at hs-block-start-regexp)
|
|
362 (hs-find-block-beginning))
|
|
363 (progn
|
|
364 (hs-hide-block-at-point end)
|
|
365 (hs-safety-is-job-n)
|
2
|
366 (run-hooks 'hs-hide-hook)))))))
|
0
|
367
|
|
368 (defun hs-show-block (&optional end)
|
|
369 "Selects a block and shows it. With prefix arg, reposition at end.
|
2
|
370 Upon completion, point is repositioned and the normal hook
|
|
371 `hs-show-hook' is run. See documentation for `hs-hide-block' and `run-hooks'."
|
0
|
372 (interactive "P")
|
|
373 (hs-life-goes-on
|
|
374 (let ((c-reg (hs-inside-comment-p)))
|
|
375 (if c-reg
|
|
376 (cond ((string= comment-end "")
|
|
377 (message "already looking at the entire comment"))
|
|
378 (t
|
|
379 (hs-flag-region (car c-reg) (nth 1 c-reg) ?\n)
|
|
380 (goto-char (if end (nth 1 c-reg) (car c-reg)))))
|
|
381 (if (or (looking-at hs-block-start-regexp)
|
|
382 (hs-find-block-beginning))
|
|
383 (progn
|
|
384 (hs-show-block-at-point end)
|
|
385 (hs-safety-is-job-n)
|
2
|
386 (run-hooks 'hs-show-hook)))))))
|
0
|
387
|
|
388 (defun hs-show-region (beg end)
|
|
389 "Shows all lines from BEG to END, without doing any block analysis.
|
2
|
390 Note:` hs-show-region' is intended for use when when `hs-show-block' signals
|
0
|
391 `unbalanced parentheses' and so is an emergency measure only. You may
|
|
392 become very confused if you use this command indiscriminately."
|
|
393 (interactive "r")
|
|
394 (hs-life-goes-on
|
|
395 (hs-flag-region beg end ?\n)
|
|
396 (hs-safety-is-job-n)
|
2
|
397 (run-hooks 'hs-show-hook)))
|
0
|
398
|
|
399 ;;;###autoload
|
|
400 (defun hs-minor-mode (&optional arg)
|
|
401 "Toggle hideshow minor mode.
|
|
402 With ARG, turn hideshow minor mode on if ARG is positive, off otherwise.
|
|
403 When hideshow minor mode is on, the menu bar is augmented with hideshow
|
2
|
404 commands and the hideshow commands are enabled. The variables
|
|
405 `selective-display' and `selective-display-ellipses' are set to t.
|
|
406 Last, the normal hook `hs-minor-mode-hook' is run; see the doc for `run-hooks'.
|
|
407
|
0
|
408 Turning hideshow minor mode off reverts the menu bar and the
|
|
409 variables to default values and disables the hideshow commands."
|
|
410 (interactive "P")
|
|
411 (setq hs-minor-mode
|
|
412 (if (null arg)
|
|
413 (not hs-minor-mode)
|
|
414 (> (prefix-numeric-value arg) 0)))
|
|
415 (if hs-minor-mode
|
|
416 (progn
|
|
417 (if (eq hs-emacs-type 'lucid)
|
|
418 (progn
|
|
419 (set-buffer-menubar (copy-sequence current-menubar))
|
|
420 (add-menu nil (car hs-menu-bar) (cdr hs-menu-bar))))
|
|
421 (setq selective-display t
|
|
422 selective-display-ellipses t)
|
|
423 (hs-grok-mode-type)
|
|
424 (run-hooks 'hs-minor-mode-hook))
|
|
425 (if (eq hs-emacs-type 'lucid)
|
|
426 (set-buffer-menubar (delete hs-menu-bar current-menubar)))
|
|
427 (kill-local-variable 'selective-display)
|
|
428 (kill-local-variable 'selective-display-ellipses)))
|
|
429
|
|
430
|
|
431 ;;;----------------------------------------------------------------------------
|
|
432 ;;; load-time setup routines
|
|
433
|
|
434 ;; which emacs being used?
|
|
435 (setq hs-emacs-type
|
|
436 (if (string-match "XEmacs\\|Lucid" emacs-version)
|
|
437 'lucid
|
|
438 'fsf))
|
|
439
|
|
440 ;; keymaps and menus
|
|
441 (if (not hs-minor-mode-map)
|
|
442 (setq hs-minor-mode-map (make-sparse-keymap))
|
|
443 ;; XEmacs: need this for the change in add-minor-mode
|
|
444 (fset 'hs-minor-mode-map hs-minor-mode-map)
|
|
445 (cond
|
|
446 ((eq hs-emacs-type 'lucid)
|
|
447 (setq hs-menu-bar ; build top down for lucid
|
|
448 '("hideshow"
|
|
449 ["Hide Block" hs-hide-block t]
|
|
450 ["Show Block" hs-show-block t]
|
|
451 ["Hide All" hs-hide-all t]
|
|
452 ["Show All" hs-show-all t]
|
|
453 ["Show Region" hs-show-region t])))
|
|
454 (t ; build bottom up for others
|
|
455 (define-key hs-minor-mode-map [menu-bar hideshow]
|
|
456 (cons "hideshow" (make-sparse-keymap "hideshow")))
|
|
457 (define-key hs-minor-mode-map [menu-bar hideshow hs-show-region]
|
|
458 '("Show Region" . hs-show-region))
|
|
459 (define-key hs-minor-mode-map [menu-bar hideshow hs-show-all]
|
|
460 '("Show All" . hs-show-all))
|
|
461 (define-key hs-minor-mode-map [menu-bar hideshow hs-hide-all]
|
|
462 '("Hide All" . hs-hide-all))
|
|
463 (define-key hs-minor-mode-map [menu-bar hideshow hs-show-block]
|
|
464 '("Show Block" . hs-show-block))
|
|
465 (define-key hs-minor-mode-map [menu-bar hideshow hs-hide-block]
|
|
466 '("Hide Block" . hs-hide-block)))))
|
|
467
|
|
468 ;; some housekeeping
|
|
469 ;(or (assq 'hs-minor-mode minor-mode-map-alist)
|
|
470 ; (setq minor-mode-map-alist
|
|
471 ; (cons (cons 'hs-minor-mode hs-minor-mode-map)
|
|
472 ; minor-mode-map-alist)))
|
|
473 ;(or (assq 'hs-minor-mode minor-mode-alist)
|
|
474 ; (setq minor-mode-alist (append minor-mode-alist
|
|
475 ; (list '(hs-minor-mode " hs")))))
|
|
476 ;; XEmacs: do it right.
|
|
477 ;;;###autoload
|
|
478 (add-minor-mode 'hs-minor-mode " hs" 'hs-minor-mode-map)
|
|
479
|
|
480 ;; make some variables buffer-local
|
|
481 (make-variable-buffer-local 'hs-minor-mode)
|
|
482 (make-variable-buffer-local 'hs-c-start-regexp)
|
|
483 (make-variable-buffer-local 'hs-c-end-regexp)
|
|
484 (make-variable-buffer-local 'hs-block-start-regexp)
|
|
485 (make-variable-buffer-local 'hs-block-end-regexp)
|
|
486 (make-variable-buffer-local 'hs-forward-sexp-func)
|
|
487 (put 'hs-minor-mode 'permanent-local t)
|
|
488 (put 'hs-c-start-regexp 'permanent-local t)
|
|
489 (put 'hs-c-end-regexp 'permanent-local t)
|
|
490 (put 'hs-block-start-regexp 'permanent-local t)
|
|
491 (put 'hs-block-end-regexp 'permanent-local t)
|
|
492 (put 'hs-forward-sexp-func 'permanent-local t)
|
|
493
|
|
494
|
|
495 ;;;----------------------------------------------------------------------------
|
|
496 ;;; that's it
|
|
497
|
|
498 (provide 'hideshow)
|
|
499
|
|
500 ;;; hideshow.el ends here
|