Convert consecutive FSF copyright years to ranges.
[bpt/emacs.git] / lisp / outline.el
index 2aecfe2..d43afd9 100644 (file)
@@ -1,17 +1,17 @@
 ;;; outline.el --- outline mode commands for Emacs
 
-;; Copyright (C) 1986, 1993, 1994, 1995, 1997, 2000, 2001, 2002,
-;;   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1986, 1993-1995, 1997, 2000-2011
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: outlines
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +19,7 @@
 ;; GNU General Public License for more details.
 
 ;; 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., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -43,7 +41,7 @@
 (defgroup outlines nil
   "Support for hierarchical outlining."
   :prefix "outline-"
-  :group 'editing)
+  :group 'wp)
 
 (defcustom outline-regexp "[*\^L]+"
   "Regular expression to match the beginning of a heading.
@@ -105,78 +103,78 @@ in the file it applies to."
                  :help "Hide everything but the top LEVELS levels of headers, in whole buffer"))
     (define-key map [hide hide-subtree]
       '(menu-item "Hide Subtree" hide-subtree
-                 :help ""))
+                 :help "Hide everything after this heading at deeper levels"))
     (define-key map [hide hide-entry]
       '(menu-item "Hide Entry" hide-entry
-                 :help ""))
+                 :help "Hide the body directly following this heading"))
     (define-key map [hide hide-body]
       '(menu-item "Hide Body" hide-body
-                 :help ""))
+                 :help "Hide all body lines in buffer, leaving all headings visible"))
     (define-key map [hide hide-leaves]
       '(menu-item "Hide Leaves" hide-leaves
-                 :help ""))
+                 :help "Hide the body after this heading and at deeper levels"))
 
     (define-key map [show] (cons "Show" (make-sparse-keymap "Show")))
 
     (define-key map [show show-subtree]
       '(menu-item "Show Subtree" show-subtree
-                 :help ""))
+                 :help "Show everything after this heading at deeper levels"))
     (define-key map [show show-children]
       '(menu-item "Show Children" show-children
-                 :help ""))
+                 :help "Show all direct subheadings of this heading"))
     (define-key map [show show-branches]
       '(menu-item "Show Branches" show-branches
-                 :help ""))
+                 :help "Show all subheadings of this heading, but not their bodies"))
     (define-key map [show show-entry]
       '(menu-item "Show Entry" show-entry
-                 :help ""))
+                 :help "Show the body directly following this heading"))
     (define-key map [show show-all]
       '(menu-item "Show All" show-all
-                 :help ""))
+                 :help "Show all of the text in the buffer"))
 
     (define-key map [headings]
       (cons "Headings" (make-sparse-keymap "Headings")))
 
     (define-key map [headings demote-subtree]
       '(menu-item "Demote subtree" outline-demote
-                 :help ""))
+                 :help "Demote headings lower down the tree"))
     (define-key map [headings promote-subtree]
       '(menu-item "Promote subtree" outline-promote
-                 :help ""))
+                 :help "Promote headings higher up the tree"))
     (define-key map [headings move-subtree-down]
       '(menu-item "Move subtree down" outline-move-subtree-down
-                 :help ""))
+                 :help "Move the currrent subtree down past arg headlines of the same level"))
     (define-key map [headings move-subtree-up]
       '(menu-item "Move subtree up" outline-move-subtree-up
-                 :help ""))
+                 :help "Move the currrent subtree up past arg headlines of the same level"))
     (define-key map [headings copy]
       '(menu-item "Copy to kill ring" outline-headers-as-kill
                  :enable mark-active
-                 :help ""))
+                 :help "Save the visible outline headers in region at the start of the kill ring"))
     (define-key map [headings outline-insert-heading]
 
       '(menu-item "New heading" outline-insert-heading
-                 :help ""))
+                 :help "Insert a new heading at same depth at point"))
     (define-key map [headings outline-backward-same-level]
 
       '(menu-item "Previous Same Level" outline-backward-same-level
-                 :help ""))
+                 :help "Move backward to the arg'th subheading at same level as this one."))
     (define-key map [headings outline-forward-same-level]
 
       '(menu-item "Next Same Level" outline-forward-same-level
-                 :help ""))
+                 :help "Move forward to the arg'th subheading at same level as this one"))
     (define-key map [headings outline-previous-visible-heading]
 
       '(menu-item "Previous" outline-previous-visible-heading
-                 :help ""))
+                 :help "Move to the previous heading line"))
     (define-key map [headings outline-next-visible-heading]
 
       '(menu-item "Next" outline-next-visible-heading
-                 :help ""))
+                 :help "Move to the next visible heading line"))
     (define-key map [headings outline-up-heading]
 
       '(menu-item "Up" outline-up-heading
-                 :help ""))
+                 :help "Move to the visible heading line of which the present line is a subheading"))
     map))
 
 (defvar outline-minor-mode-menu-bar-map
@@ -349,7 +347,7 @@ Turning on outline mode calls the value of `text-mode-hook' and then of
   (add-hook 'change-major-mode-hook 'show-all nil t))
 
 (defcustom outline-minor-mode-prefix "\C-c@"
-  "*Prefix key to use for Outline commands in Outline minor mode.
+  "Prefix key to use for Outline commands in Outline minor mode.
 The value of this variable is checked as part of loading Outline mode.
 After that, changing the prefix key requires manipulating keymaps."
   :type 'string
@@ -382,6 +380,7 @@ See the command `outline-mode' for more information on this mode."
   "*Function of no args to compute a header's nesting level in an outline.
 It can assume point is at the beginning of a header line and that the match
 data reflects the `outline-regexp'.")
+;;;###autoload(put 'outline-level 'risky-local-variable t)
 
 (defvar outline-heading-alist ()
   "Alist associating a heading for every possible level.
@@ -446,10 +445,6 @@ at the end of the buffer."
   "Non-nil if the character after point is invisible."
   (get-char-property (or pos (point)) 'invisible))
 
-(defun outline-visible ()
-  (not (outline-invisible-p)))
-(make-obsolete 'outline-visible 'outline-invisible-p)
-
 (defun outline-back-to-heading (&optional invisible-ok)
   "Move to previous heading line, or beg of this line if it's a heading.
 Only visible heading lines are considered, unless INVISIBLE-OK is non-nil."
@@ -596,7 +591,7 @@ If there are no such entries, return nil.
 ALIST defaults to `outline-heading-alist'.
 Similar to (car (rassoc LEVEL ALIST)).
 If there are several different entries with same new level, choose
-the one with the smallest distance to the assocation of HEAD in the alist.
+the one with the smallest distance to the association of HEAD in the alist.
 This makes it possible for promotion to work in modes with several
 independent sets of headings (numbered, unnumbered, appendix...)"
   (unless alist (setq alist outline-heading-alist))
@@ -907,6 +902,8 @@ Show the heading too, if it is currently invisible."
                   (goto-char (point-max))
                   ;; Keep empty last line, if available.
                   (if (bolp) (1- (point)) (point)))))
+      (if (< end beg)
+         (setq beg (prog1 end (setq end beg))))
       ;; First hide everything.
       (outline-flag-region beg end t)
       ;; Then unhide the top level headers.
@@ -914,7 +911,11 @@ Show the heading too, if it is currently invisible."
        (lambda ()
         (if (<= (funcall outline-level) levels)
             (outline-show-heading)))
-       beg end)))
+       beg end)
+      ;; Finally unhide any trailing newline.
+      (goto-char (point-max))
+      (if (and (bolp) (not (bobp)) (outline-invisible-p (1- (point))))
+          (outline-flag-region (1- (point)) (point) nil))))
   (run-hooks 'outline-view-change-hook))
 
 (defun hide-other ()
@@ -1117,5 +1118,4 @@ convenient way to make a table of contents of the buffer."
 (provide 'outline)
 (provide 'noutline)
 
-;; arch-tag: 1724410e-7d4d-4f46-b801-49e18171e874
 ;;; outline.el ends here