summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-01-18 17:18:06 -0600
committerCase Duckworth2022-01-18 17:18:06 -0600
commitefc08126f7119569112b336f0cd73eefdf9737b5 (patch)
tree5356cbf6626cb72f7f0c69dbbf4fa35ee6955fc6 /lisp
parentModify org-file-apps after loading org (diff)
downloademacs-efc08126f7119569112b336f0cd73eefdf9737b5.tar.gz
emacs-efc08126f7119569112b336f0cd73eefdf9737b5.zip
Um
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+elfeed.el75
-rw-r--r--lisp/+eshell.el8
-rw-r--r--lisp/+org.el8
-rw-r--r--lisp/+straight.el41
-rw-r--r--lisp/+tab-bar.el55
-rw-r--r--lisp/acdw.el24
-rw-r--r--lisp/fibs.el37
7 files changed, 210 insertions, 38 deletions
diff --git a/lisp/+elfeed.el b/lisp/+elfeed.el index 9e5f787..ef93347 100644 --- a/lisp/+elfeed.el +++ b/lisp/+elfeed.el
@@ -2,8 +2,6 @@
2 2
3;;; Code: 3;;; Code:
4 4
5(require 'elfeed)
6
7;; https://karthinks.com/software/lazy-elfeed/ 5;; https://karthinks.com/software/lazy-elfeed/
8(defun +elfeed-scroll-up-command (&optional arg) 6(defun +elfeed-scroll-up-command (&optional arg)
9 "Scroll up or go to next feed item in Elfeed" 7 "Scroll up or go to next feed item in Elfeed"
@@ -31,5 +29,78 @@
31 (interactive) 29 (interactive)
32 (elfeed-show-visit t)) 30 (elfeed-show-visit t))
33 31
32;;; Fetch feeds async
33;; https://github.com/skeeto/elfeed/issues/367
34
35(defun +elfeed--update-message ()
36 (message "[Elfeed] Update in progress")
37 'ignore)
38
39(defvar +elfeed--update-running nil "Whether an update is currently running.")
40
41(defun +elfeed-update-command ()
42 (interactive)
43 (let ((script (expand-file-name "~/.local/bin/elfeed")))
44 (message "[Elfeed] Updating in the background.")
45 (setq +elfeed--update-running t)
46 (elfeed-db-save)
47 (advice-add 'elfeed :override #'+elfeed--update-message)
48 (ignore-errors (kill-buffer "*elfeed-search*"))
49 (ignore-errors (kill-buffer "*elfeed-log*"))
50 (elfeed-db-unload)
51 (unless (file-exists-p script)
52 (make-directory (file-name-directory script) :parents)
53 (with-temp-buffer
54 (insert "(progn\n"
55 " (load (locate-user-emacs-file \"early-init\"))\n"
56 " (straight-use-package 'elfeed)\n"
57 " (require 'elfeed)\n"
58 " (elfeed)\n"
59 " (elfeed-update)\n"
60 " (while (> (elfeed-queue-count-total) 0)\n"
61 " (sleep-for 5)\n"
62 " (message \"%s\" (elfeed-queue-count-total))\n"
63 " (accept-process-output))\n"
64 " (elfeed-db-save-safe)\n"
65 " (elfeed-db-gc-safe))")
66 (write-file script)))
67 (set-process-sentinel (start-process-shell-command
68 "Elfeed" nil (concat "emacs --script " script))
69 (lambda (a b)
70 (advice-remove 'elfeed #'+elfeed--update-message)
71 (setq +elfeed--update-running nil)
72 (message "[Elfeed] Background update %s."
73 (string-trim b))))))
74
75(defvar +elfeed--update-timer nil "Timer for `elfeed-update-command'.")
76(defvar +elfeed--update-first-time 6 "How long to wait for the first time.")
77(defvar +elfeed--update-repeat (* 60 15) "How long between updates.")
78
79(defun +elfeed--cancel-update-timer ()
80 "Cancel `+elfeed--update-timer'."
81 (unless +elfeed--update-running
82 (ignore-errors (cancel-timer +elfeed--update-timer))
83 (setq +elfeed--update-timer nil)))
84
85(defun +elfeed--reinstate-update-timer ()
86 "Reinstate `+elfeed--update-timer'."
87 (setq +elfeed--update-timer
88 (run-at-time +elfeed--update-first-time
89 +elfeed--update-repeat
90 #'+elfeed-update-command)))
91
92(define-minor-mode +elfeed-update-async-mode
93 "Minor mode to update elfeed async-style every 15 minutes."
94 :global t
95 (if +elfeed-update-async-mode
96 (progn ; enable
97 (+elfeed--reinstate-update-timer)
98 (advice-add 'elfeed :before '+elfeed--cancel-update-timer)
99 (advice-add 'elfeed-search-quit-window :after '+elfeed--reinstate-update-timer))
100 (progn ; disable
101 (advice-remove 'elfeed '+elfeed--cancel-update-timer)
102 (advice-remove 'elfeed-search-quit-window '+elfeed--reinstate-update-timer)
103 (+elfeed--cancel-update-timer))))
104
34(provide '+elfeed) 105(provide '+elfeed)
35;;; +elfeed.el ends here 106;;; +elfeed.el ends here
diff --git a/lisp/+eshell.el b/lisp/+eshell.el index 1f8677c..d49358d 100644 --- a/lisp/+eshell.el +++ b/lisp/+eshell.el
@@ -91,10 +91,10 @@ something, it's really annoying to work with."
91 ,@forms) 91 ,@forms)
92 (when (featurep 'eshell) 92 (when (featurep 'eshell)
93 `(dolist (buf (buffer-list)) 93 `(dolist (buf (buffer-list))
94 (with-current-buffer buf 94 (with-current-buffer buf
95 (when (derived-mode-p 'eshell-mode) 95 (when (derived-mode-p 'eshell-mode)
96 (+eshell@setup))))) 96 (+eshell@setup)))))
97 '(add-hook 'eshell-mode-hook #'+eshell@setup))) 97 (add-hook 'eshell-mode-hook #'+eshell@setup)))
98 98
99(provide '+eshell) 99(provide '+eshell)
100;;; +eshell.el ends here 100;;; +eshell.el ends here
diff --git a/lisp/+org.el b/lisp/+org.el index 5869622..11a816f 100644 --- a/lisp/+org.el +++ b/lisp/+org.el
@@ -433,8 +433,12 @@ the deletion might narrow the column."
433 (when (and (memq this-char-type types) (memq prev-char-type types)) 433 (when (and (memq this-char-type types) (memq prev-char-type types))
434 (backward-char) 434 (backward-char)
435 (setq type prev-char-type)) ; what the fuckckckckck 435 (setq type prev-char-type)) ; what the fuckckckckck
436 (if (memq type types) 436 ;; Okay, so this ^ is pretty janky and doesn't /really/ work that well,
437 (progn (org-open-at-point arg)) 437 ;; especially on DEADLINE (and probably SCHEDULED) lines. However, since
438 ;; I really just want to open the list of URLs /most of the time/, I'm
439 ;; fixing it like this instead.
440 (unless (and (memq type types)
441 (ignore-errors (org-open-at-point arg)))
438 (while (not 442 (while (not
439 (progn 443 (progn
440 (org-back-to-heading) 444 (org-back-to-heading)
diff --git a/lisp/+straight.el b/lisp/+straight.el new file mode 100644 index 0000000..d00ad9a --- /dev/null +++ b/lisp/+straight.el
@@ -0,0 +1,41 @@
1;;; +straight.el --- Straight.el extras -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;;; Code:
6
7(defun +straight-update-package (package &optional recursive)
8 "Update PACKAGE using straight.
9This pulls, rebuilds, and loads the updated PACKAGE."
10 (interactive (list (straight--select-package "Update package"
11 #'straight--installed-p)
12 current-prefix-arg))
13 (+with-message (format "Pulling package `%s'%s" package
14 (if recursive " and deps" ""))
15 (funcall (if recursive
16 #'straight-pull-package-and-deps
17 #'straight-pull-package)
18 package
19 :from-upstream))
20 (+with-message (format "Rebuilding package `%s'%s" package
21 (if recursive " and deps" ""))
22 (straight-rebuild-package package recursive))
23 (+with-message (format "Loading package `%s'%s" package
24 (if recursive " and deps" ""))
25 (ignore-errors (load-library (symbol-name package)))
26 (when recursive
27 (dolist (dep (straight--get-transitive-dependencies package))
28 (ignore-errors (load-library (symbol-name package)))))))
29
30(defun +straight-update-all (from-upstream)
31 "Update all installed packages using straight.
32This pulls and rebuilds all packages at once. It does not reload
33all of them, for reasons that should be obvious.
34
35With a prefix argument, it also pulls the packages FROM-UPSTREAM."
36 (interactive "P")
37 (straight-pull-all from-upstream)
38 (straight-rebuild-all))
39
40(provide '+straight)
41;;; +straight.el ends here
diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el index 2e9198c..b11be2c 100644 --- a/lisp/+tab-bar.el +++ b/lisp/+tab-bar.el
@@ -22,7 +22,7 @@
22 `((global menu-item ,(string-trim-right 22 `((global menu-item ,(string-trim-right
23 (format-mode-line mode-line-misc-info)) 23 (format-mode-line mode-line-misc-info))
24 24
25 ignore))) 25 ignore :help (discord-date-string))))
26 26
27(defvar +tab-bar-show-original nil 27(defvar +tab-bar-show-original nil
28 "Original value of `tab-bar-show'.") 28 "Original value of `tab-bar-show'.")
@@ -129,35 +129,30 @@ Used by `tab-bar-format-menu-bar'."
129;;; Tab bar format tabs 129;;; Tab bar format tabs
130 130
131(require 'el-patch) 131(require 'el-patch)
132 132(el-patch-feature tab-bar)
133(el-patch-defun tab-bar--format-tab (tab i) 133(with-eval-after-load 'tab-bar
134 (append 134 (el-patch-defun tab-bar--format-tab (tab i)
135 (el-patch-remove 135 "Format TAB using its index I and return the result as a keymap."
136 `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore))) 136 (append
137 (cond 137 (el-patch-remove
138 ((eq (car tab) 'current-tab) 138 `((,(intern (format "sep-%i" i)) menu-item ,(tab-bar-separator) ignore)))
139 `((current-tab 139 (cond
140 menu-item 140 ((eq (car tab) 'current-tab)
141 ,(funcall tab-bar-tab-name-format-function tab i) 141 `((current-tab
142 ignore 142 menu-item
143 :help "Current tab"))) 143 ,(funcall tab-bar-tab-name-format-function tab i)
144 (t 144 ignore
145 `((,(intern (format "tab-%i" i)) 145 :help "Current tab")))
146 menu-item 146 (t
147 ,(funcall tab-bar-tab-name-format-function tab i) 147 `((,(intern (format "tab-%i" i))
148 ,(or 148 menu-item
149 (alist-get 'binding tab) 149 ,(funcall tab-bar-tab-name-format-function tab i)
150 `(lambda () 150 ,(alist-get 'binding tab)
151 (interactive) 151 :help "Click to visit tab"))))
152 (tab-bar-select-tab ,i))) 152 (when (alist-get 'close-binding tab)
153 :help "Click to visit tab")))) 153 `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i)))
154 `((,(if (eq (car tab) 'current-tab) 'C-current-tab (intern (format "C-tab-%i" i))) 154 menu-item ""
155 menu-item "" 155 ,(alist-get 'close-binding tab)))))))
156 ,(or
157 (alist-get 'close-binding tab)
158 `(lambda ()
159 (interactive)
160 (tab-bar-close-tab ,i)))))))
161 156
162 157
163;; Emacs 27 158;; Emacs 27
diff --git a/lisp/acdw.el b/lisp/acdw.el index 17741ab..a96e6a7 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -248,5 +248,29 @@ With optional ARG (\\[universal-argument]), just split."
248 (interactive "P") 248 (interactive "P")
249 (+split-window-then :below arg)) 249 (+split-window-then :below arg))
250 250
251(defun +bytes (number unit)
252 "Convert NUMBER UNITs to bytes.
253UNIT can be one of :kb, :mb, :gb, :tb, :pb, :eb, :zb, :yb; :kib, :mib, :gib,
254:tib, :pib, :eib, :zib, :yib."
255 (* number (pcase unit
256 ;; Base 10 units
257 (:kb 1000)
258 (:mb (* 1000 1000))
259 (:gb (* 1000 1000 1000))
260 (:tb (* 1000 1000 1000 1000))
261 (:pb (* 1000 1000 1000 1000 1000))
262 (:eb (* 1000 1000 1000 1000 1000 1000))
263 (:zb (* 1000 1000 1000 1000 1000 1000 1000))
264 (:yb (* 1000 1000 1000 1000 1000 1000 1000 1000))
265 ;; Base 2 units
266 (:kib 1024)
267 (:mib (* 1024 1024))
268 (:gib (* 1024 1024 1024))
269 (:tib (* 1024 1024 1024 1024))
270 (:pib (* 1024 1024 1024 1024 1024))
271 (:eib (* 1024 1024 1024 1024 1024 1024))
272 (:zib (* 1024 1024 1024 1024 1024 1024 1024))
273 (:yib (* 1024 1024 1024 1024 1024 1024 1024 1024)))))
274
251(provide 'acdw) 275(provide 'acdw)
252;;; acdw.el ends here 276;;; acdw.el ends here
diff --git a/lisp/fibs.el b/lisp/fibs.el new file mode 100644 index 0000000..545c2a7 --- /dev/null +++ b/lisp/fibs.el
@@ -0,0 +1,37 @@
1;;; fibs.el --- Play backgammon with FIBS -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;; fibs.com is one of the oldest backgammon servers out there, and it's
6;; accessible via telnet. This package provides a wrapper to enable you to play
7;; backgammon on fibs.com more easily than just opening a telnet session
8;; yourself.
9
10;;; TODO:
11
12;; - Automatically log in.
13;; - Add a `fibs-quit' function to kill the telnet server and buffer.
14
15;;; Code:
16
17(require 'telnet)
18
19(defgroup fibs nil
20 "Customizations for FIBS, the First Internet Backgammon Server."
21 :group 'games)
22
23(defcustom fibs-server "fibs.com"
24 "The server to connect to FIBS with."
25 :type 'string)
26
27(defcustom fibs-port 4321
28 "The port to connect to FIBS with."
29 :type 'number)
30
31;;;###autoload
32(defun fibs ()
33 (interactive)
34 (telnet fibs-server fibs-port))
35
36(provide 'fibs)
37;;; fibs.el ends here