annotate lisp/gnus/gnus-topic.el @ 16:0293115a14e9 r19-15b91

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