Skip to content

Instantly share code, notes, and snippets.

@ivan4th
Created March 20, 2013 15:14
Show Gist options
  • Save ivan4th/5205479 to your computer and use it in GitHub Desktop.
Save ivan4th/5205479 to your computer and use it in GitHub Desktop.
ido-based jabber-chat-with variant for jabber.el
(require 'ido)
(provide 'my-jabber-chat-with)
(defvar *my-jid-history* '())
(defun my-jabber-read-jid-completing (prompt)
(let* ((hist-items (remove-duplicates *my-jid-history* :test #'equal))
(choices
(mapcar #'symbol-name (jabber-concat-rosters))))
(setf choices (append hist-items
(sort (set-difference choices hist-items :test #'equal)
#'string<)))
(ido-completing-read prompt choices
nil nil nil '*my-jid-history*)))
(defun my-jabber-jid-connection (jid)
(or (find-if
#'(lambda (jc)
(cl-find jid (plist-get (fsm-get-state-data jc) :roster)
:key #'symbol-name
:test #'equal))
jabber-connections)
(error "cannot determine connection for %s" jid)))
(defun my-jabber-chat-with (jid &optional other-window)
"ido-based jabber-chat-with variant"
(interactive (list (my-jabber-read-jid-completing "Chat with: ")
current-prefix-arg))
(let* ((jc (my-jabber-jid-connection jid))
(buffer (jabber-chat-create-buffer jc jid)))
(if other-window
(switch-to-buffer-other-window buffer)
(switch-to-buffer buffer))))
(global-set-key "\C-x\C-j\C-j" 'my-jabber-chat-with)
(provide 'my-jabber-chat-with)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment