Journey into Emacs.

Why bother?

Because Emacs, the text editor, is the environment in which I do almost all my written work. That is to say

Emacs began in about 1976 - an almost incredibly ancient piece of software! It has of course been expanded, developed and refined, and remains one of the two great editors of the unix world - vi being the other. "Emacs" is an abbreviation of "editing macros" - as if the original author was saying "Here is a bunch of macros - take them away and make your own editor." That is what most emacs users have done, to a greater or lesser extent, and Emacs has grown over the years with thousands of extensions and customizations added to it by users. Each user has their own unique .emacs file written in Emacs-lisp. I am currently using Emacs 22.3.

This is what it looks like as I'm editing another part of this site. (A nice feature of Muse (see below) is in-line viewing of images once you have completed the link.)

The runtime file for Emacs

is usually ~/.emacs. Mine is a mess! But here is it anyway.

A good .emacs file is a work of art - why let the customize interface mess it up with slabs of code at the end? No need - here's how to avoid that automated vandalism!

(setq custom-file "~/.emacs.d/custom.el")
(load custom-file 'noerror)

My keybindings

One of the very best things about Emacs is the possibilities it gives for making the editor work to suit your own particular needs. The downside is that it soon becomes very annoying to work with an Emacs that hasn't been adapted your tastes.

Here are my keybindings for Emacs.

Useful packages.


Perhaps I should mention here the Muse package which I am using to produce this. What is Muse?

Emacs Muse is an authoring and publishing environment for Emacs. It simplifies the process of writings documents and publishing them to various output formats from the same input file. Muse uses a very simple Wiki-like format as input.

Muse consists of two main parts: an enhanced text-mode for authoring documents and navigating within Muse projects, and a set of publishing styles for generating different kinds of output.

So one can generate all this

from one working file. Not bad!!

Muse and Css files on a per-project basis

One trick not well documented with Muse is how to set up style files, amongst other things, on a per-project basis. This is how to do it, based on work by Muse's author Michael Olson

The technique is to derive a new style from "html" and use that instead, using muse-derive-style (which is to be found in muse-publish.el). Here are the necessary incantations: first we derive two new "styles"

(muse-derive-style "glynweb-html" "html"
                    :style-sheet "<link rel=\"stylesheet\"
                    type=\"text/css\" media=\"all\"
                    href=\"../css/mystyle.css\" />")

(muse-derive-style "central-html" "html" :style-sheet "<link
rel=\"stylesheet\" type=\"text/css\" media=\"all\"
href=\"../css/centralmain.css\" />")

Then we can set out the muse-project-alist using the derived styles as appropriate

(setq muse-project-alist
            '(("glynweb" ("~/html/glynweb/glyn" :default "index" )
(:base "glynweb-html" :path "~/html/glynweb/glyn"))
              ("central" ("~/html/glynweb/central" :default "index")
(:base "central-html" :path "~/html/glynweb/central"))))


TRAMP is a package for editing remote files and also for editing as root. It can and should use ssh to ensure a secure connection. It will use scp by default and ssh is preferable - hence the default method variable below.

The incantation required for editing as root is

C-x C-f /[ssh/root@localhost]/etc/hosts

In fact

C-x C-f /[root@localhost]/etc/hosts

should do it :-) Simply to launch tramp use this

(require 'tramp)
(setq tramp-default-method "ssh")


From the org-mode manual:-

"Org-mode is a mode for keeping notes, maintaining TODO lists, and doing project planning with a fast and effective plain-text system.

Org-mode develops organizational tasks around NOTES files that contain lists or information about projects as plain text. Org-mode is implemented on top of outline-mode, which makes it possible to keep the content of large files well structured. Visibility cycling and structure editing help to work with the tree. Tables are easily created with a built-in table editor. Org-mode su pports TODO items, deadlines, time stamps, and scheduling. It dynamically compiles entries into an agenda that utilizes and smoothly integrates much of the Emacs calendar and diary. Plain text URL-like links connect to websites, emails, Usenet messages, BBDB entries, and any files related to the projects. For printing and sharing of notes, an Org-mode file can be exported as a structured ASCII file, as HTML, or (todo and agenda items only) as an iCalendar file. It can also serve as a publishing tool for a set of linked webpages."

The table editor alone is worth the trouble of setting this up. Useful too is the "export-as-latex" variable which allows one to produce a beautifully printed version of the files created.

It's All Text.

Having gone to the trouble of building and installing the amazing Emacs you want to use it for everything ! You can use it to browse the web, but frankly there are better browsers available, such as Firefox. You can set up Emacs as your editor of choice for filling in web-page text-boxes viewed in Firefox by using the Its All Text plugin, available here. Especially handy for composing e-mail via a webmail site. P.S. With Emacs 23.2, to make this open up a new frame when editing something in Firefox I needed to create and call a small script

emacsclient -c "$@"


e-blog is a (currently) simple interface to the Gdata API for Blogger. It allows posting to a Blogger blog from within Emacs.

Rather than presenting the user with buffers filled with XML to embed their posts in, e-blog presents a buffer similar to what you would expect from an MUA. XML tags within blog posts do seem to work, so slightly more adventurous formatting is possible.

Grab it here.

Things worth remembering!


If you have a file that is giving you problems (such as the site-start.el file in some distributions) you can use the command

M-x eval-region

on parts of that file until you find the offending part.

A real time-saver!

Face at point?

C-u C-x = will tell you all you need to know.

Back to FreeBSD page