summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw.el215
1 files changed, 1 insertions, 214 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index 9aa0821..9387cf1 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -1,4 +1,4 @@
1:;;; acdw.el -*- lexical-binding: t; coding: utf-8-unix -*- 1;;; acdw.el -*- lexical-binding: t; coding: utf-8-unix -*-
2;; Author: Case Duckworth <acdw@acdw.net> 2;; Author: Case Duckworth <acdw@acdw.net>
3;; Created: Sometime during Covid-19, 2020 3;; Created: Sometime during Covid-19, 2020
4;; Keywords: configuration 4;; Keywords: configuration
@@ -91,187 +91,6 @@ directory."
91 (make-directory (file-name-directory f) 'parents)) 91 (make-directory (file-name-directory f) 'parents))
92 f)) 92 f))
93 93
94;;; Settings
95
96;; (defun acdw/set (assignments)
97;; "Perform `customize-set-variable' on each of ASSIGNMENTS.
98
99;; ASSIGNMENTS is a list where each element is of the form
100;; (VARIABLE VALUE [COMMENT])."
101;; (let (setting) ; for return value
102;; (dolist (assignment assignments setting)
103;; (customize-set-variable (car assignment)
104;; (cadr assignment)
105;; (if (and (caddr assignment)
106;; (stringp (caddr assignment)))
107;; (caddr assignment)
108;; "Customized by `acdw/set'."))
109;; (setq setting (car assignment)))))
110
111;;; Faces
112
113;; (defun acdw/set-face (face spec)
114;; "Customize FACE according to SPEC, and register it with `customize'.
115;; SPEC is as for `defface'."
116;; (put face 'customized-face spec)
117;; (face-spec-set face spec))
118
119;; (defmacro acdw/set-faces (face-specs)
120;; "Run `acdw/set-face' over each face in FACE-SPECS."
121;; (let (face-list)
122;; (dolist (face face-specs)
123;; (push `(acdw/set-face ',(car face) ',(cdr face)) face-list))
124;; `(progn
125;; ,@face-list)))
126
127;;; Hooks
128;; (defmacro acdw/hooks (hook-specs &rest args)
129;; "Add functions to hooks, according to HOOK-SPECS.
130
131;; Each HOOK-SPEC is of the following format: (HOOKS FUNCS [DEPTH] [LOCAL]).
132;; Either HOOKS or FUNCS can also be a list, in which case `add-hook' is called
133;; over the Cartesian product of HOOKS and FUNCS. In each HOOK-SPEC, DEPTH and
134;; LOCAL apply to all hooks defined; if finer control is needed, either pass the
135;; same hooks and functions in different HOOK-SPECs, or just use `add-hook'.
136
137;; ARGS accept the following keywords:
138
139;; :after FEATURE .. `autoload' all functions after FEATURE."
140;; (let ((after (plist-get args :after))
141;; (command-list))
142;; (dolist (spec hook-specs)
143;; (let* ((hooks (car spec))
144;; (funcs (cadr spec))
145;; (depth (or (caddr spec) 0))
146;; (local (cadddr spec)))
147;; (when (not (listp hooks)) (setq hooks (list hooks)))
148;; (when (not (listp funcs)) (setq funcs (list funcs)))
149;; (dolist (hook hooks)
150;; (dolist (func funcs)
151;; (push `(add-hook ',hook #',func ,depth ,local) command-list)
152;; (when after
153;; (push `(autoload #',func ,after) command-list))))))
154;; `(progn
155;; ,@command-list)))
156
157;;; Keybindings
158
159;; (defvar acdw/bind-default-map 'acdw/map
160;; "The default keymap to use with `acdw/bind'.")
161
162;; (defmacro acdw/bind (key command &rest args)
163;; "A simple key-binding macro to take care of the repetitive stuff
164;; automatically.
165
166;; If KEY is a vector, it's passed directly to `define-key',
167;; otherwise it's wrapped in `kbd'.
168
169;; The following keywords are recognized:
170
171;; :after ARGS .. call `autoload' on COMMAND using ARGS before
172;; binding the key. ARGS can be just the filename to
173;; load; in that case it's wrapped in a list.
174
175;; :map KEYMAP .. define KEY in KEYMAP instead of the
176;; default `acdw/bind-default-map'. If `:after' is also supplied,
177;; run `autoload' on KEYMAP (except when using `:map-after', see).
178
179;; :map-after FILE .. run the underlying `define-key' command in an
180;; `with-eval-after-load'. For the rare occasion when the keymap is
181;; defined in a different file than the command it binds (looking
182;; at you, `org-mode')."
183;; (let ((after (when-let (sym (plist-get args :after))
184;; (if (not (listp sym))
185;; (list sym)
186;; sym)))
187;; (map-after (plist-get args :map-after))
188;; (keymap (or (plist-get args :map) acdw/bind-default-map))
189;; (keycode (if (vectorp key) key (kbd key)))
190;; (command-list))
191;; (let ((define-key-command `(define-key ,keymap ,keycode ',command)))
192;; (if map-after
193;; (push `(with-eval-after-load ,map-after
194;; ,define-key-command)
195;; command-list)
196;; (push define-key-command command-list)))
197;; (when after
198;; (unless (fboundp command)
199;; (push `(autoload ',command ,@after) command-list))
200;; (unless (or map-after
201;; (eq keymap acdw/bind-default-map))
202;; (push `(autoload ',keymap ,(car after) nil nil 'keymap) command-list)))
203;; `(progn
204;; ,@command-list)))
205
206;; (defmacro acdw/binds (bindings)
207;; "Bind multiple keys at once."
208;; (let (bind-list)
209;; (dolist (bind bindings)
210;; (push `(acdw/bind ,@bind) bind-list))
211;; `(progn
212;; ,@bind-list)))
213
214;; convenience
215;; (defmacro acdw/bind-after-map (file keymap bindings)
216;; "Wrap multiple calls of `acdw/bind' after FILE and with KEYMAP.
217;; KEYMAP can be nil."
218;; (declare (indent 2))
219;; (let ((bind-list)
220;; (extra-args (if keymap
221;; `(:after ,file :map ,keymap)
222;; `(:after ,file))))
223;; (dolist (binding bindings)
224;; (push `(acdw/bind ,@binding ,@extra-args) bind-list))
225;; `(progn
226;; ,@bind-list)))
227
228;;; Packages
229
230;; (defmacro acdw/pkg (package &rest args)
231;; "Set up a package using `straight.el'.
232
233;; ARGS can include the following keywords:
234
235;; :local BOOL .. if BOOL is non-nil, don't run `straight-use-package' on
236;; PACKAGE. Good for using `acdw/pkg' on local features.
237;; :require BOOL .. if BOOL is non-nil, run `require' on PACKAGE before anything.
238;; :now FORMS .. run FORMS immediately.
239;; :then FORMS .. run FORMS after loading PACKAGE, using `with-eval-after-load'.
240;; :set SETTINGS .. pass SETTINGS to `acdw/set', right after `:now' forms.
241;; SETTINGS should be properly quoted, just like they'd be passed
242;; to the function.
243;; :binds BINDS .. run `acdw/bind-after-map' on BINDS.
244;; :hooks HOOKS .. run `acdw/hooks' on HOOKS."
245;; (declare (indent 1))
246;; (let ((local-pkg (plist-get args :local))
247;; (require-pkg (plist-get args :require))
248;; (now-forms (plist-get args :now))
249;; (settings (plist-get args :set))
250;; (binds (plist-get args :binds))
251;; (hooks (plist-get args :hooks))
252;; (then-forms (plist-get args :then))
253;; (requirement (if (listp package)
254;; (car package)
255;; package))
256;; (final-form))
257;; (when then-forms
258;; (push `(with-eval-after-load ',requirement ,@then-forms) final-form))
259;; (when hooks
260;; (push `(acdw/hooks ,hooks :after ,(symbol-name requirement)) final-form))
261;; (when binds
262;; (push `(acdw/bind-after-map ,(symbol-name requirement) nil ,binds)
263;; final-form))
264;; (when settings
265;; (push `(acdw/set ,settings) final-form))
266;; (when now-forms
267;; (push `(progn ,@now-forms) final-form))
268;; (unless local-pkg
269;; (push `(straight-use-package ',package) final-form))
270;; (when require-pkg
271;; (push `(require ',requirement) final-form))
272;; `(progn
273;; ,@final-form)))
274
275;;; Reading mode 94;;; Reading mode
276 95
277(define-minor-mode acdw/reading-mode 96(define-minor-mode acdw/reading-mode
@@ -320,35 +139,3 @@ directory."
320 139
321(provide 'acdw) 140(provide 'acdw)
322;;; acdw.el ends here 141;;; acdw.el ends here
323
324;;; Elephant graveyard
325
326;; XXX NOT WORKING -- And is this even necessary?
327;; (defmacro acdw/defun-hook (hook docstring &optional depth local &rest forms)
328;; "Add FORMS to a function described by DOCSTRING, then add that
329;; function to HOOK. DOCSTRING is converted to a function name by
330;; calling `docstring-to-symbol', if it's a string, or used as-is
331;; otherwise. The optional DEPTH and LOCAL are passed to
332;; `add-hook', if they're present (i.e., not a list).
333
334;; This macro aims to split the difference between the syntax of
335;; lambdas in hooks and the ability to easily disable hooks."
336;; (declare (indent 2))
337;; (let ((name (if (stringp docstring)
338;; (docstring-to-symbol docstring "hook-")
339;; docstring)))
340;; (when (listp local) (push local forms) (setq local nil))
341;; (when (listp depth) (push depth forms) (setq depth 0))
342;; `(progn
343;; (defun ,name () ,@forms)
344;; (add-hook ,hook #',name ,depth ,local))))
345
346;; Utilities XXX related to `acdw/defun-hook'
347;; (defun docstring-to-symbol (docstring &optional prefix)
348;; "Convert a DOCSTRING to a symbol by lowercasing the string,
349;; converting non-symbol-safe characters to '-', and calling
350;; `intern'. Returns the created symbol."
351;; (let ((str (split-string (downcase docstring) "[ \f\t\n\r\v'\"`,]+"
352;; :omit-nulls)))
353;; (when prefix (push prefix str))
354;; (intern (mapconcat #'identity str "-"))))