emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Multi-line noweb expansion in elisp insert form (Was Re: macro repla


From: Kaushal Modi
Subject: [O] Multi-line noweb expansion in elisp insert form (Was Re: macro replacement in code block?)
Date: Wed, 01 Nov 2017 16:04:55 +0000

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 <address@hidden> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]