This commit is contained in:
Case Duckworth 2022-02-18 18:25:27 -06:00
parent b05b4c8107
commit 5b35d5c91b
1 changed files with 100 additions and 102 deletions

202
init.el
View File

@ -93,19 +93,6 @@
(:with-mode Custom-mode (:with-mode Custom-mode
(:local-set imenu-generic-expression +cus-edit-imenu-generic-expression))) (:local-set imenu-generic-expression +cus-edit-imenu-generic-expression)))
(setup (:require ecomplete)
(:also-load +ecomplete)
(:option message-mail-alias-type 'ecomplete
message-self-insert-commands nil
message-expand-name-standard-ui t)
(with-eval-after-load 'ecomplete
(:option completion-category-defaults nil)
(with-eval-after-load 'embark
(:bind-into embark-email-map
"+" #'+ecomplete-add-email
"\\" #'+ecomplete-remove-email)))
(add-hook 'message-sent-hook #'message-put-addresses-in-ecomplete))
(setup (:require goto-addr) (setup (:require goto-addr)
(if (fboundp #'global-goto-address-mode) (if (fboundp #'global-goto-address-mode)
(global-goto-address-mode) (global-goto-address-mode)
@ -189,41 +176,42 @@
(add-to-list '+browse-url-secondary-browser-regexps (add-to-list '+browse-url-secondary-browser-regexps
(replace-regexp-in-string "\\." "\\\\." domain))) (replace-regexp-in-string "\\." "\\\\." domain)))
;; Set up URL handlers. ;; Set up URL handlers.
(require 'chd) (with-eval-after-load 'org-contacts
(+browse-url-set-handlers (require 'chd)
(list (+browse-url-set-handlers
(cons (rx ; images (list
"." (or "jpeg" "jpg" "png" "bmp") eos) (cons (rx ; images
(lambda (&rest args) "." (or "jpeg" "jpg" "png" "bmp") eos)
(apply (lambda (&rest args)
(cond ((executable-find "mpv") #'+browse-image-with-mpv) (apply
(t #'eww-browse-url)) (cond ((executable-find "mpv") #'+browse-image-with-mpv)
args))) (t #'eww-browse-url))
(cons (rx (or ;; videos args)))
"youtube.com" "youtu.be" "invidious" "yewtu.be" (cons (rx (or ;; videos
(seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos) "youtube.com" "youtu.be" "invidious" "yewtu.be"
;; music (seq "." (or "mp4" "gif" "mov" "MOV" "webm") eos)
"soundcloud.com" "bandcamp.com" ;; music
(seq "." (or "ogg" "mp3" "opus" "m4a") eos))) "soundcloud.com" "bandcamp.com"
(lambda (&rest args) (seq "." (or "ogg" "mp3" "opus" "m4a") eos)))
(apply (if (executable-find "mpv") (lambda (&rest args)
#'+browse-url-with-mpv (apply (if (executable-find "mpv")
browse-url-secondary-browser-function) #'+browse-url-with-mpv
args))) browse-url-secondary-browser-function)
(cons chd/url-regexps #'browse-url-chrome) args)))
(cons (+browse-url-secondary-browser-regexps-combine) ; non-text websites (cons chd/url-regexps #'browse-url-chrome)
(lambda (&rest args) (cons (+browse-url-secondary-browser-regexps-combine) ; non-text websites
(apply browse-url-secondary-browser-function args))) (lambda (&rest args)
(cons "xkcd\\.com" (apply browse-url-secondary-browser-function args)))
(lambda (&rest args) (cons "xkcd\\.com"
(apply (if (fboundp #'xkcd-get) (lambda (&rest args)
(progn (require '+xkcd) (apply (if (fboundp #'xkcd-get)
#'+xkcd-get-from-url) (progn (require '+xkcd)
+browse-url-browser-function) #'+xkcd-get-from-url)
args))) +browse-url-browser-function)
(cons "." ; everything else args)))
(lambda (&rest args) (cons "." ; everything else
(apply +browse-url-browser-function args))))) (lambda (&rest args)
(apply +browse-url-browser-function args))))))
;; Transform URLs before passing to `browse-url' ;; Transform URLs before passing to `browse-url'
(:option +browse-url-transformations `((,(rx (or "youtube.com" (:option +browse-url-transformations `((,(rx (or "youtube.com"
"youtu.be")) "youtu.be"))
@ -236,15 +224,14 @@
"old.reddit.com")) "old.reddit.com"))
. "teddit.net") . "teddit.net")
("medium\\.com" ("medium\\.com"
. "scribe.rip"))) . "scribe.rip")
("www\\.npr\\.org"
. "text.npr.org")))
(+browse-url-transform-url-global-mode +1)) (+browse-url-transform-url-global-mode +1))
(setup calendar (setup calendar
(require '_location) (require '_location)
(:option calendar-location-name _location-name (:option diary-file (private/ "diary")))
calendar-latitude _location-latitude
calendar-longitude _location-longitude
diary-file (private/ "diary")))
(setup compile (setup compile
(:option compilation-always-kill t (:option compilation-always-kill t
@ -282,6 +269,20 @@
(with-eval-after-load 'frowny (with-eval-after-load 'frowny
(add-to-list 'frowny-inhibit-modes #'dired-mode))) (add-to-list 'frowny-inhibit-modes #'dired-mode)))
(setup ecomplete (:quit)
(:load-after org-contacts)
(:also-load +ecomplete)
(:option message-mail-alias-type 'ecomplete
message-self-insert-commands nil
message-expand-name-standard-ui t)
(with-eval-after-load 'ecomplete
(:option completion-category-defaults nil)
(with-eval-after-load 'embark
(:bind-into embark-email-map
"+" #'+ecomplete-add-email
"\\" #'+ecomplete-remove-email)))
(add-hook 'message-sent-hook #'message-put-addresses-in-ecomplete))
(setup ehelp (setup ehelp
;; Trying this instead of `helpful' ;; Trying this instead of `helpful'
(:global [help] 'ehelp-command (:global [help] 'ehelp-command
@ -462,39 +463,15 @@
)) ))
(setup notmuch (setup notmuch
(add-to-list 'load-path (:load-from "~/usr/share/emacs/site-lisp/")
(car (file-expand-wildcards "/usr/share/emacs/site-lisp/elpa-src/notmuch*"))) ;;(:load-after org-contacts)
(require 'notmuch) (:also-load +notmuch)
(require '+notmuch) (+define-dir notmuch/ (sync/ "emacs/notmuch")
(+define-dir notmuch/ (private/ "notmuch")
"Notmuch configuration and data.") "Notmuch configuration and data.")
(:option notmuch-init-file (notmuch/ "init.el" t) (:option notmuch-init-file (notmuch/ "notmuch-init.el" t)
notmuch-address-save-filename (notmuch/ "addresses" t) notmuch-address-save-filename (notmuch/ "addresses" t)
notmuch-address-use-company (featurep 'company) notmuch-address-use-company (featurep 'company)
notmuch-search-oldest-first nil notmuch-search-oldest-first nil)
notmuch-saved-searches (list
(list :name "next"
:query (+notmuch-query-concat "tag:inbox"
"NOT tag:/List/")
:key "n")
(list :name "lists"
:query (+notmuch-query-concat "tag:/List/")
:key "l")
;; original
(list :name "inbox"
:query (+notmuch-query-concat "tag:inbox"
"NOT tag:Spam")
:key "i")
(list :name "unread"
:query (+notmuch-query-concat "tag:unread"
"NOT tag:Spam")
:key "u")
(list :name "flagged" :query "tag:flagged" :key "f")
(list :name "sent" :query "tag:sent" :key "t")
(list :name "drafts" :query "tag:draft" :key "d")
(list :name "all mail" :query "*" :key "a")))
;; I don't know why or how this isn't properly loaded, but here we are.
(with-eval-after-load 'notmuch (load notmuch-init-file :noerror))
;; Composing mail ;; Composing mail
(:option message-kill-buffer-on-exit t) (:option message-kill-buffer-on-exit t)
;; Sending mail ;; Sending mail
@ -503,12 +480,31 @@
message-sendmail-envelope-from 'header message-sendmail-envelope-from 'header
mail-envelope-from 'header) mail-envelope-from 'header)
;; Extras and fixes ;; Extras and fixes
;; +send-mail-dispatch is defined in notmuch/init.el (with-eval-after-load 'notmuch
(add-hook 'notmuch-show-mode-hook #'visual-fill-column-mode) (load notmuch-init-file :noerror)
(add-hook 'message-send-hook #'+send-mail-dispatch) ;;(add-hook 'notmuch-show-mode-hook #'visual-fill-column-mode)
(advice-add 'notmuch-tag :filter-args #'+notmuch-correct-tags) (add-hook 'message-send-hook #'+send-mail-dispatch)
(:+leader "m" #'+notmuch-goto (advice-add 'notmuch-tag :filter-args #'+notmuch-correct-tags)
"C-m" #'+notmuch-goto)) (:option notmuch-saved-searches (list
(list :name "lists"
:query (+notmuch-query-concat "tag:/List/"
"tag:unread")
:key "l")
;; original
(list :name "inbox"
:query (+notmuch-query-concat "tag:inbox"
"NOT tag:Spam")
:key "i")
(list :name "unread"
:query (+notmuch-query-concat "tag:unread"
"NOT tag:Spam")
:key "u")
(list :name "flagged" :query "tag:flagged" :key "f")
(list :name "sent" :query "tag:sent" :key "t")
(list :name "drafts" :query "tag:draft" :key "d")
(list :name "all mail" :query "*" :key "a"))))
(:+leader "m" #'+notmuch-goto "C-m" #'+notmuch-goto
"n" #'notmuch "C-n" #'notmuch))
(setup org (setup org
;; Plain org with the `setup' form for sorting, but I install with straight. ;; Plain org with the `setup' form for sorting, but I install with straight.
@ -649,7 +645,8 @@
(setup org-attach (setup org-attach
(:also-load +org-attach) (:also-load +org-attach)
(:option org-attach-method 'lns) (:option org-attach-method 'lns)
(+org-attach-fix-args-mode +1)) (with-eval-after-load '+org-attach
(+org-attach-fix-args-mode +1)))
(setup org-capture (setup org-capture
(:require +org-capture) (:require +org-capture)
@ -698,6 +695,7 @@
(+org-capture-sort)) (+org-capture-sort))
(setup org-contacts (setup org-contacts
(:load-after org)
(:also-straight org-vcard) ; for importing Vcard files (:also-straight org-vcard) ; for importing Vcard files
(:option org-contacts-matcher "contact") ; Contacts are tagged "contact" (:option org-contacts-matcher "contact") ; Contacts are tagged "contact"
) )
@ -1130,7 +1128,7 @@ They are completed by \"M-x TAB\" only in Tramp debug buffers."
("C-M-#" . consult-register) ("C-M-#" . consult-register)
;; Other custom bindings ;; Other custom bindings
("M-y" . consult-yank-pop) ("M-y" . consult-yank-pop)
("<f1> a" . consult-apropos) ;;("<f1> a" . consult-apropos)
;; M-g bindings (goto-map) ;; M-g bindings (goto-map)
("M-g e" . consult-compile-error) ("M-g e" . consult-compile-error)
("M-g f" . consult-flymake) ; or consult-flycheck ("M-g f" . consult-flymake) ; or consult-flycheck
@ -1163,9 +1161,9 @@ They are completed by \"M-x TAB\" only in Tramp debug buffers."
(define-key isearch-mode-map (car binding) (cdr binding)))) (define-key isearch-mode-map (car binding) (cdr binding))))
(:+menu "b" #'consult-buffer (:+menu "b" #'consult-buffer
"f" #'find-file) "f" #'find-file)
(with-eval-after-load 'org-mode (:bind-into org
(define-key org-mode-map "M-g o" 'consult-org-heading)) "M-g o" #'consult-org-heading)
(advice-add 'consult-yank-pop :after '+yank@indent) (advice-add 'consult-yank-pop :after #'+yank@indent)
(:when-loaded (:when-loaded
(:option consult-narrow-key "<" (:option consult-narrow-key "<"
consult-project-root-function '+consult-project-root) consult-project-root-function '+consult-project-root)
@ -1211,8 +1209,6 @@ They are completed by \"M-x TAB\" only in Tramp debug buffers."
(setup (:straight consult-notmuch) (setup (:straight consult-notmuch)
(:load-after consult notmuch) (:load-after consult notmuch)
(with-eval-after-load 'consult
(add-to-list 'consult-buffer-sources 'consult-notmuch-buffer-source))
(with-eval-after-load 'vertico-multiform (with-eval-after-load 'vertico-multiform
(setf (alist-get 'consult-notmuch vertico-multiform-commands) '(buffer) (setf (alist-get 'consult-notmuch vertico-multiform-commands) '(buffer)
(alist-get 'consult-notmuch-tree vertico-multiform-commands) '(buffer)))) (alist-get 'consult-notmuch-tree vertico-multiform-commands) '(buffer))))
@ -1679,10 +1675,11 @@ See also `crux-reopen-as-root-mode'."
(file-exists-p i)) (file-exists-p i))
i)) i))
auth-sources) auth-sources)
mastodon-tl--enable-proportional-fonts t mastodon-tl--show-avatars t
mastodon-tl--show-avatars t) mastodon-tl--enable-proportional-fonts nil)
(:hook #'mastodon-async-mode (:hook #'mastodon-async-mode
#'reading-mode #'visual-fill-column-mode
#'variable-pitch-mode
#'hl-line-mode #'hl-line-mode
#'lin-mode)) #'lin-mode))
@ -1732,8 +1729,8 @@ See also `crux-reopen-as-root-mode'."
eshell-mode eshell-mode
vterm-mode vterm-mode
crossword-mode)) crossword-mode))
(:+key "C-a" #'+mwim-beginning-maybe (:global "C-a" #'+mwim-beginning-maybe
"C-e" #'+mwim-end-maybe)) "C-e" #'+mwim-end-maybe))
(setup (:straight notmuch-bookmarks) (setup (:straight notmuch-bookmarks)
(:load-after notmuch) (:load-after notmuch)
@ -2056,7 +2053,8 @@ See also `crux-reopen-as-root-mode'."
(append reading-modes) '(visual-fill-column-mode . +1)) (append reading-modes) '(visual-fill-column-mode . +1))
(:hook #'visual-line-mode) (:hook #'visual-line-mode)
(:hook-into org-mode) (:hook-into org-mode)
(advice-add #'text-scale-adjust :after #'visual-fill-column-adjust)) (advice-add #'text-scale-adjust :after #'visual-fill-column-adjust)
(:global [f12] #'visual-fill-column-mode))
(setup (:straight vlf) (setup (:straight vlf)
(:require vlf-setup)) (:require vlf-setup))