;;; .ercrc.el --- Edward O'Connor's ERC configuration -*- emacs-lisp -*- ;; Copyright (C) 1997 -- 2011 Edward O'Connor ;; Author: Edward O'Connor ;; Keywords: local ;; This file is NOT part of GNU Emacs. ;; This 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 2, or (at your option) any later ;; version. ;; This file 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 Emacs; see the file COPYING, or type `C-h C-c'. If not, ;; write to the Free Software Foundation at this address: ;; Free Software Foundation ;; 51 Franklin Street, Fifth Floor ;; Boston, MA 02110-1301 ;; USA ;;; Code: (setq erc-header-line-uses-help-echo-p nil ;; Just the topic, ma'am. erc-header-line-format "%o") (require 'erc-autojoin nil t) (require 'erc-join nil t) (setq erc-autojoin-channels-alist '((".*a11y.org" "#epub") (".*freenode.net" "#emacs" "#emacs-ops" "#erc" "#gnus" "#html5" "#indiewebcamp" "#microformats" "#schemaorg" "#webkit" "#whatwg") (".*w3.org" "#css" "#css-test" "#dnt" "#fx" "#webapps" "#html-wg" "#html-xml"))) (require 'erc-nickserv nil t) (require 'erc-services nil t) (if ted-erc-identify ; Defined in .emacs (progn (erc-nickserv-mode 1) (erc-services-mode 1)) ;; Still want to catch the case where the server password ;; auto-identified us. (when (fboundp 'erc-nickserv-identification-autodetect) (add-hook 'erc-server-NOTICE-functions 'erc-nickserv-identification-autodetect))) (setq erc-prompt-for-nickserv-password nil) (erc-autojoin-mode 0) ;; Delay channel auto-join until after NickServ cloaks us. (defun ted-post-cloak-autojoin (network nick) "Autojoin when NickServ tells us to." (interactive) (when ted-erc-autojoin ; Defined in .emacs (erc-autojoin-channels erc-session-server (erc-current-nick))) nil) ;; For earlier versions of ERC, without `erc-nickserv-identified-hook'. ;; Freenode-only. (defun ted-post-cloak-autojoin-OLD (proc parsed) "Autojoin iff NickServ tells us to." (with-current-buffer (process-buffer proc) (when (and (string-match "^.*freenode\\.net$" ; $ (erc-response.sender parsed)) (string-match ".*NickServ set your hostname to.*" (erc-response.contents parsed)) ;; Only autojoin for my primary nick. (string-equal (car erc-nick) (erc-current-nick)) ted-erc-autojoin) ; Defined in .emacs (erc-autojoin-channels erc-session-server (erc-current-nick)) nil))) (if (boundp 'erc-nickserv-identified-hook) (add-hook 'erc-nickserv-identified-hook 'ted-post-cloak-autojoin) (add-hook 'erc-server-NOTICE-functions 'ted-post-cloak-autojoin-OLD)) (defun ted-non-fn-autojoin (server nick) (when (and ted-erc-autojoin (not (string-match ".*freenode.net" server))) (erc-autojoin-channels erc-session-server (erc-current-nick)))) (add-hook 'erc-after-connect 'ted-non-fn-autojoin) (defun ted-erc-spc-dwim () "DWIMmy behavior for the SPC key in ERC." (interactive) (condition-case nil (insert " ") (text-read-only (condition-case nil (scroll-up) (end-of-buffer (recenter 0)))))) (eval-after-load "erc" '(define-key erc-mode-map (kbd "SPC") 'ted-erc-spc-dwim)) (when (require 'erc-highlight-nicknames nil t) (erc-highlight-nicknames-mode 1)) (require 'erc-match) (erc-match-mode 1) (setq erc-pals nil erc-fools '(;; bots "cchelpbot" "fsbot" "jibot" "mfbot" "pimpbot" "RRSAgent" "rudybot" "whereisbot" "Zakim" ;; #emacs "ams" "imnowme" "jordanb" "kamo9088" "micka" "tknudsen" "xah") erc-fool-highlight-type 'all erc-keywords '("ljupdate")) (require 'erc-fill) (erc-fill-mode 1) (setq erc-fill-column 72) ;; protected, for using ERC in emacs -q (when (fboundp 'ted-hide-trailing-whitespace) (add-hook 'erc-mode-hook 'ted-hide-trailing-whitespace)) (require 'erc-stamp) (erc-stamp-mode 1) (setq erc-insert-timestamp-function 'erc-insert-timestamp-left erc-timestamp-format "[%H:%M] " erc-insert-away-timestamp-function 'erc-insert-timestamp-left erc-away-timestamp-format "<%H:%M> ") (require 'erc-button) (erc-button-mode 1) (setq erc-button-wrap-long-urls nil erc-button-buttonize-nicks nil) (require 'erc-netsplit) (erc-netsplit-mode 1) (require 'erc-ring) (erc-ring-mode 1) (require 'erc-dcc) (require 'erc-page) (erc-page-mode 1) (require 'erc-track) (erc-track-mode 1) (setq erc-track-switch-direction 'importance) (setq erc-track-exclude-types '("324" "329" "332" "333" "353" "JOIN" "NAMES" "NICK" "QUIT" "PART" "TOPIC")) (global-set-key (kbd "C-c SPC") 'erc-track-switch-buffer) (global-set-key (kbd "") 'erc-track-switch-buffer) (defvar ted-modified-channels-length 0 "Last recorded length of `erc-modified-channels-alist'. This is updated each time `ted-erc-growl' gets called from `etc-track-list-changed-hook'.") (defun ted-erc-growl () "Use growl for ERC track change notifications." (let ((modified-channels-length (length erc-modified-channels-alist))) (when (> modified-channels-length ted-modified-channels-length) (let ((msg (format "New messages in: %s" (mapconcat (lambda (pair) (buffer-name (car pair))) erc-modified-channels-alist ", ")))) (growl "IRC Activity" msg) (message "%s" msg))) (setq ted-modified-channels-length modified-channels-length))) (when (and (eq system-type 'darwin) (locate-library "growl") window-system) (autoload 'growl "growl") (add-hook 'erc-track-list-changed-hook 'ted-erc-growl)) ;; emacs-w3m clobbers erc-track-mode's C-c C-SPC binding. (eval-after-load "w3m" '(define-key w3m-mode-map (kbd "C-c C-SPC") 'erc-track-switch-buffer)) (require 'erc-truncate) (erc-truncate-mode 1) (defun erc-cmd-SHOW (&rest form) "Eval FORM and send the result and the original form as: FORM => (eval FORM)." (let* ((form-string (mapconcat 'identity form " ")) (result (condition-case err (eval (read-from-whole-string form-string)) (error (format "Error: %s" error))))) (erc-send-message (format "%s => %S" form-string result)))) (add-to-list 'erc-noncommands-list 'erc-cmd-SHOW) (defun erc-cmd-OPME () "Ask ChanServ to grant me op in this channel." (erc-message "PRIVMSG" (format "ChanServ op %s" (erc-default-target) (erc-current-nick)) nil)) (defun erc-cmd-DEOPME () "Deop myself from this channel." (erc-cmd-DEOP (format "%s" (erc-current-nick)))) (defun erc-cmd-BAN (nick) "Ban NICK from this channel." (erc-server-send (format "mode %s +b *!*~%s@*" (erc-default-target) nick))) (defun erc-cmd-NP () "Display currently playing iTunes track" (erc-send-message (shell-command-to-string "osascript -e 'tell application \"iTunes\" to if player state is playing then \"NP: \" \& name of current track \& \" - \" \& artist of current track'"))) (add-to-list 'erc-noncommands-list 'erc-cmd-NP) (defun erc-cmd-YOW () (erc-send-message (erc-replace-regexp-in-string "\n" "" (yow)))) (add-to-list 'erc-noncommands-list 'erc-cmd-YOW) (defun erc-cmd-OPME () "request a chanop op to me" (erc-message "PRIVMSG" (format "chanserv op %s %s" (erc-default-target) (erc-current-nick)) nil)) (defun erc-cmd-DEOPME () "Deop myself from current channel" (erc-cmd-DEOP (format "%s" (erc-current-nick)))) (when (and (boundp 'viper-mode) viper-mode) (require 'erc-viper nil t)) (defvar ted-erc-pcomplete-nick-postfix-overrides '(("Zakim" . ", ")) "An alist of nicks which take non-default completion postfixes. Each cell is of the form (NICK . POSTFIX), both strings.") (defun ted-erc-pcomplete-format-nick (nick &optional postfix) "Return NICK, formatted for completion. Will use POSTFIX for formatting, unless an override is provided for NICK in `ted-erc-pcomplete-nick-postfix-overrides'. If POSTFIX is not provided, we default to `erc-pcomplete-nick-postfix'." (concat nick (or (cdr (assoc nick ted-erc-pcomplete-nick-postfix-overrides)) postfix erc-pcomplete-nick-postfix))) (defun ted-pcomplete-erc-nicks (&optional postfix ignore-self) "Returns a list of nicks in the current channel. Optional argument POSTFIX is something to append to the nickname. If optional argument IGNORE-SELF is non-nil, don't return the current nick." (let ((users (if erc-pcomplete-order-nickname-completions (erc-sort-channel-users-by-activity (erc-get-channel-user-list)) (erc-get-channel-user-list))) (nicks nil)) (dolist (user users) (let ((nick (erc-server-user-nickname (car user)))) (unless (and ignore-self (string= nick (erc-current-nick))) (setq nicks (cons (ted-erc-pcomplete-format-nick nick postfix) nicks))))) (nreverse nicks))) (eval-after-load "erc-pcomplete" '(defalias 'pcomplete-erc-nicks 'ted-pcomplete-erc-nicks)) ;;; .ercrc.el ends here