+(defun mu-cite-method-list ()
+ (mapcar (function car) mu-cite-default-methods-alist))
+
+
+;;; @ formats
+;;;
+
+(defvar widget-mu-cite-method-prompt-value-history nil
+ "History of input to `widget-mu-cite-method-prompt-value'.")
+
+(define-widget 'mu-cite-method 'symbol
+ "A mu-cite-method."
+ :format "%{%t%}: %v"
+ :tag "Method"
+ :prompt-history 'widget-mu-cite-method-prompt-value-history
+ :prompt-value 'widget-mu-cite-method-prompt-value
+ :action 'widget-mu-cite-method-action)
+
+(defun widget-mu-cite-method-prompt-value (widget prompt value unbound)
+ ;; Read mu-cite-method from minibuffer.
+ (intern
+ (completing-read (format "%s (default %s) " prompt value)
+ (mapcar (function
+ (lambda (sym)
+ (list (symbol-name sym))
+ ))
+ (mu-cite-method-list)))))
+
+(defun widget-mu-cite-method-action (widget &optional event)
+ ;; Read a mu-cite-method from the minibuffer.
+ (let ((answer
+ (widget-mu-cite-method-prompt-value
+ widget
+ (widget-apply widget :menu-tag-get)
+ (widget-value widget)
+ t)))
+ (widget-value-set widget answer)
+ (widget-apply widget :notify widget event)
+ (widget-setup)))
+
+(defcustom mu-cite-cited-prefix-regexp
+ "\\(^[^ \t\n<>]+>+[ \t]*\\|^[ \t]*$\\)"
+ "Regexp to match the citation prefix.
+If match, mu-cite doesn't insert citation prefix."
+ :type 'regexp
+ :group 'mu-cite)
+
+(defcustom mu-cite-prefix-format '(prefix-register-verbose "> ")
+ "List to represent citation prefix.
+Each elements must be string or method name."
+ :type '(repeat
+ (choice :tag "String or Method name"
+ mu-cite-method
+ (item "-")
+ (choice-item :tag "String: \"> \"" "> ")
+ (string :tag "Other String")))
+ :group 'mu-cite)
+
+(defcustom mu-cite-top-format '(in-id ">>>>>\t" from " wrote:\n")
+ "List to represent top string of citation.
+Each elements must be string or method name."
+ :type '(repeat
+ (choice :tag "String or Method name"
+ mu-cite-method
+ (item "-")
+ (choice-item :tag "String: \">>>>>\\t\"" ">>>>>\t")
+ (choice-item :tag "String: \" wrote:\\n\"" " wrote:\n")
+ (string :tag "Other String")))
+ :group 'mu-cite)
+
+
+;;; @ hooks
+;;;
+
+(defcustom mu-cite-instantiation-hook nil
+ "List of functions called just before narrowing to the message."
+ :type 'hook
+ :group 'mu-cite)
+
+(defcustom mu-cite-pre-cite-hook nil
+ "List of functions called before citing a region of text."
+ :type 'hook
+ :group 'mu-cite)
+
+(defcustom mu-cite-post-cite-hook nil
+ "List of functions called after citing a region of text."
+ :type 'hook
+ :group 'mu-cite)
+
+
+;;; @ field
+;;;
+
+(defvar mu-cite-get-field-value-method-alist nil
+ "Alist major-mode vs. function to get field-body of header.")
+
+(defun mu-cite-get-field-value (name)
+ "Return the value of the header field NAME.
+If the field is not found in the header, a method function which is
+registered in variable `mu-cite-get-field-value-method-alist' is called."
+ (or (std11-field-body name)
+ (let ((method (assq major-mode mu-cite-get-field-value-method-alist)))
+ (if method
+ (funcall (cdr method) name)))))
+
+
+;;; @ item methods
+;;;
+
+;;; @@ ML count
+;;;
+
+(defcustom mu-cite-ml-count-field-list
+ '("X-Ml-Count" "X-Mail-Count" "X-Seqno" "X-Sequence" "Mailinglist-Id")
+ "List of header fields which contain sequence number of mailing list."
+ :type '(repeat (choice (choice-item "X-Ml-Count")
+ (choice-item "X-Mail-Count")
+ (choice-item "X-Seqno")
+ (choice-item "X-Sequence")
+ (choice-item "Mailinglist-Id")
+ (item "-")
+ (string :tag "Other")))
+ :group 'mu-cite)
+
+(defun mu-cite-get-ml-count-method ()
+ "A mu-cite method to return a ML-count.
+This function searches a field about ML-count, which is specified by
+variable `mu-cite-ml-count-field-list', in a header.
+If the field is found, the function returns a number part of the
+field.
+
+Notice that please use (mu-cite-get-value 'ml-count)
+instead of call the function directly."
+ (let ((field-list mu-cite-ml-count-field-list))
+ (catch 'tag
+ (while field-list
+ (let* ((field (car field-list))
+ (ml-count (mu-cite-get-field-value field)))
+ (if (and ml-count (string-match "[0-9]+" ml-count))
+ (throw 'tag (match-string 0 ml-count)))
+ (setq field-list (cdr field-list)))))))
+