emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Charles C. Berry" <ccberry@ucsd.edu>
To: Eric S Fraga <e.fraga@ucl.ac.uk>
Cc: emacs-orgmode@gnu.org
Subject: Re: order of evaluation upon export: macros are evaluated too soon
Date: Wed, 7 Jun 2017 11:43:02 -0700	[thread overview]
Message-ID: <alpine.OSX.2.20.1706071140310.21528@charles-berrys-macbook.local> (raw)
In-Reply-To: <874lvriyuv.fsf@delle7240.chemeng.ucl.ac.uk>

On Wed, 7 Jun 2017, Eric S Fraga wrote:

> Hello all,
>
> I have a document with this (ECM) structure:
>
> #+begin_src org
>  ,#+macro: item I{{{n(i)}}}@@latex:}%@@
>  ,#+options: toc:nil num:nil
>
>  ,* {{{item()}}} Some topic
>  ,* {{{item()}}} Another topic                                  :noexport:
>  ,* {{{item()}}} A final one
> #+end_src
>
> I would like the exported headings to be numbered Q1, Q2, ... but only
> the exported ones.


Maybe implement somethng like this:


#+BEGIN_SRC emacs-lisp
   (defun n-noexport (x y)
     (let ((tags (nth 5 (org-heading-components))))
       (unless (and tags
 		   (string-match ":noexport:" tags))
 	(org-macro--counter-increment x y))))
#+END_SRC

#+MACRO: n2 (eval (n-noexport "$1" "$2"))


* heading 1

{{{n2()}}}


* heading 2                                                :noexport:notever:

{{{n2()}}}

* heading 3
{{{n2()}}}


HTH,

Chuck

  reply	other threads:[~2017-06-07 18:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-07 15:47 order of evaluation upon export: macros are evaluated too soon Eric S Fraga
2017-06-07 18:43 ` Charles C. Berry [this message]
2017-06-07 19:56   ` Nicolas Goaziou
     [not found]   ` <e995e3bb8ecb466ba85e8be925f1a72b@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-06-08 11:43     ` Eric S Fraga
2017-06-08 12:36       ` Nicolas Goaziou
     [not found]       ` <62ad9bab51254374aaa68b4ef0fd0b29@DB5PR01MB1895.eurprd01.prod.exchangelabs.com>
2017-06-10 10:44         ` Eric S Fraga
     [not found] ` <51249f80b2dc43118f5855b8d0ce737e@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2017-06-08 11:39   ` Eric S Fraga

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=alpine.OSX.2.20.1706071140310.21528@charles-berrys-macbook.local \
    --to=ccberry@ucsd.edu \
    --cc=e.fraga@ucl.ac.uk \
    --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).