1 ;;; gnus-registry.el --- article registry for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
6 ;; Author: Ted Zlatanov <tzz@lifelogs.com>
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)
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.
28 ;; This is the gnus-registry.el package, which works with all
29 ;; backends, not just nnmail (e.g. NNTP). The major issue is that it
30 ;; doesn't go across backends, so for instance if an article is in
31 ;; nnml:sys and you see a reference to it in nnimap splitting, the
32 ;; article will end up in 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)
52 ;; - get the correct group on spool actions
54 ;; - articles that are spooled to a different backend should be handled
58 (eval-when-compile (require 'cl))
66 (defvar gnus-registry-dirty t
67 "Boolean set to t when the registry is modified")
69 (defgroup gnus-registry nil
74 (defvar gnus-registry-hashtb (make-hash-table
77 "*The article registry by Message ID.")
79 (defcustom gnus-registry-unfollowed-groups '("delayed" "drafts" "queue")
80 "List of groups that gnus-registry-split-fancy-with-parent won't return.
81 The group names are matched, they don't have to be fully
82 qualified. This parameter tells the Registry 'never split a
83 message into a group that matches one of these, regardless of
86 :type '(repeat string))
88 (defcustom gnus-registry-install nil
89 "Whether the registry should be installed."
93 (defcustom gnus-registry-clean-empty t
94 "Whether the empty registry entries should be deleted.
95 Registry entries are considered empty when they have no groups
100 (defcustom gnus-registry-use-long-group-names nil
101 "Whether the registry should use long group names (BUGGY)."
102 :group 'gnus-registry
105 (defcustom gnus-registry-track-extra nil
106 "Whether the registry should track extra data about a message.
107 The Subject and Sender (From:) headers are currently tracked this
109 :group 'gnus-registry
111 '(set :tag "Tracking choices"
112 (const :tag "Track by subject (Subject: header)" subject)
113 (const :tag "Track by sender (From: header)" sender)))
115 (defcustom gnus-registry-entry-caching t
116 "Whether the registry should cache extra information."
117 :group 'gnus-registry
120 (defcustom gnus-registry-minimum-subject-length 5
121 "The minimum length of a subject before it's considered trackable."
122 :group 'gnus-registry
125 (defcustom gnus-registry-trim-articles-without-groups t
126 "Whether the registry should clean out message IDs without groups."
127 :group 'gnus-registry
130 (defcustom gnus-registry-cache-file
132 (or gnus-dribble-directory gnus-home-directory "~/")
133 ".gnus.registry.eld")
134 "File where the Gnus registry will be stored."
135 :group 'gnus-registry
138 (defcustom gnus-registry-max-entries nil
139 "Maximum number of entries in the registry, nil for unlimited."
140 :group 'gnus-registry
141 :type '(radio (const :format "Unlimited " nil)
142 (integer :format "Maximum number: %v")))
144 (defun gnus-registry-track-subject-p ()
145 (memq 'subject gnus-registry-track-extra))
147 (defun gnus-registry-track-sender-p ()
148 (memq 'sender gnus-registry-track-extra))
150 (defun gnus-registry-cache-read ()
151 "Read the registry cache file."
153 (let ((file gnus-registry-cache-file))
154 (when (file-exists-p file)
155 (gnus-message 5 "Reading %s..." file)
157 (gnus-message 5 "Reading %s...done" file))))
159 (defun gnus-registry-cache-save ()
160 "Save the registry cache file."
162 (let ((file gnus-registry-cache-file))
164 (set-buffer (gnus-get-buffer-create " *Gnus-registry-cache*"))
165 (make-local-variable 'version-control)
166 (setq version-control gnus-backup-startup-file)
167 (setq buffer-file-name file)
168 (setq default-directory (file-name-directory buffer-file-name))
169 (buffer-disable-undo)
171 (gnus-message 5 "Saving %s..." file)
172 (if gnus-save-startup-file-via-temp-buffer
173 (let ((coding-system-for-write gnus-ding-file-coding-system)
174 (standard-output (current-buffer)))
175 (gnus-gnus-to-quick-newsrc-format t "gnus registry startup file" 'gnus-registry-alist)
176 (gnus-registry-cache-whitespace file)
178 (let ((coding-system-for-write gnus-ding-file-coding-system)
179 (version-control gnus-backup-startup-file)
181 (working-dir (file-name-directory file))
184 ;; Generate the name of a non-existent file.
185 (while (progn (setq working-file
187 (if (and (eq system-type 'ms-dos)
188 (not (gnus-long-file-names)))
189 "%s#%d.tm#" ; MSDOS limits files to 8+3
190 (if (memq system-type '(vax-vms axp-vms))
193 working-dir (setq i (1+ i))))
194 (file-exists-p working-file)))
198 (gnus-with-output-to-file working-file
199 (gnus-gnus-to-quick-newsrc-format t "gnus registry startup file" 'gnus-registry-alist))
201 ;; These bindings will mislead the current buffer
202 ;; into thinking that it is visiting the startup
204 (let ((buffer-backed-up nil)
205 (buffer-file-name startup-file)
206 (file-precious-flag t)
207 (setmodes (file-modes startup-file)))
208 ;; Backup the current version of the startup file.
211 ;; Replace the existing startup file with the temp file.
212 (rename-file working-file startup-file t)
213 (gnus-set-file-modes startup-file setmodes)))
215 (delete-file working-file)
218 (gnus-kill-buffer (current-buffer))
219 (gnus-message 5 "Saving %s...done" file))))
221 ;; Idea from Dan Christensen <jdc@chow.mat.jhu.edu>
222 ;; Save the gnus-registry file with extra line breaks.
223 (defun gnus-registry-cache-whitespace (filename)
224 (gnus-message 7 "Adding whitespace to %s" filename)
226 (goto-char (point-min))
227 (while (re-search-forward "^(\\|(\\\"" nil t)
228 (replace-match "\n\\&" t))
229 (goto-char (point-min))
230 (while (re-search-forward " $" nil t)
231 (replace-match "" t t))))
233 (defun gnus-registry-save (&optional force)
234 (when (or gnus-registry-dirty force)
235 (let ((caching gnus-registry-entry-caching))
236 ;; turn off entry caching, so mtime doesn't get recorded
237 (setq gnus-registry-entry-caching nil)
238 ;; remove entry caches
241 (if (hash-table-p value)
242 (remhash key gnus-registry-hashtb)))
243 gnus-registry-hashtb)
244 ;; remove empty entries
245 (when gnus-registry-clean-empty
246 (gnus-registry-clean-empty-function))
247 ;; now trim and clean text properties from the registry appropriately
248 (setq gnus-registry-alist
249 (gnus-registry-remove-alist-text-properties
251 (gnus-hashtable-to-alist
252 gnus-registry-hashtb))))
254 (gnus-registry-cache-save)
255 (setq gnus-registry-entry-caching caching)
256 (setq gnus-registry-dirty nil))))
258 (defun gnus-registry-clean-empty-function ()
259 "Remove all empty entries from the registry. Returns count thereof."
265 (dolist (group (gnus-registry-fetch-groups key))
266 (when (gnus-parameter-registry-ignore group)
269 "gnus-registry: deleted ignored group %s from key %s"
271 (gnus-registry-delete-group key group)))
273 (unless (gnus-registry-group-count key)
274 (gnus-registry-delete-id key))
277 (gnus-registry-fetch-group key)
278 ;; TODO: look for specific extra data here!
279 ;; in this example, we look for 'label
280 (gnus-registry-fetch-extra key 'label))
282 (gnus-registry-delete-id key))
284 (unless (stringp key)
287 "gnus-registry key %s was not a string, removing"
289 (gnus-registry-delete-id key))))
291 gnus-registry-hashtb)
294 (defun gnus-registry-read ()
295 (gnus-registry-cache-read)
296 (setq gnus-registry-hashtb (gnus-alist-to-hashtable gnus-registry-alist))
297 (setq gnus-registry-dirty nil))
299 (defun gnus-registry-remove-alist-text-properties (v)
300 "Remove text properties from all strings in alist."
302 (gnus-string-remove-all-properties v)
303 (if (and (listp v) (listp (cdr v)))
304 (mapcar 'gnus-registry-remove-alist-text-properties v)
305 (if (and (listp v) (stringp (cdr v)))
306 (cons (gnus-registry-remove-alist-text-properties (car v))
307 (gnus-registry-remove-alist-text-properties (cdr v)))
310 (defun gnus-registry-trim (alist)
311 "Trim alist to size, using gnus-registry-max-entries.
312 Also, drop all gnus-registry-ignored-groups matches."
313 (if (null gnus-registry-max-entries)
314 alist ; just return the alist
315 ;; else, when given max-entries, trim the alist
316 (let* ((timehash (make-hash-table
319 (trim-length (- (length alist) gnus-registry-max-entries))
320 (trim-length (if (natnump trim-length) trim-length 0)))
323 (puthash key (gnus-registry-fetch-extra key 'mtime) timehash))
324 gnus-registry-hashtb)
326 ;; we use the return value of this setq, which is the trimmed alist
333 (or (cdr (gethash (car a) timehash)) '(0 0 0))
334 (or (cdr (gethash (car b) timehash)) '(0 0 0))))))))))
336 (defun gnus-registry-action (action data-header from &optional to method)
337 (let* ((id (mail-header-id data-header))
338 (subject (gnus-string-remove-all-properties
339 (gnus-registry-simplify-subject
340 (mail-header-subject data-header))))
341 (sender (gnus-string-remove-all-properties (mail-header-from data-header)))
342 (from (gnus-group-guess-full-name-from-command-method from))
343 (to (if to (gnus-group-guess-full-name-from-command-method to) nil))
344 (to-name (if to to "the Bit Bucket"))
345 (old-entry (gethash id gnus-registry-hashtb)))
346 (gnus-message 7 "Registry: article %s %s from %s to %s"
348 (if method "respooling" "going")
352 ;; All except copy will need a delete
353 (gnus-registry-delete-group id from)
355 (when (equal 'copy action)
356 (gnus-registry-add-group id from subject sender)) ; undo the delete
358 (gnus-registry-add-group id to subject sender)))
360 (defun gnus-registry-spool-action (id group &optional subject sender)
361 (let ((group (gnus-group-guess-full-name-from-command-method group)))
362 (when (and (stringp id) (string-match "\r$" id))
363 (setq id (substring id 0 -1)))
364 (gnus-message 7 "Registry: article %s spooled to %s"
367 (gnus-registry-add-group id group subject sender)))
369 ;; Function for nn{mail|imap}-split-fancy: look up all references in
370 ;; the cache and if a match is found, return that group.
371 (defun gnus-registry-split-fancy-with-parent ()
372 "Split this message into the same group as its parent. The parent
373 is obtained from the registry. This function can be used as an entry
374 in `nnmail-split-fancy' or `nnimap-split-fancy', for example like
375 this: (: gnus-registry-split-fancy-with-parent)
377 This function tracks ALL backends, unlike
378 `nnmail-split-fancy-with-parent' which tracks only nnmail
381 For a message to be split, it looks for the parent message in the
382 References or In-Reply-To header and then looks in the registry
383 to see which group that message was put in. This group is
384 returned, unless it matches one of the entries in
385 gnus-registry-unfollowed-groups or
386 nnmail-split-fancy-with-parent-ignore-groups.
388 See the Info node `(gnus)Fancy Mail Splitting' for more details."
389 (let* ((refstr (or (message-fetch-field "references") "")) ; guarantee string
390 (reply-to (message-fetch-field "in-reply-to")) ; grab reply-to
391 ;; now, if reply-to is valid, append it to the References
393 (concat refstr " " reply-to)
395 (nnmail-split-fancy-with-parent-ignore-groups
396 (if (listp nnmail-split-fancy-with-parent-ignore-groups)
397 nnmail-split-fancy-with-parent-ignore-groups
398 (list nnmail-split-fancy-with-parent-ignore-groups)))
400 ;; the references string must be valid and parse to valid references
401 (if (and refstr (gnus-extract-references refstr))
403 (setq references (nreverse (gnus-extract-references refstr)))
405 (setq res (or (gnus-registry-fetch-group x) res))
406 (when (or (gnus-registry-grep-in-list
408 gnus-registry-unfollowed-groups)
409 (gnus-registry-grep-in-list
411 nnmail-split-fancy-with-parent-ignore-groups))
415 ;; else: there were no references, now try the extra tracking
416 (let ((sender (gnus-string-remove-all-properties(message-fetch-field "from")))
417 (subject (gnus-string-remove-all-properties
418 (gnus-registry-simplify-subject
419 (message-fetch-field "subject"))))
421 (when (and single-match
422 (gnus-registry-track-sender-p)
426 (let ((this-sender (cdr
427 (gnus-registry-fetch-extra key 'sender))))
428 (when (and single-match
430 (equal sender this-sender))
431 ;; too many matches, bail
432 (unless (equal res (gnus-registry-fetch-group key))
433 (setq single-match nil))
434 (setq res (gnus-registry-fetch-group key))
435 (when (and sender res)
437 ;; raise level of messaging if gnus-registry-track-extra
438 (if gnus-registry-track-extra 7 9)
439 "%s (extra tracking) traced sender %s to group %s"
440 "gnus-registry-split-fancy-with-parent"
443 gnus-registry-hashtb))
444 (when (and single-match
445 (gnus-registry-track-subject-p)
447 (< gnus-registry-minimum-subject-length (length subject)))
450 (let ((this-subject (cdr
451 (gnus-registry-fetch-extra key 'subject))))
452 (when (and single-match
454 (equal subject this-subject))
455 ;; too many matches, bail
456 (unless (equal res (gnus-registry-fetch-group key))
457 (setq single-match nil))
458 (setq res (gnus-registry-fetch-group key))
459 (when (and subject res)
461 ;; raise level of messaging if gnus-registry-track-extra
462 (if gnus-registry-track-extra 7 9)
463 "%s (extra tracking) traced subject %s to group %s"
464 "gnus-registry-split-fancy-with-parent"
467 gnus-registry-hashtb))
471 "gnus-registry-split-fancy-with-parent: too many extra matches for %s"
474 (when (and refstr res)
477 "gnus-registry-split-fancy-with-parent traced %s to group %s"
480 (when (and res gnus-registry-use-long-group-names)
481 (let ((m1 (gnus-find-method-for-group res))
482 (m2 (or gnus-command-method
483 (gnus-find-method-for-group gnus-newsgroup-name)))
484 (short-res (gnus-group-short-name res)))
485 (if (gnus-methods-equal-p m1 m2)
489 "gnus-registry-split-fancy-with-parent stripped group %s to %s"
492 (setq res short-res))
496 "gnus-registry-split-fancy-with-parent ignored foreign group %s"
501 (defun gnus-registry-wash-for-keywords (&optional force)
503 (let ((id (gnus-registry-fetch-message-id-fast gnus-current-article))
505 (if (or (not (gnus-registry-fetch-extra id 'keywords))
508 (set-buffer gnus-article-buffer)
510 (save-window-excursion
512 (narrow-to-region (point) (point-max))
513 (with-syntax-table gnus-adaptive-word-syntax-table
514 (while (re-search-forward "\\b\\w+\\b" nil t)
515 (setq word (gnus-registry-remove-alist-text-properties
516 (downcase (buffer-substring
517 (match-beginning 0) (match-end 0)))))
518 (if (> (length word) 3)
519 (push word words))))))
520 (gnus-registry-store-extra-entry id 'keywords words)))))
522 (defun gnus-registry-find-keywords (keyword)
523 (interactive "skeyword: ")
527 (when (gnus-registry-grep-in-list
529 (cdr (gnus-registry-fetch-extra key 'keywords)))
530 (push key articles)))
531 gnus-registry-hashtb)
534 (defun gnus-registry-register-message-ids ()
535 "Register the Message-ID of every article in the group"
536 (unless (gnus-parameter-registry-ignore gnus-newsgroup-name)
537 (dolist (article gnus-newsgroup-articles)
538 (let ((id (gnus-registry-fetch-message-id-fast article)))
539 (unless (gnus-registry-fetch-group id)
540 (gnus-message 9 "Registry: Registering article %d with group %s"
541 article gnus-newsgroup-name)
542 (gnus-registry-add-group
543 (gnus-registry-fetch-message-id-fast article)
545 (gnus-registry-fetch-simplified-message-subject-fast article)
546 (gnus-registry-fetch-sender-fast article)))))))
548 (defun gnus-registry-fetch-message-id-fast (article)
549 "Fetch the Message-ID quickly, using the internal gnus-data-list function"
550 (if (and (numberp article)
551 (assoc article (gnus-data-list nil)))
552 (mail-header-id (gnus-data-header (assoc article (gnus-data-list nil))))
555 (defun gnus-registry-simplify-subject (subject)
556 (if (stringp subject)
557 (gnus-simplify-subject subject)
560 (defun gnus-registry-fetch-simplified-message-subject-fast (article)
561 "Fetch the Subject quickly, using the internal gnus-data-list function"
562 (if (and (numberp article)
563 (assoc article (gnus-data-list nil)))
564 (gnus-string-remove-all-properties
565 (gnus-registry-simplify-subject
566 (mail-header-subject (gnus-data-header
567 (assoc article (gnus-data-list nil))))))
570 (defun gnus-registry-fetch-sender-fast (article)
571 "Fetch the Sender quickly, using the internal gnus-data-list function"
572 (if (and (numberp article)
573 (assoc article (gnus-data-list nil)))
574 (gnus-string-remove-all-properties
575 (mail-header-from (gnus-data-header
576 (assoc article (gnus-data-list nil)))))
579 (defun gnus-registry-grep-in-list (word list)
585 (string-match x word))
588 (defun gnus-registry-fetch-extra (id &optional entry)
589 "Get the extra data of a message, based on the message ID.
590 Returns the first place where the trail finds a nonstring."
591 (let ((entry-cache (gethash entry gnus-registry-hashtb)))
593 (hash-table-p entry-cache)
594 (gethash id entry-cache))
595 (gethash id entry-cache)
596 ;; else, if there is no caching possible...
597 (let ((trail (gethash id gnus-registry-hashtb)))
599 (dolist (crumb trail)
600 (unless (stringp crumb)
601 (return (gnus-registry-fetch-extra-entry crumb entry id)))))))))
603 (defun gnus-registry-fetch-extra-entry (alist &optional entry id)
604 "Get the extra data of a message, or a specific entry in it.
605 Update the entry cache if needed."
607 (let ((entry-cache (gethash entry gnus-registry-hashtb))
609 (when gnus-registry-entry-caching
610 ;; create the hash table
611 (unless (hash-table-p entry-cache)
612 (setq entry-cache (make-hash-table
615 (puthash entry entry-cache gnus-registry-hashtb))
617 ;; get the entree from the hash table or from the alist
618 (setq entree (gethash id entry-cache)))
621 (setq entree (assq entry alist))
622 (when gnus-registry-entry-caching
623 (puthash id entree entry-cache)))
627 (defun gnus-registry-store-extra (id extra)
628 "Store the extra data of a message, based on the message ID.
629 The message must have at least one group name."
630 (when (gnus-registry-group-count id)
631 ;; we now know the trail has at least 1 group name, so it's not empty
632 (let ((trail (gethash id gnus-registry-hashtb))
633 (old-extra (gnus-registry-fetch-extra id))
635 (dolist (crumb trail)
636 (unless (stringp crumb)
637 (dolist (entry crumb)
638 (setq entry-cache (gethash (car entry) gnus-registry-hashtb))
640 (remhash id entry-cache))))
641 (puthash id (cons extra (delete old-extra trail))
642 gnus-registry-hashtb)
643 (setq gnus-registry-dirty t)))))
645 (defun gnus-registry-store-extra-entry (id key value)
646 "Put a specific entry in the extras field of the registry entry for id."
647 (let* ((extra (gnus-registry-fetch-extra id))
648 (alist (gnus-registry-remove-alist-text-properties
649 (cons (cons key value)
650 (gnus-assq-delete-all key (gnus-registry-fetch-extra id))))))
651 (gnus-registry-store-extra id alist)))
653 (defun gnus-registry-fetch-group (id)
654 "Get the group of a message, based on the message ID.
655 Returns the first place where the trail finds a group name."
656 (when (gnus-registry-group-count id)
657 ;; we now know the trail has at least 1 group name
658 (let ((trail (gethash id gnus-registry-hashtb)))
659 (dolist (crumb trail)
660 (when (stringp crumb)
661 (return (if gnus-registry-use-long-group-names
663 (gnus-group-short-name crumb))))))))
665 (defun gnus-registry-fetch-groups (id)
666 "Get the groups of a message, based on the message ID."
667 (let ((trail (gethash id gnus-registry-hashtb))
669 (dolist (crumb trail)
670 (when (stringp crumb)
671 ;; push the group name into the list
675 (if (or (not (stringp crumb)) gnus-registry-use-long-group-names)
677 (gnus-group-short-name crumb))
679 ;; return the list of groups
682 (defun gnus-registry-group-count (id)
683 "Get the number of groups of a message, based on the message ID."
684 (let ((trail (gethash id gnus-registry-hashtb)))
685 (if (and trail (listp trail))
686 (apply '+ (mapcar (lambda (x) (if (stringp x) 1 0)) trail))
689 (defun gnus-registry-delete-group (id group)
690 "Delete a group for a message, based on the message ID."
692 (let ((trail (gethash id gnus-registry-hashtb))
693 (short-group (gnus-group-short-name group)))
694 (puthash id (if trail
695 (delete short-group (delete group trail))
697 gnus-registry-hashtb))
698 ;; now, clear the entry if there are no more groups
699 (when gnus-registry-trim-articles-without-groups
700 (unless (gnus-registry-group-count id)
701 (gnus-registry-delete-id id)))
702 ;; is this ID still in the registry?
703 (when (gethash id gnus-registry-hashtb)
704 (gnus-registry-store-extra-entry id 'mtime (current-time)))))
706 (defun gnus-registry-delete-id (id)
707 "Delete a message ID from the registry."
709 (remhash id gnus-registry-hashtb)
712 (when (hash-table-p value)
714 gnus-registry-hashtb)))
716 (defun gnus-registry-add-group (id group &optional subject sender)
717 "Add a group for a message, based on the message ID."
720 (not (string-match "totally-fudged-out-message-id" id)))
721 (let ((full-group group)
722 (group (if gnus-registry-use-long-group-names
724 (gnus-group-short-name group))))
725 (gnus-registry-delete-group id group)
727 (unless gnus-registry-use-long-group-names ;; unnecessary in this case
728 (gnus-registry-delete-group id full-group))
730 (let ((trail (gethash id gnus-registry-hashtb)))
731 (puthash id (if trail
734 gnus-registry-hashtb)
736 (when (and (gnus-registry-track-subject-p)
738 (gnus-registry-store-extra-entry
741 (gnus-registry-simplify-subject subject)))
742 (when (and (gnus-registry-track-sender-p)
744 (gnus-registry-store-extra-entry
749 (gnus-registry-store-extra-entry id 'mtime (current-time)))))))
751 (defun gnus-registry-clear ()
752 "Clear the Gnus registry."
754 (setq gnus-registry-alist nil)
755 (setq gnus-registry-hashtb (gnus-alist-to-hashtable gnus-registry-alist))
756 (setq gnus-registry-dirty t))
759 (defun gnus-registry-initialize ()
761 (setq gnus-registry-install t)
762 (gnus-registry-install-hooks)
763 (gnus-registry-read))
766 (defun gnus-registry-install-hooks ()
767 "Install the registry hooks."
769 (add-hook 'gnus-summary-article-move-hook 'gnus-registry-action)
770 (add-hook 'gnus-summary-article-delete-hook 'gnus-registry-action)
771 (add-hook 'gnus-summary-article-expire-hook 'gnus-registry-action)
772 (add-hook 'nnmail-spool-hook 'gnus-registry-spool-action)
774 (add-hook 'gnus-save-newsrc-hook 'gnus-registry-save)
775 (add-hook 'gnus-read-newsrc-el-hook 'gnus-registry-read)
777 (add-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids))
779 (defun gnus-registry-unload-hook ()
780 "Uninstall the registry hooks."
782 (remove-hook 'gnus-summary-article-move-hook 'gnus-registry-action)
783 (remove-hook 'gnus-summary-article-delete-hook 'gnus-registry-action)
784 (remove-hook 'gnus-summary-article-expire-hook 'gnus-registry-action)
785 (remove-hook 'nnmail-spool-hook 'gnus-registry-spool-action)
787 (remove-hook 'gnus-save-newsrc-hook 'gnus-registry-save)
788 (remove-hook 'gnus-read-newsrc-el-hook 'gnus-registry-read)
790 (remove-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids))
792 (add-hook 'gnus-registry-unload-hook 'gnus-registry-unload-hook)
794 (when gnus-registry-install
795 (gnus-registry-install-hooks)
796 (gnus-registry-read))
798 ;; TODO: a lot of things
800 (provide 'gnus-registry)
802 ;;; arch-tag: 5cba0a32-718a-4a97-8c91-0a15af21da94
803 ;;; gnus-registry.el ends here