2017-06-11 01:49:39 +02:00
|
|
|
;;; app/irc/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
2017-06-11 16:09:09 +02:00
|
|
|
(defvar +irc-left-padding 13
|
2018-04-02 08:07:44 +02:00
|
|
|
"By how much spaces the left hand side of the line should be padded.
|
|
|
|
Below a value of 12 this may result in uneven alignment between the various
|
|
|
|
types of messages.")
|
2017-06-11 16:09:09 +02:00
|
|
|
|
2017-08-06 12:54:09 +02:00
|
|
|
(defvar +irc-truncate-nick-char ?…
|
|
|
|
"Character to displayed when nick > `+irc-left-padding' in length.")
|
|
|
|
|
2017-07-20 22:55:34 +02:00
|
|
|
(defvar +irc-scroll-to-bottom-on-commands
|
|
|
|
'(self-insert-command yank hilit-yank)
|
|
|
|
"If these commands are called pre prompt the buffer will scroll to `point-max'.")
|
|
|
|
|
2017-06-11 16:09:09 +02:00
|
|
|
(defvar +irc-disconnect-hook nil
|
2018-04-02 08:07:44 +02:00
|
|
|
"Runs each hook when circe noticies the connection has been disconnected.
|
|
|
|
Useful for scenarios where an instant reconnect will not be successful.")
|
2017-06-11 16:09:09 +02:00
|
|
|
|
|
|
|
(defvar +irc-bot-list '("fsbot" "rudybot")
|
2018-04-02 08:07:44 +02:00
|
|
|
"Nicks listed have `circe-fool-face' applied and will not be tracked.")
|
2017-06-11 16:09:09 +02:00
|
|
|
|
|
|
|
(defvar +irc-time-stamp-format "%H:%M"
|
2018-04-02 08:07:44 +02:00
|
|
|
"The format of time stamps.
|
|
|
|
|
|
|
|
See `format-time-string' for a full description of available
|
|
|
|
formatting directives. ")
|
2017-06-11 16:09:09 +02:00
|
|
|
|
|
|
|
(defvar +irc-notifications-watch-strings nil
|
2018-04-02 08:07:44 +02:00
|
|
|
"A list of strings which can trigger a notification. You don't need to put
|
|
|
|
your nick here.
|
|
|
|
|
|
|
|
See `circe-notifications-watch-strings'.")
|
2017-06-11 01:49:39 +02:00
|
|
|
|
2017-06-12 12:37:38 +02:00
|
|
|
(defvar +irc-defer-notifications nil
|
|
|
|
"How long to defer enabling notifications, in seconds (e.g. 5min = 300).
|
|
|
|
Useful for ZNC users who want to avoid the deluge of notifications during buffer
|
|
|
|
playback.")
|
|
|
|
|
2017-06-12 14:35:41 +02:00
|
|
|
(defvar +irc--defer-timer nil)
|
|
|
|
|
2017-07-14 18:19:08 +02:00
|
|
|
(defsubst +irc--pad (left right)
|
|
|
|
(format (format "%%%ds | %%s" +irc-left-padding)
|
|
|
|
(concat "*** " left) right))
|
|
|
|
|
2017-06-11 01:49:39 +02:00
|
|
|
|
|
|
|
;;
|
2018-09-07 19:36:16 -04:00
|
|
|
;; Packages
|
2017-06-11 01:49:39 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! circe
|
2019-07-23 12:30:47 +02:00
|
|
|
:commands circe circe-server-buffers
|
2017-06-12 12:37:38 +02:00
|
|
|
:init (setq circe-network-defaults nil)
|
2017-06-11 01:49:39 +02:00
|
|
|
:config
|
2017-06-12 12:37:38 +02:00
|
|
|
(setq circe-default-quit-message nil
|
|
|
|
circe-default-part-message nil
|
|
|
|
circe-use-cycle-completion t
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-reduce-lurker-spam t
|
|
|
|
|
|
|
|
circe-format-say (format "{nick:+%ss} │ {body}" +irc-left-padding)
|
|
|
|
circe-format-self-say circe-format-say
|
|
|
|
circe-format-action (format "{nick:+%ss} * {body}" +irc-left-padding)
|
|
|
|
circe-format-self-action circe-format-action
|
2018-04-02 07:53:51 +02:00
|
|
|
circe-format-server-notice
|
|
|
|
(let ((left "-Server-")) (concat (make-string (- +irc-left-padding (length left)) ? )
|
|
|
|
(concat left " _ {body}")))
|
|
|
|
circe-format-notice (format "{nick:%ss} _ {body}" +irc-left-padding)
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-format-server-topic
|
2017-06-12 12:37:38 +02:00
|
|
|
(+irc--pad "Topic" "{userhost}: {topic-diff}")
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-format-server-join-in-channel
|
2017-06-12 12:37:38 +02:00
|
|
|
(+irc--pad "Join" "{nick} ({userinfo}) joined {channel}")
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-format-server-join
|
2017-06-12 12:37:38 +02:00
|
|
|
(+irc--pad "Join" "{nick} ({userinfo})")
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-format-server-part
|
2017-06-12 12:37:38 +02:00
|
|
|
(+irc--pad "Part" "{nick} ({userhost}) left {channel}: {reason}")
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-format-server-quit
|
2017-06-12 12:37:38 +02:00
|
|
|
(+irc--pad "Quit" "{nick} ({userhost}) left IRC: {reason}]")
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-format-server-quit-channel
|
2017-06-12 12:37:38 +02:00
|
|
|
(+irc--pad "Quit" "{nick} ({userhost}) left {channel}: {reason}]")
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-format-server-rejoin
|
2017-06-12 12:37:38 +02:00
|
|
|
(+irc--pad "Re-join" "{nick} ({userhost}), left {departuredelta} ago")
|
2018-04-02 07:53:51 +02:00
|
|
|
circe-format-server-netmerge
|
|
|
|
(+irc--pad "Netmerge" "{split}, split {ago} ago (Use /WL to see who's still missing)")
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-format-server-nick-change
|
2017-06-12 12:37:38 +02:00
|
|
|
(+irc--pad "Nick" "{old-nick} ({userhost}) is now known as {new-nick}")
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-format-server-nick-change-self
|
2017-06-12 12:37:38 +02:00
|
|
|
(+irc--pad "Nick" "You are now known as {new-nick} ({old-nick})")
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-format-server-nick-change-self
|
2017-06-12 12:37:38 +02:00
|
|
|
(+irc--pad "Nick" "{old-nick} ({userhost}) is now known as {new-nick}")
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-format-server-mode-change
|
2017-06-12 12:37:38 +02:00
|
|
|
(+irc--pad "Mode" "{change} on {target} by {setter} ({userhost})")
|
2017-06-11 01:49:39 +02:00
|
|
|
circe-format-server-lurker-activity
|
2017-06-12 12:37:38 +02:00
|
|
|
(+irc--pad "Lurk" "{nick} joined {joindelta} ago"))
|
|
|
|
|
2019-07-29 12:18:08 +02:00
|
|
|
(add-hook 'doom-real-buffer-functions #'+circe-buffer-p)
|
2017-06-17 14:07:53 +02:00
|
|
|
(add-hook 'circe-channel-mode-hook #'turn-on-visual-line-mode)
|
2019-07-29 12:18:08 +02:00
|
|
|
(add-hook 'circe-mode-hook #'+irc--add-circe-buffer-to-persp-h)
|
2017-06-11 01:49:39 +02:00
|
|
|
|
2019-07-23 17:24:56 +02:00
|
|
|
(defadvice! +irc--circe-run-disconnect-hook-a (&rest _)
|
|
|
|
"Runs `+irc-disconnect-hook' after circe disconnects."
|
2019-07-23 12:30:47 +02:00
|
|
|
:after #'circe--irc-conn-disconnected
|
2018-04-02 08:08:13 +02:00
|
|
|
(run-hooks '+irc-disconnect-hook))
|
2019-07-23 12:30:47 +02:00
|
|
|
|
2019-07-26 19:57:13 +02:00
|
|
|
(add-hook! 'lui-pre-output-hook
|
2019-07-23 12:30:47 +02:00
|
|
|
(defun +irc-circe-truncate-nicks-h ()
|
|
|
|
"Truncate long nicknames in chat output non-destructively."
|
|
|
|
(when-let (beg (text-property-any (point-min) (point-max) 'lui-format-argument 'nick))
|
|
|
|
(goto-char beg)
|
|
|
|
(let ((end (next-single-property-change beg 'lui-format-argument))
|
|
|
|
(nick (plist-get (plist-get (text-properties-at beg) 'lui-keywords)
|
|
|
|
:nick)))
|
|
|
|
(when (> (length nick) +irc-left-padding)
|
|
|
|
(compose-region (+ beg +irc-left-padding -1) end
|
|
|
|
+irc-truncate-nick-char))))))
|
|
|
|
|
2019-07-26 19:57:13 +02:00
|
|
|
(add-hook! 'circe-message-option-functions
|
2019-07-23 12:30:47 +02:00
|
|
|
(defun +irc-circe-message-option-bot-h (nick &rest ignored)
|
|
|
|
"Fontify known bots and mark them to not be tracked."
|
|
|
|
(when (member nick +irc-bot-list)
|
|
|
|
'((text-properties . (face circe-fool-face lui-do-not-track t))))))
|
|
|
|
|
2019-01-23 15:54:12 -05:00
|
|
|
;; Let `+irc/quit' and `circe' handle buffer cleanup
|
|
|
|
(define-key circe-mode-map [remap kill-buffer] #'bury-buffer)
|
|
|
|
;; Fail gracefully if not in a circe buffer
|
2019-01-22 13:56:34 -08:00
|
|
|
(global-set-key [remap tracking-next-buffer] #'+irc/tracking-next-buffer)
|
2019-01-21 17:20:22 -08:00
|
|
|
|
2018-10-07 21:32:42 -04:00
|
|
|
(map! :localleader
|
2018-12-22 04:36:51 -05:00
|
|
|
(:map circe-mode-map
|
2019-01-23 15:54:12 -05:00
|
|
|
"a" #'tracking-next-buffer
|
2018-12-22 04:36:51 -05:00
|
|
|
"j" #'circe-command-JOIN
|
|
|
|
"m" #'+irc/send-message
|
|
|
|
"p" #'circe-command-PART
|
|
|
|
"Q" #'+irc/quit
|
|
|
|
"R" #'circe-reconnect
|
|
|
|
(:when (featurep! :completion ivy)
|
|
|
|
"c" #'+irc/ivy-jump-to-channel))
|
|
|
|
(:map circe-channel-mode-map
|
|
|
|
"n" #'circe-command-NAMES)))
|
2017-06-12 12:37:38 +02:00
|
|
|
|
2017-06-11 01:49:39 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! circe-color-nicks
|
2017-12-08 22:33:12 -05:00
|
|
|
:hook (circe-channel-mode . enable-circe-color-nicks)
|
2017-06-11 01:49:39 +02:00
|
|
|
:config
|
|
|
|
(setq circe-color-nicks-min-constrast-ratio 4.5
|
|
|
|
circe-color-nicks-everywhere t))
|
|
|
|
|
2017-06-11 16:09:09 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! circe-new-day-notifier
|
2017-06-17 14:07:53 +02:00
|
|
|
:after circe
|
2017-06-12 12:37:38 +02:00
|
|
|
:config
|
2017-06-17 14:07:53 +02:00
|
|
|
(enable-circe-new-day-notifier)
|
2017-06-12 12:37:38 +02:00
|
|
|
(setq circe-new-day-notifier-format-message
|
|
|
|
(+irc--pad "Day" "Date changed [{day}]")))
|
2017-06-11 01:49:39 +02:00
|
|
|
|
2017-06-11 16:09:09 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! circe-notifications
|
2017-06-11 01:49:39 +02:00
|
|
|
:commands enable-circe-notifications
|
2017-06-12 12:37:38 +02:00
|
|
|
:init
|
|
|
|
(if +irc-defer-notifications
|
|
|
|
(add-hook! 'circe-server-connected-hook
|
2017-06-12 14:35:41 +02:00
|
|
|
(setq +irc--defer-timer
|
|
|
|
(run-at-time +irc-defer-notifications nil
|
|
|
|
#'enable-circe-notifications)))
|
2017-06-12 12:37:38 +02:00
|
|
|
(add-hook 'circe-server-connected-hook #'enable-circe-notifications))
|
|
|
|
:config
|
|
|
|
(setq circe-notifications-watch-strings +irc-notifications-watch-strings
|
|
|
|
circe-notifications-emacs-focused nil
|
|
|
|
circe-notifications-alert-style
|
|
|
|
(cond (IS-MAC 'osx-notifier)
|
2019-07-29 12:18:08 +02:00
|
|
|
(IS-LINUX 'libnotify)
|
|
|
|
(circe-notifications-alert-style))))
|
2017-06-11 01:49:39 +02:00
|
|
|
|
2017-06-11 16:09:09 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! lui
|
2017-06-11 01:49:39 +02:00
|
|
|
:commands lui-mode
|
|
|
|
:config
|
2018-06-03 15:46:00 +02:00
|
|
|
(define-key lui-mode-map "\C-u" #'lui-kill-to-beginning-of-line)
|
2018-06-04 09:17:04 +02:00
|
|
|
(setq lui-fill-type nil)
|
|
|
|
|
2019-02-22 00:20:29 -05:00
|
|
|
(when (featurep! :tools flyspell)
|
2018-06-04 09:17:04 +02:00
|
|
|
(setq lui-flyspell-p t))
|
2017-06-11 16:09:09 +02:00
|
|
|
|
2017-06-17 14:07:53 +02:00
|
|
|
(after! evil
|
2019-07-23 12:30:47 +02:00
|
|
|
(defun +irc-evil-insert-h ()
|
2017-06-17 14:07:53 +02:00
|
|
|
"Ensure entering insert mode will put us at the prompt, unless editing
|
|
|
|
after prompt marker."
|
|
|
|
(when (> (marker-position lui-input-marker) (point))
|
2017-06-24 20:24:20 +02:00
|
|
|
(goto-char (point-max))))
|
2017-06-17 14:07:53 +02:00
|
|
|
|
|
|
|
(add-hook! 'lui-mode-hook
|
2019-07-26 19:57:13 +02:00
|
|
|
(add-hook 'evil-insert-state-entry-hook #'+irc-evil-insert-h
|
|
|
|
nil 'local))
|
2017-07-20 22:55:34 +02:00
|
|
|
|
2017-12-08 22:57:08 -05:00
|
|
|
(mapc (lambda (cmd) (push cmd +irc-scroll-to-bottom-on-commands))
|
2017-07-20 22:55:34 +02:00
|
|
|
'(evil-paste-after evil-paste-before evil-open-above evil-open-below)))
|
|
|
|
|
|
|
|
|
2019-07-23 12:30:47 +02:00
|
|
|
(defun +irc-preinput-scroll-to-bottom-h ()
|
2017-07-20 22:55:34 +02:00
|
|
|
"Go to the end of the buffer in all windows showing it.
|
|
|
|
Courtesy of esh-mode.el"
|
|
|
|
(when (memq this-command +irc-scroll-to-bottom-on-commands)
|
|
|
|
(let* ((selected (selected-window))
|
|
|
|
(current (current-buffer)))
|
|
|
|
(when (> (marker-position lui-input-marker) (point))
|
|
|
|
(walk-windows
|
|
|
|
(function
|
|
|
|
(lambda (window)
|
|
|
|
(when (eq (window-buffer window) current)
|
|
|
|
(select-window window)
|
|
|
|
(goto-char (point-max))
|
|
|
|
(select-window selected))))
|
|
|
|
nil t)))))
|
|
|
|
|
|
|
|
(add-hook! 'lui-mode-hook
|
2019-07-23 12:30:47 +02:00
|
|
|
(add-hook 'pre-command-hook #'+irc-preinput-scroll-to-bottom-h nil t))
|
2017-06-17 14:07:53 +02:00
|
|
|
|
2019-02-05 11:06:21 -08:00
|
|
|
;; enable a horizontal line marking the last read message
|
2019-07-23 12:30:47 +02:00
|
|
|
(add-hook 'lui-mode-hook #'enable-lui-track-bar)
|
2017-06-17 14:07:53 +02:00
|
|
|
|
2019-07-23 12:30:47 +02:00
|
|
|
(add-hook! 'lui-mode-hook
|
|
|
|
(defun +irc-init-lui-margins-h ()
|
|
|
|
(setq lui-time-stamp-position 'right-margin
|
|
|
|
lui-time-stamp-format +irc-time-stamp-format
|
|
|
|
right-margin-width (length (format-time-string lui-time-stamp-format))))
|
|
|
|
(defun +irc-init-lui-wrapping-a ()
|
|
|
|
(setq fringes-outside-margins t
|
|
|
|
word-wrap t
|
|
|
|
wrap-prefix (make-string (+ +irc-left-padding 3) ? )))))
|
2017-06-11 01:49:39 +02:00
|
|
|
|
2017-06-11 16:09:09 +02:00
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! lui-logging
|
2017-06-17 14:07:53 +02:00
|
|
|
:after lui
|
|
|
|
:config (enable-lui-logging))
|
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! lui-autopaste
|
2017-12-08 22:33:12 -05:00
|
|
|
:hook (circe-channel-mode . enable-lui-autopaste))
|