[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] ob-tangle.el: Blocks overwrite each other when grouping before t
From: |
Evgenii Klimov |
Subject: |
[PATCH] ob-tangle.el: Blocks overwrite each other when grouping before tangling |
Date: |
Wed, 12 Jul 2023 23:51:43 +0100 |
And here's the patch to fix it.
>From 2695d48f265a4100a9fc25c4dd278ab2b4b89ba5 Mon Sep 17 00:00:00 2001
From: Evgenii Klimov <eugene.dev@lipklim.org>
Date: Wed, 12 Jul 2023 19:24:48 +0100
Subject: [PATCH] ob-tangle.el: Avoid relative file names when grouping blocks
to tangle
* lisp/ob-tangle.el (org-babel-effective-tangled-filename): Avoid
using relative file names that could cause one block to overwrite the
others in `org-babel-tangle-collect-blocks' if they have the same
target file but in different formats.
---
lisp/ob-tangle.el | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el
index 25129616f..4aab453e3 100644
--- a/lisp/ob-tangle.el
+++ b/lisp/ob-tangle.el
@@ -427,17 +427,23 @@ that the appropriate major-mode is set. SPEC has the
form:
org-babel-tangle-comment-format-end link-data)))))
(defun org-babel-effective-tangled-filename (buffer-fn src-lang src-tfile)
- "Return effective tangled filename of a source-code block.
+ "Return effective tangled absolute filename of a source-code block.
BUFFER-FN is the name of the buffer, SRC-LANG the language of the
block and SRC-TFILE is the value of the :tangle header argument,
as computed by `org-babel-tangle-single-block'."
- (let ((base-name (cond
- ((string= "yes" src-tfile)
- ;; Use the buffer name
- (file-name-sans-extension buffer-fn))
- ((string= "no" src-tfile) nil)
- ((> (length src-tfile) 0) src-tfile)))
- (ext (or (cdr (assoc src-lang org-babel-tangle-lang-exts)) src-lang)))
+ (let* ((fnd (file-name-directory (buffer-file-name
+ (get-buffer buffer-fn))))
+ (base-name (cond
+ ((string= "yes" src-tfile)
+ ;; Use the buffer name
+ (file-name-concat fnd
+ (file-name-sans-extension buffer-fn)))
+ ((string= "no" src-tfile) nil)
+ ((> (length src-tfile) 0)
+ (if (file-name-directory src-tfile)
+ src-tfile
+ (file-name-concat fnd src-tfile)))))
+ (ext (or (cdr (assoc src-lang org-babel-tangle-lang-exts)) src-lang)))
(when base-name
;; decide if we want to add ext to base-name
(if (and ext (string= "yes" src-tfile))
--
2.34.1
- [BUG] ob-tangle.el: Blocks overwrite each other when grouping before tangling, Evgenii Klimov, 2023/07/12
- [PATCH] ob-tangle.el: Blocks overwrite each other when grouping before tangling,
Evgenii Klimov <=
- [PATCH v2] ob-tangle.el: Blocks overwrite each other when grouping before tangling, Evgenii Klimov, 2023/07/13
- Re: [PATCH v2] ob-tangle.el: Blocks overwrite each other when grouping before tangling, Ihor Radchenko, 2023/07/14
- [PATCH v3] ob-tangle.el: Blocks overwrite each other when grouping before tangling, Evgenii Klimov, 2023/07/24
- Re: [PATCH v3] ob-tangle.el: Blocks overwrite each other when grouping before tangling, Ihor Radchenko, 2023/07/25
- [PATCH v4] ob-tangle.el: Blocks overwrite each other when grouping before tangling, Evgenii Klimov, 2023/07/25
- Re: [PATCH v4] ob-tangle.el: Blocks overwrite each other when grouping before tangling, Ihor Radchenko, 2023/07/26
- [PATCH v5] ob-tangle.el: Blocks overwrite each other when grouping before tangling, Evgenii Klimov, 2023/07/26
- Re: [PATCH v5] ob-tangle.el: Blocks overwrite each other when grouping before tangling, Ihor Radchenko, 2023/07/28