Skip to content

Export as org before generating #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hubisan opened this issue Jul 1, 2020 · 3 comments
Closed

Export as org before generating #3

hubisan opened this issue Jul 1, 2020 · 3 comments

Comments

@hubisan
Copy link
Contributor

hubisan commented Jul 1, 2020

Just an idea: It would be quite cool to export the subtree as org before generating the template with

(org-org-export-as-org &optional ASYNC SUBTREEP VISIBLE-ONLY BODY-ONLY EXT-PLIST)
(org-org-export-as-org nil t nil t)

This would make it possible to use a lot of additional org features. The following come in to my mind but there are certainly many more:


Macros

Use macros to replace text snippets during export.

* Project template
:PROPERTIES:
:package:     test
:END:
#+MACRO: macro-input (eval (completing-read "Type: " '("First" "Second") nil t "First"))
#+MACRO: poem Rose is $1, violet's $2. Life's ordered: Org assists you.
{{{poem(red,blue)}}}
{{{macro-input}}}
{{{property(package)}}}

This lets the user select from First and Second and exports as:

#+macro: macro-input (eval (completing-read "Type: " '("First" "Second") nil t "First"))
#+macro: poem Rose is $1, violet's $2. Life's ordered: Org assists you.
Rose is red, violet's blue. Life's ordered: Org assists you.
First
test

(only part disturbing is that the user-input macro is evaluated even if the expansion is not in the subtree, but could be solved by copying the subtree to another buffer first or whatever. Or of course let the user have an org file for each template.)


Include

Include other files:

#+INCLUDE: "~/dev/file-templates/GPLv3.txt"

Source block

Source block noweb

Include the code or the result of other source blocks with noweb.

An example with a simple named block and a shell source block:

#+NAME: year
: 2020

#+NAME: whoami
#+BEGIN_SRC sh
  whoami
#+END_SRC

* Subtree
#+BEGIN_SRC emacs-lisp :noweb yes
  ; by <<whoami()>> in <<year()>>
#+END_SRC

Exports to in my case:

#+begin_src emacs-lisp
  ; by hubisan in 2020
#+end_src

Macros could be used as variables for the source blocks as far as I know.

Inlines source blocks

this is some src_elisp[:results raw]{(concat "inline" "-" "code")}
> this is some inline-code

Call on separate line or inline

The source block called can even be located in another files.

#+CALL: file.org:whoami()
my username is call_file.org:whoami()
@conao3
Copy link
Owner

conao3 commented Jul 1, 2020

It seems very interesting! Do you want to send PR?

@hubisan
Copy link
Contributor Author

hubisan commented Jul 1, 2020

Will try to implement it, will take a while though as quite busy atm.

@conao3
Copy link
Owner

conao3 commented Jul 18, 2020

close with merging #10.

@conao3 conao3 closed this as completed Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants