blob: 39cd23150fb8c6d43095e6344d858ae8dcba3611 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
;; -*- lexical-binding: t; -*-
;;;; packages
(require 'package)
(add-to-list 'load-path (expand-file-name "~/.guix-profile/share/emacs/site-lisp"))
(guix-emacs-autoload-packages)
(require 'use-package-ensure)
(setopt use-package-always-ensure t)
;; (setq use-package-verbose t) ; for debugging
(setenv "PATH" (format "%s:%s" (expand-file-name "~/Personal/scripts/") (getenv "PATH")))
;;;; functions
(defun cleanup-buffer ()
(interactive)
(delete-trailing-whitespace)
(untabify (point-min) (point-max))
(indent-region (point-min) (point-max)))
(defun clamp (lower-bound upper-bound value)
(max lower-bound (min value upper-bound)))
(defun request-sudo ()
"Uses TRAMP to edit currently opened file as root."
(interactive)
(when buffer-file-name
(find-alternate-file
(concat "/sudo:root@localhost:"
buffer-file-name))))
(defun rip-video (url &rest _)
"Given a url, rip and play the video
with yt-dlp and mpv."
(message "Ludu %s" url)
(start-process-shell-command "rip-video" nil (concat "rip-video " url)))
(defun parse-and-rip-video ()
"If region, open SEARCH with mpv in --full-screen. Else,
open URL at point."
(interactive)
(let ((URL-OR-SEARCH
(if (use-region-p)
(buffer-substring (mark) (point))
(shr-url-at-point nil))))
(rip-video URL)))
;;;; defaults
(global-unset-key (kbd "C-z"))
(global-unset-key (kbd "C-x C-z")) ; terrible binding
(global-set-key (kbd "C-z =") 'text-scale-increase)
(global-set-key (kbd "C-z -") 'text-scale-decrease)
(setopt inhibit-startup-message t)
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(require 'display-line-numbers)
(global-display-line-numbers-mode)
(global-visual-line-mode t)
(setopt display-line-numbers-type 'relative)
(global-hl-line-mode 1)
(global-auto-revert-mode 1)
(winner-mode 1)
;; messy editing + cleanup buffers on save
(setopt next-line-add-newlines t)
(add-hook 'before-save-hook 'cleanup-buffer)
;; prompts
(setopt use-short-answers t)
(setopt vc-follow-symlinks t)
(setopt kill-whole-line t)
;; recursive minibuffers
(setopt enable-recursive-minibuffers t)
(minibuffer-depth-indicate-mode 1)
;; allow one side window per side of frame
(setopt window-sides-slots '(1 1 1 1))
;; dictionary
(keymap-global-set "C-c i" 'dictionary-lookup-definition)
(setopt dictionary-server "localhost"
dictionary-use-single-buffer t)
;; do not show async command buffers by default
(add-to-list 'display-buffer-alist
(cons "\\*Async Shell Command\\*.*" (cons #'display-buffer-no-window nil)))
(setopt scroll-up-aggressively '0.0
scroll-down-aggressively '0.0)
;; move backups to tmp folder
(setopt backup-directory-alist `(("." . ,(expand-file-name "tmp/backups/" user-emacs-directory))))
(make-directory (expand-file-name "tmp/auto_saves/" user-emacs-directory) t)
;; move auto-saves to tmp folder
(setopt auto-save-list-file-prefix (expand-file-name "tmp/auto_saves/sessions/" user-emacs-directory)
auto-save-file-transforms `((".*" ,(expand-file-name "tmp/auto_saves/" user-emacs-directory) t)))
;;;; built-in packages
(use-package newsticker
:demand t
:bind (("C-z C-n" . newsticker-show-news)
:map newsticker-treeview-item-mode-map
("C-j" . parse-and-rip-video))
:custom
(newsticker-url-list-defaults nil)
(newsticker-automatically-mark-items-as-old nil)
(newsticker-url-list '(("Ambrose and Elsewhere" "https://jamesenge.com/engeblog/feed" nil nil nil)
("James Enge Mastodon" "https://mastodon.sdf.org/@jamesenge.rss" nil nil nil)
("Tales From the Magician's Skull" "https://goodman-games.com/tftms/category/book-reviews/feed" nil nil nil)
("Parabola GNU/Linux-libre" "https://www.parabola.nu/feeds/news/" nil nil nil)
("suckless.org news" "https://suckless.org/atom.xml" nil nil nil)
("Mental Outlaw" "https://vid.puffyan.us/feed/channel/UC7YOGHUfC1Tb6E4pudI9STA" nil nil nil)
("Luke Smith" "https://vid.puffyan.us/feed/channel/UC2eYFnH61tmytImy1mTYvhA" nil nil nil)
("Brent Westbrook" "https://yewtu.be/feed/channel/UC0PBefyEK7qQ7HN325nUamQ" nil nil nil)
("Bugswriter" "https://yewtu.be/feed/channel/UCngn7SVujlvskHRvRKc1cTw" nil nil nil)
("Protesilaos Stravrou" "https://yewtu.be/feed/playlist/PL8Bwba5vnQK14z96Gil86pLMDO2GnOhQ6" nil nil nil)))
;; may require ./newsticker/groups to be cleared
(newsticker-groups '("Feeds"
("READING" "James Enge Mastodon" "Tales From the Magician's Skull" "Ambrose and Elsewhere")
("TECH" "Parabola GNU/Linux-libre" "suckless.org news")
("VIDEO" "Mental Outlaw" "Luke Smith" "Brent Westbrook" "Bugswriter" "Protesilaos Stravrou"))))
(use-package eww
:demand t
:custom
;; default to eww
(browse-url-browser-function 'eww-browse-url)
(shr-use-fonts nil)
(shr-cookie-policy nil)
(shr-max-width 85)
(url-privacy-level '(email os emacs lastloc cookies))
(eww-search-prefix "https://searx.be/search?q=")
(eww-auto-rename-buffer 'title)
(eww-use-browse-url (regexp-opt '("mailto:" "youtube.com" "youtu.be" "yewtu.be")))
(browse-url-handlers
`((,(regexp-opt '("youtube.com" "youtu.be" "yewtu.be")) . rip-video))))
(use-package image-dired
:bind (("C-c d" . dired-jump))
:custom
(dired-listing-switches "-alh")
(dired-guess-shell-alist-user
`((,(regexp-opt '(".mkv" ".mov" ".mp4" ".webm" ".m4v" ".wav" ".mp3" ".opus" ".ogv" ".flac")) "mpv &")
(,(regexp-opt '(".pdf")) "zathura &")
(,(regexp-opt '(".html")) "icecat &"))))
(use-package erc
:config
(defalias 'erc 'erc-tls)
:custom
(erc-lurker-threshold-time 3600)
(erc-server "irc.libera.chat")
(erc-nick "Isaz")
(erc-kill-buffer-on-part t)
(erc-autojoin-channels-alist '(("irc.libera.chat" "#parabola" "#emacs" "#guix"))))
|