X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/f2ec0e5e493ee518f6fa422cb4e946613d8f3fa0..c62bf05a3723508124eda3bc4e208b112520eaad:/lisp/net/rcirc.el diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index e4aaef9498..ba2d3f130c 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -1,6 +1,7 @@ ;;; rcirc.el --- default, simple IRC client. -;; Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +;; Free Software Foundation, Inc. ;; Author: Ryan Yeske ;; URL: http://www.nongnu.org/rcirc @@ -85,6 +86,10 @@ used. VALUE must be a string. If absent, `rcirc-default-full-name' is used. +`:pass' + +VALUE must be a string. + `:channels' VALUE must be a list of strings describing which channels to join @@ -95,6 +100,7 @@ connected to automatically." (:port integer) (:user-name string) (:full-name string) + (:pass string) (:channels (repeat string))))) :group 'rcirc) @@ -108,15 +114,15 @@ connected to automatically." :type 'string :group 'rcirc) -(defcustom rcirc-default-user-name (user-login-name) +(defcustom rcirc-default-user-name "user" "Your user name sent to the server when connecting." + :version "24.1" ; changed default :type 'string :group 'rcirc) -(defcustom rcirc-default-full-name (if (string= (user-full-name) "") - rcirc-default-user-name - (user-full-name)) +(defcustom rcirc-default-full-name "unknown" "The full name sent to the server when connecting." + :version "24.1" ; changed default :type 'string :group 'rcirc) @@ -275,6 +281,11 @@ Called with 5 arguments, PROCESS, SENDER, RESPONSE, TARGET and TEXT." :type 'hook :group 'rcirc) +(defcustom rcirc-sort-nicknames nil + "If non-nil, sorts nickname listings." + :type 'boolean + :group 'rcirc) + (defcustom rcirc-always-use-server-buffer-flag nil "Non-nil means messages without a channel target will go to the server buffer." :type 'boolean @@ -369,6 +380,9 @@ and the cdr part is used for encoding." (defvar rcirc-nick-name-history nil "History variable for \\[rcirc] call.") +(defvar rcirc-user-name-history nil + "History variable for \\[rcirc] call.") + ;;;###autoload (defun rcirc (arg) "Connect to all servers in `rcirc-server-alist'. @@ -393,6 +407,12 @@ If ARG is non-nil, instead prompt for connection parameters." (or (plist-get server-plist :nick) rcirc-default-nick) 'rcirc-nick-name-history)) + (user-name (read-string "IRC Username: " + (or (plist-get server-plist :user-name) + rcirc-default-user-name) + 'rcirc-user-name-history)) + (pass (read-passwd "IRC Password: " nil + (plist-get server-plist :pass))) (channels (split-string (read-string "IRC Channels: " (mapconcat 'identity @@ -400,7 +420,7 @@ If ARG is non-nil, instead prompt for connection parameters." :channels) " ")) "[, ]+" t))) - (rcirc-connect server port nick rcirc-default-user-name + (rcirc-connect server port nick user-name pass rcirc-default-full-name channels)) ;; connect to servers in `rcirc-server-alist' @@ -411,6 +431,7 @@ If ARG is non-nil, instead prompt for connection parameters." (port (or (plist-get (cdr c) :port) rcirc-default-port)) (user-name (or (plist-get (cdr c) :user-name) rcirc-default-user-name)) + (pass (plist-get (cdr c) :pass)) (full-name (or (plist-get (cdr c) :full-name) rcirc-default-full-name)) (channels (plist-get (cdr c) :channels))) @@ -421,7 +442,7 @@ If ARG is non-nil, instead prompt for connection parameters." (setq connected p))) (if (not connected) (condition-case e - (rcirc-connect server port nick user-name + (rcirc-connect server port nick user-name pass full-name channels) (quit (message "Quit connecting to %s" server))) (with-current-buffer (process-buffer connected) @@ -453,8 +474,8 @@ If ARG is non-nil, instead prompt for connection parameters." (defvar rcirc-process nil) ;;;###autoload -(defun rcirc-connect (server &optional port nick user-name full-name - startup-channels) +(defun rcirc-connect (server &optional port nick user-name pass + full-name startup-channels) (save-excursion (message "Connecting to %s..." server) (let* ((inhibit-eol-conversion) @@ -503,10 +524,11 @@ If ARG is non-nil, instead prompt for connection parameters." (add-hook 'auto-save-hook 'rcirc-log-write) ;; identify + (when pass + (rcirc-send-string process (concat "PASS " pass))) (rcirc-send-string process (concat "NICK " nick)) (rcirc-send-string process (concat "USER " user-name - " hostname servername :" - full-name)) + " 0 * :" full-name)) ;; setup ping timer if necessary (unless rcirc-keepalive-timer @@ -1067,8 +1089,8 @@ Create the buffer if it doesn't exist." (goto-char (point-max)) (when (not (equal 0 (- (point) rcirc-prompt-end-marker))) ;; delete a trailing newline - (when (eq (point) (point-at-bol)) - (delete-backward-char 1)) + (when (bolp) + (delete-char -1)) (let ((input (buffer-substring-no-properties rcirc-prompt-end-marker (point)))) (dolist (line (split-string input "\n")) @@ -1633,6 +1655,38 @@ if NICK is also on `rcirc-ignore-list-automatic'." rcirc-ignore-list (delete nick rcirc-ignore-list)))) +(defun rcirc-nickname< (s1 s2) + "Compares two IRC nicknames. Operator nicknames (@) are +considered less than voiced nicknames (+). Any other nicknames +are greater than voiced nicknames. + +Returns t if S1 is less than S2, otherwise nil. + +The comparison is case-insensitive." + (setq s1 (downcase s1) + s2 (downcase s2)) + (let* ((s1-op (eq ?@ (string-to-char s1))) + (s2-op (eq ?@ (string-to-char s2)))) + (if s1-op + (if s2-op + (string< (substring s1 1) (substring s2 1)) + t) + (if s2-op + nil + (string< s1 s2))))) + +(defun rcirc-sort-nicknames-join (input sep) + "Takes a string of nicknames and returns the string with the +nicknames sorted. + +INPUT is a string containing nicknames separated by SEP. + +This function is non-destructive, sorting a copy of the input." + (let ((parts (split-string input sep t)) + copy) + (setq copy (sort parts 'rcirc-nickname<)) + (mapconcat 'identity copy sep))) + ;;; activity tracking (defvar rcirc-track-minor-mode-map (make-sparse-keymap) "Keymap for rcirc track minor mode.") @@ -2537,7 +2591,10 @@ keywords when no KEYWORD is given." (buffer (rcirc-get-temp-buffer-create process channel))) (with-current-buffer buffer (rcirc-print process sender "NAMES" channel - (buffer-substring (point-min) (point-max)))) + (let ((content (buffer-substring (point-min) (point-max)))) + (if rcirc-sort-nicknames + (rcirc-sort-nicknames-join content " ") + content)))) (kill-buffer buffer))) (defun rcirc-handler-433 (process sender args text)