From 901436ff657087553045d8ad3ccf52daea4c8c41 Mon Sep 17 00:00:00 2001 From: MORIOKA Tomohiko Date: Sat, 21 Sep 2013 20:36:00 +0900 Subject: [PATCH] (est-eval-value-as-composition-list): New function. (est-eval-value-as-decomposition-list): New function. (est-eval-apply-value): Add new formats `decomposition', `composition' and `unordered-composition-list'. --- est-eval.el | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/est-eval.el b/est-eval.el index fb850d1..5624e6a 100644 --- a/est-eval.el +++ b/est-eval.el @@ -381,6 +381,49 @@ (error (format "%s" value))) (format "%s" value))) +(defun est-eval-value-as-composition-list (value &optional separator subtype) + (if (and (listp value) + (listp (cdr value))) + (condition-case nil + (let (props) + (if separator + (setq props (list :separator separator))) + (if subtype + (setq props (list* :subtype subtype props))) + (list* 'list props + (mapcar + (lambda (cell) + (list 'list nil + "+ " + (list 'object (list :object (car cell)) + (format "U+%04X" (car cell))) + " : " + (est-eval-value-as-object (cdr cell)))) + (sort value + (lambda (a b) + (< (car a)(car b))))))) + (error (format "%s" value))) + (format "%s" value))) + +(defun est-eval-value-as-decomposition-list (value) + (if (and (listp value) + (listp (cdr value))) + (condition-case nil + (let (props) + (list* 'list props + (mapconcat #'char-to-string value "") + (list + " (" + (list* 'list '(:separator " + ") + (mapcar + (lambda (chr) + (list 'object (list :object chr) + (format "U+%04X" chr))) + value)) + ")"))) + (error (format "%s" value))) + (format "%s" value))) + (defun est-eval-value-as-ids (value) (if (listp value) (list 'ids nil (ideographic-structure-to-ids value)) @@ -614,11 +657,17 @@ (est-eval-value-as-kangxi-radical value)) ((eq format 'ids) (est-eval-value-as-ids value)) + ((eq format 'decomposition) + (est-eval-value-as-decomposition-list value)) + ((eq format 'composition) + (est-eval-value-as-composition-list value)) ((or (eq format 'space-separated) (eq format 'space-separated-char-list)) (est-eval-value-as-object-list value " ")) ((eq format 'unordered-list) (est-eval-value-as-object-list value nil 'unordered-list)) + ((eq format 'unordered-composition-list) + (est-eval-value-as-composition-list value nil 'unordered-list)) ((eq format 'space-separated-ids) (est-eval-value-as-space-separated-ids value)) ((eq format 'space-separated-domain-list) -- 1.7.10.4