From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.help Subject: Re: Org mode & "literate programming": including files Date: Wed, 07 Apr 2021 05:54:48 +0200 Message-ID: References: <20210406183852.67ucwze6yxugvgrl@bob-nuc> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29392"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (windows-nt) Cc: Emacs mailing list To: Bob Heffernan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 07 05:55:26 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 1lTzHq-0007X5-D3 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 07 Apr 2021 05:55:26 +0200 Original-Received: from localhost ([::1]:46102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTzHp-00021U-EC for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 06 Apr 2021 23:55:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTzHL-00021N-CS for help-gnu-emacs@gnu.org; Tue, 06 Apr 2021 23:54:55 -0400 Original-Received: from mail-db8eur06olkn2048.outbound.protection.outlook.com ([40.92.51.48]:62432 helo=EUR06-DB8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTzHI-0002N2-CC for help-gnu-emacs@gnu.org; Tue, 06 Apr 2021 23:54:54 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TiWOkNed+BzvfKKtrBg+Qr0g73bm0x2Qb738Kq3xhIrZ8/ELxjA9finnHcW8M3TvAvM7NIrHH6Xu8J2k/4nxOgG+jZdk/55JisfCb+k6juIPEaVcri5Xsj10SAUAiAwot9uXhrh8V6gHM5J3DtxpWXSf2L6iseEPZu+Fi8zzGms2kekhplrIbAJ0aqfjmS0CTvt/Hnt2RGZfZW7XN8Jokc/u15PyuSlH8qmU/FxHAFtCrKKGroRhnmw9UADX6x6Ab+RILrofj1hpF/qsRrAeBeuemIPPuiQjLQRgzPZ4Pzv5VIEFX+5T6+Q12f9o1N3iBPVCzkuqU79eWzCLCOirWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4N4wbJK437OxzBDN+SkkgvrpMLPvhyXWa2GBqo0b3FE=; b=KoS/hTDh+4Ikd0EL0BqZaRBvgYTkOpqGelQUogZJy9hw1y5zHoLQB6isqz6x4C9d1QCcfXNLiAsk2SCDh5SkfpIu16tS9v4vccwfj7NZEJYga4tTDMj280s5G2wVoOpsh10NL+rjvWPRfPKou1tJJ/573X6vP528zTvpAbyZJH+BWv0i0MnvzBOV8QIZNNsU6rkUo2YrnWUw4KuXKKyG3yImNAA02hVdfHUm1wXyVVstmDl8w7VwUq/xpNpCWWOhqb7aB7TQt8NdEndtbnHM0NhciwFUCifV9SIibYg+iCmhNtqAVofcC18+oVqWblk9XgbAIOUbAc9zqygHSZLZBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4N4wbJK437OxzBDN+SkkgvrpMLPvhyXWa2GBqo0b3FE=; b=HxMozzIQgnbSlGSWaFSmI7cl+qbOilYW+BE2O2EmBl+OWu7cV5qKV4MHjLr+HZS8hk/dAFPB4KGApMB03XjRrAP4SZTgXmGqH9JF9oGMO8g2tjVIUqgw7ktJkNWGUfYN1SMhkPOdbmctddngEljm9WeyqpQ17hfG2ka1LxjMXaP2WjfZaqqAC0TdIpLmqqR8rTXKkaB7NNW2CwQfya9a4V7Qvks4S+G9tfD1M40CvKSttrEIH8LfmylRzLujv3Xn3xDO5ot/I/F/AJmsg8layYh8iW+/eB533KVHFlz2JdMlCLXYlBioUv8ATcmSQ9hMWQab2PZTYgDbQrYDqDA46Q== Original-Received: from VI1EUR06FT052.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc37::52) by VI1EUR06HT230.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc37::199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.28; Wed, 7 Apr 2021 03:54:49 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2a01:111:e400:fc37::4a) by VI1EUR06FT052.mail.protection.outlook.com (2a01:111:e400:fc37::62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Wed, 7 Apr 2021 03:54:49 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:167F590919F42E05D7197746ECA1E6D1B83788DEE252B9E7EA5CFED7FD96D7C0; UpperCasedChecksum:573CCD97B1C7EC49FE05FF66A02819DC917677F11D0E71BDECE8CB6742266F3A; SizeAsReceived:7450; Count:46 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::2103:e705:bc0c:5a8b]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::2103:e705:bc0c:5a8b%6]) with mapi id 15.20.4020.017; Wed, 7 Apr 2021 03:54:49 +0000 In-Reply-To: <20210406183852.67ucwze6yxugvgrl@bob-nuc> (Bob Heffernan's message of "Tue, 6 Apr 2021 19:38:52 +0100") X-TMN: [UUpfSktSJYcMXPdz5X5qVYgPMf3KaZf+] X-ClientProxiedBy: AS8PR04CA0040.eurprd04.prod.outlook.com (2603:10a6:20b:312::15) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <82im4y4ulz.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from HP-Laptop.homepc (81.232.177.30) by AS8PR04CA0040.eurprd04.prod.outlook.com (2603:10a6:20b:312::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17 via Frontend Transport; Wed, 7 Apr 2021 03:54:48 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: c17a65e7-c1f8-48ef-8daa-08d8f978e3cc X-MS-TrafficTypeDiagnostic: VI1EUR06HT230: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z5CMNE1rrgpZHD0cEgzEESLieBbG5Jnyz5IeLujPsLc55uzaiJl3jbrlHpJ6zMEksKHhKNe5XKBTgpc87apQKQHOMJkdC/SlSp6BPd6xg30m5/hCiuGl7XNnouOkzAkL5n2KIWSkyh4nYuHlwZJQNV8fD9Sh9wJeMeGXpSAx5ysvYre+il1IJbygdmKMZiCNqaXAkQlH4YrhIQTroRFJQXYp/owAtsdYv4ZuyF5KOtEMXJQlWs3TTg+I5/IGFAKdXMRcSAbpVnb/kjcXkiDpizrbQ40AKAcUDKIAFwBainZcrCrc964O4hdooBKL3sHGL7ogJvsYuH0AxRfX2aAQlAV35csOG2CGmaDz/eGLKWHjY2QNFZ0PLUp8DKBGNmhQYsWQq2UWd0YchAfIVt+nvtO9Xw7t/x760uqy3qECpIiwc0DKM53Ps8csoP90e2Nx X-MS-Exchange-AntiSpam-MessageData: 5+N58qExeznF4a96hwkpwJIxs1wuBX5cnQ8RfV1vu6UCxnpgtXpUA+iUBj5FA/FJKcAIn0yxpj1ay4aLOMUswMUB9455lg3pzHuWkbJ1jjSO9OagqgdCVY6LLfJN3EnC21V24mMXx288xOHUqjjazg== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: c17a65e7-c1f8-48ef-8daa-08d8f978e3cc X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2021 03:54:48.9884 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VI1EUR06FT052.eop-eur06.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1EUR06HT230 Received-SPF: pass client-ip=40.92.51.48; envelope-from=arthur.miller@live.com; helo=EUR06-DB8-obe.outbound.protection.outlook.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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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:128880 Archived-At: Bob Heffernan writes: > 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. I saw your question on reddit, and I saw somebody already posted you an answer. You are looking for `org-babel-lob-ingest`. Check the SX link posted to you on Reddit, it has what you are asking for: https://emacs.stackexchange.com/questions/31999/config-examples-and-use-cases-of-library-of-babel Hope it works for you and don't forgett to say thanks to the guy on Reddit.