emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Nice theorem display ?


From: Bastien
Subject: Re: [O] Nice theorem display ?
Date: Tue, 07 Aug 2012 23:38:22 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux)

Hi Joon,

Joon Kwon <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]