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

Shouldn't org-appear (require 'subr-x)? #26

Closed nchachereau closed 3 years ago

nchachereau commented 3 years ago

Hello,

Just installed using straight, and when trying it out I got errors such as Error in post-command-hook (org-appear--post-cmd): (invalid-function (elem (org-element-context))).

It seems that the issue are the when-let macros that were not correctly understood when org-appear.el got compiled to an .elc file by straight when it "built" the package.

Adding (require 'subr-x) to the file seems to fix the issue for me. (I'm still on GNU Emacs 26.3, in case that makes any difference.)

Thank you for this package, looking forward to using it, now that it works :+1:

awth13 commented 3 years ago

Hello and thank you for the heads up, @nchachereau!

I think you're right but I will have to investigate it some more since there seems to be some weirdness going on with when-let. It does compile without subr-x on 27.2, puzzlingly.

nchachereau commented 3 years ago

Looking into it, the difference seems rather simple. My copy of subr-x does not have autoload cookies for when-let and if-let, unlike in current Emacs source - current, but since, according to blame, that change was introduced two years ago, I guess it is a part of Emacs 27.

I am no elisp expert, but I guess you might just as well require subr-x. This would bring support to Emacs 26 and make no difference for users of later versions, since it is going to get loaded anyway due to the autoload cookies. Unless I am mistaken of course.

(Regarding the weirdness you link to, it seems to be a red herring: according to the creator of straight.el on Reddit, "if-let is not obsolete. It was previously planned to be made obsolete between Emacs 25 and Emacs 26, but then the developers changed their mind.").

P.S. I plan upgrading my Emacs soon-ish… I might never have noticed this problem :stuck_out_tongue_closed_eyes:. P.P.S. What intrigues me a bit is that in my tests it seemed to work when I used org-appear without compiling it. Maybe some other part of my config loads subr-x, while it wasn't loaded when straight "built" it. I would need to create a minimal test with emacs -Q, but I am not sure it's worth it.

awth13 commented 3 years ago

Well, you've pretty much done my investigation for me :) Thanks for taking the time!

I added an explicit require for subr-x in 4015980f2c587d61def9e14372b86b1eb053ec2e.

P.S.

Maybe some other part of my config loads subr-x, while it wasn't loaded when straight "built" it

This is almost certainly the case.

nchachereau commented 3 years ago

Well, you've pretty much done my investigation for me :) Thanks for taking the time!

Just a small way of giving back! Just pulled the last commits and tested, works as expected. Thanks!