summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw.el83
1 files changed, 83 insertions, 0 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el new file mode 100644 index 0000000..03e4a62 --- /dev/null +++ b/lisp/acdw.el
@@ -0,0 +1,83 @@
1:;;; acdw.el -*- lexical-binding: t; coding: utf-8-unix -*-
2;;
3;; Author: Case Duckworth <acdw@acdw.net>
4;; Created: Sometime during Covid-19, 2020
5;; Keywords: configuration
6;; URL: https://tildegit.org/acdw/emacs
7;; Bankruptcy: 5b
8;;
9;; This file is NOT part of GNU Emacs.
10;;
11;;; License:
12;;
13;; Everyone is permitted to do whatever with this software, without
14;; limitation. This software comes without any warranty whatsoever,
15;; but with two pieces of advice:
16;; - Don't hurt yourself.
17;; - Make good choices.
18;;
19;;; Commentary:
20;; `acdw.el' contains `acdw/map', its mode, and assorted ease-of-life
21;; functions for me, acdw.
22;;
23;;; Code:
24
25;;; Directories (think `no-littering')
26
27(defvar acdw/dir (expand-file-name
28 (convert-standard-filename "var/")
29 user-emacs-directory)
30 "A directory to hold extra configuration and emacs data.")
31
32(defun acdw/in-dir (file &optional make-directory)
33 "Expand FILE relative to `acdw/dir', optionally creating its
34directory."
35 (let ((f (expand-file-name (convert-standard-filename file)
36 acdw/dir)))
37 (when make-directory
38 (make-directory (file-name-directory) 'parents))
39 f))
40
41;;; Settings
42
43(defun acdw/set (assignments)
44 "Perform `customize-set-variable' on each of ASSIGNMENTS.
45
46ASSIGNMENTS is a list where each element is of the form
47(VARIABLE VALUE [COMMENT])."
48 (dolist (assn assignments)
49 (customize-set-variable (car assignment)
50 (cadr assignment)
51 (if (and (caddr assignment)
52 (stringp (caddr assignment)))
53 (caddr assignment)
54 "Customized by `acdw/set'."))))
55
56;;; Keymap & Mode
57
58(defvar acdw/map (make-sparse-keymap)
59 "A keymap for my custom bindings.")
60
61(define-minor-mode acdw/mode
62 "A mode for `acdw/map'."
63 :init-value t
64 :lighter " acdw"
65 :keymap acdw/map)
66(define-globalized-minor-mode acdw/global-mode acdw/mode acdw/mode)
67
68;; Disable `acdw/mode' in the minibuffer
69(defun acdw/mode--disable ()
70 "Disable `acdw/mode'."
71 (acdw/mode -1))
72(add-hook 'minibuffer-setup-hook #'acdw/mode--disable)
73
74;; Set up a leader key for `acdw/mode'
75(defvar acdw/leader
76 (let ((map (make-sparse-keymap))
77 (c-z (global-key-binding "\C-z")))
78 (define-key acdw/map "\C-z" map)
79 (define-key map "\C-z" c-z)
80 map))
81
82(provide 'acdw)
83;;; acdw.el ends here