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

Toggle fixes when purpose-mode is toggled #180

Merged
merged 2 commits into from
Mar 9, 2021
Merged

Toggle fixes when purpose-mode is toggled #180

merged 2 commits into from
Mar 9, 2021

Conversation

bmag
Copy link
Owner

@bmag bmag commented Mar 6, 2021

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

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.
window-purpose-fixes.el Outdated Show resolved Hide resolved
(defmacro purpose-advice-syncer (symbol where function)
"Return a function that adds or removes an advice, depending on
the value of `purpose-mode'."
`(lambda ()
Copy link
Collaborator

@wyuenho wyuenho Mar 6, 2021

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.

  1. Make a function name based on the symbol given, i.e. (intern (format "purpose-%s-advice" symbol))
  2. Check for the function id'ed by the symbol's existence, if exists, return the symbol
  3. otherwise, make that function and return its symbol.

Copy link
Owner Author

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.

Copy link
Collaborator

@wyuenho wyuenho Mar 9, 2021

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.

window-purpose-fixes.el Outdated Show resolved Hide resolved
window-purpose-fixes.el Outdated Show resolved Hide resolved
@bmag
Copy link
Owner Author

bmag commented Mar 9, 2021

Fixed the issues, should be good to go now.

Copy link
Collaborator

@wyuenho wyuenho left a comment

Choose a reason for hiding this comment

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

LGTM!

@bmag bmag merged commit 655df54 into master Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Purpose fixes do not uninstall cleanly when purpose-mode is off
2 participants