emacs-devel
[Top][All Lists]
Advanced

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

Re: extending case-fold-search to remove nonspacing marks (diacritics et


From: Artur Malabarba
Subject: Re: extending case-fold-search to remove nonspacing marks (diacritics etc.)
Date: Thu, 5 Feb 2015 23:06:26 +0000

Something essentially identical to this was being discussed here a
couple of weeks ago. Look for the thread "Single quotes in Info". I
wrote a small elisp solution for building this into isearch (which you
can find on the "scratch/isearch-character-group-folding" branch). It
took a different approach to yours, relating characters to regexp, but
it works.

It's not merged because I was advised to looking into using the
case-fold-search machinery.


2015-02-05 20:16 GMT-02:00 Ted Zlatanov <address@hidden>:
> https://emacs.stackexchange.com/questions/7992/how-to-search-an-arabic-word-in-text-without-its-diacritics-accents
> suggested it would be useful if diacritics were ignored when searching
> for text in various situations. This is similar to `case-fold-search'
> but more generic. Here's what I suggested as the answer at the ELisp
> level:
>
> #+begin_src emacs-lisp
> (defun kill-marks (string)
>   (concat (loop for c across string
>                 when (not (eq 'Mn (get-char-code-property c 
> 'general-category)))
>                 collect c)))
>
> (let* ((original1 "your Arabic string here")
>       (normalized1 (ucs-normalize-NFKD-string original1))
>       (original2 "your other Arabic string here")
>       (normalized2 (ucs-normalize-NFKD-string original2)))
>   (equal
>    (replace-regexp-in-string "." 'kill-marks normalized1)
>    (replace-regexp-in-string "." 'kill-marks normalized2)))
> #+end_src
>
> This would probably be useful for other languages, not just Arabic. But
> implementing it for users so it works like `case-fold-search' (you just
> set something in Customize and all search commands DWYM) seems much
> harder. Does anyone have suggestions? Maybe some defadvice magic? Or is
> it not possible?
>
> Thanks
> Ted
>
>



reply via email to

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