Subject: bug#4136: 23.1; delete-pair

From: Juri Linkov <[email-masked]>
Date: Sun, 16 Aug 2009 02:06:06 +0300

>> It seems you and Martin prefer checking against the
>> `insert-pair-alist' because the function name `delete-pair' suggests
>> it should be a counterpart of `insert-pair'.
>
> ...this is exactly the issue: it is much better if `delete-foo' is
> always an operation that reverts what `insert-foo' does.

The exact reverse is impossible.  For instance, put the cursor
on the letter `f' in:

    foo "" bar

and type `M-3 M-"' where M-" is bound to `insert-pair'.
The result will be:

    "foo "" bar"

Now what `delete-pair' should do to revert this back to the original?

> The current state of `delete-pair' is so bad that my guess is that
> hardly anyone used it, so adding another command doesn't make much
> sense.  How about making it do the proper thing (removing only
> balanced pairs as specified by `insert-pair-alist'), and ignoring
> errors with a prefix argument?

I've been using `delete-pair' for many years several times a day
without any problem because my lists are always correctly balanced
thanks to `insert-pair' that I exclusively use to create balanced
lists and strings.

That's why even in the current state of `delete-pair' it is the useful
reverse of `insert-pair' because the latter creates balanced lists
and the former deletes them.

>> This is fixed in the following version:
>> [...]
>
> This version doesn't make much sense as an operation you'd want to do
> on code:
>
>   (foo '(x y z))
>   -->
>   (foo 'x y z)

It makes sense when `foo' is a multi-argument function like `list', e.g.

    (list 'x y z)

So I see no reason to introduce more restrictions to decide what
parens the user is allowed to delete in his/her code.

-- 
Juri Linkov
http://www.jurta.org/emacs/