about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-08-24 23:01:20 -0500
committerCase Duckworth2021-08-24 23:01:20 -0500
commitda40526c8a93895b20bf7f8f292a1ace9bf9df07 (patch)
tree3cb7856daf3690da7cfac983dabd09f956724872
parentChange helpful-switch-to-buffer-function (diff)
downloademacs-da40526c8a93895b20bf7f8f292a1ace9bf9df07.tar.gz
emacs-da40526c8a93895b20bf7f8f292a1ace9bf9df07.zip
Setup `repeat-mode' real nice like
-rw-r--r--init.el83
-rw-r--r--lisp/acdw.el13
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."
676 (recentf-mode +1)) 676 (recentf-mode +1))
677 677
678(setup repeat 678(setup repeat
679 ;; new for Emacs 28!
679 (:only-if (fboundp #'repeat-mode)) 680 (:only-if (fboundp #'repeat-mode))
681
682 (:option repeat-exit-key "g"
683 repeat-exit-timeout 5)
684
680 (repeat-mode +1)) 685 (repeat-mode +1))
681 686
682(setup (:require savehist) 687(setup (:require savehist)
@@ -819,9 +824,69 @@ like a dumbass."
819 (acdw/system :home))) 824 (acdw/system :home)))
820 recenter-positions '(top middle bottom)) 825 recenter-positions '(top middle bottom))
821 826
822 (tooltip-mode -1) 827 (tooltip-mode -1))
828
829(setup winner
830 ;; see https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00888.html
831 (:global "C-x 4 C-/" winner-undo
832 "C-x 4 /" winner-undo
833 "C-x 4 C-?" winner-redo
834 "C-x 4 ?" winner-redo)
835
836 ;; add `winner-undo' and `winner-redo' to `repeat-mode'
837 (when (fboundp 'repeat-mode)
838 (defvar winner-mode-repeat-map
839 (let ((map (make-sparse-keymap)))
840 (define-key map "/" #'winner-undo)
841 (define-key map "?" #'winner-redo)
842 map)
843 "Keymap to repeat `winner-mode' sequences. Used in `repeat-mode'.")
844
845 (put 'winner-undo 'repeat-map 'winner-mode-repeat-map)
846 (put 'winner-redo 'repeat-map 'winner-mode-repeat-map))
847
823 (winner-mode +1)) 848 (winner-mode +1))
824 849
850(setup windmove
851 (:option windmove-wrap-around t)
852 (:global
853 ;; moving
854 "C-x 4 <left>" windmove-left
855 "C-x 4 <right>" windmove-right
856 "C-x 4 <up>" windmove-up
857 "C-x 4 <down>" windmove-down
858 ;; swapping
859 "C-x 4 S-<left>" windmove-swap-states-left
860 "C-x 4 S-<right>" windmove-swap-states-right
861 "C-x 4 S-<up>" windmove-swap-states-up
862 "C-x 4 S-<down>" windmove-swap-states-down)
863
864 (when (fboundp 'repeat-mode)
865 (defvar windmove-repeat-map
866 (let ((map (make-sparse-keymap)))
867 ;; moving
868 (define-key map [left] #'windmove-left)
869 (define-key map [right] #'windmove-right)
870 (define-key map [up] #'windmove-up)
871 (define-key map [down] #'windmove-down)
872 ;; swapping
873 (define-key map [S-left] #'windmove-swap-states-left)
874 (define-key map [S-right] #'windmove-swap-states-right)
875 (define-key map [S-up] #'windmove-swap-states-up)
876 (define-key map [S-down] #'windmove-swap-states-down)
877 map)
878 "Keymap to repeat various `windmove' sequences. Used in `repeat-mode'.")
879
880 (dolist (sym '(windmove-left
881 windmove-right
882 windmove-up
883 windmove-down
884 windmove-swap-states-left
885 windmove-swap-states-right
886 windmove-swap-states-up
887 windmove-swap-states-down))
888 (put sym 'repeat-map 'windmove-repeat-map))))
889
825(setup w32 890(setup w32
826 (:option w32-allow-system-shell t 891 (:option w32-allow-system-shell t
827 w32-pass-lwindow-to-system nil 892 w32-pass-lwindow-to-system nil
@@ -1028,13 +1093,25 @@ like a dumbass."
1028 (funcall #'vertico-exit))))) 1093 (funcall #'vertico-exit)))))
1029 1094
1030(setup (:straight crux) 1095(setup (:straight crux)
1031 1096
1032 (:global "M-`" crux-other-window-or-switch-buffer 1097 (:global "C-x o" acdw/other-window-or-switch-buffer
1033 "C-o" crux-smart-open-line 1098 "C-o" crux-smart-open-line
1034 "M-o" crux-smart-open-line-above 1099 "M-o" crux-smart-open-line-above
1035 "C-M-\\" crux-cleanup-buffer-or-region 1100 "C-M-\\" crux-cleanup-buffer-or-region
1036 "C-x 4 t" crux-transpose-windows) 1101 "C-x 4 t" crux-transpose-windows)
1037 1102
1103 (when (fboundp 'repeat-mode)
1104 (define-key other-window-repeat-map "o"
1105 #'acdw/other-window-or-switch-buffer)
1106 (define-key other-window-repeat-map "O"
1107 (defun acdw/other-window-or-switch-buffer-backward ()
1108 (interactive)
1109 (setq repeat-map 'other-window-repeat-map)
1110 (acdw/other-window-or-switch-buffer -1)))
1111
1112 (put 'acdw/other-window-or-switch-buffer
1113 'repeat-map 'other-window-repeat-map))
1114
1038 (crux-reopen-as-root-mode +1)) 1115 (crux-reopen-as-root-mode +1))
1039 1116
1040;; requires extension: 1117;; 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."
566 (forward-sexp 2) 566 (forward-sexp 2)
567 ('scan-error (end-of-buffer)))) 567 ('scan-error (end-of-buffer))))
568 568
569
570;;; Crux tweaks
571
572;; `crux-other-window-or-switch-buffer' doesn't take an argument.
573(defun acdw/other-window-or-switch-buffer (&optional arg)
574 "Call `other-window' or switch buffers, depending on window count."
575 (interactive "P")
576 (if (one-window-p)
577 (switch-to-buffer nil)
578 (other-window (or arg 1))))
579
580
581
569(provide 'acdw) 582(provide 'acdw)
570;;; acdw.el ends here 583;;; acdw.el ends here