; start it up (irc nil) ; set default frame look (setq default-frame-alist '( (font . "fontset-osaka_lite") (tool-bar-lines . 0) (menu-bar-lines . 1) (background-color . "seashell") (line-spacing . 3) )) (set-background-color "seashell") (tabbar-mode t) (setq rcirc-fill-column (window-width)) ;-- ; notify me when i'm in another app. OS X. (load-file "/Users/xah/web/emacs/xah_emacs_growl.el") ;---- ; turn on spell checking (add-hook 'rcirc-mode-hook (lambda () (flyspell-mode 1))) ;---- ;; beep when i'm mentioned (defun my-rcirc-print-hook (a b c d e) (when (and (string-match (rcirc-nick a) e) (not (string-match (concat "<" (rcirc-nick a) ">") e))) ; but, ignore my own messages ; (start-process "beep" nil "play" (expand-file-name "~/beep.wav")) (beep) )) (add-hook 'rcirc-print-hooks 'my-rcirc-print-hook) (add-hook 'rcirc-mode-hook (lambda () (define-key rcirc-mode-map (kbd "M-o") 'other-window) (define-key rcirc-mode-map (kbd "M-p") 'yank) (define-key rcirc-mode-map (kbd "M-") (lambda () (rcirc-insert-prev-input 1))) ) ) ;-- ; auto reconnect after network connection disruption (eval-after-load 'rcirc '(defun-rcirc-command reconnect (arg) "Reconnect the server process." (interactive "i") (unless process (error "There's no process for this target")) (let* ((server (car (process-contact process))) (port (process-contact process :service)) (nick (rcirc-nick process)) channels query-buffers) (dolist (buf (buffer-list)) (with-current-buffer buf (when (eq process (rcirc-buffer-process)) (remove-hook 'change-major-mode-hook 'rcirc-change-major-mode-hook) (if (rcirc-channel-p rcirc-target) (setq channels (cons rcirc-target channels)) (setq query-buffers (cons buf query-buffers)))))) (delete-process process) (rcirc-connect server port nick rcirc-default-user-name rcirc-default-user-full-name channels)))) ;-- ; make each nick name colored differently ; from http://www.emacswiki.org/cgi-bin/wiki/rcircColoredNicks ; 2006-10-04, — Xah, ∑ http://xahlee.org/ (defvar rcirc-colors (if (fboundp 'color-distance) (let ((min-distance (* 0.23 (color-distance "black" "white"))) (bg (face-background 'default)) (fg (face-foreground 'rcirc-my-nick)) candidates) (dolist (item color-name-rgb-alist) (let ((color (car item))) (when (and (not (color-gray-p color)) (> (color-distance color bg) min-distance) (> (color-distance color fg) min-distance)) (setq candidates (cons color candidates))))) candidates) (delete (face-background 'default) (defined-colors))) "Colors to use for nicks in rcirc. By default, all the non-grey colors that are very different from the default background are candidates. The minimum color-distance is half the distance between black and red as computed by `color-distance'. To check out the list, evaluate (list-colors-display rcirc-colors).") (defvar rcirc-color-mapping (make-hash-table :test 'equal) "Hash-map mapping nicks to color names.") (eval-after-load 'rcirc '(defun rcirc-facify (string face) "Return a copy of STRING with FACE property added. Also add colors to other nicks based on `rcirc-colors'." (when (and (eq face 'rcirc-other-nick) (not (string= string ""))) (let ((color (gethash string rcirc-color-mapping))) (unless color (setq color (elt rcirc-colors (random (length rcirc-colors)))) (puthash string color rcirc-color-mapping)) (setq face `((foreground-color . ,color))))) (if face (propertize (or string "") 'face face 'rear-nonsticky t) string))) (defadvice rcirc-mangle-text (after rcirc-mangle-text-color-nick activate) "Highlight nicks according to `rcirc-color-mapping'." (with-syntax-table rcirc-nick-syntax-table (maphash (lambda (nick color) (let ((face (cons 'foreground-color color))) (rcirc-map-regexp (lambda (start end string) (add-text-properties start end `(face ,face rear-nonsticky t) text)) (concat "\\b" (regexp-quote nick) "\\b") text))) rcirc-color-mapping))) (eval-after-load 'rcirc '(defun-rcirc-command color (args) "Change one of the nick colors." (interactive) (setq args (split-string args)) (rcirc-do-color (car args) (cadr args) process target))) (defun rcirc-do-color (nick color process target) "Implement /COLOR." (if (not nick) (let (names) (maphash (lambda (key value) (add-text-properties 0 (length key) `(face ((foreground-color . ,value)) help-echo ,value) key) (setq names (cons key names))) rcirc-color-mapping) (rcirc-print process (rcirc-nick process) "NOTICE" target (mapconcat 'identity names " "))) (unless color (error "Use what color?")) (puthash nick color rcirc-color-mapping))) (defadvice rcirc-handler-NICK (before rcirc-handler-NICK-colors activate) "Update colors in `rcirc-color-mapping'." (let* ((old-nick (rcirc-user-nick sender)) (color (gethash old-nick rcirc-color-mapping)) (new-nick (car args))) ;; don't delete the old mapping (puthash new-nick color rcirc-color-mapping))) ;--