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
|
74
|
162 (defvar hs-emacs-type 'lucid
|
0
|
163 "Used to support both FSF Emacs and Xemacs.")
|
|
164
|
74
|
165 ;; This doesn't work
|
|
166 ;(eval-when-compile
|
|
167 ; (if (string-match "XEmacs\\|Lucid" emacs-version)
|
|
168 ; (progn
|
|
169 ; (defvar current-menubar nil "")
|
|
170 ; (defun set-buffer-menubar (arg1))
|
|
171 ; (defmacro add-menu (arg1 arg2 arg3)))))
|
0
|
172
|
|
173
|
|
174 ;;;----------------------------------------------------------------------------
|
|
175 ;;; support funcs
|
|
176
|
|
177 ;; snarfed from outline.el, but added buffer-read-only
|
|
178 (defun hs-flag-region (from to flag)
|
|
179 "Hides or shows lines from FROM to TO, according to FLAG.
|
2
|
180 If FLAG is `?\\n' (the newline character) then show the text;
|
|
181 if FLAG is `?\\^M' \(control-M) then hide the text."
|
0
|
182 (let ((modp (buffer-modified-p))
|
|
183 buffer-read-only) ; nothing is immune
|
|
184 (unwind-protect (progn
|
|
185 (subst-char-in-region
|
|
186 from to
|
|
187 (if (= flag ?\n) ?\C-m ?\n)
|
|
188 flag t))
|
|
189 (set-buffer-modified-p modp))))
|
|
190
|
|
191 (defun hs-hide-block-at-point (&optional end)
|
|
192 "Hide block iff on block beginning, optional END means reposition at end."
|
|
193 (if (looking-at hs-block-start-regexp)
|
|
194 (let* ((p (point))
|
|
195 (q (progn (funcall hs-forward-sexp-func 1) (point))))
|
|
196 (forward-line -1) (end-of-line)
|
|
197 (if (and (< p (point)) (> (count-lines p q) 1))
|
|
198 (hs-flag-region p (point) ?\C-m))
|
|
199 (goto-char (if end q p)))))
|
|
200
|
|
201 (defun hs-show-block-at-point (&optional end)
|
|
202 "Show block iff on block beginning. Optional END means reposition at end."
|
|
203 (if (looking-at hs-block-start-regexp)
|
|
204 (let* ((p (point))
|
|
205 (q
|
|
206 (condition-case error ; probably unbalanced paren
|
|
207 (progn
|
|
208 (funcall hs-forward-sexp-func 1)
|
|
209 (point))
|
|
210 (error
|
|
211 (cond
|
|
212 ((eq hs-unbalance-handler-method 'ignore)
|
|
213 ;; just ignore this block
|
|
214 (point))
|
|
215 ((eq hs-unbalance-handler-method 'top-level)
|
|
216 ;; try to get out of rat's nest and expose the whole func
|
|
217 (if (/= (current-column) 0) (beginning-of-defun))
|
|
218 (setq p (point))
|
|
219 (re-search-forward (concat "^" hs-block-start-regexp)
|
|
220 (point-max) t 2)
|
|
221 (point))
|
|
222 ((eq hs-unbalance-handler-method 'next-line)
|
|
223 ;; assumption is that user knows what s/he's doing
|
|
224 (beginning-of-line) (setq p (point))
|
|
225 (end-of-line 2) (point))
|
|
226 (t
|
|
227 ;; pass error through -- this applies to `signal', too
|
|
228 (signal (car error) (cdr error))))))))
|
|
229 (hs-flag-region p q ?\n)
|
|
230 (goto-char (if end (1+ (point)) p)))))
|
|
231
|
|
232 (defun hs-safety-is-job-n ()
|
2
|
233 "Warn if `selective-display' or `selective-display-ellipses' is nil."
|
0
|
234 (let ((str ""))
|
|
235 (or selective-display
|
|
236 (setq str "selective-display nil "))
|
|
237 (or selective-display-ellipses
|
|
238 (setq str (concat str "selective-display-ellipses nil")))
|
|
239 (if (= (length str) 0)
|
|
240 nil
|
|
241 (message "warning: %s" str)
|
|
242 (sit-for 2))))
|
|
243
|
|
244 (defun hs-inside-comment-p ()
|
|
245 "Returns non-nil if point is inside a comment, otherwise nil.
|
|
246 Actually, for multi-line-able comments, returns a list containing
|
|
247 the buffer position of the start and the end of the comment."
|
|
248 ;; is it single-line-only or multi-line-able?
|
|
249 (save-excursion
|
|
250 (let ((p (point))
|
|
251 q)
|
|
252 (if (string= comment-end "") ; single line
|
|
253 (let (found)
|
|
254 (beginning-of-line)
|
|
255 (setq found (re-search-forward hs-c-start-regexp p t))
|
|
256 (and found (not (search-forward "\"" p t))))
|
|
257 (re-search-forward hs-c-end-regexp (point-max) 1)
|
|
258 (setq q (point))
|
|
259 (forward-comment -1)
|
|
260 (re-search-forward hs-c-start-regexp (point-max) 1)
|
|
261 (if (< (- (point) (length comment-start)) p)
|
|
262 (list (match-beginning 0) q))))))
|
|
263
|
|
264 (defun hs-grok-mode-type ()
|
|
265 "Setup variables for new buffers where applicable."
|
|
266 (if (and (boundp 'comment-start)
|
|
267 (boundp 'comment-end))
|
|
268 (progn
|
|
269 (setq hs-c-start-regexp (regexp-quote comment-start))
|
|
270 (if (string-match " +$" hs-c-start-regexp)
|
|
271 (setq hs-c-start-regexp
|
|
272 (substring hs-c-start-regexp 0 (1- (match-end 0)))))
|
|
273 (setq hs-c-end-regexp (if (string= "" comment-end) "\n"
|
|
274 (regexp-quote comment-end)))
|
|
275 (if (string-match "^ +" hs-c-end-regexp)
|
|
276 (setq hs-c-end-regexp
|
|
277 (substring hs-c-end-regexp (match-end 0))))
|
|
278 (let ((lookup (assoc major-mode hs-special-modes-alist)))
|
|
279 (setq hs-block-start-regexp (or (nth 1 lookup) "\\s\(")
|
|
280 hs-block-end-regexp (or (nth 2 lookup) "\\s\)")
|
|
281 hs-forward-sexp-func (or (nth 3 lookup) 'forward-sexp))))))
|
|
282
|
|
283 (defun hs-find-block-beginning ()
|
|
284 "Repositions point at block-start. Return point, or nil if top-level."
|
|
285 (let (done
|
|
286 (here (point))
|
|
287 (both-regexps (concat "\\(" hs-block-start-regexp "\\)\\|\\("
|
|
288 hs-block-end-regexp "\\)")))
|
|
289 (while (and (not done)
|
|
290 (re-search-backward both-regexps (point-min) t))
|
|
291 (if (match-beginning 1) ; start of start-regexp
|
|
292 (setq done (match-beginning 1))
|
|
293 (goto-char (match-end 2)) ; end of end-regexp
|
|
294 (funcall hs-forward-sexp-func -1)))
|
|
295 (goto-char (or done here))
|
|
296 done))
|
|
297
|
|
298 (defmacro hs-life-goes-on (&rest body)
|
|
299 "Executes optional BODY iff variable `hs-minor-mode' is non-nil."
|
|
300 (list 'if 'hs-minor-mode (cons 'progn body)))
|
|
301
|
|
302
|
|
303 ;;;----------------------------------------------------------------------------
|
|
304 ;;; commands
|
|
305
|
|
306 ;;;###autoload
|
|
307 (defun hs-hide-all ()
|
|
308 "Hides all top-level blocks, displaying only first and last lines.
|
2
|
309 It moves point to the beginning of the line, and it runs the normal hook
|
|
310 `hs-hide-hook'. See documentation for `run-hooks'."
|
0
|
311 (interactive)
|
|
312 (hs-life-goes-on
|
|
313 (message "hiding all blocks ...")
|
|
314 (save-excursion
|
|
315 (hs-flag-region (point-min) (point-max) ?\n) ; eliminate weirdness
|
|
316 (goto-char (point-min))
|
|
317 (let ((count 0)
|
|
318 (top-level-re (concat "^" hs-block-start-regexp)))
|
|
319 (while (progn
|
|
320 (forward-comment (buffer-size))
|
|
321 (re-search-forward top-level-re (point-max) t))
|
|
322 (goto-char (match-beginning 0))
|
|
323 (hs-hide-block-at-point t)
|
|
324 (message "hiding ... %d" (setq count (1+ count)))))
|
|
325 (hs-safety-is-job-n))
|
|
326 (beginning-of-line)
|
|
327 (message "hiding all blocks ... done")
|
2
|
328 (run-hooks 'hs-hide-hook)))
|
0
|
329
|
|
330 (defun hs-show-all ()
|
|
331 "Shows all top-level blocks.
|
2
|
332 This does not change point; it runs the normal hook `hs-show-hook'.
|
|
333 See documentation for `run-hooks'."
|
0
|
334 (interactive)
|
|
335 (hs-life-goes-on
|
|
336 (message "showing all blocks ...")
|
|
337 (hs-flag-region (point-min) (point-max) ?\n)
|
|
338 (message "showing all blocks ... done")
|
2
|
339 (run-hooks 'hs-show-hook)))
|
0
|
340
|
|
341 ;;;###autoload
|
|
342 (defun hs-hide-block (&optional end)
|
|
343 "Selects a block and hides it. With prefix arg, reposition at end.
|
|
344 Block is defined as a sexp for lispish modes, mode-specific otherwise.
|
|
345 Comments are blocks, too. Upon completion, point is at repositioned and
|
2
|
346 the normal hook `hs-hide-hook' is run. See documentation for `run-hooks'."
|
0
|
347 (interactive "P")
|
|
348 (hs-life-goes-on
|
|
349 (let ((c-reg (hs-inside-comment-p)))
|
|
350 (if c-reg
|
|
351 (cond ((string= comment-end "")
|
|
352 (message "can't hide a single-line comment"))
|
|
353 ((< (count-lines (car c-reg) (nth 1 c-reg)) 2)
|
2
|
354 (message "not enough comment lines to hide"))
|
0
|
355 (t
|
|
356 (goto-char (nth 1 c-reg))
|
|
357 (forward-line -1)
|
|
358 (hs-flag-region (car c-reg) (point) ?\C-m)
|
|
359 (goto-char (if end (nth 1 c-reg) (car c-reg)))
|
|
360 (hs-safety-is-job-n)
|
2
|
361 (run-hooks 'hs-hide-hook)))
|
0
|
362 (if (or (looking-at hs-block-start-regexp)
|
|
363 (hs-find-block-beginning))
|
|
364 (progn
|
|
365 (hs-hide-block-at-point end)
|
|
366 (hs-safety-is-job-n)
|
2
|
367 (run-hooks 'hs-hide-hook)))))))
|
0
|
368
|
|
369 (defun hs-show-block (&optional end)
|
|
370 "Selects a block and shows it. With prefix arg, reposition at end.
|
2
|
371 Upon completion, point is repositioned and the normal hook
|
|
372 `hs-show-hook' is run. See documentation for `hs-hide-block' and `run-hooks'."
|
0
|
373 (interactive "P")
|
|
374 (hs-life-goes-on
|
|
375 (let ((c-reg (hs-inside-comment-p)))
|
|
376 (if c-reg
|
|
377 (cond ((string= comment-end "")
|
|
378 (message "already looking at the entire comment"))
|
|
379 (t
|
|
380 (hs-flag-region (car c-reg) (nth 1 c-reg) ?\n)
|
|
381 (goto-char (if end (nth 1 c-reg) (car c-reg)))))
|
|
382 (if (or (looking-at hs-block-start-regexp)
|
|
383 (hs-find-block-beginning))
|
|
384 (progn
|
|
385 (hs-show-block-at-point end)
|
|
386 (hs-safety-is-job-n)
|
2
|
387 (run-hooks 'hs-show-hook)))))))
|
0
|
388
|
|
389 (defun hs-show-region (beg end)
|
|
390 "Shows all lines from BEG to END, without doing any block analysis.
|
2
|
391 Note:` hs-show-region' is intended for use when when `hs-show-block' signals
|
0
|
392 `unbalanced parentheses' and so is an emergency measure only. You may
|
|
393 become very confused if you use this command indiscriminately."
|
|
394 (interactive "r")
|
|
395 (hs-life-goes-on
|
|
396 (hs-flag-region beg end ?\n)
|
|
397 (hs-safety-is-job-n)
|
2
|
398 (run-hooks 'hs-show-hook)))
|
0
|
399
|
|
400 ;;;###autoload
|
|
401 (defun hs-minor-mode (&optional arg)
|
|
402 "Toggle hideshow minor mode.
|
|
403 With ARG, turn hideshow minor mode on if ARG is positive, off otherwise.
|
|
404 When hideshow minor mode is on, the menu bar is augmented with hideshow
|
2
|
405 commands and the hideshow commands are enabled. The variables
|
|
406 `selective-display' and `selective-display-ellipses' are set to t.
|
|
407 Last, the normal hook `hs-minor-mode-hook' is run; see the doc for `run-hooks'.
|
|
408
|
0
|
409 Turning hideshow minor mode off reverts the menu bar and the
|
|
410 variables to default values and disables the hideshow commands."
|
|
411 (interactive "P")
|
|
412 (setq hs-minor-mode
|
|
413 (if (null arg)
|
|
414 (not hs-minor-mode)
|
|
415 (> (prefix-numeric-value arg) 0)))
|
|
416 (if hs-minor-mode
|
|
417 (progn
|
|
418 (if (eq hs-emacs-type 'lucid)
|
|
419 (progn
|
|
420 (set-buffer-menubar (copy-sequence current-menubar))
|
74
|
421 (add-submenu (car hs-menu-bar) hs-menu-bar)))
|
0
|
422 (setq selective-display t
|
|
423 selective-display-ellipses t)
|
|
424 (hs-grok-mode-type)
|
|
425 (run-hooks 'hs-minor-mode-hook))
|
|
426 (if (eq hs-emacs-type 'lucid)
|
|
427 (set-buffer-menubar (delete hs-menu-bar current-menubar)))
|
|
428 (kill-local-variable 'selective-display)
|
|
429 (kill-local-variable 'selective-display-ellipses)))
|
|
430
|
|
431
|
|
432 ;;;----------------------------------------------------------------------------
|
|
433 ;;; load-time setup routines
|
|
434
|
|
435 ;; which emacs being used?
|
|
436 (setq hs-emacs-type
|
|
437 (if (string-match "XEmacs\\|Lucid" emacs-version)
|
|
438 'lucid
|
|
439 'fsf))
|
|
440
|
|
441 ;; keymaps and menus
|
|
442 (if (not hs-minor-mode-map)
|
|
443 (setq hs-minor-mode-map (make-sparse-keymap))
|
|
444 ;; XEmacs: need this for the change in add-minor-mode
|
|
445 (fset 'hs-minor-mode-map hs-minor-mode-map)
|
|
446 (cond
|
|
447 ((eq hs-emacs-type 'lucid)
|
|
448 (setq hs-menu-bar ; build top down for lucid
|
|
449 '("hideshow"
|
|
450 ["Hide Block" hs-hide-block t]
|
|
451 ["Show Block" hs-show-block t]
|
|
452 ["Hide All" hs-hide-all t]
|
|
453 ["Show All" hs-show-all t]
|
|
454 ["Show Region" hs-show-region t])))
|
|
455 (t ; build bottom up for others
|
|
456 (define-key hs-minor-mode-map [menu-bar hideshow]
|
|
457 (cons "hideshow" (make-sparse-keymap "hideshow")))
|
|
458 (define-key hs-minor-mode-map [menu-bar hideshow hs-show-region]
|
|
459 '("Show Region" . hs-show-region))
|
|
460 (define-key hs-minor-mode-map [menu-bar hideshow hs-show-all]
|
|
461 '("Show All" . hs-show-all))
|
|
462 (define-key hs-minor-mode-map [menu-bar hideshow hs-hide-all]
|
|
463 '("Hide All" . hs-hide-all))
|
|
464 (define-key hs-minor-mode-map [menu-bar hideshow hs-show-block]
|
|
465 '("Show Block" . hs-show-block))
|
|
466 (define-key hs-minor-mode-map [menu-bar hideshow hs-hide-block]
|
|
467 '("Hide Block" . hs-hide-block)))))
|
|
468
|
|
469 ;; some housekeeping
|
|
470 ;(or (assq 'hs-minor-mode minor-mode-map-alist)
|
|
471 ; (setq minor-mode-map-alist
|
|
472 ; (cons (cons 'hs-minor-mode hs-minor-mode-map)
|
|
473 ; minor-mode-map-alist)))
|
|
474 ;(or (assq 'hs-minor-mode minor-mode-alist)
|
|
475 ; (setq minor-mode-alist (append minor-mode-alist
|
|
476 ; (list '(hs-minor-mode " hs")))))
|
|
477 ;; XEmacs: do it right.
|
|
478 ;;;###autoload
|
|
479 (add-minor-mode 'hs-minor-mode " hs" 'hs-minor-mode-map)
|
|
480
|
|
481 ;; make some variables buffer-local
|
|
482 (make-variable-buffer-local 'hs-minor-mode)
|
|
483 (make-variable-buffer-local 'hs-c-start-regexp)
|
|
484 (make-variable-buffer-local 'hs-c-end-regexp)
|
|
485 (make-variable-buffer-local 'hs-block-start-regexp)
|
|
486 (make-variable-buffer-local 'hs-block-end-regexp)
|
|
487 (make-variable-buffer-local 'hs-forward-sexp-func)
|
|
488 (put 'hs-minor-mode 'permanent-local t)
|
|
489 (put 'hs-c-start-regexp 'permanent-local t)
|
|
490 (put 'hs-c-end-regexp 'permanent-local t)
|
|
491 (put 'hs-block-start-regexp 'permanent-local t)
|
|
492 (put 'hs-block-end-regexp 'permanent-local t)
|
|
493 (put 'hs-forward-sexp-func 'permanent-local t)
|
|
494
|
|
495
|
|
496 ;;;----------------------------------------------------------------------------
|
|
497 ;;; that's it
|
|
498
|
|
499 (provide 'hideshow)
|
|
500
|
|
501 ;;; hideshow.el ends here
|