unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* flush-lines and keep-lines
@ 2005-06-16  3:17 Luc Teirlinck
  2005-06-16 16:24 ` Richard Stallman
  0 siblings, 1 reply; 3+ messages in thread
From: Luc Teirlinck @ 2005-06-16  3:17 UTC (permalink / raw)


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:

12
34
56

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

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

12
6

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.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-06-17  3:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-16  3:17 flush-lines and keep-lines Luc Teirlinck
2005-06-16 16:24 ` Richard Stallman
2005-06-17  3:00   ` Luc Teirlinck

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).