emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Daniel Clemente <n142857@gmail.com>
To: org-mode Mailinglist <emacs-orgmode@gnu.org>
Subject: macros which expand to other macros
Date: Wed, 02 Sep 2009 23:29:34 +0200	[thread overview]
Message-ID: <87ab1d6nnl.fsf@gmail.com> (raw)


Hi.

  I want to include a note in several pages, therefore I created a #+MACRO for it. The macro must say „This file is best viewed when you open file {{{input-file}}} in org-mode (Emacs).“, where {{{input-file}}} would be expanded to the name of the file being expanded.
  Then I noticed that macros can't expand to other macros. This means:

#+MACRO: uno 1
#+MACRO: one {{{uno}}}
{{{uno}}} works (1) but {{{one}}} should also be 1, not {{…uno}}}


  I attach a patch [1] which adds support for macros which expand to other macros, so the previous examples would work.

  It would of course get locked if you wanted macros like #+MACRO: recu {{{recu}}}, but that's apparently the intended behaviour :-)

  It will even work for macros that create parts of other macros.

#+MACRO: cc1 100001
#+MACRO: cc2 100002
#+MACRO: mycc-start {{{cc
#+MACRO: mycc-end 2}}}
Yes, it is {{{mycc-start}}}{{{mycc-end}}}.
And even:
#+MACRO: mycc {{{mycc-start}}}{{{mycc-end}}}
{{{mycc}}}.

  (100002 in both cases).
  If this is too complex, this partial macro writing can be disallowed by changing the (beginning-of-line) to a (goto-char (match-beginning 0)).


-- Daniel


[1]

diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 3e12e6a..3d2fad8 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -2106,7 +2106,7 @@ TYPE must be a string, any of:
 	  (if (and val (not (stringp val)))
 	      (setq val (format "%s" val))))
 	(and (stringp val)
-	     (replace-match val t t))))))
+	     (prog1 (replace-match val t t) (beginning-of-line)))))))
 
 (defun org-export-apply-macros-in-string (s)
   "Apply the macros in string S."

             reply	other threads:[~2009-09-02 21:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-02 21:29 Daniel Clemente [this message]
2009-09-03  6:50 ` macros which expand to other macros Carsten Dominik

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

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87ab1d6nnl.fsf@gmail.com \
    --to=n142857@gmail.com \
    --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 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).