From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id qGCSAJbGkmD5ywAAgWs5BA (envelope-from ) for ; Wed, 05 May 2021 18:23:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id mDm/N5XGkmACBAAA1q6Kng (envelope-from ) for ; Wed, 05 May 2021 16:23:49 +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 07BE1C448 for ; Wed, 5 May 2021 18:23:49 +0200 (CEST) Received: from localhost ([::1]:45358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leKJP-0006xu-QR for larch@yhetil.org; Wed, 05 May 2021 12:23:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKI6-0006td-QS for emacs-orgmode@gnu.org; Wed, 05 May 2021 12:22:27 -0400 Received: from mout01.posteo.de ([185.67.36.65]:58725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKI2-0002OE-Qf for emacs-orgmode@gnu.org; Wed, 05 May 2021 12:22:26 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id C0A3A240028 for ; Wed, 5 May 2021 18:22:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.eu; s=2017; t=1620231739; bh=UZVPQ3idXlPplK/hbXqH1BGgmugFlGjJMkxVz10CAHs=; h=Subject:To:Cc:From:Date:From; b=boAIS0x6VfBrNgj4jyoJOK2DA7uZ29WXhnlJ6b40hEzvfnod9whOoKAhct0dnQGHM NYFH5t7o+IZQ5a768z8UvzpY7RF99sXCQOANwbkf6T16vPe7Kzno83CGNirz+A9StM jFaOcEXnlkvfDzVi78O01ytf26WiqQIJmuU7sgD3ol/L0kncD6YQFrHwETShhVsH3O OJ/f9zlibXFEnM68Lio+LkxTuSj+f6HEjdlcLK8gG0+cRJh9Z1ItJffmC9QYqQlXc0 UhaJasBKL85FewAVVpyDHcYY1DtMlketr0exnMtAqex4Jq0Ynu9u9ln335H3YW7zBf kf6Wsk+n6HfRw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Fb26f34Fnz9rxN; Wed, 5 May 2021 18:22:18 +0200 (CEST) Subject: Re: [PATCH] tangling seems to have broken today To: Bastien References: <8735v1uwqv.fsf@disroot.org> <87h7jhl2l7.fsf@gmail.com> <87a6p98fb0.fsf@gnu.org> From: =?UTF-8?Q?S=c3=a9bastien_Miquel?= Message-ID: Date: Wed, 5 May 2021 16:22:16 +0000 MIME-Version: 1.0 In-Reply-To: <87a6p98fb0.fsf@gnu.org> Content-Type: multipart/mixed; boundary="------------1732BE436A558A7E35FA91E8" Content-Language: fr Received-SPF: pass client-ip=185.67.36.65; envelope-from=sebastien.miquel@posteo.eu; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: , Reply-To: sebastien.miquel@posteo.eu Cc: Timothy , emacs-orgmode@gnu.org, Eric S Fraga Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620231829; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=ctOjcMyFhVkzNlNdBOCMeLRl+Bou7KxIVKF1Jox58P8=; b=uA/aw6U5Pqq1yeekubbqfR/gMphVHyF2g6jlB4Bag1TDTMNTFmGxGuqiKtd9t8rBs+cxee nGLrqiErF81/uMtpZS/TZW35IpyU0R8x5BF/jpvxeEgujWTrMBy55EfgH6jx3cTa4WUr5u iSQNWxzUxv35ap3GzO+upPCXkjgdPhrlduJ7+G4VhYO7khct54SYMZDtdq0z/5TOwWXEdl yGyMJQo4yfBJhvtAshMx1bdeV+k/1DHbqNsGQtxJzIJDmPpxmw9g0MKGm4OnyzMU2Bp+rg 12F1iUbIZOgOolu5emEp30m0phjePQScfYh+ApdCMEZh2Iu2wqNIePWARzdQEQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620231829; a=rsa-sha256; cv=none; b=LesUM6GrhlrEX9RZD2PqDE7PysVLEnnA/qPzBZ7lzfPbA50U3euR0f0Iwrp8fH8SMGco7i f0cIjv9ar2eqUcAJ8b7Hwqqvyh/DOUgMqMH0UhHmh5UD1P+CLP5949NZkf5dQBUJk3U7bT XpK3/ImwWnC+zykBbJFDVeJeppnu5C/tbb6A8HbMMfRshQMNjD1i6lvYROKD9ksygvew1B jtJXEseF53fLTXRXGJ1MkAYwqEtaJ7HbHGLuQZoIkXmI5QodXkP6d2IExyPpl2ZiC/Tx9f QJvYX0P9jWrG/Mp4flmKNeIjd6KbD9Eg+IzSsh1EGFHhRtZIn69rEjbHRn4eZQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.eu header.s=2017 header.b=boAIS0x6; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.eu (policy=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-Migadu-Spam-Score: -1.37 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.eu header.s=2017 header.b=boAIS0x6; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.eu (policy=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-Migadu-Queue-Id: 07BE1C448 X-Spam-Score: -1.37 X-Migadu-Scanner: scn0.migadu.com X-TUID: JaZvohZTkrwf This is a multi-part message in MIME format. --------------1732BE436A558A7E35FA91E8 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi Bastien, The issue is that currently tangling a single block by calling `org-babel-tangle` with a prefix argument fails. This is unrelated to the earlier thread today, but was introduced by my original commit a2cb9b853d. Unfortunately, fixing it requires some refactorisation to avoid code duplication. To keep the patch as simple as possible, I have introduced a new helper function, I hope this is okay. I have tested the attached patch with the uses cases shown so far, as well as my own and the org test suite. I apologise again for the troubles. -- Sébastien Miquel --------------1732BE436A558A7E35FA91E8 Content-Type: text/x-patch; charset=UTF-8; name="0001-ob-tangle.el-Fix-single-block-tangle.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-ob-tangle.el-Fix-single-block-tangle.patch" >From 69be5864d9c936396317d81b6c39ddb166ac45d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= Date: Wed, 5 May 2021 17:45:09 +0200 Subject: [PATCH] ob-tangle.el: Fix single block tangle lisp/ob-tangle.el (org-babel-tangle-single-block): Fix the result when `only-this-block' is `t' to match what is expected by `org-babel-tangle'. (org-babel-effective-tangled-filename): Extract the computation of filename of tangled src block. (org-babel-tangle-collect-blocks): Use `org-babel-effective-tangled-filename'. --- lisp/ob-tangle.el | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index 8af03b11a..562776ae8 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -350,6 +350,22 @@ that the appropriate major-mode is set. SPEC has the form: (org-fill-template 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. +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)) + ((> (length src-tfile) 0) 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)) + (concat base-name "." ext) base-name)))) + (defun org-babel-tangle-collect-blocks (&optional lang-re tangle-file) "Collect source blocks in the current Org file. Return an association list of language and source-code block @@ -378,17 +394,8 @@ be used to limit the collected code blocks by target file." ;; file name. (let* ((block (org-babel-tangle-single-block counter)) (src-tfile (cdr (assq :tangle (nth 4 block)))) - (base-name (cond - ((string= "yes" src-tfile) - ;; buffer name - (file-name-sans-extension - (nth 1 block))) - ((> (length src-tfile) 0) src-tfile))) - (ext (or (cdr (assoc src-lang org-babel-tangle-lang-exts)) src-lang)) - (file-name (when base-name - ;; decide if we want to add ext to base-name - (if (and ext (string= "yes" src-tfile)) - (concat base-name "." ext) base-name))) + (file-name (org-babel-effective-tangled-filename + (nth 1 block) src-lang src-tfile)) (by-fn (assoc file-name blocks))) (if by-fn (setcdr by-fn (cons (cons src-lang block) (cdr by-fn))) (push (cons file-name (list (cons src-lang block))) blocks))))))) @@ -482,7 +489,10 @@ non-nil, return the full association list to be used by (org-trim (org-remove-indentation body))) comment))) (if only-this-block - (list (cons src-lang (list result))) + (let* ((src-tfile (cdr (assq :tangle (nth 4 result)))) + (file-name (org-babel-effective-tangled-filename + (nth 1 result) src-lang src-tfile))) + (list (cons file-name (list (cons src-lang result))))) result))) (defun org-babel-tangle-comment-links (&optional info) -- 2.31.1 --------------1732BE436A558A7E35FA91E8--