Skip to content

Instantly share code, notes, and snippets.

@pedrodelgallego
Created May 21, 2010 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrodelgallego/408813 to your computer and use it in GitHub Desktop.
Save pedrodelgallego/408813 to your computer and use it in GitHub Desktop.
(add-to-list 'load-path "~/.emacs.d/erc")
(require 'erc)
;; Only track my nick(s)
(defadvice erc-track-find-face (around erc-track-find-face-promote-query activate)
(if (erc-query-buffer-p)
(setq ad-return-value (intern "erc-current-nick-face"))
ad-do-it))
(setq erc-keywords '("Lau" "lau" "ljensen"))
(setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
"324" "329" "332" "333" "353" "477"))
;; Use libnotify
(defun clean-message (s)
(setq s (replace-regexp-in-string "'" "'"
(replace-regexp-in-string "\"" """
(replace-regexp-in-string "&" "&"
(replace-regexp-in-string "<" "&lt;"
(replace-regexp-in-string ">" "&gt;" s)))))))
(defun call-libnotify (matched-type nick msg)
(let* ((cmsg (split-string (clean-message msg)))
(nick (first (split-string nick "!")))
(msg (mapconcat 'identity (rest cmsg) " ")))
(shell-command-to-string
(format "notify-send -u critical '%s says:' '%s'" nick msg))))
(add-hook 'erc-text-matched-hook 'call-libnotify)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment