]> code.delx.au - gnu-emacs/blobdiff - lisp/reveal.el
2005-10-01 Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
[gnu-emacs] / lisp / reveal.el
index 393400071a60457b646f4a18c45aade048ef95f2..41b7c4268c27de713de93954a1f12675fe8b5bfd 100644 (file)
@@ -1,6 +1,7 @@
 ;;; reveal.el --- Automatically reveal hidden text at point
 
-;; Copyright (C) 2000, 2001, 2004  Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
+;;   2005 Free Software Foundation, Inc.
 
 ;; Author: Stefan Monnier <monnier@cs.yale.edu>
 ;; Keywords: outlines
@@ -19,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
@@ -54,7 +55,8 @@
 
 (defcustom reveal-around-mark t
   "Reveal text around the mark, if active."
-  :type 'boolean)
+  :type 'boolean
+  :group 'reveal)
 
 (defvar reveal-open-spots nil)
 (make-variable-buffer-local 'reveal-open-spots)
                          (overlays-at (point))))
         (push (cons (selected-window) ol) reveal-open-spots)
         (setq old-ols (delq ol old-ols))
-        (let ((open (overlay-get ol 'reveal-toggle-invisible)) inv)
-          (when (or open
-                    (and (setq inv (overlay-get ol 'invisible))
-                         (symbolp inv)
-                         (or (setq open (or (get inv 'reveal-toggle-invisible)
-                                            (overlay-get ol 'isearch-open-invisible-temporary)))
-                             (overlay-get ol 'isearch-open-invisible)
-                             (and (consp buffer-invisibility-spec)
-                                  (assq inv buffer-invisibility-spec)))
-                         (overlay-put ol 'reveal-invisible inv)))
+        (let ((inv (overlay-get ol 'invisible)) open)
+          (when (and inv
+                     ;; There's an `invisible' property.  Make sure it's
+                     ;; actually invisible.
+                     (or (not (listp buffer-invisibility-spec))
+                         (memq inv buffer-invisibility-spec)
+                         (assq inv buffer-invisibility-spec))
+                     (or (setq open
+                               (or (overlay-get ol 'reveal-toggle-invisible)
+                                   (and (symbolp inv)
+                                        (get inv 'reveal-toggle-invisible))
+                                   (overlay-get ol 'isearch-open-invisible-temporary)))
+                         (overlay-get ol 'isearch-open-invisible)
+                         (and (consp buffer-invisibility-spec)
+                              (cdr (assq inv buffer-invisibility-spec))))
+                     (overlay-put ol 'reveal-invisible inv))
             (if (null open)
                 (overlay-put ol 'invisible nil)
               ;; Use the provided opening function and repeat (since the
               (setq repeat t)
               (condition-case err
                   (funcall open ol nil)
-                (error (message "!!Reveal-show: %s !!" err)
+                (error (message "!!Reveal-show (funcall %s %s nil): %s !!"
+                                open ol err)
                        ;; Let's default to a meaningful behavior to avoid
                        ;; getting stuck in an infinite loop.
                        (setq repeat nil)
                                           (overlay-get ol 'isearch-open-invisible-temporary)))))
                   (condition-case err
                       (funcall open ol t)
-                    (error (message "!!Reveal-hide: %s !!" err)))
+                    (error (message "!!Reveal-hide (funcall %s %s t): %s !!"
+                                    open ol err)))
                 (overlay-put ol 'invisible inv))))))))
    (error (message "Reveal: %s" err)))))
 
+(defvar reveal-mode-map
+  (let ((map (make-sparse-keymap)))
+    ;; Override the default move-beginning-of-line and move-end-of-line
+    ;; which skips valuable invisible text.
+    (define-key map [remap move-beginning-of-line] 'beginning-of-line)
+    (define-key map [remap move-end-of-line] 'end-of-line)
+    map))
+
 ;;;###autoload
 (define-minor-mode reveal-mode
   "Toggle Reveal mode on or off.
@@ -159,7 +177,9 @@ Reveal mode renders invisible text around point visible again.
 Interactively, with no prefix argument, toggle the mode.
 With universal prefix ARG (or if ARG is nil) turn mode on.
 With zero or negative ARG turn mode off."
+  :group 'reveal
   :lighter (global-reveal-mode nil " Reveal")
+  :keymap reveal-mode-map
   (if reveal-mode
       (progn
        (set (make-local-variable 'search-invisible) t)