Mercurial > emacs
annotate lisp/gnus/gnus-dup.el @ 100988:66cd52ff7458
* elisp.texi: Update node listing.
* display.texi (Faces): Put Font Selection node after Auto Faces.
(Face Attributes): Don't link to Font Lookup. Document
font-family-list.
(Fonts): New node.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Thu, 08 Jan 2009 20:57:30 +0000 |
parents | a9dc0e7c3f2b |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
17493 | 1 ;;; gnus-dup.el --- suppression of duplicate articles in Gnus |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
2 |
74547 | 3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
100908 | 4 ;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
17493 | 5 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 7 ;; Keywords: news |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
17493 | 12 ;; it under the terms of the GNU General Public License as published by |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
17493 | 15 |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17493 | 19 ;; GNU General Public License for more details. |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
17493 | 23 |
24 ;;; Commentary: | |
25 | |
26 ;; This package tries to mark articles as read the second time the | |
27 ;; user reads a copy. This is useful if the server doesn't support | |
28 ;; Xref properly, or if the user reads the same group from several | |
29 ;; servers. | |
30 | |
31 ;;; Code: | |
32 | |
19493
8d840c4548c0
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
33 (eval-when-compile (require 'cl)) |
8d840c4548c0
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
34 |
17493 | 35 (require 'gnus) |
36 (require 'gnus-art) | |
37 | |
38 (defgroup gnus-duplicate nil | |
39 "Suppression of duplicate articles." | |
40 :group 'gnus) | |
41 | |
42 (defcustom gnus-save-duplicate-list nil | |
43 "*If non-nil, save the duplicate list when shutting down Gnus. | |
44 If nil, duplicate suppression will only work on duplicates | |
45 seen in the same session." | |
46 :group 'gnus-duplicate | |
47 :type 'boolean) | |
48 | |
49 (defcustom gnus-duplicate-list-length 10000 | |
50 "*The number of Message-IDs to keep in the duplicate suppression list." | |
51 :group 'gnus-duplicate | |
52 :type 'integer) | |
53 | |
54 (defcustom gnus-duplicate-file (nnheader-concat gnus-directory "suppression") | |
55 "*The name of the file to store the duplicate suppression list." | |
56 :group 'gnus-duplicate | |
57 :type 'file) | |
58 | |
59 ;;; Internal variables | |
60 | |
61 (defvar gnus-dup-list nil) | |
62 (defvar gnus-dup-hashtb nil) | |
63 | |
64 (defvar gnus-dup-list-dirty nil) | |
65 | |
66 ;;; | |
67 ;;; Starting and stopping | |
68 ;;; | |
69 | |
70 (gnus-add-shutdown 'gnus-dup-close 'gnus) | |
71 | |
72 (defun gnus-dup-close () | |
73 "Possibly save the duplicate suppression list and shut down the subsystem." | |
74 (gnus-dup-save) | |
75 (setq gnus-dup-list nil | |
76 gnus-dup-hashtb nil | |
77 gnus-dup-list-dirty nil)) | |
78 | |
79 (defun gnus-dup-open () | |
80 "Possibly read the duplicate suppression list and start the subsystem." | |
81 (if gnus-save-duplicate-list | |
82 (gnus-dup-read) | |
83 (setq gnus-dup-list nil)) | |
84 (setq gnus-dup-hashtb (gnus-make-hashtable gnus-duplicate-list-length)) | |
85 ;; Enter all Message-IDs into the hash table. | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
86 (let ((obarray gnus-dup-hashtb)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
87 (mapc 'intern gnus-dup-list))) |
17493 | 88 |
89 (defun gnus-dup-read () | |
90 "Read the duplicate suppression list." | |
91 (setq gnus-dup-list nil) | |
92 (when (file-exists-p gnus-duplicate-file) | |
93 (load gnus-duplicate-file t t t))) | |
94 | |
95 (defun gnus-dup-save () | |
96 "Save the duplicate suppression list." | |
97 (when (and gnus-save-duplicate-list | |
98 gnus-dup-list-dirty) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
99 (with-temp-file gnus-duplicate-file |
17493 | 100 (gnus-prin1 `(setq gnus-dup-list ',gnus-dup-list)))) |
101 (setq gnus-dup-list-dirty nil)) | |
102 | |
103 ;;; | |
104 ;;; Interface functions | |
105 ;;; | |
106 | |
107 (defun gnus-dup-enter-articles () | |
108 "Enter articles from the current group for future duplicate suppression." | |
109 (unless gnus-dup-list | |
110 (gnus-dup-open)) | |
111 (setq gnus-dup-list-dirty t) ; mark list for saving | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
112 (let (msgid) |
17493 | 113 ;; Enter the Message-IDs of all read articles into the list |
114 ;; and hash table. | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
115 (dolist (datum gnus-newsgroup-data) |
17493 | 116 (when (and (not (gnus-data-pseudo-p datum)) |
117 (> (gnus-data-number datum) 0) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19493
diff
changeset
|
118 (not (memq (gnus-data-number datum) gnus-newsgroup-unreads)) |
17493 | 119 (not (= (gnus-data-mark datum) gnus-canceled-mark)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
120 (setq msgid (mail-header-id (gnus-data-header datum))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
121 (not (nnheader-fake-message-id-p msgid)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
122 (not (intern-soft msgid gnus-dup-hashtb))) |
17493 | 123 (push msgid gnus-dup-list) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
124 (intern msgid gnus-dup-hashtb)))) |
17493 | 125 ;; Chop off excess Message-IDs from the list. |
126 (let ((end (nthcdr gnus-duplicate-list-length gnus-dup-list))) | |
127 (when end | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
128 (mapc (lambda (id) (unintern id gnus-dup-hashtb)) (cdr end)) |
17493 | 129 (setcdr end nil)))) |
130 | |
131 (defun gnus-dup-suppress-articles () | |
132 "Mark duplicate articles as read." | |
133 (unless gnus-dup-list | |
134 (gnus-dup-open)) | |
135 (gnus-message 6 "Suppressing duplicates...") | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
136 (let ((auto (and gnus-newsgroup-auto-expire |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
137 (memq gnus-duplicate-mark gnus-auto-expirable-marks))) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
138 number) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
139 (dolist (header gnus-newsgroup-headers) |
17493 | 140 (when (and (intern-soft (mail-header-id header) gnus-dup-hashtb) |
141 (gnus-summary-article-unread-p (mail-header-number header))) | |
142 (setq gnus-newsgroup-unreads | |
143 (delq (setq number (mail-header-number header)) | |
144 gnus-newsgroup-unreads)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
145 (if (not auto) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
146 (push (cons number gnus-duplicate-mark) gnus-newsgroup-reads) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
147 (push number gnus-newsgroup-expirable) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
148 (push (cons number gnus-expirable-mark) gnus-newsgroup-reads))))) |
17493 | 149 (gnus-message 6 "Suppressing duplicates...done")) |
150 | |
151 (defun gnus-dup-unsuppress-article (article) | |
152 "Stop suppression of ARTICLE." | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
153 (let* ((header (gnus-data-header (gnus-data-find article))) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
78224
diff
changeset
|
154 (id (when header (mail-header-id header)))) |
17493 | 155 (when id |
156 (setq gnus-dup-list-dirty t) | |
157 (setq gnus-dup-list (delete id gnus-dup-list)) | |
158 (unintern id gnus-dup-hashtb)))) | |
159 | |
160 (provide 'gnus-dup) | |
161 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
162 ;; arch-tag: 903e94db-7b00-4d19-83ee-cf34a81fa5fb |
17493 | 163 ;;; gnus-dup.el ends here |