* [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option
@ 2022-10-26 19:37 dziltener
2022-10-28 2:19 ` Ihor Radchenko
2022-10-30 4:17 ` Timothy
0 siblings, 2 replies; 12+ messages in thread
From: dziltener @ 2022-10-26 19:37 UTC (permalink / raw)
To: emacs-orgmode; +Cc: Daniel Ziltener
From: Daniel Ziltener <dziltener@lyrion.ch>
* ob-tangle.el, ob-core.el, test-ob-tangle.el, org-manual.org: Add a
"strip-tangle" noweb option to strip the noweb tags when tangling, but
keep and expand them otherwise.
---
doc/org-manual.org | 6 ++++++
lisp/ob-core.el | 6 +++---
lisp/ob-tangle.el | 4 +++-
testing/lisp/test-ob-tangle.el | 27 +++++++++++++++++++++++++++
4 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/doc/org-manual.org b/doc/org-manual.org
index 18a050069..cb85f4702 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -18993,6 +18993,12 @@ tangled, or exported.
Expansion of noweb syntax references in the body of the code block
when tangling. No expansion when evaluating or exporting.
+- =strip-tangle= ::
+
+ Expansion of noweb syntax references in the body of the code block
+ when evaluating or exporting. Removes noweb syntax references
+ when tangling.
+
- =no-export= ::
Expansion of noweb syntax references in the body of the code block
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 518831ec6..ae77182ef 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -2880,9 +2880,9 @@ parameters when merging lists."
"Check if PARAMS require expansion in CONTEXT.
CONTEXT may be one of :tangle, :export or :eval."
(let ((allowed-values (cl-case context
- (:tangle '("yes" "tangle" "no-export" "strip-export"))
- (:eval '("yes" "no-export" "strip-export" "eval"))
- (:export '("yes")))))
+ (:tangle '("yes" "tangle" "no-export" "strip-export" "strip-tangle"))
+ (:eval '("yes" "no-export" "strip-export" "eval" "strip-tangle"))
+ (:export '("yes" "strip-tangle")))))
(cl-some (lambda (v) (member v allowed-values))
(split-string (or (cdr (assq :noweb params)) "")))))
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 2da92efaf..d9d847195 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -536,7 +536,9 @@ non-nil, return the full association list to be used by
(body
;; Run the tangle-body-hook.
(let ((body (if (org-babel-noweb-p params :tangle)
- (org-babel-expand-noweb-references info)
+ (if (string= "strip-tangle" (cdr (assq :noweb (nth 2 info))))
+ (replace-regexp-in-string (org-babel-noweb-wrap) "" (nth 1 info))
+ (org-babel-expand-noweb-references info))
(nth 1 info))))
(with-temp-buffer
(insert
diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index a0003ee40..455745e5c 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -510,6 +510,33 @@ another block
(org-split-string (buffer-string))))
(delete-file file))))))
+(ert-deftest ob-tangle/strip-tangle ()
+ "Test if strip-tangle works correctly when tangling noweb code blocks."
+ (should
+ (equal '("1")
+ (let ((file (make-temp-file "org-tangle-")))
+ (unwind-protect
+ (progn
+ (org-test-with-temp-text-in-file
+ (format "
+#+name: block1
+#+begin_src elisp
+2
+#+end_src
+
+#+begin_src elisp :noweb strip-tangle :tangle %s
+1<<block1>>
+#+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)
--
2.35.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option
2022-10-26 19:37 [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option dziltener
@ 2022-10-28 2:19 ` Ihor Radchenko
2022-10-28 8:09 ` Daniel Ziltener
2022-10-30 4:17 ` Timothy
1 sibling, 1 reply; 12+ messages in thread
From: Ihor Radchenko @ 2022-10-28 2:19 UTC (permalink / raw)
To: dziltener; +Cc: emacs-orgmode
dziltener@lyrion.ch writes:
> From: Daniel Ziltener <dziltener@lyrion.ch>
>
> * ob-tangle.el, ob-core.el, test-ob-tangle.el, org-manual.org: Add a
> "strip-tangle" noweb option to strip the noweb tags when tangling, but
> keep and expand them otherwise.
Thanks for the patch!
If I understand correctly, you are suggesting
Could you please follow
https://orgmode.org/worg/org-contribute.html#commit-messages for the
commit log entries?
Also, do you have FSF copyright assignment? If no, you also need to add
TINYCHANGE cookie to the commit message. See
https://orgmode.org/worg/org-contribute.html#first-patch
> +- =strip-tangle= ::
> +
> + Expansion of noweb syntax references in the body of the code block
> + when evaluating or exporting. Removes noweb syntax references
> + when tangling.
This is a new feature and thus should also be mentioned in etc/NEWS.
Also, please use double space between sentences. See
doc/Documentation_Standards.org.
> (let ((allowed-values (cl-case context
> - (:tangle '("yes" "tangle" "no-export" "strip-export"))
> - (:eval '("yes" "no-export" "strip-export" "eval"))
> - (:export '("yes")))))
> + (:tangle '("yes" "tangle" "no-export" "strip-export" "strip-tangle"))
> + (:eval '("yes" "no-export" "strip-export" "eval" "strip-tangle"))
> + (:export '("yes" "strip-tangle")))))
AFAIU, you are suggesting a new value for :noweb header argument.
But this function has nothing to do with :noweb. This change will check
for :tangle strip-tangle, :eval strip-tangle, and :export strip-tangle.
What is the purpose?
Also, the allowed values of standard header args are defined in
org-babel-common-header-args-w-values, which you did not change.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option
2022-10-28 2:19 ` Ihor Radchenko
@ 2022-10-28 8:09 ` Daniel Ziltener
2022-10-29 3:49 ` Ihor Radchenko
0 siblings, 1 reply; 12+ messages in thread
From: Daniel Ziltener @ 2022-10-28 8:09 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1.1: Type: text/plain, Size: 2266 bytes --]
Am 28.10.22 um 04:19 schrieb Ihor Radchenko:
> dziltener@lyrion.ch writes:
>
>> From: Daniel Ziltener <dziltener@lyrion.ch>
>>
>> * ob-tangle.el, ob-core.el, test-ob-tangle.el, org-manual.org: Add a
>> "strip-tangle" noweb option to strip the noweb tags when tangling, but
>> keep and expand them otherwise.
> Thanks for the patch!
>
> If I understand correctly, you are suggesting
>
> Could you please follow
> https://orgmode.org/worg/org-contribute.html#commit-messages for the
> commit log entries?
I tried to follow that. To follow it "more" I guess I have to make one
commit per file I changed? There isn't an example for multiple files, so
I was not sure how exactly to follow it.
> Also, do you have FSF copyright assignment? If no, you also need to add
> TINYCHANGE cookie to the commit message. See
> https://orgmode.org/worg/org-contribute.html#first-patch
I do, yes, I sent in the signed form on Wednesday as requested by the FSF.
>> +- =strip-tangle= ::
>> +
>> + Expansion of noweb syntax references in the body of the code block
>> + when evaluating or exporting. Removes noweb syntax references
>> + when tangling.
> This is a new feature and thus should also be mentioned in etc/NEWS.
>
> Also, please use double space between sentences. See
> doc/Documentation_Standards.org.
Noted, I'll do both of these.
>> (let ((allowed-values (cl-case context
>> - (:tangle '("yes" "tangle" "no-export" "strip-export"))
>> - (:eval '("yes" "no-export" "strip-export" "eval"))
>> - (:export '("yes")))))
>> + (:tangle '("yes" "tangle" "no-export" "strip-export" "strip-tangle"))
>> + (:eval '("yes" "no-export" "strip-export" "eval" "strip-tangle"))
>> + (:export '("yes" "strip-tangle")))))
> AFAIU, you are suggesting a new value for :noweb header argument.
> But this function has nothing to do with :noweb. This change will check
> for :tangle strip-tangle, :eval strip-tangle, and :export strip-tangle.
> What is the purpose?
I suppose then I made a mistake there. My intention was what you mention
next:
> Also, the allowed values of standard header args are defined in
> org-babel-common-header-args-w-values, which you did not change.
I will adjust that one instead.
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 1205 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option
2022-10-28 8:09 ` Daniel Ziltener
@ 2022-10-29 3:49 ` Ihor Radchenko
2022-10-29 23:34 ` Daniel Ziltener
0 siblings, 1 reply; 12+ messages in thread
From: Ihor Radchenko @ 2022-10-29 3:49 UTC (permalink / raw)
To: Daniel Ziltener; +Cc: emacs-orgmode
Daniel Ziltener <dziltener@lyrion.ch> writes:
>> Could you please follow
>> https://orgmode.org/worg/org-contribute.html#commit-messages for the
>> commit log entries?
> I tried to follow that. To follow it "more" I guess I have to make one
> commit per file I changed? There isn't an example for multiple files, so
> I was not sure how exactly to follow it.
See https://orgmode.org/worg/org-contribute.html#org5bd92c9. Basically,
you need to provide changed function/variable/section name in the
changelog.
When you make the same change in multiple files, just do something like
* lisp/org-capture.el (org-capture-set-plist):
* doc/org.texi (Capture): <Details of the change>.
>> Also, do you have FSF copyright assignment? If no, you also need to add
>> TINYCHANGE cookie to the commit message. See
>> https://orgmode.org/worg/org-contribute.html#first-patch
> I do, yes, I sent in the signed form on Wednesday as requested by the FSF.
Great!
They should reply within 5 working days. If they don't, you can followup
with them and wait another 5 days. If that also does not work, let us
know.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option
2022-10-29 3:49 ` Ihor Radchenko
@ 2022-10-29 23:34 ` Daniel Ziltener
2022-10-30 4:12 ` Ihor Radchenko
0 siblings, 1 reply; 12+ messages in thread
From: Daniel Ziltener @ 2022-10-29 23:34 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1.1: Type: text/plain, Size: 5320 bytes --]
From: Daniel Ziltener <dziltener@lyrion.ch>
* lisp/ob-tangle.el (org-babel-tangle-single-block): strip noweb tags
from block if :noweb has been set to strip-tangle.
* lisp/ob-core.el (org-babel-common-header-args-w-values): add
"strip-tangle" as new allowed value.
* testing/lisp/test-ob-tangle.el (ob-tangle/strip-tangle): add new test
case for strip-tangle.
* doc/org-manual.org (Noweb Reference Syntax): adjust documentation for
the noweb header argument.
* etc/ORG-NEWS: add entry for new header argument value.
This patch adds the "strip-tangle" option for the :noweb header
argument. This strips the noweb tags before tangling the block. This can
be useful for e.g. testing purposes where one wants to use a block as
test case that can be both run inline as well as tangled into a file for
automated testing.
---
doc/org-manual.org | 6 ++++++
etc/ORG-NEWS | 5 +++++
lisp/ob-core.el | 2 +-
lisp/ob-tangle.el | 4 +++-
testing/lisp/test-ob-tangle.el | 26 ++++++++++++++++++++++++++
5 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/doc/org-manual.org b/doc/org-manual.org
index 18a050069..064d51bcd 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -18993,6 +18993,12 @@ tangled, or exported.
Expansion of noweb syntax references in the body of the code block
when tangling. No expansion when evaluating or exporting.
+- =strip-tangle= ::
+
+ Expansion of noweb syntax references in the body of the code block
+ when evaluating or exporting. Removes noweb syntax references
+ when exporting.
+
- =no-export= ::
Expansion of noweb syntax references in the body of the code block
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 6e875deb6..2c66d2e45 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -228,6 +228,11 @@ commands.
=:noweb-prefix= can be set to =no= to prevent the prefix characters
from being repeated when expanding a multiline noweb reference.
+*** New =:noweb= babel header argument value =strip-tangle=
+
+=:noweb= can be set to =strip-tangle= to strip the noweb syntax references
+before tangling.
+
*** New LaTeX source block backend using =engraved-faces-latex=
When ~org-latex-src-block-backend~ is set to ~engraved~,
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 518831ec6..c52f113b4 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -414,7 +414,7 @@ then run `org-babel-switch-to-session'."
(mkdirp . ((yes no)))
(no-expand)
(noeval)
- (noweb . ((yes no tangle no-export strip-export)))
+ (noweb . ((yes no tangle strip-tangle no-export strip-export)))
(noweb-ref . :any)
(noweb-sep . :any)
(noweb-prefix . ((no yes)))
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 2da92efaf..d9d847195 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -536,7 +536,9 @@ non-nil, return the full association list to be used by
(body
;; Run the tangle-body-hook.
(let ((body (if (org-babel-noweb-p params :tangle)
- (org-babel-expand-noweb-references info)
+ (if (string= "strip-tangle" (cdr (assq :noweb
(nth 2 info))))
+ (replace-regexp-in-string
(org-babel-noweb-wrap) "" (nth 1 info))
+ (org-babel-expand-noweb-references info))
(nth 1 info))))
(with-temp-buffer
(insert
diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index a0003ee40..af2a72682 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -510,6 +510,32 @@ another block
(org-split-string (buffer-string))))
(delete-file file))))))
+(ert-deftest ob-tangle/strip-tangle ()
+ "Test if strip-tangle works correctly when tangling noweb code blocks."
+ (should
+ (equal '("1")
+ (let ((file (make-temp-file "org-tangle-")))
+ (unwind-protect
+ (progn
+ (org-test-with-temp-text-in-file
+ (format "
+#+name: block1
+#+begin_src elisp
+2
+#+end_src
+
+#+begin_src elisp :noweb strip-tangle :tangle %s
++1<<block1>>
+#+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)
--
2.35.3
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 1205 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option
2022-10-29 23:34 ` Daniel Ziltener
@ 2022-10-30 4:12 ` Ihor Radchenko
2022-10-30 10:42 ` Daniel Ziltener
0 siblings, 1 reply; 12+ messages in thread
From: Ihor Radchenko @ 2022-10-30 4:12 UTC (permalink / raw)
To: Daniel Ziltener; +Cc: emacs-orgmode
Daniel Ziltener <dziltener@lyrion.ch> writes:
> From: Daniel Ziltener <dziltener@lyrion.ch>
>
> * lisp/ob-tangle.el (org-babel-tangle-single-block): strip noweb tags
> from block if :noweb has been set to strip-tangle.
> * lisp/ob-core.el (org-babel-common-header-args-w-values): add
> "strip-tangle" as new allowed value.
> * testing/lisp/test-ob-tangle.el (ob-tangle/strip-tangle): add new test
> case for strip-tangle.
> * doc/org-manual.org (Noweb Reference Syntax): adjust documentation for
> the noweb header argument.
> * etc/ORG-NEWS: add entry for new header argument value.
>
> This patch adds the "strip-tangle" option for the :noweb header
> argument. This strips the noweb tags before tangling the block. This can
> be useful for e.g. testing purposes where one wants to use a block as
> test case that can be both run inline as well as tangled into a file for
> automated testing.
Thanks, but it looks like your PGP signature corrupted the email patch.
Could you please create a separate patch file and attach it in the
reply?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option
2022-10-30 4:12 ` Ihor Radchenko
@ 2022-10-30 10:42 ` Daniel Ziltener
2022-11-02 6:17 ` Ihor Radchenko
0 siblings, 1 reply; 12+ messages in thread
From: Daniel Ziltener @ 2022-10-30 10:42 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1.1: Type: text/plain, Size: 1222 bytes --]
Am 30.10.22 um 05:12 schrieb Ihor Radchenko:
> Daniel Ziltener <dziltener@lyrion.ch> writes:
>
>> From: Daniel Ziltener <dziltener@lyrion.ch>
>>
>> * lisp/ob-tangle.el (org-babel-tangle-single-block): strip noweb tags
>> from block if :noweb has been set to strip-tangle.
>> * lisp/ob-core.el (org-babel-common-header-args-w-values): add
>> "strip-tangle" as new allowed value.
>> * testing/lisp/test-ob-tangle.el (ob-tangle/strip-tangle): add new test
>> case for strip-tangle.
>> * doc/org-manual.org (Noweb Reference Syntax): adjust documentation for
>> the noweb header argument.
>> * etc/ORG-NEWS: add entry for new header argument value.
>>
>> This patch adds the "strip-tangle" option for the :noweb header
>> argument. This strips the noweb tags before tangling the block. This can
>> be useful for e.g. testing purposes where one wants to use a block as
>> test case that can be both run inline as well as tangled into a file for
>> automated testing.
> Thanks, but it looks like your PGP signature corrupted the email patch.
> Could you please create a separate patch file and attach it in the
> reply?
Sure, here's the patch attached, as generated by "git format-patch
origin/main".
[-- Attachment #1.1.2: 0001-lisp-ob-tangle.el-lisp-ob-core.el-Add-strip-tangle.patch --]
[-- Type: text/x-patch, Size: 4804 bytes --]
From 0133162ef78e007fe4918016a4aabf8bc3734488 Mon Sep 17 00:00:00 2001
From: Daniel Ziltener <dziltener@lyrion.ch>
Date: Sun, 30 Oct 2022 01:20:53 +0200
Subject: [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle
* lisp/ob-tangle.el (org-babel-tangle-single-block): strip noweb tags
from block if :noweb has been set to strip-tangle.
* lisp/ob-core.el (org-babel-common-header-args-w-values): add
"strip-tangle" as new allowed value.
* testing/lisp/test-ob-tangle.el (ob-tangle/strip-tangle): add new test
case for strip-tangle.
* doc/org-manual.org (Noweb Reference Syntax): adjust documentation for
the noweb header argument.
* etc/ORG-NEWS: add entry for new header argument value.
This patch adds the "strip-tangle" option for the :noweb header
argument. This strips the noweb tags before tangling the block. This can
be useful for e.g. testing purposes where one wants to use a block as
test case that can be both run inline as well as tangled into a file for
automated testing.
---
doc/org-manual.org | 6 ++++++
etc/ORG-NEWS | 5 +++++
lisp/ob-core.el | 2 +-
lisp/ob-tangle.el | 4 +++-
testing/lisp/test-ob-tangle.el | 26 ++++++++++++++++++++++++++
5 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/doc/org-manual.org b/doc/org-manual.org
index 18a050069..064d51bcd 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -18993,6 +18993,12 @@ tangled, or exported.
Expansion of noweb syntax references in the body of the code block
when tangling. No expansion when evaluating or exporting.
+- =strip-tangle= ::
+
+ Expansion of noweb syntax references in the body of the code block
+ when evaluating or exporting. Removes noweb syntax references
+ when exporting.
+
- =no-export= ::
Expansion of noweb syntax references in the body of the code block
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 6e875deb6..2c66d2e45 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -228,6 +228,11 @@ commands.
=:noweb-prefix= can be set to =no= to prevent the prefix characters
from being repeated when expanding a multiline noweb reference.
+*** New =:noweb= babel header argument value =strip-tangle=
+
+=:noweb= can be set to =strip-tangle= to strip the noweb syntax references
+before tangling.
+
*** New LaTeX source block backend using =engraved-faces-latex=
When ~org-latex-src-block-backend~ is set to ~engraved~,
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 518831ec6..c52f113b4 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -414,7 +414,7 @@ then run `org-babel-switch-to-session'."
(mkdirp . ((yes no)))
(no-expand)
(noeval)
- (noweb . ((yes no tangle no-export strip-export)))
+ (noweb . ((yes no tangle strip-tangle no-export strip-export)))
(noweb-ref . :any)
(noweb-sep . :any)
(noweb-prefix . ((no yes)))
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 2da92efaf..d9d847195 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -536,7 +536,9 @@ non-nil, return the full association list to be used by
(body
;; Run the tangle-body-hook.
(let ((body (if (org-babel-noweb-p params :tangle)
- (org-babel-expand-noweb-references info)
+ (if (string= "strip-tangle" (cdr (assq :noweb (nth 2 info))))
+ (replace-regexp-in-string (org-babel-noweb-wrap) "" (nth 1 info))
+ (org-babel-expand-noweb-references info))
(nth 1 info))))
(with-temp-buffer
(insert
diff --git a/testing/lisp/test-ob-tangle.el b/testing/lisp/test-ob-tangle.el
index a0003ee40..af2a72682 100644
--- a/testing/lisp/test-ob-tangle.el
+++ b/testing/lisp/test-ob-tangle.el
@@ -510,6 +510,32 @@ another block
(org-split-string (buffer-string))))
(delete-file file))))))
+(ert-deftest ob-tangle/strip-tangle ()
+ "Test if strip-tangle works correctly when tangling noweb code blocks."
+ (should
+ (equal '("1")
+ (let ((file (make-temp-file "org-tangle-")))
+ (unwind-protect
+ (progn
+ (org-test-with-temp-text-in-file
+ (format "
+#+name: block1
+#+begin_src elisp
+2
+#+end_src
+
+#+begin_src elisp :noweb strip-tangle :tangle %s
++1<<block1>>
+#+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)
--
2.35.3
[-- Attachment #1.1.3: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 1205 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option
2022-10-30 10:42 ` Daniel Ziltener
@ 2022-11-02 6:17 ` Ihor Radchenko
2022-12-27 10:59 ` Ihor Radchenko
0 siblings, 1 reply; 12+ messages in thread
From: Ihor Radchenko @ 2022-11-02 6:17 UTC (permalink / raw)
To: Daniel Ziltener; +Cc: emacs-orgmode
Daniel Ziltener <dziltener@lyrion.ch> writes:
>> Could you please create a separate patch file and attach it in the
>> reply?
> Sure, here's the patch attached, as generated by "git format-patch
> origin/main".
Thanks!
I tried to apply your patch and run tests. The new test for
"strip-tangle" is failing on my side.
Also, several small comments about the commit message.
> * lisp/ob-tangle.el (org-babel-tangle-single-block): strip noweb tags
> from block if :noweb has been set to strip-tangle.
> * lisp/ob-core.el (org-babel-common-header-args-w-values): add
> "strip-tangle" as new allowed value.
> * testing/lisp/test-ob-tangle.el (ob-tangle/strip-tangle): add new test
> case for strip-tangle.
> * doc/org-manual.org (Noweb Reference Syntax): adjust documentation for
> the noweb header argument.
> * etc/ORG-NEWS: add entry for new header argument value.
Please start sentences with capital letter. Also, use "strip-tangle" or
strip-tangle consistently.
> This patch adds the "strip-tangle" option for the :noweb header
> argument. This strips the noweb tags before tangling the block. This can
^" "
We use double space between sentences in commit messages as well. Not
only in the documentation.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option
2022-10-26 19:37 [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option dziltener
2022-10-28 2:19 ` Ihor Radchenko
@ 2022-10-30 4:17 ` Timothy
2022-10-31 3:24 ` Ihor Radchenko
1 sibling, 1 reply; 12+ messages in thread
From: Timothy @ 2022-10-30 4:17 UTC (permalink / raw)
To: dziltener; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 512 bytes --]
Hi Daniel,
> Add a “strip-tangle” noweb option to strip the noweb tags when tangling, but
> keep and expand them otherwise.
I must admit I can’t see the point of this — would you mind providing an
example of when this would be useful?
All the best,
Timothy
--
Timothy (‘tecosaur’/‘TEC’), Org mode contributor.
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/tec>.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option
2022-10-30 4:17 ` Timothy
@ 2022-10-31 3:24 ` Ihor Radchenko
2022-10-31 3:31 ` Timothy
0 siblings, 1 reply; 12+ messages in thread
From: Ihor Radchenko @ 2022-10-31 3:24 UTC (permalink / raw)
To: Timothy; +Cc: dziltener, emacs-orgmode
Timothy <orgmode@tec.tecosaur.net> writes:
> Hi Daniel,
>
>> Add a “strip-tangle” noweb option to strip the noweb tags when tangling, but
>> keep and expand them otherwise.
>
> I must admit I can’t see the point of this — would you mind providing an
> example of when this would be useful?
#+name: setup
#+begin_src bash
cd /path/to/tests
#+end_src
#+begin_src bash :noweb strip-tangle
<<setup>>
make test1
#+end_src
#+begin_src bash :noweb strip-tangle
<<setup>>
make test2
#+end_src
Then, one can interactively run individual tests from Org and then
tangle the whole file into batch test script.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option
2022-10-31 3:24 ` Ihor Radchenko
@ 2022-10-31 3:31 ` Timothy
0 siblings, 0 replies; 12+ messages in thread
From: Timothy @ 2022-10-31 3:31 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Timothy, dziltener, emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 675 bytes --]
Hi Ihor,
> #+name: setup
> #+begin_src bash
>
> cd /path/to/tests
> #+end_src
>
> #+begin_src bash :noweb strip-tangle
>
> make test1
> #+end_src
>
> #+begin_src bash :noweb strip-tangle
>
> make test2
> #+end_src
>
> Then, one can interactively run individual tests from Org and then
> tangle the whole file into batch test script.
Ah, this makes sense to me now. Thanks for the example!
All the best,
Timothy
--
Timothy (‘tecosaur’/‘TEC’), Org mode contributor.
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/tec>.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2022-12-27 11:01 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-26 19:37 [PATCH] lisp/ob-tangle.el, lisp/ob-core.el: Add strip-tangle noweb option dziltener
2022-10-28 2:19 ` Ihor Radchenko
2022-10-28 8:09 ` Daniel Ziltener
2022-10-29 3:49 ` Ihor Radchenko
2022-10-29 23:34 ` Daniel Ziltener
2022-10-30 4:12 ` Ihor Radchenko
2022-10-30 10:42 ` Daniel Ziltener
2022-11-02 6:17 ` Ihor Radchenko
2022-12-27 10:59 ` Ihor Radchenko
2022-10-30 4:17 ` Timothy
2022-10-31 3:24 ` Ihor Radchenko
2022-10-31 3:31 ` Timothy
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.