-
Notifications
You must be signed in to change notification settings - Fork 22
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
Toggle fixes when purpose-mode is toggled #180
Conversation
Toggle the integration fixes on when purpose-mode is activated, and toggle them off when purpose-mode is deactivated. Mainly, this means the relevant advices are now active only while purpose-mode is active.
(defmacro purpose-advice-syncer (symbol where function) | ||
"Return a function that adds or removes an advice, depending on | ||
the value of `purpose-mode'." | ||
`(lambda () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't calling (purpose-fix-install)
again install two instances of the same hook? You should be able to memoize a hook here. i.e.
- Make a function name based on the symbol given, i.e.
(intern (format "purpose-%s-advice" symbol))
- Check for the function id'ed by the symbol's existence, if exists, return the symbol
- otherwise, make that function and return its symbol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling it twice actually won't install two instances. Both calls will return equal closures, so add-hook
will treat them as equal and avoid duplicates in the hook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is only true in emacs-27, add-hook
doesn't use equal
in emacs-26 and below.
Fixed the issues, should be good to go now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Toggle the integration fixes on when purpose-mode is activated, and toggle them
off when purpose-mode is deactivated. Mainly, this means the relevant advices
are now active only while purpose-mode is active.
Fixes #166