diff options
| author | Chong Yidong | 2006-12-08 16:26:32 +0000 |
|---|---|---|
| committer | Chong Yidong | 2006-12-08 16:26:32 +0000 |
| commit | 4921bbddd79cd25c99c6b6e3522c9ddf1fb6a88d (patch) | |
| tree | e9811950c95346a998a6a9ed0f035fb330b0fa08 | |
| parent | f88e76a8a708878e9253964e5a9ed06699076745 (diff) | |
| download | emacs-4921bbddd79cd25c99c6b6e3522c9ddf1fb6a88d.tar.gz emacs-4921bbddd79cd25c99c6b6e3522c9ddf1fb6a88d.zip | |
(gnus-make-thread-indent-array): New optional arg specifying array size.
(gnus-summary-insert-line, gnus-summary-prepare-threads): Regrow indent
array if it is too small.
(gnus-sort-threads-recursive): Renamed from gnus-sort-thread-1.
(gnus-sort-threads-loop): New function.
| -rw-r--r-- | lisp/gnus/gnus-sum.el | 65 |
1 files changed, 48 insertions, 17 deletions
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index 05d5614756b..55df66862c2 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el | |||
| @@ -3343,16 +3343,17 @@ buffer that was in action when the last article was fetched." | |||
| 3343 | t | 3343 | t |
| 3344 | (not (cdr (gnus-data-find-list article))))) | 3344 | (not (cdr (gnus-data-find-list article))))) |
| 3345 | 3345 | ||
| 3346 | (defun gnus-make-thread-indent-array () | 3346 | (defun gnus-make-thread-indent-array (&optional n) |
| 3347 | (let ((n 200)) | 3347 | (when (or n |
| 3348 | (unless (and gnus-thread-indent-array | 3348 | (progn (setq n 200) nil) |
| 3349 | (= gnus-thread-indent-level gnus-thread-indent-array-level)) | 3349 | (null gnus-thread-indent-array) |
| 3350 | (setq gnus-thread-indent-array (make-vector 201 "") | 3350 | (/= gnus-thread-indent-level gnus-thread-indent-array-level)) |
| 3351 | gnus-thread-indent-array-level gnus-thread-indent-level) | 3351 | (setq gnus-thread-indent-array (make-vector (1+ n) "") |
| 3352 | (while (>= n 0) | 3352 | gnus-thread-indent-array-level gnus-thread-indent-level) |
| 3353 | (aset gnus-thread-indent-array n | 3353 | (while (>= n 0) |
| 3354 | (make-string (* n gnus-thread-indent-level) ? )) | 3354 | (aset gnus-thread-indent-array n |
| 3355 | (setq n (1- n)))))) | 3355 | (make-string (* n gnus-thread-indent-level) ?\s)) |
| 3356 | (setq n (1- n))))) | ||
| 3356 | 3357 | ||
| 3357 | (defun gnus-update-summary-mark-positions () | 3358 | (defun gnus-update-summary-mark-positions () |
| 3358 | "Compute where the summary marks are to go." | 3359 | "Compute where the summary marks are to go." |
| @@ -3451,6 +3452,9 @@ buffer that was in action when the last article was fetched." | |||
| 3451 | gnus-tmp-expirable gnus-tmp-subject-or-nil | 3452 | gnus-tmp-expirable gnus-tmp-subject-or-nil |
| 3452 | &optional gnus-tmp-dummy gnus-tmp-score | 3453 | &optional gnus-tmp-dummy gnus-tmp-score |
| 3453 | gnus-tmp-process) | 3454 | gnus-tmp-process) |
| 3455 | (if (>= gnus-tmp-level (length gnus-thread-indent-array)) | ||
| 3456 | (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array)) | ||
| 3457 | gnus-tmp-level))) | ||
| 3454 | (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level)) | 3458 | (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level)) |
| 3455 | (gnus-tmp-lines (mail-header-lines gnus-tmp-header)) | 3459 | (gnus-tmp-lines (mail-header-lines gnus-tmp-header)) |
| 3456 | (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0)) | 3460 | (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0)) |
| @@ -4549,23 +4553,46 @@ If LINE, insert the rebuilt thread starting on line LINE." | |||
| 4549 | (1+ (gnus-point-at-eol)) | 4553 | (1+ (gnus-point-at-eol)) |
| 4550 | (gnus-delete-line))))))) | 4554 | (gnus-delete-line))))))) |
| 4551 | 4555 | ||
| 4552 | (defun gnus-sort-threads-1 (threads func) | 4556 | (defun gnus-sort-threads-recursive (threads func) |
| 4553 | (sort (mapcar (lambda (thread) | 4557 | (sort (mapcar (lambda (thread) |
| 4554 | (cons (car thread) | 4558 | (cons (car thread) |
| 4555 | (and (cdr thread) | 4559 | (and (cdr thread) |
| 4556 | (gnus-sort-threads-1 (cdr thread) func)))) | 4560 | (gnus-sort-threads-recursive (cdr thread) func)))) |
| 4557 | threads) func)) | 4561 | threads) func)) |
| 4558 | 4562 | ||
| 4563 | (defun gnus-sort-threads-loop (threads func) | ||
| 4564 | (let* ((superthread (cons nil threads)) | ||
| 4565 | (stack (list (cons superthread threads))) | ||
| 4566 | remaining-threads thread) | ||
| 4567 | (while stack | ||
| 4568 | (setq remaining-threads (cdr (car stack))) | ||
| 4569 | (if remaining-threads | ||
| 4570 | (progn (setq thread (car remaining-threads)) | ||
| 4571 | (setcdr (car stack) (cdr remaining-threads)) | ||
| 4572 | (if (cdr thread) | ||
| 4573 | (push (cons thread (cdr thread)) stack))) | ||
| 4574 | (setq thread (caar stack)) | ||
| 4575 | (setcdr thread (sort (cdr thread) func)) | ||
| 4576 | (pop stack))) | ||
| 4577 | (cdr superthread))) | ||
| 4578 | |||
| 4559 | (defun gnus-sort-threads (threads) | 4579 | (defun gnus-sort-threads (threads) |
| 4560 | "Sort THREADS." | 4580 | "Sort THREADS." |
| 4561 | (if (not gnus-thread-sort-functions) | 4581 | (if (not gnus-thread-sort-functions) |
| 4562 | threads | 4582 | threads |
| 4563 | (gnus-message 8 "Sorting threads...") | 4583 | (gnus-message 8 "Sorting threads...") |
| 4564 | (let ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))) | 4584 | (prog1 |
| 4565 | (prog1 (gnus-sort-threads-1 | 4585 | (condition-case nil |
| 4566 | threads | 4586 | (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))) |
| 4567 | (gnus-make-sort-function gnus-thread-sort-functions)) | 4587 | (gnus-sort-threads-recursive |
| 4568 | (gnus-message 8 "Sorting threads...done"))))) | 4588 | threads (gnus-make-sort-function gnus-thread-sort-functions))) |
| 4589 | ;; Even after binding max-lisp-eval-depth, the recursive | ||
| 4590 | ;; sorter might fail for very long threads. In that case, | ||
| 4591 | ;; try using a (less well-tested) non-recursive sorter. | ||
| 4592 | (error (gnus-sort-threads-loop | ||
| 4593 | threads (gnus-make-sort-function | ||
| 4594 | gnus-thread-sort-functions)))) | ||
| 4595 | (gnus-message 8 "Sorting threads...done")))) | ||
| 4569 | 4596 | ||
| 4570 | (defun gnus-sort-articles (articles) | 4597 | (defun gnus-sort-articles (articles) |
| 4571 | "Sort ARTICLES." | 4598 | "Sort ARTICLES." |
| @@ -4990,6 +5017,10 @@ or a straight list of headers." | |||
| 4990 | gnus-tmp-closing-bracket ?\>) | 5017 | gnus-tmp-closing-bracket ?\>) |
| 4991 | (setq gnus-tmp-opening-bracket ?\[ | 5018 | (setq gnus-tmp-opening-bracket ?\[ |
| 4992 | gnus-tmp-closing-bracket ?\])) | 5019 | gnus-tmp-closing-bracket ?\])) |
| 5020 | (if (>= gnus-tmp-level (length gnus-thread-indent-array)) | ||
| 5021 | (gnus-make-thread-indent-array | ||
| 5022 | (max (* 2 (length gnus-thread-indent-array)) | ||
| 5023 | gnus-tmp-level))) | ||
| 4993 | (setq | 5024 | (setq |
| 4994 | gnus-tmp-indentation | 5025 | gnus-tmp-indentation |
| 4995 | (aref gnus-thread-indent-array gnus-tmp-level) | 5026 | (aref gnus-thread-indent-array gnus-tmp-level) |