[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parinfer-mode for Emacs might be neat for encouraging Lisp adoption

From: João Távora
Subject: Re: parinfer-mode for Emacs might be neat for encouraging Lisp adoption
Date: Fri, 13 Nov 2015 15:34:05 +0000

Hi Oleh, Christopher, Marcin

What do you think of this prototype?

    (defun joaot/setup-some-parinfer-fanciness ()
      (add-hook 'post-self-insert-hook 'joaot/reindent-up 'append 'local))

    (add-hook 'lisp-mode-hook 'joaot/setup-some-parinfer-fanciness)

    (defun joaot/reindent-up ()
          (backward-up-list) (indent-sexp))))

Now in some lisp-mode, type

   (defun parinfer ()
     (let ((foo bar)
           (baz quux))))

Change the `let' to `let*' and watch the auto-reindentation
magic. Probably very slow, but a cool trick nonetheless right?

This is useful is other languages, right? Couldn't JSON benefit from
something like this too?

> - It doesn't solve the problem of pasting unbalanced code.

IMO the problem of pasting unbalanced code is best solved by leaving it
alone, and using `electric-pair-mode's paren-balancing heuristic (on by
default), which is like paredit, but without the restraining order. And
no need to learn new commands.

Have you tried it, Oleh? Any feelings on how it could be improved?

Works for every language defining one or multiple parenthesis
syntaxes. Just like the hack above.

Personally I haven't tried lispy, basically because I want uniform
interfaces for all languages, even non-programming ones. I don't want to
re-learn shortcuts when I switch from lisp to JSON.

For that, I stick to, and am reasonably happy with, traditional sexp
navigation, the C-M-* family of movement/edition commands. Whoever came
up with those deserves some love.

On Fri, Nov 13, 2015 at 11:32 AM, Oleh Krehel <address@hidden> wrote:
> Marcin Borkowski <address@hidden> writes:
>> On 2015-11-12, at 00:30, Christopher Allan Webber <address@hidden> wrote:
>>> Here's a project borrowing some neat ideas from Emacs and extensions
>>> (especially paredit) on lisp editing and providing some of its own
>>> ideas, too:
>>>   http://shaunlebron.github.io/parinfer/index.html
>>> I could imagine this could make GNU Emacs an even better lisp hacking
>>> environment for some than it already is, or make jumping in easier, for
>>> some people.  Maybe someone will be inspired and add a plugin for it?
>>> There's a space listed for editor implementations here:
>>>   http://shaunlebron.github.io/parinfer/index.html#editor-plugins
>>> I don't have time to work on this, but I imagine someone on this list
>>> might find it interesting enough to take for a spin, so I thought I'd
>>> post it here.  At the very least, it's clearly critical for GNU Emacs to
>>> be the most advanced lisp editing environment there is. ;)
>> Oleh's lispy does a similar (though not identical) thing.
> I've looked through the Parinfer web page and I don't think it's a great
> idea (it's a neat trick though):
> - It doesn't solve the problem of pasting unbalanced code.
> - It relies on indentation to guess the thing to do.
> - The thing to do might be surprising.
> + It balances parens for potentially generic commands that know nothing
>   of Parinfer.
> I think the first 3 negative points probably outweigh the single
> positive point. Still, it would be cool to try it if anyone is up for
> implementing it.
> By the way, is anyone else on emacs-devel using lispy?  It's a really
> cool way to quickly navigate, edit, examine, and debug Elisp.  It was
> intended to be an easier Paredit, so picking it up shouldn't be too
> hard, but it will probably take a long while to pick up everything and
> reach top efficiency. See https://github.com/abo-abo/lispy if you're
> interested.
> It also has a bunch of integration tests (I saw this discussed in a
> recent thread). The tests look like this:
>     (should (string= (lispy-with "(|(a) (b) (c))" "j")
>                      "((a) |(b) (c))"))
> The parts are:
> 1. The buffer state before, including point and mark.
> 2. The user input.
> 3. The buffer state after, including point and mark.
> There are around 700 of these tests and they run very fast, around 1.5s
> to finish all of them. I think it would be cool for ERT to have this
> kind of interface, and functions like `forward-list', `up-list',
> `beginning-of-defun' etc could be tested this way.
> These type of tests are also a good way to learn new bindings (since
> they're built into the test), and what they should do in specific
> situations (since it's not easy for the user to experience each
> situation which results in a different branch taken by the command in
> question).

João Távora

reply via email to

[Prev in Thread] Current Thread [Next in Thread]