gnu-emacs-sources
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

outline+.el - extensions to GNU `outline.el'


From: Drew Adams
Subject: outline+.el - extensions to GNU `outline.el'
Date: Tue, 16 Jan 2001 21:35:20 -0500

;;; outline+.el --- Extensions to `outline.el'.
;; 
;; Emacs Lisp Archive Entry
;; Filename: outline+.el
;; Description: Extensions to `outline.el'.
;; Author: Drew Adams
;; Maintainer: Drew Adams
;; Copyright (C) 1996-2001, Drew Adams, all rights reserved.
;; Created: Fri Jun 21 08:56:04 1996
;; Version: $Id: outline+.el,v 1.4 2001/01/09 01:57:31 dadams Exp $
;; Last-Updated: Mon Jan  8 17:57:28 2001
;;           By: dadams
;;     Update #: 302
;; Keywords: abbrev, matching, local
;; Compatibility: GNU Emacs 20.x
;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 
;;; Commentary: 
;; 
;;    Extensions to `outline.el'.
;; 
;;  Menu bar:
;;
;;  Reordered and renamed menu bar Outline Mode Hide and Show menus.
;;  Names of menu items now indicate whether the item applies locally
;;  or globally.  Global and local items are separated in the menu.
;;
;;      Renamings:
;;        Hide Leaves    -> Hide Entries                (local)
;;        Hide Body      -> Hide All But Headings       (global)
;;        Hide Subtree   -> Hide Tree                   (local)
;;        Hide Sublevels -> Hide All But Top N Headings (global)
;;        Hide Other     -> Hide All But Entry          (local)
;;        Show Branches  -> Show Headings               (local)
;;        Show Children  -> Show Headings N Deep        (local)
;;        Show Subtree   -> Show Tree                   (local)
;;
;;  Outline minor mode font locking:
;;
;;     See the new command `toggle-outline-minor-mode-font-lock',
;;     intended for use as both `outline-minor-mode-hook' and
;;     `outline-minor-mode-exit-hook'.
;;
;;
;;  New function defined here: `toggle-outline-minor-mode-font-lock'.
;;
;;  New variables defined here:
;;
;;     Var `outline-minor-mode-hook' was not declared in `outline.el'.
;;     It is declared here, along with `outline-minor-mode-exit-hook'.
;;  
;;
;;  ***** NOTE: The following function defined in `vc.el' has been
;;              REDEFINED HERE:
;;
;;  `outline-minor-mode' - Call to `outline-minor-mode-exit-hook'.
;;
;;
;;  This file should be loaded after loading the standard GNU file
;;  `outline.el'.  So, in your `~/.emacs' file, do this:
;;  (eval-after-load "outline" '(progn (require 'outline+))
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 
;;; Change log:
;; 
;; RCS $Log: outline+.el,v $
;; RCS Revision 1.4  2001/01/09 01:57:31  dadams
;; RCS Adapted file header for Emacs Lisp Archive.
;; RCS
;; RCS Revision 1.3  2001/01/03 17:43:43  dadams
;; RCS *** empty log message ***
;; RCS
;; RCS Revision 1.2  2001/01/03 01:02:03  dadams
;; RCS *** empty log message ***
;; RCS
;; RCS Revision 1.1  2000/09/14 17:23:32  dadams
;; RCS Initial revision
;; RCS
; Revision 1.2  1996/07/01  13:20:44  dadams
; Require cl.el.
;
; Revision 1.1  1996/06/25  13:32:34  dadams
; Initial revision
;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 
;; This program 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 2, or (at your option)
;; any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 
;;; Code:

(require 'outline)
(require 'cl) ;; when

(provide 'outline+)

;;;;;;;;;;;;;;;;;;;;


;;;###autoload
(defvar outline-minor-mode-exit-hook nil
  "*Functions to be called when `outline-minor-mode' is exited.")

;;;###autoload
(defvar outline-minor-mode-hook nil
  "*Functions to be called when `outline-minor-mode' is entered.")


;; REPLACES ORIGINAL in `outline.el':
;; Added `outline-minor-mode-exit-hook'.
;;;###autoload
(defun outline-minor-mode (&optional arg)
  "Toggle Outline minor mode.
Non-nil prefix ARG turns mode on if ARG is positive, else turns off.
Runs `outline-minor-mode-hook' when Outline minor mode is entered.
Runs `outline-minor-mode-exit-hook' when Outline minor mode is exited.
See the command `outline-mode' for more information on this mode."
  (interactive "P")
  (setq outline-minor-mode (if (null arg)
                               (not outline-minor-mode)
                             (> (prefix-numeric-value arg) 0)))
  (setq selective-display outline-minor-mode)
  (if outline-minor-mode
      (run-hooks 'outline-minor-mode-hook)
    ;; Show all lines, getting rid of any ^M's.
    (outline-flag-region (point-min) (point-max) ?\n)
    (run-hooks 'outline-minor-mode-exit-hook))
  (set-buffer-modified-p (buffer-modified-p)))

;;;###autoload
(defun toggle-outline-minor-mode-font-lock ()
  "Toggle `font-lock-mode' for Outline minor mode.
Usable as `outline-minor-mode-hook' & `outline-minor-mode-exit-hook'.

As `outline-minor-mode-hook':
Highlight according to Outline minor mode.  If already highlit
according to some other mode, then require confirmation first.

As `outline-minor-mode-exit-hook':
Remove Outline minor mode highlighting, if any.
Then, upon confirmation, rehighlight according to the major mode."
  (interactive)
  (let* ((outline-keywords (and (fboundp 'outline-mode-font-lock-keywords)
                                (outline-mode-font-lock-keywords)))
         (outline-keywords-p (equal font-lock-keywords outline-keywords)))
    (if outline-minor-mode
        ;; Assume ENTERING outline minor mode.
        (when (and (not outline-keywords-p) ; Not already outline keywords.
                   (or (not font-lock-mode) ; OK to use outline highlighting.
                       (y-or-n-p "Use outline-minor-mode highlighting? ")))
          (setq font-lock-keywords outline-keywords)
          ;;;@@@Emacs20 (setq font-lock-no-comments t)
          (font-lock-mode -999)         ; Remove existing highlighting.
          (font-lock-mode 999))
      ;; Assume EXITING outline minor mode.
      (when (and font-lock-mode outline-keywords-p) ;  Outline highlit.
        (setq font-lock-keywords nil)   ; Reset keywords to those of major mode
        (font-lock-set-defaults)
        (font-lock-mode -999)           ; Remove existing highlighting.
        (when (y-or-n-p (format "Turn Font Lock mode ON in mode %s? "
                                mode-name))
          (font-lock-mode 999))))
    (display-in-minibuffer 'new "Outline minor mode is now "
                           (list blue-foreground-face
                                 (if outline-minor-mode "ON" "OFF")) ".")))



;; Outline mode menu-bar menu.

(define-key outline-mode-menu-bar-map [hide]
  (cons "Hide" (make-sparse-keymap "Hide")))

(define-key outline-mode-menu-bar-map [hide hide-sublevels]
  '("Hide All But Top N Headings (global)" . hide-sublevels))
(define-key outline-mode-menu-bar-map [hide hide-body]
  '("Hide All But Headings       (global)" . hide-body))
(define-key outline-mode-menu-bar-map [hide hide-separator] '("--"))
(define-key outline-mode-menu-bar-map [hide hide-other]
  '("Hide All But Entry          (local)" . hide-other))
(define-key outline-mode-menu-bar-map [hide hide-entry]
  '("Hide Entry                  (local)" . hide-entry))
(define-key outline-mode-menu-bar-map [hide hide-leaves]
  '("Hide Entries                (local)" . hide-leaves))
(define-key outline-mode-menu-bar-map [hide hide-subtree]
  '("Hide Tree                   (local)" . hide-subtree))

(define-key outline-mode-menu-bar-map [show]
   (cons "Show" (make-sparse-keymap "Show")))

(define-key outline-mode-menu-bar-map [show show-all]
  '("Show All             (global)" . show-all))
(define-key outline-mode-menu-bar-map [show show-separator] '("--"))
(define-key outline-mode-menu-bar-map [show show-entry]
  '("Show Entry           (local)" . show-entry))
(define-key outline-mode-menu-bar-map [show show-children]
  '("Show Headings N Deep (local)" . show-children))
(define-key outline-mode-menu-bar-map [show show-branches]
  '("Show Headings        (local)" . show-branches))
(define-key outline-mode-menu-bar-map [show show-subtree]
  '("Show Tree            (local)" . show-subtree))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; `outline+.el' ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]