Show
Ignore:
Timestamp:
07/16/06 08:36:52 (2 years ago)
Author:
miyoshi
Message:

Sync up with Emacs CVS HEAD.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lisp/erc/erc.el

    r4058 r4111  
    1212;;               Gergely Nagy (algernon@midgard.debian.net) 
    1313;;               David Edmondson (dme@dme.org) 
    14 ;; Maintainer: Mario Lang (mlang@delysid.org) 
     14;; Maintainer: Michael Olson (mwolson@gnu.org) 
    1515;; Keywords: IRC, chat, client, Internet 
    1616 
     
    3737 
    3838;; For more information, see the following URLs: 
    39 ;; * http://sf.net/projects/erc/ 
     39;; * http://sv.gnu.org/projects/erc/ 
    4040;; * http://www.emacswiki.org/cgi-bin/wiki.pl?EmacsIRCClient 
    4141 
    42 ;; Jul-26-2001. erc.el is now in CVS on SourceForge.  I invite everyone 
    43 ;; who wants to hack it to contact me <mlang@delysid.org> in order to 
    44 ;; get write access on the CVS. 
     42;; As of 2006-06-13, ERC development is now hosted on Savannah 
     43;; (http://sv.gnu.org/projects/erc).  I invite everyone who wants to 
     44;; hack on it to contact me <mwolson@gnu.org> in order to get write 
     45;; access to the shared Arch archive. 
    4546 
    4647;; Installation: 
     
    6768;;; Code: 
    6869 
    69 (defconst erc-version-string "Version 5.1.2
     70(defconst erc-version-string "Version 5.1.3
    7071  "ERC version.  This is used by function `erc-version'.") 
    7172 
     
    7879 
    7980(defvar erc-official-location 
    80   "http://erc.sf.net (comments mailto://mlang@delysid.org)" 
     81  "http://emacswiki.org/cgi-bin/wiki/ERC (mailing list: erc-discuss@gnu.org)" 
    8182  "Location of the ERC client on the Internet.") 
    8283 
    8384(defgroup erc nil 
    8485  "Emacs Internet Relay Chat client." 
    85   :link '(url-link "http://www.emacswiki.org/cgi-bin/wiki.pl?EmacsIRCClient") 
     86  :link '(url-link "http://www.emacswiki.org/cgi-bin/wiki/ERC") 
    8687  :prefix "erc-" 
    8788  :group 'applications) 
     
    144145 
    145146(defcustom erc-server nil 
    146   "IRC server to use
     147  "IRC server to use if one is not provided
    147148See function `erc-compute-server' for more details on connection 
    148149parameters and authentication." 
    149150  :group 'erc 
    150   :type '(choice (const nil) string)) 
     151  :type '(choice (const :tag "None" nil) 
     152                 (string :tag "Server"))) 
    151153 
    152154(defcustom erc-port nil 
    153   "IRC port to use." 
     155  "IRC port to use if not specified. 
     156 
     157This can be either a string or a number." 
    154158  :group 'erc 
    155   :type '(choice (const nil) number string)) 
     159  :type '(choice (const :tag "None" nil) 
     160                 (const :tag "Port number" number) 
     161                 (const :tag "Port string" string))) 
    156162 
    157163(defcustom erc-nick nil 
    158   "Nickname to use
    159  
    160 Can be either a string, or a list of strings. 
     164  "Nickname to use if one is not provided
     165 
     166This can be either a string, or a list of strings. 
    161167In the latter case, if the first nick in the list is already in use, 
    162168other nicks are tried in the list order. 
     
    165171parameters and authentication." 
    166172  :group 'erc 
    167   :type '(choice (const nil) 
     173  :type '(choice (const :tag "None" nil) 
    168174                 (string :tag "Nickname") 
    169                  (repeat string))) 
     175                 (repeat (string :tag "Nickname")))) 
    170176 
    171177(defcustom erc-nick-uniquifier "`" 
    172   "The character to append to the nick if it is already in use." 
     178  "The string to append to the nick if it is already in use." 
    173179  :group 'erc 
    174180  :type 'string) 
    175181 
    176 (defcustom erc-manual-set-nick-on-bad-nick-p nil 
    177   "If the nickname you chose isn't available, ERC should not automatically 
    178 attempt to set another nickname.  You can manually set another nickname with 
    179 the /NICK command." 
     182(defcustom erc-try-new-nick-p t 
     183  "If the nickname you chose isn't available, and this option is non-nil, 
     184ERC should automatically attempt to connect with another nickname. 
     185 
     186You can manually set another nickname with the /NICK command." 
    180187  :group 'erc 
    181188  :type 'boolean) 
     
    183190(defcustom erc-user-full-name nil 
    184191  "User full name. 
     192 
     193This can be either a string or a function to call. 
    185194 
    186195See function `erc-compute-full-name' for more details on connection 
    187196parameters and authentication." 
    188197  :group 'erc 
    189   :type '(choice (const nil) string function) 
     198  :type '(choice (const :tag "No name" nil) 
     199                 (string :tag "Name") 
     200                 (function :tag "Get from function")) 
    190201  :set (lambda (sym val) 
    191202         (if (functionp val) 
     
    194205 
    195206(defvar erc-password nil 
    196   "ERC password to use in authentication (not necessary).") 
     207  "Password to use when authenticating to an IRC server. 
     208It is not strictly necessary to provide this, since ERC will 
     209prompt you for it.") 
    197210 
    198211(defcustom erc-user-mode nil 
     
    872885        (\"version\" erc-quit-reason-normal) 
    873886        (\"home\" \"Gone home !\") 
    874         (\"\" \"Default Reason\"))) 
     887        (\"^$\" \"Default Reason\"))) 
    875888If the user types \"/quit zippy\", then a Zippy the Pinhead quotation 
    876889will be used as the quit message." 
     
    896909        (\"version\" erc-part-reason-normal) 
    897910        (\"home\" \"Gone home !\") 
    898         (\"\" \"Default Reason\"))) 
     911        (\"^$\" \"Default Reason\"))) 
    899912If the user types \"/part zippy\", then a Zippy the Pinhead quotation 
    900913will be used as the part message." 
     
    13741387  "Return the value of `erc-active-buffer' for the current server. 
    13751388Defaults to the server buffer." 
    1376   (with-current-buffer (erc-server-buffer) erc-active-buffer)) 
     1389  (with-current-buffer (erc-server-buffer) 
     1390    (if (buffer-live-p erc-active-buffer) 
     1391        erc-active-buffer) 
     1392    (setq erc-active-buffer (current-buffer)))) 
    13771393 
    13781394(defun erc-set-active-buffer (buffer) 
     
    15961612     nil 
    15971613     (mapcar (lambda (buf) 
    1598                (with-current-buffer buf 
    1599                  (and (eq major-mode 'erc-mode) 
    1600                       (or (not proc) 
    1601                           (eq proc erc-server-process)) 
    1602                       (funcall predicate) 
    1603                       buf))) 
     1614               (when (buffer-live-p buf) 
     1615                 (with-current-buffer buf 
     1616                   (and (eq major-mode 'erc-mode) 
     1617                        (or (not proc) 
     1618                            (eq proc erc-server-process)) 
     1619                        (funcall predicate) 
     1620                        buf)))) 
    16041621             (buffer-list))))) 
    16051622 
     
    17611778    (const :tag "Set away status automatically" autoaway) 
    17621779    (const :tag "Join channels automatically" autojoin) 
    1763     (const :tag "Integrate with Big Brother Database" bbdb) 
    17641780    (const :tag "Buttonize URLs, nicknames, and other text" button) 
    17651781    (const :tag "Wrap long lines" fill) 
     1782    (const :tag "Launch an identd server on port 8113" identd) 
    17661783    (const :tag "Highlight or remove IRC control characters" 
    17671784           irccontrols) 
     1785    (const :tag "List channels in a separate buffer" list) 
    17681786    (const :tag "Save buffers in logs" log) 
    17691787    (const :tag "Highlight pals, fools, and other keywords" match) 
     
    17771795           completion) 
    17781796    (const :tag "Complete nicknames and commands (old)" hecomplete) 
     1797    (const :tag "Process CTCP PAGE requests from IRC" page) 
    17791798    (const :tag "Make displayed lines read-only" readonly) 
    17801799    (const :tag "Replace text in messages" replace) 
     
    20642083 
    20652084That is, if called with 
     2085 
    20662086   (erc-select :server \"irc.freenode.net\" :full-name \"Harry S Truman\") 
     2087 
    20672088server and full-name will be set to those values, whereas 
    2068 erc-compute-port, erc-compute-nick and erc-compute-full-name will 
    2069 be invoked for those parameters' values
     2089`erc-compute-port', `erc-compute-nick' and `erc-compute-full-name' will 
     2090be invoked for the values of the other parameters.
    20702091  (interactive (erc-select-read-args)) 
    20712092 
     
    30483069     ((functionp res) (funcall res)) 
    30493070     ((stringp res) res) 
    3050      ;; hopefully never reached 
    3051      (s)))) 
     3071     (s s) 
     3072     (t (erc-quit-reason-normal))))) 
    30523073 
    30533074(defun erc-part-reason-normal (&optional s) 
     
    30753096     ((functionp res) (funcall res)) 
    30763097     ((stringp res) res) 
    3077      (s)))) 
     3098     (s s) 
     3099     (t (erc-part-reason-normal))))) 
    30783100 
    30793101(defun erc-cmd-QUIT (reason) 
     
    37143736 
    37153737See also `erc-display-error-notice'." 
    3716   (if (or erc-manual-set-nick-on-bad-nick-p 
     3738  (if (or (not erc-try-new-nick-p) 
    37173739          ;; how many default-nicks are left + one more try... 
    37183740          (eq erc-nick-change-attempt-count 
     
    37363758                                 nick 
    37373759                                 (if (and erc-server-connected nicklen) 
    3738                                      (- (string-to-number nicklen) 1) 
     3760                                     (- (string-to-number nicklen) 
     3761                                        (length erc-nick-uniquifier)) 
    37393762                                   ;; rfc2812 max nick length = 9 
    37403763                                   ;; we must assume this is the 
    37413764                                   ;; server's setting if we haven't 
    37423765                                   ;; established a connection yet 
    3743                                    8)) 
     3766                                   (- 9 (length erc-nick-uniquifier)))) 
    37443767                                erc-nick-uniquifier))) 
    37453768      (erc-cmd-NICK newnick) 
     
    50995122  "Toggle use of flood control on sent messages. 
    51005123 
    5101 If ARG is non-nil, use flood control. 
    5102 If ARG is nil, do not use flood control. 
     5124If ARG is positive, use flood control. 
     5125If ARG is non-nil and not positive, do not use flood control. 
    51035126 
    51045127See `erc-server-flood-margin' for an explanation of the available 
    51055128flood control parameters." 
    51065129  (interactive "P") 
    5107   (setq erc-flood-protect arg) 
     5130  (cond ((and (numberp arg) (> arg 0)) 
     5131         (setq erc-flood-protect t)) 
     5132        (arg (setq erc-flood-protect nil)) 
     5133        (t (setq erc-flood-protect (not erc-flood-protect)))) 
    51085134  (message "ERC flood control is %s" 
    51095135           (cond (erc-flood-protect "ON") 
     
    51315157(defun erc-get-channel-mode-from-keypress (key) 
    51325158  "Read a key sequence and call the corresponding channel mode function. 
    5133 After doing C-c C-o type in a channel mode letter. 
     5159After doing C-c C-o, type in a channel mode letter. 
    51345160 
    51355161C-g means quit. 
    5136 RET let's you type more than one mode at a time. 
     5162RET lets you type more than one mode at a time. 
    51375163If \"l\" is pressed, `erc-set-channel-limit' gets called. 
    51385164If \"k\" is pressed, `erc-set-channel-key' gets called. 
     
    53855411  "Return an IRC server name. 
    53865412 
    5387 Tries a number of increasingly more default methods until a non-nil value is 
    5388 found: 
    5389  
    5390 - SERVER 
    5391 - `erc-server' 
     5413This tries a number of increasingly more default methods until a 
     5414non-nil value is found. 
     5415 
     5416- SERVER (the argument passwd to this function) 
     5417- The `erc-server' option 
    53925418- The value of the IRCSERVER environment variable 
    5393 - `erc-default-server'.
     5419- The `erc-default-server' variable
    53945420  (or server 
    53955421      erc-server 
     
    53985424 
    53995425(defun erc-compute-nick (&optional nick) 
    5400   "Return user's NICK
    5401  
    5402 Tries a number of increasingly more default methods until a non-nil value is 
    5403 found: 
    5404  
    5405 - NICK 
    5406 - `erc-nick' 
     5426  "Return user's IRC nick
     5427 
     5428This tries a number of increasingly more default methods until a 
     5429non-nil value is found. 
     5430 
     5431- NICK (the argument passed to this function) 
     5432- The `erc-nick' option 
    54075433- The value of the IRCNICK environment variable 
    5408 - via the function `user-login-name'.
     5434- The result from the `user-login-name' function
    54095435  (or nick 
    54105436      (if (consp erc-nick) (car erc-nick) erc-nick) 
     
    54145440 
    54155441(defun erc-compute-full-name (&optional full-name) 
    5416   "Return user's FULL-NAME
    5417  
    5418 Tries a number of increasingly more default methods until a non-nil value is 
    5419 found: 
    5420  
    5421 - FULL-NAME 
    5422 - `erc-user-full-name' 
     5442  "Return user's full name
     5443 
     5444This tries a number of increasingly more default methods until a 
     5445non-nil value is found. 
     5446 
     5447- FULL-NAME (the argument passed to this function) 
     5448- The `erc-user-full-name' option 
    54235449- The value of the IRCNAME environment variable 
    5424 - via the function `user-full-name'.
     5450- The result from the `user-full-name' function
    54255451  (or full-name 
    54265452      erc-user-full-name 
     
    54325458  "Return a port for an IRC server. 
    54335459 
    5434 Tries a number of increasingly more default methods until a non-nil 
    5435 value is found: 
    5436  
    5437 - PORT 
    5438 - \"ircd\"." 
    5439   (or port erc-port "ircd")) 
     5460This tries a number of increasingly more default methods until a 
     5461non-nil value is found. 
     5462 
     5463- PORT (the argument passed to this function) 
     5464- The `erc-port' option 
     5465- The `erc-default-port' variable" 
     5466  (or port erc-port erc-default-port)) 
    54405467 
    54415468;; time routines 
     
    58195846        version-string)))) 
    58205847 
    5821 (defun erc-version-modules (&optional here) 
    5822   "Show the version numbers of all loaded ERC modules in the minibuffer. 
    5823 If optional argument HERE is non-nil, insert version number at point." 
    5824   (interactive "P") 
    5825   (let ((version-string 
    5826          (mapconcat 'identity 
    5827                     (let (versions (case-fold-search nil)) 
    5828                       (dolist (var (apropos-internal "^erc-.*version$")) 
    5829                         (when (and (boundp var) 
    5830                                    (stringp (symbol-value var))) 
    5831                           (setq versions (cons (format "%S: %s" 
    5832                                                        var (symbol-value var)) 
    5833                                                versions)))) 
    5834                       versions) ", "))) 
    5835     (if here 
    5836         (insert version-string) 
    5837       (if (interactive-p) 
    5838           (message "%s" version-string) 
    5839         version-string)))) 
    5840  
    58415848(defun erc-modes (&optional here) 
    58425849  "Show the active ERC modes in the minibuffer. 
     
    58585865          (message "%s" string) 
    58595866        string)))) 
    5860  
    5861 (defun erc-latest-version () 
    5862   "Retrieve the latest erc.el version from CVS." 
    5863   (interactive) 
    5864   (if (ignore-errors (require 'url)) 
    5865       (progn 
    5866         (switch-to-buffer (get-buffer-create "*erc.el latest version*")) 
    5867         (delete-region (point-min) (point-max)) 
    5868         (kill-all-local-variables) 
    5869         (url-insert-file-contents (concat 
    5870                                    "http://cvs.sourceforge.net/viewcvs.py/" 
    5871                                    "*checkout*/erc/erc/erc.el?content-type" 
    5872                                    "=text%2Fplain&rev=HEAD")) 
    5873         (emacs-lisp-mode) 
    5874         (current-buffer)) 
    5875     (error "URL needs to be installed"))) 
    5876  
    5877 (defun erc-ediff-latest-version () 
    5878   "Ediff your installed erc.el with the latest CVS version. 
    5879 See also `erc-latest-version'." 
    5880   (interactive) 
    5881   (let ((current (locate-library "erc.el"))) 
    5882     (if current 
    5883         (ediff-buffers (find-file current) 
    5884                        (erc-latest-version)) 
    5885       (error "You do not appear to have the uncompiled erc.el file")))) 
    58865867 
    58875868(defun erc-trim-string (s) 
     
    61856166       (erc-response.command vect))) 
    61866167 
     6168;; Teach url.el how to open irc:// URLs with ERC. 
     6169;; To activate, customize `url-irc-function' to `url-irc-erc'. 
     6170 
     6171;;;###autoload 
     6172(defun erc-handle-irc-url (host port channel user password) 
     6173  "Use ERC to IRC on HOST:PORT in CHANNEL as USER with PASSWORD. 
     6174If ERC is already connected to HOST:PORT, simply /join CHANNEL. 
     6175Otherwise, connect to HOST:PORT as USER and /join CHANNEL." 
     6176  (let ((server-buffer 
     6177         (car (erc-buffer-filter 
     6178               (lambda () 
     6179                 (and (string-equal erc-session-server host) 
     6180                      (= erc-session-port port) 
     6181                      erc-server-connected 
     6182                      (eq (erc-server-buffer) (current-buffer)))))))) 
     6183    (with-current-buffer (or server-buffer (current-buffer)) 
     6184      (if (and server-buffer channel) 
     6185          (erc-cmd-JOIN channel) 
     6186        (erc host port (or user (erc-compute-nick)) (erc-compute-full-name) 
     6187             (not server-buffer) password nil channel 
     6188             (when server-buffer 
     6189               (get-buffer-process server-buffer))))))) 
     6190 
    61876191(provide 'erc) 
    61886192