From db3d8d26a2b533955b1645eb1e482e1bb38a28ba Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 29 Mar 2021 23:21:58 -0500 Subject: Sturf --- init.el | 322 +++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 168 insertions(+), 154 deletions(-) (limited to 'init.el') diff --git a/init.el b/init.el index cec8777..05bca5f 100644 --- a/init.el +++ b/init.el @@ -18,7 +18,7 @@ ;;; `setup' -- configuration macro (straight-use-package '(setup :host nil - :repo "https://git.sr.ht/~zge/setup")) + :repo "https://git.sr.ht/~zge/setup")) (require 'setup) ;; shorthand for `customize-set-variable' (via setup) @@ -43,7 +43,7 @@ (setup-define :acdw/map (lambda (key command) `(define-key acdw/map - ,(if (stringp key) (kbd key) key) + ,(if (stringp key) (kbd key) key) #',command)) :documentation "Bind KEY to COMMAND in `acdw/map'." :debug '(form sexp) @@ -53,7 +53,7 @@ (setup-define :acdw/leader (lambda (key command) `(define-key acdw/leader - ,(if (stringp key) (kbd key) key) + ,(if (stringp key) (kbd key) key) #',command)) :documentation "Bind KEY to COMMAND in `acdw/leader' map." :debug '(form sexp) @@ -65,7 +65,7 @@ `(progn (autoload #',command (symbol-name setup-name)) (define-key (symbol-value setup-map) - ,(if (stringp key) (kbd key) key) + ,(if (stringp key) (kbd key) key) #',command))) :documentation "Bind KEY to COMMAND, and autload COMMAND from FEATURE." :debug '(form sexp) @@ -133,10 +133,10 @@ ;; Uniquify (setup (:require uniquify) - (:option uniquify-buffer-name-style 'forward - uniquify-separator path-separator - uniquify-after-kill-buffer-p t - uniquify-ignore-buffers-re "^\\*")) + (:option uniquify-buffer-name-style 'forward + uniquify-separator path-separator + uniquify-after-kill-buffer-p t + uniquify-ignore-buffers-re "^\\*")) ;; Files (setc backup-directory-alist `((".*" . ,(acdw/in-dir "backup/" t))) @@ -155,26 +155,24 @@ (acdw/when-unfocused #'save-some-buffers t))) (setup (:require autorevert) - (global-auto-revert-mode +1)) + (global-auto-revert-mode +1)) (setup (:require saveplace) - (:option save-place-file (acdw/in-dir "places.el") - save-place-forget-unreadable-files (eq acdw/system :home)) + (:option save-place-file (acdw/in-dir "places.el") + save-place-forget-unreadable-files (eq acdw/system :home)) (save-place-mode +1)) (setup (:require recentf) - (:option recentf-save-file (acdw/in-dir "recentf.el") - recentf-max-menu-items 100 - recentf-max-saved-items nil - recentf-auto-cleanup 60 - (append recentf-exclude) acdw/dir) + (:option recentf-save-file (acdw/in-dir "recentf.el") + recentf-max-menu-items 100 + recentf-max-saved-items nil + recentf-auto-cleanup 60 + (append recentf-exclude) acdw/dir) (recentf-mode +1)) ;; Minibuffer (setc minibuffer-prompt-properties - '(read-only t - cursor-intangible t - face minibuffer-prompt) + '(read-only t cursor-intangible t face minibuffer-prompt) enable-recursive-minibuffers t file-name-shadow-properties '(invisible t intangible t) read-answer-short t) @@ -183,30 +181,30 @@ (fset 'yes-or-no-p #'y-or-n-p) (setup (:require savehist) - (:option (append savehist-additional-variables) 'kill-ring - (append savehist-additional-variables) 'search-ring - (append savehist-additional-variables) 'regexp-search-ring - history-length t - history-delete-duplicates t - savehist-autosave-interval 6 - savehist-file (acdw/in-dir "savehist.el")) + (:option (append savehist-additional-variables) 'kill-ring + (append savehist-additional-variables) 'search-ring + (append savehist-additional-variables) 'regexp-search-ring + history-length t + history-delete-duplicates t + savehist-autosave-interval 6 + savehist-file (acdw/in-dir "savehist.el")) (savehist-mode +1)) (setup (:require icomplete) - (:option completion-ignore-case t - read-buffer-completion-ignore-case t - icomplete-delay-completions-threshold 0 - icomplete-max-delay-chars 0 - icomplete-compute-delay 0 - icomplete-show-matches-on-no-input t - icomplete-with-buffer-completion-tables t - icomplete-in-buffer t - completion-styles '(partial-completion substring flex)) + (:option completion-ignore-case t + read-buffer-completion-ignore-case t + icomplete-delay-completions-threshold 0 + icomplete-max-delay-chars 0 + icomplete-compute-delay 0 + icomplete-show-matches-on-no-input t + icomplete-with-buffer-completion-tables t + icomplete-in-buffer t + completion-styles '(partial-completion substring flex)) (fido-mode -1) (icomplete-mode +1)) (setup imenu - (:option imenu-auto-rescan t)) + (:option imenu-auto-rescan t)) ;; Cursor (setc cursor-type 'bar @@ -230,26 +228,49 @@ ;; Dired (setup dired - (: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) + (: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) (:also-load dired-x) (:hook dired-hide-details-mode hl-line-mode) (:acdw/map "C-x C-j" dired-jump)) + +;;;; Web browsing +(when (eq acdw/system :work) + (add-to-list 'exec-path "C:/Program Files/Mozilla Firefox")) + +(setup browse-url + (:option browse-url-browser-function 'eww-browse-url + browse-url-secondary-browser-function (if (executable-find "firefox") + 'browse-url-firefox + 'browse-url-default-browser) + browse-url-new-window-flag t + browse-url-firefox-new-window-is-tab t)) + +(setup shr + (:option shr-width text-width + shr-max-width text-width + shr-max-image-proportion 0.6 + shr-image-animate t + shr-discard-aria-hidden t)) + +(add-hook 'text-mode-hook #'goto-address-mode) +(add-hook 'prog-mode-hook #'goto-address-prog-mode) + ;; Eshell (setup eshell - (:option eshell-directory-name (acdw/in-dir "eshell/" t) - eshell-aliases-file (acdw/in-dir "eshell/aliases" t))) + (:option eshell-directory-name (acdw/in-dir "eshell/" t) + eshell-aliases-file (acdw/in-dir "eshell/aliases" t))) ;; Garbage collection (add-hook 'minibuffer-setup-hook #'acdw/gc-disable) @@ -269,7 +290,13 @@ disabled-command-function nil load-prefer-newer t comp-async-report-warnings-errors nil - frame-title-format "%b %+%* GNU Emacs") + frame-title-format "%b %+%* GNU Emacs" + use-dialog-box nil + use-file-dialog nil + inhibit-startup-echo-area-message (pcase acdw/system + (:home "acdw") + (:work "aduckworth") + (:other (getenv "USER")))) ;; Etc. bindings (autoload 'ehelp-command "ehelp" nil nil 'keymap) @@ -286,95 +313,99 @@ ;;; Interactivity - ;;;; Begin-end (setup (:straight beginend) - (beginend-global-mode +1)) + (beginend-global-mode +1)) ;;;; Expand-region (setup (:straight expand-region) - (:acdw/map "C-=" er/expand-region)) + (:acdw/map "C-=" er/expand-region)) ;;;; CRUX (setup (:straight crux) - (:with-map acdw/map - (:bind "M-o" crux-other-window-or-switch-buffer) - (:bind "C-a" crux-move-beginning-of-line) - (:bind "C-k" crux-kill-and-join-forward)) + (:with-map acdw/map + (:bind "M-o" crux-other-window-or-switch-buffer) + (:bind "C-a" crux-move-beginning-of-line) + (:bind "C-k" crux-kill-and-join-forward)) (crux-reopen-as-root-mode +1)) ;;; Functionality +;;;; Async +(setup (:straight async) + (autoload 'dired-async-mode "dired-async.el" nil t) + (dired-async-mode +1)) + ;;;; Undo-fu (setup (:straight undo-fu) - (:with-map acdw/map - (:bind "C-/" undo-fu-only-undo - "C-?" undo-fu-only-redo))) + (:with-map acdw/map + (:bind "C-/" undo-fu-only-undo + "C-?" undo-fu-only-redo))) (setup (:straight undo-fu-session) - (:option undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" - "/git-rebase-todo\\'") - undo-fu-session-directory (acdw/in-dir "undo/" t)) + (:option undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" + "/git-rebase-todo\\'") + undo-fu-session-directory (acdw/in-dir "undo/" t)) (global-undo-fu-session-mode +1)) ;;; Minibuffer ;;;; Icomplete-vertical (setup (:straight icomplete-vertical) - (let ((map icomplete-minibuffer-map)) - (let ((command #'icomplete-forward-completions)) - (define-key map (kbd "") command) - (define-key map (kbd "C-n") command)) - (let ((command #'icomplete-backward-completions)) - (define-key map (kbd "") command) - (define-key map (kbd "C-p") command)) - (define-key map (kbd "RET") #'icomplete-force-complete-and-exit) - (define-key map (kbd "C-RET") #'minibuffer-complete-and-exit)) + (let ((map icomplete-minibuffer-map)) + (let ((command #'icomplete-forward-completions)) + (define-key map (kbd "") command) + (define-key map (kbd "C-n") command)) + (let ((command #'icomplete-backward-completions)) + (define-key map (kbd "") command) + (define-key map (kbd "C-p") command)) + (define-key map (kbd "RET") #'icomplete-force-complete-and-exit) + (define-key map (kbd "C-RET") #'minibuffer-complete-and-exit)) (icomplete-vertical-mode +1)) ;;;; Orderless (setup (:straight orderless) - (:option (prepend completion-styles) 'orderless)) + (:option (prepend completion-styles) 'orderless)) ;;;; Consult (setup (:straight consult) - (:with-map acdw/map - (:bind-autoload - ;; C-c bindings (`mode-specific-map') - "C-c h" consult-history - "C-c m" consult-mode-command - ;; C-x bindings (`ctl-x-map') - "C-x M-:" consult-complex-command - "C-x b" consult-buffer - "C-x 4 b" consult-buffer-other-window - "C-x 5 b" consult-buffer-other-frame - "C-x r x" consult-register - "C-x r b" consult-bookmark - ;; M-g bindings (`goto-map') - "M-g o" consult-outline - "M-g m" consult-mark - "M-g k" consult-global-mark - "M-g i" consult-imenu - "M-g e" consult-error - ;; M-s bindings (`search-map') - "M-s g" consult-grep ; alts: consult-git-grep, consult-ripgrep - "M-s f" consult-find ; alts: consult-locate - "M-s l" consult-line - "M-s m" consult-multi-occur - "M-s k" consult-keep-lines - "M-s u" consult-focus-lines - ;; Other bindings - "M-y" consult-yank-pop - " a" consult-apropos - "C-h a" consult-apropos)) + (:with-map acdw/map + (:bind-autoload + ;; C-c bindings (`mode-specific-map') + "C-c h" consult-history + "C-c m" consult-mode-command + ;; C-x bindings (`ctl-x-map') + "C-x M-:" consult-complex-command + "C-x b" consult-buffer + "C-x 4 b" consult-buffer-other-window + "C-x 5 b" consult-buffer-other-frame + "C-x r x" consult-register + "C-x r b" consult-bookmark + ;; M-g bindings (`goto-map') + "M-g o" consult-outline + "M-g m" consult-mark + "M-g k" consult-global-mark + "M-g i" consult-imenu + "M-g e" consult-error + ;; M-s bindings (`search-map') + "M-s g" consult-grep ; alts: consult-git-grep, consult-ripgrep + "M-s f" consult-find ; alts: consult-locate + "M-s l" consult-line + "M-s m" consult-multi-occur + "M-s k" consult-keep-lines + "M-s u" consult-focus-lines + ;; Other bindings + "M-y" consult-yank-pop + " a" consult-apropos + "C-h a" consult-apropos)) (autoload 'consult-register-preview "consult") (:option register-preview-delay 0 register-preview-function #'consult-register-preview)) ;;;; Marginalia (setup (:straight marginalia) - (:option marginalia-annotators '(marginalia-annotators-heavy - marginalia-annotators-light)) + (:option marginalia-annotators '(marginalia-annotators-heavy + marginalia-annotators-light)) (marginalia-mode +1)) ;;; UI @@ -383,19 +414,19 @@ (setup (:straight (modus-themes :host gitlab :repo "protesilaos/modus-themes")) - (:option modus-themes-slanted-constructs t - modus-themes-bold-constructs t - modus-themes-region 'bg-only - modus-themes-org-blocks 'grayscale - modus-themes-headings '((1 . section) - (t . no-color)) - modus-themes-mode-line nil) + (:option modus-themes-slanted-constructs t + modus-themes-bold-constructs t + modus-themes-region 'bg-only + modus-themes-org-blocks 'grayscale + modus-themes-headings '((1 . section) + (t . no-color)) + modus-themes-mode-line nil) (acdw/sunrise-sunset #'modus-themes-load-operandi #'modus-themes-load-vivendi)) ;;;; Mode line (setup (:straight simple-modeline) - (setup (:straight minions)) + (setup (:straight minions)) (:option simple-modeline-segments '((acdw-modeline/modified acdw-modeline/buffer-name @@ -415,13 +446,13 @@ ;;;; 0x0 -- upload files to a nullpointer (setup (:straight (0x0 :host nil :repo "https://git.sr.ht/~zge/nullpointer-emacs")) - (:option 0x0-default-host 'ttm)) + (:option 0x0-default-host 'ttm)) ;;; Applications ;;;; Magit (setup (:straight magit) - (:acdw/leader "g" magit-status) + (:acdw/leader "g" magit-status) (:option magit-display-buffer-function (defun magit-display-buffer-same-window (buffer) "Display BUFFER in the selected window like God intended." @@ -430,29 +461,19 @@ ;;;; File browsing (setup (:straight dired-subtree) - (define-key dired-mode-map "i" #'dired-subtree-toggle)) + (define-key dired-mode-map "i" #'dired-subtree-toggle)) (setup (:straight dired-collapse) - (:hook-into dired-mode)) - -;;;; Web browsing -(when (eq acdw/system :work) - (add-to-list 'exec-path "C:/Program Files/Mozilla Firefox")) - -(setc browse-url-browser-function 'browse-url-firefox - browse-url-new-window-flag t - browse-url-firefox-new-window-is-tab t - shr-max-width fill-column - shr-width fill-column) + (:hook-into dired-mode)) -(add-hook 'text-mode-hook #'goto-address-mode) -(add-hook 'prog-mode-hook #'goto-address-prog-mode) +(setup (:straight trashed) + (:option trashed-action-confirmer 'y-or-n-p)) ;;;; Gemini/gopher browsing (setup (:straight (elpher :host nil :repo "git://thelambdalab.xyz/elpher.git")) - (:option elpher-ipv4-always t - elpher-certificate-directory (acdw/in-dir "elpher/")) + (:option elpher-ipv4-always t + elpher-certificate-directory (acdw/in-dir "elpher/")) (:bind "n" elpher-next-link "p" elpher-prev-link "o" elpher-follow-current-link @@ -464,18 +485,18 @@ (setup (:straight (gemini-mode :host nil :repo "https://git.carcosa.net/jmcbray/gemini.el.git")) - (:option (append auto-mode-alist) - '("\\.\\(gemini\\|gmi\\)\\'" . gemini-mode))) + (:option (append auto-mode-alist) + '("\\.\\(gemini\\|gmi\\)\\'" . gemini-mode))) ;;;; Read e-books (nov.el) (setup (:straight nov) - (:option nov-text-width fill-column - (append auto-mode-alist) '("\\.epub\\'" . nov-mode))) + (:option nov-text-width fill-column + (append auto-mode-alist) '("\\.epub\\'" . nov-mode))) ;;;; Org mode (setup (:straight (org :host nil :repo "https://code.orgmode.org/bzg/org-mode.git")) - (require 'acdw-org) + (require 'acdw-org) (:option org-directory "~/org" org-hide-emphasis-markers t org-fontify-whole-heading-line t @@ -503,33 +524,26 @@ ;;;; Formatting (setup (:straight (apheleia :host github :repo "raxod502/apheleia")) - (apheleia-global-mode +1)) + (apheleia-global-mode +1)) ;;;; Emacs lisp (setup emacs-lisp - (require 'cl-lib) (:option eval-expression-print-length nil eval-expression-print-level nil - lisp-indent-function #'common-lisp-indent-function) - (put 'cl-flet 'common-lisp-indent-function - (get 'flet 'common-lisp-indent-function)) - (put 'cl-labels 'common-lisp-indent-function - (get 'labels 'common-lisp-indent-function)) - (put 'if 'common-lisp-indent-function 2) - (put 'dotimes-protect 'common-lisp-indent-function - (get 'when 'common-lisp-indent-function))) + lisp-indent-function #'lisp-indent-function)) ;;;; Shell scripts (setup sh - (:option sh-basic-offset tab-width - sh-indent-after-case 0 - sh-indent-for-case-alt '+ - sh-indent-for-case-label 0) + (:option sh-basic-offset tab-width + sh-indent-after-case 0 + sh-indent-for-case-alt '+ + sh-indent-for-case-label 0) (:local-set indent-tabs-mode t) (when (executable-find "shfmt") - (:option (append apheleia-formatters) '(shfmt . ("shfmt")) - (append apheleia-mode-alist) '(sh-mode . shfmt))) + (with-eval-after-load 'apheleia + (:option (append apheleia-formatters) '(shfmt . ("shfmt")) + (append apheleia-mode-alist) '(sh-mode . shfmt)))) (when (executable-find "shellcheck") (straight-use-package 'flymake-shellcheck) @@ -538,9 +552,9 @@ ;;;; Web languages (setup (:straight web-mode) - (:option css-level-offset 2 - js-indent-level 2 - sgml-indent-offset 2) + (:option css-level-offset 2 + js-indent-level 2 + sgml-indent-offset 2) (dolist (extension '("\\(p\\|dj\\)?html" "html?" "\\(tpl\\.\\)?php" -- cgit 1.4.1-21-gabe81