# HG changeset patch # User Alex Schroeder # Date 1137623221 0 # Node ID 83e39e1cce60b142e986f978ccd7fb03262ff69e # Parent 259a58cdd236ae61bb851d091b0609fb938a79e7 (rmail-header-get-limit): Rewrote macro as simple defun. (rmail-header-persist-attributes): Doc. (rmail-header-add-header): Simplified the finding of the header. Delete header if value is nil or "". (rmail-header-remove-keyword): Deleted stub. Removing can be handled by calling `rmail-header-add-header' with value nil or "". diff -r 259a58cdd236 -r 83e39e1cce60 lisp/mail/rmailhdr.el --- a/lisp/mail/rmailhdr.el Wed Jan 18 22:20:18 2006 +0000 +++ b/lisp/mail/rmailhdr.el Wed Jan 18 22:27:01 2006 +0000 @@ -1,7 +1,6 @@ ;;; 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 @@ -45,42 +44,37 @@ "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." @@ -102,7 +96,6 @@ (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)) @@ -208,15 +201,9 @@ (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."