bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#27896: 25.2; `C-M-%' with `rectangle-mark-mode'


From: Drew Adams
Subject: bug#27896: 25.2; `C-M-%' with `rectangle-mark-mode'
Date: Mon, 31 Jul 2017 21:17:15 -0700 (PDT)

emacs -Q

In *scratch*:

1. Duplicate the two lines of text, to get this:

;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-x C-f and enter text in its buffer.
;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with C-x C-f and enter text in its buffer.

2. Activate the region from before the `T' in the first `This' to after
   the `f' in the second `file', with point before the `T'.  Then `M-x
   rectangle-mark-mode'.

3. `C-M-%' and type `e.*t' for the regexp and `AA' for the replacement
   text.

I was expecting both occurrences of "eat" (inside "create") to be
candidates for replacement, since they are both within the rectangle and
they both match the regexp - but only the second occurrence is a
candidate for replacement.

(If you use regexp `e.t' instead, there is no such error.)

It seems that what is happening is that the regexp is being checked
against the full region, i.e., before the region is limited to the
rectangular portion.

Is that the design?  I think a user would expect the rectangle to define
the region of possible query-replacing, not just define a clipping area
from the full region of searching.  IOW, I think a user would expect the
rectangular limits to be established first, and then searching to be
limited to that rectangular space.

If nothing else, if this is the intended design then I think the doc
should be clear about it.  It should say, in that case, that matches are
sought throughout the full, non-rectangular region, and only those
matches that are wholly (?) within the rectangle are then retained as
possible matches.

My guess of what's happening is supported by this: If you do the same
thing (same region) but without using `rectangle-mark-mode' then you see
that rectangle mark mode just retains the matches for the normal,
non-rectangular region, that are wholly within the rectangle.

Here are the matches for the normal, non-rectangular region:

;; This buffer is for text that is not saved, and for Lisp evaluation.
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; To create a file, visit it with C-x C-f and enter text in its buffer.
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; This buffer is for text that is not saved, and for Lisp evaluation.
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; To create a file, visit it with C-x C-f and enter text in its buffer.
        ^^^

This should be documented, as it is not, I think, what someone expects
by searching a rectangular region (a region delimited by a rectangle).
I think someone would expect that the search domain is limited by the
rectangle, and then query-replace applies to matches within that domain.

That's very different from the current behavior, which is to leave the
search domain as the full region (undelimited by the rectangle) and then
filter out (remove) any matches from that that are not wholly within the
rectangle.



In GNU Emacs 25.2.1 (x86_64-w64-mingw32)
 of 2017-04-24 built on LAPHROAIG
Windowing system distributor 'Microsoft Corp.', version 6.1.7601
Configured using:
 'configure --without-dbus --without-compress-install 'CFLAGS=-O2
 -static -g3''





reply via email to

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