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: Juri Linkov
Subject: Re: keep|flush-lines, how-many to be used backward.
Date: Wed, 26 Sep 2007 00:49:09 +0300
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

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

For example, the argument of `C-u C-s' turns string isearch into
regexp isearch.  Since keep-lines and co works with regexps by default,
C-u could be used to read and search the string.

Another example is query-replace from the same file replace.el.
`C-u M-%' replaces delimited matches surrounded by word boundaries,
but I think this is less useful for keep-lines than using C-u to
search strings instead of regexps.

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

OTOH, there is a good tradition to use the negative argument to change the
direction in which the command operates.  Since this requires the argument
to be numeric, we could find a way to interpret this number usefully.
For example, this number could count lines or paragraphs to operate on.

But this could be implemented later when someone comes with a good idea
of using the number.  For now, -1 (`M--') could mean operating in the
opposite direction.  This argument will have a good mnemonics.

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

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)

to

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

or better to more general:

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

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




reply via email to

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