about summary refs log tree commit diff stats
path: root/lisp/acdw.el
diff options
context:
space:
mode:
authorCase Duckworth2022-03-11 20:04:05 -0600
committerCase Duckworth2022-03-11 20:04:05 -0600
commitf6512fe1bd9738e1c2c5c9a7ad92098b2f02fa34 (patch)
treec5cf0551e9e25e5238f474fd6ad44fbe6d155e56 /lisp/acdw.el
parentAdd snippets (diff)
downloademacs-f6512fe1bd9738e1c2c5c9a7ad92098b2f02fa34.tar.gz
emacs-f6512fe1bd9738e1c2c5c9a7ad92098b2f02fa34.zip
Uh
Diffstat (limited to 'lisp/acdw.el')
-rw-r--r--lisp/acdw.el57
1 files changed, 39 insertions, 18 deletions
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