From d19fb84fbbdc1363a52cc3bd3723e4dda75812f3 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 28 Sep 2021 16:20:55 -0500 Subject: Add acdw-circe.el --- init.el | 48 ++++++----------------------------------------- lisp/acdw-circe.el | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 42 deletions(-) create mode 100644 lisp/acdw-circe.el diff --git a/init.el b/init.el index 11c9e71..a5efd8b 100644 --- a/init.el +++ b/init.el @@ -1026,9 +1026,9 @@ specific to most general, they are these: (setup (:straight circe) (require 'circe) (require 'acdw-irc) + (:also-load acdw-circe) (:option acdw-irc/left-margin 20 - acdw-irc/post-my-nick "-> " circe-channel-killed-confirmation nil circe-color-nicks-everywhere t circe-default-nick "acdw" @@ -1084,44 +1084,9 @@ specific to most general, they are these: (:bind "C-c C-p" #'circe-command-PART "C-l" #'lui-track-jump-to-indicator) - (:advise circe-command-PART :after - (defun circe-part@kill-buffer (&rest _) - (let ((circe-channel-killed-confirmation nil)) - (kill-buffer))) - - circe-command-QUIT :after - (defun circe-quit@kill-buffer (&rest _) - ;; `circe-server-killed-confirmation' set to nil, and manually - ;; deleting all chat buffers, pending Github issue #402 - ;; (https://github.com/emacs-circe/circe/issues/402) - (let ((circe-server-killed-confirmation nil)) - (with-circe-server-buffer - (dolist (buf (circe-server-chat-buffers)) - (let ((circe-channel-killed-confirmation nil)) - (kill-buffer buf))) - (kill-buffer)))) - - circe-command-GQUIT :after - (defun circe-gquit@kill-buffer (&rest _) - ;; `circe-server-killed-confirmation' set to nil, and manually - ;; deleting all chat buffers, pending Github issue #402 - ;; (https://github.com/emacs-circe/circe/issues/402) - (let ((circe-server-killed-confirmation nil)) - (dolist (buf (circe-server-buffers)) - (with-current-buffer buf - (dolist (buf (circe-server-chat-buffers)) - (let ((circe-channel-killed-confirmation nil)) - (kill-buffer buf)) - (cancel-timer 'irc-send--queue)) - (message "%s: %s" buf circe-server-killed-confirmation) - (kill-buffer)))))) - - (defun circe-command-SHORTEN (url) - "Shorten URL using `0x0-shorten-uri'." - (interactive "sURL to shorten: ") - ;; TODO: enable /shorten URL comment syntax - (let ((short-url (0x0-shorten-uri (0x0--choose-server) url))) - (circe-command-SAY short-url))) + (:advise circe-command-PART :after #'circe-part@kill-buffer + circe-command-QUIT :after #'circe-quit@kill-buffer + circe-command-GQUIT :after #'circe-gquit@kill-buffer) (:with-mode circe-chat-mode (:hook #'acdw/stop-paren-annoyances @@ -1132,12 +1097,11 @@ specific to most general, they are these: (lui-set-prompt (concat (propertize - (acdw-irc/margin-format (buffer-name) "" ">") + (acdw-irc/margin-format (buffer-name) " " "> ") 'face 'circe-prompt-face 'read-only t 'intangible t - 'cursor-intangible t) - " "))))) + 'cursor-intangible t)))))) (autoload 'circe-nick-color-reset "circe-color-nicks") (add-hook 'modus-themes-after-load-theme-hook diff --git a/lisp/acdw-circe.el b/lisp/acdw-circe.el new file mode 100644 index 0000000..69b10be --- /dev/null +++ b/lisp/acdw-circe.el @@ -0,0 +1,55 @@ +;;; acdw-circe.el --- bespoke circe customizations -*- lexical-binding: t -*- + +;;; Commentary: + +;; Besoke Circe customizations. + +;;; Code: + +(require 'circe) + +;;; Chat commands +(defun circe-command-SHORTEN (url) + "Shorten URL using `0x0-shorten-uri'." + (interactive "sURL to shorten: ") + (require '0x0) + ;; TODO: enable /shorten URL comment syntax + (let ((short-url (0x0-shorten-uri (0x0--choose-server) url))) + (circe-command-SAY short-url))) + +;;; Advices + +(defun circe-part@kill-buffer (&rest _) + "Advice to kill the channel buffer after PART." + (let ((circe-channel-killed-confirmation nil)) + (kill-buffer))) + +(defun circe-quit@kill-buffer (&rest _) + "Advice to kill all buffers of a server after QUIT." + ;; `circe-server-killed-confirmation' set to nil, and manually + ;; deleting all chat buffers, pending Github issue #402 + ;; (https://github.com/emacs-circe/circe/issues/402) + (let ((circe-server-killed-confirmation nil)) + (with-circe-server-buffer + (dolist (buf (circe-server-chat-buffers)) + (let ((circe-channel-killed-confirmation nil)) + (kill-buffer buf))) + (kill-buffer)))) + +(defun circe-gquit@kill-buffer (&rest _) + "Advice to kill all Circe related buffers after GQUIT." + ;; `circe-server-killed-confirmation' set to nil, and manually + ;; deleting all chat buffers, pending Github issue #402 + ;; (https://github.com/emacs-circe/circe/issues/402) + (let ((circe-server-killed-confirmation nil)) + (dolist (buf (circe-server-buffers)) + (with-current-buffer buf + (dolist (buf (circe-server-chat-buffers)) + (let ((circe-channel-killed-confirmation nil)) + (kill-buffer buf)) + (cancel-timer 'irc-send--queue)) + (message "%s: %s" buf circe-server-killed-confirmation) + (kill-buffer))))) + +(provide 'acdw-circe) +;;; acdw-circe.el ends here -- cgit 1.4.1-21-gabe81