aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardofSprites <[email protected]>2024-12-09 21:36:14 -0500
committerBardofSprites <[email protected]>2024-12-09 21:36:14 -0500
commit0eccdd32a3944b312ae6031c979f2bfcf6546d54 (patch)
tree97eeeee3176239acc872494f7926e32ba40ab7cf
parent877e23654c3abe6ac3f7d2fa6e353a30d9982f54 (diff)
ryo-modal with modeline and cursor
-rw-r--r--bard-elisp/bard-modeline.el21
-rw-r--r--bard-elisp/bard-ryo.el5
-rw-r--r--bard-elisp/bard-theme.el22
-rw-r--r--bard-emacs-modules/bard-emacs-keyboard.el151
-rw-r--r--bard-emacs-modules/bard-emacs-modeline.el2
5 files changed, 200 insertions, 1 deletions
diff --git a/bard-elisp/bard-modeline.el b/bard-elisp/bard-modeline.el
index b87047d..e1892ef 100644
--- a/bard-elisp/bard-modeline.el
+++ b/bard-elisp/bard-modeline.el
@@ -233,6 +233,25 @@ Specific to the current window's mode line.")
(propertize " Center " 'face 'prot-modeline-indicator-yellow-bg)))
"Mode line construct to report the multilingual environment.")
+;; FIXME: Combine these two functions one day...
+(defvar-local bard-modeline-ryo-modal-normal
+ '(:eval
+ (when (and (mode-line-window-selected-p)
+ (not (bard/ryo-insert-p))
+ (not (derived-mode-p 'Info-mode 'help-mode 'special-mode 'message-mode)))
+ (propertize "<N>" 'face 'prot-modeline-indicator-magenta-bg))
+ )
+ "Mode line construct to show normal mode for ryo-modal.")
+
+(defvar-local bard-modeline-ryo-modal-insert
+ '(:eval
+ (when (and (mode-line-window-selected-p)
+ (bard/ryo-insert-p)
+ (not (derived-mode-p 'Info-mode 'help-mode 'special-mode 'message-mode)))
+ (propertize "<I>" 'face 'prot-modeline-indicator-blue-bg))
+ )
+ "Mode line construct to show insert mode for ryo-modal.")
+
;;;; Input method
(defvar-local prot-modeline-input-method
@@ -529,6 +548,8 @@ Specific to the current window's mode line.")
(dolist (construct '(prot-modeline-kbd-macro
prot-modeline-narrow
bard-modeline-centered-cursor
+ bard-modeline-ryo-modal-insert
+ bard-modeline-ryo-modal-normal
prot-modeline-input-method
prot-modeline-buffer-status
prot-modeline-evil
diff --git a/bard-elisp/bard-ryo.el b/bard-elisp/bard-ryo.el
new file mode 100644
index 0000000..6fea20d
--- /dev/null
+++ b/bard-elisp/bard-ryo.el
@@ -0,0 +1,5 @@
+(defun bard/ryo-insert-p ()
+ "Return t if `ryo-modal-mode` is not bound or not active."
+ (not (bound-and-true-p ryo-modal-mode)))
+
+(provide 'bard-ryo)
diff --git a/bard-elisp/bard-theme.el b/bard-elisp/bard-theme.el
index 1d37ffb..fcc8a16 100644
--- a/bard-elisp/bard-theme.el
+++ b/bard-elisp/bard-theme.el
@@ -77,7 +77,8 @@
(dolist (hook '(bard/after-theme-load-hook))
(add-hook hook #'fontaine-apply-current-preset)
- (add-hook hook #'logos-update-fringe-in-buffers))
+ (add-hook hook #'logos-update-fringe-in-buffers)
+ (add-hook hook #'bard/update-ryo-cursor-color))
(defun bard/select-theme (&optional theme)
"Enable the specified THEME, or prompt the user to select one if THEME is nil."
@@ -96,4 +97,23 @@
(message "Loaded the %s theme" colored-theme-name)
(run-hooks 'bard/after-theme-load-hook)))
+(defun bard/update-ryo-cursor-color ()
+ "Update the color variable of `ryo-modal-mode' cursor to match the ef/modus theme."
+ (let ((active-theme (car custom-enabled-themes))
+ (cursor-color nil))
+ (cond
+ ((and (fboundp 'ef-themes-with-colors)
+ (string-prefix-p "ef-" (symbol-name active-theme)))
+ (ef-themes-with-colors
+ (setq ryo-modal-cursor-color cursor
+ ryo-modal-default-cursor-color cursor)))
+ ((and (fboundp 'modus-themes-with-colors)
+ (string-prefix-p "modus-" (symbol-name active-theme)))
+ (modus-themes-with-colors
+ (setq ryo-modal-cursor-color cursor
+ ryo-modal-default-cursor-color cursor)))
+ (t (setq cursor-color "red"))
+ (setq ryo-modal-cursor-color cursor-color
+ ryo-modal-default-cursor-color cursor-color))))
+
(provide 'bard-theme)
diff --git a/bard-emacs-modules/bard-emacs-keyboard.el b/bard-emacs-modules/bard-emacs-keyboard.el
new file mode 100644
index 0000000..350c3f4
--- /dev/null
+++ b/bard-emacs-modules/bard-emacs-keyboard.el
@@ -0,0 +1,151 @@
+(require 'bard-ryo)
+
+(use-package hydra
+ :ensure t
+ :config
+ )
+
+(use-package ryo-modal
+ :ensure t
+ :bind (("C-c SPC" . ryo-modal-mode)
+ ("<escape>" . ryo-modal-mode))
+ :config
+ (setq-default cursor-type '(bar . 2))
+ (setq ryo-modal-cursor-type 'box)
+ (ryo-modal-keys
+ ("," ryo-modal-repeat)
+ ("f" ryo-modal-mode)
+ ;; movement
+ ("i" previous-line)
+ ("j" backward-char)
+ ("k" next-line)
+ ("l" forward-char)
+ ;; word movement
+ ("o" forward-word)
+ ("u" backward-word)
+
+ ;; sexp movement
+ ("(" backward-sexp)
+ (")" forward-sexp)
+
+ ;; deletion
+ ("e" backward-kill-word)
+ ("r" kill-word)
+ ("d" backward-delete-char)
+
+ ;; copy/paste/cut
+ ("x" kill-region)
+ ("c" kill-ring-save)
+ ("v" yank)
+
+ ("s" open-line)
+ ("y" undo)
+ ("t" set-mark-command)
+
+ ;; searching
+ ("n" isearch-forward)
+ ("N" isearch-backward)
+
+ ;; command mode
+ ("a" "M-x")
+
+ ;;window management
+ ("1" delete-other-windows)
+ ("2" split-window-below)
+ ("3" split-window-right))
+
+ (define-key global-map (kbd "C-<SPC>") nil)
+
+ (ryo-modal-key
+ "SPC"
+ '(("SPC" ryo-modal-mode)
+ ("w" save-buffer)
+ ("j" dired-jump)
+ ("f" find-file)
+ ("m" pop-to-mark-command)))
+
+ (ryo-modal-key
+ "SPC r" :hydra
+ '(hydra-replace ()
+ "Replace/Substitute hydra"
+ ("a" substitute-target-above-point "above")
+ ("b" substitute-target-below-point "below")
+ ("d" substitute-target-in-defun "defun")
+ ("s" substitute-target-in-buffer "buffer")
+ ("r" query-replace-regexp "regexp"))
+ :norepeat t)
+
+ (ryo-modal-key
+ "SPC n" :hydra
+ '(hydra-denote ()
+ "Denote hydra"
+ ("n" denote "new note")
+ ("<SPC>" denote-region "note region")
+ ("o" denote-sort-dired "sort dired")
+ ("j" denote-journal-extras-new-entry "journal")
+ ("r" denote-rename-file-using-front-matter "rename note")
+ ("k" denote-rename-file-keywords "edit keywords")
+ ("i" denote-link "insert link")
+ ("I" denote-add-links "insert listed links")
+ ("b" denote-backlinks "list backlinks")
+ ("f" bard/find-notes-file "find in notes")
+ ("s" bard/search-notes-directory "search in notes")
+ ("l" denote-find-link "list links")
+ ("L" denote-find-backlink "list backlinks")
+ ("q" nil "cancel" :color red)
+ )
+ :norepeat t)
+
+ (ryo-modal-key
+ "SPC s" :hydra
+ '(hydra-consult ()
+ "Consult hydra"
+ ("f" consult-find "find")
+ ("g" consult-grep "grep")
+ ("k" consult-kmacro "kmacro")
+ ("o" consult-outline "outline")
+ ("r" consult-register "register")
+ ("l" consult-line "search file")
+ ("q" nil "cancel" :color red))
+ :norepeat t)
+
+ (ryo-modal-key
+ "SPC o" :hydra
+ '(hydra-open ()
+ "Open hydra"
+ ("a" bard/default-agenda "agenda")
+ ("c" calendar "calendar")
+ ("g" magit-status "git")
+ ("m" notmuch "mail")
+ ("q" nil "cancel" :color red)
+ ("r" elfeed "rss")
+ ("w" eww "web browser")
+ ("x" org-capture "capture"))
+ :norepeat t)
+
+ (ryo-modal-key
+ "SPC t" :hydra
+ '(hydra-tab ()
+ "Tab hydra"
+ ("0" tab-close "close")
+ ("1" tab-close-other "delete others")
+ ("2" tab-new "new")
+ ("t" tab-next "next")
+ ("T" tab-next "prev")
+ ("d" dired-other-tab "dired tab")
+ ("q" nil "cancel" :color red))
+ :norepeat t)
+
+ (ryo-modal-key
+ "SPC b" :hydra
+ '(hydra-buffer ()
+ "Buffer hydra"
+ ("k" kill-buffer "kill buffer")
+ ("b" consult-buffer "switch-buffer")
+ ("l" ibuffer "buffer list")
+ ("q" nil "cancel" :color red))
+ :norepeat t)
+
+ )
+
+(provide 'bard-emacs-keyboard)
diff --git a/bard-emacs-modules/bard-emacs-modeline.el b/bard-emacs-modules/bard-emacs-modeline.el
index 5333aae..0f27bab 100644
--- a/bard-emacs-modules/bard-emacs-modeline.el
+++ b/bard-emacs-modules/bard-emacs-modeline.el
@@ -9,6 +9,8 @@
prot-modeline-narrow
bard-modeline-centered-cursor
prot-modeline-input-method
+ bard-modeline-ryo-modal-insert
+ bard-modeline-ryo-modal-normal
prot-modeline-buffer-status
" "
prot-modeline-buffer-identification