Re: Paredit in Lispworks editor?
Hello Cam,
Camille Troillard wrote:
Thanks to the recent discussion about the history of LispWorks and Interlisp D,
I reminded that you were working on a port of the paredit mode.
Indeed, I had the same thought. It is disappointing that a structured editor existed and has been lost. Although, I don't think I would be too fond of the real-time evaluation feature, unless it could be turned off.
How is your progress?
Is there anything the LispWorks community can do to help?
I am very curious to try this tool in LispWorks.
I keep getting stuck at the point of parsing the buffer so that the location of the point in the SEXP tree is known. I actually have 3 potential approaches to finishing this step.
- Complete the recursive decent parser that I've partially implemented.
- Integrate and use a CL reader written by PJB.
- Implement the parser using META-SEXP.
I'm actually leaning towards option 3 because option 1 is stalled and requires more work than it is probably worth. Option 2 is overkill. PJB's reader code is very well written, but does more than is necessary and is probably too much overhead for what we are trying to accomplish. Option 3 is probably the best. All I need to do is write a method in META-SEXP for creating a parser context from the editor buffer and then define the necessary META rules to parse the buffer. The only real downside to option 3 is that it would require include META-SEXP. I was hoping to implement the code so that no external libraries were necessary, but I don't think requiring META-SEXP is too much of a problem.
Anyway, I haven't had much time to work on this recently. In the meantime, I'm using a very crude approximation that I found in the documentation and source code for the LispWorks editor:
;;; Key bindings
(editor:bind-key "Indent New Line" #\Return :mode "Lisp")
(editor:bind-key "Insert Parentheses For Selection" #\( :mode "Lisp")
(editor:bind-key "Insert Double Quotes For Selection" #\" :mode "Lisp")
;;; Custom commands and bindings
(editor:defcommand "Move Over ()" (p)
"Move past the next close parenthesis.
Any indentation preceeding the parenthesis is deleted."
"Move past the next close parenthesis."
(declare (ignore p))
(let ((point (editor:current-point)))
(editor:with-point ((m point))
(cond ((editor::forward-up-list m)
(editor:move-point point m)
(editor::point-before point)
(loop (editor:with-point ((back point))
(editor::back-to-indentation back)
(unless (editor:point= back point)
(return)))
(editor::delete-indentation point))
(editor::point-after point))
(t (editor:editor-error))))))
(editor:bind-key "Move Over ()" #\) :mode "Lisp")
NOTE: This approximation is bare minimum and if you are accustomed to PAREDIT, you may find it annoying because it lulls you into expecting the PAREDIT functionality. For example, you can delete a closing parenthesis and then have problems adding it back since it doesn't handle unbalanced parentheses at all.
I'll report back as soon as I have something worth distributing. Feel free to keep prodding me.
Best regards,
Tom
----------------------------------------------------------------
Thomas M. Hermann
Odonata Research LLC
http://www.odonata-research.com/http://www.linkedin.com/in/thomasmhermann
On Sat, Feb 18, 2012 at 5:03 AM, Camille Troillard
<camille@osculator.net> wrote:
Hello Thomas,
Thomas M. Hermann <thomas.m.hermann <at> odonata-research.com> writes:
>
> Anyway, let me know if you have anything that you want to collaborate on.
> I have your email and will notify you if I make any progress on my end..
Thanks to the recent discussion about the history of LispWorks and Interlisp D,
I reminded that you were working on a port of the paredit mode.
How is your progress?
Is there anything the LispWorks community can do to help?
I am very curious to try this tool in LispWorks.
Best,
Cam