Need help cloning? Visit
is a free Git and Mercurial client for Windows.
is a free Git and Mercurial client for Mac.
-;;; mail-header.el --- Mail header parsing, merging, formatting
+;;; mailheader.el --- Mail header parsing, merging, formatting
;; Copyright (C) 1996 by Free Software Foundation, Inc.
-;; Author: Erik Naggum <firstname.lastname@example.org>
+;; Author: Erik Naggum <email@example.com>
;; Keywords: tools, mail, news
-;; This file is part of GNU Emacs.
+;; This file is part of XEmacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; XEmacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
-;; GNU Emacs is distributed in the hope that it will be useful,
+;; XEmacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
+;; along with XEmacs; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
;; This package provides an abstraction to RFC822-style messages, used in
-;; mail news, and some other systems. The simple syntactic rules for such
+;; mail, news, and some other systems. The simple syntactic rules for such
;; headers, such as quoting and line folding, are routinely reimplemented
;; in many individual packages. This package removes the need for this
;; redundancy by representing message headers as association lists,
+ (require 'cl))
;; Make the byte-compiler shut up.
(push (if (cdr value)
(cons header (mapconcat #'identity (nreverse value) " "))
- (cons header (car value)))
+ (cons header (car value)))
HEADER-ALIST defaults to the dynamically bound variable `headers' if nil.
See `mail-header' for the semantics of VALUE."
(let* ((alist (or header-alist headers))
- (entry (assq header alist)))
+ (entry (assq header alist)))
(setf (cdr entry) value)
- (nconc alist (list (cons header value)))))
+ (nconc alist (list (cons header value)))))
(defsetf mail-header (header &optional header-alist) (value)
(defun mail-header-format (format-rules headers)
"Use FORMAT-RULES to format HEADERS and insert into current buffer.
-FORMAT-RULES is an alist whose keys are header names (symbols), and whose
-values are functions that format the header, the results of which are
-inserted, unless it is nil. The function takes two arguments, the header
-symbol, and the value of that header. If the function itself is nil, the
-default action is to insert the value of the header, unless it is nil.
+HEADERS should be an alist of the form (HEADER . VALUE),
+where HEADER is a header field name (a symbol or a string),
+and VALUE is the contents for that header field.
+FORMAT-RULES is an alist of elements (HEADER . FUNCTION) Here HEADER
+is a header field name (a symbol), and FUNCTION is how to format that
+header field, if it appears in HEADERS. Each FUNCTION should take two
+arguments: the header symbol, and the value of that header. The value
+returned by FUNCTION is inserted in the buffer unless it is nil.
+If the function for a header field is nil, or if no function is
+specified for a particular header field, the default action is to
+insert the value of the header, unless it is nil.
The headers are inserted in the order of the FORMAT-RULES.
-A key of t represents any otherwise unmentioned headers.
+A key of t in FORMAT-RULES represents any otherwise unmentioned headers.
A key of nil has as its value a list of defaulted headers to ignore."
(let ((ignore (append (cdr (assq nil format-rules))
(mapcar #'car format-rules))))
(dolist (rule format-rules)
(let* ((header (car rule))
- (value (mail-header header)))
+ (value (mail-header header)))
+ (if (stringp header)
+ (setq header (intern header)))
(cond ((null header) 'ignore)
((eq header t)
(dolist (defaulted headers)
-;;; mail-header.el ends here
+;;; mailheader.el ends here