From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: parinfer-mode for Emacs might be neat for encouraging Lisp adoption Date: Fri, 13 Nov 2015 15:34:05 +0000 Message-ID: References: <877flow194.fsf@dustycloud.org> <871tbv4c9a.fsf@mbork.pl> <874mgq879a.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1447428884 13880 80.91.229.3 (13 Nov 2015 15:34:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 13 Nov 2015 15:34:44 +0000 (UTC) Cc: Christopher Allan Webber , Emacs developers To: Oleh Krehel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 13 16:34:38 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZxGMx-0005tW-UK for ged-emacs-devel@m.gmane.org; Fri, 13 Nov 2015 16:34:32 +0100 Original-Received: from localhost ([::1]:53651 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxGMx-0000aQ-8X for ged-emacs-devel@m.gmane.org; Fri, 13 Nov 2015 10:34:31 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxGMt-0000Xs-2h for emacs-devel@gnu.org; Fri, 13 Nov 2015 10:34:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZxGMr-0000Ge-Ic for emacs-devel@gnu.org; Fri, 13 Nov 2015 10:34:27 -0500 Original-Received: from mail-io0-x234.google.com ([2607:f8b0:4001:c06::234]:35237) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZxGMr-0000GP-D7 for emacs-devel@gnu.org; Fri, 13 Nov 2015 10:34:25 -0500 Original-Received: by ioc74 with SMTP id 74so100638709ioc.2 for ; Fri, 13 Nov 2015 07:34:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=81o2cimycZcH08QNIr/IOY8DhUcHvykT/Sxb3Zhl0UU=; b=FyOcXlrBabVEwysjsPQ17WNLGTxYCgtsAXQvCyxFG8u4RxJZdWEXIf7AFYjWBbNXPa D8uWAMHsn7sQzhUfCEtupY2DqANHV9S6XcEaxmiXV7YGbaamMMwiiVQThzlZGNNyYeI1 N3TMykhp7pcL9icPQrHJ0xp0x558Yow85Dpg5Q+3dMSXPBMGfHIsnN2GeyaL7L6ljdvx l5KM8gXlIUu7xsTbTESFAb6RYN/m4okyvxCHrrjvxXyLnNJqwMUSi3SoUFcSoj6+s8QG 3DLjgVLwab22KyHkxetEaqMtfh35tK3GAgQ3K0bFNjv5Ix4RC7H2Y4H/ZKGjyC3DlLfU c0kg== X-Received: by 10.107.10.24 with SMTP id u24mr24639357ioi.22.1447428864788; Fri, 13 Nov 2015 07:34:24 -0800 (PST) Original-Received: by 10.107.169.154 with HTTP; Fri, 13 Nov 2015 07:34:05 -0800 (PST) In-Reply-To: <874mgq879a.fsf@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c06::234 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:194374 Archived-At: 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 () (ignore-errors (save-excursion (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 wrote: > Marcin Borkowski writes: > >> On 2015-11-12, at 00:30, Christopher Allan Webber 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 t= o >>> 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=3D (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). > --=20 Jo=C3=A3o T=C3=A1vora