Skip to content

Commit

Permalink
Use nadvice.el instead of advice.el
Browse files Browse the repository at this point in the history
  • Loading branch information
darth10 committed May 29, 2020
1 parent 8b49ae9 commit cf0a453
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions which-key.el
Original file line number Diff line number Diff line change
Expand Up @@ -763,11 +763,11 @@ problems at github.")
(defvar which-key--god-mode-key-string nil
"Holds key string to use for god-mode support.")

(defadvice god-mode-lookup-command
(around which-key--god-mode-lookup-command-advice disable)
(setq which-key--god-mode-key-string (ad-get-arg 0))
(defun which-key--god-mode-lookup-command-advice (orig-fn &rest args)
"Advice function for `god-mode-lookup-command'."
(setq which-key--god-mode-key-string (car args))
(unwind-protect
ad-do-it
(apply orig-fn args)
(when (bound-and-true-p which-key-mode)
(which-key--hide-popup))))

Expand All @@ -777,14 +777,11 @@ so you need to explicitly opt-in for now. Please report any
problems at github. If DISABLE is non-nil disable support."
(interactive "P")
(setq which-key--god-mode-support-enabled (null disable))
(if disable
(ad-disable-advice
'god-mode-lookup-command
'around 'which-key--god-mode-lookup-command-advice)
(ad-enable-advice
'god-mode-lookup-command
'around 'which-key--god-mode-lookup-command-advice))
(ad-activate 'god-mode-lookup-command))
(cond (which-key--god-mode-support-enabled
(advice-add 'god-mode-lookup-command
:around #'which-key--god-mode-lookup-command-advice))
(t (advice-remove 'god-mode-lookup-command
#'which-key--god-mode-lookup-command-advice))))

;;; Mode

Expand Down

0 comments on commit cf0a453

Please sign in to comment.