From: Juri Linkov <juri@linkov.net>
To: Artur Malabarba <bruce.connor.am@gmail.com>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: extending case-fold-search to remove nonspacing marks (diacritics etc.)
Date: Fri, 06 Feb 2015 02:54:45 +0200 [thread overview]
Message-ID: <87386jx2m2.fsf@mail.linkov.net> (raw)
In-Reply-To: <CAAdUY-+A6Rz=BSbbOfDxVKPznLwGbZmbi0JUi0EY4=MHrQaW6g@mail.gmail.com> (Artur Malabarba's message of "Thu, 5 Feb 2015 23:17:42 +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.
I see that your branch contains nothing more than was already implemented
a long time ago in bug#13041 where the major stumbling block was
an inefficiency of the regexp-based solution. Could you help to improve it?
> The bright side is that I think this two-char way of writing latin
> accents is much less common (not 100% sure though, it's hard to tell
> the difference). The downside is that I know nothing about other
> languages, so maybe using two chars to represent one char is the
> default behavior in some other languages?
As https://emacs.stackexchange.com/q/7992/478 indicates,
other languages require insertion/deletion of special characters
like diacritics/accents from the search string/buffer for normalization.
When looking for a solution I recommend you to check ucs-normalize.
For example, evaluating:
(require 'ucs-normalize)
ucs-normalize-combining-chars
you can see exactly the same characters
1616 1615 1619 1648 1618 1612 1613 1611 1617 1614
mentioned in https://emacs.stackexchange.com/a/8001/478
Using its corresponding regexp `ucs-normalize-combining-chars-regexp'
is easy in isearch, e.g.:
;; Decomposition search for accented letters.
(define-key isearch-mode-map "\M-sd" 'isearch-toggle-decomposition)
(defun isearch-toggle-decomposition ()
"Toggle Unicode decomposition searching on or off."
(interactive)
(setq isearch-word (unless (eq isearch-word 'isearch-decomposition-regexp)
'isearch-decomposition-regexp))
(if isearch-word (setq isearch-regexp nil))
(setq isearch-success t isearch-adjusted t)
(isearch-update))
(defun isearch-decomposition-regexp (string &optional _lax)
"Return a regexp that matches decomposed Unicode characters in STRING."
(let ((accents (substring ucs-normalize-combining-chars-regexp 0 -1)))
(mapconcat
(lambda (c0)
(concat (string c0) accents "?"))
(replace-regexp-in-string accents "" string) "")))
(put 'isearch-decomposition-regexp 'isearch-message-prefix "deco ")
But this is more inefficient than properly implementing it using case tables.
next prev parent reply other threads:[~2015-02-06 0:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87386jx2m2.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=bruce.connor.am@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.