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

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

Re: Defining outline-regexp Interactively?, the Pros of outline-minor-mo


From: Veli-Pekka Tätilä
Subject: Re: Defining outline-regexp Interactively?, the Pros of outline-minor-mode
Date: Sun, 5 Oct 2008 16:07:58 +0300

Hi list,
I'll answer my own questions. The following function seems to do the trick 
of defining a local outline regexp for the minor mode in the current buffer 
for me interactively. I don't know much Lisp yet but the Emacs wiki and 
programming in Emacs lisp helped a lot.

(defun prompt-for-outline-regexp (new-regexp)
  "ask the user for a local value of outline-regexp in this buffer"
  (interactive "sOutline regexp: ")
  (set (make-local-variable 'outline-regexp) new-regexp)
) ; defun

I bind it as follows:

(global-set-key (kbd "<f9>") 'prompt-for-outline-regexp)

And then, as to matching book headings, that one seems to be rather straight 
forward, too. Here:

http://www.linux.com/feature/114144

Quote with snippage:
For example, suppose you have a file that contains a book manuscript. 
Chapters in this file always begin with a numbered title line, sections 
beneath it are titled with the chapter number followed by a period and 
section number, and subsections add another number, <snip>

You can view such a file as an outline in outline mode by changing the 
outline-regexp variable to a regexp that will match one or more numbers 
followed by the grouping of a period character and an optional second 
number. <snip>

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

-- 
With kind regards Veli-Pekka Tätilä
Accessibility, Apps and Coding plus Synths and Music:
http://vtatila.kapsi.fi




reply via email to

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