Wednesday, December 15, 2010

Finding Emacs - Add an External Mode, Predictive, Byte Compiling

I've tried to keep these posts short to illustrate one point that will be easy to find (for me as well when I need to remember) however I'm combining three things here because they dovetail so well and really depend upon each other.


Add an External Mode

Modes in Emacs are really collections of Emacs Lisp files collected together in a directory.  You tell Emacs about them by referring to them in the " init.el " file.

This is where I believe that using the standard Emacs intitialisation structure even for Aquamacs is an excellent idea.  Use the " .emacs.d " initialisation directory and place the external modes you are adding into this directory. That way it is all neatly packed together.


Predictive


I first read about predictive on this page.  It gives a good introduction to what it is all about and how to do Byte compiling of Lisp files on a Windows machine.  Normally, when you add an external mode, they give a " makefile " which is not much good to you in Windows, however you can simply do a manual version of it using Byte Compiling using Dired.  I will repeat a couple of points on my linked page, just in case it becomes broken at some stage in the future, which will not be much good to me if I've forgotten it and am trying to piece things together again.

So, obtain Predictive from here.  I used a Windows archive utility (check freewarefiles) to unpack the " tar.gz " file into a folder called " predictive ".  Place this folder in the " .emacs.d " directory.

These are the lines I put in my " init.el " file to point to the directory.

;; Predictive
(setq load-path (cons "~/.emacs.d/predictive" load-path))
(autoload 'predictive-mode "predictive" "predictive" t)

You are all set now (after you restart Emacs to get the init.el file re-read), you can manually start predictive-mode by:

M-x predictive-mode (RETURN)

See my post about File Variables for an automagic way of starting it.

It now all works ....... errrr ........ sooorrrrttttt of.

It is sooo slooowwww it is almost unuseable.  To speed things up, we need to ...


Byte Compile Lisp Files

This is where that previous post on Dired comes in handy.  We can change to the appropriate directory, mark the files and then byte compile them from within Emacs.

C-x d ~/.emacs.d/predictive RET
% m \.el$ RET  
B                        
  • With the first line, we open Dired, changing to the predictive directory
  • The next line (starting with the % character) marks all the  " .el " files
  • Finally, the command " B " tells Emacs to start byte compiling all the marked files.  You will only have to reply " yes, or y " to confirm you want it to start.
The byte compilation will take some time, so don't worry, it will get there.  Once it is finished, restart Emacs and now you are on your way with a much faster and useable " predictive mode "


later .....

No comments:

Post a Comment