* nnheader.el (mm-disable-multibyte): New function.
[elisp/gnus.git-] / lisp / nnheader.el
index 0928e90..cfee952 100644 (file)
@@ -136,7 +136,6 @@ This variable is a substitute for `mm-text-coding-system-for-write'.")
   (autoload 'nnmail-message-id "nnmail")
   (autoload 'mail-position-on-field "sendmail")
   (autoload 'message-remove-header "message")
-  (autoload 'gnus-point-at-eol "gnus-util")
   (autoload 'gnus-buffer-live-p "gnus-util"))
 
 ;; mm-util stuff.
@@ -287,7 +286,24 @@ nil, ."
     "Return non-nil if SYM is a coding system."
     (or (and (fboundp 'find-coding-system) (find-coding-system sym))
        (and (fboundp 'coding-system-p) (coding-system-p sym))))
-  (defalias 'mm-coding-system-p 'nnheader-coding-system-p))
+  (defalias 'mm-coding-system-p 'nnheader-coding-system-p)
+
+  (defalias 'mm-disable-multibyte
+    (static-if (featurep 'xemacs)
+       'ignore
+      (lambda nil (set-buffer-multibyte nil))))
+  (defalias 'mm-enable-multibyte
+    (static-if (featurep 'xemacs)
+       'ignore
+      ;; Why isn't it t but `to'?  See mm-util.el.
+      (lambda nil (set-buffer-multibyte 'to))))
+
+  (defalias 'mm-encode-coding-region 'encode-coding-region)
+
+  (defalias 'mm-string-make-unibyte
+    (if (fboundp 'string-make-unibyte)
+       'string-make-unibyte
+      'identity)))
 
 ;; mail-parse stuff.
 (unless (featurep 'mail-parse)
@@ -328,7 +344,7 @@ nil, ."
                (first t)
                (bol (save-restriction
                       (widen)
-                      (gnus-point-at-bol))))
+                      (point-at-bol))))
            (while (not (eobp))
              (when (and (or break qword-break)
                         (> (- (point) bol) 76))
@@ -404,18 +420,18 @@ nil, ."
          (goto-char (point-min))
          (let ((bol (save-restriction
                       (widen)
-                      (gnus-point-at-bol)))
-               (eol (gnus-point-at-eol)))
+                      (point-at-bol)))
+               (eol (point-at-eol)))
            (forward-line 1)
            (while (not (eobp))
              (if (and (looking-at "[ \t]")
-                      (< (- (gnus-point-at-eol) bol) 76))
+                      (< (- (point-at-eol) bol) 76))
                  (delete-region eol (progn
                                       (goto-char eol)
                                       (skip-chars-forward "\r\n")
                                       (point)))
-               (setq bol (gnus-point-at-bol)))
-             (setq eol (gnus-point-at-eol))
+               (setq bol (point-at-bol)))
+             (setq eol (point-at-eol))
              (forward-line 1)))))))
 
   (unless (fboundp 'std11-unfold-field)
@@ -664,9 +680,9 @@ given, the return value will not contain the last newline."
           (goto-char p)
           (if (search-forward "\nmessage-id:" nil t)
               (buffer-substring
-               (1- (or (search-forward "<" (gnus-point-at-eol) t)
+               (1- (or (search-forward "<" (point-at-eol) t)
                        (point)))
-               (or (search-forward ">" (gnus-point-at-eol) t) (point)))
+               (or (search-forward ">" (point-at-eol) t) (point)))
             ;; If there was no message-id, we just fake one to make
             ;; subsequent routines simpler.
             (nnheader-generate-fake-message-id)))
@@ -775,7 +791,7 @@ given, the return value will not contain the last newline."
        (nnheader-generate-fake-message-id))))
 
 (defun nnheader-parse-nov ()
-  (let ((eol (gnus-point-at-eol)))
+  (let ((eol (point-at-eol)))
     (make-full-mail-header
      (nnheader-nov-read-integer)       ; number
      (nnheader-nov-field)              ; subject
@@ -1178,7 +1194,7 @@ list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
       ;; This is invalid, but not all articles have Message-IDs.
       ()
     (mail-position-on-field "References")
-    (let ((begin (gnus-point-at-bol))
+    (let ((begin (point-at-bol))
          (fill-column 78)
          (fill-prefix "\t"))
       (when references
@@ -1212,6 +1228,14 @@ list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
      (point-max)))
   (goto-char (point-min)))
 
+(defun nnheader-get-lines-and-char ()
+  "Return the number of lines and chars in the article body."
+  (goto-char (point-min))
+  (if (not (re-search-forward "\n\r?\n" nil t))
+      (list 0 0)
+    (list (count-lines (point) (point-max))
+         (- (point-max) (point)))))
+
 (defun nnheader-remove-body ()
   "Remove the body from an article in this current buffer."
   (goto-char (point-min))
@@ -1251,8 +1275,7 @@ list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
 
 (defvar nnheader-directory-files-is-safe
   (or (eq system-type 'windows-nt)
-      (and (not (featurep 'xemacs))
-          (> emacs-major-version 20)))
+      (not (featurep 'xemacs)))
   "If non-nil, Gnus believes `directory-files' is safe.
 It has been reported numerous times that `directory-files' fails with
 an alarming frequency on NFS mounted file systems. If it is nil,
@@ -1604,7 +1627,6 @@ find-file-hooks, etc.
   "Strip all \r's from the current buffer."
   (nnheader-skeleton-replace "\r"))
 
-(defalias 'nnheader-run-at-time 'run-at-time)
 (defalias 'nnheader-cancel-timer 'cancel-timer)
 (defalias 'nnheader-cancel-function-timers 'cancel-function-timers)
 (defalias 'nnheader-string-as-multibyte 'string-as-multibyte)