My Emacs configuration.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

db-hydras.el 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ;;; db-hydras.el --- Personal hydras ' -*- lexical-binding: t -*-
  2. ;;; Commentary:
  3. ;;; Code:
  4. (autoload 'rectangle-exchange-point-and-mark "rect")
  5. (require 'hydra)
  6. (require 'db-customize)
  7. (defhydra hydra-toggle (:color blue)
  8. "toggle"
  9. ("c" column-number-mode "column")
  10. ("d" toggle-debug-on-error "debug-on-error")
  11. ("e" toggle-debug-on-error "debug-on-error")
  12. ("f" auto-fill-mode "auto-fill")
  13. ("l" toggle-truncate-lines "truncate lines")
  14. ("q" toggle-debug-on-quit "debug-on-quit")
  15. ("r" read-only-mode "read-only"))
  16. ;; zooming with single keystrokes (from oremacs)
  17. (defhydra hydra-zoom (:color red
  18. :body-pre (require 'face-remap))
  19. ;; the following newline is important, as otherwise the format string is not
  20. ;; interpreted correctly; cf. https://oremacs.com/2015/02/23/hydra-0.11.0/
  21. "
  22. Zoom (%`text-scale-mode-amount): "
  23. ("g" text-scale-increase "increase")
  24. ("l" text-scale-decrease "decrease"))
  25. (defhydra hydra-rectangle (:body-pre (rectangle-mark-mode 1)
  26. :color pink
  27. :post (deactivate-mark))
  28. "
  29. ^_k_^ _d_elete _s_tring
  30. _h_ _l_ _o_k _y_ank
  31. ^_j_^ _n_ew-copy _r_eset
  32. ^^^^ _e_xchange _u_ndo
  33. ^^^^ ^ ^ _p_aste
  34. "
  35. ("h" backward-char nil)
  36. ("l" forward-char nil)
  37. ("k" previous-line nil)
  38. ("j" next-line nil)
  39. ("n" copy-rectangle-as-kill nil)
  40. ("d" delete-rectangle nil)
  41. ("r" (if (region-active-p)
  42. (deactivate-mark)
  43. (rectangle-mark-mode 1))
  44. nil)
  45. ("y" yank-rectangle nil)
  46. ("u" undo nil)
  47. ("s" string-rectangle nil)
  48. ("p" kill-rectangle nil)
  49. ("e" rectangle-exchange-point-and-mark nil)
  50. ("o" nil nil))
  51. ;; The hydra for our frequently used features should be defined here, but should
  52. ;; also be redefined every time `db/frequently-used-features' is redefined via
  53. ;; customize. To this end, we provide a special function here that defines this
  54. ;; hydra, that can also be called in the setter of
  55. ;; `db/frequently-used-features'.
  56. (defun db/define-feature-shortcuts-hydra ()
  57. "Globally define `hydra-feature-shortcuts' for feature shortcuts.
  58. If instead of a shortcut character nil is provided, no entry in
  59. the hydra will be generated. See documentation of
  60. `db/frequently-used-features' for details."
  61. (eval
  62. `(defhydra hydra-feature-shortcuts (:color blue)
  63. ""
  64. ,@(mapcar (lambda (entry)
  65. (pcase-let ((`(,description ,shortcut ,function) entry))
  66. (list (string shortcut) function description)))
  67. (cl-remove-if #'(lambda (entry)
  68. (null (cl-second entry)))
  69. db/frequently-used-features)))))
  70. (db/define-feature-shortcuts-hydra)
  71. (provide 'db-hydras)
  72. ;;; db-hydras.el ends here