Add roster formatting options

Patches applied:

 * mange@freemail.hu--2004-laptop/emacs-jabber--hack--0--patch-3
   Add roster formatting option
This commit is contained in:
Magnus Henoch 2004-08-07 17:29:02 +00:00 committed by Kirill A. Korinskiy
parent 731b32c0a4
commit b660d78253
4 changed files with 89 additions and 44 deletions

View File

@ -190,7 +190,8 @@ CLOSURE-DATA should be 'initial if initial roster push, nil otherwise."
(setq highest-priority (or priority 0))
(put buddy 'connected (plist-get resource-plist 'connected))
(put buddy 'show (plist-get resource-plist 'show))
(put buddy 'status (plist-get resource-plist 'status)))
(put buddy 'status (plist-get resource-plist 'status))
(put buddy 'resource (car resource)))
;; if we have not found a connected resource yet, but this
;; disconnected resource has a status message, display it.

View File

@ -23,13 +23,39 @@
(require 'jabber-util)
(require 'jabber-alert)
(require 'jabber-keymap)
(require 'format-spec)
(defgroup jabber-roster nil "roster display options"
:group 'jabber)
(defcustom jabber-roster-line-spacing 0
"Number of empty lines between roster items"
:type 'integer
(defcustom jabber-roster-line-format " %c %n - %s (%S)\n"
"The format specification of the lines in the roster display.
These fields are available:
%c \"*\" if the contact is connected, or \" \" if not
%n Nickname of contact, or JID if no nickname
%j Bare JID of contact (without resource)
%r Highest-priority resource of contact
%s Availability of contact as string (\"Online\", \"Away\" etc)
%S Status string specified by contact"
:type 'string
:group 'jabber-roster)
(defcustom jabber-resource-line-format " %r - %s (%S), priority %p\n"
"The format specification of resource lines in the roster display.
These are displayed when `jabber-show-resources' permits it.
These fields are available:
%c \"*\" if the contact is connected, or \" \" if not
%n Nickname of contact, or JID if no nickname
%j Bare JID of contact (without resource)
%p Priority of this resource
%r Name of this resource
%s Availability of resource as string (\"Online\", \"Away\" etc)
%S Status string specified by resource"
:type 'string
:group 'jabber-roster)
(defcustom jabber-sort-order '("chat" "" "away" "dnd" "xa")
@ -149,20 +175,20 @@ bring up menus of actions.
(jabber-sort-roster)
(dolist (buddy *jabber-roster*)
(let ((buddy-str (concat (if (get buddy 'connected)
" * "
" ")
(if (> (length (get buddy 'name)) 0)
(get buddy 'name)
(symbol-name buddy))
(format " - %s" (or
(cdr (assoc (get buddy 'show) jabber-presence-strings))
(get buddy 'show)))
(if (get buddy 'status)
(format " (%s)" (jabber-fix-status (get buddy 'status))))
(if jabber-debug-roster
(format " --- [%S] ---" (symbol-plist buddy)))
)))
(let ((buddy-str (format-spec jabber-roster-line-format
(list
(cons ?c (if (get buddy 'connected) "*" " "))
(cons ?n (if (> (length (get buddy 'name)) 0)
(get buddy 'name)
(symbol-name buddy)))
(cons ?j (symbol-name buddy))
(cons ?r (or (get buddy 'resource) ""))
(cons ?s (or
(cdr (assoc (get buddy 'show) jabber-presence-strings))
(get buddy 'show)))
(cons ?S (if (get buddy 'status)
(jabber-fix-status (get buddy 'status))
""))))))
(add-text-properties 0
(length buddy-str)
(list
@ -185,23 +211,30 @@ bring up menus of actions.
;; 'keymap
;; map
;; buddy-str))
(insert buddy-str "\n"))
(insert buddy-str))
(when (or (eq jabber-show-resources 'always)
(and (eq jabber-show-resources 'sometimes)
(> (jabber-count-connected-resources buddy) 1)))
(dolist (resource (get buddy 'resources))
(when (plist-get (cdr resource) 'connected)
(let ((resource-str (concat " "
(if (> (length (car resource)) 0)
(car resource)
"empty")
(format " - %s" (or
(cdr (assoc (plist-get (cdr resource) 'show) jabber-presence-strings))
(plist-get (cdr resource) 'show)))
(if (plist-get (cdr resource) 'status)
(format " (%s)" (jabber-fix-status (plist-get (cdr resource) 'status))))
(format ", priority %d" (plist-get (cdr resource) 'priority)))))
(let ((resource-str (format-spec jabber-resource-line-format
(list
(cons ?c "*")
(cons ?n (if (> (length (get buddy 'name)) 0)
(get buddy 'name)
(symbol-name buddy)))
(cons ?j (symbol-name buddy))
(cons ?r (if (> (length (car resource)) 0)
(car resource)
"empty"))
(cons ?s (or
(cdr (assoc (plist-get (cdr resource) 'show) jabber-presence-strings))
(plist-get (cdr resource) 'show)))
(cons ?S (if (plist-get (cdr resource) 'status)
(jabber-fix-status (plist-get (cdr resource) 'status))
""))
(cons ?p (number-to-string (plist-get (cdr resource) 'priority)))))))
(add-text-properties 0
(length resource-str)
(list
@ -211,8 +244,7 @@ bring up menus of actions.
'jabber-jid
(format "%s/%s" (symbol-name buddy) (car resource)))
resource-str)
(insert resource-str "\n")))))
(insert (make-string jabber-roster-line-spacing ?\n)))
(insert resource-str))))))
(insert "__________________________________")
(goto-char (point-min))
(setq buffer-read-only t)

View File

@ -91,11 +91,6 @@
(defgroup jabber-debug nil "debugging options"
:group 'jabber)
(defcustom jabber-debug-roster nil
"show debugging information on roster"
:type 'boolean
:group 'jabber-debug)
(defcustom jabber-debug-log-xml nil
"log all XML i/o in *-jabber-xml-log-*"
:type 'boolean

View File

@ -536,7 +536,8 @@ priority during a session with @code{jabber-send-presence}.
@vindex jabber-sort-order
@vindex jabber-show-resources
@vindex jabber-roster-line-spacing
@vindex jabber-roster-line-format
@vindex jabber-resource-line-format
@code{jabber-sort-order} controls how roster items are sorted by
presence. It is a list containing strings corresponding to show
@ -546,9 +547,29 @@ status (@pxref{Presence}) or @code{nil}, which represents offline.
are shown in the roster buffer. The default is to show resources when
a contact has more than one connected resource.
@code{jabber-roster-line-spacing} specifies the number of blank lines
between each roster item. The default is zero, but you might want a
less compact look.
@code{jabber-roster-line-format} specifies how the entry for each
contact looks. It is a string where some characters are special if
preceded by a percent sign:
@table @code
@item %c
"*" if the contact is connected, or " " if not
@item %n
Nickname of contact, or JID if no nickname
@item %j
Bare JID of contact (without resource)
@item %r
Highest-priority resource of contact
@item %s
Availability of contact as string ("Online", "Away" etc)
@item %S
Status string specified by contact
@end table
@code{jabber-resource-line-format} is nearly identical, except that
the values correspond to the values of the resource in question, and
that the @code{%p} escape is available, which inserts the priority of
the resource.
@node Customizing alerts, Debug options, Customizing the roster buffer, Customization
@section Customizing alerts
@ -703,15 +724,11 @@ The info alert hooks take an extra argument, as could be expected.
@node Debug options, , Customizing alerts, Customization
@section Debug options
@vindex jabber-debug-roster
@vindex jabber-debug-log-xml
These settings provide a lot of information which is usually not very
interesting, but can be useful for debugging various things.
@code{jabber-debug-roster} toggles debug output in the roster. This
means that you can see the properties of each contact.
@code{jabber-debug-log-xml} activates XML logging. All XML stanzas
sent and received are logged in the buffer @code{*-jabber-xml-log-*}
in list format. @xref{XML representation}.