annotate lisp/gnus-topic.el @ 16625:b24b7ef8573b

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