annotate lisp/gnus/gnus-topic.el @ 7:c153ca296910

Added tag r19-15b4 for changeset 27bc7f280385
author cvs
date Mon, 13 Aug 2007 08:47:16 +0200
parents ac2d302a0011
children 0293115a14e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; gnus-topic.el --- a folding minor mode for Gnus group buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Copyright (C) 1995,96 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Ilja Weis <kult@uni-paderborn.de>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 (require 'gnus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (eval-when-compile (require 'cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 (defvar gnus-topic-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 "Minor mode for Gnus group buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defvar gnus-topic-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 "Hook run in topic mode buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defvar gnus-topic-line-format "%i[ %(%{%n%}%) -- %A ]%v\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "Format of topic lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 It works along the same lines as a normal formatting string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 with some simple extensions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 %i Indentation based on topic level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 %n Topic name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 %v Nothing if the topic is visible, \"...\" otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 %g Number of groups in the topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 %a Number of unread articles in the groups in the topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 %A Number of unread articles in the groups in the topic and its subtopics.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defvar gnus-topic-indent-level 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 "*How much each subtopic should be indented.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; Internal variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (defvar gnus-topic-active-topology nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (defvar gnus-topic-active-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defvar gnus-topology-checked-p nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 "Whether the topology has been checked in this session.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defvar gnus-topic-killed-topics nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defvar gnus-topic-inhibit-change-level nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defvar gnus-topic-tallied-groups nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (defconst gnus-topic-line-format-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 `((?n name ?s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (?v visible ?s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (?i indentation ?s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (?g number-of-groups ?d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (?a (gnus-topic-articles-in-topic entries) ?d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (?A total-number-of-articles ?d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (?l level ?d)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (defvar gnus-topic-line-format-spec nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; Functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defun gnus-group-topic-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 "The name of the topic on the current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (let ((topic (get-text-property (gnus-point-at-bol) 'gnus-topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (and topic (symbol-name topic))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defun gnus-group-topic-level ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "The level of the topic on the current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (get-text-property (gnus-point-at-bol) 'gnus-topic-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (defun gnus-group-topic-unread ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 "The number of unread articles in topic on the current line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (get-text-property (gnus-point-at-bol) 'gnus-topic-unread))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (defun gnus-topic-unread (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 "Return the number of unread articles in TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (or (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (and (gnus-topic-goto-topic topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (gnus-group-topic-unread)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (defun gnus-topic-init-alist ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 "Initialize the topic structures."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (setq gnus-topic-topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (cons (list "Gnus" 'visible)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (mapcar (lambda (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (list (list (car topic) 'visible)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 '(("misc")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (setq gnus-topic-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (list (cons "misc"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (mapcar (lambda (info) (gnus-info-group info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (cdr gnus-newsrc-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (list "Gnus")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (gnus-topic-enter-dribble))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (defun gnus-group-prepare-topics (level &optional all lowest regexp list-topic topic-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 "List all newsgroups with unread articles of level LEVEL or lower, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 use the `gnus-group-topics' to sort the groups.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 If ALL is non-nil, list groups that have no unread articles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (set-buffer gnus-group-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (let ((buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (lowest (or lowest 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (setq gnus-topic-tallied-groups nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (when (or (not gnus-topic-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (not gnus-topology-checked-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (gnus-topic-check-topology))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (unless list-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; List dead groups?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (when (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (gnus-group-prepare-flat-list-dead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 gnus-level-zombie ?Z
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (when (and (>= level gnus-level-killed) (<= lowest gnus-level-killed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (gnus-group-prepare-flat-list-dead
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (setq gnus-killed-list (sort gnus-killed-list 'string<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 gnus-level-killed ?K
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 regexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; Use topics.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (when (< lowest gnus-level-zombie)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (if list-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (let ((top (gnus-topic-find-topology list-topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (gnus-topic-prepare-topic (cdr top) (car top)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (or topic-level level) all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (gnus-topic-prepare-topic gnus-topic-topology 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (or topic-level level) all))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (gnus-group-set-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (setq gnus-group-list-mode (cons level all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (run-hooks 'gnus-group-prepare-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (defun gnus-topic-prepare-topic (topicl level &optional list-level all silent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 "Insert TOPIC into the group buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 If SILENT, don't insert anything. Return the number of unread
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 articles in the topic and its subtopics."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (let* ((type (pop topicl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (entries (gnus-topic-find-groups (car type) list-level all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (visiblep (and (eq (nth 1 type) 'visible) (not silent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (gnus-group-indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (make-string (* gnus-topic-indent-level level) ? ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (beg (progn (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (topicl (reverse topicl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (all-entries entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (unread 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (topic (car type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 info entry end active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;; Insert any sub-topics.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (while topicl
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (incf unread
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (gnus-topic-prepare-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (pop topicl) (1+ level) list-level all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (not visiblep))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (setq end (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; Insert all the groups that belong in this topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (while (setq entry (pop entries))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (when visiblep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (if (stringp entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; Dead groups.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (gnus-group-insert-group-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 entry (if (member entry gnus-zombie-list) 8 9)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 nil (- (1+ (cdr (setq active (gnus-active entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (car active)) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; Living groups.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (when (setq info (nth 2 entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (gnus-group-insert-group-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (gnus-info-group info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (gnus-info-level info) (gnus-info-marks info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (car entry) (gnus-info-method info)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (when (and (listp entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (numberp (car entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (not (member (gnus-info-group (setq info (nth 2 entry)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 gnus-topic-tallied-groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (push (gnus-info-group info) gnus-topic-tallied-groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (incf unread (car entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;; Insert the topic line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (unless silent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (gnus-extent-start-open (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (gnus-topic-insert-topic-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (car type) visiblep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (not (eq (nth 2 type) 'hidden))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 level all-entries unread))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 unread))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (defun gnus-topic-find-groups (topic &optional level all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 "Return entries for all visible groups in TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (let ((groups (cdr (assoc topic gnus-topic-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 info clevel unread group lowest params visible-groups entry active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (setq lowest (or lowest 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (setq level (or level 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;; We go through the newsrc to look for matches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (while groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (setq entry (gnus-gethash (setq group (pop groups)) gnus-newsrc-hashtb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 info (nth 2 entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 params (gnus-info-params info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 active (gnus-active group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 unread (or (car entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (and (not (equal group "dummy.group"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (- (1+ (cdr active)) (car active))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 clevel (or (gnus-info-level info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (if (member group gnus-zombie-list) 8 9)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 unread ; nil means that the group is dead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (<= clevel level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (>= clevel lowest) ; Is inside the level we want.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (or all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (if (eq unread t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 gnus-group-list-inactive-groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (> unread 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (and gnus-list-groups-with-ticked-articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (cdr (assq 'tick (gnus-info-marks info))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ; Has right readedness.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;; Check for permanent visibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (and gnus-permanently-visible-groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (string-match gnus-permanently-visible-groups group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (memq 'visible params)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (cdr (assq 'visible params)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 ;; Add this group to the list of visible groups.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (push (or entry group) visible-groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (nreverse visible-groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (defun gnus-topic-remove-topic (&optional insert total-remove hide in-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 "Remove the current topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (let ((topic (gnus-group-topic-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (level (gnus-group-topic-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (beg (progn (beginning-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (when topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (while (and (zerop (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (> (or (gnus-group-topic-level) (1+ level)) level)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (delete-region beg (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (setcar (cdadr (gnus-topic-find-topology topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (if insert 'visible 'invisible))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (when hide
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (setcdr (cdadr (gnus-topic-find-topology topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (list hide)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (unless total-remove
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (gnus-topic-insert-topic topic in-level)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (defun gnus-topic-insert-topic (topic &optional level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 "Insert TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (gnus-group-prepare-topics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (car gnus-group-list-mode) (cdr gnus-group-list-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 nil nil topic level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (defun gnus-topic-fold (&optional insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 "Remove/insert the current topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (let ((topic (gnus-group-topic-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (when topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (if (not (gnus-group-active-topic-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (gnus-topic-remove-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (or insert (not (gnus-topic-visible-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (let ((gnus-topic-topology gnus-topic-active-topology)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (gnus-topic-alist gnus-topic-active-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (gnus-group-list-mode (cons 5 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (gnus-topic-remove-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (or insert (not (gnus-topic-visible-p))) nil nil 9)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (defun gnus-group-topic-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 "Return non-nil if the current line is a topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (gnus-group-topic-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (defun gnus-topic-visible-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 "Return non-nil if the current topic is visible."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (get-text-property (gnus-point-at-bol) 'gnus-topic-visible))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (defun gnus-topic-insert-topic-line (name visiblep shownp level entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 &optional unread)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (let* ((visible (if visiblep "" "..."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (indentation (make-string (* gnus-topic-indent-level level) ? ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (total-number-of-articles unread)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (number-of-groups (length entries))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (active-topic (eq gnus-topic-alist gnus-topic-active-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;; Insert the text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (gnus-add-text-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (prog1 (1+ (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (eval gnus-topic-line-format-spec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (gnus-topic-remove-excess-properties)1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (list 'gnus-topic (intern name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 'gnus-topic-level level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 'gnus-topic-unread unread
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 'gnus-active active-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 'gnus-topic-visible visiblep))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (defun gnus-topic-previous-topic (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 "Return the previous topic on the same level as TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (let ((top (cddr (gnus-topic-find-topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (gnus-topic-parent-topic topic)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (unless (equal topic (caaar top))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (while (and top (not (equal (caaadr top) topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (setq top (cdr top)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (caaar top))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (defun gnus-topic-parent-topic (topic &optional topology)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 "Return the parent of TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (unless topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (setq topology gnus-topic-topology))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (let ((parent (car (pop topology)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 result found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (while (and topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (not (setq found (equal (caaar topology) topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (not (setq result (gnus-topic-parent-topic topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (car topology)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (setq topology (cdr topology)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (or result (and found parent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (defun gnus-topic-next-topic (topic &optional previous)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 "Return the next sibling of TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (let ((topology gnus-topic-topology)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (parentt (cddr (gnus-topic-find-topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (gnus-topic-parent-topic topic))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (while (and parentt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (not (equal (caaar parentt) topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (setq prev (caaar parentt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 parentt (cdr parentt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (if previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 prev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (caaadr parentt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (defun gnus-topic-find-topology (topic &optional topology level remove)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 "Return the topology of TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (unless topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (setq topology gnus-topic-topology)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (setq level 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (let ((top topology)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (if (equal (caar topology) topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (when remove
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (delq topology remove))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (cons level topology))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (setq topology (cdr topology))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (while (and topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (not (setq result (gnus-topic-find-topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 topic (car topology) (1+ level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (and remove top)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (setq topology (cdr topology)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (gnus-add-shutdown 'gnus-topic-close 'gnus)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (defun gnus-topic-close ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq gnus-topic-active-topology nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 gnus-topic-active-alist nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 gnus-topic-killed-topics nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 gnus-topic-tallied-groups nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 gnus-topology-checked-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
381
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (defun gnus-topic-check-topology ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 ;; The first time we set the topology to whatever we have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 ;; gotten here, which can be rather random.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (unless gnus-topic-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (gnus-topic-init-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (setq gnus-topology-checked-p t)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
389 ;; Go through the topic alist and make sure that all topics
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
390 ;; are in the topic topology.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (let ((topics (gnus-topic-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (alist gnus-topic-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 changed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (unless (member (caar alist) topics)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (nconc gnus-topic-topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (list (list (list (caar alist) 'visible))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (setq changed t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (setq alist (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (when changed
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
401 (gnus-topic-enter-dribble))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
402 ;; Conversely, go through the topology and make sure that all
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
403 ;; topologies have alists.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
404 (while topics
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
405 (unless (assoc (car topics) gnus-topic-alist)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
406 (push (list (car topics)) gnus-topic-alist))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
407 (pop topics)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
408 ;; Go through all living groups and make sure that
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
409 ;; they belong to some topic.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (let* ((tgroups (apply 'append (mapcar (lambda (entry) (cdr entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 gnus-topic-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (entry (assoc (caar gnus-topic-topology) gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (newsrc gnus-newsrc-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (while newsrc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (unless (member (setq group (gnus-info-group (pop newsrc))) tgroups)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
417 (setcdr entry (cons group (cdr entry))))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
418 ;; Go through all topics and make sure they contain only living groups.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
419 (let ((alist gnus-topic-alist)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
420 topic)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
421 (while (setq topic (pop alist))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
422 (while (cdr topic)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
423 (if (gnus-gethash (cadr topic) gnus-newsrc-hashtb)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
424 (setq topic (cdr topic))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
425 (setcdr topic (cddr topic)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (defvar gnus-tmp-topics nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (defun gnus-topic-list (&optional topology)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (unless topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (setq topology gnus-topic-topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 gnus-tmp-topics nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (push (caar topology) gnus-tmp-topics)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (mapcar 'gnus-topic-list (cdr topology))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 gnus-tmp-topics)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (defun gnus-topic-enter-dribble ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (gnus-dribble-enter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (format "(setq gnus-topic-topology '%S)" gnus-topic-topology)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (defun gnus-topic-articles-in-topic (entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (let ((total 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (while entries
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (when (numberp (setq number (car (pop entries))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (incf total number)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 total))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (defun gnus-group-topic (group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 "Return the topic GROUP is a member of."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (let ((alist gnus-topic-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (while alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (when (member group (cdar alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (setq out (caar alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 alist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (setq alist (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 out))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (defun gnus-topic-goto-topic (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 "Go to TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (when topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (gnus-goto-char (text-property-any (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 'gnus-topic (intern topic)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (defun gnus-group-parent-topic ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 "Return the name of the current topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (let ((result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (or (get-text-property (point) 'gnus-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (and (gnus-goto-char (previous-single-property-change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (point) 'gnus-topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (get-text-property (max (1- (point)) (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 'gnus-topic))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (when result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (symbol-name result))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (defun gnus-topic-update-topic ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 "Update all parent topics to the current group."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (when (and (eq major-mode 'gnus-group-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 gnus-topic-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (let ((group (gnus-group-group-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (when (and group (gnus-get-info group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (gnus-topic-goto-topic (gnus-group-parent-topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (gnus-topic-update-topic-line (gnus-group-topic-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (gnus-group-goto-group group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (gnus-group-position-point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (defun gnus-topic-goto-missing-group (group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 "Place point where GROUP is supposed to be inserted."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (let* ((topic (gnus-group-topic group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (groups (cdr (assoc topic gnus-topic-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (g (cdr (member group groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (unfound t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (while (and g unfound)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (when (gnus-group-goto-group (pop g))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (setq unfound nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (when unfound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (setq g (cdr (member group (reverse groups))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (while (and g unfound)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (when (gnus-group-goto-group (pop g))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (setq unfound nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (when unfound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (gnus-topic-goto-topic topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (forward-line 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (defun gnus-topic-update-topic-line (topic-name &optional reads)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (let* ((top (gnus-topic-find-topology topic-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (type (cadr top))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (children (cddr top))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (entries (gnus-topic-find-groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (car type) (car gnus-group-list-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (cdr gnus-group-list-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (parent (gnus-topic-parent-topic topic-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (all-entries entries)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (unread 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 old-unread entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (when (gnus-topic-goto-topic (car type))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ;; Tally all the groups that belong in this topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (if reads
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (setq unread (- (gnus-group-topic-unread) reads))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (while children
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (incf unread (gnus-topic-unread (caar (pop children)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (while (setq entry (pop entries))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (when (numberp (car entry))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (incf unread (car entry)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (setq old-unread (gnus-group-topic-unread))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;; Insert the topic line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (gnus-topic-insert-topic-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (car type) (gnus-topic-visible-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (not (eq (nth 2 type) 'hidden))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (gnus-group-topic-level) all-entries unread)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (gnus-delete-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (when parent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (gnus-topic-update-topic-line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 parent (- old-unread (gnus-group-topic-unread))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 unread))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (defun gnus-topic-grok-active (&optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 "Parse all active groups and create topic structures for them."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ;; First we make sure that we have really read the active file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (when (or force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (not gnus-topic-active-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (let (groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 ;; Get a list of all groups available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (mapatoms (lambda (g) (when (symbol-value g)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (push (symbol-name g) groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 gnus-active-hashtb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (setq groups (sort groups 'string<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 ;; Init the variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (setq gnus-topic-active-topology (list (list "" 'visible)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (setq gnus-topic-active-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 ;; Descend the top-level hierarchy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (gnus-topic-grok-active-1 gnus-topic-active-topology groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ;; Set the top-level topic names to something nice.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (setcar (car gnus-topic-active-topology) "Gnus active")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (setcar (car gnus-topic-active-alist) "Gnus active"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (defun gnus-topic-grok-active-1 (topology groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (let* ((name (caar topology))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (prefix (concat "^" (regexp-quote name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 tgroups ntopology group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (while (and groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (string-match prefix (setq group (car groups))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (if (not (string-match "\\." group (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 ;; There are no further hierarchies here, so we just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 ;; enter this group into the list belonging to this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 ;; topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (push (pop groups) tgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ;; New sub-hierarchy, so we add it to the topology.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (nconc topology (list (setq ntopology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (list (list (substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 group 0 (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 'invisible)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 ;; Descend the hierarchy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (setq groups (gnus-topic-grok-active-1 ntopology groups))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; We remove the trailing "." from the topic name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (setq name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (if (string-match "\\.$" name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (substring name 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 ;; Add this topic and its groups to the topic alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (push (cons name (nreverse tgroups)) gnus-topic-active-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (setcar (car topology) name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 ;; We return the rest of the groups that didn't belong
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ;; to this topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 groups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (defun gnus-group-active-topic-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 "Return whether the current active comes from the active topics."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (get-text-property (point) 'gnus-active)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 ;;; Topic mode, commands and keymap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (defvar gnus-topic-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (defvar gnus-group-topic-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (unless gnus-topic-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (setq gnus-topic-mode-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ;; Override certain group mode keys.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (gnus-define-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 gnus-topic-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 "=" gnus-topic-select-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 "\r" gnus-topic-select-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 " " gnus-topic-read-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 "\C-k" gnus-topic-kill-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 "\C-y" gnus-topic-yank-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 "\M-g" gnus-topic-get-new-news-this-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 "AT" gnus-topic-list-active
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 gnus-mouse-2 gnus-mouse-pick-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 ;; Define a new submap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (gnus-define-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (gnus-group-topic-map "T" gnus-group-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 "#" gnus-topic-mark-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 "\M-#" gnus-topic-unmark-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 "n" gnus-topic-create-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 "m" gnus-topic-move-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 "D" gnus-topic-remove-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 "c" gnus-topic-copy-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 "h" gnus-topic-hide-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 "s" gnus-topic-show-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 "M" gnus-topic-move-matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 "C" gnus-topic-copy-matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 "\C-i" gnus-topic-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 [tab] gnus-topic-indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 "r" gnus-topic-rename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 "\177" gnus-topic-delete))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (defun gnus-topic-make-menu-bar ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (unless (boundp 'gnus-topic-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (easy-menu-define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 gnus-topic-menu gnus-topic-mode-map ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 '("Topics"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ["Toggle topics" gnus-topic-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 ("Groups"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 ["Copy" gnus-topic-copy-group t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ["Move" gnus-topic-move-group t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 ["Remove" gnus-topic-remove-group t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 ["Copy matching" gnus-topic-copy-matching t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 ["Move matching" gnus-topic-move-matching t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ("Topics"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 ["Show" gnus-topic-show-topic t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ["Hide" gnus-topic-hide-topic t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ["Delete" gnus-topic-delete t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 ["Rename" gnus-topic-rename t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ["Create" gnus-topic-create-topic t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 ["Mark" gnus-topic-mark-topic t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 ["Indent" gnus-topic-indent t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 ["List active" gnus-topic-list-active t]))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 (defun gnus-topic-mode (&optional arg redisplay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 "Minor mode for topicsifying Gnus group buffers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (interactive (list current-prefix-arg t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (when (eq major-mode 'gnus-group-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (make-local-variable 'gnus-topic-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (setq gnus-topic-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (if (null arg) (not gnus-topic-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (> (prefix-numeric-value arg) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 ;; Infest Gnus with topics.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (when gnus-topic-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (when (and menu-bar-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (gnus-visual-p 'topic-menu 'menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (gnus-topic-make-menu-bar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (setq gnus-topic-line-format-spec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (gnus-parse-format gnus-topic-line-format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 gnus-topic-line-format-alist t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (unless (assq 'gnus-topic-mode minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (push '(gnus-topic-mode " Topic") minor-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (unless (assq 'gnus-topic-mode minor-mode-map-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (push (cons 'gnus-topic-mode gnus-topic-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 minor-mode-map-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (add-hook 'gnus-summary-exit-hook 'gnus-topic-update-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (add-hook 'gnus-group-catchup-group-hook 'gnus-topic-update-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (add-hook 'gnus-group-update-group-hook 'gnus-topic-update-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (make-local-variable 'gnus-group-prepare-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (setq gnus-group-prepare-function 'gnus-group-prepare-topics)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (make-local-variable 'gnus-group-goto-next-group-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (setq gnus-group-goto-next-group-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 'gnus-topic-goto-next-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (setq gnus-group-change-level-function 'gnus-topic-change-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (setq gnus-goto-missing-group-function 'gnus-topic-goto-missing-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (make-local-variable 'gnus-group-indentation-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (setq gnus-group-indentation-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 'gnus-topic-group-indentation)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
692 (gnus-make-local-hook 'gnus-check-bogus-groups-hook)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
693 (add-hook 'gnus-check-bogus-groups-hook 'gnus-topic-clean-alist)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (setq gnus-topology-checked-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 ;; We check the topology.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (when gnus-newsrc-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (gnus-topic-check-topology))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (run-hooks 'gnus-topic-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ;; Remove topic infestation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (unless gnus-topic-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (remove-hook 'gnus-summary-exit-hook 'gnus-topic-update-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (remove-hook 'gnus-group-change-level-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 'gnus-topic-change-level)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
704 (remove-hook 'gnus-check-bogus-groups-hook 'gnus-topic-clean-alist)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (setq gnus-group-prepare-function 'gnus-group-prepare-flat))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (when redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (gnus-group-list-groups))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (defun gnus-topic-select-group (&optional all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 "Select this newsgroup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 No article is selected automatically.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 If ALL is non-nil, already read articles become readable.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
713 If ALL is a number, fetch this number of articles.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
714
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
715 If performed over a topic line, toggle folding the topic."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (if (gnus-group-topic-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (let ((gnus-group-list-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (if all (cons (if (numberp all) all 7) t) gnus-group-list-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (gnus-topic-fold all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (gnus-group-select-group all)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (defun gnus-mouse-pick-topic (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 "Select the group or topic under the mouse pointer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (mouse-set-point e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (gnus-topic-read-group nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (defun gnus-topic-read-group (&optional all no-article group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 "Read news in this newsgroup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 If the prefix argument ALL is non-nil, already read articles become
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 readable. IF ALL is a number, fetch this number of articles. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 optional argument NO-ARTICLE is non-nil, no article will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 auto-selected upon group entry. If GROUP is non-nil, fetch that
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
735 group.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
736
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
737 If performed over a topic line, toggle folding the topic."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (if (gnus-group-topic-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (let ((gnus-group-list-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (if all (cons (if (numberp all) all 7) t) gnus-group-list-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (gnus-topic-fold all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (gnus-group-read-group all no-article group)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 (defun gnus-topic-create-topic (topic parent &optional previous full-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (read-string "New topic: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (gnus-group-parent-topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 ;; Check whether this topic already exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (when (gnus-topic-find-topology topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (error "Topic aleady exists"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (unless parent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (setq parent (caar gnus-topic-topology)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (let ((top (cdr (gnus-topic-find-topology parent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (full-topic (or full-topic `((,topic visible)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (unless top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (error "No such parent topic: %s" parent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (if previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (while (and (cdr top)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (not (equal (caaadr top) previous)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (setq top (cdr top)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (setcdr top (cons full-topic (cdr top))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (nconc top (list full-topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (unless (assoc topic gnus-topic-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (push (list topic) gnus-topic-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (gnus-topic-enter-dribble)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (gnus-group-list-groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (gnus-topic-goto-topic topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (defun gnus-topic-move-group (n topic &optional copyp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 "Move the next N groups to TOPIC.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 If COPYP, copy the groups instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (list current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (completing-read "Move to topic: " gnus-topic-alist nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (let ((groups (gnus-group-process-prefix n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (topicl (assoc topic gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (mapcar (lambda (g)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 (gnus-group-remove-mark g)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (when (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (setq entry (assoc (gnus-group-parent-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 (not copyp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (setcdr entry (gnus-delete-first g (cdr entry))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 (nconc topicl (list g)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (gnus-group-position-point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (gnus-topic-enter-dribble)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (gnus-group-list-groups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (defun gnus-topic-remove-group ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 "Remove the current group from the topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 (let ((topicl (assoc (gnus-group-parent-topic) gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (group (gnus-group-group-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (when (and topicl group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 (gnus-delete-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (gnus-delete-first group topicl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (gnus-group-position-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (defun gnus-topic-copy-group (n topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 "Copy the current group to a topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (list current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (completing-read "Copy to topic: " gnus-topic-alist nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (gnus-topic-move-group n topic t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (defun gnus-topic-group-indentation ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (make-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (* gnus-topic-indent-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (or (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (gnus-topic-goto-topic (gnus-group-parent-topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (gnus-group-topic-level)) 0)) ? ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
819 (defun gnus-topic-clean-alist ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
820 "Remove bogus groups from the topic alist."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
821 (let ((topic-alist gnus-topic-alist)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
822 result topic)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
823 (unless gnus-killed-hashtb
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
824 (gnus-make-hashtable-from-killed))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
825 (while (setq topic (pop topic-alist))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
826 (let ((topic-name (pop topic))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
827 group filtered-topic)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
828 (while (setq group (pop topic))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
829 (if (and (gnus-gethash group gnus-active-hashtb)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
830 (not (gnus-gethash group gnus-killed-hashtb)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
831 (push group filtered-topic)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
832 (push (cons topic-name (nreverse filtered-topic)) result)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
833 (setq gnus-topic-alist (nreverse result))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
834
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (defun gnus-topic-change-level (group level oldlevel)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 "Run when changing levels to enter/remove groups from topics."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (set-buffer gnus-group-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (when (and gnus-topic-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 gnus-topic-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (not gnus-topic-inhibit-change-level))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 ;; Remove the group from the topics.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (when (and (< oldlevel gnus-level-zombie)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (>= level gnus-level-zombie))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (let (alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (when (setq alist (assoc (gnus-group-parent-topic) gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (setcdr alist (gnus-delete-first group (cdr alist))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ;; If the group is subscribed. then we enter it into the topics.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (when (and (< level gnus-level-zombie)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (>= oldlevel gnus-level-zombie))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (let* ((prev (gnus-group-group-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (gnus-topic-inhibit-change-level t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (gnus-group-indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 (make-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (* gnus-topic-indent-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (or (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (gnus-topic-goto-topic (gnus-group-parent-topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (gnus-group-topic-level)) 0)) ? ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (yanked (list group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 alist talist end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 ;; Then we enter the yanked groups into the topics they belong
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 ;; to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (when (setq alist (assoc (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (gnus-group-parent-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (caar gnus-topic-topology)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (setq talist alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (when (stringp yanked)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (setq yanked (list yanked)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (if (not prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (nconc alist yanked)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (if (not (cdr alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (setcdr alist (nconc yanked (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (while (and (not end) (cdr alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (when (equal (cadr alist) prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (setcdr alist (nconc yanked (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (setq end t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (setq alist (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (unless end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (nconc talist yanked))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (gnus-topic-update-topic)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (defun gnus-topic-goto-next-group (group props)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 "Go to group or the next group after group."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (if (null group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (gnus-topic-goto-topic (symbol-name (cadr (memq 'gnus-topic props))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (if (gnus-group-goto-group group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 ;; The group is no longer visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (let* ((list (assoc (gnus-group-parent-topic) gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (after (cdr (member group (cdr list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 ;; First try to put point on a group after the current one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (while (and after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (not (gnus-group-goto-group (car after))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (setq after (cdr after)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 ;; Then try to put point on a group before point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (unless after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (setq after (cdr (member group (reverse (cdr list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (while (and after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (not (gnus-group-goto-group (car after))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (setq after (cdr after))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 ;; Finally, just put point on the topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (unless after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (gnus-topic-goto-topic (car list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (setq after nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (defun gnus-topic-kill-group (&optional n discard)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 "Kill the next N groups."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (if (gnus-group-topic-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (let ((topic (gnus-group-topic-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (gnus-topic-remove-topic nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (push (gnus-topic-find-topology topic nil nil gnus-topic-topology)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 gnus-topic-killed-topics))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (gnus-group-kill-group n discard)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (gnus-topic-update-topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (defun gnus-topic-yank-group (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 "Yank the last topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (if gnus-topic-killed-topics
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (let ((previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 (or (gnus-group-topic-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (gnus-topic-next-topic (gnus-group-parent-topic))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (item (cdr (pop gnus-topic-killed-topics))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (gnus-topic-create-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (caar item) (gnus-topic-parent-topic previous) previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (gnus-topic-goto-topic (caar item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (let* ((prev (gnus-group-group-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (gnus-topic-inhibit-change-level t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (gnus-group-indentation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (make-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (* gnus-topic-indent-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (or (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (gnus-topic-goto-topic (gnus-group-parent-topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (gnus-group-topic-level)) 0)) ? ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 yanked alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 ;; We first yank the groups the normal way...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (setq yanked (gnus-group-yank-group arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 ;; Then we enter the yanked groups into the topics they belong
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ;; to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (setq alist (assoc (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (gnus-group-parent-topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (when (stringp yanked)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (setq yanked (list yanked)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (if (not prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (nconc alist yanked)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (if (not (cdr alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (setcdr alist (nconc yanked (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (while (cdr alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (when (equal (cadr alist) prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (setcdr alist (nconc yanked (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (setq alist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (setq alist (cdr alist))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (gnus-topic-update-topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (defun gnus-topic-hide-topic ()
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
965 "Hide the current topic."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (when (gnus-group-parent-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (gnus-topic-goto-topic (gnus-group-parent-topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (gnus-topic-remove-topic nil nil 'hidden)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (defun gnus-topic-show-topic ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 "Show the hidden topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (when (gnus-group-topic-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (gnus-topic-remove-topic t nil 'shown)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (defun gnus-topic-mark-topic (topic &optional unmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 "Mark all groups in the topic with the process mark."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (interactive (list (gnus-group-parent-topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (let ((groups (gnus-topic-find-groups topic 9 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (while groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (funcall (if unmark 'gnus-group-remove-mark 'gnus-group-set-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (gnus-info-group (nth 2 (pop groups))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 (defun gnus-topic-unmark-topic (topic &optional unmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 "Remove the process mark from all groups in the topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (interactive (list (gnus-group-parent-topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (gnus-topic-mark-topic topic t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (defun gnus-topic-get-new-news-this-topic (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 "Check for new news in the current topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (if (not (gnus-group-topic-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (gnus-group-get-new-news-this-group n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (gnus-topic-mark-topic (gnus-group-topic-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (gnus-group-get-new-news-this-group)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (defun gnus-topic-move-matching (regexp topic &optional copyp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 "Move all groups that match REGEXP to some topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (let (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (nreverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (setq topic (completing-read "Move to topic: " gnus-topic-alist nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (read-string (format "Move to %s (regexp): " topic))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (gnus-group-mark-regexp regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (gnus-topic-move-group nil topic copyp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (defun gnus-topic-copy-matching (regexp topic &optional copyp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 "Copy all groups that match REGEXP to some topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (let (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (nreverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (setq topic (completing-read "Copy to topic: " gnus-topic-alist nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (read-string (format "Copy to %s (regexp): " topic))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (gnus-topic-move-matching regexp topic t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (defun gnus-topic-delete (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 "Delete a topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (interactive (list (gnus-group-topic-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (unless topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (error "No topic to be deleted"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (let ((entry (assoc topic gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 (when (cdr entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (error "Topic not empty"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 ;; Delete if visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (when (gnus-topic-goto-topic topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (gnus-delete-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 ;; Remove from alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (setq gnus-topic-alist (delq entry gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 ;; Remove from topology.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (gnus-topic-find-topology topic nil nil 'delete)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (defun gnus-topic-rename (old-name new-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 "Rename a topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (let ((topic (gnus-group-parent-topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (list topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (read-string (format "Rename %s to: " topic)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (let ((top (gnus-topic-find-topology old-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (entry (assoc old-name gnus-topic-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (when top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (setcar (cadr top) new-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (when entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (setcar entry new-name))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1049 (forward-line -1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (gnus-group-list-groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (defun gnus-topic-indent (&optional unindent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 "Indent a topic -- make it a sub-topic of the previous topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 If UNINDENT, remove an indentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (if unindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (gnus-topic-unindent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (let* ((topic (gnus-group-parent-topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (parent (gnus-topic-previous-topic topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (unless parent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (error "Nothing to indent %s into" topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (when topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (gnus-topic-goto-topic topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (gnus-topic-kill-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (gnus-topic-create-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 topic parent nil (cdr (pop gnus-topic-killed-topics)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (or (gnus-topic-goto-topic topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (gnus-topic-goto-topic parent))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (defun gnus-topic-unindent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 "Unindent a topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (let* ((topic (gnus-group-parent-topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (parent (gnus-topic-parent-topic topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (grandparent (gnus-topic-parent-topic parent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (unless grandparent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (error "Nothing to indent %s into" topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (when topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (gnus-topic-goto-topic topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 (gnus-topic-kill-group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (gnus-topic-create-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 topic grandparent (gnus-topic-next-topic parent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (cdr (pop gnus-topic-killed-topics)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 (gnus-topic-goto-topic topic))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (defun gnus-topic-list-active (&optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 "List all groups that Gnus knows about in a topicsified fashion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 If FORCE, always re-read the active file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (when force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (gnus-get-killed-groups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (gnus-topic-grok-active force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (let ((gnus-topic-topology gnus-topic-active-topology)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (gnus-topic-alist gnus-topic-active-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 gnus-killed-list gnus-zombie-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (gnus-group-list-groups 9 nil 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (provide 'gnus-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 ;;; gnus-topic.el ends here