Function: rmail-nuke-pinhead-header

rmail-nuke-pinhead-header is a byte-compiled function defined in rmailout.el.gz.

Signature

(rmail-nuke-pinhead-header)

Documentation

Delete the "From " line in the current mbox message.

The variable rmail-unix-mail-delimiter specifies the From line format. Replaces the From line with a "Mail-from" header. Adds "Date" and
"From" headers if they are not already present.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmailout.el.gz
(defun rmail-nuke-pinhead-header ()
  "Delete the \"From \" line in the current mbox message.
The variable `rmail-unix-mail-delimiter' specifies the From line format.
Replaces the From line with a \"Mail-from\" header.  Adds \"Date\" and
\"From\" headers if they are not already present."
  (save-excursion
    (save-restriction
      (let ((start (point))
            (end (progn
		   (condition-case ()
		       (search-forward "\n\n")
		     (error
		      (goto-char (point-max))
		      (insert "\n\n")))
		   (point)))
	    has-from has-date)
	(narrow-to-region start end)
	(let ((case-fold-search t))
	  (goto-char start)
	  (setq has-from (search-forward "\nFrom:" nil t))
	  (goto-char start)
	  (setq has-date (and (search-forward "\nDate:" nil t) (point)))
	  (goto-char start))
	(let ((case-fold-search nil))
	  (if (re-search-forward (concat "^" rmail-unix-mail-delimiter) nil t)
	      (replace-match
		(concat
		  "Mail-from: \\&"
		  ;; Keep and reformat the date if we don't
		  ;;  have a Date: field.
		  (if has-date
		      ""
		    (concat
		     "Date: \\2, \\4 \\3 \\9 \\5 "

		     ;; The timezone could be matched by group 7 or group 10.
		     ;; If neither matched, use "-0000" for an unknown zone.
		     ;; It's a shame the substitution can't use "\\10".
		     (cond
		      ((/= (match-beginning 7) (match-end 7)) "\\7")
		      ((/= (match-beginning 10) (match-end 10))
		       (buffer-substring (match-beginning 10)
					 (match-end 10)))
		      (t "-0000"))
		     "\n"))
		  ;; Keep and reformat the sender if we don't
		  ;; have a From: field.
		  (if has-from
		      ""
		    "From: \\1\n"))
		t)))))))