emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: Rasmus <rasmus@gmx.us>
Cc: emacs-orgmode@gnu.org
Subject: Re: interaction between org-latex-custom-lang-environments and name when exporting to latex
Date: Mon, 23 Nov 2015 12:13:06 +0100	[thread overview]
Message-ID: <m28u5p3r5p.fsf@charm-ecran.irisa.fr> (raw)
In-Reply-To: <877fld3qcr.fsf@gmx.us> (rasmus@gmx.us's message of "Fri, 20 Nov 2015 11:41:24 +0100")

[-- Attachment #1: Type: text/plain, Size: 1948 bytes --]

Hello,

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

> Alan Schmitt <alan.schmitt@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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

  parent reply	other threads:[~2015-11-23 11:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-16 12:59 interaction between org-latex-custom-lang-environments and name when exporting to latex Alan Schmitt
2015-11-20  7:55 ` Alan Schmitt
2015-11-20 10:41   ` Rasmus
2015-11-20 11:06     ` Alan Schmitt
2015-11-23 11:13     ` Alan Schmitt [this message]
2015-11-23 17:54       ` Rasmus
2015-11-24  8:07         ` Alan Schmitt
2015-11-24 13:14           ` Rasmus
2015-11-25  7:59             ` Alan Schmitt
2015-11-25  9:57               ` Rasmus
2015-11-27 16:27                 ` Alan Schmitt
2015-11-27 21:05                   ` Rasmus
2015-11-30 12:12                     ` Alan Schmitt
2015-11-30 13:11                       ` Rasmus
2015-12-01  8:14                         ` Alan Schmitt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m28u5p3r5p.fsf@charm-ecran.irisa.fr \
    --to=alan.schmitt@polytechnique.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=rasmus@gmx.us \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).