Hi Joon,
Joon Kwon <[email protected]> writes:
> I'm wondering if there is a simple way to make the buffer display
> theorem environements (for instance) in a nice way...
>
> For instance, if I have the following code :
> #+begin_theorem
> My theorem
> Bla bla bla
> #+end_theorem
>
> I would like the buffer to display something like :
>
> Theorem :
> | My theorem
> | Bla bla bla
> +----
(defun my-format-theorem-blocks ()
"Format theorem blocks in org."
(interactive)
(save-excursion
(goto-char (point-min))
(while (re-search-forward "#\\+begin_theorem" nil t)
(let ((beg0 (match-beginning 0))
(beg (1+ (match-end 0)))
(end0 (save-excursion
(re-search-forward "#\\+end_theorem" nil t)))
(end (match-beginning 0))
content c)
(setq content (split-string (buffer-substring beg end) "\n" t))
(delete-region beg0 end0)
(insert "Theorem :\n")
(while (setq c (pop content))
(insert (format " | %s\n" c)))
(insert " +----\n")))))
M-x my-format-theorem-blocks RET
But this in a one-way only... no return.
HTH,
--
Bastien