complete-computing-environment/hydra_dipswitches.org

2.1 KiB

Hydra Dipswitches

(provide 'cce/hydra-dipswitch)

I have a Hydra function called hydra-dipswitch which exposes some common important Emacs variables, allowing me to quickly toggle common systems. I would love to expand this some day to include system-level things like Wi-Fi, power management, etc…

(defhydra hydra-dipswitch ()
  "Toggles"
  ("e" toggle-debug-on-error "Debug on Error")
  ("q" toggle-debug-on-quit "Debug on Quit")
  ("r" tasshin/read-write-toggle "Read/Write")
  ("w" whitespace-mode "Whitespace")
  ("l" lsp-ui-mode "LSP UI")
  ("f" focus-mode "Focus")
  ("t" bh/set-truncate-lines "Truncate")
  ("n" cce/toggle-theme "Light/Dark")
  ("d" visible-mode "Visible Mode")
  ("v" variable-pitch-mode "Variable Pitch"))

(with-eval-after-load 'evil-leader
  (evil-leader/set-key "t" 'hydra-dipswitch/body))
(defun tasshin/read-write-toggle ()
  "Toggles read-only in any relevant mode: ag-mode, Dired, or
just any file at all."
  (interactive)
  (if (equal major-mode 'ag-mode)
      ;; wgrep-ag can support ag-mode
      (wgrep-change-to-wgrep-mode)
    ;; dired-toggle-read-only has its own conditional:
    ;; if the mode is Dired, it will make the directory writable
    ;; if it is not, it will just toggle read only, as desired
    (dired-toggle-read-only)))
(defun bh/set-truncate-lines ()
  "Toggle value of truncate-lines and refresh window display."
  (interactive)
  (setq truncate-lines (not truncate-lines))
  ;; now refresh window display (an idiom from simple.el):
  (save-excursion
    (set-window-start (selected-window)
                      (window-start (selected-window)))))