about 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.el206
1 files changed, 0 insertions, 206 deletions
diff --git a/lisp/acdw-chat.el b/lisp/acdw-chat.el deleted file mode 100644 index 9294ffe..0000000 --- a/lisp/acdw-chat.el +++ /dev/null
@@ -1,206 +0,0 @@
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(defalias 'jabber-irc-join 'jabber-biboumi-muc-connect)
55
56(defun jabber-connect-all* (&optional arg)
57 "Run `jabber-connect-all'.
58With a prefix ARG, disconnect first."
59 (interactive "p")
60 (when arg
61 (jabber-disconnect))
62 (jabber-connect-all))
63
64(defun jabber-group-yank-join-url ()
65 "Yank a url for joining the focused group."
66 (interactive)
67 (let ((s (format "xmpp:%s?join" jabber-group)))
68 (kill-new s)
69 (message s)))
70
71
72;;; Packages
73
74(use-package jabber
75 :load-path "~/src/jabber.el/"
76 :custom-face
77 (jabber-activity-face ((t :inherit jabber-chat-prompt-foreign
78 :foreground unspecified
79 :weight normal)))
80 (jabber-activity-personal-face ((t :inherit jabber-chat-prompt-local
81 :foreground unspecified
82 :weight bold)))
83 (jabber-chat-prompt-local ((t :inherit minibuffer-prompt
84 :foreground unspecified
85 :weight normal
86 :slant italic)))
87 (jabber-chat-prompt-foreign ((t :inherit warning
88 :foreground unspecified
89 :weight normal)))
90 (jabber-chat-prompt-system ((t :inherit font-lock-doc-face
91 :foreground unspecified)))
92 (jabber-rare-time-face ((t :inherit font-lock-comment-face
93 :foreground unspecified
94 :underline nil)))
95 :bind-keymap ("C-c j" . jabber-global-keymap)
96 :bind (("C-c C-SPC" . jabber-activity-switch-to))
97 :config
98 (setq jabber-account-list '(("acdw@hmm.st"))
99 jabber-auto-reconnect t
100 jabber-biboumi-server "irc.hmm.st"
101 jabber-biboumi-irc-servers '("irc.libera.chat"
102 "irc.oftc.net"
103 "irc.tilde.chat"
104 "tilde.town"
105 "m455.casa"
106 "irc.twitch.tv")
107 jabber-biboumi-default-nick "acdw"
108 jabber-last-read-marker (make-string fill-column ?.)
109 jabber-muc-decorate-presence-patterns
110 '(("\\( enters the room ([^)]+)\\| has left the chatroom\\)$" . nil)
111 ("Mode #.*" . jabber-muc-presence-dim)
112 ("." . jabber-muc-presence-dim))
113 jabber-activity-make-strings #'jabber-activity-make-strings-shorten
114 jabber-rare-time-format " - - - - - - %H:%M %F"
115 jabber-chat-header-line-format
116 '("" (jabber-chat-buffer-show-avatar
117 (:eval
118 (let ((buddy (jabber-jid-symbol jabber-chatting-with)))
119 (jabber-propertize " "
120 'display (get buddy 'avatar)))))
121 (:eval (replace-regexp-in-string "%" "%%"
122 (jabber-jid-displayname
123 jabber-chatting-with)))
124 "\t" (:eval (let ((buddy (jabber-jid-symbol jabber-chatting-with)))
125 (propertize
126 (or
127 (cdr (assoc (get buddy 'show) jabber-presence-strings))
128 (get buddy 'show))
129 'face
130 (or (cdr (assoc (get buddy 'show) jabber-presence-faces))
131 'jabber-roster-user-online))))
132 "\t" (:eval (jabber-fix-status (get (jabber-jid-symbol jabber-chatting-with) 'status)))
133 "\t" jabber-events-message
134 "\t" jabber-chatstates-message)
135 jabber-muc-header-line-format
136 '(" " (:eval (replace-regexp-in-string "%" "%%"
137 (jabber-jid-displayname
138 jabber-group)))
139 " / " jabber-muc-topic)
140 ;; buffer name formats
141 jabber-chat-buffer-format "*xmpp* %n"
142 jabber-browse-buffer-format "*xmpp-browse* %n"
143 jabber-groupchat-buffer-format "*xmpp-muc* %n"
144 jabber-muc-private-buffer-format "*xmpp-muc-private* %n"
145 ;; "prompt" (speaker) formats
146 jabber-groupchat-prompt-format (format "%%>%dn . " jabber-prefix-width)
147 jabber-chat-local-prompt-format (format "%%>%dn . " jabber-prefix-width)
148 jabber-chat-foreign-prompt-format (format "%%>%dn . " jabber-prefix-width)
149 jabber-muc-private-foreign-prompt-format "\n%g/%n . ")
150 ;; jabber muc nick coloring
151 ;; wgreenhous | I found 1.5 ok for saturation and 2.0 for value (modus)
152 ;; (setopt jabber-muc-nick-value 1.0
153 ;; jabber-muc-nick-saturation 1.0
154 ;; jabber-muc-colorize-local t
155 ;; jabber-muc-colorize-foreign t)
156 ;; When changing the above values, make sure to
157 ;; (setq jabber-muc-participant-colors nil)
158 (add-hook 'jabber-chat-mode-hook #'jabber-ui-setup)
159 (keymap-global-set "C-x C-j" #'dired-jump) ; Extremely annoying fix
160 ;; For each binding in `jabber-global-keymap', also bind the non-control
161 ;; character (lowercase)
162 (map-keymap (lambda (key command)
163 (define-key jabber-global-keymap (vector (+ key #x60)) command))
164 jabber-global-keymap)
165 (define-key jabber-global-keymap "c" #'jabber-connect-all*)
166 (require 'jabber-httpupload nil t)
167 (add-hook 'jabber-post-connect-hooks #'jabber-enable-carbons)
168 (remove-hook 'jabber-alert-muc-hooks 'jabber-muc-echo)
169 (remove-hook 'jabber-alert-presence-hooks 'jabber-presence-echo)
170 (add-hook 'jabber-alert-muc-hooks
171 (defun jabber@highlight-acdw (&optional _ _ buf _ _)
172 (when buf
173 (with-current-buffer buf
174 (let ((regexp (rx word-boundary
175 "acdw" ; maybe get from the config?
176 word-boundary)))
177 (hi-lock-unface-buffer regexp)
178 (highlight-regexp regexp 'jabber-chat-prompt-local))))))
179 (add-hook 'jabber-chat-mode-hook
180 (defun jabber-chat@leave-when-kill ()
181 (add-hook 'kill-buffer-hook
182 (defun @jabber-leave@kill ()
183 (ignore-errors
184 (apply #'jabber-muc-leave (jabber-muc-argument-list))))
185 nil :local)))
186 (when (fboundp 'jabber-chat-update-focus)
187 (add-hook 'window-configuration-change-hook #'jabber-chat-update-focus))
188 (with-eval-after-load 'consult
189 (defvar jabber-chat-buffer-source
190 `( :name "Jabber"
191 :hidden nil
192 :narrow ?j
193 :category buffer
194 :state ,#'consult--buffer-state
195 :items ,(lambda ()
196 (mapcar #'buffer-name
197 (seq-filter (lambda (buf)
198 (with-current-buffer buf
199 (eq major-mode 'jabber-chat-mode)))
200 (buffer-list))))))
201 (add-to-list 'consult-buffer-sources 'jabber-chat-buffer-source :append)
202 (consult-customize
203 consult-buffer :preview-key "M-.")))
204
205(provide 'acdw-chat)
206;;; acdw-chat.el ends here