rudolfochrist / interleave

Emacs minor mode to interleave notes and text books
329 stars 18 forks source link

Create new notes in the correct order [Feature] #8

Closed kaushalmodi closed 9 years ago

kaushalmodi commented 9 years ago

When creating new notes, they are always appending at the bottom of the file.

So if you first made notes for page 10 and then for page 1, the page 1 notes will end up at the bottom of the file.

The notes will be easier to access if the page order is maintained in the notes (page 1 notes, followed by page 2 notes if present, followed by page 3 notes if present, and so on).

One way would be to scan for which page notes already exist in the org file and then insert notes for the new page at the correct location.

This can be made a defcustom var.

rudolfochrist commented 9 years ago

Entries are now sorted after quit. 178d751ac6bc956785e6e896871a7fd0f9db157d

kaushalmodi commented 9 years ago

The sorting doesn't seem to work for me.

I have following page notes in order: pages 33, 37, 42, 7

I take the cursor to the beginning of the buffer and eval (interleave--sort-notes 'asc). It says

Sorting entries... done

But nothing is sorted.. the notes stay in the same order.

kaushalmodi commented 9 years ago

Ah, org 'thinks' that 7 > 42! It needs to be 07!

kaushalmodi commented 9 years ago

Here's my "hackish" attempt to fix it: https://github.com/kaushalmodi/interleave/commit/50939fa1de806c023cd49f1aa3f82ce88de41f84

I didn't do a pull request but I am sure there must be a cleaner way to make the org-sort-entries to work correctly.. probably by specifying a sorting function?

I call this a hack because it won't work reliably unless you convert all the existing note entries to have that property value in "%06d" format.