;;; rmail-header.el --- Header handling code of "RMAIL" mail reader for Emacs
-;; Copyright (C) 2002
-;; Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2006 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: mail
"Records the current header display mode.
nil means headers are displayed, t indicates headers are not displayed.")
-(defmacro rmail-header-get-limit ()
- '(progn
- (goto-char (point-min))
- (if (search-forward "\n\n" nil t)
- (1- (point))
- (error "Invalid message format."))))
+(defun rmail-header-get-limit ()
+ "Return the end of the headers."
+ (goto-char (point-min))
+ (if (search-forward "\n\n" nil t)
+ (1- (point))
+ (error "Invalid message format.")))
;;; The following functions are presented alphabetically ordered by
;;; name.
(defun rmail-header-add-header (header value)
"Add HEADER to the list of headers and associate VALUE with it.
-The current buffer, possibly narrowed, contains a single message."
+The current buffer, possibly narrowed, contains a single message.
+If VALUE is nil or the empty string, the header is removed
+instead."
(save-excursion
(let* ((inhibit-read-only t)
(case-fold-search t)
(limit (rmail-header-get-limit))
start end)
-
;; Search for the given header. If found, then set it's value.
;; If not then add the header to the end of the header section.
(goto-char (point-min))
(if (re-search-forward (format "^%s: " header) limit t)
-
- ;; Kill the current value and replace it with the new.
- (progn
- (beginning-of-line)
- (setq start (point))
- (while (progn
- (forward-line 1)
- (looking-at "[ \t]+")))
- (kill-region start (point)))
-
- ;; Add a new header at the end of the headers.
+ (let ((start (match-beginning 0)))
+ (re-search-forward "\n[^ \t]")
+ (goto-char limit)
+ (kill-region start (1+ (match-beginning 0))))
(goto-char limit))
- (insert header ": " value "\n"))))
+ (when (> (length value) 0)
+ (insert header ": " value "\n")))))
(defun rmail-header-contains-keyword-p (keyword)
"Return t if KEYWORD exists in the current buffer, nil otherwise."
(inhibit-point-motion-hooks t)
(limit (rmail-header-get-limit))
result start end)
-
;; Search for the given header. If found return it, otherwise
;; nil.
(goto-char (point-min))
(forward-line 1))))))
(defun rmail-header-persist-attributes (attributes)
- "Save ATTRIBUTES in the Rmail BABYL header.
-The current buffer, possibly narrowed, contains a single message."
+ "Save ATTRIBUTES in the Rmail BABYL header."
(rmail-header-set-header rmail-header-attribute-header attributes))
-(defun rmail-header-remove-keyword (keyword)
- "..."
- ;; tbd
- )
-
(defun rmail-header-set-header (header value)
"Set the current value of HEADER to VALUE.
The current buffer, possibly narrowed, contains a single message."