abo-abo / hydra

make Emacs bindings that stick around
1.84k stars 112 forks source link

Hydra doesn't exit when minibuffer closes #287

Open ambihelical opened 6 years ago

ambihelical commented 6 years ago

I have a hydra which controls git-timemachine. Everything works well except when I happen to close the minibuffer while perusing the timemachine buffer. One way to this is by calling delete-other-windows in the git-timemachine window. In this case :post is not invoked. The only recovery that I've found is to M-x git-timemachine-quit in the timemachine window.

Is this something that hydra should handle, or lacking that, any ideas on how to fix this would be appreciated.

Here is the use-package config I'm using:


(defvar git-timemachine-mode-map (make-sparse-keymap))

(use-package git-timemachine
  :commands ( hydra-timemachine/body )
  :init
  ;; evil-motion-state when in timemachine mode
  (add-hook 'git-timemachine-mode-hook (lambda ()
                                           (when (fboundp 'evil-motion-state)
                                             (evil-motion-state))))
  :config

  (eval '(defhydra hydra-timemachine
           (:hint nil 
            :post (progn (message "in post") (git-timemachine-quit))
            :body-pre (git-timemachine)
            :foreign-keys run )
    "Time machine"
    ("<up>" #'git-timemachine-show-previous-revision "Previous revision" :column "Navigation")
    ("<down>" #'git-timemachine-show-next-revision "Next revision")
    ("C-c h" #'git-timemachine-show-current-revision "Current revision")
    ("C-c C-c" "Quit" :color blue )
    ("C-c b" #'git-timemachine-blame "Show culprits" :column "Operations")
    ("C-c r" #'git-timemachine-kill-revision "Yank revision")
    ("C-c s" #'git-timemachine-kill-abbreviated-revision "Yank abbreviated revision")))
  :general
  (:keymaps 'global :prefix "<f9>"  "t" #'hydra-timemachine/body)
  :diminish "🕓")
abo-abo commented 6 years ago

Please list a more detailed list of steps to reproduce the issue.

ambihelical commented 6 years ago
  1. add above config with use-package configured. I have setq use-package-always-ensure t in my config, so you may need to add :ensure t if this is not the case in yours.
  2. open any text file which is under git control
  3. F9 t or M-x hydra-timemachine/body so now viewing git-timemachine buffer with active hydra.
  4. M-x delete-other-windows.

Hydra visually goes away and doesn't exit, or if it does, the :post function doesn't run. Run M-x git-timemachine-quit in the buffer to get rid of the timemachine buffer.