;;; emacs init --- an init for emacs -*- lexical-binding: t; -*- ;; by C. Duckworth ;; URL: https://git.acdw.net/emacs ;; Bankruptcy: 9 ;; ;; Everyone is permitted to do whatever they like with this software ;; without limitation. This software comes without any warranty ;; whatsoever, but with two pieces of advice: ;; - Be kind to yourself. ;; - Make good choices. (progn ;; Settings (setq truncate-string-ellipsis "…" ring-bell-function #'ignore read-file-name-completion-ignore-case t) ;; Keys (define-keys (current-global-map) "C-x C-k" #'kill-current-buffer "C-/" #'undo-only "C-?" #'undo-redo "M-j" nil "" nil) ;; Advice (define-advice keyboard-escape-quit (:around (fn &rest r)) "Don't close quits on `keyboard-escape-quit'." (let ((buffer-quit-function #'ignore)) (apply fn r))) ;; Themes (load-theme 'modus-operandi)) (yoke auth-source nil (setq auth-sources `(default "secrets:passwords")) (setq-local-hook authinfo-mode-hook truncate-lines t)) (yoke consult "https://github.com/minad/consult" (require 'consult) (setq register-preview-delay 0 register-preview-function #'consult-register-format xref-show-xrefs-function #'consult-xref tab-always-indent 'complete completion-in-region-function #'consult-completion-in-region consult-narrow-key "<" consult--regexp-compiler #'consult--orderless-regexp-compiler) (advice-add #'register-preview :override #'consult-register-window) (define-keys (current-global-map) ;; C-c bindings (mode-specific-map) "C-c h" #'consult-history "C-c m" #'consult-mode-command "C-c b" #'consult-bookmark "C-c k" #'consult-kmacro ;; C-x bindings (ctl-x-map) "C-x M-:" #'consult-complex-command "" #'consult-buffer "C-x b" #'consult-buffer "C-x 4 b" #'consult-buffer-other-window "C-x 5 b" #'consult-buffer-other-frame ;; Custom M-# bindings for fast register access "M-#" #'consult-register-load "M-'" #'consult-register-store "C-M-#" #'consult-register ;; Other custom bindings "M-y" #'consult-yank-pop ;;(" a" . consult-apropos) ;; M-g bindings (goto-map) "M-g e" #'consult-compile-error "M-g f" #'consult-flymake ; or consult-flycheck "M-g g" #'consult-goto-line "M-g M-g" #'consult-goto-line "M-g o" #'consult-outline ; or consult-org-heading "M-g m" #'consult-mark "M-g k" #'consult-global-mark "M-g i" #'consult-imenu "M-g M-i" #'consult-imenu "M-g I" #'consult-imenu-multi ;; M-s bindings (search-map) "M-s f" #'consult-find "M-s F" #'consult-locate "M-s g" #'consult-grep "M-s G" #'consult-git-grep "M-s r" #'consult-ripgrep "M-s l" #'consult-line "M-s L" #'consult-line-multi "M-s m" #'consult-multi-occur "M-s k" #'consult-keep-lines "M-s u" #'consult-focus-lines ;; Isearch integration "M-s e" #'consult-isearch-history) (eval-after isearch-mode (define-keys isearch-mode-map "M-e" #'consult-isearch-history "M-s e" #'consult-isearch-history "M-s l" #'consult-line "M-s L" #'consult-line-multi)) (eval-after org (define-key org-mode-map (kbd "M-g o") #'consult-org-heading))) (yoke orderless "https://github.com/oantolin/orderless" (require 'orderless) (setq completion-styles '(substring orderless basic) completion-category-defaults nil completion-category-overrides '((file (styles basic partial-completion))) orderless-component-separator #'orderless-escapable-split-on-space)) (yoke vertico "https://github.com/minad/vertico" (require 'vertico) (setq resize-mini-windows 'grow-only vertico-count-format nil vertico-cycle t) (vertico-mode)) (yoke marginalia "https://github.com/minad/marginalia/" (marginalia-mode)) (yoke slime "https://github.com/slime/slime" ;; r7rs-swank (let ((r7rsloc (yoke-git "https://github.com/ecraven/r7rs-swank"))) (cond ((executable-find "chibi-scheme") (defun chibi-scheme-start-swank (file encoding) (format "%S\n\n" `(start-swank ,file))) (setq slime-lisp-implementations (cons `(chibi-scheme ("chibi-scheme" ,(format "-A%s" r7rsloc) "-m" "(chibi-swank)") :init chibi-scheme-start-swank) (bound-and-true-p slime-lisp-implementations))))))) (yoke puni "https://github.com/amaikinono/puni" (puni-global-mode) (electric-pair-mode) (define-keys puni-mode-map "C-)" #'puni-slurp-forward "C-(" #'puni-slurp-backward "C-}" #'puni-barf-forward "C-{" #'puni-barf-backward)) (yoke hungry-delete "https://github.com/nflath/hungry-delete" (setq hungry-delete-chars-to-skip " \t" hungry-delete-join-reluctantly nil) (eval-after hungry-delete (add-to-list* 'hungry-delete-except-modes 'eshell-mode 'nim-mode 'python-mode)) (defun +hungry-delete-or (hd-fn fn arg) (funcall (if (looking-back (format "[%s]" hungry-delete-chars-to-skip) arg) hd-fn fn) arg)) (define-keys puni-mode-map [remap puni-backward-delete-char] (defun puni@hungry-delete-backward (arg) (interactive "p") (+hungry-delete-or #'hungry-delete-backward #'puni-backward-delete-char arg)) [remap puni-forward-delete-char] (defun puni@hungry-delete-forward (arg) (interactive "p") (+hungry-delete-or #'hungry-delete-forward #'puni-forward-delete-char arg))) (global-hungry-delete-mode)) (yoke cape "https://github.com/minad/cape" (defun cape-insinuate () (add-to-list* 'completion-at-point-functions #'cape-dabbrev #'cape-file)) (add-hook* '(text-mode-hook prog-mode-hook) #'cape-insinuate)) (yoke minions "https://github.com/tarsius/minions" (minions-mode))