After I first saw libnotify with ircII, I thought “I can do that in Emacs!” This past weekend, I finally got around to doing it. (Note that for this demonstration, I send myself a stupid message from… ircII.) Here’s the magical bits:
(defvar mah/erc-nick-notify-last '(0 0 0)) (defvar mah/erc-nick-ntify-delay '(0 5 0)) (defvar mah/erc-nick-notify-cmd "notify-send") (defvar mah/erc-nick-notify-icon "/usr/share/icons/default.kde/48x48/apps/edu_languages.png") (defvar mah/erc-nick-notify-timeout 10000) (defvar mah/erc-nick-notify-urgency "low"); (defvar mah/erc-nick-notify-category "im.received"); (defun mah/erc-nick-notify () "Notify me when my nick shows up. This function should be in the insert-post-hook." (let ((now (current-time))) (when (time-less-p mah/erc-nick-notify-delay (time-since mah/erc-nick-notify-last)) (setq mah/erc-nick-notify-last now) (goto-char (point-min)) (when (re-search-forward (concat "^\\(" "\\(<\\([^>]*\\)\>\\)" ; <someone> "\\|" ;; Don't match if we're saying something "\\(\\* " (regexp-quote (erc-current-nick)) "\\)" "\\)" "\\(.*" (regexp-quote (erc-current-nick)) ".*\\)") nil t) (let ((msg (concat (when (> (length (match-string-no-properties 2)) 0) (concat "<b><" (match-string-no-properties 3) "></b> ")) (match-string-no-properties 5)))) (shell-command (concat mah/erc-nick-notify-cmd " -i " mah/erc-nick-notify-icon " -t " (int-to-string mah/erc-nick-notify-timeout) " -u " mah/erc-nick-notify-urgency " -c " mah/erc-nick-notify-category " -- " "'" (buffer-name) "'" " '" msg "'")))))))