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 qGjMBFVBYF9EAgAA0tVLHw (envelope-from ) for ; Tue, 15 Sep 2020 04:21:41 +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 uG3bOlRBYF9CEwAA1q6Kng (envelope-from ) for ; Tue, 15 Sep 2020 04:21:40 +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 0117C940539 for ; Tue, 15 Sep 2020 04:21:40 +0000 (UTC) Received: from localhost ([::1]:60738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kI2TK-0005Rk-L6 for larch@yhetil.org; Tue, 15 Sep 2020 00:21:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI2Ss-0005RW-B4 for emacs-orgmode@gnu.org; Tue, 15 Sep 2020 00:21:10 -0400 Received: from pb-smtp21.pobox.com ([173.228.157.53]:63032) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kI2Sk-0006jm-UA for emacs-orgmode@gnu.org; Tue, 15 Sep 2020 00:21:08 -0400 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 8CECF105A6C; Tue, 15 Sep 2020 00:21:00 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:in-reply-to:references:date:message-id:mime-version :content-type; s=sasl; bh=vGVwnL64cS7bojntxnfi1xxZ4CE=; b=Gv8IMc KqoVJT8N5mElQxlHtommAdcquYckm1i4gyIh/Xk+rFm6nh+z8Yrt1r1kJXpa5ad9 TfFzSG0lVIGVruCoA+U6ZVZ8E9tS910+wmMtso7GlWcEE4w62ZfKyivg957JTObV 6ZFfJW2KJIL79DVFwAjez8RYQAO9zY8RH5WdM= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 85089105A6B; Tue, 15 Sep 2020 00:21:00 -0400 (EDT) (envelope-from kyle@kyleam.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=kyleam.com; h=from:to:cc:subject:in-reply-to:references:date:message-id:mime-version:content-type; s=mesmtp; bh=4vgRG54QegJKZ7lj2JGz+v4NUw70P2fwFqubrEJacqg=; b=o0LOyXaq9d0p5zSLqNh2Zm9DOANepeDXFe4GaHhhHZz5+EuAU/u9f/nBB99NoBr2ZyL8QDzReDD7uT7LMhoQjK6+dDImoVmKIVtflh8820klPjCBo1dOafSveNkfXFiXn4gZnnpeHNbo68ssT9C04rnfi9I5NrDYJtvVhMIUx1g= Received: from localhost (unknown [45.33.91.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id F0B85105A6A; Tue, 15 Sep 2020 00:20:57 -0400 (EDT) (envelope-from kyle@kyleam.com) From: Kyle Meyer To: Tom Gillespie Subject: [PATCH] ob-core: Fix handling of multiple noweb refs in same line In-Reply-To: References: Date: Tue, 15 Sep 2020 00:20:56 -0400 Message-ID: <87tuvzllg7.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: DAC04702-F70A-11EA-869C-843F439F7C89-24757444!pb-smtp21.pobox.com Received-SPF: pass client-ip=173.228.157.53; envelope-from=kyle@kyleam.com; helo=pb-smtp21.pobox.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/15 00:21:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: , Cc: emacs-orgmode 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=pobox.com header.s=sasl header.b=Gv8IMc K; dkim=pass header.d=kyleam.com header.s=mesmtp header.b=o0LOyXaq; dmarc=none; 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: -1.21 X-TUID: cSOeF02vJtu/ Tom Gillespie writes: > Hi, > The 9.4 release has a bug where it will only tangle the first noweb > reference on a line. > This is also present at 9c31cba002a1ba93053aebea1f778be87f61ba06. It happens in > emacs-27 and emacs-28. The reproduction is below. Best! Thanks for the report and the reproducer. This bisects to c1aed9f80 (ob-core: Refactor `org-babel-expand-noweb-references', 2020-01-12). The patch below addresses the case you provided (added as a test) and doesn't cause any of the other tests to fail. However, I'm no tangler, so I'd appreciate if you could give it some testing and report back. (I should also look more closely at org-babel-expand-noweb-references before applying and see if I spot anything that suggests this change is problematic.) -- >8 -- Subject: [PATCH] ob-core: Fix handling of multiple noweb refs in same line * lisp/ob-core.el (org-babel-expand-noweb-references): Don't anchor noweb regexp at start of line to allow multiple matches per line. * testing/lisp/test-ob-tangle.el (ob-tangle/multiple-noweb-in-line): Add test. This fixes a regression introduced by c1aed9f80 (ob-core: Refactor `org-babel-expand-noweb-references', 2020-01-12), which was part of the 9.4 release. Reported-by: Tom Gillespie Ref: https://orgmode.org/list/CA+G3_PO2yO1jMMpdrkc39BGQQ2eU5X4FzTEJVotjDJo-50dsqQ@mail.gmail.com --- lisp/ob-core.el | 2 +- testing/lisp/test-ob-tangle.el | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lisp/ob-core.el b/lisp/ob-core.el index a5e079d9a..7300f239e 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -2781,7 +2781,7 @@ (defun org-babel-expand-noweb-references (&optional info parent-buffer) (lang (nth 0 info)) (body (nth 1 info)) (comment (string= "noweb" (cdr (assq :comments (nth 2 info))))) - (noweb-re (format "^\\(.*?\\)\\(%s\\)" + (noweb-re (format "\\(.*?\\)\\(%s\\)" (with-current-buffer parent-buffer (org-babel-noweb-wrap)))) (cache nil) diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el index e0e2ea52c..cfdf16d40 100644 --- a/testing/lisp/test-ob-tangle.el +++ b/testing/lisp/test-ob-tangle.el @@ -420,6 +420,38 @@ (ert-deftest ob-tangle/commented-src-blocks () (org-split-string (buffer-string)))) (delete-file file)))))) +(ert-deftest ob-tangle/multiple-noweb-in-line () + "Test handling of multiple noweb references in a single line." + (should + (equal '("1" "2" "1") + (let ((file (make-temp-file "org-tangle-"))) + (unwind-protect + (progn + (org-test-with-temp-text-in-file + (format " +#+name: block1 +#+begin_src elisp +1 +#+end_src + +#+name: block2 +#+begin_src elisp +2 +#+end_src + +#+name: block3 +#+begin_src elisp :noweb yes :tangle %s +<> <> <> +#+end_src" + file) + (let ((org-babel-noweb-error-all-langs nil) + (org-babel-noweb-error-langs nil)) + (org-babel-tangle))) + (with-temp-buffer + (insert-file-contents file) + (org-split-string (buffer-string)))) + (delete-file file)))))) + (ert-deftest ob-tangle/detangle-false-positive () "Test handling of false positive link during detangle." (let (buffer) base-commit: e6021bc9b18982b30dd61417d98276b2984892cd -- 2.28.0