+;;; @ formats
+;;;
+
+(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 a string or a method name."
+ :type (list
+ 'repeat
+ (list
+ 'group
+ :convert-widget
+ (function
+ (lambda (widget)
+ (list
+ 'choice
+ :tag "Method or String"
+ :args
+ (nconc
+ (mapcar
+ (function (lambda (elem) (list 'choice-item (car elem))))
+ mu-cite-default-methods-alist)
+ '((symbol :tag "Method")
+ (const :tag "-" nil)
+ (choice-item :tag "String: \"> \"" "> ")
+ (string))))))))
+ :set (function (lambda (symbol value)
+ (set-default symbol (delq nil value))))
+ :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 a string or a method name."
+ :type (list
+ 'repeat
+ (list
+ 'group
+ :convert-widget
+ (function
+ (lambda (widget)
+ (list 'choice
+ :tag "Method or String"
+ :args
+ (nconc
+ (mapcar
+ (function (lambda (elem) (list 'choice-item (car elem))))
+ mu-cite-default-methods-alist)
+ '((symbol :tag "Method")
+ (const :tag "-" nil)
+ (choice-item :tag "String: \">>>>>\\t\"" ">>>>>\t")
+ (choice-item :tag "String: \" wrote:\\n\"" " wrote:\n")
+ (string :tag "String"))))))))
+ :set (function (lambda (symbol value)
+ (set-default symbol (delq nil value))))
+ :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 contains a sequence number of the mailing list."
+ :type '(repeat (choice :tag "Field Name"
+ (choice-item "X-Ml-Count")
+ (choice-item "X-Mail-Count")
+ (choice-item "X-Seqno")
+ (choice-item "X-Sequence")
+ (choice-item "Mailinglist-Id")
+ (const :tag "-" nil)
+ (string :tag "Other")))
+ :set (function (lambda (symbol value)
+ (set-default symbol (delq nil value))))
+ :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
+the 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 to 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)))))))
+
+