From 983c7330e87481227393670b2151cb0539dc4de4 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 7 Mar 2021 22:14:38 -0600 Subject: 5c --- lisp/acdw.el | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 lisp/acdw.el (limited to 'lisp') 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 @@ +:;;; acdw.el -*- lexical-binding: t; coding: utf-8-unix -*- +;; +;; Author: Case Duckworth +;; Created: Sometime during Covid-19, 2020 +;; Keywords: configuration +;; URL: https://tildegit.org/acdw/emacs +;; Bankruptcy: 5b +;; +;; This file is NOT part of GNU Emacs. +;; +;;; License: +;; +;; Everyone is permitted to do whatever with this software, without +;; limitation. This software comes without any warranty whatsoever, +;; but with two pieces of advice: +;; - Don't hurt yourself. +;; - Make good choices. +;; +;;; Commentary: +;; `acdw.el' contains `acdw/map', its mode, and assorted ease-of-life +;; functions for me, acdw. +;; +;;; Code: + +;;; Directories (think `no-littering') + +(defvar acdw/dir (expand-file-name + (convert-standard-filename "var/") + user-emacs-directory) + "A directory to hold extra configuration and emacs data.") + +(defun acdw/in-dir (file &optional make-directory) + "Expand FILE relative to `acdw/dir', optionally creating its +directory." + (let ((f (expand-file-name (convert-standard-filename file) + acdw/dir))) + (when make-directory + (make-directory (file-name-directory) 'parents)) + f)) + +;;; Settings + +(defun acdw/set (assignments) + "Perform `customize-set-variable' on each of ASSIGNMENTS. + +ASSIGNMENTS is a list where each element is of the form +(VARIABLE VALUE [COMMENT])." + (dolist (assn assignments) + (customize-set-variable (car assignment) + (cadr assignment) + (if (and (caddr assignment) + (stringp (caddr assignment))) + (caddr assignment) + "Customized by `acdw/set'.")))) + +;;; Keymap & Mode + +(defvar acdw/map (make-sparse-keymap) + "A keymap for my custom bindings.") + +(define-minor-mode acdw/mode + "A mode for `acdw/map'." + :init-value t + :lighter " acdw" + :keymap acdw/map) +(define-globalized-minor-mode acdw/global-mode acdw/mode acdw/mode) + +;; Disable `acdw/mode' in the minibuffer +(defun acdw/mode--disable () + "Disable `acdw/mode'." + (acdw/mode -1)) +(add-hook 'minibuffer-setup-hook #'acdw/mode--disable) + +;; Set up a leader key for `acdw/mode' +(defvar acdw/leader + (let ((map (make-sparse-keymap)) + (c-z (global-key-binding "\C-z"))) + (define-key acdw/map "\C-z" map) + (define-key map "\C-z" c-z) + map)) + +(provide 'acdw) +;;; acdw.el ends here -- cgit 1.4.1-21-gabe81