May 28, 2004

More on XEmacs for MacOS X

Apple | Emacs

Hooray! I managed to get XEmacs' internal buffer structure hooked up into Cocoa's text system!

The first step was to build a library from the XEmacs source code, which I could link against my Cocoa-based project. This was pretty straightforward, adding a couple of defines and ifdefs to remove the main function from the library. I also added some rules to the makefile to build the actual library.

Then I built a very simple editor application using Cocoa's default text classes. Once this worked, I replaced the default NSTextStorage class with my own subclass that uses XEmacs' buffer internal structure to hold the characters. Since NSTextStorage's API makes use of NSString to get the string to be displayed, I also created a simple subclass of it, that accesses the characters directly from the buffer structure.

I can now edit my .bashrc file, insert, replace and delete characters in a window on screen, and have these operations reflect directly in the associated buffer structure.

One problem I need to solve is with Unicode characters. MacOS X APIs use unichar, a 16 bit short integer to represent Unicode characters, while XEmacs uses IChar, a 32 bit integer. I need to find a way to normalize XEmacs' multibyte characters to MacOS X's unicode characters. I haven't poked yet in the MacOS X's Foundation header files to see if there is anything that would do the job. If you know of something, please let me know.

The next step is to hook-up the XEmacs Lisp engine in the system. This is the first real challenge, since the important stuff in Emacs is done in Lisp.

Posted by ovidiu at May 28, 2004 10:41 PM |
Copyright © 2002-2016 Ovidiu Predescu.