;;; $Id: .emacs-chat.el,v 1.1 2008/05/17 13:31:28 minh Exp minh $ ;;; Copyright (c) 2006, 2007 Nhat Minh LĂȘ. All rights reserved. ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; 1. Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; ;;; 2. Redistributions in binary form must reproduce the above ;;; copyright notice, this list of conditions and the following ;;; disclaimer in the documentation and/or other materials provided ;;; with the distribution. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; Minh's .emacs chat configuration (setq erc-modules '(autojoin fill irccontrols log match netsplit noncommands notify pcomplete completion readonly ring scrolltobottom stamp track truncate)) ;;(erc-update-modules) (setq erc-fill-column 78 erc-fill-static-center 6 erc-fill-function 'erc-fill-static) (setq erc-input-line-position -1) (setq erc-track-visibility 'visible) (setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE")) (setq erc-track-showcount t) (setq erc-track-exclude-server-buffer t) (setq erc-notice-highlight-type 'prefix erc-current-nick-highlight-type 'nick-or-keyword) (setq erc-echo-notice-always-hook '(erc-echo-notice-in-active-buffer)) (setq erc-auto-query t) (setq erc-kill-buffer-on-part t erc-kill-queries-on-quit t erc-kill-server-buffer-on-quit t) (setq erc-dcc-get-default-directory "~/download") (setq erc-prompt ">>>") (setq erc-nick "rz0") (setq erc-server "irc.quakenet.org") (setq erc-autojoin-channels-alist '(("quakenet.org" "#siteduzero") ("epiknet.org" "#sdz"))) ;; (setq erc-encoding-coding-alist '(("#siteduzero" . utf-8) ;; ("#sdz" . utf-8))) (setq erc-prompt-for-password nil) (setq erc-netsplit-show-server-mode-changes-flag t) (defun minh-notify-ratpoison (match-type user-mask text) (when (eq match-type 'current-nick) (ratpoison-command (format "echo Message from %.20s" (car (split-string user-mask "!")))))) (add-hook 'erc-text-matched-hook 'minh-notify-ratpoison) (defun erc-cmd-QAUTH () "Authenticate to the Q bot on Quakenet." (erc-message "PRIVMSG" (format "Q@CServe.quakenet.org AUTH %s %s" qnet-user qnet-password))) (defun erc-cmd-TAUTH () "Authenticate to Themis." (erc-message "PRIVMSG" (format "themis IDENTIFY %s" themis-password))) (defvar minh-irc-servers '((:server "irc.quakenet.org") (:server "irc.epiknet.org"))) (defun minh-connect-irc () "Connect to `minh-irc-servers'." (interactive) (let ((lis minh-irc-servers)) (while lis (apply 'erc (car lis)) (setq lis (cdr lis))))) (defun minh-connect-im () "Connect to instant messenging gateway." (interactive) (erc :server "localhost" :nick "minh")) (global-set-key (kbd "C-c x i") 'minh-connect-irc) (global-set-key (kbd "C-c x j") 'minh-connect-im) ;; IM-over-IRC (add-hook 'erc-join-hook 'bitlbee-identify) (defun bitlbee-identify () "If we're on the bitlbee server, send the identify command to the &bitlbee channel." (when (and (string= "localhost" erc-session-server) (string= "&bitlbee" (buffer-name))) (erc-message "PRIVMSG" (format "%s identify %s" (erc-default-target) bitlbee-password)))) (add-hook 'erc-after-connect 'minh-irc-identify) (defun minh-irc-identify (server nick) "Identify on Quakenet and Epiknet." (cond ((string-match "epiknet" (downcase server)) (erc-cmd-TAUTH)) ((string-match "quakenet" (downcase server)) (erc-cmd-QAUTH)))) (defun minh-bitlbee-status () "Return non-nil if away. The function retrieves Bitlbee status from ERC buffer." (let ((b (get-buffer "&bitlbee"))) (cond ((null b) nil) ((null (save-excursion (set-buffer b) (erc-away-p))) t) (t 'away)))) (defun minh-bitlbee-status-string () "Status string corresponding to `minh-bitlbee-status'." (let ((s (minh-bitlbee-status))) (cond ((equal s 'away) "@") ((null s) "-") (t "&")))) ;; Jabber (when (require 'jabber nil t) (defun minh-jabber-jid-invisible-in-frame-p (jid) "Returns t if the associated buffer is not visible in current frame." (null (get-buffer-window (get-buffer (jabber-chat-get-buffer jid)) nil))) (setq jabber-server "gmail.com" jabber-username "nhat.minh.le" jabber-nickname "minh") (setq jabber-network-server "talk.google.com" jabber-connection-type 'ssl) (setq jabber-roster-buffer "*Roster*" jabber-chat-buffer-format "%j" jabber-groupchat-buffer-format "%j") (setq jabber-roster-show-bindings nil) (setq jabber-history-enabled t jabber-use-global-history nil jabber-history-dir "~/log" jabber-history-enable-rotation t) (setq jabber-message-alert-same-buffer nil) (setq jabber-activity-make-strings 'jabber-activity-make-strings-shorten) (setq jabber-activity-show-p 'minh-jabber-jid-invisible-in-frame-p) ;; (add-hook 'jabber-chat-mode-hook ;; (function (lambda () ;; (setq fill-column (- (window-width) tab-width))))) )