Mercurial > emacs
annotate lisp/reveal.el @ 66993:d621651aacea
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 18 Nov 2005 17:05:44 +0000 |
parents | 3fbf09f9769f |
children | 0217588b5a1c |
rev | line source |
---|---|
41621 | 1 ;;; reveal.el --- Automatically reveal hidden text at point |
2 | |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64091
diff
changeset
|
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, |
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64091
diff
changeset
|
4 ;; 2005 Free Software Foundation, Inc. |
41621 | 5 |
6 ;; Author: Stefan Monnier <monnier@cs.yale.edu> | |
7 ;; Keywords: outlines | |
8 | |
42320 | 9 ;; This file is part of GNU Emacs. |
10 | |
45340 | 11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
41621 | 12 ;; it under the terms of the GNU General Public License as published by |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
45341 | 16 ;; GNU Emacs is distributed in the hope that it will be useful, |
41621 | 17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
64091 | 23 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
41621 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; Reveal mode is a minor mode that makes sure that text around point | |
29 ;; is always visible. When point enters a region of hidden text, | |
30 ;; `reveal-mode' temporarily makes it visible. | |
31 ;; | |
32 ;; This is normally used in conjunction with `outline-minor-mode', | |
33 ;; `hs-minor-mode', `hide-ifdef-mode', ... | |
34 ;; | |
35 ;; It only works with packages that hide text using overlays. | |
36 ;; Packages can provide special support for it by placing | |
37 ;; a function in the `reveal-toggle-invisible' property on the symbol | |
38 ;; used as the value of the `invisible' overlay property. | |
39 ;; The function is called right after revealing (or re-hiding) the | |
40 ;; text with two arguments: the overlay and a boolean that's non-nil | |
41 ;; if we have just revealed the text. When revealing, that function | |
42 ;; may re-hide some of the text. | |
43 | |
44 ;;; Todo: | |
45 | |
46 ;; - find other hysteresis features. | |
66744
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
47 ;; - don't hide after a scroll command |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
48 ;; - delay hiding by a couple seconds (i.e. hide in the background) |
41621 | 49 |
50 ;;; Code: | |
51 | |
52 (defgroup reveal nil | |
53 "Reveal hidden text on the fly." | |
54 :group 'editing) | |
55 | |
56 (defcustom reveal-around-mark t | |
57 "Reveal text around the mark, if active." | |
62531
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
61275
diff
changeset
|
58 :type 'boolean |
c905fcf5e3d9
Specify missing group (and type, if simple) in defcustom.
Juanma Barranquero <lekktu@gmail.com>
parents:
61275
diff
changeset
|
59 :group 'reveal) |
41621 | 60 |
66744
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
61 (defvar reveal-open-spots nil |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
62 "List of spots in the buffer which are open. |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
63 Each element has the form (WINDOW . OVERLAY).") |
41621 | 64 (make-variable-buffer-local 'reveal-open-spots) |
65 | |
57816
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
66 (defvar reveal-last-tick nil) |
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
67 (make-variable-buffer-local 'reveal-last-tick) |
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
68 |
41621 | 69 ;; Actual code |
70 | |
71 (defun reveal-post-command () | |
72 ;; Refresh the spots that might have changed. | |
73 ;; `Refreshing' here means to try and re-hide the corresponding text. | |
74 ;; We don't refresh everything correctly: | |
75 ;; - we only refresh spots in the current window. | |
76 ;; FIXME: do we actually know that (current-buffer) = (window-buffer) ? | |
77 (with-local-quit | |
45428
ac7e0cc03aed
(reveal-post-command): Reverse the semantics of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45341
diff
changeset
|
78 (condition-case err |
66744
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
79 (let ((old-ols (delq nil |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
80 (mapcar |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
81 (lambda (x) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
82 ;; We refresh any spot in the current window as |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
83 ;; well as any spots associated with a dead |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
84 ;; window or a window which does not show this |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
85 ;; buffer any more. |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
86 (if (or (eq (car x) (selected-window)) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
87 (not (window-live-p (car x))) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
88 (not (eq (window-buffer (car x)) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
89 (current-buffer)))) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
90 (cdr x))) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
91 reveal-open-spots))) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
92 (repeat t)) |
41621 | 93 ;; Open new overlays. |
94 (while repeat | |
95 (setq repeat nil) | |
96 (dolist (ol (nconc (when (and reveal-around-mark mark-active) | |
97 (overlays-at (mark))) | |
98 (overlays-at (point)))) | |
99 (setq old-ols (delq ol old-ols)) | |
60301
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
100 (let ((inv (overlay-get ol 'invisible)) open) |
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
101 (when (and inv |
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
102 ;; There's an `invisible' property. Make sure it's |
66744
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
103 ;; actually invisible, and ellipsised. |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
104 (and (consp buffer-invisibility-spec) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
105 (cdr (assq inv buffer-invisibility-spec))) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
106 (or (setq open |
60301
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
107 (or (overlay-get ol 'reveal-toggle-invisible) |
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
108 (and (symbolp inv) |
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
109 (get inv 'reveal-toggle-invisible)) |
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
110 (overlay-get ol 'isearch-open-invisible-temporary))) |
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
111 (overlay-get ol 'isearch-open-invisible) |
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
112 (and (consp buffer-invisibility-spec) |
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
113 (cdr (assq inv buffer-invisibility-spec)))) |
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
114 (overlay-put ol 'reveal-invisible inv)) |
66744
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
115 (push (cons (selected-window) ol) reveal-open-spots) |
45428
ac7e0cc03aed
(reveal-post-command): Reverse the semantics of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45341
diff
changeset
|
116 (if (null open) |
66744
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
117 (progn ;; (debug) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
118 (overlay-put ol 'invisible nil)) |
41621 | 119 ;; Use the provided opening function and repeat (since the |
120 ;; opening function might have hidden a subpart around point). | |
121 (setq repeat t) | |
122 (condition-case err | |
45428
ac7e0cc03aed
(reveal-post-command): Reverse the semantics of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45341
diff
changeset
|
123 (funcall open ol nil) |
60301
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
124 (error (message "!!Reveal-show (funcall %s %s nil): %s !!" |
f3c5c717aa02
(reveal-post-command): Don't try to reveal overlays which
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
58435
diff
changeset
|
125 open ol err) |
50374
73660951a233
(reveal-post-command): Better error handling and debugging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48399
diff
changeset
|
126 ;; Let's default to a meaningful behavior to avoid |
73660951a233
(reveal-post-command): Better error handling and debugging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48399
diff
changeset
|
127 ;; getting stuck in an infinite loop. |
50384
09ec24acd6a5
(reveal-post-command): Remove buggy debugging code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50374
diff
changeset
|
128 (setq repeat nil) |
50374
73660951a233
(reveal-post-command): Better error handling and debugging.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
48399
diff
changeset
|
129 (overlay-put ol 'invisible nil)))))))) |
41621 | 130 ;; Close old overlays. |
57816
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
131 (if (not (eq reveal-last-tick |
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
132 (setq reveal-last-tick (buffer-modified-tick)))) |
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
133 ;; The buffer was modified since last command: let's refrain from |
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
134 ;; closing any overlay because it tends to behave poorly when |
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
135 ;; inserting text at the end of an overlay (basically the overlay |
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
136 ;; should be rear-advance when it's open, but things like |
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
137 ;; outline-minor-mode make it non-rear-advance because it's |
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
138 ;; a better choice when it's closed). |
66744
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
139 nil |
57816
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
140 ;; The last command was only a point motion or some such |
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
141 ;; non-buffer-modifying command. Let's close whatever can be closed. |
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
142 (dolist (ol old-ols) |
66744
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
143 (if (and (>= (point) (save-excursion |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
144 (goto-char (overlay-start ol)) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
145 (line-beginning-position 1))) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
146 (<= (point) (save-excursion |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
147 (goto-char (overlay-end ol)) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
148 (line-beginning-position 2))) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
149 ;; If the application has moved the overlay to some other |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
150 ;; buffer, we'd better reset the buffer to its |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
151 ;; original state. |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
152 (eq (current-buffer) (overlay-buffer ol))) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
153 ;; Still near the overlay: keep it open. |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
154 nil |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
155 ;; Really close it. |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
156 (let ((open (overlay-get ol 'reveal-toggle-invisible)) inv) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
157 (if (or open |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
158 (and (setq inv (overlay-get ol 'reveal-invisible)) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
159 (setq open (or (get inv 'reveal-toggle-invisible) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
160 (overlay-get ol 'isearch-open-invisible-temporary))))) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
161 (condition-case err |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
162 (funcall open ol t) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
163 (error (message "!!Reveal-hide (funcall %s %s t): %s !!" |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
164 open ol err))) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
165 (overlay-put ol 'invisible inv)) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
166 ;; Remove the olverlay from the list of open spots. |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
167 (setq reveal-open-spots |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
168 (delq (rassoc ol reveal-open-spots) |
3fbf09f9769f
(reveal-post-command): Rework the handling of
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
169 reveal-open-spots))))))) |
50384
09ec24acd6a5
(reveal-post-command): Remove buggy debugging code.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50374
diff
changeset
|
170 (error (message "Reveal: %s" err))))) |
41621 | 171 |
58435
180297c18beb
(reveal-mode-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57816
diff
changeset
|
172 (defvar reveal-mode-map |
180297c18beb
(reveal-mode-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57816
diff
changeset
|
173 (let ((map (make-sparse-keymap))) |
60487
bf372b4b92e9
(reveal-mode-map): Bind C-a to beginning-of-line.
Kim F. Storm <storm@cua.dk>
parents:
60301
diff
changeset
|
174 ;; Override the default move-beginning-of-line and move-end-of-line |
bf372b4b92e9
(reveal-mode-map): Bind C-a to beginning-of-line.
Kim F. Storm <storm@cua.dk>
parents:
60301
diff
changeset
|
175 ;; which skips valuable invisible text. |
61087
386a445c2ae9
(reveal-mode-map): Don't override C-a and C-e.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60487
diff
changeset
|
176 (define-key map [remap move-beginning-of-line] 'beginning-of-line) |
386a445c2ae9
(reveal-mode-map): Don't override C-a and C-e.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
60487
diff
changeset
|
177 (define-key map [remap move-end-of-line] 'end-of-line) |
58435
180297c18beb
(reveal-mode-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57816
diff
changeset
|
178 map)) |
180297c18beb
(reveal-mode-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57816
diff
changeset
|
179 |
41621 | 180 ;;;###autoload |
181 (define-minor-mode reveal-mode | |
182 "Toggle Reveal mode on or off. | |
183 Reveal mode renders invisible text around point visible again. | |
184 | |
185 Interactively, with no prefix argument, toggle the mode. | |
186 With universal prefix ARG (or if ARG is nil) turn mode on. | |
187 With zero or negative ARG turn mode off." | |
61275
4e273c06e466
(reveal-mode): Specify :group.
Lute Kamstra <lute@gnu.org>
parents:
61087
diff
changeset
|
188 :group 'reveal |
41778
19e76eadbf86
(reveal-mode): Fix reveal-mode's lighter.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
41621
diff
changeset
|
189 :lighter (global-reveal-mode nil " Reveal") |
58435
180297c18beb
(reveal-mode-map): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57816
diff
changeset
|
190 :keymap reveal-mode-map |
41621 | 191 (if reveal-mode |
192 (progn | |
193 (set (make-local-variable 'search-invisible) t) | |
194 (add-hook 'post-command-hook 'reveal-post-command nil t)) | |
195 (kill-local-variable 'search-invisible) | |
196 (remove-hook 'post-command-hook 'reveal-post-command t))) | |
197 | |
198 ;;;###autoload | |
199 (define-minor-mode global-reveal-mode | |
200 "Toggle Reveal mode in all buffers on or off. | |
201 Reveal mode renders invisible text around point visible again. | |
202 | |
203 Interactively, with no prefix argument, toggle the mode. | |
204 With universal prefix ARG (or if ARG is nil) turn mode on. | |
205 With zero or negative ARG turn mode off." | |
48399
59fc5f077731
(global-reveal-mode): Add group.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
45428
diff
changeset
|
206 :global t :group 'reveal |
41621 | 207 (setq-default reveal-mode global-reveal-mode) |
208 (if global-reveal-mode | |
209 (progn | |
210 (setq search-invisible t) | |
211 (add-hook 'post-command-hook 'reveal-post-command)) | |
212 (setq search-invisible 'open) ;FIXME | |
213 (remove-hook 'post-command-hook 'reveal-post-command))) | |
214 | |
215 (provide 'reveal) | |
48399
59fc5f077731
(global-reveal-mode): Add group.
Markus Rost <rost@math.uni-bielefeld.de>
parents:
45428
diff
changeset
|
216 |
57816
af6e1f8dd9e0
(reveal-last-tick): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
217 ;; arch-tag: 96ba0242-2274-4ed7-8e10-26bc0707b4d8 |
41621 | 218 ;;; reveal.el ends here |