summaryrefslogtreecommitdiff
path: root/lisp/gnus/nnheader.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/gnus/nnheader.el')
-rw-r--r--lisp/gnus/nnheader.el105
1 files changed, 42 insertions, 63 deletions
diff --git a/lisp/gnus/nnheader.el b/lisp/gnus/nnheader.el
index cd43016014..6782229ad2 100644
--- a/lisp/gnus/nnheader.el
+++ b/lisp/gnus/nnheader.el
@@ -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.
@@ -62,18 +63,23 @@ they will keep on jabbering all the time."
:group 'gnus-server
:type 'boolean)
-(defvar nnheader-max-head-length 8192
- "*Max length of the head of articles.
+(defcustom nnheader-max-head-length 8192
+ "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
entire file immediately, disregarding `nnheader-head-chop-length'.
Integer values will in effect be rounded up to the nearest multiple of
-`nnheader-head-chop-length'.")
-
-(defvar nnheader-head-chop-length 2048
- "*Length of each read operation when trying to fetch HEAD headers.")
+`nnheader-head-chop-length'."
+ :group 'gnus-article-various ; FIXME?
+ :type '(choice integer (const :tag "Read chunks" nil)
+ (const :tag "Read entire file" t)))
+
+(defcustom nnheader-head-chop-length 2048
+ "Length of each read operation when trying to fetch HEAD headers."
+ :group 'gnus-article-various ; FIXME?
+ :type 'integer)
(defvar nnheader-read-timeout
(if (string-match "windows-nt\\|os/2\\|cygwin"
@@ -98,7 +104,7 @@ Integer values will in effect be rounded up to the nearest multiple of
"How long nntp should wait between checking for the end of output.
Shorter values mean quicker response, but are more CPU intensive.")
-(defvar nnheader-file-name-translation-alist
+(defcustom nnheader-file-name-translation-alist
(let ((case-fold-search t))
(cond
((string-match "windows-nt\\|os/2\\|cygwin"
@@ -110,15 +116,19 @@ Shorter values mean quicker response, but are more CPU intensive.")
nil
'((?+ . ?-)))))
(t nil)))
- "*Alist that says how to translate characters in file names.
+ "Alist that says how to translate characters in file names.
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 \\='((?: . ?_)))"
+ :group 'gnus-article-various ; FIXME?
+ :type '(alist :key-type character :value-type character))
-(defvar nnheader-directory-separator-character
+(defcustom nnheader-directory-separator-character
(string-to-char (substring (file-name-as-directory ".") -1))
- "*A character used to a directory separator.")
+ "A character used as a directory separator."
+ :group 'gnus-article-various ; FIXME?
+ :type 'character)
(autoload 'nnmail-message-id "nnmail")
(autoload 'mail-position-on-field "sendmail")
@@ -621,8 +631,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 +736,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 +788,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 +830,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."
@@ -886,8 +874,10 @@ without formatting."
(or (not (numberp gnus-verbose-backends))
(<= level gnus-verbose-backends)))
-(defvar nnheader-pathname-coding-system 'iso-8859-1
- "*Coding system for file name.")
+(defcustom nnheader-pathname-coding-system 'iso-8859-1
+ "Coding system for file name."
+ :group 'gnus-article-various ; FIXME?
+ :type 'coding-system)
(defun nnheader-group-pathname (group dir &optional file)
"Make file name for GROUP."
@@ -898,7 +888,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 +992,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 +1082,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 +1098,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)