summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-12-06 19:58:46 -0600
committerCase Duckworth2021-12-06 19:58:46 -0600
commitc7a9cba8247444ab08a9f3266404bb2156924cf0 (patch)
treeb739d84c4f9c7d2bc50f0787050789c004db65dc
parentStuff... (diff)
downloademacs-c7a9cba8247444ab08a9f3266404bb2156924cf0.tar.gz
emacs-c7a9cba8247444ab08a9f3266404bb2156924cf0.zip
Mostley add +key.el (but of course other stuff)
-rw-r--r--init.el71
-rw-r--r--lisp/+emacs.el1
-rw-r--r--lisp/+key.el65
-rw-r--r--lisp/+modeline.el2
4 files changed, 115 insertions, 24 deletions
diff --git a/init.el b/init.el index 60707af..e0cf8ae 100644 --- a/init.el +++ b/init.el
@@ -38,6 +38,9 @@
38 (save-buffer))) 38 (save-buffer)))
39 (:hook '+init-add-setup-to-imenu)) 39 (:hook '+init-add-setup-to-imenu))
40 40
41(setup (:require +key)
42 (+key-global-mode +1))
43
41(setup (:require auth-source) 44(setup (:require auth-source)
42 (:option auth-sources (list (private/ "authinfo") 45 (:option auth-sources (list (private/ "authinfo")
43 (private/ "authinfo.gpg") 46 (private/ "authinfo.gpg")
@@ -82,7 +85,7 @@
82 (:hook 'dired-collapse-mode 85 (:hook 'dired-collapse-mode
83 'dired-hide-details-mode 86 'dired-hide-details-mode
84 'hl-line-mode) 87 'hl-line-mode)
85 (:global "C-x C-j" 'dired-jump) 88 (:+key "C-x C-j" 'dired-jump)
86 (with-eval-after-load 'dired 89 (with-eval-after-load 'dired
87 (pcase system-type 90 (pcase system-type
88 ((or 'ms-dos 'windows-nt) 91 ((or 'ms-dos 'windows-nt)
@@ -164,7 +167,7 @@
164 167
165(setup (:straight anzu) 168(setup (:straight anzu)
166 (:option anzu-cons-mode-line-p nil) 169 (:option anzu-cons-mode-line-p nil)
167 (:global [remap query-replace] 'anzu-query-replace-regexp 170 (:+key [remap query-replace] 'anzu-query-replace-regexp
168 [remap query-replace-regexp] 'anzu-query-replace-regexp) 171 [remap query-replace-regexp] 'anzu-query-replace-regexp)
169 (global-anzu-mode +1) 172 (global-anzu-mode +1)
170 (:bind-into isearch 173 (:bind-into isearch
@@ -175,7 +178,7 @@
175 178
176(setup (:straight avy) 179(setup (:straight avy)
177 (:also-load +avy) 180 (:also-load +avy)
178 (:global "M-j" 'avy-goto-char-timer) 181 (:+key "M-j" 'avy-goto-char-timer)
179 (:bind-into isearch 182 (:bind-into isearch
180 "M-j" 'avy-isearch) 183 "M-j" 'avy-isearch)
181 (:when-loaded 184 (:when-loaded
@@ -366,7 +369,7 @@
366 (:option consult--regexp-compiler 'consult--orderless-regexp-compiler)))) 369 (:option consult--regexp-compiler 'consult--orderless-regexp-compiler))))
367 370
368(setup (:straight crux) 371(setup (:straight crux)
369 (:global "C-o" 'crux-smart-open-line 372 (:+key "C-o" 'crux-smart-open-line
370 "M-o" 'crux-other-window-or-switch-buffer 373 "M-o" 'crux-other-window-or-switch-buffer
371 "C-x 4 t" 'crux-transpose-windows) 374 "C-x 4 t" 'crux-transpose-windows)
372 375
@@ -415,7 +418,7 @@ See also `crux-reopen-as-root-mode'."
415 418
416(setup (:straight embark) 419(setup (:straight embark)
417 (:option prefix-help-command 'embark-prefix-help-command) 420 (:option prefix-help-command 'embark-prefix-help-command)
418 (:global "C-." 'embark-act 421 (:+key "C-." 'embark-act
419 "M-." 'embark-dwim 422 "M-." 'embark-dwim
420 "<help> B" 'embark-bindings)) 423 "<help> B" 'embark-bindings))
421 424
@@ -441,12 +444,12 @@ See also `crux-reopen-as-root-mode'."
441 "XDG_CACHE_HOME"))) 444 "XDG_CACHE_HOME")))
442 445
443(setup (:straight expand-region) 446(setup (:straight expand-region)
444 (:global "C-=" 'er/expand-region)) 447 (:+key "C-=" 'er/expand-region))
445 448
446(setup (:straight (filldent 449(setup (:straight (filldent
447 :host github 450 :host github
448 :repo "duckwork/filldent.el")) 451 :repo "duckwork/filldent.el"))
449 (:global "M-q" 'filldent-dwim)) 452 (:+key "M-q" 'filldent-dwim))
450 453
451(setup (:straight (frowny 454(setup (:straight (frowny
452 :host github 455 :host github
@@ -458,7 +461,7 @@ See also `crux-reopen-as-root-mode'."
458 (gcmh-mode +1)) 461 (gcmh-mode +1))
459 462
460(setup (:straight helpful) 463(setup (:straight helpful)
461 (:global "<help> f" 'helpful-callable 464 (:+key "<help> f" 'helpful-callable
462 "<help> v" 'helpful-variable 465 "<help> v" 'helpful-variable
463 "<help> k" 'helpful-key 466 "<help> k" 'helpful-key
464 "C-c C-d" 'helpful-at-point)) 467 "C-c C-d" 'helpful-at-point))
@@ -466,7 +469,7 @@ See also `crux-reopen-as-root-mode'."
466(setup (:straight (hippie-completing-read 469(setup (:straight (hippie-completing-read
467 :host github 470 :host github
468 :repo "duckwork/hippie-completing-read")) 471 :repo "duckwork/hippie-completing-read"))
469 (:global "M-/" 'hippie-completing-read)) 472 (:+key "M-/" 'hippie-completing-read))
470 473
471(setup (:straight hungry-delete) 474(setup (:straight hungry-delete)
472 (:option hungry-delete-chars-to-skip " \t" 475 (:option hungry-delete-chars-to-skip " \t"
@@ -508,7 +511,7 @@ See also `crux-reopen-as-root-mode'."
508 (isearch-mb-mode +1)) 511 (isearch-mb-mode +1))
509 512
510(setup (:straight lacarte) 513(setup (:straight lacarte)
511 (:global "<f10>" 'lacarte-execute-menu-command)) 514 (:+key "<f10>" 'lacarte-execute-menu-command))
512 515
513(setup (:straight marginalia) 516(setup (:straight marginalia)
514 (marginalia-mode +1)) 517 (marginalia-mode +1))
@@ -527,7 +530,7 @@ See also `crux-reopen-as-root-mode'."
527 :repo "protesilaos/modus-themes"))) 530 :repo "protesilaos/modus-themes")))
528 531
529(setup (:straight mwim) 532(setup (:straight mwim)
530 (:global "C-a" #'mwim-beginning 533 (:+key "C-a" #'mwim-beginning
531 "C-e" #'mwim-end)) 534 "C-e" #'mwim-end))
532 535
533(setup (:straight orderless) 536(setup (:straight orderless)
@@ -615,6 +618,9 @@ See also `crux-reopen-as-root-mode'."
615 org-appear-delay 0) 618 org-appear-delay 0)
616 (:hook-into org-mode)) 619 (:hook-into org-mode))
617 620
621(setup (:straight org-sticky-header)
622 (:hook-into org-mode))
623
618(setup (:straight paredit) 624(setup (:straight paredit)
619 (:bind "DEL" 'paredit-backward-delete 625 (:bind "DEL" 'paredit-backward-delete
620 "C-<backspace>" 'paredit-backward-kill-word) 626 "C-<backspace>" 'paredit-backward-kill-word)
@@ -630,13 +636,21 @@ See also `crux-reopen-as-root-mode'."
630 lisp-interaction-mode 636 lisp-interaction-mode
631 scheme-mode)) 637 scheme-mode))
632 638
639(setup (:straight scratch)
640 (:require +scratch)
641 (:option initial-major-mode 'emacs-lisp-mode
642 initial-scratch-message
643 ";; ABANDON ALL HOPE YE WHO ENTER HERE\n")
644 (add-hook 'kill-buffer-query-functions '+scratch-immortal)
645 (add-hook 'scratch-create-buffer-hook '+scratch-buffer-setup))
646
633(setup (:straight (shell-command+ 647(setup (:straight (shell-command+
634 :host nil 648 :host nil
635 :repo "https://git.sr.ht/~pkal/shell-command-plus")) 649 :repo "https://git.sr.ht/~pkal/shell-command-plus"))
636 (:option shell-command-prompt "$ ") 650 (:option shell-command-prompt "$ ")
637 (:bind-into dired 651 (:bind-into dired
638 "M-!" 'shell-command+) 652 "M-!" 'shell-command+)
639 (:global "M-!" 'shell-command+)) 653 (:+key "M-!" 'shell-command+))
640 654
641(setup (:straight (simple-modeline 655(setup (:straight (simple-modeline
642 :fork (:repo "duckwork/simple-modeline"))) 656 :fork (:repo "duckwork/simple-modeline")))
@@ -657,6 +671,9 @@ See also `crux-reopen-as-root-mode'."
657 +modeline-major-mode))) 671 +modeline-major-mode)))
658 (simple-modeline-mode +1)) 672 (simple-modeline-mode +1))
659 673
674(setup (:straight smartscan)
675 (smartscan-mode +1))
676
660(setup (:straight (sophomore 677(setup (:straight (sophomore
661 :host github 678 :host github
662 :repo "duckwork/sophomore.el")) 679 :repo "duckwork/sophomore.el"))
@@ -681,11 +698,27 @@ See also `crux-reopen-as-root-mode'."
681 (auto-save-visited-mode -1) 698 (auto-save-visited-mode -1)
682 (super-save-mode +1)) 699 (super-save-mode +1))
683 700
701(setup (:straight topsy)
702 (:hook-into prog-mode
703 circe-chat-mode)
704 (:when-loaded
705 (:option
706 topsy-header-line-format
707 '(:eval
708 (list
709 (propertize " "
710 'display
711 `((space
712 :align-to
713 ,(unless (bound-and-true-p visual-fill-column-mode)
714 0))))
715 (funcall topsy-fn))))))
716
684(setup (:straight trashed) 717(setup (:straight trashed)
685 (:option trashed-action-confirmer #'y-or-n-p)) 718 (:option trashed-action-confirmer #'y-or-n-p))
686 719
687(setup (:straight undo-fu) 720(setup (:straight undo-fu)
688 (:global "C-/" #'undo-fu-only-undo 721 (:+key "C-/" #'undo-fu-only-undo
689 "C-?" #'undo-fu-only-redo)) 722 "C-?" #'undo-fu-only-redo))
690 723
691(setup (:straight undo-fu-session) 724(setup (:straight undo-fu-session)
@@ -697,7 +730,7 @@ See also `crux-reopen-as-root-mode'."
697 730
698(setup (:straight (unfill :host github :repo "purcell/unfill" 731(setup (:straight (unfill :host github :repo "purcell/unfill"
699 :fork (:host github :repo "duckwork/unfill"))) 732 :fork (:host github :repo "duckwork/unfill")))
700 (:global "M-q" #'unfill-toggle)) 733 (:+key "M-q" #'unfill-toggle))
701 734
702(setup (:straight (vertico 735(setup (:straight (vertico
703 :host github 736 :host github
@@ -731,16 +764,8 @@ See also `crux-reopen-as-root-mode'."
731 (global-whitespace-cleanup-mode +1)) 764 (global-whitespace-cleanup-mode +1))
732 765
733(setup (:straight zzz-to-char) 766(setup (:straight zzz-to-char)
734 (:global "M-z" (lambda (prefix) 767 (:+key "M-z" (lambda (prefix)
735 "Call `zzz-to-char' or `zzz-up-to-char' with PREFIX arg." 768 "Call `zzz-to-char' or `zzz-up-to-char' with PREFIX arg."
736 (interactive "P") 769 (interactive "P")
737 (call-interactively 770 (call-interactively
738 (if prefix #'zzz-up-to-char #'zzz-to-char))))) 771 (if prefix #'zzz-up-to-char #'zzz-to-char)))))
739
740(setup (:straight scratch)
741 (:also-load +scratch)
742 (:option initial-major-mode 'emacs-lisp-mode
743 initial-scratch-message
744 ";; ABANDON ALL HOPE YE WHO ENTER HERE")
745 (add-hook 'kill-buffer-query-functions '+scratch-immortal)
746 (add-hook 'scratch-create-buffer-hook '+scratch-buffer-setup))
diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 7440c92..147bb76 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el
@@ -57,6 +57,7 @@ Do this only if the buffer is not visiting a file."
57 executable-prefix-env t 57 executable-prefix-env t
58 fast-but-imprecise-scrolling t 58 fast-but-imprecise-scrolling t
59 file-name-shadow-properties '(invisible t intangible t) 59 file-name-shadow-properties '(invisible t intangible t)
60 fill-column 80
60 frame-resize-pixelwise t 61 frame-resize-pixelwise t
61 global-auto-revert-non-file-buffers t 62 global-auto-revert-non-file-buffers t
62 global-mark-ring-max 100 63 global-mark-ring-max 100
diff --git a/lisp/+key.el b/lisp/+key.el new file mode 100644 index 0000000..5b4f467 --- /dev/null +++ b/lisp/+key.el
@@ -0,0 +1,65 @@
1;;; +key.el --- minor mode for keymaps -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;; Much of the code here was cribbed from https://emacs.stackexchange.com/a/358,
6;; which in turn was cribbed in part from
7;; https://github.com/kaushalmodi/.emacs.d/blob/master/elisp/modi-mode.el,
8;; https://github.com/jwiegley/use-package/blob/master/bind-key.el and
9;; elsewhere.
10
11;; The basic idea is to have a minor-mode for my personal key customizations,
12;; especially a "leader key" set up à la vim. In Emacs, I use `C-z' for this
13;; leader key, because of its easy location and relative uselessness by default.
14
15;;; Code:
16
17;; I need to define this map before the proper mode map.
18(defvar +key-leader-map (let ((map (make-sparse-keymap))
19 (c-z (global-key-binding "\C-z")))
20 (define-key map "\C-z" c-z)
21 map)
22 "A leader keymap under the \"C-z\" bind.")
23
24(defvar +key-mode-map (let ((map (make-sparse-keymap)))
25 (define-key map "\C-z" +key-leader-map)
26 map)
27 "Keymap for `+key-mode'.")
28
29;;;###autoload
30(define-minor-mode +key-mode
31 "A minor mode with keybindings that will override every other mode."
32 :init-value t
33 :lighter " +"
34 :keymap +key-mode-map)
35
36;;;###autoload
37(define-globalized-minor-mode +key-global-mode +key-mode +key-mode)
38
39(add-to-list 'emulation-mode-map-alists `((+key-mode . ,+key-mode-map)))
40
41(defun turn-off-+key-mode ()
42 "Turn off `+key-mode'."
43 (+key-mode -1))
44(add-hook 'minibuffer-setup-hook 'turn-off-+key-mode)
45
46;; Extras for `setup'
47(with-eval-after-load 'setup
48 (setup-define :+key
49 (lambda (key command)
50 `(define-key +key-mode-map ,key ,command))
51 :documentation "Bind KEY to COMMAND in `+key-mode-map'."
52 :debug '(form sexp)
53 :ensure '(kbd func)
54 :repeatable t)
55
56 (setup-define :+leader
57 (lambda (key command)
58 `(define-key +key-leader-map ,key ,command))
59 :documentation "Bind KEY to COMMAND in `+key-leader-map'."
60 :debug '(form sexp)
61 :ensure '(kbd func)
62 :repeatable t))
63
64(provide '+key)
65;;; +key.el ends here
diff --git a/lisp/+modeline.el b/lisp/+modeline.el index b417e50..0dc34c7 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el
@@ -151,7 +151,7 @@ The order of elements matters: whichever one matches first is applied."
151 151
152(defun +modeline-anzu () 152(defun +modeline-anzu ()
153 "Display `anzu--update-mode-line'." 153 "Display `anzu--update-mode-line'."
154 (anzu--update-mode-line)) 154 (concat " " (anzu--update-mode-line)))
155 155
156(provide '+modeline) 156(provide '+modeline)
157;;; +modeline.el ends here 157;;; +modeline.el ends here