about summary refs log tree commit diff stats
path: root/init.el
diff options
context:
space:
mode:
authorCase Duckworth2021-08-30 16:37:49 -0500
committerCase Duckworth2021-08-30 16:37:49 -0500
commit46d55405836a35e4a10a875307e1702d766bd704 (patch)
treeb21d51d6fab0c5598ae855a1c7b6c86943660a86 /init.el
parentBetterize typo-mode (diff)
parentDelete commented flyspell blocks (diff)
downloademacs-46d55405836a35e4a10a875307e1702d766bd704.tar.gz
emacs-46d55405836a35e4a10a875307e1702d766bd704.zip
Merge branch 'main' of tildegit.org:acdw/emacs
Diffstat (limited to 'init.el')
-rw-r--r--init.el250
1 files changed, 148 insertions, 102 deletions
diff --git a/init.el b/init.el index 856c9c5..1a54c79 100644 --- a/init.el +++ b/init.el
@@ -81,15 +81,31 @@
81 browse-url-firefox-new-window-is-tab t) 81 browse-url-firefox-new-window-is-tab t)
82 82
83 (acdw/browse-url-set-handlers 83 (acdw/browse-url-set-handlers
84 `(("\\.jpe?g\\'" . ,(if (executable-find "feh") 84 (list
85 #'browse-url-feh 85 (cons (rx (seq "." (or "jpeg" "jpg" ; images
86 #'eww-browse-url)) 86 "png")
87 ("youtube\\.com\\|youtu\\.be" . ,(if (executable-find "mpv") 87 eos))
88 #'browse-url-mpv 88 (lambda (&rest args)
89 #'eww-browse-url)) 89 (apply (if (executable-find "feh")
90 ("google\\.com" . browse-url-default-browser) 90 #'browse-url-feh
91 ("\\(twitter\\.com\\|t\\.co\\)" . acdw/eww-browse-twitter-url) 91 #'eww-browse-url)
92 ("." . eww-browse-url))) 92 args)))
93 (cons (rx (or "youtube.com" ; videos
94 "youtu.be"
95 (seq "." (or "mp4"
96 "gif")
97 eos)))
98 (lambda (&rest args)
99 (apply (if (executable-find "mpv")
100 #'browse-url-mpv
101 browse-url-secondary-browser-function)
102 args)))
103 (cons (rx (or "google.com" ; websites that don't work with eww
104 "reddit.com"
105 "twitter.com"))
106 browse-url-secondary-browser-function)
107 (cons "." ; everything else
108 #'eww-browse-url)))
93 109
94 ;; Buttonize gemini:// links. 110 ;; Buttonize gemini:// links.
95 (acdw/add-button-url-regexp-protocol "gemini")) 111 (acdw/add-button-url-regexp-protocol "gemini"))
@@ -153,8 +169,7 @@
153 ("Variables" "^\\(?:Show Value\\|Hide\\) \\([^:\n]*\\)" 1)))))) 169 ("Variables" "^\\(?:Show Value\\|Hide\\) \\([^:\n]*\\)" 1))))))
154 170
155(setup debugger 171(setup debugger
156 (:hook visual-line-mode) 172 (:hook visual-line-mode))
157 (:global "C-c d" toggle-debug-on-error))
158 173
159(setup dired 174(setup dired
160 (setq-default dired-recursive-copies 'always 175 (setq-default dired-recursive-copies 'always
@@ -323,6 +338,7 @@
323 338
324 (:option 339 (:option
325 erc-auto-discard-away t 340 erc-auto-discard-away t
341 erc-auto-set-away t
326 erc-autoaway-idle-seconds 600 342 erc-autoaway-idle-seconds 600
327 erc-autoaway-message "BRB (autoaway: %i seconds)" 343 erc-autoaway-message "BRB (autoaway: %i seconds)"
328 erc-button-url-regexp browse-url-button-regexp 344 erc-button-url-regexp browse-url-button-regexp
@@ -333,7 +349,7 @@
333 erc-fill-static-center 14 349 erc-fill-static-center 14
334 erc-format-nick-function #'erc-format-truncate-@nick 350 erc-format-nick-function #'erc-format-truncate-@nick
335 erc-header-line-face-method #'erc/update-header-line-show-disconnected 351 erc-header-line-face-method #'erc/update-header-line-show-disconnected
336 erc-hide-list '("NICK" "MODE" "JOIN" "PART" "QUIT") 352 erc-hide-list '("NICK" "MODE" "JOIN" "PART" "QUIT" "AWAY")
337 erc-interpret-controls-p t 353 erc-interpret-controls-p t
338 erc-interpret-mirc-color t 354 erc-interpret-mirc-color t
339 erc-join-buffer 'bury 355 erc-join-buffer 'bury
@@ -353,7 +369,9 @@
353 erc-server-coding-system '(utf-8 . utf-8) 369 erc-server-coding-system '(utf-8 . utf-8)
354 erc-timestamp-intangible t 370 erc-timestamp-intangible t
355 erc-track-exclude-types (append erc-hide-list 371 erc-track-exclude-types (append erc-hide-list
356 '("AWAY" 372 '("AWAY" ; for some reason this triggers
373 ; track anyway... so it's in
374 ; `erc-hide-list'
357 "353" "324" "329" "332" "333" "477")) 375 "353" "324" "329" "332" "333" "477"))
358 erc-track-exclude-server-buffer t 376 erc-track-exclude-server-buffer t
359 erc-track-position-in-mode-line 'before-modes 377 erc-track-position-in-mode-line 'before-modes
@@ -487,74 +505,6 @@ like a dumbass."
487 (define-key flyspell-mode-map 505 (define-key flyspell-mode-map
488 (kbd (car keybind)) (cdr keybind)))))) 506 (kbd (car keybind)) (cdr keybind))))))
489 507
490;; (setup flyspell
491;; ;; follow the directions here: https://old.reddit.com/r/emacs/comments/dgj0ae
492;; ;; in short:
493;; ;; - download hunspell from GitHub and put in ~/usr/bin
494;; ;; - download LibreOffice English dictionaries and put in
495;; ;; ~/usr/share/hunspell
496;; (setq-default
497;; flyspell-issue-message-flag nil
498;; ispell-program-name "hunspell"
499;; ispell-dictionary "default"
500;; ispell-personal-dictionary "~/.hunspell_personal"
501;; ispell-local-dictionary-alist '(("default"
502;; "[[:alpha:]]" "[^[:alpha:]]"
503;; "[']" nil
504;; ("-d" "en_US") nil utf-8)))
505
506;; (acdw/system
507;; (:work (let ((dicpath (expand-file-name "~/usr/share/hunspell/")))
508;; (setenv "DICPATH" dicpath))))
509
510;; ;; new variable `ispell-hunspell-dictionary-alist' is defined in Emacs
511;; ;; If it's nil, Emacs tries to automatically set up the dictionaries.
512;; (when (boundp 'ispell-hunspell-dictionary-alist)
513;; (setq ispell-hunspell-dictionary-alist ispell-local-dictionary-alist))
514
515;; (:needs ispell-program-name) ; don't proceed if not installed
516
517;; (unless (file-exists-p ispell-personal-dictionary)
518;; (write-region "" nil ispell-personal-dictionary nil 0))
519
520;; (when (executable-find ispell-program-name)
521;; (add-hook 'text-mode-hook #'flyspell-mode)
522;; (add-hook 'prog-mode-hook #'flyspell-prog-mode))
523
524;; (:when-loaded
525;; (setup (:straight flyspell-correct)
526;; (:with-map flyspell-mode-map
527;; (:bind "C-;" flyspell-correct-wrapper
528;; ;; Remove all other binds
529;; "C-," nil
530;; "C-." nil
531;; "C-M-i" nil)))))
532
533;; (setup flyspell
534;; (:option
535;; flyspell-issue-message-flag nil
536;; ispell-program-name "aspell"
537;; ispell-dictionary "en_US"
538;; ispell-personal-dictionary "~/.dictionary"
539;; ispell-extra-args '("--sug-mode=ultra" "--lang=en_US"))
540
541;; (:needs ispell-program-name)
542
543;; (unless (file-exists-p ispell-personal-dictionary)
544;; (write-region "" nil ispell-personal-dictionary nil 0))
545
546;; (add-hook 'text-mode-hook #'flyspell-mode)
547;; (add-hook 'prog-mode-hook #'flyspell-prog-mode)
548
549;; (:when-loaded
550;; (setup (:straight flyspell-correct)
551;; (:with-map flyspell-mode-map
552;; (:bind "C-;" flyspell-correct-wrapper
553;; ;; Remove other binds
554;; "C-," nil
555;; "C-." nil
556;; "C-M-i" nil)))))
557
558(setup frames 508(setup frames
559 (:option frame-title-format '("%b@" 509 (:option frame-title-format '("%b@"
560 (:eval 510 (:eval
@@ -609,11 +559,7 @@ like a dumbass."
609 (mode . gemini-mode) 559 (mode . gemini-mode)
610 (mode . eww-mode)))))) 560 (mode . eww-mode))))))
611 561
612 (global-set-key (kbd "C-x C-b") 562 (global-set-key (kbd "C-x C-b") #'ibuffer)
613 (defun list-buffers-or-ibuffer (arg)
614 "`list-buffers', or with a prefix arg, `ibuffer'."
615 (interactive "P")
616 (if arg (ibuffer) (electric-buffer-list nil))))
617 563
618 (add-hook 'ibuffer-mode-hook 564 (add-hook 'ibuffer-mode-hook
619 (defun ibuffer@filter-to-default () 565 (defun ibuffer@filter-to-default ()
@@ -1006,8 +952,7 @@ like a dumbass."
1006 kill-read-only-ok t 952 kill-read-only-ok t
1007 load-prefer-newer t 953 load-prefer-newer t
1008 native-comp-async-report-warnings-errors nil 954 native-comp-async-report-warnings-errors nil
1009 set-mark-command-repeat-pop t 955 set-mark-command-repeat-pop t)
1010 )
1011 956
1012 (when (fboundp 'command-completion-default-include-p) 957 (when (fboundp 'command-completion-default-include-p)
1013 (setq read-extended-command-predicate 958 (setq read-extended-command-predicate
@@ -1018,13 +963,24 @@ like a dumbass."
1018 "C-c c" capitalize-dwim 963 "C-c c" capitalize-dwim
1019 "C-c u" upcase-dwim 964 "C-c u" upcase-dwim
1020 "C-c l" downcase-dwim 965 "C-c l" downcase-dwim
1021 "C-c t" acdw/insert-iso-date) 966 "C-c d" acdw/insert-iso-date
967 "M-`" nil)
968
969 ;; toggle bindings
970 (defvar toggle-map (make-sparse-keymap)
971 "A keymap for toggling!")
972 (global-set-key (kbd "C-c t") toggle-map)
973
974 (:with-map toggle-map
975 (:bind "c" column-number-mode
976 "l" display-line-numbers-mode
977 "d" toggle-debug-on-error))
1022 978
1023 (defalias 'forward-word-with-case 'forward-word 979 (defalias 'forward-word-with-case 'forward-word
1024 "Alias for `forward-word' for use in `case-repeat-map'.") 980 "Alias for `forward-word' for use in `case-repeat-map'.")
1025 (defalias 'backward-word-with-case 'backward-word 981 (defalias 'backward-word-with-case 'backward-word
1026 "Alias for `backward-word for use in `case-repeat-map'.") 982 "Alias for `backward-word for use in `case-repeat-map'.")
1027 983
1028 (defvar case-repeat-map 984 (defvar case-repeat-map
1029 (let ((map (make-sparse-keymap))) 985 (let ((map (make-sparse-keymap)))
1030 (define-key map "c" #'capitalize-word) 986 (define-key map "c" #'capitalize-word)
@@ -1035,6 +991,7 @@ like a dumbass."
1035 (define-key map "b" #'backward-word-with-case) 991 (define-key map "b" #'backward-word-with-case)
1036 map) 992 map)
1037 "A map to repeat word-casing commands. For use with `repeat-mode'.") 993 "A map to repeat word-casing commands. For use with `repeat-mode'.")
994
1038 (dolist (command '(capitalize-word 995 (dolist (command '(capitalize-word
1039 capitalize-dwim 996 capitalize-dwim
1040 upcase-word 997 upcase-word
@@ -1092,10 +1049,17 @@ like a dumbass."
1092 (define-key gnus-article-mode-map key #'ace-link-gnus)) 1049 (define-key gnus-article-mode-map key #'ace-link-gnus))
1093 (with-eval-after-load 'ert 1050 (with-eval-after-load 'ert
1094 (define-key ert-results-mode-map "o" #'ace-link-help)) 1051 (define-key ert-results-mode-map "o" #'ace-link-help))
1052 (with-eval-after-load 'mastodon
1053 (define-key mastodon-mode-map "o" #'ace-link-addr))
1095 ;; And still everything else 1054 ;; And still everything else
1096 (setq ace-link-fallback-function #'ace-link-addr) 1055 (setq ace-link-fallback-function #'ace-link-addr)
1097 (global-set-key key #'ace-link))) 1056 (global-set-key key #'ace-link)))
1098 1057
1058(setup (:straight alert)
1059 (:option alert-default-style (acdw/system
1060 (:home 'libnotify)
1061 (_ 'message))))
1062
1099(setup (:straight avy) 1063(setup (:straight avy)
1100 (:global "C-'" avy-goto-char-timer 1064 (:global "C-'" avy-goto-char-timer
1101 "M-g f" avy-goto-line 1065 "M-g f" avy-goto-line
@@ -1108,6 +1072,74 @@ like a dumbass."
1108(setup (:straight (beginend)) 1072(setup (:straight (beginend))
1109 (beginend-global-mode +1)) 1073 (beginend-global-mode +1))
1110 1074
1075(setup (:straight circe)
1076 (require 'circe)
1077 (require 'acdw-irc)
1078
1079 (setq acdw-irc/post-my-nick "-> ")
1080
1081 (setq circe-default-part-message "See You, Space Cowpokes . . ."
1082 circe-highlight-nick-type 'all
1083 ;; circe-network-options in private.el
1084 circe-reduce-lurker-spam t
1085 circe-server-auto-join-default-type :after-auth)
1086
1087 (add-hook 'circe-chat-mode-hook
1088 (defun circe-chat@setup ()
1089 (lui-set-prompt
1090 (concat (propertize (acdw-irc/margin-format (buffer-name)
1091 ""
1092 ">")
1093 'face 'circe-prompt-face
1094 'read-only t 'intangible t
1095 'cursor-intangible t)
1096 " "))
1097 (enable-circe-color-nicks)
1098 (enable-circe-display-images)
1099 (enable-circe-new-day-notifier)))
1100
1101 (let ((len (number-to-string (- acdw-irc/left-margin 1
1102 (+ (length acdw-irc/pre-nick)
1103 (length acdw-irc/post-nick)))))
1104 (my-len (number-to-string (- acdw-irc/left-margin 1
1105 (+ (length acdw-irc/pre-my-nick)
1106 (length acdw-irc/post-my-nick))))))
1107 (setq circe-format-say (concat acdw-irc/pre-nick
1108 "{nick:" len "." len "s} "
1109 acdw-irc/post-nick
1110 "{body}")
1111 circe-format-self-say (concat acdw-irc/pre-my-nick
1112 "{nick:" my-len "." my-len "s} "
1113 acdw-irc/post-my-nick
1114 "{body}")
1115 circe-format-action (concat "*"
1116 (repeat-string
1117 (- acdw-irc/left-margin 3)
1118 " ")
1119 "* {nick} {body}")
1120 circe-format-self-action (concat "-*"
1121 (repeat-string
1122 (- acdw-irc/left-margin 4)
1123 " ")
1124 "* {nick} {body}")
1125 lui-fill-type (concat
1126 (repeat-string (- acdw-irc/left-margin 2)
1127 " ")
1128 " ")))
1129
1130 (setq lui-time-stamp-position 'right-margin
1131 lui-time-stamp-format "%H:%M")
1132 (add-hook 'lui-mode-hook
1133 (defun lui-mode@setup ()
1134 (setq-local fringes-outside-margins t
1135 lui-track-bar-behavior 'before-switch-to-buffer
1136 right-margin-width 5
1137 scroll-margin 0
1138 word-wrap t
1139 wrap-prefix (repeat-string
1140 (1+ acdw-irc/left-margin) " "))
1141 (enable-lui-track-bar))))
1142
1111(setup (:straight (consult 1143(setup (:straight (consult
1112 :host github 1144 :host github
1113 :repo "minad/consult")) 1145 :repo "minad/consult"))
@@ -1263,7 +1295,10 @@ like a dumbass."
1263 (when (and (daemonp) 1295 (when (and (daemonp)
1264 (require 'edit-server nil :noerror)) 1296 (require 'edit-server nil :noerror))
1265 (edit-server-start) 1297 (edit-server-start)
1266 (add-hook 'edit-server-done-hook #'unfill-buffer))) 1298
1299 (advice-add 'edit-server-make-frame :before
1300 (defun edit-server@set-a-variable (&rest _)
1301 (setq edit-server-frame-p t)))))
1267 1302
1268(setup (:straight (electric-cursor 1303(setup (:straight (electric-cursor
1269 :host github 1304 :host github
@@ -1420,7 +1455,7 @@ successive invocations."
1420 1455
1421(setup (:straight helpful) 1456(setup (:straight helpful)
1422 (:option helpful-max-buffers 5 1457 (:option helpful-max-buffers 5
1423 helpful-switch-buffer-function #'pop-to-buffer 1458 ;; helpful-switch-buffer-function #'pop-to-buffer
1424 ;; helpful-switch-buffer-function 1459 ;; helpful-switch-buffer-function
1425 ;; (lambda (buf) 1460 ;; (lambda (buf)
1426 ;; (pop-to-buffer buf 1461 ;; (pop-to-buffer buf
@@ -1434,13 +1469,14 @@ successive invocations."
1434 "<help> k" helpful-key 1469 "<help> k" helpful-key
1435 "<help> o" helpful-symbol 1470 "<help> o" helpful-symbol
1436 "C-c C-d" helpful-at-point) 1471 "C-c C-d" helpful-at-point)
1437 (with-eval-after-load 'helpful 1472 ;; (with-eval-after-load 'helpful
1438 (define-key helpful-mode-map "q" 1473 ;; (define-key helpful-mode-map "q"
1439 (defun helpful-mode|quit () 1474 ;; (defun helpful-mode|quit ()
1440 (interactive) 1475 ;; (interactive)
1441 (bury-buffer) 1476 ;; (bury-buffer)
1442 (unless (window-parameter (frame-selected-window) 'no-other-window) 1477 ;; (unless (window-parameter (frame-selected-window) 'no-other-window)
1443 (delete-window)))))) 1478 ;; (delete-window)))))
1479 )
1444 1480
1445(setup (:straight iscroll) 1481(setup (:straight iscroll)
1446 (:hook-into text-mode)) 1482 (:hook-into text-mode))
@@ -1476,7 +1512,9 @@ successive invocations."
1476 (:straight request) 1512 (:straight request)
1477 (:option mastodon-instance-url "https://writing.exchange" 1513 (:option mastodon-instance-url "https://writing.exchange"
1478 mastodon-auth-source-file (car auth-sources) 1514 mastodon-auth-source-file (car auth-sources)
1479 mastodon-client--token-file (acdw/dir "mastodon.plstore"))) 1515 mastodon-client--token-file (acdw/dir "mastodon.plstore"))
1516 (:hook hl-line-mode
1517 olivetti-mode))
1480 1518
1481(setup (:straight (modus-themes 1519(setup (:straight (modus-themes
1482 :host gitlab 1520 :host gitlab
@@ -1492,6 +1530,8 @@ successive invocations."
1492 (acdw/sunrise-sunset #'modus-themes-load-operandi 1530 (acdw/sunrise-sunset #'modus-themes-load-operandi
1493 #'modus-themes-load-vivendi)) 1531 #'modus-themes-load-vivendi))
1494 1532
1533(setup (:straight markdown-mode))
1534
1495(setup (:straight mwim) 1535(setup (:straight mwim)
1496 (:global "C-a" mwim-beginning 1536 (:global "C-a" mwim-beginning
1497 "C-e" mwim-end)) 1537 "C-e" mwim-end))
@@ -1673,6 +1713,11 @@ successive invocations."
1673 (dolist (mode lispy-modes) 1713 (dolist (mode lispy-modes)
1674 (add-hook (intern (concat (symbol-name mode) "-hook")) #'paren-face-mode))) 1714 (add-hook (intern (concat (symbol-name mode) "-hook")) #'paren-face-mode)))
1675 1715
1716(setup (:straight persistent-scratch)
1717 (:option persistent-scratch-backup-directory (acdw/dir "scratch" t)
1718 persistent-scratch-keep-n-newest-backups 12))
1719(persistent-scratch-setup-default))
1720
1676(setup (:straight restart-emacs) 1721(setup (:straight restart-emacs)
1677 (defun emacs-upgrade (&optional update-packages) 1722 (defun emacs-upgrade (&optional update-packages)
1678 "Pull config, upgrade packages, restart Emacs." 1723 "Pull config, upgrade packages, restart Emacs."
@@ -1695,11 +1740,12 @@ successive invocations."
1695 acdw-modeline/wc 1740 acdw-modeline/wc
1696 acdw-modeline/text-scale 1741 acdw-modeline/text-scale
1697 simple-modeline-segment-process 1742 simple-modeline-segment-process
1743 acdw-modeline/track
1698 acdw-modeline/god-mode-indicator 1744 acdw-modeline/god-mode-indicator
1699 acdw-modeline/winum 1745 acdw-modeline/winum
1700 acdw-modeline/minions 1746 acdw-modeline/minions
1701 acdw-modeline/narrowed 1747 acdw-modeline/narrowed
1702 simple-modeline-segment-major-mode))) 1748 acdw-modeline/major-mode)))
1703 1749
1704 ;; I've put in a pull request to add the (- 0 right-margin) bit here. 1750 ;; I've put in a pull request to add the (- 0 right-margin) bit here.
1705 (advice-add 'simple-modeline--format :override 1751 (advice-add 'simple-modeline--format :override
@@ -1947,7 +1993,7 @@ call `zzz-to-char'."
1947 1993
1948 (add-hook 'after-make-frame-functions 1994 (add-hook 'after-make-frame-functions
1949 (defun after-make-frame@maximize (frame) 1995 (defun after-make-frame@maximize (frame)
1950 (unless (or edit-server-edit-mode) 1996 (unless (bound-and-true-p edit-server-frame-p)
1951 (toggle-frame-maximized frame))))) 1997 (toggle-frame-maximized frame)))))
1952 1998
1953;;;; Work 1999;;;; Work