Lisp HUG Maillist Archive

Paredit in Lispworks editor?


Does anybody have or know of Paredit, or some subset or similar, working
in the lispworks editor?

I see mention of it in some older posts.  I respect that it is not a
trivial feature.

Thanks,
Matt



Re: Paredit in Lispworks editor?

Matt,

I am not aware of any. When I started using LispWorks, one of the first things I did was try to translate paredit to LispWorks. The biggest impediment was the lack of a function in the LispWorks editor that is analogous to the emacs function parse-partial-sexp, as has been mentioned in previous threads. So, now you have to write a function that will parse the lisp syntax in the LispWorks editor. I have a development version of such a function. It actually scans the entire buffer and stores a list of the positions of the top-level forms. Within each top level form object is a list of all sub-forms. It works for some test cases. The stage I'm at now is maintaining state as the buffer is modified. Once that is robust, the core functionality required to implement an equivalent to paredit in LispWorks is available.

The reason this isn't complete is because I'm always tending to some fire drill related to my day job. The fact that you've asked for it twice over the past year gives me more motivation than usual to get this up and running. I was just scanning over the code and realized that I think I still have a problem with parsing sharpsign regions. But I don't think it's a show stopper, just need to actually work on it.

One of the things I don't like about how paredit operates is that it does not store much state, it repeatedly parses. What I'm trying to implement is intended to store the state of the buffer and update the tree of objects as the buffer is updated. I'm also trying to use built-in LispWorks editor function as much as possible.

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.

Good luck

Tom
----------------------------------------------------------------
Thomas M. Hermann
Odonata Research LLC
http://www.odonata-research.com/
http://www.linkedin.com/in/thomasmhermann


On Fri, Jun 24, 2011 at 2:18 AM, Matt Lamari <matt.lamari@gmail.com> wrote:


Does anybody have or know of Paredit, or some subset or similar, working
in the lispworks editor?

I see mention of it in some older posts.  I respect that it is not a
trivial feature.

Thanks,
Matt



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.
  1. Complete the recursive decent parser that I've partially implemented.
  2. Integrate and use a CL reader written by PJB.
  3. 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



Updated at: 2020-12-10 08:37 UTC