From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi 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 Message-ID: References: <17470BC7-0FB7-458A-AE92-30EC6A7A303F@therogoffs.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a113e8036f02341055cee08eb" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9vVs-0001F9-1V for emacs-orgmode@gnu.org; Wed, 01 Nov 2017 12:05:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9vVq-0002sS-Jy for emacs-orgmode@gnu.org; Wed, 01 Nov 2017 12:05:08 -0400 Received: from mail-yw0-x22a.google.com ([2607:f8b0:4002:c05::22a]:56750) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e9vVq-0002sJ-EG for emacs-orgmode@gnu.org; Wed, 01 Nov 2017 12:05:06 -0400 Received: by mail-yw0-x22a.google.com with SMTP id l32so2225988ywh.13 for ; Wed, 01 Nov 2017 09:05:06 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-org list --001a113e8036f02341055cee08eb Content-Type: text/plain; charset="UTF-8" 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 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 "<>\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 "<>\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 --001a113e8036f02341055cee08eb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 do= n't have a fully working solution (see below). Hopefully someone can he= lp figure out the reason for "Invalid read syntax: #" error.
<= /div>

Below example Org file will work right away. But it will fail with th= e above error the moment second line (for more macros) is added to org-macr= os block.

Here's a mi= nimal working example to recreate that specific problem:

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

=3D=3D=3D=3D=3D

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

#+RE= SULTS:
#+MACRO: AA 1

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

<= /div>
#+RESULTS:
#+MACRO: BB 2
#+MACRO: CC 3
<= div>
* This works
#+NAME: works
#+BEGIN_S= RC emacs-lisp :var macro=3D"AA" :noweb yes :results raw :exports = none
(with-temp-buffer
=C2=A0 (insert "<<org= -macros-1-line>>\n")
=C2=A0 (insert (concat "{{{&= quot; macro "}}}"))
=C2=A0 (org-mode)
=C2=A0 = (org-macro-replace-all
=C2=A0 =C2=A0(append org-macro-templates o= rg-export-global-macros))
=C2=A0 (buffer-substring-no-properties = (point-min) (point-max)))
#+END_SRC
#+CALL: works()

* This does not work
#+NAME: noworky
<= div>#+BEGIN_SRC emacs-lisp :var macro=3D"BB" :noweb yes :results = raw :exports none
(with-temp-buffer
=C2=A0 (insert &quo= t;<<org-macros-2-lines>>\n")
=C2=A0 (insert &quo= t;// ---------------------------\n")
=C2=A0 (insert (concat = "{{{" macro "}}}"))
=C2=A0 (org-mode)
=C2=A0 (org-macro-replace-all
=C2=A0 =C2=A0(append org-macro-t= emplates org-export-global-macros))
=C2=A0 (buffer-substring-no-p= roperties (point-min) (point-max)))
#+END_SRC

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

when you = try to export (or even if you =3DC-c C-c=3D that =3Dnoworky=3D block.
=

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

=C2=A0
--

Kaushal Modi

--001a113e8036f02341055cee08eb--