Mercurial > emacs
comparison lisp/erc/erc-backend.el @ 74093:bc5d69739d5e
Merge from erc--emacs--22
Merge from my ERC Emacs 22 integration branch. The version is now "5.2
stable pre-release". This will probably be the last change to the
version of ERC in Emacs 22 before the release, pending any bugfixes. For
details on the changes, see the lisp/erc/ChangeLog file.
Note that ERC is now invoked with M-x erc, not M-x erc-select. If you
were using the old `erc' function programmatically, use `erc-open'
instead.
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-520
Creator: Michael Olson <mwolson@gnu.org>
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 20 Nov 2006 06:50:29 +0000 |
parents | 430a916ae2ba |
children | d629c8e9985d |
comparison
equal
deleted
inserted
replaced
74092:b4cb60fd110d | 74093:bc5d69739d5e |
---|---|
414 (erc-current-time)))))) | 414 (erc-current-time)))))) |
415 (current-buffer))))) | 415 (current-buffer))))) |
416 | 416 |
417 (defun erc-server-process-alive () | 417 (defun erc-server-process-alive () |
418 "Return non-nil when `erc-server-process' is open or running." | 418 "Return non-nil when `erc-server-process' is open or running." |
419 (and (boundp 'erc-server-process) | 419 (and erc-server-process |
420 (processp erc-server-process) | 420 (processp erc-server-process) |
421 (memq (process-status erc-server-process) '(run open)))) | 421 (memq (process-status erc-server-process) '(run open)))) |
422 | 422 |
423 ;;;; Connecting to a server | 423 ;;;; Connecting to a server |
424 | 424 |
510 (not (string-match "^deleted" event)) | 510 (not (string-match "^deleted" event)) |
511 ;; open-network-stream-nowait error for connection refused | 511 ;; open-network-stream-nowait error for connection refused |
512 (not (string-match "^failed with code 111" event))) | 512 (not (string-match "^failed with code 111" event))) |
513 ;; Yuck, this should perhaps funcall | 513 ;; Yuck, this should perhaps funcall |
514 ;; erc-server-reconnect-function with no args | 514 ;; erc-server-reconnect-function with no args |
515 (erc erc-session-server erc-session-port erc-server-current-nick | 515 (erc-open erc-session-server erc-session-port erc-server-current-nick |
516 erc-session-user-full-name t erc-session-password) | 516 erc-session-user-full-name t erc-session-password) |
517 ;; terminate, do not reconnect | 517 ;; terminate, do not reconnect |
518 (erc-display-message nil 'error (current-buffer) | 518 (erc-display-message nil 'error (current-buffer) |
519 'terminated ?e event)))) | 519 'terminated ?e event)))) |
520 | 520 |
521 (defun erc-process-sentinel (cproc event) | 521 (defun erc-process-sentinel (cproc event) |
671 ;; being killed, which results in a weird SIGPIPE error. | 671 ;; being killed, which results in a weird SIGPIPE error. |
672 ;; Catch this and ignore it. | 672 ;; Catch this and ignore it. |
673 (error nil))))) | 673 (error nil))))) |
674 (when erc-server-flood-queue | 674 (when erc-server-flood-queue |
675 (setq erc-server-flood-timer | 675 (setq erc-server-flood-timer |
676 (run-at-time 2 nil #'erc-server-send-queue buffer)))))) | 676 (run-at-time (+ 0.2 erc-server-flood-penalty) |
677 nil #'erc-server-send-queue buffer)))))) | |
677 | 678 |
678 (defun erc-message (message-command line &optional force) | 679 (defun erc-message (message-command line &optional force) |
679 "Send LINE to the server as a privmsg or a notice. | 680 "Send LINE to the server as a privmsg or a notice. |
680 MESSAGE-COMMAND should be either \"PRIVMSG\" or \"NOTICE\". | 681 MESSAGE-COMMAND should be either \"PRIVMSG\" or \"NOTICE\". |
681 If the target is \",\", the last person you've got a message from will | 682 If the target is \",\", the last person you've got a message from will |
1036 (setq chnl (match-string 1 chnl))) | 1037 (setq chnl (match-string 1 chnl))) |
1037 (save-excursion | 1038 (save-excursion |
1038 (let* ((str (cond | 1039 (let* ((str (cond |
1039 ;; If I have joined a channel | 1040 ;; If I have joined a channel |
1040 ((erc-current-nick-p nick) | 1041 ((erc-current-nick-p nick) |
1041 (setq buffer (erc erc-session-server erc-session-port | 1042 (setq buffer (erc-open erc-session-server erc-session-port |
1042 nick erc-session-user-full-name | 1043 nick erc-session-user-full-name |
1043 nil nil | 1044 nil nil |
1044 erc-default-recipients chnl | 1045 erc-default-recipients chnl |
1045 erc-server-process)) | 1046 erc-server-process)) |
1046 (when buffer | 1047 (when buffer |
1047 (set-buffer buffer) | 1048 (set-buffer buffer) |
1048 (erc-add-default-channel chnl) | 1049 (erc-add-default-channel chnl) |
1049 (erc-server-send (format "MODE %s" chnl))) | 1050 (erc-server-send (format "MODE %s" chnl))) |
1050 (erc-with-buffer (chnl proc) | 1051 (erc-with-buffer (chnl proc) |
1581 | 1582 |
1582 (define-erc-response-handler (353) | 1583 (define-erc-response-handler (353) |
1583 "NAMES notice." nil | 1584 "NAMES notice." nil |
1584 (let ((channel (third (erc-response.command-args parsed))) | 1585 (let ((channel (third (erc-response.command-args parsed))) |
1585 (users (erc-response.contents parsed))) | 1586 (users (erc-response.contents parsed))) |
1586 (erc-with-buffer (channel proc) | |
1587 (erc-channel-receive-names users)) | |
1588 (erc-display-message parsed 'notice (or (erc-get-buffer channel proc) | 1587 (erc-display-message parsed 'notice (or (erc-get-buffer channel proc) |
1589 'active) | 1588 'active) |
1590 's353 ?c channel ?u users))) | 1589 's353 ?c channel ?u users) |
1590 (erc-with-buffer (channel proc) | |
1591 (erc-channel-receive-names users)))) | |
1591 | 1592 |
1592 (define-erc-response-handler (366) | 1593 (define-erc-response-handler (366) |
1593 "End of NAMES." nil | 1594 "End of NAMES." nil |
1594 (erc-with-buffer ((second (erc-response.command-args parsed)) proc) | 1595 (erc-with-buffer ((second (erc-response.command-args parsed)) proc) |
1595 (erc-channel-end-receiving-names))) | 1596 (erc-channel-end-receiving-names))) |
1596 | 1597 |
1597 (define-erc-response-handler (367) | 1598 (define-erc-response-handler (367) |
1598 "Channel ban list entries" nil | 1599 "Channel ban list entries" nil |
1599 (multiple-value-bind (channel banmask setter time) | 1600 (multiple-value-bind (channel banmask setter time) |
1600 (cdr (erc-response.command-args parsed)) | 1601 (cdr (erc-response.command-args parsed)) |
1601 (erc-display-message parsed 'notice 'active 's367 | 1602 ;; setter and time are not standard |
1602 ?c channel | 1603 (if setter |
1603 ?b banmask | 1604 (erc-display-message parsed 'notice 'active 's367-set-by |
1604 ?s setter | 1605 ?c channel |
1605 ?t time))) | 1606 ?b banmask |
1607 ?s setter | |
1608 ?t (or time "")) | |
1609 (erc-display-message parsed 'notice 'active 's367 | |
1610 ?c channel | |
1611 ?b banmask)))) | |
1606 | 1612 |
1607 (define-erc-response-handler (368) | 1613 (define-erc-response-handler (368) |
1608 "End of channel ban list" nil | 1614 "End of channel ban list" nil |
1609 (let ((channel (second (erc-response.command-args parsed)))) | 1615 (let ((channel (second (erc-response.command-args parsed)))) |
1610 (erc-display-message parsed 'notice 'active 's368 | 1616 (erc-display-message parsed 'notice 'active 's368 |