Sunday, June 8, 2008

Developing software using JED

I am a command line user! Thats that, I don't really like graphical user interfaces. They tend to take up way to much memory/CPU etc etc for my taste (I want to use those for things like music and other things that I need them for when doing my daily routine and I don't want to have many gigabytes of memory installed to do this smoothly, even though memory is cheap today). So I use the command line to do a lot of things.

One of the things I do is edit files, be they text files or program source code files (which are text files, but for this discussion I will make a difference between the a normal text file and a source code file) or something else and I don't want to fire up OpenOffice or some other GUI program to edit a file that is just plain text be they 2 lines or 10000 lines. For this task I really like the small weight editor called JED developed mainly by John E. Davis (hence the name of the editor). This is a lightweight version of Emacs, well it is and it isn't, it has a mode that emulates Emacs and which I use so for me it is a lightweight Emacs editor :-)

To begin editing files in JED it is good to have a quick reference at hand.

The reason I am writing about this editor now is that I would like to get starting to program Octave which is a big project and not easy to navigate through. The program begins in a small file called main.c which does nothing except call another function which begins the main C++ program. Now where is this function located in all the files? I have no idea to begin with so I use a little program called ctags that by issuing the following command

ctags -R *

it creates a file called tags in the source directory which contains a list over all the functions used in the program and in which file they are located (there are dozens of files so searching through them manually is not good and a waste of time when you have utilities like this). When this list is created I can place my cursor inside JED on the function I like to find and press ESC+. (that is I press ESC followed by dot) and I get a minibuffer at the bottom of the screen that asks

Find tag: (default: the_function_that_my_pointer_was_at)

and there I can either type in a name of a function I want to find or it will find the function the cursor was placed at if I just press Enter without giving another function name. This will find the source code file that the function is in, open it up in a new buffer and split the screen of my xterm in two and display my old source file in one window and the new one in the other. To move between the two windows press Alt+x and type other_window, to get back into one window mode typ Alt+x and one_window (TODO, put some nice keyboard shortcuts to these functions).

This function to find the programming functions by typing Esc+. is not on by default, to get it to work you need to follow the instructions of the developer of ntags and put the following line in your .jedrc file

() = evalfile(autoload);

No comments: