From 200a440c8448595b081a8225464f6cf97ef4c03f Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Sun, 12 Mar 2023 11:45:35 -0400 Subject: Add multiple cursors config --- emacs/.config/emacs-kj/init.el | 73 +++------------------- emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el | 25 ++++++++ 2 files changed, 35 insertions(+), 63 deletions(-) create mode 100644 emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el (limited to 'emacs/.config/emacs-kj') diff --git a/emacs/.config/emacs-kj/init.el b/emacs/.config/emacs-kj/init.el index b771a0c..3658e63 100644 --- a/emacs/.config/emacs-kj/init.el +++ b/emacs/.config/emacs-kj/init.el @@ -553,15 +553,6 @@ (require 'kj-development) (require 'kj-eshell) -(defun kj/modules (module-directory) - (cl-loop for path in (f-files module-directory) - if (string-match "\\([^/]*\\).el" path) - collect (intern (match-string 1 path)))) - -(dolist (module (kj/modules - (expand-file-name "lisp" user-emacs-directory))) - (require module)) - (setq math-additional-units '((ZiB "1024 * EiB" "Zebibyte") (EiB "1024 * PiB" "Exbibyte") @@ -781,60 +772,6 @@ (interactive) (previous-line kj/some-lines)) -(use-package emacs - :init - (defvar kj/leader-map - (make-sparse-keymap) - "Keymap for leader key") - :bind (:repeat-map kj/leader-map - ("." . mc/mark-next-like-this) - ("," . mc/mark-previous-like-this) - ("C-." . mc/skip-to-next-like-this) - ("C-," . mc/skip-to-previous-like-this) - ("<" . mc/unmark-next-like-this) - (">" . mc/unmark-previous-like-this) - ("*" . mc/mark-all-like-this) - ("w" . mc/mark-next-like-this-word) - ("W" . mc/mark-all-words-like-this) - ("s" . set-rectangular-region-anchor) - ("y" . mc/mark-next-like-this-symbol) - ("Y" . mc/mark-all-like-this-symbol) - ("d" . kj/forward-some-lines) - ("u" . kj/previous-some-lines) - ("C-SPC" . mc/mark-pop) - ("(" . mc/mark-all-symbols-like-this-in-defun) - ("C-(" . mc/mark-all-words-like-this-in-defun) - ("M-(" . mc/mark-all-like-this-in-defun) - :exit - ("s" . shell) - ("$" . eshell) - ("b" . consult-buffer)) - - :bind (("S-") - ("S-" . mc/add-cursor-on-click)) - - :bind (:map selected-keymap - ("C-." . mc/skip-to-next-like-this) - ("C-," . mc/skip-to-previous-like-this) - ("." . mc/mark-next-like-this) - ("," . mc/mark-previous-like-this) - ("w" . mc/mark-next-like-this-word) - ("W" . mc/mark-all-words-like-this) - ("s" . set-rectangular-region-anchor) - ("y" . mc/mark-next-like-this-symbol) - ("Y" . mc/mark-all-like-this-symbol))) - -(defvar kj/keys-minor-mode-map - (let ((map (make-sparse-keymap))) - (define-key map (kbd "C-t") kj/leader-map) - map) - "Keymap for kj/keys-minor-mode") -(define-minor-mode kj/keys-minor-mode - "A minor mode so that my key settings override annoying major modes." - :init-value t - :lighter " kj-keys") -(kj/keys-minor-mode 1) - ;; Repeat commands (e.g., C-x o o o) ;; (use-package repeat-help ;; :ensure t ;; or :straight t @@ -946,5 +883,15 @@ (put 'narrow-to-region 'disabled nil) (put 'downcase-region 'disabled nil) +(defun kj/modules (module-directory) + (cl-loop for path in (f-files module-directory) + if (string-match "\\([^/]*\\).el" path) + collect (intern (match-string 1 path)))) + +(dolist (module (kj/modules + (expand-file-name "lisp" user-emacs-directory))) + (require module)) + ;; Restore gc. (setq gc-cons-threshold (* 16 1024 1024)) + diff --git a/emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el b/emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el new file mode 100644 index 0000000..fe928cf --- /dev/null +++ b/emacs/.config/emacs-kj/lisp/kj-multiple-cursors.el @@ -0,0 +1,25 @@ +;;; -*- lexical-binding: t; -*- + +(use-package multiple-cursors + :config + (defvar kj/multiple-cursors-map (make-sparse-keymap)) + (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 "") '("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) + ) +(provide 'kj-multiple-cursors) + -- cgit v1.2.3