all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: Daniel Clemente <n142857@gmail.com>
Cc: org-mode Mailinglist <emacs-orgmode@gnu.org>
Subject: Re: macros which expand to other macros
Date: Thu, 3 Sep 2009 08:50:31 +0200	[thread overview]
Message-ID: <0668E2B8-079C-4040-BD9B-ED84523C3A7E@gmail.com> (raw)
In-Reply-To: <87ab1d6nnl.fsf@gmail.com>

Hi Daniel,

I have applied the patch, thanks.  I used the more restrictive version  
without
allowing partial macros.  Seems a bit wired to me.  Or can someone come
up with a compelling use case?

- Carsten

On Sep 2, 2009, at 11:29 PM, Daniel Clemente wrote:

>
> 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."
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

      reply	other threads:[~2009-09-03  6:50 UTC|newest]

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

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=0668E2B8-079C-4040-BD9B-ED84523C3A7E@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=n142857@gmail.com \
    /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.