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

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

Re: State of the art in Emacs outlining?


From: Matthias Meulien
Subject: Re: State of the art in Emacs outlining?
Date: 02 Oct 2002 19:11:30 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Christian Lemburg <lemburg@aixonix.de> wrote:

> (defun text-outline-mode ()
>   "Set customized outline major mode for text with numbered headings"
>   (interactive)
>   (setq outline-regexp "[0-9.]+")
>   (outline-mode))

Anolog with header level support, font-lock-mode. Put the following
lines in `text-mode-hook' for example.

;; Provides outline facilities based on numbered headers.

(defun 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
the number of . characters that `outline-regexp' matches."
  (save-excursion
    (looking-at outline-regexp)
    (let ((string (match-string 0))
          (level 0))
      (while (string-match "\\." string)
        (setq level (1+ level)
              string (substring string (match-end 0))))
      level)))

(setq outline-regexp "\\([0-9]+\\.\\)+ ")

(setq imenu-generic-expression
        (list (list nil (concat "^\\(?:" outline-regexp "\\).*$") 0)))

(outline-minor-mode 1)

(set (make-local-variable 'font-lock-defaults)
       '(outline-font-lock-keywords t nil nil backward-paragraph))

(imenu-add-menubar-index)
-- 
Matthias


reply via email to

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