* Defining outline-regexp Interactively?, the Pros of outline-minor-mode
@ 2008-10-04 18:54 Veli-Pekka Tätilä
2008-10-05 13:07 ` Veli-Pekka Tätilä
0 siblings, 1 reply; 2+ messages in thread
From: Veli-Pekka Tätilä @ 2008-10-04 18:54 UTC (permalink / raw)
To: help-gnu-emacs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2143 bytes --]
Hi,
One thing I really like in Emacs is outline-minor-mode. A newbie question,
though, can I easily interactively set the outline-regexp without having to
evaluate Lisp code in a separate buffer, or update my config? My matching
needs dynamically depend on the kind of content in the buffer, I use a
regexp for matching functions when doing Lua, but would like to use a regexp
matching numbered headings like 1.3. when viewing a text dump of the Lua
reference manual.
In fact, I view outline minor mode as a kind of alternative UI to traversing
regexp search results non-linearly. Which reminds me if I have n
dot-separated sections e.g.
1.3.5
can I make outline-minor-mode understand the concept of subchapters and
subsubchapters in its tree structures? I can regexp match the bits all
right, though.
As to what's good in it:
Outline minor mode let's me easily hide function bodies and get the big
picture, without having to use regexp matching to jump from function to
function. It also makes rearranging stuff a breeze compared to selecting
line by line and cutting and pasting, which is what I used to do. It also
works great for languages not supported out of the box, such as Lua, if you
just say something like:
(setq outline-regexp "function")
The Emacs wiki has taught me almost as many handy things as the book
Learning Gnu Emacs, it is a great resource!
Further more, things are so much easier to manage from the keyboard if you
go and redefine the branch management keys to emulate tree-control keyboard
conventions. I found the following in the wiki and have it in my .emacs file
(for Windows and Linux):
(global-set-key [M-left] 'hide-body)
(global-set-key [M-right] 'show-all)
(global-set-key [M-up] 'outline-previous-heading)
(global-set-key [M-down] 'outline-next-heading)
(global-set-key [C-M-left] 'hide-sublevels)
(global-set-key [C-M-right] 'show-children)
(global-set-key [C-M-up] 'outline-previous-visible-heading)
(global-set-key [C-M-down] 'outline-next-visible-heading)
--
With kind regards Veli-Pekka Tätilä
Accessibility, Apps and Coding plus Synths and Music:
http://vtatila.kapsi.fi
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Defining outline-regexp Interactively?, the Pros of outline-minor-mode
2008-10-04 18:54 Defining outline-regexp Interactively?, the Pros of outline-minor-mode Veli-Pekka Tätilä
@ 2008-10-05 13:07 ` Veli-Pekka Tätilä
0 siblings, 0 replies; 2+ messages in thread
From: Veli-Pekka Tätilä @ 2008-10-05 13:07 UTC (permalink / raw)
To: help-gnu-emacs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1420 bytes --]
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-10-05 13:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-04 18:54 Defining outline-regexp Interactively?, the Pros of outline-minor-mode Veli-Pekka Tätilä
2008-10-05 13:07 ` Veli-Pekka Tätilä
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).