unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Ryan Yeske" <rcyeske@gmail.com>
To: emacs-devel@gnu.org
Subject: rcirc update
Date: Wed, 7 Mar 2007 15:14:00 -0800	[thread overview]
Message-ID: <8fd0ace10703071514s392c2657h5f24aabc892e59cc@mail.gmail.com> (raw)

2007-03-02  Ryan Yeske  <rcyeske@gmail.com>

	* net/rcirc.el (rcirc-timeout-seconds): New variable.
	(rcirc-keepalive-seconds): Remove variable.
	(rcirc-server-name, rcirc-timeout-timer, rcirc-connecting)
	(rcirc-process): New variables.
	(rcirc-connect): Initalize new variables.
	(rcirc-keepalive): Don't send keepalive pings before connection is
	completed.
	(rcirc-sentinel): Do mark all channels with activity when
	connection is dropped.  Run hook with process buffer local.
	(rcirc-reschedule-timeout, rcirc-delete-process): New functions.
	(rcirc-buffer-process): Return value of rcirc-process if
	rcirc-server-buffer is nil.
	(rcirc-server-name): Return the reported server name.
	(rcirc-update-prompt): Simplify computation of the server name.
	(rcirc-format-response-string): Likewise.
	(rcirc-handler-001): Mark server as connected, record the reported
	server name, and schedule a timeout.
	(rcirc-track-nick): Add a spec for the tty class.
	(rcirc-user-non-nick): Remove function.
	(rcirc-nick-prefix-chars): Add variable.
	(rcirc-user-nick): Use above variable.


Index: rcirc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/net/rcirc.el,v
retrieving revision 1.30
diff -c -r1.30 rcirc.el
*** rcirc.el	24 Nov 2006 10:33:22 -0000	1.30
--- rcirc.el	2 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))
  \f
--- 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))
  \f
***************
*** 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)		; server provided by server
! (defvar rcirc-server-name nil)		; 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 ****
  	   (user-name (or user-name rcirc-default-user-name))
  	   (full-name (or full-name rcirc-default-user-full-name))
  	   (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 ----
  	   (user-name (or user-name rcirc-default-user-name))
  	   (full-name (or full-name rcirc-default-user-full-name))
  	   (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)	; 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
! 	(unless rcirc-keepalive-timer
! 	  (setq rcirc-keepalive-timer
! 		(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
! 	(setq rcirc-keepalive-timer
! 	      (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
! 		(if (> (cadr (time-since rcirc-last-server-message-time))
! 		       rcirc-keepalive-seconds)
! 		    (kill-process process)
! 		  (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)
! 	      (with-rcirc-process-buffer process
! 		(when (not rcirc-connecting)
! 		  (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 ****
  		       (format "%s: %s (%S)"
  			       (process-name process)
  			       sentinel
! 			       (process-status process)) t)
  	  ;; remove the prompt from buffers
  	  (let ((inhibit-read-only t))
  	    (delete-region rcirc-prompt-start-marker
! 			   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 ----
  		       (format "%s: %s (%S)"
  			       (process-name process)
  			       sentinel
! 			       (process-status process)) (not rcirc-target))
  	  ;; remove the prompt from buffers
  	  (let ((inhibit-read-only t))
  	    (delete-region rcirc-prompt-start-marker
! 			   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
+ 	(when rcirc-timeout-timer (cancel-timer rcirc-timeout-timer))
+ 	(setq rcirc-timeout-timer (run-at-time rcirc-timeout-seconds nil
+ 					       'rcirc-delete-process
+ 					       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
! 			  (with-current-buffer buffer
! 			    rcirc-server-buffer)
! 			rcirc-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
! 			      (with-current-buffer buffer
! 				rcirc-server-buffer)
! 			    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 ****
  	      (setq prompt
  		    (replace-regexp-in-string (car rep) (cdr rep) prompt)))
  	    (list (cons "%n" (rcirc-buffer-nick))
! 		  (cons "%s" (with-rcirc-server-buffer (or rcirc-server "")))
  		  (cons "%t" (or rcirc-target ""))))
        (save-excursion
  	(delete-region rcirc-prompt-start-marker rcirc-prompt-end-marker)
--- 816,822 ----
  	      (setq prompt
  		    (replace-regexp-in-string (car rep) (cdr rep) prompt)))
  	    (list (cons "%n" (rcirc-buffer-nick))
! 		  (cons "%s" (with-rcirc-server-buffer rcirc-server-name))
  		  (cons "%t" (or rcirc-target ""))))
        (save-excursion
  	(delete-region rcirc-prompt-start-marker rcirc-prompt-end-marker)
***************
*** 1079,1087 ****
  		   "%")
  		  ((or (eq key ?n) (eq key ?N))
  		   ;; %n/%N -- nick
! 		   (let ((nick (concat (if (string= (with-rcirc-process-buffer
! 							process
! 						      rcirc-server)
  						    sender)
  					   ""
  					 sender)
--- 1105,1111 ----
  		   "%")
  		  ((or (eq key ?n) (eq key ?N))
  		   ;; %n/%N -- nick
! 		   (let ((nick (concat (if (string= (rcirc-server-name process)
  						    sender)
  					   ""
  					 sender)
***************
*** 1302,1320 ****
  	(rcirc-cmd-join channel process)))))
  \f
  ;;; 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 ""))
  	(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 ----
  	(rcirc-cmd-join channel process)))))
  \f
  ;;; 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
! 			      "]?\\([^! ]+\\)!?") (or user ""))
  	(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)

             reply	other threads:[~2007-03-07 23:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-07 23:14 Ryan Yeske [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-10-02  0:11 rcirc update Ryan Yeske
2009-10-15  6:50 ` Glenn Morris
2007-10-22 18:04 Ryan Yeske
2007-10-29  1:25 ` Glenn Morris
2007-10-31  5:21   ` Ryan Yeske
2007-11-01  4:04     ` Glenn Morris
2007-06-09  5:21 Ryan Yeske
2007-06-13 20:30 ` Chong Yidong
2007-06-13 21:17   ` Stefan Monnier
2007-06-16  3:02     ` Ryan Yeske
2007-06-16  3:58       ` Miles Bader
2007-06-16  5:08         ` Ryan Yeske
2007-06-16 21:26           ` Miles Bader
2007-06-17 23:33             ` Ryan Yeske
2007-06-20 19:53               ` Ryan Yeske
2007-06-28  9:51                 ` Ryan Yeske
2007-06-29  0:54                   ` Miles Bader
2007-06-29  7:34                   ` Thien-Thi Nguyen
2006-09-02  0:02 Ryan Yeske
2006-08-20 17:50 Ryan Yeske
2006-08-21  5:36 ` Miles Bader

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8fd0ace10703071514s392c2657h5f24aabc892e59cc@mail.gmail.com \
    --to=rcyeske@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).