Showing posts from June, 2009

lab 103 - python content assist

NAME lab 103 - python content assist NOTES Building on lab 102 I've started to write an acme client for python content-assist in python. I read the code for python's IDLE editor and pulled some pieces out of that to help with my implementation. The and modules are copied out of idlelib and reduced to just the functions I needed. Just as in lab 102 the acme client is implemented using pyxp to connect to the acme file system. In an acme editor window execute PyAssist. Start typing some python. After typing a dot the client will display available attributes for the module. Continue typing and it will reduce the list to those names with a matching prefix. Press the Tab key to complete a name or prefix depending on whether there is one or more names. After typing an open parenthesis the client will show the call tip for the function. The client implements an Import command so that more python modules can be added to the namespace. PyAssist

lab 102 - python acme client

NAME lab 102 - python acme client NOTES A recent post to 9phackers announced Pyxp , another implementation of Styx in Python. I immediately downloaded Pyxp and tried it out. I had no trouble using it so I started thinking about python clients I could write. Python is still new to me so writing a styx client was an excuse to get more practice. I started with an acme client. I translated the acmewin limbo module I use for most acme-sac clients to python. Below is a simple example opening a new acme window and doing some operations on it. from acmewin import Acmewin win = Acmewin() win.writebody("hello, world!\n\n\n") win.tagwrite("Hello") win.writebody("goodbye") win.replace("/goodbye/", "GOODBYE")",") Remember to export the namespace before trying it out. % styxlisten -A 'tcp!*!localhost' export / % I recently saw on Hacker News a repost of Peter Norvig's spelli

lab 101 - limbo B+ tree

NAME lab 101 - limbo B+ tree NOTES This lab is an implementation of a B+ tree. It is code from a much older lab that was overly complicated and buggy. I pulled the B+ tree code out, tried to fix the bugs and clean it up. The interface is roughly the same as dbm(2). Here is a synopsis. include "btree.m"; btreem := load Btreem Btreem->PATH; Datum, Btree: import Btreem; Btree: adt { create: fn(file: string, perm: int): ref Btree; open: fn(file: string, flags: int): ref Btree; fetch: fn(b: self ref Btree, key: Datum): Datum; delete: fn(b: self ref Btree, key: Datum): int; store: fn(b: self ref Btree, key: Datum, val: Datum):int; firstkey: fn(b: self ref Btree): Datum; nextkey: fn(b: self ref Btree, key: Datum): Datum; flush: fn(b: self ref Btree); close: fn(b: self ref Btree); }; init: fn(); Like Dbm the keys and values are stored as arrays of bytes, and being a B+tree the values are stored only in the leaf nodes. The maximum key and val size is 255 each

lab 100 - limbo tags

NAME lab 100 - limbo tags NOTES I've been playing more with exuberant ctags . It's possible to make ctags recognize limbo source code using regular expressions to identify symbols we want tagged. Here's a command I defined called ltags . It will search for functions, assuming the function name is not preceded by spaces, and, more reliably, find adt and module definitions: #!/dis/sh os -t ( /n/D/ctags57/ctags.exe -n '--tag-relative=yes' '--langdef=limbo' '--langmap=limbo:.b.m' '--regex-limbo=/^([a-zA-Z][a-zA-Z0-9]+)\(.*\)/\1/m/' '--regex-limbo=/([a-zA-Z][a-zA-Z0-9]+) *: *adt */\1/t/' '--regex-limbo=/([a-zA-Z][a-zA-Z0-9]+) *: *module */\1/c/' $* ) Try running it under /, and use relative path names: % cd / % ltags -R appl module And open the acme client Ctag /tags I added a command "Tag" to the Ctag program that will find and print all matching symbols to the name given as argumen