rudolfochrist / interleave

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

Allow other kind of headings #38

Closed Yevgnen closed 7 years ago

Yevgnen commented 7 years ago

Since I use org-ref to handle my references, sometimes it may necessary to insert bibliography into notes. I use a individual heading to keep these thing but it seems that interleave does not allow any other headings which doesn't have property :interleave_page_note. Thus this alerts an error when quitting in docview as

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  string-to-number(nil)
  #[nil "\300\301\302\303\"!\206\n\304\207" [string-to-number org-entry-get nil "interleave_page_note" -1] 4]()
  #[0 "\305\307U\203\310-!\205D\311\312\313\314!!!\207\305\315U\203*\310-!\205D\303\312\313\314!!!\207\305\316U\2039\317`\320\"\206D\321\207\305\322U\203c\212\323 \210`)\324.\325#\204W\324/\325#\203_\326\313\321!!\202b\327\306!\207\305\330U\203\207\212\323 \210`)\324\3310\332Q\325#\203\203\326\313\321!!\202\206\327\306!\207\305\333U\203\250\212\323 \210`)\3241\325#\203\244\326\313\334!!\202\247\327\306!\207\305\335U\203\311\212\323 \210`)\3242\325#\203\305\326\313\334!!\202\310\327\306!\207\305\336U\203\342\3243\337 \325#\203\337\340\313\341!!\2074\207\305\342U\203\362\343\344\302\242\"\206D\345\207\305\346U\203\310-!\205D\313\341!\2115\235\203
\347\202\350\3306\235G!Z\207\305\351U\203?\301\242\2039\304\301\242 \240\210\304\242;\2036\304\303\304\242!\240\210\304\242\207\352\353\301\242\"\207\352\354\300\242\"\207" [(102) (#[nil "\300\301\302\303\"!\206\n\304\207" [string-to-number org-entry-get nil "interleave_page_note" -1] 4]) (nil) downcase (1) 102 (22604 64124 425733 0) 110 looking-at string-to-number org-sort-remove-invisible match-string 4 97 107 get-text-property :org-clock-minutes 0 116 outline-next-heading re-search-forward t org-time-string-to-seconds float-time 99 "^[  ]*\\[" "\\]" 115 1 100 112 point-at-eol string-to-char 2 114 org-entry-get nil "" 111 - + 102 error "Invalid key function `%s'" "Invalid sorting type `%c'" org-complex-heading-regexp org-ts-regexp org-ts-regexp-both org-ts-regexp1 org-scheduled-time-regexp ...] 6]()
  sort-build-lists(#[0 "\301\300\242\302\303#\203
\304\224b\207db\207" [("^\\* +") re-search-forward nil t 0] 4] #[0 "\300 \301\302\303\304\305!\306\"\307$\216\3101\311\312!0\202\210db)\207" [match-data make-byte-code 0 "\301\300\302\"\207" vconcat vector [set-match-data evaporate] 3 (error) outline-forward-same-level 1] 7] #[0 "\305\307U\203\310-!\205D\311\312\313\314!!!\207\305\315U\203*\310-!\205D\303\312\313\314!!!\207\305\316U\2039\317`\320\"\206D\321\207\305\322U\203c\212\323 \210`)\324.\325#\204W\324/\325#\203_\326\313\321!!\202b\327\306!\207\305\330U\203\207\212\323 \210`)\324\3310\332Q\325#\203\203\326\313\321!!\202\206\327\306!\207\305\333U\203\250\212\323 \210`)\3241\325#\203\244\326\313\334!!\202\247\327\306!\207\305\335U\203\311\212\323 \210`)\3242\325#\203\305\326\313\334!!\202\310\327\306!\207\305\336U\203\342\3243\337 \325#\203\337\340\313\341!!\2074\207\305\342U\203\362\343\344\302\242\"\206D\345\207\305\346U\203\310-!\205D\313\341!\2115\235\203
\347\202\350\3306\235G!Z\207\305\351U\203?\301\242\2039\304\301\242 \240\210\304\242;\2036\304\303\304\242!\240\210\304\242\207\352\353\301\242\"\207\352\354\300\242\"\207" [(102) (#[nil "\300\301\302\303\"!\206\n\304\207" [string-to-number org-entry-get nil "interleave_page_note" -1] 4]) (nil) downcase (1) 102 (22604 64124 425733 0) 110 looking-at string-to-number org-sort-remove-invisible match-string 4 97 107 get-text-property :org-clock-minutes 0 116 outline-next-heading re-search-forward t org-time-string-to-seconds float-time 99 "^[  ]*\\[" "\\]" 115 1 100 112 point-at-eol string-to-char 2 114 org-entry-get nil "" 111 - + 102 error "Invalid key function `%s'" "Invalid sorting type `%c'" org-complex-heading-regexp org-ts-regexp org-ts-regexp-both org-ts-regexp1 org-scheduled-time-regexp ...] 6] nil)
  sort-subr(nil #[0 "\301\300\242\302\303#\203
\304\224b\207db\207" [("^\\* +") re-search-forward nil t 0] 4] #[0 "\300 \301\302\303\304\305!\306\"\307$\216\3101\311\312!0\202\210db)\207" [match-data make-byte-code 0 "\301\300\302\"\207" vconcat vector [set-match-data evaporate] 3 (error) outline-forward-same-level 1] 7] #[0 "\305\307U\203\310-!\205D\311\312\313\314!!!\207\305\315U\203*\310-!\205D\303\312\313\314!!!\207\305\316U\2039\317`\320\"\206D\321\207\305\322U\203c\212\323 \210`)\324.\325#\204W\324/\325#\203_\326\313\321!!\202b\327\306!\207\305\330U\203\207\212\323 \210`)\324\3310\332Q\325#\203\203\326\313\321!!\202\206\327\306!\207\305\333U\203\250\212\323 \210`)\3241\325#\203\244\326\313\334!!\202\247\327\306!\207\305\335U\203\311\212\323 \210`)\3242\325#\203\305\326\313\334!!\202\310\327\306!\207\305\336U\203\342\3243\337 \325#\203\337\340\313\341!!\2074\207\305\342U\203\362\343\344\302\242\"\206D\345\207\305\346U\203\310-!\205D\313\341!\2115\235\203
\347\202\350\3306\235G!Z\207\305\351U\203?\301\242\2039\304\301\242 \240\210\304\242;\2036\304\303\304\242!\240\210\304\242\207\352\353\301\242\"\207\352\354\300\242\"\207" [(102) (#[nil "\300\301\302\303\"!\206\n\304\207" [string-to-number org-entry-get nil "interleave_page_note" -1] 4]) (nil) downcase (1) 102 (22604 64124 425733 0) 110 looking-at string-to-number org-sort-remove-invisible match-string 4 97 107 get-text-property :org-clock-minutes 0 116 outline-next-heading re-search-forward t org-time-string-to-seconds float-time 99 "^[  ]*\\[" "\\]" 115 1 100 112 point-at-eol string-to-char 2 114 org-entry-get nil "" 111 - + 102 error "Invalid key function `%s'" "Invalid sorting type `%c'" org-complex-heading-regexp org-ts-regexp org-ts-regexp-both org-ts-regexp1 org-scheduled-time-regexp ...] 6] nil <)
  org-sort-entries(nil 102 #[nil "\300\301\302\303\"!\206\n\304\207" [string-to-number org-entry-get nil "interleave_page_note" -1] 4] <)
  interleave--sort-notes(asc)
  interleave-quit()
  funcall-interactively(interleave-quit)
  call-interactively(interleave-quit nil nil)
  command-execute(interleave-quit)

One workaround is to manually add a :interleave_page_note for any other headings for a suitable value(in the reference case, a large one). What would the best workflow to do this ? Thanks !

rudolfochrist commented 7 years ago

This needs definitely code adjustments. Especially how interleave--sort-notes is implemented. The question is where should those headings be placed? At the beginning, at the end? Should all headings without interleave_page_note be sorted the same way or should this be specified for each heading individually?

Currently I think, sorting all headings that aren't page notes to the end is a good approach. But this needs some more thinking. Thank you for reporting this.

Regards, Sebastian

rudolfochrist commented 7 years ago

UPDATE:

The actual problem was that we gave the value of the interleave_page_note property to string-to-number. But this property can be nil, so it failed.

Headlines without page note property are sorted above those with this property (We use -1 for the lack of the property. I think this is the most sensible approach because this won't collide ever with the page note property. PDF pages won't be negative, hopefully :))