From 2d2cab9d97d3e84e5b7158181523fe2c5bbffe85 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 16 Apr 2023 17:06:41 -0500 Subject: uhhh --- lisp/acdw-chat.el | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 lisp/acdw-chat.el (limited to 'lisp/acdw-chat.el') diff --git a/lisp/acdw-chat.el b/lisp/acdw-chat.el new file mode 100644 index 0000000..62dcf72 --- /dev/null +++ b/lisp/acdw-chat.el @@ -0,0 +1,174 @@ +;;; acdw-chat.el --- Chat applications (mostly jabber) -*- lexical-binding: t; -*- + +;;; Code: + +(defcustom jabber-prefix-width 10 + "Width of jabber prompts and other prefixes." + :type 'number + :group 'jabber) + +(defun jabber-ui-setup () + "Setup the `jabber' user interface." + (visual-fill-column-mode) + (electric-pair-local-mode -1) + (auto-fill-mode -1) + (setq-local wrap-prefix (make-string (+ 3 jabber-prefix-width) #x20) + visual-fill-column-extra-text-width `(,(+ 3 jabber-prefix-width) + . 1))) + +(defcustom jabber-biboumi-server "localhost" + "Biboumi server for `jabber-biboumi-muc-connect'." + :type 'string + :group 'jabber) + +(defcustom jabber-biboumi-irc-servers '("irc.libera.chat") + "IRC servers for the user to choose from with `jabber-biboumi-muc-connect'." + :type '(repeat string) + :group 'jabber) + +(defcustom jabber-biboumi-default-nick "" + "Default nick for biboumi rooms." + :type 'string + :group 'jabber) + +(defun jabber-biboumi-muc-connect (channel server nick &optional biboumi-server) + "Connect to a biboumi (IRC gateway) server MUC. +CHANNEL, SERVER, NICK, and BIBOUMI-SERVER are passed to +`jabber-muc-join'. If BIBOUMI-SERVER isn't given, +`jabber-biboumi-server' is used." + (interactive (list (concat "#" (string-remove-prefix "#" (read-string + "Channel: "))) + (completing-read "Server: " jabber-biboumi-irc-servers) + (read-string (format "Nick [%s]: " + jabber-biboumi-default-nick) + nil nil jabber-biboumi-default-nick))) + (let ((room (format "%s%%%s@%s" channel server (or biboumi-server + jabber-biboumi-server)))) + (if (assoc room *jabber-active-groupchats*) + (switch-to-buffer (jabber-muc-get-buffer room)) + (jabber-muc-join (jabber-read-account) + room + nick + 'popup)))) + +(defun jabber-group-yank-join-url () + "Yank a url for joining the focused group." + (interactive) + (let ((s (format "xmpp:%s?join" jabber-group))) + (kill-new s) + (message s))) + + +;;; Packages + +(use-package jabber + :load-path "~/src/emacs/jabber/" + :custom-face + (jabber-activity-face ((t :inherit jabber-chat-prompt-foreign + :foreground unspecified + :weight normal))) + (jabber-activity-personal-face ((t :inherit jabber-chat-prompt-local + :foreground unspecified + :weight bold))) + (jabber-chat-prompt-local ((t :inherit minibuffer-prompt + :foreground unspecified + :weight normal + :slant italic))) + (jabber-chat-prompt-foreign ((t :inherit warning + :foreground unspecified + :weight normal))) + (jabber-chat-prompt-system ((t :inherit font-lock-doc-face + :foreground unspecified))) + (jabber-rare-time-face ((t :inherit font-lock-comment-face + :foreground unspecified + :underline nil))) + :bind-keymap ("C-c j" . jabber-global-keymap) + :bind (("C-c C-SPC" . jabber-activity-switch-to)) + :config + (setopt jabber-account-list '(("acdw@hmm.st")) + jabber-auto-reconnect t + jabber-biboumi-server "irc.hmm.st" + jabber-biboumi-irc-servers '("irc.libera.chat" + "irc.tilde.chat" + "tilde.town" + "m455.casa" + "irc.twitch.tv") + jabber-biboumi-default-nick "acdw" + jabber-last-read-marker (make-string fill-column ?.) + jabber-muc-decorate-presence-patterns + '(("\\( enters the room ([^)]+)\\| has left the chatroom\\)$" . nil) + ("Mode #.*" . jabber-muc-presence-dim) + ("." . jabber-muc-presence-dim)) + jabber-activity-make-strings #'jabber-activity-make-strings-shorten + jabber-rare-time-format " - - - - - - %H:%M %F" + jabber-muc-header-line-format + '(" " (:eval (replace-regexp-in-string "%" "%%" + (jabber-jid-displayname + jabber-group))) + " / " jabber-muc-topic) + ;; buffer name formats + jabber-chat-buffer-format "*xmpp* %n" + jabber-browse-buffer-format "*xmpp-browse* %n" + jabber-groupchat-buffer-format "*xmpp-muc* %n" + jabber-muc-private-buffer-format "*xmpp-muc-private* %n" + ;; "prompt" (speaker) formats + jabber-groupchat-prompt-format (format "%%>%dn . " jabber-prefix-width) + jabber-chat-local-prompt-format (format "%%>%dn . " jabber-prefix-width) + jabber-chat-foreign-prompt-format (format "%%>%dn . " jabber-prefix-width) + jabber-muc-private-foreign-prompt-format "\n%g/%n . ") + ;; jabber muc nick coloring + ;; wgreenhous | I found 1.5 ok for saturation and 2.0 for value (modus) + ;; (setopt jabber-muc-nick-value 1.0 + ;; jabber-muc-nick-saturation 1.0 + ;; jabber-muc-colorize-local t + ;; jabber-muc-colorize-foreign t) + ;; When changing the above values, make sure to + ;; (setq jabber-muc-participant-colors nil) + (add-hook 'jabber-chat-mode-hook #'jabber-ui-setup) + (keymap-global-set "C-x C-j" #'dired-jump) ; Extremely annoying fix + ;; For each binding in `jabber-global-keymap', also bind the non-control + ;; character (lowercase) + (map-keymap (lambda (key command) + (define-key jabber-global-keymap (vector (+ key #x60)) command)) + jabber-global-keymap) + (require 'jabber-httpupload nil t) + (add-hook 'jabber-post-connect-hooks #'jabber-enable-carbons) + (remove-hook 'jabber-alert-muc-hooks 'jabber-muc-echo) + (remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo) + (add-hook 'jabber-alert-muc-hooks + (defun jabber@highlight-acdw (&optional _ _ buf _ _) + (when buf + (with-current-buffer buf + (let ((regexp (rx word-boundary + "acdw" ; maybe get from the config? + word-boundary))) + (hi-lock-unface-buffer regexp) + (highlight-regexp regexp 'jabber-chat-prompt-local)))))) + (add-hook 'jabber-chat-mode-hook + (defun jabber-chat@leave-when-kill () + (add-hook 'kill-buffer-hook + (defun @jabber-leave@kill () + (ignore-errors + (apply #'jabber-muc-leave (jabber-muc-argument-list)))) + nil :local))) + (when (fboundp 'jabber-chat-update-focus) + (add-hook 'window-configuration-change-hook #'jabber-chat-update-focus)) + (with-eval-after-load 'consult + (defvar jabber-chat-buffer-source + `( :name "Jabber" + :hidden nil + :narrow ?j + :category buffer + :state ,#'consult--buffer-state + :items ,(lambda () + (mapcar #'buffer-name + (seq-filter (lambda (buf) + (with-current-buffer buf + (eq major-mode 'jabber-chat-mode))) + (buffer-list)))))) + (add-to-list 'consult-buffer-sources 'jabber-chat-buffer-source :append) + (consult-customize + consult-buffer :preview-key "M-."))) + +(provide 'acdw-chat) +;;; acdw-chat.el ends here -- cgit 1.4.1-21-gabe81