[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7. Advanced Usage


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.1 Connecting to an IRC Server

The easiest way to connect to an IRC server is to call M-x erc. If you want to assign this function to a keystroke, the following will help you figure out its parameters.

Function: erc

Select connection parameters and run ERC. Non-interactively, it takes the following keyword arguments.

That is, if called with the following arguments, server and full-name will be set to those values, whereas erc-compute-port, erc-compute-nick and erc-compute-full-name will be invoked for the values of the other parameters.

 
(erc :server "irc.freenode.net" :full-name "Harry S Truman")

Server

Function: erc-compute-server &optional server

Return an IRC server name.

This tries a number of increasingly more default methods until a non-nil value is found.

User Option: erc-server nil

IRC server to use if one is not provided.

Port

Function: erc-compute-port &optional port

Return a port for an IRC server.

This tries a number of increasingly more default methods until a non-nil value is found.

User Option: erc-port

IRC port to use if not specified.

This can be either a string or a number.

Nick

Function: erc-compute-nick &optional nick

Return user's IRC nick.

This tries a number of increasingly more default methods until a non-nil value is found.

User Option: erc-nick

Nickname to use if one is not provided.

This can be either a string, or a list of strings. In the latter case, if the first nick in the list is already in use, other nicks are tried in the list order.

User Option: erc-nick-uniquifier

The string to append to the nick if it is already in use.

User Option: erc-try-new-nick-p

If the nickname you chose isn't available, and this option is non-nil, ERC should automatically attempt to connect with another nickname.

You can manually set another nickname with the /NICK command.

Full name

Function: erc-compute-full-name &optional full-name

Return user's full name.

This tries a number of increasingly more default methods until a non-nil value is found.

User Option: erc-user-full-name

User full name.

This can be either a string or a function to call.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2 Sample Configuration

Here is an example of configuration settings for ERC. This can go into your Emacs configuration file. Everything after the (require 'erc) command can optionally go into `~/.emacs.d/.ercrc.el'.

 
;;; Sample ERC configuration

;; Add the ERC directory to load path -- you don't need this if you are
;; using the version of ERC that comes with Emacs
(add-to-list 'load-path "~/elisp/erc")

;; Load ERC
(require 'erc)

;; Load authentication info from an external source.  Put sensitive
;; passwords and the like in here.
(load "~/.emacs.d/.erc-auth")

;; This is an example of how to make a new command.  Type "/uptime" to
;; use it.
(defun erc-cmd-UPTIME (&rest ignore)
  "Display the uptime of the system, as well as some load-related
stuff, to the current ERC buffer."
  (let ((uname-output
         (replace-regexp-in-string
          ", load average: " "] {Load average} ["
          ;; Collapse spaces, remove
          (replace-regexp-in-string
           " +" " "
           ;; Remove beginning and trailing whitespace
           (replace-regexp-in-string
            "^ +\\|[ \n]+$" ""
            (shell-command-to-string "uptime"))))))
    (erc-send-message
     (concat "{Uptime} [" uname-output "]"))))

;; This causes ERC to connect to the Freenode network upon hitting
;; C-c e f.  Replace MYNICK with your IRC nick.
(global-set-key "\C-cef" (lambda () (interactive)
                           (erc :server "irc.freenode.net" :port "6667"
                                :nick "MYNICK")))

;; This causes ERC to connect to the IRC server on your own machine (if
;; you have one) upon hitting C-c e b.  Replace MYNICK with your IRC
;; nick.  Often, people like to run bitlbee (http://bitlbee.org/) as an
;; AIM/Jabber/MSN to IRC gateway, so that they can use ERC to chat with
;; people on those networks.
(global-set-key "\C-ceb" (lambda () (interactive)
                           (erc :server "localhost" :port "6667"
                                :nick "MYNICK")))

;; Make C-c RET (or C-c C-RET) send messages instead of RET. This has
;; been commented out to avoid confusing new users.
;; (define-key erc-mode-map (kbd "RET") nil)
;; (define-key erc-mode-map (kbd "C-c RET") 'erc-send-current-line)
;; (define-key erc-mode-map (kbd "C-c C-RET") 'erc-send-current-line)

;;; Options

;; Join the #emacs and #erc channels whenever connecting to Freenode.
(setq erc-autojoin-channels-alist '(("freenode.net" "#emacs" "#erc")))

;; Interpret mIRC-style color commands in IRC chats
(setq erc-interpret-mirc-color t)

;; The following are commented out by default, but users of other
;; non-Emacs IRC clients might find them useful.
;; Kill buffers for channels after /part
;; (setq erc-kill-buffer-on-part t)
;; Kill buffers for private queries after quitting the server
;; (setq erc-kill-queries-on-quit t)
;; Kill buffers for server messages after quitting the server
;; (setq erc-kill-server-buffer-on-quit t)

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.3 Options

This section has not yet been written. For now, the easiest way to check out the available options for ERC is to do M-x customize-group erc RET.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated on July, 16 2011 using texi2html 1.76.