Recent Upgrades To MicroEmacs

Authors

Publication

Pub Details

Date

Pages

See all articles from QL Hacker's Journal 33

MicroEmacs is becoming my favorite editor, esp. now that I have a Q40. As MicroEmacs becomes more powerful, it needs some more horsepower to run quickly. On the Q40, speed is not an issue at all.

There are some new features to MicroEmacs that impact the programmer. They are:

  • Support for Client-Server Manager (CSM)
  • Syntax Highlighting
  • Support for CTAGS

CSM is an easy way for one program to control another. The Server program handles requests from the clients, and passes back to the client an acknowledgement of the request or some data. When I first encountered CSM I was not too sure how it could be used. It was created to provide scripting for QEM. The scripts are written in SuperBasic, sending commands to QEM via CSM.

Now MicroEmacs has CSM support, allowing SuperBasic programs to send MicroEmacs commands to the editor. This opens up a number of possibilities for having other program interact with MicroEmacs.

How I am thinking about using the MicroEmacs-CSM link is in Structured SuperBasic (SSB). SSB is just a simple filter that converts SSB code to SuperBasic. If SSB encounters a syntax error, it just reports it and exits. With a link to MicroEmacs, SSB could connect to MicroEmacs via CSM, move the cursor to the exact line with the error, then SuperBasic can exit. The user would switch to MicroEmacs and be at the problem line, ready to edit it. This would move SSB and MicroEmacs closer to an Integrated Development Environment.

Here is an Structured SuperBasic example of how easy something like this would be:

## Make sure MicroEmacs is running as a server
IF FINDSERVER("emacs") THEN
  ## Connect to MicroEmacs
  CLIENT "emacs"
  ## Add line count to goto-line command
  command$ = "goto-line "&var
  ## Send a request to MicroEmacs
  REQUEST "emacs",command$,return$
  IF return$ = "KO" THEN
     ## There was an error
  END IF
END IF

Syntax Highlighting is a way for MicroEmacs to show the syntactical elements of a program by showing the different words in different colors and italics. Syntax Highlighting supports C (_c and _h files), SuperBasic (_bas, _sbas, _ssb files), and assembler (_asm, _s, _cmd, and _rc files).

I’ve only used Syntax Highlighting with Structured SuperBasic and it does make the code a little clearer.

Comment lines (##) are shown in white and italics. There is a slight problem here as SSB defines comment lines as any line starting with ##, excluding any spaces in front of the ## (this allows for indented comments). MicroEmacs only supports lines that begin with ## in column 1.

SuperBasic control commands (DEFine, FOR, TO, NEXT, RETURN, IF, THEN, ELSE, etc.) are shown in white. The SuperBasic short cuts (such as DEF for DEFine) are not supported. The case of the words are ignored. DEFine, DEFINE, and define are all understood to be the same.

The rest of the code is shown in the normal green.

The color used to highlight the different elements can be changes by using 4 different MicroEmacs variables. So, if you prefer comments to be in red, you can do that.

Ctags come from Unix and were originally created for the Unix editor, vi. A tag file is created by using the program ctag. The editor then reads this file to understand the tags.

Ctags is designed to be used on a collection of source files in a directory. The tag file is sort of like an index file showing what procedures are defined and used in what source files. Ctags is not very useful with source code residing only one file.

MicroEmacs understands how to read a tag file and can be used to navigate through the source code files, by moving to a procedure and executing the ‘tag-word’ command. Moving forward is accomplished with the ‘re-tag-word’ command and moving back is done with the ‘back-from-tag-word’ command.

Ctags understands C, C++, Eifiel, Java, Fortran, and SuperBasic. This means that MicroEmacs also supports these languages with tag files.

Products

 

Downloadable Media

 

Image Gallery

Scroll to Top