(est-eval-value-as-journal-volume): Renamed from
authorMORIOKA Tomohiko <tomo.git@chise.org>
Wed, 12 Sep 2012 01:40:05 +0000 (10:40 +0900)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Wed, 12 Sep 2012 01:40:05 +0000 (10:40 +0900)
`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'.

est-eval.el

index fcd2b52..748197a 100644 (file)
 ;;         (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)
             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))
                  ;; (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)
            (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)
                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
               ))
     (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)))
         ((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)
          ))