changelog shortlog graph tags branches changeset files revisions annotate raw help

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

changeset 19: ca703415cc62
parent: f82cb9ded8cf
child: e74bcdf93260
author: Richard Westhaver <ellis@rwest.io>
date: Tue, 21 May 2024 22:20:59 -0400
permissions: -rw-r--r--
description: add paredit.el
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 "lab")
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 (require 'paredit)
57 (add-hook 'common-lisp-mode-hook #'enable-paredit-mode)
58 (add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
59 
60 (repeat-mode)
61 
62 (defun remember-project ()
63  (interactive)
64  (project-remember-project (project-current))
65  project--list)
66 
67 (defun remember-lab-projects ()
68  (interactive)
69  (project-remember-projects-under user-lab-directory t))
70 
71 (keymap-global-set "C-<tab>" #'hippie-expand)
72 (keymap-set minibuffer-local-map "C-<tab>" #'hippie-expand)
73 (keymap-set ctl-x-x-map "p p" #'remember-project)
74 (keymap-set ctl-x-x-map "p l" #'remember-lab-projects)
75 
76 (add-hook 'prog-mode-hook #'skt-mode)
77 (add-hook 'org-mode-hook #'skt-mode)
78 (add-hook 'prog-mode-hook #'company-mode)
79 
80 (add-hook 'notmuch-message-mode-hook #'turn-on-orgtbl)
81 
82 (setopt skt-enable-tempo-elements t
83  skt-completing-read t
84  skt-delete-duplicate-marks t)
85 
86 (keymap-set skt-mode-map "C-c M-b" #'tempo-backward-mark)
87 (keymap-set skt-mode-map "C-c M-f" #'tempo-forward-mark)
88 (keymap-set skt-mode-map "C-c M-a" #'tempo-complete-tag)
89 
90 (use-package markdown-mode :ensure t)
91 
92 (use-package ol-notmuch :ensure t)
93 
94 (use-package notmuch
95  :ensure t
96  :init
97  (setopt
98  mail-user-agent 'message-user-agent
99  smtpmail-smtp-server "smtp.gmail.com"
100  message-send-mail-function 'message-smtpmail-send-it
101  smtpmail-debug-info t
102  message-default-mail-headers "Cc: \nBcc: \n"
103  message-kill-buffer-on-exit t
104  user-mail-address "ellis@rwest.io"
105  user-full-name "Richard Westhaver"
106  notmuch-hello-sections '(notmuch-hello-insert-saved-searches
107  notmuch-hello-insert-search
108  notmuch-hello-insert-recent-searches
109  notmuch-hello-insert-alltags)
110  notmuch-show-logo nil
111  notmuch-search-oldest-first nil
112  notmuch-hello-hide-tags '("kill")
113  notmuch-saved-searches '((:name "inbox" :query "tag:inbox" :key "i")
114  (:name "unread" :query "tag:unread" :key "u")
115  (:name "new" :query "tag:new" :key "n")
116  (:name "sent" :query "tag:sent" :key "e")
117  (:name "drafts" :query "tag:draft" :key "d")
118  (:name "all mail" :query "*" :key "a")
119  (:name "todo" :query "tag:todo" :key "t")))
120  :config
121  ;;;###autoload
122  (defun notmuch-exec-offlineimap ()
123  "execute offlineimap command and tag new mail with notmuch"
124  (interactive)
125  (start-process-shell-command "offlineimap"
126  "*offlineimap*"
127  "offlineimap -o")
128  (notmuch-refresh-all-buffers))
129 
130  (defun offlineimap-get-password (host port)
131  (let* ((netrc (netrc-parse (expand-file-name "~/.netrc.gpg")))
132  (hostentry (netrc-machine netrc host port port)))
133  (when hostentry (netrc-get hostentry "password"))))
134 
135  (defun mark-as-read ()
136  "mark message as read."
137  (interactive)
138  (notmuch-search-tag '("-new" "-unread" "-inbox")))
139 
140  (defun mark-as-todo ()
141  "mark message as todo."
142  (interactive)
143  (mark-as-read)
144  (notmuch-search-tag '("-new" "-unread" "-inbox" "+todo")))
145 
146  (defun mark-as-spam ()
147  "mark message as spam."
148  (interactive)
149  (mark-as-read)
150  (notmuch-search-tag (list "+spam")))
151 
152  (keymap-set user-map "e m" #'notmuch)
153  (keymap-set user-map "e M" #'notmuch-exec-offlineimap)
154  (keymap-set notmuch-search-mode-map "S" #'mark-as-spam)
155  (keymap-set notmuch-search-mode-map "R" #'mark-as-read)
156  (keymap-set notmuch-search-mode-map "T" #'mark-as-todo))
157 
158 (use-package elfeed
159  :ensure t
160  :custom
161  elfeed-feeds
162  '(("http://threesixty360.wordpress.com/feed/" blog math)
163  ("http://www.50ply.com/atom.xml" blog dev)
164  ("http://blog.cryptographyengineering.com/feeds/posts/default" blog)
165  ("http://abstrusegoose.com/feed.xml" comic)
166  ("http://accidental-art.tumblr.com/rss" image math)
167  ("http://researchcenter.paloaltonetworks.com/unit42/feed/" security)
168  ("http://curiousprogrammer.wordpress.com/feed/" blog dev)
169  ("http://feeds.feedburner.com/amazingsuperpowers" comic)
170  ("http://amitp.blogspot.com/feeds/posts/default" blog dev)
171  ("http://pages.cs.wisc.edu/~psilord/blog/rssfeed.rss" blog)
172  ("http://www.anticscomic.com/?feed=rss2" comic)
173  ("http://feeds.feedburner.com/blogspot/TPQSS" blog dev)
174  ("http://techchrunch.com/feeds" tech news)
175  ("https://rss.nytimes.com/services/xml/rss/nyt/Technology.xml" tech news)
176  ("https://static.fsf.org/fsforg/rss/news.xml" tech news)
177  ("https://feeds.npr.org/1001/rss.xml" news)
178  ("https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=10000664" fin news)
179  ("https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=19854910" tech news)
180  ("https://search.cnbc.com/rs/search/combinedcms/view.xml?partnerId=wrss01&id=100003114" us news)
181  ("http://arxiv.org/rss/cs" cs rnd)
182  ("http://arxiv.org/rss/math" math rnd)
183  ("http://arxiv.org/rss/q-fin" q-fin rnd)
184  ("http://arxiv.org/rss/stat" stat rnd)
185  ("http://arxiv.org/rss/econ" econ rnd)
186  ;; John Wiegley
187  ("http://newartisans.com/rss.xml" dev blog)
188  ;; comp
189  ;; ("https://lab.rwest.io/comp.atom?feed_token=pHu9qwLkjy4CWJHx9rrJ" comp vc)
190  ("https://www.reddit.com/r/listentothis/.rss" music reddit)
191  ("https://www.ftc.gov/feeds/press-release-consumer-protection.xml" gov ftc)
192  ("https://api2.fcc.gov/edocs/public/api/v1/rss/" gov fcc)
193  )
194  :init
195  (defun yt-dl-it (url)
196  "Downloads the URL in an async shell"
197  (let ((default-directory "~/media/yt"))
198  (async-shell-command (format "youtube-dl %s" url))))
199 
200  (defun elfeed-youtube-dl (&optional use-generic-p)
201  "Youtube-DL link"
202  (interactive "P")
203  (let ((entries (elfeed-search-selected)))
204  (cl-loop for entry in entries
205  do (elfeed-untag entry 'unread)
206  when (elfeed-entry-link entry)
207  do (yt-dl-it it))
208  (mapc #'elfeed-search-update-entry entries)
209  (unless (use-region-p) (forward-line))))
210  :config
211  (keymap-set elfeed-search-mode-map "d" 'elfeed-youtube-dl)
212  (keymap-set user-map "e f" #'elfeed)
213  (keymap-set user-map "e F" #'elfeed-update))
214 
215 (use-package org-mime :ensure t)
216 
217 (use-package sh-script
218  :hook (sh-mode . flymake-mode))
219 
220 (use-package tempo
221  :custom
222  tempo-interactive t
223  :config
224  (tempo-define-template
225  "org:readme"
226  '("#+TITLE: " p n>
227  "#+AUTHOR: " user-full-name " <" user-mail-address ">" n>)
228  "org:readme"
229  "Insert a readme.org file template.")
230  (tempo-define-template "org:src"
231  '("#+begin_src " p n>
232  "#+end_src" n>)
233  "org:src"))
234 ;;; Org Config
235 (keymap-set user-map "t" #'org-todo)
236 
237 ;; populate org-babel
238 (org-babel-do-load-languages
239  ;; TODO 2021-10-24: bqn, apl, k
240  'org-babel-load-languages '((shell . t)
241  (emacs-lisp . t)
242  (lisp . t)
243  (org . t)
244  (eshell . t)
245  (sed . t)
246  (awk . t)
247  (dot . t)
248  (js . t)
249  (C . t)
250  (python . t)
251  (lua . t)
252  (lilypond . t)))
253 ;;; IRC
254 (setq erc-format-nick-function 'erc-format-@nick)
255 
256 (defun start-erc ()
257  "Connect to IRC."
258  (interactive)
259  (erc-tls :server "irc.libera.chat" :port 6697
260  :client-certificate '("/mnt/y/data/private/krypt/libera.pem"))
261  (setq erc-autojoin-channels-alist '(("irc.libera.chat" "#emacs")
262  ("irc.libera.chat" "#linux")
263  ("irc.libera.chat" "#rust")
264  ("irc.libera.chat" "#btrfs")
265  ("irc.libera.chat" "#lisp")
266  ("irc.libera.chat" "#sbcl")
267  ("irc.oftc.net" "#llvm"))))
268 ;;; Tags
269 ;;;###autoload
270 (defun refresh-tags ()
271  "Refresh TAGS database in `user-emacs-directory'."
272  (interactive)
273  (let ((default-directory user-emacs-directory))
274  (async-shell-command
275  "etags ./*.el \\
276 ./lib/*.el \\
277 ~/comp/org/*.el \\
278 ~/comp/core/emacs/*.el \\
279 ~/comp/core/emacs/lib/*.el \\
280 -o TAGS")))
281 
282 (unless (string-equal "hyde" system-name)
283  (add-hook 'dired-mode-hook #'all-the-icons-dired-mode)
284  (add-hook 'ibuffer-mode-hook #'all-the-icons-ibuffer-mode))
285 
286 (provide 'ellis)
287 ;;; ellis.el ends here