home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

commit 4a904cb056d2c316b702f3cbdaa3fba72328c54c
parent ba56928af59ccaca279ebc429bf5dd7bed928f07
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Mon, 12 Feb 2024 16:47:11 +0100

tools/emacs: configure repeat

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Mtools/emacs/config/config-navigating.el | 29+++++++++++++++++++++++++++++
Mtools/emacs/config/programming-config.el | 22++++++++++++++++++++++
2 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/tools/emacs/config/config-navigating.el b/tools/emacs/config/config-navigating.el @@ -105,5 +105,34 @@ (keymap-global-set "S-<down-mouse-2>" 'strokes-do-stroke) +(use-package repeat + :config + (setq repeat-on-final-keystroke t) + (setq set-mark-command-repeat-pop t) + + (repeat-mode 1) + + (defvar isearch-repeat-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "s") #'isearch-repeat-forward) + (define-key map (kbd "r") #'isearch-repeat-backward) + map)) + + (dolist (cmd '(isearch-repeat-forward isearch-repeat-backward)) + (put cmd 'repeat-map 'isearch-repeat-map)) + + (defvar buffer-navigation-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "n") #'next-line) + (define-key map (kbd "p") #'previous-line) + (define-key map (kbd "f") #'forward-word) + (define-key map (kbd "b") #'backward-word) + (define-key map (kbd "u") #'scroll-up-command) + (define-key map (kbd "d") #'scroll-down-command) + map)) + + (dolist (cmd '(next-line previous-line forward-word backward-word scroll-up-command scroll-down-command)) + (put cmd 'repeat-map 'buffer-navigation-map))) + (provide 'config-navigating) ;;; config-navigating.el ends here diff --git a/tools/emacs/config/programming-config.el b/tools/emacs/config/programming-config.el @@ -18,9 +18,29 @@ (use-package adoc-mode :mode ("\\.adoc\\'" . conf-toml-mode)) +(defun repeatize (keymap) + "Add `repeat-mode' support to a KEYMAP." + (map-keymap + (lambda (_key cmd) + (when (symbolp cmd) + (put cmd 'repeat-map keymap))) + (symbol-value keymap))) + +(defvar flymake-repeat-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "n") 'flymake-goto-next-error) + (define-key map (kbd "p") 'flymake-goto-prev-error) + (define-key map (kbd "f") 'attrap-flymake) + (define-key map (kbd "M-n") 'flymake-goto-next-error) + (define-key map (kbd "M-p") 'flymake-goto-prev-error) + map)) + (use-package flymake :defer t :bind + (:map flymake-mode-map + ("M-n" . flymake-goto-next-error) + ("M-p" . flymake-goto-prev-error)) ( :map flymake-diagnostics-buffer-mode-map ("p" . @@ -45,6 +65,8 @@ (next-line) (save-excursion (flymake-show-diagnostic(point))))))) + :config + (repeatize 'flymake-repeat-map) :hook (prog-mode . flyspell-prog-mode) (prog-mode . flymake-mode))