Undo all of the last changes.
[elisp/gnus.git-] / lisp / message.el
index 9a69178..a040cc1 100644 (file)
@@ -1330,11 +1330,14 @@ Return the number of headers removed."
             ;; There might be a continuation header, so we have to search
             ;; until we find a new non-continuation line.
             (progn
-              (while (and (zerop (forward-line 1))
-                          (memq (char-after) '(?\t ?\ ))))
-              (point))))
-       (while (and (zerop (forward-line 1))
-                   (memq (char-after) '(?\t ?\ ))))))
+              (forward-line 1)
+              (if (re-search-forward "^[^ \t]" nil t)
+                  (goto-char (match-beginning 0))
+                (point-max)))))
+       (forward-line 1)
+       (if (re-search-forward "^[^ \t]" nil t)
+           (goto-char (match-beginning 0))
+         (goto-char (point-max)))))
     number))
 
 (defun message-remove-first-header (header)
@@ -1409,9 +1412,11 @@ Point is left at the beginning of the narrowed-to region."
 
 (defun message-next-header ()
   "Go to the beginning of the next header."
-  (while (and (zerop (forward-line 1))
-             (memq (char-after) '(?\t ?\ ))))
-  (not (eobp)))
+  (beginning-of-line)
+  (or (eobp) (forward-char 1))
+  (not (if (re-search-forward "^[^ \t]" nil t)
+          (beginning-of-line)
+        (goto-char (point-max)))))
 
 (defun message-sort-headers-1 ()
   "Sort the buffer as headers using `message-rank' text props."
@@ -2498,7 +2503,7 @@ This sub function is for exclusive use of `message-send-mail'."
              (message-remove-header message-ignored-mail-headers t))
            (goto-char (point-max))
            ;; require one newline at the end.
-           (or (bolp)
+           (or (= (preceding-char) ?\n)
                (insert ?\n))
            (when (and news
                       (or (message-fetch-field "cc")
@@ -2528,7 +2533,7 @@ This sub function is for exclusive use of `message-send-mail'."
       (re-search-forward
        (concat "^" (regexp-quote mail-header-separator) "\n"))
       (replace-match "\n")
-      (forward-char -1)
+      (backward-char 1)
       (setq delimline (point-marker))
       (run-hooks 'message-send-mail-hook)
       ;; Insert an extra newline if we need it to work around
@@ -2586,7 +2591,7 @@ to find out how to use this."
   (re-search-forward
    (concat "^" (regexp-quote mail-header-separator) "\n"))
   (replace-match "\n")
-  (forward-char -1)
+  (backward-char 1)
   (run-hooks 'message-send-mail-hook)
   ;; send the message
   (case
@@ -2656,7 +2661,7 @@ to find out how to use this."
     (re-search-forward
      (concat "^" (regexp-quote mail-header-separator) "\n"))
     (replace-match "\n")
-    (forward-char -1)
+    (backward-char 1)
     (run-hooks 'message-send-mail-hook)
     (if recipients
        (let ((result (smtp-via-smtp user-mail-address
@@ -2732,7 +2737,7 @@ This sub function is for exclusive use of `message-send-news'."
              (message-remove-header message-ignored-news-headers t))
            (goto-char (point-max))
            ;; require one newline at the end.
-           (or (bolp)
+           (or (= (preceding-char) ?\n)
                (insert ?\n))
            (setq result (message-maybe-split-and-send-news method)))
        (kill-buffer tembuf))
@@ -2752,7 +2757,7 @@ This sub function is for exclusive use of `message-send-news'."
     (re-search-forward
      (concat "^" (regexp-quote mail-header-separator) "\n"))
     (replace-match "\n")
-    (forward-char -1)
+    (backward-char 1)
     (run-hooks 'message-send-news-hook)
     (gnus-open-server method)
     (gnus-request-post method)
@@ -3275,7 +3280,7 @@ If NOW, use that time instead."
       (while (re-search-forward "[\t\n]+" nil t)
        (replace-match "" t t))
       (unless (zerop (buffer-size))
-       (buffer-substring (point-min) (point-max))))))
+       (buffer-string)))))
 
 (defun message-make-lines ()
   "Count the number of lines and return numeric string."
@@ -3388,7 +3393,7 @@ If NOW, use that time instead."
            (replace-match "\\1(\\3)" t)
            (goto-char fullname-start)))
        (insert ")")))
-      (buffer-substring (point-min) (point-max)))))
+      (buffer-string))))
 
 (defun message-make-sender ()
   "Return the \"real\" user address.
@@ -4054,8 +4059,7 @@ that further discussion should take place only in "
            (while (re-search-forward "[ \t]+" nil t)
              (replace-match " " t t))
            ;; Remove addresses that match `rmail-dont-reply-to-names'.
-           (insert (prog1 (rmail-dont-reply-to (buffer-substring
-                                                (point-min) (point-max)))
+           (insert (prog1 (rmail-dont-reply-to (buffer-string))
                      (erase-buffer)))
            (goto-char (point-min))
            ;; Perhaps Mail-Copies-To: never removed the only address?
@@ -4065,8 +4069,7 @@ that further discussion should take place only in "
                  (mapcar
                   (lambda (addr)
                     (cons (mail-strip-quoted-names addr) addr))
-                  (message-tokenize-header (buffer-substring
-                                            (point-min) (point-max)))))
+                  (message-tokenize-header (buffer-string))))
            (let ((s ccalist))
              (while s
                (setq ccalist (delq (assoc (car (pop s)) s) ccalist)))))
@@ -4404,7 +4407,7 @@ header line with the old Message-ID."
     (while (re-search-backward "[ \t]+$" nil t)
       (replace-match ""))
 
-    (buffer-substring (point-min) (point-max))))
+    (buffer-string)))
 
 ;;; Forwarding messages.