Mostley add +key.el (but of course other stuff)

This commit is contained in:
Case Duckworth 2021-12-06 19:58:46 -06:00
parent 58ab5fc5e2
commit c7a9cba824
4 changed files with 115 additions and 24 deletions

71
init.el
View File

@ -38,6 +38,9 @@
(save-buffer)))
(:hook '+init-add-setup-to-imenu))
(setup (:require +key)
(+key-global-mode +1))
(setup (:require auth-source)
(:option auth-sources (list (private/ "authinfo")
(private/ "authinfo.gpg")
@ -82,7 +85,7 @@
(:hook 'dired-collapse-mode
'dired-hide-details-mode
'hl-line-mode)
(:global "C-x C-j" 'dired-jump)
(:+key "C-x C-j" 'dired-jump)
(with-eval-after-load 'dired
(pcase system-type
((or 'ms-dos 'windows-nt)
@ -164,7 +167,7 @@
(setup (:straight anzu)
(:option anzu-cons-mode-line-p nil)
(:global [remap query-replace] 'anzu-query-replace-regexp
(:+key [remap query-replace] 'anzu-query-replace-regexp
[remap query-replace-regexp] 'anzu-query-replace-regexp)
(global-anzu-mode +1)
(:bind-into isearch
@ -175,7 +178,7 @@
(setup (:straight avy)
(:also-load +avy)
(:global "M-j" 'avy-goto-char-timer)
(:+key "M-j" 'avy-goto-char-timer)
(:bind-into isearch
"M-j" 'avy-isearch)
(:when-loaded
@ -366,7 +369,7 @@
(:option consult--regexp-compiler 'consult--orderless-regexp-compiler))))
(setup (:straight crux)
(:global "C-o" 'crux-smart-open-line
(:+key "C-o" 'crux-smart-open-line
"M-o" 'crux-other-window-or-switch-buffer
"C-x 4 t" 'crux-transpose-windows)
@ -415,7 +418,7 @@ See also `crux-reopen-as-root-mode'."
(setup (:straight embark)
(:option prefix-help-command 'embark-prefix-help-command)
(:global "C-." 'embark-act
(:+key "C-." 'embark-act
"M-." 'embark-dwim
"<help> B" 'embark-bindings))
@ -441,12 +444,12 @@ See also `crux-reopen-as-root-mode'."
"XDG_CACHE_HOME")))
(setup (:straight expand-region)
(:global "C-=" 'er/expand-region))
(:+key "C-=" 'er/expand-region))
(setup (:straight (filldent
:host github
:repo "duckwork/filldent.el"))
(:global "M-q" 'filldent-dwim))
(:+key "M-q" 'filldent-dwim))
(setup (:straight (frowny
:host github
@ -458,7 +461,7 @@ See also `crux-reopen-as-root-mode'."
(gcmh-mode +1))
(setup (:straight helpful)
(:global "<help> f" 'helpful-callable
(:+key "<help> f" 'helpful-callable
"<help> v" 'helpful-variable
"<help> k" 'helpful-key
"C-c C-d" 'helpful-at-point))
@ -466,7 +469,7 @@ See also `crux-reopen-as-root-mode'."
(setup (:straight (hippie-completing-read
:host github
:repo "duckwork/hippie-completing-read"))
(:global "M-/" 'hippie-completing-read))
(:+key "M-/" 'hippie-completing-read))
(setup (:straight hungry-delete)
(:option hungry-delete-chars-to-skip " \t"
@ -508,7 +511,7 @@ See also `crux-reopen-as-root-mode'."
(isearch-mb-mode +1))
(setup (:straight lacarte)
(:global "<f10>" 'lacarte-execute-menu-command))
(:+key "<f10>" 'lacarte-execute-menu-command))
(setup (:straight marginalia)
(marginalia-mode +1))
@ -527,7 +530,7 @@ See also `crux-reopen-as-root-mode'."
:repo "protesilaos/modus-themes")))
(setup (:straight mwim)
(:global "C-a" #'mwim-beginning
(:+key "C-a" #'mwim-beginning
"C-e" #'mwim-end))
(setup (:straight orderless)
@ -615,6 +618,9 @@ See also `crux-reopen-as-root-mode'."
org-appear-delay 0)
(:hook-into org-mode))
(setup (:straight org-sticky-header)
(:hook-into org-mode))
(setup (:straight paredit)
(:bind "DEL" 'paredit-backward-delete
"C-<backspace>" 'paredit-backward-kill-word)
@ -630,13 +636,21 @@ See also `crux-reopen-as-root-mode'."
lisp-interaction-mode
scheme-mode))
(setup (:straight scratch)
(:require +scratch)
(:option initial-major-mode 'emacs-lisp-mode
initial-scratch-message
";; ABANDON ALL HOPE YE WHO ENTER HERE\n")
(add-hook 'kill-buffer-query-functions '+scratch-immortal)
(add-hook 'scratch-create-buffer-hook '+scratch-buffer-setup))
(setup (:straight (shell-command+
:host nil
:repo "https://git.sr.ht/~pkal/shell-command-plus"))
(:option shell-command-prompt "$ ")
(:bind-into dired
"M-!" 'shell-command+)
(:global "M-!" 'shell-command+))
(:+key "M-!" 'shell-command+))
(setup (:straight (simple-modeline
:fork (:repo "duckwork/simple-modeline")))
@ -657,6 +671,9 @@ See also `crux-reopen-as-root-mode'."
+modeline-major-mode)))
(simple-modeline-mode +1))
(setup (:straight smartscan)
(smartscan-mode +1))
(setup (:straight (sophomore
:host github
:repo "duckwork/sophomore.el"))
@ -681,11 +698,27 @@ See also `crux-reopen-as-root-mode'."
(auto-save-visited-mode -1)
(super-save-mode +1))
(setup (:straight topsy)
(:hook-into prog-mode
circe-chat-mode)
(:when-loaded
(:option
topsy-header-line-format
'(:eval
(list
(propertize " "
'display
`((space
:align-to
,(unless (bound-and-true-p visual-fill-column-mode)
0))))
(funcall topsy-fn))))))
(setup (:straight trashed)
(:option trashed-action-confirmer #'y-or-n-p))
(setup (:straight undo-fu)
(:global "C-/" #'undo-fu-only-undo
(:+key "C-/" #'undo-fu-only-undo
"C-?" #'undo-fu-only-redo))
(setup (:straight undo-fu-session)
@ -697,7 +730,7 @@ See also `crux-reopen-as-root-mode'."
(setup (:straight (unfill :host github :repo "purcell/unfill"
:fork (:host github :repo "duckwork/unfill")))
(:global "M-q" #'unfill-toggle))
(:+key "M-q" #'unfill-toggle))
(setup (:straight (vertico
:host github
@ -731,16 +764,8 @@ See also `crux-reopen-as-root-mode'."
(global-whitespace-cleanup-mode +1))
(setup (:straight zzz-to-char)
(:global "M-z" (lambda (prefix)
(:+key "M-z" (lambda (prefix)
"Call `zzz-to-char' or `zzz-up-to-char' with PREFIX arg."
(interactive "P")
(call-interactively
(if prefix #'zzz-up-to-char #'zzz-to-char)))))
(setup (:straight scratch)
(:also-load +scratch)
(:option initial-major-mode 'emacs-lisp-mode
initial-scratch-message
";; ABANDON ALL HOPE YE WHO ENTER HERE")
(add-hook 'kill-buffer-query-functions '+scratch-immortal)
(add-hook 'scratch-create-buffer-hook '+scratch-buffer-setup))

View File

@ -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

65
lisp/+key.el Normal file
View File

@ -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

View File

@ -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