about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+emacs.el1
-rw-r--r--lisp/+key.el65
-rw-r--r--lisp/+modeline.el2
3 files changed, 67 insertions, 1 deletions
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