[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: outline-mode to recognize Vim-type foldmarkers {{{1 {{{2 {{{3
From: |
Teemu Likonen |
Subject: |
Re: outline-mode to recognize Vim-type foldmarkers {{{1 {{{2 {{{3 |
Date: |
Wed, 03 Dec 2008 14:59:32 GMT |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
Andreas Politz (2008-11-27 00:03 +0100) wrote:
> ;; vim outline
>
> Eval the next 2 expressions in the buffers context.
>
> ;; (set (make-local-variable 'outline-regexp) ".*{{{\\([0-9]+\\)")
> ;; (set (make-local-variable 'outline-level) 'vim-outline-level)
>
> (defun vim-outline-level ()
> (save-excursion
> (re-search-forward "{{{\\([0-9]+\\)" nil t)
> (string-to-number (match-string 1))))
Thanks again. I turned this idea into an interactive command which can
be called like "M-x set-vim-foldmarker RET {{{ RET" or from Lisp code.
It can helpful to add lines like these
(outline-minor-mode 1)
(set-vim-foldmarker "{{{")
to some filetype's hook, for example. Here's the function:
(defun set-vim-foldmarker (fmr)
"Set Vim-type foldmarkers for the current buffer"
(interactive "sSet local Vim foldmarker: ")
(when (not (equal fmr ""))
(set (make-local-variable 'outline-regexp)
(concat ".*" fmr "\\([0-9]+\\)"))
(set (make-local-variable 'outline-level)
`(lambda ()
(save-excursion
(re-search-forward
,(concat fmr "\\([0-9]+\\)") nil t)
(string-to-number (match-string 1)))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: outline-mode to recognize Vim-type foldmarkers {{{1 {{{2 {{{3,
Teemu Likonen <=