From 74ffce06536e935dd8ec2ba45b5658a1a70bedc3 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Wed, 1 Sep 2021 21:15:57 -0500 Subject: Reorganize I've moved the preamble stuff to early-init.el, and I ran `sort-sexps' on the first and then second page of init.el. --- early-init.el | 41 ++ init.el | 1396 +++++++++++++++++++++++++-------------------------------- 2 files changed, 656 insertions(+), 781 deletions(-) diff --git a/early-init.el b/early-init.el index e8d02ad..9f8e7f0 100644 --- a/early-init.el +++ b/early-init.el @@ -191,4 +191,45 @@ say, `tool-bar-mode' once to toggle the tool bar back on." before-init-time))) gcs-done)) +;;; `setup' +(straight-use-package '(setup :host nil :repo "https://git.sr.ht/~pkal/setup")) +(require 'setup) + +(setup setup + ;; Install a package using `straight-use-package' + (setup-define :straight + (lambda (recipe) + `(straight-use-package ',recipe)) + :documentation + "Install RECIPE with `straight-use-package'. +This macro can be used as HEAD, and will replace itself with the +first RECIPE's package." + :repeatable t + :shorthand (lambda (sexp) + (let ((recipe (cadr sexp))) + (if (consp recipe) + (car recipe) + recipe)))) + ;; Install a package with straight, but only under a condition + (setup-define :straight-if + (lambda (recipe condition) + `(if ,condition + (straight-use-package ',recipe) + ,(setup-quit))) + :documentation + "Install RECIPE with `straight-use-package' when CONDITION is met. +If CONDITION is false, stop evaluating the body. This macro can +be used as HEAD, and will replace itself with the RECIPE's +package. This macro is not repeatable." + :repeatable nil + :shorthand (lambda (sexp) + (let ((recipe (cadr sexp))) + (if (consp recipe) (car recipe) recipe))))) + +;;; `no-littering' +(setup (:straight no-littering) + (:option no-littering-etc-directory (acdw/dir) + no-littering-var-directory (acdw/dir)) + (require 'no-littering)) + ;;; early-init.el ends here diff --git a/init.el b/init.el index edbc99c..965ec06 100644 --- a/init.el +++ b/init.el @@ -15,74 +15,59 @@ ;; - Make good choices. ;;; Code: - -;;; Setup - -;;;; `setup' -(straight-use-package '(setup :host nil :repo "https://git.sr.ht/~pkal/setup")) -(require 'setup) - -(setup setup - ;; Install a package using `straight-use-package' - (setup-define :straight - (lambda (recipe) - `(straight-use-package ',recipe)) - :documentation - "Install RECIPE with `straight-use-package'. -This macro can be used as HEAD, and will replace itself with the -first RECIPE's package." - :repeatable t - :shorthand (lambda (sexp) - (let ((recipe (cadr sexp))) - (if (consp recipe) - (car recipe) - recipe)))) - ;; Install a package with straight, but only under a condition - (setup-define :straight-if - (lambda (recipe condition) - `(if ,condition - (straight-use-package ',recipe) - ,(setup-quit))) - :documentation - "Install RECIPE with `straight-use-package' when CONDITION is met. -If CONDITION is false, stop evaluating the body. This macro can -be used as HEAD, and will replace itself with the RECIPE's -package. This macro is not repeatable." - :repeatable nil - :shorthand (lambda (sexp) - (let ((recipe (cadr sexp))) - (if (consp recipe) (car recipe) recipe))))) - -;;;; `no-littering' -(setup (:straight no-littering) - (:option no-littering-etc-directory (acdw/dir) - no-littering-var-directory (acdw/dir)) - (require 'no-littering)) - -;;;; My packages -(when-let ((default-directory - (expand-file-name-exists-p "pkg/" user-emacs-directory))) - (normal-top-level-add-subdirs-to-load-path)) - -;;;; Private stuff -(acdw/require-private) - -;;;; Compatibility with older versions -(require 'acdw-compat) - -;;;; Lisp -(require 'acdw-lisp) - -;;; Basics +;;; Built-ins ;; NOTE that some of the names in `setup' forms are arbitrary. +(setup (:require auth-source) + (:option auth-sources '("~/.authinfo" "~/.authinfo.gpg"))) + +(setup (:require recentf) + (:option recentf-save-file (acdw/dir "recentf.el") + recentf-max-menu-items 100 + recentf-max-saved-items nil + recentf-auto-cleanup 'mode + (append recentf-exclude) (acdw/dir)) + + (advice-add 'dired-rename-file :after #'rjs/recentf-rename-notify) + + (recentf-mode +1)) + +(setup (:require savehist) + (:option history-length t + history-delete-duplicates t + savehist-autosave-interval 60 + savehist-file (acdw/dir "savehist.el")) + + (dolist (var '(extended-command-history + global-mark-ring + kill-ring + regexp-search-ring + search-ring + mark-ring)) + (add-to-list 'savehist-additional-variables var)) + + (savehist-mode +1)) + +(setup (:require server) + (unless (server-running-p) + (server-start))) + +(setup Info + (:hook variable-pitch-mode + acdw/reading-mode)) + (setup acdw + (:also-load acdw-compat + acdw-lisp) + (acdw/require-private) + (:option user-full-name "Case Duckworth" - user-mail-address "acdw@acdw.net")) + user-mail-address "acdw@acdw.net") -(setup (:require auth-source) - (:option auth-sources '("~/.authinfo" "~/.authinfo.gpg"))) + (when-let ((default-directory + (expand-file-name-exists-p "pkg/" user-emacs-directory))) + (normal-top-level-add-subdirs-to-load-path))) (setup autorevert (:option global-auto-revert-non-file-buffers t) @@ -133,8 +118,7 @@ package. This macro is not repeatable." (:global "C-x k" acdw/kill-a-buffer)) (setup calendar - (:option calendar-week-start-day 1 ; Monday - )) + (:option calendar-week-start-day 1)) (setup completion (:option completion-ignore-case t @@ -153,7 +137,6 @@ package. This macro is not repeatable." (blink-cursor-mode +1)) (setup cus-edit - (:option custom-file null-device ; don't store customizations custom-magic-show nil custom-magic-show-button t @@ -312,20 +295,10 @@ package. This macro is not repeatable." (add-hook 'emacs-lisp-mode-hook #'turn-on-eldoc-mode) (add-hook 'ielm-mode-hook #'turn-on-eldoc-mode) - (setup (:straight macrostep) - (define-key emacs-lisp-mode-map (kbd "C-c e") #'macrostep-expand)) - - (setup (:straight eros) - (:hook-into emacs-lisp-mode)) - ;; Add advice to pulse evaluated regions (define-advice eval-region (:around (fn start end &rest args) pulse-region) (pulse-momentary-highlight-region start end) - (apply fn start end args)) - - (setup (:straight elisp-slime-nav) - (:hook-into emacs-lisp-mode - ielm-mode))) + (apply fn start end args))) (setup encoding (:option locale-coding-system 'utf-8-unix @@ -351,104 +324,6 @@ package. This macro is not repeatable." (_ (set-selection-coding-system 'utf-8) (set-clipboard-coding-system 'utf-8)))) -(setup erc - (:require acdw-erc) - (:also-load erc-autoaway - erc-track - erc-goodies) - - (:option - erc-auto-discard-away t - erc-auto-set-away t - erc-autoaway-idle-seconds 600 - erc-autoaway-message "BRB (autoaway: %i seconds)" - erc-button-url-regexp browse-url-button-regexp - erc-common-server-suffixes '(("tilde.chat\\'" . "~") - ("libera.chat\\'" . "LC")) - erc-default-server "irc.tilde.chat" - erc-fill-function #'erc-fill-static - erc-fill-static-center 14 - erc-format-nick-function #'erc-format-truncate-@nick - erc-header-line-face-method #'erc/update-header-line-show-disconnected - erc-hide-list '("NICK" "MODE" "JOIN" "PART" "QUIT" "AWAY") - erc-interpret-controls-p t - erc-interpret-mirc-color t - erc-join-buffer 'bury - erc-kill-buffer-on-part t - erc-kill-queries-on-quit t - erc-kill-server-buffer-on-quit t - erc-nick "acdw" - erc-nick-truncate (- erc-fill-static-center 1) - erc-pcomplete-nick-postfix ":" - erc-prompt #'acdw-erc/prompt - erc-prompt-for-password nil ; use ~/.authinfo - erc-rename-buffers t - erc-server erc-default-server - erc/servers - (when (boundp 'erc-autojoin-channels-alist) - (mapcar #'car erc-autojoin-channels-alist)) - erc-server-coding-system '(utf-8 . utf-8) - erc-timestamp-intangible t - erc-track-exclude-types (append erc-hide-list - '("AWAY" ; for some reason this triggers - ; track anyway... so it's in - ; `erc-hide-list' - "353" "324" "329" "332" "333" "477")) - erc-track-exclude-server-buffer t - erc-track-position-in-mode-line 'before-modes - erc-track-visibility nil ; only the selected frame - ) - - ;; Thanks bpalmer! - (advice-add 'show-paren-function :around - (defun show-paren@skip-in-erc (f &rest r) - "Skip `show-paren-mode' in `erc-mode'." - (unless (derived-mode-p 'erc-mode) - (apply f r)))) - - (add-hook 'kill-emacs-hook #'erc/disconnect) - - (add-hook 'erc-mode-hook - (defun erc-mode@setup () - (setq-local scroll-margin 0))) - - (:hook erc-autoaway-mode - erc-track-mode - erc-truncate-mode) - - ;; disable ERC tracking when working ... BE PRODUCTIVE! - (add-hook 'org-clock-in-hook #'erc-track-disable) - (add-hook 'org-clock-out-hook #'erc-track-enable) - - (:bind "C-c C-b" acdw-erc/erc-switch-to-buffer - "C-c C-c" nil ; def: `erc-toggle-interpret-controls' - ) - - (with-eval-after-load 'erc - (when (acdw/system :work) - ;; IDK why, but on 28 this bit doesn't work -- which is at home. - (setup (:straight erc-hl-nicks) - (:option (append erc-modules) 'hl-nicks - erc-hl-nicks-minimum-contrast-ratio 4.5 - erc-hl-nicks-color-contrast-strategy '(invert contrast)) - (:hook-into erc-mode) - ;; Refresh nick colors after changing modus theme - ;; Ideally, there'd be a hook for /any/ time we changed theme... but - ;; whatever. - (add-hook 'modus-themes-after-load-theme-hook - #'erc-hl-nicks-refresh-colors))) - - ;; (setup (:straight erc-image) - ;; (:option (append erc-modules) 'image - ;; erc-image-inline-rescale 300)) - - ;; Rewrite `erc-quit/part-reason-default' - (defun erc-quit/part-reason-default () - "Default quit/part message." - (format "\C-iSee You, Space Cowpokes. . .\C-i")) - - (erc-update-modules))) - (setup eshell (:also-load acdw-eshell em-smart) @@ -516,16 +391,6 @@ like a dumbass." (setup flyspell (add-hook 'text-mode-hook #'flyspell-mode)) -(setup (:straight flyspell-correct) - (add-hook 'flyspell-mode-hook - (defun flyspell-mode@flyspell-correct () - (dolist (keybind '(("C-;" . flyspell-correct-wrapper) - ("C-," . nil) - ("C-." . nil) - ("C-M-i" . nil))) - (define-key flyspell-mode-map - (kbd (car keybind)) (cdr keybind)))))) - (setup frames (:option frame-title-format '("%b@" (:eval @@ -571,7 +436,9 @@ like a dumbass." (mode . gnus-article-mode) (name . "^\\.bbdb$") (name . "^\\.newsrc-dribble") - (mode . erc-mode))) + (mode . erc-mode) + (mode . circe-server-mode) + (mode . circe-channel-mode))) ("shell" (or (mode . eshell-mode) (mode . shell-mode) (mode . vterm-mode))) @@ -591,10 +458,6 @@ like a dumbass." (setup imenu (:option imenu-auto-rescan t)) -(setup Info - (:hook variable-pitch-mode - acdw/reading-mode)) - (setup isearch (:option search-default-mode t)) @@ -726,17 +589,6 @@ like a dumbass." "C-g" reb-quit "C-c C-k" reb-quit)))) -(setup (:require recentf) - (:option recentf-save-file (acdw/dir "recentf.el") - recentf-max-menu-items 100 - recentf-max-saved-items nil - recentf-auto-cleanup 'mode - (append recentf-exclude) (acdw/dir)) - - (advice-add 'dired-rename-file :after #'rjs/recentf-rename-notify) - - (recentf-mode +1)) - (setup repeat ;; new for Emacs 28! (:only-if (fboundp #'repeat-mode)) @@ -746,22 +598,6 @@ like a dumbass." (repeat-mode +1)) -(setup (:require savehist) - (:option history-length t - history-delete-duplicates t - savehist-autosave-interval 60 - savehist-file (acdw/dir "savehist.el")) - - (dolist (var '(extended-command-history - global-mark-ring - kill-ring - regexp-search-ring - search-ring - mark-ring)) - (add-to-list 'savehist-additional-variables var)) - - (savehist-mode +1)) - (setup saveplace (:option save-place-file (acdw/dir "places.el") save-place-forget-unreadable-files (acdw/system :home)) @@ -803,10 +639,6 @@ like a dumbass." (delete-selection-mode +1)) -(setup (:require server) - (unless (server-running-p) - (server-start))) - (setup sh-mode (:option sh-basic-offset tab-width sh-indent-after-case 0 @@ -864,10 +696,18 @@ like a dumbass." (setup view (:option view-read-only t) - (defun acdw/read-view-mode () - (acdw/reading-mode (if view-mode +1 -1))) - - (:hook acdw/read-view-mode)) + (add-hook 'view-mode-hook + (defun acdw/read-view-mode () + (acdw/reading-mode (if view-mode +1 -1))))) + +(setup w32 + (:option w32-allow-system-shell t + w32-pass-lwindow-to-system nil + w32-lwindow-modifier 'super + w32-pass-rwindow-to-system nil + w32-rwindow-modifier 'super + w32-pass-apps-to-system nil + w32-apps-modifier 'hyper)) (setup whitespace (:option whitespace-style @@ -878,40 +718,6 @@ like a dumbass." (:global "M-SPC" cycle-spacing)) -(setup windows - (require 'acdw-bell) - (:option use-dialog-box nil - use-file-dialog nil - tab-bar-show 1 - visible-bell nil - ring-bell-function (lambda () - (acdw-bell/flash-mode-line - (acdw/system :home))) - recenter-positions '(top middle bottom)) - - (tooltip-mode -1)) - -(setup winner - ;; see https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00888.html - (:global "C-x 4 C-/" winner-undo - "C-x 4 /" winner-undo - "C-x 4 C-?" winner-redo - "C-x 4 ?" winner-redo) - - ;; add `winner-undo' and `winner-redo' to `repeat-mode' - (when (fboundp 'repeat-mode) - (defvar winner-mode-repeat-map - (let ((map (make-sparse-keymap))) - (define-key map "/" #'winner-undo) - (define-key map "?" #'winner-redo) - map) - "Keymap to repeat `winner-mode' sequences. Used in `repeat-mode'.") - - (put 'winner-undo 'repeat-map 'winner-mode-repeat-map) - (put 'winner-redo 'repeat-map 'winner-mode-repeat-map)) - - (winner-mode +1)) - (setup windmove (:option windmove-wrap-around t) (:global @@ -952,19 +758,44 @@ like a dumbass." windmove-swap-states-down)) (put sym 'repeat-map 'windmove-repeat-map)))) -(setup w32 - (:option w32-allow-system-shell t - w32-pass-lwindow-to-system nil - w32-lwindow-modifier 'super - w32-pass-rwindow-to-system nil - w32-rwindow-modifier 'super - w32-pass-apps-to-system nil - w32-apps-modifier 'hyper)) +(setup windows + (require 'acdw-bell) + (:option use-dialog-box nil + use-file-dialog nil + tab-bar-show 1 + visible-bell nil + ring-bell-function (lambda () + (acdw-bell/flash-mode-line + (acdw/system :home))) + recenter-positions '(top middle bottom)) + + (tooltip-mode -1)) + +(setup winner + ;; see https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00888.html + (:global "C-x 4 C-/" winner-undo + "C-x 4 /" winner-undo + "C-x 4 C-?" winner-redo + "C-x 4 ?" winner-redo) + + ;; add `winner-undo' and `winner-redo' to `repeat-mode' + (when (fboundp 'repeat-mode) + (defvar winner-mode-repeat-map + (let ((map (make-sparse-keymap))) + (define-key map "/" #'winner-undo) + (define-key map "?" #'winner-redo) + map) + "Keymap to repeat `winner-mode' sequences. Used in `repeat-mode'.") + + (put 'winner-undo 'repeat-map 'winner-mode-repeat-map) + (put 'winner-redo 'repeat-map 'winner-mode-repeat-map)) + + (winner-mode +1)) -;;; "Et cetera" settings -;; This should stay as /minimal/ as possible. Anything that can go somewhere -;; else /should/ go there. -(setup emacs +(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 @@ -1007,7 +838,6 @@ like a dumbass." (defalias 'backward-word-with-case 'backward-word "Alias for `backward-word for use in `case-repeat-map'.") - ;; XXX: this isn't repeating correctly ... (defvar case-repeat-map (let ((map (make-sparse-keymap))) (define-key map "c" #'capitalize-word) @@ -1027,7 +857,12 @@ like a dumbass." downcase-dwim forward-word-with-case backward-word-with-case)) - (put command 'repeat-map 'case-repeat-map))) + (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))))) ;;; Packages @@ -1053,158 +888,15 @@ like a dumbass." (apheleia--get-formatter-command))) (indent-region (point-min) (point-max)))))) -(setup (:straight-if affe - (and (or (executable-find "fd") - (executable-find "find")) - (executable-find "rg"))) - ;; Keys are bound in `acdw/sensible-grep' and `acdw/sensible-find' - (defun affe-orderless-regexp-compiler (input _type) - (setq input (orderless-pattern-compiler input)) - (cons input (lambda (str) (orderless--highlight input str)))) - - (:option affe-regexp-compiler #'affe-orderless-regexp-compiler)) - -(setup (:straight async) - (autoload 'dired-async-mode "dired-async.el" nil t) - (dired-async-mode +1) - (add-hook 'dired-mode - (defun dired@disable-dired-async-mode-line () - (autoload 'dired-async--modeline-mode "dired-async.el" nil t) - (dired-async--modeline-mode -1)))) - -(setup (:straight alert) - (:option alert-default-style (acdw/system - (:home 'libnotify) - (_ 'message)))) - -(setup (:straight avy) - (:global "C-'" avy-goto-char-timer - "M-g f" avy-goto-line - "M-g w" avy-goto-word-1 - "C-c C-j" avy-resume) - - (with-eval-after-load "isearch" - (define-key isearch-mode-map (kbd "C-'") #'avy-isearch))) - (setup (:straight (beginend)) (beginend-global-mode +1)) -(setup (:straight circe) - (require 'circe) - (require 'acdw-irc) - - (setq acdw-irc/post-my-nick "-> ") - - (setq circe-default-nick "acdw" - circe-default-part-message "See You, Space Cowpokes . . ." - circe-highlight-nick-type 'all - circe-network-options - (("Libera Chat" - :channels ("#emacs" "#systemcrafters" "##webpals") - :sasl-username "acdw" - :sasl-password ,(acdw/fetch-password :host "libera.chat")) - ("Tilde Chat" - :channels ("#meta" "#bread" "#dadjokes" "#team") - :host "irc.tilde.chat" :port 6697 :use-tls t - :sasl-username "acdw" - :sasl-password ,(acdw/fetch-password :host "tilde.chat")) - ("Casa" - :channels ("#basement") - :host "m455.casa" :port 6697 :use-tls t - :sasl-username "acdw" - :sasl-password ,(acdw/fetch-password :host "m455.casa"))) - circe-reduce-lurker-spam t - circe-server-auto-join-default-type :after-auth) - - (defun irc () - "Connect to IRC." - (interactive) - (dolist (network (mapcar #'car circe-network-options)) - (circe-maybe-connect network))) +(setup (:straight (consult + :host github + :repo "minad/consult")) + (require 'acdw-consult) - (defun circe-network-connected-p (network) - "Return non-nil if there's any Circe server-buffer whose -`circe-server-netwok' is NETWORK." - (catch 'return - (dolist (buffer (circe-server-buffers)) - (with-current-buffer buffer - (if (string= network circe-server-network) - (throw 'return t)))))) - - (defun circe-maybe-connect (network) - "Connect to NETWORK, but ask user for confirmation if it's -already been connected to." - (interactive "sNetwork: ") - (if (or (not (circe-network-connected-p network)) - (y-or-n-p (format "Already connected to %s, reconnect?" network))) - (circe network))) - - (add-hook 'circe-chat-mode-hook - (defun circe-chat@setup () - (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))) - - (add-hook 'modus-themes-after-load-theme-hook - #'circe-nick-color-reset) - - (let ((len (number-to-string (- acdw-irc/left-margin 1 - (+ (length acdw-irc/pre-nick) - (length acdw-irc/post-nick))))) - (my-len (number-to-string (- acdw-irc/left-margin 1 - (+ (length acdw-irc/pre-my-nick) - (length acdw-irc/post-my-nick)))))) - (setq circe-format-say (concat acdw-irc/pre-nick - "{nick:" len "." len "s} " - acdw-irc/post-nick - "{body}") - circe-format-self-say (concat acdw-irc/pre-my-nick - "{nick:" my-len "." my-len "s} " - acdw-irc/post-my-nick - "{body}") - circe-format-action (concat "*" - (repeat-string - (- acdw-irc/left-margin 3) - " ") - "* {nick} {body}") - circe-format-self-action (concat "-*" - (repeat-string - (- acdw-irc/left-margin 4) - " ") - "* {nick} {body}") - lui-fill-type (concat - (repeat-string (- acdw-irc/left-margin 2) - " ") - " "))) - - (setq lui-time-stamp-position 'right-margin - lui-time-stamp-format "%H:%M") - (add-hook 'lui-mode-hook - (defun lui-mode@setup () - (setq-local fringes-outside-margins t - lui-track-bar-behavior 'before-switch-to-buffer - right-margin-width 5 - scroll-margin 0 - word-wrap t - wrap-prefix (repeat-string - acdw-irc/left-margin " ")) - ;; (enable-lui-track-bar) - ))) - -(setup (:straight (consult - :host github - :repo "minad/consult")) - (require 'acdw-consult) - - (setq consult--regexp-compiler #'consult--orderless-regexp-compiler) + (setq consult--regexp-compiler #'consult--orderless-regexp-compiler) ;; Bindings (:global @@ -1294,32 +986,333 @@ already been connected to." (:option xref-show-xrefs-function #'consult-xref xref-show-definitions-function #'consult-xref) - ;; Projects - (:option consult-project-root-function #'vc-root-dir) + ;; Projects + (:option consult-project-root-function #'vc-root-dir) + + ;; Competion-at-point (complete-region) + (:option completion-in-region-function #'acdw-consult/complete-in-region + completion-cycle-threshold 3 + tab-always-indent 'complete) + + ;; 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)) + + (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))))) + +(setup (:straight (electric-cursor + :host github + :repo "duckwork/electric-cursor")) + (electric-cursor-mode +1)) + +(setup (:straight (elpher :host nil + :repo "git://thelambdalab.xyz/elpher.git")) + (:option elpher-ipv4-always t + elpher-certificate-directory (acdw/dir "elpher/") + elpher-gemini-max-fill-width fill-column) + + (:bind "n" elpher-next-link + "p" elpher-prev-link + "o" elpher-follow-current-link + "G" elpher-go-current) + + (:hook acdw/reading-mode) + + (autoload 'elpher-bookmarks "elpher" nil t) + (autoload 'elpher-go "elpher" nil t) + + ;; Make `eww' gemini/gopher aware. From Emacswiki. + (define-advice eww-browse-url (:around (fn url &rest args) gemini-elpher) + (cond ((string-match-p "\\`\\(gemini\\|gopher\\)://" url) + (require 'elpher) + (elpher-go url)) + (t (apply fn url args))))) + +(setup (:straight (gemini-mode + :host nil + :repo "https://git.carcosa.net/jmcbray/gemini.el.git")) + (add-to-list 'auto-mode-alist '("\\.\\(gemini\\|gmi\\)\\'" . gemini-mode)) + (:hook turn-off-auto-fill)) + +(setup (:straight (gemini-write + :host nil + :repo "https://alexschroeder.ch/cgit/gemini-write" + :branch "main")) + (require 'gemini-write)) + +(setup (:straight (mastodon + :host github + :repo "mooseyboots/mastodon.el")) + (:straight request) + (:option mastodon-instance-url "https://writing.exchange" + mastodon-auth-source-file (car auth-sources) + mastodon-client--token-file (acdw/dir "mastodon.plstore")) + (:hook hl-line-mode + acdw/reading-mode)) + +(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) + + (acdw/sunrise-sunset #'modus-themes-load-operandi + #'modus-themes-load-vivendi)) + +(setup (:straight (orderless + :host github + :repo "oantolin/orderless")) + (require 'orderless) + + (:option (append completion-styles) 'orderless + orderless-component-separator #'orderless-escapable-split-on-space + orderless-style-dispatchers '(acdw/orderless-dispatch)) + + (defun fix-dollar (args) + (if (string-suffix-p "$" (car args)) + (list (concat (substring (car args) 0 -1) "[\x100000-\x10FFFD]*$")) + args)) + (advice-add #'orderless-regexp :filter-args #'fix-dollar) + + (defun acdw/orderless-dispatch (pattern _index _total) + "My custom dispatcher for `orderless'." + (cond + ;; Ensure that $ works with Consult commands, which add disambiguation + ;; suffixes -- see `fix-dollar' + ((string-suffix-p "$" pattern) + `(orderless-regexp . ,(concat (substring pattern 0 -1) + "[\x100000-\x10FFFD]*$"))) + ;; File extensions + ((string-match-p "\\`\\.." pattern) + `(orderless-regexp . ,(concat "\\." (substring pattern 1) + "[\x100000-\x10FFFD]*$"))) + ;; Ignore single ! + ((string= "!" pattern) + `(orderless-literal . "")) + ;; Character folding + ((string-prefix-p "%" pattern) + `(char-fold-to-regexp . ,(substring pattern 1))) + ((string-suffix-p "%" pattern) + `(char-fold-to-regexp . ,(substring pattern 0 -1))) + ;; Without literal + ((string-prefix-p "!" pattern) + `(orderless-without-literal . ,(substring pattern 1))) + ((string-suffix-p "!" pattern) + `(orderless-without-literal . ,(substring pattern 0 -1))) + ;; Initialism matching + ((string-prefix-p "`" pattern) + `(orderless-initialism . ,(substring pattern 1))) + ((string-suffix-p "`" pattern) + `(orderless-initialism . ,(substring pattern 0 -1))) + ;; Literal matching + ((string-prefix-p "=" pattern) + `(orderless-literal . ,(substring pattern 1))) + ((string-suffix-p "=" pattern) + `(orderless-literal . ,(substring pattern 0 -1))) + ;; Flex matching + ((string-prefix-p "~" pattern) + `(orderless-flex . ,(substring pattern 1))) + ((string-suffix-p "~" pattern) + `(orderless-flex . ,(substring pattern 0 -1)))))) + +(setup (:straight (topsy + :host github + :repo "alphapapa/topsy.el")) + (:hook-into prog-mode)) + +(setup (:straight (unfocused + :host github + :repo "duckwork/unfocused")) + (unfocused-mode +1)) + +(setup (:straight (vertico + :host github + :repo "minad/vertico" + :files ("*" "extensions/*" + (:exclude ".git")))) + + (:option resize-mini-windows 'grow-only + vertico-count-format nil + vertico-cycle t) + + (defun up-directory (arg) + "Move up a directory (delete backwards to /)." + (interactive "p") + (if (string-match-p "/." (minibuffer-contents)) + (zap-up-to-char (- arg) ?/) + (backward-kill-word arg))) + + (with-eval-after-load 'vertico + (define-key vertico-map (kbd "") #'up-directory)) + + (if (boundp 'comp-deferred-compilation-deny-list) + (add-to-list 'comp-deferred-compilation-deny-list "vertico")) + + (vertico-mode +1) + + ;; Extensions! + (:also-load vertico-mouse) + (vertico-mouse-mode +1) + + ;; Prefix the current candidate with "> ". From Vertico wiki. + (defun vertico-format@add-arrow (orig cand prefix suffix index _start) + (setq cand (funcall orig cand prefix suffix index _start)) + (concat + (if (= vertico--index index) + (propertize "> " 'face 'vertico-current) + " ") + cand)) + (advice-add #'vertico--format-candidate :around #'vertico-format@add-arrow)) + +(setup (:straight alert) + (:option alert-default-style (acdw/system + (:home 'libnotify) + (_ 'message)))) + +(setup (:straight async) + (autoload 'dired-async-mode "dired-async.el" nil t) + (dired-async-mode +1) + (add-hook 'dired-mode + (defun dired@disable-dired-async-mode-line () + (autoload 'dired-async--modeline-mode "dired-async.el" nil t) + (dired-async--modeline-mode -1)))) + +(setup (:straight avy) + (:global "C-'" avy-goto-char-timer + "M-g f" avy-goto-line + "M-g w" avy-goto-word-1 + "C-c C-j" avy-resume) + + (with-eval-after-load "isearch" + (define-key isearch-mode-map (kbd "C-'") #'avy-isearch))) + +(setup (:straight circe) + (require 'circe) + (require 'acdw-irc) + + (setq acdw-irc/post-my-nick "-> ") + + (setq circe-default-nick "acdw" + circe-default-part-message "See You, Space Cowpokes . . ." + circe-highlight-nick-type 'all + circe-network-options + `(("Libera Chat" + :channels ("#emacs" "#systemcrafters" "##webpals") + :sasl-username "acdw" + :sasl-password ,(acdw/fetch-password :host "libera.chat")) + ("Tilde Chat" + :channels ("#meta" "#bread" "#dadjokes" "#team") + :host "irc.tilde.chat" :port 6697 :use-tls t + :sasl-username "acdw" + :sasl-password ,(acdw/fetch-password :host "tilde.chat")) + ("Casa" + :channels ("#basement") + :host "m455.casa" :port 6697 :use-tls t + :sasl-username "acdw" + :sasl-password ,(acdw/fetch-password :host "m455.casa"))) + circe-reduce-lurker-spam t + circe-server-auto-join-default-type :after-auth) + + (defun irc () + "Connect to IRC." + (interactive) + (dolist (network (mapcar #'car circe-network-options)) + (circe-maybe-connect network))) + + (defun circe-network-connected-p (network) + "Return non-nil if there's any Circe server-buffer whose +`circe-server-netwok' is NETWORK." + (catch 'return + (dolist (buffer (circe-server-buffers)) + (with-current-buffer buffer + (if (string= network circe-server-network) + (throw 'return t)))))) + + (defun circe-maybe-connect (network) + "Connect to NETWORK, but ask user for confirmation if it's +already been connected to." + (interactive "sNetwork: ") + (if (or (not (circe-network-connected-p network)) + (y-or-n-p (format "Already connected to %s, reconnect?" network))) + (circe network))) + + (add-hook 'circe-chat-mode-hook + (defun circe-chat@setup () + (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))) - ;; Competion-at-point (complete-region) - (:option completion-in-region-function #'acdw-consult/complete-in-region - completion-cycle-threshold 3 - tab-always-indent 'complete) + (add-hook 'modus-themes-after-load-theme-hook + #'circe-nick-color-reset) - ;; 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)) + (let ((len (number-to-string (- acdw-irc/left-margin 1 + (+ (length acdw-irc/pre-nick) + (length acdw-irc/post-nick))))) + (my-len (number-to-string (- acdw-irc/left-margin 1 + (+ (length acdw-irc/pre-my-nick) + (length acdw-irc/post-my-nick)))))) + (setq circe-format-say (concat acdw-irc/pre-nick + "{nick:" len "." len "s} " + acdw-irc/post-nick + "{body}") + circe-format-self-say (concat acdw-irc/pre-my-nick + "{nick:" my-len "." my-len "s} " + acdw-irc/post-my-nick + "{body}") + circe-format-action (concat "*" + (repeat-string + (- acdw-irc/left-margin 3) + " ") + "* {nick} {body}") + circe-format-self-action (concat "-*" + (repeat-string + (- acdw-irc/left-margin 4) + " ") + "* {nick} {body}") + lui-fill-type (concat + (repeat-string (- acdw-irc/left-margin 2) + " ") + " "))) - (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))))) + (setq lui-time-stamp-position 'right-margin + lui-time-stamp-format "%H:%M") + (add-hook 'lui-mode-hook + (defun lui-mode@setup () + (setq-local fringes-outside-margins t + lui-track-bar-behavior 'before-switch-to-buffer + right-margin-width 5 + scroll-margin 0 + word-wrap t + wrap-prefix (repeat-string + acdw-irc/left-margin " ")) + ;; (enable-lui-track-bar) + ))) (setup (:straight crux) @@ -1358,11 +1351,6 @@ already been connected to." (defun edit-server@set-a-variable (&rest _) (setq-local edit-server-frame-p t))))) -(setup (:straight (electric-cursor - :host github - :repo "duckwork/electric-cursor")) - (electric-cursor-mode +1)) - (setup (:straight elfeed elfeed-protocol) (:option elfeed-use-curl t @@ -1380,35 +1368,9 @@ already been connected to." ;; see https://irreal.org/blog/?p=8885 ) -(setup (:straight (elpher :host nil - :repo "git://thelambdalab.xyz/elpher.git")) - (:option elpher-ipv4-always t - elpher-certificate-directory (acdw/dir "elpher/") - elpher-gemini-max-fill-width fill-column) - - (:bind "n" elpher-next-link - "p" elpher-prev-link - "o" elpher-follow-current-link - "G" elpher-go-current) - - (:hook acdw/reading-mode) - - (autoload 'elpher-bookmarks "elpher" nil t) - (autoload 'elpher-go "elpher" nil t) - - ;; Make `eww' gemini/gopher aware. From Emacswiki. - (define-advice eww-browse-url (:around (fn url &rest args) gemini-elpher) - (cond ((string-match-p "\\`\\(gemini\\|gopher\\)://" url) - (require 'elpher) - (elpher-go url)) - (t (apply fn url args)))) - - (:when-loaded - (setup (:straight (gemini-write - :host nil - :repo "https://alexschroeder.ch/cgit/gemini-write" - :branch "main")) - (require 'gemini-write)))) +(setup (:straight elisp-slime-nav) + (:hook-into emacs-lisp-mode + ielm-mode)) (setup (:straight embark) (:global "C-." embark-act) @@ -1428,9 +1390,9 @@ already been connected to." embark-become-indicator embark-action-indicator) (with-eval-after-loads (embark consult) - (setup (:straight embark-consult) - (add-hook 'embark-collect-mode-hook - #'consult-preview-at-point-mode)))) + (:straight embark-consult) + (add-hook 'embark-collect-mode-hook + #'consult-preview-at-point-mode))) (setup (:straight epithet) (add-hook 'Info-selection-hook #'epithet-rename-buffer) @@ -1438,44 +1400,8 @@ already been connected to." (add-hook 'help-mode-hook #'epithet-rename-buffer) (add-hook 'occur-mode-hook #'epithet-rename-buffer)) -(setup (:straight-if eradio - (executable-find "mpv")) - (:option - eradio-player '("mpv" "--no-video" "--no-terminal") - eradio-channels `(("KLSU" . - "http://130.39.238.143:8010/stream.mp3") - ("Soma FM Synphaera" . - "https://somafm.com/synphaera256.pls") - ("SomaFM BAGel Radio" . - "https://somafm.com/bagel.pls") - ("SomaFM Boot Liquor" . - "https://somafm.com/bootliquor320.pls") - ("SomaFM Deep Space One" . - "https://somafm.com/deepspaceone.pls") - ("SomaFM Fluid" . - "https://somafm.com/fluid.pls") - ("SomaFM Underground 80s" . - "https://somafm.com/u80s256.pls") - ("WBRH: Jazz & More" . - "http://wbrh.streamguys1.com/wbrh-mp3") - ("KBRH Blues & Rhythm Hits" . - "http://wbrh.streamguys1.com/kbrh-mp3") - ("WRKF HD-2" . - ,(concat "https://playerservices.streamtheworld.com/" - "api/livestream-redirect/WRKFHD2.mp3")) - ("WRKF: NPR for the Capital Region" . - ,(concat "https://playerservices.streamtheworld.com/" - "api/livestream-redirect/WRKFFM.mp3")) - ("BadRadio: 24/7 PHONK" . - "https://s2.radio.co/s2b2b68744/listen") - ("tilderadio" . - "https://radio.tildeverse.org/radio/8000/radio.ogg") - ("vantaradio" . - "https://vantaa.black/radio"))) - (:global "C-c r r" eradio-play ; mnemonic: radio - "C-c r s" eradio-stop ; mnemonic: stop - "C-c r p" eradio-toggle ; mnemonic: play/pause - )) +(setup (:straight eros) + (:hook-into emacs-lisp-mode)) (setup (:straight expand-region) @@ -1504,73 +1430,28 @@ successive invocations." (:global "C-=" er/expand-region "C-SPC" acdw/set-mark-or-expand-region)) -(setup (:straight-if fennel-mode - (executable-find "fennel")) - (autoload 'fennel-repl "fennel-mode" nil t) - (add-to-list 'auto-mode-alist '("\\.fnl\\'" . fennel-mode))) +(setup (:straight flyspell-correct) + (add-hook 'flyspell-mode-hook + (defun flyspell-mode@flyspell-correct () + (dolist (keybind '(("C-;" . flyspell-correct-wrapper) + ("C-," . nil) + ("C-." . nil) + ("C-M-i" . nil))) + (define-key flyspell-mode-map + (kbd (car keybind)) (cdr keybind)))))) (setup (:straight gcmh) (:option gcmh-idle-delay 'auto) (gcmh-mode +1)) -(setup (:straight-if geiser - (progn - (defvar acdw/schemes - (let (schemes) ; these binaries should be checked... - (dolist (scheme '(("scheme" . geiser-chez) ; chez - ("petite" . geiser-chez) ; petite - ("csi" . geiser-chez) ; chicken - ("gsi" . geiser-gambit) ; gambit - ("gosh" . geiser-gauche) ; gauche - ("guile" . geiser-guile) - ("kawa" . geiser-kawa) - ("mit-scheme" . geiser-mit) - ("racket" . geiser-racket) - ("stklos" . geiser-stklos))) - (when-let (binary (executable-find (car scheme))) - (push binary schemes) - ;; and install the proper helper package - (straight-use-package (cdr scheme)))) - (nreverse schemes))) - acdw/schemes))) - -(setup (:straight (gemini-mode - :host nil - :repo "https://git.carcosa.net/jmcbray/gemini.el.git")) - (add-to-list 'auto-mode-alist '("\\.\\(gemini\\|gmi\\)\\'" . gemini-mode)) - (:hook turn-off-auto-fill)) - -(setup gforth - (when (locate-library "gforth") - (autoload 'forth-mode "gforth") - (add-to-list 'auto-mode-alist '("\\.fs\\'" . forth-mode)) - (autoload 'forth-block-mode "gforth") - (add-to-list 'auto-mode-alist '("\\.fb\\'" . forth-block-mode)))) - +;; TODO: figure out a popper.el / shackle.el ... thing to fix this (setup (:straight helpful) - (:option helpful-max-buffers 5 - ;; helpful-switch-buffer-function #'pop-to-buffer - ;; helpful-switch-buffer-function - ;; (lambda (buf) - ;; (pop-to-buffer buf - ;; '((display-buffer-reuse-mode-window - ;; display-buffer-pop-up-window) - ;; (mode . helpful-mode)) - ;; :norecord)) - ) + (:option helpful-max-buffers 5) (:global " f" helpful-callable " v" helpful-variable " k" helpful-key " o" helpful-symbol - "C-c C-d" helpful-at-point) - ;; (with-eval-after-load 'helpful - ;; (define-key helpful-mode-map "q" - ;; (defun helpful-mode|quit () - ;; (interactive) - ;; (bury-buffer) - ;; (unless (window-parameter (frame-selected-window) 'no-other-window) - ;; (delete-window))))) - ) + "C-c C-d" helpful-at-point)) (setup (:straight iscroll) (:hook-into text-mode)) @@ -1578,9 +1459,6 @@ successive invocations." (setup (:straight lacarte) (:global "" lacarte-execute-menu-command)) -(setup (:straight-if ledger-mode - (executable-find "ledger"))) - (setup (:straight link-hint) ;; Browse web URLs with a browser with a prefix argument. (dolist (type '(gnus-w3m-image-url @@ -1612,6 +1490,9 @@ browser defined in `browse-url-secondary-browser-function'." (setup (:straight lua-mode) (add-to-list 'auto-mode-alist '("\\.lua\\'" . lua-mode))) +(setup (:straight macrostep) + (define-key emacs-lisp-mode-map (kbd "C-c e") #'macrostep-expand)) + (setup (:straight magit) (:global "C-c g" magit-status) @@ -1628,110 +1509,26 @@ browser defined in `browse-url-secondary-browser-function'." marginalia-annotators-light)) (marginalia-mode +1)) -(setup (:straight (mastodon - :host github - :repo "mooseyboots/mastodon.el")) - (:straight request) - (:option mastodon-instance-url "https://writing.exchange" - mastodon-auth-source-file (car auth-sources) - mastodon-client--token-file (acdw/dir "mastodon.plstore")) - (:hook hl-line-mode - olivetti-mode)) - -(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) - - (acdw/sunrise-sunset #'modus-themes-load-operandi - #'modus-themes-load-vivendi)) - (setup (:straight markdown-mode)) (setup (:straight mwim) (:global "C-a" mwim-beginning "C-e" mwim-end)) -(setup (:straight nov) - (:option nov-text-width fill-column) - (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))) - -(setup (:straight package-lint)) - -(setup (:straight package-lint-flymake)) - -(setup (:straight olivetti) - (:option olivetti-body-width (+ fill-column 4) - olivetti-minimum-body-width fill-column) - - (add-hook 'olivetti-mode-hook - (defun acdw/olivetti-mode-hook () - (if olivetti-mode - (setq-local indicate-empty-lines nil - indicate-buffer-boundaries nil) - (acdw/setup-fringes))))) - -(setup (:straight (orderless - :host github - :repo "oantolin/orderless")) - (require 'orderless) - - (:option (append completion-styles) 'orderless - orderless-component-separator #'orderless-escapable-split-on-space - orderless-style-dispatchers '(acdw/orderless-dispatch)) - - (defun fix-dollar (args) - (if (string-suffix-p "$" (car args)) - (list (concat (substring (car args) 0 -1) "[\x100000-\x10FFFD]*$")) - args)) - (advice-add #'orderless-regexp :filter-args #'fix-dollar) - - (defun acdw/orderless-dispatch (pattern _index _total) - "My custom dispatcher for `orderless'." - (cond - ;; Ensure that $ works with Consult commands, which add disambiguation - ;; suffixes -- see `fix-dollar' - ((string-suffix-p "$" pattern) - `(orderless-regexp . ,(concat (substring pattern 0 -1) - "[\x100000-\x10FFFD]*$"))) - ;; File extensions - ((string-match-p "\\`\\.." pattern) - `(orderless-regexp . ,(concat "\\." (substring pattern 1) - "[\x100000-\x10FFFD]*$"))) - ;; Ignore single ! - ((string= "!" pattern) - `(orderless-literal . "")) - ;; Character folding - ((string-prefix-p "%" pattern) - `(char-fold-to-regexp . ,(substring pattern 1))) - ((string-suffix-p "%" pattern) - `(char-fold-to-regexp . ,(substring pattern 0 -1))) - ;; Without literal - ((string-prefix-p "!" pattern) - `(orderless-without-literal . ,(substring pattern 1))) - ((string-suffix-p "!" pattern) - `(orderless-without-literal . ,(substring pattern 0 -1))) - ;; Initialism matching - ((string-prefix-p "`" pattern) - `(orderless-initialism . ,(substring pattern 1))) - ((string-suffix-p "`" pattern) - `(orderless-initialism . ,(substring pattern 0 -1))) - ;; Literal matching - ((string-prefix-p "=" pattern) - `(orderless-literal . ,(substring pattern 1))) - ((string-suffix-p "=" pattern) - `(orderless-literal . ,(substring pattern 0 -1))) - ;; Flex matching - ((string-prefix-p "~" pattern) - `(orderless-flex . ,(substring pattern 1))) - ((string-suffix-p "~" pattern) - `(orderless-flex . ,(substring pattern 0 -1)))))) +(setup (:straight nov) + (:option nov-text-width fill-column) + (add-to-list 'auto-mode-alist '("\\.epub\\'" . nov-mode))) + +(setup (:straight olivetti) + (:option olivetti-body-width (+ fill-column 4) + olivetti-minimum-body-width fill-column) + + (add-hook 'olivetti-mode-hook + (defun acdw/olivetti-mode-hook () + (if olivetti-mode + (setq-local indicate-empty-lines nil + indicate-buffer-boundaries nil) + (acdw/setup-fringes))))) (setup (:straight org org-contrib) @@ -1803,10 +1600,14 @@ browser defined in `browse-url-secondary-browser-function'." (lambda (start end) "Count words stupidly with a limit." (acdw-org/count-words-stupidly start end - 999))))) - - (setup (:straight org-appear) - (:hook-into org-mode))) + 999)))))) + +(setup (:straight org-appear) + (:hook-into org-mode)) + +(setup (:straight package-lint)) + +(setup (:straight package-lint-flymake)) (setup (:straight page-break-lines) (global-page-break-lines-mode +1)) @@ -1830,7 +1631,6 @@ browser defined in `browse-url-secondary-browser-function'." (require 'eldoc) (eldoc-add-command 'paredit-backward-delete 'paredit-close-round)) - (setup (:straight paren-face) (dolist (mode lispy-modes) (add-hook (intern (concat (symbol-name mode) "-hook")) #'paren-face-mode))) @@ -1838,7 +1638,9 @@ browser defined in `browse-url-secondary-browser-function'." (setup (:straight persistent-scratch) (:option persistent-scratch-backup-directory (acdw/dir "scratch" t) persistent-scratch-keep-n-newest-backups 12) + (persistent-scratch-setup-default) + (mapc (lambda (buf) (with-current-buffer buf (when (funcall persistent-scratch-scratch-buffer-p-function) @@ -1893,45 +1695,15 @@ browser defined in `browse-url-secondary-browser-function'." (simple-modeline-mode +1)) -(setup (:straight-if sly - (progn (defvar acdw/lisp-bin - (or (executable-find "sbcl") - (executable-find "clisp") - "")) - (executable-find acdw/lisp-bin))) - - (:option inferior-lisp-program acdw/lisp-bin - sly-kill-without-query-p t) - - (:also-load sly-autoloads) - (setup (:straight clhs)) - - (:with-feature sly-mrepl - (dolist (key '("RET" "")) - (:bind key sly-mrepl-return-at-end)) - (:bind "C-c C-c" sly-mrepl-return)) - - (defun sly-mrepl-return-at-end () - (interactive) - (if (<= (point-max) (point)) - (sly-mrepl-return) - (if (bound-and-true-p paredit-mode) - (paredit-newline) - (electric-newline-and-maybe-indent))))) - (setup (:straight ssh-config-mode) (dolist (spec '(("/\\.ssh/config\\'" . ssh-config-mode) ("/sshd?_config\\'" . ssh-config-mode) ("/knownhosts\\'" . ssh-known-hosts-mode) ("/authorized_keys2?\\'" . ssh-authorized-keys-mode))) (add-to-list 'auto-mode-alist spec)) + (add-hook 'ssh-config-mode-hook #'turn-on-font-lock)) -(setup (:straight (topsy - :host github - :repo "alphapapa/topsy.el")) - (:hook-into prog-mode)) - (setup (:straight typo) ;; Enable C-c 8 map in all buffers @@ -1966,8 +1738,7 @@ If used with a numeric prefix argument N, N backticks will be inserted." ("`" "‘")) (:bind "'" typo-cycle-apostrophe - "`" typo-cycle-backtick) - )) + "`" typo-cycle-backtick))) (setup (:straight undo-fu) (:global "C-/" undo-fu-only-undo @@ -1983,50 +1754,6 @@ If used with a numeric prefix argument N, N backticks will be inserted." (setup (:straight unfill)) -(setup (:straight (unfocused - :host github - :repo "duckwork/unfocused")) - (unfocused-mode +1)) - -(setup (:straight (vertico - :host github - :repo "minad/vertico" - :files ("*" "extensions/*" - (:exclude ".git")))) - - (:option resize-mini-windows 'grow-only - vertico-count-format nil - vertico-cycle t) - - (defun up-directory (arg) - "Move up a directory (delete backwards to /)." - (interactive "p") - (if (string-match-p "/." (minibuffer-contents)) - (zap-up-to-char (- arg) ?/) - (backward-kill-word arg))) - - (with-eval-after-load 'vertico - (define-key vertico-map (kbd "") #'up-directory)) - - (if (boundp 'comp-deferred-compilation-deny-list) - (add-to-list 'comp-deferred-compilation-deny-list "vertico")) - - (vertico-mode +1) - - ;; Extensions! - (:also-load vertico-mouse) - (vertico-mouse-mode +1) - - ;; Prefix the current candidate with "> ". From Vertico wiki. - (defun vertico-format@add-arrow (orig cand prefix suffix index _start) - (setq cand (funcall orig cand prefix suffix index _start)) - (concat - (if (= vertico--index index) - (propertize "> " 'face 'vertico-current) - " ") - cand)) - (advice-add #'vertico--format-candidate :around #'vertico-format@add-arrow)) - (setup (:straight wc-mode) ; TODO: move some of this stuff around (:option wc-modeline-format "[%tww]" @@ -2043,6 +1770,7 @@ If used with a numeric prefix argument N, N backticks will be inserted." (:option css-level-offset 2 js-indent-level 2 sgml-indent-offset 2) + (dolist (ext '("\\.\\(p\\|dj\\)?html\\'" "\\.html?\\'" "\\.\\(tpl\\.\\)?php\\'" @@ -2102,35 +1830,141 @@ call `zzz-to-char'." (:global "M-z" acdw/zzz-up-to-char)) - -;;; System-dependent - -;;;; Home -(when (acdw/system :home) +(setup (:straight-if (pdf-tools + :host github + :repo "vedang/pdf-tools") + (acdw/system :home)) + (add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode)) + (pdf-loader-install)) - (setup (:straight exec-path-from-shell) - (when (daemonp) - (exec-path-from-shell-initialize))) +(setup (:straight-if affe + (and (or (executable-find "fd") + (executable-find "find")) + (executable-find "rg"))) + ;; Keys are bound in `acdw/sensible-grep' and `acdw/sensible-find' + (defun affe-orderless-regexp-compiler (input _type) + (setq input (orderless-pattern-compiler input)) + (cons input (lambda (str) (orderless--highlight input str)))) - (setup (:straight pkgbuild-mode)) + (:option affe-regexp-compiler #'affe-orderless-regexp-compiler)) + +(setup (:straight-if ahk-mode + (acdw/system :work))) + +;; TODO: look into emms or something related for this +(setup (:straight-if eradio + (executable-find "mpv")) + (:option + eradio-player '("mpv" "--no-video" "--no-terminal") + eradio-channels `(("KLSU" . + "http://130.39.238.143:8010/stream.mp3") + ("Soma FM Synphaera" . + "https://somafm.com/synphaera256.pls") + ("SomaFM BAGel Radio" . + "https://somafm.com/bagel.pls") + ("SomaFM Boot Liquor" . + "https://somafm.com/bootliquor320.pls") + ("SomaFM Deep Space One" . + "https://somafm.com/deepspaceone.pls") + ("SomaFM Fluid" . + "https://somafm.com/fluid.pls") + ("SomaFM Underground 80s" . + "https://somafm.com/u80s256.pls") + ("WBRH: Jazz & More" . + "http://wbrh.streamguys1.com/wbrh-mp3") + ("KBRH Blues & Rhythm Hits" . + "http://wbrh.streamguys1.com/kbrh-mp3") + ("WRKF HD-2" . + ,(concat "https://playerservices.streamtheworld.com/" + "api/livestream-redirect/WRKFHD2.mp3")) + ("WRKF: NPR for the Capital Region" . + ,(concat "https://playerservices.streamtheworld.com/" + "api/livestream-redirect/WRKFFM.mp3")) + ("BadRadio: 24/7 PHONK" . + "https://s2.radio.co/s2b2b68744/listen") + ("tilderadio" . + "https://radio.tildeverse.org/radio/8000/radio.ogg") + ("vantaradio" . + "https://vantaa.black/radio"))) + (:global "C-c r r" eradio-play ; mnemonic: radio + "C-c r s" eradio-stop ; mnemonic: stop + "C-c r p" eradio-toggle ; mnemonic: play/pause + )) + +(setup (:straight-if exec-path-from-shell + (acdw/system :home)) + (when (daemonp) + (exec-path-from-shell-initialize))) + +(setup (:straight-if fennel-mode + (executable-find "fennel")) + (autoload 'fennel-repl "fennel-mode" nil t) + (add-to-list 'auto-mode-alist '("\\.fnl\\'" . fennel-mode))) + +(setup (:straight-if geiser + (progn + (defvar acdw/schemes + (let (schemes) ; these binaries should be checked... + (dolist (scheme '(("scheme" . geiser-chez) ; chez + ("petite" . geiser-chez) ; petite + ("csi" . geiser-chez) ; chicken + ("gsi" . geiser-gambit) ; gambit + ("gosh" . geiser-gauche) ; gauche + ("guile" . geiser-guile) + ("kawa" . geiser-kawa) + ("mit-scheme" . geiser-mit) + ("racket" . geiser-racket) + ("stklos" . geiser-stklos))) + (when-let (binary (executable-find (car scheme))) + (push binary schemes) + ;; and install the proper helper package + (straight-use-package (cdr scheme)))) + (nreverse schemes))) + acdw/schemes))) + +(setup (:straight-if ledger-mode + (executable-find "ledger"))) + +(setup (:straight-if pkgbuild-mode + (executable-find "makepkg"))) + +(setup (:straight-if sly + (progn (defvar acdw/lisp-bin + (or (executable-find "sbcl") + (executable-find "clisp") + "")) + (executable-find acdw/lisp-bin))) + + (:option inferior-lisp-program acdw/lisp-bin + sly-kill-without-query-p t) - (setup (:straight (pdf-tools - :host github - :repo "vedang/pdf-tools")) - (add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode)) - (pdf-loader-install)) + (:also-load sly-autoloads) + (setup (:straight clhs)) + + (:with-feature sly-mrepl + (dolist (key '("RET" "")) + (:bind key sly-mrepl-return-at-end)) + (:bind "C-c C-c" sly-mrepl-return)) - (setup (:straight systemd)) + (defun sly-mrepl-return-at-end () + (interactive) + (if (<= (point-max) (point)) + (sly-mrepl-return) + (if (bound-and-true-p paredit-mode) + (paredit-newline) + (electric-newline-and-maybe-indent))))) - (setup (:straight vterm)) +(setup (:straight-if systemd + (executable-find "systemd"))) - (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-if vterm + (acdw/system :home))) -;;;; Work -(when (acdw/system :work) - (setup (:straight ahk-mode))) +(setup gforth + (when (locate-library "gforth") + (autoload 'forth-mode "gforth") + (add-to-list 'auto-mode-alist '("\\.fs\\'" . forth-mode)) + (autoload 'forth-block-mode "gforth") + (add-to-list 'auto-mode-alist '("\\.fb\\'" . forth-block-mode)))) ;;; init.el ends here -- cgit 1.4.1-21-gabe81