From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joon Ro Subject: Questions about using macro replacement Date: Thu, 24 Aug 2017 03:13:19 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_BY2PR15MB04217BB07669D2F0D829F4C5EB9A0BY2PR15MB0421namp_" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48749) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dkiaD-00058b-G1 for emacs-orgmode@gnu.org; Wed, 23 Aug 2017 23:13:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dkia9-00045D-8m for emacs-orgmode@gnu.org; Wed, 23 Aug 2017 23:13:25 -0400 Received: from mail-oln040092011082.outbound.protection.outlook.com ([40.92.11.82]:7130 helo=NAM04-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dkia8-00044w-Uu for emacs-orgmode@gnu.org; Wed, 23 Aug 2017 23:13:21 -0400 Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: "emacs-orgmode@gnu.org" --_000_BY2PR15MB04217BB07669D2F0D829F4C5EB9A0BY2PR15MB0421namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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://orgmod= e.org/manual/Macro-replacement.html). Is this only available in development= al version? 2. I was wondering if it is possible use macro expansion for :EXPORT_FILE_N= AME: property of a subtree? 3. Is it possible to create a file link which uses macro? I would like to c= reate a link to the exported pdf file dynamically. For example, if the valu= e of :EXPORT_FILE_NAME: is exported, how would I create a link which automa= tically link to exported.pdf? Any help would be greatly appreciated. Thank you! Joon --_000_BY2PR15MB04217BB07669D2F0D829F4C5EB9A0BY2PR15MB0421namp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
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://orgmod= e.org/manual/Macro-replacement.html). Is this only available in development= al version?

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

3. Is it possible to create a file link which uses macro? I would like to c= reate 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

--_000_BY2PR15MB04217BB07669D2F0D829F4C5EB9A0BY2PR15MB0421namp_-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Price Subject: Re: Questions about using macro replacement Date: Sat, 26 Aug 2017 17:44:03 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a1143df4cdc81560557aef574" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:32843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dlisB-0001xQ-23 for emacs-orgmode@gnu.org; Sat, 26 Aug 2017 17:44:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dlis9-0008V9-Op for emacs-orgmode@gnu.org; Sat, 26 Aug 2017 17:44:07 -0400 Received: from mail-pf0-x22e.google.com ([2607:f8b0:400e:c00::22e]:33730) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dlis9-0008Ux-Fv for emacs-orgmode@gnu.org; Sat, 26 Aug 2017 17:44:05 -0400 Received: by mail-pf0-x22e.google.com with SMTP id r62so5247317pfj.0 for ; Sat, 26 Aug 2017 14:44:05 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Joon Ro Cc: "emacs-orgmode@gnu.org" --001a1143df4cdc81560557aef574 Content-Type: text/plain; charset="UTF-8" Answering without full knowledge! On Wed, Aug 23, 2017 at 11:13 PM, Joon Ro 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 > > --001a1143df4cdc81560557aef574 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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://or= gmode.org/manual/Macro-replacement.html). Is this only available i= n developmental version?

Yes, I'm pretty sure this has not bee= n merged yet

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

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

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

* some heading
<= div>:PROPERTIES
:EXPORT_FILE_NAME: test-me
:END:

will get you somewhat close.=C2=A0 I don't under= stand 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 c= reate a link to the exported pdf file dynamically.=C2=A0For example, if the value of=C2=A0:EXPOR= T_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 underst= and correctly, macros are not aware of the export target.=C2=A0 So probably= you would need some other mechanism to od this.

Any help would be greatly appreciated. Thank you!
Joon


--001a1143df4cdc81560557aef574-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joon Ro Subject: Re: Questions about using macro replacement Date: Sat, 26 Aug 2017 23:56:26 +0000 Message-ID: References: , Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_BY2PR15MB042112C787E69A87D46F2532EB980BY2PR15MB0421namp_" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dlkwK-0002qS-32 for emacs-orgmode@gnu.org; Sat, 26 Aug 2017 19:56:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dlkwH-00089t-0J for emacs-orgmode@gnu.org; Sat, 26 Aug 2017 19:56:32 -0400 Received: from mail-oln040092001038.outbound.protection.outlook.com ([40.92.1.38]:10160 helo=NAM01-BY2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dlkwG-00089M-Go for emacs-orgmode@gnu.org; Sat, 26 Aug 2017 19:56:28 -0400 In-Reply-To: Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Matt Price Cc: "emacs-orgmode@gnu.org" --_000_BY2PR15MB042112C787E69A87D46F2532EB980BY2PR15MB0421namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 po= ssible. 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_N= AME: property of a subtree? Since macros can be set to expand to arbitrary elisp, I would think this *s= hould* 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 w= ell 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 c= reate a link to the exported pdf file dynamically. For example, if the valu= e of :EXPORT_FILE_NAME: is exported, how would I create a link which automa= tically 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 so= me other mechanism to od this. I figured it out using elisp link: elisp:(org-open-link-from-string (concat "file:./" (org-entry-get nil "EXPO= RT_FILE_NAME") ".pdf")) Best Regards, Joon --_000_BY2PR15MB042112C787E69A87D46F2532EB980BY2PR15MB0421namp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Answering without full knowledge!

Thank you so much for the reply - your repl= y 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_F= ILE_NAME: property of a subtree?
Since macros can be set to expand to arbitrary elisp, I would think th= is *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-el= ement) ))
#+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 c= reate 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 corr= ectly, macros are not aware of the export target.  So probably you wou= ld need some other mechanism to od this. 

I figured it out using elisp link:

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

Best Regards,
Joon
--_000_BY2PR15MB042112C787E69A87D46F2532EB980BY2PR15MB0421namp_--