From: MORIOKA Tomohiko Date: Wed, 12 Sep 2012 01:40:05 +0000 (+0900) Subject: (est-eval-value-as-journal-volume): Renamed from X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd3449c51bf4fddf8e9692d11e6bc10835468b24;p=chise%2Fest.git (est-eval-value-as-journal-volume): Renamed from `est-eval-journal-volume'. (est-eval-value-as-article): New function. (est-eval-value-as-book): New function. (est-eval-value-as-object): - Use `est-eval-value-as-journal-volume' instead of `est-eval-journal-volume'. - Use function `est-eval-value-as-article' for genre `article@ruimoku'. - Use function `est-eval-value-as-book' for genre `book@ruimoku'. (est-eval-value-as-object-list): - Add new optional argument `subtype'; set it into property :subtype. - Fix problem when `value' is not a valid list. (est-eval-value-as-creators-names): Add new optional argument `subtype'; set it into property :subtype. (est-eval-value-as-created-works): Likewise. (est-eval-apply-value): Add new formats `unordered-list', `unordered-creator-name-list' and `unordered-created-work-list'. --- diff --git a/est-eval.el b/est-eval.el index fcd2b52..748197a 100644 --- a/est-eval.el +++ b/est-eval.el @@ -103,7 +103,7 @@ ;; (t nil) ;; )) -(defun est-eval-journal-volume (value) +(defun est-eval-value-as-journal-volume (value) (let ((journal (car (concord-object-get value '<-volume))) volume-type number-type year) @@ -130,6 +130,68 @@ year 'cjk)) )) +(defun est-eval-value-as-article (value) + (let ((creators (concord-object-get value '->creator)) + (title (concord-object-get value 'title)) + creator-name creator-role) + (concat + (mapconcat + (lambda (creator) + (setq creator-name + (concord-object-get + (car (concord-object-get creator '->creator/name)) + '=name)) + (setq creator-role + (or (concord-object-get creator 'role*name) + (format "(%s)" + (concord-object-get creator 'role*type)))) + (concat creator-name " " creator-role)) + creators ", ") + (if (eq (concord-object-get value 'writing-system) 'cjk) + (concat "「" title "」") + (concat " ‘" title "’"))))) + +(defun est-eval-value-as-book (value) + (let ((creators (concord-object-get value '->creator)) + (title (concord-object-get value 'title)) + (subtitle (concord-object-get value 'title/subtitle)) + (series (concord-object-get value 'series)) + (publisher (car (concord-object-get value 'publisher))) + (date (car (concord-object-get value 'date))) + creator-name creator-role) + (concat + (mapconcat + (lambda (creator) + (setq creator-name + (concord-object-get + (car (concord-object-get creator '->creator/name)) + '=name)) + (setq creator-role + (or (concord-object-get creator 'role*name) + (format "(%s)" + (concord-object-get creator 'role*type)))) + (concat creator-name " " creator-role)) + creators ", ") + (if (eq (concord-object-get value 'writing-system) 'cjk) + (concat "「" title + (if subtitle + (concat " — " subtitle)) + "」") + (concat " ‘" title + (if subtitle + (concat " — " subtitle)) + "’")) + (if series + (concat " " series)) + (if publisher + (concat ", " + (concord-object-get + (car (concord-object-get + publisher '->publisher/name)) + '=name))) + (if date + (concat ", " (concord-object-get date 'name)))))) + ;; (defun est-eval-creator (value) ;; (est-eval-list ;; '((value (:feature ->name)) @@ -150,7 +212,13 @@ ;; (est-eval-list ;; (est-journal-volume-get-object-format value) ;; value nil) - (est-eval-journal-volume value) + (est-eval-value-as-journal-volume value) + ) + ((eq genre 'article@ruimoku) + (est-eval-value-as-article value) + ) + ((eq genre 'book@ruimoku) + (est-eval-value-as-book value) ) ;; ((eq genre 'creator@ruimoku) ;; (est-eval-creator value) @@ -197,19 +265,18 @@ (format "%c" (ideographic-radical value))) (est-eval-value-as-S-exp value))) -(defun est-eval-value-as-object-list (value &optional separator) - (if (listp value) - (list* 'list - (if separator - (list :separator separator)) - ;; (mapcar - ;; (lambda (unit) - ;; (if (characterp unit) - ;; (list 'char-link nil (format "%c" unit)) - ;; (format "%s" unit))) - ;; value) - (mapcar #'est-eval-value-as-object value) - ) +(defun est-eval-value-as-object-list (value &optional separator subtype) + (if (and (listp value) + (listp (cdr value))) + (condition-case err + (let (props) + (if separator + (setq props (list :separator separator))) + (if subtype + (setq props (list* :subtype subtype props))) + (list* 'list props + (mapcar #'est-eval-value-as-object value))) + (error err (format "%s" value))) (format "%s" value))) (defun est-eval-value-as-ids (value) @@ -320,11 +387,13 @@ value))) (est-eval-value-default value))) -(defun est-eval-value-as-creators-names (value) +(defun est-eval-value-as-creators-names (value &optional subtype) (if (listp value) (let (role-name) (list* 'creator-name - '(:separator " ") + (if subtype + '(:subtype unordered-list) + '(:separator " ")) (mapcar (lambda (creator) (setq role-name (concord-object-get creator @@ -344,10 +413,12 @@ )) (est-eval-value-default value))) -(defun est-eval-value-as-created-works (value) +(defun est-eval-value-as-created-works (value &optional subtype) (if (listp value) (list* 'creator-name - '(:separator " ") + (if subtype + '(:subtype unordered-list) + '(:separator " ")) (mapcar (lambda (creator) (est-eval-list '((value (:feature <-creator))) @@ -428,14 +499,20 @@ ((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 'space-separated-ids) (est-eval-value-as-space-separated-ids value)) ((eq format 'space-separated-domain-list) (est-eval-value-as-domain-list value)) ((eq format 'space-separated-creator-name-list) (est-eval-value-as-creators-names value)) + ((eq format 'unordered-creator-name-list) + (est-eval-value-as-creators-names value 'unordered-list)) ((eq format 'space-separated-created-work-list) (est-eval-value-as-created-works value)) + ((eq format 'unordered-created-work-list) + (est-eval-value-as-created-works value 'unordered-list)) (t (est-eval-value-default value) ))