From 56e245ab584824a5c25b6c859c12619a61c2c5b4 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 18 Oct 2010 19:40:34 -0400 Subject: [PATCH] Add the erc-nick-notify library. Add an erc-mode-hook to enable erc-nick-notify. Add sounds/images to be used by erc-nick-notify. --- audio/beep.mp3 | Bin 0 -> 6318 bytes erc-nick-notify.el | 205 +++++++++++++++++++++++++++++++++++ images/dialog-warning.png | Bin 0 -> 1391 bytes mode-hooks.el | 1 + mode-hooks/erc-mode-hooks.el | 9 ++ 5 files changed, 215 insertions(+) create mode 100644 audio/beep.mp3 create mode 100644 erc-nick-notify.el create mode 100644 images/dialog-warning.png create mode 100644 mode-hooks/erc-mode-hooks.el diff --git a/audio/beep.mp3 b/audio/beep.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..cd3a3ecded0158e5ececd0520a73cfe59915e2a3 GIT binary patch literal 6318 zcmeI$do)yg8wc>;Tn)x$m>Ab~BFX(8<(OdzQIphUk|r}`+#~6t%#aefC7hI+ZbT$1 zB-g^Lj>=$CoDQ9E9LjNGtX%hNdjGZFwcdZuvexU_Yp>tl&)RG4XMaC??LW3F)f@%H zwZV(#WV*DfFYUX-qr=#4hfWx=!b71SCy-M>fIsVK6oBV0H7;EN5C%j5kh2tyzBLVn zhsXeuN2Ae_0EQ25u?-45IQ{jinQ7J8xbYA9daAs=bSj>E9TjYD^AoiLwOy7+sKt|H zMcs|80UC+sg-Zg5XyJWe_KW>-Dg;V)%NwV}M(b8uJYeDgZ!HYNi9ajZ25^+6 z{ac~r1igR-8l=Cqk zfDYv_?$&L^%B@Az9vjG@;-9qQ902Q$iz>kitE9#y4AO?fR3e%{g&(&xv3b0}Df390 zs)LR3#bWp5Om=7W@Odq)o0MX~n2RN3^1e3DAxLAwB(O26=it}AxC#X+(}8{0^!z@Z z2zE8)04A@f{@cR>AdkMb=aO;8nyiAvZ)^%P2?x$vjpkcuP=e$3x}-+5IvCh(xT{GC z31G;zMK4azrE9S{p02I>p>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R`BvR12qi;+z5wAr5E62-x zV4s98C96goy6G^h-98-}RrreX*;;sT|K<0mlRn%tw3G0z(YaYH7OLT{iN5V9N&%=q z+mX4oOhD0462b7ym4!igWNU0A{%1aB=|NF|EM5RgxN~dTpC0Lxa=PX(X2alg3~8dP z=3w}QdJ-xy1=)mqy&a{G05mQZg+1GdcqD07u7QLi@BoEKlCshMWamq|;}}1T!5Qi) z>Lh5L`b<>2Ou8tEKp$UUk^I`_h{gVSo|H*GCd?r7u?|wzk5}QWYoFTGX=GZUyDLK@ zA%~q=PHp}>Gb=alb9IF5@!?C3Cie1zw<b1Vh;xgg5xXlb z?=-Ug*P%;0k~f{)g5oiG|=L6okQlQqWmCUaggsz^c$n(pYYmRiWilSxLQBp_Qbu+$^g? u%cZiCdaFV!Nn^QLR)v;JWhM1ih5k1UXz6$CKf5g}^v{m4dbj_U0QfhHsJ}P> literal 0 HcmV?d00001 diff --git a/erc-nick-notify.el b/erc-nick-notify.el new file mode 100644 index 0000000..baa15c8 --- /dev/null +++ b/erc-nick-notify.el @@ -0,0 +1,205 @@ +;;; erc-nick-notify.el --- Notify popup for ERC + +;; Filename: erc-nick-notify.el +;; Description: Notify popup for ERC +;; Author: Andy Stewart lazycat.manatee@gmail.com +;; Maintainer: Andy Stewart lazycat.manatee@gmail.com +;; Copyright (C) 2008, 2009, Andy Stewart, all rights reserved. +;; Created: 2008-12-04 12:47:28 +;; Version: 0.2.1 +;; Last-Updated: 2009-01-31 10:47:32 +;; By: Andy Stewart +;; URL: http://www.emacswiki.org/emacs/download/erc-nick-notify.el +;; Keywords: erc, notify +;; Compatibility: GNU Emacs 23.0.60.1 +;; +;; Features that might be required by this library: +;; +;; `erc' +;; + +;;; This file is NOT part of GNU Emacs + +;;; License +;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth +;; Floor, Boston, MA 02110-1301, USA. + +;;; Commentary: +;; +;; Notify popup for ERC +;; +;; This extension use `notify-send' for notify. +;; So make you have install `notify-send' in your system. +;; + +;;; Installation: +;; +;; Put erc-nick-notify.el to your load-path. +;; The load-path is usually ~/elisp/. +;; It's set in your ~/.emacs like this: +;; (add-to-list 'load-path (expand-file-name "~/elisp")) +;; +;; And the following to your ~/.emacs startup file. +;; +;; (require 'erc-nick-notify) +;; +;; No need more. + +;;; Customize: +;; +;; `erc-nick-notify-delay' +;; The delay time that between two messages. +;; `erc-nick-notify-cmd' +;; The command that use for notify. +;; `erc-nick-notify-icon' +;; The file name of icon display. +;; `erc-nick-notify-timeout' +;; The timeout in milliseconds at which to expire the notification. +;; `erc-nick-notify' +;; The urgency level. +;; `erc-nick-notify-category' +;; The notification category. +;; +;; All of the above can be customize by: +;; M-x customize-group RET erc-nick-notify RET +;; + +;;; Change log: +;; +;; 2009/01/31 +;; Fix doc. +;; +;; 2008/12/21 +;; Fix `void-variable' bug. +;; +;; 2008/12/08 +;; Add customize support. +;; +;; 2008/12/04 +;; First released. +;; + +;;; Acknowledgements: +;; +;; +;; + +;;; TODO +;; +;; +;; + +;;; Require +(require 'erc) + +;;; Code: + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Customize ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defgroup erc-nick-notify nil + "Notify popup for ERC." + :group 'erc) + +(defcustom erc-nick-notify-delay '(0 5 0) + "The delay time that between two message. +Default is 5 minutes." + :type 'list + :group 'erc-nick-notify) + +(defcustom erc-nick-notify-cmd "notify-send" + "The command that use for notify." + :type 'string + :group 'erc-nick-notify) + +(defcustom erc-nick-notify-icon "~/MyEmacs/Image/Irc.png" + "Specifies an icon filename or stock icon to display." + :type 'string + :group 'erc-nick-notify) + +(defcustom erc-nick-notify-timeout 10000 + "Specifies the timeout in milliseconds at which to expire the notification." + :type 'number + :group 'erc-nick-notify) + +(defcustom erc-nick-notify-urgency "low" + "Specifies the urgency level (low, normal, critical)." + :type 'string + :group 'erc-nick-notify) + +(defcustom erc-nick-notify-category "im.received" + "Specifies the notification category." + :type 'string + :group 'erc-nick-notify) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Variable ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defvar erc-nick-notify-last '(0 0 0) + "The last time that receive message.") + +(defvar erc-nick-notify-buffer nil + "The buffer name of last notify me.") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interactive Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defun erc-nick-notify-jump-last-channel () + "Jump to last channel that notify me." + (interactive) + (if erc-nick-notify-buffer + (switch-to-buffer erc-nick-notify-buffer) + (message "Nobody notify you in IRC."))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Utilities Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defun erc-nick-notify () + "Notify me when my nick show up. +This function should be in the insert-post-hook." + (let ((now (current-time))) + (when (time-less-p erc-nick-notify-delay + (time-since erc-nick-notify-last)) + (setq erc-nick-notify-last now) + (goto-char (point-min)) + (when (re-search-forward + (concat "\\(" + "\\(<\\([^>]*\\)>\\)" ; + "\\|" + ;; 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 "<" (match-string-no-properties 3) + "> ")) + (match-string-no-properties 5)))) + (setq erc-nick-notify-buffer (buffer-name)) + (shell-command (concat erc-nick-notify-cmd + " -i " erc-nick-notify-icon + " -t " (int-to-string + erc-nick-notify-timeout) + " -u " erc-nick-notify-urgency + " -c " erc-nick-notify-category + " -- " + " \"" erc-nick-notify-buffer "\"" + " \"" + (if (boundp 'msg) + msg "") + "\""))))))) + +;; Add `erc-nick-notify' to `erc-insert-post-hook' +(add-hook 'erc-insert-post-hook 'erc-nick-notify) + +(provide 'erc-nick-notify) + +;;; erc-nick-notify.el ends here + +;;; LocalWords: erc cmd im msg lt diff --git a/images/dialog-warning.png b/images/dialog-warning.png new file mode 100644 index 0000000000000000000000000000000000000000..7233d45d8e6e41ef8fcb318c76303a9b6f23997e GIT binary patch literal 1391 zcmV-#1(5oQP)}piCG~<@Tj_&{ee%V|SZW{gB8?y>5~HGEkRU`Q5xgR16NK8$#%7av&gnyv zB_>9ji%*39&LbK3qFu zI7(%ZZ%;}2Gqh=wf?-g1;X+qD8r}8{{PEcV%0X!tqH%6yq(DC>&`hf#DjvXW3(1702fiEY= zF5vsm0&oGwD!P6+uzb1JdigTStXXLJ`Pjl?)VXtsUA;>7;>9+ps^67D`lthR!lCrM zJiGbuAzhIO`u_b0*{$vea+<+#n+u)TG0)=^W&Y8i0fonJZU{&O3K7Vlni6`w*i02KV;P{rfRu zG0etBGUm-QC7c=+fU_{mF@F3e|CA|e+x6?%3JOrCPscC}T3cI*Mx&UfiIS0lW6Kua z*4E+=1XR`QT~P`vMhu|BsqFlGD_&EBWm!0O?*~ty__PKSBsxE>~io%jH4{flNukRa8X# z{rjXQCrg{pH?0i59u|NFLJ0B8)HQ2(TUCW{yU};B)sYgKfwF=i#fQ*|T%prYYO&>#^_Jg-l9HIC3}~D2jrjDCoMLxDnFn#I<)X9Z#O% zl~TASP4c~kT|)vm3aV6;lT*TB*>>d$((gwvEKE2_WWLjh)9HL~UI>A6!v?geQ)#cO zBP%CIQ>6UickujYfDG8-Td-iF{q<|n@$@N&XN+4a)1MXii!#xt%)zy89UYGz zG12e0NnI~2gPDT@C~$aEUY=^+y^GP-hO?w((CCB^XqtxXDMlUN#ETcC z1p+4hp6CQXDP-AvzM{13Y_09qE$nO8qUGca8odyL^73*nUc5M{b0Gw_%uGDnx6}FT z856u-Rdc(;WsuwJSM3x1@yun*tghR)G2?Oc_3NRv6|2V>LcBLlv~F)$efs`;+#5F% zJ#z;0`E&f~>DJ4JhLgbjz5vpKd|!698oPE4fasPj{qtqSV!U}nQhK`b970DyKML_) z0Ovbsj@-OC=8MgnrPMUAEG)wS)5J22?y+HDnPzw2Z#-bF|D0)J#^W@