[Top][All Lists]

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

flush-lines and keep-lines

From: Luc Teirlinck
Subject: flush-lines and keep-lines
Date: Wed, 15 Jun 2005 22:17:48 -0500 (CDT)

There are some inconsistencies between flush-lines and keep-lines, if
they operate on a region that contains partial lines.

If point is not at the beginning of a line, `flush-lines' gets rid of
the line point is on if and only if the part of the line _after_ point
contains a match for the regexp.  `keep-lines' unconditionally keeps
that line.  This difference in philosophy might not be too bad and
could just be documented.

With transient mark mode enabled and an active region, a partial line
at the beginning of the region is treated as above.  Might again not
be too bad.  `flush-lines' erases a partial line at the end of the
region if and only if the part _inside the region_ contains a match for
regexp, thereby being consistent with its own behavior for the line at
the beginning of the region.  But the behavior of `keep-lines' there
seems very unexpected.

Take a buffer with the following three lines:


If the region starts at 2 and ends at 5 (both _inclusive_)

M-x keep-lines RET 7 RET results in:


The last line got _partially_ erased.  The docs seem to suggest that
keep-lines should keep or erase entire lines, not parts of them, even
in the presence of partial lines.

To make the behavior of `keep-lines' symmetric at both ends of the
region, the last line should be unconditionally kept in its entirety.

Maybe the difference with flush-lines could then be explained by the
principle:  If you are not sure, just by looking at the region,
whether to erase or keep, then keep the line.

You can never be sure by looking only at part of a line that the
entire line does _not_ contain a match, so keep-lines always needs to
keep all partial lines.  But if the part you are seeing contains a
match, you _know_ that flush-lines needs to erase it.



reply via email to

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