awth13 / org-appear

Toggle visibility of hidden Org mode element parts upon entering and leaving an element
MIT License
375 stars 19 forks source link

Errors in org-appear--post-cmd #21

Closed DarwinAwardWinner closed 3 years ago

DarwinAwardWinner commented 3 years ago

In certain circumstances, org-appear--post-cmd throws (user-error "Cannot move further up"), which I think is thrown from org-backward-element. The call stack also includes org-appear--hide-invisible and font-lock-ensure, but that's as far as I've gotten with debugging via inserting message calls. Unfortunately, It seems to be impossible to get a backtrace from a function in post-command-hook, because any error causes Emacs to just delete the function from post-command-hook. And I can't figure out how to get org-appear--post-cmd to throw the same error outside of post-command-hook. Once the hook is removed, org-appear stops working.

One way to semi-consistently trigger this error is to mess around with C-c C-c in tables with formatting in them, e.g.

* Bad org-appear in table
| This         | is     | a         | table |
|--------------+--------+-----------+-------|
| *Bold element* | /Italic/ | _underline_ | ~code~  |
| *Bold element* | /Italic/ | _underline_ | ~code~  |
| *Bold element* | /Italic/ | _underline_ | ~code~  |

Put that in an org-mode buffer, enable org-appear-mode, and then start moving around the table and hitting C-c C-c. You should see the error at some point, usually on the 2nd or 3rd cell that you try.

awth13 commented 3 years ago

Thank you, @DarwinAwardWinner! I usually toggle org-appear-mode on and off depending on what I'm doing as I don't like it being always on and moving things. Without your input, I probably wouldn't have encountered these issues.

That being said, I can't reproduce this one. Moreover, org-appear doesn't call org-backward-element at any point, as far as I know.

Did this occur after or before you implement the fixes proposed in #19? What is your Emacs/Org version?

DarwinAwardWinner commented 3 years ago

Hmm, I can't reproduce this from emacs -Q, so it might be a bad interaction with some other part of my org-mode config. I'll see if I can figure it out later and report back.

doolio commented 1 year ago

I see this error after upgrading to Org mode version 9.7-pre (release_9.6.7-649-g85b747 @ /home/doolio/.emacs.d/straight/build/org/). I have org-appear configured to load after Org which is itself lazily loaded. This error then appears as soon as I open the first org file. Unfortunately, this doesn't trigger the debugger because as reported above any error causes Emacs to just delete the function from post-command-hook and once the hook is removed, org-appear stops working.

If it matters I'm still running GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2023-02-23, modified by Debian.