Hello,

On 2015-11-20 11:41, Rasmus <ras...@gmx.us> writes:

> Alan Schmitt <alan.schm...@polytechnique.org> writes:
>
>> I was wondering if someone had been able to reproduce this, and if so
>> should I file it as a bug?
>
> Sure.  It's how org-latex-src-block handles custom environments (see "Case
> 2.").  At the moment this is hardcoded.

I've started to look into this, and I would like some advice regarding
the design of the solution.

What I propose is to have either a string or a function in
`org-latex-custom-lang-environments'. A string would be used as it is
currently, whereas a function would be applied. Here is what it could
look like:

#+begin_src emacs-lisp
;; Case 2.  Custom environment.
(custom-env
(let ((caption-str (org-latex--caption/label-string src-block info))
       (formatted-src (org-export-format-code-default src-block info)))
   (cond
    ((stringp custom-env) (format "\\begin{%s}\n%s\\end{%s}\n"
                                  custom-env
                                  (concat (and caption-above-p caption-str)
                                          formatted-src
                                          (and (not caption-above-p) 
caption-str))
                                  custom-env))
    ((functionp custom-env) (funcall custom-env
                                     formatted-src
                                     (org-latex--label src-block info)))
    (t (user-error "`org-latex-custom-lang-environments' should map %s to 
either a string or a function" lang)))))
#+end_src

My main design question is what the arguments to the function should be.
I thought the formatted source code and label would work, but I'm
wondering if it may be better to simply give the `src-block' and `info'
arguments directly.

WDYT?

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7
Athmospheric CO₂ (Updated November 22, 2015, Mauna Loa Obs.): 400.35 ppm

Attachment: signature.asc
Description: PGP signature

Reply via email to