experimenting with hydra/expand region

This commit is contained in:
Levi Neely 2024-09-21 09:32:29 +02:00
parent 2e8a3de96e
commit d7f1ccfdca
4 changed files with 66 additions and 26 deletions

View File

@ -8,6 +8,8 @@
;;; Code: ;;; Code:
(require 'module-base) (require 'module-base)
(require 'module-region)
(require 'module-hydra)
(require 'module-detached) (require 'module-detached)
(require 'module-dired) (require 'module-dired)
(require 'module-async) (require 'module-async)

View File

@ -0,0 +1,51 @@
;;; module-hydra.el --- better keybindings
;;;
;;; Commentary:
;;;
;;; Setup more convenient keybindings for Emacs.
;;;
;;; Code:
(require 'module-pkg)
(require 'module-region)
(pkg/require 'hydra)
(defhydra hydra-vertical-nav (:color red)
"Vertical navigation"
("n" next-line "down")
("p" previous-line "up")
("C-n" next-line "down")
("C-p" previous-line "up")
("f" forward-paragraph "forward paragraph")
("b" backward-paragraph "backward paragraph")
("q" nil "quit" :exit t))
(defhydra hydra-expand-region (:color red :hint nil)
"
Expand/Contract region
"
("e" er/expand-region "expand")
("c" er/contract-region "contract")
("w" er/mark-word "word")
("s" er/mark-symbol "symbol")
("d" er/mark-defun "function")
("p" er/mark-inside-pairs "inside pairs")
("P" er/mark-outside-pairs "outside pairs")
("q" er/mark-inside-quotes "inside quotes")
("Q" er/mark-outside-quotes "outside quotes")
("." er/mark-text-sentence "sentence")
("h" er/mark-html-attribute "html attribute")
("t" er/mark-inner-tag "inner tag")
("T" er/mark-outer-tag "outer tag")
("u" undo "undo" :color blue)
("r" redo "redo" :color blue)
("q" nil "quit" :color blue))
(global-set-key (kbd "C-c v") 'hydra-vertical-nav/body)
(global-set-key (kbd "C-c r") 'hydra-expand-region/body)
(provide 'module-hydra)
;;; module-hydra.el ends here.

View File

@ -0,0 +1,13 @@
;;; module-region.el --- region selection
;;;
;;; Commentary:
;;;
;;; Setup more convenient region selection.
;;;
;;; Code:
(require 'module-pkg)
(pkg/require 'expand-region)
(provide 'module-region)
;;; module-region.el ends here.

View File

@ -8,32 +8,6 @@
(require 'module-pkg) (require 'module-pkg)
(pkg/require 'scratch) (pkg/require 'scratch)
(pkg/require 'persistent-scratch)
(defvar persistent-scratch-directory "~/.local/state/emacs/"
"The place to save persistent scratch buffers.")
(defun my-set-scratch-mode ()
"Set default scratch mode."
(funcall 'text-mode))
(persistent-scratch-setup-default)
(setq persistent-scratch-directory "~/.local/state/emacs/"
persistent-scratch-autosave-interval 30
persistent-scratch-what-to-save '(((:current . "*scratch*") .
(major-mode point narrowing)))
persistent-scratch-save-file (expand-file-name
"scratch" persistent-scratch-directory))
(unless (file-exists-p persistent-scratch-directory)
(make-directory persistent-scratch-directory t))
(add-hook 'scratch-create-buffer-hook 'my-set-scratch-mode)
(add-hook 'after-init-hook #'persistent-scratch-autosave-mode)
(global-set-key (kbd "C-c s") #'persistent-scratch-save)
(global-set-key (kbd "C-c r") #'persistent-scratch-restore)
(provide 'module-scratch) (provide 'module-scratch)
;;; module-scratch.el ends here. ;;; module-scratch.el ends here.