Anonymous avatar Anonymous committed 061747b

Sync with Emacs 21 (Doc fixes, support string
`headers' in mail-header-format).

Comments (0)

Files changed (1)

-;;; 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 <erik@arcana.naggum.no>
+;; Author: Erik Naggum <erik@naggum.no>
 ;; 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.
 
 ;;; Commentary:
 
 ;; 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,
 
 ;;; Code:
 
-(require 'cl)
+(eval-when-compile
+  (require 'cl))
 
 ;; Make the byte-compiler shut up.
 (defvar headers)
 		value))
 	(push (if (cdr value)
 		  (cons header (mapconcat #'identity (nreverse value) " "))
-		(cons header (car value)))
+		  (cons header (car value)))
 	      message-headers)))
     (goto-char top)
     (nreverse message-headers)))
 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)))
     (if entry
 	(setf (cdr entry) value)
-      (nconc alist (list (cons header value)))))
+	(nconc alist (list (cons header value)))))
   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)
 
 (provide 'mailheader)
 
-;;; mail-header.el ends here
+;;; mailheader.el ends here
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.