From 87154dc2829a68be2500cc66f74807fbb7d3ff70 Mon Sep 17 00:00:00 2001 From: yamaoka Date: Fri, 12 Dec 2003 06:41:38 +0000 Subject: [PATCH] Synch to Gnus 200312120529. --- lisp/gnus-agent.el | 424 ++++++++++++++++++++++++++-------------------------- lisp/gnus-cus.el | 4 + lisp/gnus-start.el | 19 +-- texi/ChangeLog | 6 + texi/gnus-ja.texi | 23 ++- texi/gnus.texi | 22 ++- 6 files changed, 268 insertions(+), 230 deletions(-) diff --git a/lisp/gnus-agent.el b/lisp/gnus-agent.el index c0e44ec..598444e 100644 --- a/lisp/gnus-agent.el +++ b/lisp/gnus-agent.el @@ -1166,6 +1166,27 @@ This can be added to `gnus-select-article-hook' or ;; will add it while reading the file. (gnus-write-active-file file old nil)))) +(defun gnus-agent-possibly-alter-active (group active) + "Possibly expand a group's active range to include articles +downloaded into the agent." + +;; I can't use the agent's active file here as there is no practical +;; mechanism to update the active ranges in that file as the oldest +;; articles are removed from the agent. + (let* ((gnus-command-method (or gnus-command-method + (gnus-find-method-for-group group))) + (alist (gnus-agent-load-alist group))) + + (let ((new-min (or (caar gnus-agent-article-alist) + (car active))) + (new-max (or (caar (last gnus-agent-article-alist)) + (cdr active)))) + + (when (< new-min (car active)) + (setcar active new-min)) + (when (> new-max (cdr active)) + (setcdr active new-max))))) + (defun gnus-agent-save-groups (method) (gnus-agent-save-active-1 method 'gnus-groups-to-gnus-format)) @@ -3325,234 +3346,215 @@ If REREAD is not nil, downloaded articles are marked as unread." (message "Ignoring unexpected input") (sit-for 1) t))))) - (gnus-message 5 "Regenerating in %s" group) - (let* ((gnus-command-method (or gnus-command-method - (gnus-find-method-for-group group))) - (file (gnus-agent-article-name ".overview" group)) - (dir (file-name-directory file)) - point - (downloaded (if (file-exists-p dir) - (sort (mapcar (lambda (name) (string-to-int name)) - (directory-files dir nil "^[0-9]+$" t)) - '>) - (progn (gnus-make-directory dir) nil))) - dl nov-arts - alist header - regenerated) - - (mm-with-unibyte-buffer - (if (file-exists-p file) - (let ((nnheader-file-coding-system - gnus-agent-file-coding-system)) - (nnheader-insert-file-contents file))) - (set-buffer-modified-p nil) - - ;; Load the article IDs found in the overview file. As a - ;; side-effect, validate the file contents. - (let ((load t)) - (while load - (setq load nil) - (goto-char (point-min)) - (while (< (point) (point-max)) - (cond ((and (looking-at "[0-9]+\t") - (<= (- (match-end 0) (match-beginning 0)) 9)) - (push (read (current-buffer)) nov-arts) - (forward-line 1) - (let ((l1 (car nov-arts)) - (l2 (cadr nov-arts))) - (cond ((not l2) - nil) - ((< l1 l2) - (gnus-message 3 "gnus-agent-regenerate-group: NOV\ + + (when group + (gnus-message 5 "Regenerating in %s" group) + (let* ((gnus-command-method (or gnus-command-method + (gnus-find-method-for-group group))) + (file (gnus-agent-article-name ".overview" group)) + (dir (file-name-directory file)) + point + (downloaded (if (file-exists-p dir) + (sort (mapcar (lambda (name) (string-to-int name)) + (directory-files dir nil "^[0-9]+$" t)) + '>) + (progn (gnus-make-directory dir) nil))) + dl nov-arts + alist header + regenerated) + + (mm-with-unibyte-buffer + (if (file-exists-p file) + (let ((nnheader-file-coding-system + gnus-agent-file-coding-system)) + (nnheader-insert-file-contents file))) + (set-buffer-modified-p nil) + + ;; Load the article IDs found in the overview file. As a + ;; side-effect, validate the file contents. + (let ((load t)) + (while load + (setq load nil) + (goto-char (point-min)) + (while (< (point) (point-max)) + (cond ((and (looking-at "[0-9]+\t") + (<= (- (match-end 0) (match-beginning 0)) 9)) + (push (read (current-buffer)) nov-arts) + (forward-line 1) + (let ((l1 (car nov-arts)) + (l2 (cadr nov-arts))) + (cond ((not l2) + nil) + ((< l1 l2) + (gnus-message 3 "gnus-agent-regenerate-group: NOV\ entries are NOT in ascending order.") - ;; Don't sort now as I haven't verified - ;; that every line begins with a number - (setq load t)) - ((= l1 l2) - (forward-line -1) - (gnus-message 4 "gnus-agent-regenerate-group: NOV\ + ;; Don't sort now as I haven't verified + ;; that every line begins with a number + (setq load t)) + ((= l1 l2) + (forward-line -1) + (gnus-message 4 "gnus-agent-regenerate-group: NOV\ entries contained duplicate of article %s. Duplicate deleted." l1) - (gnus-delete-line) - (setq nov-arts (cdr nov-arts)))))) - (t - (gnus-message 1 "gnus-agent-regenerate-group: NOV\ + (gnus-delete-line) + (setq nov-arts (cdr nov-arts)))))) + (t + (gnus-message 1 "gnus-agent-regenerate-group: NOV\ entries contained line that did not begin with an article number. Deleted\ line.") - (gnus-delete-line)))) - (if load - (progn - (gnus-message 5 "gnus-agent-regenerate-group: Sorting NOV\ + (gnus-delete-line)))) + (if load + (progn + (gnus-message 5 "gnus-agent-regenerate-group: Sorting NOV\ entries into ascending order.") - (sort-numeric-fields 1 (point-min) (point-max)) + (sort-numeric-fields 1 (point-min) (point-max)) (setq nov-arts nil))))) - (gnus-agent-check-overview-buffer) - - ;; Construct a new article alist whose nodes match every header - ;; in the .overview file. As a side-effect, missing headers are - ;; reconstructed from the downloaded article file. - (while (or downloaded nov-arts) - (cond ((and downloaded - (or (not nov-arts) - (> (car downloaded) (car nov-arts)))) - ;; This entry is missing from the overview file - (gnus-message 3 "Regenerating NOV %s %d..." group - (car downloaded)) - (let ((file (concat dir (number-to-string (car downloaded))))) - (mm-with-unibyte-buffer - (nnheader-insert-file-contents file) - (nnheader-remove-body) - (setq header (nnheader-parse-naked-head))) - (mail-header-set-number header (car downloaded)) - (if nov-arts - (let ((key (concat "^" (int-to-string (car nov-arts)) - "\t"))) - (or (re-search-backward key nil t) - (re-search-forward key)) - (forward-line 1)) - (goto-char (point-min))) - (nnheader-insert-nov header)) - (setq nov-arts (cons (car downloaded) nov-arts))) - ((eq (car downloaded) (car nov-arts)) - ;; This entry in the overview has been downloaded - (push (cons (car downloaded) - (time-to-days - (nth 5 (file-attributes - (concat dir (number-to-string - (car downloaded))))))) alist) - (setq downloaded (cdr downloaded)) - (setq nov-arts (cdr nov-arts))) - (t - ;; This entry in the overview has not been downloaded - (push (cons (car nov-arts) nil) alist) - (setq nov-arts (cdr nov-arts))))) - - ;; When gnus-agent-consider-all-articles is set, - ;; gnus-agent-regenerate-group should NOT remove article IDs from - ;; the alist. Those IDs serve as markers to indicate that an - ;; attempt has been made to fetch that article's header. - - ;; When gnus-agent-consider-all-articles is NOT set, - ;; gnus-agent-regenerate-group can remove the article ID of every - ;; article (with the exception of the last ID in the list - it's - ;; special) that no longer appears in the overview. In this - ;; situtation, the last article ID in the list implies that it, - ;; and every article ID preceeding it, have been fetched from the - ;; server. - (if gnus-agent-consider-all-articles - ;; Restore all article IDs that were not found in the overview file. - (let* ((n (cons nil alist)) - (merged n) - (o (gnus-agent-load-alist group))) - (while o - (let ((nID (caadr n)) - (oID (caar o))) - (cond ((not nID) - (setq n (setcdr n (list (list oID)))) - (setq o (cdr o))) - ((< oID nID) - (setcdr n (cons (list oID) (cdr n))) - (setq o (cdr o))) - ((= oID nID) - (setq o (cdr o)) - (setq n (cdr n))) - (t - (setq n (cdr n)))))) - (setq alist (cdr merged))) - ;; Restore the last article ID if it is not already in the new alist - (let ((n (last alist)) - (o (last (gnus-agent-load-alist group)))) - (cond ((not o) - nil) - ((not n) - (push (cons (caar o) nil) alist)) - ((< (caar n) (caar o)) - (setcdr n (list (car o))))))) - - (let ((inhibit-quit t)) - (if (setq regenerated (buffer-modified-p)) - (write-region-as-coding-system - gnus-agent-file-coding-system - (point-min) (point-max) file nil 'silent)) - - (setq regenerated (or regenerated - (and reread gnus-agent-article-alist) - (not (equal alist gnus-agent-article-alist))) - ) - - (setq gnus-agent-article-alist alist) - - (when regenerated - (gnus-agent-save-alist group))) - ) - - (when (and reread gnus-agent-article-alist) - (gnus-make-ascending-articles-unread - group - (delq nil (mapcar (function (lambda (c) - (cond ((eq reread t) - (car c)) - ((cdr c) - (car c))))) - gnus-agent-article-alist))) - - (when (gnus-buffer-live-p gnus-group-buffer) - (gnus-group-update-group group t) - (sit-for 0)) - ) - - (gnus-message 5 nil) - regenerated)) + (gnus-agent-check-overview-buffer) + + ;; Construct a new article alist whose nodes match every header + ;; in the .overview file. As a side-effect, missing headers are + ;; reconstructed from the downloaded article file. + (while (or downloaded nov-arts) + (cond ((and downloaded + (or (not nov-arts) + (> (car downloaded) (car nov-arts)))) + ;; This entry is missing from the overview file + (gnus-message 3 "Regenerating NOV %s %d..." group + (car downloaded)) + (let ((file (concat dir (number-to-string (car downloaded))))) + (mm-with-unibyte-buffer + (nnheader-insert-file-contents file) + (nnheader-remove-body) + (setq header (nnheader-parse-naked-head))) + (mail-header-set-number header (car downloaded)) + (if nov-arts + (let ((key (concat "^" (int-to-string (car nov-arts)) + "\t"))) + (or (re-search-backward key nil t) + (re-search-forward key)) + (forward-line 1)) + (goto-char (point-min))) + (nnheader-insert-nov header)) + (setq nov-arts (cons (car downloaded) nov-arts))) + ((eq (car downloaded) (car nov-arts)) + ;; This entry in the overview has been downloaded + (push (cons (car downloaded) + (time-to-days + (nth 5 (file-attributes + (concat dir (number-to-string + (car downloaded))))))) alist) + (setq downloaded (cdr downloaded)) + (setq nov-arts (cdr nov-arts))) + (t + ;; This entry in the overview has not been downloaded + (push (cons (car nov-arts) nil) alist) + (setq nov-arts (cdr nov-arts))))) + + ;; When gnus-agent-consider-all-articles is set, + ;; gnus-agent-regenerate-group should NOT remove article IDs from + ;; the alist. Those IDs serve as markers to indicate that an + ;; attempt has been made to fetch that article's header. + + ;; When gnus-agent-consider-all-articles is NOT set, + ;; gnus-agent-regenerate-group can remove the article ID of every + ;; article (with the exception of the last ID in the list - it's + ;; special) that no longer appears in the overview. In this + ;; situtation, the last article ID in the list implies that it, + ;; and every article ID preceeding it, have been fetched from the + ;; server. + + (if gnus-agent-consider-all-articles + ;; Restore all article IDs that were not found in the overview file. + (let* ((n (cons nil alist)) + (merged n) + (o (gnus-agent-load-alist group))) + (while o + (let ((nID (caadr n)) + (oID (caar o))) + (cond ((not nID) + (setq n (setcdr n (list (list oID)))) + (setq o (cdr o))) + ((< oID nID) + (setcdr n (cons (list oID) (cdr n))) + (setq o (cdr o))) + ((= oID nID) + (setq o (cdr o)) + (setq n (cdr n))) + (t + (setq n (cdr n)))))) + (setq alist (cdr merged))) + ;; Restore the last article ID if it is not already in the new alist + (let ((n (last alist)) + (o (last (gnus-agent-load-alist group)))) + (cond ((not o) + nil) + ((not n) + (push (cons (caar o) nil) alist)) + ((< (caar n) (caar o)) + (setcdr n (list (car o))))))) + + (let ((inhibit-quit t)) + (if (setq regenerated (buffer-modified-p)) + (write-region-as-coding-system + gnus-agent-file-coding-system + (point-min) (point-max) file nil 'silent)) + + (setq regenerated (or regenerated + (and reread gnus-agent-article-alist) + (not (equal alist gnus-agent-article-alist)))) + + (setq gnus-agent-article-alist alist) + + (when regenerated + (gnus-agent-save-alist group) + + ;; I have to alter the group's active range NOW as + ;; gnus-make-ascending-articles-unread will use it to + ;; recalculate the number of unread articles in the group + + (let ((group (gnus-group-real-name group)) + (group-active (gnus-active group))) + (when group-active + (let ((new-min (or (caar gnus-agent-article-alist) + (car group-active))) + (new-max (or (caar (last gnus-agent-article-alist)) + (cdr group-active)))) + + (when (< new-min (car group-active)) + (setcar group-active new-min)) + + (when (> new-max (cdr group-active)) + (setcdr group-active new-max)))))))) + + (when (and reread gnus-agent-article-alist) + (gnus-make-ascending-articles-unread + group + (delq nil (mapcar (function (lambda (c) + (cond ((eq reread t) + (car c)) + ((cdr c) + (car c))))) + gnus-agent-article-alist))) + + (when (gnus-buffer-live-p gnus-group-buffer) + (gnus-group-update-group group t) + (sit-for 0))) + + (gnus-message 5 nil) + regenerated))) ;;;###autoload (defun gnus-agent-regenerate (&optional clean reread) "Regenerate all agent covered files. -If CLEAN, don't read existing active files." +If CLEAN, obsolete (ignore)." (interactive "P") (let (regenerated) (gnus-message 4 "Regenerating Gnus agent files...") (dolist (gnus-command-method (gnus-agent-covered-methods)) - (let ((active-file (gnus-agent-lib-file "active")) - active-hashtb active-changed - point) - (gnus-make-directory (file-name-directory active-file)) - (if clean - (setq active-hashtb (gnus-make-hashtable 1000)) - (mm-with-unibyte-buffer - (if (file-exists-p active-file) - (let ((nnheader-file-coding-system - gnus-agent-file-coding-system)) - (nnheader-insert-file-contents active-file)) - (setq active-changed t)) - (gnus-active-to-gnus-format - nil (setq active-hashtb - (gnus-make-hashtable - (count-lines (point-min) (point-max))))))) (dolist (group (gnus-groups-from-server gnus-command-method)) (setq regenerated (or (gnus-agent-regenerate-group group reread) - regenerated)) - (let ((min (or (caar gnus-agent-article-alist) 1)) - (max (or (caar (last gnus-agent-article-alist)) 0)) - (active (gnus-gethash-safe (gnus-group-real-name group) - active-hashtb)) - (read (gnus-info-read (gnus-get-info group)))) - (if (not active) - (progn - (setq active (cons min max) - active-changed t) - (gnus-sethash group active active-hashtb)) - (when (> (car active) min) - (setcar active min) - (setq active-changed t)) - (when (< (cdr active) max) - (setcdr active max) - (setq active-changed t))))) - (when active-changed - (setq regenerated t) - (gnus-message 4 "Regenerate %s" active-file) - (let ((nnmail-active-file-coding-system - gnus-agent-file-coding-system)) - (gnus-write-active-file active-file active-hashtb))))) + regenerated)))) (gnus-message 4 "Regenerating Gnus agent files...done") + regenerated)) (defun gnus-agent-go-online (&optional force) diff --git a/lisp/gnus-cus.el b/lisp/gnus-cus.el index 08e62f0..bfc8133 100644 --- a/lisp/gnus-cus.el +++ b/lisp/gnus-cus.el @@ -1045,6 +1045,10 @@ articles in the thread. (gnus-agent-cat-prepare-category-field agent-enable-expiration) (gnus-agent-cat-prepare-category-field agent-days-until-old) + (widget-insert "\nVisual Settings ") + + (gnus-agent-cat-prepare-category-field agent-disable-undownloaded-faces) + (use-local-map widget-keymap) (widget-setup) (buffer-enable-undo)))) diff --git a/lisp/gnus-start.el b/lisp/gnus-start.el index 279880a..9688b4b 100644 --- a/lisp/gnus-start.el +++ b/lisp/gnus-start.el @@ -37,7 +37,6 @@ (require 'gnus-util) (autoload 'message-make-date "message") (autoload 'gnus-agent-read-servers-validate "gnus-agent") -(autoload 'gnus-agent-load-alist "gnus-agent") (defcustom gnus-startup-file (nnheader-concat gnus-home-directory ".newsrc") "Your `.newsrc' file. @@ -1533,18 +1532,6 @@ newsgroup." (gnus-active group)) (gnus-active group) - (when (and gnus-agent - (gnus-agent-method-p method)) - ;; The agent may be storing articles that are no longer in the - ;; server's active range. If that is the case, the active range - ;; needs to be expanded such that the agent's articles can be - ;; included in the summary. - (let* ((gnus-command-method method) - (alist (gnus-agent-load-alist group))) - (if (and (car alist) - (< (caar alist) (car active))) - (setcar active (caar alist))))) - (gnus-set-active group active) ;; Return the new active info. active))))) @@ -1564,6 +1551,12 @@ newsgroup." (when (and gnus-use-cache info) (inline (gnus-cache-possibly-alter-active (gnus-info-group info) active))) + + ;; If the agent is enabled, we may have to alter the active info. + (when (and gnus-agent info) + (inline (gnus-agent-possibly-alter-active + (gnus-info-group info) active))) + ;; Modify the list of read articles according to what articles ;; are available; then tally the unread articles and add the ;; number to the group hash table entry. diff --git a/texi/ChangeLog b/texi/ChangeLog index 6a5eb4b..dd92234 100644 --- a/texi/ChangeLog +++ b/texi/ChangeLog @@ -1,3 +1,9 @@ +2003-12-11 Kevin Greiner + + * gnus.texi (Agent Parameters): Added references in Topic and + Group Parameters. Added gnus-agent-cat-disable-undownloaded-faces + to the list of documented agent parameters. + 2003-12-11 Jesper Harder * message.texi (Mailing Lists): Fix typo. diff --git a/texi/gnus-ja.texi b/texi/gnus-ja.texi index 27c859f..51a8e11 100644 --- a/texi/gnus-ja.texi +++ b/texi/gnus-ja.texi @@ -3009,6 +3009,13 @@ if address \"sender\" \"sieve-admin@@extundo.com\" @{ Sieve 言語は RFC 3028 で述べられていま す (@pxref{Top, Emacs Sieve, Top, sieve, Emacs Sieve})。 +@item (agent parameters) +エージェントを使うようにしてあると、個々のグループでエージェントの振る舞 +いを制御するどのパラメータも設定することができます。エージェントパラメー +タについては @ref{Category Syntax} を参照して下さい。たいていのユーザは、 +設定に要する苦労を最小限にするために、エージェントカテゴリーかグループト +ピックのどちらかでエージェントパラメータを設定することを選ぶでしょう。 + @item (@var{variable} @var{form}) グループに入るときに、そのグループローカルの変数を設定するグループパラメー タを使用することができます。@samp{news.answers} においてスレッド表示を行 @@ -3935,7 +3942,10 @@ Gnus トピック内の全てのグループはグループパラメータを、その親 (と先祖) のトピッ クパラメータから継承します。グループパラメータとして正しいものは全て、ト -ピックパラメータとしても正しいものです(@pxref{Group Parameters})。 +ピックパラメータとしても正しいものです(@pxref{Group Parameters})。エージェ +ントを使うようにしてあると、すべてのエージェントパラメータ (@ref{Category +Syntax} の Agent Parameters を参照 (訳注: 必要なら Index を使って)) は有 +効なトピックパラメータでもあります。 さらに、以下のパラメータはトピックパラメータとしてのみ有効です: @@ -16808,12 +16818,13 @@ Commands}) か、またはエージェントに扱って欲しくないのに自動的に追加され 変数を上書きする多くの任意なパラメータから成ります。エージェントパラメー タの完全なリストを以下に示します。 +@cindex Agent Parameters @table @code @item gnus-agent-cat-name -The name of the category. +分類の名前。 @item gnus-agent-cat-groups -The list of groups that are in this category. +この分類にあるグループのリスト。 @item gnus-agent-cat-predicate (通常) どの記事をダウンロードするのが適当かという大まかな輪郭を与える述 @@ -16845,6 +16856,12 @@ The list of groups that are in this category. @item gnus-agent-cat-length-when-long @code{gnus-agent-long-article} を上書きする整数。 + +@item gnus-agent-cat-disable-undownloaded-faces +ダウンロードされていない記事を gnus-summary-*-undownloaded-face を使って +概略バッファにすべき @emph{ではない} ことを示すシンボル。値 +が @code{nil} だと、他のシンボルがそれらを抑制していても、ダウンロードさ +れていない記事用のフェースを使えるようになります。 @end table いったん分類が作られたら、分類の名前を変えることはできません。 diff --git a/texi/gnus.texi b/texi/gnus.texi index 7286e92..0388b22 100644 --- a/texi/gnus.texi +++ b/texi/gnus.texi @@ -3001,6 +3001,13 @@ if address \"sender\" \"sieve-admin@@extundo.com\" @{ The Sieve language is described in RFC 3028. @xref{Top, Emacs Sieve, Top, sieve, Emacs Sieve}. +@item (agent parameters) +If the agent has been enabled, you can set any of the its parameters +to control the behavior of the agent in individual groups. See Agent +Parameters in @ref{Category Syntax}. Most users will choose to set +agent parameters in either an agent category or group topic to +minimize the configuration effort. + @item (@var{variable} @var{form}) You can use the group parameters to set variables local to the group you are entering. If you want to turn threading off in @samp{news.answers}, @@ -3961,9 +3968,11 @@ allowed---@code{visible} and @code{invisible}. @subsection Topic Parameters @cindex topic parameters -All groups in a topic will inherit group parameters from the parent (and -ancestor) topic parameters. All valid group parameters are valid topic -parameters (@pxref{Group Parameters}). +All groups in a topic will inherit group parameters from the parent +(and ancestor) topic parameters. All valid group parameters are valid +topic parameters (@pxref{Group Parameters}). When the agent is +enabled, all agent parameters (See Agent Parameters in @ref{Category +Syntax}) are also valid topic parameters. In addition, the following parameters are only valid as topic parameters: @@ -17557,6 +17566,7 @@ category, and a number of optional parameters that override the customizable variables. The complete list of agent parameters are listed below. +@cindex Agent Parameters @table @code @item gnus-agent-cat-name The name of the category. @@ -17595,6 +17605,12 @@ an integer that overrides the value of @item gnus-agent-cat-length-when-long an integer that overrides the value of @code{gnus-agent-long-article}. + +@item gnus-agent-cat-disable-undownloaded-faces +a symbol indicating whether the summary buffer should @emph{not} display +undownloaded articles using the gnus-summary-*-undownloaded-face +faces. The symbol nil will enable the use of undownloaded faces while +all other symbols disable them. @end table The name of a category can not be changed once the category has been -- 1.7.10.4