From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Ryan Yeske" Newsgroups: gmane.emacs.devel Subject: rcirc update Date: Wed, 7 Mar 2007 15:14:00 -0800 Message-ID: <8fd0ace10703071514s392c2657h5f24aabc892e59cc@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1173309269 25966 80.91.229.12 (7 Mar 2007 23:14:29 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 7 Mar 2007 23:14:29 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 08 00:14:21 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HP5Ku-0002TA-5v for ged-emacs-devel@m.gmane.org; Thu, 08 Mar 2007 00:14:20 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HP5L2-0003cO-FH for ged-emacs-devel@m.gmane.org; Wed, 07 Mar 2007 18:14:28 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HP5Kp-0003c6-FQ for emacs-devel@gnu.org; Wed, 07 Mar 2007 18:14:15 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HP5Km-0003bX-SB for emacs-devel@gnu.org; Wed, 07 Mar 2007 18:14:15 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HP5Km-0003bU-K6 for emacs-devel@gnu.org; Wed, 07 Mar 2007 18:14:12 -0500 Original-Received: from nf-out-0910.google.com ([64.233.182.187]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HP5Kc-0002Ni-MN for emacs-devel@gnu.org; Wed, 07 Mar 2007 18:14:03 -0500 Original-Received: by nf-out-0910.google.com with SMTP id n15so395171nfc for ; Wed, 07 Mar 2007 15:14:01 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=dELzV75Azv+EBaBlfFDHVAeizXtr805vEI1H2quD520ij50rsoWt1RdxR+JxMa/9pa7E3d7mkrSoZ/M78pR4ocCi6CurtGg7sY3GXPEzsk+eCUpLPVVQ7GJ6QvId3q0WJx5sMdS2VbDVZgEhmcVn/L7bQ63ATLb/uzSXF8DEL4U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Uqh6gxCiABZSjRusaL8gtLF0GKJNYq2aFhzUXab2zNar0etcBTOuDu+Xy0UFqCq9lYGI1z4h2w/Y+NW+EDXxk8MDEygv5cTRBhzcnB1DyeWjhT0SpYVe+TqWjQ/BuTE+zQouM/5ySGHUwbMjttm7HO6qqRtyPaDS1A+/mBtpzqw= Original-Received: by 10.82.111.8 with SMTP id j8mr10317490buc.1173309240725; Wed, 07 Mar 2007 15:14:00 -0800 (PST) Original-Received: by 10.82.164.2 with HTTP; Wed, 7 Mar 2007 15:14:00 -0800 (PST) Content-Disposition: inline X-detected-kernel: Linux 2.4-2.6 (Google crawlbot) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:67542 Archived-At: 2007-03-02 Ryan Yeske =09* net/rcirc.el (rcirc-timeout-seconds): New variable. =09(rcirc-keepalive-seconds): Remove variable. =09(rcirc-server-name, rcirc-timeout-timer, rcirc-connecting) =09(rcirc-process): New variables. =09(rcirc-connect): Initalize new variables. =09(rcirc-keepalive): Don't send keepalive pings before connection is =09completed. =09(rcirc-sentinel): Do mark all channels with activity when =09connection is dropped. Run hook with process buffer local. =09(rcirc-reschedule-timeout, rcirc-delete-process): New functions. =09(rcirc-buffer-process): Return value of rcirc-process if =09rcirc-server-buffer is nil. =09(rcirc-server-name): Return the reported server name. =09(rcirc-update-prompt): Simplify computation of the server name. =09(rcirc-format-response-string): Likewise. =09(rcirc-handler-001): Mark server as connected, record the reported =09server name, and schedule a timeout. =09(rcirc-track-nick): Add a spec for the tty class. =09(rcirc-user-non-nick): Remove function. =09(rcirc-nick-prefix-chars): Add variable. =09(rcirc-user-nick): Use above variable. Index: rcirc.el =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/emacs/emacs/lisp/net/rcirc.el,v retrieving revision 1.30 diff -c -r1.30 rcirc.el *** rcirc.el=0924 Nov 2006 10:33:22 -0000=091.30 --- rcirc.el=092 Mar 2007 22:40:28 -0000 *************** *** 312,320 **** "List of urls seen in the current buffer.") (put 'rcirc-urls 'permanent-local t) ! (defvar rcirc-keepalive-seconds 60 ! "Number of seconds between keepalive pings. ! If nil, do not send keepalive pings.") (defconst rcirc-id-string (concat "rcirc on GNU Emacs " emacs-version)) =0C --- 312,319 ---- "List of urls seen in the current buffer.") (put 'rcirc-urls 'permanent-local t) ! (defvar rcirc-timeout-seconds 60 ! "Kill connection after this many seconds if there is no activity.") (defconst rcirc-id-string (concat "rcirc on GNU Emacs " emacs-version)) =0C *************** *** 357,363 **** (defvar rcirc-topic nil) (defvar rcirc-keepalive-timer nil) (defvar rcirc-last-server-message-time nil) ! (defvar rcirc-server nil) ;;;###autoload (defun rcirc-connect (&optional server port nick user-name full-name startup-channels) --- 356,366 ---- (defvar rcirc-topic nil) (defvar rcirc-keepalive-timer nil) (defvar rcirc-last-server-message-time nil) ! (defvar rcirc-server nil)=09=09; server provided by server ! (defvar rcirc-server-name nil)=09=09; server name given by 001 response ! (defvar rcirc-timeout-timer nil) ! (defvar rcirc-connecting nil) ! (defvar rcirc-process nil) ;;;###autoload (defun rcirc-connect (&optional server port nick user-name full-name startup-channels) *************** *** 374,380 **** =09 (user-name (or user-name rcirc-default-user-name)) =09 (full-name (or full-name rcirc-default-user-full-name)) =09 (startup-channels startup-channels) ! (process (open-network-stream server nil server port-number))) ;; set up process (set-process-coding-system process 'raw-text 'raw-text) (switch-to-buffer (rcirc-generate-new-buffer-name process nil)) --- 377,383 ---- =09 (user-name (or user-name rcirc-default-user-name)) =09 (full-name (or full-name rcirc-default-user-full-name)) =09 (startup-channels startup-channels) ! (process (make-network-process :name server :host server :service port-number))) ;; set up process (set-process-coding-system process 'raw-text 'raw-text) (switch-to-buffer (rcirc-generate-new-buffer-name process nil)) *************** *** 382,389 **** --- 385,396 ---- (rcirc-mode process nil) (set-process-sentinel process 'rcirc-sentinel) (set-process-filter process 'rcirc-filter) + (make-local-variable 'rcirc-process) + (setq rcirc-process process) (make-local-variable 'rcirc-server) (setq rcirc-server server) + (make-local-variable 'rcirc-server-name) + (setq rcirc-server-name server)=09; update when we get 001 response (make-local-variable 'rcirc-buffer-alist) (setq rcirc-buffer-alist nil) (make-local-variable 'rcirc-nick-table) *************** *** 396,401 **** --- 403,414 ---- (setq rcirc-startup-channels startup-channels) (make-local-variable 'rcirc-last-server-message-time) (setq rcirc-last-server-message-time (current-time)) + (make-local-variable 'rcirc-timeout-timer) + (setq rcirc-timeout-timer nil) + (make-local-variable 'rcirc-user-disconnect) + (setq rcirc-user-disconnect nil) + (make-local-variable 'rcirc-connecting) + (setq rcirc-connecting t) ;; identify (rcirc-send-string process (concat "NICK " nick)) *************** *** 404,413 **** full-name)) ;; setup ping timer if necessary ! (when rcirc-keepalive-seconds ! =09(unless rcirc-keepalive-timer ! =09 (setq rcirc-keepalive-timer ! =09=09(run-at-time 0 rcirc-keepalive-seconds 'rcirc-keepalive)))) (message "Connecting to %s...done" server) --- 417,425 ---- full-name)) ;; setup ping timer if necessary ! (unless rcirc-keepalive-timer ! =09(setq rcirc-keepalive-timer ! =09 (run-at-time 0 (/ rcirc-timeout-seconds 2) 'rcirc-keepalive))) (message "Connecting to %s...done" server) *************** *** 430,441 **** last ping." (if (rcirc-process-list) (mapc (lambda (process) ! (with-rcirc-process-buffer process ! =09=09(if (> (cadr (time-since rcirc-last-server-message-time)) ! =09=09 rcirc-keepalive-seconds) ! =09=09 (kill-process process) ! =09=09 (rcirc-send-string process (concat "PING " rcirc-server))))) (rcirc-process-list)) (cancel-timer rcirc-keepalive-timer) (setq rcirc-keepalive-timer nil))) --- 442,452 ---- last ping." (if (rcirc-process-list) (mapc (lambda (process) ! =09 (with-rcirc-process-buffer process ! =09=09(when (not rcirc-connecting) ! =09=09 (rcirc-send-string process (concat "PING " (rcirc-server-name process)))))) (rcirc-process-list)) + ;; no processes, clean up timer (cancel-timer rcirc-keepalive-timer) (setq rcirc-keepalive-timer nil))) *************** *** 472,483 **** =09=09 (format "%s: %s (%S)" =09=09=09 (process-name process) =09=09=09 sentinel ! =09=09=09 (process-status process)) t) =09 ;; remove the prompt from buffers =09 (let ((inhibit-read-only t)) =09 (delete-region rcirc-prompt-start-marker ! =09=09=09 rcirc-prompt-end-marker))))) ! (run-hook-with-args 'rcirc-sentinel-hooks process sentinel))) (defun rcirc-process-list () "Return a list of rcirc processes." --- 483,494 ---- =09=09 (format "%s: %s (%S)" =09=09=09 (process-name process) =09=09=09 sentinel ! =09=09=09 (process-status process)) (not rcirc-target)) =09 ;; remove the prompt from buffers =09 (let ((inhibit-read-only t)) =09 (delete-region rcirc-prompt-start-marker ! =09=09=09 rcirc-prompt-end-marker)))) ! (run-hook-with-args 'rcirc-sentinel-hooks process sentinel)))) (defun rcirc-process-list () "Return a list of rcirc processes." *************** *** 496,501 **** --- 507,513 ---- (defun rcirc-filter (process output) "Called when PROCESS receives OUTPUT." (rcirc-debug process output) + (rcirc-reschedule-timeout process) (with-rcirc-process-buffer process (setq rcirc-last-server-message-time (current-time)) (setq rcirc-process-output (concat rcirc-process-output output)) *************** *** 506,511 **** --- 518,536 ---- (split-string rcirc-process-output "[\n\r]" t)) (setq rcirc-process-output nil)))) + (defun rcirc-reschedule-timeout (process) + (with-rcirc-process-buffer process + (when (not rcirc-connecting) + (with-rcirc-process-buffer process + =09(when rcirc-timeout-timer (cancel-timer rcirc-timeout-timer)) + =09(setq rcirc-timeout-timer (run-at-time rcirc-timeout-seconds nil + =09=09=09=09=09 'rcirc-delete-process + =09=09=09=09=09 process)))))) + + (defun rcirc-delete-process (process) + (message "delete process %S" process) + (delete-process process)) + (defvar rcirc-trap-errors-flag t) (defun rcirc-process-server-response (process text) (if rcirc-trap-errors-flag *************** *** 557,571 **** (defun rcirc-buffer-process (&optional buffer) "Return the process associated with channel BUFFER. With no argument or nil as argument, use the current buffer." ! (get-buffer-process (if buffer ! =09=09=09 (with-current-buffer buffer ! =09=09=09 rcirc-server-buffer) ! =09=09=09rcirc-server-buffer))) (defun rcirc-server-name (process) "Return PROCESS server name, given by the 001 response." (with-rcirc-process-buffer process ! (or rcirc-server rcirc-default-server))) (defun rcirc-nick (process) "Return PROCESS nick." --- 582,597 ---- (defun rcirc-buffer-process (&optional buffer) "Return the process associated with channel BUFFER. With no argument or nil as argument, use the current buffer." ! (or (get-buffer-process (if buffer ! =09=09=09 (with-current-buffer buffer ! =09=09=09=09rcirc-server-buffer) ! =09=09=09 rcirc-server-buffer)) ! rcirc-process)) (defun rcirc-server-name (process) "Return PROCESS server name, given by the 001 response." (with-rcirc-process-buffer process ! (or rcirc-server-name rcirc-default-server))) (defun rcirc-nick (process) "Return PROCESS nick." *************** *** 790,796 **** =09 (setq prompt =09=09 (replace-regexp-in-string (car rep) (cdr rep) prompt))) =09 (list (cons "%n" (rcirc-buffer-nick)) ! =09=09 (cons "%s" (with-rcirc-server-buffer (or rcirc-server ""))) =09=09 (cons "%t" (or rcirc-target "")))) (save-excursion =09(delete-region rcirc-prompt-start-marker rcirc-prompt-end-marker) --- 816,822 ---- =09 (setq prompt =09=09 (replace-regexp-in-string (car rep) (cdr rep) prompt))) =09 (list (cons "%n" (rcirc-buffer-nick)) ! =09=09 (cons "%s" (with-rcirc-server-buffer rcirc-server-name)) =09=09 (cons "%t" (or rcirc-target "")))) (save-excursion =09(delete-region rcirc-prompt-start-marker rcirc-prompt-end-marker) *************** *** 1079,1087 **** =09=09 "%") =09=09 ((or (eq key ?n) (eq key ?N)) =09=09 ;; %n/%N -- nick ! =09=09 (let ((nick (concat (if (string=3D (with-rcirc-process-buffer ! =09=09=09=09=09=09=09process ! =09=09=09=09=09=09 rcirc-server) =09=09=09=09=09=09 sender) =09=09=09=09=09 "" =09=09=09=09=09 sender) --- 1105,1111 ---- =09=09 "%") =09=09 ((or (eq key ?n) (eq key ?N)) =09=09 ;; %n/%N -- nick ! =09=09 (let ((nick (concat (if (string=3D (rcirc-server-name process) =09=09=09=09=09=09 sender) =09=09=09=09=09 "" =09=09=09=09=09 sender) *************** *** 1302,1320 **** =09(rcirc-cmd-join channel process))))) =0C ;;; nick management (defun rcirc-user-nick (user) "Return the nick from USER. Remove any non-nick junk." (save-match-data ! (if (string-match "^[@%+]?\\([^! ]+\\)!?" (or user "")) =09(match-string 1 user) user))) - (defun rcirc-user-non-nick (user) - "Return the non-nick portion of USER." - (if (string-match "^[@+]?[^! ]+!?\\(.*\\)" (or user "")) - (match-string 1 user) - user)) - (defun rcirc-nick-channels (process nick) "Return list of channels for NICK." (with-rcirc-process-buffer process --- 1326,1340 ---- =09(rcirc-cmd-join channel process))))) =0C ;;; nick management + (defvar rcirc-nick-prefix-chars "~&@%+") (defun rcirc-user-nick (user) "Return the nick from USER. Remove any non-nick junk." (save-match-data ! (if (string-match (concat "^[" rcirc-nick-prefix-chars ! =09=09=09 "]?\\([^! ]+\\)!?") (or user "")) =09(match-string 1 user) user))) (defun rcirc-nick-channels (process nick) "Return list of channels for NICK." (with-rcirc-process-buffer process *************** *** 2009,2015 **** (rcirc-handler-generic process "001" sender args text) ;; set the real server name (with-rcirc-process-buffer process ! (setq rcirc-server sender) (setq rcirc-nick (car args)) (rcirc-update-prompt) (when rcirc-auto-authenticate-flag (rcirc-authenticate)) --- 2029,2037 ---- (rcirc-handler-generic process "001" sender args text) ;; set the real server name (with-rcirc-process-buffer process ! (setq rcirc-connecting nil) ! (rcirc-reschedule-timeout process) ! (setq rcirc-server-name sender) (setq rcirc-nick (car args)) (rcirc-update-prompt) (when rcirc-auto-authenticate-flag (rcirc-authenticate)) *************** *** 2419,2425 **** :group 'rcirc-faces) (defface rcirc-track-nick ! '((t (:inverse-video t))) "The face used in the mode-line when your nick is mentioned." :group 'rcirc-faces) --- 2441,2448 ---- :group 'rcirc-faces) (defface rcirc-track-nick ! '((((type tty)) (:inherit default)) ! (t (:inverse-video t))) "The face used in the mode-line when your nick is mentioned." :group 'rcirc-faces)