From d90ea15d7aea877100fc01736575bb4d5c3cce52 Mon Sep 17 00:00:00 2001 From: Akhil Wali Date: Fri, 29 May 2020 20:06:46 +1200 Subject: [PATCH 1/3] Use nadvice.el instead of advice.el --- which-key.el | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/which-key.el b/which-key.el index 6eb8e35..6311290 100644 --- a/which-key.el +++ b/which-key.el @@ -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)))) @@ -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 From 3af8606daa42699bb3a3101c8af80ed847a20e8c Mon Sep 17 00:00:00 2001 From: Akhil Wali Date: Mon, 15 Jun 2020 19:21:17 +1200 Subject: [PATCH 2/3] Fix paging when used with God mode --- which-key.el | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/which-key.el b/which-key.el index 6311290..5e65069 100644 --- a/which-key.el +++ b/which-key.el @@ -771,6 +771,18 @@ problems at github.") (when (bound-and-true-p which-key-mode) (which-key--hide-popup)))) +(defun which-key--god-mode-help-char-dispatch (orig-fn &rest args) + "Advice function for `god-mode-help-char-dispatch'." + (if (not (which-key--popup-showing-p)) + (apply orig-fn args) + (which-key-C-h-dispatch) + ;; Discard last prefix input. `discard-input' cannot be used + ;; here as it ends any macro being defined. + (setq unread-command-events nil) + ;; Return keys entered so far to prevent quitting current key + ;; sequence. + (cadr args))) + (defun which-key-enable-god-mode-support (&optional disable) "Enable support for god-mode if non-nil. This is experimental, so you need to explicitly opt-in for now. Please report any @@ -779,9 +791,13 @@ problems at github. If DISABLE is non-nil disable support." (setq which-key--god-mode-support-enabled (null disable)) (cond (which-key--god-mode-support-enabled (advice-add 'god-mode-lookup-command - :around #'which-key--god-mode-lookup-command-advice)) + :around #'which-key--god-mode-lookup-command-advice) + (advice-add 'god-mode-help-char-dispatch + :around #'which-key--god-mode-help-char-dispatch)) (t (advice-remove 'god-mode-lookup-command - #'which-key--god-mode-lookup-command-advice)))) + #'which-key--god-mode-lookup-command-advice) + (advice-remove 'god-mode-help-char-dispatch + #'which-key--god-mode-help-char-dispatch)))) ;;; Mode From 499442d33496ba2082d39eb3d0d7e5e2eae03833 Mon Sep 17 00:00:00 2001 From: Akhil Wali Date: Mon, 15 Jun 2020 19:21:50 +1200 Subject: [PATCH 3/3] Stop timer to prevent which-key--hide-popup call --- which-key.el | 1 + 1 file changed, 1 insertion(+) diff --git a/which-key.el b/which-key.el index 5e65069..4fc7e8e 100644 --- a/which-key.el +++ b/which-key.el @@ -775,6 +775,7 @@ problems at github.") "Advice function for `god-mode-help-char-dispatch'." (if (not (which-key--popup-showing-p)) (apply orig-fn args) + (which-key--stop-timer) (which-key-C-h-dispatch) ;; Discard last prefix input. `discard-input' cannot be used ;; here as it ends any macro being defined.