Start a new topic

Sync only list of files specified in init.org

I have 3000+ org files total split across subfolders (org-roam!), so syncing subfolders takes forever. The app has been syncing since yesterday morning and it's only gotten through <500 files.


In Emacs, you can specify a list of org-agenda-files, including files in subfolders. I only use beorg to read my agenda, so I only need my org-agenda-files synced. With the new subfolders feature (+ maybe the ability to exclude particular files), is it possible to selectively sync only my list of agenda files, even if some of them are in subfolders?


In response to my related ticket, Matthew suggested one potential solution for more advanced users: write a Scheme function that could be defined to return true if a particular file is to be included in the sync. Unfortunately I don't know much Scheme, so any help or alternative ideas would be appreciated!


Not good at writing Lisp/Scheme, but I imagine this function would take an argument and compare it against a list.  You could probably find Lisp examples in Emacs packages and then convert to Scheme.  I think scheme.org has documentation on the language.


Another option might be to redo your syncing process on the Emacs side.  Since the purpose of syncing here is to get the necessary files to BeOrg, there isn't much of a reason to sync org-roam stuff as well.  You could probably use 'rsync' or 'syncthing' to only sync up the files that need to go across to BeOrg.  This would just require some shell scripting (although syncthing does have a GUI).


Even if you're syncing with other Emacs systems and want to sync all the files for that purpose, it might be easier to setup a separate sync for BeOrg that strips the list of files down to what you need for BeOrg.  Then, you can use the normal sync process in BeOrg.

Here is an example of how this will work in the next release:


(define (sync-ignore-file path) (check-prefixes path '("ignore1/" "ignore2/" "private.org")))


In the above example beorg will ignore any files in the ignore1 and ignore2 folders, and also the file private.org. A user could define sync-ignore-file to do more complex matching if required.


I hope to get this update out a little later this month.


2 people like this
@mathew has this been released? Does this go into init.org as well?

Matthew,


Could you also remind people where to find the latest documentation on Scheme functions recognized by Beorg?  Perhaps put a link on beorg.app...?

I found a mention of it here: https://appsonthemove.freshdesk.com/support/discussions/topics/14000020176



I have the following in my init.org:


```

  (define blacklist '("1.org" "2.org"))

  (define (sync-ignore-file path) (member path blacklist))

```


but I see in the log that both `1.org` and `2.org` are being examined for syncing. What am I missing?

sync-ignore-file has been released. If you would like to use this just redefine that function in your init.org file.


I've just uploaded the latest library.org file to beorg.app. You can find this at https://beorg.app/manual/library-org/. It is linked to from the Learning > Scripting page. You can also find this in beorg itself (which is always up-to-date from the REPL, button top right on the Settings tab.


1 person likes this

Hi Dmitry - check the beorg log (see bottom of Settings tab) and look for a line such as "Remote file not newer than local file" to see how beorg is seeing the names of those files. path will be a full relative path to your org folder - so if, for example, 1.org is in a subfolder then you would need a different check.

Oh, just took a look at Beorg > Learning > Scripting and found the link to library.org.  One problem:


Library.org has some long lines and the box it is displayed in on the web page cuts off the lines.  There is a horizontal scrollbar way at the bottom of the box, but, if you scroll all the way down to find it, you lose context and it is impossible to see how far to scroll right.


Can that be fixed?

I've added links so you can download library.org on the website and view in Emacs or another text editor. I have also included the BiwaScheme source file that beorg uses and some additional JavaScript which extends the Scheme functions. This should hopefully give a complete picture of what is available for use in the Scheme scripting in beorg.


1 person likes this

Here's what's sort of working for me:



```

    (define blacklist '("file.org"))

    (define (sync-ignore-file path)

        (log-debug (format "-- Examining file ~s" path))

        (member path blacklist))

```


I have 600 entries in the blacklist. I suspect that this is causing performance degradation instead. In the log, I see "Examining file" entries and they last for about 20 seconds. Mean while I can't make any changes to the agenda. So this is not the way to go.


Any other thoughts on how to optimize synchronization?




Hi Dmitry. What sync method are you using (and approximately how many files is beorg checking to see what needs syncing)?


I personally have "Auto sync on modify" turned off on the Settings tab. beorg will still sync when moved into the foreground/background but not after each change.

Hi Matthew, 


I have roughly 1700 .org files and I use dropbox. 


I tried using iCloud which seems more performant but it stopped syncing my org directory at some point, I suspect because of the .git folder -- I use git-auto-commit module.

I'm submitting a beorg update to Apple which I'm hoping will help. It looks as though the issue wasn't in the sync itself, but when beorg was trying to work out what name to use for each file - and making too many requests to it's database of cached .org files. I was experiencing a similar issue and with the fix beorg feels much snappier. Look out for 3.27.0 in the coming days.

Hey Matthew, revisiting this to see if you have any thoughts. My org dir has grown to 2000+ files and Dropbox sync has slowed down significantly.


I spent a bit of time cleaning things up and crafting an init.org that has taken the sync from 2m+ to just under 1 minute. Here's the relevant portion: https://gist.github.com/dmitrym0/9e81b746136a538ed5e65fb047433b05


Do you see any ways to speed the sync up further or is it just a consequence of having to iterate over so many files?

Login or Signup to post a comment