From 5348b735a21e9c62a700b86e06eb5f2c1c950c30 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 25 Sep 2021 14:03:00 -0500 Subject: Resort --- init.el | 448 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 225 insertions(+), 223 deletions(-) diff --git a/init.el b/init.el index 8e82408..9ed10a6 100644 --- a/init.el +++ b/init.el @@ -13,12 +13,14 @@ ;; Everyone is permitted to do whatever with this software, without ;; limitation. This software comes without any warranty whatsoever, ;; but with two pieces of advice: -;; - Don't hurt yourself. +;; - Be kind to yourself. ;; - Make good choices. -;;; Code: +;;; Commentary: + +;; Some of the names in these `setup' forms are arbitrary. -;; NOTE that some of the names in `setup' forms are arbitrary. +;;; Code: (setup (:require auth-source) (:option auth-sources (list (acdw/sync-dir "authinfo") @@ -92,26 +94,25 @@ In short, DO NOT USE THIS FUNCTION!!!" (save-excursion (sort-sexps (point-min) (point-max) - (lambda (sexp) - (format "%S" (cadr sexp))) + ;; Key function + nil + ;; Sort function (lambda (s1 s2) ; oh god, this is worse. (let* ((s1 (cdr s1)) (s2 (cdr s2)) ; for the strings themselves - (s1-require (string-match ":require" s1)) - (s2-require (string-match ":require" s2)) - (s1-straight (string-match ":straight" s1)) - (s2-straight (string-match ":straight" s2)) + (require-regexp (rx bos (* nonl) ":require")) + (straight-regexp (rx bos (* nonl) ":straight")) + (s1-require (string-match require-regexp s1)) + (s2-require (string-match require-regexp s2)) + (s1-straight (string-match straight-regexp s1)) + (s2-straight (string-match straight-regexp s2)) (s1-bare (not (or s1-require s1-straight))) (s2-bare (not (or s2-require s2-straight)))) (cond - ;; if both are the same, sort regular style - ((or (and s1-require s2-require) - (and s1-bare s2-bare)) - (string< s1 s2)) + ;; Straight forms require some weirdness ((and s1-straight s2-straight) (let* ((r (rx ":straight" (? "-if") (* space) (? "("))) (s1 (replace-regexp-in-string r "" s1)) (s2 (replace-regexp-in-string r "" s2))) - (message "'%S' '%S'" s1 s2) (string< s1 s2))) ;; requires should go first ((and s1-require (not s2-require)) t) @@ -195,142 +196,6 @@ In short, DO NOT USE THIS FUNCTION!!!" (setup calendar (:option calendar-week-start-day 1)) -(setup (:straight circe) - (require 'circe) - (require 'acdw-irc) - - (:option acdw-irc/left-margin 20 - acdw-irc/post-my-nick "-> " - circe-channel-killed-confirmation nil - circe-color-nicks-everywhere t - circe-default-nick "acdw" - circe-default-part-message "See You, Space Cowpokes . . ." - circe-default-user "acdw" - circe-format-action (format - (format "%%%ds* {nick} {body}" - (- acdw-irc/left-margin 2)) " ") - circe-format-say (format - "{nick:%1$d.%1$ds} | {body}" - (- acdw-irc/left-margin 3)) - circe-format-self-action circe-format-action - circe-format-self-say (format - "{nick:%1$d.%1$ds} > {body}" - (- acdw-irc/left-margin 3)) - circe-network-options - `(("Libera Chat" - :channels ("#emacs" "#systemcrafters" "##webpals") - :sasl-username ,circe-default-nick - :sasl-password ,(acdw/make-password-fetcher - :host "libera.chat")) - ("Tilde Chat" :host "irc.tilde.chat" :port 6697 :use-tls t - :channels ("#meta" "#bread" "#dadjokes" "#team" - "#emacs" "#nsfw") - :sasl-username ,circe-default-nick - :sasl-password ,(acdw/make-password-fetcher - :host "tilde.chat")) - ("Casa" :host "m455.casa" :port 6697 :use-tls t - :channels ("#basement") - :sasl-username ,circe-default-nick - :sasl-password ,(acdw/make-password-fetcher - :host "m455.casa")) - ("Pissnet" :host "piss.hmm.st" :port 6697 :use-tls t - :channels ("#i-just-peed") - :sasl-username ,circe-default-nick - :sasl-password ,(acdw/make-password-fetcher - :host "piss.hmm.st")) - ;; TODO: irc.chat.twitch.tv - ) - circe-reduce-lurker-spam t - circe-server-auto-join-default-type :after-auth - circe-server-buffer-action (lambda (buf) - (message "Connected to %s" buf))) - - (with-eval-after-load 'circe - (:face circe-nick-highlight-face - ((t (:inherit (modus-themes-hl-line modus-themes-bold)))) - circe-my-message-face - ((t (:inherit (modus-themes-slant)))))) - - (:bind "C-c C-p" #'circe-command-PART - "C-l" #'lui-track-jump-to-indicator) - - (:advise circe-command-PART :after - (defun circe-part@kill-buffer (&rest _) - (let ((circe-channel-killed-confirmation nil)) - (kill-buffer))) - - circe-command-QUIT :after - (defun circe-quit@kill-buffer (&rest _) - ;; `circe-server-killed-confirmation' set to nil, and manually - ;; deleting all chat buffers, pending Github issue #402 - ;; (https://github.com/emacs-circe/circe/issues/402) - (let ((circe-server-killed-confirmation nil)) - (with-circe-server-buffer - (dolist (buf (circe-server-chat-buffers)) - (let ((circe-channel-killed-confirmation nil)) - (kill-buffer buf))) - (kill-buffer)))) - - circe-command-GQUIT :after - (defun circe-gquit@kill-buffer (&rest _) - ;; `circe-server-killed-confirmation' set to nil, and manually - ;; deleting all chat buffers, pending Github issue #402 - ;; (https://github.com/emacs-circe/circe/issues/402) - (let ((circe-server-killed-confirmation nil)) - (dolist (buf (circe-server-buffers)) - (with-current-buffer buf - (dolist (buf (circe-server-chat-buffers)) - (let ((circe-channel-killed-confirmation nil)) - (kill-buffer buf)) - (cancel-timer 'irc-send--queue)) - (message "%s: %s" buf circe-server-killed-confirmation) - (kill-buffer)))))) - - (defun circe-command-SHORTEN (url) - "Shorten URL using `0x0-shorten-uri'." - (interactive "sURL to shorten: ") - ;; TODO: enable /shorten URL comment syntax - (let ((short-url (0x0-shorten-uri (0x0--choose-server) url))) - (circe-command-SAY short-url))) - - (:with-mode circe-chat-mode - (:hook #'acdw/stop-paren-annoyances - #'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) - " "))))) - - (autoload 'circe-nick-color-reset "circe-color-nicks") - (add-hook 'modus-themes-after-load-theme-hook - #'circe-nick-color-reset) - - (:with-mode lui-mode - (:option lui-fill-column (+ fill-column acdw-irc/left-margin) - lui-fill-type (repeat-string acdw-irc/left-margin " ") - lui-time-stamp-position 'right-margin - lui-time-stamp-format "%H:%M" - lui-track-behavior 'before-switch-to-buffer - lui-track-indicator 'fringe - lui-fill-remove-face-from-newline nil) - - (: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 #'enable-lui-track))) - (setup completion (:option completion-ignore-case t read-buffer-completion-ignore-case t @@ -341,6 +206,9 @@ In short, DO NOT USE THIS FUNCTION!!!" (:global "M-/" #'hippie-expand)) +(setup css-mode + (:bind "C-c C-h" #'css-lookup-symbol)) + (setup cursor (:option cursor-type 'bar cursor-in-non-selected-windows 'hollow @@ -446,24 +314,6 @@ In short, DO NOT USE THIS FUNCTION!!!" ;; https://oremacs.com/2015/01/17/setting-up-ediff/ (add-hook 'ediff-after-quit-hook-internal #'winner-undo)) -;; requires extension: -;; https://addons.mozilla.org/en-US/firefox/addon/edit-with-emacs1/ -(setup (:straight edit-server) - (:require edit-server) - (edit-server-start) - - (:option edit-server-default-major-mode 'text-mode - edit-server-url-major-mode-alist - (list (cons (rx (| "reddit.com" - "tildes.net")) - 'markdown-mode) - (cons (rx "github.com") - 'gfm-mode))) - - (:advise edit-server-make-frame :before - (defun edit-server@set-a-variable (&rest _) - (setq-local edit-server-frame-p t)))) - (setup eldoc (:option eldoc-idle-delay 0.1 eldoc-echo-area-use-multiline-p nil)) @@ -881,6 +731,24 @@ specific to most general, they are these: ;; (put 'backward-page 'repeat-map 'page-navigation-repeat-map) ) +(setup prog + (:option show-paren-delay 0 + show-paren-style 'mixed + show-paren-when-point-inside-paren t + show-paren-when-point-in-periphery t + smie-indent-basic tab-width) + + (:hook show-paren-mode + electric-pair-local-mode + acdw/setup-fringes + + (defun prog-mode@auto-fill () + (setq-local comment-auto-fill-only-comments t) + (turn-on-auto-fill))) + + (add-hook 'after-save-hook + #'executable-make-buffer-file-executable-if-script-p)) + (setup repeat ;; new for Emacs 28! (:only-if (fboundp #'repeat-mode)) @@ -1146,6 +1014,142 @@ specific to most general, they are these: (:with-feature isearch (:bind "C-'" #'avy-isearch))) +(setup (:straight circe) + (require 'circe) + (require 'acdw-irc) + + (:option acdw-irc/left-margin 20 + acdw-irc/post-my-nick "-> " + circe-channel-killed-confirmation nil + circe-color-nicks-everywhere t + circe-default-nick "acdw" + circe-default-part-message "See You, Space Cowpokes . . ." + circe-default-user "acdw" + circe-format-action (format + (format "%%%ds* {nick} {body}" + (- acdw-irc/left-margin 2)) " ") + circe-format-say (format + "{nick:%1$d.%1$ds} | {body}" + (- acdw-irc/left-margin 3)) + circe-format-self-action circe-format-action + circe-format-self-say (format + "{nick:%1$d.%1$ds} > {body}" + (- acdw-irc/left-margin 3)) + circe-network-options + `(("Libera Chat" + :channels ("#emacs" "#systemcrafters" "##webpals") + :sasl-username ,circe-default-nick + :sasl-password ,(acdw/make-password-fetcher + :host "libera.chat")) + ("Tilde Chat" :host "irc.tilde.chat" :port 6697 :use-tls t + :channels ("#meta" "#bread" "#dadjokes" "#team" + "#emacs" "#nsfw") + :sasl-username ,circe-default-nick + :sasl-password ,(acdw/make-password-fetcher + :host "tilde.chat")) + ("Casa" :host "m455.casa" :port 6697 :use-tls t + :channels ("#basement") + :sasl-username ,circe-default-nick + :sasl-password ,(acdw/make-password-fetcher + :host "m455.casa")) + ("Pissnet" :host "piss.hmm.st" :port 6697 :use-tls t + :channels ("#i-just-peed") + :sasl-username ,circe-default-nick + :sasl-password ,(acdw/make-password-fetcher + :host "piss.hmm.st")) + ;; TODO: irc.chat.twitch.tv + ) + circe-reduce-lurker-spam t + circe-server-auto-join-default-type :after-auth + circe-server-buffer-action (lambda (buf) + (message "Connected to %s" buf))) + + (with-eval-after-load 'circe + (:face circe-nick-highlight-face + ((t (:inherit (modus-themes-hl-line modus-themes-bold)))) + circe-my-message-face + ((t (:inherit (modus-themes-slant)))))) + + (:bind "C-c C-p" #'circe-command-PART + "C-l" #'lui-track-jump-to-indicator) + + (:advise circe-command-PART :after + (defun circe-part@kill-buffer (&rest _) + (let ((circe-channel-killed-confirmation nil)) + (kill-buffer))) + + circe-command-QUIT :after + (defun circe-quit@kill-buffer (&rest _) + ;; `circe-server-killed-confirmation' set to nil, and manually + ;; deleting all chat buffers, pending Github issue #402 + ;; (https://github.com/emacs-circe/circe/issues/402) + (let ((circe-server-killed-confirmation nil)) + (with-circe-server-buffer + (dolist (buf (circe-server-chat-buffers)) + (let ((circe-channel-killed-confirmation nil)) + (kill-buffer buf))) + (kill-buffer)))) + + circe-command-GQUIT :after + (defun circe-gquit@kill-buffer (&rest _) + ;; `circe-server-killed-confirmation' set to nil, and manually + ;; deleting all chat buffers, pending Github issue #402 + ;; (https://github.com/emacs-circe/circe/issues/402) + (let ((circe-server-killed-confirmation nil)) + (dolist (buf (circe-server-buffers)) + (with-current-buffer buf + (dolist (buf (circe-server-chat-buffers)) + (let ((circe-channel-killed-confirmation nil)) + (kill-buffer buf)) + (cancel-timer 'irc-send--queue)) + (message "%s: %s" buf circe-server-killed-confirmation) + (kill-buffer)))))) + + (defun circe-command-SHORTEN (url) + "Shorten URL using `0x0-shorten-uri'." + (interactive "sURL to shorten: ") + ;; TODO: enable /shorten URL comment syntax + (let ((short-url (0x0-shorten-uri (0x0--choose-server) url))) + (circe-command-SAY short-url))) + + (:with-mode circe-chat-mode + (:hook #'acdw/stop-paren-annoyances + #'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) + " "))))) + + (autoload 'circe-nick-color-reset "circe-color-nicks") + (add-hook 'modus-themes-after-load-theme-hook + #'circe-nick-color-reset) + + (:with-mode lui-mode + (:option lui-fill-column (+ fill-column acdw-irc/left-margin) + lui-fill-type (repeat-string acdw-irc/left-margin " ") + lui-time-stamp-position 'right-margin + lui-time-stamp-format "%H:%M" + lui-track-behavior 'before-switch-to-buffer + lui-track-indicator 'fringe + lui-fill-remove-face-from-newline nil) + + (: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 #'enable-lui-track))) + (setup (:straight (consult :host github :repo "minad/consult")) @@ -1288,8 +1292,49 @@ specific to most general, they are these: ("/" winner-undo "?" winner-redo))) +(setup (:straight dictionary) + (:option dictionary-use-single-buffer t) + + (autoload 'dictionary-search "dictionary" + "Ask for a word and search it in all dictionaries" t) + (autoload 'dictionary-match-words "dictionary" + "Ask for a word and search all matching words in the dictionaries" t) + (autoload 'dictionary-lookup-definition "dictionary" + "Unconditionally lookup the word at point." t) + (autoload 'dictionary "dictionary" + "Create a new dictionary buffer" t) + (autoload 'dictionary-mouse-popup-matching-words "dictionary" + "Display entries matching the word at the cursor" t) + (autoload 'dictionary-popup-matching-words "dictionary" + "Display entries matching the word at the point" t) + (autoload 'dictionary-tooltip-mode "dictionary" + "Display tooltips for the current word" t) + (autoload 'global-dictionary-tooltip-mode "dictionary" + "Enable/disable dictionary-tooltip-mode for all buffers" t) + + (:with-map lookup-map + (:bind "d" #'dictionary-search))) + (setup (:straight edit-indirect)) +;; requires extension: +;; https://addons.mozilla.org/en-US/firefox/addon/edit-with-emacs1/ +(setup (:straight edit-server) + (:require edit-server) + (edit-server-start) + + (:option edit-server-default-major-mode 'text-mode + edit-server-url-major-mode-alist + (list (cons (rx (| "reddit.com" + "tildes.net")) + 'markdown-mode) + (cons (rx "github.com") + 'gfm-mode))) + + (:advise edit-server-make-frame :before + (defun edit-server@set-a-variable (&rest _) + (setq-local edit-server-frame-p t)))) + (setup (:straight (electric-cursor :host github :repo "duckwork/electric-cursor")) @@ -1640,7 +1685,7 @@ browser defined in `browse-url-secondary-browser-function'." (define-key lisp-interaction-mode-map (kbd "C-c e") #'macrostep-expand)) (setup (:straight magit) - (:global "C-c g" #'magit-status) + (:global "C-x g" #'magit-status) (:option magit-display-buffer-function (defun magit-display-buffer-same-window (buffer) @@ -1957,24 +2002,6 @@ the default is \"/\"." (persistent-scratch-mode +1)))) (buffer-list))) -(setup prog - (:option show-paren-delay 0 - show-paren-style 'mixed - show-paren-when-point-inside-paren t - show-paren-when-point-in-periphery t - smie-indent-basic tab-width) - - (:hook show-paren-mode - electric-pair-local-mode - acdw/setup-fringes - - (defun prog-mode@auto-fill () - (setq-local comment-auto-fill-only-comments t) - (turn-on-auto-fill))) - - (add-hook 'after-save-hook - #'executable-make-buffer-file-executable-if-script-p)) - (setup (:straight-if pkgbuild-mode (executable-find "makepkg")) (:file-match "PKGBUILD")) @@ -1982,19 +2009,17 @@ the default is \"/\"." (setup (:straight powerthesaurus) (:global "C-c l t" #'powerthesaurus-lookup-word-dwim)) -1(setup (:straight restart-emacs) - (defun emacs-upgrade (&optional update-packages) - "Pull config, upgrade packages, restart Emacs." - (interactive "P") - (emacs-git-pull-config) - (when update-packages - (require 'straight-x) - (straight-x-pull-all)) - (restart-emacs))) - -(setup (:straight (shell-command+ - :host nil - :repo "https://git.sr.ht/~pkal/shell-command-plus")) +(setup (:straight restart-emacs) + (defun emacs-upgrade (&optional update-packages) + "Pull config, upgrade packages, restart Emacs." + (interactive "P") + (emacs-git-pull-config) + (when update-packages + (require 'straight-x) + (straight-x-pull-all)) + (restart-emacs)))(setup (:straight (shell-command+ + :host nil + :repo "https://git.sr.ht/~pkal/shell-command-plus")) (:option shell-command-prompt "$ ") (:with-feature dired (:bind "M-!" shell-command+)) @@ -2265,27 +2290,4 @@ If used with a numeric prefix argument N, N backticks will be inserted." (call-interactively #'zzz-to-char) (call-interactively #'zzz-up-to-char))))) -(setup (:straight dictionary) - (:option dictionary-use-single-buffer t) - - (autoload 'dictionary-search "dictionary" - "Ask for a word and search it in all dictionaries" t) - (autoload 'dictionary-match-words "dictionary" - "Ask for a word and search all matching words in the dictionaries" t) - (autoload 'dictionary-lookup-definition "dictionary" - "Unconditionally lookup the word at point." t) - (autoload 'dictionary "dictionary" - "Create a new dictionary buffer" t) - (autoload 'dictionary-mouse-popup-matching-words "dictionary" - "Display entries matching the word at the cursor" t) - (autoload 'dictionary-popup-matching-words "dictionary" - "Display entries matching the word at the point" t) - (autoload 'dictionary-tooltip-mode "dictionary" - "Display tooltips for the current word" t) - (autoload 'global-dictionary-tooltip-mode "dictionary" - "Enable/disable dictionary-tooltip-mode for all buffers" t) - - (:with-map lookup-map - (:bind "d" #'dictionary-search))) - ;;; init.el ends here -- cgit 1.4.1-21-gabe81