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

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

Re: automatic selection during search


From: Yuri Khan
Subject: Re: automatic selection during search
Date: Tue, 1 Oct 2013 10:56:49 +0700

On Tue, Oct 1, 2013 at 3:05 AM, Barry Margolin <address@hidden> wrote:

>> C-space, C-s foo RET
>>
>> Now you have marked the region between where you were and the next "foo", so
>> you can kill it or copy it.
>>
>> This is the use case that get supported by C-s not disabling the mark.  Maybe
>> you don't need it.
>
> That's the case he says he "understands". His post is about a different
> situation, where he first copies to the clipboard and then starts a new
> search.
>
> But no one else seems to be able to reproduce this behavior.

OK, recipes.

I start “emacs -Q”.

Help | About Emacs
=> […] GNU Emacs 24.2.1 (x86_64-pc-linux-gnu, GTK+ Version 3.6.4)
 of 2013-04-09 on allspice, modified by Debian […]

C-x k RET
=> *scratch* buffer is current, with its default text:
===
;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.
===

M-: cua-mode
=> nil

M-: transient-mark-mode
=> t

M-: shift-select-mode
=> t

::: Test 1a :::

Using arrows, move the point before “This”.

C-SPACE
=> Mark set

Move point with arrows
=> selection extends
(expected, because of explicit request for persistent mark)

::: Test 1b :::

Move the point back before “This”.

C-SPACE C-s for
=> ;; [This buffer is for] notes you…
(expected, because of explicit request for persistent mark)

Move point with arrows
=> selection shrinks and extends
(expected)

C-SPACE C-SPACE
=> Mark set
=> Mark deactivated

::: Test 2a :::

Move point back before “This”.
S-<right>
=> ;; [T]his buffer…

Move point with arrows
=> selection deactivates
(expected, because the mark is transient)

::: Test 2b :::

Move point back before “This”.
Shift+Right arrow
=> ;; [T]his buffer…

C-s for
=> ;; [This buffer is for] notes you…
(unexpected, because the mark is transient and should be deactivated
by the cursor movement)

::: Test 3a :::

Move point back before “This”.
C-S-<right>
=> ;; [This] buffer…

C-<insert>
=> ;; This| buffer…
(ok, maybe it’s customary in non-cua land)

C-s for
=> ;; This buffer is for| notes you…

::: Test 3b :::

M-x cua-mode
=> Cua mode enabled

Move point back before “This”.
C-S-<right>
=> ;; [This] buffer…

C-c
=> ;; This| buffer…
(unexpected, and not what I experience in my usual configuration.
Turns out I have (setq cua-keep-region-after-copy t) in my
.emacs.d/init.el)

C-s for
=> ;; This buffer is for| notes you…

::: Test 3c :::

(still in cua-mode)

M-x set-variable cua-keep-region-after-copy t

Move point back before “This”.
C-S-<right>
=> ;; [This] buffer…

C-c
=> ;; [This] buffer…
(now things are the way I am used to)

C-s for
=> ;; [This buffer is for] notes you…
(unexpected, because the mark is transient and C-s is a cursor movement command)

::: Test 3d :::

(still in cua-mode, with cua-keep-region-after-copy set to t)

Move point back before “This”.
C-S-<right>
=> ;; [This] buffer…

C-c
=> ;; [This] buffer…

Move point with arrow keys
=> selection is cleared

-----

OK, so cua-mode is not the reason. Neither is copying (aside from the
fact that it clears selection by default).

My current understanding is that C-s never clears selection, even in
transient-mark-mode (and I consider this a bug). So, when I copy
something, it remains selected (because of
cua-keep-region-after-copy), and then C-s extends selection. The crude
workaround that I am able to come up with, without having to read and
understand all of isearch, is the following advice:

===
(defadvice isearch-search-string (after yk-isearch-transient (string
bound noerror) activate)
  (when (and ad-return-value     ;; isearch found something
             transient-mark-mode ;; and we are in transient-mark-mode
             (not cua--explicit-region-start)) ;; and don’t have an
explicit persistent mark
    (cua--deactivate)))
===

The question remains why Peter Dyballa mentioned C-INSERT as one of
the keys not to press before C-s.



reply via email to

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