> I'm semi-new to emacs and now have a programming need that is list-
> based and editing-intensive. So I thought I might take a shot at
> writing an emacs mode. I'm curious the best way to approach is.
> Quick summary: I'm looking to write a program to do morphological
> forced connections. You make lists of words like this:
> type: cavern, city, county, mountain
> material: crystal, wood, flesh, gold
> And a pattern like this:
> A @type@ made of @material@ @location@ inhabited by @inhabitants@
> @government@ @special@
> When run, random words are pulled into the pattern:
> "A cavern made of crystal in space inhabited by ghosts ruled by a
> hereditary monarch where learning is exalted."
> "An island made of wood in the polar regions inhabited by apes ruled
> by a ghost which is sacred."
> etc. (example from O'Reilly's Mind Performance Hacks)
> So how does look for an elisp package:
> - User starts a new file and selects the mode
> - The mode knows about a format to specify lists and patterns (perhaps
> comments in the new buffer document it for reference)
> - User edits the text file, editing lists and patterns
> - When things are as the user likes, he hits a key to "evaluate" which
> generates the morph pattern
> (1) Does that sound like the right emacsy approach?
> (2) I can hack through the lisp to get it to interpret and process the
> buffer, but I am not sure how to structure the "hit a key and
> evaluate". I may not have read far enough in the docs.
it's pretty easy. How exactly to do depends on what kinda interface/design you want.
in anycase, you can have user press a key and the whole buffer's text will be considered as input. (with this choice, the disadvantage is that the buffer context must be pretty much syntactically correct, just like a language. Any extra coma, space, might break it. Or, you could write more elaborate code to parse but the effort quickly gets exponential in proportion on syntax leniency)
> (3) One thing I'm not sure about is where to put the results. What is
> the preferred emacs approach: put the results in the buffer? The lisp
> interactive mode puts the results in the minibuffer.
again, much of this depends on what YOU want first. You could have the output in a special buffer, which i suggest is easiest. typically, named like this: “*word output*”
> If I get it going, I'll publish it for others.
great. Your task seems pretty easy as elisp coding goes. I think anyone coded elisp for a couple of years can create it in half a day, based on my own experience. (i have some elisp tutorial on my site if you haven't seen already)