From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id eHP3HK3euGXGRAAA62LTzQ:P1 (envelope-from ) for ; Tue, 30 Jan 2024 12:34:05 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id eHP3HK3euGXGRAAA62LTzQ (envelope-from ) for ; Tue, 30 Jan 2024 12:34:05 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=lbyOJfe8; dmarc=pass (policy=none) header.from=posteo.net; 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=1706614445; h=from:from:sender:sender: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=3dDTUWA2wh+lfzg3BAbcvevDGxaHx7ngIepJjpH19cY=; b=ErBZOUYp6UrJCtLXpuCzxurbf92gsnbHKJb+R2wTQr35wLuhPsouTYB0uQzZNaSmiRsexD o2kDqo2NhBeZJ08vYQwCJNsPrnGecJWTfu6FidNcqwRzWRgLXZuHH1Ft+7zuk7CeuYX0Gf qWy3k/P7DyM1oZ+ldnyqx1e6D5J7M+36uqNTRjJLC4oNZ6R6IVZLwbE0yBauuUwU9a9/q3 mpc6+YGvdRgdvzNLQHYgGifabQjlv0KnNySPXlc7q07Q03P4geaty37RylBdYErr4tCHGd 9wJ5ecZ2LRAqo5uXjYliPvmU2YyWHvb7zBS9IREHTt17YDvCiilPFvhT75D46w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=lbyOJfe8; dmarc=pass (policy=none) header.from=posteo.net; 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=1706614445; a=rsa-sha256; cv=none; b=MnuftdzRB0YAsQLCbX9LeSayV2VRLYAz6a2MROK6U7BO/cDs66gdIup89ozK1TZ7d5CbL/ 1Bbe61wWRxFBsvUZa4VSb3NpLfXCICpzmWhjh38qyZJ4DfbhPeXQEmP702G2XrKo2I/dVA HR1qrZSuLRSFwDguGdij1ypn4GTBhUV/1kYNsZAz71PBe9CIWVi7yur+wUhwwWJZIF+OF1 FoYIrbpa59J8+yCnmculOf3HWIHODxpL+oJ6FiQbU5cQAkYmP3FMak84Kllbg29u7gAIyT XTgjVjPLfGYFwQZORJff3r76SSZPv5bO52mz2eYF+gbzOChzYFkH+4lYNyOk7A== 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 0FD7B23E40 for ; Tue, 30 Jan 2024 12:34:05 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUmMX-0000KC-N3; Tue, 30 Jan 2024 06:33:10 -0500 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 1rUmMR-0000Ea-Ge for emacs-orgmode@gnu.org; Tue, 30 Jan 2024 06:33:04 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUmMP-0005nc-AT for emacs-orgmode@gnu.org; Tue, 30 Jan 2024 06:33:03 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id A387F24002A for ; Tue, 30 Jan 2024 12:32:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1706614377; bh=6iarfM+P6LRsAhvDmeaxqHDNh/310d4255POABThAYQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=lbyOJfe8eFxDP5J8TvEgTHYA42M0KrOjxF6Dtwq82VM9cRmZdmUATfBLlWFwtF2UJ cg1alJ2QvgtNjl49vbY5yx//PXSFKpY8Cr4f7mXlhG2aQBZ6u/GIbdl0sGhE5gzXSf Y7SL1nKewXpa4sGDO5kg6MCMARbIu4wqzr2eV01/8/Gl/gB6Uyv8a/MpfY2ub0Dg6F x7TGBtxQDSoafhJop/+1Pnoshdw3PK1qoglp56iSmenQbHVKMZLz7z528mJbXk5Fne D79BvjbSH8GlgYj/B5XRg7y0wSzAR7agX8RjlXV6OHXebFupDCwkg9sOQ6h1FT6qMC Y946VvtC+iT2g== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4TPNMD63zzz6tvh; Tue, 30 Jan 2024 12:32:56 +0100 (CET) From: Ihor Radchenko To: Olivier Lischer Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] ob-tangle: Add flag to optionally remove files before writing In-Reply-To: <87y1c8dm65.fsf@liolin.ch> References: <877cjzhjtg.fsf@liolin.ch> <87wmryelfo.fsf@localhost> <878r49i78e.fsf@liolin.ch> <87le89qi2c.fsf@localhost> <87y1c8dm65.fsf@liolin.ch> Date: Tue, 30 Jan 2024 11:36:28 +0000 Message-ID: <87y1c78343.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; 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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -9.88 X-Spam-Score: -9.88 X-Migadu-Queue-Id: 0FD7B23E40 X-Migadu-Scanner: mx12.migadu.com X-TUID: kVXFsIqArQN2 Olivier Lischer writes: >> I suggest changing your patch, setting the default value of >> `org-babel-tangle-remove-file-before-write' to 'auto. >> This will keep the current behaviour but fall back to delete + write new >> file when the tangle target is read-only. >> That will avoid feature regression. > > I changed the path as you proposed. Thanks, but I think that I was not clear enough explaining what I wanted you to change. > -(defcustom org-babel-tangle-uncomment-comments nil > +(defcustom org-babel-tangle-uncomment-comments 'auto I did not ask to change `org-babel-tangle-uncomment-comments'. I meant that you allow the new variable you propose (`org-babel-tangle-remove-file-before-write') to have 3 values: nil, t, and 'auto. > +(defcustom org-babel-tangle-remove-file-before-write nil ... with default being 'auto, not nil. > - ;; We do not erase, but overwrite previous file > - ;; to preserve any existing symlinks. > - (write-region nil nil file-name) > + (when (and (file-exists-p file-name) org-babel-tangle-remove-file-before-write) > + (delete-file file-name)) > + (write-region nil nil file-name) Then, with the default value of 'auto, you only call `delete-file' when the file is read-only. It would also help to extend the comment ";; We do not erase...", not just delete it. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at