all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Martin Steffen <msteffen@ifi.uio.no>
To: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: question about links, macros + org-publish and "parametrization"
Date: Thu, 30 May 2024 07:03:04 +0200	[thread overview]
Message-ID: <xk924jaf51tj.fsf@afram.ifi.uio.no> (raw)
In-Reply-To: <xk92mso83qio.fsf@afram.ifi.uio.no> (Martin Steffen's message of "Thu, 30 May 2024 05:52:31 +0200")



Hi,

maybe my email was premature. The combination of macros and links you
described is nice and useful for me (I did not much in the ways of
macros in org before). However, one aspect I am after seems not to work.

Your example was as follows, and it works:

--8<---------------cut here---------------start------------->8---
#+macro: link [[file:t.org][$1]]

#+macro: target {{{link($1)}}}

This is some text where I can look at {{{target(blah)}}}
--8<---------------cut here---------------end--------------->8---


There are 2 tweaks I had in mind in addition to your example, which
I can't get to work.

The first one is that the argument for the macro link should (also)
occur in the first part, a part of the link, not the text:

#+macro: source [[file:./$1/t.org][for the subdirectory  $1]]


That actually works, if one uses in the text

    {{{target(bla)}}}

that's great, but it leaves me replacing in the text many occurrences of
"bla" across many files.

The second tweak is that "bla" is a macro as well (centrally defined).
something like the following (modifing your example)

--8<---------------cut here---------------start------------->8---
#+macro: year 24
#+macro: source [[file:./$1/t.org][for the year $1]]
#+macro: target {{{source({{{year}}})}}}
--8<---------------cut here---------------end--------------->8---

Then of I call the macros

1)   {{{source(24)}}}   : that works, $1 is replaced both times
                          and the link points to file:./24/t.org

2) {{{source({{{year}}})}}}: that does not work 
3) {{{target}}}            : that does not work either


In both cases 2) and 3), the result of the macro expansion is the following (I
export to markdown)


    [for the year 24](./{{{year}}}/t.md)

-   [for the year 24](./{{{year}}}/t.md)

i.e, the argument  (intended to be 24) is properly replaced in ``text
part'' but not in the `` link'' part.


I don't know if I simply expect ``too much'' from the macro-expansion
facilities.... best, Martin




>>>>> "Martin" == Martin Steffen <msteffen@ifi.uio.no> writes:

>>>>> "Fraga," == Fraga, Eric <e.fraga@ucl.ac.uk> writes:

    Martin>     Fraga,> Hello,

    Martin>     Fraga,> I'm not entirely sure if I am missing something
    Martin> but, in case

    Martin> thanks, it was more that I was missing something. I tried to
    Martin> combine links and macros in a naive ways (without much
    Martin> studying the manual), so I thought perhaps nesting is not
    Martin> possible (or there is another way).

    Martin> Your suggestion solves my "problem" and makes the set-up a
    Martin> bit more "parametric" and easier to adapt, without that one
    Martin> forgets some bits, which is very nice.

    Martin> best, Martin



    Martin>     Fraga,> it helps, macros can themselves invoke other
    Martin> macros and Fraga,> macros can make use of [[target][desc]]
    Martin> syntax directly.  Fraga,> Can you not build up a hierarchy
    Martin> of macros that would Fraga,> achieve what you want, along
    Martin> these lines:

    Martin>     Fraga,> #+macro: link [[file:t.org][$1]]

    Martin>     Fraga,> #+macro: target {{{link($1)}}}

    Martin>     Fraga,> This is some text where I can look at
    Martin> {{{target(blah)}}}

    Martin>     Fraga,> HTH, eric

    Martin>     Fraga,> -- : Eric S Fraga, with org
    Martin> release_9.6.19-1230-g407a55 in Fraga,> Emacs 30.0.50


  reply	other threads:[~2024-05-30  5:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-28 10:02 question about links, macros + org-publish and "parametrization" Martin Steffen
2024-05-29  8:44 ` Fraga, Eric
2024-05-30  3:52   ` Martin Steffen
2024-05-30  5:03     ` Martin Steffen [this message]
2024-05-30  8:40       ` Fraga, Eric
2024-05-30 11:25         ` Martin Steffen
2024-05-30 16:28       ` Max Nikulin
2024-05-30 16:33         ` Ihor Radchenko
2024-05-31 10:29           ` Max Nikulin
2024-05-29 13:35 ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xk924jaf51tj.fsf@afram.ifi.uio.no \
    --to=msteffen@ifi.uio.no \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.