* outline-mode to recognize Vim-type foldmarkers {{{1 {{{2 {{{3
@ 2008-11-26 19:46 Teemu Likonen
2008-11-26 23:03 ` Andreas Politz
0 siblings, 1 reply; 4+ messages in thread
From: Teemu Likonen @ 2008-11-26 19:46 UTC (permalink / raw)
To: help-gnu-emacs
Is it possible to configure outline-mode to recognize folding levels by
Vim-type foldmarkers? How? By default, Vim's foldmarker is {{{ and a
number after the marker defines the folding level, like this:
{{{1 (= first-level heading)
{{{2 (= second-level heading)
{{{3 (= third-level heading)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: outline-mode to recognize Vim-type foldmarkers {{{1 {{{2 {{{3
2008-11-26 19:46 outline-mode to recognize Vim-type foldmarkers {{{1 {{{2 {{{3 Teemu Likonen
@ 2008-11-26 23:03 ` Andreas Politz
2008-11-27 12:44 ` Teemu Likonen
2008-12-03 14:59 ` Teemu Likonen
0 siblings, 2 replies; 4+ messages in thread
From: Andreas Politz @ 2008-11-26 23:03 UTC (permalink / raw)
To: help-gnu-emacs
Teemu Likonen wrote:
> Is it possible to configure outline-mode to recognize folding levels by
> Vim-type foldmarkers? How? By default, Vim's foldmarker is {{{ and a
> number after the marker defines the folding level, like this:
>
> {{{1 (= first-level heading)
> {{{2 (= second-level heading)
> {{{3 (= third-level heading)
>
;; 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))))
-ap
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: outline-mode to recognize Vim-type foldmarkers {{{1 {{{2 {{{3
2008-11-26 23:03 ` Andreas Politz
@ 2008-11-27 12:44 ` Teemu Likonen
2008-12-03 14:59 ` Teemu Likonen
1 sibling, 0 replies; 4+ messages in thread
From: Teemu Likonen @ 2008-11-27 12:44 UTC (permalink / raw)
To: help-gnu-emacs
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, and nice to hear that it wasn't very difficult.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: outline-mode to recognize Vim-type foldmarkers {{{1 {{{2 {{{3
2008-11-26 23:03 ` Andreas Politz
2008-11-27 12:44 ` Teemu Likonen
@ 2008-12-03 14:59 ` Teemu Likonen
1 sibling, 0 replies; 4+ messages in thread
From: Teemu Likonen @ 2008-12-03 14:59 UTC (permalink / raw)
To: help-gnu-emacs
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)))))))
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-12-03 14:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-26 19:46 outline-mode to recognize Vim-type foldmarkers {{{1 {{{2 {{{3 Teemu Likonen
2008-11-26 23:03 ` Andreas Politz
2008-11-27 12:44 ` Teemu Likonen
2008-12-03 14:59 ` Teemu Likonen
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.