summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1997-01-31 09:34:45 +0000
committerRichard M. Stallman <rms@gnu.org>1997-01-31 09:34:45 +0000
commitb7bf1cef3358ed09fba928ccd1a14e1b8aaa3f82 (patch)
treef3ed5ec9b7d09c335829ea922408ce0443b4345f /lisp
parent1e3b420bcb2f88ac3c941c1f5e657a99cf97a6c3 (diff)
downloademacs-b7bf1cef3358ed09fba928ccd1a14e1b8aaa3f82.tar.gz
(mail-fetch-field): New arg LIST.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mail/mail-utils.el25
1 files changed, 16 insertions, 9 deletions
diff --git a/lisp/mail/mail-utils.el b/lisp/mail/mail-utils.el
index ebf2f617789..2dc5a7687b8 100644
--- a/lisp/mail/mail-utils.el
+++ b/lisp/mail/mail-utils.el
@@ -168,17 +168,18 @@ Usenet paths ending in an element that matches are removed also."
userids)))
;;;###autoload
-(defun mail-fetch-field (field-name &optional last all)
+(defun mail-fetch-field (field-name &optional last all list)
"Return the value of the header field FIELD-NAME.
The buffer is expected to be narrowed to just the headers of the message.
If second arg LAST is non-nil, use the last such field if there are several.
-If third arg ALL is non-nil, concatenate all such fields with commas between."
+If third arg ALL is non-nil, concatenate all such fields with commas between.
+If 4th arg LIST is non-nil, return a list of all such fields."
(save-excursion
(goto-char (point-min))
(let ((case-fold-search t)
(name (concat "^" (regexp-quote field-name) "[ \t]*:[ \t]*")))
- (if all
- (let ((value ""))
+ (if (or all list)
+ (let ((value (if all "")))
(while (re-search-forward name nil t)
(let ((opoint (point)))
(while (progn (forward-line 1)
@@ -186,11 +187,17 @@ If third arg ALL is non-nil, concatenate all such fields with commas between."
;; Back up over newline, then trailing spaces or tabs
(forward-char -1)
(skip-chars-backward " \t" opoint)
- (setq value (concat value
- (if (string= value "") "" ", ")
- (buffer-substring-no-properties
- opoint (point))))))
- (and (not (string= value "")) value))
+ (if list
+ (setq value (cons (buffer-substring-no-properties
+ opoint (point))
+ value))
+ (setq value (concat value
+ (if (string= value "") "" ", ")
+ (buffer-substring-no-properties
+ opoint (point)))))))
+ (if list
+ value
+ (and (not (string= value "")) value)))
(if (re-search-forward name nil t)
(progn
(if last (while (re-search-forward name nil t)))