emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r100517: * lisp/net/rcirc.el (rcirc-s


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r100517: * lisp/net/rcirc.el (rcirc-sort-nicknames): New custom.
Date: Thu, 03 Jun 2010 11:07:49 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100517
author: Deniz Dogan <address@hidden>
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Thu 2010-06-03 11:07:49 -0400
message:
  * lisp/net/rcirc.el (rcirc-sort-nicknames): New custom.
  (rcirc-nickname<, rcirc-sort-nicknames-join): New funs.
  (rcirc-handler-366): Use them.
modified:
  lisp/ChangeLog
  lisp/net/rcirc.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-06-03 01:48:10 +0000
+++ b/lisp/ChangeLog    2010-06-03 15:07:49 +0000
@@ -1,3 +1,9 @@
+2010-06-03  Deniz Dogan  <address@hidden>
+
+       * net/rcirc.el (rcirc-sort-nicknames): New custom.
+       (rcirc-nickname<, rcirc-sort-nicknames-join): New funs.
+       (rcirc-handler-366): Use them.
+
 2010-06-03  Stefan Monnier  <address@hidden>
 
        Split smie-indent-calculate into more manageable chunks.

=== modified file 'lisp/net/rcirc.el'
--- a/lisp/net/rcirc.el 2010-05-25 03:38:41 +0000
+++ b/lisp/net/rcirc.el 2010-06-03 15:07:49 +0000
@@ -281,6 +281,11 @@
   :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
@@ -1650,6 +1655,38 @@
            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.")
@@ -2554,7 +2591,10 @@
          (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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]