Mostly keywording stuff

I messed up my commits here... bah
This commit is contained in:
Case Duckworth 2021-09-04 23:57:04 -05:00
parent 2d95e1efef
commit fd3d5fc55f
2 changed files with 246 additions and 255 deletions

475
init.el
View File

@ -125,13 +125,13 @@ AKA, DO NOT USE THIS FUNCTION!!!"
(setup browse-url
(:require acdw-browse-url)
(setq-default browse-url-secondary-browser-function
(if (executable-find "firefox") ; prefer Firefox
#'browse-url-firefox
#'browse-url-default-browser)
browse-url-new-window-flag nil ; for eww
browse-url-firefox-arguments '("--new-tab") ; for firefox
browse-url-firefox-new-window-is-tab t)
(:option browse-url-secondary-browser-function
(if (executable-find "firefox") ; prefer Firefox
#'browse-url-firefox
#'browse-url-default-browser)
browse-url-new-window-flag nil ; for eww
browse-url-firefox-arguments '("--new-tab") ; for firefox
browse-url-firefox-new-window-is-tab t)
(acdw/browse-url-set-handlers
(list
@ -222,9 +222,8 @@ AKA, DO NOT USE THIS FUNCTION!!!"
circe-reduce-lurker-spam t
circe-server-auto-join-default-type :after-auth)
(custom-set-faces '(circe-nick-highlight-face
((t (:inherit (modus-themes-hl-line))))
:now))
(:face circe-nick-highlight-face
((t (:inherit (modus-themes-hl-line)))))
(:bind "C-c C-p" #'circe-command-PART)
@ -248,18 +247,19 @@ AKA, DO NOT USE THIS FUNCTION!!!"
(:with-mode circe-chat-mode
(:hook #'acdw/stop-paren-annoyances
(defun circe-chat@setup ()
#'enable-circe-color-nicks
#'enable-circe-display-images
#'enable-circe-new-day-notifier
(defun circe-chat@set-prompt ()
(lui-set-prompt
(concat (propertize (acdw-irc/margin-format (buffer-name)
""
">")
'face 'circe-prompt-face
'read-only t 'intangible t
'cursor-intangible t)
" "))
(enable-circe-color-nicks)
(enable-circe-display-images)
(enable-circe-new-day-notifier))))
(concat
(propertize
(acdw-irc/margin-format (buffer-name) "" ">")
'face 'circe-prompt-face
'read-only t
'intangible t
'cursor-intangible t)
" ")))))
(autoload 'circe-nick-color-reset "circe-color-nicks")
(add-hook 'modus-themes-after-load-theme-hook
@ -272,16 +272,15 @@ AKA, DO NOT USE THIS FUNCTION!!!"
lui-time-stamp-format "%H:%M"
lui-track-behavior 'before-switch-to-buffer
lui-track-indicator 'fringe)
(:local-set fringes-outside-margins t
right-margin-width 5
scroll-margin 0
word-wrap t
wrap-prefix (repeat-string acdw-irc/left-margin " ")
line-number-mode nil)
(:hook (defun lui-mode@setup ()
(setq-local fringes-outside-margins t
right-margin-width 5
scroll-margin 0
word-wrap t
wrap-prefix (repeat-string
acdw-irc/left-margin " ")
line-number-mode nil)
(enable-lui-track)))))
(:hook #'enable-lui-track)))
(setup completion
(:option completion-ignore-case t
@ -296,10 +295,10 @@ AKA, DO NOT USE THIS FUNCTION!!!"
(setup (:straight (consult
:host github
:repo "minad/consult"))
(require 'acdw-consult)
(setq consult--regexp-compiler #'consult--orderless-regexp-compiler)
(:require acdw-consult)
(:autoload consult-register-preview)
;; Bindings
(:global
;; C-c bindings (`mode-specific-map')
@ -344,32 +343,6 @@ AKA, DO NOT USE THIS FUNCTION!!!"
"M-s e" #'consult-isearch
"M-s l" #'consult-line))
;; see https://github.com/oantolin/completing-history
(defmacro consult-history-to-modes (map-hook-alist)
(let (defuns)
(dolist (map-hook map-hook-alist)
(let ((map-name (symbol-name (car map-hook)))
(key-defs `(progn (define-key
,(car map-hook)
(kbd "M-r")
(function consult-history))
(define-key ,(car map-hook)
(kbd "M-s") nil))))
(push (if (cdr map-hook)
`(add-hook ',(cdr map-hook)
(defun
,(intern (concat map-name
"@consult-history-bind"))
nil
,(concat
"Bind `consult-history' to M-r in "
map-name ".\n"
"Defined by `consult-history-to-modes'.")
,key-defs))
key-defs)
defuns)))
`(progn ,@ (nreverse defuns))))
(consult-history-to-modes ((minibuffer-local-map . nil)
(shell-mode-map . shell-mode-hook)
(term-mode-map . term-mode-hook)
@ -377,47 +350,38 @@ AKA, DO NOT USE THIS FUNCTION!!!"
(comint-mode-map . comint-mode-hook)
(sly-mrepl-mode-map . sly-mrepl-hook)))
;; Registers
(:autoload consult-register-preview)
(:option register-preview-delay 0
register-preview-function #'consult-register-format)
(:advise register-preview :override #'consult-register-window)
;; Xref
(:option xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref)
;; Projects
(:option consult-project-root-function #'vc-root-dir)
;; Competion-at-point (complete-region)
(:option completion-in-region-function #'acdw-consult/complete-in-region
register-preview-function #'consult-register-format
xref-show-xrefs-function #'consult-xref
xref-show-definitions-function #'consult-xref
consult-project-root-function #'vc-root-dir
completion-in-region-function #'acdw-consult/complete-in-region
completion-cycle-threshold 3
tab-always-indent 'complete)
(:advise register-preview :override #'consult-register-window)
;; Completing-read-multple
(if (fboundp #'consult-completing-read-multiple)
(:advise completing-read-multple
:override #'consult-completing-read-multiple)
;; else
(defun crm-indicator (args)
(cons (concat "[CRM] " (car args)) (cdr args)))
(:advise completing-read-multiple
:filter-args #'crm-indicator))
(:advise completing-read-multple :override
#'consult-completing-read-multiple)
(:advise completing-read-multiple :filter-args
(defun crm-indicator (args)
(cons (concat "[CRM] " (car args)) (cdr args)))))
(with-eval-after-load 'orderless
(:option consult--regexp-compiler
#'consult--orderless-regexp-compiler))
(with-eval-after-loads (vertico consult)
(when (boundp 'consult-crm-map)
(define-key consult-crm-map "\r" #'+vertico-crm-exit)
(define-key consult-crm-map "\t" #'vertico-exit)
(defun +vertico-crm-exit ()
(interactive)
(run-at-time 0 nil #'vertico-exit)
(funcall #'vertico-exit)))))
(:with-map consult-crm-map
(:bind "RET" (defun +vertico-crm-exit ()
(interactive)
(run-at-time 0 nil #'vertico-exit)
(funcall #'vertico-exit))
"TAB" #'vertico-exit))))
(setup (:straight crux)
(:global "C-x o" #'acdw/other-window-or-switch-buffer
"C-o" #'crux-smart-open-line
"M-o" #'crux-smart-open-line-above
@ -425,9 +389,8 @@ AKA, DO NOT USE THIS FUNCTION!!!"
"C-x 4 t" #'crux-transpose-windows)
(when (fboundp 'repeat-mode)
(unless (boundp 'other-window-repeat-map)
(defvar other-window-repeat-map (make-sparse-keymap)
"A map for repeating `other-window' keys."))
(defvar other-window-repeat-map (make-sparse-keymap)
"A map for repeating `other-window' keys.")
(define-key other-window-repeat-map "o"
#'acdw/other-window-or-switch-buffer)
@ -475,37 +438,34 @@ AKA, DO NOT USE THIS FUNCTION!!!"
nil))))
(:with-mode Custom-mode
(:hook (defun custom-mode@imenu () ; thanks u/oantolin!
"Build `imenu' for `Custom-mode'."
(setq
imenu-generic-expression
'(("Faces" (rx (seq bol
(or "Show" "Hide") " "
(group (zero-or-more nonl))
" face: [sample]"))
1)
("Variables" (rx (seq bol
(or "Show Value" "Hide") " "
(group (zero-or-more
(not (any "\n:"))))))
1)))))))
(:local-set imenu-generic-expression ; thanks u/oantolin!
'(("Faces" (rx (seq bol
(or "Show" "Hide") " "
(group (zero-or-more nonl))
" face: [sample]"))
1)
("Variables" (rx (seq bol
(or "Show Value" "Hide") " "
(group (zero-or-more
(not (any "\n:"))))))
1)))))
(setup debugger
(:hook visual-line-mode))
(setup dired
(:also-load dired-x)
(setq-default dired-recursive-copies 'always
dired-recursive-deletes 'always
delete-by-moving-to-trash t
dired-listing-switches "-Al"
ls-lisp-dirs-first t
dired-ls-F-marks-symlinks t
dired-no-confirm '(byte-compile
chgrp chmod chown copy
hardlink load move
shell touch symlink)
dired-dwim-target t)
(:option dired-recursive-copies 'always
dired-recursive-deletes 'always
delete-by-moving-to-trash t
dired-listing-switches "-Al"
ls-lisp-dirs-first t
dired-ls-F-marks-symlinks t
dired-no-confirm '(byte-compile
chgrp chmod chown copy
hardlink load move
shell touch symlink)
dired-dwim-target t)
(:hook dired-hide-details-mode
hl-line-mode)
@ -614,6 +574,12 @@ AKA, DO NOT USE THIS FUNCTION!!!"
:host "mf.acdw.net"))))
(elfeed-protocol-enable)
(:advise elfeed :after
(defun elfeed@protocol-update (&rest _)
(elfeed-search-fetch nil)))
(:face message-header-subject
((t (:height 1.5))))
(:with-mode elfeed-show-mode
(:hook (defun elfeed-show@setup ()
@ -641,16 +607,17 @@ AKA, DO NOT USE THIS FUNCTION!!!"
lisp-indent-function #'lisp-indent-function)
(:with-mode emacs-lisp-mode
(:hook #'checkdoc-minor-mode
#'turn-on-eldoc-mode
(defun emacs-lisp@enforce-lexical-binding ()
(setq-local lexical-binding t))
(:local-set lexical-binding t
(append imenu-generic-expression)
`("Setup"
,(rx (seq
(group bol (* space) "(setup" (+ space))
(? (group "(:" (+ graph) (* space) (? "(")))
(group (+ (any word ?-)))))
3))
(defun emacs-lisp@imenu-add-setup ()
(:option (append imenu-generic-expression)
'("Setup"
"\\(^\\s-*(setup +(?\\)\\(\\_<.+\\_>\\)" 2))))
(:hook #'checkdoc-minor-mode
#'turn-on-eldoc-mode)
;; Emulate slime's eval binds
(:bind "C-c C-c" #'eval-defun
@ -661,7 +628,7 @@ AKA, DO NOT USE THIS FUNCTION!!!"
(:advise eval-region :around
(defun eval-region@pulse (fn beg end &rest args)
(pulse-momentary-highlight-region beg end)
(apply fn start end args))))
(apply fn beg end args))))
(setup (:straight elisp-slime-nav)
(:hook-into emacs-lisp-mode
@ -679,7 +646,7 @@ AKA, DO NOT USE THIS FUNCTION!!!"
"o" #'elpher-follow-current-link
"G" #'elpher-go-current)
(:hook acdw/reading-mode)
(:hook #'acdw/reading-mode)
(:autoload (elpher-bookmarks :interactive t)
(elpher-go :interactive t))
@ -692,22 +659,99 @@ AKA, DO NOT USE THIS FUNCTION!!!"
;; (t (apply fn url args))))
)
(setup emacs
;; "Et cetera" settings
;; This should stay as /minimal/ as possible. Anything that can go somewhere
;; else /should/ go there.
(:option
attempt-orderly-shutdown-on-fatal-signal nil
attempt-stack-overflow-recovery nil
echo-keystrokes 0.01
find-function-C-source-directory (acdw/find-emacs-source)
kill-read-only-ok t
load-prefer-newer t
native-comp-async-report-warnings-errors nil
set-mark-command-repeat-pop t)
(when (fboundp 'command-completion-default-include-p)
(setq read-extended-command-predicate
#'command-completion-default-include-p))
(defvar case-map (make-sparse-keymap)
"A keymap for setting case in various ways.")
(global-set-key (kbd "C-c c") case-map)
(defvar lookup-map (make-sparse-keymap)
"A keymap for looking up things.")
(global-set-key (kbd "C-c l") lookup-map)
(:global "M-=" #'count-words
"C-w" #'kill-region-or-backward-word
"C-c c c" #'capitalize-dwim
"C-c c t" #'titlecase-dwim
"C-c c u" #'upcase-dwim
"C-c c l" #'downcase-dwim
"C-c d" #'acdw/insert-iso-date
"M-`" nil)
;; toggle bindings
(defvar toggle-map (make-sparse-keymap)
"A keymap for toggling!")
(global-set-key (kbd "C-c t") toggle-map)
(:with-map toggle-map
(:bind "c" #'column-number-mode
"l" #'display-line-numbers-mode
"d" #'toggle-debug-on-error))
(defalias 'forward-word-with-case 'forward-word
"Alias for `forward-word' for use in `case-repeat-map'.")
(defalias 'backward-word-with-case 'backward-word
"Alias for `backward-word for use in `case-repeat-map'.")
(defvar case-repeat-map
(let ((map (make-sparse-keymap)))
(define-key map "c" #'capitalize-word)
(define-key map "u" #'upcase-word)
(define-key map "l" #'downcase-word)
;; movement
(define-key map "f" #'forward-word-with-case)
(define-key map "b" #'backward-word-with-case)
map)
"A map to repeat word-casing commands. For use with `repeat-mode'.")
(dolist (command '(capitalize-word
capitalize-dwim
upcase-word
upcase-dwim
downcase-word
downcase-dwim
forward-word-with-case
backward-word-with-case))
(put command 'repeat-map 'case-repeat-map))
(add-hook 'after-make-frame-functions
(defun after-make-frame@maximize (frame)
(unless (bound-and-true-p edit-server-frame-p)
(toggle-frame-maximized frame)))))
(setup (:straight embark)
(:global "C-." #'embark-act)
(:option prefix-help-command #'embark-prefix-help-command
(append display-buffer-alist)
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
`(,(rx (seq bos "*Embark Collect "
(group (| "Live" "Completions"))
"*"))
nil
(window-parameters (mode-line-format . none)))
embark-prompter #'embark-keymap-prompter
embark-verbose-indicator-display-action
'(display-buffer-at-bottom (window-height . fit-window-to-buffer)))
(setq embark-action-indicator
(lambda (map _target)
(which-key--show-keymap "Embark" map nil nil 'no-paging)
#'which-key--hide-popup-ignore-command)
embark-become-indicator embark-action-indicator)
'(display-buffer-at-bottom (window-height . fit-window-to-buffer))
embark-action-indicator
(lambda (map _target)
(which-key--show-keymap "Embark" map nil nil 'no-paging)
#'which-key--hide--ignore-command)
embark-become-indicator embark-action-indicator)
(with-eval-after-loads (embark consult)
(:straight embark-consult)
@ -803,29 +847,24 @@ AKA, DO NOT USE THIS FUNCTION!!!"
eshell-smart-space-goes-to-end t
eshell-where-to-jump 'begin)
(defun eshell-buffer-name ()
(rename-buffer (concat "*eshell*<" (eshell/pwd) ">") t))
;; Make navigating amongst prompts easier
(:local-set outline-regexp eshell-prompt-regexp
page-delimiter eshell-prompt-regexp)
(add-hook 'eshell-directory-change-hook #'eshell-buffer-name)
(add-hook 'eshell-prompt-load-hook #'eshell-buffer-name)
(:bind "C-d" #'eshell-quit-or-delete-char)
(:hook eshell-arg-hist-mode
(:hook #'eshell-arg-hist-mode
(defun eshell-mode@setup ()
;; Define keys
(dolist (spec '(("C-d" . eshell-quit-or-delete-char)))
(define-key eshell-mode-map (kbd (car spec)) (cdr spec)))
;; Fix modeline
(when (boundp 'simple-modeline--mode-line)
(setq mode-line-format '(:eval simple-modeline--mode-line)))
;; Make navigating amongst prompts easier
(setq-local outline-regexp eshell-prompt-regexp
page-delimiter eshell-prompt-regexp))))
(setq mode-line-format '(:eval simple-modeline--mode-line))))))
(setup eww
(:option eww-search-prefix "https://duckduckgo.com/html?q="
url-privacy-level '(email agent cookies lastloc))
(:hook acdw/reading-mode))
(:hook #'acdw/reading-mode))
(setup (:straight-if exec-path-from-shell
(acdw/system :home))
@ -877,11 +916,7 @@ successive invocations."
vc-make-backup-files t
version-control t)
(auto-save-visited-mode +1)
(add-hook 'unfocused-hook
(defun unfocused@save-buffers ()
(save-some-buffers t))))
(auto-save-visited-mode +1))
(setup find-func
(:global "C-c l f" #'find-function
@ -905,9 +940,7 @@ successive invocations."
" %+%* GNU Emacs"
(:eval (when (frame-parameter nil 'client)
" Client")))
window-resize-pixelwise t)
(add-hook 'unfocused-hook #'garbage-collect))
window-resize-pixelwise t))
(setup (:straight gcmh)
(:option gcmh-idle-delay 'auto)
@ -1121,9 +1154,7 @@ browser defined in `browse-url-secondary-browser-function'."
(:file-match (rx ".lua" eos)))
(setup (:straight macrostep)
(:with-mode emacs-lisp-mode
(:bind "C-c e" #'macrostep-expand)))
(define-key emacs-lisp-mode-map (kbd "C-c e") #'macrostep-expand))
(setup (:straight magit)
(:global "C-c g" #'magit-status)
@ -1182,7 +1213,10 @@ browser defined in `browse-url-secondary-browser-function'."
(minibuffer-depth-indicate-mode +1)
(file-name-shadow-mode +1)
(minibuffer-electric-default-mode +1)
(fset 'yes-or-no-p #'y-or-n-p))
(if (version< emacs-version "28")
(fset 'yes-or-no-p #'y-or-n-p)
(setq use-short-answers t)))
(setup (:straight (modus-themes
:host gitlab
@ -1418,6 +1452,7 @@ browser defined in `browse-url-secondary-browser-function'."
(mapc (lambda (buf)
(with-current-buffer buf
(when (funcall persistent-scratch-scratch-buffer-p-function)
(setq lexical-binding t)
(persistent-scratch-mode +1))))
(buffer-list)))
@ -1607,6 +1642,9 @@ browser defined in `browse-url-secondary-browser-function'."
acdw-modeline/narrowed
acdw-modeline/major-mode)))
(:option tab-bar-mode t
tab-bar-show 1)
;; I've put in a pull request to add the (- 0 right-margin) bit here.
(:advise simple-modeline--format :override
(defun simple-modeline@format (lefts rights)
@ -1727,7 +1765,12 @@ If used with a numeric prefix argument N, N backticks will be inserted."
(setup (:straight (unfocused
:host github
:repo "duckwork/unfocused"))
(unfocused-mode +1))
(unfocused-mode +1)
(:with-hook unfocused-hook
(:hook (defun unfocused@save-buffers ()
(save-some-buffers t))
#'garbage-collect)))
(setup uniquify
(:option uniquify-buffer-name-style 'forward
@ -1887,20 +1930,20 @@ If used with a numeric prefix argument N, N backticks will be inserted."
(setup window
(require 'acdw-bell)
(:option Man-notify-method 'pushy
display-buffer-alist ; from FrostyX
'(("shell.*" (display-buffer-same-window) ())
(".*" (display-buffer-reuse-window
display-buffer-same-window)
(reusable-frames . t)))
recenter-positions '(top middle bottom)
ring-bell-function (lambda ()
(acdw-bell/flash-mode-line
(acdw/system :home)))
tab-bar-show 1
use-dialog-box nil
use-file-dialog nil
visible-bell nil)
(:option
;; Man-notify-method 'pushy
;; display-buffer-alist ; from FrostyX
;; '(("shell.*" (display-buffer-same-window) ())
;; (".*" (display-buffer-reuse-window
;; display-buffer-same-window)
;; (reusable-frames . t)))
recenter-positions '(top middle bottom)
ring-bell-function (lambda ()
(acdw-bell/flash-mode-line
(acdw/system :home)))
use-dialog-box nil
use-file-dialog nil
visible-bell nil)
(tooltip-mode -1))
@ -1951,82 +1994,6 @@ If used with a numeric prefix argument N, N backticks will be inserted."
(winum-mode +1))
(setup x-emacs
;; "Et cetera" settings
;; This should stay as /minimal/ as possible. Anything that can go somewhere
;; else /should/ go there.
(:option
attempt-orderly-shutdown-on-fatal-signal nil
attempt-stack-overflow-recovery nil
echo-keystrokes 0.01
find-function-C-source-directory (acdw/find-emacs-source)
kill-read-only-ok t
load-prefer-newer t
native-comp-async-report-warnings-errors nil
set-mark-command-repeat-pop t)
(when (fboundp 'command-completion-default-include-p)
(setq read-extended-command-predicate
#'command-completion-default-include-p))
(defvar case-map (make-sparse-keymap)
"A keymap for setting case in various ways.")
(global-set-key (kbd "C-c c") case-map)
(defvar lookup-map (make-sparse-keymap)
"A keymap for looking up things.")
(global-set-key (kbd "C-c l") lookup-map)
(:global "M-=" #'count-words
"C-w" #'kill-region-or-backward-word
"C-c c c" #'capitalize-dwim
"C-c c t" #'titlecase-dwim
"C-c c u" #'upcase-dwim
"C-c c l" #'downcase-dwim
"C-c d" #'acdw/insert-iso-date
"M-`" nil)
;; toggle bindings
(defvar toggle-map (make-sparse-keymap)
"A keymap for toggling!")
(global-set-key (kbd "C-c t") toggle-map)
(:with-map toggle-map
(:bind "c" #'column-number-mode
"l" #'display-line-numbers-mode
"d" #'toggle-debug-on-error))
(defalias 'forward-word-with-case 'forward-word
"Alias for `forward-word' for use in `case-repeat-map'.")
(defalias 'backward-word-with-case 'backward-word
"Alias for `backward-word for use in `case-repeat-map'.")
(defvar case-repeat-map
(let ((map (make-sparse-keymap)))
(define-key map "c" #'capitalize-word)
(define-key map "u" #'upcase-word)
(define-key map "l" #'downcase-word)
;; movement
(define-key map "f" #'forward-word-with-case)
(define-key map "b" #'backward-word-with-case)
map)
"A map to repeat word-casing commands. For use with `repeat-mode'.")
(dolist (command '(capitalize-word
capitalize-dwim
upcase-word
upcase-dwim
downcase-word
downcase-dwim
forward-word-with-case
backward-word-with-case))
(put command 'repeat-map 'case-repeat-map))
(add-hook 'after-make-frame-functions
(defun after-make-frame@maximize (frame)
(unless (bound-and-true-p edit-server-frame-p)
(toggle-frame-maximized frame)))))
(setup (:straight xr))
(setup (:straight zzz-to-char)

View File

@ -4,7 +4,6 @@
(require 'consult)
;; "Sensible" functions
(defun acdw-consult/sensible-grep (&optional arg)
"Perform `consult-git-grep' if in a git project, otherwise `consult-ripgrep'
if ripgrep is installed, otherwise `consult-grep'."
@ -43,4 +42,29 @@ if ripgrep is installed, otherwise `consult-grep'."
#'completion--in-region)
args))
(defmacro consult-history-to-modes (map-hook-alist)
(let (defuns)
(dolist (map-hook map-hook-alist)
(let ((map-name (symbol-name (car map-hook)))
(key-defs `(progn (define-key
,(car map-hook)
(kbd "M-r")
(function consult-history))
(define-key ,(car map-hook)
(kbd "M-s") nil))))
(push (if (cdr map-hook)
`(add-hook ',(cdr map-hook)
(defun
,(intern (concat map-name
"@consult-history-bind"))
nil
,(concat
"Bind `consult-history' to M-r in "
map-name ".\n"
"Defined by `consult-history-to-modes'.")
,key-defs))
key-defs)
defuns)))
`(progn ,@ (nreverse defuns))))
(provide 'acdw-consult)