annotate lisp/gnus/gnus-topic.el @ 161:28f395d8dc7a r20-3b7

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