X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fgnus-registry.el;h=f1618b376ef57da84407cd82c31fabf9616496b6;hb=d9dfa9384e316caeea28a44d55f8e7421a4a6065;hp=25d84b11d4100b5a96e628c443ba411ba18bb872;hpb=592dfba56d49972352096210e3c7f251e9d9f63b;p=gnus diff --git a/lisp/gnus-registry.el b/lisp/gnus-registry.el index 25d84b11d..f1618b376 100644 --- a/lisp/gnus-registry.el +++ b/lisp/gnus-registry.el @@ -1,6 +1,6 @@ ;;; gnus-registry.el --- article registry for Gnus -;; Copyright (C) 2002-2011 Free Software Foundation, Inc. +;; Copyright (C) 2002-2012 Free Software Foundation, Inc. ;; Author: Ted Zlatanov ;; Keywords: news registry @@ -57,6 +57,16 @@ ;; You should also consider using the nnregistry backend to look up ;; articles. See the Gnus manual for more information. +;; Finally, you can put %uM in your summary line format to show the +;; registry marks if you do this: + +;; show the marks as single characters (see the :char property in +;; `gnus-registry-marks'): +;; (defalias 'gnus-user-format-function-M 'gnus-registry-article-marks-to-chars) + +;; show the marks by name (see `gnus-registry-marks'): +;; (defalias 'gnus-user-format-function-M 'gnus-registry-article-marks-to-names) + ;; TODO: ;; - get the correct group on spool actions @@ -132,6 +142,7 @@ display.") The addresses are matched, they don't have to be fully qualified. In the messages, these addresses can be the sender or the recipients." + :version "24.1" :group 'gnus-registry :type '(repeat regexp)) @@ -154,6 +165,8 @@ nnmairix groups are specifically excluded because they are ephemeral." (const :tag "Always Install" t) (const :tag "Ask Me" ask))) +(defvar gnus-registry-enabled nil) + (defvar gnus-summary-misc-menu) ;; Avoid byte compiler warning. (defvar gnus-registry-misc-menus nil) ; ugly way to keep the menus @@ -231,6 +244,7 @@ the Bit Bucket." (defcustom gnus-registry-max-pruned-entries nil "Maximum number of pruned entries in the registry, nil for unlimited." + :version "24.1" :group 'gnus-registry :type '(radio (const :format "Unlimited " nil) (integer :format "Maximum number: %v"))) @@ -311,6 +325,20 @@ This is not required after changing `gnus-registry-cache-file'." (gnus-message 5 "Saving Gnus registry (size %d) to %s...done" (registry-size db) file))) +(defun gnus-registry-remove-ignored () + (interactive) + (let* ((db gnus-registry-db) + (grouphashtb (registry-lookup-secondary db 'group)) + (old-size (registry-size db))) + (registry-reindex db) + (loop for k being the hash-keys of grouphashtb + using (hash-values v) + when (gnus-registry-ignore-group-p k) + do (registry-delete db v nil)) + (registry-reindex db) + (gnus-message 4 "Removed %d ignored entries from the Gnus registry" + (- old-size (registry-size db))))) + ;; article move/copy/spool/delete actions (defun gnus-registry-action (action data-header from &optional to method) (let* ((id (mail-header-id data-header)) @@ -849,8 +877,9 @@ Uses `gnus-registry-marks' to find what shortcuts to install." ;; if this is called and the user doesn't want the ;; registry enabled, we'll ask anyhow - (when (eq gnus-registry-install nil) - (setq gnus-registry-install 'ask)) + (unless gnus-registry-install + (let ((gnus-registry-install 'ask)) + (gnus-registry-install-p))) ;; now the user is asked if gnus-registry-install is 'ask (when (gnus-registry-install-p) @@ -887,22 +916,32 @@ Uses `gnus-registry-marks' to find what shortcuts to install." nil (cons "Registry Marks" gnus-registry-misc-menus)))))) -;;; use like this: -;;; (defalias 'gnus-user-format-function-M -;;; 'gnus-registry-user-format-function-M) -(defun gnus-registry-user-format-function-M (headers) +(make-obsolete 'gnus-registry-user-format-function-M + 'gnus-registry-article-marks-to-chars "24.1") ? + +(defalias 'gnus-registry-user-format-function-M + 'gnus-registry-article-marks-to-chars) + +;; use like this: +;; (defalias 'gnus-user-format-function-M 'gnus-registry-article-marks-to-chars) +(defun gnus-registry-article-marks-to-chars (headers) + "Show the marks for an article by the :char property" + (let* ((id (mail-header-message-id headers)) + (marks (when id (gnus-registry-get-id-key id 'mark)))) + (mapconcat (lambda (mark) + (plist-get + (cdr-safe + (assoc mark gnus-registry-marks)) + :char)) + marks ""))) + +;; use like this: +;; (defalias 'gnus-user-format-function-M 'gnus-registry-article-marks-to-names) +(defun gnus-registry-article-marks-to-names (headers) + "Show the marks for an article by name" (let* ((id (mail-header-message-id headers)) (marks (when id (gnus-registry-get-id-key id 'mark)))) - (apply 'concat (mapcar (lambda (mark) - (let ((c - (plist-get - (cdr-safe - (assoc mark gnus-registry-marks)) - :char))) - (if c - (list c) - nil))) - marks)))) + (mapconcat (lambda (mark) (symbol-name mark)) marks ","))) (defun gnus-registry-read-mark () "Read a mark name from the user with completion." @@ -1117,7 +1156,6 @@ only the last one's marks are returned." "Initialize the Gnus registry." (interactive) (gnus-message 5 "Initializing the registry") - (setq gnus-registry-install t) ; in case it was 'ask or nil (gnus-registry-install-hooks) (gnus-registry-install-shortcuts) (gnus-registry-read)) @@ -1126,6 +1164,7 @@ only the last one's marks are returned." (defun gnus-registry-install-hooks () "Install the registry hooks." (interactive) + (setq gnus-registry-enabled t) (add-hook 'gnus-summary-article-move-hook 'gnus-registry-action) (add-hook 'gnus-summary-article-delete-hook 'gnus-registry-action) (add-hook 'gnus-summary-article-expire-hook 'gnus-registry-action) @@ -1147,23 +1186,25 @@ only the last one's marks are returned." (remove-hook 'gnus-save-newsrc-hook 'gnus-registry-save) (remove-hook 'gnus-read-newsrc-el-hook 'gnus-registry-read) - (remove-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids)) + (remove-hook 'gnus-summary-prepare-hook 'gnus-registry-register-message-ids) + (setq gnus-registry-enabled nil)) (add-hook 'gnus-registry-unload-hook 'gnus-registry-unload-hook) (defun gnus-registry-install-p () + "If the registry is not already enabled, and `gnus-registry-install' is t, +the registry is enabled. If `gnus-registry-install' is `ask', +the user is asked first. Returns non-nil iff the registry is enabled." (interactive) - (when (eq gnus-registry-install 'ask) - (setq gnus-registry-install - (gnus-y-or-n-p - (concat "Enable the Gnus registry? " - "See the variable `gnus-registry-install' " - "to get rid of this query permanently. "))) - (when gnus-registry-install - ;; we just set gnus-registry-install to t, so initialize the registry! + (unless gnus-registry-enabled + (when (if (eq gnus-registry-install 'ask) + (gnus-y-or-n-p + (concat "Enable the Gnus registry? " + "See the variable `gnus-registry-install' " + "to get rid of this query permanently. ")) + gnus-registry-install) (gnus-registry-initialize))) -;;; we could call it here: (customize-variable 'gnus-registry-install) - gnus-registry-install) + gnus-registry-enabled) ;; TODO: a few things