From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id cJ5/MEYvr2SyGgAASxT56A (envelope-from ) for ; Thu, 13 Jul 2023 00:55:02 +0200 Received: from aspmx1.migadu.com ([2001:41d0:306:2d92::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id IBCLMEYvr2SW5QAA9RJhRA (envelope-from ) for ; Thu, 13 Jul 2023 00:55:02 +0200 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 7C8D339195 for ; Thu, 13 Jul 2023 00:55:02 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lipklim.org header.s=key1 header.b=PsmnsXJy; dmarc=pass (policy=quarantine) header.from=lipklim.org; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1689202502; 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=HUQ5NM/2Sp3VFMTDBk1fxv3+KVSZDPF/iO8cn8eZRXU=; b=CydFfisiRqscrhV3E4HTt0Pb0smGmQNqxGkSH6EZ0YpJ0TQ+B+xF/OkBG6DWnDHk1oLtgH xKX2IduHtQquQ7Guj8nmr1VYG4PO6jkWBrXakJsAz97pwpvrG23rv77hOYW4IVoDJdLjIo i29PvXgLYIUe0hm/A9QvfSJA9hBmaNNnc6HvwW9/eBoX4OLU/i2GpWLs95nJrb53OeoWJN tdc+q4cxR/BSVNJtXe6MM9RHl//XTkRxXu04onn+592aiaoVN5nHdiO0S/DGvFhr+BiKpA ElvLmaKhOG1U6loOMpNzxrvvpTD8Gg5sOaau1RxnZ1H4obvsKL8zfDPkcDqrQQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=lipklim.org header.s=key1 header.b=PsmnsXJy; dmarc=pass (policy=quarantine) header.from=lipklim.org; 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1689202502; a=rsa-sha256; cv=none; b=lgVQkVMUHWUwSzBuBixmOwxyJWTWN0qM3m6iRW26y+C0G+G0F++Q5/EBF8fafVbWFn0swc yJdQ3DYz/fORFoUECh/dr4JYmdFtXb5xMcPfKBh0IMRZu87SZDovXC05QDupSBOqhaWYcV P7dHJHhmuzZlPr6GHH3dYSh/U4+UccI3sMsjjnDs0xvdgTqFJCSixBQqisyaG+ReH/8/kB AHZyGg0rJLGESLVJmwc4llnDhkm2hJjRRp4zis6eH/0kANtjh/ezk8R4GlE6HYi8IhS02+ hVoqwTcyJuQu47LpaO5AaNouDhKFE2qVuABJBL/8rKkTEAn0Mwm1pST+wpCVgg== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJij8-0004xy-8E; Wed, 12 Jul 2023 18:54:30 -0400 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 1qJij7-0004xn-6A for emacs-orgmode@gnu.org; Wed, 12 Jul 2023 18:54:29 -0400 Received: from out-1.mta1.migadu.com ([2001:41d0:203:375::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJij0-0003bL-R8 for emacs-orgmode@gnu.org; Wed, 12 Jul 2023 18:54:28 -0400 References: <87lefkd9tb.fsf@lipklim.org> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lipklim.org; s=key1; t=1689202458; h=from:from: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; bh=HUQ5NM/2Sp3VFMTDBk1fxv3+KVSZDPF/iO8cn8eZRXU=; b=PsmnsXJyYc4+GU4zOBEJNY9LSpLjYnSouilkeU6glMbbGeQChS2m+c46acPN2c9zYYaJXP RZQ9/1Yo+lSPDLjS9jYS2NRM21Od6vZteM8jOy23U1OtiWtKbPNT32X3EHZdsw+TzzsWia oC8v2I8wR6S3BCROB7qiINZxAF/TrvI= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Evgenii Klimov To: emacs-orgmode Subject: [PATCH] ob-tangle.el: Blocks overwrite each other when grouping before tangling Date: Wed, 12 Jul 2023 23:51:43 +0100 In-reply-to: <87lefkd9tb.fsf@lipklim.org> Message-ID: <87h6q8d9lz.fsf@lipklim.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2001:41d0:203:375::1; envelope-from=eugene.dev@lipklim.org; helo=out-1.mta1.migadu.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, 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-Queue-Id: 7C8D339195 X-Migadu-Scanner: mx2.migadu.com X-Migadu-Spam-Score: -9.56 X-Spam-Score: -9.56 X-TUID: Qhu7oZtSOu+S --=-=-= Content-Type: text/plain And here's the patch to fix it. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ob-tangle.el-Avoid-relative-file-names-when-grouping.patch >From 2695d48f265a4100a9fc25c4dd278ab2b4b89ba5 Mon Sep 17 00:00:00 2001 From: Evgenii Klimov 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 --=-=-=--