emacs-devel
[Top][All Lists]
Advanced

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

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


From: Drew Adams
Subject: RE: keep|flush-lines, how-many to be used backward.
Date: Fri, 28 Sep 2007 08:50:33 -0700

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

Yes (since you asked), FWIW, and without reference to the specific
prefix-arg use in this thread -

A raw prefix arg can have different kinds of values (nil, consp, integer
(negative, zero, positive)), and the numeric values of these different raw
values can also be used. Functions should be free to use any of these values
(both raw and numeric) as they like. There should be no limits or
conventions that restrict this.

However, functions that interpret a prefix arg owe it to their users to
clearly explain the behavior of the prefix arg in the doc string. As long as
that is done, I see no problem.

However #2: Other things being equal, there are some common use patterns
that can be followed (can be, not need to be), and that can make life easier
for users:

* positive numeric arg N means repeat N times

* -N means reverse the "direction" of N, whatever "direction" might mean in
a particular context.

* the default behavior (without any explicit prefix arg) should be the
behavior that users will use most

In sum:

1. No strict convention or standard meaning that limits what you do with a
function you define.

2. If there is no reason not to, you might want to follow some common use
patterns, interpreting them as appropriate in your context.

3. Document all prefix-arg behavior clearly in the doc string.

A prefix arg is a useful way to multiply the functionality of a single
function, typically a command that is bound to a key. Programmers should not
feel limited in any way in the use they make of prefix args. Explore,
experiment, do what you want with it; it's just a tool. If you want to make
things easier on users, however, and if there is no reason not to, then you
might want to follow some informal conventions - it's up to you.

Just my opinion, of course.







reply via email to

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