emacs-orgmode
[Top][All Lists]
Advanced

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

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


From: Mehmet Tekman
Subject: Re: [ANN] lisp/ob-tangle-sync.el
Date: Thu, 27 Apr 2023 08:27:23 +0200

Ruijie Yu <ruijie@netyu.xyz>  writes:

> Great idea!  Some inline comments below.
>
> You only need to say #'expand-file-name instead of the quoted lambda.
> Also, you need to set the variable, otherwise the variable
> `org-babel-tangle-sync-files' is undefined.
>
> What I have in mind is this:
>    :set (lambda (var val) (set var (mapcar #'expand-file-name val)))
>
> Here you don't have to use `progn' because it is implied from 
> `save-excursion'.
>

Thanks! I've made your changes, and I've also incorporated John
Wiegley's comments about using "import" instead of "pull" as a
tangle-sync action word (small diff attached).

I've also written up my changes in the ~etc/ORG-NEWS~ and
targeted my custom variable for the 9.7 release (diff attached).

> Is there possibility to have a local minor mode (without introducing too
> much code changes)?

I initially tried it this way, but the problem is that an org
source block buffer might be in sync-mode, but it's
corresponding tangle file might not be, making any changes
asymmetric.

Another issue is in order to see the changes in the tangled file,
the tangle buffer needs to be reverted (with user prompt) which
then switches off the sync-mode for that buffer on reload.

One way around this (and it's something I implemented 3 years ago in
my messy org-tanglesync[0] MELPA code) is to set an explicit list of
"sync files", and then for Emacs to parse every =:tangle= header in a
given file when loaded (via =org-src-mode-hook=) to create an alist of
config files and their associated tangled files[1], such as
=((file1.conf . (tanglefile1.txt tanglefile2.txt etc)))=. Then, for
example, when ~tanglefile1.txt~ is loaded, Emacs knows that it should
load the sync-mode too.

This approach works reasonably well when the "sync files" list is
mandatory, but it's also prone to errors if a sync file is edited and
the alist of config files isn't updated, and the user would also lose
the flexibility of having ~ob-tangle-sync~ function everywhere.

I think a global minor mode is really elegant in this regard and I
wish I knew about it 3 years ago!

Best,
Mehmet


0: https://gitlab.com/mtekman/org-tanglesync.el
1: 
https://gitlab.com/mtekman/org-tanglesync.el/-/blob/master/org-tanglesync.el#L400-L410

Attachment: etc_ORG-NEWS.diff
Description: Text Data

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


reply via email to

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