summary refs log tree commit diff stats
path: root/lisp/acdw-chat.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/acdw-chat.el')
-rw-r--r--lisp/acdw-chat.el174
1 files changed, 174 insertions, 0 deletions
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 @@
1;;; acdw-chat.el --- Chat applications (mostly jabber) -*- lexical-binding: t; -*-
2
3;;; Code:
4
5(defcustom jabber-prefix-width 10
6 "Width of jabber prompts and other prefixes."
7 :type 'number
8 :group 'jabber)
9
10(defun jabber-ui-setup ()
11 "Setup the `jabber' user interface."
12 (visual-fill-column-mode)
13 (electric-pair-local-mode -1)
14 (auto-fill-mode -1)
15 (setq-local wrap-prefix (make-string (+ 3 jabber-prefix-width) #x20)
16 visual-fill-column-extra-text-width `(,(+ 3 jabber-prefix-width)
17 . 1)))
18
19(defcustom jabber-biboumi-server "localhost"
20 "Biboumi server for `jabber-biboumi-muc-connect'."
21 :type 'string
22 :group 'jabber)
23
24(defcustom jabber-biboumi-irc-servers '("irc.libera.chat")
25 "IRC servers for the user to choose from with `jabber-biboumi-muc-connect'."
26 :type '(repeat string)
27 :group 'jabber)
28
29(defcustom jabber-biboumi-default-nick ""
30 "Default nick for biboumi rooms."
31 :type 'string
32 :group 'jabber)
33
34(defun jabber-biboumi-muc-connect (channel server nick &optional biboumi-server)
35 "Connect to a biboumi (IRC gateway) server MUC.
36CHANNEL, SERVER, NICK, and BIBOUMI-SERVER are passed to
37`jabber-muc-join'. If BIBOUMI-SERVER isn't given,
38`jabber-biboumi-server' is used."
39 (interactive (list (concat "#" (string-remove-prefix "#" (read-string
40 "Channel: ")))
41 (completing-read "Server: " jabber-biboumi-irc-servers)
42 (read-string (format "Nick [%s]: "
43 jabber-biboumi-default-nick)
44 nil nil jabber-biboumi-default-nick)))
45 (let ((room (format "%s%%%s@%s" channel server (or biboumi-server
46 jabber-biboumi-server))))
47 (if (assoc room *jabber-active-groupchats*)
48 (switch-to-buffer (jabber-muc-get-buffer room))
49 (jabber-muc-join (jabber-read-account)
50 room
51 nick
52 'popup))))
53
54(defun jabber-group-yank-join-url ()
55 "Yank a url for joining the focused group."
56 (interactive)
57 (let ((s (format "xmpp:%s?join" jabber-group)))
58 (kill-new s)
59 (message s)))
60
61
62;;; Packages
63
64(use-package jabber
65 :load-path "~/src/emacs/jabber/"
66 :custom-face
67 (jabber-activity-face ((t :inherit jabber-chat-prompt-foreign
68 :foreground unspecified
69 :weight normal)))
70 (jabber-activity-personal-face ((t :inherit jabber-chat-prompt-local
71 :foreground unspecified
72 :weight bold)))
73 (jabber-chat-prompt-local ((t :inherit minibuffer-prompt
74 :foreground unspecified
75 :weight normal
76 :slant italic)))
77 (jabber-chat-prompt-foreign ((t :inherit warning
78 :foreground unspecified
79 :weight normal)))
80 (jabber-chat-prompt-system ((t :inherit font-lock-doc-face
81 :foreground unspecified)))
82 (jabber-rare-time-face ((t :inherit font-lock-comment-face
83 :foreground unspecified
84 :underline nil)))
85 :bind-keymap ("C-c j" . jabber-global-keymap)
86 :bind (("C-c C-SPC" . jabber-activity-switch-to))
87 :config
88 (setopt jabber-account-list '(("acdw@hmm.st"))
89 jabber-auto-reconnect t
90 jabber-biboumi-server "irc.hmm.st"
91 jabber-biboumi-irc-servers '("irc.libera.chat"
92 "irc.tilde.chat"
93 "tilde.town"
94 "m455.casa"
95 "irc.twitch.tv")
96 jabber-biboumi-default-nick "acdw"
97 jabber-last-read-marker (make-string fill-column ?.)
98 jabber-muc-decorate-presence-patterns
99 '(("\\( enters the room ([^)]+)\\| has left the chatroom\\)$" . nil)
100 ("Mode #.*" . jabber-muc-presence-dim)
101 ("." . jabber-muc-presence-dim))
102 jabber-activity-make-strings #'jabber-activity-make-strings-shorten
103 jabber-rare-time-format " - - - - - - %H:%M %F"
104 jabber-muc-header-line-format
105 '(" " (:eval (replace-regexp-in-string "%" "%%"
106 (jabber-jid-displayname
107 jabber-group)))
108 " / " jabber-muc-topic)
109 ;; buffer name formats
110 jabber-chat-buffer-format "*xmpp* %n"
111 jabber-browse-buffer-format "*xmpp-browse* %n"
112 jabber-groupchat-buffer-format "*xmpp-muc* %n"
113 jabber-muc-private-buffer-format "*xmpp-muc-private* %n"
114 ;; "prompt" (speaker) formats
115 jabber-groupchat-prompt-format (format "%%>%dn . " jabber-prefix-width)
116 jabber-chat-local-prompt-format (format "%%>%dn . " jabber-prefix-width)
117 jabber-chat-foreign-prompt-format (format "%%>%dn . " jabber-prefix-width)
118 jabber-muc-private-foreign-prompt-format "\n%g/%n . ")
119 ;; jabber muc nick coloring
120 ;; wgreenhous | I found 1.5 ok for saturation and 2.0 for value (modus)
121 ;; (setopt jabber-muc-nick-value 1.0
122 ;; jabber-muc-nick-saturation 1.0
123 ;; jabber-muc-colorize-local t
124 ;; jabber-muc-colorize-foreign t)
125 ;; When changing the above values, make sure to
126 ;; (setq jabber-muc-participant-colors nil)
127 (add-hook 'jabber-chat-mode-hook #'jabber-ui-setup)
128 (keymap-global-set "C-x C-j" #'dired-jump) ; Extremely annoying fix
129 ;; For each binding in `jabber-global-keymap', also bind the non-control
130 ;; character (lowercase)
131 (map-keymap (lambda (key command)
132 (define-key jabber-global-keymap (vector (+ key #x60)) command))
133 jabber-global-keymap)
134 (require 'jabber-httpupload nil t)
135 (add-hook 'jabber-post-connect-hooks #'jabber-enable-carbons)
136 (remove-hook 'jabber-alert-muc-hooks 'jabber-muc-echo)
137 (remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo)
138 (add-hook 'jabber-alert-muc-hooks
139 (defun jabber@highlight-acdw (&optional _ _ buf _ _)
140 (when buf
141 (with-current-buffer buf
142 (let ((regexp (rx word-boundary
143 "acdw" ; maybe get from the config?
144 word-boundary)))
145 (hi-lock-unface-buffer regexp)
146 (highlight-regexp regexp 'jabber-chat-prompt-local))))))
147 (add-hook 'jabber-chat-mode-hook
148 (defun jabber-chat@leave-when-kill ()
149 (add-hook 'kill-buffer-hook
150 (defun @jabber-leave@kill ()
151 (ignore-errors
152 (apply #'jabber-muc-leave (jabber-muc-argument-list))))
153 nil :local)))
154 (when (fboundp 'jabber-chat-update-focus)
155 (add-hook 'window-configuration-change-hook #'jabber-chat-update-focus))
156 (with-eval-after-load 'consult
157 (defvar jabber-chat-buffer-source
158 `( :name "Jabber"
159 :hidden nil
160 :narrow ?j
161 :category buffer
162 :state ,#'consult--buffer-state
163 :items ,(lambda ()
164 (mapcar #'buffer-name
165 (seq-filter (lambda (buf)
166 (with-current-buffer buf
167 (eq major-mode 'jabber-chat-mode)))
168 (buffer-list))))))
169 (add-to-list 'consult-buffer-sources 'jabber-chat-buffer-source :append)
170 (consult-customize
171 consult-buffer :preview-key "M-.")))
172
173(provide 'acdw-chat)
174;;; acdw-chat.el ends here