annotate lisp/gnus/gnus-topic.el @ 118:7d55a9ba150c r20-1b11

Import from CVS: tag r20-1b11
author cvs
date Mon, 13 Aug 2007 09:24:17 +0200
parents fe104dbd9147
children cca96a509cfe
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
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
2 ;; Copyright (C) 1995,96,97 Free Software Foundation, Inc.
0
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)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
30 (require 'gnus-group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
31 (require 'gnus-start)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
32
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
33 (defgroup gnus-topic nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
34 "Group topics."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
35 :group 'gnus-group)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defvar gnus-topic-mode nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "Minor mode for Gnus group buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
40 (defcustom gnus-topic-mode-hook nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
41 "Hook run in topic mode buffers."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
42 :type 'hook
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
43 :group 'gnus-topic)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
45 (defcustom gnus-topic-line-format "%i[ %(%{%n%}%) -- %A ]%v\n"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 "Format of topic lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 It works along the same lines as a normal formatting string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 with some simple extensions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 %i Indentation based on topic level.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 %n Topic name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 %v Nothing if the topic is visible, \"...\" otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 %g Number of groups in the topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 %a Number of unread articles in the groups in the topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 %A Number of unread articles in the groups in the topic and its subtopics.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
56 "
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
57 :type 'string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
58 :group 'gnus-topic)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
60 (defcustom gnus-topic-indent-level 2
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
61 "*How much each subtopic should be indented."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
62 :type 'integer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
63 :group 'gnus-topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
64
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
65 (defcustom gnus-topic-display-empty-topics t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
66 "*If non-nil, display the topic lines even of topics that have no unread articles."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
67 :type 'boolean
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
68 :group 'gnus-topic)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; Internal variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (defvar gnus-topic-active-topology nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (defvar gnus-topic-active-alist nil)
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-topology-checked-p nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 "Whether the topology has been checked in this session.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (defvar gnus-topic-killed-topics nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defvar gnus-topic-inhibit-change-level nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (defvar gnus-topic-tallied-groups nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (defconst gnus-topic-line-format-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 `((?n name ?s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (?v visible ?s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (?i indentation ?s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (?g number-of-groups ?d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (?a (gnus-topic-articles-in-topic entries) ?d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (?A total-number-of-articles ?d)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (?l level ?d)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defvar gnus-topic-line-format-spec nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
93 ;;; Utility functions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (defun gnus-group-topic-name ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 "The name of the topic on the current line."
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
97 (let ((topic (get-text-property (gnus-point-at-bol) 'gnus-topic)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (and topic (symbol-name topic))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defun gnus-group-topic-level ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 "The level of the topic on the current line."
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
102 (get-text-property (gnus-point-at-bol) 'gnus-topic-level))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (defun gnus-group-topic-unread ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 "The number of unread articles in topic on the current line."
18
d95e72db5c07 Import from CVS: tag r19-15b92
cvs
parents: 16
diff changeset
106 (get-text-property (gnus-point-at-bol) 'gnus-topic-unread))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defun gnus-topic-unread (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "Return the number of unread articles in TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (or (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (and (gnus-topic-goto-topic topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (gnus-group-topic-unread)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
115 (defun gnus-group-topic-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
116 "Return non-nil if the current line is a topic."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
117 (gnus-group-topic-name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
119 (defun gnus-topic-visible-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
120 "Return non-nil if the current topic is visible."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
121 (get-text-property (gnus-point-at-bol) 'gnus-topic-visible))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
123 (defun gnus-topic-articles-in-topic (entries)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
124 (let ((total 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
125 number)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
126 (while entries
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
127 (when (numberp (setq number (car (pop entries))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
128 (incf total number)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
129 total))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
131 (defun gnus-group-topic (group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
132 "Return the topic GROUP is a member of."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
133 (let ((alist gnus-topic-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
134 out)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
135 (while alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
136 (when (member group (cdar alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
137 (setq out (caar alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
138 alist nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
139 (setq alist (cdr alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
140 out))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
142 (defun gnus-group-parent-topic (group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
143 "Return the topic GROUP is member of by looking at the group buffer."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
144 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
145 (set-buffer gnus-group-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
146 (if (gnus-group-goto-group group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
147 (gnus-current-topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
148 (gnus-group-topic group))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
149
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
150 (defun gnus-topic-goto-topic (topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
151 "Go to TOPIC."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
152 (when topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
153 (gnus-goto-char (text-property-any (point-min) (point-max)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
154 'gnus-topic (intern topic)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
156 (defun gnus-current-topic ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
157 "Return the name of the current topic."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
158 (let ((result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
159 (or (get-text-property (point) 'gnus-topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
160 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
161 (and (gnus-goto-char (previous-single-property-change
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
162 (point) 'gnus-topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
163 (get-text-property (max (1- (point)) (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
164 'gnus-topic))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
165 (when result
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
166 (symbol-name result))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
167
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
168 (defun gnus-current-topics ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
169 "Return a list of all current topics, lowest in hierarchy first."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
170 (let ((topic (gnus-current-topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
171 topics)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
172 (while topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
173 (push topic topics)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
174 (setq topic (gnus-topic-parent-topic topic)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
175 (nreverse topics)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
176
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
177 (defun gnus-group-active-topic-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
178 "Say whether the current topic comes from the active topics."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
179 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
180 (beginning-of-line)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
181 (get-text-property (point) 'gnus-active)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (defun gnus-topic-find-groups (topic &optional level all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 "Return entries for all visible groups in TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (let ((groups (cdr (assoc topic gnus-topic-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 info clevel unread group lowest params visible-groups entry active)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (setq lowest (or lowest 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (setq level (or level 7))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; We go through the newsrc to look for matches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (while groups
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
191 (when (setq group (pop groups))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
192 (setq entry (gnus-gethash group gnus-newsrc-hashtb)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
193 info (nth 2 entry)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
194 params (gnus-info-params info)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
195 active (gnus-active group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
196 unread (or (car entry)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
197 (and (not (equal group "dummy.group"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
198 active
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
199 (- (1+ (cdr active)) (car active))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
200 clevel (or (gnus-info-level info)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
201 (if (member group gnus-zombie-list) 8 9))))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
202 (and
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 unread ; nil means that the group is dead.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
204 (<= clevel level)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (>= clevel lowest) ; Is inside the level we want.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (or all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (if (eq unread t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 gnus-group-list-inactive-groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (> unread 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (and gnus-list-groups-with-ticked-articles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (cdr (assq 'tick (gnus-info-marks info))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ; Has right readedness.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;; Check for permanent visibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (and gnus-permanently-visible-groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (string-match gnus-permanently-visible-groups group))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (memq 'visible params)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (cdr (assq 'visible params)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;; Add this group to the list of visible groups.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (push (or entry group) visible-groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (nreverse visible-groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (defun gnus-topic-previous-topic (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 "Return the previous topic on the same level as TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (let ((top (cddr (gnus-topic-find-topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (gnus-topic-parent-topic topic)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (unless (equal topic (caaar top))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (while (and top (not (equal (caaadr top) topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (setq top (cdr top)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (caaar top))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (defun gnus-topic-parent-topic (topic &optional topology)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 "Return the parent of TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (unless topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (setq topology gnus-topic-topology))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (let ((parent (car (pop topology)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 result found)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (while (and topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (not (setq found (equal (caaar topology) topic)))
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
239 (not (setq result (gnus-topic-parent-topic
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
240 topic (car topology)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (setq topology (cdr topology)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (or result (and found parent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (defun gnus-topic-next-topic (topic &optional previous)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 "Return the next sibling of TOPIC."
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
246 (let ((parentt (cddr (gnus-topic-find-topology
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (gnus-topic-parent-topic topic))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (while (and parentt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (not (equal (caaar parentt) topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (setq prev (caaar parentt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 parentt (cdr parentt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (if previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 prev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (caaadr parentt))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
257 (defun gnus-topic-forward-topic (num)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
258 "Go to the next topic on the same level as the current one."
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
259 (let* ((topic (gnus-current-topic))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
260 (way (if (< num 0) 'gnus-topic-previous-topic
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
261 'gnus-topic-next-topic))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
262 (num (abs num)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
263 (while (and (not (zerop num))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
264 (setq topic (funcall way topic)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
265 (when (gnus-topic-goto-topic topic)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
266 (decf num)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
267 (unless (zerop num)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
268 (goto-char (point-max)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
269 num))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
270
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (defun gnus-topic-find-topology (topic &optional topology level remove)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 "Return the topology of TOPIC."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (unless topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (setq topology gnus-topic-topology)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (setq level 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (let ((top topology)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (if (equal (caar topology) topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (when remove
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (delq topology remove))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (cons level topology))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (setq topology (cdr topology))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (while (and topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (not (setq result (gnus-topic-find-topology
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 topic (car topology) (1+ level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (and remove top)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (setq topology (cdr topology)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 result)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
291 (defvar gnus-tmp-topics nil)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
292 (defun gnus-topic-list (&optional topology)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
293 "Return a list of all topics in the topology."
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
294 (unless topology
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
295 (setq topology gnus-topic-topology
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
296 gnus-tmp-topics nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
297 (push (caar topology) gnus-tmp-topics)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
298 (mapcar 'gnus-topic-list (cdr topology))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
299 gnus-tmp-topics)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
301 ;;; Topic parameter jazz
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
302
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
303 (defun gnus-topic-parameters (topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
304 "Return the parameters for TOPIC."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
305 (let ((top (gnus-topic-find-topology topic)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
306 (when top
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
307 (nth 3 (cadr top)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
308
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
309 (defun gnus-topic-set-parameters (topic parameters)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
310 "Set the topic parameters of TOPIC to PARAMETERS."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
311 (let ((top (gnus-topic-find-topology topic)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
312 (unless top
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
313 (error "No such topic: %s" topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
314 ;; We may have to extend if there is no parameters here
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
315 ;; to begin with.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
316 (unless (nthcdr 2 (cadr top))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
317 (nconc (cadr top) (list nil)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
318 (unless (nthcdr 3 (cadr top))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
319 (nconc (cadr top) (list nil)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
320 (setcar (nthcdr 3 (cadr top)) parameters)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
321 (gnus-dribble-enter
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
322 (format "(gnus-topic-set-parameters %S '%S)" topic parameters))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
323
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
324 (defun gnus-group-topic-parameters (group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
325 "Compute the group parameters for GROUP taking into account inheritance from topics."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
326 (let ((params-list (list (gnus-group-get-parameter group)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
327 topics params param out)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
328 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
329 (gnus-group-goto-group group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
330 (setq topics (gnus-current-topics))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
331 (while topics
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
332 (push (gnus-topic-parameters (pop topics)) params-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
333 ;; We probably have lots of nil elements here, so
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
334 ;; we remove them. Probably faster than doing this "properly".
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
335 (setq params-list (delq nil params-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
336 ;; Now we have all the parameters, so we go through them
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
337 ;; and do inheritance in the obvious way.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
338 (while (setq params (pop params-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
339 (while (setq param (pop params))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
340 (when (atom param)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
341 (setq param (cons param t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
342 ;; Override any old versions of this param.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
343 (setq out (delq (assq (car param) out) out))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
344 (push param out)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
345 ;; Return the resulting parameter list.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
346 out)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
347
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
348 ;;; General utility functions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
349
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
350 (defun gnus-topic-enter-dribble ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
351 (gnus-dribble-enter
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
352 (format "(setq gnus-topic-topology '%S)" gnus-topic-topology)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
354 ;;; Generating group buffers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
355
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
356 (defun gnus-group-prepare-topics (level &optional all lowest regexp list-topic topic-level)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
357 "List all newsgroups with unread articles of level LEVEL or lower, and
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
358 use the `gnus-group-topics' to sort the groups.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
359 If ALL is non-nil, list groups that have no unread articles.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
360 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
361 (set-buffer gnus-group-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
362 (let ((buffer-read-only nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
363 (lowest (or lowest 1)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
364
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
365 (setq gnus-topic-tallied-groups nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
366
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
367 (when (or (not gnus-topic-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
368 (not gnus-topology-checked-p))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
369 (gnus-topic-check-topology))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
370
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
371 (unless list-topic
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
372 (erase-buffer))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
373
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
374 ;; List dead groups?
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
375 (when (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
376 (gnus-group-prepare-flat-list-dead
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
377 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
378 gnus-level-zombie ?Z
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
379 regexp))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
380
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
381 (when (and (>= level gnus-level-killed) (<= lowest gnus-level-killed))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
382 (gnus-group-prepare-flat-list-dead
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
383 (setq gnus-killed-list (sort gnus-killed-list 'string<))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
384 gnus-level-killed ?K
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
385 regexp))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
386
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
387 ;; Use topics.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
388 (prog1
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
389 (when (< lowest gnus-level-zombie)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
390 (if list-topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
391 (let ((top (gnus-topic-find-topology list-topic)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
392 (gnus-topic-prepare-topic (cdr top) (car top)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
393 (or topic-level level) all))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
394 (gnus-topic-prepare-topic gnus-topic-topology 0
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
395 (or topic-level level) all)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
396
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
397 (gnus-group-set-mode-line)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
398 (setq gnus-group-list-mode (cons level all))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
399 (run-hooks 'gnus-group-prepare-hook))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
400
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
401 (defun gnus-topic-prepare-topic (topicl level &optional list-level all silent)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
402 "Insert TOPIC into the group buffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
403 If SILENT, don't insert anything. Return the number of unread
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
404 articles in the topic and its subtopics."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
405 (let* ((type (pop topicl))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
406 (entries (gnus-topic-find-groups (car type) list-level all))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
407 (visiblep (and (eq (nth 1 type) 'visible) (not silent)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
408 (gnus-group-indentation
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
409 (make-string (* gnus-topic-indent-level level) ? ))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
410 (beg (progn (beginning-of-line) (point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
411 (topicl (reverse topicl))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
412 (all-entries entries)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
413 (point-max (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
414 (unread 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
415 (topic (car type))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
416 info entry end active tick)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
417 ;; Insert any sub-topics.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
418 (while topicl
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
419 (incf unread
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
420 (gnus-topic-prepare-topic
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
421 (pop topicl) (1+ level) list-level all
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
422 (not visiblep))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
423 (setq end (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
424 (goto-char beg)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
425 ;; Insert all the groups that belong in this topic.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
426 (while (setq entry (pop entries))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
427 (when visiblep
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
428 (if (stringp entry)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
429 ;; Dead groups.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
430 (gnus-group-insert-group-line
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
431 entry (if (member entry gnus-zombie-list) 8 9)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
432 nil (- (1+ (cdr (setq active (gnus-active entry))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
433 (car active))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
434 nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
435 ;; Living groups.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
436 (when (setq info (nth 2 entry))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
437 (gnus-group-insert-group-line
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
438 (gnus-info-group info)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
439 (gnus-info-level info) (gnus-info-marks info)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
440 (car entry) (gnus-info-method info)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
441 (when (and (listp entry)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
442 (numberp (car entry))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
443 (not (member (gnus-info-group (setq info (nth 2 entry)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
444 gnus-topic-tallied-groups)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
445 (push (gnus-info-group info) gnus-topic-tallied-groups)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
446 (incf unread (car entry)))
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
447 (when (listp entry)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
448 (setq tick t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
449 (goto-char beg)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
450 ;; Insert the topic line.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
451 (when (and (not silent)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
452 (or gnus-topic-display-empty-topics ;We want empty topics
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
453 (not (zerop unread)) ;Non-empty
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
454 tick ;Ticked articles
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
455 (/= point-max (point-max)))) ;Unactivated groups
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
456 (gnus-extent-start-open (point))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
457 (gnus-topic-insert-topic-line
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
458 (car type) visiblep
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
459 (not (eq (nth 2 type) 'hidden))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
460 level all-entries unread))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
461 (goto-char end)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
462 unread))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
464 (defun gnus-topic-remove-topic (&optional insert total-remove hide in-level)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
465 "Remove the current topic."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
466 (let ((topic (gnus-group-topic-name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
467 (level (gnus-group-topic-level))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
468 (beg (progn (beginning-of-line) (point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
469 buffer-read-only)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
470 (when topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
471 (while (and (zerop (forward-line 1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
472 (> (or (gnus-group-topic-level) (1+ level)) level)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
473 (delete-region beg (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
474 ;; Do the change in this rather odd manner because it has been
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
475 ;; reported that some topics share parts of some lists, for some
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
476 ;; reason. I have been unable to determine why this is the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
477 ;; case, but this hack seems to take care of things.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
478 (let ((data (cadr (gnus-topic-find-topology topic))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
479 (setcdr data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
480 (list (if insert 'visible 'invisible)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
481 (if hide 'hide nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
482 (cadddr data))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
483 (if total-remove
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
484 (setq gnus-topic-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
485 (delq (assoc topic gnus-topic-alist) gnus-topic-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
486 (gnus-topic-insert-topic topic in-level)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
487
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
488 (defun gnus-topic-insert-topic (topic &optional level)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
489 "Insert TOPIC."
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
490 (gnus-group-prepare-topics
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
491 (car gnus-group-list-mode) (cdr gnus-group-list-mode)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
492 nil nil topic level))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
493
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
494 (defun gnus-topic-fold (&optional insert)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
495 "Remove/insert the current topic."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
496 (let ((topic (gnus-group-topic-name)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
497 (when topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
498 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
499 (if (not (gnus-group-active-topic-p))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
500 (gnus-topic-remove-topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
501 (or insert (not (gnus-topic-visible-p))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
502 (let ((gnus-topic-topology gnus-topic-active-topology)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
503 (gnus-topic-alist gnus-topic-active-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
504 (gnus-group-list-mode (cons 5 t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
505 (gnus-topic-remove-topic
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
506 (or insert (not (gnus-topic-visible-p))) nil nil 9)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
507 (gnus-topic-enter-dribble)))))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
508
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
509 (defun gnus-topic-insert-topic-line (name visiblep shownp level entries
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
510 &optional unread)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
511 (let* ((visible (if visiblep "" "..."))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
512 (indentation (make-string (* gnus-topic-indent-level level) ? ))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
513 (total-number-of-articles unread)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
514 (number-of-groups (length entries))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
515 (active-topic (eq gnus-topic-alist gnus-topic-active-alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
516 (beginning-of-line)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
517 ;; Insert the text.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
518 (gnus-add-text-properties
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
519 (point)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
520 (prog1 (1+ (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
521 (eval gnus-topic-line-format-spec)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
522 (gnus-topic-remove-excess-properties)1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
523 (list 'gnus-topic (intern name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
524 'gnus-topic-level level
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
525 'gnus-topic-unread unread
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
526 'gnus-active active-topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
527 'gnus-topic-visible visiblep))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
528
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
529 (defun gnus-topic-update-topics-containing-group (group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
530 "Update all topics that have GROUP as a member."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
531 (when (and (eq major-mode 'gnus-group-mode)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
532 gnus-topic-mode)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
533 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
534 (let ((alist gnus-topic-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
535 ;; This is probably not entirely correct. If a topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
536 ;; isn't shown, then it's not updated. But the updating
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
537 ;; should be performed in any case, since the topic's
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
538 ;; parent should be updated. Pfft.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
539 (while alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
540 (when (and (member group (cdar alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
541 (gnus-topic-goto-topic (caar alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
542 (gnus-topic-update-topic-line (caar alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
543 (pop alist))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
544
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
545 (defun gnus-topic-update-topic ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
546 "Update all parent topics to the current group."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
547 (when (and (eq major-mode 'gnus-group-mode)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
548 gnus-topic-mode)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
549 (let ((group (gnus-group-group-name))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
550 (buffer-read-only nil))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
551 (when (and group
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
552 (gnus-get-info group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
553 (gnus-topic-goto-topic (gnus-current-topic)))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
554 (gnus-topic-update-topic-line (gnus-group-topic-name))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
555 (gnus-group-goto-group group)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
556 (gnus-group-position-point)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
558 (defun gnus-topic-goto-missing-group (group)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
559 "Place point where GROUP is supposed to be inserted."
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
560 (let* ((topic (gnus-group-topic group))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
561 (groups (cdr (assoc topic gnus-topic-alist)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
562 (g (cdr (member group groups)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
563 (unfound t))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
564 ;; Try to jump to a visible group.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
565 (while (and g (not (gnus-group-goto-group (car g) t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
566 (pop g))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
567 ;; It wasn't visible, so we try to see where to insert it.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
568 (when (not g)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
569 (setq g (cdr (member group (reverse groups))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
570 (while (and g unfound)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
571 (when (gnus-group-goto-group (pop g) t)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
572 (forward-line 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
573 (setq unfound nil)))
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
574 (when (and unfound
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
575 (not (gnus-topic-goto-missing-topic topic)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
576 (gnus-topic-insert-topic-line
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
577 topic t t (car (gnus-topic-find-topology topic)) nil 0)))))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
578
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
579 (defun gnus-topic-goto-missing-topic (topic)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
580 (if (gnus-topic-goto-topic topic)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
581 (forward-line 1)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
582 ;; Topic not displayed.
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
583 (let* ((top (gnus-topic-find-topology
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
584 (gnus-topic-parent-topic topic)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
585 (tp (reverse (cddr top))))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
586 (while (not (equal (caaar tp) topic))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
587 (setq tp (cdr tp)))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
588 (pop tp)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
589 (while (and tp
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
590 (not (gnus-topic-goto-topic (caaar tp))))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
591 (pop tp))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
592 (if tp
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
593 (gnus-topic-forward-topic 1)
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
594 (gnus-topic-goto-missing-topic (caadr top))))
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 110
diff changeset
595 nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
597 (defun gnus-topic-update-topic-line (topic-name &optional reads)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
598 (let* ((top (gnus-topic-find-topology topic-name))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
599 (type (cadr top))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
600 (children (cddr top))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
601 (entries (gnus-topic-find-groups
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
602 (car type) (car gnus-group-list-mode)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
603 (cdr gnus-group-list-mode)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
604 (parent (gnus-topic-parent-topic topic-name))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
605 (all-entries entries)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
606 (unread 0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
607 old-unread entry)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
608 (when (gnus-topic-goto-topic (car type))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
609 ;; Tally all the groups that belong in this topic.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
610 (if reads
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
611 (setq unread (- (gnus-group-topic-unread) reads))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
612 (while children
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
613 (incf unread (gnus-topic-unread (caar (pop children)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
614 (while (setq entry (pop entries))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
615 (when (numberp (car entry))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
616 (incf unread (car entry)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
617 (setq old-unread (gnus-group-topic-unread))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
618 ;; Insert the topic line.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
619 (gnus-topic-insert-topic-line
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
620 (car type) (gnus-topic-visible-p)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
621 (not (eq (nth 2 type) 'hidden))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
622 (gnus-group-topic-level) all-entries unread)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
623 (gnus-delete-line))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
624 (when parent
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
625 (forward-line -1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
626 (gnus-topic-update-topic-line
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
627 parent (- old-unread (gnus-group-topic-unread))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 32
diff changeset
628 unread))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
630 (defun gnus-topic-group-indentation ()
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
631 (make-string
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
632 (* gnus-topic-indent-level
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
633 (or (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
634 (forward-line -1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
635 (gnus-topic-goto-topic (gnus-current-topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
636 (gnus-group-topic-level))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
637 0))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
638 ? ))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
639
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
640 ;;; Initialization
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
641
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
642 (gnus-add-shutdown 'gnus-topic-close 'gnus)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
643
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
644 (defun gnus-topic-close ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
645 (setq gnus-topic-active-topology nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
646 gnus-topic-active-alist nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
647 gnus-topic-killed-topics nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
648 gnus-topic-tallied-groups nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
649 gnus-topology-checked-p nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
650
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
651 (defun gnus-topic-check-topology ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
652 ;; The first time we set the topology to whatever we have
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
653 ;; gotten here, which can be rather random.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
654 (unless gnus-topic-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
655 (gnus-topic-init-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
656
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
657 (setq gnus-topology-checked-p t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
658 ;; Go through the topic alist and make sure that all topics
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
659 ;; are in the topic topology.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
660 (let ((topics (gnus-topic-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
661 (alist gnus-topic-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
662 changed)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
663 (while alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
664 (unless (member (caar alist) topics)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
665 (nconc gnus-topic-topology
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
666 (list (list (list (caar alist) 'visible))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
667 (setq changed t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
668 (setq alist (cdr alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
669 (when changed
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
670 (gnus-topic-enter-dribble))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
671 ;; Conversely, go through the topology and make sure that all
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
672 ;; topologies have alists.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
673 (while topics
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
674 (unless (assoc (car topics) gnus-topic-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
675 (push (list (car topics)) gnus-topic-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
676 (pop topics)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
677 ;; Go through all living groups and make sure that
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
678 ;; they belong to some topic.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
679 (let* ((tgroups (apply 'append (mapcar (lambda (entry) (cdr entry))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
680 gnus-topic-alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
681 (entry (assoc (caar gnus-topic-topology) gnus-topic-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
682 (newsrc (cdr gnus-newsrc-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
683 group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
684 (while newsrc
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
685 (unless (member (setq group (gnus-info-group (pop newsrc))) tgroups)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
686 (setcdr entry (cons group (cdr entry))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
687 ;; Go through all topics and make sure they contain only living groups.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
688 (let ((alist gnus-topic-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
689 topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
690 (while (setq topic (pop alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
691 (while (cdr topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
692 (if (gnus-gethash (cadr topic) gnus-newsrc-hashtb)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
693 (setq topic (cdr topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
694 (setcdr topic (cddr topic)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
695
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
696 (defun gnus-topic-init-alist ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
697 "Initialize the topic structures."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
698 (setq gnus-topic-topology
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
699 (cons (list "Gnus" 'visible)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
700 (mapcar (lambda (topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
701 (list (list (car topic) 'visible)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
702 '(("misc")))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
703 (setq gnus-topic-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
704 (list (cons "misc"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
705 (mapcar (lambda (info) (gnus-info-group info))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
706 (cdr gnus-newsrc-alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
707 (list "Gnus")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
708 (gnus-topic-enter-dribble))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
709
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
710 ;;; Maintenance
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
711
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
712 (defun gnus-topic-clean-alist ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
713 "Remove bogus groups from the topic alist."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
714 (let ((topic-alist gnus-topic-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
715 result topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
716 (unless gnus-killed-hashtb
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
717 (gnus-make-hashtable-from-killed))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
718 (while (setq topic (pop topic-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
719 (let ((topic-name (pop topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
720 group filtered-topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
721 (while (setq group (pop topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
722 (when (and (or (gnus-gethash group gnus-active-hashtb)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
723 (gnus-info-method (gnus-get-info group)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
724 (not (gnus-gethash group gnus-killed-hashtb)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
725 (push group filtered-topic)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
726 (push (cons topic-name (nreverse filtered-topic)) result)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
727 (setq gnus-topic-alist (nreverse result))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
728
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
729 (defun gnus-topic-change-level (group level oldlevel)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
730 "Run when changing levels to enter/remove groups from topics."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
731 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
732 (set-buffer gnus-group-buffer)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
733 (when (and gnus-topic-mode
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
734 gnus-topic-alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
735 (not gnus-topic-inhibit-change-level))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
736 ;; Remove the group from the topics.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
737 (when (and (< oldlevel gnus-level-zombie)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
738 (>= level gnus-level-zombie))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
739 (let (alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
740 (forward-line -1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
741 (when (setq alist (assoc (gnus-current-topic) gnus-topic-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
742 (setcdr alist (gnus-delete-first group (cdr alist))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
743 ;; If the group is subscribed we enter it into the topics.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
744 (when (and (< level gnus-level-zombie)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
745 (>= oldlevel gnus-level-zombie))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
746 (let* ((prev (gnus-group-group-name))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
747 (gnus-topic-inhibit-change-level t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
748 (gnus-group-indentation
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
749 (make-string
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
750 (* gnus-topic-indent-level
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
751 (or (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
752 (gnus-topic-goto-topic (gnus-current-topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
753 (gnus-group-topic-level))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
754 0))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
755 ? ))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
756 (yanked (list group))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
757 alist talist end)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
758 ;; Then we enter the yanked groups into the topics they belong
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
759 ;; to.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
760 (when (setq alist (assoc (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
761 (forward-line -1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
762 (or
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
763 (gnus-current-topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
764 (caar gnus-topic-topology)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
765 gnus-topic-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
766 (setq talist alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
767 (when (stringp yanked)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
768 (setq yanked (list yanked)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
769 (if (not prev)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
770 (nconc alist yanked)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
771 (if (not (cdr alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
772 (setcdr alist (nconc yanked (cdr alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
773 (while (and (not end) (cdr alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
774 (when (equal (cadr alist) prev)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
775 (setcdr alist (nconc yanked (cdr alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
776 (setq end t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
777 (setq alist (cdr alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
778 (unless end
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
779 (nconc talist yanked))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
780 (gnus-topic-update-topic)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
781
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
782 (defun gnus-topic-goto-next-group (group props)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
783 "Go to group or the next group after group."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
784 (if (not group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
785 (if (not (memq 'gnus-topic props))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
786 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
787 (gnus-topic-goto-topic (symbol-name (cadr (memq 'gnus-topic props)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
788 (if (gnus-group-goto-group group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
789 t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
790 ;; The group is no longer visible.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
791 (let* ((list (assoc (gnus-group-topic group) gnus-topic-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
792 (after (cdr (member group (cdr list)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
793 ;; First try to put point on a group after the current one.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
794 (while (and after
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
795 (not (gnus-group-goto-group (car after))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
796 (setq after (cdr after)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
797 ;; Then try to put point on a group before point.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
798 (unless after
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
799 (setq after (cdr (member group (reverse (cdr list)))))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
800 (while (and after
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
801 (not (gnus-group-goto-group (car after))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
802 (setq after (cdr after))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
803 ;; Finally, just put point on the topic.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
804 (if (not (car list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
805 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
806 (unless after
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
807 (gnus-topic-goto-topic (car list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
808 (setq after nil)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
809 t))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
810
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
811 ;;; Topic-active functions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
812
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (defun gnus-topic-grok-active (&optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 "Parse all active groups and create topic structures for them."
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
815 ;; First we make sure that we have really read the active file.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (when (or force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (not gnus-topic-active-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (let (groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ;; Get a list of all groups available.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (mapatoms (lambda (g) (when (symbol-value g)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (push (symbol-name g) groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 gnus-active-hashtb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (setq groups (sort groups 'string<))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 ;; Init the variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (setq gnus-topic-active-topology (list (list "" 'visible)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (setq gnus-topic-active-alist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 ;; Descend the top-level hierarchy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (gnus-topic-grok-active-1 gnus-topic-active-topology groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 ;; Set the top-level topic names to something nice.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (setcar (car gnus-topic-active-topology) "Gnus active")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (setcar (car gnus-topic-active-alist) "Gnus active"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (defun gnus-topic-grok-active-1 (topology groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (let* ((name (caar topology))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (prefix (concat "^" (regexp-quote name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 tgroups ntopology group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (while (and groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (string-match prefix (setq group (car groups))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (if (not (string-match "\\." group (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 ;; There are no further hierarchies here, so we just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 ;; enter this group into the list belonging to this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 ;; topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (push (pop groups) tgroups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 ;; New sub-hierarchy, so we add it to the topology.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
845 (nconc topology (list (setq ntopology
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
846 (list (list (substring
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 group 0 (match-end 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 'invisible)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ;; Descend the hierarchy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (setq groups (gnus-topic-grok-active-1 ntopology groups))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 ;; We remove the trailing "." from the topic name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (setq name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (if (string-match "\\.$" name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 (substring name 0 (match-beginning 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ;; Add this topic and its groups to the topic alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (push (cons name (nreverse tgroups)) gnus-topic-active-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (setcar (car topology) name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 ;; We return the rest of the groups that didn't belong
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 ;; to this topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 groups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 ;;; Topic mode, commands and keymap.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (defvar gnus-topic-mode-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (defvar gnus-group-topic-map nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (unless gnus-topic-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (setq gnus-topic-mode-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 ;; Override certain group mode keys.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
872 (gnus-define-keys gnus-topic-mode-map
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
873 "=" gnus-topic-select-group
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
874 "\r" gnus-topic-select-group
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
875 " " gnus-topic-read-group
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
876 "\C-k" gnus-topic-kill-group
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
877 "\C-y" gnus-topic-yank-group
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
878 "\M-g" gnus-topic-get-new-news-this-topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
879 "AT" gnus-topic-list-active
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
880 "Gp" gnus-topic-edit-parameters
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
881 "#" gnus-topic-mark-topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
882 "\M-#" gnus-topic-unmark-topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
883 gnus-mouse-2 gnus-mouse-pick-topic)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 ;; Define a new submap.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
886 (gnus-define-keys (gnus-group-topic-map "T" gnus-group-mode-map)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
887 "#" gnus-topic-mark-topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
888 "\M-#" gnus-topic-unmark-topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
889 "n" gnus-topic-create-topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
890 "m" gnus-topic-move-group
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
891 "D" gnus-topic-remove-group
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
892 "c" gnus-topic-copy-group
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
893 "h" gnus-topic-hide-topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
894 "s" gnus-topic-show-topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
895 "M" gnus-topic-move-matching
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
896 "C" gnus-topic-copy-matching
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
897 "\C-i" gnus-topic-indent
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
898 [tab] gnus-topic-indent
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
899 "r" gnus-topic-rename
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
900 "\177" gnus-topic-delete)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
901
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
902 (gnus-define-keys (gnus-topic-sort-map "S" gnus-group-topic-map)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
903 "s" gnus-topic-sort-groups
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
904 "a" gnus-topic-sort-groups-by-alphabet
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
905 "u" gnus-topic-sort-groups-by-unread
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
906 "l" gnus-topic-sort-groups-by-level
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
907 "v" gnus-topic-sort-groups-by-score
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
908 "r" gnus-topic-sort-groups-by-rank
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
909 "m" gnus-topic-sort-groups-by-method))
0
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-make-menu-bar ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (unless (boundp 'gnus-topic-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (easy-menu-define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 gnus-topic-menu gnus-topic-mode-map ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 '("Topics"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 ["Toggle topics" gnus-topic-mode t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 ("Groups"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 ["Copy" gnus-topic-copy-group t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 ["Move" gnus-topic-move-group t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 ["Remove" gnus-topic-remove-group t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 ["Copy matching" gnus-topic-copy-matching t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 ["Move matching" gnus-topic-move-matching t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ("Topics"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ["Show" gnus-topic-show-topic t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ["Hide" gnus-topic-hide-topic t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ["Delete" gnus-topic-delete t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 ["Rename" gnus-topic-rename t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 ["Create" gnus-topic-create-topic t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 ["Mark" gnus-topic-mark-topic t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 ["Indent" gnus-topic-indent t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 ["List active" gnus-topic-list-active t]))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (defun gnus-topic-mode (&optional arg redisplay)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 "Minor mode for topicsifying Gnus group buffers."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (interactive (list current-prefix-arg t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (when (eq major-mode 'gnus-group-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (make-local-variable 'gnus-topic-mode)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
938 (setq gnus-topic-mode
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (if (null arg) (not gnus-topic-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (> (prefix-numeric-value arg) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 ;; Infest Gnus with topics.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (when gnus-topic-mode
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
943 (when (gnus-visual-p 'topic-menu 'menu)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (gnus-topic-make-menu-bar))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
945 (setq gnus-topic-line-format-spec
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
946 (gnus-parse-format gnus-topic-line-format
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 gnus-topic-line-format-alist t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (unless (assq 'gnus-topic-mode minor-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (push '(gnus-topic-mode " Topic") minor-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (unless (assq 'gnus-topic-mode minor-mode-map-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (push (cons 'gnus-topic-mode gnus-topic-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 minor-mode-map-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (add-hook 'gnus-summary-exit-hook 'gnus-topic-update-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (add-hook 'gnus-group-catchup-group-hook 'gnus-topic-update-topic)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
955 (set (make-local-variable 'gnus-group-prepare-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
956 'gnus-group-prepare-topics)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
957 (set (make-local-variable 'gnus-group-get-parameter-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
958 'gnus-group-topic-parameters)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
959 (set (make-local-variable 'gnus-group-goto-next-group-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
960 'gnus-topic-goto-next-group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
961 (set (make-local-variable 'gnus-group-indentation-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
962 'gnus-topic-group-indentation)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
963 (set (make-local-variable 'gnus-group-update-group-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
964 'gnus-topic-update-topics-containing-group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
965 (set (make-local-variable 'gnus-group-sort-alist-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
966 'gnus-group-sort-topic)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (setq gnus-group-change-level-function 'gnus-topic-change-level)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (setq gnus-goto-missing-group-function 'gnus-topic-goto-missing-group)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
969 (make-local-hook 'gnus-check-bogus-groups-hook)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
970 (add-hook 'gnus-check-bogus-groups-hook 'gnus-topic-clean-alist)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (setq gnus-topology-checked-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 ;; We check the topology.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (when gnus-newsrc-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (gnus-topic-check-topology))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (run-hooks 'gnus-topic-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ;; Remove topic infestation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (unless gnus-topic-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (remove-hook 'gnus-summary-exit-hook 'gnus-topic-update-topic)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
979 (remove-hook 'gnus-group-change-level-function
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 'gnus-topic-change-level)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
981 (remove-hook 'gnus-check-bogus-groups-hook 'gnus-topic-clean-alist)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
982 (setq gnus-group-prepare-function 'gnus-group-prepare-flat)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
983 (setq gnus-group-sort-alist-function 'gnus-group-sort-flat))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (when redisplay
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (gnus-group-list-groups))))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
986
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 (defun gnus-topic-select-group (&optional all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 "Select this newsgroup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 No article is selected automatically.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 If ALL is non-nil, already read articles become readable.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
991 If ALL is a number, fetch this number of articles.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
992
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
993 If performed over a topic line, toggle folding the topic."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (if (gnus-group-topic-p)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
996 (let ((gnus-group-list-mode
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (if all (cons (if (numberp all) all 7) t) gnus-group-list-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (gnus-topic-fold all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (gnus-group-select-group all)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (defun gnus-mouse-pick-topic (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 "Select the group or topic under the mouse pointer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (mouse-set-point e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (gnus-topic-read-group nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (defun gnus-topic-read-group (&optional all no-article group)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 "Read news in this newsgroup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 If the prefix argument ALL is non-nil, already read articles become
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 readable. IF ALL is a number, fetch this number of articles. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 optional argument NO-ARTICLE is non-nil, no article will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 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
1013 group.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1014
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1015 If performed over a topic line, toggle folding the topic."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (if (gnus-group-topic-p)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
1018 (let ((gnus-group-list-mode
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (if all (cons (if (numberp all) all 7) t) gnus-group-list-mode)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (gnus-topic-fold all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (gnus-group-read-group all no-article group)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 (defun gnus-topic-create-topic (topic parent &optional previous full-topic)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
1024 (interactive
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (read-string "New topic: ")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1027 (gnus-current-topic)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 ;; Check whether this topic already exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (when (gnus-topic-find-topology topic)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1030 (error "Topic already exists"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (unless parent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (setq parent (caar gnus-topic-topology)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (let ((top (cdr (gnus-topic-find-topology parent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (full-topic (or full-topic `((,topic visible)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (unless top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (error "No such parent topic: %s" parent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (if previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (while (and (cdr top)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (not (equal (caaadr top) previous)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (setq top (cdr top)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (setcdr top (cons full-topic (cdr top))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (nconc top (list full-topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (unless (assoc topic gnus-topic-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (push (list topic) gnus-topic-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (gnus-topic-enter-dribble)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (gnus-group-list-groups)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 (gnus-topic-goto-topic topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (defun gnus-topic-move-group (n topic &optional copyp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 "Move the next N groups to TOPIC.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 If COPYP, copy the groups instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (list current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (completing-read "Move to topic: " gnus-topic-alist nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (let ((groups (gnus-group-process-prefix n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (topicl (assoc topic gnus-topic-alist))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1058 (start-group (progn (forward-line 1) (gnus-group-group-name)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1059 (start-topic (gnus-group-topic-name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 entry)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
1061 (mapcar
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1062 (lambda (g)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1063 (gnus-group-remove-mark g)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1064 (when (and
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1065 (setq entry (assoc (gnus-current-topic) gnus-topic-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1066 (not copyp))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1067 (setcdr entry (gnus-delete-first g (cdr entry))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1068 (nconc topicl (list g)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1069 groups)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1070 (gnus-topic-enter-dribble)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1071 (if start-group
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1072 (gnus-group-goto-group start-group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1073 (gnus-topic-goto-topic start-topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1074 (gnus-group-list-groups)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1076 (defun gnus-topic-remove-group (&optional arg)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 "Remove the current group from the topic."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1078 (interactive "P")
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
1079 (gnus-group-iterate arg
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1080 (lambda (group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1081 (let ((topicl (assoc (gnus-current-topic) gnus-topic-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1082 (buffer-read-only nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1083 (when (and topicl group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1084 (gnus-delete-line)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1085 (gnus-delete-first group topicl))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1086 (gnus-topic-update-topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1087 (gnus-group-position-point)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (defun gnus-topic-copy-group (n topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 "Copy the current group to a topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (list current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (completing-read "Copy to topic: " gnus-topic-alist nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (gnus-topic-move-group n topic t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (defun gnus-topic-kill-group (&optional n discard)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 "Kill the next N groups."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (if (gnus-group-topic-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (let ((topic (gnus-group-topic-name)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
1101 (push (cons
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1102 (gnus-topic-find-topology topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1103 (assoc topic gnus-topic-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1104 gnus-topic-killed-topics)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (gnus-topic-remove-topic nil t)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1106 (gnus-topic-find-topology topic nil nil gnus-topic-topology)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1107 (gnus-topic-enter-dribble))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (gnus-group-kill-group n discard)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (gnus-topic-update-topic)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
1110
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (defun gnus-topic-yank-group (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 "Yank the last topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (if gnus-topic-killed-topics
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
1115 (let* ((previous
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1116 (or (gnus-group-topic-name)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1117 (gnus-topic-next-topic (gnus-current-topic))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1118 (data (pop gnus-topic-killed-topics))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1119 (alist (cdr data))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1120 (item (cdar data)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1121 (push alist gnus-topic-alist)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (gnus-topic-create-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (caar item) (gnus-topic-parent-topic previous) previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 item)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1125 (gnus-topic-enter-dribble)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (gnus-topic-goto-topic (caar item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (let* ((prev (gnus-group-group-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (gnus-topic-inhibit-change-level t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (gnus-group-indentation
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
1130 (make-string
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (* gnus-topic-indent-level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (or (save-excursion
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1133 (gnus-topic-goto-topic (gnus-current-topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1134 (gnus-group-topic-level))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1135 0))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1136 ? ))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 yanked alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 ;; We first yank the groups the normal way...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (setq yanked (gnus-group-yank-group arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 ;; Then we enter the yanked groups into the topics they belong
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
1141 ;; to.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (setq alist (assoc (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (forward-line -1)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1144 (gnus-current-topic))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (when (stringp yanked)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (setq yanked (list yanked)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (if (not prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (nconc alist yanked)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (if (not (cdr alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (setcdr alist (nconc yanked (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (while (cdr alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (when (equal (cadr alist) prev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (setcdr alist (nconc yanked (cdr alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (setq alist nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (setq alist (cdr alist))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (gnus-topic-update-topic)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (defun gnus-topic-hide-topic ()
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1160 "Hide the current topic."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (interactive)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1162 (when (gnus-current-topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1163 (gnus-topic-goto-topic (gnus-current-topic))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (gnus-topic-remove-topic nil nil 'hidden)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (defun gnus-topic-show-topic ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 "Show the hidden topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (when (gnus-group-topic-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (gnus-topic-remove-topic t nil 'shown)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (defun gnus-topic-mark-topic (topic &optional unmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 "Mark all groups in the topic with the process mark."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1174 (interactive (list (gnus-group-topic-name)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1175 (if (not topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1176 (call-interactively 'gnus-group-mark-group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1177 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1178 (let ((groups (gnus-topic-find-groups topic 9 t)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1179 (while groups
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1180 (funcall (if unmark 'gnus-group-remove-mark 'gnus-group-set-mark)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1181 (gnus-info-group (nth 2 (pop groups)))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (defun gnus-topic-unmark-topic (topic &optional unmark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 "Remove the process mark from all groups in the topic."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1185 (interactive (list (gnus-group-topic-name)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1186 (if (not topic)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1187 (call-interactively 'gnus-group-unmark-group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1188 (gnus-topic-mark-topic topic t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (defun gnus-topic-get-new-news-this-topic (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 "Check for new news in the current topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (if (not (gnus-group-topic-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (gnus-group-get-new-news-this-group n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (gnus-topic-mark-topic (gnus-group-topic-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (gnus-group-get-new-news-this-group)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (defun gnus-topic-move-matching (regexp topic &optional copyp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 "Move all groups that match REGEXP to some topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (let (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (nreverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (setq topic (completing-read "Move to topic: " gnus-topic-alist nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (read-string (format "Move to %s (regexp): " topic))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 (gnus-group-mark-regexp regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (gnus-topic-move-group nil topic copyp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (defun gnus-topic-copy-matching (regexp topic &optional copyp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 "Copy all groups that match REGEXP to some topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (let (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (nreverse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (setq topic (completing-read "Copy to topic: " gnus-topic-alist nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 (read-string (format "Copy to %s (regexp): " topic))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (gnus-topic-move-matching regexp topic t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (defun gnus-topic-delete (topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 "Delete a topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (interactive (list (gnus-group-topic-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (unless topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (error "No topic to be deleted"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (let ((entry (assoc topic gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (when (cdr entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (error "Topic not empty"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 ;; Delete if visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (when (gnus-topic-goto-topic topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (gnus-delete-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 ;; Remove from alist.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (setq gnus-topic-alist (delq entry gnus-topic-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 ;; Remove from topology.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (gnus-topic-find-topology topic nil nil 'delete)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (defun gnus-topic-rename (old-name new-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 "Rename a topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (interactive
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1239 (let ((topic (gnus-current-topic)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (list topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (read-string (format "Rename %s to: " topic)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (let ((top (gnus-topic-find-topology old-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (entry (assoc old-name gnus-topic-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (when top
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (setcar (cadr top) new-name))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 100
diff changeset
1246 (when entry
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (setcar entry new-name))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1248 (forward-line -1)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1249 (gnus-dribble-touch)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (gnus-group-list-groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (defun gnus-topic-indent (&optional unindent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 "Indent a topic -- make it a sub-topic of the previous topic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 If UNINDENT, remove an indentation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (if unindent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (gnus-topic-unindent)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1258 (let* ((topic (gnus-current-topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1259 (parent (gnus-topic-previous-topic topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1260 (buffer-read-only nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (unless parent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (error "Nothing to indent %s into" topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (when topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (gnus-topic-goto-topic topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (gnus-topic-kill-group)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1266 (push (cdar gnus-topic-killed-topics) gnus-topic-alist)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (gnus-topic-create-topic
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1268 topic parent nil (cdaar gnus-topic-killed-topics))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1269 (pop gnus-topic-killed-topics)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 (or (gnus-topic-goto-topic topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (gnus-topic-goto-topic parent))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 (defun gnus-topic-unindent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 "Unindent a topic."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (interactive)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1276 (let* ((topic (gnus-current-topic))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (parent (gnus-topic-parent-topic topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (grandparent (gnus-topic-parent-topic parent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (unless grandparent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (error "Nothing to indent %s into" topic))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (when topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (gnus-topic-goto-topic topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (gnus-topic-kill-group)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1284 (push (cdar gnus-topic-killed-topics) gnus-topic-alist)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (gnus-topic-create-topic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 topic grandparent (gnus-topic-next-topic parent)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1287 (cdaar gnus-topic-killed-topics))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1288 (pop gnus-topic-killed-topics)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (gnus-topic-goto-topic topic))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 (defun gnus-topic-list-active (&optional force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 "List all groups that Gnus knows about in a topicsified fashion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 If FORCE, always re-read the active file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (when force
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (gnus-get-killed-groups))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (gnus-topic-grok-active force)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (let ((gnus-topic-topology gnus-topic-active-topology)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (gnus-topic-alist gnus-topic-active-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 gnus-killed-list gnus-zombie-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (gnus-group-list-groups 9 nil 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1303 ;;; Topic sorting functions
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1304
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1305 (defun gnus-topic-edit-parameters (group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1306 "Edit the group parameters of GROUP.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1307 If performed on a topic, edit the topic parameters instead."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1308 (interactive (list (gnus-group-group-name)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1309 (if group
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1310 (gnus-group-edit-group-parameters group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1311 (if (not (gnus-group-topic-p))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1312 (error "Nothing to edit on the current line.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1313 (let ((topic (gnus-group-topic-name)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1314 (gnus-edit-form
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1315 (gnus-topic-parameters topic)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
1316 (format "Editing the topic parameters for `%s'."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents: 98
diff changeset
1317 (or group topic))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1318 `(lambda (form)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1319 (gnus-topic-set-parameters ,topic form)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1320
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1321 (defun gnus-group-sort-topic (func reverse)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1322 "Sort groups in the topics according to FUNC and REVERSE."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1323 (let ((alist gnus-topic-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1324 (while alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1325 ;; !!!Sometimes nil elements sneak into the alist,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1326 ;; for some reason or other.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1327 (setcar alist (delq nil (car alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1328 (setcar alist (delete "dummy.group" (car alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1329 (gnus-topic-sort-topic (pop alist) func reverse))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1330
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1331 (defun gnus-topic-sort-topic (topic func reverse)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1332 ;; Each topic only lists the name of the group, while
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1333 ;; the sort predicates expect group infos as inputs.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1334 ;; So we first transform the group names into infos,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1335 ;; then sort, and then transform back into group names.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1336 (setcdr
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1337 topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1338 (mapcar
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1339 (lambda (info) (gnus-info-group info))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1340 (sort
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1341 (mapcar
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1342 (lambda (group) (gnus-get-info group))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1343 (cdr topic))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1344 func)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1345 ;; Do the reversal, if necessary.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1346 (when reverse
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1347 (setcdr topic (nreverse (cdr topic)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1348
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1349 (defun gnus-topic-sort-groups (func &optional reverse)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1350 "Sort the current topic according to FUNC.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1351 If REVERSE, reverse the sorting order."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1352 (interactive (list gnus-group-sort-function current-prefix-arg))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1353 (let ((topic (assoc (gnus-current-topic) gnus-topic-alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1354 (gnus-topic-sort-topic
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1355 topic (gnus-make-sort-function func) reverse)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1356 (gnus-group-list-groups)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1357
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1358 (defun gnus-topic-sort-groups-by-alphabet (&optional reverse)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1359 "Sort the current topic alphabetically by group name.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1360 If REVERSE, sort in reverse order."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1361 (interactive "P")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1362 (gnus-topic-sort-groups 'gnus-group-sort-by-alphabet reverse))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1363
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1364 (defun gnus-topic-sort-groups-by-unread (&optional reverse)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1365 "Sort the current topic by number of unread articles.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1366 If REVERSE, sort in reverse order."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1367 (interactive "P")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1368 (gnus-topic-sort-groups 'gnus-group-sort-by-unread reverse))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1369
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1370 (defun gnus-topic-sort-groups-by-level (&optional reverse)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1371 "Sort the current topic by group level.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1372 If REVERSE, sort in reverse order."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1373 (interactive "P")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1374 (gnus-topic-sort-groups 'gnus-group-sort-by-level reverse))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1375
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1376 (defun gnus-topic-sort-groups-by-score (&optional reverse)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1377 "Sort the current topic by group score.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1378 If REVERSE, sort in reverse order."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1379 (interactive "P")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1380 (gnus-topic-sort-groups 'gnus-group-sort-by-score reverse))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1381
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1382 (defun gnus-topic-sort-groups-by-rank (&optional reverse)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1383 "Sort the current topic by group rank.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1384 If REVERSE, sort in reverse order."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1385 (interactive "P")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1386 (gnus-topic-sort-groups 'gnus-group-sort-by-rank reverse))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1387
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1388 (defun gnus-topic-sort-groups-by-method (&optional reverse)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1389 "Sort the current topic alphabetically by backend name.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1390 If REVERSE, sort in reverse order."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1391 (interactive "P")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1392 (gnus-topic-sort-groups 'gnus-group-sort-by-method reverse))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1393
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (provide 'gnus-topic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 ;;; gnus-topic.el ends here