summaryrefslogtreecommitdiff
path: root/lisp/language
diff options
context:
space:
mode:
authorMattias Engdegård <mattiase@acm.org>2023-07-05 15:25:30 +0200
committerMattias Engdegård <mattiase@acm.org>2023-07-05 19:32:18 +0200
commitd7168e8575794b7af4e7e2bde51ca0663bbc2eac (patch)
treed57f2b92a107b338f5ec470329844594131612bf /lisp/language
parent1dc2d5441e3d7d202ca9d842b73f165a1b2ed42e (diff)
downloademacs-d7168e8575794b7af4e7e2bde51ca0663bbc2eac.tar.gz
Improve some big regexps
* lisp/language/lao-util.el (lao-transcription-pattern): Remove duplicate definition. * lisp/language/tibetan.el (tibetan-regexp, tibetan-precomposed-regexp) (tibetan-precomposition-rule-regexp): Use regexp-opt.
Diffstat (limited to 'lisp/language')
-rw-r--r--lisp/language/lao-util.el19
-rw-r--r--lisp/language/tibetan.el41
2 files changed, 11 insertions, 49 deletions
diff --git a/lisp/language/lao-util.el b/lisp/language/lao-util.el
index 6b9a8984414..33e98a60d63 100644
--- a/lisp/language/lao-util.el
+++ b/lisp/language/lao-util.el
@@ -301,25 +301,6 @@
(defconst lao-transcription-pattern
(concat
"\\("
- (mapconcat 'car lao-transcription-consonant-alist "\\|")
- "\\)\\("
- (mapconcat 'car lao-transcription-semi-vowel-alist "\\|")
- "\\)?\\(\\("
- (mapconcat 'car lao-transcription-vowel-alist "\\|")
- "\\)\\("
- (mapconcat 'car lao-transcription-maa-sakod-alist "\\|")
- "\\)?\\("
- (mapconcat (lambda (x) (regexp-quote (car x)))
- lao-transcription-tone-alist "\\|")
- "\\)?\\)?\\|"
- (mapconcat (lambda (x) (regexp-quote (car x)))
- lao-transcription-punctuation-alist "\\|")
- )
- "Regexp of Roman transcription pattern for one Lao syllable.")
-
-(defconst lao-transcription-pattern
- (concat
- "\\("
(regexp-opt (mapcar 'car lao-transcription-consonant-alist))
"\\)\\("
(regexp-opt (mapcar 'car lao-transcription-semi-vowel-alist))
diff --git a/lisp/language/tibetan.el b/lisp/language/tibetan.el
index 1292092c582..2249fa467b1 100644
--- a/lisp/language/tibetan.el
+++ b/lisp/language/tibetan.el
@@ -558,48 +558,29 @@
("སྨ" . "")))
(defconst tibetan-regexp
- (let (pattern)
- (dolist (alist (list tibetan-precomposed-transcription-alist
- tibetan-consonant-transcription-alist
- tibetan-vowel-transcription-alist
- tibetan-modifier-transcription-alist
- tibetan-subjoined-transcription-alist)
- (apply #'concat (nreverse (cdr pattern))))
- (dolist (key-val alist)
- (setq pattern (cons "\\|" (cons (regexp-quote (car key-val))
- pattern))))))
+ (regexp-opt
+ (mapcar (lambda (x) (regexp-quote (car x)))
+ (append tibetan-precomposed-transcription-alist
+ tibetan-consonant-transcription-alist
+ tibetan-vowel-transcription-alist
+ tibetan-modifier-transcription-alist
+ tibetan-subjoined-transcription-alist)))
"Regexp matching a Tibetan transcription of a composable Tibetan sequence.
The result of matching is to be used for indexing alists at conversion
from a roman transcription to the corresponding Tibetan character.")
(defvar tibetan-precomposed-regexp
(purecopy
- (let ((l tibetan-precomposed-transcription-alist)
- temp)
- (setq temp "^\\(")
- (setq temp
- (concat temp (car (car l))))
- (setq l (cdr l))
- (while l
- (setq temp
- (concat temp "\\|" (car (car l))))
- (setq l (cdr l)))
- (concat temp "\\)")))
+ (concat "^" (regexp-opt
+ (mapcar #'car tibetan-precomposed-transcription-alist)
+ t)))
"Regexp string to match a romanized Tibetan complex consonant.
The result of matching is to be used for indexing alists when the input key
from an input method is converted to the corresponding precomposed glyph.")
(defvar tibetan-precomposition-rule-regexp
(purecopy
- (let ((l tibetan-precomposition-rule-alist)
- temp)
- (setq temp "\\(")
- (setq temp (concat temp (car (car l))))
- (setq l (cdr l))
- (while l
- (setq temp (concat temp "\\|" (car (car l))))
- (setq l (cdr l)))
- (concat temp "\\)")))
+ (regexp-opt (mapcar #'car tibetan-precomposition-rule-alist) t))
"Regexp string to match a sequence of Tibetan consonantic components.
That is, one base consonant and one or more subjoined consonants.
The result of matching is to be used for indexing alist when the component