X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=std11.el;h=616d3adff515be624ba51c2b45361729110c1876;hb=d0f10b946e5ff78d869d16245a00a19e987aa13e;hp=f36830d135ec2c7d7b5166d395c118e6e3452bfa;hpb=cee4dc7e8d299510da404135a72fcec60603171b;p=elisp%2Fflim.git diff --git a/std11.el b/std11.el index f36830d..616d3ad 100644 --- a/std11.el +++ b/std11.el @@ -48,18 +48,24 @@ (point) ) +(defsubst std11-fetch-field (name) + "Return the value of the header field NAME. +The buffer is expected to be narrowed to just the headers of the message." + (save-excursion + (goto-char (point-min)) + (let ((case-fold-search t)) + (if (re-search-forward (concat "^" name ":[ \t]*") nil t) + (buffer-substring-no-properties (match-end 0) (std11-field-end)) + )))) + (defun std11-field-body (name &optional boundary) - "Return body of field NAME. -If BOUNDARY is not nil, it is used as message header separator. -\[std11.el]" + "Return the value of the header field NAME. +If BOUNDARY is not nil, it is used as message header separator." (save-excursion (save-restriction (std11-narrow-to-header boundary) - (goto-char (point-min)) - (let ((case-fold-search t)) - (if (re-search-forward (concat "^" name ":[ \t]*") nil t) - (buffer-substring-no-properties (match-end 0) (std11-field-end)) - ))))) + (std11-fetch-field name) + ))) (defun std11-find-field-body (field-names &optional boundary) "Return the first found field-body specified by FIELD-NAMES @@ -110,16 +116,18 @@ header separator. [std11.el]" ;;; (defun std11-unfold-string (string) - "Unfold STRING as message header field. [std11.el]" - (let ((dest "")) - (while (string-match "\n\\([ \t]\\)" string) + "Unfold STRING as message header field." + (let ((dest "") + (p 0)) + (while (string-match "\n\\([ \t]\\)" string p) (setq dest (concat dest - (substring string 0 (match-beginning 0)) - (match-string 1 string) + (substring string p (match-beginning 0)) + (substring string + (match-beginning 1) + (setq p (match-end 0))) )) - (setq string (substring string (match-end 0))) ) - (concat dest string) + (concat dest (substring string p)) )) @@ -677,6 +685,21 @@ If BOUNDARY is not nil, it is used as message header separator. (cdr ret)) ))) +(defun std11-parse-in-reply-to (tokens) + "Parse lexical TOKENS as In-Reply-To field, and return the result." + (let ((ret (or (std11-parse-msg-id tokens) + (std11-parse-phrase tokens)))) + (if ret + (let ((dest (list (car ret)))) + (setq tokens (cdr ret)) + (while (setq ret (or (std11-parse-msg-id tokens) + (std11-parse-phrase tokens))) + (setq dest (cons (car ret) dest)) + (setq tokens (cdr ret)) + ) + (nreverse dest) + )))) + ;;; @ composer ;;;