[emacs-berlin] exporting org-babel code blocks verbatim

Stefano Rodighiero stefano.rodighiero at gmail.com
Fri Sep 27 08:12:46 UTC 2019


Hi Gary,

first idea that came to my mind is using the threading macro
(to my knowledge, this idiom has its origins in the Clojure
community, and it was then ported to Emacs Lisp; it is
defined in `dash.el`).

Here is how `my-html-src-block` could look like using it:

```
(require 'dash)

(defun larsen-my-html-src-block (src-block contents info)
  (let ((expanded-src-block (org-export-expand src-block contents t)))
    (org-html-src-block
     (-> (org-element-copy src-block)
         (org-element-put-property :language "org")
         (org-element-put-property :value expanded-src-block))
     contents info)))
```

You can notice I "lifted" the application of `org-html-src-block`,
and I removed all occurrences of the symbol `src-block-copy`:
thanks to the `->`, the value of the expression
`(org-element-copy src-block)` is used as first argument the
first time `org-element-put-property` is used, then the value
returned by it is injected as first parameter in the second (and last)
use of `org-element-put-property`.

I didn't test this extensively, but running it on a small org
file seems to be working fine. Let me know, I hope it helps.

I guess it's a matter of taste: one has to carefully inspect the
context (and know the idiom!) to figure out there is actually
no missing argument for `org-element-put-property`.

s.


On Thu, Sep 26, 2019 at 5:15 PM Gary Phillips <gary.phillips at rolmo.com>
wrote:

> Hi all,
> I enjoyed yesterday’s meeting.
> Thanks for letting me share my esoteric org-mode discoveries yesterday.
> The attached org file contains elisp which implements the exporter.
> Tillman was right to suspect my use of setq, at best it’s bad style so I
> fixed that.
> Cheers
> Gary
>
> _______________________________________________
> emacs-berlin mailing list
> emacs-berlin at emacs-berlin.org
> https://mailb.org/mailman/listinfo/emacs-berlin
>


-- 
www.stefanorodighiero.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailb.org/pipermail/emacs-berlin/attachments/20190927/22659fe4/attachment.html>


More information about the emacs-berlin mailing list