From e8d4afa471bc4812eef63ae9b8f7c156638fd8f8 Mon Sep 17 00:00:00 2001
From: Case Duckworth
Date: Fri, 3 Sep 2021 16:19:27 -0500
Subject: Further improve IRC experience

- Add SLAP command
- Kill buffer on PART
- Turns out, circe formatting variables can be functions!  Thank the gods :D
---
 init.el          | 64 +++++++++++++++++++++++++++++++-------------------------
 lisp/acdw-irc.el | 14 +++++++++++++
 2 files changed, 50 insertions(+), 28 deletions(-)

diff --git a/init.el b/init.el
index 275d830..1dac20c 100644
--- a/init.el
+++ b/init.el
@@ -1232,6 +1232,7 @@ like a dumbass."
   
   (:option acdw-irc/left-margin 12
            acdw-irc/post-my-nick "-> "
+           circe-channel-killed-confirmation nil
            circe-color-nicks-everywhere t
            circe-default-nick "acdw"
            circe-default-part-message "See You, Space Cowpokes . . ."
@@ -1264,6 +1265,12 @@ like a dumbass."
                       ((t (:inherit (modus-themes-hl-line))))
                       :now))
 
+  (:bind "C-c C-p" circe-command-PART)
+
+  (:advise circe-command-PART :after
+           (defun circe-command-PART@kill-buffer (&rest _)
+             (kill-buffer)))
+
   (add-hook 'circe-chat-mode-hook
             (defun circe-chat@setup ()
               (lui-set-prompt
@@ -1284,34 +1291,35 @@ like a dumbass."
   (add-hook 'modus-themes-after-load-theme-hook
             #'circe-nick-color-reset)
 
-  (let ((len (number-to-string (- acdw-irc/left-margin 1
-                                  (+ (length acdw-irc/pre-nick)
-                                     (length acdw-irc/post-nick)))))
-        (my-len (number-to-string (- acdw-irc/left-margin 1
-                                     (+ (length acdw-irc/pre-my-nick)
-                                        (length acdw-irc/post-my-nick))))))
-    (setq circe-format-say (concat acdw-irc/pre-nick
-                                   "{nick:" len "." len "s} "
-                                   acdw-irc/post-nick
-                                   "{body}")
-          circe-format-self-say (concat acdw-irc/pre-my-nick
-                                        "{nick:" my-len "." my-len "s} "
-                                        acdw-irc/post-my-nick
-                                        "{body}")
-          circe-format-action (concat "*"
-                                      (repeat-string
-                                       (- acdw-irc/left-margin 3)
-                                       " ")
-                                      "* {nick} {body}")
-          circe-format-self-action (concat "-*"
-                                           (repeat-string
-                                            (- acdw-irc/left-margin 4)
-                                            " ")
-                                           "* {nick} {body}")
-          lui-fill-type (concat
-                         (repeat-string (- acdw-irc/left-margin 2)
-                                        " ")
-                         "  ")))
+  (setq circe-format-say
+        (lambda (&rest plist)
+          (concat
+           (acdw-irc/margin-format (plist-get plist :nick) "" " |" t)
+           " "
+           (plist-get plist :body)))
+        
+        circe-format-self-say
+        (lambda (&rest plist)
+          (concat
+           (acdw-irc/margin-format (plist-get plist :nick) "-" " >" t)
+           " "
+           (plist-get plist :body)))
+
+        circe-format-action
+        (lambda (&rest plist)
+          (concat
+           (acdw-irc/margin-format (plist-get plist :nick) "*" " *" t)
+           " "
+           (plist-get plist :body)))
+
+        circe-format-self-action
+        (lambda (&rest plist)
+          (concat
+           (acdw-irc/margin-format (plist-get plist :nick) "-*" " *" t)
+           " "
+           (plist-get plist :body)))
+
+        lui-fill-type (repeat-string acdw-irc/left-margin " "))
 
   (:option lui-fill-column fill-column
            lui-time-stamp-position 'right-margin
diff --git a/lisp/acdw-irc.el b/lisp/acdw-irc.el
index 0891f31..f5e5657 100644
--- a/lisp/acdw-irc.el
+++ b/lisp/acdw-irc.el
@@ -102,6 +102,20 @@ already been connected to."
           (y-or-n-p (format "Already connected to %s, reconnect?" network)))
       (circe network)))
 
+;; the most important command ever.
+(defun circe-command-SLAP (nick)
+  "Slap NICK around with a large trout."
+  (interactive "sNick: ")
+  (if (not circe-chat-target)
+      (circe-display-server-message "No target for current buffer")
+    (let ((line    (concat "slaps " nick " around a bit with a large trout")))
+      (circe-display 'circe-format-self-action
+                     :body line 
+                     :nick (circe-nick))
+      (irc-send-ctcp (circe-server-process)
+                     circe-chat-target
+                     "ACTION" line))))
+
 
 (provide 'acdw-irc)
 ;;; acdw-irc.el ends here
-- 
cgit 1.4.1-21-gabe81