+(comment
+ (use-package message-x
+ :custom
+ (message-x-completion-alist
+ (quote
+ (("\\([rR]esent-\\|[rR]eply-\\)?[tT]o:\\|[bB]?[cC][cC]:" . gnus-harvest-find-address)
+ ((if
+ (boundp
+ (quote message-newgroups-header-regexp))
+ message-newgroups-header-regexp message-newsgroups-header-regexp)
+ . message-expand-group))))))
+
+(comment
+ (use-package gnus-harvest
+ :commands gnus-harvest-install
+ :demand t
+ :config
+ (if (featurep 'message-x)
+ (gnus-harvest-install 'message-x)
+ (gnus-harvest-install))))
+
+\f
+;;; IRC (with ERC and ZNC)
+
+(use-package erc
+ :bind (("C-c a e b" . erc-switch-to-buffer)
+ :map erc-mode-map
+ ("M-a" . erc-track-switch-buffer))
+ :custom
+ (erc-join-buffer 'bury)
+ (erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
+ (erc-nick "bandali")
+ (erc-prompt "erc>")
+ (erc-rename-buffers t)
+ (erc-server-reconnect-attempts 5)
+ (erc-server-reconnect-timeout 3)
+ :config
+ (with-eval-after-load 'ivy
+ ;; ignore channel buffer names
+ (add-to-list 'ivy-ignore-buffers "^#"))
+ (defun erc-cmd-OPME ()
+ "Request chanserv to op me."
+ (erc-message "PRIVMSG"
+ (format "chanserv op %s %s"
+ (erc-default-target)
+ (erc-current-nick)) nil))
+ (defun erc-cmd-DEOPME ()
+ "Deop myself from current channel."
+ (erc-cmd-DEOP (format "%s" (erc-current-nick))))
+ (add-to-list 'erc-modules 'keep-place)
+ (add-to-list 'erc-modules 'notifications)
+ (add-to-list 'erc-modules 'spelling)
+ (add-to-list 'erc-modules 'scrolltoplace)
+ (erc-update-modules)
+
+ (when (and (version<= "24.4" emacs-version)
+ (version< emacs-version "27"))
+ ;; fix erc-lurker bug
+ ;; patch submitted: https://bugs.gnu.org/36843#10
+ ;; TODO: remove when patch is merged and emacs 27 is released
+ (defvar erc-message-parsed)
+ (defun erc-display-message (parsed type buffer msg &rest args)
+ "Display MSG in BUFFER.
+
+ARGS, PARSED, and TYPE are used to format MSG sensibly.
+
+See also `erc-format-message' and `erc-display-line'."
+ (let ((string (if (symbolp msg)
+ (apply #'erc-format-message msg args)
+ msg))
+ (erc-message-parsed parsed))
+ (setq string
+ (cond
+ ((null type)
+ string)
+ ((listp type)
+ (mapc (lambda (type)
+ (setq string
+ (erc-display-message-highlight type string)))
+ type)
+ string)
+ ((symbolp type)
+ (erc-display-message-highlight type string))))
+
+ (if (not (erc-response-p parsed))
+ (erc-display-line string buffer)
+ (unless (erc-hide-current-message-p parsed)
+ (erc-put-text-property 0 (length string) 'erc-parsed parsed string)
+ (erc-put-text-property 0 (length string) 'rear-sticky t string)
+ (when (erc-response.tags parsed)
+ (erc-put-text-property 0 (length string) 'tags (erc-response.tags parsed)
+ string))
+ (erc-display-line string buffer)))))
+
+ (defun erc-lurker-update-status (_message)
+ "Update `erc-lurker-state' if necessary.
+
+This function is called from `erc-insert-pre-hook'. If the
+current message is a PRIVMSG, update `erc-lurker-state' to
+reflect the fact that its sender has issued a PRIVMSG at the
+current time. Otherwise, take no action.
+
+This function depends on the fact that `erc-display-message'
+lexically binds `erc-message-parsed', which is used to check if
+the current message is a PRIVMSG and to determine its sender.
+See also `erc-lurker-trim-nicks' and `erc-lurker-ignore-chars'.
+
+In order to limit memory consumption, this function also calls
+`erc-lurker-cleanup' once every `erc-lurker-cleanup-interval'
+updates of `erc-lurker-state'."
+ (when (and (boundp 'erc-message-parsed)
+ (erc-response-p erc-message-parsed))
+ (let* ((command (erc-response.command erc-message-parsed))
+ (sender
+ (erc-lurker-maybe-trim
+ (car (erc-parse-user (erc-response.sender erc-message-parsed)))))
+ (server
+ (erc-canonicalize-server-name erc-server-announced-name)))
+ (when (equal command "PRIVMSG")
+ (when (>= (cl-incf erc-lurker-cleanup-count)
+ erc-lurker-cleanup-interval)
+ (setq erc-lurker-cleanup-count 0)
+ (erc-lurker-cleanup))
+ (unless (gethash server erc-lurker-state)
+ (puthash server (make-hash-table :test 'equal) erc-lurker-state))
+ (puthash sender (current-time)
+ (gethash server erc-lurker-state))))))))
+
+(use-package erc-fill
+ :after erc
+ :custom
+ (erc-fill-column 77)
+ (erc-fill-function 'erc-fill-static)
+ (erc-fill-static-center 18))
+
+(use-package erc-pcomplete
+ :after erc
+ :custom
+ (erc-pcomplete-nick-postfix ","))
+
+(use-package erc-track
+ :after erc
+ :custom
+ (erc-track-enable-keybindings nil)
+ (erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
+ "324" "329" "332" "333" "353" "477"))
+ (erc-track-priority-faces-only 'all)
+ (erc-track-shorten-function nil))
+
+(use-package erc-hl-nicks
+ :after erc)
+
+(use-package erc-scrolltoplace
+ :after erc)
+