summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/+elfeed.el88
-rw-r--r--lisp/+emacs.el11
-rw-r--r--lisp/+ispell.el52
-rw-r--r--lisp/+kmacro.el1
-rw-r--r--lisp/+modeline.el23
-rw-r--r--lisp/+org.el4
-rw-r--r--lisp/+tab-bar.el6
-rw-r--r--lisp/acdw.el57
8 files changed, 148 insertions, 94 deletions
diff --git a/lisp/+elfeed.el b/lisp/+elfeed.el index ac316c4..8f7f17a 100644 --- a/lisp/+elfeed.el +++ b/lisp/+elfeed.el
@@ -60,49 +60,51 @@
60 (make-directory (file-name-directory script) :parents) 60 (make-directory (file-name-directory script) :parents)
61 (with-temp-buffer 61 (with-temp-buffer
62 (insert 62 (insert
63 (prin1-to-string ;; Print the following s-expression to a string 63 (let ((print-level nil)
64 `(progn 64 (print-length nil))
65 ;; Set up the environment 65 (prin1-to-string ;; Print the following s-expression to a string
66 (setq lexical-binding t) 66 `(progn
67 (load (locate-user-emacs-file "early-init")) 67 ;; Set up the environment
68 (dolist (pkg '(elfeed elfeed-org)) 68 (setq lexical-binding t)
69 (straight-use-package pkg) 69 (load (locate-user-emacs-file "early-init"))
70 (require pkg)) 70 (dolist (pkg '(elfeed elfeed-org))
71 ;; Copy variables from current environment 71 (straight-use-package pkg)
72 (progn 72 (require pkg))
73 ,@(cl-loop for copy-var in '(rmh-elfeed-org-files 73 ;; Copy variables from current environment
74 elfeed-db-directory 74 (progn
75 elfeed-curl-program-name 75 ,@(cl-loop for copy-var in '(rmh-elfeed-org-files
76 elfeed-use-curl 76 elfeed-db-directory
77 elfeed-curl-extra-arguments 77 elfeed-curl-program-name
78 elfeed-enclosure-default-dir) 78 elfeed-use-curl
79 collect `(progn (message "%S = %S" ',copy-var ',(symbol-value copy-var)) 79 elfeed-curl-extra-arguments
80 (setq ,copy-var ',(symbol-value copy-var))))) 80 elfeed-enclosure-default-dir)
81 ;; Define new variables for this environment 81 collect `(progn (message "%S = %S" ',copy-var ',(symbol-value copy-var))
82 (progn 82 (setq ,copy-var ',(symbol-value copy-var)))))
83 ,@(cl-loop for (new-var . new-val) in '((elfeed-curl-max-connections . 4)) 83 ;; Define new variables for this environment
84 collect `(progn (message "%S = %S" ',new-var ',new-val) 84 (progn
85 (setq ,new-var ',new-val)))) 85 ,@(cl-loop for (new-var . new-val) in '((elfeed-curl-max-connections . 4))
86 ;; Redefine `elfeed-log' to log everything 86 collect `(progn (message "%S = %S" ',new-var ',new-val)
87 (defun elfeed-log (level fmt &rest objects) 87 (setq ,new-var ',new-val))))
88 (princ (format "[%s] [%s]: %s\n" 88 ;; Redefine `elfeed-log' to log everything
89 (format-time-string "%F %T") 89 (defun elfeed-log (level fmt &rest objects)
90 level 90 (princ (format "[%s] [%s]: %s\n"
91 (apply #'format fmt objects)))) 91 (format-time-string "%F %T")
92 ;; Run elfeed 92 level
93 (elfeed-org) 93 (apply #'format fmt objects))))
94 (elfeed) 94 ;; Run elfeed
95 (elfeed-db-load) 95 (elfeed-org)
96 (elfeed-update) 96 (elfeed)
97 ;; Wait for `elfeed-update' to finish 97 (elfeed-db-load)
98 (while (> (elfeed-queue-count-total) 0) 98 (elfeed-update)
99 (sleep-for 5) 99 ;; Wait for `elfeed-update' to finish
100 (message "%s" (elfeed-queue-count-total)) 100 (while (> (elfeed-queue-count-total) 0)
101 (accept-process-output)) 101 (sleep-for 5)
102 ;; Garbage collect and save the database 102 (message "%s" (elfeed-queue-count-total))
103 (elfeed-db-gc) 103 (accept-process-output))
104 (elfeed-db-save) 104 ;; Garbage collect and save the database
105 (princ (format ,update-message-format "done."))))) 105 (elfeed-db-gc)
106 (elfeed-db-save)
107 (princ (format ,update-message-format "done."))))))
106 (write-file script)) 108 (write-file script))
107 (chmod script #o777) 109 (chmod script #o777)
108 (message update-message-format "start") 110 (message update-message-format "start")
diff --git a/lisp/+emacs.el b/lisp/+emacs.el index f26dc98..b7e31e2 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el
@@ -60,15 +60,18 @@ Do this only if the buffer is not visiting a file."
60 enable-recursive-minibuffers t 60 enable-recursive-minibuffers t
61 executable-prefix-env t 61 executable-prefix-env t
62 fast-but-imprecise-scrolling t 62 fast-but-imprecise-scrolling t
63 find-file-visit-truename t
64 file-name-shadow-properties '(invisible t intangible t) 63 file-name-shadow-properties '(invisible t intangible t)
65 fill-column 80 64 fill-column 80
65 find-file-visit-truename t
66 frame-resize-pixelwise t 66 frame-resize-pixelwise t
67 global-auto-revert-non-file-buffers t 67 global-auto-revert-non-file-buffers t
68 global-mark-ring-max 100 68 global-mark-ring-max 100
69 hscroll-margin 1 69 hscroll-margin 1
70 hscroll-step 1 70 hscroll-step 1
71 imenu-auto-rescan t 71 imenu-auto-rescan t
72 image-use-external-converter (or (executable-find "convert")
73 (executable-find "gm")
74 (executable-find "ffmpeg"))
72 indent-tabs-mode nil 75 indent-tabs-mode nil
73 indicate-buffer-boundaries 'left 76 indicate-buffer-boundaries 'left
74 indicate-empty-lines nil 77 indicate-empty-lines nil
@@ -104,7 +107,7 @@ Do this only if the buffer is not visiting a file."
104 save-interprogram-paste-before-kill t 107 save-interprogram-paste-before-kill t
105 scroll-conservatively 101 108 scroll-conservatively 101
106 scroll-down-aggressively 0.01 109 scroll-down-aggressively 0.01
107 scroll-margin 1 110 scroll-margin 2
108 scroll-preserve-screen-position 1 111 scroll-preserve-screen-position 1
109 scroll-step 1 112 scroll-step 1
110 scroll-up-aggressively 0.01 113 scroll-up-aggressively 0.01
@@ -148,6 +151,9 @@ Do this only if the buffer is not visiting a file."
148 151
149;;; Encodings 152;;; Encodings
150 153
154;; Allegedly, this is the only one you need...
155(set-language-environment "UTF-8")
156;; But I still set all of these, for fun.
151(setq-default locale-coding-system 'utf-8-unix 157(setq-default locale-coding-system 'utf-8-unix
152 coding-system-for-read 'utf-8-unix 158 coding-system-for-read 'utf-8-unix
153 coding-system-for-write 'utf-8-unix 159 coding-system-for-write 'utf-8-unix
@@ -159,7 +165,6 @@ Do this only if the buffer is not visiting a file."
159 STRING)) 165 STRING))
160 166
161(set-charset-priority 'unicode) 167(set-charset-priority 'unicode)
162(set-language-environment "UTF-8")
163(prefer-coding-system 'utf-8-unix) 168(prefer-coding-system 'utf-8-unix)
164(set-default-coding-systems 'utf-8-unix) 169(set-default-coding-systems 'utf-8-unix)
165(set-terminal-coding-system 'utf-8-unix) 170(set-terminal-coding-system 'utf-8-unix)
diff --git a/lisp/+ispell.el b/lisp/+ispell.el index c3ee417..697233f 100644 --- a/lisp/+ispell.el +++ b/lisp/+ispell.el
@@ -58,30 +58,34 @@ prefix ARG is non-nil; then it just saves them."
58 (unless (buffer-file-name) 58 (unless (buffer-file-name)
59 (user-error "Buffer not attached to file")) 59 (user-error "Buffer not attached to file"))
60 (hack-dir-local-variables) 60 (hack-dir-local-variables)
61 (when-let ((new-words (+ispell-append-removing-duplicates 61 (let ((print-level nil)
62 :test #'string= 62 (print-length nil))
63 ispell-buffer-session-localwords 63 (when-let ((new-words (cl-remove-if (lambda (el) (eq el '\.\.\.)) ; XXX: NO IDEA
64 (alist-get 'ispell-buffer-session-localwords 64 ; where this came from
65 dir-local-variables-alist) 65 (+ispell-append-removing-duplicates
66 (alist-get 'ispell-buffer-session-localwords 66 :test #'string=
67 file-local-variables-alist) 67 ispell-buffer-session-localwords
68 (+ispell-buffer-local-words-list)))) 68 (alist-get 'ispell-buffer-session-localwords
69 (save-excursion 69 dir-local-variables-alist)
70 (add-dir-local-variable 70 (alist-get 'ispell-buffer-session-localwords
71 major-mode 71 file-local-variables-alist)
72 'ispell-buffer-session-localwords 72 (+ispell-buffer-local-words-list)))))
73 (setq ispell-buffer-session-localwords 73 (save-excursion
74 new-words)) 74 (add-dir-local-variable
75 (when (or arg 75 major-mode
76 (y-or-n-p "Save .dir-locals.el?")) 76 'ispell-buffer-session-localwords
77 (save-buffer)) 77 (setq ispell-buffer-session-localwords
78 (bury-buffer)) 78 new-words))
79 (or ispell-buffer-local-name 79 (when (or arg
80 (setq ispell-buffer-local-name (buffer-name))) 80 (y-or-n-p "Save .dir-locals.el?"))
81 (save-excursion 81 (save-buffer))
82 (goto-char (point-min)) 82 (bury-buffer))
83 (while (search-forward ispell-words-keyword nil t) 83 (or ispell-buffer-local-name
84 (delete-region (point-at-bol) (1+ (point-at-eol))))))) 84 (setq ispell-buffer-local-name (buffer-name)))
85 (save-excursion
86 (goto-char (point-min))
87 (while (search-forward ispell-words-keyword nil t)
88 (delete-region (point-at-bol) (1+ (point-at-eol))))))))
85 89
86;;;###autoload 90;;;###autoload
87(defun +ispell-move-buffer-words-to-dir-locals-hook () 91(defun +ispell-move-buffer-words-to-dir-locals-hook ()
diff --git a/lisp/+kmacro.el b/lisp/+kmacro.el index 2b2916f..a3cde61 100644 --- a/lisp/+kmacro.el +++ b/lisp/+kmacro.el
@@ -21,6 +21,7 @@
21 21
22(defun +kmacro-change-mode-line (&rest _) 22(defun +kmacro-change-mode-line (&rest _)
23 "Remap the mode-line face when recording a kmacro." 23 "Remap the mode-line face when recording a kmacro."
24
24 (add-to-list 'face-remapping-alist '(mode-line . +kmacro-modeline))) 25 (add-to-list 'face-remapping-alist '(mode-line . +kmacro-modeline)))
25 26
26(defun +kmacro-restore-mode-line (&rest _) 27(defun +kmacro-restore-mode-line (&rest _)
diff --git a/lisp/+modeline.el b/lisp/+modeline.el index c8dab4e..7bef5c6 100644 --- a/lisp/+modeline.el +++ b/lisp/+modeline.el
@@ -296,7 +296,7 @@ See `line-number-mode', `column-number-mode', `file-percentage-mode'"
296 (interactive "e") 296 (interactive "e")
297 (with-selected-window 297 (with-selected-window
298 (posn-window 298 (posn-window
299 (event-start ev)) 299 (event-start e))
300 (god-local-mode -1) 300 (god-local-mode -1)
301 (force-mode-line-update))))) 301 (force-mode-line-update)))))
302 'mouse-face 'mode-line-highlight)))) 302 'mouse-face 'mode-line-highlight))))
@@ -326,5 +326,26 @@ See `line-number-mode', `column-number-mode', `file-percentage-mode'"
326 map)) 326 map))
327 'mouse-face 'mode-line-highlight)))) 327 'mouse-face 'mode-line-highlight))))
328 328
329(defface +modeline-kmacro-indicator '((t :foreground "Firebrick"))
330 "Face for the kmacro indicator in the modeline.")
331
332(defun +modeline-kmacro-indicator (&optional spacer)
333 "Display an indicator when recording a kmacro."
334 (when defining-kbd-macro
335 (concat (or spacer +modeline-default-spacer)
336 (propertize "●"
337 'face '+modeline-kmacro-indicator
338 'help-echo (format (concat "Defining a macro\n"
339 "Current step: %d\n"
340 "mouse-1: Stop recording")
341 kmacro-counter)
342 'local-map (purecopy (simple-modeline-make-mouse-map
343 'mouse-1 (lambda (e)
344 (interactive "e")
345 (with-selected-window
346 (posn-window (event-start e))
347 (kmacro-end-macro nil)))))
348 'mouse-face 'mode-line-highlight))))
349
329(provide '+modeline) 350(provide '+modeline)
330;;; +modeline.el ends here 351;;; +modeline.el ends here
diff --git a/lisp/+org.el b/lisp/+org.el index 2ff3e11..3d14c52 100644 --- a/lisp/+org.el +++ b/lisp/+org.el
@@ -550,6 +550,7 @@ language name.")
550 "Export region to HTML, and copy it to the clipboard. 550 "Export region to HTML, and copy it to the clipboard.
551Arguments ASYNC, SUBTREEP, VISIBLE-ONLY, BODY-ONLY, EXT-PLIST, 551Arguments ASYNC, SUBTREEP, VISIBLE-ONLY, BODY-ONLY, EXT-PLIST,
552and POST-PROCESS are passed to `org-export-to-file'." 552and POST-PROCESS are passed to `org-export-to-file'."
553 (interactive) ; XXX: hould this be interactive?
553 (message "Exporting Org to HTML...") 554 (message "Exporting Org to HTML...")
554 (let ((org-tmp-file "/tmp/org.html")) 555 (let ((org-tmp-file "/tmp/org.html"))
555 (org-export-to-file 'html org-tmp-file 556 (org-export-to-file 'html org-tmp-file
@@ -567,8 +568,5 @@ and POST-PROCESS are passed to `org-export-to-file'."
567 (interactive) 568 (interactive)
568 (+org-export-clip-to-html nil :subtree)) 569 (+org-export-clip-to-html nil :subtree))
569 570
570;;; Taskwise functions
571;; TODO: break out into another library
572
573(provide '+org) 571(provide '+org)
574;;; +org.el ends here 572;;; +org.el ends here
diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el index c4b7420..e328146 100644 --- a/lisp/+tab-bar.el +++ b/lisp/+tab-bar.el
@@ -27,7 +27,8 @@
27 "Display `tracking-mode-line-buffers' in the tab-bar." 27 "Display `tracking-mode-line-buffers' in the tab-bar."
28 ;; TODO: write something to convert a mode-line construct to a tab-bar 28 ;; TODO: write something to convert a mode-line construct to a tab-bar
29 ;; construct. 29 ;; construct.
30 (when tracking-mode 30 (when (and tracking-mode
31 (not (bound-and-true-p org-clock-current-task)))
31 (cons (when (> (length tracking-mode-line-buffers) 0) 32 (cons (when (> (length tracking-mode-line-buffers) 0)
32 '(track-mode-line-separator menu-item " " ignore)) 33 '(track-mode-line-separator menu-item " " ignore))
33 (cl-loop for i from 0 below (length tracking-mode-line-buffers) 34 (cl-loop for i from 0 below (length tracking-mode-line-buffers)
@@ -63,7 +64,8 @@
63 64
64(defun +tab-bar-org-clock () 65(defun +tab-bar-org-clock ()
65 "Display `org-mode-line-string' in the tab-bar." 66 "Display `org-mode-line-string' in the tab-bar."
66 (when (org-clocking-p) 67 (when (and (fboundp 'org-clocking-p)
68 (org-clocking-p))
67 ;; org-mode-line-string 69 ;; org-mode-line-string
68 `((org-clocking menu-item 70 `((org-clocking menu-item
69 ,org-mode-line-string 71 ,org-mode-line-string
diff --git a/lisp/acdw.el b/lisp/acdw.el index 7012b16..de2b8e7 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -281,24 +281,30 @@ always nil; this function is mostly intended for use in init."
281(defun chat-disconnect () 281(defun chat-disconnect ()
282 "Disconnect from all chats." 282 "Disconnect from all chats."
283 (interactive) 283 (interactive)
284 (ignore-errors 284 (+with-progress "Quitting circe..."
285 (circe-command-GQUIT "☮ 🫀 🍞"))
286 (ignore-errors
287 (jabber-disconnect))
288 (dolist (team +slack-teams)
289 (ignore-errors 285 (ignore-errors
290 (slack-team-disconnect team))) 286 (circe-command-GQUIT "☮ 🫀 🍞")
291 (ignore-errors (slack-ws-close)) 287 (cancel-timer (irc-connection-get conn :flood-timer))))
292 (+mapc-some-buffers (lambda () "Remove the buffer from tracking and kill it unconditionally." 288 (+with-progress "Quitting jabber..."
293 (let ((kill-buffer-query-functions nil)) 289 (ignore-errors
294 (tracking-remove-buffer (current-buffer)) 290 (jabber-disconnect)))
295 (kill-buffer))) 291 (+with-progress "Quitting-slack..."
296 (lambda () "Return t if derived from the following modes." 292 (dolist (team +slack-teams)
297 (derived-mode-p 'lui-mode 293 (ignore-errors
298 'jabber-chat-mode 294 (slack-team-disconnect team)))
299 'jabber-roster-mode 295 (ignore-errors (slack-ws-close)))
300 'jabber-browse-mode 296 (+with-progress "Killing buffers..."
301 'slack-mode)))) 297 (ignore-errors
298 (+mapc-some-buffers (lambda () "Remove the buffer from tracking and kill it unconditionally."
299 (let ((kill-buffer-query-functions nil))
300 (tracking-remove-buffer (current-buffer))
301 (kill-buffer)))
302 (lambda () "Return t if derived from the following modes."
303 (derived-mode-p 'lui-mode
304 'jabber-chat-mode
305 'jabber-roster-mode
306 'jabber-browse-mode
307 'slack-mode))))))
302 308
303;; I can never remember all the damn chat things I run, so this just does all of em. 309;; I can never remember all the damn chat things I run, so this just does all of em.
304(defun chat (&optional arg) 310(defun chat (&optional arg)
@@ -306,7 +312,9 @@ always nil; this function is mostly intended for use in init."
306With optional ARG, kill all chat-related buffers first." 312With optional ARG, kill all chat-related buffers first."
307 (interactive "P") 313 (interactive "P")
308 (when arg (chat-disconnect)) 314 (when arg (chat-disconnect))
309 (mapc #'call-interactively chat-functions)) 315 (dolist-with-progress-reporter (fn chat-functions)
316 "Connecting to chat..."
317 (call-interactively fn)))
310 318
311(defun +forward-paragraph (arg) 319(defun +forward-paragraph (arg)
312 "Move forward ARG (simple) paragraphs. 320 "Move forward ARG (simple) paragraphs.
@@ -353,5 +361,18 @@ SEPARATOR defaults to the newline (\\n)."
353 (with-current-buffer (find-file-noselect file) 361 (with-current-buffer (find-file-noselect file)
354 (buffer-string))) 362 (buffer-string)))
355 363
364(defmacro +with-progress (pr-args &rest body)
365 "Perform BODY wrapped in a progress reporter.
366PR-ARGS is the list of arguments to pass to
367`make-progress-reporter'; it can be a single string for the
368message, as well. If you want to use a formatted string, wrap
369the `format' call in a list."
370 (declare (indent 1))
371 (let ((reporter (gensym))
372 (pr-args (if (listp pr-args) pr-args (list pr-args))))
373 `(let ((,reporter (make-progress-reporter ,@pr-args)))
374 (prog1 (progn ,@body)
375 (progress-reporter-done ,reporter)))))
376
356(provide 'acdw) 377(provide 'acdw)
357;;; acdw.el ends here 378;;; acdw.el ends here