From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 2Js8CeZnUmSuZAAASxT56A (envelope-from ) for ; Wed, 03 May 2023 15:55:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id iGT7COZnUmRS+AAA9RJhRA (envelope-from ) for ; Wed, 03 May 2023 15:55:50 +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 8CE46CEA8 for ; Wed, 3 May 2023 15:55:49 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puCwa-0004WR-RK; Wed, 03 May 2023 09:54:56 -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 1puCwY-0004Va-CW for emacs-orgmode@gnu.org; Wed, 03 May 2023 09:54:54 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1puCwW-0000uC-E2 for emacs-orgmode@gnu.org; Wed, 03 May 2023 09:54:54 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3f4000ec6ecso4876835e9.0 for ; Wed, 03 May 2023 06:54:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683122090; x=1685714090; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=LdZYIO8W49huQ1bMW6xXyKR/UrLfUyRMfhmt21Z0XDA=; b=mN6BXJZ7VYY3WDiQ9ETOpsoY5PS1V6FYzC6ZBBdYnuU81rPnRw2qrgFctwBGfWMWi9 /CMkn8qd/dXQBGh+Wlt7DJUVsMpEQazWfxsUogFyktHzocDdirEwF9Mz6cJzQuVBsVzs vxPdkim+L4YyFYuoylQsbUGswqeEHsViE0entyz4uCitJhsx8j4oQsGpELt22tUnSCiE zPNKmjo+QbDhlmIBTsm6rVsMJEF1vQnG0n4tvfPbivOoInhvDCl7da7E51Tr3ytm0O50 CrbLFF4LtePcGYoLlkUobrSASyXnWmgrd+ZemgfCrx38VcP6Qzl1rJQMklEQ2zVY8Z4z yqcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683122090; x=1685714090; h=mime-version:message-id:date:user-agent:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LdZYIO8W49huQ1bMW6xXyKR/UrLfUyRMfhmt21Z0XDA=; b=ClLdtuQk1LrOf5QvE7ob6J9OPtfZRUyzfTjnkDK9uT0x/iXuxxgfgEh6CDEOdD6cjE m8gHQKWu1129bZzdByDSn4JNKoInDwaVxSWiKJlrluytEuLTwOkZ2acSKLR82CDvJi5O 9kez7ac8yz0tOJVZD9so7jP27gzRWPwduM3IBzDINei36IS/EyGLgqisig6YLwtDHQAp NGG6TivSciebpW5RMNppsL+8oAyf9TYDYc3z35Gu3Qjdn7omMI/s+HORdYGmNGFAZPSi A3elAUGMvL+rHj73LXAPoiiByxDVORaqsHuFSlzfNny66wiJQrDOJu3jSAawxyJ9t9RQ 9zug== X-Gm-Message-State: AC+VfDyp+68XHv30Gn/BZyHvQmcSVlZuT6HACJdZzscr/g0ybTq2U8Qm AqopKk2dmX8woX24vFbZWJo6XHWYlS8= X-Google-Smtp-Source: ACHHUZ5vev7irZv9pf2nnTlBE+koLRg98GQC8RN+AVMhSDrA0T1OsnxI2J9vWVWmp+fOXAQFpVoDgA== X-Received: by 2002:adf:dc8c:0:b0:2f8:f775:c885 with SMTP id r12-20020adfdc8c000000b002f8f775c885mr170358wrj.6.1683122089927; Wed, 03 May 2023 06:54:49 -0700 (PDT) Received: from hayvan (pharma2-70.w2k.pharmakol.uni-freiburg.de. [132.230.165.170]) by smtp.gmail.com with ESMTPSA id p17-20020a056000019100b002fda1b12a0bsm34065337wrx.2.2023.05.03.06.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 May 2023 06:54:49 -0700 (PDT) From: Mehmet Tekman To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: [ANN] lisp/ob-tangle-sync.el In-Reply-To: <87r0rxabd4.fsf@localhost> (Ihor Radchenko's message of "Wed, 03 May 2023 11:43:51 +0000") References: <87r0rxabd4.fsf@localhost> User-Agent: Gnus/5.13 (Gnus v5.13) Date: Wed, 03 May 2023 15:54:48 +0200 Message-ID: <871qjx8qqf.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=mtekman89@gmail.com; helo=mail-wm1-x32d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 ARC-Seal: i=1; s=key1; d=yhetil.org; t=1683122149; a=rsa-sha256; cv=none; b=Zcqdt/vLxG6+8d9Ve3p9cqhNtq2fHg1MXnG5f3GmxrMK/vCMzs6uA2aiM06OEiCBJpqucL UpnGTLKYavMAiShVI/SR/k+Sby6AMiWeqq+mNeMmC7o47dnKo6wnvP3RlPmKaNZHHkcxK3 YyhuJ3UW+FGQLLNEddVqTG8S09ok1YJrRZgu27SXITVH6ry3WTLyhSyd47rkjNi1MIuiyL NP3Sz7MezD78sCqfJ56UcN07cnlzdxRXGRJ2NDxODSKWE/SSaAHuDpdOFGoIRbXaSqrLHj 1PFS+PYTOIbdq+BbQ/Tf4OAFhF23QQ7Jp5zSPaROuZJ2xA/v5UbVVIZumofH+A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=mN6BXJZ7; dmarc=pass (policy=none) header.from=gmail.com; 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=1683122149; 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=LdZYIO8W49huQ1bMW6xXyKR/UrLfUyRMfhmt21Z0XDA=; b=OhEhg9xbL1JYkEK2uBB7it2R2+MyuXFKy3FkKn2NuMj8SrNC3rlsZRxX604Ga2keo+ekiV CVTq0gmG08wIOpGYFLr+V+3XGt4BIoXIB4L7qWSrLiDXSW6/Wqcw6FFqNJw+OSPlEtGB6Q VimbvwVeSkJkuflN+Q2ufEnRhZ4ShJtmgzpXqnwc0PeUD7nTD+mBqYxRM2HVx+63cKEU4m dNBZPLMj457r08B1w6HmBsVHG69zfmmvsRQcCoTBHRaJzd86GJDsGEFyPzIDI4qGJrsFKl U/zGTVDmBBOK9b5CaiOSgMgo8Lo8nYw4NABp2Aknr4JqIcwp3f7OhJXaUYikIw== X-Migadu-Spam-Score: -8.51 X-Spam-Score: -8.51 X-Migadu-Queue-Id: 8CE46CEA8 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=mN6BXJZ7; dmarc=pass (policy=none) header.from=gmail.com; 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" X-TUID: GCCXoPSEEVWQ Ihor Radchenko writes: > Mehmet Tekman writes: >> >> One issue that I cannot seem to solve by myself is getting the >> `org-babel-tangle-sync-mode' to persist on the `after-save-hook' >> after it's been activated. My understanding of this hook is >> that it is global and persists across buffers, but I'm seeing >> some inconsistent behaviour that requires me to toggle the mode >> on and off again. > > Any hook can be local. > See LOCAL argument in help:add-hook Ah, that solves the problem immediately thank you! > Mehmet Tekman writes: > >> I've modified the ob-tangle.el file for the main tangling and >> detangling functions. Most importantly, both functions can now >> exchange information from the source Org mode file to the target >> remote tangle file in either direction, depending on whether the >> source Org file has `:tangle-sync ' in the header. > > Thanks! > >> The action is one of: >> >> - "export" = always transmit information from the source Org mode >> block to the target remote file. >> - "import" = always transmit information from the target remote >> file to the source Org mode block. >> - "skip" = skip the block. >> - "both" = transmit information from source block to target block >> or target block to source, depending on whether the >> tangle or detangle is called from the source buffer or >> the target buffer respectively. > > May it be better to make :tangle header argument compound? > Like ":tangle "file" export". Similar to :results header argument. See > "16.6 Results of Evaluation" section of Org manual. > That's a great idea I had not considered, and would definitely reduce the header bloat, especially since `:tangle-sync' *requires* the `:tangle' header to be there. > Also, some general comments on the patches: > Great! > 2. When naming private functions, "--" should be after library prefix: > org-babel--... > Thanks, I will rename `org-babel-detangle-single-block--from-source'. > 3. Please do not use private functions from third-party libraries. I am > talking about `cl--set-buffer-substring' in particular. > So initially I used `(setf (buffer-substring X Y) new-content)` but I recieved a warning from Emacs that it was an obsolete generalized variable. After some searching I found this entry in an emacs fork used the cl library: https://github.com/emacs-citar/citar/commit/809953a2191d0e3217ffbed9270be9b3cd6abfd2 Since `(require 'cl-lib)' is already imported in ~ob-tangle.el~, I did not think it was too taboo to use. How does one then set the buffer substring? > 4. Please make sure that docstrings clearly describe what the function > does, each of its arguments, and the expected return value. > In the patch, `org-babel-detangle--block-contents', NEAREST is > ambiguous. The actual meaning is "block at point or previous block". > > 5. Pay attention to buffer boundaries. In particular, remember that > buffer may be narrowed when you call a command and that expressions > like (+ 2 (line-beginning-position)) may resolve beyond > `point-min'/`point-max'. > > 6. Avoid using cryptic list functions like `cdadar' when you can use > something more readable. > > 7. When naming functions or macros, make sure that the name is roughly > describing the purpose of the function. In `org-babel-detangle', you > added `single-block-metrics' local function that does not only do the > metrics, but also (unexpectedly!) calls > `org-babel-detangle-single-block'. This is especially important for > local functions that lack docstring. > > 8. In `org-babel-tangle', (setq block-counter (+ 1 block-counter)) > appears to be misplaced into outer sexp level after your patch. Thanks for these, I will clean up and better document my code. > 1. Please make sure that patches do not leave Org in broken state in the > middle of the patchset. Your patch #1 adds two `defun's in the middle > of `org-babel-detangle', which is not right. > > 9. In commit messages, please mark newly added functions clearly. > Like "(org-babel-foo): New function. It does this and that." > Same for commit summaries - "lisp/ob-tangle.el: Detangle a single > block" is awkward. You should clearly indicate that you added > something new to the library. Apologies. I rebased and squashed all my commits into one, and then selectively staged hunks into seperate commits for the git format-patc process. For some reason the diff function decided that the new functions should exist right in the middle of an existing function and I was not sure how to resolve it at the time (though I have a better idea now). I will take better care with the messages. I tried to look for previous "[ANN]" postings in the mailing list that I could emulate, but didn't pay enough attention it seems. I'm finally using `gnus' as my mail client so I'm slowly getting into a more streamlined mindset that should be better at submitting and formatting patches. (To reply to a mailing list, I do a wide reply to the author and hope that the `Mail-Followup-To' header is used?) Apropos patches: Given how broken my current patches are, my next set of changes will be not contingent on the previous ones. I will start a new set of patches. I hope that's okay. Best, Mehmet