This is my GNU Emacs page. I intend to put whatever Lisp hacks and code I've written for Emacs here, if I think it might be useful for other human beings. I basically use Emacs for all editing except Java coding, where I currently use Netbeans. [For small and quick editing tasks, I tend to use GNU nano.]

As it happens, Emacs is much more than just an editor. I use Gnus for all my email needs, which is a strange and awesomely configurable beast of a News reader, built on top of the Emacs Operating System, that also happens to support email.

An editor needs to be programmable. Enter the wonderful runtime extensible world of Emacs Lisp. Lisp is fun, however strange it might look at first. It allows me to implement new things that I need, fix things that annoy me and tweak things to work exactly how I want, all with ease.

Index

.emacs

My current .emacs file. I publish it here solely as an example. It does contain references to some resources which are not published, and it probably won't work with anything but a recent GNU Emacs version (>= 23). I haven't put any effort into making it compatible with other Emacs flavours or versions.

Gnus

Gnus configuration can be a daunting task, and it took me some time to get it working to my taste. Take note tham I am an extremely picky person about matters such as email clients.

I explain some selected and exemplified parts of my Gnus configuration and code on a page of its own. Amongst other things, it shows examples of integrating Gnus with the NetworkManager library.

Google/GMail contacts

I hacked up a small library to fetch GMail/Google contacts over HTTP into Emacs, because I wanted an easy way to sync up my BBDB address book. The code is currently in alpha state, but works for me (tm).

Emacs Lisp code: google-contacts.el

Usage example:

;; Example of using google-contacts.el
;; Load library
(load-file "/path/to/google-contacts.el")

;; Configure username/password to GMail
(setq google-contacts-email "my-email@gmail.com")
(setq google-contacts-passwd "secret")

;; Retrieve Google contacts and put the resulting list in `my-contacts' variable:
(setq my-contacts (google-contacts-retrieve))

;; Use contents of `my-contacts' variable to whatever you need it for.
;; It's structure should be easy to understand.
;; You can look at it by doing a "C-h v my-contacts" to describe the variable.

;; You can merge the contacts into BBDB address book:
(google-contacts-merge-with-bbdb my-contacts)

;; Here's an interactive function that retrieves Google contacts and updates
;; BBDB:
(defun google-contacts-update-bbdb()
  "Fetch contacts from Google and merge them into local BBDB."
  (interactive)
  (google-contacts-merge-with-bbdb (google-contacts-retrieve)))
;; Please read warning about function `google-contacts-merge-with-bbdb' in top
;; of google-contacts.el file.

Desktop notifications from Emacs

The following code demonstrates how you can display desktop notifications with Emacs, using D-Bus. It requires that your Linux distribution supports the necessary desktop notification service. I use this for notification of new email from Gnus and notification of upcoming appointments in my calendar (using Org-mode).

Emacs Lisp code:

;; -*- coding: utf-8; mode: emacs-lisp -*-
;; Using Freedesktop Notifications service over D-Bus ..
;; Call notify-show-message to trigger desktop notifications..

(require 'dbus)

(defvar notify-icon-alist
  '((mail . "notification-message-email")
    (appt . "/usr/share/icons/gnome/scalable/status/appointment-soon.svg")))

(defun notify-show-message(summary message &optional icon)
  "Show message MESSAGE using the 'notify-send' command.
An optional icon reference can be provided, and available icons
can be seen in variable `notify-icon-alist'."
  ;; Encode summary and message string to utf-8
  (setq summary (encode-coding-string summary 'utf-8)
        message (encode-coding-string message 'utf-8))
        
  (if (assoc icon notify-icon-alist)
      (dbus-call-method
       :session
       "org.freedesktop.Notifications" "/org/freedesktop/Notifications"
       "org.freedesktop.Notifications" "Notify" "GNU Emacs"
       0 (cdr (assoc icon notify-icon-alist)) summary message
       '(:array) '(:array :signature "{sv}") -1)

    (dbus-call-method
     :session "org.freedesktop.Notifications" "/org/freedesktop/Notifications"
     "org.freedesktop.Notifications" "Notify" "GNU Emacs"
     0 "" summary message '(:array) '(:array :signature "{sv}") -1)
    )
  )

(provide 'notify)

NetworkManager

I wrote some integration code between NetworkManager and Emacs using the D-bus bindings that comes with Emacs23. It lets Emacs know when network goes down or comes up. It can be used for anything, but I use it for setting Gnus in offline/online state automatically.

Emacs Lisp code: nm.el

Emacs resources

I will not make any attempt at providing a comprehensive list of links to Emacs resource here, as there is simply too much out there. However, I can tell you about a few of the resources I use most frequently: