A friend of mine showed me that he was connected to jabber in emacs for gtalk. So I gave it a try. I read some blog posts and tried it. I clearly reuse the main parts of those and add my glue on it regarding credentials.
In this post, I will concentrate on:
- how to install jabber in emacs
- and not be bother by the credentials at each connection.
Problem
I do not want to be asked for my password each time I'm connecting.
Solution
I reuse a mechanism I was introduced to with org2blog.
Note For those that are concerned by security, I hear you. I strongly believe in separating concerns and security is not the issue at hand so I do not focus on it at all.
So my ~/.authinfo needs to be secured. Many ways exists, on the top of my head, decent file rights, home encryption, etc… Then again, that's not the subject at hand.
install
Indeed, It's the same snippet as before, I add my new package to this list each time I need it.
(require 'package) (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/") t) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t) (package-initialize) (when (not package-archive-contents) (package-refresh-contents)) (defvar my-packages '(jabber) "A list of packages to ensure are installed at launch.") (dolist (p my-packages) (when (not (package-installed-p p)) (package-install p)))
source: user-install-packages-pack/init.el
Evaluate the buffer C-c m b
, then let emacs work.
setup
~.authinfo/
We need the netrc library to parse the ~/.authinfo
machine jabber login <your-email-gtalk> password <your-credentials>
Note
- The name jabber is the primary key you will reference in the code later.
- <your-email-gtalk> is the account gtalk
- <your-credentials> this can be your gtalk password or the password you generated in your google-account for emacs 1
parsing
Here is the parsing part:
(require 'netrc) ;; load the entry tony-blog in the ~/.netrc, we obtain a hash-map with the needed data (setq cred (netrc-machine (netrc-parse "~/.authinfo") "jabber" t))
cred
is mounted as a list of pairs.
(("machine" . "jabber") ("login" . "my-gtalk-email") ("password" . "some-password"))
Now, you have access only in ram to your credentials.
(netrc-get cred "login") (netrc-get cred "password")
Note
Place yourself just after the )
of the first expression (for example) and C-x C-e
to evaluate the s-expression.
jabber setup
There is a subtlety here. I used a emacs-lisp macro to be able to interpose the login and password inside the jabber setup. Notice the backquote ` (prevent the evaluation of the list) and the comma (to let the evaluation takes place).
;; Jabber client configuration (setq jabber-account-list `((,(netrc-get cred "login") (:password . ,(netrc-get cred "password")) (:network-server . "talk.google.com") (:connection-type . ssl) (:port . 5223))))
When executing, we obtain what we want, a list with our credentials embedded (this will not be written in files, only in rams).
(("my-gtalk-email" (:password . "some-password") (:network-server . "talk.google.com") (:connection-type . ssl) (:port . 5223)))
Optional jabber setup
This setup is to avoid the loading of avatar (takes too much place on the screen, but you can remove this line to load them by default).
(setq jabber-vcard-avatars-retrieve nil jabber-chat-buffer-show-avatar nil)
full
(require 'netrc) ;; load the entry tony-blog in the ~/.netrc, we obtain a hash-map with the needed data (setq cred (netrc-machine (netrc-parse "~/.authinfo") "jabber" t)) ;; Jabber client configuration (setq jabber-account-list `((,(netrc-get cred "login") (:password . ,(netrc-get cred "password")) (:network-server . "talk.google.com") (:connection-type . ssl) (:port . 5223)))) (setq jabber-vcard-avatars-retrieve nil jabber-chat-buffer-show-avatar nil)
source: user-chat-pack/init.el
Connection
To connect: C-c C-x C-c
(M-x jabber-connect
)
To connect: C-c C-x C-d
(M-x jabber-disconnect
)
Conclusion
You should be good to go. Happy chat!
Footnotes:
This way, if your ~/.authinfo
is compromised, only emacs is.