From c7a9cba8247444ab08a9f3266404bb2156924cf0 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 6 Dec 2021 19:58:46 -0600 Subject: Mostley add +key.el (but of course other stuff) --- lisp/+emacs.el | 1 + lisp/+key.el | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ lisp/+modeline.el | 2 +- 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 lisp/+key.el (limited to 'lisp') 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." executable-prefix-env t fast-but-imprecise-scrolling t file-name-shadow-properties '(invisible t intangible t) + fill-column 80 frame-resize-pixelwise t global-auto-revert-non-file-buffers t 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 @@ +;;; +key.el --- minor mode for keymaps -*- lexical-binding: t; -*- + +;;; Commentary: + +;; Much of the code here was cribbed from https://emacs.stackexchange.com/a/358, +;; which in turn was cribbed in part from +;; https://github.com/kaushalmodi/.emacs.d/blob/master/elisp/modi-mode.el, +;; https://github.com/jwiegley/use-package/blob/master/bind-key.el and +;; elsewhere. + +;; The basic idea is to have a minor-mode for my personal key customizations, +;; especially a "leader key" set up à la vim. In Emacs, I use `C-z' for this +;; leader key, because of its easy location and relative uselessness by default. + +;;; Code: + +;; I need to define this map before the proper mode map. +(defvar +key-leader-map (let ((map (make-sparse-keymap)) + (c-z (global-key-binding "\C-z"))) + (define-key map "\C-z" c-z) + map) + "A leader keymap under the \"C-z\" bind.") + +(defvar +key-mode-map (let ((map (make-sparse-keymap))) + (define-key map "\C-z" +key-leader-map) + map) + "Keymap for `+key-mode'.") + +;;;###autoload +(define-minor-mode +key-mode + "A minor mode with keybindings that will override every other mode." + :init-value t + :lighter " +" + :keymap +key-mode-map) + +;;;###autoload +(define-globalized-minor-mode +key-global-mode +key-mode +key-mode) + +(add-to-list 'emulation-mode-map-alists `((+key-mode . ,+key-mode-map))) + +(defun turn-off-+key-mode () + "Turn off `+key-mode'." + (+key-mode -1)) +(add-hook 'minibuffer-setup-hook 'turn-off-+key-mode) + +;; Extras for `setup' +(with-eval-after-load 'setup + (setup-define :+key + (lambda (key command) + `(define-key +key-mode-map ,key ,command)) + :documentation "Bind KEY to COMMAND in `+key-mode-map'." + :debug '(form sexp) + :ensure '(kbd func) + :repeatable t) + + (setup-define :+leader + (lambda (key command) + `(define-key +key-leader-map ,key ,command)) + :documentation "Bind KEY to COMMAND in `+key-leader-map'." + :debug '(form sexp) + :ensure '(kbd func) + :repeatable t)) + +(provide '+key) +;;; +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." (defun +modeline-anzu () "Display `anzu--update-mode-line'." - (anzu--update-mode-line)) + (concat " " (anzu--update-mode-line))) (provide '+modeline) ;;; +modeline.el ends here -- cgit 1.4.1-21-gabe81