ctrlf icon indicating copy to clipboard operation
ctrlf copied to clipboard

Support char folding

Open d12frosted opened this issue 5 years ago • 1 comments

Hello,

It seems that ctrlf doesn't support char-fold-to-regexp search mode (see search-default-mode). It would be lovely to get support of this feature as it helps searching text with diacritical marks. For example, consider the following buffer:

Bună dimineața
Buna dimineata

With isearch typing buna matches both variants, while ctrlf matches only the last one.

You can read more about this feature in the documentation of char-fold-to-regexp function or in pretty old post by Artur Malabarba.

Thanks in advance :)

d12frosted avatar Aug 03 '20 15:08 d12frosted

As a workaround, I define the following as my default style. But this doesn't apply char fold when switching to alternate ctrlf styles.

(defun aj/ctrlf-translate-fuzzy-char-fold (input)
  (ctrlf-translate-fuzzy-regexp (char-fold-to-regexp input)))

(add-to-list
 'ctrlf-style-alist
 '(fuzzy-char-fold
   . (:prompt "fuzzy CF"
              :translator aj/ctrlf-translate-fuzzy-char-fold
              :case-fold ctrlf-no-uppercase-literal-p
              :fallback (isearch-forward . isearch-backward))))

(setq ctrlf-default-search-style 'fuzzy-char-fold)

andersjohansson avatar May 25 '21 14:05 andersjohansson