Emre Sevinc <emres@bilgi.edu.tr> wrote:
+---------------
| (defun date-line? (line)
| "Check for DATE line"
| (and (> (length line) 6) (equal (subseq line 0 6) "Date: ")))
+---------------
IMHO, all of the ones of this pattern would be better written as follows
[notice the CHAR-EQUAL, since RFC 2822 specifies case-insensitive header
field names]:
(defun date-line-p (line)
(not (mismatch "Date: " line :end2 6 :test #'char-equal)))
Even better, fold all those into one general case:
(defun prefix-match-p (prefix line)
(not (mismatch prefix line :end2 (length prefix) :test #'char-equal)))
which you can use as (PREFIX-MATCH-P "date: " LINE), etc.
Note that RFC 2822 does *NOT* actually require a space after the colon
[though it's not likely you'll see that case], so you'd really be safer
with just (PREFIX-MATCH-P "date:" LINE), etc.
+---------------
| ;; TODO: the function below looks horrible. do something...
+---------------
Yup, the (CONS (CONS ...)) stuff is pretty ugly. But if you replace
the DO loop with a LOOP, you can using COLLECT INTO multiple variables
to vastly simplify the building of the multiple result lists.
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607