changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > infra > home / .emacs.d/ellis.el

changeset 3: f82cb9ded8cf
parent: ellis.el@2cd49f7c09bb
child: ca703415cc62
author: Richard Westhaver <ellis@rwest.io>
date: Wed, 01 May 2024 19:00:03 -0400
permissions: -rw-r--r--
description: import
1 ;;; ellis.el --- Richard's custom-file -*- lexical-binding: t; -*-
2 
3 ;; Copyright (C) 2023
4 
5 ;; Author: Richard Westhaver <ellis@rwest.io>
6 
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
11 
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16 
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
19 
20 ;;; Commentary:
21 
22 ;; This is an example of what you may want to add to your custom
23 ;; config file. Feel free to rip.
24 
25 ;;; Code:
26 (require 'inbox)
27 (require 'sk)
28 (require 'slime-cape)
29 (require 'sxp)
30 (require 'ulang)
31 
32 (defalias 'make #'compile)
33 
34 (setopt default-theme 'modus-vivendi-tritanopia
35  user-lab-directory (join-paths user-home-directory "dev")
36  company-source-directory (join-paths user-lab-directory "comp"))
37 
38 (unless (display-graphic-p) (setq default-theme 'wheatgrass))
39 
40 (when (linux-p) (setq dired-listing-switches "-alsh"))
41 
42 (defvar emacs-config-source (join-paths company-source-directory "core/emacs"))
43 
44 ;;;###autoload
45 (defun edit-emacs-config (&optional src)
46  (interactive (list current-prefix-arg))
47  (let ((file (if src
48  (expand-file-name "default.el" emacs-config-source)
49  user-custom-file)))
50  (find-file file)))
51 
52 (keymap-set user-map "e c" #'edit-emacs-config)
53 (keymap-set emacs-lisp-mode-map "C-c C-l" #'load-file)
54 (keymap-set emacs-lisp-mode-map "C-c M-k" #'elisp-byte-compile-file)
55 
56 ;; (add-hook 'common-lisp-mode-hook #'enable-paredit-mode)
57 ;; (add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
58 
59 (repeat-mode)
60 
61 (defun remember-project ()
62  (interactive)
63  (project-remember-project (project-current))
64  project--list)
65 
66 (defun remember-lab-projects ()
67  (interactive)
68  (project-remember-projects-under user-lab-directory t))
69 
70 (keymap-global-set "C-<tab>" #'hippie-expand)
71 (keymap-set minibuffer-local-map "C-<tab>" #'hippie-expand)
72 (keymap-set ctl-x-x-map "p p" #'remember-project)
73 (keymap-set ctl-x-x-map "p l" #'remember-lab-projects)
74 
75 (add-hook 'prog-mode-hook #'skt-mode)
76 (add-hook 'org-mode-hook #'skt-mode)
77 (add-hook 'prog-mode-hook #'company-mode)
78 
79 (add-hook 'notmuch-message-mode-hook #'turn-on-orgtbl)
80 
81 (setopt skt-enable-tempo-elements t
82  skt-completing-read t
83  skt-delete-duplicate-marks t)
84 
85 (keymap-set skt-mode-map "C-c M-b" #'tempo-backward-mark)
86 (keymap-set skt-mode-map "C-c M-f" #'tempo-forward-mark)
87 (keymap-set skt-mode-map "C-c M-a" #'tempo-complete-tag)
88 
89 (use-package markdown-mode :ensure t)
90 
91 (use-package ol-notmuch :ensure t)
92 
93 (use-package notmuch
94  :ensure t
95  :init
96  (setopt
97  mail-user-agent 'message-user-agent
98  smtpmail-smtp-server "smtp.gmail.com"
99  message-send-mail-function 'message-smtpmail-send-it
100  smtpmail-debug-info t
101  message-default-mail-headers "Cc: \nBcc: \n"
102  message-kill-buffer-on-exit t
103  user-mail-address "ellis@rwest.io"
104  user-full-name "Richard Westhaver"
105  notmuch-hello-sections '(notmuch-hello-insert-saved-searches
106  notmuch-hello-insert-search
107  notmuch-hello-insert-recent-searches
108  notmuch-hello-insert-alltags)
109  notmuch-show-logo nil
110  notmuch-search-oldest-first nil
111  notmuch-hello-hide-tags '("kill")
112  notmuch-saved-searches '((:name "inbox" :query "tag:inbox" :key "i")
113  (:name "unread" :query "tag:unread" :key "u")
114  (:name "new" :query "tag:new" :key "n")
115  (:name "sent" :query "tag:sent" :key "e")
116  (:name "drafts" :query "tag:draft" :key "d")
117  (:name "all mail" :query "*" :key "a")
118  (:name "todo" :query "tag:todo" :key "t")))
119  :config
120  ;;;###autoload
121  (defun notmuch-exec-offlineimap ()
122  "execute offlineimap command and tag new mail with notmuch"
123  (interactive)
124  (start-process-shell-command "offlineimap"
125  "*offlineimap*"
126  "offlineimap -o")
127  (notmuch-refresh-all-buffers))
128 
129  (defun offlineimap-get-password (host port)
130  (let* ((netrc (netrc-parse (expand-file-name "~/.netrc.gpg")))
131  (hostentry (netrc-machine netrc host port port)))
132  (when hostentry (netrc-get hostentry "password"))))
133 
134  (defun mark-as-read ()
135  "mark message as read."
136  (interactive)
137  (notmuch-search-tag '("-new" "-unread" "-inbox")))
138 
139  (defun mark-as-todo ()
140  "mark message as todo."
141  (interactive)
142  (mark-as-read)
143  (notmuch-search-tag '("-new" "-unread" "-inbox" "+todo")))
144 
145  (defun mark-as-spam ()
146  "mark message as spam."
147  (interactive)
148  (mark-as-read)
149  (notmuch-search-tag (list "+spam")))
150 
151  (keymap-set user-map "e m" #'notmuch)
152  (keymap-set user-map "e M" #'notmuch-exec-offlineimap)
153  (keymap-set notmuch-search-mode-map "S" #'mark-as-spam)
154  (keymap-set notmuch-search-mode-map "R" #'mark-as-read)
155  (keymap-set notmuch-search-mode-map "T" #'mark-as-todo))
156 
157 (use-package elfeed
158  :ensure t
159  :custom
160  elfeed-feeds
161  '(("http://threesixty360.wordpress.com/feed/" blog math)
162  ("http://www.50ply.com/atom.xml" blog dev)
163  ("http://blog.cryptographyengineering.com/feeds/posts/default" blog)
164  ("http://abstrusegoose.com/feed.xml" comic)
165  ("http://accidental-art.tumblr.com/rss" image math)
166  ("http://researchcenter.paloaltonetworks.com/unit42/feed/" security)
167  ("http://curiousprogrammer.wordpress.com/feed/" blog dev)
168  ("http://feeds.feedburner.com/amazingsuperpowers" comic)
169  ("http://amitp.blogspot.com/feeds/posts/default" blog dev)
170  ("http://pages.cs.wisc.edu/~psilord/blog/rssfeed.rss" blog)
171  ("http://www.anticscomic.com/?feed=rss2" comic)
172  ("http://feeds.feedburner.com/blogspot/TPQSS" blog dev)
173  ("http://techchrunch.com/feeds" tech news)
174  ("https://rss.nytimes.com/services/xml/rss/nyt/Technology.xml" tech news)
175  ("https://static.fsf.org/fsforg/rss/news.xml" tech news)
176  ("https://feeds.npr.org/1001/rss.xml" news)
177  ("https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=10000664" fin news)
178  ("https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=19854910" tech news)
179  ("https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=100003114" us news)
180  ("http://arxiv.org/rss/cs" cs rnd)
181  ("http://arxiv.org/rss/math" math rnd)
182  ("http://arxiv.org/rss/q-fin" q-fin rnd)
183  ("http://arxiv.org/rss/stat" stat rnd)
184  ("http://arxiv.org/rss/econ" econ rnd)
185  ;; John Wiegley
186  ("http://newartisans.com/rss.xml" dev blog)
187  ;; comp
188  ;; ("https://lab.rwest.io/comp.atom?feed_token=pHu9qwLkjy4CWJHx9rrJ" comp vc)
189  ("https://www.reddit.com/r/listentothis/.rss" music reddit)
190  ("https://www.ftc.gov/feeds/press-release-consumer-protection.xml" gov ftc)
191  ("https://api2.fcc.gov/edocs/public/api/v1/rss/" gov fcc)
192  )
193  :init
194  (defun yt-dl-it (url)
195  "Downloads the URL in an async shell"
196  (let ((default-directory "~/media/yt"))
197  (async-shell-command (format "youtube-dl %s" url))))
198 
199  (defun elfeed-youtube-dl (&optional use-generic-p)
200  "Youtube-DL link"
201  (interactive "P")
202  (let ((entries (elfeed-search-selected)))
203  (cl-loop for entry in entries
204  do (elfeed-untag entry 'unread)
205  when (elfeed-entry-link entry)
206  do (yt-dl-it it))
207  (mapc #'elfeed-search-update-entry entries)
208  (unless (use-region-p) (forward-line))))
209  :config
210  (keymap-set elfeed-search-mode-map "d" 'elfeed-youtube-dl)
211  (keymap-set user-map "e f" #'elfeed)
212  (keymap-set user-map "e F" #'elfeed-update))
213 
214 (use-package org-mime :ensure t)
215 
216 (use-package sh-script
217  :hook (sh-mode . flymake-mode))
218 
219 (use-package tempo
220  :custom
221  tempo-interactive t
222  :config
223  (tempo-define-template
224  "org:readme"
225  '("#+TITLE: " p n>
226  "#+AUTHOR: " user-full-name " <" user-mail-address ">" n>)
227  "org:readme"
228  "Insert a readme.org file template.")
229  (tempo-define-template "org:src"
230  '("#+begin_src " p n>
231  "#+end_src" n>)
232  "org:src"))
233 ;;; Org Config
234 (keymap-set user-map "t" #'org-todo)
235 
236 ;; populate org-babel
237 (org-babel-do-load-languages
238  ;; TODO 2021-10-24: bqn, apl, k
239  'org-babel-load-languages '((shell . t)
240  (emacs-lisp . t)
241  (lisp . t)
242  (org . t)
243  (eshell . t)
244  (sed . t)
245  (awk . t)
246  (dot . t)
247  (js . t)
248  (C . t)
249  (python . t)
250  (lua . t)
251  (lilypond . t)))
252 ;;; IRC
253 (setq erc-format-nick-function 'erc-format-@nick)
254 
255 (defun start-erc ()
256  "Connect to IRC."
257  (interactive)
258  (erc-tls :server "irc.libera.chat" :port 6697
259  :client-certificate '("/mnt/y/data/private/krypt/libera.pem"))
260  (setq erc-autojoin-channels-alist '(("irc.libera.chat" "#emacs")
261  ("irc.libera.chat" "#linux")
262  ("irc.libera.chat" "#rust")
263  ("irc.libera.chat" "#btrfs")
264  ("irc.libera.chat" "#lisp")
265  ("irc.libera.chat" "#sbcl")
266  ("irc.oftc.net" "#llvm"))))
267 ;;; Tags
268 ;;;###autoload
269 (defun refresh-tags ()
270  "Refresh TAGS database in `user-emacs-directory'."
271  (interactive)
272  (let ((default-directory user-emacs-directory))
273  (async-shell-command
274  "etags ./*.el \\
275 ./lib/*.el \\
276 ~/dev/comp/org/*.el \\
277 ~/dev/comp/core/emacs/*.el \\
278 ~/dev/comp/core/emacs/lib/*.el \\
279 -o TAGS")))
280 
281 (unless (string-equal "hyde" system-name)
282  (add-hook 'dired-mode-hook #'all-the-icons-dired-mode)
283  (add-hook 'ibuffer-mode-hook #'all-the-icons-ibuffer-mode))
284 
285 (provide 'ellis)
286 ;;; ellis.el ends here