From da40526c8a93895b20bf7f8f292a1ace9bf9df07 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 24 Aug 2021 23:01:20 -0500 Subject: Setup `repeat-mode' real nice like --- init.el | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- lisp/acdw.el | 13 ++++++++++ 2 files changed, 93 insertions(+), 3 deletions(-) diff --git a/init.el b/init.el index 5d601a8..967be23 100644 --- a/init.el +++ b/init.el @@ -676,7 +676,12 @@ like a dumbass." (recentf-mode +1)) (setup repeat + ;; new for Emacs 28! (:only-if (fboundp #'repeat-mode)) + + (:option repeat-exit-key "g" + repeat-exit-timeout 5) + (repeat-mode +1)) (setup (:require savehist) @@ -819,9 +824,69 @@ like a dumbass." (acdw/system :home))) recenter-positions '(top middle bottom)) - (tooltip-mode -1) + (tooltip-mode -1)) + +(setup winner + ;; see https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00888.html + (:global "C-x 4 C-/" winner-undo + "C-x 4 /" winner-undo + "C-x 4 C-?" winner-redo + "C-x 4 ?" winner-redo) + + ;; add `winner-undo' and `winner-redo' to `repeat-mode' + (when (fboundp 'repeat-mode) + (defvar winner-mode-repeat-map + (let ((map (make-sparse-keymap))) + (define-key map "/" #'winner-undo) + (define-key map "?" #'winner-redo) + map) + "Keymap to repeat `winner-mode' sequences. Used in `repeat-mode'.") + + (put 'winner-undo 'repeat-map 'winner-mode-repeat-map) + (put 'winner-redo 'repeat-map 'winner-mode-repeat-map)) + (winner-mode +1)) +(setup windmove + (:option windmove-wrap-around t) + (:global + ;; moving + "C-x 4 " windmove-left + "C-x 4 " windmove-right + "C-x 4 " windmove-up + "C-x 4 " windmove-down + ;; swapping + "C-x 4 S-" windmove-swap-states-left + "C-x 4 S-" windmove-swap-states-right + "C-x 4 S-" windmove-swap-states-up + "C-x 4 S-" windmove-swap-states-down) + + (when (fboundp 'repeat-mode) + (defvar windmove-repeat-map + (let ((map (make-sparse-keymap))) + ;; moving + (define-key map [left] #'windmove-left) + (define-key map [right] #'windmove-right) + (define-key map [up] #'windmove-up) + (define-key map [down] #'windmove-down) + ;; swapping + (define-key map [S-left] #'windmove-swap-states-left) + (define-key map [S-right] #'windmove-swap-states-right) + (define-key map [S-up] #'windmove-swap-states-up) + (define-key map [S-down] #'windmove-swap-states-down) + map) + "Keymap to repeat various `windmove' sequences. Used in `repeat-mode'.") + + (dolist (sym '(windmove-left + windmove-right + windmove-up + windmove-down + windmove-swap-states-left + windmove-swap-states-right + windmove-swap-states-up + windmove-swap-states-down)) + (put sym 'repeat-map 'windmove-repeat-map)))) + (setup w32 (:option w32-allow-system-shell t w32-pass-lwindow-to-system nil @@ -1028,13 +1093,25 @@ like a dumbass." (funcall #'vertico-exit))))) (setup (:straight crux) - - (:global "M-`" crux-other-window-or-switch-buffer + + (:global "C-x o" acdw/other-window-or-switch-buffer "C-o" crux-smart-open-line "M-o" crux-smart-open-line-above "C-M-\\" crux-cleanup-buffer-or-region "C-x 4 t" crux-transpose-windows) + (when (fboundp 'repeat-mode) + (define-key other-window-repeat-map "o" + #'acdw/other-window-or-switch-buffer) + (define-key other-window-repeat-map "O" + (defun acdw/other-window-or-switch-buffer-backward () + (interactive) + (setq repeat-map 'other-window-repeat-map) + (acdw/other-window-or-switch-buffer -1))) + + (put 'acdw/other-window-or-switch-buffer + 'repeat-map 'other-window-repeat-map)) + (crux-reopen-as-root-mode +1)) ;; requires extension: diff --git a/lisp/acdw.el b/lisp/acdw.el index 7e82a9a..bd64af3 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -566,5 +566,18 @@ It's called 'require-private' for historical reasons." (forward-sexp 2) ('scan-error (end-of-buffer)))) + +;;; Crux tweaks + +;; `crux-other-window-or-switch-buffer' doesn't take an argument. +(defun acdw/other-window-or-switch-buffer (&optional arg) + "Call `other-window' or switch buffers, depending on window count." + (interactive "P") + (if (one-window-p) + (switch-to-buffer nil) + (other-window (or arg 1)))) + + + (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81