Index

Explaining Memo text-based file format

Sometime ago I started developing note-taking software called Memo for GNU/Linux. Before actually writing any code I designed a file format for Memo to use.

When designing a file format you need to think about what features you want the file format to have. For Memo, that was quite easy. Notes need date, an id and the actual note text. Each section is separated by a tab character. Tab is universal, it's easy to parse and it makes the output look clean and organized.

Memo 1.0 is released and the file format is stable. During the development of 1.0 I added a status section. Memo supports statuses UNDONE, DONE and POSTPONED.

The format of the file is following:

      id     status         date           content       
      |      |               |              |             
      |- id  |-U/D/P         |- yyy-MM-dd   |- actual note
      
      Sections are separated by a tab character	
    

Tagging

I've seen similar file formats with additional tags section. I decided that it would be unnecessary. Instead, Memo search functionality is written in a way that there are no need for separated tag section. You can embed "tags" in the content of the note, if you want to. Let's see an example:

11    U    2014-10-28    Pay @bills

Now you could do a search memo -f "@bills" and Memo would display all the notes with a "tag" @bills. Memo also supports searching with regular expressions, which make the search very powerful.

Id codes are static

Someone asked me why the id codes are not dynamic, meaning that why the codes are not always in order. For example if you have notes with ids 1, 2, 3 and 4 and you delete note with id 2. After that the output of Memo would look like this:

      1    U    2014-11-11   My note content
      3    U    2014-11-12   Another note
      4    U    2014-11-12   Something important here
    

As you can see, you now have notes with id codes 1, 3 and 4. Why not 1, 2 and 3? First of all, this is a feature, not a bug. Reason for this design decision is simple. You must be able to "trust" the content of the file and the output of the program. Memo is very scriptable and often used together with other programs such as Cron. It's very likely that you have a script which relies on a particular id code. Reordering the id codes after a delete operation would break that script.


Copyright © Niko Rosvall 2019