diff options
| author | Gnus developers | 2011-04-06 22:08:31 +0000 |
|---|---|---|
| committer | Katsumi Yamaoka | 2011-04-06 22:08:31 +0000 |
| commit | 2237da9c046e02caa87e3b3bd80fb207020a057a (patch) | |
| tree | 0af09fe76729e549fb577ed66b686176ac0d7ed0 | |
| parent | e67a13abd8584d05dbac22496adb3cfb9256d8d8 (diff) | |
| download | emacs-2237da9c046e02caa87e3b3bd80fb207020a057a.tar.gz emacs-2237da9c046e02caa87e3b3bd80fb207020a057a.zip | |
Merge changes made in Gnus trunk.
registry.el, gnus-registry.el: Use `ignore-errors' instead of third argument NOERROR for `require', since XEmacs 21.4 does not support it.
registry.el (initialize-instance): Change :after to :AFTER to be compatible with old EIEIO version in XEmacs.
gnus-registry.el (gnus-registry-post-process-groups)
(gnus-registry--split-fancy-with-parent-internal): Fix splitting bugs and provide better messaging.
gnus-registry.el: Load ERT unconditionally anyway, discarding errors.
registry.el: Load ERT unconditionally anyway, discarding errors.
| -rw-r--r-- | lisp/gnus/ChangeLog | 33 | ||||
| -rw-r--r-- | lisp/gnus/gnus-registry.el | 193 | ||||
| -rw-r--r-- | lisp/gnus/registry.el | 7 |
3 files changed, 145 insertions, 88 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index b79a5de55e1..f6ce9f089ef 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,10 +1,39 @@ | |||
| 1 | 2011-04-06 David Engster <dengste@eml.cc> | ||
| 2 | |||
| 3 | * registry.el, gnus-registry.el: Use `ignore-errors' instead of third | ||
| 4 | argument NOERROR for `require', since XEmacs 21.4 does not support it. | ||
| 5 | |||
| 6 | 2011-04-06 David Engster <dengste@eml.cc> | ||
| 7 | |||
| 8 | * registry.el (initialize-instance): Change :after to :AFTER to be | ||
| 9 | compatible with old EIEIO version in XEmacs. | ||
| 10 | |||
| 11 | 2011-04-06 Teodor Zlatanov <tzz@lifelogs.com> | ||
| 12 | |||
| 13 | * gnus-registry.el (gnus-registry-post-process-groups) | ||
| 14 | (gnus-registry--split-fancy-with-parent-internal): Fix splitting bugs | ||
| 15 | and provide better messaging. | ||
| 16 | |||
| 17 | 2011-04-06 David Engster <dengste@eml.cc> | ||
| 18 | |||
| 19 | * Makefile.in (fail-on-warning): New rule to compile with warnings as | ||
| 20 | errors. | ||
| 21 | |||
| 22 | * dgnushack.el (dgnushack-compile-error-on-warn): New function to call | ||
| 23 | dgnushack-compile with error-on-warn enabled, and to signal an error if | ||
| 24 | clean compilation failed. | ||
| 25 | (dgnushack-compile): New argument 'error-on-warn'. If non-nil, compile | ||
| 26 | with `byte-compile-error-on-warn'. Return nil if errors occured. | ||
| 27 | |||
| 1 | 2011-04-06 Teodor Zlatanov <tzz@lifelogs.com> | 28 | 2011-04-06 Teodor Zlatanov <tzz@lifelogs.com> |
| 2 | 29 | ||
| 3 | * gnus-registry.el: Don't use ERT if it's not available. | 30 | * gnus-registry.el: Don't use ERT if it's not available. Load it |
| 31 | unconditionally anyway, discarding errors. | ||
| 4 | (gnus-registry-delete-entries): New convenience function. | 32 | (gnus-registry-delete-entries): New convenience function. |
| 5 | (gnus-registry-import-eld): Import from old .eld registry. | 33 | (gnus-registry-import-eld): Import from old .eld registry. |
| 6 | 34 | ||
| 7 | * registry.el: Don't use ERT if it's not available. | 35 | * registry.el: Don't use ERT if it's not available. Load it |
| 36 | unconditionally anyway, discarding errors. | ||
| 8 | 37 | ||
| 9 | * proto-stream.el (gnutls-negotiate): Revert inadvertent commit of the | 38 | * proto-stream.el (gnutls-negotiate): Revert inadvertent commit of the |
| 10 | version from the Claudio Bley GnuTLS patch (extra optional parameters | 39 | version from the Claudio Bley GnuTLS patch (extra optional parameters |
diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el index 511012df577..5145f01d635 100644 --- a/lisp/gnus/gnus-registry.el +++ b/lisp/gnus/gnus-registry.el | |||
| @@ -58,9 +58,11 @@ | |||
| 58 | (eval-when-compile (require 'cl)) | 58 | (eval-when-compile (require 'cl)) |
| 59 | 59 | ||
| 60 | (eval-when-compile | 60 | (eval-when-compile |
| 61 | (when (null (require 'ert nil t)) | 61 | (when (null (ignore-errors (require 'ert))) |
| 62 | (defmacro* ert-deftest (name () &body docstring-keys-and-body)))) | 62 | (defmacro* ert-deftest (name () &body docstring-keys-and-body)))) |
| 63 | 63 | ||
| 64 | (ignore-errors | ||
| 65 | (require 'ert)) | ||
| 64 | (require 'gnus) | 66 | (require 'gnus) |
| 65 | (require 'gnus-int) | 67 | (require 'gnus-int) |
| 66 | (require 'gnus-sum) | 68 | (require 'gnus-sum) |
| @@ -394,85 +396,83 @@ See the Info node `(gnus)Fancy Mail Splitting' for more details." | |||
| 394 | &allow-other-keys) | 396 | &allow-other-keys) |
| 395 | (gnus-message | 397 | (gnus-message |
| 396 | 10 | 398 | 10 |
| 397 | "gnus-registry--split-fancy-with-parent-internal: %S" spec) | 399 | "gnus-registry--split-fancy-with-parent-internal %S" spec) |
| 398 | (let ((db gnus-registry-db) | 400 | (let ((db gnus-registry-db) |
| 399 | found) | 401 | found) |
| 400 | ;; this is a big if-else statement. it uses | 402 | ;; this is a big chain of statements. it uses |
| 401 | ;; gnus-registry-post-process-groups to filter the results after | 403 | ;; gnus-registry-post-process-groups to filter the results after |
| 402 | ;; every step. | 404 | ;; every step. |
| 403 | (cond | 405 | ;; the references string must be valid and parse to valid references |
| 404 | ;; the references string must be valid and parse to valid references | 406 | (when references |
| 405 | (references | 407 | (gnus-message |
| 408 | 9 | ||
| 409 | "%s is tracing references %s" | ||
| 410 | log-agent refstr) | ||
| 406 | (dolist (reference (nreverse references)) | 411 | (dolist (reference (nreverse references)) |
| 407 | (gnus-message | 412 | (gnus-message 9 "%s is looking up %s" log-agent reference) |
| 408 | 9 | 413 | (loop for group in (gnus-registry-get-id-key reference 'group) |
| 409 | "%s is looking for matches for reference %s from [%s]" | 414 | when (gnus-registry-follow-group-p group) |
| 410 | log-agent reference refstr) | 415 | do (gnus-message 7 "%s traced %s to %s" log-agent reference group) |
| 411 | (setq found | 416 | do (push group found))) |
| 412 | (loop for group in (gnus-registry-get-id-key reference 'group) | ||
| 413 | when (gnus-registry-follow-group-p group) | ||
| 414 | do (gnus-message | ||
| 415 | 7 | ||
| 416 | "%s traced the reference %s from [%s] to group %s" | ||
| 417 | log-agent reference refstr group) | ||
| 418 | collect group))) | ||
| 419 | ;; filter the found groups and return them | 417 | ;; filter the found groups and return them |
| 420 | ;; the found groups are the full groups | 418 | ;; the found groups are the full groups |
| 421 | (setq found (gnus-registry-post-process-groups | 419 | (setq found (gnus-registry-post-process-groups |
| 422 | "references" refstr found))) | 420 | "references" refstr found))) |
| 423 | 421 | ||
| 424 | ;; else: there were no matches, try the extra tracking by sender | 422 | ;; else: there were no matches, try the extra tracking by sender |
| 425 | ((and (memq 'sender gnus-registry-track-extra) | 423 | (when (and (null found) |
| 426 | sender | 424 | (memq 'sender gnus-registry-track-extra) |
| 427 | (gnus-grep-in-list | 425 | sender |
| 428 | sender | 426 | (gnus-grep-in-list |
| 429 | gnus-registry-unfollowed-addresses)) | 427 | sender |
| 430 | (let ((groups (apply | 428 | gnus-registry-unfollowed-addresses)) |
| 431 | 'append | 429 | (let ((groups (apply |
| 432 | (mapcar | 430 | 'append |
| 433 | (lambda (reference) | 431 | (mapcar |
| 434 | (gnus-registry-get-id-key reference 'group)) | 432 | (lambda (reference) |
| 435 | (registry-lookup-secondary-value db 'sender sender))))) | 433 | (gnus-registry-get-id-key reference 'group)) |
| 436 | (setq found | 434 | (registry-lookup-secondary-value db 'sender sender))))) |
| 437 | (loop for group in groups | 435 | (setq found |
| 438 | when (gnus-registry-follow-group-p group) | 436 | (loop for group in groups |
| 439 | do (gnus-message | 437 | when (gnus-registry-follow-group-p group) |
| 440 | ;; raise level of messaging if gnus-registry-track-extra | 438 | do (gnus-message |
| 441 | (if gnus-registry-track-extra 7 9) | 439 | ;; warn more if gnus-registry-track-extra |
| 442 | "%s (extra tracking) traced sender '%s' to groups %s" | 440 | (if gnus-registry-track-extra 7 9) |
| 443 | log-agent sender found) | 441 | "%s (extra tracking) traced sender '%s' to %s" |
| 444 | collect group))) | 442 | log-agent sender group) |
| 445 | 443 | collect group))) | |
| 446 | ;; filter the found groups and return them | 444 | |
| 447 | ;; the found groups are NOT the full groups | 445 | ;; filter the found groups and return them |
| 448 | (setq found (gnus-registry-post-process-groups | 446 | ;; the found groups are NOT the full groups |
| 449 | "sender" sender found))) | 447 | (setq found (gnus-registry-post-process-groups |
| 448 | "sender" sender found))) | ||
| 450 | 449 | ||
| 451 | ;; else: there were no matches, now try the extra tracking by subject | 450 | ;; else: there were no matches, now try the extra tracking by subject |
| 452 | ((and (memq 'subject gnus-registry-track-extra) | 451 | (when (and (null found) |
| 453 | subject | 452 | (memq 'subject gnus-registry-track-extra) |
| 454 | (< gnus-registry-minimum-subject-length (length subject))) | 453 | subject |
| 455 | (let ((groups (apply | 454 | (< gnus-registry-minimum-subject-length (length subject))) |
| 456 | 'append | 455 | (let ((groups (apply |
| 457 | (mapcar | 456 | 'append |
| 458 | (lambda (reference) | 457 | (mapcar |
| 459 | (gnus-registry-get-id-key reference 'group)) | 458 | (lambda (reference) |
| 460 | (registry-lookup-secondary-value db 'subject subject))))) | 459 | (gnus-registry-get-id-key reference 'group)) |
| 461 | (setq found | 460 | (registry-lookup-secondary-value db 'subject subject))))) |
| 462 | (loop for group in groups | 461 | (setq found |
| 463 | when (gnus-registry-follow-group-p group) | 462 | (loop for group in groups |
| 464 | do (gnus-message | 463 | when (gnus-registry-follow-group-p group) |
| 465 | ;; raise level of messaging if gnus-registry-track-extra | 464 | do (gnus-message |
| 466 | (if gnus-registry-track-extra 7 9) | 465 | ;; warn more if gnus-registry-track-extra |
| 467 | "%s (extra tracking) traced subject '%s' to groups %s" | 466 | (if gnus-registry-track-extra 7 9) |
| 468 | log-agent subject found) | 467 | "%s (extra tracking) traced subject '%s' to %s" |
| 469 | collect group)) | 468 | log-agent subject group) |
| 470 | ;; filter the found groups and return them | 469 | collect group)) |
| 471 | ;; the found groups are NOT the full groups | 470 | ;; filter the found groups and return them |
| 472 | (setq found (gnus-registry-post-process-groups | 471 | ;; the found groups are NOT the full groups |
| 473 | "subject" subject found))))) | 472 | (setq found (gnus-registry-post-process-groups |
| 474 | ;; after the (cond) we extract the actual value safely | 473 | "subject" subject found)))) |
| 475 | (car-safe found))) | 474 | ;; after the (cond) we extract the actual value safely |
| 475 | (car-safe found))) | ||
| 476 | 476 | ||
| 477 | (defun gnus-registry-post-process-groups (mode key groups) | 477 | (defun gnus-registry-post-process-groups (mode key groups) |
| 478 | "Inspects GROUPS found by MODE for KEY to determine which ones to follow. | 478 | "Inspects GROUPS found by MODE for KEY to determine which ones to follow. |
| @@ -489,25 +489,48 @@ Foreign methods are not supported so they are rejected. | |||
| 489 | Reduces the list to a single group, or complains if that's not | 489 | Reduces the list to a single group, or complains if that's not |
| 490 | possible. Uses `gnus-registry-split-strategy'." | 490 | possible. Uses `gnus-registry-split-strategy'." |
| 491 | (let ((log-agent "gnus-registry-post-process-group") | 491 | (let ((log-agent "gnus-registry-post-process-group") |
| 492 | out) | 492 | (desc (format "%d groups" (length groups))) |
| 493 | 493 | out chosen) | |
| 494 | ;; the strategy can be nil, in which case groups is nil | 494 | ;; the strategy can be nil, in which case chosen is nil |
| 495 | (setq groups | 495 | (setq chosen |
| 496 | (case gnus-registry-split-strategy | 496 | (case gnus-registry-split-strategy |
| 497 | ;; first strategy | 497 | ;; default, take only one-element lists into chosen |
| 498 | ((nil) | ||
| 499 | (and (= (length groups) 1) | ||
| 500 | (car-safe groups))) | ||
| 501 | |||
| 498 | ((first) | 502 | ((first) |
| 499 | (and groups (list (car-safe groups)))) | 503 | (car-safe groups)) |
| 500 | 504 | ||
| 501 | ((majority) | 505 | ((majority) |
| 502 | (let ((freq (make-hash-table | 506 | (let ((freq (make-hash-table |
| 503 | :size 256 | 507 | :size 256 |
| 504 | :test 'equal))) | 508 | :test 'equal))) |
| 505 | (mapc (lambda (x) (puthash x (1+ (gethash x freq 0)) freq)) | 509 | (mapc (lambda (x) (let ((x (gnus-group-short-name x))) |
| 510 | (puthash x (1+ (gethash x freq 0)) freq))) | ||
| 506 | groups) | 511 | groups) |
| 507 | (list (car-safe | 512 | (setq desc (format "%d groups, %d unique" |
| 508 | (sort groups (lambda (a b) | 513 | (length groups) |
| 509 | (> (gethash a freq 0) | 514 | (hash-table-count freq))) |
| 510 | (gethash b freq 0)))))))))) | 515 | (car-safe |
| 516 | (sort groups | ||
| 517 | (lambda (a b) | ||
| 518 | (> (gethash (gnus-group-short-name a) freq 0) | ||
| 519 | (gethash (gnus-group-short-name b) freq 0))))))))) | ||
| 520 | |||
| 521 | (if chosen | ||
| 522 | (gnus-message | ||
| 523 | 9 | ||
| 524 | "%s: strategy %s on %s produced %s" | ||
| 525 | log-agent gnus-registry-split-strategy desc chosen) | ||
| 526 | (gnus-message | ||
| 527 | 9 | ||
| 528 | "%s: strategy %s on %s did not produce an answer" | ||
| 529 | log-agent | ||
| 530 | (or gnus-registry-split-strategy "default") | ||
| 531 | desc)) | ||
| 532 | |||
| 533 | (setq groups (and chosen (list chosen))) | ||
| 511 | 534 | ||
| 512 | (dolist (group groups) | 535 | (dolist (group groups) |
| 513 | (let ((m1 (gnus-find-method-for-group group)) | 536 | (let ((m1 (gnus-find-method-for-group group)) |
| @@ -517,18 +540,20 @@ possible. Uses `gnus-registry-split-strategy'." | |||
| 517 | (if (gnus-methods-equal-p m1 m2) | 540 | (if (gnus-methods-equal-p m1 m2) |
| 518 | (progn | 541 | (progn |
| 519 | ;; this is REALLY just for debugging | 542 | ;; this is REALLY just for debugging |
| 520 | (gnus-message | 543 | (when (not (equal group short-name)) |
| 521 | 10 | 544 | (gnus-message |
| 522 | "%s stripped group %s to %s" | 545 | 10 |
| 523 | log-agent group short-name) | 546 | "%s: stripped group %s to %s" |
| 547 | log-agent group short-name)) | ||
| 524 | (add-to-list 'out short-name)) | 548 | (add-to-list 'out short-name)) |
| 525 | ;; else... | 549 | ;; else... |
| 526 | (gnus-message | 550 | (gnus-message |
| 527 | 7 | 551 | 7 |
| 528 | "%s ignored foreign group %s" | 552 | "%s: ignored foreign group %s" |
| 529 | log-agent group)))) | 553 | log-agent group)))) |
| 530 | 554 | ||
| 531 | ;; is there just one group? | 555 | (setq out (delq nil out)) |
| 556 | |||
| 532 | (cond | 557 | (cond |
| 533 | ((= (length out) 1) out) | 558 | ((= (length out) 1) out) |
| 534 | ((null out) | 559 | ((null out) |
diff --git a/lisp/gnus/registry.el b/lisp/gnus/registry.el index cc03b20662d..8fb7aab82fb 100644 --- a/lisp/gnus/registry.el +++ b/lisp/gnus/registry.el | |||
| @@ -78,9 +78,12 @@ | |||
| 78 | ;;; Code: | 78 | ;;; Code: |
| 79 | 79 | ||
| 80 | (eval-when-compile | 80 | (eval-when-compile |
| 81 | (when (null (require 'ert nil t)) | 81 | (when (null (ignore-errors (require 'ert))) |
| 82 | (defmacro* ert-deftest (name () &body docstring-keys-and-body)))) | 82 | (defmacro* ert-deftest (name () &body docstring-keys-and-body)))) |
| 83 | 83 | ||
| 84 | (ignore-errors | ||
| 85 | (require 'ert)) | ||
| 86 | |||
| 84 | (eval-when-compile (require 'cl)) | 87 | (eval-when-compile (require 'cl)) |
| 85 | (eval-and-compile | 88 | (eval-and-compile |
| 86 | (or (ignore-errors (progn | 89 | (or (ignore-errors (progn |
| @@ -128,7 +131,7 @@ | |||
| 128 | :type hash-table | 131 | :type hash-table |
| 129 | :documentation "The data hashtable."))) | 132 | :documentation "The data hashtable."))) |
| 130 | 133 | ||
| 131 | (defmethod initialize-instance :after ((this registry-db) slots) | 134 | (defmethod initialize-instance :AFTER ((this registry-db) slots) |
| 132 | "Set value of data slot of THIS after initialization." | 135 | "Set value of data slot of THIS after initialization." |
| 133 | (with-slots (data tracker) this | 136 | (with-slots (data tracker) this |
| 134 | (unless (member :data slots) | 137 | (unless (member :data slots) |