all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mark Lillibridge <mdl@alum.mit.edu>
To: 13330@debbugs.gnu.org
Subject: bug#13330: 24.2; rmail-set-header doesn't work for multi-line headers
Date: Tue, 01 Jan 2013 14:40:52 -0800	[thread overview]
Message-ID: <87obh8ttl7.fsf@foil.strangled.net> (raw)


This should be obvious from inspection (rmail.el:2166):

  (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."
    (if (search-forward "\n\n" nil t)
        (progn
  	(forward-char -1)
  	(narrow-to-region (point-min) (point))
  	(goto-char (point-min))
  	(if (re-search-forward (concat "^" (regexp-quote name) ":") nil 'move)
              (if value
                  (progn
                    (delete-region (point) (line-end-position))
                    (insert " " value))
                (delete-region (line-beginning-position)
                               (line-beginning-position 2)))
            (if value (insert name ": " value "\n"))))
      (rmail-error-bad-format)))
  
  (defun rmail-set-header (name &optional msgnum value)
    "Set message header NAME to VALUE in message number MSGNUM.
  If MSGNUM is nil, use the current message.  NAME and VALUE are strings.
  VALUE may also be nil, meaning to remove the header."
    (rmail-apply-in-message msgnum 'rmail-set-header-1 name value)
    (with-current-buffer rmail-buffer
      ;; Ensure header changes get saved.
      ;; (Note replacing a header with an identical copy modifies.)
      (set-buffer-modified-p t)
      ;; However: don't save in mbox format over a Babyl file
      ;; merely because of this.
      (rmail-dont-modify-format)))

but if not, evaluate (esc-:) "(rmail-set-header "subject" nil)" on a
Rmail message with a multiline subject like:

|X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED,
|	RP_MATCHES_RCVD autolearn=unavailable version=3.3.1
|From: Mark Lillibridge <mark.lillibridge@hp.com>
|To: <bug-gnu-emacs@gnu.org>
|Subject: this is a long subject
|  with several lines
|  indeed
|Date: Sat, 22 Oct 2011 12:05:57 -0700
|Reply-To: <mark.lillibridge@hp.com>
|Content-type: text/plain; charset=us-ascii
|
|
|empty body

The result (after hitting t twice to re-decode) is:

|X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED,
|	RP_MATCHES_RCVD autolearn=unavailable version=3.3.1
|From: Mark Lillibridge <mark.lillibridge@hp.com>
|To: <bug-gnu-emacs@gnu.org>
|  with several lines
|  indeed
|Date: Sat, 22 Oct 2011 12:05:57 -0700
|Reply-To: <mark.lillibridge@hp.com>
|Content-type: text/plain; charset=us-ascii
|
|
|empty body

Notice that only the first line of the Subject has been deleted.  

    Should there be a warning that this function does not RFC2047 encode
value so the caller is responsible for doing any such encoding if
needed?

- Mark





             reply	other threads:[~2013-01-01 22:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-01 22:40 Mark Lillibridge [this message]
2013-01-03 19:42 ` bug#13330: 24.2; rmail-set-header doesn't work for multi-line headers Glenn Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87obh8ttl7.fsf@foil.strangled.net \
    --to=mdl@alum.mit.edu \
    --cc=13330@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.