Subject: Re: bug#4136: 23.1; delete-pair

From: Juri Linkov <[email-masked]>
Date: Mon, 17 Aug 2009 03:46:46 +0300

> Believe me, I've written a paren or two, and I use `insert-pair'
> enough to have my own improved version of it.  (In fact, guess why I
> almost never use smileys in emails.)

You can write smileys using the closing parenthesis (but we should
improve `delete-pair' to delete smileys completely after deleting the
closing parenthesis ;-)

> Still, the first time I tried this, the cursor was at the beginning of
> an indented line.

Where did you get this weird idea that `delete-pair' should delete
a character far away from the current cursor position?  Look,
`insert-char' inserts a character at point and `delete-char' deletes
a character at point.  `insert-pair' inserts an opening character
at point.  So why `delete-pair' shouldn't do the same?  Why it shouldn't
delete an opening character at point instead of using some additional
heuristics to find the position of the opening character?

>> 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.
>
> ... unless you happen to have your cursor on a non-paren.

Why would I want to put cursor on a non-paren when I want to delete a paren?

>> > 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.
>
> You've missed my point: the difference between "y" and "'y" is *huge*,
> changing one to the other is something that you don't want to do by
> mistake.

99% of time when you write a program it is in the erroneous state until
you finish editing.  But this doesn't mean we should disallow the user
to have an intermediate erroneous state.  So of course, in the above
example you can add necessary quotes after deleting a pair of parentheses.

>> I know, I know, after I fix this, you'll come up with another
>> test case like
>>
>>          `foo bar'
>
> Those examples are very good IMO -- it's not being picky for nothing,
> it's an attempt to avoid nasty surprises that make you end up with
> erroneous code.  Emacs is usually good at being a careful editor for
> code, `delete-pair' is very exceptional in this aspect.

Emacs is good at following the KISS principle to not over-engineer
simple functions.

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