emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Defining macros globally


From: Charles C. Berry
Subject: Re: [O] Defining macros globally
Date: Mon, 19 Dec 2016 10:41:31 -0800
User-agent: Alpine 2.20 (OSX 67 2015-01-07)

On Mon, 19 Dec 2016, Nicolas Goaziou wrote:

Hello,

Arun Isaac <address@hidden> writes:

Is it possible to define macros globally, probably in the ~/.emacs init
file with some elisp, instead of on a per-file basis using the #+MACRO
keyword?

This is not possible ATM.

Perhaps the OP could do this?

#+BEGIN_SRC emacs-lisp
  (setq my-new-macros
        '(("def" . "d $1 e $2 f")
          ("ghi" . "GHI only")))

  (defun add-my-macros (&rest x)
    (nconc org-macro-templates my-new-macros))

  (advice-add 'org-macro-initialize-templates :filter-return
              #'add-my-macros)


#+END_SRC

Admittedly, this invites problems if `my-new-macros' is malformed. But there could be ways to impose a discipline that would assure that it is not.


HTH,

Chuck



reply via email to

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