*** empty log message ***
[emacs.git] / lisp / gnus / gnus-registry.el
blob17e8d5a5f507d0981d9f294a19efa41ba21b5e49
1 ;;; gnus-registry.el --- article registry for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Ted Zlatanov <tzz@lifelogs.com>
7 ;; Keywords: news
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
26 ;;; Commentary:
28 ;; This is the gnus-registry.el package, works with other backends
29 ;; besides nnmail. The major issue is that it doesn't go across
30 ;; backends, so for instance if an article is in nnml:sys and you see
31 ;; a reference to it in nnimap splitting, the article will end up in
32 ;; nnimap:sys
34 ;; gnus-registry.el intercepts article respooling, moving, deleting,
35 ;; and copying for all backends. If it doesn't work correctly for
36 ;; you, submit a bug report and I'll be glad to fix it. It needs
37 ;; documentation in the manual (also on my to-do list).
39 ;; Put this in your startup file (~/.gnus.el for instance)
41 ;; (setq gnus-registry-max-entries 2500
42 ;; gnus-registry-use-long-group-names t)
44 ;; (gnus-registry-initialize)
46 ;; Then use this in your fancy-split:
48 ;; (: gnus-registry-split-fancy-with-parent)
50 ;; TODO:
52 ;; - get the correct group on spool actions
54 ;; - articles that are spooled to a different backend should be handled
56 ;;; Code:
58 (eval-when-compile (require 'cl))
60 (require 'gnus)
61 (require 'gnus-int)
62 (require 'gnus-sum)
63 (require 'nnmail)
65 (defvar gnus-registry-dirty t
66 "Boolean set to t when the registry is modified")
68 (defgroup gnus-registry nil
69 "The Gnus registry."
70 :version "22.1"
71 :group 'gnus)
73 (defvar gnus-registry-hashtb nil
74 "*The article registry by Message ID.")
76 (defcustom gnus-registry-unfollowed-groups '("delayed" "drafts" "queue")
77 "List of groups that gnus-registry-split-fancy-with-parent won't follow.
78 The group names are matched, they don't have to be fully qualified."
79 :group 'gnus-registry
80 :type '(repeat string))
82 (defcustom gnus-registry-install nil
83 "Whether the registry should be installed."
84 :group 'gnus-registry
85 :type 'boolean)
87 (defcustom gnus-registry-clean-empty t
88 "Whether the empty registry entries should be deleted.
89 Registry entries are considered empty when they have no groups."
90 :group 'gnus-registry
91 :type 'boolean)
93 (defcustom gnus-registry-use-long-group-names nil
94 "Whether the registry should use long group names (BUGGY)."
95 :group 'gnus-registry
96 :type 'boolean)
98 (defcustom gnus-registry-track-extra nil
99 "Whether the registry should track extra data about a message.
100 The Subject and Sender (From:) headers are currently tracked this
101 way."
102 :group 'gnus-registry
103 :type
104 '(set :tag "Tracking choices"
105 (const :tag "Track by subject (Subject: header)" subject)
106 (const :tag "Track by sender (From: header)" sender)))
108 (defcustom gnus-registry-entry-caching t
109 "Whether the registry should cache extra information."
110 :group 'gnus-registry
111 :type 'boolean)
113 (defcustom gnus-registry-minimum-subject-length 5
114 "The minimum length of a subject before it's considered trackable."
115 :group 'gnus-registry
116 :type 'integer)
118 (defcustom gnus-registry-trim-articles-without-groups t
119 "Whether the registry should clean out message IDs without groups."
120 :group 'gnus-registry
121 :type 'boolean)
123 (defcustom gnus-registry-cache-file "~/.gnus.registry.eld"
124 "File where the Gnus registry will be stored."
125 :group 'gnus-registry
126 :type 'file)
128 (defcustom gnus-registry-max-entries nil
129 "Maximum number of entries in the registry, nil for unlimited."
130 :group 'gnus-registry
131 :type '(radio (const :format "Unlimited " nil)
132 (integer :format "Maximum number: %v")))
134 ;; Function(s) missing in Emacs 20
135 (when (memq nil (mapcar 'fboundp '(puthash)))
136 (require 'cl)
137 (unless (fboundp 'puthash)
138 ;; alias puthash is missing from Emacs 20 cl-extra.el
139 (defalias 'puthash 'cl-puthash)))
141 (defun gnus-registry-track-subject-p ()
142 (memq 'subject gnus-registry-track-extra))
144 (defun gnus-registry-track-sender-p ()
145 (memq 'sender gnus-registry-track-extra))
147 (defun gnus-registry-cache-read ()
148 "Read the registry cache file."
149 (interactive)
150 (let ((file gnus-registry-cache-file))
151 (when (file-exists-p file)
152 (gnus-message 5 "Reading %s..." file)
153 (gnus-load file)
154 (gnus-message 5 "Reading %s...done" file))))
156 (defun gnus-registry-cache-save ()
157 "Save the registry cache file."
158 (interactive)
159 (let ((file gnus-registry-cache-file))
160 (save-excursion
161 (set-buffer (gnus-get-buffer-create " *Gnus-registry-cache*"))
162 (make-local-variable 'version-control)
163 (setq version-control gnus-backup-startup-file)
164 (setq buffer-file-name file)
165 (setq default-directory (file-name-directory buffer-file-name))
166 (buffer-disable-undo)
167 (erase-buffer)
168 (gnus-message 5 "Saving %s..." file)
169 (if gnus-save-startup-file-via-temp-buffer
170 (let ((coding-system-for-write gnus-ding-file-coding-system)
171 (standard-output (current-buffer)))
172 (gnus-gnus-to-quick-newsrc-format t "gnus registry startup file" 'gnus-registry-alist)
173 (gnus-registry-cache-whitespace file)
174 (save-buffer))
175 (let ((coding-system-for-write gnus-ding-file-coding-system)
176 (version-control gnus-backup-startup-file)
177 (startup-file file)
178 (working-dir (file-name-directory file))
179 working-file
180 (i -1))
181 ;; Generate the name of a non-existent file.
182 (while (progn (setq working-file
183 (format
184 (if (and (eq system-type 'ms-dos)
185 (not (gnus-long-file-names)))
186 "%s#%d.tm#" ; MSDOS limits files to 8+3
187 (if (memq system-type '(vax-vms axp-vms))
188 "%s$tmp$%d"
189 "%s#tmp#%d"))
190 working-dir (setq i (1+ i))))
191 (file-exists-p working-file)))
193 (unwind-protect
194 (progn
195 (gnus-with-output-to-file working-file
196 (gnus-gnus-to-quick-newsrc-format t "gnus registry startup file" 'gnus-registry-alist))
198 ;; These bindings will mislead the current buffer
199 ;; into thinking that it is visiting the startup
200 ;; file.
201 (let ((buffer-backed-up nil)
202 (buffer-file-name startup-file)
203 (file-precious-flag t)
204 (setmodes (file-modes startup-file)))
205 ;; Backup the current version of the startup file.
206 (backup-buffer)
208 ;; Replace the existing startup file with the temp file.
209 (rename-file working-file startup-file t)
210 (set-file-modes startup-file setmodes)))
211 (condition-case nil
212 (delete-file working-file)
213 (file-error nil)))))
215 (gnus-kill-buffer (current-buffer))
216 (gnus-message 5 "Saving %s...done" file))))
218 ;; Idea from Dan Christensen <jdc@chow.mat.jhu.edu>
219 ;; Save the gnus-registry file with extra line breaks.
220 (defun gnus-registry-cache-whitespace (filename)
221 (gnus-message 5 "Adding whitespace to %s" filename)
222 (save-excursion
223 (goto-char (point-min))
224 (while (re-search-forward "^(\\|(\\\"" nil t)
225 (replace-match "\n\\&" t))
226 (goto-char (point-min))
227 (while (re-search-forward " $" nil t)
228 (replace-match "" t t))))
230 (defun gnus-registry-save (&optional force)
231 (when (or gnus-registry-dirty force)
232 (let ((caching gnus-registry-entry-caching))
233 ;; turn off entry caching, so mtime doesn't get recorded
234 (setq gnus-registry-entry-caching nil)
235 ;; remove entry caches
236 (maphash
237 (lambda (key value)
238 (if (hash-table-p value)
239 (remhash key gnus-registry-hashtb)))
240 gnus-registry-hashtb)
241 ;; remove empty entries
242 (when gnus-registry-clean-empty
243 (gnus-registry-clean-empty-function))
244 ;; now trim the registry appropriately
245 (setq gnus-registry-alist (gnus-registry-trim
246 (hashtable-to-alist gnus-registry-hashtb)))
247 ;; really save
248 (gnus-registry-cache-save)
249 (setq gnus-registry-entry-caching caching)
250 (setq gnus-registry-dirty nil))))
252 (defun gnus-registry-clean-empty-function ()
253 "Remove all empty entries from the registry. Returns count thereof."
254 (let ((count 0))
255 (maphash
256 (lambda (key value)
257 (unless (gnus-registry-fetch-group key)
258 (incf count)
259 (remhash key gnus-registry-hashtb)))
260 gnus-registry-hashtb)
261 count))
263 (defun gnus-registry-read ()
264 (gnus-registry-cache-read)
265 (setq gnus-registry-hashtb (alist-to-hashtable gnus-registry-alist))
266 (setq gnus-registry-dirty nil))
268 (defun gnus-registry-trim (alist)
269 "Trim alist to size, using gnus-registry-max-entries."
270 (if (null gnus-registry-max-entries)
271 alist ; just return the alist
272 ;; else, when given max-entries, trim the alist
273 (let* ((timehash (make-hash-table
274 :size 4096
275 :test 'equal))
276 (trim-length (- (length alist) gnus-registry-max-entries))
277 (trim-length (if (natnump trim-length) trim-length 0)))
278 (maphash
279 (lambda (key value)
280 (puthash key (gnus-registry-fetch-extra key 'mtime) timehash))
281 gnus-registry-hashtb)
283 ;; we use the return value of this setq, which is the trimmed alist
284 (setq alist
285 (nthcdr
286 trim-length
287 (sort alist
288 (lambda (a b)
289 (time-less-p
290 (cdr (gethash (car a) timehash))
291 (cdr (gethash (car b) timehash))))))))))
293 (defun alist-to-hashtable (alist)
294 "Build a hashtable from the values in ALIST."
295 (let ((ht (make-hash-table
296 :size 4096
297 :test 'equal)))
298 (mapc
299 (lambda (kv-pair)
300 (puthash (car kv-pair) (cdr kv-pair) ht))
301 alist)
302 ht))
304 (defun hashtable-to-alist (hash)
305 "Build an alist from the values in HASH."
306 (let ((list nil))
307 (maphash
308 (lambda (key value)
309 (setq list (cons (cons key value) list)))
310 hash)
311 list))
313 (defun gnus-registry-action (action data-header from &optional to method)
314 (let* ((id (mail-header-id data-header))
315 (subject (gnus-registry-simplify-subject
316 (mail-header-subject data-header)))
317 (sender (mail-header-from data-header))
318 (from (gnus-group-guess-full-name-from-command-method from))
319 (to (if to (gnus-group-guess-full-name-from-command-method to) nil))
320 (to-name (if to to "the Bit Bucket"))
321 (old-entry (gethash id gnus-registry-hashtb)))
322 (gnus-message 5 "Registry: article %s %s from %s to %s"
324 (if method "respooling" "going")
325 from
328 ;; All except copy will need a delete
329 (gnus-registry-delete-group id from)
331 (when (equal 'copy action)
332 (gnus-registry-add-group id from subject sender)) ; undo the delete
334 (gnus-registry-add-group id to subject sender)))
336 (defun gnus-registry-spool-action (id group &optional subject sender)
337 (let ((group (gnus-group-guess-full-name-from-command-method group)))
338 (when (and (stringp id) (string-match "\r$" id))
339 (setq id (substring id 0 -1)))
340 (gnus-message 5 "Registry: article %s spooled to %s"
342 group)
343 (gnus-registry-add-group id group subject sender)))
345 ;; Function for nn{mail|imap}-split-fancy: look up all references in
346 ;; the cache and if a match is found, return that group.
347 (defun gnus-registry-split-fancy-with-parent ()
348 "Split this message into the same group as its parent. The parent
349 is obtained from the registry. This function can be used as an entry
350 in `nnmail-split-fancy' or `nnimap-split-fancy', for example like
351 this: (: gnus-registry-split-fancy-with-parent)
353 For a message to be split, it looks for the parent message in the
354 References or In-Reply-To header and then looks in the registry to
355 see which group that message was put in. This group is returned.
357 See the Info node `(gnus)Fancy Mail Splitting' for more details."
358 (let ((refstr (or (message-fetch-field "references")
359 (message-fetch-field "in-reply-to")))
360 (nnmail-split-fancy-with-parent-ignore-groups
361 (if (listp nnmail-split-fancy-with-parent-ignore-groups)
362 nnmail-split-fancy-with-parent-ignore-groups
363 (list nnmail-split-fancy-with-parent-ignore-groups)))
364 references res)
365 (if refstr
366 (progn
367 (setq references (nreverse (gnus-split-references refstr)))
368 (mapcar (lambda (x)
369 (setq res (or (gnus-registry-fetch-group x) res))
370 (when (or (gnus-registry-grep-in-list
372 gnus-registry-unfollowed-groups)
373 (gnus-registry-grep-in-list
375 nnmail-split-fancy-with-parent-ignore-groups))
376 (setq res nil)))
377 references))
379 ;; else: there were no references, now try the extra tracking
380 (let ((sender (message-fetch-field "from"))
381 (subject (gnus-registry-simplify-subject
382 (message-fetch-field "subject")))
383 (single-match t))
384 (when (and single-match
385 (gnus-registry-track-sender-p)
386 sender)
387 (maphash
388 (lambda (key value)
389 (let ((this-sender (cdr
390 (gnus-registry-fetch-extra key 'sender))))
391 (when (and single-match
392 this-sender
393 (equal sender this-sender))
394 ;; too many matches, bail
395 (unless (equal res (gnus-registry-fetch-group key))
396 (setq single-match nil))
397 (setq res (gnus-registry-fetch-group key))
398 (gnus-message
399 ;; raise level of messaging if gnus-registry-track-extra
400 (if gnus-registry-track-extra 5 9)
401 "%s (extra tracking) traced sender %s to group %s"
402 "gnus-registry-split-fancy-with-parent"
403 sender
404 (if res res "nil")))))
405 gnus-registry-hashtb))
406 (when (and single-match
407 (gnus-registry-track-subject-p)
408 subject
409 (< gnus-registry-minimum-subject-length (length subject)))
410 (maphash
411 (lambda (key value)
412 (let ((this-subject (cdr
413 (gnus-registry-fetch-extra key 'subject))))
414 (when (and single-match
415 this-subject
416 (equal subject this-subject))
417 ;; too many matches, bail
418 (unless (equal res (gnus-registry-fetch-group key))
419 (setq single-match nil))
420 (setq res (gnus-registry-fetch-group key))
421 (gnus-message
422 ;; raise level of messaging if gnus-registry-track-extra
423 (if gnus-registry-track-extra 5 9)
424 "%s (extra tracking) traced subject %s to group %s"
425 "gnus-registry-split-fancy-with-parent"
426 subject
427 (if res res "nil")))))
428 gnus-registry-hashtb))
429 (unless single-match
430 (gnus-message
432 "gnus-registry-split-fancy-with-parent: too many extra matches for %s"
433 refstr)
434 (setq res nil))))
435 (gnus-message
437 "gnus-registry-split-fancy-with-parent traced %s to group %s"
438 refstr (if res res "nil"))
440 (when (and res gnus-registry-use-long-group-names)
441 (let ((m1 (gnus-find-method-for-group res))
442 (m2 (or gnus-command-method
443 (gnus-find-method-for-group gnus-newsgroup-name)))
444 (short-res (gnus-group-short-name res)))
445 (if (gnus-methods-equal-p m1 m2)
446 (progn
447 (gnus-message
449 "gnus-registry-split-fancy-with-parent stripped group %s to %s"
451 short-res)
452 (setq res short-res))
453 ;; else...
454 (gnus-message
456 "gnus-registry-split-fancy-with-parent ignored foreign group %s"
457 res)
458 (setq res nil))))
459 res))
461 (defun gnus-registry-register-message-ids ()
462 "Register the Message-ID of every article in the group"
463 (unless (gnus-parameter-registry-ignore gnus-newsgroup-name)
464 (dolist (article gnus-newsgroup-articles)
465 (let ((id (gnus-registry-fetch-message-id-fast article)))
466 (unless (gnus-registry-fetch-group id)
467 (gnus-message 9 "Registry: Registering article %d with group %s"
468 article gnus-newsgroup-name)
469 (gnus-registry-add-group
470 (gnus-registry-fetch-message-id-fast article)
471 gnus-newsgroup-name
472 (gnus-registry-fetch-simplified-message-subject-fast article)
473 (gnus-registry-fetch-sender-fast article)))))))
475 (defun gnus-registry-fetch-message-id-fast (article)
476 "Fetch the Message-ID quickly, using the internal gnus-data-list function"
477 (if (and (numberp article)
478 (assoc article (gnus-data-list nil)))
479 (mail-header-id (gnus-data-header (assoc article (gnus-data-list nil))))
480 nil))
482 (defun gnus-registry-simplify-subject (subject)
483 (if (stringp subject)
484 (gnus-simplify-subject subject)
485 nil))
487 (defun gnus-registry-fetch-simplified-message-subject-fast (article)
488 "Fetch the Subject quickly, using the internal gnus-data-list function"
489 (if (and (numberp article)
490 (assoc article (gnus-data-list nil)))
491 (gnus-registry-simplify-subject
492 (mail-header-subject (gnus-data-header
493 (assoc article (gnus-data-list nil)))))
494 nil))
496 (defun gnus-registry-fetch-sender-fast (article)
497 "Fetch the Sender quickly, using the internal gnus-data-list function"
498 (if (and (numberp article)
499 (assoc article (gnus-data-list nil)))
500 (mail-header-from (gnus-data-header
501 (assoc article (gnus-data-list nil))))
502 nil))
504 (defun gnus-registry-grep-in-list (word list)
505 (when word
506 (memq nil
507 (mapcar 'not
508 (mapcar
509 (lambda (x)
510 (string-match x word))
511 list)))))
513 (defun gnus-registry-fetch-extra (id &optional entry)
514 "Get the extra data of a message, based on the message ID.
515 Returns the first place where the trail finds a nonstring."
516 (let ((entry-cache (gethash entry gnus-registry-hashtb)))
517 (if (and entry
518 (hash-table-p entry-cache)
519 (gethash id entry-cache))
520 (gethash id entry-cache)
521 ;; else, if there is no caching possible...
522 (let ((trail (gethash id gnus-registry-hashtb)))
523 (when (listp trail)
524 (dolist (crumb trail)
525 (unless (stringp crumb)
526 (return (gnus-registry-fetch-extra-entry crumb entry id)))))))))
528 (defun gnus-registry-fetch-extra-entry (alist &optional entry id)
529 "Get the extra data of a message, or a specific entry in it.
530 Update the entry cache if needed."
531 (if (and entry id)
532 (let ((entry-cache (gethash entry gnus-registry-hashtb))
533 entree)
534 (when gnus-registry-entry-caching
535 ;; create the hash table
536 (unless (hash-table-p entry-cache)
537 (setq entry-cache (make-hash-table
538 :size 4096
539 :test 'equal))
540 (puthash entry entry-cache gnus-registry-hashtb))
542 ;; get the entree from the hash table or from the alist
543 (setq entree (gethash id entry-cache)))
545 (unless entree
546 (setq entree (assq entry alist))
547 (when gnus-registry-entry-caching
548 (puthash id entree entry-cache)))
549 entree)
550 alist))
552 (defun gnus-registry-store-extra (id extra)
553 "Store the extra data of a message, based on the message ID.
554 The message must have at least one group name."
555 (when (gnus-registry-group-count id)
556 ;; we now know the trail has at least 1 group name, so it's not empty
557 (let ((trail (gethash id gnus-registry-hashtb))
558 (old-extra (gnus-registry-fetch-extra id))
559 entry-cache)
560 (dolist (crumb trail)
561 (unless (stringp crumb)
562 (dolist (entry crumb)
563 (setq entry-cache (gethash (car entry) gnus-registry-hashtb))
564 (when entry-cache
565 (remhash id entry-cache))))
566 (puthash id (cons extra (delete old-extra trail))
567 gnus-registry-hashtb)
568 (setq gnus-registry-dirty t)))))
570 (defun gnus-registry-store-extra-entry (id key value)
571 "Put a specific entry in the extras field of the registry entry for id."
572 (let* ((extra (gnus-registry-fetch-extra id))
573 (alist (cons (cons key value)
574 (gnus-assq-delete-all key (gnus-registry-fetch-extra id)))))
575 (gnus-registry-store-extra id alist)))
577 (defun gnus-registry-fetch-group (id)
578 "Get the group of a message, based on the message ID.
579 Returns the first place where the trail finds a group name."
580 (when (gnus-registry-group-count id)
581 ;; we now know the trail has at least 1 group name
582 (let ((trail (gethash id gnus-registry-hashtb)))
583 (dolist (crumb trail)
584 (when (stringp crumb)
585 (return (if gnus-registry-use-long-group-names
586 crumb
587 (gnus-group-short-name crumb))))))))
589 (defun gnus-registry-group-count (id)
590 "Get the number of groups of a message, based on the message ID."
591 (let ((trail (gethash id gnus-registry-hashtb)))
592 (if (and trail (listp trail))
593 (apply '+ (mapcar (lambda (x) (if (stringp x) 1 0)) trail))
594 0)))
596 (defun gnus-registry-delete-group (id group)
597 "Delete a group for a message, based on the message ID."
598 (when group
599 (when id
600 (let ((trail (gethash id gnus-registry-hashtb))
601 (group (gnus-group-short-name group)))
602 (puthash id (if trail
603 (delete group trail)
604 nil)
605 gnus-registry-hashtb))
606 ;; now, clear the entry if there are no more groups
607 (when gnus-registry-trim-articles-without-groups
608 (unless (gnus-registry-group-count id)
609 (gnus-registry-delete-id id)))
610 ;; is this ID still in the registry?
611 (when (gethash id gnus-registry-hashtb)
612 (gnus-registry-store-extra-entry id 'mtime (current-time))))))
614 (defun gnus-registry-delete-id (id)
615 "Delete a message ID from the registry."
616 (when (stringp id)
617 (remhash id gnus-registry-hashtb)
618 (maphash
619 (lambda (key value)
620 (when (hash-table-p value)
621 (remhash id value)))
622 gnus-registry-hashtb)))
624 (defun gnus-registry-add-group (id group &optional subject sender)
625 "Add a group for a message, based on the message ID."
626 (when group
627 (when (and id
628 (not (string-match "totally-fudged-out-message-id" id)))
629 (let ((full-group group)
630 (group (if gnus-registry-use-long-group-names
631 group
632 (gnus-group-short-name group))))
633 (gnus-registry-delete-group id group)
635 (unless gnus-registry-use-long-group-names ;; unnecessary in this case
636 (gnus-registry-delete-group id full-group))
638 (let ((trail (gethash id gnus-registry-hashtb)))
639 (puthash id (if trail
640 (cons group trail)
641 (list group))
642 gnus-registry-hashtb)
644 (when (and (gnus-registry-track-subject-p)
645 subject)
646 (gnus-registry-store-extra-entry
648 'subject
649 (gnus-registry-simplify-subject subject)))
650 (when (and (gnus-registry-track-sender-p)
651 sender)
652 (gnus-registry-store-extra-entry
654 'sender
655 sender))
657 (gnus-registry-store-extra-entry id 'mtime (current-time)))))))
659 (defun gnus-registry-clear ()
660 "Clear the Gnus registry."
661 (interactive)
662 (setq gnus-registry-alist nil)
663 (setq gnus-registry-hashtb (alist-to-hashtable gnus-registry-alist))
664 (setq gnus-registry-dirty t))
666 ;;;###autoload
667 (defun gnus-registry-initialize ()
668 (interactive)
669 (setq gnus-registry-install t)
670 (gnus-registry-install-hooks)
671 (gnus-registry-read))
673 ;;;###autoload
674 (defun gnus-registry-install-hooks ()
675 "Install the registry hooks."
676 (interactive)
677 (add-hook 'gnus-summary-article-move-hook 'gnus-registry-action)
678 (add-hook 'gnus-summary-article-delete-hook 'gnus-registry-action)
679 (add-hook 'gnus-summary-article-expire-hook 'gnus-registry-action)
680 (add-hook 'nnmail-spool-hook 'gnus-registry-spool-action)
682 (add-hook 'gnus-save-newsrc-hook 'gnus-registry-save)
683 (add-hook 'gnus-read-newsrc-el-hook 'gnus-registry-read)
685 (add-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids))
687 (defun gnus-registry-unload-hook ()
688 "Uninstall the registry hooks."
689 (interactive)
690 (remove-hook 'gnus-summary-article-move-hook 'gnus-registry-action)
691 (remove-hook 'gnus-summary-article-delete-hook 'gnus-registry-action)
692 (remove-hook 'gnus-summary-article-expire-hook 'gnus-registry-action)
693 (remove-hook 'nnmail-spool-hook 'gnus-registry-spool-action)
695 (remove-hook 'gnus-save-newsrc-hook 'gnus-registry-save)
696 (remove-hook 'gnus-read-newsrc-el-hook 'gnus-registry-read)
698 (remove-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids))
700 (add-hook 'gnus-registry-unload-hook 'gnus-registry-unload-hook)
702 (when gnus-registry-install
703 (gnus-registry-install-hooks)
704 (gnus-registry-read))
706 ;; TODO: a lot of things
708 (provide 'gnus-registry)
710 ;;; arch-tag: 5cba0a32-718a-4a97-8c91-0a15af21da94
711 ;;; gnus-registry.el ends here