unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* extending case-fold-search to remove nonspacing marks (diacritics etc.)
@ 2015-02-05 22:16 Ted Zlatanov
  2015-02-05 23:06 ` Artur Malabarba
  2015-02-06  7:29 ` Eli Zaretskii
  0 siblings, 2 replies; 18+ messages in thread
From: Ted Zlatanov @ 2015-02-05 22:16 UTC (permalink / raw)
  To: emacs-devel

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




^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2015-02-07 12:59 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-05 22:16 extending case-fold-search to remove nonspacing marks (diacritics etc.) Ted Zlatanov
2015-02-05 23:06 ` Artur Malabarba
2015-02-05 23:17   ` Artur Malabarba
2015-02-06  0:54     ` Juri Linkov
2015-02-06  2:32       ` Artur Malabarba
2015-02-06  2:51         ` Artur Malabarba
2015-02-06  7:48         ` Eli Zaretskii
2015-02-06  9:06           ` Artur Malabarba
2015-02-06  9:41             ` Eli Zaretskii
2015-02-06 10:03               ` Artur Malabarba
2015-02-06 10:04               ` Eli Zaretskii
2015-02-06  4:58     ` Stephen J. Turnbull
2015-02-06  7:51       ` Eli Zaretskii
2015-02-06 14:50         ` Stefan Monnier
2015-02-06 14:54           ` Eli Zaretskii
2015-02-06  7:35     ` Eli Zaretskii
2015-02-06  7:29 ` Eli Zaretskii
2015-02-07 12:59   ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).