From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id +EltKHUo6l4icwAA0tVLHw (envelope-from ) for ; Wed, 17 Jun 2020 14:28:05 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id D/NaJHUo6l7ZVwAA1q6Kng (envelope-from ) for ; Wed, 17 Jun 2020 14:28:05 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id EA2669404D3 for ; Wed, 17 Jun 2020 14:28:04 +0000 (UTC) Received: from localhost ([::1]:36464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jlZ2o-0000IF-GY for larch@yhetil.org; Wed, 17 Jun 2020 10:28:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jlYzE-00040T-2Y for emacs-orgmode@gnu.org; Wed, 17 Jun 2020 10:24:20 -0400 Received: from mail-qv1-xf30.google.com ([2607:f8b0:4864:20::f30]:38193) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jlYzC-0005Zy-0H for emacs-orgmode@gnu.org; Wed, 17 Jun 2020 10:24:19 -0400 Received: by mail-qv1-xf30.google.com with SMTP id ec10so1085053qvb.5 for ; Wed, 17 Jun 2020 07:24:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=AXzkJxA7FB3vXpbO0Gcxal2Kx5X7FvV7hky3xOlSXVY=; b=O6OeQhNAbt4wDtnkGdtdmawdJe9h7joMr5jbDuUUcDHfrAL6Plf1mbgzy0xRDv2vs5 53qaN2zBitgjPUOXFAiIn9YRO6rSOJ8zM6LQ90CQywkw/7CnHSemihFq3GFSVMb0fhl9 UBF+yX4sW5BeGwa+3T1DzW3DjMlmDZUbwVzX4OIO5gYN3w9Jl7Um33vAo+M+J5KOgKhG NLOCEi17TFoKMSPy8UKrNdWAgIOPBrtpD/Y2JJsx5OkbWWP6YWEWVaHfcxY/9mzeDWhI q+snpc3ZcroWSHq0BAqeI0FEdwed79SoaHr+fYcGqeT6Th/zuP/gLHvZm8R0xO9HCd1D cmSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=AXzkJxA7FB3vXpbO0Gcxal2Kx5X7FvV7hky3xOlSXVY=; b=aCbRnM3Sq1lpQ/wN2gslCR9Bsg5XNJehAz/zHiYgvSVMRmnfLJ0tZI9VLD6Wl/0qBD n/2s8IkUuopP6sEy7h2Ei/D/0UMV6PxBS4lroPZ3OQbqKQaG1JlLTI7qnSKt6Of3XdEa +IOGCEBKe2/jcP4L068+KIf9Brvafxd6fiHoAjqHakj3gmDH/QiOSCNrH9bQD/Gaxgoi MkuWlgqhAutGysVIv81j0giZkL/FbAo7aVlCnpcGlmAy1+K595njm8hEbD7qA9eQEpB7 J7K3Gazu+q/ZvcSKCFPhI6asmfMYO1pB+4qP2KUQn+Q7s4kzl6FygIVE8pD7Zzy5qrfP GTWA== X-Gm-Message-State: AOAM533K+cJiVYu7rutFvRCHY9gN6hh+fHOBELngpFIM2CDgr7impZ6R cCt26emW1HfxyU4m5uolVhtoJKOecEePkPNN0bY9ON5T X-Google-Smtp-Source: ABdhPJxNR+oCVhowOO7+vJii5CXDdOZqaU/lxWcRzN4vsZytcWpQBUBBX4s1QBbwAnfoPT3/+aLZVDHkICNRNUgn6Kc= X-Received: by 2002:ad4:494c:: with SMTP id o12mr7997929qvy.102.1592403856551; Wed, 17 Jun 2020 07:24:16 -0700 (PDT) MIME-Version: 1.0 References: <20200616112110.5646866fc6589d2b12f3646f@gmail.com> In-Reply-To: <20200616112110.5646866fc6589d2b12f3646f@gmail.com> From: Salomon Turgman Date: Wed, 17 Jun 2020 10:23:50 -0400 Message-ID: Subject: Re: Import Reusable org-babel snippet using #+SETUPFILE To: org mode Content-Type: multipart/alternative; boundary="00000000000035778f05a8486a58" Received-SPF: pass client-ip=2607:f8b0:4864:20::f30; envelope-from=sturgman@gmail.com; helo=mail-qv1-xf30.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=O6OeQhNA; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.71 X-TUID: zzeZXEufxxls --00000000000035778f05a8486a58 Content-Type: text/plain; charset="UTF-8" Hey Doug, What types of things are in GeneralORGTools.org? Are those babel definitions? Or something else? -s- On Tue, Jun 16, 2020 at 11:21 AM Salomon Turgman wrote: > Thanks for the useful example. I will take a look. Didn't know about > org-sbe! > > -s- > > On Mon, 15 Jun 2020 15:52:16 -0400 > Douglas Perrin wrote: > > > Hi Salomon Turgman, > > I do this a lot and have had success using a combination of #+SETUPFILE > to > > bring in names and configuration, and org-sbe to do initialization. I mix > > emacs vars and org names in my source headers with back quoting. > > > > The following example has a template file containing user/local > > information. This is brought into the example file, on load, through > #:eval > > calling org-babel-lob-ingest and org-sbe, in addition, parameters are > > pulled in with #+SETUPFILE and the same template file name. The end > result > > for this example is a running docker image with access to local paths and > > "remote" execution via tramp. More complex orchestration and actions in > the > > template are certainly possible using org-sbe calls in the init elisp > > source blocks but hopefully, this shows the flavor of what can be done. > > > > In addition to avoiding code duplication, I have found this to be very > > effective when my group is all working from the same org file (via git) > but > > everyone has their own template file with credentials, local paths, and > org > > more preferences (ie showstars). > > Regards, > > Doug > > > > > --------------------------------------------------------------------------------------------------------------------------------- > > TemplatingExample.org > > > --------------------------------------------------------------------------------------------------------------------------------- > > #+SETUPFILE: Template-Loader.org > > > > * Init Code, run when file is opened > > #+name: Execute-On-Load > > #+begin_src elisp :results output > > ;; for this the container and image have the same name > > (setq *DockerName* "ContanerName") > > #+end_src > > > > * Run Contaner > > #+begin_src bash :results raw drawer :var DockerName=`,*DockerName* > > DockerHubUID=`,*DockerHubUID* containerName=`,*DockerContainer* > > LocalWorkPath=`,*LocalWorkPath* LocalDataPath=`,*LocalDataPath* > > docker run --rm -d \ > > -v $LocalWorkPath:/root/Workdir \ > > -v $LocalDataPath:/root/Data \ > > --name $DockerName $DockerHubUID/$DockerName bash -c "tail -f > > /dev/null" > > #+end_src > > > > * run IN contaner > > #+begin_src bash :results output :dir (concat "/docker:" `,*DockerName* > > ":/root/Workdir/") > > ls > > #+end_src > > > > # Local Variables: > > # eval: (org-babel-lob-ingest "Template-Loader.org") > > # eval: (org-sbe "Init-Template") > > # eval: (org-sbe "Execute-On-Load") > > # End: > > > > > --------------------------------------------------------------------------------------------------------------------------------- > > Template-Loader.org > > > --------------------------------------------------------------------------------------------------------------------------------- > > #+STARTUP: showstars > > #+PROPERTY: header-args :mkdirp yes > > > > #+name: Init-Template > > #+begin_src emacs-lisp :results none > > ;; This is called expecitly via org-sbe in the buffer that will uses > the > > templating > > (setq *DockerHubUID* "MyUserName") > > (setq *LocalWorkPath* "/run/desktop/mnt/host/c/Users/.....") > > (setq *LocalDataPath* "/run/desktop/mnt/host/d/devData/") > > > > ;; ingest + SBE can be used to bring in a hierarchy of templates > > (org-babel-lob-ingest "./GroupTools/GeneralORGTools.org") > > (org-sbe "GeneralORGTools.org") > > > > #+end_src > > > -- > Salomon Turgman > --00000000000035778f05a8486a58 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hey Doug,

What types of thin= gs are in GeneralORGTools.org? Are those babel definitions? Or something el= se?

-s-

On Tue, Jun 16, 2020 at 11:21 AM = Salomon Turgman <sturgman@gmail.co= m> wrote:
Thanks for the useful example. I will take a look. Didn't know about o= rg-sbe!

-s-

On Mon, 15 Jun 2020 15:52:16 -0400
Douglas Perrin <= doug2024@gmail.com> wrote:

> Hi Salomon Turgman,
> I do this a lot and have had success using a combination of #+SETUPFIL= E to
> bring in names and configuration, and org-sbe to do initialization. I = mix
> emacs vars and org names in my source headers with back quoting.
>
> The following example has a template file containing user/local
> information. This is brought into the example file, on load, through #= :eval
> calling org-babel-lob-ingest and org-sbe, in addition, parameters are<= br> > pulled in with #+SETUPFILE and the same template file name. The end re= sult
> for this example is a running docker image with access to local paths = and
> "remote" execution via tramp. More complex orchestration and= actions in the
> template are certainly possible using org-sbe calls in the init elisp<= br> > source blocks but hopefully, this shows the flavor of what can be done= .
>
> In addition to avoiding code duplication, I have found this to be very=
> effective when my group is all working from the same org file (via git= ) but
> everyone has their own template file with credentials, local paths, an= d org
> more preferences (ie showstars).
> Regards,
> Doug
>
> ----------------------------------------------------------------------= -----------------------------------------------------------
> TemplatingExample.org
> ----------------------------------------------------------------------= -----------------------------------------------------------
> #+SETUPFILE: Template-Loader.org
>
> * Init Code, run when file is opened
> #+name: Execute-On-Load
> #+begin_src elisp=C2=A0 :results output
>=C2=A0 =C2=A0 ;; for this the container and image have the same name >=C2=A0 =C2=A0 =C2=A0(setq *DockerName* "ContanerName")
> #+end_src
>
> * Run Contaner
> #+begin_src bash=C2=A0 :results raw drawer :var DockerName=3D`,*Docker= Name*
> DockerHubUID=3D`,*DockerHubUID* containerName=3D`,*DockerContainer* > LocalWorkPath=3D`,*LocalWorkPath* LocalDataPath=3D`,*LocalDataPath* >=C2=A0 =C2=A0 docker run --rm -d \
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-v $LocalWorkPath:/root/Workdi= r \
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-v $LocalDataPath:/root/Data \=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0--name $DockerName $DockerHubU= ID/$DockerName bash -c "tail -f
> /dev/null"
>=C2=A0 =C2=A0#+end_src
>
> * run IN contaner
> #+begin_src bash=C2=A0 :results output :dir (concat "/docker:&quo= t; `,*DockerName*
> ":/root/Workdir/")
> ls
> #+end_src
>
> # Local Variables:
> # eval: (org-babel-lob-ingest "Template-Loader.org")
> # eval: (org-sbe "Init-Template")
> # eval: (org-sbe "Execute-On-Load")
> # End:
>
> ----------------------------------------------------------------------= -----------------------------------------------------------
> Template-Loader.org
> ----------------------------------------------------------------------= -----------------------------------------------------------
> #+STARTUP: showstars
> #+PROPERTY: header-args :mkdirp yes
>
> #+name: Init-Template
> #+begin_src emacs-lisp :results none
>=C2=A0 =C2=A0;; This is called expecitly via org-sbe in the buffer that= will uses the
> templating
>=C2=A0 =C2=A0 =C2=A0(setq *DockerHubUID* "MyUserName")
>=C2=A0 =C2=A0 =C2=A0(setq *LocalWorkPath* "/run/desktop/mnt/host/c= /Users/.....")
>=C2=A0 =C2=A0 =C2=A0(setq *LocalDataPath* "/run/desktop/mnt/host/d= /devData/")
>
>=C2=A0 =C2=A0;; ingest + SBE can be used to bring in a hierarchy of tem= plates
>=C2=A0 =C2=A0(org-babel-lob-ingest "./GroupTools/GeneralORGTools.o= rg")
>=C2=A0 =C2=A0(org-sbe "GeneralORGTools.org")
>
> #+end_src


--
Salomon Turgman <sturgman@gmail.com>
--00000000000035778f05a8486a58--