JED Modes

As you probably know JED has a really cool programming interface which makes it easy to do syntax highlighting, auto indenting and various other useful things for various mode.

My JED Modes

From time to time I manage to get fed up (or I'm just lazy or both) enough doing a certain task that I write a mode to simplify those tasks. Below is a list of modes which I have written so far and which you may or may not find useful.

  • asm.sl - GNU Assembler mode
  • cisco.sl - Cisco configuration file mode
  • clay.sl - Frogfoot Traffic Volume Measurement Tool configuration file mode updated 2004-09-03
  • cob.sl - Common Object Broker configuration file mode
  • config.sl - My libconfig configuration file mode
  • debian.sl - Debian control file mode (for Debian developers) updated 2004-07-22
  • diff.sl - Unified diff editing mode
  • ftc.sl - Frogfoot Traffic Control configuration file mode updated 2004-09-03
  • ftm.sl - Frogfoot Traffic Monitor configuration file mode
  • ipexd.sl - IP Exchange Daemon configuration file mode
  • mib.sl - SNMP MIB (or any other ASN.1 files) file editing mode
  • muttmail.sl - Mutt mode (very popular)
  • postgres.sl - Postgres command file (scheme) mode
  • rwhoisd.sl - RWhois Server configuration file mode
  • tinysnmp.sl - TinySNMPd configuration file mode updated 2004-07-22
  • abz.sl - My color scheme

Most of the modes above just provide syntax highlighting. Some exceptions are the diff and mutt modes which provide all sorts of other functionality as well.

In order to use my MIB mode, you might need to patch JED.

Other JED Modes

I also have some other JED modes which I'm sure I did not write (I may have improved them), but which others do not seem to have. Here are some of them.

  • muttrc.sl - A mutt configuration file mode
  • nasm.sl - A mode to edit NASM assembler files

Links to other JED Afficionados

Below is a list of pages which you might want to visit.

  • PHP Mode This is definitely the coolest php mode out there. A really big recommendation for anybody who code php!
  • Jed homepage The official Jed homepage. A good starting point for information if you'e interested in the editor or want to download the latest version.
  • cpbotha.net Charl Botha is the current Debian maintainer for Jed. He also have various jed links, screenshots, etc. of jed on his page. This of course is his jed page.
  • JED Modes Repository A very useful page if you're looking for nifty non-standard jed modes. Hopefully this will contain an extensive list of modes in the near future.
  • mooch's JED page A while ago, Johann started a JED page as well. He has written some cool modes which you can find on his page.
  • Dino Leonardo Sangoi have some interesting JED modes as well. Most of his modes are incomplete, but he has some really cool ideas (e.g. a mode for GNU Make, changelogs, diff files, etc.) I've based my unified diff mode on his diff mode (read: I wrote a crappy one, saw his, threw away mine and started working on his one instead).

Tips & tricks

Byte compiling .sl files

Assuming your JED_ROOT is set to /usr/share/jed/lib and all your .sl files reside there, change to that directory and edit bytecomp.sl. Search for a line that says

% list of file to byte compile:

Insert the files you want to compile in there. Now run jed as follows

jed -batch -n -l codeparse.sl

If you have any files that uses DFA syntax highlighting, you should also edit codeparse.sl and insert a line that says

() = evalfile ("some_filename.sl");

somewhere between the HAS_DFA_SYNTAX directives. Of course, you have to replace some_filename.sl with the name of your .sl file.

Alternatively, change to the directory where the .sl file is that you want to byte compile, start up an empty buffer in jed, and in there type this

byte_compile_file("some_filename.sl", 0);

Now type evalbuffer in the mini_buffer to the M-x prompt. Remember though that you need to be in the same directory as your .sl file when you do. Of course, you have to replace some_filename.sl with the name of your .sl file.

Loading .sl modes (and adding it as the default mode for certain file extensions)

This is easiest explained with examples, so here goes:

autoload ("postgres_mode","postgres");
add_mode_for_extension ("postgres","pg");
add_mode_for_extension ("postgres","pgsql");

You can either put this in the system wide jed.rc file or in your ~/.jedrc.

Binding keys to built-in jed functions

To find out what built-in functions there is in jed, start jed, type M-x (That's Meta X (as in ALT-X or ESC-X) if you don't know what I'm talking about and press TAB twice. A small buffer will pop up through which you can browse through all the functions. When you've chosen one, open you configuration file and insert the following:

setkey("your_command","^a");

Just replace your_command with the command you have chosen and ^a with your hotkey. ^ is Ctrl and \ is Meta.

Adding keywords in JED modes

Something which caught me when I wrote my first JED mode was JED's strange way of specifying keywords. Just look at the following statements:

() = define_keywords_n (asm,".if",3,0);
() = define_keywords_n (asm,".bss.equ.got",4,0);

What is immediately obvious is that you specify all the keywords of a certain length after each other and you have keyword statements for each length keyword. What is not so obvious (at least it wasn't obvious to me), is that those keywords should also be alphabetically sorted.

To help with the painful process of sorting keywords, I wrote a small application to sort all the keywords for you. You might find this application useful if you write JED modes from time to time.

Debian Package

I maintain my own Debian package which you can find below. It does not use the resolver library, and has a small patch applied to support my MIB mode.

download