emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: emacs-org list <emacs-orgmode@gnu.org>
Subject: Multi-line noweb expansion in elisp insert form (Was Re: macro replacement in code block?)
Date: Wed, 01 Nov 2017 16:04:55 +0000	[thread overview]
Message-ID: <CAFyQvY1FhjrTU6OaG+rR2=PKPg60J9RNEuFfXu7f=EaS4dEyuA@mail.gmail.com> (raw)
In-Reply-To: <CAFyQvY0kaqOUvgF6RZkhZBt7Nas8jYbqS9Wt4UHS0XYzJjb0DQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2069 bytes --]

Hello all,

While trying to come up with a solution for this problem[1], I ended up
with a new problem :)

On Wed, Nov 1, 2017 at 11:51 AM Kaushal Modi <kaushal.modi@gmail.com> wrote:

> I still don't have a fully working solution (see below). Hopefully someone
> can help figure out the reason for "Invalid read syntax: #" error.
>
> Below example Org file will work right away. But it will fail with the
> above error the moment second line (for more macros) is added to org-macros
> block.
>

Here's a minimal working example to recreate that specific problem:

- The problem is seen when you C-c C-c the "noworky" block.

=====

#+BEGIN_SRC org :noweb-ref org-macros-1-line :results output replace
:exports none
,#+MACRO: AA 1
#+END_SRC

#+RESULTS:
#+MACRO: AA 1

#+BEGIN_SRC org :noweb-ref org-macros-2-lines :results output replace
:exports none
,#+MACRO: BB 2
,#+MACRO: CC 3
#+END_SRC

#+RESULTS:
#+MACRO: BB 2
#+MACRO: CC 3

* This works
#+NAME: works
#+BEGIN_SRC emacs-lisp :var macro="AA" :noweb yes :results raw :exports none
(with-temp-buffer
  (insert "<<org-macros-1-line>>\n")
  (insert (concat "{{{" macro "}}}"))
  (org-mode)
  (org-macro-replace-all
   (append org-macro-templates org-export-global-macros))
  (buffer-substring-no-properties (point-min) (point-max)))
#+END_SRC
#+CALL: works()

* This does not work
#+NAME: noworky
#+BEGIN_SRC emacs-lisp :var macro="BB" :noweb yes :results raw :exports none
(with-temp-buffer
  (insert "<<org-macros-2-lines>>\n")
  (insert "// ---------------------------\n")
  (insert (concat "{{{" macro "}}}"))
  (org-mode)
  (org-macro-replace-all
   (append org-macro-templates org-export-global-macros))
  (buffer-substring-no-properties (point-min) (point-max)))
#+END_SRC

If you uncomment the below =#+CALL= line, you will get:
#+BEGIN_EXAMPLE
org-babel-execute:emacs-lisp: Invalid read syntax: "#"
#+END_EXAMPLE

when you try to export (or even if you =C-c C-c= that =noworky= block.

# #+CALL: noworky()
=====

[1]: http://lists.gnu.org/archive/html/emacs-orgmode/2017-11/msg00007.html

-- 

Kaushal Modi

[-- Attachment #2: Type: text/html, Size: 3523 bytes --]

  reply	other threads:[~2017-11-01 16:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-31 23:13 macro replacement in code block? David Rogoff
2017-11-01  0:32 ` Kaushal Modi
2017-11-01  3:21   ` David Rogoff
2017-11-01 15:51     ` Kaushal Modi
2017-11-01 16:04       ` Kaushal Modi [this message]
2017-11-01 16:17       ` Kaushal Modi
2017-11-01 17:32         ` David Rogoff
2017-11-01 18:48           ` Kaushal Modi

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='CAFyQvY1FhjrTU6OaG+rR2=PKPg60J9RNEuFfXu7f=EaS4dEyuA@mail.gmail.com' \
    --to=kaushal.modi@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).