Add 2012 to FSF copyright years for Emacs files
[bpt/emacs.git] / lisp / net / rcirc.el
index 71b3fe0..771c983 100644 (file)
@@ -1,6 +1,6 @@
 ;;; rcirc.el --- default, simple IRC client.
 
-;; Copyright (C) 2005-2011  Free Software Foundation, Inc.
+;; Copyright (C) 2005-2012  Free Software Foundation, Inc.
 
 ;; Author: Ryan Yeske <rcyeske@gmail.com>
 ;; Maintainers: Ryan Yeske <rcyeske@gmail.com>,
@@ -659,7 +659,7 @@ Functions are called with PROCESS and SENTINEL arguments.")
 (defun rcirc-disconnect-buffer (&optional buffer)
   (with-current-buffer (or buffer (current-buffer))
     ;; set rcirc-target to nil for each channel so cleanup
-    ;; doesnt happen when we reconnect
+    ;; doesn't happen when we reconnect
     (setq rcirc-target nil)
     (setq mode-line-process ":disconnected")))
 
@@ -964,7 +964,13 @@ This number is independent of the number of lines in the buffer.")
   (setq mode-line-process nil)
 
   (set (make-local-variable 'rcirc-input-ring)
-       (make-ring rcirc-input-ring-size))
+       ;; If rcirc-input-ring is already a ring with desired size do
+       ;; not re-initialize.
+       (if (and (ring-p rcirc-input-ring)
+               (= (ring-size rcirc-input-ring)
+                  rcirc-input-ring-size))
+          rcirc-input-ring
+        (make-ring rcirc-input-ring-size)))
   (set (make-local-variable 'rcirc-server-buffer) (process-buffer process))
   (set (make-local-variable 'rcirc-target) target)
   (set (make-local-variable 'rcirc-topic) nil)
@@ -973,6 +979,7 @@ This number is independent of the number of lines in the buffer.")
   (set (make-local-variable 'rcirc-recent-quit-alist) nil)
   (set (make-local-variable 'rcirc-current-line) 0)
 
+  (use-hard-newlines t)
   (set (make-local-variable 'rcirc-short-buffer-name) nil)
   (set (make-local-variable 'rcirc-urls) nil)
 
@@ -1556,18 +1563,16 @@ record activity."
 
          ;; keep window on bottom line if it was already there
          (when rcirc-scroll-show-maximum-output
-           (walk-windows (lambda (w)
-                           (when (eq (window-buffer w) (current-buffer))
-                             (with-current-buffer (window-buffer w)
-                               (when (eq major-mode 'rcirc-mode)
-                                 (with-selected-window w
-                                   (when (<= (- (window-height)
-                                                (count-screen-lines (window-point)
-                                                                    (window-start))
-                                                1)
-                                             0)
-                                     (recenter -1)))))))
-                                 nil t))
+           (let ((window (get-buffer-window)))
+             (when window
+               (with-selected-window window
+                 (when (eq major-mode 'rcirc-mode)
+                   (when (<= (- (window-height)
+                                (count-screen-lines (window-point)
+                                                    (window-start))
+                                1)
+                             0)
+                     (recenter -1)))))))
 
          ;; flush undo (can we do something smarter here?)
          (buffer-disable-undo)
@@ -2137,6 +2142,16 @@ CHANNELS is a comma- or space-separated string of channel names."
       (dolist (b buffers) ;; order the new channel buffers in the buffer list
         (switch-to-buffer b)))))
 
+(defun-rcirc-command invite (nick-channel)
+  "Invite NICK to CHANNEL."
+  (interactive (list
+               (concat
+                (completing-read "Invite nick: "
+                                 (with-rcirc-server-buffer rcirc-nick-table))
+                " "
+                (read-string "Channel: "))))
+  (rcirc-send-string process (concat "INVITE " nick-channel)))
+
 ;; TODO: /part #channel reason, or consider removing #channel altogether
 (defun-rcirc-command part (channel)
   "Part CHANNEL."