aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/mail
diff options
context:
space:
mode:
authorGlenn Morris2013-01-03 11:41:59 -0800
committerGlenn Morris2013-01-03 11:41:59 -0800
commita8aa6c2d08c5bf67cae9db62663e69fb183fbddb (patch)
tree8fcd43b707d1ab91bb1543836c65b676722d1848 /lisp/mail
parent0d1f53adb0f0a614c102fb5c2b5212ace4b4078b (diff)
downloademacs-a8aa6c2d08c5bf67cae9db62663e69fb183fbddb.tar.gz
emacs-a8aa6c2d08c5bf67cae9db62663e69fb183fbddb.zip
* lisp/mail/rmail.el (rmail-set-header-1): Handle multi-line headers
Ignore case. Fixes: debbugs:13330
Diffstat (limited to 'lisp/mail')
-rw-r--r--lisp/mail/rmail.el27
1 files changed, 21 insertions, 6 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index a05cd342862..e32d3c608d4 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -2173,20 +2173,35 @@ If MSGNUM is nil, use the current message."
2173 2173
2174(defun rmail-set-header-1 (name value) 2174(defun rmail-set-header-1 (name value)
2175 "Subroutine of `rmail-set-header'. 2175 "Subroutine of `rmail-set-header'.
2176Narrow to header, set header NAME to VALUE, replacing existing if present. 2176Narrow to headers, set header NAME to VALUE, replacing existing if present.
2177VALUE nil means to remove NAME altogether." 2177VALUE nil means to remove NAME altogether.
2178
2179Only changes the first instance of NAME. If VALUE is multi-line,
2180continuation lines should already be indented. VALUE should not
2181end in a newline."
2178 (if (search-forward "\n\n" nil t) 2182 (if (search-forward "\n\n" nil t)
2179 (progn 2183 (progn
2180 (forward-char -1) 2184 (forward-char -1)
2181 (narrow-to-region (point-min) (point)) 2185 (narrow-to-region (point-min) (point))
2186 ;; cf mail-fetch-field.
2182 (goto-char (point-min)) 2187 (goto-char (point-min))
2183 (if (re-search-forward (concat "^" (regexp-quote name) ":") nil 'move) 2188 (if (let ((case-fold-search t))
2189 (re-search-forward (concat "^" (regexp-quote name) "[ \t]*:")
2190 nil 'move))
2191 (let ((start (point))
2192 end)
2193 (while (and (zerop (forward-line 1))
2194 (looking-at "[ \t]")))
2195 ;; Back up over newline.
2196 (forward-char -1)
2197 (setq end (point))
2198 (goto-char start)
2184 (if value 2199 (if value
2185 (progn 2200 (progn
2186 (delete-region (point) (line-end-position)) 2201 (delete-region start end)
2187 (insert " " value)) 2202 (insert " " value))
2188 (delete-region (line-beginning-position) 2203 (delete-region (line-beginning-position) (1+ end))))
2189 (line-beginning-position 2))) 2204 ;; Not already present: insert at end of headers.
2190 (if value (insert name ": " value "\n")))) 2205 (if value (insert name ": " value "\n"))))
2191 (rmail-error-bad-format))) 2206 (rmail-error-bad-format)))
2192 2207