> I noticed that you modified argument order of a public function > `org-babel-detangle' -- is it possible that you retain the order of > arguments?
Good catch - I think I changed the order so that it would match the interactivity of its sister function `org-babel-tangle', and I think in a previous rendition of ob-tangle-sync.el, I called `org-babel-detangle' interactively. But I see now that I no longer directly call it anywhere in my edited code, so I can easily change it back. Attached is a patch Best On Wed, 3 May 2023 at 04:35, Ruijie Yu <rui...@netyu.xyz> wrote: > > Mehmet Tekman <mtekma...@gmail.com> writes: > > > Hello again, sorry for the delay - I had some holiday time off > > that couldn't wait ;-) > > > > 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 <action>' in the header. > > > > 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. > > > > These functions work at the whole buffer and at the per-block > > level. The `org-babel-tangle-sync' functions automate this > > process by hooking into the `after-save-hook' and tangling / > > detangling the current block. > > > > I feel that I should write what the main motivation for this is: > > Dotfiles that are always in sync with the org-mode files they > > stem from. > > > > Hope this turns into something big! > > Best, > > > > Mehmet > > > > [4. application/x-patch; > 0005-lisp-ob-tangle-sync.el-Automatic-synchronization-of-.patch]... > > > > [5. application/x-patch; > 0004-lisp-ob-tangle.el-Sync-aware-tangle-function-with-be.patch]... > > > > [6. application/x-patch; > 0002-lisp-ob-tangle.el-Sync-action-aware-detangle-functio.patch]... > > > > [7. application/x-patch; > 0003-lisp-ob-tangle.el-Tangle-function-made-aware-of-remo.patch]... > > > > [8. application/x-patch; > 0001-lisp-ob-tangle.el-Detangle-a-single-block.patch]... > > > > [9. application/x-patch; > 0006-etc-ORG-NEWS-lisp-ob-tangle.el-Added-news-and-name.patch]... > > I noticed that you modified argument order of a public function > `org-babel-detangle' -- is it possible that you retain the order of > arguments? > > The accumulated change you proposed is this: > > -(defun org-babel-detangle (&optional source-code-file) > +(defun org-babel-detangle (&optional arg source-code-file ignore-header) > > What I think it should be: > > (defun org-babel-detangle (&optional source-code-file arg > ignore-header) ...) > > This way, existing (external) users of this function can rest assured > that their code is not broken by your patchset. Thoughts? > > -- > Best, > > > RY > > [Please note that this mail might go to spam due to some > misconfiguration in my mail server -- still investigating.] >
From 3399279e2c5c2a56076fa85adffffe7aa5c2ca74 Mon Sep 17 00:00:00 2001 From: MT <mtekma...@gmail.com> Date: Wed, 3 May 2023 09:47:34 +0200 Subject: [PATCH 7/7] lisp/ob-tangle.el: Restore argument order in org-babel-detangle * ob-tangle.el (org-babel-detangle): Change `source-code-file' to be the first argument again for external usage. This changes the prefix argument functionality, which is replaced by a much easier `single-p' argument to denote whether a single block is being detangled. --- lisp/ob-tangle.el | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lisp/ob-tangle.el b/lisp/ob-tangle.el index f199c77bc..fde6683a6 100644 --- a/lisp/ob-tangle.el +++ b/lisp/ob-tangle.el @@ -660,13 +660,13 @@ by `org-babel-get-src-block-info'." (org-fill-template org-babel-tangle-comment-format-end link-data)))) ;; de-tangling functions -(defun org-babel-detangle (&optional arg source-code-file ignore-header) +(defun org-babel-detangle (&optional source-code-file single-p ignore-header) "Propagate changes in source file back original to Org file. This requires that code blocks were tangled with link comments -which enable the original code blocks to be found. With one -universal prefix argument, only detangle the block at point. If -IGNORE-HEADER then detangle regardless of `:tangle-sync' status." - (interactive "P") +which enable the original code blocks to be found. If SINGLE-P +is t then only detangle a single block. If IGNORE-HEADER then +detangle regardless of `:tangle-sync' status." + (interactive) (save-excursion (when source-code-file (find-file source-code-file)) (let ((counter 0) (skip-counter 0) (tang-counter 0) end) @@ -677,7 +677,7 @@ IGNORE-HEADER then detangle regardless of `:tangle-sync' status." ((string= action "export") (setq tang-counter (1+ tang-counter)))) (setq counter (1+ counter)))))) - (if (equal arg '(4)) + (if single-p (funcall single-block-metrics) (goto-char (point-min)) (while (re-search-forward org-link-bracket-re nil t) -- 2.40.1