all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Luc Teirlinck <teirllm@dms.auburn.edu>
Subject: flush-lines and keep-lines
Date: Wed, 15 Jun 2005 22:17:48 -0500 (CDT)	[thread overview]
Message-ID: <200506160317.j5G3Hmp26222@raven.dms.auburn.edu> (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.

             reply	other threads:[~2005-06-16  3:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-16  3:17 Luc Teirlinck [this message]
2005-06-16 16:24 ` flush-lines and keep-lines Richard Stallman
2005-06-17  3:00   ` Luc Teirlinck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200506160317.j5G3Hmp26222@raven.dms.auburn.edu \
    --to=teirllm@dms.auburn.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.