Kungsgeten / yankpad

Paste snippets from an org-mode file
MIT License
216 stars 18 forks source link

Issue with yankpad-category-descriptions in empty org file #66

Closed ag91 closed 4 years ago

ag91 commented 4 years ago

Hi! I have been scratching my head lately because any time I was trying to insert an org-mode snippet in an empty org file I would get:

org-back-to-heading: Before first headline at position 3 in buffer test.org

If you want to reproduce just create an empty org-mode file and call (yankpad-insert), really (yankpad-category-descriptions "") for the minimal reproduction step.

After some inspection of yankpad.el I found the possible culprit: apparently yankpad-category-descriptions uses (org-narrow-to-subtree) which simply cannot work because an empty org-mode file has no subtree in it. I wonder if you designed the function this way for a reason because I am not sure I get what yankpad-category-descriptions actually does. Any chance you could ignore the errors like (ignore-errors (org-narrow-to-subtree))? Would that make sense to skip the narrowing if no org headline is in there?

Thanks for Yankpad!

Kungsgeten commented 4 years ago

Hi! For me it works fine to run (yankpad-insert) at the top of an empty org-mode file.

yankpad-category-descriptions shouldn't be executed from outside the yankpad-file, so that functions shouldn't be called in the context of your empty file. It could be something going on with your yankpad-file, or there might be some bug in my code (maybe both). If you could turn on M-x toggle-debug-on-error and post the result here, and maybe also your yankpad-file if it isn't private.

ag91 commented 4 years ago

Ah! You are right, this was an issue on my side. I checked again my yankpad.org and I found out that recently I deleted a heading that I included in org-mode:

So my org-mode heading in the Yankpad file starts with:

When I removed the included heading that did not exist anymore, everything worked fine again.

Sorry for the noise! And thanks for pointing out it could be on my side: next time I will try to reproduce with a pristine Yankpad file before submitting an issue :P

On Sun 30 Aug 2020 at 23:44, Erik Sjöstrand notifications@github.com wrote:

Hi! For me it works fine to run (yankpad-insert) at the top of an empty org-mode file.

yankpad-category-descriptions shouldn't be executed from outside the yankpad-file, so that functions shouldn't be called in the context of your empty file. It could be something going on with your yankpad-file, or there might be some bug in my code (maybe both). If you could turn on M-x toggle-debug-on-error and post the result here, and maybe also your yankpad-file if it isn't private.