Re: editor for direct editing of the syntax tree: possible?
- From: Xah Lee <xah@xxxxxxxxxx>
- Date: Tue, 8 Jan 2008 15:18:25 -0800 (PST)
Hi,
here's 2 things i would like to have when editing lisp code:
(1) have a function, such that when invoked, the current block of lisp
code the cursor is on, will be all reformatted by a mechanical rule.
(somewhat analogous to fill-paragraph)
For detail, see:
★ A Simple Lisp Code Formatter
http://xahlee.org/emacs/lisp_formatter.html
(2) have the ability to move cursor by syntax tree like emacs's
backward-sexp, down-list, mark-sexp etc., but on more complex tree
syntax the XML.
For detail, see
★ A Text Editor Feature: Syntax Tree Walking
http://xahlee.org/emacs/syntax_tree_walk.html
Xah
xah@xxxxxxxxxx
? http://xahlee.org/
On Jan 7, 8:56 am, ruzsa.bal...@xxxxxxxxx wrote:
Hello there.
In the past weeks I've been thinking about a source code editor which
would make it possible to directly edit the symbolic representation of
Lisp forms - as they are returned by the "read" function - instead of
manipulating the source as plain text (array of characters). In such
an editor, I could move around the atoms and lists (widen/narrow
focus, step forward/backward between elements on the current level)
with the arrow keys, I could use "c" to change an element, "a" to
append a new one after the current, "i" to insert one in front of the
current, "o" to enter a new list above the current one, etc.
To realize this, the Lisp system should somehow save the forms
resulting from "read" calls and associate them with the defined
package symbols (I don't know yet what to do with those forms which
"read" cannot identify as definers), so that they can be later
retrieved when the source for a given object is to be shown. The
editor would show a list of packages currently defined in the Lisp
system, and a list of symbols (grouped by type) defined in those
packages. If I choose a symbol, I see the source code for it, can edit
it and feed the updated version back to the system for evaluation
(like in Slime).
My first problem is that I'd like to preserve the original read
syntax. For instance, when read sees something like this: #x0bc2, it
should save the element in such a way, that it retains its format
(hexadecimal), so I can show it in the correct way later on. I thought
about a source-code representation system, using objects of class
"source-element" and its subclasses, which would make it possible to
save attributes of an element together with the element value
(representation). The read function would analyze each element, decide
its source-element-type, make up the corresponding source-element
object and store it in the source tree at the element's location. When
I want to show (deserialize) the source, each source-element could
have a print method which would give back the original element (or
there would be three variants for print-source: one which creates the
text representation for editing, another which creates a tree which
could be fed to eval, and yet another which could create a serialized
version which would contain the necessary object constructors to
recreate the internal tree when it is fed back to read - this way the
source could be exported to the file system for backup, version
control or transfer to another Lisp system).
I'm sure I'm not the first who thought about this - after all, the
idea directly follows from the fact that code is data in Lisp -, but
as there is no proliferation of such editors nowadays, I suspect that
my ideas are a bit naive. If you happen to have any insight into why
this is not such a good idea, or you know of an existing system -
possibly with downloadable source code - which implements a scheme
like this, or the obstacles the developers had to face during
implementation, I'd be happy to hear about it.
Sincerely,
Balazs Ruzsa
Hungary
.
- Follow-Ups:
- Re: editor for direct editing of the syntax tree: possible?
- From: Rainer Joswig
- Re: editor for direct editing of the syntax tree: possible?
- From: John Thingstad
- Re: editor for direct editing of the syntax tree: possible?
- References:
- editor for direct editing of the syntax tree: possible?
- From: ruzsa . balazs
- editor for direct editing of the syntax tree: possible?
- Prev by Date: Re: Lisp and Scheme with fewer parentheses / Mathematica??
- Next by Date: Re: Lisp and Scheme with fewer parentheses / Mathematica??
- Previous by thread: Re: editor for direct editing of the syntax tree: possible?
- Next by thread: Re: editor for direct editing of the syntax tree: possible?
- Index(es):
Relevant Pages
|