From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id OHMwJOKf52XexAAA62LTzQ:P1 (envelope-from ) for ; Tue, 05 Mar 2024 23:42:42 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id OHMwJOKf52XexAAA62LTzQ (envelope-from ) for ; Tue, 05 Mar 2024 23:42:42 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Rp9Q5Fei; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1709678562; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=KCEidL6cqGUAZ7kJJvOcxYNSegoBjveVEIbMCBagVu4=; b=qYqd1MUI0815I29A/WIOAu3Ew5Fn+d8kCGLjdOZ6an9/zZGoQYzJmczjuIo1xaqmD+EHGe KxEbIr0uF4LcXPnR6yS1UwPCJodqSipo2BJC74PwdKN/y9KcgUBGqPovLDsBH6THS1L1Jz 8X3t/rj3AUumHK0g2NT7m4vd0WSyiG5KB7T6qxX+aAph5yAsZDXexo6m17WaAM+Z92od27 W/W0cuscAtmk7W3On6pzdc2QhOLqfcZywj3W/Fh4WJzCAfhJgkDEnolpvL6xbIdmoNQ+Py fdhwx0UYYifcIGgdvcZtkFvqhFolzHrSw9ZLF0GiYAon728g32k2PSMVp+AlXQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Rp9Q5Fei; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1709678562; a=rsa-sha256; cv=none; b=rCFfVRNuaW60S4f2VvBdOkus3KkI8QqpQymQP4ZzZv9cXAi3SfC6pGsqG8X7ZG6MLfu68F tfW44EeX5DRDrM+QSiT4vemimqA+NYfWY1Ik+ethVigU+EjY9mH8u/LzYi2RQD9Eo6SzUN dgkv41WyO3hG4tmePTa+yi0fxMKPlTVmYhD/WxU3lyAd+RNzxuJdl9BjvLGv1KmyoZnaAv hXehem8BBGrLLF966/w3DRaSi550nywyCSvM9vs0AFzW1jJDIDPRQFPiQKzKM1IxFQDhqc LOeG9d3UQcl9blbREEDZkkbI+Jkx9zlLTDLtOqkgk8P2jYIRnxdLiF/jocZJxw== 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 80FCD41DDF for ; Tue, 5 Mar 2024 23:42:42 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhdTt-0007ji-IA; Tue, 05 Mar 2024 17:41:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rhdTs-0007ja-Pa for emacs-orgmode@gnu.org; Tue, 05 Mar 2024 17:41:52 -0500 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rhdTq-0000D5-V8 for emacs-orgmode@gnu.org; Tue, 05 Mar 2024 17:41:52 -0500 Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-7882c4a259bso112310085a.1 for ; Tue, 05 Mar 2024 14:41:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709678509; x=1710283309; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:from:to:cc:subject:date:message-id:reply-to; bh=KCEidL6cqGUAZ7kJJvOcxYNSegoBjveVEIbMCBagVu4=; b=Rp9Q5FeiWxu2uziOiAvDkXT9+wtSsrcPm6ZoPMVmtU92HbxBuhiVm1Wu0QyGpWgMhi WS9UsWFRMiFwu4jXk3uEogTf0lSiGfRuArTPVlJOkE2pQqmsqRvQdRKn6mVyCiRwjH8b jWXXM02iB/T2bWo+ENvThJ/vzBIVnQs4Pt+6aRdMNAwqF+2tTzZpgOSKrteaTzcXiLU1 JbbY3Fu4LTP5SubhMpQglw7caN2ArKspry2Wx9CWpm7aniSbkaMXa6OxNYL8MfwXpzxR +fEX4DIz3X0kdf/BRpFu0/xkRcv/M9ygmW5TuZChDjgYAcdVciOZfV8sGwlFv8qd05Yy /bOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709678509; x=1710283309; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KCEidL6cqGUAZ7kJJvOcxYNSegoBjveVEIbMCBagVu4=; b=gPPN3HoLCiqFGxJJ4WE9pfHqFdfhL0i2Y/KMfigzf1vi74EsoW8BABODGQxjcnJzep mJqdoBXUMCOFCAln01FZdGmCPwtPbfKvs3a972JlRCtVSPckkxxH+7koQ6moZaoBAuOW uy0g9V+it4DrHdH2i1TuAPDTo5+NH+DKDHfzO/vSUb/zR5shNu744K9dozRAzlKcl+g+ T6bHvGcWwp0dMGsqMUVrbhwlz6SLKKLYslc2lzbABvTASmVCMSDQ2VP2dfF2Po5FML7s OvEX7PCc1N4YR0mZz6FL2/mSdvkrh2AzlGcUq6LQVbL0y6CVpDwI/UzqvunPpAjsuUpj 2rUA== X-Gm-Message-State: AOJu0Ywa8uWFtb4ll3NgffZ934vgT86BoVD7HQWFl68zeu2IMWFq7UZg gbryvbSrCnTYhQ9X8HcJMiO793FeNDC1fg4spg5Yr+XKuyZkgD2I8hwfJU0lWOs= X-Google-Smtp-Source: AGHT+IFebOm1elu2d9rkkz3O0nUsegG/yf1pN8ZbXSzmQ6v9o2ibKVAegEVPxJT+4UpNtBDP45o11A== X-Received: by 2002:a05:620a:4727:b0:788:3e02:f266 with SMTP id bs39-20020a05620a472700b007883e02f266mr595214qkb.78.1709678508819; Tue, 05 Mar 2024 14:41:48 -0800 (PST) Received: from localhost (024-236-139-114.res.spectrum.com. [24.236.139.114]) by smtp.gmail.com with ESMTPSA id c17-20020a05620a0cf100b007881eb5683fsm3533907qkj.2.2024.03.05.14.41.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 14:41:48 -0800 (PST) From: termux To: emacs-orgmode@gnu.org Subject: Re: noweb-start and noweb-end header args In-Reply-To: (Amy Grinn's message of "Tue, 05 Mar 2024 14:22:07 -0500") References: Date: Tue, 05 Mar 2024 17:41:48 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::733; envelope-from=grinn.amy@gmail.com; helo=mail-qk1-x733.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -9.44 X-Spam-Score: -9.44 X-Migadu-Queue-Id: 80FCD41DDF X-Migadu-Scanner: mx11.migadu.com X-TUID: MOYeLZrliKQp --=-=-= Content-Type: text/plain Amy Grinn writes: > I would like to add support for setting 'org-babel-noweb-wrap-start and > 'org-babel-noweb-wrap-end for each src block individually using the > header args :noweb-start and :noweb-end: Here's another possible syntax we could use: :noweb [wrap-start] [wrap-end] #+name: message #+begin_src elisp "Firewall is now in safe mode." #+end_src #+name: firewall-safe-mode #+begin_src sh :noweb yes echo <> #+end_src #+name: firewall #+begin_src sh :noweb yes <<< >>> safe_mode () { echo "Error encountered, switching to safe mode." <<>> exit 1 } #+end_src #+begin_src sh :noweb yes ":-) " " (-:" :tangle "test.sh" # Setup firewall :-) firewall (-: # Do other things #+end_src --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=noweb-extra-header-args2.diff Content-Description: Noweb header argument new syntax diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 4dcfbd3b0..f60b4be12 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -194,15 +194,20 @@ This string must include a \"%s\" which will be replaced by the results." :package-version '(Org . "9.1") :safe #'booleanp) -(defun org-babel-noweb-wrap (&optional regexp) +(defun org-babel-noweb-wrap (&optional regexp info) "Return regexp matching a Noweb reference. Match any reference, or only those matching REGEXP, if non-nil. When matching, reference is stored in match group 1." - (concat (regexp-quote org-babel-noweb-wrap-start) - (or regexp "\\([^ \t\n]\\(?:.*?[^ \t\n]\\)?\\)") - (regexp-quote org-babel-noweb-wrap-end))) + (let ((noweb (mapcar + (lambda (token) + (if (stringp token) token (symbol-name token))) + (org-babel-read + (format "'(%s)" (cdr (assq :noweb (nth 2 info)))))))) + (concat (regexp-quote (or (nth 1 noweb) org-babel-noweb-wrap-start)) + (or regexp "\\([^ \t\n]\\(?:.*?[^ \t\n]\\)?\\)") + (regexp-quote (or (nth 2 noweb) org-babel-noweb-wrap-end))))) (defvar org-babel-src-name-regexp "^[ \t]*#\\+name:[ \t]*" @@ -3116,7 +3121,7 @@ block but are passed literally to the \"example-block\"." (not (equal (cdr v) "no")))))) (noweb-re (format "\\(.*?\\)\\(%s\\)" (with-current-buffer parent-buffer - (org-babel-noweb-wrap))))) + (org-babel-noweb-wrap nil info))))) (unless (equal (cons parent-buffer (with-current-buffer parent-buffer (buffer-chars-modified-tick))) --=-=-=--