From 42b237655fd30f72a0784c2e0c3b86d28277e893 Mon Sep 17 00:00:00 2001 From: Teodor Zlatanov Date: Wed, 6 Apr 2011 12:55:49 +0000 Subject: [PATCH] gnus-registry.el: Don't use ERT if it's not available. (gnus-registry-delete-entries): New convenience function. (gnus-registry-import-eld): Import from old .eld registry. registry.el: Don't use ERT if it's not available. proto-stream.el (gnutls-negotiate): Revert inadvertent commit of the version from the Claudio Bley GnuTLS patch (extra optional parametersnand host name). --- lisp/gnus/ChangeLog | 12 +++++++++ lisp/gnus/gnus-registry.el | 53 +++++++++++++++++++++++++++++++++++++- lisp/gnus/registry.el | 5 +++- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 8115d5ca2b8..b79a5de55e1 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,15 @@ +2011-04-06 Teodor Zlatanov + + * gnus-registry.el: Don't use ERT if it's not available. + (gnus-registry-delete-entries): New convenience function. + (gnus-registry-import-eld): Import from old .eld registry. + + * registry.el: Don't use ERT if it's not available. + + * proto-stream.el (gnutls-negotiate): Revert inadvertent commit of the + version from the Claudio Bley GnuTLS patch (extra optional parameters + and host name). + 2011-04-05 Teodor Zlatanov * gnus-registry.el (gnus-registry-fixup-registry): New function to diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el index 3ab8400a500..511012df577 100644 --- a/lisp/gnus/gnus-registry.el +++ b/lisp/gnus/gnus-registry.el @@ -57,7 +57,10 @@ (eval-when-compile (require 'cl)) -(require 'ert) +(eval-when-compile + (when (null (require 'ert nil t)) + (defmacro* ert-deftest (name () &body docstring-keys-and-body)))) + (require 'gnus) (require 'gnus-int) (require 'gnus-sum) @@ -807,6 +810,9 @@ only the last one's marks are returned." (nth 1 (assoc id entries)))) +(defun gnus-registry-delete-entries (idlist) + (registry-delete gnus-registry-db idlist nil)) + (defun gnus-registry-get-id-key (id key) (cdr-safe (assq key (gnus-registry-get-or-make-entry id)))) @@ -818,6 +824,51 @@ only the last one's marks are returned." (registry-insert db id entry) entry)) +(defun gnus-registry-import-eld (file) + (interactive "fOld registry file to import? ") + ;; example content: + ;; (setq gnus-registry-alist '( + ;; ("" ((marks nil) + ;; (mtime 19365 1776 440496) + ;; (sender . "root (Cron Daemon)") + ;; (subject . "Cron")) + ;; "cron" "nnml+private:cron") + (load file t) + (when (boundp 'gnus-registry-alist) + (let* ((old (symbol-value 'gnus-registry-alist)) + (count 0) + (expected (length old)) + entry) + (while (car-safe old) + (incf count) + ;; don't use progress reporters for backwards compatibility + (when (and (< 0 expected) + (= 0 (mod count 100))) + (message "importing: %d of %d (%.2f%%)" + count expected (/ (* 100 count) expected))) + (setq entry (car-safe old) + old (cdr-safe old)) + (let* ((id (car-safe entry)) + (new-entry (gnus-registry-get-or-make-entry id)) + (rest (cdr-safe entry)) + (groups (loop for p in rest + when (stringp p) + collect p)) + extra-cell key val) + ;; remove all the strings from the entry + (delete* nil rest :test (lambda (a b) (stringp b))) + (gnus-registry-set-id-key id 'group groups) + ;; just use the first extra element + (setq rest (car-safe rest)) + (while (car-safe rest) + (setq extra-cell (car-safe rest) + key (car-safe extra-cell) + val (cdr-safe extra-cell) + rest (cdr-safe rest)) + (when (and val (atom val)) + (setq val (list val))) + (gnus-registry-set-id-key id key val)))) + (message "Import done, collected %d entries" count)))) (ert-deftest gnus-registry-usage-test () (let* ((n 100) diff --git a/lisp/gnus/registry.el b/lisp/gnus/registry.el index 319da8ffab7..cc03b20662d 100644 --- a/lisp/gnus/registry.el +++ b/lisp/gnus/registry.el @@ -77,7 +77,10 @@ ;;; Code: -(eval-when-compile (require 'ert)) +(eval-when-compile + (when (null (require 'ert nil t)) + (defmacro* ert-deftest (name () &body docstring-keys-and-body)))) + (eval-when-compile (require 'cl)) (eval-and-compile (or (ignore-errors (progn -- 2.39.2