(defsubst mailcap-look-at-type-field ()
(let ((type (mailcap-look-at-token)))
- (if (and type
- (eq (char-after (point)) ?/)
- )
- (progn
- (forward-char)
- (let ((subtype (mailcap-look-at-token)))
- (if subtype
- (cons (cons 'type type)
- (unless (string= subtype "*")
- (list (cons 'subtype subtype))
- ))))))))
+ (if type
+ (if (eq (char-after (point)) ?/)
+ (progn
+ (forward-char)
+ (let ((subtype (mailcap-look-at-token)))
+ (if subtype
+ (cons (cons 'type (intern type))
+ (unless (string= subtype "*")
+ (list (cons 'subtype (intern subtype)))
+ )))))
+ (list (cons 'type (intern type)))
+ ))))
;;; @ field separator
(defsubst mailcap-look-at-field ()
(let ((token (mailcap-look-at-token)))
(if token
- (if (eq (char-after (point)) ?=)
+ (if (looking-at "[ \t]*=[ \t]*")
(let ((value (progn
- (forward-char)
+ (goto-char (match-end 0))
(mailcap-look-at-mtext))))
(if value
- (cons token value)
+ (cons (intern token) value)
))
- (list token)
+ (list (intern token))
))))
(t entries)
))))
+(defvar mailcap-file "~/.mailcap"
+ "*File name of user's mailcap file.")
+
+(defun mailcap-parse-file (&optional filename order)
+ "Parse FILENAME as a mailcap, and return the result.
+If optional argument ORDER is a function, result is sorted by it.
+If optional argument ORDER is not specified, result is sorted original
+order. Otherwise result is not sorted."
+ (or filename
+ (setq filename mailcap-file))
+ (with-temp-buffer
+ (insert-file-contents filename)
+ (mailcap-parse-buffer (current-buffer) order)
+ ))
+
;;; @ end
;;;