summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emacs/.config/emacs-kj/init.el1
-rw-r--r--emacs/.config/emacs-kj/lisp/kj-bindings.el2
-rw-r--r--emacs/.config/emacs-kj/lisp/kj-lib.el17
-rw-r--r--emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el34
4 files changed, 35 insertions, 19 deletions
diff --git a/emacs/.config/emacs-kj/init.el b/emacs/.config/emacs-kj/init.el
index 46ae903..e1938f4 100644
--- a/emacs/.config/emacs-kj/init.el
+++ b/emacs/.config/emacs-kj/init.el
@@ -15,6 +15,7 @@
(load bootstrap-file nil 'nomessage))
(push (expand-file-name "lisp" user-emacs-directory) load-path)
+(require 'kj-lib)
(setq user-full-name "KJ Orbekk"
user-mail-address "kj@orbekk.com")
diff --git a/emacs/.config/emacs-kj/lisp/kj-bindings.el b/emacs/.config/emacs-kj/lisp/kj-bindings.el
index 11a45f3..b60db7a 100644
--- a/emacs/.config/emacs-kj/lisp/kj-bindings.el
+++ b/emacs/.config/emacs-kj/lisp/kj-bindings.el
@@ -6,7 +6,7 @@
("C-c s" . kj/shell-here)
("C-c t" . eshell)
("M-o" . other-window)
- ("C-c m" . smerge-ediff)
+ ("C-c M" . smerge-ediff)
("C-c b r" . revert-buffer)
("C-c r l" . consult-flymake)
("C-c r f" . eglot-format)
diff --git a/emacs/.config/emacs-kj/lisp/kj-lib.el b/emacs/.config/emacs-kj/lisp/kj-lib.el
new file mode 100644
index 0000000..117584b
--- /dev/null
+++ b/emacs/.config/emacs-kj/lisp/kj-lib.el
@@ -0,0 +1,17 @@
+;;; -*- lexical-binding: t; -*-
+
+(defmacro define-repeating-key (keymap key cmd &optional desc)
+ "DEF may be a cons cell (DESCRIPTION . FUNC) or a command."
+ `(let ((def
+ ,(if desc
+ `'(,desc ,cmd)
+ `',cmd)))
+ (define-key ,keymap ,key def)
+ (put ',cmd 'repeat-map ',keymap)))
+
+(provide 'kj-lib)
+
+(macroexpand '(define-repeating-key map "." mc/mark-next-like-this ))
+(define-repeating-map)
+
+(macroexpand '(define-repeating-key map "." mc/mark-next-like-this "→ this"))
diff --git a/emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el b/emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el
index 5c80ccf..b841d9f 100644
--- a/emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el
+++ b/emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el
@@ -2,24 +2,22 @@
(use-package multiple-cursors
:config
- (defvar kj/multiple-cursors-map (make-sparse-keymap "cursors"))
- (define-key kj/multiple-cursors-map "." '("→ this" . mc/mark-next-like-this))
- (define-key kj/multiple-cursors-map "," '("← this" . mc/mark-previous-like-this))
- (define-key kj/multiple-cursors-map ">" '("⇥ this" . mc/skip-to-next-like-this))
- (define-key kj/multiple-cursors-map "<" '("⇤ this" . mc/skip-to-previous-like-this))
- (define-key kj/multiple-cursors-map "<" '("⇤ this" . mc/skip-to-previous-like-this))
- (define-key kj/multiple-cursors-map "*" '("all like this" . mc/mark-all-like-this))
- (define-key kj/multiple-cursors-map "w" '("word" . mc/mark-next-like-this-word))
- (define-key kj/multiple-cursors-map "s" '("symbol" . mc/mark-next-like-this-symbol))
- (define-key kj/multiple-cursors-map "(" '("symbol defun" . mc/mark-all-symbols-like-this-in-defun))
- (define-key kj/multiple-cursors-map (kbd "DEL") '("DEL last" . mc/unmark-next-like-this))
- (define-key kj/multiple-cursors-map (kbd "<delete>") '("DEL first" . mc/unmark-previous-like-this))
- (global-set-key (kbd "C-c m") (cons "cursors" kj/multiple-cursors-map))
-
- (map-keymap
- (lambda (_key cmd)
- (put (cdr cmd) 'repeat-map 'kj/multiple-cursors-map))
- kj/multiple-cursors-map))
+ (defvar kj/multiple-cursors-map
+ (let ((map (make-sparse-keymap "cursors")))
+ (define-repeating-key map "." mc/mark-next-like-this "→ this")
+ (define-repeating-key map "," mc/mark-previous-like-this "← this")
+ (define-repeating-key map ">" mc/skip-to-next-like-this "⇥ this")
+ (define-repeating-key map "<" mc/skip-to-previous-like-this "⇤ this")
+ (define-repeating-key map "<" mc/skip-to-previous-like-this "⇤ this")
+ (define-repeating-key map "*" mc/mark-all-like-this "all like this")
+ (define-repeating-key map "w" mc/mark-next-like-this-word "word")
+ (define-repeating-key map "s" mc/mark-next-like-this-symbol "symbol")
+ (define-repeating-key map "(" mc/mark-all-symbols-like-this-in-defun "symbol defun")
+ (define-repeating-key map (kbd "DEL") mc/unmark-next-like-this "DEL last")
+ (define-repeating-key map (kbd "<delete>") mc/unmark-previous-like-this "DEL first")
+ (define-key map (kbd "C-g") '("quit" . ignore))
+ map))
+ (global-set-key (kbd "C-c m") (cons "cursors" kj/multiple-cursors-map)))
(provide 'kj-multiple-cursors)