diff options
Diffstat (limited to 'lisp/erc')
-rw-r--r-- | lisp/erc/ChangeLog | 447 | ||||
-rw-r--r-- | lisp/erc/erc-autoaway.el | 3 | ||||
-rw-r--r-- | lisp/erc/erc-backend.el | 175 | ||||
-rw-r--r-- | lisp/erc/erc-button.el | 2 | ||||
-rw-r--r-- | lisp/erc/erc-compat.el | 16 | ||||
-rw-r--r-- | lisp/erc/erc-goodies.el | 17 | ||||
-rw-r--r-- | lisp/erc/erc-ibuffer.el | 8 | ||||
-rw-r--r-- | lisp/erc/erc-identd.el | 3 | ||||
-rw-r--r-- | lisp/erc/erc-lang.el | 2 | ||||
-rw-r--r-- | lisp/erc/erc-log.el | 105 | ||||
-rw-r--r-- | lisp/erc/erc-match.el | 2 | ||||
-rw-r--r-- | lisp/erc/erc-netsplit.el | 15 | ||||
-rw-r--r-- | lisp/erc/erc-notify.el | 3 | ||||
-rw-r--r-- | lisp/erc/erc-services.el | 83 | ||||
-rw-r--r-- | lisp/erc/erc-sound.el | 12 | ||||
-rw-r--r-- | lisp/erc/erc-stamp.el | 84 | ||||
-rw-r--r-- | lisp/erc/erc-track.el | 124 | ||||
-rw-r--r-- | lisp/erc/erc.el | 303 |
18 files changed, 1127 insertions, 277 deletions
diff --git a/lisp/erc/ChangeLog b/lisp/erc/ChangeLog index a631a4514a4..b7d1d1bfe30 100644 --- a/lisp/erc/ChangeLog +++ b/lisp/erc/ChangeLog @@ -1,3 +1,62 @@ +2008-01-04 Stefan Monnier <monnier@iro.umontreal.ca> + + * erc-ibuffer.el (erc-channel-modes): + Pass mode-name through format-mode-line + +2007-12-09 Michael Olson <mwolson@gnu.org> + + * erc-services.el (erc-nickserv-alist): Fix regexps for GRnet. + +2007-12-09 Giorgos Keramidas <keramida@ceid.upatras.gr> (tiny change) + + * erc-backend.el, erc.el: + Parse 275 (secure connection) responses. + + * erc-services.el: Add identification hooks for GRnet, the Greek + IRC network <http://www.irc.gr>. + +2007-12-08 David Kastrup <dak@gnu.org> + + * erc-stamp.el (erc-echo-timestamp): + * erc-lang.el (language): + * erc-backend.el (erc-server-connect): Fix buggy call to `message'. + +2007-12-07 Edward O'Connor <ted@oconnor.cx> + + * erc-services.el: Provide a hook that runs when nickserv confirms + that the user has successfully identified. + (services, erc-nickserv-identify-mode): Add and remove + erc-nickserv-identification-autodetect from + erc-server-NOTICE-functions. + (erc-nickserv-alist): Add SUCCESS-REGEXP to each entry. + (erc-nickserv-alist-identified-regexp) + (erc-nickserv-identification-autodetect): New functions. + (erc-nickserv-identified-hook): New hook. + +2007-12-06 D. Goel <deego3@gmail.com> + + * erc-match.el (erc-add-entry-to-list): Fix buggy call to `error'. + +2007-12-01 Glenn Morris <rgm@gnu.org> + + * erc-backend.el (erc-server-send-ping): Move after definition of + erc-server-send. + + * erc.el (iswitchb-temp-buflist, iswitchb-read-buffer) + (erc-controls-strip): Declare for compiler. + (erc-iswitchb): Don't require iswitchb when compiling. Test + iswitchb-mode is bound. + +2007-11-30 Dan Nicolaescu <dann@ics.uci.edu> + + * erc.el (open-ssl-stream, open-tls-stream, erc-network-name): + Declare as functions. + +2007-11-29 Giorgos Keramidas <keramida@ceid.upatras.gr> (tiny change) + + * erc-backend.el, erc.el: + Parse 307 (nick has identified) responses. + 2007-11-15 Juanma Barranquero <lekktu@gmail.com> * erc.el (erc-open): @@ -5,27 +64,405 @@ * erc-log.el (log): * erc-match.el (erc-log-matches): Fix typos in docstrings. +2007-11-11 Michael Olson <mwolson@gnu.org> + + * erc-autoaway.el (erc-autoaway-possibly-set-away): + * erc-netsplit.el (erc-netsplit-timer): + * erc-notify.el (erc-notify-timer): + * erc-track.el (erc-user-is-active): Only run if we have + successfully established a connection to the server and have + logged in. I suspect that sending messages too soon may make some + IRC servers not respond well, particularly when the network + connection is iffy or subject to traffic-shaping. + +2007-11-01 Michael Olson <mwolson@gnu.org> + + * erc-compat.el (erc-set-write-file-functions): New compatibility + function to set the write hooks appropriately. + + * erc-log.el (erc-log-setup-logging): Use + erc-set-write-file-functions. This fixes a byte-compiler warning. + + * erc-stamp.el: Silence byte-compiler warning about + erc-fill-column. + + * erc.el (erc-with-all-buffers-of-server): Bind the result of + mapcar to a variable in order to silence a byte-compiler warning. + +2007-10-29 Michael Olson <mwolson@gnu.org> + + * erc-ibuffer.el (erc-modified-channels-alist): Use + eval-when-compile, and explain why we are doing this. + +2007-10-25 Dan Nicolaescu <dann@ics.uci.edu> + + * erc-ibuffer.el (erc-modified-channels-alist): Pacify + byte-compiler. + +2007-10-13 Glenn Morris <rgm@gnu.org> + + * erc-track.el (erc-modified-channels-update): Use mapc rather + than mapcar. + +2007-10-12 Diane Murray <disumu@x3y2z1.net> + + * erc.el (erc-join-channel): Prompt for channel key if C-u or + another prefix-arg was typed. + + * NEWS: Noted this change. + +2007-10-07 Michael Olson <mwolson@gnu.org> + + * erc.el (erc-cmd-ME'S): New command that handles the case where + someone types "/me's". It concatenates the text " 's" to the + beginning of the input and then sends the result like a normal + "/me" command. + (erc-command-regexp): Permit single-quote character. + +2007-09-30 Aidan Kehoe <kehoea@parhasard.net> (tiny change) + + * erc-log.el (erc-save-buffer-in-logs): Prevent spurious warnings + when looking at a log file and concurrently saving to it. + +2007-09-18 Exal de Jesus Garcia Carrillo <exal@gnu.org> (tiny change) + + * erc.texi (Special-Features): Fix small typo. + +2007-09-16 Michael Olson <mwolson@gnu.org> + + * erc-track.el (erc-track-switch-direction): Mention + erc-track-faces-priority-list. Thanks to Leo for the suggestion. + +2007-09-11 Exal de Jesus Garcia Carrillo <exal@gnu.org> (tiny change) + + * erc-sound.el: Fix typo in setting up instructions. + +2007-09-10 Michael Olson <mwolson@gnu.org> + + * Makefile (elpa): Copy dir template rather than echoing a few + lines. The reason for this is that the ELPA package for ERC was + getting a corrupt dir entry. + + * dir-template: Template for the ELPA dir file. + +2007-09-08 Michael Olson <mwolson@gnu.org> + + * erc-log.el (erc-log-filter-function): New option that specifies + the function to call for filtering text before writing it to a log + file. Thanks to David O'Toole for the suggestion. + (erc-save-buffer-in-logs): Use erc-log-filter-function. Make sure + we carry along the value of coding-system-for-write, because this + could potentially be shadowed by the temporary buffer. + + * erc.el (erc-version-string): Update to 5.3, development version. + +2007-09-07 Glenn Morris <rgm@gnu.org> + + * erc.el (erc-toggle-debug-irc-protocol): Fix call to + erc-view-mode-enter. + 2007-08-08 Glenn Morris <rgm@gnu.org> * erc-log.el, erc.el: Replace `iff' in doc-strings and comments. +2007-09-03 Michael Olson <mwolson@gnu.org> + + * erc.el (erc-default-port): Make this an integer value rather + than a string. Thanks to Luca Capello for the report. + +2007-08-27 Michael Olson <mwolson@gnu.org> + + * erc.el (erc-cmd-GQUIT): If erc-kill-queries-on-quit is non-nil, + kill all query buffers after 4 seconds. + +2007-08-16 Michael Olson <mwolson@gnu.org> + + * NEWS: Add ERC 5.3 changes section, and mention jbms' erc-track + compatibility note. + + * erc-track.el (erc-track-list-changed-hook): Turn this into a + customizable option. + (erc-track-switch-direction): Add 'importance option. + (erc-modified-channels-display): If erc-track-switch-direction is + 'importance, call erc-track-sort-by-importance. + (erc-track-face-priority): New function that returns a number + indicating the position of a face in erc-track-faces-priority-list. + (erc-track-sort-by-importance): New function that sorts + erc-modified-channels-list according to erc-track-face-priority. + (erc-track-get-active-buffer): Make 'oldest a rough opposite of + 'importance. + +2007-08-14 Jeremy Maitin-Shepard <jbms@cmu.edu> + + * erc-track.el (erc-track-remove-disconnected-buffers): New + variable which controls whether buffers associated with a server + that is disconnected should be removed from + `erc-modified-channels-alist'. Existing behavior is to + unconditionally remove such buffers, which is achieved by setting + `erc-track-removed-disconnected-buffers' to t. When set to t, + which is the new default value, such buffers remain in the list, + which I think is often the desired behavior, since the user may + likely wish to find out about activity that occurred in a channel + prior to it being disconnected. + (erc-track-list-changed-hook): New hook that is run whenever the + contents of `erc-modified-channels-alist' changes; it is useful + for users such as myself that don't use the default mode-line + notification but instead use a separate mechanism (which is tied + to my window manager) to provide notification of channel activity. + (erc-track-get-buffer-window): New function that acts as a wrapper + around `get-buffer-window' that handles the `selected-visible' + option of `erc-track-visibility'; previously, the value of + `erc-track-visibility' was passed directly to `get-buffer-window', + which does not support `selected-visible'; consequently, + `selected-visible' was not properly supported. + (erc-track-modified-channels): Fix a bug in the logic for removing + buffers from the list in certain cases. + (erc-track-position-in-mode-line): Add a supported value that + specifies that the tracking information should not be added to the + mode line at all. The value of nil is used to indicate that the + information should not be added at all to the mode line. + (erc-track-add-to-mode-line): Check for position eq to t, rather + than non-nil. + (erc-buffer-visible): Use erc-track-get-buffer-window. + (erc-modified-channels-update): Take + erc-track-remove-disconnected-buffers into account. + (erc-modified-channels-display): Run `erc-track-list-changed-hook'. + + * erc.el (erc-reuse-frames): New option that determines whether + new frames are always created. Defaults to t. This only has an + effect when erc-join-buffer is set to 'frame. + (erc-setup-buffer): Use it. + +2007-08-14 Michael Olson <mwolson@gnu.org> + + * erc-backend.el (erc-server-reconnect): If the server buffer has + been killed, use the current buffer instead. If the current + buffer is not an ERC buffer, give an error. This fixes a bug when + /reconnect is run from a channel buffer whose server buffer has + been deleted. Thanks to jbms for the report. + (erc-process-sentinel-1): Take server buffer as an argument, so + that we can make sure that it is current. + (erc-process-sentinel): Pass buffer to erc-process-sentinel-1. + (erc-process-sentinel-2): New function split from + erc-process-sentinel-1. If server buffer is deleted during a + reconnect attempt, stop trying to reconnect. Fix bug where + reconnect was not happening when erc-server-reconnect-attempts was + t. Call erc-server-reconnect-p only once each time. If we are + instructed to try connecting indefinitely, tell the user that they + can stop this by killing the server buffer. Call the process + sentinel by means of run-at-time, so that there is time to kill + the buffer if need be; this also removes the need for a while + loop. Refuse to reconnect again if erc-server-reconnect-timeout + is not an number. + + * erc.el (erc-command-no-process-p): Fix bug: the return value of + erc-extract-command-from-line is a list rather than a single + symbol. Thanks to jbms for the report. + (erc-cmd-RECONNECT): Use simpler logic, and use buffer-live-p + rather than bufferp. + (erc-send-current-line, erc-display-command, erc-display-msg): + Handle case where erc-server-process is nil, so that /reconnect + works. + +2007-08-12 Michael Olson <mwolson@gnu.org> + + * erc-identd.el (erc-identd-filter): Instead of sending an EOF + character, which now confuses freenode, stop the server process, + so that no new connections are accepted, and kill the current + client process. + 2007-07-30 Michael Olson <mwolson@gnu.org> * erc-nicklist.el: Remove from the Emacs source tree. This file is not release quality, and relies heavily on a module which cannot be distributed with ERC due to licensing reasons. +2007-07-29 Michael Olson <mwolson@gnu.org> + + * erc-list.el: Relicense to GPLv3. Since the file was already + licensed under version 2 or later, it turns out that we do not + need the permission of all of the authors in order to proceed. + 2007-07-25 Glenn Morris <rgm@gnu.org> * Relicense all FSF files to GPLv3 or later. -2007-06-07 Juanma Barranquero <lekktu@gmail.com> +2007-07-13 Michael Olson <mwolson@gnu.org> + + * erc-goodies.el (erc-get-bg-color-face, erc-get-fg-color-face): + Use erc-error rather than message and beep. + + * erc-sound.el: Indentation fix. + + * erc.el (erc-command-no-process-p): New function that determines + if its argument is an ERC command that can be run when the server + process is not alive. + (erc-cmd-SET, erc-cmd-CLEAR, erc-cmd-COUNTRY, erc-cmd-HELP) + (erc-cmd-LASTLOG, erc-cmd-QUIT, erc-cmd-GQUIT) + (erc-cmd-RECONNECT, erc-cmd-SERVER): Denote that these commands + can be run even when the server process is not alive. + (erc-send-current-line): Call erc-command-no-process-p if the + server process is not alive, to determine if we have a command + that can be run anyway. Thanks to Tom Tromey for the bug report. + (erc-error): New function that either displays a message or throws + an error, depending on whether debug-on-error is non-nil. + (erc-cmd-SERVER, erc-send-current-line): Use it. + +2007-07-10 Michael Olson <mwolson@gnu.org> + + * Relicense all FSF-assigned code to GPLv3. + +2007-06-25 Michael Olson <mwolson@gnu.org> + + * erc.texi (Options): Fix typo. + (Getting Help and Reporting Bugs): Update webpage URL. Make Gmane + part more readable. + +2007-06-20 Michael Olson <mwolson@gnu.org> + + * erc-stamp.el (erc-timestamp-format-left): New option that + specifies the left timestamp to use for + erc-insert-timestamp-left-and-right. + (erc-timestamp-format-right): New option that specifies the right + timestamp to use for erc-insert-timestamp-left-and-right. + (erc-insert-timestamp-function): Change default to + erc-insert-timestamp-left-and-right. + (erc-insert-away-timestamp-function): Ditto. + (erc-timestamp-last-inserted-left) + (erc-timestamp-last-inserted-right): New variables to keep track + of data for erc-insert-timestamp-left-and-right. + (erc-insert-timestamp-left-and-right): New function that places + timestamps on both the left and right sides of the screen, but + only if each timestamp has changed since it was last computed. + Thanks to offby1 for urging me to merge this. + + * erc.el (erc-open-ssl-stream): Display informative error when + ssl.el not found. + (erc-tls): New function to connect using tls.el. + (erc-open-tls-stream): New function to initiate tls connection. + Display informative error when tls.el not found. + +2007-06-19 Michael Olson <mwolson@gnu.org> + + * erc-log.el: Update header with accurate instructions. + +2007-06-17 Michael Olson <mwolson@gnu.org> + + * erc-pkg.el: Update description to match what is currently in ELPA. + +2007-06-14 Juanma Barranquero <lekktu@gmail.com> + + * erc-goodies.el (erc-scroll-to-bottom): Remove redundant check. + +2007-06-13 Michael Olson <mwolson@gnu.org> + + * erc-compat.el (erc-with-selected-window): New compatibility + macro that implements `with-selected-window'. - * erc.el (erc-startup-file-list): Fix typo in docstring. + * erc-goodies.el (erc-scroll-to-bottom): Use it. This fixes a bug + with buffer ordering where ERC buffers would move to the top. + Thanks to Ivan Kanis for the patch. + +2007-06-10 Michael Olson <mwolson@gnu.org> + + * erc-log.el (erc-logging-enabled): Fix a bug that occurred when + `erc-log-channels-directory' had the name of a function. 2007-06-06 Juanma Barranquero <lekktu@gmail.com> - * erc.el (erc-show-channel-key-p): Fix typo in docstring. + * erc.el (erc-show-channel-key-p, erc-startup-file-list): + Fix typo in docstring. + +2007-06-03 Michael Olson <mwolson@gnu.org> + + * erc-compat.el (erc-view-mode-enter): Make this its own function, + in order to document what we do, and provide sane fallback + behavior. + + * erc.el (erc-toggle-debug-irc-protocol): Don't pass any arguments + to erc-view-mode-enter, since we don't do anything special with + the exit function. This fixes a bug with Emacs 21 and Emacs 22. + Thanks to Leo for noticing. + +2007-05-30 Michael Olson <mwolson@gnu.org> + + * erc-compat.el (erc-user-emacs-directory): New variable that + determines where to find user-specific Emacs settings. For Emacs, + this is usually ~/.emacs.d, and for XEmacs this is usually + ~/.xemacs. + + * erc.el (erc-startup-file-list): Use erc-user-emacs-directory. + +2007-05-28 Michael Olson <mwolson@gnu.org> + + * erc-button.el (erc-button-url-regexp): Recognize parentheses as + part of URLs. Thanks to Lawrence Mitchell for the fix. + +2007-05-26 Michael Olson <mwolson@gnu.org> + + * erc.texi (Modules): Fix references to completion modules. + +2007-05-21 Michael Olson <mwolson@gnu.org> + + * Makefile (SOURCE): Remove erc-pkg.el. + (debclean): New rule to clean old Debian packages of ERC. + (debprepare): Don't modify the released tarball, but copy it as + the .orig.tar.gz file. + (debrelease, debrevision): Remove. + (debinstall): New target that copies the generated Debian file to + a distro-specific location. + (deb): New rule that chains together the stages in building a + Debian package. + (EXTRAS): Add erc-nicklist.el, since it is not release-quality. + (extras): Copy images directory. + + * erc-nicklist.el (erc-nicklist-icons-directory): Use + locate-library to find the "images" directory. This should be + more failsafe. Thanks to Tom Tromey for the idea. + +2007-05-19 Michael Olson <mwolson@gnu.org> + + * Makefile (ELPA): New variable that contains the location of my + local ELPA repository. + (elpa): New rule that makes an ELPA package for ERC. + +2007-04-19 Michael Olson <mwolson@gnu.org> + + * erc.el (erc-parse-prefix): New function that retrieves the + PREFIX server parameter from the current server and returns an + alist of prefix type to prefix character. + (erc-channel-receive-names): Use `erc-parse-prefix' to determine + whether the first character of a nick is a prefix character or + not. This should fix a bug reported by bromine about needing to + type "%" first to complete nicks of people who are "hops" on + Slashnet. This should also support for very exotic IRC server + setups, if any exist. + (erc-update-current-channel-member): Indentation. + +2007-04-15 Michael Olson <mwolson@gnu.org> + + * erc-log.el (erc-generate-log-file-name-function): Docfix. + Mention how to deal with the case for putting log files in + different directories. Change a customization type from `symbol' + to `function'. + (erc-log-channels-directory): Allow this to contain a function + name, which is called with the same args as in + `erc-generate-log-file-name-function'. Thanks to andrewy for the + report and use case. + (erc-current-logfile): Detect if `erc-log-channels-directory' is a + function and call it with arguments if so. + +2007-04-12 Michael Olson <mwolson@gnu.org> + + * erc-backend.el (define-erc-response-handler): Mention that hook + processing stops when the function returns non-nil. This should + help avoid a nasty "gotcha" when making custom functions. Thanks + to John Sullivan for the report. + +2007-04-08 Diane Murray <disumu@x3y2z1.net> + + * erc-nicklist.el (erc-nicklist-voiced-position): Fixed + customization mismatch. 2007-04-01 Michael Olson <mwolson@gnu.org> @@ -55,6 +492,10 @@ tarball. (upload-extras): New rule to upload the extras tarball. It's yucky to replicate upload, but oh well. + (DISTRIBUTOR): New variable used to differentiate between building + packages for Ubuntu and Debian. + (debrelease, debrevision): Use it. + (debbuild): Run linda in addition to lintian. * NEWS: Mention extras tarball. Note which files have been renamed. Note that erc-list is enabled by default, except in diff --git a/lisp/erc/erc-autoaway.el b/lisp/erc/erc-autoaway.el index cbfdd0786aa..d777b4e4cb8 100644 --- a/lisp/erc/erc-autoaway.el +++ b/lisp/erc/erc-autoaway.el @@ -248,7 +248,8 @@ exceeds `erc-autoaway-idle-seconds'." ;; A test for (erc-server-process-alive) is not necessary, because ;; this function is called from `erc-timer-hook', which is called ;; whenever the server sends something to the client. - (when (and erc-auto-set-away + (when (and erc-server-connected + erc-auto-set-away (not erc-autoaway-caused-away) (erc-autoaway-some-open-server-buffer)) (let ((idle-time (erc-time-diff erc-autoaway-last-sent-time diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index eff0157c2ff..0fead116d8f 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -461,27 +461,6 @@ Currently this is called by `erc-send-input'." (upcase-word 1) (buffer-string))) -(defun erc-server-send-ping (buf) - "Send a ping to the IRC server buffer in BUF. -Additionally, detect whether the IRC process has hung." - (if (buffer-live-p buf) - (with-current-buffer buf - (if (and erc-server-send-ping-timeout - (> - (erc-time-diff (erc-current-time) - erc-server-last-received-time) - erc-server-send-ping-timeout)) - (progn - ;; if the process is hung, kill it - (setq erc-server-timed-out t) - (delete-process erc-server-process)) - (erc-server-send (format "PING %.0f" (erc-current-time))))) - ;; remove timer if the server buffer has been killed - (let ((timer (assq buf erc-server-ping-timer-alist))) - (when timer - (erc-cancel-timer (cdr timer)) - (setcdr timer nil))))) - (defun erc-server-setup-periodical-ping (buffer) "Set up a timer to periodically ping the current server. The current buffer is given by BUFFER." @@ -536,7 +515,7 @@ We will store server variables in the buffer given by BUFFER." (set-process-filter process 'erc-server-filter-function) (set-process-buffer process buffer))) (erc-log "\n\n\n********************************************\n") - (message (erc-format-message + (message "%s" (erc-format-message 'login ?n (with-current-buffer buffer (erc-current-nick)))) ;; wait with script loading until we receive a confirmation (first @@ -550,11 +529,12 @@ We will store server variables in the buffer given by BUFFER." (defun erc-server-reconnect () "Reestablish the current IRC connection. Make sure you are in an ERC buffer when running this." - (let ((server (erc-server-buffer))) - (unless (and server - (buffer-live-p server)) - (error "Couldn't switch to server buffer")) - (with-current-buffer server + (let ((buffer (erc-server-buffer))) + (unless (buffer-live-p buffer) + (if (eq major-mode 'erc-mode) + (setq buffer (current-buffer)) + (error "Reconnect must be run from an ERC buffer"))) + (with-current-buffer buffer (erc-update-mode-line) (erc-set-active-buffer (current-buffer)) (setq erc-server-last-sent-time 0) @@ -609,39 +589,61 @@ EVENT is the message received from the closed connection process." ;; open-network-stream-nowait error for connection refused (not (string-match "^failed with code 111" event))))) -(defun erc-process-sentinel-1 (event) +(defun erc-process-sentinel-2 (event buffer) + "Called when `erc-process-sentinel-1' has detected an unexpected disconnect." + (if (not (buffer-live-p buffer)) + (erc-update-mode-line) + (with-current-buffer buffer + (let ((reconnect-p (erc-server-reconnect-p event))) + (erc-display-message nil 'error (current-buffer) + (if reconnect-p 'disconnected + 'disconnected-noreconnect)) + (if (not reconnect-p) + ;; terminate, do not reconnect + (progn + (erc-display-message nil 'error (current-buffer) + 'terminated ?e event) + ;; Update mode line indicators + (erc-update-mode-line) + (set-buffer-modified-p nil)) + ;; reconnect + (condition-case err + (progn + (setq erc-server-reconnecting nil) + (erc-server-reconnect) + (setq erc-server-reconnect-count 0)) + (error (when (buffer-live-p buffer) + (set-buffer buffer) + (if (integerp erc-server-reconnect-attempts) + (setq erc-server-reconnect-count + (1+ erc-server-reconnect-count)) + (message "%s ... %s" + "Reconnecting until we succeed" + "kill the ERC server buffer to stop")) + (if (numberp erc-server-reconnect-timeout) + (run-at-time erc-server-reconnect-timeout nil + #'erc-process-sentinel-2 + event buffer) + (error (concat "`erc-server-reconnect-timeout`" + " must be a number"))))))))))) + +(defun erc-process-sentinel-1 (event buffer) "Called when `erc-process-sentinel' has decided that we're disconnecting. Determine whether user has quit or whether erc has been terminated. Conditionally try to reconnect and take appropriate action." - (if erc-server-quitting - ;; normal quit - (progn - (erc-display-message nil 'error (current-buffer) 'finished) - (when erc-kill-server-buffer-on-quit + (with-current-buffer buffer + (if erc-server-quitting + ;; normal quit + (progn + (erc-display-message nil 'error (current-buffer) 'finished) + ;; Update mode line indicators + (erc-update-mode-line) + ;; Kill server buffer if user wants it (set-buffer-modified-p nil) - (kill-buffer (current-buffer)))) - ;; unexpected disconnect - (let ((again t)) - (while again - (setq again nil) - (erc-display-message nil 'error (current-buffer) - (if (erc-server-reconnect-p event) - 'disconnected - 'disconnected-noreconnect)) - (if (erc-server-reconnect-p event) - (condition-case err - (progn - (setq erc-server-reconnecting nil) - (erc-server-reconnect) - (setq erc-server-reconnect-count 0)) - (error (when (integerp erc-server-reconnect-attempts) - (setq erc-server-reconnect-count - (1+ erc-server-reconnect-count)) - (sit-for erc-server-reconnect-timeout) - (setq again t)))) - ;; terminate, do not reconnect - (erc-display-message nil 'error (current-buffer) - 'terminated ?e event)))))) + (when erc-kill-server-buffer-on-quit + (kill-buffer (current-buffer)))) + ;; unexpected disconnect + (erc-process-sentinel-2 event buffer)))) (defun erc-process-sentinel (cproc event) "Sentinel function for ERC process." @@ -668,12 +670,7 @@ Conditionally try to reconnect and take appropriate action." (delete-region (point) (point-max)) ;; Decide what to do with the buffer ;; Restart if disconnected - (erc-process-sentinel-1 event) - ;; Make sure we don't write to the buffer if it has been - ;; killed - (when (buffer-live-p buf) - (erc-update-mode-line) - (set-buffer-modified-p nil)))))) + (erc-process-sentinel-1 event buf))))) ;;;; Sending messages @@ -757,6 +754,27 @@ protection algorithm." (message "ERC: No process running") nil))) +(defun erc-server-send-ping (buf) + "Send a ping to the IRC server buffer in BUF. +Additionally, detect whether the IRC process has hung." + (if (buffer-live-p buf) + (with-current-buffer buf + (if (and erc-server-send-ping-timeout + (> + (erc-time-diff (erc-current-time) + erc-server-last-received-time) + erc-server-send-ping-timeout)) + (progn + ;; if the process is hung, kill it + (setq erc-server-timed-out t) + (delete-process erc-server-process)) + (erc-server-send (format "PING %.0f" (erc-current-time))))) + ;; remove timer if the server buffer has been killed + (let ((timer (assq buf erc-server-ping-timer-alist))) + (when timer + (erc-cancel-timer (cdr timer)) + (setcdr timer nil))))) + ;; From Circe (defun erc-server-send-queue (buffer) "Send messages in `erc-server-flood-queue'. @@ -1054,8 +1072,11 @@ Would expand to: \"Some non-generic variable documentation. Hook called upon receiving a WHOIS server response. + Each function is called with two arguments, the process associated - with the response and the parsed response. + with the response and the parsed response. If the function returns + non-nil, stop processing the hook. Otherwise, continue. + See also `erc-server-311'.\") (defalias 'erc-server-WI 'erc-server-311) @@ -1064,7 +1085,9 @@ Would expand to: Hook called upon receiving a WI server response. Each function is called with two arguments, the process associated - with the response and the parsed response. + with the response and the parsed response. If the function returns + non-nil, stop processing the hook. Otherwise, continue. + See also `erc-server-311'.\")) \(fn (NAME &rest ALIASES) &optional EXTRA-FN-DOC EXTRA-VAR-DOC &rest FN-BODY)" @@ -1078,7 +1101,9 @@ Would expand to: (fn-name (intern (format "erc-server-%s" name))) (hook-doc (format "%sHook called upon receiving a %%s server response. Each function is called with two arguments, the process associated -with the response and the parsed response. +with the response and the parsed response. If the function returns +non-nil, stop processing the hook. Otherwise, continue. + See also `%s'." (if extra-var-doc (concat extra-var-doc "\n\n") @@ -1513,6 +1538,16 @@ A server may send more than one 005 message." See `erc-display-server-message'." nil (erc-display-server-message proc parsed)) +(define-erc-response-handler (275) + "Display secure connection message." nil + (multiple-value-bind (nick user message) + (cdr (erc-response.command-args parsed)) + (erc-display-message + parsed 'notice 'active 's275 + ?n nick + ?m (mapconcat 'identity (cddr (erc-response.command-args parsed)) + " ")))) + (define-erc-response-handler (290) "Handle dancer-ircd CAPAB messages." nil nil) @@ -1539,6 +1574,16 @@ See `erc-display-server-message'." nil (erc-display-message parsed 'notice 'active 's306 ?m (erc-response.contents parsed))) +(define-erc-response-handler (307) + "Display nick-identified message." nil + (multiple-value-bind (nick user message) + (cdr (erc-response.command-args parsed)) + (erc-display-message + parsed 'notice 'active 's307 + ?n nick + ?m (mapconcat 'identity (cddr (erc-response.command-args parsed)) + " ")))) + (define-erc-response-handler (311 314) "WHOIS/WHOWAS notices." nil (let ((fname (erc-response.contents parsed)) diff --git a/lisp/erc/erc-button.el b/lisp/erc/erc-button.el index 426139cd80e..a74d56b90bd 100644 --- a/lisp/erc/erc-button.el +++ b/lisp/erc/erc-button.el @@ -99,7 +99,7 @@ above them." (concat "\\(www\\.\\|\\(s?https?\\|" "ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\)" "\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?" - "[-a-zA-Z0-9_=!?#$@~`%&*+\\/:;.,]+[-a-zA-Z0-9_=#$@~`%&*+\\/]") + "[-a-zA-Z0-9_=!?#$@~`%&*+\\/:;.,()]+[-a-zA-Z0-9_=#$@~`%&*+\\/()]") "Regular expression that matches URLs." :group 'erc-button :type 'regexp) diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index 66ab51e8f48..d99d8fca7da 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -50,12 +50,27 @@ See `erc-encoding-coding-alist'." (defalias 'erc-delete-dups 'delete-dups) (defalias 'erc-replace-regexp-in-string 'replace-regexp-in-string) +(defun erc-set-write-file-functions (new-val) + (set (make-local-variable 'write-file-functions) new-val)) + (defvar erc-emacs-build-time (if (stringp emacs-build-time) emacs-build-time (format-time-string "%Y-%m-%d" emacs-build-time)) "Time at which Emacs was dumped out.") +;; Emacs 21 and XEmacs do not have user-emacs-directory, but XEmacs +;; has user-init-directory. +(defvar erc-user-emacs-directory + (cond ((boundp 'user-emacs-directory) + user-emacs-directory) + ((boundp 'user-init-directory) + user-init-directory) + (t "~/.emacs.d/")) + "Directory beneath which additional per-user Emacs-specific files +are placed. +Note that this should end with a directory separator.") + ;; XEmacs' `replace-match' does not replace matching subexpressions in strings. (defun erc-replace-match-subexpression-in-string (newtext string match subexp start &optional fixedcase literal) @@ -68,6 +83,7 @@ See `replace-match' for explanations of FIXEDCASE and LITERAL." (replace-match newtext fixedcase literal string)) (t (replace-match newtext fixedcase literal string subexp)))) +(defalias 'erc-with-selected-window 'with-selected-window) (defalias 'erc-cancel-timer 'cancel-timer) (defalias 'erc-make-obsolete 'make-obsolete) (defalias 'erc-make-obsolete-variable 'make-obsolete-variable) diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index dc443b9b615..9612b001156 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -77,15 +77,14 @@ You can control which line is recentered to by customizing the variable `erc-input-line-position'. DISPLAY-START is ignored." - (if (and window (window-live-p window)) + (if (window-live-p window) ;; Temporarily bind resize-mini-windows to nil so that users who have it ;; set to a non-nil value will not suffer from premature minibuffer ;; shrinkage due to the below recenter call. I have no idea why this ;; works, but it solves the problem, and has no negative side effects. ;; (Fran Litterio, 2003/01/07) (let ((resize-mini-windows nil)) - (save-selected-window - (select-window window) + (erc-with-selected-window window (save-restriction (widen) (when (and erc-insert-marker @@ -282,10 +281,8 @@ The value `erc-interpret-controls-p' must also be t for this to work." "Fetches the right face for background color N (0-15)." (if (stringp n) (setq n (string-to-number n))) (if (not (numberp n)) - (progn - (message "erc-get-bg-color-face: n is NaN: %S" n) - (beep) - 'default) + (prog1 'default + (erc-error "erc-get-bg-color-face: n is NaN: %S" n)) (when (> n 16) (erc-log (format " Wrong color: %s" n)) (setq n (mod n 16))) @@ -298,10 +295,8 @@ The value `erc-interpret-controls-p' must also be t for this to work." "Fetches the right face for foreground color N (0-15)." (if (stringp n) (setq n (string-to-number n))) (if (not (numberp n)) - (progn - (message "erc-get-fg-color-face: n is NaN: %S" n) - (beep) - 'default) + (prog1 'default + (erc-error "erc-get-fg-color-face: n is NaN: %S" n)) (when (> n 16) (erc-log (format " Wrong color: %s" n)) (setq n (mod n 16))) diff --git a/lisp/erc/erc-ibuffer.el b/lisp/erc/erc-ibuffer.el index 3e659ee216d..14ac36540a9 100644 --- a/lisp/erc/erc-ibuffer.el +++ b/lisp/erc/erc-ibuffer.el @@ -71,6 +71,10 @@ (string-match qualifier (or erc-server-announced-name erc-session-server))))) +;; Silence the byte-compiler +(eval-when-compile + (defvar erc-modified-channels-alist)) + (define-ibuffer-column erc-modified (:name "M") (if (and (boundp 'erc-track-mode) erc-track-mode) @@ -154,8 +158,8 @@ (format "l %d" erc-channel-user-limit) "") ")") - (if (not (eq major-mode 'erc-mode)) - mode-name + (if (not (derived-mode-p 'erc-mode)) + (format-mode-line mode-name nil nil (current-buffer)) ""))) (define-ibuffer-column erc-nick (:name "Nick") diff --git a/lisp/erc/erc-identd.el b/lisp/erc/erc-identd.el index 24f450388dd..d8d8a80b875 100644 --- a/lisp/erc/erc-identd.el +++ b/lisp/erc/erc-identd.el @@ -74,7 +74,8 @@ This can be either a string or a number." (format "%s, %s : USERID : %s : %s\n" port-on-server port-on-client system-type (user-login-name))) - (process-send-eof erc-identd-process))))) + (stop-process erc-identd-process) + (delete-process proc))))) ;;;###autoload (defun erc-identd-start (&optional port) diff --git a/lisp/erc/erc-lang.el b/lisp/erc/erc-lang.el index 67f0960cb51..e3858eb1153 100644 --- a/lisp/erc/erc-lang.el +++ b/lisp/erc/erc-lang.el @@ -197,7 +197,7 @@ Normungsinstitut (ON), Postfach 130, A-1021 Vienna, Austria.") "Return the language name for the ISO CODE." (interactive (list (completing-read "ISO language code: " iso-638-languages))) - (message (cdr (assoc code iso-638-languages)))) + (message "%s" (cdr (assoc code iso-638-languages)))) (defun erc-cmd-LANG (language) "Display the language name for the language code given by LANGUAGE." diff --git a/lisp/erc/erc-log.el b/lisp/erc/erc-log.el index dbbaebdf796..c48b5d9529a 100644 --- a/lisp/erc/erc-log.el +++ b/lisp/erc/erc-log.el @@ -31,17 +31,26 @@ ;; Quick start: ;; -;; (setq erc-enable-logging t) +;; (require 'erc-log) ;; (setq erc-log-channels-directory "/path/to/logfiles") ; must be writable +;; (erc-log-enable) ;; -;; There are two ways to setup logging. The first will write to the log files -;; on each incoming or outgoing line - this may not be optimal on a laptop -;; HDD. To do this, M-x customize-variable erc-modules, and add "log". +;; Or: ;; -;; The second method will save buffers on /part, /quit, or killing the -;; channel buffer. To do this, add the following to your .emacs: +;; M-x customize-variable erc-modules, and add "log". ;; -;; (require 'erc-log) +;; There are two ways to setup logging. The first (default) method +;; will save buffers on /part, /quit, or killing the channel +;; buffer. +;; +;; The second will write to the log files on each incoming or outgoing +;; line - this may not be optimal on a laptop HDD. To use this +;; method, add the following to the above instructions. +;; +;; (setq erc-save-buffer-on-part nil +;; erc-save-queries-on-quit nil +;; erc-log-write-after-send t +;; erc-log-write-after-insert t) ;; ;; If you only want to save logs for some buffers, customise the ;; variable `erc-enable-logging'. @@ -99,15 +108,19 @@ The function must take five arguments: BUFFER, TARGET, NICK, SERVER and PORT. BUFFER is the buffer to be saved, TARGET is the name of the channel, or the target of the query, NICK is the current nick, -SERVER and PORT are the parameters used to connect BUFFERs -`erc-server-process'." +SERVER and PORT are the parameters that were used to connect to BUFFERs +`erc-server-process'. + +If you want to write logs into different directories, make a +custom function which returns the directory part and set +`erc-log-channels-directory' to its name." :group 'erc-log :type '(choice (const :tag "Long style" erc-generate-log-file-name-long) (const :tag "Long, but with network name rather than server" erc-generate-log-file-name-network) (const :tag "Short" erc-generate-log-file-name-short) (const :tag "With date" erc-generate-log-file-name-with-date) - (symbol :tag "Other function"))) + (function :tag "Other function"))) (defcustom erc-truncate-buffer-on-save nil "Truncate any ERC (channel, query, server) buffer when it is saved." @@ -134,10 +147,16 @@ Log files are stored in `erc-log-channels-directory'." "The directory to place log files for channels. Leave blank to disable logging. If not nil, all the channel buffers are logged in separate files in that directory. The -directory should not end with a trailing slash." +directory should not end with a trailing slash. + +If this is the name of a function, the function will be called +with the buffer, target, nick, server, and port arguments. See +`erc-generate-log-file-name-function' for a description of these +arguments." :group 'erc-log :type '(choice directory - (const nil))) + (function "Function") + (const :tag "Disable logging" nil))) (defcustom erc-log-insert-log-on-open nil "*Insert log file contents into the buffer if a log file exists." @@ -186,6 +205,16 @@ This should ideally, be a \"catch-all\" coding system, like `emacs-mule', or `iso-2022-7bit'." :group 'erc-log) +(defcustom erc-log-filter-function nil + "*If non-nil, pass text through the given function before writing it to +a log file. + +The function should take one argument, which is the text to filter." + :group 'erc-log + :type '(choice (function "Function") + (const :tag "No filtering" nil))) + + ;;;###autoload (autoload 'erc-log-mode "erc-log" nil t) (define-erc-module log nil "Automatically logs things you receive on IRC into files. @@ -196,7 +225,7 @@ format is defined through a formatting function on Since automatic logging is not always a Good Thing (especially if people say things in different coding systems), you can turn logging behavior on and off with the variable `erc-enable-logging', which can -also be a predicate function. To only log when you are not set away, use: +also be a predicate function. To only log when you are not set away, use: \(setq erc-enable-logging (lambda (buffer) @@ -239,14 +268,7 @@ The current buffer is given by BUFFER." (with-current-buffer buffer (auto-save-mode -1) (setq buffer-file-name nil) - (cond ((boundp 'write-file-functions) - (set (make-local-variable 'write-file-functions) - '(erc-save-buffer-in-logs))) - ((boundp 'local-write-file-hooks) - (setq local-write-file-hooks '(erc-save-buffer-in-logs))) - (t - (set (make-local-variable 'write-file-hooks) - '(erc-save-buffer-in-logs)))) + (erc-set-write-file-functions '(erc-save-buffer-in-logs)) (when erc-log-insert-log-on-open (ignore-errors (insert-file-contents (erc-current-logfile)) (move-marker erc-last-saved-position @@ -297,7 +319,8 @@ Logging is enabled if `erc-log-channels-directory' is non-nil, the directory is writeable (it will be created as necessary) and `erc-enable-logging' returns a non-nil value." (and erc-log-channels-directory - (erc-directory-writable-p erc-log-channels-directory) + (or (functionp erc-log-channels-directory) + (erc-directory-writable-p erc-log-channels-directory)) (if (functionp erc-enable-logging) (funcall erc-enable-logging (or buffer (current-buffer))) erc-enable-logging))) @@ -316,14 +339,19 @@ filename is downcased." If BUFFER is nil, the value of `current-buffer' is used. This is determined by `erc-generate-log-file-name-function'. The result is converted to lowercase, as IRC is case-insensitive" - (expand-file-name - (erc-log-standardize-name - (funcall erc-generate-log-file-name-function - (or buffer (current-buffer)) - (or (buffer-name buffer) (erc-default-target)) - (erc-current-nick) - erc-session-server erc-session-port)) - erc-log-channels-directory)) + (unless buffer (setq buffer (current-buffer))) + (let ((target (or (buffer-name buffer) (erc-default-target))) + (nick (erc-current-nick)) + (server erc-session-server) + (port erc-session-port)) + (expand-file-name + (erc-log-standardize-name + (funcall erc-generate-log-file-name-function + buffer target nick server port)) + (if (functionp erc-log-channels-directory) + (funcall erc-log-channels-directory + buffer target nick server port) + erc-log-channels-directory)))) (defun erc-generate-log-file-name-with-date (buffer &rest ignore) "This function computes a short log file name. @@ -380,7 +408,8 @@ You can save every individual message by putting this function on (or buffer (setq buffer (current-buffer))) (when (erc-logging-enabled buffer) (let ((file (erc-current-logfile buffer)) - (coding-system-for-write erc-log-file-coding-system)) + (coding-system erc-log-file-coding-system) + (inhibit-clash-detection t)) ; needed for XEmacs (save-excursion (with-current-buffer buffer (save-restriction @@ -388,9 +417,17 @@ You can save every individual message by putting this function on ;; early on in the initialization, don't try and write the log out (when (and (markerp erc-last-saved-position) (> erc-insert-marker (1+ erc-last-saved-position))) - (write-region (1+ (marker-position erc-last-saved-position)) - (marker-position erc-insert-marker) - file t 'nomessage) + (let ((start (1+ (marker-position erc-last-saved-position))) + (end (marker-position erc-insert-marker))) + (if (functionp erc-log-filter-function) + (let ((text (buffer-substring start end))) + (with-temp-buffer + (insert (funcall erc-log-filter-function text)) + (let ((coding-system-for-write coding-system)) + (write-region (point-min) (point-max) + file t 'nomessage)))) + (let ((coding-system-for-write coding-system)) + (write-region start end file t 'nomessage)))) (if (and erc-truncate-buffer-on-save (interactive-p)) (progn (let ((inhibit-read-only t)) (erase-buffer)) diff --git a/lisp/erc/erc-match.el b/lisp/erc/erc-match.el index c0efeef3d8f..a98b1d92f4a 100644 --- a/lisp/erc/erc-match.el +++ b/lisp/erc/erc-match.el @@ -299,7 +299,7 @@ Completion is performed on the optional alist COMPLETIONS." (lambda (x) (not (erc-member-ignore-case (car x) (symbol-value list))))))) (if (erc-member-ignore-case entry (symbol-value list)) - (error (format "\"%s\" is already on the list" entry)) + (error "\"%s\" is already on the list" entry) (set list (cons entry (symbol-value list)))))) (defun erc-remove-entry-from-list (list prompt) diff --git a/lisp/erc/erc-netsplit.el b/lisp/erc/erc-netsplit.el index 48970fb76c7..5bcb4327c18 100644 --- a/lisp/erc/erc-netsplit.el +++ b/lisp/erc/erc-netsplit.el @@ -173,13 +173,14 @@ join from that split has been detected or not.") (defun erc-netsplit-timer (now) "Clean cruft from `erc-netsplit-list' older than 10 minutes." - (dolist (elt erc-netsplit-list) - (when (> (erc-time-diff (cadr elt) now) 600) - (when erc-netsplit-debug - (erc-display-message - nil 'notice (current-buffer) - (concat "Netsplit: Removing " (car elt)))) - (setq erc-netsplit-list (delq elt erc-netsplit-list))))) + (when erc-server-connected + (dolist (elt erc-netsplit-list) + (when (> (erc-time-diff (cadr elt) now) 600) + (when erc-netsplit-debug + (erc-display-message + nil 'notice (current-buffer) + (concat "Netsplit: Removing " (car elt)))) + (setq erc-netsplit-list (delq elt erc-netsplit-list)))))) ;;;###autoload (defun erc-cmd-WHOLEFT () diff --git a/lisp/erc/erc-notify.el b/lisp/erc/erc-notify.el index 96d49df4799..7f777309f66 100644 --- a/lisp/erc/erc-notify.el +++ b/lisp/erc/erc-notify.el @@ -111,7 +111,8 @@ changes." ;;;; Timer handler (defun erc-notify-timer (now) - (when (and erc-notify-list + (when (and erc-server-connected + erc-notify-list (> (erc-time-diff erc-last-ison-time now) erc-notify-interval)) diff --git a/lisp/erc/erc-services.el b/lisp/erc/erc-services.el index 18bcb6f2a09..ac57de9cd15 100644 --- a/lisp/erc/erc-services.el +++ b/lisp/erc/erc-services.el @@ -29,9 +29,10 @@ ;; are made to test if NickServ is the real NickServ for a given network or ;; server. -;; As a default, ERC has the data for the official nickname services on the -;; networks Austnet, BrasNET, Dalnet, freenode, GalaxyNet, and Slashnet. -;; You can add more by using M-x customize-variable RET erc-nickserv-alist. +;; As a default, ERC has the data for the official nickname services on +;; the networks Austnet, BrasNET, Dalnet, freenode, GalaxyNet, GRnet, +;; and Slashnet. You can add more by using M-x customize-variable RET +;; erc-nickserv-alist. ;; Usage: ;; @@ -109,7 +110,9 @@ You can also use M-x erc-nickserv-identify-mode to change modes." (remove-hook 'erc-after-connect 'erc-nickserv-identify-on-connect) (remove-hook 'erc-nick-changed-functions - 'erc-nickserv-identify-on-nick-change))) + 'erc-nickserv-identify-on-nick-change) + (remove-hook 'erc-server-NOTICE-functions + 'erc-nickserv-identification-autodetect))) ;;;###autoload (defun erc-nickserv-identify-mode (mode) @@ -118,6 +121,8 @@ You can also use M-x erc-nickserv-identify-mode to change modes." (list (intern (completing-read "Choose Nickserv identify mode (RET to disable): " '(("autodetect") ("nick-change") ("both")) nil t)))) + (add-hook 'erc-server-NOTICE-functions + 'erc-nickserv-identification-autodetect) (cond ((eq mode 'autodetect) (setq erc-nickserv-identify-mode 'autodetect) (add-hook 'erc-server-NOTICE-functions @@ -149,7 +154,9 @@ You can also use M-x erc-nickserv-identify-mode to change modes." (remove-hook 'erc-after-connect 'erc-nickserv-identify-on-connect) (remove-hook 'erc-nick-changed-functions - 'erc-nickserv-identify-on-nick-change)))) + 'erc-nickserv-identify-on-nick-change) + (remove-hook 'erc-server-NOTICE-functions + 'erc-nickserv-identification-autodetect)))) (defcustom erc-prompt-for-nickserv-password t "Ask for the password when identifying to NickServ." @@ -176,6 +183,7 @@ Example of use: (const DALnet) (const freenode) (const GalaxyNet) + (const GRnet) (const iip) (const OFTC) (const QuakeNet) @@ -192,63 +200,70 @@ Example of use: '((Ars nil nil "Census" - "IDENTIFY" nil nil) + "IDENTIFY" nil nil nil) (Austnet "NickOP!service@austnet.org" "/msg\\s-NickOP@austnet.org\\s-identify\\s-<password>" "nickop@austnet.org" - "identify" nil nil) + "identify" nil nil nil) (Azzurra "NickServ!service@azzurra.org" "/ns\\s-IDENTIFY\\s-password" "NickServ" - "IDENTIFY" nil nil) + "IDENTIFY" nil nil nil) (BitlBee nil nil "&bitlbee" - "identify" nil nil) + "identify" nil nil nil) (BRASnet "NickServ!services@brasnet.org" "/NickServ\\s-IDENTIFY\\s-senha" "NickServ" - "IDENTIFY" nil "") + "IDENTIFY" nil "" nil) (DALnet "NickServ!service@dal.net" "/msg\\s-NickServ@services.dal.net\\s-IDENTIFY\\s-<password>" "NickServ@services.dal.net" - "IDENTIFY" nil nil) + "IDENTIFY" nil nil nil) (freenode "NickServ!NickServ@services." "/msg\\s-NickServ\\s-IDENTIFY\\s-<password>" "NickServ" - "IDENTIFY" nil nil) + "IDENTIFY" nil nil + "Password\\s-accepted\\s--\\s-you\\s-are\\s-now\\s-recognized") (GalaxyNet "NS!nickserv@galaxynet.org" "Please\\s-change\\s-nicks\\s-or\\s-authenticate." "NS@services.galaxynet.org" - "AUTH" t nil) + "AUTH" t nil nil) + (GRnet + "NickServ!service@irc.gr" + "This\\s-nickname\\s-is\\s-registered\\s-and\\s-protected." + "NickServ" + "IDENTIFY" nil nil + "Password\\s-accepted\\s--\\s-you\\s-are\\s-now\\s-recognized.") (iip "Trent@anon.iip" "type\\s-/squery\\s-Trent\\s-identify\\s-<password>" "Trent@anon.iip" - "IDENTIFY" nil "SQUERY") + "IDENTIFY" nil "SQUERY" nil) (OFTC "NickServ!services@services.oftc.net" "type\\s-/msg\\s-NickServ\\s-IDENTIFY\\s-password." "NickServ" - "IDENTIFY" nil nil) + "IDENTIFY" nil nil nil) (QuakeNet nil nil "Q@CServe.quakenet.org" - "auth" t nil) + "auth" t nil nil) (SlashNET "NickServ!services@services.slashnet.org" "/msg\\s-NickServ\\s-IDENTIFY\\s-password" "NickServ@services.slashnet.org" - "IDENTIFY" nil nil)) + "IDENTIFY" nil nil nil)) "Alist of NickServer details, sorted by network. Every element in the list has the form - \(SYMBOL NICKSERV REGEXP NICK KEYWORD USE-CURRENT ANSWER) + \(SYMBOL NICKSERV REGEXP NICK KEYWORD USE-CURRENT ANSWER SUCCESS-REGEXP) SYMBOL is a network identifier, a symbol, as used in `erc-networks-alist'. NICKSERV is the description of the nickserv in the form nick!user@host. @@ -258,7 +273,9 @@ KEYWORD is the keyword to use in the reply message to identify yourself. USE-CURRENT indicates whether the current nickname must be used when identifying. ANSWER is the command to use for the answer. The default is 'privmsg. - This last element is optional." +SUCCESS-REGEXP is a regular expression matching the message nickserv + sends when you've successfully identified. +The last two elements are optional." :group 'erc-services :type '(repeat (list :tag "Nickserv data" @@ -292,8 +309,36 @@ ANSWER is the command to use for the answer. The default is 'privmsg. (defsubst erc-nickserv-alist-ident-command (network &optional entry) (nth 6 (or entry (assoc network erc-nickserv-alist)))) +(defsubst erc-nickserv-alist-identified-regexp (network &optional entry) + (nth 7 (or entry (assoc network erc-nickserv-alist)))) + ;; Functions: +(defcustom erc-nickserv-identified-hook nil + "Run this hook when NickServ acknowledged successful identification. +Hooks are called with arguments (NETWORK NICK)." + :group 'erc-services + :type 'hook) + +(defun erc-nickserv-identification-autodetect (proc parsed) + "Check for NickServ's successful identification notice. +Make sure it is the real NickServ for this network and that it has +specifically confirmed a successful identification attempt. +If this is the case, run `erc-nickserv-identified-hook'." + (let* ((network (erc-network)) + (sender (erc-nickserv-alist-sender network)) + (success-regex (erc-nickserv-alist-identified-regexp network)) + (sspec (erc-response.sender parsed)) + (nick (car (erc-response.command-args parsed))) + (msg (erc-response.contents parsed))) + ;; continue only if we're sure it's the real nickserv for this network + ;; and it's told us we've successfully identified + (when (and sender (equal sspec sender) + (string-match success-regex msg)) + (erc-log "NickServ IDENTIFY success notification detected") + (run-hook-with-args 'erc-nickserv-identified-hook network nick) + nil))) + (defun erc-nickserv-identify-autodetect (proc parsed) "Check for a NickServ identify request everytime a notice is received. Make sure it is the real NickServ for this network and that it has diff --git a/lisp/erc/erc-sound.el b/lisp/erc/erc-sound.el index e62034eef71..1ee8fbf8d5a 100644 --- a/lisp/erc/erc-sound.el +++ b/lisp/erc/erc-sound.el @@ -30,7 +30,7 @@ ;; Add the following to your .emacs if you want to play sounds. ;; -;; (require 'erc-soud) +;; (require 'erc-sound) ;; (erc-sound-enable) ;; ;; To send requests to other users from within query buffers, type the @@ -125,7 +125,7 @@ See also `play-sound-file'." (if (and (not filepath) erc-default-sound) (setq filepath erc-default-sound)) (cond ((and filepath (file-exists-p filepath)) - (play-sound-file filepath)) + (play-sound-file filepath)) (t (beep))) (erc-log (format "Playing sound file %S" filepath)))) @@ -142,5 +142,11 @@ See also `play-sound-file'." (provide 'erc-sound) -;; arch-tag: 53657d1d-007f-4a20-91c1-588e71cf0cee ;;; erc-sound.el ends here +;; +;; Local Variables: +;; indent-tabs-mode: t +;; tab-width: 8 +;; End: + +;; arch-tag: 53657d1d-007f-4a20-91c1-588e71cf0cee diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el index 75e512894f5..d3a05ee65b8 100644 --- a/lisp/erc/erc-stamp.el +++ b/lisp/erc/erc-stamp.el @@ -58,16 +58,48 @@ If nil, timestamping is turned off." :type '(choice (const nil) (string))) -(defcustom erc-insert-timestamp-function 'erc-insert-timestamp-right +(defcustom erc-timestamp-format-left "\n[%a %b %e %Y]\n" + "*If set to a string, messages will be timestamped. +This string is processed using `format-time-string'. +Good examples are \"%T\" and \"%H:%M\". + +This timestamp is used for timestamps on the left side of the +screen when `erc-insert-timestamp-function' is set to +`erc-insert-timestamp-left-and-right'. + +If nil, timestamping is turned off." + :group 'erc-stamp + :type '(choice (const nil) + (string))) + +(defcustom erc-timestamp-format-right " [%H:%M]" + "*If set to a string, messages will be timestamped. +This string is processed using `format-time-string'. +Good examples are \"%T\" and \"%H:%M\". + +This timestamp is used for timestamps on the right side of the +screen when `erc-insert-timestamp-function' is set to +`erc-insert-timestamp-left-and-right'. + +If nil, timestamping is turned off." + :group 'erc-stamp + :type '(choice (const nil) + (string))) + +(defcustom erc-insert-timestamp-function 'erc-insert-timestamp-left-and-right "*Function to use to insert timestamps. It takes a single argument STRING which is the final string which all text-properties already appended. This function only cares about inserting this string at the right position. Narrowing is in effect while it is called, so (point-min) and (point-max) determine the region to -operate on." +operate on. + +You will probably want to set +`erc-insert-away-timestamp-function' to the same value." :group 'erc-stamp - :type '(choice (const :tag "Right" erc-insert-timestamp-right) + :type '(choice (const :tag "Both sides" erc-insert-timestamp-left-and-right) + (const :tag "Right" erc-insert-timestamp-right) (const :tag "Left" erc-insert-timestamp-left) function)) @@ -82,12 +114,14 @@ If `erc-timestamp-format' is set, this will not be used." :type '(choice (const nil) (string))) -(defcustom erc-insert-away-timestamp-function 'erc-insert-timestamp-right +(defcustom erc-insert-away-timestamp-function + 'erc-insert-timestamp-left-and-right "*Function to use to insert the away timestamp. See `erc-insert-timestamp-function' for details." :group 'erc-stamp - :type '(choice (const :tag "Right" erc-insert-timestamp-right) + :type '(choice (const :tag "Both sides" erc-insert-timestamp-left-and-right) + (const :tag "Right" erc-insert-timestamp-right) (const :tag "Left" erc-insert-timestamp-left) function)) @@ -160,6 +194,18 @@ or `erc-send-modify-hook'." "Last timestamp inserted into the buffer.") (make-variable-buffer-local 'erc-timestamp-last-inserted) +(defvar erc-timestamp-last-inserted-left nil + "Last timestamp inserted into the left side of the buffer. +This is used when `erc-insert-timestamp-function' is set to +`erc-timestamp-left-and-right'") +(make-variable-buffer-local 'erc-timestamp-last-inserted-left) + +(defvar erc-timestamp-last-inserted-right nil + "Last timestamp inserted into the right side of the buffer. +This is used when `erc-insert-timestamp-function' is set to +`erc-timestamp-left-and-right'") +(make-variable-buffer-local 'erc-timestamp-last-inserted-right) + (defcustom erc-timestamp-only-if-changed-flag t "*Insert timestamp only if its value changed since last insertion. If `erc-insert-timestamp-function' is `erc-insert-timestamp-left', a @@ -218,6 +264,10 @@ property to get to the POSth column." (list 'space ':align-to pos))) (insert string)) +;; Silence byte-compiler +(eval-when-compile + (defvar erc-fill-column)) + (defun erc-insert-timestamp-right (string) "Insert timestamp on the right side of the screen. STRING is the timestamp to insert. The function is a possible value @@ -272,6 +322,26 @@ be printed just before the window-width." (when erc-timestamp-intangible (erc-put-text-property from (1+ (point)) 'intangible t))))) +(defun erc-insert-timestamp-left-and-right (string) + "This is another function that can be assigned to +`erc-insert-timestamp-function'. If the date is changed, it will +print a blank line, the date, and another blank line. If the time is +changed, it will then print it off to the right." + (let* ((ct (current-time)) + (ts-left (erc-format-timestamp ct erc-timestamp-format-left)) + (ts-right (erc-format-timestamp ct erc-timestamp-format-right))) + ;; insert left timestamp + (unless (string-equal ts-left erc-timestamp-last-inserted-left) + (goto-char (point-min)) + (erc-put-text-property 0 (length ts-left) 'field 'erc-timestamp ts-left) + (insert ts-left) + (setq erc-timestamp-last-inserted-left ts-left)) + ;; insert right timestamp + (let ((erc-timestamp-only-if-changed-flag t) + (erc-timestamp-last-inserted erc-timestamp-last-inserted-right)) + (erc-insert-timestamp-right ts-right) + (setq erc-timestamp-last-inserted-right ts-right)))) + ;; for testing: (setq erc-timestamp-only-if-changed-flag nil) (defun erc-format-timestamp (time format) @@ -342,8 +412,8 @@ NOW is position of point currently." (when erc-echo-timestamps (let ((stamp (get-text-property now 'timestamp))) (when stamp - (message (format-time-string erc-echo-timestamp-format - stamp)))))) + (message "%s" (format-time-string erc-echo-timestamp-format + stamp)))))) (provide 'erc-stamp) diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el index 6ccbbc3309f..76a692219ca 100644 --- a/lisp/erc/erc-track.el +++ b/lisp/erc/erc-track.el @@ -95,6 +95,12 @@ Activity means that there was no user input in the last 10 seconds." :group 'erc-track :type '(repeat string)) +(defcustom erc-track-remove-disconnected-buffers nil + "*If true, remove buffers associated with a server that is +disconnected from `erc-modified-channels-alist'." + :group 'erc-track + :type 'boolean) + (defcustom erc-track-exclude-types '("NICK") "*List of message types to be ignored. This list could look like '(\"JOIN\" \"PART\")." @@ -151,6 +157,16 @@ If nil instead of a function, shortening is disabled." :type '(choice (const :tag "Disabled") function)) +(defcustom erc-track-list-changed-hook nil + "Hook that is run whenever the contents of +`erc-modified-channels-alist' changes. + +This is useful for people that don't use the default mode-line +notification but instead use a separate mechanism to provide +notification of channel activity." + :group 'erc-track + :type 'hook) + (defcustom erc-track-use-faces t "*Use faces in the mode-line. The faces used are the same as used for text in the buffers. @@ -192,12 +208,14 @@ Setting this variable only has effects in GNU Emacs versions above 21.3. Choices are: 'before-modes - add to the beginning of `mode-line-modes' 'after-modes - add to the end of `mode-line-modes' - -Any other value means add to the end of `global-mode-string'." +t - add to the end of `global-mode-string'. +nil - don't add to mode line +" :group 'erc-track :type '(choice (const :tag "Just before mode information" before-modes) (const :tag "Just after mode information" after-modes) - (const :tag "After all other information" nil)) + (const :tag "After all other information" t) + (const :tag "Don't display in mode line" nil)) :set (lambda (sym val) (set sym val) (when (and (boundp 'erc-track-mode) @@ -263,12 +281,18 @@ when there are no more active channels." (defcustom erc-track-switch-direction 'oldest "Direction `erc-track-switch-buffer' should switch. + importance - find buffer with the most important message oldest - find oldest active buffer newest - find newest active buffer leastactive - find buffer with least unseen messages - mostactive - find buffer with most unseen messages." + mostactive - find buffer with most unseen messages. + +If set to 'importance, the importance is determined by position +in `erc-track-faces-priority-list', where first is most +important." :group 'erc-track - :type '(choice (const oldest) + :type '(choice (const importance) + (const oldest) (const newest) (const leastactive) (const mostactive))) @@ -296,7 +320,7 @@ See `erc-track-position-in-mode-line' for possible values." (boundp 'mode-line-modes)) (add-to-list 'mode-line-modes '(t erc-modified-channels-object) t)) - (t + ((eq position t) (when (not global-mode-string) (setq global-mode-string '(""))) ; Padding for mode-line wart (add-to-list 'global-mode-string @@ -641,17 +665,25 @@ only consider active buffers visible.") (defun erc-user-is-active (&rest ignore) "Set `erc-buffer-activity'." - (setq erc-buffer-activity (erc-current-time)) - (erc-track-modified-channels)) + (when erc-server-connected + (setq erc-buffer-activity (erc-current-time)) + (erc-track-modified-channels))) + +(defun erc-track-get-buffer-window (buffer frame-param) + (if (eq frame-param 'selected-visible) + (if (eq (frame-visible-p (selected-frame)) t) + (get-buffer-window buffer nil) + nil) + (get-buffer-window buffer frame-param))) (defun erc-buffer-visible (buffer) "Return non-nil when the buffer is visible." (if erc-track-when-inactive (when erc-buffer-activity; could be nil - (and (get-buffer-window buffer erc-track-visibility) + (and (erc-track-get-buffer-window buffer erc-track-visibility) (<= (erc-time-diff erc-buffer-activity (erc-current-time)) erc-buffer-activity-timeout))) - (get-buffer-window buffer erc-track-visibility))) + (erc-track-get-buffer-window buffer erc-track-visibility))) ;;; Tracking the channel modifications @@ -668,18 +700,22 @@ called via `window-configuration-change-hook'. ARGS are ignored." (interactive) (unless erc-modified-channels-update-inside - (let ((erc-modified-channels-update-inside t)) - (mapcar (lambda (elt) - (let ((buffer (car elt))) - (when (or (not (bufferp buffer)) - (not (buffer-live-p buffer)) - (erc-buffer-visible buffer) - (not (with-current-buffer buffer - erc-server-connected))) - (erc-modified-channels-remove-buffer buffer)))) - erc-modified-channels-alist) + (let ((erc-modified-channels-update-inside t) + (removed-channel nil)) + (mapc (lambda (elt) + (let ((buffer (car elt))) + (when (or (not (bufferp buffer)) + (not (buffer-live-p buffer)) + (erc-buffer-visible buffer) + (and erc-track-remove-disconnected-buffers + (not (with-current-buffer buffer + erc-server-connected)))) + (setq removed-channel t) + (erc-modified-channels-remove-buffer buffer)))) + erc-modified-channels-alist) + (when removed-channel (erc-modified-channels-display) - (force-mode-line-update t)))) + (force-mode-line-update t))))) (defvar erc-track-mouse-face (if (featurep 'xemacs) 'modeline-mousable @@ -729,10 +765,13 @@ If FACES are provided, color STRING with them." "Set `erc-modified-channels-object' according to `erc-modified-channels-alist'. Use `erc-make-mode-line-buffer-name' to create buttons." - (if (or - (eq 'mostactive erc-track-switch-direction) - (eq 'leastactive erc-track-switch-direction)) - (erc-track-sort-by-activest)) + (cond ((or (eq 'mostactive erc-track-switch-direction) + (eq 'leastactive erc-track-switch-direction)) + (erc-track-sort-by-activest)) + ((eq 'importance erc-track-switch-direction) + (erc-track-sort-by-importance))) + (run-hooks 'erc-track-list-changed-hook) + (unless (eq erc-track-position-in-mode-line nil) (if (null erc-modified-channels-alist) (setq erc-modified-channels-object (erc-modified-channels-object nil)) ;; erc-modified-channels-alist contains all the data we need. To @@ -768,7 +807,7 @@ Use `erc-make-mode-line-buffer-name' to create buttons." (when (featurep 'xemacs) (erc-modified-channels-object nil)) (setq erc-modified-channels-object - (erc-modified-channels-object strings))))) + (erc-modified-channels-object strings)))))) (defun erc-modified-channels-remove-buffer (buffer) "Remove BUFFER from `erc-modified-channels-alist'." @@ -802,8 +841,7 @@ is in `erc-mode'." (if (and (not (erc-buffer-visible (current-buffer))) (not (member this-channel erc-track-exclude)) (not (and erc-track-exclude-server-buffer - (string= this-channel - (buffer-name (erc-server-buffer))))) + (erc-server-buffer-p))) (not (erc-message-type-member (or (erc-find-parsed-property) (point-min)) @@ -847,10 +885,10 @@ is in `erc-mode'." (erc-modified-channels-display))) ;; Else if the active buffer is the current buffer, remove it ;; from our list. - (when (or (erc-buffer-visible (current-buffer)) + (when (and (or (erc-buffer-visible (current-buffer)) (and this-channel - (assq (current-buffer) erc-modified-channels-alist) (member this-channel erc-track-exclude))) + (assq (current-buffer) erc-modified-channels-alist)) ;; Remove it from mode-line if buffer is visible or ;; channel was added to erc-track-exclude recently. (erc-modified-channels-remove-buffer (current-buffer)) @@ -887,6 +925,29 @@ That means the number of unseen messages in a channel." (sort erc-modified-channels-alist (lambda (a b) (> (nth 1 a) (nth 1 b)))))) +(defun erc-track-face-priority (face) + "Return a number indicating the priority of FACE in +`erc-track-faces-priority-list'. Lower number means higher +priority. + +If face is not in `erc-track-faces-priority-list', it will have a +higher number than any other face in that list." + (let ((count 0)) + (catch 'done + (dolist (item erc-track-faces-priority-list) + (if (eq item face) + (throw 'done t) + (setq count (1+ count))))) + count)) + +(defun erc-track-sort-by-importance () + "Sort erc-modified-channels-alist by importance. +That means the position of the face in `erc-track-faces-priority-list'." + (setq erc-modified-channels-alist + (sort erc-modified-channels-alist + (lambda (a b) (< (erc-track-face-priority (cddr a)) + (erc-track-face-priority (cddr b))))))) + (defun erc-track-get-active-buffer (arg) "Return the buffer name of ARG in `erc-modified-channels-alist'. Negative arguments index in the opposite direction. This direction is @@ -898,7 +959,8 @@ relative to `erc-track-switch-direction'" (oldest 'newest) (newest 'oldest) (mostactive 'leastactive) - (leastactive 'mostactive))) + (leastactive 'mostactive) + (importance 'oldest))) (setq arg (- arg))) (setq offset (case dir ((oldest leastactive) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 00d61a60ffd..c197f618442 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -66,7 +66,7 @@ ;;; Code: -(defconst erc-version-string "Version 5.2" +(defconst erc-version-string "Version 5.3 (devel)" "ERC version. This is used by function `erc-version'.") (eval-when-compile (require 'cl)) @@ -836,8 +836,9 @@ See `erc-server-flood-margin' for other flood-related parameters.") ;; Script parameters (defcustom erc-startup-file-list - '("~/.emacs.d/.ercrc.el" "~/.emacs.d/.ercrc" - "~/.ercrc.el" "~/.ercrc" ".ercrc.el" ".ercrc") + (list (concat erc-user-emacs-directory ".ercrc.el") + (concat erc-user-emacs-directory ".ercrc") + "~/.ercrc.el" "~/.ercrc" ".ercrc.el" ".ercrc") "List of files to try for a startup script. The first existent and readable one will get executed. @@ -1460,7 +1461,7 @@ Turning on `erc-mode' runs the hook `erc-mode-hook'." (defconst erc-default-server "irc.freenode.net" "IRC server to use if it cannot be detected otherwise.") -(defconst erc-default-port "6667" +(defconst erc-default-port 6667 "IRC port to use if it cannot be detected otherwise.") (defcustom erc-join-buffer 'buffer @@ -1491,6 +1492,14 @@ This only has effect when `erc-join-buffer' is set to `frame'." :group 'erc-buffers :type 'boolean) +(defcustom erc-reuse-frames t + "*Determines whether new frames are always created. +Non-nil means that a new frame is not created to display an ERC +buffer if there is already a window displaying it. This only has +effect when `erc-join-buffer' is set to `frame'." + :group 'erc-buffers + :type 'boolean) + (defun erc-channel-p (channel) "Return non-nil if CHANNEL seems to be an IRC channel name." (cond ((stringp channel) @@ -1671,16 +1680,24 @@ nil." ;; Make the evaluation have the correct order (let ((pre (make-symbol "pre")) (pro (make-symbol "pro"))) - `(let ((,pro ,process) - (,pre ,pred)) - (mapcar (lambda (buffer) - (with-current-buffer buffer - ,@forms)) - (erc-buffer-list ,pre - ,pro))))) + `(let* ((,pro ,process) + (,pre ,pred) + (res (mapcar (lambda (buffer) + (with-current-buffer buffer + ,@forms)) + (erc-buffer-list ,pre + ,pro)))) + ;; Silence the byte-compiler by binding the result of mapcar to + ;; a variable. + res))) (put 'erc-with-all-buffers-of-server 'lisp-indent-function 1) (put 'erc-with-all-buffers-of-server 'edebug-form-spec '(form form body)) +;; (iswitchb-mode) will autoload iswitchb.el +(defvar iswitchb-temp-buflist) +(declare-function iswitchb-read-buffer "iswitchb" + (prompt &optional default require-match start matches-set)) + (defun erc-iswitchb (&optional arg) "Use `iswitchb-read-buffer' to prompt for a ERC buffer to switch to. When invoked with prefix argument, use all erc buffers. Without prefix @@ -1691,9 +1708,7 @@ If `erc-track-mode' is in enabled, put the last element of Due to some yet unresolved reason, global function `iswitchb-mode' needs to be active for this function to work." (interactive "P") - (eval-when-compile - (require 'iswitchb)) - (let ((enabled iswitchb-mode)) + (let ((enabled (bound-and-true-p iswitchb-mode))) (or enabled (iswitchb-mode 1)) (unwind-protect (let ((iswitchb-make-buflist-hook @@ -1888,14 +1903,16 @@ removed from the list will be disabled." ((eq erc-join-buffer 'bury) nil) ((eq erc-join-buffer 'frame) - (funcall '(lambda (frame) + (when (or (not erc-reuse-frames) + (not (get-buffer-window buffer t))) + ((lambda (frame) (raise-frame frame) (select-frame frame)) (make-frame (or erc-frame-alist default-frame-alist))) (switch-to-buffer buffer) (when erc-frame-dedicated-flag - (set-window-dedicated-p (selected-window) t))) + (set-window-dedicated-p (selected-window) t)))) (t (if (active-minibuffer-window) (display-buffer buffer) @@ -2151,20 +2168,56 @@ Arguments are the same as for `erc'." (defalias 'erc-select-ssl 'erc-ssl) +(declare-function open-ssl-stream "ext:ssl" (name buffer host service)) + (defun erc-open-ssl-stream (name buffer host port) "Open an SSL stream to an IRC server. The process will be given the name NAME, its target buffer will be BUFFER. HOST and PORT specify the connection target." - (when (require 'tls) - (let ((proc (open-tls-stream name buffer host port))) + (when (condition-case nil + (require 'ssl) + (error (message "You don't have ssl.el. %s" + "Try using `erc-tls' instead.") + nil)) + (let ((proc (open-ssl-stream name buffer host port))) ;; Ugly hack, but it works for now. Problem is it is ;; very hard to detect when ssl is established, because s_client ;; doesn't give any CONNECTIONESTABLISHED kind of message, and ;; most IRC servers send nothing and wait for you to identify. - ;; Disabled when switching to tls.el -- jas - ;(sit-for 5) + (sit-for 5) proc))) +(defun erc-tls (&rest r) + "Interactively select TLS connection parameters and run ERC. +Arguments are the same as for `erc'." + (interactive (erc-select-read-args)) + (let ((erc-server-connect-function 'erc-open-tls-stream)) + (apply 'erc r))) + +(declare-function open-tls-stream "tls" (name buffer host port)) + +(defun erc-open-tls-stream (name buffer host port) + "Open an TLS stream to an IRC server. +The process will be given the name NAME, its target buffer will be +BUFFER. HOST and PORT specify the connection target." + (when (condition-case nil + (require 'tls) + (error (message "You don't have tls.el. %s" + "Try using `erc-ssl' instead.") + nil)) + (open-tls-stream name buffer host port))) + +;;; Displaying error messages + +(defun erc-error (&rest args) + "Pass ARGS to `format', and display the result as an error message. +If `debug-on-error' is set to non-nil, then throw a real error with this +message instead, to make debugging easier." + (if debug-on-error + (apply #'error args) + (apply #'message args) + (beep))) + ;;; Debugging the protocol (defvar erc-debug-irc-protocol nil @@ -2179,6 +2232,8 @@ but you won't see it. WARNING: Do not set this variable directly! Instead, use the function `erc-toggle-debug-irc-protocol' to toggle its value.") +(declare-function erc-network-name "erc-networks" ()) + (defun erc-log-irc-protocol (string &optional outbound) "Append STRING to the buffer *erc-protocol*. @@ -2228,7 +2283,7 @@ If ARG is non-nil, show the *erc-protocol* buffer." (interactive "P") (let* ((buf (get-buffer-create "*erc-protocol*"))) (with-current-buffer buf - (erc-view-mode-enter 1) + (erc-view-mode-enter) (when (null (current-local-map)) (let ((inhibit-read-only t)) (insert (erc-make-notice "This buffer displays all IRC protocol traffic exchanged with each server.\n")) @@ -2456,6 +2511,14 @@ See also `erc-server-send'." (match-string 1 arglist) arglist))) +(defun erc-command-no-process-p (str) + "Return non-nil if STR is an ERC command that can be run when the process +is not alive, nil otherwise." + (let ((fun (erc-extract-command-from-line str))) + (and fun + (symbolp (car fun)) + (get (car fun) 'process-not-needed)))) + (defun erc-command-name (cmd) "For CMD being the function name of a ERC command, something like erc-cmd-FOO, this returns a string /FOO." @@ -2565,6 +2628,7 @@ VALUE is computed by evaluating the rest of LINE in Lisp." (defalias 'erc-cmd-VAR 'erc-cmd-SET) (defalias 'erc-cmd-VARIABLE 'erc-cmd-SET) (put 'erc-cmd-SET 'do-not-parse-args t) +(put 'erc-cmd-SET 'process-not-needed t) (defun erc-cmd-default (line) "Fallback command. @@ -2623,6 +2687,7 @@ If no USER argument is specified, list the contents of `erc-ignore-list'." "Clear the window content." (recenter 0) t) +(put 'erc-cmd-CLEAR 'process-not-needed t) (defun erc-cmd-OPS () "Show the ops in the current channel." @@ -2656,6 +2721,7 @@ If no USER argument is specified, list the contents of `erc-ignore-list'." (erc-display-message nil 'notice 'active 'country-unknown ?d tld)) t)) +(put 'erc-cmd-COUNTRY 'process-not-needed t) (defun erc-cmd-AWAY (line) "Mark the user as being away, the reason being indicated by LINE. @@ -2736,6 +2802,7 @@ For a list of user commands (/join /part, ...): t)) (defalias 'erc-cmd-H 'erc-cmd-HELP) +(put 'erc-cmd-HELP 'process-not-needed t) (defun erc-cmd-JOIN (channel &optional key) "Join the channel given in CHANNEL, optionally with KEY. @@ -2959,6 +3026,11 @@ LINE has the format \"USER ACTION\"." (t nil))) (put 'erc-cmd-ME 'do-not-parse-args t) +(defun erc-cmd-ME\'S (line) + "Do a /ME command, but add the string \" 's\" to the beginning." + (erc-cmd-ME (concat " 's" line))) +(put 'erc-cmd-ME\'S 'do-not-parse-args t) + (defun erc-cmd-LASTLOG (line) "Show all lines in the current buffer matching the regexp LINE. @@ -2973,6 +3045,7 @@ the matching is case-sensitive." (occur line) t) (put 'erc-cmd-LASTLOG 'do-not-parse-args t) +(put 'erc-cmd-LASTLOG 'process-not-needed t) (defun erc-send-message (line &optional force) "Send LINE to the current channel or user and display it. @@ -3195,20 +3268,34 @@ the message given by REASON." (defalias 'erc-cmd-EXIT 'erc-cmd-QUIT) (defalias 'erc-cmd-SIGNOFF 'erc-cmd-QUIT) (put 'erc-cmd-QUIT 'do-not-parse-args t) +(put 'erc-cmd-QUIT 'process-not-needed t) (defun erc-cmd-GQUIT (reason) "Disconnect from all servers at once with the same quit REASON." (erc-with-all-buffers-of-server nil #'erc-open-server-buffer-p - (erc-cmd-QUIT reason))) + (erc-cmd-QUIT reason)) + (when erc-kill-queries-on-quit + ;; if the query buffers have not been killed within 4 seconds, + ;; kill them + (run-at-time + 4 nil + (lambda () + (dolist (buffer (erc-buffer-list (lambda (buf) + (not (erc-server-buffer-p buf))))) + (kill-buffer buffer))))) + t) (defalias 'erc-cmd-GQ 'erc-cmd-GQUIT) (put 'erc-cmd-GQUIT 'do-not-parse-args t) +(put 'erc-cmd-GQUIT 'process-not-needed t) (defun erc-cmd-RECONNECT () "Try to reconnect to the current IRC server." - (let ((buffer (or (erc-server-buffer) (current-buffer))) + (let ((buffer (erc-server-buffer)) (process nil)) - (with-current-buffer (if (bufferp buffer) buffer (current-buffer)) + (unless (buffer-live-p buffer) + (setq buffer (current-buffer))) + (with-current-buffer buffer (setq erc-server-quitting nil) (setq erc-server-reconnecting t) (setq erc-server-reconnect-count 0) @@ -3218,6 +3305,7 @@ the message given by REASON." (erc-server-reconnect)) (setq erc-server-reconnecting nil))) t) +(put 'erc-cmd-RECONNECT 'process-not-needed t) (defun erc-cmd-SERVER (server) "Connect to SERVER, leaving existing connection intact." @@ -3225,9 +3313,9 @@ the message given by REASON." (condition-case nil (erc :server server :nick (erc-current-nick)) (error - (message "Cannot find host %s." server) - (beep))) + (erc-error "Cannot find host %s." server))) t) +(put 'erc-cmd-SERVER 'process-not-needed t) (eval-when-compile (defvar motif-version-string) @@ -3598,7 +3686,7 @@ If `point' is at the beginning of a channel name, use that as default." (set-buffer (process-buffer erc-server-process)) erc-channel-list))) (completing-read "Join channel: " table nil nil nil nil chnl)) - (when erc-prompt-for-channel-key + (when (or current-prefix-arg erc-prompt-for-channel-key) (read-from-minibuffer "Channel key (RET for none): " nil)))) (erc-cmd-JOIN channel (when (>= (length key) 1) key))) @@ -4411,33 +4499,65 @@ See also `erc-channel-begin-receiving-names'." erc-channel-users) (setq erc-channel-new-member-names nil)) +(defun erc-parse-prefix () + "Return an alist of valid prefix character types and their representations. +Example: (operator) o => @, (voiced) v => +." + (let ((str (or (cdr (assoc "PREFIX" (erc-with-server-buffer + erc-server-parameters))) + ;; provide a sane default + "(ov)@+")) + types chars) + (when (string-match "^(\\([^)]+\\))\\(.+\\)$" str) + (setq types (match-string 1 str) + chars (match-string 2 str)) + (let ((len (min (length types) (length chars))) + (i 0) + (alist nil)) + (while (< i len) + (setq alist (cons (cons (elt types i) (elt chars i)) + alist)) + (setq i (1+ i))) + alist)))) + (defun erc-channel-receive-names (names-string) "This function is for internal use only. Update `erc-channel-users' according to NAMES-STRING. NAMES-STRING is a string listing some of the names on the channel." - (let (names name op voice) - ;; We need to delete "" because in XEmacs, (split-string "a ") - ;; returns ("a" ""). - (setq names (delete "" (split-string names-string))) - (let ((erc-channel-members-changed-hook nil)) - (dolist (item names) - (cond ((string-match "^@\\(.*\\)$" item) - (setq name (match-string 1 item) - op 'on - voice 'off)) - ((string-match "^+\\(.*\\)$" item) - (setq name (match-string 1 item) - op 'off - voice 'on)) - (t (setq name item - op 'off - voice 'off))) - (puthash (erc-downcase name) t - erc-channel-new-member-names) - (erc-update-current-channel-member - name name t op voice))) + (let (prefix op-ch voice-ch names name op voice) + (setq prefix (erc-parse-prefix)) + (setq op-ch (cdr (assq ?o prefix)) + voice-ch (cdr (assq ?v prefix))) + ;; We need to delete "" because in XEmacs, (split-string "a ") + ;; returns ("a" ""). + (setq names (delete "" (split-string names-string))) + (let ((erc-channel-members-changed-hook nil)) + (dolist (item names) + (let ((updatep t) + ch) + (if (rassq (elt item 0) prefix) + (cond ((= (length item) 1) + (setq updatep nil)) + ((eq (elt item 0) op-ch) + (setq name (substring item 1) + op 'on + voice 'off)) + ((eq (elt item 0) voice-ch) + (setq name (substring item 1) + op 'off + voice 'on)) + (t (setq name (substring item 1) + op 'off + voice 'off))) + (setq name item + op 'off + voice 'off)) + (when updatep + (puthash (erc-downcase name) t + erc-channel-new-member-names) + (erc-update-current-channel-member + name name t op voice))))) (run-hooks 'erc-channel-members-changed-hook))) (defcustom erc-channel-members-changed-hook nil @@ -4529,15 +4649,15 @@ See also: `erc-update-user' and `erc-update-channel-member'." (setq changed t) (setf (erc-channel-user-op cuser) (cond ((eq op 'on) t) - ((eq op 'off) nil) - (t op)))) + ((eq op 'off) nil) + (t op)))) (when (and voice (not (eq (erc-channel-user-voice cuser) voice))) (setq changed t) (setf (erc-channel-user-voice cuser) (cond ((eq voice 'on) t) - ((eq voice 'off) nil) - (t voice)))) + ((eq voice 'off) nil) + (t voice)))) (when update-message-time (setf (erc-channel-user-last-message-time cuser) (current-time))) (setq user-changed @@ -4559,11 +4679,11 @@ See also: `erc-update-user' and `erc-update-channel-member'." (erc-server-user-buffers user)))) (setq cuser (make-erc-channel-user :op (cond ((eq op 'on) t) - ((eq op 'off) nil) - (t op)) + ((eq op 'off) nil) + (t op)) :voice (cond ((eq voice 'on) t) - ((eq voice 'off) nil) - (t voice)) + ((eq voice 'off) nil) + (t voice)) :last-message-time (if update-message-time (current-time)))) (puthash (erc-downcase nick) (cons user cuser) @@ -4892,39 +5012,37 @@ Specifically, return the position of `erc-insert-marker'." (interactive) (save-restriction (widen) - (cond - ((< (point) (erc-beg-of-input-line)) - (message "Point is not in the input area") - (beep)) - ((not (erc-server-buffer-live-p)) - (message "ERC: No process running") - (beep)) - (t - (erc-set-active-buffer (current-buffer)) + (if (< (point) (erc-beg-of-input-line)) + (erc-error "Point is not in the input area") (let ((inhibit-read-only t) (str (erc-user-input)) (old-buf (current-buffer))) - - ;; Kill the input and the prompt - (delete-region (erc-beg-of-input-line) - (erc-end-of-input-line)) - - (unwind-protect - (erc-send-input str) - ;; Fix the buffer if the command didn't kill it - (when (buffer-live-p old-buf) - (with-current-buffer old-buf - (save-restriction - (widen) - (goto-char (point-max)) - (set-marker (process-mark erc-server-process) (point)) - (set-marker erc-insert-marker (point)) - (let ((buffer-modified (buffer-modified-p))) - (erc-display-prompt) - (set-buffer-modified-p buffer-modified)))))) - - ;; Only when last hook has been run... - (run-hook-with-args 'erc-send-completed-hook str)))))) + (if (and (not (erc-server-buffer-live-p)) + (not (erc-command-no-process-p str))) + (erc-error "ERC: No process running") + (erc-set-active-buffer (current-buffer)) + + ;; Kill the input and the prompt + (delete-region (erc-beg-of-input-line) + (erc-end-of-input-line)) + + (unwind-protect + (erc-send-input str) + ;; Fix the buffer if the command didn't kill it + (when (buffer-live-p old-buf) + (with-current-buffer old-buf + (save-restriction + (widen) + (goto-char (point-max)) + (when (processp erc-server-process) + (set-marker (process-mark erc-server-process) (point))) + (set-marker erc-insert-marker (point)) + (let ((buffer-modified (buffer-modified-p))) + (erc-display-prompt) + (set-buffer-modified-p buffer-modified)))))) + + ;; Only when last hook has been run... + (run-hook-with-args 'erc-send-completed-hook str)))))) (defun erc-user-input () "Return the input of the user in the current buffer." @@ -4932,7 +5050,7 @@ Specifically, return the position of `erc-insert-marker'." erc-input-marker (erc-end-of-input-line))) -(defvar erc-command-regexp "^/\\([A-Za-z]+\\)\\(\\s-+.*\\|\\s-*\\)$" +(defvar erc-command-regexp "^/\\([A-Za-z']+\\)\\(\\s-+.*\\|\\s-*\\)$" "Regular expression used for matching commands in ERC.") (defun erc-send-input (input) @@ -4985,7 +5103,8 @@ This returns non-nil only if we actually send anything." (erc-put-text-property beg (point) 'face 'erc-command-indicator-face) (insert "\n")) - (set-marker (process-mark erc-server-process) (point)) + (when (processp erc-server-process) + (set-marker (process-mark erc-server-process) (point))) (set-marker erc-insert-marker (point)) (save-excursion (save-restriction @@ -5004,7 +5123,8 @@ current position." (erc-put-text-property beg (point) 'face 'erc-input-face)) (insert "\n") - (set-marker (process-mark erc-server-process) (point)) + (when (processp erc-server-process) + (set-marker (process-mark erc-server-process) (point))) (set-marker erc-insert-marker (point)) (save-excursion (save-restriction @@ -5844,6 +5964,9 @@ if `erc-away' is non-nil." (cond (lag (format "lag:%.0f" lag)) (t "")))) +;; erc-goodies is required at end of this file. +(declare-function erc-controls-strip "erc-goodies" (str)) + (defun erc-update-mode-line-buffer (buffer) "Update the mode line in a single ERC buffer BUFFER." (with-current-buffer buffer @@ -6090,10 +6213,12 @@ All windows are opened in the current frame." (s252 . "%i operator(s) online") (s253 . "%i unknown connection(s)") (s254 . "%i channels formed") + (s275 . "%n %m") (s301 . "%n is AWAY: %r") (s303 . "Is online: %n") (s305 . "%m") (s306 . "%m") + (s307 . "%n %m") (s311 . "%n is %f (%u@%h)") (s312 . "%n is/was on server %s (%c)") (s313 . "%n is an IRC operator") |