Pages

Sunday, September 12, 2010

IRC with ERC


erc is an excellent package to access irc from emacs. This includes an
interface to IDO fast buffer selection. I keep the important password
type vars in private.gpg.





  (require 'erc)

(setq
erc-prompt-for-nickserv-password nil
erc-autoaway-idle-seconds 600
erc-autoaway-message "Timed out."
erc-auto-discard-away t
)


; alert when someone highlights you.
(defun my-erc-nick-match (match-type nickuserhost message)
(cond
((eq match-type 'current-nick)
(if (eq (string-match (concat (erc-current-nick) ":") message) 0) (rgr/notify message)))))

(add-hook 'erc-text-matched-hook 'my-erc-nick-match)

; auto truncatebuffers
(defvar erc-insert-post-hook)
(add-hook 'erc-insert-post-hook
'erc-truncate-buffer)

(defun rgr/start-erc ()
(interactive)
(unless (erc-already-logged-in "im.rootdir.de" 6668 "rgr") (erc :server "88.198.83.122" :nick "rgr" :password bitl-password :port 6668)) ; im.rootdir.de
(if (not (erc-already-logged-in "irc.freenode.net" 6667 "rgr"))
(erc :server "irc.freenode.net" :nick "rgr" :password erc-password :port 6667)
(progn
(switch-to-buffer "#emacs"))) )

; /INFO auto logs the eval line for someone to evaluate to take them to the same INFO page you are currently viewing.
(defun erc-cmd-INFO (&rest ignore)
(erc-send-message (format "Evaluate this using C-x C-e with cursor at closing bracket --> %s" (rgr/info-link))))

; IDO switch between irc channels.
(defun rgr/ido-erc-buffer()
(interactive)
(switch-to-buffer
(ido-completing-read "Channel:"
(save-excursion
(delq
nil
(mapcar (lambda (buf)
(when (buffer-live-p buf)
(with-current-buffer buf
(and (eq major-mode 'erc-mode)
(buffer-name buf)))))
(buffer-list)))))))

(global-set-key (kbd "C-c e") 'rgr/ido-erc-buffer)





No comments:

Post a Comment