emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: Org-Mode mailing list <emacs-orgmode@gnu.org>
Subject: How to handle an inline multiline noweb reference
Date: Tue, 27 Nov 2018 10:45:38 +0100	[thread overview]
Message-ID: <87wooykg59.fsf@mbork.pl> (raw)

Hi folks,

I have a multiline source block (a complex sql query).  I'd like it to
be inserted into another (shell) source block, so that I can run psql on
a remote server (via ssh) and execute this query (I cannot access the
database from my machine).

I came up with this:

--8<---------------cut here---------------start------------->8---
#+name: sql_join
#+begin_src sql
  SELECT ... -- complicated, multiline query;
#+end_src

#+name: sql_oneline
#+begin_src elisp :noweb yes
  (replace-regexp-in-string "\n" " " "
<<sql_join>>" t t)
#+end_src

#+begin_src sh :noweb yes :results output verbatim
ssh user@host "psql connector -c '<<sql_oneline()>>'"
#+end_src
--8<---------------cut here---------------end--------------->8---

but it's fairly complicated.  Any better ideas?

TIA,

--
Marcin Borkowski
http://mbork.pl

             reply	other threads:[~2018-11-27  9:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-27  9:45 Marcin Borkowski [this message]
2018-11-28  2:08 ` How to handle an inline multiline noweb reference Grant Rettke
2018-11-28  2:33   ` Samuel Wales
2018-11-28  7:08     ` Eric S Fraga
2018-11-28 17:33       ` Grant Rettke
2018-11-28 22:35       ` Samuel Wales
2018-11-29  6:24         ` Eric S Fraga
2018-11-29 22:16           ` Samuel Wales
2018-11-29 22:18             ` Samuel Wales
2018-11-30  6:46               ` Eric S Fraga
2018-11-30  6:44             ` Eric S Fraga
2018-11-30 15:20       ` Marcin Borkowski
2018-11-30 17:23   ` Marcin Borkowski
2018-12-02  3:59     ` Grant Rettke

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=87wooykg59.fsf@mbork.pl \
    --to=mbork@mbork.pl \
    --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).