all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Barzilay <eli@barzilay.org>
To: Juri Linkov <juri@jurta.org>
Cc: 4136@emacsbugs.donarmstrong.com
Subject: bug#4136: 23.1; delete-pair
Date: Sat, 15 Aug 2009 20:00:22 -0400	[thread overview]
Message-ID: <19079.19478.357436.68768@winooski.ccs.neu.edu> (raw)
In-Reply-To: <87ab20znhd.fsf@mail.jurta.org>

On Aug 16, Juri Linkov wrote:
> >> 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.

Of course it isn't, but the operation is one that negates in what it
"generally does" the thing that `insert-foo' does.  Just like
`scroll-down' and `scroll-up' are opposites even though they don't
always cancel out.


> > 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.

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.)  Still, the first time I tried
this, the cursor was at the beginning of an indented line.  But the
point is still the same: having two nearly identical functions is
exactly what prefix arguments are for.


> 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.


> >> 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.

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.


On Aug 16, Juri Linkov wrote:
> >> This is fixed in the following version:
> >>
> >> (defun delete-pair ()
> >>   "Delete a pair of characters enclosing the sexp that follows point."
> >>   (interactive)
> >>   (save-excursion
> >>     (forward-sexp 1)
> >>     (save-excursion
> >>       (backward-sexp 1)
> >>       (skip-syntax-forward "'")
> >>       (delete-char 1))
> >>     (delete-char -1)))
> >
> > Still doesn't seem TDTRT with `point' before something like
> >
> >        `foo'
> 
> 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.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!





  reply	other threads:[~2009-08-16  0:00 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-13  6:22 bug#4136: 23.1; delete-pair Eli Barzilay
2009-08-13  9:53 ` martin rudalics
2009-08-13 23:29   ` Juri Linkov
2009-08-14  1:18     ` Eli Barzilay
2009-08-14 15:50       ` Stefan Monnier
2009-08-14 22:45       ` Juri Linkov
2009-08-15  1:46         ` Eli Barzilay
2009-08-15 23:06           ` Juri Linkov
2009-08-16  0:00             ` Eli Barzilay [this message]
2009-08-17  0:46               ` Juri Linkov
2009-08-17  3:13                 ` Eli Barzilay
2009-08-17 21:17                   ` Juri Linkov
2009-08-18  7:13                     ` martin rudalics
2009-08-19  0:48                       ` Juri Linkov
2020-09-14 14:08                       ` Lars Ingebrigtsen
2020-09-14 19:12                         ` Juri Linkov
2020-09-15 12:27                           ` Lars Ingebrigtsen
2020-09-15 18:07                             ` Juri Linkov
2020-09-17 14:45                               ` Lars Ingebrigtsen
2020-09-18  8:35                                 ` Juri Linkov
2020-09-18 10:59                                   ` Lars Ingebrigtsen
2020-09-21 19:12                                     ` Juri Linkov
2020-09-22 14:45                                       ` Lars Ingebrigtsen
2020-09-22 18:18                                         ` Juri Linkov
2020-09-23 13:15                                           ` Lars Ingebrigtsen
2020-11-12 20:21                                             ` Juri Linkov
2020-11-12 21:16                                               ` Basil L. Contovounesios
2020-11-13  8:29                                                 ` Juri Linkov
2020-11-16 20:55                                                   ` Juri Linkov
2020-11-16 21:37                                                     ` Drew Adams
2009-08-16 10:27             ` martin rudalics
2009-08-18  3:10           ` Stefan Monnier
2009-08-19  0:47             ` Juri Linkov
2009-08-15 10:11         ` martin rudalics
2009-08-14  7:17     ` martin rudalics
2009-08-14 22:45       ` Juri Linkov
2009-08-15 10:11         ` martin rudalics
2009-08-15 23:03           ` Juri Linkov
2009-08-16 10:27             ` martin rudalics
2009-08-13 23:28 ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19079.19478.357436.68768@winooski.ccs.neu.edu \
    --to=eli@barzilay.org \
    --cc=4136@emacsbugs.donarmstrong.com \
    --cc=juri@jurta.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.