/[emacs]/emacs/lisp/gnus/nnkiboze.el
ViewVC logotype

Diff of /emacs/lisp/gnus/nnkiboze.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7.18.2 by miles, Tue Oct 14 23:34:51 2003 UTC revision 1.7.18.3 by miles, Thu Sep 16 00:12:16 2004 UTC
# Line 1  Line 1 
1  ;;; nnkiboze.el --- select virtual news access for Gnus  ;;; nnkiboze.el --- select virtual news access for Gnus
2    
3  ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000  ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003
4  ;;      Free Software Foundation, Inc.  ;;      Free Software Foundation, Inc.
5    
6  ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>  ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
# Line 109  Line 109 
109        (setq num (string-to-int (match-string 2 xref))        (setq num (string-to-int (match-string 2 xref))
110              group (match-string 1 xref))              group (match-string 1 xref))
111        (or (with-current-buffer buffer        (or (with-current-buffer buffer
112              (gnus-cache-request-article num group))              (or (and gnus-use-cache (gnus-cache-request-article num group))
113                    (gnus-agent-request-article num group)))
114            (gnus-request-article num group buffer)))))            (gnus-request-article num group buffer)))))
115    
116  (deffoo nnkiboze-request-scan (&optional group server)  (deffoo nnkiboze-request-scan (&optional group server)
117      (nnkiboze-possibly-change-group group)
118    (nnkiboze-generate-group (concat "nnkiboze:" group)))    (nnkiboze-generate-group (concat "nnkiboze:" group)))
119    
120  (deffoo nnkiboze-request-group (group &optional server dont-check)  (deffoo nnkiboze-request-group (group &optional server dont-check)
# Line 227  Finds out what articles are to be part o Line 229  Finds out what articles are to be part o
229  (defun nnkiboze-generate-group (group &optional inhibit-list-groups)  (defun nnkiboze-generate-group (group &optional inhibit-list-groups)
230    (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))    (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
231           (newsrc-file (concat nnkiboze-directory           (newsrc-file (concat nnkiboze-directory
232                                (nnheader-translate-file-chars                                (nnheader-translate-file-chars
233                                 (concat group ".newsrc"))))                                 (concat group ".newsrc"))))
234           (nov-file (concat nnkiboze-directory           (nov-file (concat nnkiboze-directory
235                             (nnheader-translate-file-chars                             (nnheader-translate-file-chars
236                              (concat group ".nov"))))                              (concat group ".nov"))))
237           method nnkiboze-newsrc gname newsrc active           method nnkiboze-newsrc gname newsrc active
238           ginfo lowest glevel orig-info nov-buffer           ginfo lowest glevel orig-info nov-buffer
239           ;; Bind various things to nil to make group entry faster.           ;; Bind various things to nil to make group entry faster.
# Line 242  Finds out what articles are to be part o Line 244  Finds out what articles are to be part o
244           (gnus-score-use-all-scores nil)           (gnus-score-use-all-scores nil)
245           (gnus-use-scoring t)           (gnus-use-scoring t)
246           (gnus-verbose (min gnus-verbose 3))           (gnus-verbose (min gnus-verbose 3))
247           gnus-select-group-hook gnus-summary-prepare-hook           gnus-select-group-hook gnus-summary-prepare-hook
248           gnus-thread-sort-functions gnus-show-threads           gnus-thread-sort-functions gnus-show-threads
249           gnus-visual gnus-suppress-duplicates num-unread)           gnus-visual gnus-suppress-duplicates num-unread)
250      (unless info      (unless info
251        (error "No such group: %s" group))        (error "No such group: %s" group))
252      ;; Load the kiboze newsrc file for this group.      ;; Load the kiboze newsrc file for this group.
253      (when (file-exists-p newsrc-file)      (mm-with-unibyte
254        (load newsrc-file))        (when (file-exists-p newsrc-file)
255      (let ((coding-system-for-write nnkiboze-file-coding-system))          (load newsrc-file))
256        (with-temp-file nov-file        (let ((coding-system-for-write nnkiboze-file-coding-system))
257          (when (file-exists-p nov-file)          (gnus-make-directory (file-name-directory nov-file))
258            (insert-file-contents nov-file))          (with-temp-file nov-file
259          (setq nov-buffer (current-buffer))            (when (file-exists-p nov-file)
260          ;; Go through the active hashtb and add new all groups that match the              (insert-file-contents nov-file))
261          ;; kiboze regexp.            (setq nov-buffer (current-buffer))
262          (mapatoms            ;; Go through the active hashtb and add new all groups that match the
263           (lambda (group)            ;; kiboze regexp.
264             (and (string-match nnkiboze-regexp            (mapatoms
265                                (setq gname (symbol-name group))) ; Match             (lambda (group)
266                  (not (assoc gname nnkiboze-newsrc)) ; It isn't registered               (and (string-match nnkiboze-regexp
267                  (numberp (car (symbol-value group))) ; It is active                                  (setq gname (symbol-name group))) ; Match
268                  (or (> nnkiboze-level 7)                    (not (assoc gname nnkiboze-newsrc)) ; It isn't registered
269                      (and (setq glevel (nth 1 (nth 2 (gnus-gethash                    (numberp (car (symbol-value group))) ; It is active
270                                                       gname gnus-newsrc-hashtb))))                    (or (> nnkiboze-level 7)
271                           (>= nnkiboze-level glevel)))                        (and (setq glevel
272                  (not (string-match "^nnkiboze:" gname)) ; Exclude kibozes                                   (nth 1 (nth 2 (gnus-gethash
273                  (push (cons gname (1- (car (symbol-value group))))                                                  gname gnus-newsrc-hashtb))))
274                        nnkiboze-newsrc)))                             (>= nnkiboze-level glevel)))
275           gnus-active-hashtb)                    (not (string-match "^nnkiboze:" gname)) ; Exclude kibozes
276          ;; `newsrc' is set to the list of groups that possibly are                    (push (cons gname (1- (car (symbol-value group))))
277          ;; component groups to this kiboze group.  This list has elements                          nnkiboze-newsrc)))
278          ;; on the form `(GROUP . NUMBER)', where NUMBER is the highest             gnus-active-hashtb)
279          ;; number that has been kibozed in GROUP in this kiboze group.            ;; `newsrc' is set to the list of groups that possibly are
280          (setq newsrc nnkiboze-newsrc)            ;; component groups to this kiboze group.  This list has elements
281          (while newsrc            ;; on the form `(GROUP . NUMBER)', where NUMBER is the highest
282            (if (not (setq active (gnus-gethash            ;; number that has been kibozed in GROUP in this kiboze group.
283                                   (caar newsrc) gnus-active-hashtb)))            (setq newsrc nnkiboze-newsrc)
284                ;; This group isn't active after all, so we remove it from            (while newsrc
285                ;; the list of component groups.              (if (not (setq active (gnus-gethash
286                (setq nnkiboze-newsrc (delq (car newsrc) nnkiboze-newsrc))                                     (caar newsrc) gnus-active-hashtb)))
287              (setq lowest (cdar newsrc))                  ;; This group isn't active after all, so we remove it from
288              ;; Ok, we have a valid component group, so we jump to it.                  ;; the list of component groups.
289              (switch-to-buffer gnus-group-buffer)                  (setq nnkiboze-newsrc (delq (car newsrc) nnkiboze-newsrc))
290              (gnus-group-jump-to-group (caar newsrc))                (setq lowest (cdar newsrc))
291              (gnus-message 3 "nnkiboze: Checking %s..." (caar newsrc))                ;; Ok, we have a valid component group, so we jump to it.
292              (setq ginfo (gnus-get-info (gnus-group-group-name))                (switch-to-buffer gnus-group-buffer)
293                    orig-info (gnus-copy-sequence ginfo)                (gnus-group-jump-to-group (caar newsrc))
294                    num-unread (car (gnus-gethash (caar newsrc)                (gnus-message 3 "nnkiboze: Checking %s..." (caar newsrc))
295                                                  gnus-newsrc-hashtb)))                (setq ginfo (gnus-get-info (gnus-group-group-name))
296              (unwind-protect                      orig-info (gnus-copy-sequence ginfo)
297                  (progn                      num-unread (car (gnus-gethash (caar newsrc)
298                    ;; We set all list of article marks to nil.  Since we operate                                                    gnus-newsrc-hashtb)))
299                    ;; on copies of the real lists, we can destroy anything we                (unwind-protect
300                    ;; want here.                    (progn
301                    (when (nth 3 ginfo)                      ;; We set all list of article marks to nil.  Since we operate
302                      (setcar (nthcdr 3 ginfo) nil))                      ;; on copies of the real lists, we can destroy anything we
303                    ;; We set the list of read articles to be what we expect for                      ;; want here.
304                    ;; this kiboze group -- either nil or `(1 . LOWEST)'.                      (when (nth 3 ginfo)
305                    (when ginfo                        (setcar (nthcdr 3 ginfo) nil))
306                      (setcar (nthcdr 2 ginfo)                      ;; We set the list of read articles to be what we expect for
307                              (and (not (= lowest 1)) (cons 1 lowest))))                      ;; this kiboze group -- either nil or `(1 . LOWEST)'.
308                    (when (and (or (not ginfo)                      (when ginfo
309                                   (> (length (gnus-list-of-unread-articles                        (setcar (nthcdr 2 ginfo)
310                                               (car ginfo)))                                (and (not (= lowest 1)) (cons 1 lowest))))
311                                      0))                      (when (and (or (not ginfo)
312                               (progn                                     (> (length (gnus-list-of-unread-articles
313                                 (ignore-errors                                                 (car ginfo)))
314                                   (gnus-group-select-group nil))                                        0))
315                                 (eq major-mode 'gnus-summary-mode)))                                 (progn
316                      ;; We are now in the group where we want to be.                                   (ignore-errors
317                      (setq method (gnus-find-method-for-group                                     (gnus-group-select-group nil))
318                                    gnus-newsgroup-name))                                   (eq major-mode 'gnus-summary-mode)))
319                      (when (eq method gnus-select-method)                        ;; We are now in the group where we want to be.
320                        (setq method nil))                        (setq method (gnus-find-method-for-group
321                      ;; We go through the list of scored articles.                                      gnus-newsgroup-name))
322                      (while gnus-newsgroup-scored                        (when (eq method gnus-select-method)
323                        (when (> (caar gnus-newsgroup-scored) lowest)                          (setq method nil))
324                          ;; If it has a good score, then we enter this article                        ;; We go through the list of scored articles.
325                          ;; into the kiboze group.                        (while gnus-newsgroup-scored
326                          (nnkiboze-enter-nov                          (when (> (caar gnus-newsgroup-scored) lowest)
327                           nov-buffer                            ;; If it has a good score, then we enter this article
328                           (gnus-summary-article-header                            ;; into the kiboze group.
329                            (caar gnus-newsgroup-scored))                            (nnkiboze-enter-nov
330                           gnus-newsgroup-name))                             nov-buffer
331                        (setq gnus-newsgroup-scored (cdr gnus-newsgroup-scored)))                             (gnus-summary-article-header
332                      ;; That's it.  We exit this group.                              (caar gnus-newsgroup-scored))
333                      (when (eq major-mode 'gnus-summary-mode)                             gnus-newsgroup-name))
334                        (kill-buffer (current-buffer)))))                          (setq gnus-newsgroup-scored (cdr gnus-newsgroup-scored)))
335                ;; Restore the proper info.                        ;; That's it.  We exit this group.
336                (when ginfo                        (when (eq major-mode 'gnus-summary-mode)
337                  (setcdr ginfo (cdr orig-info)))                          (kill-buffer (current-buffer)))))
338                (setcar (gnus-gethash (caar newsrc) gnus-newsrc-hashtb)                  ;; Restore the proper info.
339                        num-unread)))                  (when ginfo
340            (setcdr (car newsrc) (car active))                    (setcdr ginfo (cdr orig-info)))
341            (gnus-message 3 "nnkiboze: Checking %s...done" (caar newsrc))                  (setcar (gnus-gethash (caar newsrc) gnus-newsrc-hashtb)
342            (setq newsrc (cdr newsrc)))))                          num-unread)))
343      ;; We save the kiboze newsrc for this group.              (setcdr (car newsrc) (cdr active))
344      (with-temp-file newsrc-file              (gnus-message 3 "nnkiboze: Checking %s...done" (caar newsrc))
345        (insert "(setq nnkiboze-newsrc '")              (setq newsrc (cdr newsrc)))))
346        (gnus-prin1 nnkiboze-newsrc)        ;; We save the kiboze newsrc for this group.
347        (insert ")\n")))        (gnus-make-directory (file-name-directory newsrc-file))
348          (with-temp-file newsrc-file
349            (insert "(setq nnkiboze-newsrc '")
350            (gnus-prin1 nnkiboze-newsrc)
351            (insert ")\n")))
352    (unless inhibit-list-groups    (unless inhibit-list-groups
353      (save-excursion      (save-excursion
354        (set-buffer gnus-group-buffer)        (set-buffer gnus-group-buffer)
355        (gnus-group-list-groups)))        (gnus-group-list-groups)))
356    t)    t))
357    
358  (defun nnkiboze-enter-nov (buffer header group)  (defun nnkiboze-enter-nov (buffer header group)
359    (save-excursion    (save-excursion

Legend:
Removed from v.1.7.18.2  
changed lines
  Added in v.1.7.18.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26