diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2022-01-17 16:24:17 +0100 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-01-17 16:24:17 +0100 |
commit | a1ffee1e82b7152772da86a3adc7513128ffefdf (patch) | |
tree | 4b708c7f244a2944b58ffd482b748f12ff3b3253 /lisp | |
parent | 523a96a99ed7fe21c945b8e1cd0e3a2bc76c4ba0 (diff) | |
download | emacs-a1ffee1e82b7152772da86a3adc7513128ffefdf.tar.gz emacs-a1ffee1e82b7152772da86a3adc7513128ffefdf.tar.bz2 emacs-a1ffee1e82b7152772da86a3adc7513128ffefdf.zip |
Add textsec-restriction-level function
* lisp/international/textsec.el (textsec-restriction-level): New
function.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/international/textsec.el | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lisp/international/textsec.el b/lisp/international/textsec.el index 884425d4922..fc809d52c1d 100644 --- a/lisp/international/textsec.el +++ b/lisp/international/textsec.el @@ -97,6 +97,58 @@ Not that a string may have several different minimal cover sets." (setq set (seq-union set (seq-difference s set)))) (sort (delq 'common (delq 'inherited set)) #'string<))) +(defun textsec-restriction-level (string) + "Say what restriction level STRING qualifies for. +Levels are (in order of restrictiveness) `ascii-only', +`single-script', `highly-restrictive', `moderately-restrictive', +`minimally-restrictive' and `unrestricted'." + (let ((scripts (textsec-covering-scripts string))) + (cond + ((string-match "\\`[[:ascii:]]+\\'" string) + 'ascii-only) + ((textsec-single-script-p string) + 'single-script) + ((or (null (seq-difference scripts '(latin han hiragana katakana))) + (null (seq-difference scripts '(latin han bopomofo))) + (null (seq-difference scripts '(latin han hangul)))) + 'highly-restrictive) + ((and (= (length scripts) 2) + (memq 'latin scripts) + (seq-intersection scripts + '(arabic + armenian + bengali + bopomofo + devanagari + ethiopic + georgian + gujarati + gurmukhi + hangul + han + hebrew + hiragana + katakana + kannada + khmer + lao + malayalam + myanmar + oriya + sinhala + tamil + telugu + thaana + thai + tibetan))) + ;; The string is covered by Latin and any one other Recommended + ;; script, except Cyrillic, Greek. + 'moderately-retrictive) + ;; Fixme `minimally-restrictive' -- needs well-formedness criteria + ;; and Identifier Profile. + (t + 'unrestricted)))) + (provide 'textsec) ;;; textsec.el ends here |