emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] [PATCH] `org-macro--collect-macros' can collect macro definition


From: Fabrice Niessen
Subject: Re: [O] [PATCH] `org-macro--collect-macros' can collect macro definitions from include files
Date: Wed, 05 Feb 2014 21:11:37 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)


Hello,

Nicolas Goaziou wrote:
> Bastien <address@hidden> writes:
>> "Fabrice Niessen" writes:
>>
>>> As the DOCSTRING of the function `org-macro--collect-macros' tells it,
>>> it "collects macro definitions in current buffer and setup files", not
>>> from INCLUDE files.
>>
>> Then your patch should change the docstring too.

Right!

>> I think we want to collect macros from setupfile only,
>> that's one of the differences between INCLUDE and SETUPFILE.
>
> I agree.
>
> Not all "Include" files are Org files.

OK, but that shouldn't be a problem either: if there is no #+MACRO in an
"Include" file, that doesn't matter...

> Moreover, "INCLUDE" keywords are expanded before initializing macro
> templates during export, so "MACRO" keywords should be read when
> appropriate.

You say that the order of operations, during export, is:

- Include files through "INCLUDE" keywords
- Expand macros

OK. Still, I don't understand what you mean by "so MACRO keywords should
be read when appropriate"?

Anyway, let me explain what I wish such a feature (_or_ the opposite:
that Babel blocks are allowed in SETUPFILE)...

I'm sharing on GitHub a project [1] where I write Org macros that
everybody could once need, and these are easily accessible (once cloned)
in every file, after a simple directive such as:

  #+INCLUDE: /path/to/org-macros.setup

As I do have Babel code blocks inside the `org-macros.setup' file, it
needs to be loaded via the "INCLUDE" directive, not via a "SETUPFILE".

Example of such macro calling a Babel code block:

  ╭────
  │ #+name: version-history
  │ #+begin_src sh :exports none :results silent :colnames '(Version Date 
Author Comment)
  │ git log --pretty=format:"%h%x09%ad%x09%an%x09%s" --date=short | head -n 5
  │ #+end_src
  │
  │ #+MACRO: version-history call_version-history[:eval yes]()[:eval yes 
:results table :colnames '(Version Date Author Comment)]
  ╰────

So, thanks to the INCLUDE directive, I already have a one-liner to
include such "extended macros". But these aren't collected by
`org-macro--collect-macros'...

Best regards,
Fabrice

[1] https://github.com/fniessen/org-macros

-- 
Fabrice Niessen
Leuven, Belgium
http://www.pirilampo.org/




reply via email to

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