emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Vararg macros, and code block as macro?


From: Kaushal Modi
Subject: Re: [O] Vararg macros, and code block as macro?
Date: Thu, 26 Jul 2018 11:21:19 -0400

Hello Diego,

I can try to answer your second question.

On Thu, Jul 26, 2018 at 10:35 AM Diego Zamboni <address@hidden> wrote:

2. Related to my workaround above, I am wondering if there's a way to refer to a source block as the macro definition. At the moment I just joined my whole elisp block into a single line for the macro definition, but I would love to have it in a proper source block so I can edit it properly, have indentation and syntax highlighting, etc.

How about adding this to your emacs config:

(defun my/org-macro-keys-code (str)
  "Split STR at spaces and wrap each element with `~' char, separated by `+'."
  (mapconcat (lambda (s)
               (concat "~" s "~"))
             (split-string str)
             (concat (string ?\u200B) "+" (string ?\u200B))))

Make sure that that always evaluates before you do Org exports, and then simply use this in your Org files:

#+macro: keys (eval (my/org-macro-keys-code $1))
{{{keys("Ctrl c Ctrl e H H")}}}

PS: Thanks for sharing that code! You are following the vision of ox-hugo.. replacing Hugo shortcodes with Org macros :+1: :)
--

Kaushal Modi


reply via email to

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