Mercurial > emacs
annotate lisp/progmodes/hideshow.el @ 17973:52395fdffffe
(webjump-adult-p): Function deleted.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 27 May 1997 16:20:16 +0000 |
parents | 8899e9305c25 |
children | 22cbed2e6098 |
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 |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
8 ;; Keywords: C C++ java lisp tools editing comments blocks hiding |
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 | |
73 (defvar hs-unbalance-handler-method 'top-level | |
10841 | 74 "*Symbol representing how \"unbalanced parentheses\" should be handled. |
14151 | 75 This error is usually signaled by `hs-show-block'. One of four values: |
10841 | 76 `top-level', `next-line', `signal' or `ignore'. Default is `top-level'. |
10276 | 77 |
10841 | 78 - `top-level' -- Show top-level block containing the currently troublesome |
14151 | 79 block. |
10841 | 80 - `next-line' -- Use the fact that, for an already hidden block, its end |
14151 | 81 will be on the next line. Attempt to show this block. |
10841 | 82 - `signal' -- Pass the error through, stopping execution. |
83 - `ignore' -- Ignore the error, continuing execution. | |
10276 | 84 |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
85 Values other than these four will be interpreted as `signal'.") |
10276 | 86 |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
87 ;;;#autoload |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
88 (defvar hs-special-modes-alist |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
89 '((c-mode "{" "}") |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
90 (c++-mode "{" "}") |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
91 (java-mode "\\(\\(public\\|private\\|protected\\|static\\|\\s-\\)+\\([a-zA-Z0-9_:]+[ \t]+\\)\\([a-zA-Z0-9_:]+\\)[ \t]*([^)]*)[ \t\n]*\\([ \t\n]throws[ \t]+[^{]+\\)*[ \t]*\\){" "}" java-hs-forward-sexp)) |
10841 | 92 "*Alist of the form (MODE START-RE END-RE FORWARD-SEXP-FUNC). |
93 If present, hideshow will use these values for the start and end regexps, | |
94 respectively. Since Algol-ish languages do not have single-character | |
10276 | 95 block delimiters, the function `forward-sexp' which is used by hideshow |
10841 | 96 doesn't work. In this case, if a similar function is provided, you can |
97 register it and have hideshow use it instead of `forward-sexp'. To add | |
10276 | 98 more values, use |
99 | |
100 \t(pushnew '(new-mode st-re end-re function-name) | |
101 \t hs-special-modes-alist :test 'equal) | |
102 | |
10841 | 103 For example: |
10276 | 104 |
105 \t(pushnew '(simula-mode \"begin\" \"end\" simula-next-statement) | |
106 \t hs-special-modes-alist :test 'equal) | |
107 | |
10841 | 108 Note that the regexps should not contain leading or trailing whitespace.") |
10276 | 109 |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
110 (defvar hs-minor-mode-hook '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
|
111 "Hook called when `hs-minor-mode' is installed. |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
112 A good value for this would be `hs-hide-initial-comment-block' to |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
113 hide all the comments at the beginning of the file.") |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
114 |
14151 | 115 (defvar hs-hide-hook nil |
116 "*Hooks called at the end of `hs-hide-all' and `hs-hide-block'.") | |
10276 | 117 |
14151 | 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'.") | |
10276 | 121 |
122 (defvar hs-minor-mode-prefix "\C-c" | |
10841 | 123 "*Prefix key to use for hideshow commands in hideshow minor mode.") |
10276 | 124 |
125 | |
126 ;;;---------------------------------------------------------------------------- | |
127 ;;; internal variables | |
128 | |
129 (defvar hs-minor-mode nil | |
10841 | 130 "Non-nil if using hideshow mode as a minor mode of some other mode. |
131 Use the command `hs-minor-mode' to toggle this variable.") | |
10276 | 132 |
133 (defvar hs-minor-mode-map nil | |
10841 | 134 "Mode map for hideshow minor mode.") |
10276 | 135 |
136 (defvar hs-menu-bar nil | |
10841 | 137 "Menu bar for hideshow minor mode (Xemacs only).") |
10276 | 138 |
139 (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
|
140 "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
|
141 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
|
142 surrounding whitespace is stripped.") |
10276 | 143 |
144 (defvar hs-c-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
|
145 "Regexp for end of comments. |
10841 | 146 See `hs-c-start-regexp'.") |
10276 | 147 |
148 (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
|
149 "Regexp for beginning of block.") |
10276 | 150 |
151 (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
|
152 "Regexp for end of block.") |
10276 | 153 |
154 (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
|
155 "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
|
156 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
|
157 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
|
158 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
|
159 For other modes such as simula, a more specialized function |
10276 | 160 is necessary.") |
161 | |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
162 (defvar hs-hide-comments-when-hiding-all t |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
163 "Hide the comments too when you do an `hs-hide-all'." ) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
164 |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
165 ;(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
|
166 ; "Used to support both Emacs and Xemacs.") |
10841 | 167 |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
168 ;(eval-when-compile |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
169 ; (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
|
170 ; (progn |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
171 ; (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
|
172 ; (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
|
173 ; (defun add-menu (arg1 arg2 arg3))))) |
10276 | 174 |
175 ;;;---------------------------------------------------------------------------- | |
176 ;;; support funcs | |
177 | |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
178 ;; snarfed from noutline.el; |
10276 | 179 (defun hs-flag-region (from to flag) |
10841 | 180 "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
|
181 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
|
182 (save-excursion |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
183 (goto-char from) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
184 (end-of-line) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
185 (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
|
186 (if flag |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
187 (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
|
188 ;; 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
|
189 (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
|
190 (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
|
191 (overlay-put overlay 'intangible t))))) |
10276 | 192 |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
193 ;; 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
|
194 ;; 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
|
195 ;; 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
|
196 (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
|
197 (if (< end beg) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
198 (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
|
199 (save-excursion |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
200 (goto-char beg) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
201 (while (< (point) end) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
202 (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
|
203 (while overlays |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
204 (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
|
205 (if (eq (overlay-get o prop) value) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
206 (if (or |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
207 (and (> (overlay-end o) beg) (< (overlay-end o) end)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
208 (and (< (overlay-start o) beg) (< (overlay-start o) end))) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
209 (delete-overlay o)))) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
210 (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
|
211 (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
|
212 |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
213 (defun hs-hide-block-at-point (&optional end comment c-reg) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
214 "Hide block iff on block beginning, optional END means reposition at end. |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
215 COMMENT true means that it should hide a comment block, C-REG is a list |
17270
8899e9305c25
(hs-hide-block-at-point): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
17259
diff
changeset
|
216 of the form (BEGIN . END) and specifies the limits of the comment." |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
217 (if comment |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
218 (let ((reg (if c-reg c-reg (hs-inside-comment-p)))) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
219 (goto-char (nth 1 reg)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
220 (forward-line -1) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
221 (end-of-line) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
222 (hs-flag-region (car reg) (point) t) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
223 (goto-char (if end (nth 1 reg) (car reg))) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
224 ) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
225 (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
|
226 (let* ((p (point)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
227 (q (progn (funcall hs-forward-sexp-func 1) (point)))) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
228 (forward-line -1) (end-of-line) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
229 (if (and (< p (point)) (> (count-lines p q) 1)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
230 (hs-flag-region p (point) t)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
231 (goto-char (if end q p)))))) |
10276 | 232 |
233 (defun hs-show-block-at-point (&optional end) | |
10841 | 234 "Show block iff on block beginning. Optional END means reposition at end." |
235 (if (looking-at hs-block-start-regexp) | |
236 (let* ((p (point)) | |
237 (q | |
238 (condition-case error ; probably unbalanced paren | |
239 (progn | |
240 (funcall hs-forward-sexp-func 1) | |
241 (point)) | |
242 (error | |
243 (cond | |
244 ((eq hs-unbalance-handler-method 'ignore) | |
245 ;; just ignore this block | |
246 (point)) | |
247 ((eq hs-unbalance-handler-method 'top-level) | |
248 ;; try to get out of rat's nest and expose the whole func | |
249 (if (/= (current-column) 0) (beginning-of-defun)) | |
250 (setq p (point)) | |
251 (re-search-forward (concat "^" hs-block-start-regexp) | |
252 (point-max) t 2) | |
253 (point)) | |
254 ((eq hs-unbalance-handler-method 'next-line) | |
255 ;; assumption is that user knows what s/he's doing | |
256 (beginning-of-line) (setq p (point)) | |
257 (end-of-line 2) (point)) | |
258 (t | |
259 ;; pass error through -- this applies to `signal', too | |
260 (signal (car error) (cdr error)))))))) | |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
261 (hs-flag-region p q nil) |
10841 | 262 (goto-char (if end (1+ (point)) p))))) |
10276 | 263 |
264 (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
|
265 "Warn `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
|
266 (if (or buffer-invisibility-spec (assq hs buffer-invisibility-spec) ) |
10841 | 267 nil |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
268 (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
|
269 (sit-for 2))) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
270 |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
271 (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
|
272 (interactive) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
273 "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
|
274 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
|
275 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
|
276 (let ((p (point)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
277 c-reg) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
278 (goto-char (point-min)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
279 (skip-chars-forward " \t\n") |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
280 (setq c-reg (hs-inside-comment-p)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
281 (if (and c-reg (> (count-lines (car c-reg) (nth 1 c-reg)) 2)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
282 (hs-hide-block) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
283 (goto-char p)))) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
284 |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
285 (defun hs-inside-single-line-comment-p () |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
286 "Look to see if we are on a single line comment." |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
287 (save-excursion |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
288 (beginning-of-line) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
289 (looking-at (concat "^[ \t]*" hs-c-start-regexp)))) |
10276 | 290 |
291 (defun hs-inside-comment-p () | |
10841 | 292 "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
|
293 Actually, returns a list containing the buffer position of the start |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
294 and the end of the comment." |
10276 | 295 (save-excursion |
296 (let ((p (point)) | |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
297 q |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
298 p-aux) |
10276 | 299 (if (string= comment-end "") ; single line |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
300 (if (not (hs-inside-single-line-comment-p)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
301 nil |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
302 ;;find-beginning-of-the-chained-single-line-comments |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
303 (beginning-of-line) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
304 (forward-comment (- (buffer-size))) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
305 (skip-chars-forward " \t\n") |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
306 (beginning-of-line) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
307 (setq q (point)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
308 (goto-char p) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
309 ;;find-end-of-the-chained-single-line-comments |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
310 (forward-comment (buffer-size)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
311 (skip-chars-backward " \t\n") |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
312 (list q (point))) |
10276 | 313 (re-search-forward hs-c-end-regexp (point-max) 1) |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
314 (forward-comment (buffer-size)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
315 (skip-chars-backward " \t\n") |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
316 (end-of-line) |
10276 | 317 (setq q (point)) |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
318 (forward-comment (- 0 (buffer-size))) |
10276 | 319 (re-search-forward hs-c-start-regexp (point-max) 1) |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
320 (setq p-aux (- (point) (length comment-start))) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
321 (if (and (>= p-aux 0) (< p-aux p)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
322 (list (match-beginning 0) q)))))) |
10276 | 323 |
324 (defun hs-grok-mode-type () | |
10841 | 325 "Setup variables for new buffers where applicable." |
326 (if (and (boundp 'comment-start) | |
327 (boundp 'comment-end)) | |
328 (progn | |
329 (setq hs-c-start-regexp (regexp-quote comment-start)) | |
330 (if (string-match " +$" hs-c-start-regexp) | |
331 (setq hs-c-start-regexp | |
332 (substring hs-c-start-regexp 0 (1- (match-end 0))))) | |
333 (setq hs-c-end-regexp (if (string= "" comment-end) "\n" | |
334 (regexp-quote comment-end))) | |
335 (if (string-match "^ +" hs-c-end-regexp) | |
336 (setq hs-c-end-regexp | |
337 (substring hs-c-end-regexp (match-end 0)))) | |
338 (let ((lookup (assoc major-mode hs-special-modes-alist))) | |
339 (setq hs-block-start-regexp (or (nth 1 lookup) "\\s\(") | |
340 hs-block-end-regexp (or (nth 2 lookup) "\\s\)") | |
341 hs-forward-sexp-func (or (nth 3 lookup) 'forward-sexp)))))) | |
10276 | 342 |
343 (defun hs-find-block-beginning () | |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
344 "Repositions point at block-start. |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
345 Return point, or nil if top-level." |
10276 | 346 (let (done |
347 (here (point)) | |
348 (both-regexps (concat "\\(" hs-block-start-regexp "\\)\\|\\(" | |
349 hs-block-end-regexp "\\)"))) | |
350 (while (and (not done) | |
351 (re-search-backward both-regexps (point-min) t)) | |
352 (if (match-beginning 1) ; start of start-regexp | |
353 (setq done (match-beginning 1)) | |
354 (goto-char (match-end 2)) ; end of end-regexp | |
355 (funcall hs-forward-sexp-func -1))) | |
356 (goto-char (or done here)) | |
357 done)) | |
358 | |
359 (defmacro hs-life-goes-on (&rest body) | |
10841 | 360 "Executes optional BODY iff variable `hs-minor-mode' is non-nil." |
10276 | 361 (list 'if 'hs-minor-mode (cons 'progn body))) |
362 | |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
363 (defun 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
|
364 "Return non-nil if point is in an already-hidden block otherwise nil." |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
365 (save-excursion |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
366 (end-of-line) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
367 (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
|
368 (found nil)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
369 (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
|
370 (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
|
371 overlays (cdr overlays))) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
372 found))) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
373 |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
374 (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
|
375 "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
|
376 (if (< arg 0) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
377 (backward-sexp 1) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
378 (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
|
379 (progn |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
380 (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
|
381 (forward-char -1) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
382 (forward-sexp 1)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
383 (forward-sexp 1)))) |
10276 | 384 |
385 ;;;---------------------------------------------------------------------------- | |
386 ;;; commands | |
387 | |
388 ;;;###autoload | |
389 (defun hs-hide-all () | |
10841 | 390 "Hides all top-level blocks, displaying only first and last lines. |
14151 | 391 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
|
392 `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
|
393 If `hs-hide-comments-when-hiding-all' is t also hides the comments." |
10276 | 394 (interactive) |
395 (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
|
396 (message "Hiding all blocks ...") |
10276 | 397 (save-excursion |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
398 (hs-flag-region (point-min) (point-max) nil) ; eliminate weirdness |
10276 | 399 (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
|
400 (if hs-hide-comments-when-hiding-all |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
401 (let ((count 0) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
402 (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
|
403 (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
|
404 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
|
405 "\\)\\|\\(" 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
|
406 (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
|
407 (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
|
408 (progn |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
409 (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
|
410 (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
|
411 (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
|
412 ;;found a comment |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
413 (setq c-reg (hs-inside-comment-p)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
414 (if c-reg |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
415 (progn |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
416 (goto-char (nth 1 c-reg)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
417 (if (> (count-lines (car c-reg) (nth 1 c-reg)) 2) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
418 (progn |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
419 (hs-hide-block-at-point t t c-reg) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
420 (message "Hiding ... %d" |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
421 (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
|
422 (let ((count 0) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
423 (top-level-re (concat "^" 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
|
424 (while |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
425 (progn |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
426 (forward-comment (buffer-size)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
427 (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
|
428 (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
|
429 (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
|
430 (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
|
431 (hs-safety-is-job-n)) |
10276 | 432 (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
|
433 (message "Hiding all blocks ... done") |
14151 | 434 (run-hooks 'hs-hide-hook))) |
10276 | 435 |
436 (defun hs-show-all () | |
10841 | 437 "Shows all top-level blocks. |
14151 | 438 This does not change point; it runs the normal hook `hs-show-hook'. |
439 See documentation for `run-hooks'." | |
10276 | 440 (interactive) |
441 (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
|
442 (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
|
443 (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
|
444 (message "Showing all blocks ... done") |
14151 | 445 (run-hooks 'hs-show-hook))) |
10276 | 446 |
447 (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
|
448 "Selects a block and hides it. |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
449 With prefix arg, reposition at end. Block is defined as a sexp for |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
450 lispish modes, mode-specific otherwise. Comments are blocks, too. |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
451 Upon completion, point is at repositioned and the normal hook |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
452 `hs-hide-hook' is run. See documentation for `run-hooks'." |
10276 | 453 (interactive "P") |
454 (hs-life-goes-on | |
455 (let ((c-reg (hs-inside-comment-p))) | |
456 (if c-reg | |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
457 (cond |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
458 ((<= (count-lines (car c-reg) (nth 1 c-reg)) 2) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
459 (message "Not enough comment lines to hide!")) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
460 (t |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
461 (goto-char (nth 1 c-reg)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
462 (hs-hide-block-at-point end t c-reg) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
463 (hs-safety-is-job-n) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
464 (run-hooks 'hs-hide-hook))) |
10841 | 465 (if (or (looking-at hs-block-start-regexp) |
466 (hs-find-block-beginning)) | |
467 (progn | |
468 (hs-hide-block-at-point end) | |
469 (hs-safety-is-job-n) | |
14151 | 470 (run-hooks 'hs-hide-hook))))))) |
10276 | 471 |
472 (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
|
473 "Selects a block and shows it. |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
474 With prefix arg, reposition at end. Upon completion, point is |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
475 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
|
476 See documentation for `hs-hide-block' and `run-hooks'." |
10276 | 477 (interactive "P") |
478 (hs-life-goes-on | |
479 (let ((c-reg (hs-inside-comment-p))) | |
480 (if c-reg | |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
481 (progn |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
482 (hs-flag-region (car c-reg) (nth 1 c-reg) nil) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
483 (hs-safety-is-job-n) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
484 (goto-char (if end (nth 1 c-reg) (car c-reg)))) |
10841 | 485 (if (or (looking-at hs-block-start-regexp) |
486 (hs-find-block-beginning)) | |
487 (progn | |
488 (hs-show-block-at-point end) | |
489 (hs-safety-is-job-n) | |
14151 | 490 (run-hooks 'hs-show-hook))))))) |
10276 | 491 |
492 (defun hs-show-region (beg end) | |
10841 | 493 "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
|
494 Note:`hs-show-region' is intended for use when `hs-show-block' signals |
10841 | 495 `unbalanced parentheses' and so is an emergency measure only. You may |
10276 | 496 become very confused if you use this command indiscriminately." |
497 (interactive "r") | |
498 (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
|
499 (hs-flag-region beg end nil) |
10276 | 500 (hs-safety-is-job-n) |
14151 | 501 (run-hooks 'hs-show-hook))) |
10276 | 502 |
503 ;;;###autoload | |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
504 (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
|
505 "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
|
506 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
|
507 (interactive "@e") |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
508 (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
|
509 (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
|
510 (hs-show-block) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
511 (hs-hide-block))) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
512 |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
513 ;;;###autoload |
10276 | 514 (defun hs-minor-mode (&optional arg) |
10841 | 515 "Toggle hideshow minor mode. |
516 With ARG, turn hideshow minor mode on if ARG is positive, off otherwise. | |
517 When hideshow minor mode is on, the menu bar is augmented with hideshow | |
14151 | 518 commands and the hideshow commands are enabled. The variables |
519 `selective-display' and `selective-display-ellipses' are set to t. | |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
520 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
|
521 for `run-hooks'. |
14151 | 522 |
10841 | 523 Turning hideshow minor mode off reverts the menu bar and the |
10276 | 524 variables to default values and disables the hideshow commands." |
525 (interactive "P") | |
526 (setq hs-minor-mode | |
527 (if (null arg) | |
528 (not hs-minor-mode) | |
529 (> (prefix-numeric-value arg) 0))) | |
530 (if hs-minor-mode | |
531 (progn | |
17259
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
532 ; (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
|
533 ; (progn |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
534 ; (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
|
535 ; (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
|
536 (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
|
537 (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
|
538 (add-to-invisibility-spec '(hs . t)) ;;hs invisible |
10276 | 539 (hs-grok-mode-type) |
540 (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
|
541 ; (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
|
542 ; (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
|
543 (remove-from-invisibility-spec '(hs . t)))) |
10276 | 544 |
545 | |
546 ;;;---------------------------------------------------------------------------- | |
547 ;;; load-time setup routines | |
548 | |
10841 | 549 ;; 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
|
550 ;(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
|
551 ; (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
|
552 ; 'lucid |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
553 ; 'fsf)) |
10841 | 554 |
10276 | 555 ;; 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
|
556 (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
|
557 nil |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
558 (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
|
559 ;; 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
|
560 (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
|
561 (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
|
562 (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
|
563 (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
|
564 (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
|
565 |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
566 (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
|
567 |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
568 ;; 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
|
569 (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
|
570 (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
|
571 (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
|
572 '("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
|
573 (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
|
574 '("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
|
575 (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
|
576 '("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
|
577 (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
|
578 '("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
|
579 (define-key hs-minor-mode-map [menu-bar Hide/Show hs-hide-block] |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
580 '("Hide Block" . hs-hide-block)) |
24a4fe3b0ae9
(hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents:
16774
diff
changeset
|
581 ) |
10276 | 582 |
583 ;; some housekeeping | |
10841 | 584 (or (assq 'hs-minor-mode minor-mode-map-alist) |
585 (setq minor-mode-map-alist | |
586 (cons (cons 'hs-minor-mode hs-minor-mode-map) | |
587 minor-mode-map-alist))) | |
588 (or (assq 'hs-minor-mode minor-mode-alist) | |
589 (setq minor-mode-alist (append minor-mode-alist | |
590 (list '(hs-minor-mode " hs"))))) | |
10276 | 591 |
592 ;; make some variables buffer-local | |
593 (make-variable-buffer-local 'hs-minor-mode) | |
594 (make-variable-buffer-local 'hs-c-start-regexp) | |
595 (make-variable-buffer-local 'hs-c-end-regexp) | |
596 (make-variable-buffer-local 'hs-block-start-regexp) | |
597 (make-variable-buffer-local 'hs-block-end-regexp) | |
598 (make-variable-buffer-local 'hs-forward-sexp-func) | |
599 (put 'hs-minor-mode 'permanent-local t) | |
600 (put 'hs-c-start-regexp 'permanent-local t) | |
601 (put 'hs-c-end-regexp 'permanent-local t) | |
602 (put 'hs-block-start-regexp 'permanent-local t) | |
603 (put 'hs-block-end-regexp 'permanent-local t) | |
604 (put 'hs-forward-sexp-func 'permanent-local t) | |
605 | |
606 | |
607 ;;;---------------------------------------------------------------------------- | |
608 ;;; that's it | |
609 | |
610 (provide 'hideshow) | |
611 | |
612 ;;; hideshow.el ends here |