[Top][All Lists]

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

Re: Yanking in isearch mode

From: Kevin Rodgers
Subject: Re: Yanking in isearch mode
Date: Thu, 03 Jun 2010 02:41:06 -0600
User-agent: Thunderbird (Macintosh/20100228)

Drew Adams wrote:
>> The yank with M-y is all lower case and then the i-search
>> becomes case insensitive. Is their any way it can preserve the case?
> Sounds like a bug. But see below.
> What should happen is that search always respects `case-fold-search'.
> And that include `M-y' yanking.
> Suppose you copy some text "ABC" to the kill ring.  If `case-fold-search' is
> non-nil when you use `M-y' then it yanks "abc" and search is case-insensitive.
> But if `case-fold-search' is nil when you use `M-y' then it yanks "ABC" and
> search is case-sensitive.
> You can toggle case-sensitivity during isearch with `M-c'. However, that 
> change the search string.  So if search is case-insensitive and the search
> string is "abc" then it stays "abc" after `M-c' and it searches for only
> lower-case "abc".

M-c is bound to isearch-toggle-case-fold, which does:

  (setq isearch-case-fold-search
        (if isearch-case-fold-search nil 'yes))

And isearch-case-fold-search has this comment:

; case-fold-search while searching.
;   either nil, t, or 'yes.  'yes means the same as t except that mixed
;   case in the search string is ignored.
(defvar isearch-case-fold-search nil)

But `yes' is not treated specially in isearch.el -- so what is that all

Also, M-y is bound to isearch-yank-kill, which calls
isearch-yank-string, which does:

  ;; Downcase the string if not supposed to case-fold yanked strings.
  (if (and isearch-case-fold-search
           (eq 'not-yanks search-upper-case))
      (setq string (downcase string)))

But search-upper-case defaults to `not-yanks', and it is not modified
in isearch.el:

(defcustom search-upper-case 'not-yanks
  "*If non-nil, upper case chars disable case fold searching.
That is, upper and lower case chars must match exactly.
This applies no matter where the chars come from, but does not
apply to chars in regexps that are prefixed with `\\'.
If this value is `not-yanks', yanked text is always downcased."
  :type '(choice (const :tag "off" nil)
                 (const not-yanks)
                 (other :tag "on" t))
  :group 'isearch)

So it seems that the statement "If this value is `not-yanks', yanked
text is always downcased" is not true, since isearch-yank-string also
depends on isearch-case-fold-search.

Are the `yes' and `not-yanks' values of isearch-case-fold-search and
`search-upper-case' respectively really needed, or are they cruft?

> You can always use `M-e' to edit the search string - e.g. `M-u' to make words
> there uppercase.

Kevin Rodgers
Denver, Colorado, USA

reply via email to

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