diff options
author | Miles Bader <miles@gnu.org> | 2006-07-14 02:29:50 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 2006-07-14 02:29:50 +0000 |
commit | 0b6bb13008bc74c054c00b8f9d24507dd9383689 (patch) | |
tree | adf40183ef9d45dbbb00d1ace47e4b245396e198 /lisp | |
parent | b96028676212ff2a63baaf7087cd88fdc60f907b (diff) | |
download | emacs-0b6bb13008bc74c054c00b8f9d24507dd9383689.tar.gz |
Update for ERC 5.1.3.
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-348
Creator: Michael Olson <mwolson@gnu.org>
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/erc/ChangeLog | 194 | ||||
-rw-r--r-- | lisp/erc/erc-autoaway.el | 128 | ||||
-rw-r--r-- | lisp/erc/erc-backend.el | 12 | ||||
-rw-r--r-- | lisp/erc/erc-identd.el | 31 | ||||
-rw-r--r-- | lisp/erc/erc-imenu.el | 5 | ||||
-rw-r--r-- | lisp/erc/erc-log.el | 80 | ||||
-rw-r--r-- | lisp/erc/erc-match.el | 7 | ||||
-rw-r--r-- | lisp/erc/erc-pcomplete.el | 27 | ||||
-rw-r--r-- | lisp/erc/erc-track.el | 2 | ||||
-rw-r--r-- | lisp/erc/erc.el | 232 | ||||
-rw-r--r-- | lisp/url/ChangeLog | 4 | ||||
-rw-r--r-- | lisp/url/url-irc.el | 4 |
12 files changed, 503 insertions, 223 deletions
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog index 49b274b5149..216d14d0aa6 100644 --- a/lisp/erc/ChangeLog +++ b/lisp/erc/ChangeLog @@ -1,3 +1,197 @@ +2006-07-12 Michael Olson <mwolson@gnu.org> + + * erc-match.el (erc-log-matches): Bind inhibit-read-only rather + than call toggle-read-only. + + * erc.el (erc-handle-irc-url): Move here from erc-goodies.el and + add autoload cookie. + +2006-07-09 Michael Olson <mwolson@gnu.org> + + * erc.el (erc-version-string): Release ERC 5.1.3. + + * erc.texi: Update for the 5.1.3 release. + + * erc-autoaway.el (erc-autoaway-set-back): Fix bug after returning + from being set automatically away and current buffer is not an ERC + buffer. + + * erc-identd.el: Fix compiler error. + + * erc.texi (Development): Use @subheading instead of @subsection. + (Advanced Usage): Add menu. + (Connecting): Fully document how to connect to an IRC server. + (Options, Tips and Tricks, Sample Configuration): New unwritten + sections. + + * erc.el (erc-server, erc-port, erc-nick, erc-nick-uniquifier) + (erc-user-full-name, erc-password): Docfixes and customization + interface tweaks. + (erc-try-new-nick-p): Rename from + `erc-manual-set-nick-on-bad-nick-p' and invert meaning. + (erc-nickname-in-use): Use `erc-try-new-nick-p'. Check the length + of `erc-nick-uniquifier', in case someone wants multiple + characters. + (erc-compute-server, erc-compute-nick, erc-compute-full-name) + (erc-compute-port): Docfixes. + + * erc-log.el (log): Move all add-hook calls here, rather than + executing them immediately, and also cause them to be un-hooked + when the module is removed. + (erc-save-buffer-on-part): Move next to + `erc-save-queries-on-quit'. + (erc-save-buffer-on-quit, erc-save-queries-on-quit): Default to t. + (erc-log-write-after-send, erc-log-write-after-insert): Default to + nil. This makes things fast, but reasonably failsafe, by default. + +2006-07-08 Michael Olson <mwolson@gnu.org> + + * erc-log.el (erc-log-insert-log-on-open): Make this nil by + default, since most IRC clients don't do this. + (erc-log-write-after-send): New option that determines whether the + log file will be written to after every sent message. + (erc-log-write-after-insert): New option that determines whether + the log file will be written to when new text is added to a logged + ERC buffer. + (log): Use the aforementioned options. + + * erc.texi (Modules): Document the "completion" module. + + * erc-pcomplete.el (pcomplete-erc-nicks): Make sure that we don't + have a nil element in the list when ignore-self is non-nil. + +2006-07-05 Michael Olson <mwolson@gnu.org> + + * erc.el (erc-modules): Add the `page' module to the list. + + * erc.texi (Modules): Add entries for `list' and `page' modules. + Change "spell" to "spelling". + (History): Use past tense throughout. + +2006-07-02 Michael Olson <mwolson@gnu.org> + + * erc-backend.el (erc-call-hooks): Fix (stringp nil) error that + can happen when doing /PART. + + * erc.el (erc-quit-reason-various-alist) + (erc-part-reason-various-alist): In the example, use "^$" as an + example, since "" matches anything. + (erc-quit-reason-various, erc-part-reason-various): If no argument + is given, and no matches are found, use our default reason instead + of "nil". + +2006-06-30 Michael Olson <mwolson@gnu.org> + + * erc.texi (Modules): Mention identd. + (Releases): Update mailing list address and download location. + (Development): Refactor. Provide updated directions for Arch. + Make URLs clickable. + (Keystroke Summary): Typo fix. Use more Texinfo syntax. + (Getting Started): Give simpler example. We do not need to + explicitly load every module. + (History): Update. + + * erc.el (erc-version-modules): Remove, since we do not use this + function anymore. + (erc-latest-version, erc-ediff-latest-version): Remove, since this + was only useful back when ERC consisted of one file. + (erc-modules): Add line for identd. + (erc-get-channel-mode-from-keypress): Typo fix. + + * erc-imenu.el: Remove unnecessary lines in header. + + * erc-goodies.el (erc-handle-irc-url): Docfix. + + * erc-identd.el: Define an ERC module for this. + (erc-identd-start): Don't create a process buffer if possible. + Otherwise, use conventional hidden names for process buffers. + +2006-06-29 Michael Olson <mwolson@gnu.org> + + * erc-backend.el (erc-coding-system-for-target): Match + case-insensitively. Use a pattern match instead of `assoc', as + per the documentation for `erc-encoding-coding-alist'. + + * erc-track.el (erc-track-shorten-aggressively): Fix typo. + +2006-06-27 Michael Olson <mwolson@gnu.org> + + * erc.el: Update maintainer information and URLs. + +2006-06-14 Michael Olson <mwolson@gnu.org> + + * erc.el (erc-active-buffer): If the active buffer has been + deleted, default to the server buffer. + (erc-toggle-flood-control): When the user hits C-c C-f, make flood + control really toggle, not unconditionally turn off. + +2006-06-12 Michael Olson <mwolson@gnu.org> + + * NEWS: Add items since the 5.1.2 release. + + * erc-autoaway.el (erc-autoaway-caused-away): New variable that + indicates whether the current away status was caused by this + module. + (erc-autoaway-set-back): Only set back if this module set the user + away. + (erc-autoaway-set-away): Update `erc-autoaway-caused-away'. + (erc-autoaway-reset-indicators): New function that resets some + indicators when the user is no longer away. + (autoaway): Add the above function to the 305 hook. + +2006-06-05 Romain Francoise <romain@orebokech.com> + + * erc.texi (History): Fix various typos. + +2006-06-04 Michael Olson <mwolson@gnu.org> + + * erc-autoaway.el (erc-autoaway-idle-method): Move after the + definition of the autoaway module. + (autoaway): Don't do anything if erc-autoaway-idle-method is + unbound. This prevents an error on startup. + +2006-06-03 Michael Olson <mwolson@gnu.org> + + * erc-autoaway.el: Thanks to Mark Plaksin for the ideas and patch. + (erc-autoaway-idle-method): Renamed from + `erc-autoaway-use-emacs-idle'. We have more than two choices for + how to do this, so it's best to make this take symbol values. + Improve documentation. Remove warning against Emacs idle-time; + the point is moot now that we get user idle time via a different + method. Make sure we disable and re-enable the module when + changing this value. + (autoaway): Conditionalize on the above option. If using the idle + timer or user idle methods, don't add anything to the + send-completed or server-001 hooks, since it is unnecessary. + (erc-autoaway-reestablish-idletimer, erc-autoaway-message): + Docfix. + (erc-autoaway-idle-seconds): Use erc-autoaway-idle-method. + (erc-autoaway-reset-idle-irc): Renamed from + `erc-autoaway-reset-idle'. Don't pass line to + `erc-autoaway-set-away', since it is not used. + (erc-autoaway-reset-idle-user): New function that resets the idle + state for user idle time. + (erc-autoaway-set-back): Remove line argument, since it is not + used. + +2006-06-01 Michael Olson <mwolson@gnu.org> + + * erc.el (erc-buffer-filter): Make sure all buffers returned from + this are live. + +2006-05-01 Edward O'Connor <ted@oconnor.cx> + + * erc-goodies.el: (erc-handle-irc-url): New function, suitable as + a value for `url-irc-function'. + +2006-04-18 Diane Murray <disumu@x3y2z1.net> + + * erc-pcomplete.el (pcomplete-erc-nicks): Added new optional + argument IGNORE-SELF. If this is non-nil, don't return the user's + current nickname. Doc fix. + (pcomplete/erc-mode/complete-command): Don't complete the current + nickname. + 2006-04-05 Diane Murray <disumu@x3y2z1.net> * erc.el (erc-cmd-SV): Removed the exclamation point. Show the diff --git a/lisp/erc/erc-autoaway.el b/lisp/erc/erc-autoaway.el index 56713cba8bf..4614bd70e27 100644 --- a/lisp/erc/erc-autoaway.el +++ b/lisp/erc/erc-autoaway.el @@ -40,19 +40,6 @@ yourself back when you type something." "The Emacs idletimer. This is only used when `erc-autoaway-use-emacs-idle' is non-nil.") -(defcustom erc-autoaway-use-emacs-idle nil - "*If non-nil, the idle time refers to idletime in Emacs. -If nil, the idle time refers to idletime on IRC only. -The time itself is specified by `erc-autoaway-idle-seconds'. -See `erc-autoaway-mode' for more information on the various -definitions of being idle. - -Note that using Emacs idletime is currently broken for most versions, -since process activity (as happens all the time on IRC) makes Emacs -non-idle. Emacs idle-time and user idle-time are just not the same." - :group 'erc-autoaway - :type 'boolean) - ;;;###autoload (autoload 'erc-autoaway-mode "erc-autoaway") (define-erc-module autoaway nil "In ERC autoaway mode, you can be set away automatically. @@ -61,35 +48,65 @@ the number of seconds specified in `erc-autoaway-idle-seconds'. There are several kinds of being idle: -IRC idle time measures how long since you last sent something (see -`erc-autoaway-last-sent-time'). This is the default. +User idle time measures how long you have not been sending any +commands to Emacs. This is the default. Emacs idle time measures how long Emacs has been idle. This is currently not useful, since Emacs is non-idle when it handles -ping-pong with IRC servers. See `erc-autoaway-use-emacs-idle' for -more information. +ping-pong with IRC servers. See `erc-autoaway-idle-method' +for more information. -User idle time measures how long you have not been sending any -commands to Emacs, or to your system. Emacs currently provides no way -to measure user idle time. +IRC idle time measures how long since you last sent something (see +`erc-autoaway-last-sent-time'). If `erc-auto-discard-away' is set, then typing anything, will set you no longer away. Related variables: `erc-public-away-p' and `erc-away-nickname'." ;; Enable: - ((add-hook 'erc-send-completed-hook 'erc-autoaway-reset-idletime) - (add-hook 'erc-server-001-functions 'erc-autoaway-reset-idletime) - (add-hook 'erc-timer-hook 'erc-autoaway-possibly-set-away) - (when erc-autoaway-use-emacs-idle - (erc-autoaway-reestablish-idletimer))) + ((when (boundp 'erc-autoaway-idle-method) + (cond + ((eq erc-autoaway-idle-method 'irc) + (add-hook 'erc-send-completed-hook 'erc-autoaway-reset-idle-irc) + (add-hook 'erc-server-001-functions 'erc-autoaway-reset-idle-irc)) + ((eq erc-autoaway-idle-method 'user) + (add-hook 'post-command-hook 'erc-autoaway-reset-idle-user)) + ((eq erc-autoaway-idle-method 'emacs) + (erc-autoaway-reestablish-idletimer))) + (add-hook 'erc-timer-hook 'erc-autoaway-possibly-set-away) + (add-hook 'erc-server-305-functions 'erc-autoaway-reset-indicators))) ;; Disable: - ((remove-hook 'erc-send-completed-hook 'erc-autoaway-reset-idletime) - (remove-hook 'erc-server-001-functions 'erc-autoaway-reset-idletime) - (remove-hook 'erc-timer-hook 'erc-autoaway-possibly-set-away) - (when erc-autoaway-idletimer - (erc-cancel-timer erc-autoaway-idletimer) - (setq erc-autoaway-idletimer nil)))) + ((when (boundp 'erc-autoaway-idle-method) + (cond + ((eq erc-autoaway-idle-method 'irc) + (remove-hook 'erc-send-completed-hook 'erc-autoaway-reset-idle-irc) + (remove-hook 'erc-server-001-functions 'erc-autoaway-reset-idle-irc)) + ((eq erc-autoaway-idle-method 'user) + (remove-hook 'post-command-hook 'erc-autoaway-reset-idle-user)) + ((eq erc-autoaway-idle-method 'emacs) + (erc-cancel-timer erc-autoaway-idletimer) + (setq erc-autoaway-idletimer nil))) + (remove-hook 'erc-timer-hook 'erc-autoaway-possibly-set-away) + (remove-hook 'erc-server-305-functions 'erc-autoaway-reset-indicators)))) + +(defcustom erc-autoaway-idle-method 'user + "*The method used to determine how long you have been idle. +If 'user, the time of the last command sent to Emacs is used. +If 'emacs, the idle time in Emacs is used. +If 'irc, the time of the last IRC command is used. + +The time itself is specified by `erc-autoaway-idle-seconds'. + +See `erc-autoaway-mode' for more information on the various +definitions of being idle." + :group 'erc-autoaway + :type '(choice (const :tag "User idle time" user) + (const :tag "Emacs idle time" emacs) + (const :tag "Last IRC action" irc)) + :set (lambda (sym val) + (erc-autoaway-disable) + (set-default sym val) + (erc-autoaway-enable))) (defcustom erc-auto-set-away t "*If non-nil, set away after `erc-autoaway-idle-seconds' seconds of idling. @@ -120,8 +137,8 @@ See `erc-auto-discard-away'." (defun erc-autoaway-reestablish-idletimer () "Reestablish the emacs idletimer. -You have to call this function each time you change -`erc-autoaway-idle-seconds', if `erc-autoaway-use-emacs-idle' is set." +If `erc-autoaway-idle-method' is 'emacs, you must call this +function each time you change `erc-autoaway-idle-seconds'." (interactive) (when erc-autoaway-idletimer (erc-cancel-timer erc-autoaway-idletimer)) @@ -138,36 +155,49 @@ you have to run `erc-autoaway-reestablish-idletimer' afterwards." :group 'erc-autoaway :set (lambda (sym val) (set-default sym val) - (when erc-autoaway-use-emacs-idle + (when (eq erc-autoaway-idle-method 'emacs) (erc-autoaway-reestablish-idletimer))) :type 'number) (defcustom erc-autoaway-message "I'm gone (autoaway after %i seconds of idletime)" - "*Message ERC will use when he sets you automatically away. -It is used as a `format' string with the argument of the idletime in -seconds." + "*Message ERC will use when setting you automatically away. +It is used as a `format' string with the argument of the idletime +in seconds." :group 'erc-autoaway :type 'string) (defvar erc-autoaway-last-sent-time (erc-current-time) "The last time the user sent something.") -(defun erc-autoaway-reset-idletime (line &rest stuff) - "Reset the stored idletime for the user. -This is one global variable since a user talking on one net can talk -on another net too." +(defvar erc-autoaway-caused-away nil + "Indicates whether this module was responsible for setting the +user's away status.") + +(defun erc-autoaway-reset-idle-user (&rest stuff) + "Reset the stored user idle time. +This is one global variable since a user talking on one net can +talk on another net too." + (when erc-auto-discard-away + (erc-autoaway-set-back)) + (setq erc-autoaway-last-sent-time (erc-current-time))) + +(defun erc-autoaway-reset-idle-irc (line &rest stuff) + "Reset the stored IRC idle time. +This is one global variable since a user talking on one net can +talk on another net too." (when (and erc-auto-discard-away (stringp line) (not (string-match erc-autoaway-no-auto-discard-regexp line))) - (erc-autoaway-set-back line)) + (erc-autoaway-set-back)) (setq erc-autoaway-last-sent-time (erc-current-time))) -(defun erc-autoaway-set-back (line) +(defun erc-autoaway-set-back () "Discard the away state globally." - (when (erc-away-p) - (setq erc-autoaway-last-sent-time (erc-current-time)) - (erc-cmd-GAWAY ""))) + (let ((server-buffer (car (erc-buffer-list #'erc-server-buffer-p)))) + (when (and erc-autoaway-caused-away + (with-current-buffer server-buffer (erc-away-p))) + (erc-cmd-GAWAY "")))) (defun erc-autoaway-possibly-set-away (current-time) "Set autoaway when `erc-auto-set-away' is true and the idletime is @@ -193,8 +223,14 @@ exceeds `erc-autoaway-idle-seconds'." ;; existing process. (when (and (erc-server-process-alive) (not (erc-away-p))) + (setq erc-autoaway-caused-away t) (erc-cmd-GAWAY (format erc-autoaway-message idle-time)))) +(defun erc-autoaway-reset-indicators (&rest stuff) + "Reset indicators used by the erc-autoaway module." + (setq erc-autoaway-last-sent-time (erc-current-time)) + (setq erc-autoaway-caused-away nil)) + (provide 'erc-autoaway) ;;; erc-autoaway.el ends here diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 3ea0f74eed7..7dce9e4bf01 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -563,7 +563,11 @@ action." "Return the coding system or cons cell appropriate for TARGET. This is determined via `erc-encoding-coding-alist' or `erc-server-coding-system'." - (or (cdr (assoc target erc-encoding-coding-alist)) + (or (let ((case-fold-search t)) + (catch 'match + (dolist (pat erc-encoding-coding-alist) + (when (string-match (car pat) target) + (throw 'match (cdr pat)))))) (and (functionp erc-server-coding-system) (funcall erc-server-coding-system)) erc-server-coding-system)) @@ -849,8 +853,10 @@ Finds hooks by looking in the `erc-server-responses' hashtable." (let ((hook (or (erc-get-hook (erc-response.command message)) 'erc-default-server-functions))) (run-hook-with-args-until-success hook process message) - (with-current-buffer (erc-server-buffer) - (run-hook-with-args 'erc-timer-hook (erc-current-time))))) + (let ((server-buffer (erc-server-buffer))) + (when (buffer-live-p server-buffer) + (with-current-buffer server-buffer + (run-hook-with-args 'erc-timer-hook (erc-current-time))))))) (add-hook 'erc-default-server-functions 'erc-handle-unknown-server-response) diff --git a/lisp/erc/erc-identd.el b/lisp/erc/erc-identd.el index 0f70aab0fbd..f30c40d4792 100644 --- a/lisp/erc/erc-identd.el +++ b/lisp/erc/erc-identd.el @@ -24,16 +24,32 @@ ;;; Commentary: -;; You can have a local identd server (running on port 8113; I use DNAT -;; to bind 113->8113) if you add this to .emacs.el: +;; This module allows you to run a local identd server on port 8113. +;; You will need to set up DNAT to bind 113->8113, or use a proxy. -;; (add-hook 'erc-connect-pre-hook 'erc-identd-start) -;; (add-hook 'erc-disconnected-hook 'erc-identd-stop) +;; To use this module, add identd to `erc-modules' and run +;; `erc-update-modules'. + +;; Here is an example /etc/inetd.conf rule that forwards identd +;; traffic to port 8113. You will need simpleproxy installed for it +;; to work. + +;; 113 stream tcp nowait nobody /usr/sbin/tcpd /usr/bin/simpleproxy simpleproxy -i -R 127.0.0.1:8113 ;;; Code: +(require 'erc) + (defvar erc-identd-process nil) +;;;###autoload (autoload 'erc-identd-mode "erc-identd") +(define-erc-module identd nil + "This mode launches an identd server on port 8113." + ((add-hook 'erc-connect-pre-hook 'erc-identd-start) + (add-hook 'erc-disconnected-hook 'erc-identd-stop)) + ((remove-hook 'erc-connect-pre-hook 'erc-identd-start) + (remove-hook 'erc-disconnected-hook 'erc-identd-stop))) + (defun erc-identd-filter (proc string) "This filter implements RFC1413 (identd authentication protocol)." (let ((erc-identd-process proc)) @@ -63,10 +79,11 @@ system." (delete-process erc-identd-process)) (setq erc-identd-process (make-network-process :name "identd" - :buffer (generate-new-buffer "identd") + :buffer nil :host 'local :service port - :server t :noquery t - :filter 'erc-identd-filter))) + :server t :noquery t :nowait t + :filter 'erc-identd-filter)) + (set-process-query-on-exit-flag erc-identd-process nil)) ;;;###autoload (defun erc-identd-stop (&rest ignore) diff --git a/lisp/erc/erc-imenu.el b/lisp/erc/erc-imenu.el index 88de1cedf6e..e897a9d8a0c 100644 --- a/lisp/erc/erc-imenu.el +++ b/lisp/erc/erc-imenu.el @@ -31,11 +31,6 @@ ;;; Code: - -;; Author: Mario Lang <mlang@delysid.org> - -;; This file is not part of GNU Emacs. But the same license applies. - ;;; Commentary: ;; This package defines the function `erc-create-imenu-index'. ERC diff --git a/lisp/erc/erc-log.el b/lisp/erc/erc-log.el index db60e5629bf..b316a8588bd 100644 --- a/lisp/erc/erc-log.el +++ b/lisp/erc/erc-log.el @@ -115,11 +115,6 @@ SERVER and PORT are the parameters used to connect BUFFERs (const erc-generate-log-file-name-with-date) (symbol))) -(defcustom erc-save-buffer-on-part nil - "*Save the channel buffer content using `erc-save-buffer-in-logs' on PART." - :group 'erc-log - :type 'boolean) - (defcustom erc-truncate-buffer-on-save nil "Truncate any ERC (channel, query, server) buffer when it is saved." :group 'erc-log @@ -150,14 +145,41 @@ directory should not end with a trailing slash." :type '(choice directory (const nil))) -(defcustom erc-log-insert-log-on-open t +(defcustom erc-log-insert-log-on-open nil "*Insert log file contents into the buffer if a log file exists." :group 'erc-log :type 'boolean) -(defcustom erc-save-queries-on-quit nil - "Save all query (also channel) buffers of the server on QUIT. -See the variable `erc-save-buffer-on-part' for details." +(defcustom erc-save-buffer-on-part t + "*Save the channel buffer content using `erc-save-buffer-in-logs' on PART. + +If you set this to nil, you may want to enable both +`erc-log-write-after-send' and `erc-log-write-after-insert'." + :group 'erc-log + :type 'boolean) + +(defcustom erc-save-queries-on-quit t + "*Save all query (also channel) buffers of the server on QUIT. + +If you set this to nil, you may want to enable both +`erc-log-write-after-send' and `erc-log-write-after-insert'." + :group 'erc-log + :type 'boolean) + +(defcustom erc-log-write-after-send nil + "*If non-nil, write to log file after every message you send. + +If you set this to nil, you may want to enable both +`erc-save-buffer-on-part' and `erc-save-queries-on-quit'." + :group 'erc-log + :type 'boolean) + +(defcustom erc-log-write-after-insert nil + "*If non-nil, write to log file when new text is added to a +logged ERC buffer. + +If you set this to nil, you may want to enable both +`erc-save-buffer-on-part' and `erc-save-queries-on-quit'." :group 'erc-log :type 'boolean) @@ -187,29 +209,28 @@ also be a predicate function. To only log when you are not set away, use: (with-current-buffer buffer (not erc-away))))" ;; enable - ((add-hook 'erc-insert-post-hook - 'erc-save-buffer-in-logs) - (add-hook 'erc-send-post-hook - 'erc-save-buffer-in-logs)) + ((when erc-log-write-after-insert + (add-hook 'erc-insert-post-hook 'erc-save-buffer-in-logs)) + (when erc-log-write-after-send + (add-hook 'erc-send-post-hook 'erc-save-buffer-in-logs)) + (add-hook 'erc-kill-buffer-hook 'erc-save-buffer-in-logs) + (add-hook 'erc-kill-channel-hook 'erc-save-buffer-in-logs) + (add-hook 'erc-quit-hook 'erc-conditional-save-queries) + (add-hook 'erc-part-hook 'erc-conditional-save-buffer) + ;; append, so that 'erc-initialize-log-marker runs first + (add-hook 'erc-connect-pre-hook 'erc-log-setup-logging 'append)) ;; disable - ((remove-hook 'erc-insert-post-hook - 'erc-save-buffer-in-logs) - (remove-hook 'erc-send-post-hook - 'erc-save-buffer-in-logs))) - -(when erc-enable-logging - (add-hook 'erc-kill-buffer-hook - 'erc-save-buffer-in-logs) - (add-hook 'erc-kill-channel-hook - 'erc-save-buffer-in-logs) - (add-hook 'erc-quit-hook - 'erc-conditional-save-queries) - (add-hook 'erc-part-hook - 'erc-conditional-save-buffer)) + ((remove-hook 'erc-insert-post-hook 'erc-save-buffer-in-logs) + (remove-hook 'erc-send-post-hook 'erc-save-buffer-in-logs) + (remove-hook 'erc-kill-buffer-hook 'erc-save-buffer-in-logs) + (remove-hook 'erc-kill-channel-hook 'erc-save-buffer-in-logs) + (remove-hook 'erc-quit-hook 'erc-conditional-save-queries) + (remove-hook 'erc-part-hook 'erc-conditional-save-buffer) + (remove-hook 'erc-connect-pre-hook 'erc-log-setup-logging))) (define-key erc-mode-map "\C-c\C-l" 'erc-save-buffer-in-logs) -;;;functionality referenced from erc.el +;;; functionality referenced from erc.el (defun erc-log-setup-logging () "Setup the buffer-local logging variables in the current buffer. This function is destined to be run from `erc-connect-pre-hook'." @@ -224,9 +245,6 @@ This function is destined to be run from `erc-connect-pre-hook'." (move-marker erc-last-saved-position (1- (point-max))))))) -;;; Append, so that 'erc-initialize-log-marker keeps running first. -(add-hook 'erc-connect-pre-hook 'erc-log-setup-logging 'append) - (defun erc-log-all-but-server-buffers (buffer) "Returns t if logging should be enabled in BUFFER. Returns nil iff `erc-server-buffer-p' returns t." diff --git a/lisp/erc/erc-match.el b/lisp/erc/erc-match.el index 88c6d4c425d..ffbc7482aae 100644 --- a/lisp/erc/erc-match.el +++ b/lisp/erc/erc-match.el @@ -553,10 +553,9 @@ deactivate/activate match logging in the latter. See ?m message ?u nickuserhost)))) (with-current-buffer (erc-log-matches-make-buffer match-buffer-name) - (toggle-read-only -1) - (point-max) - (insert line) - (toggle-read-only 1)))))) + (let ((inhibit-read-only t)) + (goto-char (point-max)) + (insert line))))))) (defun erc-log-matches-make-buffer (name) "Create or get a log-matches buffer named NAME and return it." diff --git a/lisp/erc/erc-pcomplete.el b/lisp/erc/erc-pcomplete.el index d6d4dfdd3b3..33231ee2590 100644 --- a/lisp/erc/erc-pcomplete.el +++ b/lisp/erc/erc-pcomplete.el @@ -106,7 +106,7 @@ the most recent speakers are listed first." (pcomplete-here (append (pcomplete-erc-commands) - (pcomplete-erc-nicks erc-pcomplete-nick-postfix)))) + (pcomplete-erc-nicks erc-pcomplete-nick-postfix t)))) (defvar erc-pcomplete-ctcp-commands '("ACTION" "CLIENTINFO" "ECHO" "FINGER" "PING" "TIME" "USERINFO" "VERSION")) @@ -212,14 +212,23 @@ the most recent speakers are listed first." not-ops)) -(defun pcomplete-erc-nicks (&optional postfix) - "Returns a list of nicks in the current channel." - (let ((users (erc-get-channel-user-list))) - (if erc-pcomplete-order-nickname-completions - (setq users (erc-sort-channel-users-by-activity users))) - (mapcar (lambda (x) - (concat (erc-server-user-nickname (car x)) postfix)) - users))) +(defun 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) + (unless (and ignore-self + (string= (erc-server-user-nickname (car user)) + (erc-current-nick))) + (setq nicks (cons (concat (erc-server-user-nickname (car user)) + postfix) + nicks)))) + (nreverse nicks))) (defun pcomplete-erc-all-nicks (&optional postfix) "Returns a list of all nicks on the current server." diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el index 63005678613..b045fb24999 100644 --- a/lisp/erc/erc-track.el +++ b/lisp/erc/erc-track.el @@ -108,7 +108,7 @@ If this variable is set to `max', then channel names will be shortened to the max. Usually, shortened channel names will remain unique for a given set of existing channels. When shortening to the max, the shortened channel names will be unique for the set of active channels only. -Example: If there are tow active channels #emacs and #vi, and two inactive +Example: If there are two active channels #emacs and #vi, and two inactive channels #electronica and #folk, then usually the active channels are shortened to #em and #v. When shortening to the max, however, #emacs is not compared to #electronica -- only to #vi, therefore it can be shortened diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 1baede01259..fd5a49eae4b 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -11,7 +11,7 @@ ;; Andreas Fuchs (afs@void.at) ;; Gergely Nagy (algernon@midgard.debian.net) ;; David Edmondson (dme@dme.org) -;; Maintainer: Mario Lang (mlang@delysid.org) +;; Maintainer: Michael Olson (mwolson@gnu.org) ;; Keywords: IRC, chat, client, Internet ;; This file is part of GNU Emacs. @@ -36,12 +36,13 @@ ;; ERC is an IRC client for Emacs. ;; For more information, see the following URLs: -;; * http://sf.net/projects/erc/ +;; * http://sv.gnu.org/projects/erc/ ;; * http://www.emacswiki.org/cgi-bin/wiki.pl?EmacsIRCClient -;; Jul-26-2001. erc.el is now in CVS on SourceForge. I invite everyone -;; who wants to hack it to contact me <mlang@delysid.org> in order to -;; get write access on the CVS. +;; As of 2006-06-13, ERC development is now hosted on Savannah +;; (http://sv.gnu.org/projects/erc). I invite everyone who wants to +;; hack on it to contact me <mwolson@gnu.org> in order to get write +;; access to the shared Arch archive. ;; Installation: @@ -66,7 +67,7 @@ ;;; Code: -(defconst erc-version-string "Version 5.1.2" +(defconst erc-version-string "Version 5.1.3" "ERC version. This is used by function `erc-version'.") (eval-when-compile (require 'cl)) @@ -77,12 +78,12 @@ (require 'erc-menu) (defvar erc-official-location - "http://erc.sf.net (comments mailto://mlang@delysid.org)" + "http://emacswiki.org/cgi-bin/wiki/ERC (mailing list: erc-discuss@gnu.org)" "Location of the ERC client on the Internet.") (defgroup erc nil "Emacs Internet Relay Chat client." - :link '(url-link "http://www.emacswiki.org/cgi-bin/wiki.pl?EmacsIRCClient") + :link '(url-link "http://www.emacswiki.org/cgi-bin/wiki/ERC") :prefix "erc-" :group 'applications) @@ -143,57 +144,69 @@ ;; tunable connection and authentication parameters (defcustom erc-server nil - "IRC server to use. + "IRC server to use if one is not provided. See function `erc-compute-server' for more details on connection parameters and authentication." :group 'erc - :type '(choice (const nil) string)) + :type '(choice (const :tag "None" nil) + (string :tag "Server"))) (defcustom erc-port nil - "IRC port to use." + "IRC port to use if not specified. + +This can be either a string or a number." :group 'erc - :type '(choice (const nil) number string)) + :type '(choice (const :tag "None" nil) + (const :tag "Port number" number) + (const :tag "Port string" string))) (defcustom erc-nick nil - "Nickname to use. + "Nickname to use if one is not provided. -Can be either a string, or a list of strings. +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. See function `erc-compute-nick' for more details on connection parameters and authentication." :group 'erc - :type '(choice (const nil) + :type '(choice (const :tag "None" nil) (string :tag "Nickname") - (repeat string))) + (repeat (string :tag "Nickname")))) (defcustom erc-nick-uniquifier "`" - "The character to append to the nick if it is already in use." + "The string to append to the nick if it is already in use." :group 'erc :type 'string) -(defcustom erc-manual-set-nick-on-bad-nick-p nil - "If the nickname you chose isn't available, ERC should not automatically -attempt to set another nickname. You can manually set another nickname with -the /NICK command." +(defcustom erc-try-new-nick-p t + "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." :group 'erc :type 'boolean) (defcustom erc-user-full-name nil "User full name. +This can be either a string or a function to call. + See function `erc-compute-full-name' for more details on connection parameters and authentication." :group 'erc - :type '(choice (const nil) string function) + :type '(choice (const :tag "No name" nil) + (string :tag "Name") + (function :tag "Get from function")) :set (lambda (sym val) (if (functionp val) (set sym (funcall val)) (set sym val)))) (defvar erc-password nil - "ERC password to use in authentication (not necessary).") + "Password to use when authenticating to an IRC server. +It is not strictly necessary to provide this, since ERC will +prompt you for it.") (defcustom erc-user-mode nil "Initial user modes to be set after a connection is established." @@ -871,7 +884,7 @@ As an example: (\"xmms\" dme:now-playing) (\"version\" erc-quit-reason-normal) (\"home\" \"Gone home !\") - (\"\" \"Default Reason\"))) + (\"^$\" \"Default Reason\"))) If the user types \"/quit zippy\", then a Zippy the Pinhead quotation will be used as the quit message." :group 'erc-quit-and-part @@ -895,7 +908,7 @@ As an example: (\"xmms\" dme:now-playing) (\"version\" erc-part-reason-normal) (\"home\" \"Gone home !\") - (\"\" \"Default Reason\"))) + (\"^$\" \"Default Reason\"))) If the user types \"/part zippy\", then a Zippy the Pinhead quotation will be used as the part message." :group 'erc-quit-and-part @@ -1373,7 +1386,10 @@ server buffer") (defun erc-active-buffer () "Return the value of `erc-active-buffer' for the current server. Defaults to the server buffer." - (with-current-buffer (erc-server-buffer) erc-active-buffer)) + (with-current-buffer (erc-server-buffer) + (if (buffer-live-p erc-active-buffer) + erc-active-buffer) + (setq erc-active-buffer (current-buffer)))) (defun erc-set-active-buffer (buffer) "Set the value of `erc-active-buffer' to BUFFER." @@ -1595,12 +1611,13 @@ server connection, or nil which means all open connections." (delq nil (mapcar (lambda (buf) - (with-current-buffer buf - (and (eq major-mode 'erc-mode) - (or (not proc) - (eq proc erc-server-process)) - (funcall predicate) - buf))) + (when (buffer-live-p buf) + (with-current-buffer buf + (and (eq major-mode 'erc-mode) + (or (not proc) + (eq proc erc-server-process)) + (funcall predicate) + buf)))) (buffer-list))))) (defun erc-buffer-list (&optional predicate proc) @@ -1760,11 +1777,12 @@ removed from the list will be disabled." :greedy t (const :tag "Set away status automatically" autoaway) (const :tag "Join channels automatically" autojoin) - (const :tag "Integrate with Big Brother Database" bbdb) (const :tag "Buttonize URLs, nicknames, and other text" button) (const :tag "Wrap long lines" fill) + (const :tag "Launch an identd server on port 8113" identd) (const :tag "Highlight or remove IRC control characters" irccontrols) + (const :tag "List channels in a separate buffer" list) (const :tag "Save buffers in logs" log) (const :tag "Highlight pals, fools, and other keywords" match) (const :tag "Detect netsplits" netsplit) @@ -1776,6 +1794,7 @@ removed from the list will be disabled." (const :tag "Complete nicknames and commands (programmable)" completion) (const :tag "Complete nicknames and commands (old)" hecomplete) + (const :tag "Process CTCP PAGE requests from IRC" page) (const :tag "Make displayed lines read-only" readonly) (const :tag "Replace text in messages" replace) (const :tag "Enable an input history" ring) @@ -2063,10 +2082,12 @@ Non-interactively, it takes keyword arguments (full-name (erc-compute-full-name))) That is, if called with + (erc-select :server \"irc.freenode.net\" :full-name \"Harry S Truman\") + 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 those parameters' values" +`erc-compute-port', `erc-compute-nick' and `erc-compute-full-name' will +be invoked for the values of the other parameters." (interactive (erc-select-read-args)) (run-hook-with-args 'erc-before-connect server port nick) @@ -3047,8 +3068,8 @@ If S is non-nil, it will be used as the quit reason." (cond ((functionp res) (funcall res)) ((stringp res) res) - ;; hopefully never reached - (s)))) + (s s) + (t (erc-quit-reason-normal))))) (defun erc-part-reason-normal (&optional s) "Normal part message. @@ -3074,7 +3095,8 @@ If S is non-nil, it will be used as the quit reason." (cond ((functionp res) (funcall res)) ((stringp res) res) - (s)))) + (s s) + (t (erc-part-reason-normal))))) (defun erc-cmd-QUIT (reason) "Disconnect from the current server. @@ -3713,7 +3735,7 @@ E.g. \"Read error to Nick [user@some.host]: 110\" would be shortened to "If NICK is unavailable, tell the user the REASON. See also `erc-display-error-notice'." - (if (or erc-manual-set-nick-on-bad-nick-p + (if (or (not erc-try-new-nick-p) ;; how many default-nicks are left + one more try... (eq erc-nick-change-attempt-count (if (consp erc-nick) @@ -3735,12 +3757,13 @@ See also `erc-display-error-notice'." (setq newnick (concat (truncate-string-to-width nick (if (and erc-server-connected nicklen) - (- (string-to-number nicklen) 1) + (- (string-to-number nicklen) + (length erc-nick-uniquifier)) ;; rfc2812 max nick length = 9 ;; we must assume this is the ;; server's setting if we haven't ;; established a connection yet - 8)) + (- 9 (length erc-nick-uniquifier)))) erc-nick-uniquifier))) (erc-cmd-NICK newnick) (erc-display-error-notice @@ -5098,13 +5121,16 @@ If ARG is non-nil and not positive, turns CTCP replies off." (defun erc-toggle-flood-control (&optional arg) "Toggle use of flood control on sent messages. -If ARG is non-nil, use flood control. -If ARG is nil, do not use flood control. +If ARG is positive, use flood control. +If ARG is non-nil and not positive, do not use flood control. See `erc-server-flood-margin' for an explanation of the available flood control parameters." (interactive "P") - (setq erc-flood-protect arg) + (cond ((and (numberp arg) (> arg 0)) + (setq erc-flood-protect t)) + (arg (setq erc-flood-protect nil)) + (t (setq erc-flood-protect (not erc-flood-protect)))) (message "ERC flood control is %s" (cond (erc-flood-protect "ON") (t "OFF")))) @@ -5130,10 +5156,10 @@ This command is sent even if excess flood is detected." (defun erc-get-channel-mode-from-keypress (key) "Read a key sequence and call the corresponding channel mode function. -After doing C-c C-o type in a channel mode letter. +After doing C-c C-o, type in a channel mode letter. C-g means quit. -RET let's you type more than one mode at a time. +RET lets you type more than one mode at a time. If \"l\" is pressed, `erc-set-channel-limit' gets called. If \"k\" is pressed, `erc-set-channel-key' gets called. Anything else will be sent to `erc-toggle-channel-mode'." @@ -5384,28 +5410,28 @@ Sets the buffer local variables: (defun erc-compute-server (&optional server) "Return an IRC server name. -Tries a number of increasingly more default methods until a non-nil value is -found: +This tries a number of increasingly more default methods until a +non-nil value is found. -- SERVER -- `erc-server' +- SERVER (the argument passwd to this function) +- The `erc-server' option - The value of the IRCSERVER environment variable -- `erc-default-server'." +- The `erc-default-server' variable" (or server erc-server (getenv "IRCSERVER") erc-default-server)) (defun erc-compute-nick (&optional nick) - "Return user's NICK. + "Return user's IRC nick. -Tries a number of increasingly more default methods until a non-nil value is -found: +This tries a number of increasingly more default methods until a +non-nil value is found. -- NICK -- `erc-nick' +- NICK (the argument passed to this function) +- The `erc-nick' option - The value of the IRCNICK environment variable -- via the function `user-login-name'." +- The result from the `user-login-name' function" (or nick (if (consp erc-nick) (car erc-nick) erc-nick) (getenv "IRCNICK") @@ -5413,15 +5439,15 @@ found: (defun erc-compute-full-name (&optional full-name) - "Return user's FULL-NAME. + "Return user's full name. -Tries a number of increasingly more default methods until a non-nil value is -found: +This tries a number of increasingly more default methods until a +non-nil value is found. -- FULL-NAME -- `erc-user-full-name' +- FULL-NAME (the argument passed to this function) +- The `erc-user-full-name' option - The value of the IRCNAME environment variable -- via the function `user-full-name'." +- The result from the `user-full-name' function" (or full-name erc-user-full-name (getenv "IRCNAME") @@ -5431,12 +5457,13 @@ found: (defun erc-compute-port (&optional port) "Return a port for an IRC server. -Tries a number of increasingly more default methods until a non-nil -value is found: +This tries a number of increasingly more default methods until a +non-nil value is found. -- PORT -- \"ircd\"." - (or port erc-port "ircd")) +- PORT (the argument passed to this function) +- The `erc-port' option +- The `erc-default-port' variable" + (or port erc-port erc-default-port)) ;; time routines @@ -5818,26 +5845,6 @@ If optional argument HERE is non-nil, insert version number at point." (message "%s" version-string) version-string)))) -(defun erc-version-modules (&optional here) - "Show the version numbers of all loaded ERC modules in the minibuffer. -If optional argument HERE is non-nil, insert version number at point." - (interactive "P") - (let ((version-string - (mapconcat 'identity - (let (versions (case-fold-search nil)) - (dolist (var (apropos-internal "^erc-.*version$")) - (when (and (boundp var) - (stringp (symbol-value var))) - (setq versions (cons (format "%S: %s" - var (symbol-value var)) - versions)))) - versions) ", "))) - (if here - (insert version-string) - (if (interactive-p) - (message "%s" version-string) - version-string)))) - (defun erc-modes (&optional here) "Show the active ERC modes in the minibuffer. If optional argument HERE is non-nil, insert version number at point." @@ -5858,32 +5865,6 @@ If optional argument HERE is non-nil, insert version number at point." (message "%s" string) string)))) -(defun erc-latest-version () - "Retrieve the latest erc.el version from CVS." - (interactive) - (if (ignore-errors (require 'url)) - (progn - (switch-to-buffer (get-buffer-create "*erc.el latest version*")) - (delete-region (point-min) (point-max)) - (kill-all-local-variables) - (url-insert-file-contents (concat - "http://cvs.sourceforge.net/viewcvs.py/" - "*checkout*/erc/erc/erc.el?content-type" - "=text%2Fplain&rev=HEAD")) - (emacs-lisp-mode) - (current-buffer)) - (error "URL needs to be installed"))) - -(defun erc-ediff-latest-version () - "Ediff your installed erc.el with the latest CVS version. -See also `erc-latest-version'." - (interactive) - (let ((current (locate-library "erc.el"))) - (if current - (ediff-buffers (find-file current) - (erc-latest-version)) - (error "You do not appear to have the uncompiled erc.el file")))) - (defun erc-trim-string (s) "Trim leading and trailing spaces off S." (cond @@ -6184,6 +6165,29 @@ This function should be on `erc-kill-channel-hook'." (and vect (erc-response.command vect))) +;; Teach url.el how to open irc:// URLs with ERC. +;; To activate, customize `url-irc-function' to `url-irc-erc'. + +;;;###autoload +(defun erc-handle-irc-url (host port channel user password) + "Use ERC to IRC on HOST:PORT in CHANNEL as USER with PASSWORD. +If ERC is already connected to HOST:PORT, simply /join CHANNEL. +Otherwise, connect to HOST:PORT as USER and /join CHANNEL." + (let ((server-buffer + (car (erc-buffer-filter + (lambda () + (and (string-equal erc-session-server host) + (= erc-session-port port) + erc-server-connected + (eq (erc-server-buffer) (current-buffer)))))))) + (with-current-buffer (or server-buffer (current-buffer)) + (if (and server-buffer channel) + (erc-cmd-JOIN channel) + (erc host port (or user (erc-compute-nick)) (erc-compute-full-name) + (not server-buffer) password nil channel + (when server-buffer + (get-buffer-process server-buffer))))))) + (provide 'erc) ;;; Deprecated. We might eventually stop requiring the goodies automatically. diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog index 0eb0b654053..901fac01208 100644 --- a/lisp/url/ChangeLog +++ b/lisp/url/ChangeLog @@ -1,3 +1,7 @@ +2006-07-12 Michael Olson <mwolson@gnu.org> + + * url-irc.el (url-irc-erc): Call erc-handle-irc-url. + 2006-07-11 Stefan Monnier <monnier@iro.umontreal.ca> * url-cookie.el: Remove spurious * in docstrings. diff --git a/lisp/url/url-irc.el b/lisp/url/url-irc.el index 6a7a62573e9..19eec6f2ef2 100644 --- a/lisp/url/url-irc.el +++ b/lisp/url/url-irc.el @@ -68,9 +68,7 @@ PASSWORD - What password to use" (switch-to-buffer (concat chan "@" host))))) (defun url-irc-erc (host port channel user password) - (erc-select :server host :port port :nick user :password password) - (when channel - (erc-join-channel channel))) + (erc-handle-irc-url host port channel user password)) ;;;###autoload (defun url-irc (url) |