Live data from Hacker News

Cirru – An editor for AST

cirru.org

41–50 of 53 posts

Re: Cirru – An editor for AST

#41
post #39

Earlier quoted context omitted.

Paredit does try and keep the subtree you're editing correctly indented. Moreover, it has a paredit-reindent-defun command (bound to M-q), which reindents the whole tree you're editing. Bind it to whatever auto-reindent facility Emacs has (Electric keys? I don't know - I never had a need to configure it for myself.), and there you go. Personally, I'm fine with manual M-q on code if I see the identation got messed up.

M-q is useful, but something more useful IMO would be the same feature but one that removes unneeded white space within the sexpr between expressions and keep everything indented. A contrived example: (defun x () (+ x x)) => (defun x () (+ x x))

You can write an interactive function that runs fill-paragraph (or whatever M-q is bound to in the mode you are using), then deletes multiple spaces (something like http://stackoverflow.com/questions/8674912/how-to-collapse-w...).

That would not be a good default because some people, like me, like to align their code in columns (for example, things like let clauses).

What I would like to see come as an Emacs default is just-one-space working on regions with the behavior you describe.

Re: Cirru – An editor for AST

#42
post #9

Earlier quoted context omitted.

> I've yet to see one that could effectively work with dynamic languages That is a hard nut to crack, a dynamic language will frustrate static analysis.

Lisp languages cheat on that by pulling relevant metadata from the image after you loaded the code in. So if you just open a project as text, SLIME won't help you find e.g. a list of places that call a particular function - but after you load it into your Lisp image, cross-referencing features become available.

This is true under the hood of most static language IDEs as well. If they are not using a custom compiler (like JDT Core in Eclipse) they end up implementing a partial compiler to support features beyond ctags. ctags itself is the tokenizing and partial parsing step of a compiler.

Re: Cirru – An editor for AST

#44
post #24

Reminds me of http://www.lamdu.org/ while trying to remember the name I discovered: https://www.facebook.com/notes/kent-beck/prune-a-code-editor... http://jetbrains.com/mps https://github.com/cxxtree/cxxtree http://www.greenfoot.org/frames/ http://unisonweb.org/ https://github.com/chrisdone/structured-haskell-mode https://www.emacswiki.org/emacs/ParEdit https://github.com/projectured/projectured

Note that some of these (like ParEdit) are just macros for text-oriented editors, and not real structured editors.

The earliest structure editor was Interlisp's original structure editor for teletypes, which worked on Lisp lists directly. Editing on teletypes is not anything like editing on video terminals - you are basically forced to edit one line at a time instead of viewing the whole file. That's how ed works. Structured editing made a lot of sense for teletypes because you did not have to worry about putting delimiters in the wrong place, which is very hard to spot when you are doing things one line at a time.

There was an Interlisp structured editor (maybe more than one? I'm not sure) written for video terminals in the 1970s. On video terminals structured editing loses a lot of its advantages over text editing and structured editors fell out of style in the 1990s.

Re: Cirru – An editor for AST

#45
post #41
post #39

Earlier quoted context omitted.

M-q is useful, but something more useful IMO would be the same feature but one that removes unneeded white space within the sexpr between expressions and keep everything indented. A contrived example: (defun x () (+ x x)) => (defun x () (+ x x))

You can write an interactive function that runs fill-paragraph (or whatever M-q is bound to in the mode you are using), then deletes multiple spaces (something like http://stackoverflow.com/questions/8674912/how-to-collapse-w... ). That would not be a good default because some people, like me, like to align their code in columns (for example, things like let clauses). What I would like to see come as an Emacs default…

What I've noticed after using paredit is that I'm doing a lot less paren matching (well none) and a lot more white space clean up, so I think such a function would be very useful to run as a hook on insert char. Since the program is always syntactically correct, it might almost work...

And @sedachv, thanks for Parenscript. It makes Javascript almost...well, now I can work it it :) Much appreciated.

Re: Cirru – An editor for AST

#46

I don't want to be a downer, but the visual presentation is awful, I could not work with the nesting direction changing all the time. If there were a good language-specific pretty printer, and it looked like regular text in the language, I could probably stomach it.

I've used it to write web pages for nearly a year, so I believe we can. The problem is, like people may hate using indentations, they just hate. There's also a text version of Cirru http://text.cirru.org , but withouth benefits of structural editing.

Re: Cirru – An editor for AST

#47
post #40

Earlier quoted context omitted.

That's because the representation of that AST seems to be defined in terms of Python's objects, so it looks unwieldy. Compare with Lisp: Code: x AST: x Code: (let ((x 5)) (+ x x)) AST: (let ((x 5)) (+ x x)) And as for the very little syntactic sugar most Lisps have: Code: 'x AST: (quote x) :).

Ah, that helps a lot--thanks for the example! Most ASTs I've have seen look much more gruesome than that. That AST looks straight delightful. (actually now that I think about it, R may do something a bit similar)

And we can map Cirru AST to a language AST like I did in http://script.cirru.org/ ;)

Re: Cirru – An editor for AST

#48
post #38

I love seeing prototypes like this. Excellent job! One suggestion: I would implore you to add undo sooner rather than later.

That would be a huge feature. I got some ideas but have no time to finish it. It's can be something like something like Redux devtoos, because it's not just files...

Re: Cirru – An editor for AST

#49
post #24

Reminds me of http://www.lamdu.org/ while trying to remember the name I discovered: https://www.facebook.com/notes/kent-beck/prune-a-code-editor... http://jetbrains.com/mps https://github.com/cxxtree/cxxtree http://www.greenfoot.org/frames/ http://unisonweb.org/ https://github.com/chrisdone/structured-haskell-mode https://www.emacswiki.org/emacs/ParEdit https://github.com/projectured/projectured

An addition to this list: http://www.pawfal.org/dave/index.cgi?Projects/Scheme%20Brick...

Re: Cirru – An editor for AST

#50

I don't want to be a downer, but the visual presentation is awful, I could not work with the nesting direction changing all the time. If there were a good language-specific pretty printer, and it looked like regular text in the language, I could probably stomach it.

I've used it to write web pages for nearly a year, so I believe we can. The problem is, like people may hate using indentations, they just hate. There's also a text version of Cirru http://text.cirru.org , but withouth benefits of structural editing.

I'll give it a try instead of just criticizing it. :- )

I've used Paredit, which is similar in concept; I think it's really cool if it can be generalized well to languages which aren't LISP.

Post reply on HN