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

How to close hydra when switching or closing buffer #419

Open
RudolfVonKrugstein opened this issue Jul 24, 2023 · 0 comments
Open

How to close hydra when switching or closing buffer #419

RudolfVonKrugstein opened this issue Jul 24, 2023 · 0 comments

Comments

@RudolfVonKrugstein
Copy link

To make me remember keybindings while in dired mode, I made this hydra (well I copied most of it from somewhere):

  (defhydra hydra-dired (:hint nil :color pink)
    "dired"
    ("\\" dired-do-ispell "flyspell")
    ("(" dired-hide-details-mode "details")
    (")" dired-omit-mode "omit-mode")
    ("+" dired-create-directory "mkdir")
    ("=" diredp-ediff "pdiff")         ;; smart diff
    ("?" dired-summary "summay")
    ("$" diredp-hide-subdir-nomove "hide-subdir")
    ("A" dired-do-find-regexp "find regexp")
    ("C" dired-do-copy "Copy")        ;; Copy all marked files
    ("D" dired-do-delete "Delete")
    ("E" dired-mark-extension "Extension mark")
    ("e" dired-ediff-files "ediff")
    ("F" dired-do-find-marked-files "find marked")
    ("G" dired-do-chgrp "chgrp")
    ("g" revert-buffer "revert buf")        ;; read all directories again (refresh)
    ("i" dired-maybe-insert-subdir "insert subdir")
    ("l" dired-do-redisplay "redisplay")   ;; relist the marked or singel directory
    ("M" dired-do-chmod "chmod")
    ("m" dired-mark "mark")
    ("O" dired-display-file "view other")
    ("o" dired-find-file-other-window "open other")
    ("Q" dired-do-find-regexp-and-replace "replace regex")
    ("R" dired-do-rename "rename")
    ("r" dired-do-rsynch "rsync")
    ("S" dired-do-symlink "symlink")
    ("s" dired-sort-toggle-or-edit "sort")
    ("t" dired-toggle-marks "toggle marks")
    ("U" dired-unmark-all-marks "unmark all")
    ("u" dired-unmark "unmark")
    ("v" dired-view-file "view")      ;; q to exit, s to search, = gets line #
    ("w" dired-kill-subdir "kill subdir")
    ("Y" dired-do-relsymlink "rel symlink")
    ("z" diredp-compress-this-file "compress files")
    ("Z" dired-do-compress "compress")
    ("^" dired-up-directory "up directory")
    ("<backspace>" dired-up-directory)
    ("q" +dired/quit-all "quit" :color blue)
    ("." nil "toggle hydra" :color blue))

Works most of the time! But if I exit the dired buffer in some unexpedted way (i.E. I suddenly decide that dired was not the way to go to my file but recent files are) the hydra stays. That is anyoing because the keybindings don't make sense in the new context.

Is there a way to close hydra when the current buffer is closed or unfocused in any way?
Thanks!

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

No branches or pull requests

1 participant