From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id QCCPOC0gfGEWGQAAgWs5BA (envelope-from ) for ; Fri, 29 Oct 2021 18:24:13 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id iIAYNC0gfGFQZwAAbx9fmQ (envelope-from ) for ; Fri, 29 Oct 2021 16:24:13 +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 2832430049 for ; Fri, 29 Oct 2021 18:24:13 +0200 (CEST) Received: from localhost ([::1]:44322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mgUfs-0005aO-3T for larch@yhetil.org; Fri, 29 Oct 2021 12:24:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgUds-0003YA-QP for emacs-orgmode@gnu.org; Fri, 29 Oct 2021 12:22:08 -0400 Received: from ciao.gmane.io ([116.202.254.214]:32860) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mgUdr-0002d2-D9 for emacs-orgmode@gnu.org; Fri, 29 Oct 2021 12:22:08 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mgUdl-0004nU-OF for emacs-orgmode@gnu.org; Fri, 29 Oct 2021 18:22:01 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: Re: tangle option to not write a file with same contents? Date: Fri, 29 Oct 2021 23:21:52 +0700 Message-ID: References: <583051.1635393898@apollo2.minshall.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 In-Reply-To: <583051.1635393898@apollo2.minshall.org> Content-Language: en-US Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 3 X-Spam_score: 0.3 X-Spam_bar: / X-Spam_report: (0.3 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-2.512, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , 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=1635524653; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jA6IIgCfC9SNDZ5V3LN2aEb//9D6AZO+pRJirwAYB0s=; b=sgQBMZDlMTIM8otbJLlo+dipc8Jscqp7lM6TqQOd+GqX7c8G5jJ/dlM4IVEXO/rkXK9XLn d6Zq3uIZb1RbIxR0oTFaVDqZ/lxgc8gJIju9k7Hdo9dMrAT55VHuvYC7fyLJl1u3NrJvcP M6a2scJKK3O+aFuPvcFnpB5ZZ+fFgSIYrdZtD6dQ6ZapsjbLZxJDbV2ivlcm0+YBCteGX5 MlA87m/aQJwVwc42pyMbMyNroDo7H6BHEBQzi01VZJzYTglPyZuYCgOedP/LMs/kV+ARTU px9wz7RxCvR5fyCaR3OIIGHjhi5yOtrkjYP5jNZ8bvcOlJF8BNdSTBx9E8wQ9A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1635524653; a=rsa-sha256; cv=none; b=GbGZa9/LNO21qbsouLm/loIiTcmtJsBhEsfE9COBTS/A8oz1DAe8Zys0dsN1JPK3eJ/3pE fEXn4Dm7XsSYvG3mTpcHdY+YNft8OWU/Yv4u4M3X2mInyll+jRh+j4cMqjOcxtJ9yWBx2T Dvqx275jcHO1ezzEUbyDPohojIs2fFPmcqaBkFhhVn3t1yhw0v2q1PnIgohvdBM06SZLd5 cSIg/7h9JKlP73snWWijJVa4Ds+ClaUJCoLzjUvzRcKTejpXgO2yEMukcIkP+Tn6wG3Zrd ZpWJSZQiI+QdjXOikLWYe1wWbPUxPzHbOJgKCjb6kZwQtb6WZKzYKT3tWeMpKQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (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: -0.82 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (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: 2832430049 X-Spam-Score: -0.82 X-Migadu-Scanner: scn0.migadu.com X-TUID: dzkZhEjmNJcL On 28/10/2021 11:04, Greg Minshall wrote: > > i wonder if it would be reasonable to add an option such that, when > tangling, `org-babel-tangle` would not write a file with the > already-existing contents of the target file? Are you going to celebrate a decade of the feature request? https://list.orgmode.org/orgmode/CAFDswJtMzFZgRQqsFtiQNT7c1uFE7HV4kek5j9akx1yAdWZZEg@mail.gmail.com/T/#u Holger Hoefling @ 2011-11-18 13:17 UTC Not overwriting unchanged source code files when tangling > this would be helpful, e.g., for those of us who use make(1)-based work > flows. I agree with you, make is wide spread and fast tool that is really convenient in simple cases. Some hash-based build systems are mentioned in that thread. Since that time more more similar tools have appeared, e.g. buck, reimplementations of DJB's redo https://cr.yp.to/redo.html > then, if this might generally be thought useful, i wonder if this should > be implemented as specifically this, or whether we might implement a > callback at the appropriate point in `org-babel-tangle` asking whether > or not to proceed. (then, the user's callback routine could do the > comparison.) > > if we do "specifically this", i would suggest that this comparison be > dead simple: read in the existing file's contents into some hidden > buffer, and use `compare-buffer-substrings` to compare point-{min,max} > of both. Tom Gillespie mentioned that it is easy to lost modifications of tangled files created during debugging. https://list.orgmode.org/orgmode/CA+G3_PNo8i8U9rOrC8BBydjEv9=LKgtJBopwX9J6vyNXdnjtXg@mail.gmail.com/T/#u I think, some header may be added to tangled file containing hash of rest part of file. So the file may be checked for user modifications before overwriting, that hash may be compared with the new buffer to keep existing file in place. It seems `compare-buffer-substrings` has more logic than just byte to byte comparison. Is it to handle alternatives for unicode character alternatives? For tangled buffer it should be size that is checked first...