[Top][All Lists]

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

Re: keep|flush-lines, how-many to be used backward.

From: Michaël Cadilhac
Subject: Re: keep|flush-lines, how-many to be used backward.
Date: Fri, 28 Sep 2007 11:32:07 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux)

Juri Linkov <address@hidden> writes:

>>> What do you think about using a negative argument to operate before point?
>>> Many Emacs commands change their direction when the argument is negative,
>>> e.g. for `kill-sexp' the negative arg means kill sexps before point, etc.
>> Well, on the one hand, I understand what 18 kill-sexp does.  It kills 18
>> sexps, and this is fine if you want to kill that much sexps.  On the
>> other hand, what does 18 how-many means?
>> You're asking for a differentiation between a positive and a negative
>> argument, but what is the *purpose* of the value of this argument?
> My purpose was to propose to reserve C-u for other possible future uses.

I fully understand that a prefix argument changes the behavior of a
function ; I fully understand that a numeric prefix argument repeats the
action that much time, or by modifying N times its behavior.

What I fail to agree with, is that a prefix argument can be a
three-state boolean : present, negative or positive.  I think it's just
a hack, and should not be used like that.  A user that sees that C-u and
C-- has different behavior will try to figure out what C-9 will do, but
it'd be nonsense.  Don't you agree?

> Using C-u now to change the direction will prevent these commands from
> extending to do more useful things in future.

If I continue in your way, I think you are suggesting that we don't use
the prefix value 2 in M-x search because it can be used for future
features.  It's a little bit extreme, but wanting to differentiate = 0, < 0
and > 0 will eventually lead to this.

To sum up, I think the prefix argument has only two use cases :
- As a boolean (present/absent),
- As a number.

Wanting to mix those two is, to me, a hack.

If we're going to camp on our positions :-) does someone else have an
opinion ?

>>> keep|flush-lines, how-many could do the same, e.g. `M-- M-x keep-lines'.
>> M-- puts a prefix of -1, so M-- M-x keep-lines would be the same as M-u
>> M-x keep-lines.
> `M-- M-x keep-lines' is the same as `C-u - M-x keep-lines'
> (see `prefix-numeric-value').

I was saying that, with the first proposal, C-- would have the same
behavior than C-u.

> Please also note that usually the command should have parameters it reads
> in its function arguments.  So it's better to change

> (defun keep-lines (regexp &optional rstart rend interactive direction)

Well, this is another matter.  I want to do the following with those
three functions :
- Remove the `interactive' flag (it's silly),
- Remove the `optional'.

That way, `direction' is not needed, as the caller should provide rstart
and rend (like in nearly all the functions that take a region -- as a
first count, 90%).  The direction is just an interactive help.

 |   Michaël `Micha' Cadilhac       |    The second-degree,                  |
 |   http://michael.cadilhac.name   |       is kind of                       |
 |   JID/MSN:                       |   the semantic back slang.             |
 `----  address@hidden  |                                   -  --'

Attachment: pgptctA7hZQ0J.pgp
Description: PGP signature

reply via email to

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