diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2022-01-18 10:24:32 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-01-18 10:24:32 +0100 |
commit | 4eebf528fca6f6f16168c4f76a653353f3598a35 (patch) | |
tree | ed76cf47fff33570e36280836ccf142d7cdc1596 /lisp/international/textsec.el | |
parent | 19fefea1ca567cc08c67a2167f8e366483b1c013 (diff) | |
download | emacs-4eebf528fca6f6f16168c4f76a653353f3598a35.tar.gz emacs-4eebf528fca6f6f16168c4f76a653353f3598a35.tar.bz2 emacs-4eebf528fca6f6f16168c4f76a653353f3598a35.zip |
Add textsec predicates for different types of confusability
* lisp/international/textsec.el (textsec-resolved-script-set)
(textsec-single-script-confusable-p)
(textsec-mixed-script-confusable-p)
(textsec-whole-script-confusable-p): New functions.
Diffstat (limited to 'lisp/international/textsec.el')
-rw-r--r-- | lisp/international/textsec.el | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lisp/international/textsec.el b/lisp/international/textsec.el index 304d69cb894..8095733e097 100644 --- a/lisp/international/textsec.el +++ b/lisp/international/textsec.el @@ -192,6 +192,36 @@ This algorithm is described in: (string char))) (ucs-normalize-NFD-string string))))) +(defun textsec-resolved-script-set (string) + "Return the resolved script set for STRING. +This is the minimal covering script set for STRING, but is nil is +STRING isn't a single script string." + (and (textsec-single-script-p string) + (textsec-covering-scripts string))) + +(defun textsec-single-script-confusable-p (string1 string2) + "Say whether STRING1 and STRING2 are single script confusables." + (and (equal (textsec-unconfuse-string string1) + (textsec-unconfuse-string string2)) + ;; And they have to have at least one resolved script in + ;; common. + (seq-intersection (textsec-resolved-script-set string1) + (textsec-resolved-script-set string2)))) + +(defun textsec-mixed-script-confusable-p (string1 string2) + "Say whether STRING1 and STRING2 are mixed script confusables." + (and (equal (textsec-unconfuse-string string1) + (textsec-unconfuse-string string2)) + ;; And they have no resolved scripts in common. + (null (seq-intersection (textsec-resolved-script-set string1) + (textsec-resolved-script-set string2))))) + +(defun textsec-whole-script-confusable-p (string1 string2) + "Say whether STRING1 and STRING2 are whole script confusables." + (and (textsec-mixed-script-confusable-p string1 string2) + (textsec-single-script-p string1) + (textsec-single-script-p string2))) + (provide 'textsec) ;;; textsec.el ends here |