cyruseuros / hercules

20 stars 5 forks source link

hercules + evil causes breakage #1

Open holtzermann17 opened 3 years ago

holtzermann17 commented 3 years ago

Hi, I love the idea of using Hercules together with Evil to learn my way around the new set of bindings. And it almost works!

Here's a screenshot set up to show the motion keys, just via:

(defun help-evil-motion ()
  (interactive))
(global-set-key (kbd "<f2> m") 'help-evil-motion)

Screenshot from 2021-03-24 14-23-54

However! I run into trouble actually using Hercules and Evil together, since with Hercules installed, something goes wrong with my data entry into the M-x. Let me illustrate:

Screenshot from 2021-03-24 15-07-59

I've reduced my configuration down to something minimal for reproduction purposes:

;;; Hello Emacs
(message "Start load")

(setq debug-on-error t)
(setq eval-expression-print-level 100
      eval-expression-print-length 100)

(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list 'package-archives '("melpa" .  "https://raw.githubusercontent.com/d12frosted/elpa-mirror/master/melpa/") t)
  (package-initialize)
  )
;;; Evil
(require 'evil)
;;; Hercules
(require 'hercules)

(defun help-evil-normal ()
  (interactive))
(global-set-key (kbd "<f2> n") 'help-evil-normal)

(hercules-def
 :toggle-funs #'help-evil-normal
 :keymap 'evil-normal-state-map
 :transient nil)

(defun help-evil-motion ()
  (interactive))
(global-set-key (kbd "<f2> m") 'help-evil-motion)

(hercules-def
 :toggle-funs #'help-evil-motion
 :keymap 'evil-motion-state-map
 :transient nil)

(defun help-evil-insert ()
  (interactive))
(global-set-key (kbd "<f2> i") 'help-evil-insert)

(hercules-def
 :toggle-funs #'help-evil-insert
 :keymap 'evil-insert-state-map
 :transient nil)
;;;End load
(message "End load")

Instructions for reproduction:

Save the above as ~/hercules-evil.el, then load with emacs -Q -nw -l ~/hercules-evil.el, then run:

— I believe this demonstrates the expected behaviour.

HOWEVER, now run Emacs like this: emacs -Q -l ~/hercules-evil.el and I think you will observe that on the GUI version of Emacs, you cannot go through the full process just described.

Instead, Evil mode takes over the minibuffer (for example) making it difficult to even quit Emacs properly!

jeff-phil commented 9 months ago

@holtzermann17

This is because the hercules pop-up is still active, and using those keys from the displayed keymap. I have a default hide-funs list that always includes read-from-minibuffer and keyboard-quit. So taking one of your hercules-def statements above, here it is with :hide-funs line:

(hercules-def
 :toggle-funs #'help-evil-normal
 :keymap 'evil-normal-state-map
 :hide-funs '(read-from-minibuffer keyboard-quit)
 :transient nil)

Now, when you interactively call M-x or eval-expression or get prompted to save a file, etc. hercules will hide so you can type freely.

You will need to do that for each of your hercules-def's above.

Alternative, and probably better, there is a very nice PR that automatically shows and hides: https://github.com/cyruseuros/hercules/pull/2 hercules when minibuffer is needed, and then restores it.