From f6512fe1bd9738e1c2c5c9a7ad92098b2f02fa34 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 11 Mar 2022 20:04:05 -0600 Subject: Uh --- lisp/acdw.el | 57 +++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 18 deletions(-) (limited to 'lisp/acdw.el') 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." (defun chat-disconnect () "Disconnect from all chats." (interactive) - (ignore-errors - (circe-command-GQUIT "☮ 🫀 🍞")) - (ignore-errors - (jabber-disconnect)) - (dolist (team +slack-teams) + (+with-progress "Quitting circe..." (ignore-errors - (slack-team-disconnect team))) - (ignore-errors (slack-ws-close)) - (+mapc-some-buffers (lambda () "Remove the buffer from tracking and kill it unconditionally." - (let ((kill-buffer-query-functions nil)) - (tracking-remove-buffer (current-buffer)) - (kill-buffer))) - (lambda () "Return t if derived from the following modes." - (derived-mode-p 'lui-mode - 'jabber-chat-mode - 'jabber-roster-mode - 'jabber-browse-mode - 'slack-mode)))) + (circe-command-GQUIT "☮ 🫀 🍞") + (cancel-timer (irc-connection-get conn :flood-timer)))) + (+with-progress "Quitting jabber..." + (ignore-errors + (jabber-disconnect))) + (+with-progress "Quitting-slack..." + (dolist (team +slack-teams) + (ignore-errors + (slack-team-disconnect team))) + (ignore-errors (slack-ws-close))) + (+with-progress "Killing buffers..." + (ignore-errors + (+mapc-some-buffers (lambda () "Remove the buffer from tracking and kill it unconditionally." + (let ((kill-buffer-query-functions nil)) + (tracking-remove-buffer (current-buffer)) + (kill-buffer))) + (lambda () "Return t if derived from the following modes." + (derived-mode-p 'lui-mode + 'jabber-chat-mode + 'jabber-roster-mode + 'jabber-browse-mode + 'slack-mode)))))) ;; I can never remember all the damn chat things I run, so this just does all of em. (defun chat (&optional arg) @@ -306,7 +312,9 @@ always nil; this function is mostly intended for use in init." With optional ARG, kill all chat-related buffers first." (interactive "P") (when arg (chat-disconnect)) - (mapc #'call-interactively chat-functions)) + (dolist-with-progress-reporter (fn chat-functions) + "Connecting to chat..." + (call-interactively fn))) (defun +forward-paragraph (arg) "Move forward ARG (simple) paragraphs. @@ -353,5 +361,18 @@ SEPARATOR defaults to the newline (\\n)." (with-current-buffer (find-file-noselect file) (buffer-string))) +(defmacro +with-progress (pr-args &rest body) + "Perform BODY wrapped in a progress reporter. +PR-ARGS is the list of arguments to pass to +`make-progress-reporter'; it can be a single string for the +message, as well. If you want to use a formatted string, wrap +the `format' call in a list." + (declare (indent 1)) + (let ((reporter (gensym)) + (pr-args (if (listp pr-args) pr-args (list pr-args)))) + `(let ((,reporter (make-progress-reporter ,@pr-args))) + (prog1 (progn ,@body) + (progress-reporter-done ,reporter))))) + (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81