06.03.07

GNU Emacs 22.1 released!

Posted in Emacs, Linux, Techie stuff at 11:26 am by theBlackDragon

This morning I check in on #fvwm and the first thing I notice is the following:

03/06|01:03:06 < Hun> theBlackDragon: aaaaaaaaaaah!
03/06|01:03:13 < Hun> e22 has been released!

So I run off to the Emacs homepage, but nothing to be found about a new release. Hmm.
So what can you do? Check usenet of course, and sure enough on gnu.emacs.devel (e-mail addresses removed for obvious reasons):

From: David Kastrup <*@*>
 Subject: Re: Cygwin binaries for Emacs-22.1 released!
 Newsgroups: gmane.emacs.devel
 To: Angelo Graziosi <*@*>
 Cc: emacs-devel@gnu.org
 Date: Sat, 02 Jun 2007 21:18:05 +0200
Angelo Graziosi <*@*> writes:
> Cygwin binaries for 22.1 release here:
 >
 >    http://www.webalice.it/angelo.graziosi/Emacs.html
I was going to mouth off about premature announcements and being
 careless about release numbers, but checking on the ftp server have
 found that the tarball for Emacs 22.1 has been uploaded.
Did I miss the announcement on this list?
--
 David Kastrup

And sure enough, there it was, on the GNU FTP server, all shiny and new: an Emacs 22.1 tarball, the changes from 21.x are a little bit too numerous to sum up here, I’d say just upgrade or read the ChangeLog.

01.21.07

Emacs tips #4: the Emacs Lisp REPL

Posted in Emacs at 4:40 pm by theBlackDragon

Everybody knows you can evaluate elisp expressions in the scratch buffer, but a lot less people seem to be aware of ielm the interactive Emacs Lisp mode, this mode opens a sort of Emacs REPL that allows you to work with Emacs Lisp much in the same way you’d do at a Common Lisp REPL.

Another little known fact is that you can evaluate elisp expressions at the eshell prompt, just try typing (+ 12 9) and hitting return. Spiffy eh? But you’ll quickly run into eshell’s elisp limitations: it doesn’t correctly indent code so it’s not really useful for ‘real’ elisp hacking, ielm is much better suited for that purpose as it does corretly indent elisp code.

12.29.06

Emacs tips #3 : automatically making scripts executable

Posted in Emacs at 3:01 pm by theBlackDragon

I don’t remember where I found this snippet (maybe comp.emacs) but it’s mighty useful so I thought I’d share it with you:

; Sets +x on scripts stating with a shebang
(if (< emacs-major-version 22)
       (add-hook 'after-save-hook
                 '(lambda ()
                    (progn
                      (and (save-excursion
                             (save-restriction
                               (widen)
                               (goto-char (point-min))
                               (save-match-data
                         (looking-at "^#!"))))
                           (shell-command (concat "chmod u+x "
                             buffer-file-name))
                           (message (concat "Saved as script: "
                             buffer-file-name))))))
       (add-hook 'after-save-hook
         'executable-make-buffer-file-executable-if-script-p))

Emacs versions below 22 need the former, longer method while Emacs 22 can use the oneliner in the last line.

09.03.06

Antialiased Emacs (using XFT)

Posted in Emacs at 4:57 pm by theBlackDragon

There are a couple of resources describing how to get Emacs 23 (aka “the unicode branch”) display antialiased fonts (see here for starters).

So building on my previous post on installing Emacs 23 from CVS you need to use this configure command:

./configure --prefix=/home/theBlackDragon/local --program-suffix=.emacs-23 --with-gtk --enable-font-backend --with-xft --with-freetype

You’ll need to start it like this for example:

emacs-23 --enable-font-backend --font "Bitstream Vera Sans Mono-12"

You can use an Xresource for the font if you like, but the –enable-font-backend switch is mandatory.

05.12.06

Portable Emacs

Posted in Emacs at 1:07 pm by theBlackDragon

While reading gmane.emacs.help I came accross this post where somebody asked how he could make a portable app out of Emacs' Windows version.

So since I'm still at my internship (where they use Windows) and just recently obtained an iAudio X5L portable media player which behaves like an USB2 harddisk to the OS I wondered if I could manage to make Emacs portable.

Short version: I could, the "hardest" part was in fact not even Emacs related, but my sheer lack of knowledge about Windows batch script.

I started by creating a "SOFT" folder on my external drive (named E: by Windows on this box) and extracted the altest Emacs build from the ntemacs project in this directory, thus creating "E:\SOFT\emacs" with all the usual subfolders.

Next I created a site-lisp/site-start.el file and added the following as suggested on usenet:

(let ((home (concat (substring (car command-line-args) 0 2) "/SOFT")))
  (setq user-init-file (concat home "/config/.emacs"))
  (setq auto-save-list-file-prefix (concat home "/config/.emacs.d/auto-save-list/.saves-")))

You'll need to adapt this to your particular environment of course.

This makes Emacs load my user-init-file (aka ".emacs") from "E:/SOFT/config/.emacs" and moves the auto-save-list to the external device as well, this should be superfluous though as I change the location of HOME as described later, but it accounts for the cases that you don't want to change your HOME.

This is in fact the entire Emacs side of the story, though you will probably have some work making your elisp packages work with relative paths if you didn't take that into account before.

Now you need to redefine HOME in Windows (well, you don't need to but I find it useful), you can either do that globally with the System Properties or autoexec.bat in DOS based Windows versions, but I preferred to make it dynamic by writing a wrapper batfile that sets this variable and then launches Emacs. I named it runemacs.bat (how appropriate;)) and put it in Emacs' bin directory, the content looks like this:

set HOME=%CD%\..\..\config
runemacs

That's it! You can now run Emacs entirely from your external drive!

05.11.06

Emacs tips #2 : linenumbers

Posted in Emacs at 11:25 am by theBlackDragon

A question that pops up pretty often is how you can add line numbers in the margin of your files the way most other editors do.

There are actually two ways of doing this:

  • adding the numbers in the margin
  • adding the numbers to your files, so that they get saved with your file, might be useful in certain cases (COBOL source?)

Unfortunately Emacs doesn't support either out of the box, but fortunately people have written modes that do exactly this. Modes for both the former as the latter can be found on the EmacsWiki.

Personally I (occasionaly) use setnu.el which works extremely well for my purposes.

05.04.06

Emacs tips #1

Posted in Emacs at 2:57 pm by theBlackDragon

I've been using Emacs for some time now but have only recently started to heavily customize it. With this I've also started tracking (or more actively tracking) various Emacs related resources, picking up useful bits of information along the way. I'll try to share the most useful ones here with you on a (hopefully somewhat) regular basis.

I'll kick off with a very short one, the next line enables "focus follows mouse" on Emacs windows (not frames, frames are handled by the window manager).

(setq mouse-autoselect-window t)

So what is "focus follows mouse" anyway? Basically it means that the window your mouse pointer is over receives focus (input) so you don't need to click on it to give it focus (as you have to in, say, Windows). Some people find this confusing, most people can't live without it once they get used to it.

For more information on "focus follows mouse" see here.

04.27.06

Installing GNU Emacs 23 from CVS

Posted in Emacs at 8:25 pm by theBlackDragon

Emacs 23 is the current alpha version of GNU Emacs, the most important or at least notable feature of this upcoming version is the unicode support.

Exactly how alpha this version is can easily be deduced if you realise that the current stable Emacs version is 21.4 and that 22.0.50 is the current development version, so expect things to break, even though I haven't experienced any major breakage yet.

So let's get to installing this thing, first you'll need to checkout the code from CVS, figuring out which branch the 23 version is in was probably the hardest part, finding the correct command line switches to CVS in the CVS manpage must have been the second hardest (hey, I'm an avid Subversion user) ;)

I keep my source packages in ~/tmp/src, which I'll use in this example too, just replace this folder with whatever you use. From that directory execute this command:

$ cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/sources/emacs co -r emacs-unicode-2 emacs

This then pulls in the latest Emacs 23 (or as the branch is called emacs-unicode-2, I still wonder why they changed that instead of staying with emacs-unicode) from CVS in a new directory named emacs.

After this has finished (might take a while depending on your connection speed) you have to execute a small variation on the typal configure && make && make install routine as outlined in the INSTALL.CVS file.

There are three options you'll probably want to pass to configure, being –with-gtk, –prefix and –suffix, the first for enabling GTK2 support the second to keep it out of your filesystem structure, and theh last one to add a unique suffix to the binaries, so you can add them to you $PATH without them conflicting with already installed Emacsen.

I installed Emacs 23 in my homedirectory in a folder named local with a suffix of ".emacs-23.0.0" and GTK2 enabled

$ ./configure --prefix=/home/theBlackDragon/local --program-suffix=.emacs-23.0.0 --with-gtk

After configure has done it's job you need to run make bootstrap, this can take quite some time, but fortunately you don't need to do this every time you update the sources from CVS.

make bootstrap

Now you just need to follow the "regular" steps:

$ cd lisp
$ make recompile EMACS=../src/emacs
$ cd ..
$ make install

To update Emacs afterwards you'd use:

$ cvs update
$ ./configure --prefix=/home/theBlackDragon/local --program-suffix=.emacs-23.0.0 --with-gtk
$ make
$ cd lisp
$ make recompile EMACS=../src/emacs
$ cd ..
$ make install

When this finishes succesfully you'll have Emacs 23 Alpha installed and you can start poking around. If this doesn't finish succesfully you'll either have to fix it yourself or wait a day and do a CVS update in the hopes that your problem will have been fixed.
Emacs 23 freshly built from CVS

Little disclaimer: this is how I istalled it, there might be some inaccuracies in here, should you find some, please let me know. I do hope you found this article useful in any case :)

04.26.06

JDEE installation guide bit me again

Posted in Emacs at 4:46 pm by theBlackDragon

When I last tried to get the JDEE running on Windows with GNU Emacs 22 I was stung by the old inaccuracy in the installaiton guide concerning the installation of the cedet.

The guide suggests you add the different needed parts of the cedet separately by doing this:

(add-to-list 'load-path (expand-file-name "~/emacs/site/jde/lisp"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/cedet/common"))
(load-file (expand-file-name "~/emacs/site/cedet/common/cedet.el"))
(add-to-list 'load-path (expand-file-name "~/emacs/site/elib"))

This kept on giving me errors and after trying various versions of the cedet libraries it dawned on me that it might just be possible to load the cedet as a whole, which it was. I did it like this:

(add-to-list 'load-path (expand-file-name "C:/elisp/cedet-1.0pre3/common"))
(require 'cedet)

It now works like a charm and I thought I might as well share it, maybe you'll get hit by the same problem one day (or I'll forget about it again ;) ).

For completeness sake, this is the full code in my .emacs for loading the JDE on Windows (it's the same for other OSs, just substitute the correct paths):

;;; JDEE
(add-to-list 'load-path (expand-file-name "C:/elisp/elib-1.0/"))
(add-to-list 'load-path (expand-file-name "C:/elisp/cedet-1.0pre3/common"))
(add-to-list 'load-path (expand-file-name "C:/elisp/jde-2.3.5.1/lisp/"))
(require 'cedet)

;; (require 'jde)
(setq defer-loading-jde t)

(if defer-loading-jde
    (progn
      (autoload 'jde-mode "jde" "JDE mode." t)
      (setq auto-mode-alist
        (append
         '((".java'" . jde-mode))
         auto-mode-alist)))

(require 'jde))