]> code.delx.au - gnu-emacs/blobdiff - lisp/gnus/nnheader.el
; Merge from origin/emacs-25
[gnu-emacs] / lisp / gnus / nnheader.el
index 2ce5cb8af5f9a26c0429b1fdc81e98833973dc40..191a90892f3bac1c3f6ce42f98ae297a7828c9c4 100644 (file)
@@ -1,6 +1,6 @@
 ;;; nnheader.el --- header access macros for Gnus and its backends
 
-;; Copyright (C) 1987-1990, 1993-1998, 2000-2015 Free Software
+;; Copyright (C) 1987-1990, 1993-1998, 2000-2016 Free Software
 ;; Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
@@ -40,6 +40,7 @@
 (require 'mail-utils)
 (require 'mm-util)
 (require 'gnus-util)
+(require 'subr-x)
 (autoload 'gnus-range-add "gnus-range")
 (autoload 'gnus-remove-from-range "gnus-range")
 ;; FIXME none of these are used explicitly in this file.
@@ -66,7 +67,7 @@ they will keep on jabbering all the time."
   "*Max length of the head of articles.
 
 Value is an integer, nil, or t.  nil means read in chunks of a file
-indefinitely until a complete head is found\; t means always read the
+indefinitely until a complete head is found; t means always read the
 entire file immediately, disregarding `nnheader-head-chop-length'.
 
 Integer values will in effect be rounded up to the nearest multiple of
@@ -114,7 +115,7 @@ Shorter values mean quicker response, but are more CPU intensive.")
 For instance, if \":\" is invalid as a file character in file names
 on your system, you could say something like:
 
-\(setq nnheader-file-name-translation-alist '((?: . ?_)))")
+\(setq nnheader-file-name-translation-alist \\='((?: . ?_)))")
 
 (defvar nnheader-directory-separator-character
   (string-to-char (substring (file-name-as-directory ".") -1))
@@ -621,8 +622,8 @@ the line could be found."
                        (< beg nnheader-max-head-length))))
        ;; Finally decode the contents.
        (when (mm-coding-system-p nnheader-file-coding-system)
-         (mm-decode-coding-region start (point-max)
-                                  nnheader-file-coding-system))))
+         (decode-coding-region start (point-max)
+                               nnheader-file-coding-system))))
     t))
 
 (defun nnheader-article-p ()
@@ -726,9 +727,7 @@ the line could be found."
     (string-match nnheader-numerical-short-files file)
     (string-to-number (match-string 0 file))))
 
-(defvar nnheader-directory-files-is-safe
-  (or (eq system-type 'windows-nt)
-      (not (featurep 'xemacs)))
+(defvar nnheader-directory-files-is-safe (not (eq system-type 'windows-nt))
   "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,
@@ -780,28 +779,8 @@ If FULL, translate everything."
                      2 0))
        ;; We translate -- but only the file name.  We leave the directory
        ;; alone.
-       (if (and (featurep 'xemacs)
-                (memq system-type '(windows-nt cygwin)))
-           ;; This is needed on NT and stuff, because
-           ;; file-name-nondirectory is not enough to split
-           ;; file names, containing ':', e.g.
-           ;; "d:\\Work\\News\\nntp+news.fido7.ru:fido7.ru.gnu.SCORE"
-           ;;
-           ;; we are trying to correctly split such names:
-           ;; "d:file.name" -> "a:" "file.name"
-           ;; "aaa:bbb.ccc" -> "" "aaa:bbb.ccc"
-           ;; "d:aaa\\bbb:ccc"   -> "d:aaa\\" "bbb:ccc"
-           ;; etc.
-           ;; to translate then only the file name part.
-           (progn
-             (setq leaf file
-                   path "")
-             (if (string-match "\\(^\\w:\\|[/\\]\\)\\([^/\\]+\\)$" file)
-                 (setq leaf (substring file (match-beginning 2))
-                       path (substring file 0 (match-beginning 2)))))
-         ;; Emacs DTRT, says andrewi.
-         (setq leaf (file-name-nondirectory file)
-               path (file-name-directory file))))
+       (setq leaf (file-name-nondirectory file)
+             path (file-name-directory file)))
       (setq len (length leaf))
       (while (< i len)
        (when (setq trans (cdr (assq (aref leaf i)
@@ -842,7 +821,7 @@ without formatting."
     t))
 
 (defsubst nnheader-replace-chars-in-string (string from to)
-  (mm-subst-char-in-string from to string))
+  (subst-char-in-string from to string))
 
 (defun nnheader-replace-duplicate-chars-in-string (string from to)
   "Replace characters in STRING from FROM to TO."
@@ -898,7 +877,7 @@ without formatting."
       (if (file-directory-p (concat dir group))
          (expand-file-name group dir)
        ;; If not, we translate dots into slashes.
-       (expand-file-name (mm-encode-coding-string
+       (expand-file-name (encode-coding-string
                           (nnheader-replace-chars-in-string group ?. ?/)
                           nnheader-pathname-coding-system)
                          dir))))
@@ -1002,14 +981,8 @@ See `find-file-noselect' for the arguments."
           (enable-local-eval nil)
           (coding-system-for-read nnheader-file-coding-system)
           (version-control 'never)
-          (ffh (if (boundp 'find-file-hook)
-                   'find-file-hook
-                 'find-file-hooks))
-          (val (symbol-value ffh)))
-    (set ffh nil)
-    (unwind-protect
-       (apply 'find-file-noselect args)
-      (set ffh val))))
+         (find-file-hook nil))
+    (apply 'find-file-noselect args)))
 
 (defun nnheader-directory-regular-files (dir)
   "Return a list of all regular files in DIR."
@@ -1098,16 +1071,14 @@ See `find-file-noselect' for the arguments."
 
 (defmacro nnheader-insert-buffer-substring (buffer &optional start end)
   "Copy string from unibyte buffer to multibyte current buffer."
-  (if (featurep 'xemacs)
-      `(insert-buffer-substring ,buffer ,start ,end)
-    `(if enable-multibyte-characters
-        (insert (with-current-buffer ,buffer
-                  (mm-string-to-multibyte
-                   ,(if (or start end)
-                        `(buffer-substring (or ,start (point-min))
-                                           (or ,end (point-max)))
-                      '(buffer-string)))))
-       (insert-buffer-substring ,buffer ,start ,end))))
+  `(if enable-multibyte-characters
+       (insert (with-current-buffer ,buffer
+                (string-to-multibyte
+                 ,(if (or start end)
+                      `(buffer-substring (or ,start (point-min))
+                                         (or ,end (point-max)))
+                    '(buffer-string)))))
+     (insert-buffer-substring ,buffer ,start ,end)))
 
 (defvar nnheader-last-message-time '(0 0))
 (defun nnheader-message-maybe (&rest args)
@@ -1116,9 +1087,6 @@ See `find-file-noselect' for the arguments."
       (setq nnheader-last-message-time now)
       (apply 'nnheader-message args))))
 
-(when (featurep 'xemacs)
-  (require 'nnheaderxm))
-
 (run-hooks 'nnheader-load-hook)
 
 (provide 'nnheader)