Skip to content

Instantly share code, notes, and snippets.

@lislon
Created October 1, 2015 13:32
Show Gist options
  • Select an option

  • Save lislon/780cb6f47762603ab095 to your computer and use it in GitHub Desktop.

Select an option

Save lislon/780cb6f47762603ab095 to your computer and use it in GitHub Desktop.
;; IRC
(add-hook 'erc-insert-pre-hook
(defun bb/erc-foolish-filter (msg)
"Ignores messages matching `erc-foolish-content'."
(when (erc-list-match erc-foolish-content msg)
(setq erc-insert-this nil))))
(defun bb/erc-github-filter ()
"Shortens messages from gitter."
(interactive)
(when (and (< 18 (- (point-max) (point-min)))
(string= (buffer-substring (point-min)
(+ (point-min) 18))
"<gitter> [Github] "))
(dolist (regexp '(" \\[Github\\]"
" \\(?:in\\|to\\) [^ /]+/[^ /:]+"))
(goto-char (point-min))
(when (re-search-forward regexp (point-max) t)
(replace-match "")))
(goto-char (point-min))
(when (re-search-forward
"https?://github\\.com/[^/]+/[^/]+/[^/]+/\\([[:digit:]]+\\)\\([^[:space:]]*\\)?"
(point-max) t)
(let* ((url (match-string 0))
(number (match-string 1))
(start (+ 1 (match-beginning 0)))
(end (+ 1 (length number) start)))
(replace-match (format "(#%s)" (match-string 1)))
(erc-button-add-button start end 'browse-url nil (list url)))
)))
(with-eval-after-load 'erc
(setq erc-insert-modify-hook
'(erc-controls-highlight
erc-button-add-buttons
bb/erc-github-filter
erc-fill
erc-match-message
erc-add-timestamp
erc-hl-nicks)))
(add-hook 'erc-mode-hook 'emoji-cheat-sheet-plus-display-mode)
(with-eval-after-load 'erc
(erc-track-mode -1))
(evil-leader/set-key
"aiq" 'erc-quit-server
"aig" (defun bb/gitter ()
(interactive)
(erc-tls :server "irc.gitter.im"
:port "6667"
:nick "lislon"
:password "password from https://irc.gitter.im/"
:full-name "lislon"))
"aif" (defun bb/freenode ()
(interactive)
(erc :server "irc.freenode.net"
:port "6667"
:nick "lislon"
:full-name "lislon")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment