Changeset 4111 for trunk/lisp/erc/erc.el
- Timestamp:
- 07/16/06 08:36:52 (2 years ago)
- Files:
-
- trunk/lisp/erc/erc.el (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lisp/erc/erc.el
r4058 r4111 12 12 ;; Gergely Nagy (algernon@midgard.debian.net) 13 13 ;; David Edmondson (dme@dme.org) 14 ;; Maintainer: M ario Lang (mlang@delysid.org)14 ;; Maintainer: Michael Olson (mwolson@gnu.org) 15 15 ;; Keywords: IRC, chat, client, Internet 16 16 … … 37 37 38 38 ;; For more information, see the following URLs: 39 ;; * http://s f.net/projects/erc/39 ;; * http://sv.gnu.org/projects/erc/ 40 40 ;; * http://www.emacswiki.org/cgi-bin/wiki.pl?EmacsIRCClient 41 41 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. 45 46 46 47 ;; Installation: … … 67 68 ;;; Code: 68 69 69 (defconst erc-version-string "Version 5.1. 2"70 (defconst erc-version-string "Version 5.1.3" 70 71 "ERC version. This is used by function `erc-version'.") 71 72 … … 78 79 79 80 (defvar erc-official-location 80 "http://e rc.sf.net (comments mailto://mlang@delysid.org)"81 "http://emacswiki.org/cgi-bin/wiki/ERC (mailing list: erc-discuss@gnu.org)" 81 82 "Location of the ERC client on the Internet.") 82 83 83 84 (defgroup erc nil 84 85 "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") 86 87 :prefix "erc-" 87 88 :group 'applications) … … 144 145 145 146 (defcustom erc-server nil 146 "IRC server to use .147 "IRC server to use if one is not provided. 147 148 See function `erc-compute-server' for more details on connection 148 149 parameters and authentication." 149 150 :group 'erc 150 :type '(choice (const nil) string)) 151 :type '(choice (const :tag "None" nil) 152 (string :tag "Server"))) 151 153 152 154 (defcustom erc-port nil 153 "IRC port to use." 155 "IRC port to use if not specified. 156 157 This can be either a string or a number." 154 158 :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))) 156 162 157 163 (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 166 This can be either a string, or a list of strings. 161 167 In the latter case, if the first nick in the list is already in use, 162 168 other nicks are tried in the list order. … … 165 171 parameters and authentication." 166 172 :group 'erc 167 :type '(choice (const nil)173 :type '(choice (const :tag "None" nil) 168 174 (string :tag "Nickname") 169 (repeat string)))175 (repeat (string :tag "Nickname")))) 170 176 171 177 (defcustom erc-nick-uniquifier "`" 172 "The characterto append to the nick if it is already in use."178 "The string to append to the nick if it is already in use." 173 179 :group 'erc 174 180 :type 'string) 175 181 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, 184 ERC should automatically attempt to connect with another nickname. 185 186 You can manually set another nickname with the /NICK command." 180 187 :group 'erc 181 188 :type 'boolean) … … 183 190 (defcustom erc-user-full-name nil 184 191 "User full name. 192 193 This can be either a string or a function to call. 185 194 186 195 See function `erc-compute-full-name' for more details on connection 187 196 parameters and authentication." 188 197 :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")) 190 201 :set (lambda (sym val) 191 202 (if (functionp val) … … 194 205 195 206 (defvar erc-password nil 196 "ERC password to use in authentication (not necessary).") 207 "Password to use when authenticating to an IRC server. 208 It is not strictly necessary to provide this, since ERC will 209 prompt you for it.") 197 210 198 211 (defcustom erc-user-mode nil … … 872 885 (\"version\" erc-quit-reason-normal) 873 886 (\"home\" \"Gone home !\") 874 (\" \" \"Default Reason\")))887 (\"^$\" \"Default Reason\"))) 875 888 If the user types \"/quit zippy\", then a Zippy the Pinhead quotation 876 889 will be used as the quit message." … … 896 909 (\"version\" erc-part-reason-normal) 897 910 (\"home\" \"Gone home !\") 898 (\" \" \"Default Reason\")))911 (\"^$\" \"Default Reason\"))) 899 912 If the user types \"/part zippy\", then a Zippy the Pinhead quotation 900 913 will be used as the part message." … … 1374 1387 "Return the value of `erc-active-buffer' for the current server. 1375 1388 Defaults 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)))) 1377 1393 1378 1394 (defun erc-set-active-buffer (buffer) … … 1596 1612 nil 1597 1613 (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)))) 1604 1621 (buffer-list))))) 1605 1622 … … 1761 1778 (const :tag "Set away status automatically" autoaway) 1762 1779 (const :tag "Join channels automatically" autojoin) 1763 (const :tag "Integrate with Big Brother Database" bbdb)1764 1780 (const :tag "Buttonize URLs, nicknames, and other text" button) 1765 1781 (const :tag "Wrap long lines" fill) 1782 (const :tag "Launch an identd server on port 8113" identd) 1766 1783 (const :tag "Highlight or remove IRC control characters" 1767 1784 irccontrols) 1785 (const :tag "List channels in a separate buffer" list) 1768 1786 (const :tag "Save buffers in logs" log) 1769 1787 (const :tag "Highlight pals, fools, and other keywords" match) … … 1777 1795 completion) 1778 1796 (const :tag "Complete nicknames and commands (old)" hecomplete) 1797 (const :tag "Process CTCP PAGE requests from IRC" page) 1779 1798 (const :tag "Make displayed lines read-only" readonly) 1780 1799 (const :tag "Replace text in messages" replace) … … 2064 2083 2065 2084 That is, if called with 2085 2066 2086 (erc-select :server \"irc.freenode.net\" :full-name \"Harry S Truman\") 2087 2067 2088 server and full-name will be set to those values, whereas 2068 erc-compute-port, erc-compute-nick and erc-compute-full-namewill2069 be invoked for th ose parameters' values"2089 `erc-compute-port', `erc-compute-nick' and `erc-compute-full-name' will 2090 be invoked for the values of the other parameters." 2070 2091 (interactive (erc-select-read-args)) 2071 2092 … … 3048 3069 ((functionp res) (funcall res)) 3049 3070 ((stringp res) res) 3050 ;; hopefully never reached3051 ( s))))3071 (s s) 3072 (t (erc-quit-reason-normal))))) 3052 3073 3053 3074 (defun erc-part-reason-normal (&optional s) … … 3075 3096 ((functionp res) (funcall res)) 3076 3097 ((stringp res) res) 3077 (s)))) 3098 (s s) 3099 (t (erc-part-reason-normal))))) 3078 3100 3079 3101 (defun erc-cmd-QUIT (reason) … … 3714 3736 3715 3737 See also `erc-display-error-notice'." 3716 (if (or erc-manual-set-nick-on-bad-nick-p3738 (if (or (not erc-try-new-nick-p) 3717 3739 ;; how many default-nicks are left + one more try... 3718 3740 (eq erc-nick-change-attempt-count … … 3736 3758 nick 3737 3759 (if (and erc-server-connected nicklen) 3738 (- (string-to-number nicklen) 1) 3760 (- (string-to-number nicklen) 3761 (length erc-nick-uniquifier)) 3739 3762 ;; rfc2812 max nick length = 9 3740 3763 ;; we must assume this is the 3741 3764 ;; server's setting if we haven't 3742 3765 ;; established a connection yet 3743 8))3766 (- 9 (length erc-nick-uniquifier)))) 3744 3767 erc-nick-uniquifier))) 3745 3768 (erc-cmd-NICK newnick) … … 5099 5122 "Toggle use of flood control on sent messages. 5100 5123 5101 If ARG is non-nil, use flood control.5102 If ARG is n il, do not use flood control.5124 If ARG is positive, use flood control. 5125 If ARG is non-nil and not positive, do not use flood control. 5103 5126 5104 5127 See `erc-server-flood-margin' for an explanation of the available 5105 5128 flood control parameters." 5106 5129 (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)))) 5108 5134 (message "ERC flood control is %s" 5109 5135 (cond (erc-flood-protect "ON") … … 5131 5157 (defun erc-get-channel-mode-from-keypress (key) 5132 5158 "Read a key sequence and call the corresponding channel mode function. 5133 After doing C-c C-o type in a channel mode letter.5159 After doing C-c C-o, type in a channel mode letter. 5134 5160 5135 5161 C-g means quit. 5136 RET let 's you type more than one mode at a time.5162 RET lets you type more than one mode at a time. 5137 5163 If \"l\" is pressed, `erc-set-channel-limit' gets called. 5138 5164 If \"k\" is pressed, `erc-set-channel-key' gets called. … … 5385 5411 "Return an IRC server name. 5386 5412 5387 T ries a number of increasingly more default methods until a non-nil value is5388 found: 5389 5390 - SERVER 5391 - `erc-server'5413 This tries a number of increasingly more default methods until a 5414 non-nil value is found. 5415 5416 - SERVER (the argument passwd to this function) 5417 - The `erc-server' option 5392 5418 - The value of the IRCSERVER environment variable 5393 - `erc-default-server'."5419 - The `erc-default-server' variable" 5394 5420 (or server 5395 5421 erc-server … … 5398 5424 5399 5425 (defun erc-compute-nick (&optional nick) 5400 "Return user's NICK.5401 5402 T ries a number of increasingly more default methods until a non-nil value is5403 found: 5404 5405 - NICK 5406 - `erc-nick'5426 "Return user's IRC nick. 5427 5428 This tries a number of increasingly more default methods until a 5429 non-nil value is found. 5430 5431 - NICK (the argument passed to this function) 5432 - The `erc-nick' option 5407 5433 - The value of the IRCNICK environment variable 5408 - via the function `user-login-name'."5434 - The result from the `user-login-name' function" 5409 5435 (or nick 5410 5436 (if (consp erc-nick) (car erc-nick) erc-nick) … … 5414 5440 5415 5441 (defun erc-compute-full-name (&optional full-name) 5416 "Return user's FULL-NAME.5417 5418 T ries a number of increasingly more default methods until a non-nil value is5419 found: 5420 5421 - FULL-NAME 5422 - `erc-user-full-name'5442 "Return user's full name. 5443 5444 This tries a number of increasingly more default methods until a 5445 non-nil value is found. 5446 5447 - FULL-NAME (the argument passed to this function) 5448 - The `erc-user-full-name' option 5423 5449 - The value of the IRCNAME environment variable 5424 - via the function `user-full-name'."5450 - The result from the `user-full-name' function" 5425 5451 (or full-name 5426 5452 erc-user-full-name … … 5432 5458 "Return a port for an IRC server. 5433 5459 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")) 5460 This tries a number of increasingly more default methods until a 5461 non-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)) 5440 5467 5441 5468 ;; time routines … … 5819 5846 version-string)))) 5820 5847 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-string5826 (mapconcat 'identity5827 (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 here5836 (insert version-string)5837 (if (interactive-p)5838 (message "%s" version-string)5839 version-string))))5840 5841 5848 (defun erc-modes (&optional here) 5842 5849 "Show the active ERC modes in the minibuffer. … … 5858 5865 (message "%s" string) 5859 5866 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 (progn5866 (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 (concat5870 "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 current5883 (ediff-buffers (find-file current)5884 (erc-latest-version))5885 (error "You do not appear to have the uncompiled erc.el file"))))5886 5867 5887 5868 (defun erc-trim-string (s) … … 6185 6166 (erc-response.command vect))) 6186 6167 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. 6174 If ERC is already connected to HOST:PORT, simply /join CHANNEL. 6175 Otherwise, 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 6187 6191 (provide 'erc) 6188 6192
