help-gnu-emacs
[Top][All Lists]
Advanced

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

A simpler, gentler version of char-fold-to-regexp


From: Eric Abrahamsen
Subject: A simpler, gentler version of char-fold-to-regexp
Date: Tue, 29 Aug 2017 12:38:00 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Hi,

I'm using char-fold-to-regexp to good effect in a user-facing search
routine: users can enter "Miriam", and match "Míriam".

It's a bit overkill for my purposes, though, as `char-fold-to-regexp'
effectively turns the whole search string into a perfect regexp, whereas
I want users to be able to use regexp-special characters in their search
strings. Ie, I'd like to leave the "^" in "^string" alone, and not turn
it into "[^^]". Really all I want is to create character regexps for
the range [a-zA-Z], and leave everything else alone. No multi-character
matches, no spaces, no char ranges, etc.

I figured it wouldn't be too hard to do a copy-paste number on the code
in char-fold.el, but I'm bogging down a bit at the heart of it. I just
can't wrap my head around what's happening in the
`make-decomp-match-char' internal function, in part because it's simply
doing way more than I need, in part because the unicode decomposition
table returns bytecode, which is confusing.

All I want in that inner function is to say: "If a character (for instance
?í) decomposes to a character within the range [a-zA-Z] (?i), then add
?í to the entry for ?i in my new char-table."

Can anyone show me what that would look like? All the rest of it I can
do.

Thanks,
Eric




reply via email to

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