Speedups; see ChangeLog for fine details.
[elisp/gnus.git-] / lisp / message.el
index 5f5f844..4c37aae 100644 (file)
@@ -1183,14 +1183,11 @@ 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
-              (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))
-         (point-max))))
+              (while (and (zerop (forward-line 1))
+                          (memq (char-after) '(?\t ?\ ))))
+              (point))))
+       (while (and (zerop (forward-line 1))
+                   (memq (char-after) '(?\t ?\ ))))))
     number))
 
 (defun message-narrow-to-headers ()
@@ -1237,11 +1234,9 @@ Return the number of headers removed."
 
 (defun message-next-header ()
   "Go to the beginning of the next header."
-  (beginning-of-line)
-  (or (eobp) (forward-char 1))
-  (not (if (re-search-forward "^[^ \t]" nil t)
-          (beginning-of-line)
-        (goto-char (point-max)))))
+  (while (and (zerop (forward-line 1))
+             (memq (char-after) '(?\t ?\ ))))
+  (not (eobp)))
 
 (defun message-sort-headers-1 ()
   "Sort the buffer as headers using `message-rank' text props."
@@ -2287,7 +2282,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 (eq (char-before) ?\n)
+           (or (bolp)
                (insert ?\n))
            (when (and news
                       (or (message-fetch-field "cc")
@@ -2317,7 +2312,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")
-      (backward-char 1)
+      (forward-char -1)
       (setq delimline (point-marker))
       (run-hooks 'message-send-mail-hook)
       ;; Insert an extra newline if we need it to work around
@@ -2444,7 +2439,7 @@ to find out how to use this."
     (re-search-forward
      (concat "^" (regexp-quote mail-header-separator) "\n"))
     (replace-match "\n")
-    (backward-char 1)
+    (forward-char -1)
     (run-hooks 'message-send-mail-hook)
     (if recipients
        (let ((result (smtp-via-smtp user-mail-address
@@ -2520,7 +2515,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 (eq (char-before) ?\n)
+           (or (bolp)
                (insert ?\n))
            (setq result (message-maybe-split-and-send-news method)))
        (kill-buffer tembuf))
@@ -2540,7 +2535,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")
-    (backward-char 1)
+    (forward-char -11)
     (run-hooks 'message-send-news-hook)
     ;;(require (car method))
     ;;(funcall (intern (format "%s-open-server" (car method)))
@@ -3060,7 +3055,7 @@ This sub function is for exclusive use of `message-send-news'."
       (while (re-search-forward "[\t\n]+" nil t)
        (replace-match "" t t))
       (unless (zerop (buffer-size))
-       (buffer-string)))))
+       (buffer-substring (point-min) (point-max))))))
 
 (defun message-make-lines ()
   "Count the number of lines and return numeric string."
@@ -3178,7 +3173,7 @@ This sub function is for exclusive use of `message-send-news'."
            (replace-match "\\1(\\3)" t)
            (goto-char fullname-start)))
        (insert ")")))
-      (buffer-string))))
+      (buffer-substring (point-min) (point-max)))))
 
 (defun message-make-sender ()
   "Return the \"real\" user address.
@@ -3762,7 +3757,8 @@ OTHER-HEADERS is an alist of header/value pairs."
              (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-string))
+             (insert (prog1 (rmail-dont-reply-to (buffer-substring
+                                                  (point-min) (point-max)))
                        (erase-buffer)))
              (goto-char (point-min))
              ;; Perhaps Mail-Copies-To: never removed the only address?
@@ -3772,7 +3768,8 @@ OTHER-HEADERS is an alist of header/value pairs."
                    (mapcar
                     (lambda (addr)
                       (cons (mail-strip-quoted-names addr) addr))
-                    (message-tokenize-header (buffer-string))))
+                    (message-tokenize-header (buffer-substring
+                                              (point-min) (point-max)))))
              (let ((s ccalist))
                (while s
                  (setq ccalist (delq (assoc (car (pop s)) s) ccalist)))))
@@ -4060,7 +4057,7 @@ header line with the old Message-ID."
     (while (re-search-backward "[ \t]+$" nil t)
       (replace-match ""))
 
-    (buffer-string)))
+    (buffer-substring (point-min) (point-max))))
     
 ;;; Forwarding messages.