MapaDoSite ModificaçõesRecentes Notícias SeçãoElisp HowTo

JabberEl

jabber.el aims to be a minimal Jabber client.

Screenshots

Roster:

JabberElScreenshotRosterActionMenu

A chat can also be started using the keyboard:

 M-x jabber-chat-with

If you want to, you can configure special-display-regexps to open chats in their own frame:

 (setq 
  special-display-regexps 
  '(("jabber-chat" 
      (width . 80)
     (scroll-bar-width . 16)
     (height . 15)
     (tool-bar-lines . 0)
     (menu-bar-lines 0)
     (font . "-GURSoutline-Courier New-normal-r-normal-normal-11-82-96-96-c-70-iso8859-1")
     (left . 80))))

Looking like this:

JabberElScreenshotRosterAndChatWindow

Customizations

Nifty keybindings

I have this function in my .emacs that I run after I have started emacs. It logs on and defines some nifty keybindings:

(defun jabber ()
  (interactive)
  (require 'jabber)
  (define-key jabber-chat-mode-map [escape] 
    'my-jabber-chat-delete-or-bury)

  (define-key mode-specific-map "jr"
    (lambda () 
      (interactive) 
      (switch-to-buffer "*-jabber-*")))
  
  (define-key mode-specific-map "jc"
    '(lambda () 
       (interactive) 
       (call-interactively 'jabber-connect)))

  (define-key mode-specific-map "jd"
    '(lambda () 
       (interactive) 
       (call-interactively 'jabber-disconnect)))

  (define-key mode-specific-map "jj"
    '(lambda () 
       (interactive) 
       (call-interactively 'jabber-chat-with)))

  (define-key mode-specific-map "ja"
    '(lambda () 
       (interactive) 
       (jabber-send-presence "away" "" 10)))
  
  (define-key mode-specific-map "jo"
    '(lambda () 
       (interactive) 
       (jabber-send-presence "" "" 10)))

  (define-key mode-specific-map "jx"
    '(lambda () 
       (interactive) 
       (jabber-send-presence "xa" "" 10)))
  
  (jabber-connect))


Here is the function my-jabber-chat-delete-or-bury used above:

(defun my-jabber-chat-delete-or-bury ()
  (interactive)
  (if (eq 'jabber-chat-mode major-mode)
      (condition-case e 
          (delete-frame)
        (error 
         (if (string= "Attempt to delete the sole visible or iconified frame" 
                      (cadr e))
            (bury-buffer))))))

Some useful settings

Control message history (which stored in ~/.emacs-jabber dir):

(setq
  jabber-history-enabled t
  jabber-use-global-history nil
  jabber-backlog-number 40
  jabber-backlog-days 30
 )

Don’t disturb me if someone chage presence status (usually remote clients make this automatically):

(set  jabber-alert-presence-message-function (lambda (who oldstatus newstatus statustext) nil))

The above didn’t work for me, and has unbalenced parenthesis in any case… M-x customise-variable jabber-alert-presence-hooks should give you the defcustom offered by the package (jabber-presence-echo is the one)

Redefine standard binding for sending message form RET to C-RET:

(define-key jabber-chat-mode-map (kbd "RET") 'newline)
(define-key jabber-chat-mode-map [C-return] 'jabber-chat-buffer-send)

Change prompt format:

(setq my-chat-prompt "[%t] %n>\n")
(when (featurep 'jabber)
  (setq
   jabber-chat-foreign-prompt-format my-chat-prompt
   jabber-chat-local-prompt-format my-chat-prompt
   jabber-groupchat-prompt-format my-chat-prompt
   jabber-muc-private-foreign-prompt-format "[%t] %g/%n>\n"
   )
  )

Automatically highlight URLs

Here’s a hook which will highlight URLs, and bind C-c RET to open the URL using browse-url:

    (add-hook 'jabber-chat-mode-hook 'goto-address)

Show your status in the header

This snippet will show your buddy’s resource in the HeaderLine, and also show your status if you’re not "online":

    (setq jabber-chat-header-line-format
          '(" " (:eval (jabber-jid-displayname jabber-chatting-with))
    	" " (:eval (jabber-jid-resource jabber-chatting-with)) "\t";
    	(:eval (let ((buddy (jabber-jid-symbol jabber-chatting-with)))
    		 (propertize
    		  (or
    		   (cdr (assoc (get buddy 'show) jabber-presence-strings))
    		   (get buddy 'show))
    		  'face
    		  (or (cdr (assoc (get buddy 'show) jabber-presence-faces))
    		      'jabber-roster-user-online))))
    	"\t" (:eval (get (jabber-jid-symbol jabber-chatting-with) 'status))
    	(:eval (unless (equal "" *jabber-current-show*)
    		 (concat "\t You're " *jabber-current-show*
    			 " (" *jabber-current-status* ")")))))

AutoSmiley mode

Get smileys automatically in jabber chat windows:

    (require 'autosmiley)
    (add-hook 'jabber-chat-mode-hook 'autosmiley-mode)

(Needs Lisp:autosmiley.el (AutoSmiley)

Switching accounts

(this hack is obsoleted by multiple account support in jabber-el cvs version)

My main Jabber server and its transport goes down from time to time so I also have a secondary server that I can switch to. I got tired setting the server and usernames manually so I wrote this:

(defun my-jabber-switch-account ()
  (interactive)
  (require 'jabber)
  (let* ((accounts
          '(("jabbernet" ("jabbernet.dk" nil "USERNAME"))
            ("chalmers" ("jabber.cd.chalmers.se" nil "USERNAME"))
            ("80" ("jabber80.com" 80 "USERNAME"))))
         (acc (cadr (assoc (completing-read "Account: " accounts nil t) accounts)))
         (server (nth 0 acc))
         (user (nth 2 acc))
         (port (nth 1 acc)))
    (when server
      (message "Switching to %s..." server)
      (jabber-disconnect)
      (setq jabber-server server
            jabber-port port
            jabber-username user)
      (jabber-connect))))

Announcing about new message

Using xosd

This code will alert about incoming message through xosd. Obviously, it requires xosd (package xosd-bin on debian-like distros)

(setq jabber-xosd-display-time 5)

(defun jabber-xosd-display-message (message)
  "Displays MESSAGE through the xosd"
  (let ((process-connection-type nil))
    (start-process "jabber-xosd" nil "osd_cat" "-p" "bottom" "-A" "center" "-f" "-*-courier-*-*-*-*-30" "-d" (number-to-string jabber-xosd-display-time))
    (process-send-string "jabber-xosd" message)
    (process-send-eof "jabber-xosd")))

(defun jabber-message-xosd (from buffer text propsed-alert)
  (jabber-xosd-display-message "New message."))

(add-to-list 'jabber-alert-message-hooks 'jabber-message-xosd)

; Try this line rather than the add-to-list above 
; if you experience problem on init
;(add-hook 'jabber-alert-message-hooks 'jabber-message-xosd) 

Using notification-daemon

This code will issue incoming message alerts using the notification daemon on linux systems. On Debian, the libnotify1 and libnotify-bin packages are required.

(defvar libnotify-program "/usr/bin/notify-send")

(defun notify-send (title message)
  (start-process "notify" " notify"
		 libnotify-program "--expire-time=4000" title message))

(defun libnotify-jabber-notify (from buf text proposed-alert)
  "(jabber.el hook) Notify of new Jabber chat messages via libnotify"
  (when (or jabber-message-alert-same-buffer
            (not (memq (selected-window) (get-buffer-window-list buf))))
    (if (jabber-muc-sender-p from)
        (notify-send (format "(PM) %s"
                       (jabber-jid-displayname (jabber-jid-user from)))
               (format "%s: %s" (jabber-jid-resource from) text)))
      (notify-send (format "%s" (jabber-jid-displayname from))
             text)))

(add-hook 'jabber-alert-message-hooks 'libnotify-jabber-notify)

Using growl

If you would like to use Growl, see http://philgroce.com/static/growl-with-emacs-1. It should be easy to adapt this to use ToDoChiKu for a more general solution.

Preventing messages in the echo area from clobbering the mini buffer

I found that redefining define-jabber-alert as follows prevents messages arriving while I am using the mini buffer from stealing my focus.

;; Message alert hooks
(define-jabber-alert echo "Show a message in the echo area"
  (lambda (msg)
    (unless (minibuffer-prompt)
      (message "%s" msg))))

Viewing histories

To open a new chat-like buffer in view mode that visits a contact’s history file:

(defun jabber-visit-history (jid)
  "Visit jabber history with JID in a new buffer.

Performs well only for small files.  Expect to wait a few seconds
for large histories.  Adapted from `jabber-chat-create-buffer'."
  (interactive (list (jabber-read-jid-completing "JID: ")))
  (let ((buffer (generate-new-buffer (format "*-jabber-history-%s-*"
                                             (jabber-jid-displayname jid)))))
    (switch-to-buffer buffer)
    (make-local-variable 'jabber-chat-ewoc)
    (setq jabber-chat-ewoc (ewoc-create #'jabber-chat-pp))
    (mapc 'jabber-chat-insert-backlog-entry
          (nreverse (jabber-history-query nil nil t t "."
                                          (jabber-history-filename jid))))
    (view-mode)))

Some ideas for improvement:

   1 Make it work for global history.
   1 Improve performance.
   1 Add searching capabilities (e.g., keyword).

Connecting to Google talk

There is an article related about jabber.el’s issues with Google Talk for connecting and chatting: Read GoogleTalk article.

Success-stories :)

I’m using this as my primary jabber client now and have no need for the extra jabber client (I primarily used JAJC on Windows and GAIM on Linux before) and it works really good. The nice thing is of course that you can hack it, customize key bindings etc, something that is much harder to do in most other clients. Among other things I use it as a "agent" to do stuff remotely. Read more about this in the forum on the SourceForge? page. – MathiasDahl

I am also using it for two days now. It is a good substitute to the BitlBee/ERC couple. I use it when I do not want to shoot a whole IRC session. Works pretty good. – XavierMaillard

I am using it now, works pretty well under EmacsForWindows with cygwin (for the SSL part). I have to find a way thought to have under linux to show me an icon in my status bar when i get messages. (i guess some kind of python + dbus client server for it). Good work. – chmouel

A note on the above - dbus support is in GNU Emacs in CVS now --GeoffreyTeale

Jabber.el is my XMPP client for last year. Before I used gaim, tkabber, but I not found happiness in it. Jabber.el makes me happy… – Zert

With emacs-jabber-0.7.92 or emacs-jabber-0.8.0 put

;; For debug purpose.
;; (setq jabber-debug-log-xml t)
;; (setq jabber-debug-keep-process-buffers t)

(add-to-list 'load-path "/home/user/usr/share/emacs/site-lisp/emacs-jabber-0.7.92")
(require 'jabber)

(setq jabber-account-list '(
                            ("your-name@gmail.com"
                            ;;   (:password . nil) or (:password . "your-pass")
                              (:network-server . "talk.google.com")
                              (:port . 443)
                              (:connection-type . ssl))
                            ))

in your .emacs in order to connect to gtalk. And press “C-x C-j C-c”!

I have issue with jabber on Windows - 100% CPU load or roster not appear, with openssl it not work in all case. I post to list 100% cpu load with GNUTLS on Windows and finally found solution - Emacs 23.1 + gnutls-cli form Cygwin! – gavenkoa

Setting urgency hint for Emacs frame (only for X Window System).

Function x-urgency-hint allows you to enable or disable urgency hint for the frame FRAME. Set ARG to non-nil to enable urgency hint, nil to disable.

You may, for example, enable urgency hint when the activity list is updated and disable it when the list becomes empty. In this case your WM will start blinking by taskbar button or by window’s header or perform other actions to attract the user’s attention (the appearance depends on WM). Tested with emacs-jabber v0.7.91 and IceWM? 1.2.35.

(defun x-urgency-hint (frame arg &optional source)
  (let* ((wm-hints (append (x-window-property 
			    "WM_HINTS" frame "WM_HINTS" source nil t) nil))
	 (flags (car wm-hints)))
    (setcar wm-hints
	    (if arg
		(logior flags #x00000100)
	      (logand flags #x1ffffeff)))
    (x-change-window-property "WM_HINTS" wm-hints frame "WM_HINTS" 32 t)))

;; usage example
(defvar jabber-activity-jids-count 0)

(defun jabber-urgency-hint ()
  (let ((count (length jabber-activity-jids)))
    (unless (= jabber-activity-jids-count count)
      (if (zerop count)
	  (x-urgency-hint (selected-frame) nil)
	(x-urgency-hint (selected-frame) t))
      (setq jabber-activity-jids-count count))))

(add-hook 'jabber-activity-update-hook 'jabber-urgency-hint)

--EvgenyZubok?

Page discussion

Are there any catches in using JabberEl to connect to two different jabber services at the same time? (i.e. google talk and an ordinary jabber…) How does one go about that? --MartinJ?

This is currently only possible in the CVS version. You can set up all your accounts in jabber-account-list (e.g. by using Customize), or just connect them manually with M-x jabber-connect-one. (C-x C-j C-c will connect to all accounts in jabber-account-list, or if that is empty, ask you for an account to connect to) --MagnusHenoch

Note that this was recently released as 0.8.0. See http://emacs-jabber.sourceforge.net/list-of-releases.html for more info. --JuneTateGans?

I had a problem recently with the 0.8.0 version. The file jabber-muc-nick-completion.el defines a function modify-alist, which, according to grep, is used only in that file. However, I had loaded apel, which also defines modify-alist, and not in a compatible way. Therefore, I simply changed the name of jabber’s version to jabber-modify-alist. Maybe this is already done in CVS, but I thought I’d mention it in case it’s not. --JosephGay

I had to use @googlemail.com rather than @gmail.com to get gtalk to work.

I finally got emacs-jabber up and running on my Debian Lenny machine. It refused to work for a really long time, it always stopped with a ssl error, saying that the server name does not match the certificate. Installation of the starttls package, which was not installed before, fixed the problem for me. I hope that this hint can save someone else from some headache. Update: It refuses to work again, no apparent reason.

I seem to have problems if I, by reflex, close the *-jabber-* buffer. That seems to just totally hose me. Even if I do a jabber-disconnect, jabber-connect, although the buffer comes back and says I’m online, I can’t see anyone and can’t even do a version query on myself. --PaulGoins

Painfully, jabber.el doesn’t support PGP, meaning that messages can’t be encrypted between receiving clients. If you consider that a privacy concern, consider using Gajim, Psi, or a similar Jabber client.

Is there a plan to save history for groupchat too? --DanielDehennin

Is it possible to dynamically turn on and off the alerts for specific chats? --Chet

Recently I found the emacs jabber client no longer working properly. it is version 8.0. the problem is no contact shown in the buffer *-jabber-roster-* after login, but jabber says me online. the jabber seems never go ahead when it shows “Authentication succeeded” in the minibuffer. but previously it would continue to show “….. is online” messages and load all contacts in the roster buffer. --Cesc

Are you connecting to Google Talk by any chance? Those symptoms sounds very much like a problem that’s solved in the recent 0.8.90 release. (Google Talk recently started using namespace prefixes, which jabber.el was rather ill-prepared for.) --MagnusHenoch

Yes, it is Google Talk. And I have checked out the git version for namespace prefixes after I saw the information in the mail list. It works now. --Cesc


CategoryChatClient