emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ANN] lisp/ob-tangle-sync.el


From: Mehmet Tekman
Subject: [ANN] lisp/ob-tangle-sync.el
Date: Wed, 26 Apr 2023 16:48:12 +0200

Dear fellow org-users,

I would like to contribute some a new library into org-mode, which
performs automatic synchronization between tangled files and their
org-mode source blocks via a global minor mode
`org-babel-tangle-sync-mode' which uses the after-save-hook.

Full disclosure:

I created a MELPA package with similar functionality 3 years ago, but
it did not use the existing org libraries much and needlessly
reinvented many wheels:

  https://gitlab.com/mtekman/org-tanglesync.el

This is a complete (and very concise) rewrite that uses the org
framework and that I wish to incorporate into org-mode itself. My
changes to the org-mode main branch can be found here:

  https://gitlab.com/mtekman/org-mode (ob-tangle-sync branch)


A toy example of what this does would be as follows:

- Source =emacs_conf= org-mode file

#+begin_src bash :comments yes :tangle ~/.bashrc
export PATH=$PATH:/opt/bin
#+end_src

- Tangled =~/.bashrc= file

#+begin_src bash
# [[file:repos/_mtekman/emacs_conf.org::*bashrc][bashrc:1]]
export PATH=$PATH:/opt/bin
#+end_src

By activating =org-babel-tangle-sync-mode=, I can edit either of those
buffers and every time that I save it would automatically update the
other.  If I add the header argument =:tangle-sync <action>= then I
can specify an action of:
- skip :: do nothing, just save the buffer, even if the sync mode is active
- pull :: only pull changes from =~/.bashrc= into the Emacs_conf org-mode file
- export :: only export changes from Emacs_conf to =~/.bashrc=, even if called
            from =~/.bashrc=
- both :: (default) synchronize freely between tangled file and source block
          (the is also the nil value)

By default, the mode acts on any org-mode source block with =:tangle=
headers and any tangled file with file comments. This can be changed
by setting a list of "sync files" via =org-babel-tangle-sync-files=
which only acts if the source block exists in a file given in that
custom variable.


I'm currently trying to write tests for the library, but I would also
greatly welcome any feedback and comments on the currently written
code (attached as a diff, and also available in the above org-mode
repo)

As this is also my first time submitting directly to GNU Emacs, I, um,
might also need some hand-holding. I think I've followed the main
org-contribute guidelines, but I've likely missed or glossed over a
step or two.

Cheerful regards,

Mehmet

Attachment: lisp_ob-tangle-sync.el
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]