Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwind protect for describe key #148

Merged

Conversation

andyjda
Copy link
Contributor

@andyjda andyjda commented Dec 14, 2022

As mentioned by tangxinfa in a comment to the original describe-key issue, some times the advice and hook created within the describe-key function are not removed (as would be expected). This can cause errors down the line.
This issue was caused by the fact that

(remove-hook 'help-fns-describe-function-functions
                 #'god-mode--help-fn-describe-function)

was at the end of god-mode-describe-key, without taking into account that, in cases when god-mode-describe-key exits abnormally, this last part is never executed.

The solution is to use the special form unwind-protect which allows us to specify "unwind-forms" that are always executed, even if the body of our function exits abnormally (see the documentation for more details)

Copy link
Collaborator

@darth10 darth10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix @andyjda!

LGTM, not sure why I didn't think about using unwind-protect earlier.

@darth10 darth10 merged commit 69a7415 into emacsorphanage:master Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants