help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: on adding a function call to a s-exp


From: João Távora
Subject: Re: on adding a function call to a s-exp
Date: Tue, 12 Jun 2018 17:24:12 +0100

On Tue, Jun 12, 2018 at 4:14 PM, Óscar Fuentes <ofv@wanadoo.es> wrote:

> João Távora <joaotavora@gmail.com> writes:
>
> >> I'll choose to use paredit and learn how to use it properly.  (There'll
> >> likely be other good things there that I don't currently know or use.)
> >>
> >
> > I suggest you also give (the newer, 24.4+) eletric-pair-mode a try.  It
> > should work consistently in all emacs major modes, not just lisp
> > modes, and is maintained together with Emacs. By default, in
> > emacs-lisp-mode you won't notice a difference to paredit for the most
> > common operations (you *will* notice that it lets you unbalance the
> > buffer temporarily though, but I consider that a feature).
>
> electric-pair-mode offers a tiny fraction of the features of paredit.
> The later takes some time to learn, but in my experience the effort pays
> off if you work with lispy languages.
>

OK let's bikeshed a bit here :-)

What you say is of course true for some definition of tiny, and for
some definition of the disadvantages of being tiny, which, when
compared to being bloated, are very few.

Indeed, as you say, learning-curve-wise there are exactly 0 new
commands to learn in electric-pair-mode, versus 72 in paredit, a net
gain of infinity :-).

I would add that e-p-m also doesn't surprise newcomers regardless if
you're coming from another major mode, or from Window notepad.

My main gripe with paredit is not that it forces structural integrity,
it's that it doesn't force it completely: there are many situations
where it becomes confused.  Here's an example:

   "
   some string
   "  "
   another string
   "

In paredit, I must admit to liking that C-k in the first line blows
away the whole string: it's nice because doing so would unbalance the
buffer.  But annoingly, I can't C-k the middle line to join the two
strings, which would equally result in a balanced buffer.  And neither
does it kill both strings, which would be slightly more annoying but
still reasonable in paredit-land.  Instead it does nothing.  So I
select the line and kill the region.  Emacs now complies,
unconsistently and surpsingly.  And yep, as you've guessed it, I can
delete one of the quotes in middle line.  And now comes the worse
part, because trying to rebalance is impossible (bar C-q antics and
M-x paredit-mode to turn it off):

(1) typing a quote in the middle line gives you two quotes,
    leaving the buffer unbalanced.

(2) typing a quote in the last line gives you a "scan error" about
    unbalanced parentheses.

(3) As does trying to delete the last quote, that also signals an
    error.  And deleting the first line now errors, too. grrr :-)

In (1) and (2), electric-pair-mode would notice the temporary and only
insert one quote, after which it would of course resume autopairing
and autoskipping.

The example is only short for illustrative purposes: it can happen
when applying diff hunks or editing some merge-conflicted lisp file.
Or just if you happen to use the region.

João

PS: writing this in message-mode where smileys have special syntax so
electric-pair-mode keeps working :-)


reply via email to

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