emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Questions about using macro replacement
@ 2017-08-24  3:13 Joon Ro
  2017-08-26 21:44 ` Matt Price
  0 siblings, 1 reply; 3+ messages in thread
From: Joon Ro @ 2017-08-24  3:13 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 729 bytes --]

Hi,

I have several questions about macro replacement usage.

1. I saw people using {{{n}}} macros, which looks very useful, but I could not find it in current documentation about macro replacement (http://orgmode.org/manual/Macro-replacement.html). Is this only available in developmental version?

2. I was wondering if it is possible use macro expansion for :EXPORT_FILE_NAME: property of a subtree?

3. Is it possible to create a file link which uses macro? I would like to create a link to the exported pdf file dynamically. For example, if the value of :EXPORT_FILE_NAME: is exported, how would I create a link which automatically link to exported.pdf?

Any help would be greatly appreciated. Thank you!
Joon


[-- Attachment #2: Type: text/html, Size: 3596 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Questions about using macro replacement
  2017-08-24  3:13 Questions about using macro replacement Joon Ro
@ 2017-08-26 21:44 ` Matt Price
  2017-08-26 23:56   ` Joon Ro
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Price @ 2017-08-26 21:44 UTC (permalink / raw)
  To: Joon Ro; +Cc: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 1634 bytes --]

Answering without full knowledge!

On Wed, Aug 23, 2017 at 11:13 PM, Joon Ro <joon.ro@outlook.com> wrote:

> Hi,
>
> I have several questions about macro replacement usage.
>
> 1. I saw people using {{{n}}} macros, which looks very useful, but I could
> not find it in current documentation about macro replacement (
> http://orgmode.org/manual/Macro-replacement.html). Is this only available
> in developmental version?
>
> Yes, I'm pretty sure this has not been merged yet

2. I was wondering if it is possible use macro expansion
> for :EXPORT_FILE_NAME: property of a subtree?
>
Since macros can be set to expand to arbitrary elisp, I would think this
*should* be possible.  I forget the syntax but something like:

#+MACRO: efn (eval (get-export-file-name))

#+BEGIN_SRC emacs-lisp
(defun get-export-file-name ()
 (org-element-property :export-file-name (org-element--current-element) ))
#+END_SRC

* some heading
:PROPERTIES
:EXPORT_FILE_NAME: test-me
:END:

will get you somewhat close.  I don't understand the org-element api very
well though and it generally takes me a few tries to get this sort of thing
right.

3. Is it possible to create a file link which uses macro? I would like to
> create a link to the exported pdf file dynamically. For example, if the
> value of :EXPORT_FILE_NAME: is exported, how would I create a link which
> automatically link to exported.pdf?
>

I don't think a macro will do this for you since, if I understand
correctly, macros are not aware of the export target.  So probably you
would need some other mechanism to od this.

>
> Any help would be greatly appreciated. Thank you!
> Joon
>
>

[-- Attachment #2: Type: text/html, Size: 5238 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Questions about using macro replacement
  2017-08-26 21:44 ` Matt Price
@ 2017-08-26 23:56   ` Joon Ro
  0 siblings, 0 replies; 3+ messages in thread
From: Joon Ro @ 2017-08-26 23:56 UTC (permalink / raw)
  To: Matt Price; +Cc: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 1854 bytes --]

Answering without full knowledge!

Thank you so much for the reply - your reply gave me several ideas. I think Q1 and Q3 are solved, but I still have no idea how to do Q2 or if it is possible.


Q1, I figured it out and started using it - the {{{n}}} macros are awesome!

2. I was wondering if it is possible use macro expansion for :EXPORT_FILE_NAME: property of a subtree?
Since macros can be set to expand to arbitrary elisp, I would think this *should* be possible.  I forget the syntax but something like:

#+MACRO: efn (eval (get-export-file-name))

#+BEGIN_SRC emacs-lisp
(defun get-export-file-name ()
 (org-element-property :export-file-name (org-element--current-element) ))
#+END_SRC

* some heading
:PROPERTIES
:EXPORT_FILE_NAME: test-me
:END:

will get you somewhat close.  I don't understand the org-element api very well though and it generally takes me a few tries to get this sort of thing right.


With this one, I was actually looking for using macros inside :EXPORT_FILE_NAME: property. Ultimately what I want to do is:

* some heading
:PROPERTIES:
:EXPORT_FILE_NAME: {{{n('class',1)}}} test-me
:END:

However, it did not work, as the file name became literal {{{n('class',1)}}} test-me.pdf.



3. Is it possible to create a file link which uses macro? I would like to create a link to the exported pdf file dynamically. For example, if the value of :EXPORT_FILE_NAME: is exported, how would I create a link which automatically link to exported.pdf?

I don't think a macro will do this for you since, if I understand correctly, macros are not aware of the export target.  So probably you would need some other mechanism to od this.

I figured it out using elisp link:

elisp:(org-open-link-from-string (concat "file:./" (org-entry-get nil "EXPORT_FILE_NAME") ".pdf"))

Best Regards,
Joon

[-- Attachment #2: Type: text/html, Size: 8242 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-26 23:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-24  3:13 Questions about using macro replacement Joon Ro
2017-08-26 21:44 ` Matt Price
2017-08-26 23:56   ` Joon Ro

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).