changeset 21920:eeb4e3a385db

(send-mail-function): Doc fix. (mail-header-end, mail-text-start): New functions. (mail-sendmail-delimit-header): New function. (mail-sendmail-undelimit-header): New function. (mail-mode-auto-fill): Use mail-header-end. (mail-mode-fill-paragraph, mail-send, sendmail-send-it): Likewise. (mail-sent-via, mail-position-on-field): Likewise. (mail-fill-yanked-message, mail-text): Use mail-text-start
author Richard M. Stallman <rms@gnu.org>
date Sun, 03 May 1998 04:35:16 +0000
parents 0c3d6e2c4176
children ea04bf51647c
files lisp/mail/sendmail.el
diffstat 1 files changed, 39 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/sendmail.el	Sun May 03 04:33:27 1998 +0000
+++ b/lisp/mail/sendmail.el	Sun May 03 04:35:16 1998 +0000
@@ -1,6 +1,6 @@
 ;;; sendmail.el --- mail sending commands for Emacs.
 
-;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 1998 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: mail
@@ -71,8 +71,8 @@
 ;;;###autoload
 (defvar send-mail-function 'sendmail-send-it "\
 Function to call to send the current buffer as mail.
-The headers should be delimited by a line whose contents
-match the variable `mail-header-separator'.")
+The headers should be delimited by a line which is
+not a valid RFC822 header or continuation line.")
 
 ;;;###autoload
 (defcustom mail-header-separator "--text follows this line--" "\
@@ -416,17 +416,37 @@
   (setq paragraph-separate paragraph-start)
   (run-hooks 'text-mode-hook 'mail-mode-hook))
 
+
+(defun mail-header-end ()
+  "Return the buffer location of the end of headers, as a number."
+  (save-excursion
+    (rfc822-goto-eoh)
+    (point)))
+
+(defun mail-text-start ()
+  "Return the buffer location of the start of text, as a number."
+  (save-excursion
+    (rfc822-goto-eoh)
+    (forward-line 1)
+    (point)))
+
+(defun mail-sendmail-delimit-header ()
+  "Set up whatever header delimiter convention sendmail will use.
+Concretely: replace the first blank line in the header with the separator."
+  (rfc822-goto-eoh)
+  (insert mail-header-separator)
+  (point))
+
+(defun mail-sendmail-undelimit-header ()
+  "Remove header separator to put the message in correct form for sendmail.
+Leave point at the start of the delimiter line."
+  (rfc822-goto-eoh)
+  (delete-region (point) (progn (end-of-line) (point))))
+
 (defun mail-mode-auto-fill ()
   "Carry out Auto Fill for Mail mode.
 If within the headers, this makes the new lines into continuation lines."
-  (if (< (point)
-	 (save-excursion
-	   (goto-char (point-min))
-	   (if (re-search-forward
-		(concat "^" (regexp-quote mail-header-separator) "$")
-		nil t)
-	       (point)
-	     0)))
+  (if (< (point) (mail-header-end))
       (let ((old-line-start (save-excursion (beginning-of-line) (point))))
 	(if (do-auto-fill)
 	    (save-excursion
@@ -441,14 +461,7 @@
 
 (defun mail-mode-fill-paragraph (arg)
   ;; Do something special only if within the headers.
-  (if (< (point)
-	 (save-excursion
-	   (goto-char (point-min))
-	   (if (re-search-forward
-		(concat "^" (regexp-quote mail-header-separator) "$")
-		nil t)
-	       (point)
-	     0)))
+  (if (< (point) (mail-header-end))
       (let (beg end fieldname) 
 	(re-search-backward "^[-a-zA-Z]+:" nil 'yes)
 	(setq beg (point))
@@ -623,7 +636,7 @@
 		(error "Message contains non-ASCII characters"))))
 	;; Complain about any invalid line.
 	(goto-char (point-min))
-	(while (not (looking-at (regexp-quote mail-header-separator)))
+	(while (< (point) (mail-header-end))
 	  (unless (looking-at "[ \t]\\|.*:\\|$")
 	    (push-mark opoint)
 	    (error "Invalid header line (maybe a continuation line lacks initial whitespace)"))
@@ -684,11 +697,8 @@
 	  (or (= (preceding-char) ?\n)
 	      (insert ?\n))
 	  ;; Change header-delimiter to be what sendmail expects.
-	  (goto-char (point-min))
-	  (re-search-forward
-	    (concat "^" (regexp-quote mail-header-separator) "\n"))
-	  (replace-match "\n")
-	  (backward-char 1)
+	  (goto-char (mail-header-end))
+	  (delete-region (point) (progn (end-of-line) (point)))
 	  (setq delimline (point-marker))
 	  (sendmail-sync-aliases)
 	  (if mail-aliases
@@ -986,12 +996,8 @@
   "Make a Sent-via header line from each To or CC header line."
   (interactive)
   (save-excursion
-    (goto-char (point-min))
-    ;; find the header-separator
-    (search-forward (concat "\n" mail-header-separator "\n"))
-    (forward-line -1)
     ;; put a marker at the end of the header
-    (let ((end (point-marker))
+    (let ((end (make-marker (mail-header-end)))
 	  (case-fold-search t)
 	  to-line)
       (goto-char (point-min))
@@ -1054,9 +1060,7 @@
 (defun mail-position-on-field (field &optional soft)
   (let (end
 	(case-fold-search t))
-    (goto-char (point-min))
-    (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
-    (setq end (match-beginning 0))
+    (setq end (mail-header-end))
     (goto-char (point-min))
     (if (re-search-forward (concat "^" (regexp-quote field) ":") end t)
 	(progn
@@ -1074,8 +1078,7 @@
   "Move point to beginning of message text."
   (interactive)
   (expand-abbrev)
-  (goto-char (point-min))
-  (search-forward (concat "\n" mail-header-separator "\n")))
+  (goto-char (mail-text-start)))
 
 (defun mail-signature (atpoint)
   "Sign letter with contents of the file `mail-signature-file'.
@@ -1096,8 +1099,7 @@
 Numeric argument means justify as well."
   (interactive "P")
   (save-excursion
-    (goto-char (point-min))
-    (search-forward (concat "\n" mail-header-separator "\n") nil t)
+    (goto-char (mail-text-start))
     (fill-individual-paragraphs (point)
 				(point-max)
 				justifyp