annotate lisp/progmodes/hideshow.el @ 27029:4ad11069f66d

(hs-minor-mode-menu): Fix omission bug; was used but not declared. (hs-discard-overlays, hs-isearch-show, hs-isearch-show-temporary, hs-find-block-beginning): Add or modify docstrings. (hs-isearch-show): Rewrite.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Wed, 29 Dec 1999 09:00:35 +0000
parents 340ed24f202a
children 2d84945a90bf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
1 ;;; hideshow.el --- minor mode cmds to selectively display blocks of code
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
2
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
3 ;; Copyright (C) 1994, 95, 96, 97, 98, 99 Free Software Foundation
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
4
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
5 ;; Author: Thien-Thi Nguyen <ttn@netcom.com>
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
6 ;; Dan Nicolaescu <dann@ics.uci.edu>
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
7 ;; Keywords: C C++ java lisp tools editing comments blocks hiding outlines
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
8 ;; Maintainer-Version: 5.9
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
9 ;; Time-of-Day-Author-Most-Likely-to-be-Recalcitrant: early morning
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
10
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
11 ;; This file is part of GNU Emacs.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
12
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
16 ;; any later version.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
17
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
21 ;; GNU General Public License for more details.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
22
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
23 ;; You should have received a copy of the GNU General Public License
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
26 ;; Boston, MA 02111-1307, USA.
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
27
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
28 ;;; Commentary:
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
29
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
30 ;; * Commands provided
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
31 ;;
27029
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
32 ;; This file provides Hideshow Minor Mode. When active, eight commands
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
33 ;; are available, implementing block hiding and showing. They (and their
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
34 ;; keybindings) are:
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
35 ;;
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
36 ;; hs-hide-block C-c h
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
37 ;; hs-show-block C-c s
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
38 ;; hs-hide-all C-c H
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
39 ;; hs-show-all C-c S
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
40 ;; hs-show-region C-c R
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
41 ;; hs-hide-level C-c L
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
42 ;; hs-mouse-toggle-hiding [(shift button-2)]
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
43 ;; hs-hide-initial-comment-block
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
44 ;;
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
45 ;; Blocks are defined per mode. In c-mode, c++-mode and java-mode, they
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
46 ;; are simply text between curly braces, while in Lisp-ish modes parens
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
47 ;; are used. Multi-line comment blocks can also be hidden. Read-only
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
48 ;; buffers are not a problem, since hideshow doesn't modify the text.
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
49 ;;
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
50 ;; The command `M-x hs-minor-mode' toggles the minor mode or sets it
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
51 ;; (similar to other minor modes).
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
52
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
53 ;; * Customization
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
54 ;;
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
55 ;; You can use `M-x customize-variable' on the following variables:
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
56 ;;
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
57 ;; hs-hide-comments-when-hiding-all -- self-explanatory!
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
58 ;; hs-isearch-open -- what kind of hidden blocks to
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
59 ;; open when doing isearch
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
60 ;;
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
61 ;; Hideshow works w/ incremental search (isearch) by setting the variable
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
62 ;; `hs-headline', which is the line of text at the beginning of a hidden
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
63 ;; block that contains a match for the search. You can have this show up
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
64 ;; in the mode line by modifying the variable `mode-line-format'. For
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
65 ;; example, the following code prepends this info to the mode line:
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
66 ;;
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
67 ;; (unless (memq 'hs-headline mode-line-format)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
68 ;; (setq mode-line-format
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
69 ;; (append '("-" hs-headline) mode-line-format)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
70 ;;
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
71 ;; See documentation for `mode-line-format' for more info.
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
72 ;;
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
73 ;; Hooks are run after some commands:
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
74 ;;
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
75 ;; hs-hide-hook in hs-hide-block, hs-hide-all, hs-hide-level
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
76 ;; hs-show-hook hs-show-block, hs-show-all, hs-show-region
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
77 ;;
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
78 ;; All hooks are run w/ `run-hooks'. See docs for each variable or hook
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
79 ;; for more info.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
80 ;;
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
81 ;; Normally, hideshow tries to determine appropriate values for block
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
82 ;; and comment definitions by examining the buffer's major mode. If
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
83 ;; there are problems, hideshow will not activate and in that case you
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
84 ;; may wish to override hideshow's heuristics by adding an entry to
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
85 ;; variable `hs-special-modes-alist'. Packages that use hideshow should
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
86 ;; do something like:
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
87 ;;
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
88 ;; (let ((my-mode-hs-info '(my-mode "{{" "}}" ...)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
89 ;; (if (not (member my-mode-hs-info hs-special-modes-alist))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
90 ;; (setq hs-special-modes-alist
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
91 ;; (cons my-mode-hs-info hs-special-modes-alist))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
92 ;;
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
93 ;; If you have an entry that works particularly well, consider
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
94 ;; submitting it for inclusion in hideshow.el. See docstring for
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
95 ;; `hs-special-modes-alist' for more info on the entry format.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
96
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
97 ;; * Suggested usage
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
98 ;;
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
99 ;; First make sure hideshow.el is in a directory in your `load-path'.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
100 ;; You can optionally byte-compile it using `M-x byte-compile-file'.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
101 ;; Then, add the following to your ~/.emacs:
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
102 ;;
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
103 ;; (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
104 ;; (add-hook 'X-mode-hook 'hs-minor-mode) ; other modes similarly
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14151
diff changeset
105 ;;
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
106 ;; where X = {emacs-lisp,c,c++,perl,...}. You can also manually toggle
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
107 ;; hideshow minor mode by typing `M-x hs-minor-mode'. After hideshow is
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
108 ;; activated, `hs-minor-mode-hook' is run w/ `run-hooks'. A good hook
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
109 ;; to add is `hs-hide-initial-comment-block'.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
110
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
111 ;; * Bugs
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
112 ;;
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
113 ;; (1) Hideshow does not work w/ emacs 18 because emacs 18 lacks the
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
114 ;; function `forward-comment' (among other things). If someone
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
115 ;; writes this, please send me a copy.
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
116 ;;
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
117 ;; (2) Sometimes `hs-headline' can become out of sync. To reset, type
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
118 ;; `M-x hs-minor-mode' twice (that is, deactivate then activate
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
119 ;; hideshow).
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
120 ;;
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
121 ;; (3) Hideshow 5.x is developed and tested on GNU Emacs 20.4.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
122 ;; XEmacs compatibility may have bitrotted since 4.29.
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
123 ;;
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
124 ;; Correspondance welcome; please indicate version number. Send bug
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
125 ;; reports and inquiries to <ttn@netcom.com>.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
126
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
127 ;; * Thanks
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
128 ;;
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
129 ;; Thanks go to the following people for valuable ideas, code and
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
130 ;; bug reports.
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
131 ;;
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
132 ;; adahome@ix.netcom.com Dean Andrews
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
133 ;; alfh@ifi.uio.no Alf-Ivar Holm
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
134 ;; bauer@itsm.uni-stuttgart.de Holger Bauer
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
135 ;; christoph.conrad@post.rwth-aachen.de Christoph Conrad
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
136 ;; d.love@dl.ac.uk Dave Love
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
137 ;; dirk@ida.ing.tu-bs.de Dirk Herrmann
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
138 ;; gael@gnlab030.grenoble.hp.com Gael Marziou
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
139 ;; jan.djarv@sa.erisoft.se Jan Djarv
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
140 ;; leray@dev-lme.pcc.philips.com Guillaume Leray
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
141 ;; moody@mwt.net Moody Ahmad
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
142 ;; preston.f.crow@dartmouth.edu Preston F. Crow
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
143 ;; qhslali@aom.ericsson.se Lars Lindberg
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
144 ;; reto@synopsys.com Reto Zimmermann
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
145 ;; sheff@edcsgw2.cr.usgs.gov Keith Sheffield
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
146 ;; smes@post1.com Chew Meng Kuan
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
147 ;; tonyl@eng.sun.com Tony Lam
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
148 ;; ware@cis.ohio-state.edu Pete Ware
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
149 ;;
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
150 ;; Special thanks go to Dan Nicolaescu <dann@ics.uci.edu>, who reimplemented
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
151 ;; hideshow using overlays (rather than selective display), added isearch
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
152 ;; magic, folded in custom.el compatibility, generalized comment handling,
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
153 ;; incorporated mouse support, and maintained the code in general. Version
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
154 ;; 4.0 is largely due to his efforts.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
155
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
156 ;; * History
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
157 ;;
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
158 ;; Hideshow was inspired when I learned about selective display. It was
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
159 ;; reimplemented to use overlays for 4.0 (see above). WRT older history,
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
160 ;; entries in the masterfile corresponding to versions 1.x and 2.x have
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
161 ;; been lost. XEmacs support is reliable as of 4.29. State save and
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
162 ;; restore was added in 3.5 (not widely distributed), and reliable as of
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
163 ;; 4.30. Otherwise, the code seems stable. Passes checkdoc as of 4.32.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
164 ;; Version 5.x uses new algorithms for block selection and traversal,
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
165 ;; unbundles state save and restore, and includes more isearch support.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
166
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
167 ;;; Code:
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
168
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
169 (require 'easymenu)
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
170
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
171 ;;---------------------------------------------------------------------------
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
172 ;; user-configurable variables
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
173
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
174 (defgroup hideshow nil
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
175 "Minor mode for hiding and showing program and comment blocks."
18237
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
176 :prefix "hs-"
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
177 :group 'languages)
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
178
19233
520a7d40d75c Correct the autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents: 18867
diff changeset
179 ;;;###autoload
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
180 (defcustom hs-hide-comments-when-hiding-all t
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
181 "*Hide the comments too when you do an `hs-hide-all'."
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
182 :type 'boolean
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
183 :group 'hideshow)
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
184
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
185 (defcustom hs-minor-mode-hook nil
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
186 "*Hook called when hideshow minor mode is activated."
19833
fdcd167cb293 (hs-minor-mode-hook): Fix customize type.
Richard M. Stallman <rms@gnu.org>
parents: 19233
diff changeset
187 :type 'hook
18070
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
188 :group 'hideshow)
a99f3bd58831 (hs-hide-comments-when-hiding-all)
Richard M. Stallman <rms@gnu.org>
parents: 18016
diff changeset
189
18237
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
190 (defcustom hs-isearch-open 'block
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
191 "*What kind of hidden blocks to open when doing `isearch'.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
192 One of the following symbols:
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
193
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
194 block -- open only blocks
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
195 comment -- open only comments
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
196 t -- open both blocks and comments
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
197 nil -- open neither blocks nor comments
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
198
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
199 This has effect iff `search-invisible' is set to `open'."
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
200 :type '(choice (const :tag "open only blocks" block)
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
201 (const :tag "open only comments" comment)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
202 (const :tag "open both blocks and comments" t)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
203 (const :tag "don't open any of them" nil))
18237
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
204 :group 'hideshow)
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
205
19233
520a7d40d75c Correct the autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents: 18867
diff changeset
206 ;;;###autoload
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
207 (defvar hs-special-modes-alist
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
208 '((c-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning)
18093
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
209 (c++-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning)
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
210 (bibtex-mode ("^@\\S(*\\(\\s(\\)" 1))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
211 (java-mode "{" "}" "/[*/]" nil hs-c-like-adjust-block-beginning)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
212 )
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
213 "*Alist for initializing the hideshow variables for different modes.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
214 Each element has the form
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
215 (MODE START END COMMENT-START FORWARD-SEXP-FUNC ADJUST-BEG-FUNC).
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
216
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
217 If non-nil, hideshow will use these values as regexps to define blocks
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
218 and comments, respectively for major mode MODE.
18867
b6e4c4c2a3ef (hs-special-modes-alist): Use a regexp generated by regexp-opt.
Richard M. Stallman <rms@gnu.org>
parents: 18428
diff changeset
219
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
220 START, END and COMMENT-START are regular expressions. A block is
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
221 defined as text surrounded by START and END.
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
222
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
223 As a special case, START may be a list of the form (COMPLEX-START
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
224 MDATA-SELECTOR), where COMPLEX-START is a regexp w/ multiple parts and
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
225 MDATA-SELECTOR an integer that specifies which sub-match is the proper
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
226 place to adjust point, before calling `hs-forward-sexp-func'. For
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
227 example, see the `hs-special-modes-alist' entry for `bibtex-mode'.
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
228
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
229 For some major modes, `forward-sexp' does not work properly. In those
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
230 cases, FORWARD-SEXP-FUNC specifies another function to use instead.
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
231
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
232 See the documentation for `hs-adjust-block-beginning' to see what is the
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
233 use of ADJUST-BEG-FUNC.
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
234
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
235 If any of the elements is left nil or omitted, hideshow tries to guess
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
236 appropriate values. The regexps should not contain leading or trailing
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
237 whitespace. Case does not matter.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
238
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
239 (defvar hs-hide-hook nil
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
240 "*Hook called (with `run-hooks') at the end of commands to hide text.
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
241 These commands include `hs-hide-all', `hs-hide-block' and `hs-hide-level'.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
242
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
243 (defvar hs-show-hook nil
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
244 "*Hook called (with `run-hooks') at the end of commands to show text.
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
245 These commands include `hs-show-all', `hs-show-block' and `hs-show-region'.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
246
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
247 ;;---------------------------------------------------------------------------
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
248 ;; internal variables
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
249
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
250 (defvar hs-minor-mode nil
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
251 "Non-nil if using hideshow mode as a minor mode of some other mode.
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
252 Use the command `hs-minor-mode' to toggle or set this variable.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
253
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
254 (defvar hs-minor-mode-map nil
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
255 "Keymap for hideshow minor mode.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
256
27029
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
257 (defvar hs-minor-mode-menu nil
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
258 "Menu for hideshow minor mode.")
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
259
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
260 (defvar hs-c-start-regexp nil
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
261 "Regexp for beginning of comments.
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
262 Differs from mode-specific comment regexps in that
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
263 surrounding whitespace is stripped.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
264
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
265 (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
266 "Regexp for beginning of block.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
267
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
268 (defvar hs-block-start-mdata-select nil
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
269 "Element in `hs-block-start-regexp' match data to consider as block start.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
270 The internal function `hs-forward-sexp' moves point to the beginning of this
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
271 element (using `match-beginning') before calling `hs-forward-sexp-func'.")
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
272
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
273 (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
274 "Regexp for end of block.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
275
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
276 (defvar hs-forward-sexp-func 'forward-sexp
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
277 "Function used to do a `forward-sexp'.
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
278 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
279 delimiters -- ie, the syntax table regexp for the character is
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
280 either `(' or `)' -- `hs-forward-sexp-func' would just be
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
281 `forward-sexp'. For other modes such as simula, a more specialized
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
282 function is necessary.")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
283
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
284 (defvar hs-adjust-block-beginning nil
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
285 "Function used to tweak the block beginning.
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
286 The block is hidden from the position returned by this function,
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
287 as opposed to hiding it from the position returned when searching
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
288 for `hs-block-start-regexp'.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
289
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
290 For example, in c-like modes, if we wish to also hide the curly braces
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
291 (if you think they occupy too much space on the screen), this function
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
292 should return the starting point (at the end of line) of the hidden
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
293 region.
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
294
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
295 It is called with a single argument ARG which is the the position in
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
296 buffer after the block beginning.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
297
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
298 It should return the position from where we should start hiding.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
299
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
300 It should not move the point.
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
301
18093
1e53ce338e0d (hs-show-hidden-short-form): Updated doc string.
Richard M. Stallman <rms@gnu.org>
parents: 18070
diff changeset
302 See `hs-c-like-adjust-block-beginning' for an example of using this.")
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
303
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
304 (defvar hs-headline nil
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
305 "Text of the line where a hidden block begins, set during isearch.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
306 You can display this in the mode line by adding the symbol `hs-headline'
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
307 to the variable `mode-line-format'. For example,
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
308
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
309 (unless (memq 'hs-headline mode-line-format)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
310 (setq mode-line-format
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
311 (append '(\"-\" hs-headline) mode-line-format)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
312
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
313 Note that `mode-line-format' is buffer-local.")
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
314
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
315 ;;---------------------------------------------------------------------------
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
316 ;; system dependency
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
317
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
318 ; ;; xemacs compatibility
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
319 ; (when (string-match "xemacs\\|lucid" emacs-version)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
320 ; ;; use pre-packaged compatiblity layer
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
321 ; (require 'overlay))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
322 ;
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
323 ; ;; xemacs and emacs-19 compatibility
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
324 ; (when (or (not (fboundp 'add-to-invisibility-spec))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
325 ; (not (fboundp 'remove-from-invisibility-spec)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
326 ; ;; `buffer-invisibility-spec' mutators snarfed from Emacs 20.3 lisp/subr.el
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
327 ; (defun add-to-invisibility-spec (arg)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
328 ; (cond
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
329 ; ((or (null buffer-invisibility-spec) (eq buffer-invisibility-spec t))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
330 ; (setq buffer-invisibility-spec (list arg)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
331 ; (t
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
332 ; (setq buffer-invisibility-spec
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
333 ; (cons arg buffer-invisibility-spec)))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
334 ; (defun remove-from-invisibility-spec (arg)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
335 ; (if buffer-invisibility-spec
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
336 ; (setq buffer-invisibility-spec
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
337 ; (delete arg buffer-invisibility-spec)))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
338
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
339 ;; hs-match-data
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
340 (defalias 'hs-match-data 'match-data)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
341
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
342 ;;---------------------------------------------------------------------------
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
343 ;; support functions
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
344
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
345 (defun hs-discard-overlays (from to)
27029
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
346 "Delete hideshow overlays in region defined by FROM and TO."
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
347 (when (< to from)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
348 (setq from (prog1 to (setq to from))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
349 (mapcar (lambda (ov)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
350 (when (overlay-get ov 'hs)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
351 (delete-overlay ov)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
352 (overlays-in from to)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
353
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
354 (defun hs-isearch-show (ov)
27029
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
355 "Delete overlay OV, and set `hs-headline' to nil.
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
356
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
357 This function is meant to be used as the `isearch-open-invisible'
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
358 property of an overlay."
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
359 (setq hs-headline nil)
27029
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
360 (delete-overlay ov))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
361
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
362 (defun hs-isearch-show-temporary (ov hide-p)
27029
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
363 "Hide or show overlay OV, and set `hs-headline', all depending on HIDE-P.
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
364 If HIDE-P is non-nil, `hs-headline' is set to nil and overlay OV is hidden.
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
365 Otherwise, `hs-headline' is set to the line of text at the head of OV, and
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
366 OV is shown.
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
367
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
368 This function is meant to be used as the `isearch-open-invisible-temporary'
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
369 property of an overlay."
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
370 (setq hs-headline
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
371 (if hide-p
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
372 nil
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
373 (or hs-headline
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
374 (let ((start (overlay-start ov)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
375 (buffer-substring
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
376 (save-excursion (goto-char start)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
377 (beginning-of-line)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
378 (skip-chars-forward " \t")
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
379 (point))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
380 start)))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
381 (force-mode-line-update)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
382 (overlay-put ov 'invisible (and hide-p 'hs)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
383
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
384 (defun hs-flag-region (from to flag)
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
385 "Hide or show lines from FROM to TO, according to FLAG.
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
386 If FLAG is nil then text is shown, while if FLAG is non-nil the text is
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
387 hidden. Actually flag is really either `comment' or `block' depending
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
388 on what kind of block it is suppose to hide."
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
389 (save-excursion
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
390 ;; first clear it all out
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
391 (hs-discard-overlays from to)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
392 ;; now create overlays if needed
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
393 (when flag
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
394 (let ((overlay (make-overlay from to)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
395 (overlay-put overlay 'invisible 'hs)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
396 (overlay-put overlay 'intangible t)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
397 (overlay-put overlay 'hs flag)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
398 (when (or (eq hs-isearch-open t) (eq hs-isearch-open flag))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
399 (mapcar
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
400 (lambda (pair)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
401 (overlay-put overlay (car pair) (cdr pair)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
402 '((isearch-open-invisible . hs-isearch-show)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
403 (isearch-open-invisible-temporary . hs-isearch-show-temporary))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
404 overlay))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
405
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
406 (defun hs-forward-sexp (match-data arg)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
407 "Adjust point based on MATCH-DATA and call `hs-forward-sexp-func' w/ ARG.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
408 Original match data is restored upon return."
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
409 (save-match-data
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
410 (set-match-data match-data)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
411 (goto-char (match-beginning hs-block-start-mdata-select))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
412 (funcall hs-forward-sexp-func arg)))
18237
69bb3a2c95b3 (hideshow): Added a :prefix.
Richard M. Stallman <rms@gnu.org>
parents: 18093
diff changeset
413
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
414 (defun hs-hide-comment-region (beg end &optional repos-end)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
415 "Hide a region from BEG to END, marking it as a comment.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
416 Optional arg REPOS-END means reposition at end."
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
417 (hs-flag-region (progn (goto-char beg) (end-of-line) (point))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
418 (progn (goto-char end) (end-of-line) (point))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
419 'comment)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
420 (goto-char (if repos-end end beg)))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
421
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
422 (defun hs-hide-block-at-point (&optional end comment-reg)
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
423 "Hide block iff on block beginning.
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
424 Optional arg END means reposition at end.
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
425 Optional arg COMMENT-REG is a list of the form (BEGIN END) and
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
426 specifies the limits of the comment, or nil if the block is not
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
427 a comment.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
428
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
429 The block beginning is adjusted by `hs-adjust-block-beginning'
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
430 and then further adjusted to be at the end of the line."
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
431 (if comment-reg
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
432 (hs-hide-comment-region (car comment-reg) (cadr comment-reg) end)
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
433 (if (looking-at hs-block-start-regexp)
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
434 (let* ((mdata (hs-match-data t))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
435 (pure-p (match-end 0))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
436 (p
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
437 ;; `p' is the point at the end of the block beginning,
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
438 ;; which may need to be adjusted
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
439 (save-excursion
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
440 (goto-char (funcall (or hs-adjust-block-beginning
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
441 'identity)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
442 pure-p))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
443 ;; whatever the adjustment, we move to eol
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
444 (end-of-line)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
445 (point)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
446 (q
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
447 ;; `q' is the point at the end of the block
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
448 (progn (hs-forward-sexp mdata 1)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
449 (end-of-line)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
450 (point))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
451 (if (and (< p (point)) (> (count-lines p q) 1))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
452 (overlay-put (hs-flag-region p q 'block)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
453 'hs-ofs
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
454 (- pure-p p)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
455 (goto-char (if end q (min p pure-p)))))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
456
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
457 (defun hs-safety-is-job-n ()
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
458 "Warn if `buffer-invisibility-spec' does not contain symbol `hs'."
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
459 (unless (and (listp buffer-invisibility-spec)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
460 (assq 'hs buffer-invisibility-spec))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
461 (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
462 (sit-for 2)))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
463
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
464 (defun hs-inside-comment-p ()
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
465 "Return non-nil if point is inside a comment, otherwise nil.
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
466 Actually, return a list containing the buffer position of the start
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
467 and the end of the comment. A comment block can be hidden only if on
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
468 its starting line there is only whitespace preceding the actual comment
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
469 beginning. If we are inside of a comment but this condition is not met,
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
470 we return a list having a nil as its car and the end of comment position
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
471 as cdr."
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
472 (save-excursion
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
473 ;; the idea is to look backwards for a comment start regexp, do a
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
474 ;; forward comment, and see if we are inside, then extend extend
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
475 ;; forward and backward as long as we have comments
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
476 (let ((q (point)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
477 (when (or (looking-at hs-c-start-regexp)
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
478 (re-search-backward hs-c-start-regexp (point-min) t))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
479 (forward-comment (- (buffer-size)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
480 (skip-chars-forward " \t\n\f")
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
481 (let ((p (point))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
482 (not-hidable nil))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
483 (beginning-of-line)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
484 (unless (looking-at (concat "[ \t]*" hs-c-start-regexp))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
485 ;; we are in this situation: (example)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
486 ;; (defun bar ()
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
487 ;; (foo)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
488 ;; ) ; comment
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
489 ;; ^
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
490 ;; the point was here before doing (beginning-of-line)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
491 ;; here we should advance till the next comment which
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
492 ;; eventually has only white spaces preceding it on the same
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
493 ;; line
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
494 (goto-char p)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
495 (forward-comment 1)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
496 (skip-chars-forward " \t\n\f")
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
497 (setq p (point))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
498 (while (and (< (point) q)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
499 (> (point) p)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
500 (not (looking-at hs-c-start-regexp)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
501 (setq p (point));; use this to avoid an infinite cycle
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
502 (forward-comment 1)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
503 (skip-chars-forward " \t\n\f"))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
504 (if (or (not (looking-at hs-c-start-regexp))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
505 (> (point) q))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
506 ;; we cannot hide this comment block
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
507 (setq not-hidable t)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
508 ;; goto the end of the comment
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
509 (forward-comment (buffer-size))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
510 (skip-chars-backward " \t\n\f")
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
511 (end-of-line)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
512 (if (>= (point) q)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
513 (list (if not-hidable nil p) (point))))))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
514
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
515 (defun hs-grok-mode-type ()
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
516 "Set up hideshow variables for new buffers.
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
517 If `hs-special-modes-alist' has information associated with the
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
518 current buffer's major mode, use that.
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
519 Otherwise, guess start, end and `comment-start' regexps; `forward-sexp'
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
520 function; and adjust-block-beginning function."
23253
0d6c3732f9d2 (hs-grok-mode-type) Handle nil `comment-start' and `comment-end'.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22445
diff changeset
521 (if (and (boundp 'comment-start)
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
522 (boundp 'comment-end)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
523 comment-start comment-end)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
524 (let* ((lookup (assoc major-mode hs-special-modes-alist))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
525 (start-elem (or (nth 1 lookup) "\\s(")))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
526 (if (listp start-elem)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
527 ;; handle (START-REGEXP MDATA-SELECT)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
528 (setq hs-block-start-regexp (car start-elem)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
529 hs-block-start-mdata-select (cadr start-elem))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
530 ;; backwards compatibility: handle simple START-REGEXP
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
531 (setq hs-block-start-regexp start-elem
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
532 hs-block-start-mdata-select 0))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
533 (setq hs-block-end-regexp (or (nth 2 lookup) "\\s)")
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
534 hs-c-start-regexp (or (nth 3 lookup)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
535 (let ((c-start-regexp
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
536 (regexp-quote comment-start)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
537 (if (string-match " +$" c-start-regexp)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
538 (substring c-start-regexp
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
539 0 (1- (match-end 0)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
540 c-start-regexp)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
541 hs-forward-sexp-func (or (nth 4 lookup) 'forward-sexp)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
542 hs-adjust-block-beginning (nth 5 lookup)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
543 (progn
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
544 (setq hs-minor-mode nil)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
545 (error "%s Mode doesn't support Hideshow Minor Mode" mode-name))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
546
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
547 (defun hs-find-block-beginning ()
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
548 "Reposition point at block-start.
27029
4ad11069f66d (hs-minor-mode-menu): Fix omission bug; was used but not declared.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 26989
diff changeset
549 Return point, or nil if original point was not in a block."
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
550 (let ((done nil)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
551 (here (point)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
552 ;; look if current line is block start
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
553 (if (looking-at hs-block-start-regexp)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
554 (point)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
555 ;; look backward for the start of a block that contains the cursor
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
556 (while (and (re-search-backward hs-block-start-regexp nil t)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
557 (not (setq done
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
558 (< here (save-excursion
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
559 (hs-forward-sexp (hs-match-data t) 1)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
560 (point)))))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
561 (if done
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
562 (point)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
563 (goto-char here)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
564 nil))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
565
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
566 (defun hs-hide-level-recursive (arg minp maxp)
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
567 "Recursively hide blocks ARG levels below point in region (MINP MAXP)."
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
568 (when (hs-find-block-beginning)
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
569 (setq minp (1+ (point)))
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
570 (funcall hs-forward-sexp-func 1)
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
571 (setq maxp (1- (point))))
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
572 (hs-flag-region minp maxp nil) ; eliminate weirdness
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
573 (goto-char minp)
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
574 (while (progn
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
575 (forward-comment (buffer-size))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
576 (and (< (point) maxp)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
577 (re-search-forward hs-block-start-regexp maxp t)))
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
578 (if (> arg 1)
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
579 (hs-hide-level-recursive (1- arg) minp maxp)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
580 (goto-char (match-beginning hs-block-start-mdata-select))
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
581 (hs-hide-block-at-point t)))
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
582 (hs-safety-is-job-n)
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
583 (goto-char maxp))
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
584
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
585 (defmacro hs-life-goes-on (&rest body)
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
586 "Evaluate BODY forms iff variable `hs-minor-mode' is non-nil.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
587 In the dynamic context of this macro, `inhibit-point-motion-hooks'
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
588 and `case-fold-search' are both t."
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
589 `(when hs-minor-mode
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
590 (let ((inhibit-point-motion-hooks t)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
591 (case-fold-search t))
22109
3e53877b4a08 (hs-life-goes-on): Use Emacs' native backquote support.
Dan Nicolaescu <done@ece.arizona.edu>
parents: 20820
diff changeset
592 ,@body)))
3e53877b4a08 (hs-life-goes-on): Use Emacs' native backquote support.
Dan Nicolaescu <done@ece.arizona.edu>
parents: 20820
diff changeset
593
18867
b6e4c4c2a3ef (hs-special-modes-alist): Use a regexp generated by regexp-opt.
Richard M. Stallman <rms@gnu.org>
parents: 18428
diff changeset
594 (put 'hs-life-goes-on 'edebug-form-spec '(&rest form))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
595
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
596 (defun hs-already-hidden-p ()
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
597 "Return non-nil if point is in an already-hidden block, otherwise nil."
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
598 (save-excursion
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
599 (let ((c-reg (hs-inside-comment-p)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
600 (if (and c-reg (nth 0 c-reg))
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
601 ;; point is inside a comment, and that comment is hidable
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
602 (goto-char (nth 0 c-reg))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
603 (if (and (not c-reg)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
604 (hs-find-block-beginning)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
605 (looking-at hs-block-start-regexp))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
606 ;; point is inside a block
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
607 (goto-char (match-end 0)))))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
608 (end-of-line)
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
609 (let ((overlays (overlays-at (point)))
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
610 (found nil))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
611 (while (and (not found) (overlayp (car overlays)))
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
612 (setq found (overlay-get (car overlays) 'hs)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
613 overlays (cdr overlays)))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
614 found)))
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
615
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
616 (defun hs-c-like-adjust-block-beginning (initial)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
617 "Adjust INITIAL, the buffer position after `hs-block-start-regexp'.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
618 Actually, point is never moved; a new position is returned that is
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
619 the end of the C-function header. This adjustment function is meant
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
620 to be assigned to `hs-adjust-block-beginning' for C-like modes."
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
621 (save-excursion
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
622 (goto-char (1- initial))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
623 (forward-comment (- (buffer-size)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
624 (point)))
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
625
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
626 ;;---------------------------------------------------------------------------
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
627 ;; commands
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
628
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
629 (defun hs-hide-all ()
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
630 "Hide all top level blocks, displaying only first and last lines.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
631 Move point to the beginning of the line, and run the normal hook
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
632 `hs-hide-hook'. See documentation for `run-hooks'.
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
633 If `hs-hide-comments-when-hiding-all' is non-nil, also hide the comments."
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
634 (interactive)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
635 (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
636 (message "Hiding all blocks ...")
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
637 (save-excursion
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
638 (hs-flag-region (point-min) (point-max) nil) ; eliminate weirdness
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
639 (goto-char (point-min))
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
640 (if hs-hide-comments-when-hiding-all
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
641 (let ((c-reg nil)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
642 (count 0)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
643 (block-and-comment-re
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
644 (concat "\\("
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
645 hs-block-start-regexp
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
646 "\\)\\|\\("
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
647 hs-c-start-regexp
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
648 "\\)")))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
649 (while (re-search-forward block-and-comment-re (point-max) t)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
650 (if (match-beginning 1) ;; we have found a block beginning
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
651 (progn
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
652 (goto-char (match-beginning 1))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
653 (hs-hide-block-at-point t)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
654 (message "Hiding ... %d" (setq count (1+ count))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
655 ;;found a comment
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
656 (setq c-reg (hs-inside-comment-p))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
657 (if (and c-reg (car c-reg))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
658 (if (> (count-lines (car c-reg) (nth 1 c-reg)) 1)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
659 (progn
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
660 (hs-hide-block-at-point t c-reg)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
661 (message "Hiding ... %d" (setq count (1+ count))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
662 (goto-char (nth 1 c-reg)))))))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
663 (let ((count 0)
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
664 (buf-size (buffer-size)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
665 (while
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
666 (progn
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
667 (forward-comment buf-size)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
668 (re-search-forward hs-block-start-regexp (point-max) t))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
669 (goto-char (match-beginning 0))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
670 (hs-hide-block-at-point t)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
671 (message "Hiding ... %d" (setq count (1+ count))))))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
672 (hs-safety-is-job-n))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
673 (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
674 (message "Hiding all blocks ... done")
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
675 (run-hooks 'hs-hide-hook)))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
676
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
677 (defun hs-show-all ()
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
678 "Show everything then run `hs-show-hook'. See `run-hooks'."
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
679 (interactive)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
680 (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
681 (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
682 (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
683 (message "Showing all blocks ... done")
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
684 (run-hooks 'hs-show-hook)))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
685
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
686 (defun hs-hide-block (&optional end)
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
687 "Select a block and hide it. With prefix arg, reposition at END.
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
688 Upon completion, point is repositioned and the normal hook
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
689 `hs-hide-hook' is run. See documentation for `run-hooks'."
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
690 (interactive "P")
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
691 (hs-life-goes-on
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
692 (let ((c-reg (hs-inside-comment-p)))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
693 (cond
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
694 ((and c-reg (or (null (nth 0 c-reg))
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
695 (<= (count-lines (car c-reg) (nth 1 c-reg)) 1)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
696 (message "(not enough comment lines to hide)"))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
697 ((or c-reg
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
698 (looking-at hs-block-start-regexp)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
699 (hs-find-block-beginning))
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
700 (hs-hide-block-at-point end c-reg)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
701 (hs-safety-is-job-n)
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
702 (run-hooks 'hs-hide-hook))))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
703
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
704 (defun hs-show-block (&optional end)
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
705 "Select a block and show it.
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
706 With prefix arg, reposition at END. Upon completion, point is
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
707 repositioned and the normal hook `hs-show-hook' is run.
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
708 See documentation for functions `hs-hide-block' and `run-hooks'."
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
709 (interactive "P")
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
710 (hs-life-goes-on
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
711 (or
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
712 ;; first see if we have something at the end of the line
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
713 (catch 'eol-begins-hidden-region-p
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
714 (let ((here (point)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
715 (mapcar (lambda (ov)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
716 (when (overlay-get ov 'hs)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
717 (goto-char
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
718 (cond
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
719 (end (overlay-end ov))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
720 ((eq 'comment (overlay-get ov 'hs)) here)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
721 (t (+ (overlay-start ov) (overlay-get ov 'hs-ofs)))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
722 (delete-overlay ov)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
723 (throw 'eol-begins-hidden-region-p t)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
724 (save-excursion (end-of-line) (overlays-at (point))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
725 nil))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
726 ;; not immediately obvious, look for a suitable block
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
727 (let ((c-reg (hs-inside-comment-p))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
728 p q)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
729 (cond (c-reg
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
730 (when (car c-reg)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
731 (setq p (car c-reg)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
732 q (cadr c-reg))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
733 ((and (hs-find-block-beginning)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
734 (looking-at hs-block-start-regexp)) ; fresh match-data, ugh
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
735 (setq p (point)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
736 q (progn (hs-forward-sexp (hs-match-data t) 1) (point)))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
737 (when (and p q)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
738 (hs-flag-region p q nil)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
739 (goto-char (if end q (1+ p)))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
740 (hs-safety-is-job-n)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
741 (run-hooks 'hs-show-hook))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
742
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
743 (defun hs-show-region (beg end)
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
744 "Show all lines from BEG to END, without doing any block analysis.
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
745 Note: `hs-show-region' is intended for use when `hs-show-block' signals
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
746 \"unbalanced parentheses\" and so is an emergency measure only. You may
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
747 become very confused if you use this command indiscriminately.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
748 The hook `hs-show-hook' is run; see `run-hooks'."
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
749 (interactive "r")
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
750 (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
751 (hs-flag-region beg end nil)
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
752 (hs-safety-is-job-n)
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
753 (run-hooks 'hs-show-hook)))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
754
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
755 (defun hs-hide-level (arg)
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
756 "Hide all blocks ARG levels below this block.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
757 The hook `hs-hide-hook' is run; see `run-hooks'."
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
758 (interactive "p")
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
759 (hs-life-goes-on
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
760 (save-excursion
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
761 (message "Hiding blocks ...")
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
762 (hs-hide-level-recursive arg (point-min) (point-max))
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
763 (message "Hiding blocks ... done"))
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
764 (hs-safety-is-job-n)
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
765 (run-hooks 'hs-hide-hook)))
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
766
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
767 (defun hs-mouse-toggle-hiding (e)
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
768 "Toggle hiding/showing of a block.
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
769 This command should be bound to a mouse key.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
770 Argument E is a mouse event used by `mouse-set-point'.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
771 See `hs-hide-block' and `hs-show-block'."
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
772 (interactive "@e")
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
773 (hs-life-goes-on
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
774 (mouse-set-point e)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
775 (if (hs-already-hidden-p)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
776 (hs-show-block)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
777 (hs-hide-block))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
778
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
779 (defun hs-hide-initial-comment-block ()
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
780 "Hide the first block of comments in a file.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
781 This can be useful if you have huge RCS logs in those comments."
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
782 (interactive)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
783 (hs-life-goes-on
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
784 (let ((c-reg (save-excursion
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
785 (goto-char (point-min))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
786 (skip-chars-forward " \t\n\f")
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
787 (hs-inside-comment-p))))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
788 (when c-reg
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
789 (let ((beg (car c-reg)) (end (cadr c-reg)))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
790 ;; see if we have enough comment lines to hide
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
791 (when (> (count-lines beg end) 1)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
792 (hs-hide-comment-region beg end)))))))
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
793
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
794 ;;;###autoload
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
795 (defun hs-minor-mode (&optional arg)
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
796 "Toggle hideshow minor mode.
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
797 With ARG, turn hideshow minor mode on if ARG is positive, off otherwise.
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
798 When hideshow minor mode is on, the menu bar is augmented with hideshow
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
799 commands and the hideshow commands are enabled.
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
800 The value '(hs . t) is added to `buffer-invisibility-spec'.
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
801 Last, the normal hook `hs-minor-mode-hook' is run; see `run-hooks'.
14151
1087acbd29d7 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13957
diff changeset
802
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
803 The main commands are: `hs-hide-all', `hs-show-all', `hs-hide-block',
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
804 `hs-show-block', `hs-hide-level' and `hs-show-region'. There is also
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
805 `hs-hide-initial-comment-block' and `hs-mouse-toggle-hiding'.
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
806
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
807 Turning hideshow minor mode off reverts the menu bar and the
18016
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
808 variables to default values and disables the hideshow commands.
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
809
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
810 Key bindings:
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
811 \\{hs-minor-mode-map}"
22cbed2e6098 (hs-special-modes-alist): Include also the
Richard M. Stallman <rms@gnu.org>
parents: 17270
diff changeset
812
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
813 (interactive "P")
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
814 (setq hs-headline nil
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
815 hs-minor-mode (if (null arg)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
816 (not hs-minor-mode)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
817 (> (prefix-numeric-value arg) 0)))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
818 (if hs-minor-mode
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
819 (progn
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
820 (easy-menu-add hs-minor-mode-menu)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
821 (make-variable-buffer-local 'line-move-ignore-invisible)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
822 (setq line-move-ignore-invisible t)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
823 (add-to-invisibility-spec '(hs . t)) ; hs invisible
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
824 (hs-grok-mode-type)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
825 (run-hooks 'hs-minor-mode-hook))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
826 (easy-menu-remove hs-minor-mode-menu)
17259
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
827 (remove-from-invisibility-spec '(hs . t))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
828
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
829 ;;---------------------------------------------------------------------------
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
830 ;; load-time actions
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
831
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
832 ;; 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
833 (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
834 nil
24a4fe3b0ae9 (hs-show-all, hs-safety-is-job-n): Fix messages.
Richard M. Stallman <rms@gnu.org>
parents: 16774
diff changeset
835 (setq hs-minor-mode-map (make-sparse-keymap))
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
836 (easy-menu-define hs-minor-mode-menu
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
837 hs-minor-mode-map
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
838 "Menu used when hideshow minor mode is active."
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
839 (cons "Hide/Show"
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
840 (mapcar
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
841 ;; Interpret each table entry as follows: first, populate keymap
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
842 ;; with elements 2 and 1; then, for easymenu, use entry directly
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
843 ;; unless element 0 is nil, in which case the entry is "omitted".
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
844 (lambda (ent)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
845 (define-key hs-minor-mode-map (aref ent 2) (aref ent 1))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
846 (if (aref ent 0) ent "-----"))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
847 ;; I believe there is nothing bound on these keys.
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
848 ;; menu entry command key
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
849 '(["Hide Block" hs-hide-block "\C-ch"]
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
850 ["Show Block" hs-show-block "\C-cs"]
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
851 ["Hide All" hs-hide-all "\C-cH"]
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
852 ["Show All" hs-show-all "\C-cS"]
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
853 ["Hide Level" hs-hide-level "\C-cL"]
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
854 ["Show Region" hs-show-region "\C-cR"]
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
855 [nil hs-mouse-toggle-hiding [(shift button2)]]
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
856 )))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
857
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
858 ;; some housekeeping
10841
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
859 (or (assq 'hs-minor-mode minor-mode-map-alist)
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
860 (setq minor-mode-map-alist
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
861 (cons (cons 'hs-minor-mode hs-minor-mode-map)
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
862 minor-mode-map-alist)))
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
863 (or (assq 'hs-minor-mode minor-mode-alist)
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
864 (setq minor-mode-alist (append minor-mode-alist
88926963f1ae Clean up doc strings.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 10276
diff changeset
865 (list '(hs-minor-mode " hs")))))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
866
22444
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
867 ;; make some variables permanently buffer-local
977318751daa Require `easymenu'. Rework to use easymenu. Remove eol ws.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 22109
diff changeset
868 (mapcar (lambda (var)
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
869 (make-variable-buffer-local var)
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
870 (put var 'permanent-local t))
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
871 '(hs-minor-mode
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
872 hs-c-start-regexp
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
873 hs-block-start-regexp
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
874 hs-block-start-mdata-select
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
875 hs-block-end-regexp
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
876 hs-forward-sexp-func
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
877 hs-adjust-block-beginning))
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
878
26989
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
879 ;;---------------------------------------------------------------------------
340ed24f202a Generally, synch w/ maintainer version 5.9.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 23368
diff changeset
880 ;; that's it
10276
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
881
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
882 (provide 'hideshow)
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
883
86c61b6bd265 Initial revision
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
diff changeset
884 ;;; hideshow.el ends here