Subject: Re: bug#21140: 25.0.50; Isearch "char-fold" by default

From: Daniel Colascione <[email-masked]>
Date: Mon, 27 Jul 2015 18:16:47 -0700

On 07/27/2015 07:50 AM, Artur Malabarba wrote:
>> > Char fold search is a text search, not a regexp search. It does use
>> > a regexp underneath, but that should be invisible to the user. You
>> > type some text and it matches that text or similar texts.
>>
>> "Char fold" search is a "fuzzy" search, then, similar to
>> https://github.com/auto-complete/fuzzy-el?
> 
> Not quite. It just allows simple ascii characters to match their complex
> unicode counterparts.
> For instance, if you search for "a" you will also match "á" and "ã".
> 
>> What comes the name "char fold" from?  It's not very intuitive to me
>> that it's some sort of fuzzy search; moreover, it looks like "case fold"
>> search, which is again something different...
> 
> It is exactly like case fold. ;-)
> Where case folding folds together "a" and "A", char folding folds
> together "a", "á" and "ã".
> 
> The name is also something under discussion. Suggestions of something
> more intuitive are very much welcome.
> 

I've been using this bit of awfulness to solve the "char-fold" thing. It
hides "char-fold" by default and displays "raw" if we've turned off
char-folding. It still displays "raw regex isearch" though.

I like the idea of taking over the modeline to display isearch state.

(defun fix-isearch--describe-word-mode (word-mode &optional space-before)
  (let ((description
         (cond ((eq word-mode 'character-fold-to-regexp) "")
               ((and (symbolp word-mode)
                    (get word-mode 'isearch-message-prefix))
                (get word-mode 'isearch-message-prefix))
               (word-mode "word ")
               (t "raw "))))
    (if space-before
        ;; Move space from the end to the beginning.
        (replace-regexp-in-string "\\(.*\\) \\'" " \\1" description)
      description)))

(when (fboundp 'isearch--describe-word-mode)
  (advice-add 'isearch--describe-word-mode
              :override
              'fix-isearch--describe-word-mode))