From bf765d5fe6d80fbf777d8bfa1195fb39df063284 Mon Sep 17 00:00:00 2001 From: MORIOKA Tomohiko Date: Tue, 12 Oct 2010 10:08:28 +0900 Subject: [PATCH] (www-get-genre): New function. (www-get-feature-value): Renamed from `www-char-feature'. (www-uri-decode-object): Renamed from `www-uri-decode-char'; add new argument `genre'. --- cwiki-common.el | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/cwiki-common.el b/cwiki-common.el index c682cbd..aa35fd6 100644 --- a/cwiki-common.el +++ b/cwiki-common.el @@ -33,6 +33,11 @@ (concat dest (substring string i)) coding-system)))) +(defun www-get-genre (object) + (if (characterp object) + 'character + 'default)) + (defun www-feature-type (feature-name) (or (char-feature-property feature-name 'type) (let ((str (symbol-name feature-name))) @@ -114,11 +119,11 @@ (intern (substring feature-name 0 (match-beginning 0))) feature))) -(defun www-char-feature (character feature) +(defun www-get-feature-value (object feature) (let ((latest-feature (char-feature-name-at-domain feature '$rev=latest))) (mount-char-attribute-table latest-feature) - (or (char-feature character latest-feature) - (char-feature character feature)))) + (or (char-feature object latest-feature) + (char-feature object feature)))) (defun get-previous-code-point (ccs code) (let ((chars (charset-chars ccs)) @@ -335,7 +340,7 @@ (format "%s?feature=%s&char=%s" chise-wiki-view-url uri-feature-name uri-char)) -(defun www-uri-decode-char (char-rep) +(defun www-uri-decode-object (genre char-rep) (let (ccs cpos) (cond ((string-match "\\(%3A\\|:\\)" char-rep) @@ -348,16 +353,19 @@ (string-to-number (substring cpos (match-end 0)) 16)) ) (t - (setq cpos (string-to-number cpos)) + (setq cpos (car (read-from-string cpos))) )) - (if (numberp cpos) - (decode-char ccs cpos)) + (if (and (eq genre 'character) + (numberp cpos)) + (decode-char ccs cpos) + (concord-decode-object ccs cpos genre)) ) (t (setq char-rep (decode-uri-string char-rep 'utf-8-mcs-er)) - (when (= (length char-rep) 1) - (aref char-rep 0)) - )))) + (if (eq genre 'character) + (when (= (length char-rep) 1) + (aref char-rep 0)) + (concord-decode-object '=id char-rep genre)))))) (defun www-uri-encode-char (char) (if (encode-char char '=ucs) @@ -648,7 +656,7 @@ &optional value format without-tags without-edit) (unless value - (setq value (www-char-feature object feature-name))) + (setq value (www-get-feature-value object feature-name))) (www-format-apply-value object feature-name format nil value nil nil without-tags without-edit) @@ -827,8 +835,8 @@ (setq char (decode-char 'system-char-id code)) (cond ((and (setq variants - (or (www-char-feature char '->subsumptive) - (www-char-feature char '->denotational))) + (or (www-get-feature-value char '->subsumptive) + (www-get-feature-value char '->denotational))) (progn (while (and variants (setq ret (www-format-encode-string @@ -841,8 +849,8 @@ (delete-region start end) (insert ret)) ) - ((setq ret (or (www-char-feature char 'ideographic-combination) - (www-char-feature char 'ideographic-structure))) + ((setq ret (or (www-get-feature-value char 'ideographic-combination) + (www-get-feature-value char 'ideographic-structure))) (setq ret (mapconcat (lambda (ch) @@ -944,7 +952,7 @@ &optional format lang uri-char value without-tags without-edit) (unless value - (setq value (www-char-feature char feature-name))) + (setq value (www-get-feature-value char feature-name))) (unless format (setq format (www-feature-value-format feature-name))) (cond @@ -973,7 +981,7 @@ &optional lang uri-char value without-tags without-edit) (unless value - (setq value (www-char-feature char feature-name))) + (setq value (www-get-feature-value char feature-name))) (unless uri-char (setq uri-char (www-uri-encode-char char))) (cond @@ -990,11 +998,11 @@ (setq fn (intern fn))) (setq domain (char-feature-name-domain feature-name)) (setq domain-fn (char-feature-name-at-domain fn domain)) - (if (setq ret (www-char-feature char domain-fn)) + (if (setq ret (www-get-feature-value char domain-fn)) (setq feature-name domain-fn value ret) (setq feature-name fn - value (www-char-feature char fn))) + value (www-get-feature-value char fn))) (push feature-name chise-wiki-displayed-features) )) (if (eq (car exp) 'value) -- 1.7.10.4