From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bob Heffernan Newsgroups: gmane.emacs.help Subject: Org mode & "literate programming": including files Date: Tue, 6 Apr 2021 19:38:52 +0100 Message-ID: <20210406183852.67ucwze6yxugvgrl@bob-nuc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12577"; mail-complaints-to="usenet@ciao.gmane.io" To: Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 06 20:44:28 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lTqgd-00039j-T0 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 06 Apr 2021 20:44:27 +0200 Original-Received: from localhost ([::1]:37506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTqgc-00031g-Qx for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 06 Apr 2021 14:44:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTqbS-0000pn-Mj for help-gnu-emacs@gnu.org; Tue, 06 Apr 2021 14:39:06 -0400 Original-Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:42646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lTqbP-0004qi-2S for help-gnu-emacs@gnu.org; Tue, 06 Apr 2021 14:39:06 -0400 Original-Received: by mail-wr1-x42a.google.com with SMTP id q26so9587097wrz.9 for ; Tue, 06 Apr 2021 11:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=xAB6QQXzTr7Ev7EARxvw6z0dmfU0Ptu0a7mLFfFICVY=; b=FV2KFgGs0ktOLTD90BMJUC959pPMjImMJ8EV5j3yeiyPzPRA/B9RLGewOmQOBZXwof QA96etoFzMP9DtbtakcnjsR9UjX3EzJNtm31lFBb3sGM477cHrrhZnxvq2BANeUPc+P/ xNfFWDqY1KXpcXt2HbjwtAzQIyjnG09ryOresLo6d43Bp2+B41SALw+omfUTzxBhpbTs z3XpNdmp7YbJsRIK/S7HfGii2DukV5KMZCwLwho426RSjxZIlsPKzZ64B+sq3phrPIv/ 61GZ3ez3cJu3vbwWS4JBpy/VkW3GnwJBQZR6bl6Nkjei/H/SitMtLChrIJByqSMPB8ei h21w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=xAB6QQXzTr7Ev7EARxvw6z0dmfU0Ptu0a7mLFfFICVY=; b=H2W9t0l/szf88DAU7pU0r969jAn0dNdh7lf8po5NvRbPlJceACCmnG/8koAA+HqC+7 9Q40JolC5Z8VznC/rgW+Z6u5ZMiBzHHrYIRlbNb8Pf+b0ApKKMYhCNcKFegkhXKS/cGJ IhqbicI4Z4B0wJo9LvTGAg6vHcvsqf15ylU5zpqi+KksSiuWR28lG66fOt/HSCXj3Nxe O4m9k7vE9kepcjLkkhD5v9ZofN8b8uD5xesz0wBqJB7vWNm/Zft7jmQeMYVGny0wVYJw VO91hkxCqG0D7kRN4h/+VT1kum9EqbmfD6TYpzko6tVGI3kOgVtiZWQFcuydugpDZWzv cl8g== X-Gm-Message-State: AOAM531c396zoZIhB6MsmAN06/KaCwyfs1Fw2LGCNm2US9Be23+x3sTb ZmWaE8LcThx2U9sXbk9yhn+NnGWamg/cBQ== X-Google-Smtp-Source: ABdhPJy61+caPhxPPyDNhw8CE2Ag8MPOn0qU4tjlQaAokNBc1HrgJfFbKmxXOGvotCoV4Kf/d/THnw== X-Received: by 2002:a05:6000:1283:: with SMTP id f3mr18116502wrx.188.1617734340098; Tue, 06 Apr 2021 11:39:00 -0700 (PDT) Original-Received: from localhost ([2a02:8084:9841:6600:d098:f653:b555:7e49]) by smtp.gmail.com with ESMTPSA id j14sm33681247wrw.69.2021.04.06.11.38.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 11:38:59 -0700 (PDT) Content-Disposition: inline Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=bob.heffernan@gmail.com; helo=mail-wr1-x42a.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128870 Archived-At: Dear all, I am new to Emacs (as a long-time vim user) so apologies if this question has an easy answer, but I've done a bit of searching before asking. I am looking at using org-mode for (a fairly simplistic version of) literate programming. The programming language I'm using is Scheme, although this probably doesn't matter. I've set things up so that code blocks share a session: #+PROPERTY: header-args :session *scheme* and I can then have several code blocks that work nicely together (these would usually be sprinkled throughout the document, of course, with text in between): #+begin_src scheme :results silent (define (f n) (+ n 1)) #+end_src #+begin_src scheme (f 1) #+end_src If I run the code in each block in turn with C-c C-c, which I guess calls org-babel-execute-src-block, I get #+RESULTS: : 2 So far so good and this is perfect for simple programs. However, once things get more complicated I will want to include another such org file, as a library as it were. For example, I'd like to be able to write a second org file that includes the stuff above and now knows what the definition of the procedure f is. I know that there is #+INCLUDE but I guess what I really need is to include a file and, at the same time, execute all src blocks in that file so that they are present in the same session as that of my current file. To give an example, let's say I'm working on writing solutions to Project Euler problems. After a while, I'll want a little library of procedures relating to prime numbers (since these come up a lot) which I can include as needed. It would be nice for this to also be written up nicely in org mode. I asked this question on the emacs subreddit and the library of babel was mentioned. This would work, I guess, but isn't quite what I'm looking for. Somebody else mentioned "transclusion" which seems perhaps more powerful than what I'm looking for. It seems like this should be a common problem to solve, but Google hasn't found anything for me. Thank you & best regards, Bob Heffernan