emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111411: * lisp/mail/rmail.el (rmail-


From: Glenn Morris
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111411: * lisp/mail/rmail.el (rmail-set-header-1): Handle multi-line headers
Date: Thu, 03 Jan 2013 11:41:59 -0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111411
fixes bug: http://debbugs.gnu.org/13330
committer: Glenn Morris <address@hidden>
branch nick: trunk
timestamp: Thu 2013-01-03 11:41:59 -0800
message:
  * lisp/mail/rmail.el (rmail-set-header-1): Handle multi-line headers
  Ignore case.
modified:
  lisp/ChangeLog
  lisp/mail/rmail.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-01-03 08:23:10 +0000
+++ b/lisp/ChangeLog    2013-01-03 19:41:59 +0000
@@ -1,5 +1,8 @@
 2013-01-03  Glenn Morris  <address@hidden>
 
+       * mail/rmail.el (rmail-set-header-1): Ignore case.
+       Handle multi-line headers.  (Bug#13330)
+
        * progmodes/make-mode.el (makefile-fill-paragraph): Add doc.
        Handle paragraph starting at beginning of buffer.
 

=== modified file 'lisp/mail/rmail.el'
--- a/lisp/mail/rmail.el        2013-01-02 16:13:04 +0000
+++ b/lisp/mail/rmail.el        2013-01-03 19:41:59 +0000
@@ -2173,20 +2173,35 @@
 
 (defun rmail-set-header-1 (name value)
   "Subroutine of `rmail-set-header'.
-Narrow to header, set header NAME to VALUE, replacing existing if present.
-VALUE nil means to remove NAME altogether."
+Narrow to headers, set header NAME to VALUE, replacing existing if present.
+VALUE nil means to remove NAME altogether.
+
+Only changes the first instance of NAME.  If VALUE is multi-line,
+continuation lines should already be indented.  VALUE should not
+end in a newline."
   (if (search-forward "\n\n" nil t)
       (progn
        (forward-char -1)
        (narrow-to-region (point-min) (point))
+       ;; cf mail-fetch-field.
        (goto-char (point-min))
-       (if (re-search-forward (concat "^" (regexp-quote name) ":") nil 'move)
+       (if (let ((case-fold-search t))
+             (re-search-forward (concat "^" (regexp-quote name) "[ \t]*:")
+                                nil 'move))
+           (let ((start (point))
+                 end)
+             (while (and (zerop (forward-line 1))
+                         (looking-at "[ \t]")))
+             ;; Back up over newline.
+             (forward-char -1)
+             (setq end (point))
+             (goto-char start)
             (if value
                 (progn
-                  (delete-region (point) (line-end-position))
+                   (delete-region start end)
                   (insert " " value))
-              (delete-region (line-beginning-position)
-                             (line-beginning-position 2)))
+               (delete-region (line-beginning-position) (1+ end))))
+         ;; Not already present: insert at end of headers.
           (if value (insert name ": " value "\n"))))
     (rmail-error-bad-format)))
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]