Start a new topic

Beorg removes empty lines between headings on sync

From what I understand Beorg should not remove the empty lines between subtrees i.e.


* Level 1

** Level 2

** Level 2

                           < empty space

* Level 1

** Level 2

** Level 2


but when I update an item from the agenda screen, sync via dropbox, and revert the buffer in Emacs the space between my headings is removed:


 * Level 1

** Level 2

** Level 2

* Level 1

** Level 2

** Level 2


This makes it more difficult to read my file as I prefer some empty space to delineate the subtrees.


4 people have this problem

Well, I understand as well the challenge of supporting all the various types of formatting, which is not what I'm asking. And actually, what I'm thinking is actually the opposite, I think it would be simpler to not auto format the headers and just keep the newlines as part of the content section of the header. This is how the newlines are interpreted in org-mode, for example, when we do a refile the newlines follow at the same time.


So my ideas would be to simply make it possible to disable the auto formatting so the newlines are kept as the content of the header.


The `(set! beorg-add-newline-between-headlines #t)`could be used for when we add an item from the Beorg UI (like the "add item" button)


Or another idea if we want to make it more configurable would be to make it possible to set `beorg-add-newline-between-level0-headlines` and `beorg-add-newline-between-level1-headlines` to a specific number of newlines (this one would be used by default) and also to make if possible to change the value from a file property so this can be changed from file to file

I agree, keeping the newlines as part of the header seems like a good solution. That would work perfectly in my case. If I could help somehow with these updates, I would be very happy! (I think that would just require an update when reading the files (keep the newlines as part of the internal representation) + output them to the file. We also need to consider the case of moving headlines or adding/removing, but I am fine with any behaviour here, ideally consistent to org mode implementation in Emacs.)

Great to see the detail in the above discussion. I will put some more thought into how best to accommodate these requirements.

I have been doing some work on this. It needs a little more testing, but seems to be working well.


I've defined two new Scheme variables:


  (defvar beorg-auto-lines-before-headlines #f
          "If #t then beorg will automatically add newlines before headlines, depending on the value of beorg-newlines-before-headlines. If #f then beorg will respect the number of lines before headlines already in a file, and only use beorg-newlines-before-headlines for new items.")

  (defvar beorg-newlines-before-headlines '(1)
          "The first item in this list is the number of blank lines to add before a first level headline, the second item the number of blank lines before a second level heading, etc. The last item in the list is the number of blank lines to add before all other headlines.")


This will probably be the default. It will add a blank line above each headline, regardless of what level it is. However if there are, for example, already 3 lines above a headline then it will remember that and reproduce those blank lines when it saves a modified version of the file.


If you wanted beorg to autoformat a file such that level 1 headlines always had 3 lines above them, level 2 headlines 2 lines, level 3 1 line and all other levels 0 blank lines you would add the following to your init.org:


(set! beorg-auto-lines-before-headlines #t)
(set! beorg-newlines-before-headlines '(3 2 1 0))


That's super exciting and exactly fits my needs. Actually, either of these two options would work wonders for me (the first one, `beorg-auto-lines-before-headlines`, being the preference). Let me know if I can help beta-testing that. Otherwise, looking forward to the new version. Thanks a lot! :-)

If anyone would like to help test this please raise a ticket and confirm the email address to send the test invite to.

Thank you, Matthew! I have just opened a ticket and provided my email address: https://appsonthemove.freshdesk.com/support/tickets/33584

Thanks Matthew for the new feature! I'm looking forward to trying this!


I just opened a ticket as well for my email to test!


Thanks and all the best

Thanks again, Matthew, for the awesome new Scheme variables. Sorry for delay with testing (I had flu), but I was just able to test it. TLDR: It works great, I found no issues and it works even better than I expected.


Long story - this is what I have tested:

1) Just setting (set! beorg-auto-lines-before-headlines #t)

Actually, I think this is the default behavior now. It works perfectly. I tried updating tasks from the Agenda view and from the Files view - in both cases the newlines are respected (I was double checking the same files in Dropbox in VSCode).

I also tried removing, swapping tasks, adding tasks - it worked as expected.

2) Tried setting just for fun: (set! beorg-newlines-before-headlines '(3))

It also worked as expected. Small observation though: I think Beorg was treating this as '(3 3 3 3) instead. Meaning that when I have added a sub-headline, it also got 3 leading whitespaces. I changed this to '(3 0 0 0) and it now started working as expected.


For my personal taste, I have set the following:


(set! beorg-auto-lines-before-headlines #t) (set! beorg-newlines-before-headlines '(1 0 0 0))


And it works wonders for me! :-) Thanks again for great support.


I also think, based on my testing, that this is the current default, and I think it definitely makes sense.


Let me know if I can help with anything else. :-) I can also keep sharing some suggestions for improvements in Beorg (but really, with these changes, the app is so massively useful for me, any other small issues I encountered - they were just minor peculiarities).

Great to hear it is working for you. With regard beorg-newlines-before-headlines the last number in the list covers all headline levels not already specified. So in your example you can just write:


(set! beorg-auto-lines-before-headlines #t)
(set! beorg-newlines-before-headlines '(1 0))


This feature will be paired with a new advanced settings UI which allows for customising of many Scheme variables without needing to create an init.org, hopefully bringing these kinds of features to a wider audience.

Hello, firstly thanks a lot for the updates. As someone who uses 1 newline between all headings, I've been using the older option "beorg-add-newline-between-headlines" up until this last october update, and now use the new

(set! beorg-auto-lines-before-headlines #t)
(set! beorg-newlines-before-headlines '(1))

options.


I recently discovered a bug where this option is not respected. If I make a change to a heading from the Beorg Agenda view(single tapping an entry, changing State from TODO to DONE), it will wrongly remove the newline before the heading.

The strange part is, if I do the same change in the Beorg Notes view instead (single tapping the file, single tapping the heading in the outliner, same menu as in agenda view appears, doing the same change there), no newline is removed(correct behavior).

I hope it can be reproduced.

Trying to post a comment here it doesn't seem to work.

@sxwpb thanks for reporting this issue, and apologies for slow approval of your comment - the system I use seems to almost select comments at random to put into the approval queue. I'll take a look and see if I can reproduce this.

Hey, just wanted to say thanks for this new feature. I love beorg but found myself resisting adding TODOs and notes on the go because it would mess up my formatting. This update solves the problem. A genuine thank you for prioritizing this.

Login or Signup to post a comment