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

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

;;; dash-outline-mode.el --- A major-mode similar to outline-mode


From: Kevin A. Burton
Subject: ;;; dash-outline-mode.el --- A major-mode similar to outline-mode
Date: 23 Apr 2002 17:24:59 -0700
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1.50

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Peace!

;;; dash-outline-mode.el --- A major-mode similar to outline-mode

;; $Id: $

;; Copyright (C) 2000-2003 Free Software Foundation, Inc.
;; Copyright (C) 2000-2003 Kevin A. Burton (address@hidden)

;; Author: Kevin A. Burton (address@hidden)
;; Maintainer: Kevin A. Burton (address@hidden)
;; Location: http://relativity.yi.org
;; Keywords: 
;; Version: 1.0.0

;; This file is [not yet] part of GNU Emacs.

;; 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 of the License, or 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; if not, write to the Free Software Foundation, Inc., 59 Temple
;; Place - Suite 330, Boston, MA 02111-1307, USA.

;;; Commentary:

;; Mode which is similar to `outline-mode' but matches 'dash' outlines.
;;
;; Specifically:
;;
;; - is a beginning
;;     - is another level
;;         - is another level
;;
;; This is the way I think of outlines.  I assume some people would agree.
;;
;; NOTE: If you enjoy this software, please consider a donation to the EFF
;; (http://www.eff.org)

;;; TODO:
;;

;;; Code:

(defcustom dash-outline-regexp "^\\([ ]*\\)-.*"
  "*Regular expression to match the beginning of a heading. Hide Any line whose
beginning matches this regexp is considered to start a heading.  The recommended
way to set this is with a Local Variables: list in the file it applies to.  See
also `outline-heading-end-regexp'."
  :group 'dash-outline
  :type 'regexp)

(defcustom dash-outline-level-width 4
  "*The width that an outline level (in spaces) should be. n*1 == first level,
  n*2 == second level, etc."
  :group 'dash-outline
  :type 'integer)

(define-derived-mode dash-outline-mode outline-mode "DashOutline"
  "Mode which is similar to `outline-mode' but matches 'dash' outlines.

Specifically:

- - is a beginning
    - is another level
        - is another level

This is the way I think of outlines.  I assume some people would agree."

  (hs-minor-mode)

  (make-local-variable 'outline-level)
  (setq outline-level 'dash-outline-level)
  
  (make-local-variable 'outline-regexp)
  (setq outline-regexp dash-outline-regexp))

(defun dash-outline-level ()
  "Return the depth to which a statement is nested in the outline.
Point must be at the beginning of a header line.  This is actually either the
level specified in `outline-heading-alist' or else the number of characters
matched by `outline-regexp'."
  (save-excursion
    (if (not (looking-at dash-outline-regexp))
        ;; This should never happen
        1000
      (round (/ (- (match-end 1) (match-beginning 1)) 
dash-outline-level-width)))))

(provide 'dash-outline-mode)

;;; dash-outline-mode.el ends here

- -- 
Kevin A. Burton ( address@hidden, address@hidden, address@hidden )
             Location - San Francisco, CA, Cell - 415.595.9965
        Jabber - address@hidden,  Web - http://relativity.yi.org/

The secret to creativity is knowing how to hide your sources.
  -Albert Einstein

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt

iD8DBQE8xftbAwM6xb2dfE0RAsAmAJ0fHBJj0kN3K7KsOk1A14KlNrib/gCgopcj
M8tl9VM/3MIG2IHFomdJ2RE=
=mjAA
-----END PGP SIGNATURE-----



reply via email to

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