Define org mode macro with line breaks

前端 未结 4 1673
后悔当初
后悔当初 2021-02-07 07:20

It is possible to define a macro in an org file as follow:

#+MACRO: macroname 

Is it possi

4条回答
  •  面向向阳花
    2021-02-07 07:50

    There is another solution which seems to work correctly. From org-macro.el source code:

    ;; VALUE starts with "(eval": it is a s-exp, `eval' it.
            (when (string-match "\\`(eval\\>" value)
              (setq value (eval (read value))))
    

    Thus, you may define macro like this:

    #+MACRO: newline (eval "\n")
    

    Substitutions are also supported. The macro

    #+MACRO: img (eval "#+CAPTION: $1\nfile:$2")
    

    which is called as

    {{{img(hello world!, ./img1.jpg)}}}
    

    will be replaced with:

    #+CAPTION: hello world!
    file:./img1.jpg
    

提交回复
热议问题