(require 'nnheader)
(require 'nnoo)
(require 'gnus-util)
+(require 'gnus)
(nnoo-declare nntp)
+(defgroup nntp nil
+ "NNTP access for Gnus."
+ :group 'gnus)
+
(defvoo nntp-address nil
"Address of the physical nntp server.")
;; Marks
(defvoo nntp-marks-is-evil nil
- "*If non-nil, GNus will never generate and use marks file for nntp groups.
+ "*If non-nil, Gnus will never generate and use marks file for nntp groups.
See `nnml-marks-is-evil' for more information.")
(defvoo nntp-marks-file-name ".marks")
(defcustom nntp-authinfo-file "~/.authinfo"
".netrc-like file that holds nntp authinfo passwords."
+ :group 'nntp
:type
'(choice file
(repeat :tag "Entries"
t)
(deffoo nntp-request-set-mark (group actions &optional server)
- (nntp-possibly-create-directory group server)
(unless nntp-marks-is-evil
+ (nntp-possibly-create-directory group server)
(nntp-open-marks group server)
(dolist (action actions)
(let ((range (nth 0 action))
nil)
(deffoo nntp-request-update-info (group info &optional server)
- (nntp-possibly-create-directory group server)
- (when (and (not nntp-marks-is-evil) (nntp-marks-changed-p group server))
- (nnheader-message 8 "Updating marks for %s..." group)
- (nntp-open-marks group server)
- ;; Update info using `nntp-marks'.
- (mapc (lambda (pred)
- (unless (memq (cdr pred) gnus-article-unpropagated-mark-lists)
- (gnus-info-set-marks
- info
- (gnus-update-alist-soft
- (cdr pred)
- (cdr (assq (cdr pred) nntp-marks))
- (gnus-info-marks info))
- t)))
- gnus-article-mark-lists)
- (let ((seen (cdr (assq 'read nntp-marks))))
- (gnus-info-set-read info
- (if (and (integerp (car seen))
- (null (cdr seen)))
- (list (cons (car seen) (car seen)))
- seen)))
- (nnheader-message 8 "Updating marks for %s...done" group))
- info)
+ (unless nntp-marks-is-evil
+ (nntp-possibly-create-directory group server)
+ (when (nntp-marks-changed-p group server)
+ (nnheader-message 8 "Updating marks for %s..." group)
+ (nntp-open-marks group server)
+ ;; Update info using `nntp-marks'.
+ (mapc (lambda (pred)
+ (unless (memq (cdr pred) gnus-article-unpropagated-mark-lists)
+ (gnus-info-set-marks
+ info
+ (gnus-update-alist-soft
+ (cdr pred)
+ (cdr (assq (cdr pred) nntp-marks))
+ (gnus-info-marks info))
+ t)))
+ gnus-article-mark-lists)
+ (let ((seen (cdr (assq 'read nntp-marks))))
+ (gnus-info-set-read info
+ (if (and (integerp (car seen))
+ (null (cdr seen)))
+ (list (cons (car seen) (car seen)))
+ seen)))
+ (nnheader-message 8 "Updating marks for %s...done" group)))
+ nil)
If SEND-IF-FORCE, only send authinfo to the server if the
.authinfo file has the FORCE token."
- (let* ((list (gnus-parse-netrc nntp-authinfo-file))
- (alist (gnus-netrc-machine list nntp-address "nntp"))
- (force (gnus-netrc-get alist "force"))
- (user (or (gnus-netrc-get alist "login") nntp-authinfo-user))
- (passwd (gnus-netrc-get alist "password")))
+ (let* ((list (netrc-parse nntp-authinfo-file))
+ (alist (netrc-machine list nntp-address "nntp"))
+ (force (netrc-get alist "force"))
+ (user (or (netrc-get alist "login") nntp-authinfo-user))
+ (passwd (netrc-get alist "password")))
(when (or (not send-if-force)
force)
(unless user
"Find out what the name of the server we have connected to is."
;; Wait for the status string to arrive.
(setq nntp-server-type (buffer-string))
- (let ((alist nntp-server-action-alist)
- (case-fold-search t)
- entry)
+ (let ((case-fold-search t))
;; Run server-specific commands.
- (while alist
- (setq entry (pop alist))
+ (dolist (entry nntp-server-action-alist)
(when (string-match (car entry) nntp-server-type)
(if (and (listp (cadr entry))
(not (eq 'lambda (caadr entry))))
(make-directory (directory-file-name dir) t)
(nnheader-message 5 "Creating nntp marks directory %s" dir))))
+(autoload 'time-less-p "time-date")
+
(defun nntp-marks-changed-p (group server)
(let ((file (expand-file-name
- nntp-marks-file-name
+ nntp-marks-file-name
(nnmail-group-pathname
group (nntp-marks-directory server)))))
(if (null (gnus-gethash file nntp-marks-modtime))
t ;; never looked at marks file, assume it has changed
- (not (equal (gnus-gethash file nntp-marks-modtime)
- (nth 5 (file-attributes file)))))))
+ (time-less-p (gnus-gethash file nntp-marks-modtime)
+ (nth 5 (file-attributes file))))))
(defun nntp-save-marks (group server)
(let ((file-name-coding-system nnmail-pathname-coding-system)