File: sb-lump.el

package info (click to toggle)
w3m-el 1.4.569%2B0.20170110-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,780 kB
  • sloc: lisp: 45,666; sh: 515; makefile: 403
file content (77 lines) | stat: -rw-r--r-- 2,786 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;;; sb-lump.el --- shimbun backend class to check all groups at once

;; Copyright (C) 2001, 2002 Yuuichi Teranishi <teranisi@gohome.org>

;; Author: TSUCHIYA Masatoshi <tsuchiya@namazu.org>,
;;         Yuuichi Teranishi  <teranisi@gohome.org>
;; Keywords: news

;; This file is a part of shimbun.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; see the file COPYING.  If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; Original code was nnshimbun.el written by
;; TSUCHIYA Masatoshi <tsuchiya@namazu.org>.

;;; Code:

(require 'shimbun)
(defvar shimbun-lump-check-interval 300)

(eval-and-compile
  (luna-define-class shimbun-lump (shimbun)
		     (group-header-alist last-check check-interval))
  (luna-define-internal-accessors 'shimbun-lump))

(defsubst shimbun-lump-check-interval (shimbun)
  (or (shimbun-lump-check-interval-internal shimbun)
      shimbun-lump-check-interval))

(defun shimbun-lump-lapse-seconds (time)
  (let ((now (current-time)))
    (+ (* (- (car now) (car time)) 65536)
       (- (nth 1 now) (nth 1 time)))))

(defun shimbun-lump-check-p (shimbun)
  (or (null (shimbun-lump-last-check-internal shimbun))
      (and (shimbun-lump-last-check-internal shimbun)
	   (> (shimbun-lump-lapse-seconds
	       (shimbun-lump-last-check-internal shimbun))
	      (shimbun-lump-check-interval shimbun)))))

(defun shimbun-lump-checked (shimbun)
  (shimbun-lump-set-last-check-internal shimbun (current-time)))

(luna-define-generic shimbun-get-group-header-alist (shimbun &optional range)
  "Return an alist of group and header list.")

(luna-define-method shimbun-headers ((shimbun shimbun-lump) &optional range)
  (when (shimbun-lump-check-p shimbun)
    (shimbun-lump-set-group-header-alist-internal
     shimbun (shimbun-get-group-header-alist shimbun range))
    (shimbun-lump-checked shimbun))
  (cdr (assoc (shimbun-current-group-internal shimbun)
	      (shimbun-lump-group-header-alist-internal shimbun))))

(luna-define-method shimbun-close :after ((shimbun shimbun-lump))
  (shimbun-lump-set-group-header-alist-internal shimbun nil)
  (shimbun-lump-set-last-check-internal shimbun nil))

(provide 'sb-lump)

;;; sb-lump.el ends here