Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
From: Eric M. Ludlam <eric@si...> - 2005-05-12 20:15:08
>>> Alex Polite <notmyprivateemail@...> seems to think that:
>I'm trying to use speedbar to browse emacs-wiki files.
>The structure of emacs-wiki is pretty simple.
>* Header level 1
>** Header level 2
>*** Header level 3
>I've been hacking away at sb-html.el to make it into sb-emacswiki.el
>Unfortunately my elisp skills are lacking, but I think that this is
>the essential part:
> (while (re-search-forward "^\\(*+\\) +\\(.+\\)$" nil t)
> (setq beg (match-end 0))
> (goto-char (match-beginning 0))
> (setq pos-beg (point-marker))
> ;(setq level (1- (read (match-string 1)))
> (setq level (1- (length (match-string-no-properties 1))))
> ;;(re-search-forward (concat "\\s-*</h" (match-string 1) "\\b"))
> (setq title (match-string-no-properties 2))
> (setq alist (cons (cons level (cons title pos-beg)) alist)))
> (nreverse alist)))
[ ... ]
I think the regexp you want is just this:
(while (re-search-forward "^\\(\\*+\\) +" nil t)
because * is a special regexp character, and your .+ expression could
match off to infinity.
You can test your expressions with C-M-s, and just type them in.
Just remember in that mode you only need one slash, like this: \(\*+\)
You could also calculate the depth as:
(- (match-end 1) (match-beginning 1))
and skip all the string allocation
Lastly, after each iteration, you should use (end-of-line) in order
to avoid accidentally picking up extraneous * characters.
Eric Ludlam: zappo@..., eric@...
Home: http://www.ludlam.net Siege: http://www.siege-engine.com
Emacs: http://cedet.sourceforge.net GNU: http://www.gnu.org