(file-remote-p): Docstring fix.
[bpt/emacs.git] / lisp / gnus / gnus-sum.el
CommitLineData
eec82323 1;;; gnus-sum.el --- summary mode commands for Gnus
e84b4b86
TTN
2
3;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
e3fe4da0 4;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
eec82323 5
6748645f 6;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
eec82323
LMI
7;; Keywords: news
8
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
5a9dffec 13;; the Free Software Foundation; either version 3, or (at your option)
eec82323
LMI
14;; any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
01ccbb85 18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eec82323
LMI
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs; see the file COPYING. If not, write to the
3a35cf56
LK
23;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24;; Boston, MA 02110-1301, USA.
eec82323
LMI
25
26;;; Commentary:
27
28;;; Code:
29
d09ae6ca
GM
30;; For Emacs < 22.2.
31(eval-and-compile
32 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
23f87bed 33(eval-when-compile
9efa445f
DN
34 (require 'cl))
35
36(defvar tool-bar-mode)
37(defvar gnus-tmp-header)
5ab7173c 38
eec82323
LMI
39(require 'gnus)
40(require 'gnus-group)
41(require 'gnus-spec)
42(require 'gnus-range)
43(require 'gnus-int)
44(require 'gnus-undo)
6748645f 45(require 'gnus-util)
18c06a99 46(require 'gmm-utils)
16409b0b 47(require 'mm-decode)
08c9a385 48(require 'nnoo)
23f87bed 49
6748645f 50(autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
d4dfaa19 51(autoload 'gnus-cache-write-active "gnus-cache")
23f87bed
MB
52(autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
53(autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
531e5812 54(autoload 'gnus-pick-line-number "gnus-salt" nil t)
08c9a385 55(autoload 'mm-uu-dissect "mm-uu")
23f87bed
MB
56(autoload 'gnus-article-outlook-deuglify-article "deuglify"
57 "Deuglify broken Outlook (Express) articles and redisplay."
58 t)
59(autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
60(autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
61(autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
eec82323
LMI
62
63(defcustom gnus-kill-summary-on-exit t
64 "*If non-nil, kill the summary buffer when you exit from it.
65If nil, the summary will become a \"*Dead Summary*\" buffer, and
66it will be killed sometime later."
67 :group 'gnus-summary-exit
68 :type 'boolean)
69
01c52d31
MB
70(defcustom gnus-summary-next-group-on-exit t
71 "If non-nil, go to the next unread newsgroup on summary exit.
72See `gnus-group-goto-unread'."
73 :link '(custom-manual "(gnus)Group Maneuvering")
74 :group 'gnus-summary-exit
75 :version "23.0" ;; No Gnus
76 :type 'boolean)
77
eec82323
LMI
78(defcustom gnus-fetch-old-headers nil
79 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
01c52d31
MB
80If an unread article in the group refers to an older, already
81read (or just marked as read) article, the old article will not
82normally be displayed in the Summary buffer. If this variable is
83t, Gnus will attempt to grab the headers to the old articles, and
84thereby build complete threads. If it has the value `some', all
85old headers will be fetched but only enough headers to connect
86otherwise loose threads will be displayed. This variable can
87also be a number. In that case, no more than that number of old
88headers will be fetched. If it has the value `invisible', all
6748645f 89old headers will be fetched, but none will be displayed.
eec82323 90
01c52d31
MB
91The server has to support NOV for any of this to work.
92
93This feature can seriously impact performance it ignores all
94locally cached header entries."
eec82323
LMI
95 :group 'gnus-thread
96 :type '(choice (const :tag "off" nil)
1232b9cb 97 (const :tag "on" t)
eec82323 98 (const some)
1232b9cb 99 (const invisible)
eec82323
LMI
100 number
101 (sexp :menu-tag "other" t)))
102
01c52d31 103(defcustom gnus-refer-thread-limit 500
6748645f
LMI
104 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
105If t, fetch all the available old headers."
106 :group 'gnus-thread
107 :type '(choice number
108 (sexp :menu-tag "other" t)))
109
eec82323
LMI
110(defcustom gnus-summary-make-false-root 'adopt
111 "*nil means that Gnus won't gather loose threads.
112If the root of a thread has expired or been read in a previous
113session, the information necessary to build a complete thread has been
114lost. Instead of having many small sub-threads from this original thread
115scattered all over the summary buffer, Gnus can gather them.
116
117If non-nil, Gnus will try to gather all loose sub-threads from an
118original thread into one large thread.
119
120If this variable is non-nil, it should be one of `none', `adopt',
121`dummy' or `empty'.
122
123If this variable is `none', Gnus will not make a false root, but just
124present the sub-threads after another.
125If this variable is `dummy', Gnus will create a dummy root that will
126have all the sub-threads as children.
127If this variable is `adopt', Gnus will make one of the \"children\"
128the parent and mark all the step-children as such.
129If this variable is `empty', the \"children\" are printed with empty
01ccbb85 130subject fields. (Or rather, they will be printed with a string
eec82323
LMI
131given by the `gnus-summary-same-subject' variable.)"
132 :group 'gnus-thread
133 :type '(choice (const :tag "off" nil)
134 (const none)
135 (const dummy)
136 (const adopt)
137 (const empty)))
138
23f87bed
MB
139(defcustom gnus-summary-make-false-root-always nil
140 "Always make a false dummy root."
bf247b6e 141 :version "22.1"
23f87bed
MB
142 :group 'gnus-thread
143 :type 'boolean)
144
eec82323
LMI
145(defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
146 "*A regexp to match subjects to be excluded from loose thread gathering.
147As loose thread gathering is done on subjects only, that means that
148there can be many false gatherings performed. By rooting out certain
149common subjects, gathering might become saner."
150 :group 'gnus-thread
151 :type 'regexp)
152
153(defcustom gnus-summary-gather-subject-limit nil
154 "*Maximum length of subject comparisons when gathering loose threads.
155Use nil to compare full subjects. Setting this variable to a low
156number will help gather threads that have been corrupted by
157newsreaders chopping off subject lines, but it might also mean that
158unrelated articles that have subject that happen to begin with the
159same few characters will be incorrectly gathered.
160
161If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
162comparing subjects."
163 :group 'gnus-thread
164 :type '(choice (const :tag "off" nil)
165 (const fuzzy)
166 (sexp :menu-tag "on" t)))
167
6748645f
LMI
168(defcustom gnus-simplify-subject-functions nil
169 "List of functions taking a string argument that simplify subjects.
170The functions are applied recursively.
171
23f87bed
MB
172Useful functions to put in this list include:
173`gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
174`gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
6748645f
LMI
175 :group 'gnus-thread
176 :type '(repeat function))
177
eec82323 178(defcustom gnus-simplify-ignored-prefixes nil
23f87bed 179 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
eec82323
LMI
180 :group 'gnus-thread
181 :type '(choice (const :tag "off" nil)
182 regexp))
183
184(defcustom gnus-build-sparse-threads nil
185 "*If non-nil, fill in the gaps in threads.
186If `some', only fill in the gaps that are needed to tie loose threads
187together. If `more', fill in all leaf nodes that Gnus can find. If
188non-nil and non-`some', fill in all gaps that Gnus manages to guess."
189 :group 'gnus-thread
190 :type '(choice (const :tag "off" nil)
191 (const some)
192 (const more)
193 (sexp :menu-tag "all" t)))
194
195(defcustom gnus-summary-thread-gathering-function
196 'gnus-gather-threads-by-subject
6748645f 197 "*Function used for gathering loose threads.
eec82323
LMI
198There are two pre-defined functions: `gnus-gather-threads-by-subject',
199which only takes Subjects into consideration; and
200`gnus-gather-threads-by-references', which compared the References
201headers of the articles to find matches."
202 :group 'gnus-thread
22115a9e
RS
203 :type '(radio (function-item gnus-gather-threads-by-subject)
204 (function-item gnus-gather-threads-by-references)
205 (function :tag "other")))
eec82323 206
eec82323
LMI
207(defcustom gnus-summary-same-subject ""
208 "*String indicating that the current article has the same subject as the previous.
209This variable will only be used if the value of
210`gnus-summary-make-false-root' is `empty'."
211 :group 'gnus-summary-format
212 :type 'string)
213
214(defcustom gnus-summary-goto-unread t
16409b0b
GM
215 "*If t, many commands will go to the next unread article.
216This applies to marking commands as well as other commands that
217\"naturally\" select the next article, like, for instance, `SPC' at
218the end of an article.
219
220If nil, the marking commands do NOT go to the next unread article
2642ac8f 221\(they go to the next article instead). If `never', commands that
16409b0b
GM
222usually go to the next unread article, will go to the next article,
223whether it is read or not."
eec82323
LMI
224 :group 'gnus-summary-marks
225 :link '(custom-manual "(gnus)Setting Marks")
226 :type '(choice (const :tag "off" nil)
227 (const never)
228 (sexp :menu-tag "on" t)))
229
230(defcustom gnus-summary-default-score 0
231 "*Default article score level.
232All scores generated by the score files will be added to this score.
233If this variable is nil, scoring will be disabled."
234 :group 'gnus-score-default
235 :type '(choice (const :tag "disable")
236 integer))
237
23f87bed
MB
238(defcustom gnus-summary-default-high-score 0
239 "*Default threshold for a high scored article.
240An article will be highlighted as high scored if its score is greater
241than this score."
bf247b6e 242 :version "22.1"
23f87bed
MB
243 :group 'gnus-score-default
244 :type 'integer)
245
246(defcustom gnus-summary-default-low-score 0
247 "*Default threshold for a low scored article.
248An article will be highlighted as low scored if its score is smaller
249than this score."
bf247b6e 250 :version "22.1"
23f87bed
MB
251 :group 'gnus-score-default
252 :type 'integer)
253
eec82323
LMI
254(defcustom gnus-summary-zcore-fuzz 0
255 "*Fuzziness factor for the zcore in the summary buffer.
256Articles with scores closer than this to `gnus-summary-default-score'
257will not be marked."
258 :group 'gnus-summary-format
259 :type 'integer)
260
261(defcustom gnus-simplify-subject-fuzzy-regexp nil
262 "*Strings to be removed when doing fuzzy matches.
263This can either be a regular expression or list of regular expressions
264that will be removed from subject strings if fuzzy subject
265simplification is selected."
266 :group 'gnus-thread
267 :type '(repeat regexp))
268
269(defcustom gnus-show-threads t
270 "*If non-nil, display threads in summary mode."
271 :group 'gnus-thread
272 :type 'boolean)
273
274(defcustom gnus-thread-hide-subtree nil
275 "*If non-nil, hide all threads initially.
23f87bed 276This can be a predicate specifier which says which threads to hide.
eec82323 277If threads are hidden, you have to run the command
4a2358e9 278`gnus-summary-show-thread' by hand or select an article."
eec82323 279 :group 'gnus-thread
23f87bed
MB
280 :type '(radio (sexp :format "Non-nil\n"
281 :match (lambda (widget value)
282 (not (or (consp value) (functionp value))))
283 :value t)
284 (const nil)
ad136a7c 285 (sexp :tag "Predicate specifier")))
eec82323
LMI
286
287(defcustom gnus-thread-hide-killed t
288 "*If non-nil, hide killed threads automatically."
289 :group 'gnus-thread
290 :type 'boolean)
291
6748645f
LMI
292(defcustom gnus-thread-ignore-subject t
293 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
294If nil, articles that have different subjects from their parents will
295start separate threads."
eec82323
LMI
296 :group 'gnus-thread
297 :type 'boolean)
298
299(defcustom gnus-thread-operation-ignore-subject t
300 "*If non-nil, subjects will be ignored when doing thread commands.
301This affects commands like `gnus-summary-kill-thread' and
302`gnus-summary-lower-thread'.
303
304If this variable is nil, articles in the same thread with different
305subjects will not be included in the operation in question. If this
306variable is `fuzzy', only articles that have subjects that are fuzzily
307equal will be included."
308 :group 'gnus-thread
309 :type '(choice (const :tag "off" nil)
310 (const fuzzy)
311 (sexp :tag "on" t)))
312
313(defcustom gnus-thread-indent-level 4
314 "*Number that says how much each sub-thread should be indented."
315 :group 'gnus-thread
316 :type 'integer)
317
318(defcustom gnus-auto-extend-newsgroup t
319 "*If non-nil, extend newsgroup forward and backward when requested."
320 :group 'gnus-summary-choose
321 :type 'boolean)
322
323(defcustom gnus-auto-select-first t
651408cb
MB
324 "If non-nil, select an article on group entry.
325An article is selected automatically when entering a group
326e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
327`gnus-summary-catchup-and-goto-next-group'.
328
329Which article is selected is controlled by the variable
330`gnus-auto-select-subject'.
23f87bed
MB
331
332If you want to prevent automatic selection of articles in some
333newsgroups, set the variable to nil in `gnus-select-group-hook'."
651408cb
MB
334 ;; Commands include...
335 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
336 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
337 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
eec82323
LMI
338 :group 'gnus-group-select
339 :type '(choice (const :tag "none" nil)
23f87bed
MB
340 (sexp :menu-tag "first" t)))
341
342(defcustom gnus-auto-select-subject 'unread
343 "*Says what subject to place under point when entering a group.
344
345This variable can either be the symbols `first' (place point on the
346first subject), `unread' (place point on the subject line of the first
347unread article), `best' (place point on the subject line of the
348higest-scored article), `unseen' (place point on the subject line of
99b5aab7 349the first unseen article), `unseen-or-unread' (place point on the subject
23f87bed
MB
350line of the first unseen article or, if all article have been seen, on the
351subject line of the first unread article), or a function to be called to
352place point on some subject line."
bf247b6e 353 :version "22.1"
23f87bed
MB
354 :group 'gnus-group-select
355 :type '(choice (const best)
356 (const unread)
357 (const first)
358 (const unseen)
359 (const unseen-or-unread)))
eec82323
LMI
360
361(defcustom gnus-auto-select-next t
362 "*If non-nil, offer to go to the next group from the end of the previous.
363If the value is t and the next newsgroup is empty, Gnus will exit
23f87bed
MB
364summary mode and go back to group mode. If the value is neither nil
365nor t, Gnus will select the following unread newsgroup. In
eec82323
LMI
366particular, if the value is the symbol `quietly', the next unread
367newsgroup will be selected without any confirmation, and if it is
368`almost-quietly', the next group will be selected without any
369confirmation if you are located on the last article in the group.
23f87bed 370Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
eec82323
LMI
371will go to the next group without confirmation."
372 :group 'gnus-summary-maneuvering
373 :type '(choice (const :tag "off" nil)
374 (const quietly)
375 (const almost-quietly)
376 (const slightly-quietly)
377 (sexp :menu-tag "on" t)))
378
379(defcustom gnus-auto-select-same nil
6748645f
LMI
380 "*If non-nil, select the next article with the same subject.
381If there are no more articles with the same subject, go to
382the first unread article."
eec82323
LMI
383 :group 'gnus-summary-maneuvering
384 :type 'boolean)
385
01c52d31
MB
386(defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
387 "What article should be selected after exiting an ephemeral group.
388Valid values include:
389
390`next'
391 Select the next article.
392`next-unread'
393 Select the next unread article.
394`next-noselect'
395 Move the cursor to the next article. This is the default.
396`next-unread-noselect'
397 Move the cursor to the next unread article.
398
399If it has any other value or there is no next (unread) article, the
400article selected before entering to the ephemeral group will appear."
401 :version "23.0" ;; No Gnus
402 :group 'gnus-summary-maneuvering
403 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
404 (const next) (const next-unread)
405 (const next-noselect) (const next-unread-noselect)
406 (sexp :tag "other" :value nil)))
407
23f87bed
MB
408(defcustom gnus-auto-goto-ignores 'unfetched
409 "*Says how to handle unfetched articles when maneuvering.
410
411This variable can either be the symbols nil (maneuver to any
412article), `undownloaded' (maneuvering while unplugged ignores articles
413that have not been fetched), `always-undownloaded' (maneuvering always
414ignores articles that have not been fetched), `unfetched' (maneuvering
415ignores articles whose headers have not been fetched).
416
417NOTE: The list of unfetched articles will always be nil when plugged
418and, when unplugged, a subset of the undownloaded article list."
bf247b6e 419 :version "22.1"
23f87bed
MB
420 :group 'gnus-summary-maneuvering
421 :type '(choice (const :tag "None" nil)
422 (const :tag "Undownloaded when unplugged" undownloaded)
423 (const :tag "Undownloaded" always-undownloaded)
424 (const :tag "Unfetched" unfetched)))
425
eec82323
LMI
426(defcustom gnus-summary-check-current nil
427 "*If non-nil, consider the current article when moving.
428The \"unread\" movement commands will stay on the same line if the
429current article is unread."
430 :group 'gnus-summary-maneuvering
431 :type 'boolean)
432
01c52d31 433(defcustom gnus-auto-center-summary 2
eec82323
LMI
434 "*If non-nil, always center the current summary buffer.
435In particular, if `vertical' do only vertical recentering. If non-nil
436and non-`vertical', do both horizontal and vertical recentering."
437 :group 'gnus-summary-maneuvering
438 :type '(choice (const :tag "none" nil)
439 (const vertical)
16409b0b 440 (integer :tag "height")
eec82323
LMI
441 (sexp :menu-tag "both" t)))
442
23f87bed
MB
443(defvar gnus-auto-center-group t
444 "*If non-nil, always center the group buffer.")
445
eec82323
LMI
446(defcustom gnus-show-all-headers nil
447 "*If non-nil, don't hide any headers."
448 :group 'gnus-article-hiding
449 :group 'gnus-article-headers
450 :type 'boolean)
451
452(defcustom gnus-summary-ignore-duplicates nil
453 "*If non-nil, ignore articles with identical Message-ID headers."
454 :group 'gnus-summary
455 :type 'boolean)
6748645f 456
eec82323
LMI
457(defcustom gnus-single-article-buffer t
458 "*If non-nil, display all articles in the same buffer.
459If nil, each group will get its own article buffer."
460 :group 'gnus-article-various
461 :type 'boolean)
462
463(defcustom gnus-break-pages t
464 "*If non-nil, do page breaking on articles.
465The page delimiter is specified by the `gnus-page-delimiter'
466variable."
467 :group 'gnus-article-various
468 :type 'boolean)
469
eec82323
LMI
470(defcustom gnus-move-split-methods nil
471 "*Variable used to suggest where articles are to be moved to.
23f87bed
MB
472It uses the same syntax as the `gnus-split-methods' variable.
473However, whereas `gnus-split-methods' specifies file names as targets,
474this variable specifies group names."
eec82323 475 :group 'gnus-summary-mail
6748645f
LMI
476 :type '(repeat (choice (list :value (fun) function)
477 (cons :value ("" "") regexp (repeat string))
478 (sexp :value nil))))
eec82323 479
01c52d31
MB
480(defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
481 "Function used to compute default prefix for article move/copy/etc prompts.
482The function should take one argument, a group name, and return a
483string with the suggested prefix."
484 :group 'gnus-summary-mail
485 :type 'function)
486
e62e7654
MB
487;; FIXME: Although the custom type is `character' for the following variables,
488;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
489
23f87bed 490(defcustom gnus-unread-mark ? ;Whitespace
eec82323
LMI
491 "*Mark used for unread articles."
492 :group 'gnus-summary-marks
493 :type 'character)
494
495(defcustom gnus-ticked-mark ?!
496 "*Mark used for ticked articles."
497 :group 'gnus-summary-marks
498 :type 'character)
499
500(defcustom gnus-dormant-mark ??
501 "*Mark used for dormant articles."
502 :group 'gnus-summary-marks
503 :type 'character)
504
505(defcustom gnus-del-mark ?r
506 "*Mark used for del'd articles."
507 :group 'gnus-summary-marks
508 :type 'character)
509
510(defcustom gnus-read-mark ?R
511 "*Mark used for read articles."
512 :group 'gnus-summary-marks
513 :type 'character)
514
515(defcustom gnus-expirable-mark ?E
516 "*Mark used for expirable articles."
517 :group 'gnus-summary-marks
518 :type 'character)
519
520(defcustom gnus-killed-mark ?K
521 "*Mark used for killed articles."
522 :group 'gnus-summary-marks
523 :type 'character)
524
23f87bed
MB
525(defcustom gnus-spam-mark ?$
526 "*Mark used for spam articles."
bf247b6e 527 :version "22.1"
23f87bed
MB
528 :group 'gnus-summary-marks
529 :type 'character)
530
eec82323 531(defcustom gnus-souped-mark ?F
23f87bed 532 "*Mark used for souped articles."
eec82323
LMI
533 :group 'gnus-summary-marks
534 :type 'character)
535
536(defcustom gnus-kill-file-mark ?X
537 "*Mark used for articles killed by kill files."
538 :group 'gnus-summary-marks
539 :type 'character)
540
541(defcustom gnus-low-score-mark ?Y
542 "*Mark used for articles with a low score."
543 :group 'gnus-summary-marks
544 :type 'character)
545
546(defcustom gnus-catchup-mark ?C
547 "*Mark used for articles that are caught up."
548 :group 'gnus-summary-marks
549 :type 'character)
550
551(defcustom gnus-replied-mark ?A
552 "*Mark used for articles that have been replied to."
553 :group 'gnus-summary-marks
554 :type 'character)
555
23f87bed
MB
556(defcustom gnus-forwarded-mark ?F
557 "*Mark used for articles that have been forwarded."
bf247b6e 558 :version "22.1"
23f87bed
MB
559 :group 'gnus-summary-marks
560 :type 'character)
561
562(defcustom gnus-recent-mark ?N
563 "*Mark used for articles that are recent."
bf247b6e 564 :version "22.1"
23f87bed
MB
565 :group 'gnus-summary-marks
566 :type 'character)
567
eec82323
LMI
568(defcustom gnus-cached-mark ?*
569 "*Mark used for articles that are in the cache."
570 :group 'gnus-summary-marks
571 :type 'character)
572
573(defcustom gnus-saved-mark ?S
23f87bed
MB
574 "*Mark used for articles that have been saved."
575 :group 'gnus-summary-marks
576 :type 'character)
577
578(defcustom gnus-unseen-mark ?.
579 "*Mark used for articles that haven't been seen."
bf247b6e 580 :version "22.1"
23f87bed
MB
581 :group 'gnus-summary-marks
582 :type 'character)
583
584(defcustom gnus-no-mark ? ;Whitespace
585 "*Mark used for articles that have no other secondary mark."
bf247b6e 586 :version "22.1"
eec82323
LMI
587 :group 'gnus-summary-marks
588 :type 'character)
589
590(defcustom gnus-ancient-mark ?O
591 "*Mark used for ancient articles."
592 :group 'gnus-summary-marks
593 :type 'character)
594
595(defcustom gnus-sparse-mark ?Q
596 "*Mark used for sparsely reffed articles."
597 :group 'gnus-summary-marks
598 :type 'character)
599
600(defcustom gnus-canceled-mark ?G
601 "*Mark used for canceled articles."
602 :group 'gnus-summary-marks
603 :type 'character)
604
605(defcustom gnus-duplicate-mark ?M
606 "*Mark used for duplicate articles."
607 :group 'gnus-summary-marks
608 :type 'character)
609
23f87bed 610(defcustom gnus-undownloaded-mark ?-
6748645f 611 "*Mark used for articles that weren't downloaded."
bf247b6e 612 :version "22.1"
6748645f
LMI
613 :group 'gnus-summary-marks
614 :type 'character)
615
23f87bed
MB
616(defcustom gnus-downloaded-mark ?+
617 "*Mark used for articles that were downloaded."
618 :group 'gnus-summary-marks
619 :type 'character)
620
6748645f
LMI
621(defcustom gnus-downloadable-mark ?%
622 "*Mark used for articles that are to be downloaded."
623 :group 'gnus-summary-marks
624 :type 'character)
625
626(defcustom gnus-unsendable-mark ?=
627 "*Mark used for articles that won't be sent."
628 :group 'gnus-summary-marks
629 :type 'character)
630
eec82323
LMI
631(defcustom gnus-score-over-mark ?+
632 "*Score mark used for articles with high scores."
633 :group 'gnus-summary-marks
634 :type 'character)
635
636(defcustom gnus-score-below-mark ?-
637 "*Score mark used for articles with low scores."
638 :group 'gnus-summary-marks
639 :type 'character)
640
23f87bed 641(defcustom gnus-empty-thread-mark ? ;Whitespace
eec82323
LMI
642 "*There is no thread under the article."
643 :group 'gnus-summary-marks
644 :type 'character)
645
646(defcustom gnus-not-empty-thread-mark ?=
647 "*There is a thread under the article."
648 :group 'gnus-summary-marks
649 :type 'character)
650
651(defcustom gnus-view-pseudo-asynchronously nil
652 "*If non-nil, Gnus will view pseudo-articles asynchronously."
653 :group 'gnus-extract-view
654 :type 'boolean)
655
16409b0b
GM
656(defcustom gnus-auto-expirable-marks
657 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
658 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
659 gnus-souped-mark gnus-duplicate-mark)
660 "*The list of marks converted into expiration if a group is auto-expirable."
58e39d05 661 :version "21.1"
16409b0b
GM
662 :group 'gnus-summary
663 :type '(repeat character))
664
665(defcustom gnus-inhibit-user-auto-expire t
666 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
58e39d05 667 :version "21.1"
16409b0b
GM
668 :group 'gnus-summary
669 :type 'boolean)
670
eec82323
LMI
671(defcustom gnus-view-pseudos nil
672 "*If `automatic', pseudo-articles will be viewed automatically.
673If `not-confirm', pseudos will be viewed automatically, and the user
674will not be asked to confirm the command."
675 :group 'gnus-extract-view
676 :type '(choice (const :tag "off" nil)
677 (const automatic)
678 (const not-confirm)))
679
680(defcustom gnus-view-pseudos-separately t
681 "*If non-nil, one pseudo-article will be created for each file to be viewed.
682If nil, all files that use the same viewing command will be given as a
683list of parameters to that command."
684 :group 'gnus-extract-view
685 :type 'boolean)
686
687(defcustom gnus-insert-pseudo-articles t
688 "*If non-nil, insert pseudo-articles when decoding articles."
689 :group 'gnus-extract-view
690 :type 'boolean)
691
692(defcustom gnus-summary-dummy-line-format
23f87bed 693 " %(: :%) %S\n"
eec82323
LMI
694 "*The format specification for the dummy roots in the summary buffer.
695It works along the same lines as a normal formatting string,
696with some simple extensions.
697
23f87bed
MB
698%S The subject
699
700General format specifiers can also be used.
701See `(gnus)Formatting Variables'."
702 :link '(custom-manual "(gnus)Formatting Variables")
eec82323
LMI
703 :group 'gnus-threading
704 :type 'string)
705
16409b0b 706(defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
eec82323
LMI
707 "*The format specification for the summary mode line.
708It works along the same lines as a normal formatting string,
709with some simple extensions:
710
711%G Group name
712%p Unprefixed group name
713%A Current article number
6748645f 714%z Current article score
eec82323
LMI
715%V Gnus version
716%U Number of unread articles in the group
717%e Number of unselected articles in the group
718%Z A string with unread/unselected article counts
719%g Shortish group name
720%S Subject of the current article
721%u User-defined spec
722%s Current score file name
723%d Number of dormant articles
724%r Number of articles that have been marked as read in this session
725%E Number of articles expunged by the score files"
726 :group 'gnus-summary-format
727 :type 'string)
728
16409b0b
GM
729(defcustom gnus-list-identifiers nil
730 "Regexp that matches list identifiers to be removed from subject.
731This can also be a list of regexps."
58e39d05 732 :version "21.1"
16409b0b
GM
733 :group 'gnus-summary-format
734 :group 'gnus-article-hiding
735 :type '(choice (const :tag "none" nil)
736 (regexp :value ".*")
737 (repeat :value (".*") regexp)))
738
eec82323
LMI
739(defcustom gnus-summary-mark-below 0
740 "*Mark all articles with a score below this variable as read.
741This variable is local to each summary buffer and usually set by the
742score file."
743 :group 'gnus-score-default
744 :type 'integer)
745
01c52d31
MB
746(defun gnus-widget-reversible-match (widget value)
747 "Ignoring WIDGET, convert VALUE to internal form.
748VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
749 ;; (debug value)
750 (or (symbolp value)
751 (and (listp value)
752 (eq (length value) 2)
753 (eq (nth 0 value) 'not)
754 (symbolp (nth 1 value)))))
755
756(defun gnus-widget-reversible-to-internal (widget value)
757 "Ignoring WIDGET, convert VALUE to internal form.
758VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
759FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
760 ;; (debug value)
761 (if (atom value)
762 (list value nil)
763 (list (nth 1 value) t)))
764
765(defun gnus-widget-reversible-to-external (widget value)
766 "Ignoring WIDGET, convert VALUE to external form.
767VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
768\(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
769 ;; (debug value)
770 (if (nth 1 value)
771 (list 'not (nth 0 value))
772 (nth 0 value)))
773
774(define-widget 'gnus-widget-reversible 'group
775 "A `group' that convert values."
776 :match 'gnus-widget-reversible-match
777 :value-to-internal 'gnus-widget-reversible-to-internal
778 :value-to-external 'gnus-widget-reversible-to-external)
779
eec82323
LMI
780(defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
781 "*List of functions used for sorting articles in the summary buffer.
23f87bed
MB
782
783Each function takes two articles and returns non-nil if the first
784article should be sorted before the other. If you use more than one
785function, the primary sort function should be the last. You should
786probably always include `gnus-article-sort-by-number' in the list of
787sorting functions -- preferably first. Also note that sorting by date
788is often much slower than sorting by number, and the sorting order is
789very similar. (Sorting by date means sorting by the time the message
790was sent, sorting by number means sorting by arrival time.)
791
01c52d31
MB
792Each item can also be a list `(not F)' where F is a function;
793this reverses the sort order.
794
23f87bed
MB
795Ready-made functions include `gnus-article-sort-by-number',
796`gnus-article-sort-by-author', `gnus-article-sort-by-subject',
797`gnus-article-sort-by-date', `gnus-article-sort-by-random'
798and `gnus-article-sort-by-score'.
799
800When threading is turned on, the variable `gnus-thread-sort-functions'
801controls how articles are sorted."
eec82323 802 :group 'gnus-summary-sort
01c52d31
MB
803 :type '(repeat (gnus-widget-reversible
804 (choice (function-item gnus-article-sort-by-number)
805 (function-item gnus-article-sort-by-author)
806 (function-item gnus-article-sort-by-subject)
807 (function-item gnus-article-sort-by-date)
808 (function-item gnus-article-sort-by-score)
809 (function-item gnus-article-sort-by-random)
810 (function :tag "other"))
811 (boolean :tag "Reverse order"))))
812
eec82323
LMI
813
814(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
815 "*List of functions used for sorting threads in the summary buffer.
816By default, threads are sorted by article number.
817
23f87bed
MB
818Each function takes two threads and returns non-nil if the first
819thread should be sorted before the other. If you use more than one
820function, the primary sort function should be the last. You should
821probably always include `gnus-thread-sort-by-number' in the list of
822sorting functions -- preferably first. Also note that sorting by date
823is often much slower than sorting by number, and the sorting order is
824very similar. (Sorting by date means sorting by the time the message
825was sent, sorting by number means sorting by arrival time.)
eec82323 826
01c52d31
MB
827Each list item can also be a list `(not F)' where F is a
828function; this specifies reversed sort order.
829
eec82323 830Ready-made functions include `gnus-thread-sort-by-number',
01c52d31
MB
831`gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
832`gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
833`gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
834`gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
835and `gnus-thread-sort-by-total-score' (see
836`gnus-thread-score-function').
23f87bed
MB
837
838When threading is turned off, the variable
839`gnus-article-sort-functions' controls how articles are sorted."
eec82323 840 :group 'gnus-summary-sort
01c52d31
MB
841 :type '(repeat
842 (gnus-widget-reversible
843 (choice (function-item gnus-thread-sort-by-number)
844 (function-item gnus-thread-sort-by-author)
845 (function-item gnus-thread-sort-by-recipient)
846 (function-item gnus-thread-sort-by-subject)
847 (function-item gnus-thread-sort-by-date)
848 (function-item gnus-thread-sort-by-score)
849 (function-item gnus-thread-sort-by-most-recent-number)
850 (function-item gnus-thread-sort-by-most-recent-date)
851 (function-item gnus-thread-sort-by-random)
852 (function-item gnus-thread-sort-by-total-score)
853 (function :tag "other"))
854 (boolean :tag "Reverse order"))))
eec82323
LMI
855
856(defcustom gnus-thread-score-function '+
857 "*Function used for calculating the total score of a thread.
858
859The function is called with the scores of the article and each
860subthread and should then return the score of the thread.
861
862Some functions you can use are `+', `max', or `min'."
863 :group 'gnus-summary-sort
864 :type 'function)
865
866(defcustom gnus-summary-expunge-below nil
6748645f
LMI
867 "All articles that have a score less than this variable will be expunged.
868This variable is local to the summary buffers."
eec82323
LMI
869 :group 'gnus-score-default
870 :type '(choice (const :tag "off" nil)
871 integer))
872
873(defcustom gnus-thread-expunge-below nil
874 "All threads that have a total score less than this variable will be expunged.
875See `gnus-thread-score-function' for en explanation of what a
6748645f
LMI
876\"thread score\" is.
877
878This variable is local to the summary buffers."
16409b0b 879 :group 'gnus-threading
eec82323
LMI
880 :group 'gnus-score-default
881 :type '(choice (const :tag "off" nil)
882 integer))
883
884(defcustom gnus-summary-mode-hook nil
885 "*A hook for Gnus summary mode.
886This hook is run before any variables are set in the summary buffer."
23f87bed 887 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
eec82323
LMI
888 :group 'gnus-summary-various
889 :type 'hook)
890
23f87bed
MB
891;; Extracted from gnus-xmas-redefine in order to preserve user settings
892(when (featurep 'xemacs)
893 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
894 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
895 (add-hook 'gnus-summary-mode-hook
896 'gnus-xmas-switch-horizontal-scrollbar-off))
897
eec82323
LMI
898(defcustom gnus-summary-menu-hook nil
899 "*Hook run after the creation of the summary mode menu."
900 :group 'gnus-summary-visual
901 :type 'hook)
902
903(defcustom gnus-summary-exit-hook nil
904 "*A hook called on exit from the summary buffer.
905It will be called with point in the group buffer."
906 :group 'gnus-summary-exit
907 :type 'hook)
908
909(defcustom gnus-summary-prepare-hook nil
910 "*A hook called after the summary buffer has been generated.
911If you want to modify the summary buffer, you can use this hook."
912 :group 'gnus-summary-various
913 :type 'hook)
914
6748645f
LMI
915(defcustom gnus-summary-prepared-hook nil
916 "*A hook called as the last thing after the summary buffer has been generated."
917 :group 'gnus-summary-various
918 :type 'hook)
919
eec82323
LMI
920(defcustom gnus-summary-generate-hook nil
921 "*A hook run just before generating the summary buffer.
922This hook is commonly used to customize threading variables and the
923like."
924 :group 'gnus-summary-various
925 :type 'hook)
926
927(defcustom gnus-select-group-hook nil
928 "*A hook called when a newsgroup is selected.
929
930If you'd like to simplify subjects like the
931`gnus-summary-next-same-subject' command does, you can use the
932following hook:
933
23f87bed
MB
934 (add-hook gnus-select-group-hook
935 (lambda ()
936 (mapcar (lambda (header)
937 (mail-header-set-subject
938 header
939 (gnus-simplify-subject
940 (mail-header-subject header) 're-only)))
941 gnus-newsgroup-headers)))"
eec82323
LMI
942 :group 'gnus-group-select
943 :type 'hook)
944
945(defcustom gnus-select-article-hook nil
946 "*A hook called when an article is selected."
947 :group 'gnus-summary-choose
23f87bed 948 :options '(gnus-agent-fetch-selected-article)
eec82323
LMI
949 :type 'hook)
950
951(defcustom gnus-visual-mark-article-hook
952 (list 'gnus-highlight-selected-summary)
953 "*Hook run after selecting an article in the summary buffer.
954It is meant to be used for highlighting the article in some way. It
955is not run if `gnus-visual' is nil."
956 :group 'gnus-summary-visual
957 :type 'hook)
958
16409b0b 959(defcustom gnus-parse-headers-hook nil
eec82323
LMI
960 "*A hook called before parsing the headers."
961 :group 'gnus-various
962 :type 'hook)
963
964(defcustom gnus-exit-group-hook nil
16409b0b
GM
965 "*A hook called when exiting summary mode.
966This hook is not called from the non-updating exit commands like `Q'."
eec82323
LMI
967 :group 'gnus-various
968 :type 'hook)
969
970(defcustom gnus-summary-update-hook
971 (list 'gnus-summary-highlight-line)
972 "*A hook called when a summary line is changed.
973The hook will not be called if `gnus-visual' is nil.
974
975The default function `gnus-summary-highlight-line' will
976highlight the line according to the `gnus-summary-highlight'
977variable."
978 :group 'gnus-summary-visual
979 :type 'hook)
980
981(defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
982 "*A hook called when an article is selected for the first time.
983The hook is intended to mark an article as read (or unread)
984automatically when it is selected."
985 :group 'gnus-summary-choose
986 :type 'hook)
987
988(defcustom gnus-group-no-more-groups-hook nil
989 "*A hook run when returning to group mode having no more (unread) groups."
990 :group 'gnus-group-select
991 :type 'hook)
992
993(defcustom gnus-ps-print-hook nil
994 "*A hook run before ps-printing something from Gnus."
995 :group 'gnus-summary
996 :type 'hook)
997
23f87bed
MB
998(defcustom gnus-summary-article-move-hook nil
999 "*A hook called after an article is moved, copied, respooled, or crossposted."
bf247b6e 1000 :version "22.1"
23f87bed
MB
1001 :group 'gnus-summary
1002 :type 'hook)
1003
1004(defcustom gnus-summary-article-delete-hook nil
1005 "*A hook called after an article is deleted."
bf247b6e 1006 :version "22.1"
23f87bed
MB
1007 :group 'gnus-summary
1008 :type 'hook)
1009
1010(defcustom gnus-summary-article-expire-hook nil
1011 "*A hook called after an article is expired."
bf247b6e 1012 :version "22.1"
23f87bed
MB
1013 :group 'gnus-summary
1014 :type 'hook)
1015
1016(defcustom gnus-summary-display-arrow
1017 (and (fboundp 'display-graphic-p)
1018 (display-graphic-p))
1019 "*If non-nil, display an arrow highlighting the current article."
bf247b6e 1020 :version "22.1"
23f87bed
MB
1021 :group 'gnus-summary
1022 :type 'boolean)
1023
0f49874b 1024(defcustom gnus-summary-selected-face 'gnus-summary-selected
eec82323
LMI
1025 "Face used for highlighting the current article in the summary buffer."
1026 :group 'gnus-summary-visual
1027 :type 'face)
1028
23f87bed
MB
1029(defvar gnus-tmp-downloaded nil)
1030
eec82323 1031(defcustom gnus-summary-highlight
23f87bed 1032 '(((eq mark gnus-canceled-mark)
0f49874b 1033 . gnus-summary-cancelled)
23f87bed 1034 ((and uncached (> score default-high))
0f49874b 1035 . gnus-summary-high-undownloaded)
23f87bed 1036 ((and uncached (< score default-low))
0f49874b 1037 . gnus-summary-low-undownloaded)
23f87bed 1038 (uncached
0f49874b 1039 . gnus-summary-normal-undownloaded)
23f87bed
MB
1040 ((and (> score default-high)
1041 (or (eq mark gnus-dormant-mark)
1042 (eq mark gnus-ticked-mark)))
0f49874b 1043 . gnus-summary-high-ticked)
23f87bed
MB
1044 ((and (< score default-low)
1045 (or (eq mark gnus-dormant-mark)
1046 (eq mark gnus-ticked-mark)))
0f49874b 1047 . gnus-summary-low-ticked)
23f87bed
MB
1048 ((or (eq mark gnus-dormant-mark)
1049 (eq mark gnus-ticked-mark))
0f49874b 1050 . gnus-summary-normal-ticked)
23f87bed 1051 ((and (> score default-high) (eq mark gnus-ancient-mark))
0f49874b 1052 . gnus-summary-high-ancient)
23f87bed 1053 ((and (< score default-low) (eq mark gnus-ancient-mark))
0f49874b 1054 . gnus-summary-low-ancient)
23f87bed 1055 ((eq mark gnus-ancient-mark)
0f49874b 1056 . gnus-summary-normal-ancient)
23f87bed 1057 ((and (> score default-high) (eq mark gnus-unread-mark))
0f49874b 1058 . gnus-summary-high-unread)
23f87bed 1059 ((and (< score default-low) (eq mark gnus-unread-mark))
0f49874b 1060 . gnus-summary-low-unread)
23f87bed 1061 ((eq mark gnus-unread-mark)
0f49874b 1062 . gnus-summary-normal-unread)
23f87bed 1063 ((> score default-high)
0f49874b 1064 . gnus-summary-high-read)
23f87bed 1065 ((< score default-low)
0f49874b 1066 . gnus-summary-low-read)
eec82323 1067 (t
0f49874b 1068 . gnus-summary-normal-read))
6748645f 1069 "*Controls the highlighting of summary buffer lines.
eec82323 1070
107cf8ec 1071A list of (FORM . FACE) pairs. When deciding how a particular
23f87bed
MB
1072summary line should be displayed, each form is evaluated. The content
1073of the face field after the first true form is used. You can change
1074how those summary lines are displayed, by editing the face field.
eec82323
LMI
1075
1076You can use the following variables in the FORM field.
1077
107cf8ec 1078score: The article's score.
23f87bed
MB
1079default: The default article score.
1080default-high: The default score for high scored articles.
1081default-low: The default score for low scored articles.
1082below: The score below which articles are automatically marked as read.
1083mark: The article's mark.
1084uncached: Non-nil if the article is uncached."
eec82323
LMI
1085 :group 'gnus-summary-visual
1086 :type '(repeat (cons (sexp :tag "Form" nil)
1087 face)))
c12ecb0a 1088(put 'gnus-summary-highlight 'risky-local-variable t)
eec82323 1089
6748645f
LMI
1090(defcustom gnus-alter-header-function nil
1091 "Function called to allow alteration of article header structures.
1092The function is called with one parameter, the article header vector,
0ab0f2d3
SZ
1093which it may alter in any way."
1094 :type '(choice (const :tag "None" nil)
1095 function)
1096 :group 'gnus-summary)
eec82323 1097
16409b0b 1098(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
343d6628
MB
1099 "Function used to decode a string with encoded words.")
1100
1101(defvar gnus-decode-encoded-address-function
1102 'mail-decode-encoded-address-string
1103 "Function used to decode addresses with encoded words.")
16409b0b 1104
23f87bed 1105(defcustom gnus-extra-headers '(To Newsgroups)
16409b0b 1106 "*Extra headers to parse."
58e39d05 1107 :version "21.1"
16409b0b
GM
1108 :group 'gnus-summary
1109 :type '(repeat symbol))
1110
1111(defcustom gnus-ignored-from-addresses
343d6628 1112 (and user-mail-address
7cd9f860
CY
1113 (not (string= user-mail-address ""))
1114 (regexp-quote user-mail-address))
01c52d31
MB
1115 "*From headers that may be suppressed in favor of To headers.
1116This can be a regexp or a list of regexps."
58e39d05 1117 :version "21.1"
16409b0b 1118 :group 'gnus-summary
01c52d31
MB
1119 :type '(choice regexp
1120 (repeat :tag "Regexp List" regexp)))
1121
1122(defsubst gnus-ignored-from-addresses ()
1123 (gmm-regexp-concat gnus-ignored-from-addresses))
1124
1125(defcustom gnus-summary-to-prefix "-> "
1126 "*String prefixed to the To field in the summary line when
1127using `gnus-ignored-from-addresses'."
1128 :version "22.1"
1129 :group 'gnus-summary
1130 :type 'string)
1131
1132(defcustom gnus-summary-newsgroup-prefix "=> "
1133 "*String prefixed to the Newsgroup field in the summary
1134line when using `gnus-ignored-from-addresses'."
1135 :version "22.1"
1136 :group 'gnus-summary
1137 :type 'string)
16409b0b 1138
16409b0b
GM
1139(defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1140 "List of charsets that should be ignored.
1141When these charsets are used in the \"charset\" parameter, the
1142default charset will be used instead."
58e39d05 1143 :version "21.1"
16409b0b
GM
1144 :type '(repeat symbol)
1145 :group 'gnus-charset)
1146
4b70e299
MB
1147(defcustom gnus-newsgroup-maximum-articles nil
1148 "The maximum number of articles a newsgroup.
1149If this is a number, old articles in a newsgroup exceeding this number
1150are silently ignored. If it is nil, no article is ignored. Note that
1151setting this variable to a number might prevent you from reading very
1152old articles."
1153 :group 'gnus-group-select
1154 :version "22.2"
1155 :type '(choice (const :tag "No limit" nil)
1156 integer))
1157
23f87bed
MB
1158(gnus-define-group-parameter
1159 ignored-charsets
1160 :type list
1161 :function-document
1162 "Return the ignored charsets of GROUP."
1163 :variable gnus-group-ignored-charsets-alist
1164 :variable-default
1165 '(("alt\\.chinese\\.text" iso-8859-1))
1166 :variable-document
1167 "Alist of regexps (to match group names) and charsets that should be ignored.
16409b0b
GM
1168When these charsets are used in the \"charset\" parameter, the
1169default charset will be used instead."
23f87bed
MB
1170 :variable-group gnus-charset
1171 :variable-type '(repeat (cons (regexp :tag "Group")
1172 (repeat symbol)))
1173 :parameter-type '(choice :tag "Ignored charsets"
1174 :value nil
1175 (repeat (symbol)))
1176 :parameter-document "\
1177List of charsets that should be ignored.
1178
1179When these charsets are used in the \"charset\" parameter, the
1180default charset will be used instead.")
16409b0b
GM
1181
1182(defcustom gnus-group-highlight-words-alist nil
1183 "Alist of group regexps and highlight regexps.
1184This variable uses the same syntax as `gnus-emphasis-alist'."
58e39d05 1185 :version "21.1"
16409b0b
GM
1186 :type '(repeat (cons (regexp :tag "Group")
1187 (repeat (list (regexp :tag "Highlight regexp")
1188 (number :tag "Group for entire word" 0)
1189 (number :tag "Group for displayed part" 0)
1190 (symbol :tag "Face"
1191 gnus-emphasis-highlight-words)))))
1192 :group 'gnus-summary-visual)
1193
1194(defcustom gnus-summary-show-article-charset-alist
1195 nil
1196 "Alist of number and charset.
1197The article will be shown with the charset corresponding to the
1198numbered argument.
1199For example: ((1 . cn-gb-2312) (2 . big5))."
58e39d05 1200 :version "21.1"
16409b0b
GM
1201 :type '(repeat (cons (number :tag "Argument" 1)
1202 (symbol :tag "Charset")))
1203 :group 'gnus-charset)
1204
1205(defcustom gnus-preserve-marks t
1206 "Whether marks are preserved when moving, copying and respooling messages."
58e39d05 1207 :version "21.1"
16409b0b
GM
1208 :type 'boolean
1209 :group 'gnus-summary-marks)
1210
1211(defcustom gnus-alter-articles-to-read-function nil
1212 "Function to be called to alter the list of articles to be selected."
8fc7a9a1 1213 :type '(choice (const nil) function)
16409b0b
GM
1214 :group 'gnus-summary)
1215
1216(defcustom gnus-orphan-score nil
1217 "*All orphans get this score added. Set in the score file."
1218 :group 'gnus-score-default
1219 :type '(choice (const nil)
1220 integer))
1221
8b93df01 1222(defcustom gnus-summary-save-parts-default-mime "image/.*"
23f87bed
MB
1223 "*A regexp to match MIME parts when saving multiple parts of a
1224message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1225This regexp will be used by default when prompting the user for which
1226type of files to save."
8b93df01
DL
1227 :group 'gnus-summary
1228 :type 'regexp)
1229
23f87bed
MB
1230(defcustom gnus-read-all-available-headers nil
1231 "Whether Gnus should parse all headers made available to it.
1232This is mostly relevant for slow back ends where the user may
1233wish to widen the summary buffer to include all headers
1234that were fetched. Say, for nnultimate groups."
bf247b6e 1235 :version "22.1"
23f87bed
MB
1236 :group 'gnus-summary
1237 :type '(choice boolean regexp))
1238
1239(defcustom gnus-summary-muttprint-program "muttprint"
1240 "Command (and optional arguments) used to run Muttprint."
bf247b6e 1241 :version "22.1"
23f87bed
MB
1242 :group 'gnus-summary
1243 :type 'string)
1244
01c52d31 1245(defcustom gnus-article-loose-mime t
23f87bed
MB
1246 "If non-nil, don't require MIME-Version header.
1247Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
a08b59c9 1248supply the MIME-Version header or deliberately strip it from the mail.
01c52d31
MB
1249If non-nil (the default), Gnus will treat some articles as MIME
1250even if the MIME-Version header is missing."
bf247b6e 1251 :version "22.1"
23f87bed
MB
1252 :type 'boolean
1253 :group 'gnus-article-mime)
1254
1255(defcustom gnus-article-emulate-mime t
1256 "If non-nil, use MIME emulation for uuencode and the like.
1257This means that Gnus will search message bodies for text that look
1258like uuencoded bits, yEncoded bits, and so on, and present that using
1259the normal Gnus MIME machinery."
bf247b6e 1260 :version "22.1"
23f87bed
MB
1261 :type 'boolean
1262 :group 'gnus-article-mime)
8b93df01 1263
eec82323
LMI
1264;;; Internal variables
1265
23f87bed 1266(defvar gnus-summary-display-cache nil)
16409b0b
GM
1267(defvar gnus-article-mime-handles nil)
1268(defvar gnus-article-decoded-p nil)
23f87bed
MB
1269(defvar gnus-article-charset nil)
1270(defvar gnus-article-ignored-charsets nil)
eec82323
LMI
1271(defvar gnus-scores-exclude-files nil)
1272(defvar gnus-page-broken nil)
1273
1274(defvar gnus-original-article nil)
1275(defvar gnus-article-internal-prepare-hook nil)
1276(defvar gnus-newsgroup-process-stack nil)
1277
1278(defvar gnus-thread-indent-array nil)
1279(defvar gnus-thread-indent-array-level gnus-thread-indent-level)
16409b0b
GM
1280(defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1281 "Function called to sort the articles within a thread after it has been gathered together.")
eec82323 1282
8b93df01 1283(defvar gnus-summary-save-parts-type-history nil)
23f87bed 1284(defvar gnus-summary-save-parts-last-directory mm-default-directory)
8b93df01 1285
eec82323
LMI
1286;; Avoid highlighting in kill files.
1287(defvar gnus-summary-inhibit-highlight nil)
1288(defvar gnus-newsgroup-selected-overlay nil)
1289(defvar gnus-inhibit-limiting nil)
1290(defvar gnus-newsgroup-adaptive-score-file nil)
1291(defvar gnus-current-score-file nil)
1292(defvar gnus-current-move-group nil)
1293(defvar gnus-current-copy-group nil)
1294(defvar gnus-current-crosspost-group nil)
23f87bed 1295(defvar gnus-newsgroup-display nil)
eec82323
LMI
1296
1297(defvar gnus-newsgroup-dependencies nil)
1298(defvar gnus-newsgroup-adaptive nil)
1299(defvar gnus-summary-display-article-function nil)
1300(defvar gnus-summary-highlight-line-function nil
1301 "Function called after highlighting a summary line.")
1302
1303(defvar gnus-summary-line-format-alist
1304 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1305 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1306 (?s gnus-tmp-subject-or-nil ?s)
1307 (?n gnus-tmp-name ?s)
1308 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1309 ?s)
1310 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1311 gnus-tmp-from) ?s)
1312 (?F gnus-tmp-from ?s)
1313 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1314 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1315 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
6748645f 1316 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
eec82323
LMI
1317 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1318 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1319 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
23f87bed
MB
1320 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1321 (?L gnus-tmp-lines ?s)
1322 (?O gnus-tmp-downloaded ?c)
eec82323
LMI
1323 (?I gnus-tmp-indentation ?s)
1324 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1325 (?R gnus-tmp-replied ?c)
1326 (?\[ gnus-tmp-opening-bracket ?c)
1327 (?\] gnus-tmp-closing-bracket ?c)
1328 (?\> (make-string gnus-tmp-level ? ) ?s)
1329 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1330 (?i gnus-tmp-score ?d)
1331 (?z gnus-tmp-score-char ?c)
eec82323
LMI
1332 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1333 (?U gnus-tmp-unread ?c)
23f87bed
MB
1334 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1335 ?s)
eec82323
LMI
1336 (?t (gnus-summary-number-of-articles-in-thread
1337 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1338 ?d)
1339 (?e (gnus-summary-number-of-articles-in-thread
1340 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1341 ?c)
1342 (?u gnus-tmp-user-defined ?s)
23f87bed
MB
1343 (?P (gnus-pick-line-number) ?d)
1344 (?B gnus-tmp-thread-tree-header-string ?s)
1345 (user-date (gnus-user-date
1346 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
16409b0b
GM
1347 "An alist of format specifications that can appear in summary lines.
1348These are paired with what variables they correspond with, along with
1349the type of the variable (string, integer, character, etc).")
eec82323
LMI
1350
1351(defvar gnus-summary-dummy-line-format-alist
1352 `((?S gnus-tmp-subject ?s)
1353 (?N gnus-tmp-number ?d)
1354 (?u gnus-tmp-user-defined ?s)))
1355
1356(defvar gnus-summary-mode-line-format-alist
1357 `((?G gnus-tmp-group-name ?s)
1358 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1359 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1360 (?A gnus-tmp-article-number ?d)
1361 (?Z gnus-tmp-unread-and-unselected ?s)
1362 (?V gnus-version ?s)
1363 (?U gnus-tmp-unread-and-unticked ?d)
1364 (?S gnus-tmp-subject ?s)
1365 (?e gnus-tmp-unselected ?d)
1366 (?u gnus-tmp-user-defined ?s)
1367 (?d (length gnus-newsgroup-dormant) ?d)
1368 (?t (length gnus-newsgroup-marked) ?d)
23f87bed 1369 (?h (length gnus-newsgroup-spam-marked) ?d)
eec82323 1370 (?r (length gnus-newsgroup-reads) ?d)
6748645f 1371 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
eec82323
LMI
1372 (?E gnus-newsgroup-expunged-tally ?d)
1373 (?s (gnus-current-score-file-nondirectory) ?s)))
1374
1375(defvar gnus-last-search-regexp nil
1376 "Default regexp for article search command.")
1377
1378(defvar gnus-last-shell-command nil
1379 "Default shell command on article.")
1380
23f87bed
MB
1381(defvar gnus-newsgroup-agentized nil
1382 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
eec82323
LMI
1383(defvar gnus-newsgroup-begin nil)
1384(defvar gnus-newsgroup-end nil)
1385(defvar gnus-newsgroup-last-rmail nil)
1386(defvar gnus-newsgroup-last-mail nil)
1387(defvar gnus-newsgroup-last-folder nil)
1388(defvar gnus-newsgroup-last-file nil)
26c9afc3 1389(defvar gnus-newsgroup-last-directory nil)
eec82323
LMI
1390(defvar gnus-newsgroup-auto-expire nil)
1391(defvar gnus-newsgroup-active nil)
1392
1393(defvar gnus-newsgroup-data nil)
1394(defvar gnus-newsgroup-data-reverse nil)
1395(defvar gnus-newsgroup-limit nil)
1396(defvar gnus-newsgroup-limits nil)
23f87bed 1397(defvar gnus-summary-use-undownloaded-faces nil)
eec82323
LMI
1398
1399(defvar gnus-newsgroup-unreads nil
23f87bed 1400 "Sorted list of unread articles in the current newsgroup.")
eec82323
LMI
1401
1402(defvar gnus-newsgroup-unselected nil
23f87bed 1403 "Sorted list of unselected unread articles in the current newsgroup.")
eec82323
LMI
1404
1405(defvar gnus-newsgroup-reads nil
1406 "Alist of read articles and article marks in the current newsgroup.")
1407
1408(defvar gnus-newsgroup-expunged-tally nil)
1409
1410(defvar gnus-newsgroup-marked nil
23f87bed
MB
1411 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1412
1413(defvar gnus-newsgroup-spam-marked nil
1414 "List of ranges of articles that have been marked as spam.")
eec82323
LMI
1415
1416(defvar gnus-newsgroup-killed nil
1417 "List of ranges of articles that have been through the scoring process.")
1418
1419(defvar gnus-newsgroup-cached nil
23f87bed 1420 "Sorted list of articles that come from the article cache.")
eec82323
LMI
1421
1422(defvar gnus-newsgroup-saved nil
1423 "List of articles that have been saved.")
1424
1425(defvar gnus-newsgroup-kill-headers nil)
1426
1427(defvar gnus-newsgroup-replied nil
1428 "List of articles that have been replied to in the current newsgroup.")
1429
23f87bed
MB
1430(defvar gnus-newsgroup-forwarded nil
1431 "List of articles that have been forwarded in the current newsgroup.")
1432
1433(defvar gnus-newsgroup-recent nil
1434 "List of articles that have are recent in the current newsgroup.")
1435
eec82323 1436(defvar gnus-newsgroup-expirable nil
23f87bed 1437 "Sorted list of articles in the current newsgroup that can be expired.")
eec82323
LMI
1438
1439(defvar gnus-newsgroup-processable nil
1440 "List of articles in the current newsgroup that can be processed.")
1441
6748645f 1442(defvar gnus-newsgroup-downloadable nil
23f87bed
MB
1443 "Sorted list of articles in the current newsgroup that can be processed.")
1444
1445(defvar gnus-newsgroup-unfetched nil
1446 "Sorted list of articles in the current newsgroup whose headers have
1447not been fetched into the agent.
1448
1449This list will always be a subset of gnus-newsgroup-undownloaded.")
6748645f
LMI
1450
1451(defvar gnus-newsgroup-undownloaded nil
23f87bed 1452 "List of articles in the current newsgroup that haven't been downloaded.")
6748645f
LMI
1453
1454(defvar gnus-newsgroup-unsendable nil
1455 "List of articles in the current newsgroup that won't be sent.")
1456
eec82323
LMI
1457(defvar gnus-newsgroup-bookmarks nil
1458 "List of articles in the current newsgroup that have bookmarks.")
1459
1460(defvar gnus-newsgroup-dormant nil
23f87bed
MB
1461 "Sorted list of dormant articles in the current newsgroup.")
1462
1463(defvar gnus-newsgroup-unseen nil
1464 "List of unseen articles in the current newsgroup.")
1465
1466(defvar gnus-newsgroup-seen nil
1467 "Range of seen articles in the current newsgroup.")
1468
1469(defvar gnus-newsgroup-articles nil
1470 "List of articles in the current newsgroup.")
eec82323
LMI
1471
1472(defvar gnus-newsgroup-scored nil
1473 "List of scored articles in the current newsgroup.")
1474
1475(defvar gnus-newsgroup-headers nil
1476 "List of article headers in the current newsgroup.")
1477
1478(defvar gnus-newsgroup-threads nil)
1479
1480(defvar gnus-newsgroup-prepared nil
1481 "Whether the current group has been prepared properly.")
1482
1483(defvar gnus-newsgroup-ancient nil
1484 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1485
1486(defvar gnus-newsgroup-sparse nil)
1487
1488(defvar gnus-current-article nil)
1489(defvar gnus-article-current nil)
1490(defvar gnus-current-headers nil)
1491(defvar gnus-have-all-headers nil)
1492(defvar gnus-last-article nil)
1493(defvar gnus-newsgroup-history nil)
16409b0b
GM
1494(defvar gnus-newsgroup-charset nil)
1495(defvar gnus-newsgroup-ephemeral-charset nil)
1496(defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
eec82323 1497
23f87bed
MB
1498(defvar gnus-article-before-search nil)
1499
1500(defvar gnus-summary-local-variables
eec82323
LMI
1501 '(gnus-newsgroup-name
1502 gnus-newsgroup-begin gnus-newsgroup-end
1503 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1504 gnus-newsgroup-last-folder gnus-newsgroup-last-file
26c9afc3 1505 gnus-newsgroup-last-directory
eec82323
LMI
1506 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1507 gnus-newsgroup-unselected gnus-newsgroup-marked
23f87bed 1508 gnus-newsgroup-spam-marked
eec82323 1509 gnus-newsgroup-reads gnus-newsgroup-saved
23f87bed
MB
1510 gnus-newsgroup-replied gnus-newsgroup-forwarded
1511 gnus-newsgroup-recent
1512 gnus-newsgroup-expirable
eec82323 1513 gnus-newsgroup-processable gnus-newsgroup-killed
6748645f 1514 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
23f87bed
MB
1515 gnus-newsgroup-unfetched
1516 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1517 gnus-newsgroup-seen gnus-newsgroup-articles
eec82323
LMI
1518 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1519 gnus-newsgroup-headers gnus-newsgroup-threads
1520 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1521 gnus-current-article gnus-current-headers gnus-have-all-headers
1522 gnus-last-article gnus-article-internal-prepare-hook
1523 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1524 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1525 gnus-thread-expunge-below
16409b0b
GM
1526 gnus-score-alist gnus-current-score-file
1527 (gnus-summary-expunge-below . global)
eec82323 1528 (gnus-summary-mark-below . global)
16409b0b 1529 (gnus-orphan-score . global)
eec82323
LMI
1530 gnus-newsgroup-active gnus-scores-exclude-files
1531 gnus-newsgroup-history gnus-newsgroup-ancient
1532 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1533 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1534 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1535 (gnus-newsgroup-expunged-tally . 0)
1536 gnus-cache-removable-articles gnus-newsgroup-cached
1537 gnus-newsgroup-data gnus-newsgroup-data-reverse
16409b0b 1538 gnus-newsgroup-limit gnus-newsgroup-limits
23f87bed
MB
1539 gnus-newsgroup-charset gnus-newsgroup-display
1540 gnus-summary-use-undownloaded-faces)
eec82323
LMI
1541 "Variables that are buffer-local to the summary buffers.")
1542
23f87bed
MB
1543(defvar gnus-newsgroup-variables nil
1544 "A list of variables that have separate values in different newsgroups.
1545A list of newsgroup (summary buffer) local variables, or cons of
1546variables and their default expressions to be evalled (when the default
1547values are not nil), that should be made global while the summary buffer
1548is active.
1549
1550Note: The default expressions will be evaluated (using function `eval')
1551before assignment to the local variable rather than just assigned to it.
1552If the default expression is the symbol `global', that symbol will not
1553be evaluated but the global value of the local variable will be used
1554instead.
1555
1556These variables can be used to set variables in the group parameters
1557while still allowing them to affect operations done in other buffers.
1558For example:
1559
1560\(setq gnus-newsgroup-variables
1561 '(message-use-followup-to
1562 (gnus-visible-headers .
1563 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1564")
1565
441f785c
GM
1566;; Byte-compiler warning. Specifically, this is responsible for:
1567;; "Warning: the following functions might not be defined at runtime:
1568;; gnus-build-sparse-threads, gnus-dead-summary-mode, gnus-summary-mark-below".
23f87bed
MB
1569(eval-when-compile
1570 ;; Bind features so that require will believe that gnus-sum has
1571 ;; already been loaded (avoids infinite recursion)
1572 (let ((features (cons 'gnus-sum features)))
1573 ;; Several of the declarations in gnus-sum are needed to load the
1574 ;; following files. Right now, these definitions have been
1575 ;; compiled but not defined (evaluated). We could either do a
1576 ;; eval-and-compile about all of the declarations or evaluate the
1577 ;; source file.
1578 (if (boundp 'gnus-newsgroup-variables)
1579 nil
1580 (load "gnus-sum.el" t t t))
1581 (require 'gnus)
23f87bed 1582 (require 'gnus-art)))
eec82323 1583
16409b0b
GM
1584;; MIME stuff.
1585
1586(defvar gnus-decode-encoded-word-methods
1587 '(mail-decode-encoded-word-string)
1588 "List of methods used to decode encoded words.
1589
23f87bed
MB
1590This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1591is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1592\(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
16409b0b
GM
1593whose names match REGEXP.
1594
1595For example:
23f87bed 1596\((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
16409b0b
GM
1597 mail-decode-encoded-word-string
1598 (\"chinese\" . rfc1843-decode-string))")
1599
1600(defvar gnus-decode-encoded-word-methods-cache nil)
1601
1602(defun gnus-multi-decode-encoded-word-string (string)
1603 "Apply the functions from `gnus-encoded-word-methods' that match."
1604 (unless (and gnus-decode-encoded-word-methods-cache
1605 (eq gnus-newsgroup-name
1606 (car gnus-decode-encoded-word-methods-cache)))
1607 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
01c52d31
MB
1608 (dolist (method gnus-decode-encoded-word-methods)
1609 (if (symbolp method)
1610 (nconc gnus-decode-encoded-word-methods-cache (list method))
1611 (if (and gnus-newsgroup-name
1612 (string-match (car method) gnus-newsgroup-name))
1613 (nconc gnus-decode-encoded-word-methods-cache
1614 (list (cdr method)))))))
1615 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1616 (setq string (funcall method string))))
16409b0b 1617
eec82323
LMI
1618;; Subject simplification.
1619
6748645f 1620(defun gnus-simplify-whitespace (str)
16409b0b 1621 "Remove excessive whitespace from STR."
23f87bed
MB
1622 ;; Multiple spaces.
1623 (while (string-match "[ \t][ \t]+" str)
1624 (setq str (concat (substring str 0 (match-beginning 0))
1625 " "
1626 (substring str (match-end 0)))))
1627 ;; Leading spaces.
1628 (when (string-match "^[ \t]+" str)
1629 (setq str (substring str (match-end 0))))
1630 ;; Trailing spaces.
1631 (when (string-match "[ \t]+$" str)
1632 (setq str (substring str 0 (match-beginning 0))))
1633 str)
1634
1635(defun gnus-simplify-all-whitespace (str)
1636 "Remove all whitespace from STR."
1637 (while (string-match "[ \t\n]+" str)
1638 (setq str (replace-match "" nil nil str)))
1639 str)
6748645f 1640
eec82323
LMI
1641(defsubst gnus-simplify-subject-re (subject)
1642 "Remove \"Re:\" from subject lines."
23f87bed 1643 (if (string-match message-subject-re-regexp subject)
eec82323
LMI
1644 (substring subject (match-end 0))
1645 subject))
1646
1647(defun gnus-simplify-subject (subject &optional re-only)
1648 "Remove `Re:' and words in parentheses.
1649If RE-ONLY is non-nil, strip leading `Re:'s only."
1650 (let ((case-fold-search t)) ;Ignore case.
1651 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1652 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1653 (setq subject (substring subject (match-end 0))))
1654 ;; Remove uninteresting prefixes.
1655 (when (and (not re-only)
1656 gnus-simplify-ignored-prefixes
1657 (string-match gnus-simplify-ignored-prefixes subject))
1658 (setq subject (substring subject (match-end 0))))
1659 ;; Remove words in parentheses from end.
1660 (unless re-only
1661 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1662 (setq subject (substring subject 0 (match-beginning 0)))))
1663 ;; Return subject string.
1664 subject))
1665
1666;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1667;; all whitespace.
1668(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1669 (goto-char (point-min))
1670 (while (re-search-forward regexp nil t)
16409b0b 1671 (replace-match (or newtext ""))))
eec82323
LMI
1672
1673(defun gnus-simplify-buffer-fuzzy ()
1674 "Simplify string in the buffer fuzzily.
1675The string in the accessible portion of the current buffer is simplified.
1676It is assumed to be a single-line subject.
1677Whitespace is generally cleaned up, and miscellaneous leading/trailing
1678matter is removed. Additional things can be deleted by setting
16409b0b 1679`gnus-simplify-subject-fuzzy-regexp'."
eec82323
LMI
1680 (let ((case-fold-search t)
1681 (modified-tick))
1682 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1683
1684 (while (not (eq modified-tick (buffer-modified-tick)))
1685 (setq modified-tick (buffer-modified-tick))
1686 (cond
1687 ((listp gnus-simplify-subject-fuzzy-regexp)
01c52d31
MB
1688 (mapc 'gnus-simplify-buffer-fuzzy-step
1689 gnus-simplify-subject-fuzzy-regexp))
eec82323
LMI
1690 (gnus-simplify-subject-fuzzy-regexp
1691 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1692 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1693 (gnus-simplify-buffer-fuzzy-step
1694 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1695 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1696
1697 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1698 (gnus-simplify-buffer-fuzzy-step " +" " ")
1699 (gnus-simplify-buffer-fuzzy-step " $")
1700 (gnus-simplify-buffer-fuzzy-step "^ +")))
1701
1702(defun gnus-simplify-subject-fuzzy (subject)
1703 "Simplify a subject string fuzzily.
6748645f 1704See `gnus-simplify-buffer-fuzzy' for details."
eec82323
LMI
1705 (save-excursion
1706 (gnus-set-work-buffer)
1707 (let ((case-fold-search t))
6748645f
LMI
1708 ;; Remove uninteresting prefixes.
1709 (when (and gnus-simplify-ignored-prefixes
1710 (string-match gnus-simplify-ignored-prefixes subject))
1711 (setq subject (substring subject (match-end 0))))
eec82323
LMI
1712 (insert subject)
1713 (inline (gnus-simplify-buffer-fuzzy))
1714 (buffer-string))))
1715
1716(defsubst gnus-simplify-subject-fully (subject)
23f87bed 1717 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
eec82323 1718 (cond
6748645f
LMI
1719 (gnus-simplify-subject-functions
1720 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1721 ((null gnus-summary-gather-subject-limit)
1722 (gnus-simplify-subject-re subject))
1723 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1724 (gnus-simplify-subject-fuzzy subject))
1725 ((numberp gnus-summary-gather-subject-limit)
01c52d31
MB
1726 (truncate-string-to-width (gnus-simplify-subject-re subject)
1727 gnus-summary-gather-subject-limit))
eec82323
LMI
1728 (t
1729 subject)))
1730
1731(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f 1732 "Check whether two subjects are equal.
23f87bed 1733If optional argument SIMPLE-FIRST is t, first argument is already
6748645f 1734simplified."
eec82323
LMI
1735 (cond
1736 ((null simple-first)
1737 (equal (gnus-simplify-subject-fully s1)
1738 (gnus-simplify-subject-fully s2)))
1739 (t
1740 (equal s1
1741 (gnus-simplify-subject-fully s2)))))
1742
1743(defun gnus-summary-bubble-group ()
1744 "Increase the score of the current group.
1745This is a handy function to add to `gnus-summary-exit-hook' to
1746increase the score of each group you read."
1747 (gnus-group-add-score gnus-newsgroup-name))
1748
1749\f
1750;;;
1751;;; Gnus summary mode
1752;;;
1753
1754(put 'gnus-summary-mode 'mode-class 'special)
1755
1653df0f
SZ
1756(defvar gnus-article-commands-menu)
1757
23f87bed
MB
1758;; Non-orthogonal keys
1759
1760(gnus-define-keys gnus-summary-mode-map
1761 " " gnus-summary-next-page
1762 "\177" gnus-summary-prev-page
1763 [delete] gnus-summary-prev-page
1764 [backspace] gnus-summary-prev-page
1765 "\r" gnus-summary-scroll-up
1766 "\M-\r" gnus-summary-scroll-down
1767 "n" gnus-summary-next-unread-article
1768 "p" gnus-summary-prev-unread-article
1769 "N" gnus-summary-next-article
1770 "P" gnus-summary-prev-article
1771 "\M-\C-n" gnus-summary-next-same-subject
1772 "\M-\C-p" gnus-summary-prev-same-subject
1773 "\M-n" gnus-summary-next-unread-subject
1774 "\M-p" gnus-summary-prev-unread-subject
1775 "." gnus-summary-first-unread-article
1776 "," gnus-summary-best-unread-article
1777 "\M-s" gnus-summary-search-article-forward
1778 "\M-r" gnus-summary-search-article-backward
01c52d31
MB
1779 "\M-S" gnus-summary-repeat-search-article-forward
1780 "\M-R" gnus-summary-repeat-search-article-backward
23f87bed
MB
1781 "<" gnus-summary-beginning-of-article
1782 ">" gnus-summary-end-of-article
1783 "j" gnus-summary-goto-article
1784 "^" gnus-summary-refer-parent-article
1785 "\M-^" gnus-summary-refer-article
1786 "u" gnus-summary-tick-article-forward
1787 "!" gnus-summary-tick-article-forward
1788 "U" gnus-summary-tick-article-backward
1789 "d" gnus-summary-mark-as-read-forward
1790 "D" gnus-summary-mark-as-read-backward
1791 "E" gnus-summary-mark-as-expirable
1792 "\M-u" gnus-summary-clear-mark-forward
1793 "\M-U" gnus-summary-clear-mark-backward
1794 "k" gnus-summary-kill-same-subject-and-select
1795 "\C-k" gnus-summary-kill-same-subject
1796 "\M-\C-k" gnus-summary-kill-thread
1797 "\M-\C-l" gnus-summary-lower-thread
1798 "e" gnus-summary-edit-article
1799 "#" gnus-summary-mark-as-processable
1800 "\M-#" gnus-summary-unmark-as-processable
1801 "\M-\C-t" gnus-summary-toggle-threads
1802 "\M-\C-s" gnus-summary-show-thread
1803 "\M-\C-h" gnus-summary-hide-thread
1804 "\M-\C-f" gnus-summary-next-thread
1805 "\M-\C-b" gnus-summary-prev-thread
1806 [(meta down)] gnus-summary-next-thread
1807 [(meta up)] gnus-summary-prev-thread
1808 "\M-\C-u" gnus-summary-up-thread
1809 "\M-\C-d" gnus-summary-down-thread
1810 "&" gnus-summary-execute-command
1811 "c" gnus-summary-catchup-and-exit
1812 "\C-w" gnus-summary-mark-region-as-read
1813 "\C-t" gnus-summary-toggle-truncation
1814 "?" gnus-summary-mark-as-dormant
1815 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1816 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1817 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1818 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1819 "\C-c\C-s\C-a" gnus-summary-sort-by-author
01c52d31 1820 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
23f87bed
MB
1821 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1822 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1823 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1824 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1825 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1826 "=" gnus-summary-expand-window
1827 "\C-x\C-s" gnus-summary-reselect-current-group
1828 "\M-g" gnus-summary-rescan-group
1829 "w" gnus-summary-stop-page-breaking
1830 "\C-c\C-r" gnus-summary-caesar-message
1831 "f" gnus-summary-followup
1832 "F" gnus-summary-followup-with-original
1833 "C" gnus-summary-cancel-article
1834 "r" gnus-summary-reply
1835 "R" gnus-summary-reply-with-original
1836 "\C-c\C-f" gnus-summary-mail-forward
1837 "o" gnus-summary-save-article
1838 "\C-o" gnus-summary-save-article-mail
1839 "|" gnus-summary-pipe-output
1840 "\M-k" gnus-summary-edit-local-kill
1841 "\M-K" gnus-summary-edit-global-kill
1842 ;; "V" gnus-version
1843 "\C-c\C-d" gnus-summary-describe-group
1844 "q" gnus-summary-exit
1845 "Q" gnus-summary-exit-no-update
1846 "\C-c\C-i" gnus-info-find-node
1847 gnus-mouse-2 gnus-mouse-pick-article
132cf96d 1848 [follow-link] mouse-face
23f87bed
MB
1849 "m" gnus-summary-mail-other-window
1850 "a" gnus-summary-post-news
1851 "i" gnus-summary-news-other-window
1852 "x" gnus-summary-limit-to-unread
1853 "s" gnus-summary-isearch-article
1854 "t" gnus-summary-toggle-header
1855 "g" gnus-summary-show-article
1856 "l" gnus-summary-goto-last-article
1857 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1858 "\C-d" gnus-summary-enter-digest-group
1859 "\M-\C-d" gnus-summary-read-document
1860 "\M-\C-e" gnus-summary-edit-parameters
1861 "\M-\C-a" gnus-summary-customize-parameters
1862 "\C-c\C-b" gnus-bug
1863 "*" gnus-cache-enter-article
1864 "\M-*" gnus-cache-remove-article
1865 "\M-&" gnus-summary-universal-argument
1866 "\C-l" gnus-recenter
1867 "I" gnus-summary-increase-score
1868 "L" gnus-summary-lower-score
1869 "\M-i" gnus-symbolic-argument
1870 "h" gnus-summary-select-article-buffer
1871
1872 "b" gnus-article-view-part
1873 "\M-t" gnus-summary-toggle-display-buttonized
1874
1875 "V" gnus-summary-score-map
1876 "X" gnus-uu-extract-map
1877 "S" gnus-summary-send-map)
1878
1879;; Sort of orthogonal keymap
1880(gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1881 "t" gnus-summary-tick-article-forward
1882 "!" gnus-summary-tick-article-forward
1883 "d" gnus-summary-mark-as-read-forward
1884 "r" gnus-summary-mark-as-read-forward
1885 "c" gnus-summary-clear-mark-forward
1886 " " gnus-summary-clear-mark-forward
1887 "e" gnus-summary-mark-as-expirable
1888 "x" gnus-summary-mark-as-expirable
1889 "?" gnus-summary-mark-as-dormant
1890 "b" gnus-summary-set-bookmark
1891 "B" gnus-summary-remove-bookmark
1892 "#" gnus-summary-mark-as-processable
1893 "\M-#" gnus-summary-unmark-as-processable
1894 "S" gnus-summary-limit-include-expunged
1895 "C" gnus-summary-catchup
1896 "H" gnus-summary-catchup-to-here
1897 "h" gnus-summary-catchup-from-here
1898 "\C-c" gnus-summary-catchup-all
1899 "k" gnus-summary-kill-same-subject-and-select
1900 "K" gnus-summary-kill-same-subject
1901 "P" gnus-uu-mark-map)
1902
1903(gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1904 "c" gnus-summary-clear-above
1905 "u" gnus-summary-tick-above
1906 "m" gnus-summary-mark-above
1907 "k" gnus-summary-kill-below)
1908
1909(gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1910 "/" gnus-summary-limit-to-subject
1911 "n" gnus-summary-limit-to-articles
01c52d31
MB
1912 "b" gnus-summary-limit-to-bodies
1913 "h" gnus-summary-limit-to-headers
23f87bed
MB
1914 "w" gnus-summary-pop-limit
1915 "s" gnus-summary-limit-to-subject
1916 "a" gnus-summary-limit-to-author
1917 "u" gnus-summary-limit-to-unread
1918 "m" gnus-summary-limit-to-marks
1919 "M" gnus-summary-limit-exclude-marks
1920 "v" gnus-summary-limit-to-score
1921 "*" gnus-summary-limit-include-cached
1922 "D" gnus-summary-limit-include-dormant
1923 "T" gnus-summary-limit-include-thread
1924 "d" gnus-summary-limit-exclude-dormant
1925 "t" gnus-summary-limit-to-age
1926 "." gnus-summary-limit-to-unseen
1927 "x" gnus-summary-limit-to-extra
1928 "p" gnus-summary-limit-to-display-predicate
1929 "E" gnus-summary-limit-include-expunged
1930 "c" gnus-summary-limit-exclude-childless-dormant
1931 "C" gnus-summary-limit-mark-excluded-as-read
1932 "o" gnus-summary-insert-old-articles
01c52d31
MB
1933 "N" gnus-summary-insert-new-articles
1934 "S" gnus-summary-limit-to-singletons
1935 "r" gnus-summary-limit-to-replied
1936 "R" gnus-summary-limit-to-recipient
1937 "A" gnus-summary-limit-to-address)
23f87bed
MB
1938
1939(gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1940 "n" gnus-summary-next-unread-article
1941 "p" gnus-summary-prev-unread-article
1942 "N" gnus-summary-next-article
1943 "P" gnus-summary-prev-article
1944 "\C-n" gnus-summary-next-same-subject
1945 "\C-p" gnus-summary-prev-same-subject
1946 "\M-n" gnus-summary-next-unread-subject
1947 "\M-p" gnus-summary-prev-unread-subject
1948 "f" gnus-summary-first-unread-article
1949 "b" gnus-summary-best-unread-article
1950 "j" gnus-summary-goto-article
1951 "g" gnus-summary-goto-subject
1952 "l" gnus-summary-goto-last-article
1953 "o" gnus-summary-pop-article)
1954
1955(gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1956 "k" gnus-summary-kill-thread
01c52d31 1957 "E" gnus-summary-expire-thread
23f87bed
MB
1958 "l" gnus-summary-lower-thread
1959 "i" gnus-summary-raise-thread
1960 "T" gnus-summary-toggle-threads
1961 "t" gnus-summary-rethread-current
1962 "^" gnus-summary-reparent-thread
01c52d31 1963 "\M-^" gnus-summary-reparent-children
23f87bed
MB
1964 "s" gnus-summary-show-thread
1965 "S" gnus-summary-show-all-threads
1966 "h" gnus-summary-hide-thread
1967 "H" gnus-summary-hide-all-threads
1968 "n" gnus-summary-next-thread
1969 "p" gnus-summary-prev-thread
1970 "u" gnus-summary-up-thread
1971 "o" gnus-summary-top-thread
1972 "d" gnus-summary-down-thread
1973 "#" gnus-uu-mark-thread
1974 "\M-#" gnus-uu-unmark-thread)
1975
1976(gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1977 "g" gnus-summary-prepare
1978 "c" gnus-summary-insert-cached-articles
01c52d31
MB
1979 "d" gnus-summary-insert-dormant-articles
1980 "t" gnus-summary-insert-ticked-articles)
23f87bed
MB
1981
1982(gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1983 "c" gnus-summary-catchup-and-exit
1984 "C" gnus-summary-catchup-all-and-exit
1985 "E" gnus-summary-exit-no-update
1986 "Q" gnus-summary-exit
1987 "Z" gnus-summary-exit
1988 "n" gnus-summary-catchup-and-goto-next-group
01c52d31 1989 "p" gnus-summary-catchup-and-goto-prev-group
23f87bed
MB
1990 "R" gnus-summary-reselect-current-group
1991 "G" gnus-summary-rescan-group
1992 "N" gnus-summary-next-group
1993 "s" gnus-summary-save-newsrc
1994 "P" gnus-summary-prev-group)
1995
1996(gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1997 " " gnus-summary-next-page
1998 "n" gnus-summary-next-page
1999 "\177" gnus-summary-prev-page
2000 [delete] gnus-summary-prev-page
2001 "p" gnus-summary-prev-page
2002 "\r" gnus-summary-scroll-up
2003 "\M-\r" gnus-summary-scroll-down
2004 "<" gnus-summary-beginning-of-article
2005 ">" gnus-summary-end-of-article
2006 "b" gnus-summary-beginning-of-article
2007 "e" gnus-summary-end-of-article
2008 "^" gnus-summary-refer-parent-article
2009 "r" gnus-summary-refer-parent-article
2010 "D" gnus-summary-enter-digest-group
2011 "R" gnus-summary-refer-references
2012 "T" gnus-summary-refer-thread
2013 "g" gnus-summary-show-article
2014 "s" gnus-summary-isearch-article
2015 "P" gnus-summary-print-article
01c52d31 2016 "S" gnus-sticky-article
23f87bed
MB
2017 "M" gnus-mailing-list-insinuate
2018 "t" gnus-article-babel)
2019
2020(gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2021 "b" gnus-article-add-buttons
2022 "B" gnus-article-add-buttons-to-head
2023 "o" gnus-article-treat-overstrike
2024 "e" gnus-article-emphasize
2025 "w" gnus-article-fill-cited-article
2026 "Q" gnus-article-fill-long-lines
01c52d31 2027 "L" gnus-article-toggle-truncate-lines
23f87bed
MB
2028 "C" gnus-article-capitalize-sentences
2029 "c" gnus-article-remove-cr
2030 "q" gnus-article-de-quoted-unreadable
2031 "6" gnus-article-de-base64-unreadable
2032 "Z" gnus-article-decode-HZ
01c52d31 2033 "A" gnus-article-treat-ansi-sequences
23f87bed
MB
2034 "h" gnus-article-wash-html
2035 "u" gnus-article-unsplit-urls
2036 "s" gnus-summary-force-verify-and-decrypt
2037 "f" gnus-article-display-x-face
2038 "l" gnus-summary-stop-page-breaking
2039 "r" gnus-summary-caesar-message
2040 "m" gnus-summary-morse-message
2041 "t" gnus-summary-toggle-header
2042 "g" gnus-treat-smiley
2043 "v" gnus-summary-verbose-headers
2044 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2045 "p" gnus-article-verify-x-pgp-sig
01c52d31
MB
2046 "d" gnus-article-treat-dumbquotes
2047 "i" gnus-summary-idna-message)
23f87bed
MB
2048
2049(gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2050 ;; mnemonic: deuglif*Y*
2051 "u" gnus-article-outlook-unwrap-lines
2052 "a" gnus-article-outlook-repair-attribution
2053 "c" gnus-article-outlook-rearrange-citation
2054 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2055
2056(gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2057 "a" gnus-article-hide
2058 "h" gnus-article-hide-headers
2059 "b" gnus-article-hide-boring-headers
2060 "s" gnus-article-hide-signature
2061 "c" gnus-article-hide-citation
2062 "C" gnus-article-hide-citation-in-followups
2063 "l" gnus-article-hide-list-identifiers
2064 "B" gnus-article-strip-banner
2065 "P" gnus-article-hide-pem
2066 "\C-c" gnus-article-hide-citation-maybe)
2067
2068(gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2069 "a" gnus-article-highlight
2070 "h" gnus-article-highlight-headers
2071 "c" gnus-article-highlight-citation
2072 "s" gnus-article-highlight-signature)
2073
2074(gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2075 "f" gnus-article-treat-fold-headers
2076 "u" gnus-article-treat-unfold-headers
2077 "n" gnus-article-treat-fold-newsgroups)
2078
2079(gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2080 "x" gnus-article-display-x-face
2081 "d" gnus-article-display-face
2082 "s" gnus-treat-smiley
2083 "D" gnus-article-remove-images
2084 "f" gnus-treat-from-picon
2085 "m" gnus-treat-mail-picon
2086 "n" gnus-treat-newsgroups-picon)
2087
2088(gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2089 "w" gnus-article-decode-mime-words
2090 "c" gnus-article-decode-charset
2091 "v" gnus-mime-view-all-parts
2092 "b" gnus-article-view-part)
2093
2094(gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2095 "z" gnus-article-date-ut
2096 "u" gnus-article-date-ut
2097 "l" gnus-article-date-local
2098 "p" gnus-article-date-english
2099 "e" gnus-article-date-lapsed
2100 "o" gnus-article-date-original
2101 "i" gnus-article-date-iso8601
2102 "s" gnus-article-date-user)
2103
2104(gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2105 "t" gnus-article-remove-trailing-blank-lines
2106 "l" gnus-article-strip-leading-blank-lines
2107 "m" gnus-article-strip-multiple-blank-lines
2108 "a" gnus-article-strip-blank-lines
2109 "A" gnus-article-strip-all-blank-lines
2110 "s" gnus-article-strip-leading-space
2111 "e" gnus-article-strip-trailing-space
2112 "w" gnus-article-remove-leading-whitespace)
2113
2114(gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2115 "v" gnus-version
2116 "f" gnus-summary-fetch-faq
2117 "d" gnus-summary-describe-group
2118 "h" gnus-summary-describe-briefly
2119 "i" gnus-info-find-node
2120 "c" gnus-group-fetch-charter
2121 "C" gnus-group-fetch-control)
2122
2123(gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2124 "e" gnus-summary-expire-articles
2125 "\M-\C-e" gnus-summary-expire-articles-now
2126 "\177" gnus-summary-delete-article
2127 [delete] gnus-summary-delete-article
2128 [backspace] gnus-summary-delete-article
2129 "m" gnus-summary-move-article
2130 "r" gnus-summary-respool-article
2131 "w" gnus-summary-edit-article
2132 "c" gnus-summary-copy-article
2133 "B" gnus-summary-crosspost-article
2134 "q" gnus-summary-respool-query
2135 "t" gnus-summary-respool-trace
2136 "i" gnus-summary-import-article
2137 "I" gnus-summary-create-article
2138 "p" gnus-summary-article-posted-p)
2139
2140(gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2141 "o" gnus-summary-save-article
2142 "m" gnus-summary-save-article-mail
2143 "F" gnus-summary-write-article-file
2144 "r" gnus-summary-save-article-rmail
2145 "f" gnus-summary-save-article-file
2146 "b" gnus-summary-save-article-body-file
26c9afc3 2147 "B" gnus-summary-write-article-body-file
23f87bed
MB
2148 "h" gnus-summary-save-article-folder
2149 "v" gnus-summary-save-article-vm
2150 "p" gnus-summary-pipe-output
2151 "P" gnus-summary-muttprint
2152 "s" gnus-soup-add-article)
2153
2154(gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2155 "b" gnus-summary-display-buttonized
2156 "m" gnus-summary-repair-multipart
2157 "v" gnus-article-view-part
2158 "o" gnus-article-save-part
01c52d31
MB
2159 "O" gnus-article-save-part-and-strip
2160 "r" gnus-article-replace-part
2161 "d" gnus-article-delete-part
2162 "t" gnus-article-view-part-as-type
2163 "j" gnus-article-jump-to-part
23f87bed
MB
2164 "c" gnus-article-copy-part
2165 "C" gnus-article-view-part-as-charset
2166 "e" gnus-article-view-part-externally
01c52d31 2167 "H" gnus-article-browse-html-article
23f87bed
MB
2168 "E" gnus-article-encrypt-body
2169 "i" gnus-article-inline-part
2170 "|" gnus-article-pipe-part)
2171
2172(gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2173 "p" gnus-summary-mark-as-processable
2174 "u" gnus-summary-unmark-as-processable
2175 "U" gnus-summary-unmark-all-processable
2176 "v" gnus-uu-mark-over
2177 "s" gnus-uu-mark-series
2178 "r" gnus-uu-mark-region
2179 "g" gnus-uu-unmark-region
2180 "R" gnus-uu-mark-by-regexp
2181 "G" gnus-uu-unmark-by-regexp
2182 "t" gnus-uu-mark-thread
2183 "T" gnus-uu-unmark-thread
2184 "a" gnus-uu-mark-all
2185 "b" gnus-uu-mark-buffer
2186 "S" gnus-uu-mark-sparse
2187 "k" gnus-summary-kill-process-mark
2188 "y" gnus-summary-yank-process-mark
2189 "w" gnus-summary-save-process-mark
2190 "i" gnus-uu-invert-processable)
2191
2192(gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2193 ;;"x" gnus-uu-extract-any
2194 "m" gnus-summary-save-parts
2195 "u" gnus-uu-decode-uu
2196 "U" gnus-uu-decode-uu-and-save
2197 "s" gnus-uu-decode-unshar
2198 "S" gnus-uu-decode-unshar-and-save
2199 "o" gnus-uu-decode-save
2200 "O" gnus-uu-decode-save
2201 "b" gnus-uu-decode-binhex
2202 "B" gnus-uu-decode-binhex
b890d447 2203 "Y" gnus-uu-decode-yenc
23f87bed
MB
2204 "p" gnus-uu-decode-postscript
2205 "P" gnus-uu-decode-postscript-and-save)
2206
2207(gnus-define-keys
2208 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2209 "u" gnus-uu-decode-uu-view
2210 "U" gnus-uu-decode-uu-and-save-view
2211 "s" gnus-uu-decode-unshar-view
2212 "S" gnus-uu-decode-unshar-and-save-view
2213 "o" gnus-uu-decode-save-view
2214 "O" gnus-uu-decode-save-view
2215 "b" gnus-uu-decode-binhex-view
2216 "B" gnus-uu-decode-binhex-view
2217 "p" gnus-uu-decode-postscript-view
2218 "P" gnus-uu-decode-postscript-and-save-view)
2219
2220(defvar gnus-article-post-menu nil)
2221
2222(defconst gnus-summary-menu-maxlen 20)
2223
2224(defun gnus-summary-menu-split (menu)
2225 ;; If we have lots of elements, divide them into groups of 20
2226 ;; and make a pane (or submenu) for each one.
2227 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2228 (let ((menu menu) sublists next
2229 (i 1))
2230 (while menu
2231 ;; Pull off the next gnus-summary-menu-maxlen elements
2232 ;; and make them the next element of sublist.
2233 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2234 (if next
2235 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2236 nil))
2237 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2238 (aref (car (last menu)) 0)) menu)
2239 sublists))
2240 (setq i (1+ i))
2241 (setq menu next))
2242 (nreverse sublists))
2243 ;; Few elements--put them all in one pane.
2244 menu))
eec82323
LMI
2245
2246(defun gnus-summary-make-menu-bar ()
2247 (gnus-turn-off-edit-menu 'summary)
2248
2249 (unless (boundp 'gnus-summary-misc-menu)
2250
2251 (easy-menu-define
23f87bed
MB
2252 gnus-summary-kill-menu gnus-summary-mode-map ""
2253 (cons
2254 "Score"
2255 (nconc
2256 (list
2257 ["Customize" gnus-score-customize t])
2258 (gnus-make-score-map 'increase)
2259 (gnus-make-score-map 'lower)
2260 '(("Mark"
2261 ["Kill below" gnus-summary-kill-below t]
2262 ["Mark above" gnus-summary-mark-above t]
2263 ["Tick above" gnus-summary-tick-above t]
2264 ["Clear above" gnus-summary-clear-above t])
2265 ["Current score" gnus-summary-current-score t]
2266 ["Set score" gnus-summary-set-score t]
2267 ["Switch current score file..." gnus-score-change-score-file t]
2268 ["Set mark below..." gnus-score-set-mark-below t]
2269 ["Set expunge below..." gnus-score-set-expunge-below t]
2270 ["Edit current score file" gnus-score-edit-current-scores t]
2271 ["Edit score file" gnus-score-edit-file t]
2272 ["Trace score" gnus-score-find-trace t]
2273 ["Find words" gnus-score-find-favourite-words t]
2274 ["Rescore buffer" gnus-summary-rescore t]
2275 ["Increase score..." gnus-summary-increase-score t]
2276 ["Lower score..." gnus-summary-lower-score t]))))
2277
2278 ;; Define both the Article menu in the summary buffer and the
2279 ;; equivalent Commands menu in the article buffer here for
2280 ;; consistency.
6748645f 2281 (let ((innards
23f87bed
MB
2282 `(("Hide"
2283 ["All" gnus-article-hide t]
2284 ["Headers" gnus-article-hide-headers t]
2285 ["Signature" gnus-article-hide-signature t]
2286 ["Citation" gnus-article-hide-citation t]
16409b0b 2287 ["List identifiers" gnus-article-hide-list-identifiers t]
16409b0b 2288 ["Banner" gnus-article-strip-banner t]
23f87bed
MB
2289 ["Boring headers" gnus-article-hide-boring-headers t])
2290 ("Highlight"
2291 ["All" gnus-article-highlight t]
2292 ["Headers" gnus-article-highlight-headers t]
2293 ["Signature" gnus-article-highlight-signature t]
2294 ["Citation" gnus-article-highlight-citation t])
16409b0b
GM
2295 ("MIME"
2296 ["Words" gnus-article-decode-mime-words t]
2297 ["Charset" gnus-article-decode-charset t]
2298 ["QP" gnus-article-de-quoted-unreadable t]
2299 ["Base64" gnus-article-de-base64-unreadable t]
23f87bed
MB
2300 ["View MIME buttons" gnus-summary-display-buttonized t]
2301 ["View all" gnus-mime-view-all-parts t]
2302 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2303 ["Encrypt body" gnus-article-encrypt-body
2304 :active (not (gnus-group-read-only-p))
2305 ,@(if (featurep 'xemacs) nil
2306 '(:help "Encrypt the message body on disk"))]
2307 ["Extract all parts..." gnus-summary-save-parts t]
2308 ("Multipart"
2309 ["Repair multipart" gnus-summary-repair-multipart t]
2310 ["Pipe part..." gnus-article-pipe-part t]
2311 ["Inline part" gnus-article-inline-part t]
01c52d31 2312 ["View part as type..." gnus-article-view-part-as-type t]
23f87bed
MB
2313 ["Encrypt body" gnus-article-encrypt-body
2314 :active (not (gnus-group-read-only-p))
2315 ,@(if (featurep 'xemacs) nil
2316 '(:help "Encrypt the message body on disk"))]
2317 ["View part externally" gnus-article-view-part-externally t]
01c52d31 2318 ["View HTML parts in browser" gnus-article-browse-html-article t]
23f87bed
MB
2319 ["View part with charset..." gnus-article-view-part-as-charset t]
2320 ["Copy part" gnus-article-copy-part t]
2321 ["Save part..." gnus-article-save-part t]
2322 ["View part" gnus-article-view-part t]))
2323 ("Date"
2324 ["Local" gnus-article-date-local t]
2325 ["ISO8601" gnus-article-date-iso8601 t]
2326 ["UT" gnus-article-date-ut t]
2327 ["Original" gnus-article-date-original t]
2328 ["Lapsed" gnus-article-date-lapsed t]
2329 ["User-defined" gnus-article-date-user t])
2330 ("Display"
2331 ["Remove images" gnus-article-remove-images t]
2332 ["Toggle smiley" gnus-treat-smiley t]
2333 ["Show X-Face" gnus-article-display-x-face t]
2334 ["Show picons in From" gnus-treat-from-picon t]
2335 ["Show picons in mail headers" gnus-treat-mail-picon t]
2336 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2337 ("View as different encoding"
2338 ,@(gnus-summary-menu-split
2339 (mapcar
2340 (lambda (cs)
2341 ;; Since easymenu under Emacs doesn't allow
2342 ;; lambda forms for menu commands, we should
2343 ;; provide intern'ed function symbols.
2344 (let ((command (intern (format "\
2345gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2346 (fset command
2347 `(lambda ()
2348 (interactive)
2349 (let ((gnus-summary-show-article-charset-alist
2350 '((1 . ,cs))))
2351 (gnus-summary-show-article 1))))
2352 `[,(symbol-name cs) ,command t]))
2353 (sort (if (fboundp 'coding-system-list)
2354 (coding-system-list)
2355 (mapcar 'car mm-mime-mule-charset-alist))
2356 'string<)))))
2357 ("Washing"
2358 ("Remove Blanks"
2359 ["Leading" gnus-article-strip-leading-blank-lines t]
2360 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2361 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2362 ["All of the above" gnus-article-strip-blank-lines t]
2363 ["All" gnus-article-strip-all-blank-lines t]
2364 ["Leading space" gnus-article-strip-leading-space t]
2365 ["Trailing space" gnus-article-strip-trailing-space t]
2366 ["Leading space in headers"
2367 gnus-article-remove-leading-whitespace t])
2368 ["Overstrike" gnus-article-treat-overstrike t]
2369 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2370 ["Emphasis" gnus-article-emphasize t]
2371 ["Word wrap" gnus-article-fill-cited-article t]
16409b0b 2372 ["Fill long lines" gnus-article-fill-long-lines t]
01c52d31 2373 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
16409b0b 2374 ["Capitalize sentences" gnus-article-capitalize-sentences t]
23f87bed
MB
2375 ["Remove CR" gnus-article-remove-cr t]
2376 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2377 ["Base64" gnus-article-de-base64-unreadable t]
2378 ["Rot 13" gnus-summary-caesar-message
2379 ,@(if (featurep 'xemacs) '(t)
2380 '(:help "\"Caesar rotate\" article by 13"))]
01c52d31 2381 ["De-IDNA" gnus-summary-idna-message t]
23f87bed
MB
2382 ["Morse decode" gnus-summary-morse-message t]
2383 ["Unix pipe..." gnus-summary-pipe-message t]
2384 ["Add buttons" gnus-article-add-buttons t]
2385 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2386 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2387 ["Verbose header" gnus-summary-verbose-headers t]
2388 ["Toggle header" gnus-summary-toggle-header t]
2389 ["Unfold headers" gnus-article-treat-unfold-headers t]
2390 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
16409b0b 2391 ["Html" gnus-article-wash-html t]
23f87bed
MB
2392 ["Unsplit URLs" gnus-article-unsplit-urls t]
2393 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2394 ["Decode HZ" gnus-article-decode-HZ t]
01c52d31 2395 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
23f87bed
MB
2396 ("(Outlook) Deuglify"
2397 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2398 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2399 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2400 ["Full (Outlook) deuglify"
2401 gnus-article-outlook-deuglify-article t])
2402 )
2403 ("Output"
2404 ["Save in default format..." gnus-summary-save-article
2405 ,@(if (featurep 'xemacs) '(t)
2406 '(:help "Save article using default method"))]
2407 ["Save in file..." gnus-summary-save-article-file
2408 ,@(if (featurep 'xemacs) '(t)
2409 '(:help "Save article in file"))]
2410 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2411 ["Save in MH folder..." gnus-summary-save-article-folder t]
2412 ["Save in VM folder..." gnus-summary-save-article-vm t]
2413 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2414 ["Save body in file..." gnus-summary-save-article-body-file t]
2415 ["Pipe through a filter..." gnus-summary-pipe-output t]
2416 ["Add to SOUP packet" gnus-soup-add-article t]
2417 ["Print with Muttprint..." gnus-summary-muttprint t]
531e5812
MB
2418 ["Print" gnus-summary-print-article
2419 ,@(if (featurep 'xemacs) '(t)
2420 '(:help "Generate and print a PostScript image"))])
2421 ("Copy, move,... (Backend)"
707f2b38 2422 ,@(if (featurep 'xemacs) nil
531e5812 2423 '(:help "Copying, moving, expiring articles..."))
23f87bed
MB
2424 ["Respool article..." gnus-summary-respool-article t]
2425 ["Move article..." gnus-summary-move-article
2426 (gnus-check-backend-function
2427 'request-move-article gnus-newsgroup-name)]
2428 ["Copy article..." gnus-summary-copy-article t]
2429 ["Crosspost article..." gnus-summary-crosspost-article
2430 (gnus-check-backend-function
2431 'request-replace-article gnus-newsgroup-name)]
2432 ["Import file..." gnus-summary-import-article
2433 (gnus-check-backend-function
2434 'request-accept-article gnus-newsgroup-name)]
2435 ["Create article..." gnus-summary-create-article
2436 (gnus-check-backend-function
2437 'request-accept-article gnus-newsgroup-name)]
2438 ["Check if posted" gnus-summary-article-posted-p t]
2439 ["Edit article" gnus-summary-edit-article
2440 (not (gnus-group-read-only-p))]
2441 ["Delete article" gnus-summary-delete-article
2442 (gnus-check-backend-function
2443 'request-expire-articles gnus-newsgroup-name)]
2444 ["Query respool" gnus-summary-respool-query t]
6748645f 2445 ["Trace respool" gnus-summary-respool-trace t]
23f87bed
MB
2446 ["Delete expirable articles" gnus-summary-expire-articles-now
2447 (gnus-check-backend-function
2448 'request-expire-articles gnus-newsgroup-name)])
2449 ("Extract"
2450 ["Uudecode" gnus-uu-decode-uu
2451 ,@(if (featurep 'xemacs) '(t)
2452 '(:help "Decode uuencoded article(s)"))]
2453 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2454 ["Unshar" gnus-uu-decode-unshar t]
2455 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2456 ["Save" gnus-uu-decode-save t]
2457 ["Binhex" gnus-uu-decode-binhex t]
2458 ["Postscript" gnus-uu-decode-postscript t]
2459 ["All MIME parts" gnus-summary-save-parts t])
2460 ("Cache"
2461 ["Enter article" gnus-cache-enter-article t]
2462 ["Remove article" gnus-cache-remove-article t])
16409b0b 2463 ["Translate" gnus-article-babel t]
23f87bed 2464 ["Select article buffer" gnus-summary-select-article-buffer t]
01c52d31 2465 ["Make article buffer sticky" gnus-sticky-article t]
23f87bed
MB
2466 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2467 ["Isearch article..." gnus-summary-isearch-article t]
2468 ["Beginning of the article" gnus-summary-beginning-of-article t]
2469 ["End of the article" gnus-summary-end-of-article t]
2470 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2471 ["Fetch referenced articles" gnus-summary-refer-references t]
2472 ["Fetch current thread" gnus-summary-refer-thread t]
2473 ["Fetch article with id..." gnus-summary-refer-article t]
2474 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2475 ["Redisplay" gnus-summary-show-article t]
2476 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
6748645f 2477 (easy-menu-define
23f87bed
MB
2478 gnus-summary-article-menu gnus-summary-mode-map ""
2479 (cons "Article" innards))
6748645f 2480
1653df0f
SZ
2481 (if (not (keymapp gnus-summary-article-menu))
2482 (easy-menu-define
2483 gnus-article-commands-menu gnus-article-mode-map ""
2484 (cons "Commands" innards))
2485 ;; in Emacs, don't share menu.
a1506d29 2486 (setq gnus-article-commands-menu
1653df0f
SZ
2487 (copy-keymap gnus-summary-article-menu))
2488 (define-key gnus-article-mode-map [menu-bar commands]
2489 (cons "Commands" gnus-article-commands-menu))))
eec82323
LMI
2490
2491 (easy-menu-define
23f87bed
MB
2492 gnus-summary-thread-menu gnus-summary-mode-map ""
2493 '("Threads"
2494 ["Find all messages in thread" gnus-summary-refer-thread t]
2495 ["Toggle threading" gnus-summary-toggle-threads t]
2496 ["Hide threads" gnus-summary-hide-all-threads t]
2497 ["Show threads" gnus-summary-show-all-threads t]
2498 ["Hide thread" gnus-summary-hide-thread t]
2499 ["Show thread" gnus-summary-show-thread t]
2500 ["Go to next thread" gnus-summary-next-thread t]
2501 ["Go to previous thread" gnus-summary-prev-thread t]
2502 ["Go down thread" gnus-summary-down-thread t]
2503 ["Go up thread" gnus-summary-up-thread t]
2504 ["Top of thread" gnus-summary-top-thread t]
2505 ["Mark thread as read" gnus-summary-kill-thread t]
01c52d31 2506 ["Mark thread as expired" gnus-summary-expire-thread t]
23f87bed
MB
2507 ["Lower thread score" gnus-summary-lower-thread t]
2508 ["Raise thread score" gnus-summary-raise-thread t]
2509 ["Rethread current" gnus-summary-rethread-current t]))
eec82323
LMI
2510
2511 (easy-menu-define
23f87bed
MB
2512 gnus-summary-post-menu gnus-summary-mode-map ""
2513 `("Post"
2514 ["Send a message (mail or news)" gnus-summary-post-news
2515 ,@(if (featurep 'xemacs) '(t)
531e5812 2516 '(:help "Compose a new message (mail or news)"))]
23f87bed
MB
2517 ["Followup" gnus-summary-followup
2518 ,@(if (featurep 'xemacs) '(t)
2519 '(:help "Post followup to this article"))]
2520 ["Followup and yank" gnus-summary-followup-with-original
2521 ,@(if (featurep 'xemacs) '(t)
2522 '(:help "Post followup to this article, quoting its contents"))]
2523 ["Supersede article" gnus-summary-supersede-article t]
2524 ["Cancel article" gnus-summary-cancel-article
2525 ,@(if (featurep 'xemacs) '(t)
2526 '(:help "Cancel an article you posted"))]
2527 ["Reply" gnus-summary-reply t]
2528 ["Reply and yank" gnus-summary-reply-with-original t]
2529 ["Wide reply" gnus-summary-wide-reply t]
2530 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2531 ,@(if (featurep 'xemacs) '(t)
2532 '(:help "Mail a reply, quoting this article"))]
2533 ["Very wide reply" gnus-summary-very-wide-reply t]
2534 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2535 ,@(if (featurep 'xemacs) '(t)
2536 '(:help "Mail a very wide reply, quoting this article"))]
2537 ["Mail forward" gnus-summary-mail-forward t]
2538 ["Post forward" gnus-summary-post-forward t]
2539 ["Digest and mail" gnus-uu-digest-mail-forward t]
2540 ["Digest and post" gnus-uu-digest-post-forward t]
2541 ["Resend message" gnus-summary-resend-message t]
2542 ["Resend message edit" gnus-summary-resend-message-edit t]
2543 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2544 ["Send a mail" gnus-summary-mail-other-window t]
2545 ["Create a local message" gnus-summary-news-other-window t]
2546 ["Uuencode and post" gnus-uu-post-news
2547 ,@(if (featurep 'xemacs) '(t)
2548 '(:help "Post a uuencoded article"))]
2549 ["Followup via news" gnus-summary-followup-to-mail t]
2550 ["Followup via news and yank"
2551 gnus-summary-followup-to-mail-with-original t]
2552 ;;("Draft"
2553 ;;["Send" gnus-summary-send-draft t]
2554 ;;["Send bounced" gnus-resend-bounced-mail t])
2555 ))
2556
2557 (cond
2558 ((not (keymapp gnus-summary-post-menu))
2559 (setq gnus-article-post-menu gnus-summary-post-menu))
2560 ((not gnus-article-post-menu)
2561 ;; Don't share post menu.
2562 (setq gnus-article-post-menu
2563 (copy-keymap gnus-summary-post-menu))))
2564 (define-key gnus-article-mode-map [menu-bar post]
2565 (cons "Post" gnus-article-post-menu))
eec82323
LMI
2566
2567 (easy-menu-define
23f87bed
MB
2568 gnus-summary-misc-menu gnus-summary-mode-map ""
2569 `("Gnus"
2570 ("Mark Read"
2571 ["Mark as read" gnus-summary-mark-as-read-forward t]
2572 ["Mark same subject and select"
2573 gnus-summary-kill-same-subject-and-select t]
2574 ["Mark same subject" gnus-summary-kill-same-subject t]
2575 ["Catchup" gnus-summary-catchup
2576 ,@(if (featurep 'xemacs) '(t)
2577 '(:help "Mark unread articles in this group as read"))]
2578 ["Catchup all" gnus-summary-catchup-all t]
2579 ["Catchup to here" gnus-summary-catchup-to-here t]
2580 ["Catchup from here" gnus-summary-catchup-from-here t]
2581 ["Catchup region" gnus-summary-mark-region-as-read
2582 (gnus-mark-active-p)]
2583 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2584 ("Mark Various"
2585 ["Tick" gnus-summary-tick-article-forward t]
2586 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2587 ["Remove marks" gnus-summary-clear-mark-forward t]
2588 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2589 ["Set bookmark" gnus-summary-set-bookmark t]
2590 ["Remove bookmark" gnus-summary-remove-bookmark t])
2591 ("Limit to"
2592 ["Marks..." gnus-summary-limit-to-marks t]
2593 ["Subject..." gnus-summary-limit-to-subject t]
2594 ["Author..." gnus-summary-limit-to-author t]
01c52d31
MB
2595 ["Recipient..." gnus-summary-limit-to-recipient t]
2596 ["Address..." gnus-summary-limit-to-address t]
23f87bed
MB
2597 ["Age..." gnus-summary-limit-to-age t]
2598 ["Extra..." gnus-summary-limit-to-extra t]
2599 ["Score..." gnus-summary-limit-to-score t]
2600 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2601 ["Unread" gnus-summary-limit-to-unread t]
2602 ["Unseen" gnus-summary-limit-to-unseen t]
01c52d31
MB
2603 ["Singletons" gnus-summary-limit-to-singletons t]
2604 ["Replied" gnus-summary-limit-to-replied t]
23f87bed 2605 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
996aa8c1 2606 ["Next or process marked articles" gnus-summary-limit-to-articles t]
23f87bed
MB
2607 ["Pop limit" gnus-summary-pop-limit t]
2608 ["Show dormant" gnus-summary-limit-include-dormant t]
2609 ["Hide childless dormant"
2610 gnus-summary-limit-exclude-childless-dormant t]
2611 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2612 ["Hide marked" gnus-summary-limit-exclude-marks t]
2613 ["Show expunged" gnus-summary-limit-include-expunged t])
2614 ("Process Mark"
2615 ["Set mark" gnus-summary-mark-as-processable t]
2616 ["Remove mark" gnus-summary-unmark-as-processable t]
2617 ["Remove all marks" gnus-summary-unmark-all-processable t]
01c52d31 2618 ["Invert marks" gnus-uu-invert-processable t]
23f87bed
MB
2619 ["Mark above" gnus-uu-mark-over t]
2620 ["Mark series" gnus-uu-mark-series t]
2621 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2622 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2623 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2624 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2625 ["Mark all" gnus-uu-mark-all t]
2626 ["Mark buffer" gnus-uu-mark-buffer t]
2627 ["Mark sparse" gnus-uu-mark-sparse t]
2628 ["Mark thread" gnus-uu-mark-thread t]
2629 ["Unmark thread" gnus-uu-unmark-thread t]
2630 ("Process Mark Sets"
2631 ["Kill" gnus-summary-kill-process-mark t]
2632 ["Yank" gnus-summary-yank-process-mark
2633 gnus-newsgroup-process-stack]
2634 ["Save" gnus-summary-save-process-mark t]
2635 ["Run command on marked..." gnus-summary-universal-argument t]))
2636 ("Scroll article"
2637 ["Page forward" gnus-summary-next-page
2638 ,@(if (featurep 'xemacs) '(t)
2639 '(:help "Show next page of article"))]
2640 ["Page backward" gnus-summary-prev-page
2641 ,@(if (featurep 'xemacs) '(t)
2642 '(:help "Show previous page of article"))]
2643 ["Line forward" gnus-summary-scroll-up t])
2644 ("Move"
2645 ["Next unread article" gnus-summary-next-unread-article t]
2646 ["Previous unread article" gnus-summary-prev-unread-article t]
2647 ["Next article" gnus-summary-next-article t]
2648 ["Previous article" gnus-summary-prev-article t]
2649 ["Next unread subject" gnus-summary-next-unread-subject t]
2650 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2651 ["Next article same subject" gnus-summary-next-same-subject t]
2652 ["Previous article same subject" gnus-summary-prev-same-subject t]
2653 ["First unread article" gnus-summary-first-unread-article t]
2654 ["Best unread article" gnus-summary-best-unread-article t]
2655 ["Go to subject number..." gnus-summary-goto-subject t]
2656 ["Go to article number..." gnus-summary-goto-article t]
2657 ["Go to the last article" gnus-summary-goto-last-article t]
2658 ["Pop article off history" gnus-summary-pop-article t])
2659 ("Sort"
2660 ["Sort by number" gnus-summary-sort-by-number t]
2661 ["Sort by author" gnus-summary-sort-by-author t]
01c52d31 2662 ["Sort by recipient" gnus-summary-sort-by-recipient t]
23f87bed
MB
2663 ["Sort by subject" gnus-summary-sort-by-subject t]
2664 ["Sort by date" gnus-summary-sort-by-date t]
2665 ["Sort by score" gnus-summary-sort-by-score t]
2666 ["Sort by lines" gnus-summary-sort-by-lines t]
2667 ["Sort by characters" gnus-summary-sort-by-chars t]
2668 ["Randomize" gnus-summary-sort-by-random t]
2669 ["Original sort" gnus-summary-sort-by-original t])
2670 ("Help"
2671 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2672 ["Describe group" gnus-summary-describe-group t]
2673 ["Fetch charter" gnus-group-fetch-charter
2674 ,@(if (featurep 'xemacs) nil
2675 '(:help "Display the charter of the current group"))]
2676 ["Fetch control message" gnus-group-fetch-control
2677 ,@(if (featurep 'xemacs) nil
2678 '(:help "Display the archived control message for the current group"))]
2679 ["Read manual" gnus-info-find-node t])
2680 ("Modes"
2681 ["Pick and read" gnus-pick-mode t]
2682 ["Binary" gnus-binary-mode t])
2683 ("Regeneration"
2684 ["Regenerate" gnus-summary-prepare t]
2685 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2686 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
01c52d31 2687 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
23f87bed
MB
2688 ["Toggle threading" gnus-summary-toggle-threads t])
2689 ["See old articles" gnus-summary-insert-old-articles t]
2690 ["See new articles" gnus-summary-insert-new-articles t]
2691 ["Filter articles..." gnus-summary-execute-command t]
2692 ["Run command on articles..." gnus-summary-universal-argument t]
2693 ["Search articles forward..." gnus-summary-search-article-forward t]
2694 ["Search articles backward..." gnus-summary-search-article-backward t]
2695 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2696 ["Expand window" gnus-summary-expand-window t]
2697 ["Expire expirable articles" gnus-summary-expire-articles
2698 (gnus-check-backend-function
2699 'request-expire-articles gnus-newsgroup-name)]
2700 ["Edit local kill file" gnus-summary-edit-local-kill t]
2701 ["Edit main kill file" gnus-summary-edit-global-kill t]
2702 ["Edit group parameters" gnus-summary-edit-parameters t]
2703 ["Customize group parameters" gnus-summary-customize-parameters t]
2704 ["Send a bug report" gnus-bug t]
2705 ("Exit"
2706 ["Catchup and exit" gnus-summary-catchup-and-exit
2707 ,@(if (featurep 'xemacs) '(t)
2708 '(:help "Mark unread articles in this group as read, then exit"))]
2709 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2710 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
01c52d31 2711 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
23f87bed
MB
2712 ["Exit group" gnus-summary-exit
2713 ,@(if (featurep 'xemacs) '(t)
2714 '(:help "Exit current group, return to group selection mode"))]
2715 ["Exit group without updating" gnus-summary-exit-no-update t]
2716 ["Exit and goto next group" gnus-summary-next-group t]
2717 ["Exit and goto prev group" gnus-summary-prev-group t]
2718 ["Reselect group" gnus-summary-reselect-current-group t]
2719 ["Rescan group" gnus-summary-rescan-group t]
2720 ["Update dribble" gnus-summary-save-newsrc t])))
eec82323 2721
6748645f 2722 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323 2723
60bd5589
DL
2724(defvar gnus-summary-tool-bar-map nil)
2725
18c06a99
RS
2726;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2727;; affect _new_ message buffers. We might add a function that walks thru all
2728;; summary-mode buffers and force the update.
2729(defun gnus-summary-tool-bar-update (&optional symbol value)
2730 "Update summary mode toolbar.
2731Setter function for custom variables."
2732 (setq-default gnus-summary-tool-bar-map nil)
2733 (when symbol
2734 ;; When used as ":set" function:
2735 (set-default symbol value))
2736 (when (gnus-buffer-live-p gnus-summary-buffer)
2737 (with-current-buffer gnus-summary-buffer
2738 (gnus-summary-make-tool-bar))))
2739
2740(defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2741 'gnus-summary-tool-bar-gnome
2742 'gnus-summary-tool-bar-retro)
2743 "Specifies the Gnus summary tool bar.
2744
2745It can be either a list or a symbol refering to a list. See
2746`gmm-tool-bar-from-list' for the format of the list. The
2747default key map is `gnus-summary-mode-map'.
2748
2749Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2750`gnus-summary-tool-bar-retro'."
2751 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2752 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2753 (repeat :tag "User defined list" gmm-tool-bar-item)
2754 (symbol))
01c52d31 2755 :version "23.0" ;; No Gnus
18c06a99
RS
2756 :initialize 'custom-initialize-default
2757 :set 'gnus-summary-tool-bar-update
2758 :group 'gnus-summary)
2759
2760(defcustom gnus-summary-tool-bar-gnome
2761 '((gnus-summary-post-news "mail/compose" nil)
2762 (gnus-summary-insert-new-articles "mail/inbox" nil
2763 :visible (or (not gnus-agent)
2764 gnus-plugged))
2765 (gnus-summary-reply-with-original "mail/reply")
2766 (gnus-summary-reply "mail/reply" nil :visible nil)
2767 (gnus-summary-followup-with-original "mail/reply-all")
2768 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2769 (gnus-summary-mail-forward "mail/forward")
2770 (gnus-summary-save-article "mail/save")
2771 (gnus-summary-search-article-forward "search" nil :visible nil)
2772 (gnus-summary-print-article "print")
2773 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2774 ;; Some new commands that may need more suitable icons:
2775 (gnus-summary-save-newsrc "save" nil :visible nil)
2776 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2777 (gnus-summary-prev-article "left-arrow")
2778 (gnus-summary-next-article "right-arrow")
2779 (gnus-summary-next-page "next-page")
2780 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2781 ;;
2782 ;; Maybe some sort-by-... could be added:
2783 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2784 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2785 (gnus-summary-mark-as-expirable
2786 "delete" nil
2787 :visible (gnus-check-backend-function 'request-expire-articles
2788 gnus-newsgroup-name))
2789 (gnus-summary-mark-as-spam
2790 "mail/spam" t
2791 :visible (and (fboundp 'spam-group-ham-contents-p)
2792 (spam-group-ham-contents-p gnus-newsgroup-name))
2793 :help "Mark as spam")
2794 (gnus-summary-mark-as-read-forward
2795 "mail/not-spam" nil
2796 :visible (and (fboundp 'spam-group-spam-contents-p)
2797 (spam-group-spam-contents-p gnus-newsgroup-name)))
2798 ;;
2799 (gnus-summary-exit "exit")
2800 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2801 (gnus-info-find-node "help"))
2802 "List of functions for the summary tool bar (GNOME style).
2803
2804See `gmm-tool-bar-from-list' for the format of the list."
2805 :type '(repeat gmm-tool-bar-item)
01c52d31 2806 :version "23.0" ;; No Gnus
18c06a99
RS
2807 :initialize 'custom-initialize-default
2808 :set 'gnus-summary-tool-bar-update
2809 :group 'gnus-summary)
2810
2811(defcustom gnus-summary-tool-bar-retro
2812 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2813 (gnus-summary-next-unread-article "gnus/next-ur")
2814 (gnus-summary-post-news "gnus/post")
2815 (gnus-summary-followup-with-original "gnus/fuwo")
2816 (gnus-summary-followup "gnus/followup")
2817 (gnus-summary-reply-with-original "gnus/reply-wo")
2818 (gnus-summary-reply "gnus/reply")
2819 (gnus-summary-caesar-message "gnus/rot13")
2820 (gnus-uu-decode-uu "gnus/uu-decode")
2821 (gnus-summary-save-article-file "gnus/save-aif")
2822 (gnus-summary-save-article "gnus/save-art")
2823 (gnus-uu-post-news "gnus/uu-post")
2824 (gnus-summary-catchup "gnus/catchup")
2825 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2826 (gnus-summary-exit "gnus/exit-summ")
2827 ;; Some new command that may need more suitable icons:
2828 (gnus-summary-print-article "gnus/print" nil :visible nil)
2829 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2830 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2831 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2832 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2833 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2834 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2835 ;;
2836 (gnus-info-find-node "gnus/help" nil :visible nil))
2837 "List of functions for the summary tool bar (retro look).
2838
2839See `gmm-tool-bar-from-list' for the format of the list."
2840 :type '(repeat gmm-tool-bar-item)
01c52d31 2841 :version "23.0" ;; No Gnus
18c06a99
RS
2842 :initialize 'custom-initialize-default
2843 :set 'gnus-summary-tool-bar-update
2844 :group 'gnus-summary)
2845
2846(defcustom gnus-summary-tool-bar-zap-list t
2847 "List of icon items from the global tool bar.
2848These items are not displayed in the Gnus summary mode tool bar.
2849
2850See `gmm-tool-bar-from-list' for the format of the list."
2851 :type 'gmm-tool-bar-zap-list
01c52d31 2852 :version "23.0" ;; No Gnus
18c06a99
RS
2853 :initialize 'custom-initialize-default
2854 :set 'gnus-summary-tool-bar-update
2855 :group 'gnus-summary)
2856
2857(defvar image-load-path)
2858
2859(defun gnus-summary-make-tool-bar (&optional force)
2860 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2861When FORCE, rebuild the tool bar."
2862 (when (and (not (featurep 'xemacs))
2863 (boundp 'tool-bar-mode)
2864 tool-bar-mode
2865 (or (not gnus-summary-tool-bar-map) force))
2866 (let* ((load-path
2867 (gmm-image-load-path-for-library "gnus"
2868 "mail/save.xpm"
2869 nil t))
2870 (image-load-path (cons (car load-path)
2871 (when (boundp 'image-load-path)
2872 image-load-path)))
2873 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2874 gnus-summary-tool-bar-zap-list
2875 'gnus-summary-mode-map)))
2876 (when map
2877 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2878 ;; uses it's value.
2879 (setq gnus-summary-tool-bar-map map))))
2880 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
60bd5589 2881
eec82323
LMI
2882(defun gnus-score-set-default (var value)
2883 "A version of set that updates the GNU Emacs menu-bar."
2884 (set var value)
2885 ;; It is the message that forces the active status to be updated.
2886 (message ""))
2887
2888(defun gnus-make-score-map (type)
2889 "Make a summary score map of type TYPE."
2890 (if t
2891 nil
2892 (let ((headers '(("author" "from" string)
2893 ("subject" "subject" string)
2894 ("article body" "body" string)
2895 ("article head" "head" string)
2896 ("xref" "xref" string)
16409b0b 2897 ("extra header" "extra" string)
eec82323
LMI
2898 ("lines" "lines" number)
2899 ("followups to author" "followup" string)))
2900 (types '((number ("less than" <)
2901 ("greater than" >)
2902 ("equal" =))
2903 (string ("substring" s)
2904 ("exact string" e)
2905 ("fuzzy string" f)
2906 ("regexp" r))))
2907 (perms '(("temporary" (current-time-string))
2908 ("permanent" nil)
2909 ("immediate" now)))
2910 header)
2911 (list
2912 (apply
2913 'nconc
2914 (list
2915 (if (eq type 'lower)
2916 "Lower score"
2917 "Increase score"))
2918 (let (outh)
2919 (while headers
2920 (setq header (car headers))
2921 (setq outh
2922 (cons
2923 (apply
2924 'nconc
2925 (list (car header))
2926 (let ((ts (cdr (assoc (nth 2 header) types)))
2927 outt)
2928 (while ts
2929 (setq outt
2930 (cons
2931 (apply
2932 'nconc
2933 (list (caar ts))
2934 (let ((ps perms)
2935 outp)
2936 (while ps
2937 (setq outp
2938 (cons
2939 (vector
2940 (caar ps)
2941 (list
2942 'gnus-summary-score-entry
2943 (nth 1 header)
2944 (if (or (string= (nth 1 header)
2945 "head")
2946 (string= (nth 1 header)
2947 "body"))
2948 ""
2949 (list 'gnus-summary-header
2950 (nth 1 header)))
2951 (list 'quote (nth 1 (car ts)))
16409b0b
GM
2952 (list 'gnus-score-delta-default
2953 nil)
eec82323
LMI
2954 (nth 1 (car ps))
2955 t)
2956 t)
2957 outp))
2958 (setq ps (cdr ps)))
2959 (list (nreverse outp))))
2960 outt))
2961 (setq ts (cdr ts)))
2962 (list (nreverse outt))))
2963 outh))
2964 (setq headers (cdr headers)))
2965 (list (nreverse outh))))))))
2966
704f1663
GM
2967
2968(declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
2969
eec82323
LMI
2970\f
2971
2972(defun gnus-summary-mode (&optional group)
2973 "Major mode for reading articles.
2974
2975All normal editing commands are switched off.
2976\\<gnus-summary-mode-map>
2977Each line in this buffer represents one article. To read an
2978article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2979and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2980respectively.
2981
2982You can also post articles and send mail from this buffer. To
23f87bed 2983follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
eec82323
LMI
2984of an article, type `\\[gnus-summary-reply]'.
2985
2986There are approx. one gazillion commands you can execute in this
2987buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2988
2989The following commands are available:
2990
2991\\{gnus-summary-mode-map}"
2992 (interactive)
eec82323 2993 (kill-all-local-variables)
01c52d31
MB
2994 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2995 (gnus-summary-make-local-variables))
2996 (gnus-summary-make-local-variables)
2997 (setq gnus-newsgroup-name group)
60bd5589
DL
2998 (when (gnus-visual-p 'summary-menu 'menu)
2999 (gnus-summary-make-menu-bar)
3000 (gnus-summary-make-tool-bar))
eec82323
LMI
3001 (gnus-make-thread-indent-array)
3002 (gnus-simplify-mode-line)
3003 (setq major-mode 'gnus-summary-mode)
3004 (setq mode-name "Summary")
3005 (make-local-variable 'minor-mode-alist)
3006 (use-local-map gnus-summary-mode-map)
16409b0b 3007 (buffer-disable-undo)
01c52d31
MB
3008 (setq buffer-read-only t ;Disable modification
3009 show-trailing-whitespace nil)
eec82323
LMI
3010 (setq truncate-lines t)
3011 (setq selective-display t)
3012 (setq selective-display-ellipses t) ;Display `...'
3013 (gnus-summary-set-display-table)
3014 (gnus-set-default-directory)
eec82323
LMI
3015 (make-local-variable 'gnus-summary-line-format)
3016 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
3017 (make-local-variable 'gnus-summary-dummy-line-format)
3018 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323 3019 (make-local-variable 'gnus-summary-mark-positions)
23f87bed 3020 (gnus-make-local-hook 'pre-command-hook)
6748645f 3021 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
cfcd5c91 3022 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
23f87bed 3023 (turn-on-gnus-mailing-list-mode)
87545352 3024 (mm-enable-multibyte)
eec82323
LMI
3025 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3026 (gnus-update-summary-mark-positions))
3027
3028(defun gnus-summary-make-local-variables ()
3029 "Make all the local summary buffer variables."
16409b0b
GM
3030 (let (global)
3031 (dolist (local gnus-summary-local-variables)
eec82323
LMI
3032 (if (consp local)
3033 (progn
3034 (if (eq (cdr local) 'global)
3035 ;; Copy the global value of the variable.
3036 (setq global (symbol-value (car local)))
3037 ;; Use the value from the list.
3038 (setq global (eval (cdr local))))
16409b0b 3039 (set (make-local-variable (car local)) global))
eec82323 3040 ;; Simple nil-valued local variable.
16409b0b 3041 (set (make-local-variable local) nil)))))
eec82323
LMI
3042
3043(defun gnus-summary-clear-local-variables ()
3044 (let ((locals gnus-summary-local-variables))
3045 (while locals
3046 (if (consp (car locals))
01c52d31 3047 (and (symbolp (caar locals))
eec82323 3048 (set (caar locals) nil))
01c52d31 3049 (and (symbolp (car locals))
eec82323
LMI
3050 (set (car locals) nil)))
3051 (setq locals (cdr locals)))))
3052
3053;; Summary data functions.
3054
3055(defmacro gnus-data-number (data)
3056 `(car ,data))
3057
3058(defmacro gnus-data-set-number (data number)
3059 `(setcar ,data ,number))
3060
3061(defmacro gnus-data-mark (data)
3062 `(nth 1 ,data))
3063
3064(defmacro gnus-data-set-mark (data mark)
3065 `(setcar (nthcdr 1 ,data) ,mark))
3066
3067(defmacro gnus-data-pos (data)
3068 `(nth 2 ,data))
3069
3070(defmacro gnus-data-set-pos (data pos)
3071 `(setcar (nthcdr 2 ,data) ,pos))
3072
3073(defmacro gnus-data-header (data)
3074 `(nth 3 ,data))
3075
3076(defmacro gnus-data-set-header (data header)
3077 `(setf (nth 3 ,data) ,header))
3078
3079(defmacro gnus-data-level (data)
3080 `(nth 4 ,data))
3081
3082(defmacro gnus-data-unread-p (data)
3083 `(= (nth 1 ,data) gnus-unread-mark))
3084
3085(defmacro gnus-data-read-p (data)
3086 `(/= (nth 1 ,data) gnus-unread-mark))
3087
3088(defmacro gnus-data-pseudo-p (data)
3089 `(consp (nth 3 ,data)))
3090
3091(defmacro gnus-data-find (number)
3092 `(assq ,number gnus-newsgroup-data))
3093
3094(defmacro gnus-data-find-list (number &optional data)
3095 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3096 (memq (assq ,number bdata)
3097 bdata)))
3098
3099(defmacro gnus-data-make (number mark pos header level)
3100 `(list ,number ,mark ,pos ,header ,level))
3101
3102(defun gnus-data-enter (after-article number mark pos header level offset)
3103 (let ((data (gnus-data-find-list after-article)))
3104 (unless data
3105 (error "No such article: %d" after-article))
3106 (setcdr data (cons (gnus-data-make number mark pos header level)
3107 (cdr data)))
3108 (setq gnus-newsgroup-data-reverse nil)
3109 (gnus-data-update-list (cddr data) offset)))
3110
3111(defun gnus-data-enter-list (after-article list &optional offset)
3112 (when list
3113 (let ((data (and after-article (gnus-data-find-list after-article)))
3114 (ilist list))
6748645f
LMI
3115 (if (not (or data
3116 after-article))
3117 (let ((odata gnus-newsgroup-data))
3118 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 3119 (when offset
6748645f 3120 (gnus-data-update-list odata offset)))
01c52d31 3121 ;; Find the last element in the list to be spliced into the main
6748645f 3122 ;; list.
01c52d31 3123 (setq list (last list))
6748645f
LMI
3124 (if (not data)
3125 (progn
3126 (setcdr list gnus-newsgroup-data)
3127 (setq gnus-newsgroup-data ilist)
3128 (when offset
3129 (gnus-data-update-list (cdr list) offset)))
3130 (setcdr list (cdr data))
3131 (setcdr data ilist)
3132 (when offset
3133 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
3134 (setq gnus-newsgroup-data-reverse nil))))
3135
3136(defun gnus-data-remove (article &optional offset)
3137 (let ((data gnus-newsgroup-data))
3138 (if (= (gnus-data-number (car data)) article)
3139 (progn
3140 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3141 gnus-newsgroup-data-reverse nil)
3142 (when offset
3143 (gnus-data-update-list gnus-newsgroup-data offset)))
3144 (while (cdr data)
3145 (when (= (gnus-data-number (cadr data)) article)
3146 (setcdr data (cddr data))
3147 (when offset
3148 (gnus-data-update-list (cdr data) offset))
3149 (setq data nil
3150 gnus-newsgroup-data-reverse nil))
3151 (setq data (cdr data))))))
3152
3153(defmacro gnus-data-list (backward)
3154 `(if ,backward
3155 (or gnus-newsgroup-data-reverse
3156 (setq gnus-newsgroup-data-reverse
3157 (reverse gnus-newsgroup-data)))
3158 gnus-newsgroup-data))
3159
3160(defun gnus-data-update-list (data offset)
3161 "Add OFFSET to the POS of all data entries in DATA."
6748645f 3162 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
3163 (while data
3164 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3165 (setq data (cdr data))))
3166
eec82323
LMI
3167(defun gnus-summary-article-pseudo-p (article)
3168 "Say whether this article is a pseudo article or not."
3169 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3170
3171(defmacro gnus-summary-article-sparse-p (article)
3172 "Say whether this article is a sparse article or not."
a8151ef7 3173 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
3174
3175(defmacro gnus-summary-article-ancient-p (article)
3176 "Say whether this article is a sparse article or not."
3177 `(memq ,article gnus-newsgroup-ancient))
3178
3179(defun gnus-article-parent-p (number)
3180 "Say whether this article is a parent or not."
3181 (let ((data (gnus-data-find-list number)))
23f87bed 3182 (and (cdr data) ; There has to be an article after...
eec82323
LMI
3183 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3184 (gnus-data-level (nth 1 data))))))
3185
3186(defun gnus-article-children (number)
3187 "Return a list of all children to NUMBER."
3188 (let* ((data (gnus-data-find-list number))
3189 (level (gnus-data-level (car data)))
3190 children)
3191 (setq data (cdr data))
3192 (while (and data
3193 (= (gnus-data-level (car data)) (1+ level)))
3194 (push (gnus-data-number (car data)) children)
3195 (setq data (cdr data)))
3196 children))
3197
3198(defmacro gnus-summary-skip-intangible ()
3199 "If the current article is intangible, then jump to a different article."
3200 '(let ((to (get-text-property (point) 'gnus-intangible)))
3201 (and to (gnus-summary-goto-subject to))))
3202
3203(defmacro gnus-summary-article-intangible-p ()
3204 "Say whether this article is intangible or not."
3205 '(get-text-property (point) 'gnus-intangible))
3206
3207(defun gnus-article-read-p (article)
3208 "Say whether ARTICLE is read or not."
3209 (not (or (memq article gnus-newsgroup-marked)
23f87bed 3210 (memq article gnus-newsgroup-spam-marked)
eec82323
LMI
3211 (memq article gnus-newsgroup-unreads)
3212 (memq article gnus-newsgroup-unselected)
3213 (memq article gnus-newsgroup-dormant))))
3214
3215;; Some summary mode macros.
3216
3217(defmacro gnus-summary-article-number ()
3218 "The article number of the article on the current line.
8f688cb0 3219If there isn't an article number here, then we return the current
eec82323
LMI
3220article number."
3221 '(progn
3222 (gnus-summary-skip-intangible)
3223 (or (get-text-property (point) 'gnus-number)
3224 (gnus-summary-last-subject))))
3225
3226(defmacro gnus-summary-article-header (&optional number)
6748645f 3227 "Return the header of article NUMBER."
eec82323
LMI
3228 `(gnus-data-header (gnus-data-find
3229 ,(or number '(gnus-summary-article-number)))))
3230
3231(defmacro gnus-summary-thread-level (&optional number)
6748645f 3232 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
3233 `(if (and (eq gnus-summary-make-false-root 'dummy)
3234 (get-text-property (point) 'gnus-intangible))
3235 0
3236 (gnus-data-level (gnus-data-find
3237 ,(or number '(gnus-summary-article-number))))))
3238
3239(defmacro gnus-summary-article-mark (&optional number)
6748645f 3240 "Return the mark of article NUMBER."
eec82323
LMI
3241 `(gnus-data-mark (gnus-data-find
3242 ,(or number '(gnus-summary-article-number)))))
3243
3244(defmacro gnus-summary-article-pos (&optional number)
6748645f 3245 "Return the position of the line of article NUMBER."
eec82323
LMI
3246 `(gnus-data-pos (gnus-data-find
3247 ,(or number '(gnus-summary-article-number)))))
3248
3249(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3250(defmacro gnus-summary-article-subject (&optional number)
3251 "Return current subject string or nil if nothing."
3252 `(let ((headers
3253 ,(if number
3254 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3255 '(gnus-data-header (assq (gnus-summary-article-number)
3256 gnus-newsgroup-data)))))
3257 (and headers
3258 (vectorp headers)
3259 (mail-header-subject headers))))
3260
3261(defmacro gnus-summary-article-score (&optional number)
3262 "Return current article score."
3263 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3264 gnus-newsgroup-scored))
3265 gnus-summary-default-score 0))
3266
3267(defun gnus-summary-article-children (&optional number)
6748645f 3268 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
3269 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3270 (level (gnus-data-level (car data)))
3271 l children)
3272 (while (and (setq data (cdr data))
3273 (> (setq l (gnus-data-level (car data))) level))
3274 (and (= (1+ level) l)
3275 (push (gnus-data-number (car data))
3276 children)))
3277 (nreverse children)))
3278
3279(defun gnus-summary-article-parent (&optional number)
6748645f 3280 "Return the article number of the parent of article NUMBER."
eec82323
LMI
3281 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3282 (gnus-data-list t)))
3283 (level (gnus-data-level (car data))))
3284 (if (zerop level)
3285 () ; This is a root.
3286 ;; We search until we find an article with a level less than
3287 ;; this one. That function has to be the parent.
3288 (while (and (setq data (cdr data))
3289 (not (< (gnus-data-level (car data)) level))))
3290 (and data (gnus-data-number (car data))))))
3291
3292(defun gnus-unread-mark-p (mark)
3293 "Say whether MARK is the unread mark."
3294 (= mark gnus-unread-mark))
3295
3296(defun gnus-read-mark-p (mark)
3297 "Say whether MARK is one of the marks that mark as read.
3298This is all marks except unread, ticked, dormant, and expirable."
3299 (not (or (= mark gnus-unread-mark)
3300 (= mark gnus-ticked-mark)
23f87bed 3301 (= mark gnus-spam-mark)
eec82323
LMI
3302 (= mark gnus-dormant-mark)
3303 (= mark gnus-expirable-mark))))
3304
3305(defmacro gnus-article-mark (number)
6748645f
LMI
3306 "Return the MARK of article NUMBER.
3307This macro should only be used when computing the mark the \"first\"
3308time; i.e., when generating the summary lines. After that,
3309`gnus-summary-article-mark' should be used to examine the
3310marks of articles."
eec82323 3311 `(cond
6748645f 3312 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
6748645f 3313 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
3314 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3315 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
23f87bed 3316 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
eec82323
LMI
3317 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3318 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3319 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3320 gnus-ancient-mark))))
3321
3322;; Saving hidden threads.
3323
eec82323
LMI
3324(defmacro gnus-save-hidden-threads (&rest forms)
3325 "Save hidden threads, eval FORMS, and restore the hidden threads."
3326 (let ((config (make-symbol "config")))
3327 `(let ((,config (gnus-hidden-threads-configuration)))
3328 (unwind-protect
3329 (save-excursion
3330 ,@forms)
3331 (gnus-restore-hidden-threads-configuration ,config)))))
23f87bed
MB
3332(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3333(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
eec82323 3334
107ecebb
AS
3335(defun gnus-data-compute-positions ()
3336 "Compute the positions of all articles."
3337 (setq gnus-newsgroup-data-reverse nil)
3338 (let ((data gnus-newsgroup-data))
3339 (save-excursion
3340 (gnus-save-hidden-threads
3341 (gnus-summary-show-all-threads)
3342 (goto-char (point-min))
3343 (while data
3344 (while (get-text-property (point) 'gnus-intangible)
3345 (forward-line 1))
3346 (gnus-data-set-pos (car data) (+ (point) 3))
3347 (setq data (cdr data))
3348 (forward-line 1))))))
3349
16409b0b
GM
3350(defun gnus-hidden-threads-configuration ()
3351 "Return the current hidden threads configuration."
3352 (save-excursion
3353 (let (config)
3354 (goto-char (point-min))
3355 (while (search-forward "\r" nil t)
3356 (push (1- (point)) config))
3357 config)))
3358
3359(defun gnus-restore-hidden-threads-configuration (config)
3360 "Restore hidden threads configuration from CONFIG."
3361 (save-excursion
3362 (let (point buffer-read-only)
3363 (while (setq point (pop config))
3364 (when (and (< point (point-max))
3365 (goto-char point)
3366 (eq (char-after) ?\n))
3367 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3368
eec82323
LMI
3369;; Various summary mode internalish functions.
3370
3371(defun gnus-mouse-pick-article (e)
3372 (interactive "e")
3373 (mouse-set-point e)
3374 (gnus-summary-next-page nil t))
3375
3376(defun gnus-summary-set-display-table ()
16409b0b
GM
3377 "Change the display table.
3378Odd characters have a tendency to mess
3379up nicely formatted displays - we make all possible glyphs
3380display only a single character."
eec82323
LMI
3381
3382 ;; We start from the standard display table, if any.
3383 (let ((table (or (copy-sequence standard-display-table)
3384 (make-display-table)))
3385 (i 32))
3386 ;; Nix out all the control chars...
3387 (while (>= (setq i (1- i)) 0)
3388 (aset table i [??]))
23f87bed 3389 ;; ... but not newline and cr, of course. (cr is necessary for the
eec82323
LMI
3390 ;; selective display).
3391 (aset table ?\n nil)
3392 (aset table ?\r nil)
6748645f
LMI
3393 ;; We keep TAB as well.
3394 (aset table ?\t nil)
719120ef 3395 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
fe62aacc 3396 ;; Emacs 23 (unicode), that are not set already.
719120ef
MB
3397 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3398 160
3399 256)))
eec82323
LMI
3400 (while (>= (setq i (1- i)) 127)
3401 ;; Only modify if the entry is nil.
3402 (unless (aref table i)
3403 (aset table i [??]))))
3404 (setq buffer-display-table table)))
3405
23f87bed
MB
3406(defun gnus-summary-set-article-display-arrow (pos)
3407 "Update the overlay arrow to point to line at position POS."
3408 (when (and gnus-summary-display-arrow
3409 (boundp 'overlay-arrow-position)
3410 (boundp 'overlay-arrow-string))
3411 (save-excursion
3412 (goto-char pos)
3413 (beginning-of-line)
3414 (unless overlay-arrow-position
3415 (setq overlay-arrow-position (make-marker)))
3416 (setq overlay-arrow-string "=>"
3417 overlay-arrow-position (set-marker overlay-arrow-position
3418 (point)
3419 (current-buffer))))))
3420
eec82323
LMI
3421(defun gnus-summary-setup-buffer (group)
3422 "Initialize summary buffer."
23f87bed
MB
3423 (let ((buffer (gnus-summary-buffer-name group))
3424 (dead-name (concat "*Dead Summary "
3425 (gnus-group-decoded-name group) "*")))
3426 ;; If a dead summary buffer exists, we kill it.
3427 (when (gnus-buffer-live-p dead-name)
3428 (gnus-kill-buffer dead-name))
eec82323
LMI
3429 (if (get-buffer buffer)
3430 (progn
3431 (set-buffer buffer)
3432 (setq gnus-summary-buffer (current-buffer))
3433 (not gnus-newsgroup-prepared))
3434 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 3435 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323
LMI
3436 (gnus-summary-mode group)
3437 (when gnus-carpal
3438 (gnus-carpal-setup-buffer 'summary))
01c52d31
MB
3439 (when (gnus-group-quit-config group)
3440 (set (make-local-variable 'gnus-single-article-buffer) nil))
3441 (make-local-variable 'gnus-article-buffer)
3442 (make-local-variable 'gnus-article-current)
3443 (make-local-variable 'gnus-original-article-buffer)
eec82323 3444 (setq gnus-newsgroup-name group)
23f87bed
MB
3445 ;; Set any local variables in the group parameters.
3446 (gnus-summary-set-local-parameters gnus-newsgroup-name)
eec82323
LMI
3447 t)))
3448
3449(defun gnus-set-global-variables ()
16409b0b
GM
3450 "Set the global equivalents of the buffer-local variables.
3451They are set to the latest values they had. These reflect the summary
3452buffer that was in action when the last article was fetched."
eec82323
LMI
3453 (when (eq major-mode 'gnus-summary-mode)
3454 (setq gnus-summary-buffer (current-buffer))
3455 (let ((name gnus-newsgroup-name)
3456 (marked gnus-newsgroup-marked)
23f87bed 3457 (spam gnus-newsgroup-spam-marked)
eec82323
LMI
3458 (unread gnus-newsgroup-unreads)
3459 (headers gnus-current-headers)
3460 (data gnus-newsgroup-data)
3461 (summary gnus-summary-buffer)
3462 (article-buffer gnus-article-buffer)
3463 (original gnus-original-article-buffer)
3464 (gac gnus-article-current)
3465 (reffed gnus-reffed-article-number)
16409b0b 3466 (score-file gnus-current-score-file)
23f87bed
MB
3467 (default-charset gnus-newsgroup-charset)
3468 vlist)
3469 (let ((locals gnus-newsgroup-variables))
3470 (while locals
3471 (if (consp (car locals))
3472 (push (eval (caar locals)) vlist)
3473 (push (eval (car locals)) vlist))
3474 (setq locals (cdr locals)))
3475 (setq vlist (nreverse vlist)))
01c52d31 3476 (with-current-buffer gnus-group-buffer
6748645f
LMI
3477 (setq gnus-newsgroup-name name
3478 gnus-newsgroup-marked marked
23f87bed 3479 gnus-newsgroup-spam-marked spam
6748645f
LMI
3480 gnus-newsgroup-unreads unread
3481 gnus-current-headers headers
3482 gnus-newsgroup-data data
3483 gnus-article-current gac
3484 gnus-summary-buffer summary
3485 gnus-article-buffer article-buffer
3486 gnus-original-article-buffer original
3487 gnus-reffed-article-number reffed
16409b0b
GM
3488 gnus-current-score-file score-file
3489 gnus-newsgroup-charset default-charset)
23f87bed
MB
3490 (let ((locals gnus-newsgroup-variables))
3491 (while locals
3492 (if (consp (car locals))
3493 (set (caar locals) (pop vlist))
3494 (set (car locals) (pop vlist)))
3495 (setq locals (cdr locals))))
eec82323
LMI
3496 ;; The article buffer also has local variables.
3497 (when (gnus-buffer-live-p gnus-article-buffer)
3498 (set-buffer gnus-article-buffer)
3499 (setq gnus-summary-buffer summary))))))
3500
3501(defun gnus-summary-article-unread-p (article)
3502 "Say whether ARTICLE is unread or not."
3503 (memq article gnus-newsgroup-unreads))
3504
3505(defun gnus-summary-first-article-p (&optional article)
3506 "Return whether ARTICLE is the first article in the buffer."
3507 (if (not (setq article (or article (gnus-summary-article-number))))
3508 nil
3509 (eq article (caar gnus-newsgroup-data))))
3510
3511(defun gnus-summary-last-article-p (&optional article)
3512 "Return whether ARTICLE is the last article in the buffer."
3513 (if (not (setq article (or article (gnus-summary-article-number))))
16409b0b
GM
3514 ;; All non-existent numbers are the last article. :-)
3515 t
eec82323
LMI
3516 (not (cdr (gnus-data-find-list article)))))
3517
4921bbdd
CY
3518(defun gnus-make-thread-indent-array (&optional n)
3519 (when (or n
3520 (progn (setq n 200) nil)
3521 (null gnus-thread-indent-array)
3522 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3523 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3524 gnus-thread-indent-array-level gnus-thread-indent-level)
3525 (while (>= n 0)
3526 (aset gnus-thread-indent-array n
6a30c01d 3527 (make-string (* n gnus-thread-indent-level) ? ))
4921bbdd 3528 (setq n (1- n)))))
eec82323
LMI
3529
3530(defun gnus-update-summary-mark-positions ()
3531 "Compute where the summary marks are to go."
3532 (save-excursion
6748645f 3533 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3534 (set-buffer gnus-summary-buffer))
5153a47a
MB
3535 (let ((spec gnus-summary-line-format-spec)
3536 pos)
eec82323
LMI
3537 (save-excursion
3538 (gnus-set-work-buffer)
5153a47a
MB
3539 (let ((gnus-tmp-unread ?Z)
3540 (gnus-replied-mark ?Z)
3541 (gnus-score-below-mark ?Z)
3542 (gnus-score-over-mark ?Z)
3543 (gnus-undownloaded-mark ?Z)
3544 (gnus-summary-line-format-spec spec)
54506618 3545 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3546 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3547 case-fold-search ignores)
3548 ;; Here, all marks are bound to Z.
3549 (gnus-summary-insert-line header
3550 0 nil t gnus-tmp-unread t nil "" nil 1)
3551 (goto-char (point-min))
3552 ;; Memorize the positions of the same characters as dummy marks.
3553 (while (re-search-forward "[A-D]" nil t)
3554 (push (point) ignores))
54506618 3555 (erase-buffer)
5153a47a
MB
3556 ;; We use A-D as dummy marks in order to know column positions
3557 ;; where marks should be inserted.
3558 (setq gnus-tmp-unread ?A
3559 gnus-replied-mark ?B
3560 gnus-score-below-mark ?C
3561 gnus-score-over-mark ?C
3562 gnus-undownloaded-mark ?D)
3563 (gnus-summary-insert-line header
3564 0 nil t gnus-tmp-unread t nil "" nil 1)
3565 ;; Ignore characters which aren't dummy marks.
3566 (dolist (p ignores)
3567 (delete-region (goto-char (1- p)) p)
3568 (insert ?Z))
eec82323 3569 (goto-char (point-min))
7c3bb5a5 3570 (setq pos (list (cons 'unread
5153a47a 3571 (and (search-forward "A" nil t)
7c3bb5a5 3572 (- (point) (point-min) 1)))))
eec82323 3573 (goto-char (point-min))
5153a47a 3574 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3575 (- (point) (point-min) 1)))
eec82323
LMI
3576 pos)
3577 (goto-char (point-min))
5153a47a 3578 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3579 (- (point) (point-min) 1)))
6748645f
LMI
3580 pos)
3581 (goto-char (point-min))
5153a47a 3582 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3583 (- (point) (point-min) 1)))
eec82323
LMI
3584 pos)))
3585 (setq gnus-summary-mark-positions pos))))
3586
3587(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3588 "Insert a dummy root in the summary buffer."
3589 (beginning-of-line)
3590 (gnus-add-text-properties
3591 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3592 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3593
23f87bed
MB
3594(defun gnus-summary-extract-address-component (from)
3595 (or (car (funcall gnus-extract-address-components from))
3596 from))
3597
3598(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3599 (let ((mail-parse-charset gnus-newsgroup-charset)
01c52d31 3600 (ignored-from-addresses (gnus-ignored-from-addresses))
23f87bed
MB
3601 ; Is it really necessary to do this next part for each summary line?
3602 ; Luckily, doesn't seem to slow things down much.
16409b0b 3603 (mail-parse-ignored-charsets
01c52d31
MB
3604 (with-current-buffer gnus-summary-buffer
3605 gnus-newsgroup-ignored-charsets)))
23f87bed 3606 (or
01c52d31
MB
3607 (and ignored-from-addresses
3608 (string-match ignored-from-addresses gnus-tmp-from)
23f87bed
MB
3609 (let ((extra-headers (mail-header-extra header))
3610 to
3611 newsgroups)
3612 (cond
3613 ((setq to (cdr (assq 'To extra-headers)))
01c52d31 3614 (concat gnus-summary-to-prefix
23f87bed
MB
3615 (inline
3616 (gnus-summary-extract-address-component
343d6628 3617 (funcall gnus-decode-encoded-address-function to)))))
01c52d31
MB
3618 ((setq newsgroups
3619 (or
3620 (cdr (assq 'Newsgroups extra-headers))
3621 (and
3622 (memq 'Newsgroups gnus-extra-headers)
3623 (eq (car (gnus-find-method-for-group
3624 gnus-newsgroup-name)) 'nntp)
3625 (gnus-group-real-name gnus-newsgroup-name))))
3626 (concat gnus-summary-newsgroup-prefix newsgroups)))))
23f87bed 3627 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3628
eec82323
LMI
3629(defun gnus-summary-insert-line (gnus-tmp-header
3630 gnus-tmp-level gnus-tmp-current
23f87bed 3631 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3632 gnus-tmp-expirable gnus-tmp-subject-or-nil
3633 &optional gnus-tmp-dummy gnus-tmp-score
3634 gnus-tmp-process)
4921bbdd
CY
3635 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3636 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3637 gnus-tmp-level)))
eec82323
LMI
3638 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3639 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3640 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3641 (gnus-tmp-score-char
3642 (if (or (null gnus-summary-default-score)
3643 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3644 gnus-summary-zcore-fuzz))
23f87bed 3645 ? ;Whitespace
eec82323
LMI
3646 (if (< gnus-tmp-score gnus-summary-default-score)
3647 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3648 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3649 (gnus-tmp-replied
3650 (cond (gnus-tmp-process gnus-process-mark)
3651 ((memq gnus-tmp-current gnus-newsgroup-cached)
3652 gnus-cached-mark)
3653 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3654 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3655 gnus-forwarded-mark)
eec82323
LMI
3656 ((memq gnus-tmp-current gnus-newsgroup-saved)
3657 gnus-saved-mark)
23f87bed
MB
3658 ((memq gnus-tmp-number gnus-newsgroup-recent)
3659 gnus-recent-mark)
3660 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3661 gnus-unseen-mark)
3662 (t gnus-no-mark)))
3663 (gnus-tmp-downloaded
3664 (cond (undownloaded
3665 gnus-undownloaded-mark)
3666 (gnus-newsgroup-agentized
3667 gnus-downloaded-mark)
3668 (t
3669 gnus-no-mark)))
eec82323
LMI
3670 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3671 (gnus-tmp-name
3672 (cond
3673 ((string-match "<[^>]+> *$" gnus-tmp-from)
3674 (let ((beg (match-beginning 0)))
23f87bed
MB
3675 (or (and (string-match "^\".+\"" gnus-tmp-from)
3676 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3677 (substring gnus-tmp-from 0 beg))))
3678 ((string-match "(.+)" gnus-tmp-from)
3679 (substring gnus-tmp-from
3680 (1+ (match-beginning 0)) (1- (match-end 0))))
3681 (t gnus-tmp-from)))
3682 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3683 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3684 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3685 (buffer-read-only nil))
3686 (when (string= gnus-tmp-name "")
3687 (setq gnus-tmp-name gnus-tmp-from))
3688 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3689 (setq gnus-tmp-lines -1))
3690 (if (= gnus-tmp-lines -1)
3691 (setq gnus-tmp-lines "?")
3692 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3693 (gnus-put-text-property
eec82323
LMI
3694 (point)
3695 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 3696 'gnus-number gnus-tmp-number)
eec82323
LMI
3697 (when (gnus-visual-p 'summary-highlight 'highlight)
3698 (forward-line -1)
6748645f 3699 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3700 (forward-line 1))))
3701
3702(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3703 "Update summary line after change."
eec82323
LMI
3704 (when (and gnus-summary-default-score
3705 (not gnus-summary-inhibit-highlight))
3706 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3707 (article (gnus-summary-article-number))
3708 (score (gnus-summary-article-score article)))
3709 (unless dont-update
3710 (if (and gnus-summary-mark-below
3711 (< (gnus-summary-article-score)
3712 gnus-summary-mark-below))
3713 ;; This article has a low score, so we mark it as read.
3714 (when (memq article gnus-newsgroup-unreads)
3715 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3716 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3717 ;; This article was previously marked as read on account
3718 ;; of a low score, but now it has risen, so we mark it as
3719 ;; unread.
3720 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3721 (gnus-summary-update-mark
3722 (if (or (null gnus-summary-default-score)
3723 (<= (abs (- score gnus-summary-default-score))
3724 gnus-summary-zcore-fuzz))
23f87bed 3725 ? ;Whitespace
eec82323
LMI
3726 (if (< score gnus-summary-default-score)
3727 gnus-score-below-mark gnus-score-over-mark))
3728 'score))
3729 ;; Do visual highlighting.
3730 (when (gnus-visual-p 'summary-highlight 'highlight)
6748645f 3731 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3732
3733(defvar gnus-tmp-new-adopts nil)
3734
3735(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3736 "Return the number of articles in THREAD.
3737This may be 0 in some cases -- if none of the articles in
3738the thread are to be displayed."
3739 (let* ((number
23f87bed 3740 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3741 (cond
3742 ((not (listp thread))
3743 1)
3744 ((and (consp thread) (cdr thread))
3745 (apply
3746 '+ 1 (mapcar
3747 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3748 ((null thread)
3749 1)
3750 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3751 1)
3752 (t 0))))
3753 (when (and level (zerop level) gnus-tmp-new-adopts)
3754 (incf number
3755 (apply '+ (mapcar
3756 'gnus-summary-number-of-articles-in-thread
3757 gnus-tmp-new-adopts))))
3758 (if char
3759 (if (> number 1) gnus-not-empty-thread-mark
3760 gnus-empty-thread-mark)
3761 number)))
3762
23f87bed
MB
3763(defsubst gnus-summary-line-message-size (head)
3764 "Return pretty-printed version of message size.
3765This function is intended to be used in
3766`gnus-summary-line-format-alist'."
3767 (let ((c (or (mail-header-chars head) -1)))
3768 (cond ((< c 0) "n/a") ; chars not available
3769 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3770 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3771 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3772 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3773
3774
eec82323
LMI
3775(defun gnus-summary-set-local-parameters (group)
3776 "Go through the local params of GROUP and set all variable specs in that list."
01c52d31
MB
3777 (let ((vars '(quit-config))) ; Ignore quit-config.
3778 (dolist (elem (gnus-group-find-parameter group))
eec82323
LMI
3779 (and (consp elem) ; Has to be a cons.
3780 (consp (cdr elem)) ; The cdr has to be a list.
3781 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3782 (not (memq (car elem) vars))
eec82323 3783 (ignore-errors ; So we set it.
23f87bed 3784 (push (car elem) vars)
eec82323
LMI
3785 (make-local-variable (car elem))
3786 (set (car elem) (eval (nth 1 elem))))))))
3787
3788(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3789 kill-buffer no-display backward
3790 select-articles)
eec82323
LMI
3791 "Start reading news in newsgroup GROUP.
3792If SHOW-ALL is non-nil, already read articles are also listed.
3793If NO-ARTICLE is non-nil, no article is selected initially.
3794If NO-DISPLAY, don't generate a summary buffer."
3795 (let (result)
3796 (while (and group
3797 (null (setq result
3798 (let ((gnus-auto-select-next nil))
6748645f
LMI
3799 (or (gnus-summary-read-group-1
3800 group show-all no-article
3801 kill-buffer no-display
3802 select-articles)
3803 (setq show-all nil
16409b0b 3804 select-articles nil)))))
eec82323
LMI
3805 (eq gnus-auto-select-next 'quietly))
3806 (set-buffer gnus-group-buffer)
6748645f
LMI
3807 ;; The entry function called above goes to the next
3808 ;; group automatically, so we go two groups back
3809 ;; if we are searching for the previous group.
3810 (when backward
3811 (gnus-group-prev-unread-group 2))
eec82323
LMI
3812 (if (not (equal group (gnus-group-group-name)))
3813 (setq group (gnus-group-group-name))
3814 (setq group nil)))
3815 result))
3816
3817(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3818 kill-buffer no-display
3819 &optional select-articles)
eec82323 3820 ;; Killed foreign groups can't be entered.
23f87bed
MB
3821 ;; (when (and (not (gnus-group-native-p group))
3822 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3823 ;; (error "Dead non-native groups can't be entered"))
3824 (gnus-message 5 "Retrieving newsgroup: %s..."
3825 (gnus-group-decoded-name group))
eec82323
LMI
3826 (let* ((new-group (gnus-summary-setup-buffer group))
3827 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3828 (did-select (and new-group (gnus-select-newsgroup
3829 group show-all select-articles))))
eec82323
LMI
3830 (cond
3831 ;; This summary buffer exists already, so we just select it.
3832 ((not new-group)
3833 (gnus-set-global-variables)
3834 (when kill-buffer
3835 (gnus-kill-or-deaden-summary kill-buffer))
3836 (gnus-configure-windows 'summary 'force)
3837 (gnus-set-mode-line 'summary)
3838 (gnus-summary-position-point)
3839 (message "")
3840 t)
3841 ;; We couldn't select this group.
3842 ((null did-select)
3843 (when (and (eq major-mode 'gnus-summary-mode)
3844 (not (equal (current-buffer) kill-buffer)))
3845 (kill-buffer (current-buffer))
3846 (if (not quit-config)
3847 (progn
6748645f
LMI
3848 ;; Update the info -- marks might need to be removed,
3849 ;; for instance.
3850 (gnus-summary-update-info)
eec82323
LMI
3851 (set-buffer gnus-group-buffer)
3852 (gnus-group-jump-to-group group)
3853 (gnus-group-next-unread-group 1))
3854 (gnus-handle-ephemeral-exit quit-config)))
23f87bed
MB
3855 (let ((grpinfo (gnus-get-info group)))
3856 (if (null (gnus-info-read grpinfo))
3857 (gnus-message 3 "Group %s contains no messages"
3858 (gnus-group-decoded-name group))
3859 (gnus-message 3 "Can't select group")))
eec82323
LMI
3860 nil)
3861 ;; The user did a `C-g' while prompting for number of articles,
3862 ;; so we exit this group.
3863 ((eq did-select 'quit)
3864 (and (eq major-mode 'gnus-summary-mode)
3865 (not (equal (current-buffer) kill-buffer))
3866 (kill-buffer (current-buffer)))
3867 (when kill-buffer
3868 (gnus-kill-or-deaden-summary kill-buffer))
3869 (if (not quit-config)
3870 (progn
3871 (set-buffer gnus-group-buffer)
3872 (gnus-group-jump-to-group group)
3873 (gnus-group-next-unread-group 1)
3874 (gnus-configure-windows 'group 'force))
3875 (gnus-handle-ephemeral-exit quit-config))
3876 ;; Finally signal the quit.
3877 (signal 'quit nil))
3878 ;; The group was successfully selected.
3879 (t
3880 (gnus-set-global-variables)
3881 ;; Save the active value in effect when the group was entered.
3882 (setq gnus-newsgroup-active
3883 (gnus-copy-sequence
3884 (gnus-active gnus-newsgroup-name)))
3885 ;; You can change the summary buffer in some way with this hook.
6748645f 3886 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
3887 (when (memq 'summary (gnus-update-format-specifications
3888 nil 'summary 'summary-mode 'summary-dummy))
3889 ;; The format specification for the summary line was updated,
3890 ;; so we need to update the mark positions as well.
3891 (gnus-update-summary-mark-positions))
eec82323
LMI
3892 ;; Do score processing.
3893 (when gnus-use-scoring
3894 (gnus-possibly-score-headers))
3895 ;; Check whether to fill in the gaps in the threads.
3896 (when gnus-build-sparse-threads
3897 (gnus-build-sparse-threads))
3898 ;; Find the initial limit.
26c9afc3
MB
3899 (if show-all
3900 (let ((gnus-newsgroup-dormant nil))
eec82323 3901 (gnus-summary-initial-limit show-all))
26c9afc3 3902 (gnus-summary-initial-limit show-all))
eec82323
LMI
3903 ;; Generate the summary buffer.
3904 (unless no-display
3905 (gnus-summary-prepare))
3906 (when gnus-use-trees
3907 (gnus-tree-open group)
3908 (setq gnus-summary-highlight-line-function
3909 'gnus-tree-highlight-article))
3910 ;; If the summary buffer is empty, but there are some low-scored
3911 ;; articles or some excluded dormants, we include these in the
3912 ;; buffer.
3913 (when (and (zerop (buffer-size))
3914 (not no-display))
3915 (cond (gnus-newsgroup-dormant
3916 (gnus-summary-limit-include-dormant))
3917 ((and gnus-newsgroup-scored show-all)
3918 (gnus-summary-limit-include-expunged t))))
3919 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 3920 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
3921 (if (and (zerop (buffer-size))
3922 (not no-display))
3923 (progn
3924 ;; This newsgroup is empty.
3925 (gnus-summary-catchup-and-exit nil t)
3926 (gnus-message 6 "No unread news")
3927 (when kill-buffer
3928 (gnus-kill-or-deaden-summary kill-buffer))
3929 ;; Return nil from this function.
3930 nil)
3931 ;; Hide conversation thread subtrees. We cannot do this in
3932 ;; gnus-summary-prepare-hook since kill processing may not
3933 ;; work with hidden articles.
23f87bed 3934 (gnus-summary-maybe-hide-threads)
6748645f
LMI
3935 (when kill-buffer
3936 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 3937 (gnus-summary-auto-select-subject)
eec82323
LMI
3938 ;; Show first unread article if requested.
3939 (if (and (not no-article)
3940 (not no-display)
3941 gnus-newsgroup-unreads
3942 gnus-auto-select-first)
16409b0b
GM
3943 (progn
3944 (gnus-configure-windows 'summary)
23f87bed
MB
3945 (let ((art (gnus-summary-article-number)))
3946 (unless (and (not gnus-plugged)
3947 (or (memq art gnus-newsgroup-undownloaded)
3948 (memq art gnus-newsgroup-downloadable)))
3949 (gnus-summary-goto-article art))))
3950 ;; Don't select any articles.
eec82323 3951 (gnus-summary-position-point)
6748645f
LMI
3952 (gnus-configure-windows 'summary 'force)
3953 (gnus-set-mode-line 'summary))
23f87bed
MB
3954 (when (and gnus-auto-center-group
3955 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
3956 ;; Gotta use windows, because recenter does weird stuff if
3957 ;; the current buffer ain't the displayed window.
3958 (let ((owin (selected-window)))
3959 (select-window (get-buffer-window gnus-group-buffer t))
3960 (when (gnus-group-goto-group group)
3961 (recenter))
3962 (select-window owin)))
3963 ;; Mark this buffer as "prepared".
3964 (setq gnus-newsgroup-prepared t)
6748645f 3965 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
3966 (unless (gnus-ephemeral-group-p group)
3967 (gnus-group-update-group group))
eec82323
LMI
3968 t)))))
3969
23f87bed
MB
3970(defun gnus-summary-auto-select-subject ()
3971 "Select the subject line on initial group entry."
3972 (goto-char (point-min))
3973 (cond
3974 ((eq gnus-auto-select-subject 'best)
3975 (gnus-summary-best-unread-subject))
3976 ((eq gnus-auto-select-subject 'unread)
3977 (gnus-summary-first-unread-subject))
3978 ((eq gnus-auto-select-subject 'unseen)
3979 (gnus-summary-first-unseen-subject))
3980 ((eq gnus-auto-select-subject 'unseen-or-unread)
3981 (gnus-summary-first-unseen-or-unread-subject))
3982 ((eq gnus-auto-select-subject 'first)
3983 ;; Do nothing.
3984 )
3985 ((functionp gnus-auto-select-subject)
3986 (funcall gnus-auto-select-subject))))
3987
eec82323
LMI
3988(defun gnus-summary-prepare ()
3989 "Generate the summary buffer."
3990 (interactive)
3991 (let ((buffer-read-only nil))
3992 (erase-buffer)
3993 (setq gnus-newsgroup-data nil
3994 gnus-newsgroup-data-reverse nil)
6748645f 3995 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
3996 ;; Generate the buffer, either with threads or without.
3997 (when gnus-newsgroup-headers
3998 (gnus-summary-prepare-threads
3999 (if gnus-show-threads
4000 (gnus-sort-gathered-threads
4001 (funcall gnus-summary-thread-gathering-function
4002 (gnus-sort-threads
4003 (gnus-cut-threads (gnus-make-threads)))))
4004 ;; Unthreaded display.
4005 (gnus-sort-articles gnus-newsgroup-headers))))
4006 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4007 ;; Call hooks for modifying summary buffer.
4008 (goto-char (point-min))
6748645f 4009 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
4010
4011(defsubst gnus-general-simplify-subject (subject)
23f87bed 4012 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
4013 (setq subject
4014 (cond
4015 ;; Truncate the subject.
6748645f
LMI
4016 (gnus-simplify-subject-functions
4017 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
4018 ((numberp gnus-summary-gather-subject-limit)
4019 (setq subject (gnus-simplify-subject-re subject))
4020 (if (> (length subject) gnus-summary-gather-subject-limit)
4021 (substring subject 0 gnus-summary-gather-subject-limit)
4022 subject))
4023 ;; Fuzzily simplify it.
4024 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4025 (gnus-simplify-subject-fuzzy subject))
4026 ;; Just remove the leading "Re:".
4027 (t
4028 (gnus-simplify-subject-re subject))))
4029
4030 (if (and gnus-summary-gather-exclude-subject
4031 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 4032 nil ; This article shouldn't be gathered
eec82323
LMI
4033 subject))
4034
4035(defun gnus-summary-simplify-subject-query ()
4036 "Query where the respool algorithm would put this article."
4037 (interactive)
eec82323 4038 (gnus-summary-select-article)
274f1353 4039 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
eec82323
LMI
4040
4041(defun gnus-gather-threads-by-subject (threads)
4042 "Gather threads by looking at Subject headers."
4043 (if (not gnus-summary-make-false-root)
4044 threads
4045 (let ((hashtb (gnus-make-hashtable 1024))
4046 (prev threads)
4047 (result threads)
4048 subject hthread whole-subject)
4049 (while threads
4050 (setq subject (gnus-general-simplify-subject
4051 (setq whole-subject (mail-header-subject
4052 (caar threads)))))
4053 (when subject
4054 (if (setq hthread (gnus-gethash subject hashtb))
4055 (progn
4056 ;; We enter a dummy root into the thread, if we
4057 ;; haven't done that already.
4058 (unless (stringp (caar hthread))
4059 (setcar hthread (list whole-subject (car hthread))))
4060 ;; We add this new gathered thread to this gathered
4061 ;; thread.
4062 (setcdr (car hthread)
4063 (nconc (cdar hthread) (list (car threads))))
4064 ;; Remove it from the list of threads.
4065 (setcdr prev (cdr threads))
4066 (setq threads prev))
4067 ;; Enter this thread into the hash table.
23f87bed
MB
4068 (gnus-sethash subject
4069 (if gnus-summary-make-false-root-always
4070 (progn
4071 ;; If you want a dummy root above all
4072 ;; threads...
4073 (setcar threads (list whole-subject
4074 (car threads)))
4075 threads)
4076 threads)
4077 hashtb)))
eec82323
LMI
4078 (setq prev threads)
4079 (setq threads (cdr threads)))
4080 result)))
4081
4082(defun gnus-gather-threads-by-references (threads)
4083 "Gather threads by looking at References headers."
4084 (let ((idhashtb (gnus-make-hashtable 1024))
4085 (thhashtb (gnus-make-hashtable 1024))
4086 (prev threads)
4087 (result threads)
4088 ids references id gthread gid entered ref)
4089 (while threads
4090 (when (setq references (mail-header-references (caar threads)))
4091 (setq id (mail-header-id (caar threads))
23f87bed 4092 ids (inline (gnus-split-references references))
eec82323
LMI
4093 entered nil)
4094 (while (setq ref (pop ids))
4095 (setq ids (delete ref ids))
4096 (if (not (setq gid (gnus-gethash ref idhashtb)))
4097 (progn
4098 (gnus-sethash ref id idhashtb)
4099 (gnus-sethash id threads thhashtb))
4100 (setq gthread (gnus-gethash gid thhashtb))
4101 (unless entered
4102 ;; We enter a dummy root into the thread, if we
4103 ;; haven't done that already.
4104 (unless (stringp (caar gthread))
4105 (setcar gthread (list (mail-header-subject (caar gthread))
4106 (car gthread))))
4107 ;; We add this new gathered thread to this gathered
4108 ;; thread.
4109 (setcdr (car gthread)
4110 (nconc (cdar gthread) (list (car threads)))))
4111 ;; Add it into the thread hash table.
4112 (gnus-sethash id gthread thhashtb)
4113 (setq entered t)
4114 ;; Remove it from the list of threads.
4115 (setcdr prev (cdr threads))
4116 (setq threads prev))))
4117 (setq prev threads)
4118 (setq threads (cdr threads)))
4119 result))
4120
4121(defun gnus-sort-gathered-threads (threads)
16409b0b 4122 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
4123 (let ((result threads))
4124 (while threads
4125 (when (stringp (caar threads))
4126 (setcdr (car threads)
16409b0b 4127 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
4128 (setq threads (cdr threads)))
4129 result))
4130
4131(defun gnus-thread-loop-p (root thread)
4132 "Say whether ROOT is in THREAD."
4133 (let ((stack (list thread))
4134 (infloop 0)
4135 th)
4136 (while (setq thread (pop stack))
4137 (setq th (cdr thread))
4138 (while (and th
4139 (not (eq (caar th) root)))
4140 (pop th))
4141 (if th
4142 ;; We have found a loop.
4143 (let (ref-dep)
4144 (setcdr thread (delq (car th) (cdr thread)))
4145 (if (boundp (setq ref-dep (intern "none"
4146 gnus-newsgroup-dependencies)))
4147 (setcdr (symbol-value ref-dep)
4148 (nconc (cdr (symbol-value ref-dep))
4149 (list (car th))))
4150 (set ref-dep (list nil (car th))))
4151 (setq infloop 1
4152 stack nil))
4153 ;; Push all the subthreads onto the stack.
4154 (push (cdr thread) stack)))
4155 infloop))
4156
4157(defun gnus-make-threads ()
01ccbb85 4158 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
4159 (let (threads)
4160 (while (catch 'infloop
4161 (mapatoms
4162 (lambda (refs)
4163 ;; Deal with self-referencing References loops.
4164 (when (and (car (symbol-value refs))
4165 (not (zerop
4166 (apply
4167 '+
4168 (mapcar
4169 (lambda (thread)
4170 (gnus-thread-loop-p
4171 (car (symbol-value refs)) thread))
4172 (cdr (symbol-value refs)))))))
4173 (setq threads nil)
4174 (throw 'infloop t))
4175 (unless (car (symbol-value refs))
23f87bed
MB
4176 ;; These threads do not refer back to any other
4177 ;; articles, so they're roots.
eec82323
LMI
4178 (setq threads (append (cdr (symbol-value refs)) threads))))
4179 gnus-newsgroup-dependencies)))
4180 threads))
4181
6748645f 4182;; Build the thread tree.
16409b0b 4183(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4184 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4185
4186If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4187if it was already present.
4188
4189If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4190will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4191Message-IDs will be renamed to a unique Message-ID before being
4192entered.
6748645f
LMI
4193
4194Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4195 (let* ((id (mail-header-id header))
4196 (id-dep (and id (intern id dependencies)))
23f87bed 4197 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4198 ;; Enter this `header' in the `dependencies' table.
4199 (cond
4200 ((not id-dep)
4201 (setq header nil))
4202 ;; The first two cases do the normal part: enter a new `header'
4203 ;; in the `dependencies' table.
4204 ((not (boundp id-dep))
4205 (set id-dep (list header)))
4206 ((null (car (symbol-value id-dep)))
4207 (setcar (symbol-value id-dep) header))
4208
4209 ;; From here the `header' was already present in the
4210 ;; `dependencies' table.
4211 (force-new
4212 ;; Overrides an existing entry;
4213 ;; just set the header part of the entry.
23f87bed
MB
4214 (setcar (symbol-value id-dep) header)
4215 (setq replaced t))
6748645f
LMI
4216
4217 ;; Renames the existing `header' to a unique Message-ID.
4218 ((not gnus-summary-ignore-duplicates)
4219 ;; An article with this Message-ID has already been seen.
4220 ;; We rename the Message-ID.
4221 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4222 (list header))
4223 (mail-header-set-id header id))
4224
4225 ;; The last case ignores an existing entry, except it adds any
4226 ;; additional Xrefs (in case the two articles came from different
4227 ;; servers.
4228 ;; Also sets `header' to `nil' meaning that the `dependencies'
4229 ;; table was *not* modified.
4230 (t
4231 (mail-header-set-xref
4232 (car (symbol-value id-dep))
4233 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4234 "")
4235 (or (mail-header-xref header) "")))
4236 (setq header nil)))
4237
23f87bed
MB
4238 (when (and header (not replaced))
4239 ;; First check that we are not creating a References loop.
4240 (setq parent-id (gnus-parent-id (mail-header-references header)))
4241 (setq ref parent-id)
6748645f
LMI
4242 (while (and ref
4243 (setq ref-dep (intern-soft ref dependencies))
4244 (boundp ref-dep)
4245 (setq ref-header (car (symbol-value ref-dep))))
4246 (if (string= id ref)
4247 ;; Yuk! This is a reference loop. Make the article be a
4248 ;; root article.
4249 (progn
4250 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4251 (setq ref nil)
4252 (setq parent-id nil))
6748645f 4253 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4254 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4255 (if (boundp ref-dep)
4256 (setcdr (symbol-value ref-dep)
4257 (nconc (cdr (symbol-value ref-dep))
4258 (list (symbol-value id-dep))))
4259 (set ref-dep (list nil (symbol-value id-dep)))))
4260 header))
4261
23f87bed
MB
4262(defun gnus-extract-message-id-from-in-reply-to (string)
4263 (if (string-match "<[^>]+>" string)
4264 (substring string (match-beginning 0) (match-end 0))
4265 nil))
4266
eec82323
LMI
4267(defun gnus-build-sparse-threads ()
4268 (let ((headers gnus-newsgroup-headers)
16409b0b 4269 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4270 (gnus-summary-ignore-duplicates t)
eec82323 4271 header references generation relations
6748645f 4272 subject child end new-child date)
eec82323
LMI
4273 ;; First we create an alist of generations/relations, where
4274 ;; generations is how much we trust the relation, and the relation
4275 ;; is parent/child.
4276 (gnus-message 7 "Making sparse threads...")
4277 (save-excursion
4278 (nnheader-set-temp-buffer " *gnus sparse threads*")
4279 (while (setq header (pop headers))
4280 (when (and (setq references (mail-header-references header))
4281 (not (string= references "")))
4282 (insert references)
4283 (setq child (mail-header-id header)
6748645f
LMI
4284 subject (mail-header-subject header)
4285 date (mail-header-date header)
4286 generation 0)
eec82323
LMI
4287 (while (search-backward ">" nil t)
4288 (setq end (1+ (point)))
4289 (when (search-backward "<" nil t)
6748645f 4290 (setq new-child (buffer-substring (point) end))
eec82323 4291 (push (list (incf generation)
6748645f
LMI
4292 child (setq child new-child)
4293 subject date)
eec82323 4294 relations)))
6748645f
LMI
4295 (when child
4296 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4297 (erase-buffer)))
4298 (kill-buffer (current-buffer)))
4299 ;; Sort over trustworthiness.
01c52d31
MB
4300 (dolist (relation (sort relations 'car-less-than-car))
4301 (when (gnus-dependencies-add-header
4302 (make-full-mail-header
4303 gnus-reffed-article-number
4304 (nth 3 relation) "" (or (nth 4 relation) "")
4305 (nth 1 relation)
4306 (or (nth 2 relation) "") 0 0 "")
4307 gnus-newsgroup-dependencies nil)
4308 (push gnus-reffed-article-number gnus-newsgroup-limit)
4309 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4310 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4311 gnus-newsgroup-reads)
4312 (decf gnus-reffed-article-number)))
eec82323
LMI
4313 (gnus-message 7 "Making sparse threads...done")))
4314
4315(defun gnus-build-old-threads ()
4316 ;; Look at all the articles that refer back to old articles, and
4317 ;; fetch the headers for the articles that aren't there. This will
4318 ;; build complete threads - if the roots haven't been expired by the
4319 ;; server, that is.
16409b0b
GM
4320 (let ((mail-parse-charset gnus-newsgroup-charset)
4321 id heads)
eec82323
LMI
4322 (mapatoms
4323 (lambda (refs)
4324 (when (not (car (symbol-value refs)))
4325 (setq heads (cdr (symbol-value refs)))
4326 (while heads
4327 (if (memq (mail-header-number (caar heads))
4328 gnus-newsgroup-dormant)
4329 (setq heads (cdr heads))
4330 (setq id (symbol-name refs))
4331 (while (and (setq id (gnus-build-get-header id))
6748645f 4332 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4333 (setq heads nil)))))
4334 gnus-newsgroup-dependencies)))
4335
23f87bed
MB
4336(defsubst gnus-remove-odd-characters (string)
4337 "Translate STRING into something that doesn't contain weird characters."
4338 (mm-subst-char-in-string
4339 ?\r ?\-
01c52d31 4340 (mm-subst-char-in-string ?\n ?\- string t) t))
23f87bed 4341
6748645f
LMI
4342;; This function has to be called with point after the article number
4343;; on the beginning of the line.
4344(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
01c52d31 4345 (let ((eol (point-at-eol))
6748645f 4346 (buffer (current-buffer))
23f87bed 4347 header references in-reply-to)
6748645f
LMI
4348
4349 ;; overview: [num subject from date id refs chars lines misc]
4350 (unwind-protect
23f87bed 4351 (let (x)
6748645f
LMI
4352 (narrow-to-region (point) eol)
4353 (unless (eobp)
4354 (forward-char))
4355
4356 (setq header
4357 (make-full-mail-header
4358 number ; number
23f87bed
MB
4359 (condition-case () ; subject
4360 (gnus-remove-odd-characters
4361 (funcall gnus-decode-encoded-word-function
4362 (setq x (nnheader-nov-field))))
4363 (error x))
4364 (condition-case () ; from
4365 (gnus-remove-odd-characters
343d6628 4366 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4367 (setq x (nnheader-nov-field))))
4368 (error x))
16409b0b 4369 (nnheader-nov-field) ; date
01c52d31 4370 (nnheader-nov-read-message-id number) ; id
23f87bed 4371 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4372 (nnheader-nov-read-integer) ; chars
4373 (nnheader-nov-read-integer) ; lines
4374 (unless (eobp)
8b93df01
DL
4375 (if (looking-at "Xref: ")
4376 (goto-char (match-end 0)))
4377 (nnheader-nov-field)) ; Xref
16409b0b 4378 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4379
4380 (widen))
4381
23f87bed
MB
4382 (when (and (string= references "")
4383 (setq in-reply-to (mail-header-extra header))
4384 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4385 (mail-header-set-references
4386 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4387
6748645f
LMI
4388 (when gnus-alter-header-function
4389 (funcall gnus-alter-header-function header))
4390 (gnus-dependencies-add-header header dependencies force-new)))
4391
eec82323 4392(defun gnus-build-get-header (id)
16409b0b
GM
4393 "Look through the buffer of NOV lines and find the header to ID.
4394Enter this line into the dependencies hash table, and return
4395the id of the parent article (if any)."
eec82323
LMI
4396 (let ((deps gnus-newsgroup-dependencies)
4397 found header)
4398 (prog1
4399 (save-excursion
4400 (set-buffer nntp-server-buffer)
4401 (let ((case-fold-search nil))
4402 (goto-char (point-min))
4403 (while (and (not found)
4404 (search-forward id nil t))
4405 (beginning-of-line)
4406 (setq found (looking-at
4407 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4408 (regexp-quote id))))
4409 (or found (beginning-of-line 2)))
4410 (when found
4411 (beginning-of-line)
4412 (and
4413 (setq header (gnus-nov-parse-line
4414 (read (current-buffer)) deps))
4415 (gnus-parent-id (mail-header-references header))))))
4416 (when header
4417 (let ((number (mail-header-number header)))
4418 (push number gnus-newsgroup-limit)
4419 (push header gnus-newsgroup-headers)
4420 (if (memq number gnus-newsgroup-unselected)
4421 (progn
23f87bed
MB
4422 (setq gnus-newsgroup-unreads
4423 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4424 number))
eec82323
LMI
4425 (setq gnus-newsgroup-unselected
4426 (delq number gnus-newsgroup-unselected)))
4427 (push number gnus-newsgroup-ancient)))))))
4428
6748645f
LMI
4429(defun gnus-build-all-threads ()
4430 "Read all the headers."
4431 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4432 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4433 (dependencies gnus-newsgroup-dependencies)
4434 header article)
4435 (save-excursion
4436 (set-buffer nntp-server-buffer)
4437 (let ((case-fold-search nil))
4438 (goto-char (point-min))
4439 (while (not (eobp))
4440 (ignore-errors
4441 (setq article (read (current-buffer))
16409b0b 4442 header (gnus-nov-parse-line article dependencies)))
6748645f 4443 (when header
01c52d31 4444 (with-current-buffer gnus-summary-buffer
6748645f
LMI
4445 (push header gnus-newsgroup-headers)
4446 (if (memq (setq article (mail-header-number header))
4447 gnus-newsgroup-unselected)
4448 (progn
23f87bed
MB
4449 (setq gnus-newsgroup-unreads
4450 (gnus-add-to-sorted-list
4451 gnus-newsgroup-unreads article))
6748645f
LMI
4452 (setq gnus-newsgroup-unselected
4453 (delq article gnus-newsgroup-unselected)))
4454 (push article gnus-newsgroup-ancient)))
4455 (forward-line 1)))))))
4456
eec82323 4457(defun gnus-summary-update-article-line (article header)
23f87bed 4458 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4459 (let* ((id (mail-header-id header))
4460 (thread (gnus-id-to-thread id)))
4461 (unless thread
4462 (error "Article in no thread"))
4463 ;; Update the thread.
4464 (setcar thread header)
4465 (gnus-summary-goto-subject article)
4466 (let* ((datal (gnus-data-find-list article))
4467 (data (car datal))
eec82323
LMI
4468 (buffer-read-only nil)
4469 (level (gnus-summary-thread-level)))
4470 (gnus-delete-line)
23f87bed
MB
4471 (let ((inserted (- (point)
4472 (progn
4473 (gnus-summary-insert-line
4474 header level nil
4475 (memq article gnus-newsgroup-undownloaded)
4476 (gnus-article-mark article)
4477 (memq article gnus-newsgroup-replied)
4478 (memq article gnus-newsgroup-expirable)
4479 ;; Only insert the Subject string when it's different
4480 ;; from the previous Subject string.
4481 (if (and
4482 gnus-show-threads
4483 (gnus-subject-equal
4484 (condition-case ()
4485 (mail-header-subject
4486 (gnus-data-header
4487 (cadr
4488 (gnus-data-find-list
4489 article
4490 (gnus-data-list t)))))
4491 ;; Error on the side of excessive subjects.
4492 (error ""))
4493 (mail-header-subject header)))
4494 ""
4495 (mail-header-subject header))
4496 nil (cdr (assq article gnus-newsgroup-scored))
4497 (memq article gnus-newsgroup-processable))
4498 (point)))))
4499 (when (cdr datal)
4500 (gnus-data-update-list
4501 (cdr datal)
4502 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4503
4504(defun gnus-summary-update-article (article &optional iheader)
4505 "Update ARTICLE in the summary buffer."
4506 (set-buffer gnus-summary-buffer)
6748645f 4507 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4508 (id (mail-header-id header))
4509 (data (gnus-data-find article))
4510 (thread (gnus-id-to-thread id))
4511 (references (mail-header-references header))
4512 (parent
4513 (gnus-id-to-thread
4514 (or (gnus-parent-id
4515 (when (and references
4516 (not (equal "" references)))
4517 references))
4518 "none")))
4519 (buffer-read-only nil)
6748645f 4520 (old (car thread)))
eec82323 4521 (when thread
eec82323 4522 (unless iheader
6748645f
LMI
4523 (setcar thread nil)
4524 (when parent
4525 (delq thread parent)))
4526 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4527 ;; Set the (possibly) new article number in the data structure.
4528 (gnus-data-set-number data (gnus-id-to-article id))
4529 (setcar thread old)
4530 nil))))
4531
6748645f
LMI
4532(defun gnus-rebuild-thread (id &optional line)
4533 "Rebuild the thread containing ID.
4534If LINE, insert the rebuilt thread starting on line LINE."
eec82323
LMI
4535 (let ((buffer-read-only nil)
4536 old-pos current thread data)
4537 (if (not gnus-show-threads)
4538 (setq thread (list (car (gnus-id-to-thread id))))
4539 ;; Get the thread this article is part of.
4540 (setq thread (gnus-remove-thread id)))
01c52d31 4541 (setq old-pos (point-at-bol))
eec82323 4542 (setq current (save-excursion
94384150 4543 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4544 (gnus-summary-article-number))))
4545 ;; If this is a gathered thread, we have to go some re-gathering.
4546 (when (stringp (car thread))
4547 (let ((subject (car thread))
4548 roots thr)
4549 (setq thread (cdr thread))
4550 (while thread
4551 (unless (memq (setq thr (gnus-id-to-thread
4552 (gnus-root-id
4553 (mail-header-id (caar thread)))))
4554 roots)
4555 (push thr roots))
4556 (setq thread (cdr thread)))
4557 ;; We now have all (unique) roots.
4558 (if (= (length roots) 1)
4559 ;; All the loose roots are now one solid root.
4560 (setq thread (car roots))
4561 (setq thread (cons subject (gnus-sort-threads roots))))))
4562 (let (threads)
4563 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4564 (when line
4565 (goto-char (point-min))
4566 (forward-line (1- line)))
eec82323
LMI
4567 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4568 (if gnus-show-threads
4569 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4570 (gnus-summary-prepare-unthreaded thread))
4571 (setq data (nreverse gnus-newsgroup-data))
4572 (setq threads gnus-newsgroup-threads))
4573 ;; We splice the new data into the data structure.
6748645f
LMI
4574 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4575 ;;!!! then we want to insert at the beginning of the buffer.
4576 ;;!!! That happens to be true with Gnus now, but that may
4577 ;;!!! change in the future. Perhaps.
4578 (gnus-data-enter-list
4579 (if line nil current) data (- (point) old-pos))
4580 (setq gnus-newsgroup-threads
4581 (nconc threads gnus-newsgroup-threads))
4582 (gnus-data-compute-positions))))
eec82323
LMI
4583
4584(defun gnus-number-to-header (number)
4585 "Return the header for article NUMBER."
4586 (let ((headers gnus-newsgroup-headers))
4587 (while (and headers
4588 (not (= number (mail-header-number (car headers)))))
4589 (pop headers))
4590 (when headers
4591 (car headers))))
4592
6748645f 4593(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4594 "Return the headers of the GENERATIONeth parent of HEADERS."
4595 (unless generation
4596 (setq generation 1))
a8151ef7 4597 (let ((parent t)
6748645f 4598 (headers in-headers)
a8151ef7 4599 references)
6748645f
LMI
4600 (while (and parent
4601 (not (zerop generation))
4602 (setq references (mail-header-references headers)))
4603 (setq headers (if (and references
4604 (setq parent (gnus-parent-id references)))
4605 (car (gnus-id-to-thread parent))
4606 nil))
4607 (decf generation))
4608 (and (not (eq headers in-headers))
4609 headers)))
eec82323
LMI
4610
4611(defun gnus-id-to-thread (id)
4612 "Return the (sub-)thread where ID appears."
4613 (gnus-gethash id gnus-newsgroup-dependencies))
4614
4615(defun gnus-id-to-article (id)
4616 "Return the article number of ID."
4617 (let ((thread (gnus-id-to-thread id)))
4618 (when (and thread
4619 (car thread))
4620 (mail-header-number (car thread)))))
4621
4622(defun gnus-id-to-header (id)
4623 "Return the article headers of ID."
4624 (car (gnus-id-to-thread id)))
4625
4626(defun gnus-article-displayed-root-p (article)
4627 "Say whether ARTICLE is a root(ish) article."
4628 (let ((level (gnus-summary-thread-level article))
4629 (refs (mail-header-references (gnus-summary-article-header article)))
4630 particle)
4631 (cond
4632 ((null level) nil)
4633 ((zerop level) t)
4634 ((null refs) t)
4635 ((null (gnus-parent-id refs)) t)
4636 ((and (= 1 level)
4637 (null (setq particle (gnus-id-to-article
4638 (gnus-parent-id refs))))
4639 (null (gnus-summary-thread-level particle)))))))
4640
4641(defun gnus-root-id (id)
4642 "Return the id of the root of the thread where ID appears."
4643 (let (last-id prev)
6748645f 4644 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4645 (setq last-id id
4646 id (gnus-parent-id (mail-header-references prev))))
4647 last-id))
4648
6748645f
LMI
4649(defun gnus-articles-in-thread (thread)
4650 "Return the list of articles in THREAD."
4651 (cons (mail-header-number (car thread))
4652 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4653
eec82323
LMI
4654(defun gnus-remove-thread (id &optional dont-remove)
4655 "Remove the thread that has ID in it."
6748645f 4656 (let (headers thread last-id)
eec82323 4657 ;; First go up in this thread until we find the root.
6748645f
LMI
4658 (setq last-id (gnus-root-id id)
4659 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4660 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4661 ;; been gathered into some loose thread, so we have to search
4662 ;; through the threads to find the thread we wanted.
4663 (let ((threads gnus-newsgroup-threads)
4664 sub)
4665 (while threads
4666 (setq sub (car threads))
4667 (if (stringp (car sub))
4668 ;; This is a gathered thread, so we look at the roots
4669 ;; below it to find whether this article is in this
4670 ;; gathered root.
4671 (progn
4672 (setq sub (cdr sub))
4673 (while sub
4674 (when (member (caar sub) headers)
4675 (setq thread (car threads)
4676 threads nil
4677 sub nil))
4678 (setq sub (cdr sub))))
4679 ;; It's an ordinary thread, so we check it.
4680 (when (eq (car sub) (car headers))
4681 (setq thread sub
4682 threads nil)))
4683 (setq threads (cdr threads)))
4684 ;; If this article is in no thread, then it's a root.
4685 (if thread
4686 (unless dont-remove
4687 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4688 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4689 (when thread
4690 (prog1
4691 thread ; We return this thread.
4692 (unless dont-remove
4693 (if (stringp (car thread))
4694 (progn
4695 ;; If we use dummy roots, then we have to remove the
4696 ;; dummy root as well.
4697 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4698 ;; We go to the dummy root by going to
4699 ;; the first sub-"thread", and then one line up.
4700 (gnus-summary-goto-article
4701 (mail-header-number (caadr thread)))
4702 (forward-line -1)
eec82323
LMI
4703 (gnus-delete-line)
4704 (gnus-data-compute-positions))
4705 (setq thread (cdr thread))
4706 (while thread
4707 (gnus-remove-thread-1 (car thread))
4708 (setq thread (cdr thread))))
4709 (gnus-remove-thread-1 thread))))))))
4710
4711(defun gnus-remove-thread-1 (thread)
4712 "Remove the thread THREAD recursively."
4713 (let ((number (mail-header-number (pop thread)))
4714 d)
4715 (setq thread (reverse thread))
4716 (while thread
4717 (gnus-remove-thread-1 (pop thread)))
4718 (when (setq d (gnus-data-find number))
4719 (goto-char (gnus-data-pos d))
16409b0b 4720 (gnus-summary-show-thread)
eec82323
LMI
4721 (gnus-data-remove
4722 number
01c52d31 4723 (- (point-at-bol)
eec82323 4724 (prog1
01c52d31 4725 (1+ (point-at-eol))
eec82323
LMI
4726 (gnus-delete-line)))))))
4727
4921bbdd 4728(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4729 (sort (mapcar (lambda (thread)
4730 (cons (car thread)
4731 (and (cdr thread)
4921bbdd 4732 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4733 threads) func))
4734
4921bbdd
CY
4735(defun gnus-sort-threads-loop (threads func)
4736 (let* ((superthread (cons nil threads))
4737 (stack (list (cons superthread threads)))
4738 remaining-threads thread)
4739 (while stack
4740 (setq remaining-threads (cdr (car stack)))
4741 (if remaining-threads
4742 (progn (setq thread (car remaining-threads))
4743 (setcdr (car stack) (cdr remaining-threads))
4744 (if (cdr thread)
4745 (push (cons thread (cdr thread)) stack)))
4746 (setq thread (caar stack))
4747 (setcdr thread (sort (cdr thread) func))
4748 (pop stack)))
4749 (cdr superthread)))
4750
eec82323
LMI
4751(defun gnus-sort-threads (threads)
4752 "Sort THREADS."
4753 (if (not gnus-thread-sort-functions)
4754 threads
6748645f 4755 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4756 (prog1
4757 (condition-case nil
4758 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4759 (gnus-sort-threads-recursive
4760 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4761 ;; Even after binding max-lisp-eval-depth, the recursive
4762 ;; sorter might fail for very long threads. In that case,
4763 ;; try using a (less well-tested) non-recursive sorter.
4764 (error (gnus-sort-threads-loop
4765 threads (gnus-make-sort-function
4766 gnus-thread-sort-functions))))
4767 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4768
4769(defun gnus-sort-articles (articles)
4770 "Sort ARTICLES."
4771 (when gnus-article-sort-functions
4772 (gnus-message 7 "Sorting articles...")
4773 (prog1
4774 (setq gnus-newsgroup-headers
4775 (sort articles (gnus-make-sort-function
4776 gnus-article-sort-functions)))
4777 (gnus-message 7 "Sorting articles...done"))))
4778
4779;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4780(defmacro gnus-thread-header (thread)
16409b0b
GM
4781 "Return header of first article in THREAD.
4782Note that THREAD must never, ever be anything else than a variable -
4783using some other form will lead to serious barfage."
eec82323
LMI
4784 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4785 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4786 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4787 (vector thread) 2))
4788
4789(defsubst gnus-article-sort-by-number (h1 h2)
4790 "Sort articles by article number."
4791 (< (mail-header-number h1)
4792 (mail-header-number h2)))
4793
4794(defun gnus-thread-sort-by-number (h1 h2)
4795 "Sort threads by root article number."
4796 (gnus-article-sort-by-number
4797 (gnus-thread-header h1) (gnus-thread-header h2)))
4798
23f87bed 4799(defsubst gnus-article-sort-by-random (h1 h2)
0b6799c3 4800 "Sort articles randomly."
23f87bed
MB
4801 (zerop (random 2)))
4802
4803(defun gnus-thread-sort-by-random (h1 h2)
0b6799c3 4804 "Sort threads randomly."
23f87bed
MB
4805 (gnus-article-sort-by-random
4806 (gnus-thread-header h1) (gnus-thread-header h2)))
4807
eec82323
LMI
4808(defsubst gnus-article-sort-by-lines (h1 h2)
4809 "Sort articles by article Lines header."
4810 (< (mail-header-lines h1)
4811 (mail-header-lines h2)))
4812
4813(defun gnus-thread-sort-by-lines (h1 h2)
4814 "Sort threads by root article Lines header."
4815 (gnus-article-sort-by-lines
4816 (gnus-thread-header h1) (gnus-thread-header h2)))
4817
16409b0b
GM
4818(defsubst gnus-article-sort-by-chars (h1 h2)
4819 "Sort articles by octet length."
4820 (< (mail-header-chars h1)
4821 (mail-header-chars h2)))
4822
4823(defun gnus-thread-sort-by-chars (h1 h2)
4824 "Sort threads by root article octet length."
4825 (gnus-article-sort-by-chars
4826 (gnus-thread-header h1) (gnus-thread-header h2)))
4827
eec82323
LMI
4828(defsubst gnus-article-sort-by-author (h1 h2)
4829 "Sort articles by root author."
b4fde39f 4830 (gnus-string<
eec82323
LMI
4831 (let ((extract (funcall
4832 gnus-extract-address-components
4833 (mail-header-from h1))))
4834 (or (car extract) (cadr extract) ""))
4835 (let ((extract (funcall
4836 gnus-extract-address-components
4837 (mail-header-from h2))))
4838 (or (car extract) (cadr extract) ""))))
4839
4840(defun gnus-thread-sort-by-author (h1 h2)
4841 "Sort threads by root author."
4842 (gnus-article-sort-by-author
4843 (gnus-thread-header h1) (gnus-thread-header h2)))
4844
01c52d31
MB
4845(defsubst gnus-article-sort-by-recipient (h1 h2)
4846 "Sort articles by recipient."
4847 (gnus-string<
4848 (let ((extract (funcall
4849 gnus-extract-address-components
4850 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4851 (or (car extract) (cadr extract)))
4852 (let ((extract (funcall
4853 gnus-extract-address-components
4854 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4855 (or (car extract) (cadr extract)))))
4856
4857(defun gnus-thread-sort-by-recipient (h1 h2)
4858 "Sort threads by root recipient."
4859 (gnus-article-sort-by-recipient
4860 (gnus-thread-header h1) (gnus-thread-header h2)))
4861
eec82323
LMI
4862(defsubst gnus-article-sort-by-subject (h1 h2)
4863 "Sort articles by root subject."
b4fde39f 4864 (gnus-string<
eec82323
LMI
4865 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4866 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4867
4868(defun gnus-thread-sort-by-subject (h1 h2)
4869 "Sort threads by root subject."
4870 (gnus-article-sort-by-subject
4871 (gnus-thread-header h1) (gnus-thread-header h2)))
4872
4873(defsubst gnus-article-sort-by-date (h1 h2)
4874 "Sort articles by root article date."
16409b0b 4875 (time-less-p
eec82323
LMI
4876 (gnus-date-get-time (mail-header-date h1))
4877 (gnus-date-get-time (mail-header-date h2))))
4878
4879(defun gnus-thread-sort-by-date (h1 h2)
4880 "Sort threads by root article date."
4881 (gnus-article-sort-by-date
4882 (gnus-thread-header h1) (gnus-thread-header h2)))
4883
4884(defsubst gnus-article-sort-by-score (h1 h2)
4885 "Sort articles by root article score.
4886Unscored articles will be counted as having a score of zero."
4887 (> (or (cdr (assq (mail-header-number h1)
4888 gnus-newsgroup-scored))
4889 gnus-summary-default-score 0)
4890 (or (cdr (assq (mail-header-number h2)
4891 gnus-newsgroup-scored))
4892 gnus-summary-default-score 0)))
4893
4894(defun gnus-thread-sort-by-score (h1 h2)
4895 "Sort threads by root article score."
4896 (gnus-article-sort-by-score
4897 (gnus-thread-header h1) (gnus-thread-header h2)))
4898
4899(defun gnus-thread-sort-by-total-score (h1 h2)
4900 "Sort threads by the sum of all scores in the thread.
4901Unscored articles will be counted as having a score of zero."
4902 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4903
4904(defun gnus-thread-total-score (thread)
16409b0b 4905 ;; This function find the total score of THREAD.
23f87bed
MB
4906 (cond
4907 ((null thread)
4908 0)
4909 ((consp thread)
4910 (if (stringp (car thread))
4911 (apply gnus-thread-score-function 0
4912 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4913 (gnus-thread-total-score-1 thread)))
4914 (t
4915 (gnus-thread-total-score-1 (list thread)))))
4916
4917(defun gnus-thread-sort-by-most-recent-number (h1 h2)
4918 "Sort threads such that the thread with the most recently arrived article comes first."
4919 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4920
4921(defun gnus-thread-highest-number (thread)
4922 "Return the highest article number in THREAD."
4923 (apply 'max (mapcar (lambda (header)
4924 (mail-header-number header))
4925 (message-flatten-list thread))))
4926
4927(defun gnus-thread-sort-by-most-recent-date (h1 h2)
4928 "Sort threads such that the thread with the most recently dated article comes first."
4929 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4930
4931(defun gnus-thread-latest-date (thread)
4932 "Return the highest article date in THREAD."
4933 (let ((previous-time 0))
4934 (apply 'max
4935 (mapcar
4936 (lambda (header)
4937 (setq previous-time
4938 (condition-case ()
4939 (time-to-seconds (mail-header-parse-date
4940 (mail-header-date header)))
4941 (error previous-time))))
4942 (sort
4943 (message-flatten-list thread)
4944 (lambda (h1 h2)
4945 (< (mail-header-number h1)
4946 (mail-header-number h2))))))))
eec82323
LMI
4947
4948(defun gnus-thread-total-score-1 (root)
4949 ;; This function find the total score of the thread below ROOT.
4950 (setq root (car root))
4951 (apply gnus-thread-score-function
4952 (or (append
4953 (mapcar 'gnus-thread-total-score
6748645f 4954 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
4955 (when (> (mail-header-number root) 0)
4956 (list (or (cdr (assq (mail-header-number root)
4957 gnus-newsgroup-scored))
4958 gnus-summary-default-score 0))))
4959 (list gnus-summary-default-score)
4960 '(0))))
4961
4962;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4963(defvar gnus-tmp-prev-subject nil)
4964(defvar gnus-tmp-false-parent nil)
4965(defvar gnus-tmp-root-expunged nil)
4966(defvar gnus-tmp-dummy-line nil)
4967
16409b0b
GM
4968(defun gnus-extra-header (type &optional header)
4969 "Return the extra header of TYPE."
4970 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4971 ""))
4972
23f87bed
MB
4973(defvar gnus-tmp-thread-tree-header-string "")
4974
4975(defcustom gnus-sum-thread-tree-root "> "
4976 "With %B spec, used for the root of a thread.
4977If nil, use subject instead."
bf247b6e 4978 :version "22.1"
ad136a7c 4979 :type '(radio (const :format "%v " nil) string)
23f87bed 4980 :group 'gnus-thread)
01c52d31 4981
23f87bed
MB
4982(defcustom gnus-sum-thread-tree-false-root "> "
4983 "With %B spec, used for a false root of a thread.
4984If nil, use subject instead."
bf247b6e 4985 :version "22.1"
ad136a7c 4986 :type '(radio (const :format "%v " nil) string)
23f87bed 4987 :group 'gnus-thread)
01c52d31 4988
23f87bed
MB
4989(defcustom gnus-sum-thread-tree-single-indent ""
4990 "With %B spec, used for a thread with just one message.
4991If nil, use subject instead."
bf247b6e 4992 :version "22.1"
ad136a7c 4993 :type '(radio (const :format "%v " nil) string)
23f87bed 4994 :group 'gnus-thread)
01c52d31 4995
23f87bed
MB
4996(defcustom gnus-sum-thread-tree-vertical "| "
4997 "With %B spec, used for drawing a vertical line."
bf247b6e 4998 :version "22.1"
23f87bed
MB
4999 :type 'string
5000 :group 'gnus-thread)
01c52d31 5001
23f87bed
MB
5002(defcustom gnus-sum-thread-tree-indent " "
5003 "With %B spec, used for indenting."
bf247b6e 5004 :version "22.1"
23f87bed
MB
5005 :type 'string
5006 :group 'gnus-thread)
01c52d31 5007
23f87bed
MB
5008(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5009 "With %B spec, used for a leaf with brothers."
bf247b6e 5010 :version "22.1"
23f87bed
MB
5011 :type 'string
5012 :group 'gnus-thread)
01c52d31 5013
23f87bed
MB
5014(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5015 "With %B spec, used for a leaf without brothers."
bf247b6e 5016 :version "22.1"
23f87bed
MB
5017 :type 'string
5018 :group 'gnus-thread)
5019
eec82323
LMI
5020(defun gnus-summary-prepare-threads (threads)
5021 "Prepare summary buffer from THREADS and indentation LEVEL.
5022THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5023or a straight list of headers."
5024 (gnus-message 7 "Generating summary...")
5025
5026 (setq gnus-newsgroup-threads threads)
5027 (beginning-of-line)
5028
5029 (let ((gnus-tmp-level 0)
5030 (default-score (or gnus-summary-default-score 0))
5031 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
5032 (building-line-count gnus-summary-display-while-building)
5033 (building-count (integerp gnus-summary-display-while-building))
eec82323 5034 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
5035 new-roots gnus-tmp-new-adopts thread-end simp-subject
5036 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
5037 gnus-tmp-replied gnus-tmp-subject-or-nil
5038 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5039 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
5040 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5041 tree-stack)
eec82323 5042
23f87bed
MB
5043 (setq gnus-tmp-prev-subject nil
5044 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
5045
5046 (if (vectorp (car threads))
5047 ;; If this is a straight (sic) list of headers, then a
5048 ;; threaded summary display isn't required, so we just create
5049 ;; an unthreaded one.
5050 (gnus-summary-prepare-unthreaded threads)
5051
5052 ;; Do the threaded display.
5053
23f87bed
MB
5054 (if gnus-summary-display-while-building
5055 (switch-to-buffer (buffer-name)))
eec82323
LMI
5056 (while (or threads stack gnus-tmp-new-adopts new-roots)
5057
5058 (if (and (= gnus-tmp-level 0)
eec82323
LMI
5059 (or (not stack)
5060 (= (caar stack) 0))
5061 (not gnus-tmp-false-parent)
5062 (or gnus-tmp-new-adopts new-roots))
5063 (if gnus-tmp-new-adopts
5064 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5065 thread (list (car gnus-tmp-new-adopts))
5066 gnus-tmp-header (caar thread)
5067 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5068 (when new-roots
5069 (setq thread (list (car new-roots))
5070 gnus-tmp-header (caar thread)
5071 new-roots (cdr new-roots))))
5072
5073 (if threads
5074 ;; If there are some threads, we do them before the
5075 ;; threads on the stack.
5076 (setq thread threads
5077 gnus-tmp-header (caar thread))
5078 ;; There were no current threads, so we pop something off
5079 ;; the stack.
5080 (setq state (car stack)
5081 gnus-tmp-level (car state)
23f87bed
MB
5082 tree-stack (cadr state)
5083 thread (caddr state)
eec82323
LMI
5084 stack (cdr stack)
5085 gnus-tmp-header (caar thread))))
5086
5087 (setq gnus-tmp-false-parent nil)
5088 (setq gnus-tmp-root-expunged nil)
5089 (setq thread-end nil)
5090
5091 (if (stringp gnus-tmp-header)
5092 ;; The header is a dummy root.
5093 (cond
5094 ((eq gnus-summary-make-false-root 'adopt)
5095 ;; We let the first article adopt the rest.
5096 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5097 (cddar thread)))
5098 (setq gnus-tmp-gathered
5099 (nconc (mapcar
5100 (lambda (h) (mail-header-number (car h)))
5101 (cddar thread))
5102 gnus-tmp-gathered))
5103 (setq thread (cons (list (caar thread)
5104 (cadar thread))
5105 (cdr thread)))
5106 (setq gnus-tmp-level -1
5107 gnus-tmp-false-parent t))
5108 ((eq gnus-summary-make-false-root 'empty)
5109 ;; We print adopted articles with empty subject fields.
5110 (setq gnus-tmp-gathered
5111 (nconc (mapcar
5112 (lambda (h) (mail-header-number (car h)))
5113 (cddar thread))
5114 gnus-tmp-gathered))
5115 (setq gnus-tmp-level -1))
5116 ((eq gnus-summary-make-false-root 'dummy)
5117 ;; We remember that we probably want to output a dummy
5118 ;; root.
5119 (setq gnus-tmp-dummy-line gnus-tmp-header)
5120 (setq gnus-tmp-prev-subject gnus-tmp-header))
5121 (t
5122 ;; We do not make a root for the gathered
5123 ;; sub-threads at all.
5124 (setq gnus-tmp-level -1)))
5125
5126 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
5127 subject (mail-header-subject gnus-tmp-header)
5128 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
5129
5130 (cond
5131 ;; If the thread has changed subject, we might want to make
5132 ;; this subthread into a root.
5133 ((and (null gnus-thread-ignore-subject)
5134 (not (zerop gnus-tmp-level))
5135 gnus-tmp-prev-subject
23f87bed 5136 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5137 (setq new-roots (nconc new-roots (list (car thread)))
5138 thread-end t
5139 gnus-tmp-header nil))
5140 ;; If the article lies outside the current limit,
5141 ;; then we do not display it.
5142 ((not (memq number gnus-newsgroup-limit))
5143 (setq gnus-tmp-gathered
5144 (nconc (mapcar
5145 (lambda (h) (mail-header-number (car h)))
5146 (cdar thread))
5147 gnus-tmp-gathered))
5148 (setq gnus-tmp-new-adopts (if (cdar thread)
5149 (append gnus-tmp-new-adopts
5150 (cdar thread))
5151 gnus-tmp-new-adopts)
5152 thread-end t
5153 gnus-tmp-header nil)
5154 (when (zerop gnus-tmp-level)
5155 (setq gnus-tmp-root-expunged t)))
5156 ;; Perhaps this article is to be marked as read?
5157 ((and gnus-summary-mark-below
5158 (< (or (cdr (assq number gnus-newsgroup-scored))
5159 default-score)
5160 gnus-summary-mark-below)
5161 ;; Don't touch sparse articles.
5162 (not (gnus-summary-article-sparse-p number))
5163 (not (gnus-summary-article-ancient-p number)))
5164 (setq gnus-newsgroup-unreads
5165 (delq number gnus-newsgroup-unreads))
5166 (if gnus-newsgroup-auto-expire
23f87bed
MB
5167 (setq gnus-newsgroup-expirable
5168 (gnus-add-to-sorted-list
5169 gnus-newsgroup-expirable number))
eec82323
LMI
5170 (push (cons number gnus-low-score-mark)
5171 gnus-newsgroup-reads))))
5172
5173 (when gnus-tmp-header
5174 ;; We may have an old dummy line to output before this
5175 ;; article.
6748645f
LMI
5176 (when (and gnus-tmp-dummy-line
5177 (gnus-subject-equal
5178 gnus-tmp-dummy-line
5179 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
5180 (gnus-summary-insert-dummy-line
5181 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5182 (setq gnus-tmp-dummy-line nil))
5183
5184 ;; Compute the mark.
5185 (setq gnus-tmp-unread (gnus-article-mark number))
5186
5187 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5188 gnus-tmp-header gnus-tmp-level)
5189 gnus-newsgroup-data)
5190
5191 ;; Actually insert the line.
5192 (setq
5193 gnus-tmp-subject-or-nil
5194 (cond
5195 ((and gnus-thread-ignore-subject
5196 gnus-tmp-prev-subject
23f87bed 5197 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5198 subject)
5199 ((zerop gnus-tmp-level)
5200 (if (and (eq gnus-summary-make-false-root 'empty)
5201 (memq number gnus-tmp-gathered)
5202 gnus-tmp-prev-subject
23f87bed 5203 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5204 gnus-summary-same-subject
5205 subject))
5206 (t gnus-summary-same-subject)))
5207 (if (and (eq gnus-summary-make-false-root 'adopt)
5208 (= gnus-tmp-level 1)
5209 (memq number gnus-tmp-gathered))
5210 (setq gnus-tmp-opening-bracket ?\<
5211 gnus-tmp-closing-bracket ?\>)
5212 (setq gnus-tmp-opening-bracket ?\[
5213 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5214 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5215 (gnus-make-thread-indent-array
5216 (max (* 2 (length gnus-thread-indent-array))
5217 gnus-tmp-level)))
eec82323
LMI
5218 (setq
5219 gnus-tmp-indentation
5220 (aref gnus-thread-indent-array gnus-tmp-level)
5221 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5222 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5223 gnus-summary-default-score 0)
5224 gnus-tmp-score-char
5225 (if (or (null gnus-summary-default-score)
5226 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5227 gnus-summary-zcore-fuzz))
23f87bed 5228 ? ;Whitespace
eec82323
LMI
5229 (if (< gnus-tmp-score gnus-summary-default-score)
5230 gnus-score-below-mark gnus-score-over-mark))
5231 gnus-tmp-replied
5232 (cond ((memq number gnus-newsgroup-processable)
5233 gnus-process-mark)
5234 ((memq number gnus-newsgroup-cached)
5235 gnus-cached-mark)
5236 ((memq number gnus-newsgroup-replied)
5237 gnus-replied-mark)
23f87bed
MB
5238 ((memq number gnus-newsgroup-forwarded)
5239 gnus-forwarded-mark)
eec82323
LMI
5240 ((memq number gnus-newsgroup-saved)
5241 gnus-saved-mark)
23f87bed
MB
5242 ((memq number gnus-newsgroup-recent)
5243 gnus-recent-mark)
5244 ((memq number gnus-newsgroup-unseen)
5245 gnus-unseen-mark)
5246 (t gnus-no-mark))
5247 gnus-tmp-downloaded
5248 (cond ((memq number gnus-newsgroup-undownloaded)
5249 gnus-undownloaded-mark)
5250 (gnus-newsgroup-agentized
5251 gnus-downloaded-mark)
5252 (t
5253 gnus-no-mark))
eec82323
LMI
5254 gnus-tmp-from (mail-header-from gnus-tmp-header)
5255 gnus-tmp-name
5256 (cond
5257 ((string-match "<[^>]+> *$" gnus-tmp-from)
5258 (setq beg-match (match-beginning 0))
23f87bed
MB
5259 (or (and (string-match "^\".+\"" gnus-tmp-from)
5260 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5261 (substring gnus-tmp-from 0 beg-match)))
5262 ((string-match "(.+)" gnus-tmp-from)
5263 (substring gnus-tmp-from
5264 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5265 (t gnus-tmp-from))
5266
5267 ;; Do the %B string
5268 gnus-tmp-thread-tree-header-string
5269 (cond
5270 ((not gnus-show-threads) "")
5271 ((zerop gnus-tmp-level)
5272 (cond ((cdar thread)
5273 (or gnus-sum-thread-tree-root subject))
5274 (gnus-tmp-new-adopts
5275 (or gnus-sum-thread-tree-false-root subject))
5276 (t
5277 (or gnus-sum-thread-tree-single-indent subject))))
5278 (t
5279 (concat (apply 'concat
5280 (mapcar (lambda (item)
5281 (if (= item 1)
5282 gnus-sum-thread-tree-vertical
5283 gnus-sum-thread-tree-indent))
5284 (cdr (reverse tree-stack))))
5285 (if (nth 1 thread)
5286 gnus-sum-thread-tree-leaf-with-other
5287 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5288 (when (string= gnus-tmp-name "")
5289 (setq gnus-tmp-name gnus-tmp-from))
5290 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5291 (setq gnus-tmp-lines -1))
5292 (if (= gnus-tmp-lines -1)
5293 (setq gnus-tmp-lines "?")
5294 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5295 (gnus-put-text-property
eec82323
LMI
5296 (point)
5297 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 5298 'gnus-number number)
eec82323
LMI
5299 (when gnus-visual-p
5300 (forward-line -1)
6748645f 5301 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
5302 (forward-line 1))
5303
23f87bed 5304 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5305
5306 (when (nth 1 thread)
23f87bed
MB
5307 (push (list (max 0 gnus-tmp-level)
5308 (copy-sequence tree-stack)
5309 (nthcdr 1 thread))
5310 stack))
5311 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5312 (incf gnus-tmp-level)
5313 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5314 (if gnus-summary-display-while-building
5315 (if building-count
5316 (progn
5317 ;; use a set frequency
5318 (setq building-line-count (1- building-line-count))
5319 (when (= building-line-count 0)
5320 (sit-for 0)
5321 (setq building-line-count
5322 gnus-summary-display-while-building)))
5323 ;; always
5324 (sit-for 0)))
eec82323
LMI
5325 (unless threads
5326 (setq gnus-tmp-level 0)))))
5327 (gnus-message 7 "Generating summary...done"))
5328
5329(defun gnus-summary-prepare-unthreaded (headers)
5330 "Generate an unthreaded summary buffer based on HEADERS."
5331 (let (header number mark)
5332
5333 (beginning-of-line)
5334
5335 (while headers
5336 ;; We may have to root out some bad articles...
5337 (when (memq (setq number (mail-header-number
5338 (setq header (pop headers))))
5339 gnus-newsgroup-limit)
5340 ;; Mark article as read when it has a low score.
5341 (when (and gnus-summary-mark-below
5342 (< (or (cdr (assq number gnus-newsgroup-scored))
5343 gnus-summary-default-score 0)
5344 gnus-summary-mark-below)
5345 (not (gnus-summary-article-ancient-p number)))
5346 (setq gnus-newsgroup-unreads
5347 (delq number gnus-newsgroup-unreads))
5348 (if gnus-newsgroup-auto-expire
5349 (push number gnus-newsgroup-expirable)
5350 (push (cons number gnus-low-score-mark)
5351 gnus-newsgroup-reads)))
5352
5353 (setq mark (gnus-article-mark number))
5354 (push (gnus-data-make number mark (1+ (point)) header 0)
5355 gnus-newsgroup-data)
5356 (gnus-summary-insert-line
5357 header 0 number
23f87bed 5358 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5359 mark (memq number gnus-newsgroup-replied)
5360 (memq number gnus-newsgroup-expirable)
5361 (mail-header-subject header) nil
5362 (cdr (assq number gnus-newsgroup-scored))
5363 (memq number gnus-newsgroup-processable))))))
5364
16409b0b
GM
5365(defun gnus-summary-remove-list-identifiers ()
5366 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5367 (let ((regexp (if (consp gnus-list-identifiers)
5368 (mapconcat 'identity gnus-list-identifiers " *\\|")
5369 gnus-list-identifiers))
5370 changed subject)
5371 (when regexp
01c52d31 5372 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
23f87bed
MB
5373 (dolist (header gnus-newsgroup-headers)
5374 (setq subject (mail-header-subject header)
5375 changed nil)
01c52d31 5376 (while (string-match regexp subject)
23f87bed 5377 (setq subject
01c52d31 5378 (concat (substring subject 0 (match-beginning 1))
23f87bed
MB
5379 (substring subject (match-end 0)))
5380 changed t))
23f87bed 5381 (when changed
01c52d31
MB
5382 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5383 (setq subject
5384 (concat (substring subject 0 (match-beginning 1))
5385 (substring subject (match-end 1)))))
23f87bed
MB
5386 (mail-header-set-subject header subject))))))
5387
5388(defun gnus-fetch-headers (articles)
5389 "Fetch headers of ARTICLES."
5390 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5391 (gnus-message 5 "Fetching headers for %s..." name)
5392 (prog1
5393 (if (eq 'nov
5394 (setq gnus-headers-retrieved-by
5395 (gnus-retrieve-headers
5396 articles gnus-newsgroup-name
5397 ;; We might want to fetch old headers, but
5398 ;; not if there is only 1 article.
5399 (and (or (and
5400 (not (eq gnus-fetch-old-headers 'some))
5401 (not (numberp gnus-fetch-old-headers)))
5402 (> (length articles) 1))
5403 gnus-fetch-old-headers))))
5404 (gnus-get-newsgroup-headers-xover
5405 articles nil nil gnus-newsgroup-name t)
5406 (gnus-get-newsgroup-headers))
5407 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5408
6748645f 5409(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5410 "Select newsgroup GROUP.
6748645f
LMI
5411If READ-ALL is non-nil, all articles in the group are selected.
5412If SELECT-ARTICLES, only select those articles from GROUP."
01c52d31 5413 (let* ((entry (gnus-group-entry group))
eec82323
LMI
5414 ;;!!! Dirty hack; should be removed.
5415 (gnus-summary-ignore-duplicates
23f87bed 5416 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5417 t
5418 gnus-summary-ignore-duplicates))
5419 (info (nth 2 entry))
01c52d31 5420 charset articles fetched-articles cached)
eec82323
LMI
5421
5422 (unless (gnus-check-server
475e0e0c
GM
5423 (set (make-local-variable 'gnus-current-select-method)
5424 (gnus-find-method-for-group group)))
eec82323 5425 (error "Couldn't open server"))
01c52d31 5426 (setq charset (gnus-group-name-charset gnus-current-select-method group))
eec82323
LMI
5427
5428 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5429 (gnus-activate-group group) ; Or we can activate it...
5430 (progn ; Or we bug out.
5431 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5432 (gnus-kill-buffer (current-buffer)))
01c52d31
MB
5433 (error
5434 "Couldn't activate group %s: %s"
5435 (mm-decode-coding-string group charset)
5436 (mm-decode-coding-string (gnus-status-message group) charset))))
eec82323
LMI
5437
5438 (unless (gnus-request-group group t)
01c52d31
MB
5439 (when (equal major-mode 'gnus-summary-mode)
5440 (gnus-kill-buffer (current-buffer)))
5441 (error "Couldn't request group %s: %s"
5442 (mm-decode-coding-string group charset)
5443 (mm-decode-coding-string (gnus-status-message group) charset)))
eec82323 5444
23f87bed 5445 (when gnus-agent
54506618 5446 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5447
23f87bed
MB
5448 (setq gnus-summary-use-undownloaded-faces
5449 (gnus-agent-find-parameter
5450 group
5451 'agent-enable-undownloaded-faces)))
5452
5453 (setq gnus-newsgroup-name group
5454 gnus-newsgroup-unselected nil
5455 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5456
5457 (let ((display (gnus-group-find-parameter group 'display)))
5458 (setq gnus-newsgroup-display
5459 (cond
5460 ((not (zerop (or (car-safe read-all) 0)))
5461 ;; The user entered the group with C-u SPC/RET, let's show
5462 ;; all articles.
5463 'gnus-not-ignore)
5464 ((eq display 'all)
5465 'gnus-not-ignore)
5466 ((arrayp display)
5467 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5468 ((numberp display)
5469 ;; The following is probably the "correct" solution, but
5470 ;; it makes Gnus fetch all headers and then limit the
5471 ;; articles (which is slow), so instead we hack the
5472 ;; select-articles parameter instead. -- Simon Josefsson
5473 ;; <jas@kth.se>
5474 ;;
5475 ;; (gnus-byte-compile
5476 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5477 ;; display)))))
5478 (setq select-articles
5479 (gnus-uncompress-range
5480 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5481 (if (> tmp 0)
5482 tmp
5483 1))
5484 (cdr (gnus-active group)))))
5485 nil)
5486 (t
5487 nil))))
eec82323 5488
23f87bed 5489 (gnus-summary-setup-default-charset)
eec82323
LMI
5490
5491 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5492 (when (gnus-virtual-group-p group)
5493 (setq cached gnus-newsgroup-cached))
5494
5495 (setq gnus-newsgroup-unreads
23f87bed
MB
5496 (gnus-sorted-ndifference
5497 (gnus-sorted-ndifference gnus-newsgroup-unreads
5498 gnus-newsgroup-marked)
eec82323
LMI
5499 gnus-newsgroup-dormant))
5500
5501 (setq gnus-newsgroup-processable nil)
5502
5503 (gnus-update-read-articles group gnus-newsgroup-unreads)
eec82323 5504
23f87bed
MB
5505 ;; Adjust and set lists of article marks.
5506 (when info
5507 (gnus-adjust-marked-articles info))
6748645f
LMI
5508 (if (setq articles select-articles)
5509 (setq gnus-newsgroup-unselected
23f87bed 5510 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5511 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5512
5513 (cond
5514 ((null articles)
5515 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5516 'quit)
5517 ((eq articles 0) nil)
5518 (t
5519 ;; Init the dependencies hash table.
5520 (setq gnus-newsgroup-dependencies
5521 (gnus-make-hashtable (length articles)))
16409b0b 5522 (gnus-set-global-variables)
eec82323 5523 ;; Retrieve the headers and read them in.
23f87bed
MB
5524
5525 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5526
5527 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5528 (when cached
5529 (setq gnus-newsgroup-cached cached))
5530
5531 ;; Suppress duplicates?
5532 (when gnus-suppress-duplicates
5533 (gnus-dup-suppress-articles))
5534
5535 ;; Set the initial limit.
5536 (setq gnus-newsgroup-limit (copy-sequence articles))
5537 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5538 (setq fetched-articles
5539 (mapcar (lambda (headers) (mail-header-number headers))
5540 gnus-newsgroup-headers))
5541 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5542 (setq gnus-newsgroup-unreads
23f87bed
MB
5543 (gnus-sorted-nintersection
5544 gnus-newsgroup-unreads fetched-articles))
5545 (gnus-compute-unseen-list)
5546
eec82323
LMI
5547 ;; Removed marked articles that do not exist.
5548 (gnus-update-missing-marks
23f87bed 5549 (gnus-sorted-difference articles fetched-articles))
eec82323 5550 ;; We might want to build some more threads first.
6748645f
LMI
5551 (when (and gnus-fetch-old-headers
5552 (eq gnus-headers-retrieved-by 'nov))
5553 (if (eq gnus-fetch-old-headers 'invisible)
5554 (gnus-build-all-threads)
5555 (gnus-build-old-threads)))
5556 ;; Let the Gnus agent mark articles as read.
5557 (when gnus-agent
5558 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5559 ;; Remove list identifiers from subject
5560 (when gnus-list-identifiers
5561 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5562 ;; Check whether auto-expire is to be done in this group.
5563 (setq gnus-newsgroup-auto-expire
5564 (gnus-group-auto-expirable-p group))
5565 ;; Set up the article buffer now, if necessary.
01c52d31
MB
5566 (unless (and gnus-single-article-buffer
5567 (equal gnus-article-buffer "*Article*"))
eec82323
LMI
5568 (gnus-article-setup-buffer))
5569 ;; First and last article in this newsgroup.
5570 (when gnus-newsgroup-headers
5571 (setq gnus-newsgroup-begin
5572 (mail-header-number (car gnus-newsgroup-headers))
5573 gnus-newsgroup-end
5574 (mail-header-number
5575 (gnus-last-element gnus-newsgroup-headers))))
5576 ;; GROUP is successfully selected.
5577 (or gnus-newsgroup-headers t)))))
5578
23f87bed
MB
5579(defun gnus-compute-unseen-list ()
5580 ;; The `seen' marks are treated specially.
5581 (if (not gnus-newsgroup-seen)
5582 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5583 (setq gnus-newsgroup-unseen
5584 (gnus-inverse-list-range-intersection
5585 gnus-newsgroup-articles gnus-newsgroup-seen))))
5586
d09ae6ca
GM
5587(declare-function gnus-get-predicate "gnus-agent" (predicate))
5588
23f87bed
MB
5589(defun gnus-summary-display-make-predicate (display)
5590 (require 'gnus-agent)
5591 (when (= (length display) 1)
5592 (setq display (car display)))
5593 (unless gnus-summary-display-cache
5594 (dolist (elem (append '((unread . unread)
5595 (read . read)
5596 (unseen . unseen))
5597 gnus-article-mark-lists))
5598 (push (cons (cdr elem)
5599 (gnus-byte-compile
5600 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5601 gnus-summary-display-cache)))
5602 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5603 (gnus-category-predicate-cache gnus-summary-display-cache))
5604 (gnus-get-predicate display)))
5605
5606;; Uses the dynamically bound `number' variable.
9efa445f 5607(defvar number)
23f87bed
MB
5608(defun gnus-article-marked-p (type &optional article)
5609 (let ((article (or article number)))
5610 (cond
5611 ((eq type 'tick)
5612 (memq article gnus-newsgroup-marked))
5613 ((eq type 'spam)
5614 (memq article gnus-newsgroup-spam-marked))
5615 ((eq type 'unsend)
5616 (memq article gnus-newsgroup-unsendable))
5617 ((eq type 'undownload)
5618 (memq article gnus-newsgroup-undownloaded))
5619 ((eq type 'download)
5620 (memq article gnus-newsgroup-downloadable))
5621 ((eq type 'unread)
5622 (memq article gnus-newsgroup-unreads))
5623 ((eq type 'read)
5624 (memq article gnus-newsgroup-reads))
5625 ((eq type 'dormant)
5626 (memq article gnus-newsgroup-dormant) )
5627 ((eq type 'expire)
5628 (memq article gnus-newsgroup-expirable))
5629 ((eq type 'reply)
5630 (memq article gnus-newsgroup-replied))
5631 ((eq type 'killed)
5632 (memq article gnus-newsgroup-killed))
5633 ((eq type 'bookmark)
5634 (assq article gnus-newsgroup-bookmarks))
5635 ((eq type 'score)
5636 (assq article gnus-newsgroup-scored))
5637 ((eq type 'save)
5638 (memq article gnus-newsgroup-saved))
5639 ((eq type 'cache)
5640 (memq article gnus-newsgroup-cached))
5641 ((eq type 'forward)
5642 (memq article gnus-newsgroup-forwarded))
5643 ((eq type 'seen)
5644 (not (memq article gnus-newsgroup-unseen)))
5645 ((eq type 'recent)
5646 (memq article gnus-newsgroup-recent))
5647 (t t))))
5648
eec82323 5649(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5650 "Find out what articles the user wants to read."
26c9afc3 5651 (let* ((articles
eec82323
LMI
5652 ;; Select all articles if `read-all' is non-nil, or if there
5653 ;; are no unread articles.
5654 (if (or read-all
5655 (and (zerop (length gnus-newsgroup-marked))
5656 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5657 ;; Fetch all if the predicate is non-nil.
5658 gnus-newsgroup-display)
5659 ;; We want to select the headers for all the articles in
5660 ;; the group, so we select either all the active
5661 ;; articles in the group, or (if that's nil), the
5662 ;; articles in the cache.
16409b0b 5663 (or
4b70e299 5664 (if gnus-newsgroup-maximum-articles
11abff8e
MB
5665 (let ((active (gnus-active group)))
5666 (gnus-uncompress-range
5667 (cons (max (car active)
4b70e299
MB
5668 (- (cdr active)
5669 gnus-newsgroup-maximum-articles
5670 -1))
11abff8e
MB
5671 (cdr active))))
5672 (gnus-uncompress-range (gnus-active group)))
16409b0b 5673 (gnus-cache-articles-in-group group))
23f87bed
MB
5674 ;; Select only the "normal" subset of articles.
5675 (gnus-sorted-nunion
5676 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5677 gnus-newsgroup-unreads)))
eec82323
LMI
5678 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5679 (scored (length scored-list))
5680 (number (length articles))
5681 (marked (+ (length gnus-newsgroup-marked)
5682 (length gnus-newsgroup-dormant)))
5683 (select
5684 (cond
5685 ((numberp read-all)
5686 read-all)
23f87bed
MB
5687 ((numberp gnus-newsgroup-display)
5688 gnus-newsgroup-display)
eec82323
LMI
5689 (t
5690 (condition-case ()
5691 (cond
5692 ((and (or (<= scored marked) (= scored number))
5693 (numberp gnus-large-newsgroup)
5694 (> number gnus-large-newsgroup))
23f87bed
MB
5695 (let* ((cursor-in-echo-area nil)
5696 (initial (gnus-parameter-large-newsgroup-initial
5697 gnus-newsgroup-name))
5698 (input
5699 (read-string
5700 (format
5701 "How many articles from %s (%s %d): "
01c52d31 5702 (gnus-group-decoded-name gnus-newsgroup-name)
23f87bed
MB
5703 (if initial "max" "default")
5704 number)
5705 (if initial
5706 (cons (number-to-string initial)
5707 0)))))
eec82323
LMI
5708 (if (string-match "^[ \t]*$" input) number input)))
5709 ((and (> scored marked) (< scored number)
5710 (> (- scored number) 20))
5711 (let ((input
5712 (read-string
5713 (format "%s %s (%d scored, %d total): "
5714 "How many articles from"
23f87bed
MB
5715 (gnus-group-decoded-name group)
5716 scored number))))
eec82323
LMI
5717 (if (string-match "^[ \t]*$" input)
5718 number input)))
5719 (t number))
d4dfaa19
DL
5720 (quit
5721 (message "Quit getting the articles to read")
5722 nil))))))
eec82323
LMI
5723 (setq select (if (stringp select) (string-to-number select) select))
5724 (if (or (null select) (zerop select))
5725 select
5726 (if (and (not (zerop scored)) (<= (abs select) scored))
5727 (progn
5728 (setq articles (sort scored-list '<))
5729 (setq number (length articles)))
5730 (setq articles (copy-sequence articles)))
5731
5732 (when (< (abs select) number)
5733 (if (< select 0)
5734 ;; Select the N oldest articles.
5735 (setcdr (nthcdr (1- (abs select)) articles) nil)
5736 ;; Select the N most recent articles.
5737 (setq articles (nthcdr (- number select) articles))))
5738 (setq gnus-newsgroup-unselected
23f87bed 5739 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5740 (when gnus-alter-articles-to-read-function
23f87bed 5741 (setq articles
a1506d29 5742 (sort
16409b0b 5743 (funcall gnus-alter-articles-to-read-function
23f87bed 5744 gnus-newsgroup-name articles)
16409b0b 5745 '<)))
eec82323
LMI
5746 articles)))
5747
5748(defun gnus-killed-articles (killed articles)
5749 (let (out)
5750 (while articles
5751 (when (inline (gnus-member-of-range (car articles) killed))
5752 (push (car articles) out))
5753 (setq articles (cdr articles)))
5754 out))
5755
5756(defun gnus-uncompress-marks (marks)
5757 "Uncompress the mark ranges in MARKS."
5758 (let ((uncompressed '(score bookmark))
5759 out)
5760 (while marks
5761 (if (memq (caar marks) uncompressed)
5762 (push (car marks) out)
5763 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5764 (setq marks (cdr marks)))
5765 out))
5766
23f87bed
MB
5767(defun gnus-article-mark-to-type (mark)
5768 "Return the type of MARK."
5769 (or (cadr (assq mark gnus-article-special-mark-lists))
5770 'list))
5771
5772(defun gnus-article-unpropagatable-p (mark)
5773 "Return whether MARK should be propagated to back end."
5774 (memq mark gnus-article-unpropagated-mark-lists))
5775
eec82323 5776(defun gnus-adjust-marked-articles (info)
16409b0b 5777 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5778 (let* ((marked-lists (gnus-info-marks info))
5779 (active (gnus-active (gnus-info-group info)))
5780 (min (car active))
5781 (max (cdr active))
5782 (types gnus-article-mark-lists)
54506618
MB
5783 marks var articles article mark mark-type
5784 bgn end)
eec82323 5785
23f87bed
MB
5786 (dolist (marks marked-lists)
5787 (setq mark (car marks)
5788 mark-type (gnus-article-mark-to-type mark)
5789 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5790
23f87bed
MB
5791 ;; We set the variable according to the type of the marks list,
5792 ;; and then adjust the marks to a subset of the active articles.
eec82323 5793 (cond
54506618 5794 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5795 ((eq mark-type 'list)
54506618
MB
5796 ;; Simultaneously uncompress and clip to active range
5797 ;; See gnus-uncompress-range for a description of possible marks
5798 (let (l lh)
5799 (if (not (cadr marks))
5800 (set var nil)
5801 (setq articles (if (numberp (cddr marks))
5802 (list (cdr marks))
5803 (cdr marks))
5804 lh (cons nil nil)
5805 l lh)
5806
5807 (while (setq article (pop articles))
5808 (cond ((consp article)
5809 (setq bgn (max (car article) min)
5810 end (min (cdr article) max))
5811 (while (<= bgn end)
5812 (setq l (setcdr l (cons bgn nil))
5813 bgn (1+ bgn))))
5814 ((and (<= min article)
5815 (>= max article))
5816 (setq l (setcdr l (cons article nil))))))
5817 (set var (cdr lh)))))
eec82323 5818 ;; Adjust assocs.
23f87bed
MB
5819 ((eq mark-type 'tuple)
5820 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5821 (when (not (listp (cdr (symbol-value var))))
5822 (set var (list (symbol-value var))))
5823 (when (not (listp (cdr articles)))
5824 (setq articles (list articles)))
eec82323
LMI
5825 (while articles
5826 (when (or (not (consp (setq article (pop articles))))
5827 (< (car article) min)
5828 (> (car article) max))
23f87bed
MB
5829 (set var (delq article (symbol-value var))))))
5830 ;; Adjust ranges (sloppily).
5831 ((eq mark-type 'range)
5832 (cond
5833 ((eq mark 'seen)
5834 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5835 ;; It should be (seen (NUM1 . NUM2)).
5836 (when (numberp (cddr marks))
5837 (setcdr marks (list (cdr marks))))
5838 (setq articles (cdr marks))
5839 (while (and articles
5840 (or (and (consp (car articles))
5841 (> min (cdar articles)))
5842 (and (numberp (car articles))
5843 (> min (car articles)))))
5844 (pop articles))
5845 (set var articles))))))))
eec82323
LMI
5846
5847(defun gnus-update-missing-marks (missing)
6748645f 5848 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 5849 (when missing
23f87bed 5850 (let (var m)
eec82323 5851 ;; Go through all types.
23f87bed
MB
5852 (dolist (elem gnus-article-mark-lists)
5853 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5854 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5855 (when (symbol-value var)
5856 ;; This list has articles. So we delete all missing
5857 ;; articles from it.
5858 (setq m missing)
5859 (while m
5860 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
5861
5862(defun gnus-update-marks ()
5863 "Enter the various lists of marked articles into the newsgroup info list."
5864 (let ((types gnus-article-mark-lists)
5865 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 5866 type list newmarked symbol delta-marks)
eec82323 5867 (when info
16409b0b 5868 ;; Add all marks lists to the list of marks lists.
eec82323 5869 (while (setq type (pop types))
16409b0b
GM
5870 (setq list (symbol-value
5871 (setq symbol
23f87bed 5872 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 5873
16409b0b 5874 (when list
eec82323
LMI
5875 ;; Get rid of the entries of the articles that have the
5876 ;; default score.
5877 (when (and (eq (cdr type) 'score)
5878 gnus-save-score
5879 list)
5880 (let* ((arts list)
5881 (prev (cons nil list))
5882 (all prev))
5883 (while arts
5884 (if (or (not (consp (car arts)))
5885 (= (cdar arts) gnus-summary-default-score))
5886 (setcdr prev (cdr arts))
5887 (setq prev arts))
5888 (setq arts (cdr arts)))
16409b0b
GM
5889 (setq list (cdr all)))))
5890
23f87bed
MB
5891 (when (eq (cdr type) 'seen)
5892 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5893
5894 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 5895 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 5896
23f87bed
MB
5897 (when (and (gnus-check-backend-function
5898 'request-set-mark gnus-newsgroup-name)
5899 (not (gnus-article-unpropagatable-p (cdr type))))
5900 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5901 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5902 (add (gnus-remove-from-range
5903 (gnus-copy-sequence list) old)))
5904 (when add
5905 (push (list add 'add (list (cdr type))) delta-marks))
5906 (when del
5907 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 5908
16409b0b
GM
5909 (when list
5910 (push (cons (cdr type) list) newmarked)))
5911
5912 (when delta-marks
5913 (unless (gnus-check-group gnus-newsgroup-name)
5914 (error "Can't open server for %s" gnus-newsgroup-name))
5915 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 5916
eec82323
LMI
5917 ;; Enter these new marks into the info of the group.
5918 (if (nthcdr 3 info)
5919 (setcar (nthcdr 3 info) newmarked)
5920 ;; Add the marks lists to the end of the info.
5921 (when newmarked
5922 (setcdr (nthcdr 2 info) (list newmarked))))
5923
5924 ;; Cut off the end of the info if there's nothing else there.
5925 (let ((i 5))
5926 (while (and (> i 2)
5927 (not (nth i info)))
5928 (when (nthcdr (decf i) info)
5929 (setcdr (nthcdr i info) nil)))))))
5930
5931(defun gnus-set-mode-line (where)
16409b0b 5932 "Set the mode line of the article or summary buffers.
eec82323
LMI
5933If WHERE is `summary', the summary mode line format will be used."
5934 ;; Is this mode line one we keep updated?
16409b0b
GM
5935 (when (and (memq where gnus-updated-mode-lines)
5936 (symbol-value
5937 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323
LMI
5938 (let (mode-string)
5939 (save-excursion
5940 ;; We evaluate this in the summary buffer since these
5941 ;; variables are buffer-local to that buffer.
5942 (set-buffer gnus-summary-buffer)
23f87bed 5943 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
5944 ;; below.
5945 (let* ((mformat (symbol-value
5946 (intern
5947 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
5948 (gnus-tmp-group-name (gnus-mode-string-quote
5949 (gnus-group-decoded-name
5950 gnus-newsgroup-name)))
eec82323
LMI
5951 (gnus-tmp-article-number (or gnus-current-article 0))
5952 (gnus-tmp-unread gnus-newsgroup-unreads)
5953 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5954 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5955 (gnus-tmp-unread-and-unselected
5956 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5957 (zerop gnus-tmp-unselected))
5958 "")
5959 ((zerop gnus-tmp-unselected)
5960 (format "{%d more}" gnus-tmp-unread-and-unticked))
5961 (t (format "{%d(+%d) more}"
5962 gnus-tmp-unread-and-unticked
5963 gnus-tmp-unselected))))
5964 (gnus-tmp-subject
5965 (if (and gnus-current-headers
5966 (vectorp gnus-current-headers))
5967 (gnus-mode-string-quote
5968 (mail-header-subject gnus-current-headers))
5969 ""))
5970 bufname-length max-len
23f87bed 5971 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
5972 (setq mode-string (eval mformat))
5973 (setq bufname-length (if (string-match "%b" mode-string)
5974 (- (length
5975 (buffer-name
5976 (if (eq where 'summary)
5977 nil
5978 (get-buffer gnus-article-buffer))))
5979 2)
5980 0))
5981 (setq max-len (max 4 (if gnus-mode-non-string-length
5982 (- (window-width)
5983 gnus-mode-non-string-length
5984 bufname-length)
5985 (length mode-string))))
5986 ;; We might have to chop a bit of the string off...
5987 (when (> (length mode-string) max-len)
5988 (setq mode-string
16409b0b 5989 (concat (truncate-string-to-width mode-string (- max-len 3))
eec82323
LMI
5990 "...")))
5991 ;; Pad the mode string a bit.
5992 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5993 ;; Update the mode line.
5994 (setq mode-line-buffer-identification
5995 (gnus-mode-line-buffer-identification (list mode-string)))
5996 (set-buffer-modified-p t))))
5997
5998(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5999 "Go through the HEADERS list and add all Xrefs to a hash table.
6000The resulting hash table is returned, or nil if no Xrefs were found."
6001 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6002 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6003 (xref-hashtb (gnus-make-hashtable))
6004 start group entry number xrefs header)
6005 (while headers
6006 (setq header (pop headers))
6007 (when (and (setq xrefs (mail-header-xref header))
6008 (not (memq (setq number (mail-header-number header))
6009 unreads)))
6010 (setq start 0)
6011 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6012 (setq start (match-end 0))
6013 (setq group (if prefix
6014 (concat prefix (substring xrefs (match-beginning 1)
6015 (match-end 1)))
6016 (substring xrefs (match-beginning 1) (match-end 1))))
6017 (setq number
e9bd5782 6018 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
6019 (match-end 2))))
6020 (if (setq entry (gnus-gethash group xref-hashtb))
6021 (setcdr entry (cons number (cdr entry)))
6022 (gnus-sethash group (cons number nil) xref-hashtb)))))
6023 (and start xref-hashtb)))
6024
6025(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6026 "Look through all the headers and mark the Xrefs as read."
6027 (let ((virtual (gnus-virtual-group-p from-newsgroup))
01c52d31 6028 name info xref-hashtb idlist method nth4)
eec82323
LMI
6029 (save-excursion
6030 (set-buffer gnus-group-buffer)
6031 (when (setq xref-hashtb
6032 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6033 (mapatoms
6034 (lambda (group)
6035 (unless (string= from-newsgroup (setq name (symbol-name group)))
6036 (setq idlist (symbol-value group))
6037 ;; Dead groups are not updated.
6038 (and (prog1
01c52d31 6039 (setq info (gnus-get-info name))
eec82323
LMI
6040 (when (stringp (setq nth4 (gnus-info-method info)))
6041 (setq nth4 (gnus-server-to-method nth4))))
6042 ;; Only do the xrefs if the group has the same
6043 ;; select method as the group we have just read.
6044 (or (gnus-methods-equal-p
6045 nth4 (gnus-find-method-for-group from-newsgroup))
6046 virtual
6047 (equal nth4 (setq method (gnus-find-method-for-group
6048 from-newsgroup)))
6049 (and (equal (car nth4) (car method))
6050 (equal (nth 1 nth4) (nth 1 method))))
6051 gnus-use-cross-reference
6052 (or (not (eq gnus-use-cross-reference t))
6053 virtual
6054 ;; Only do cross-references on subscribed
6055 ;; groups, if that is what is wanted.
6056 (<= (gnus-info-level info) gnus-level-subscribed))
6057 (gnus-group-make-articles-read name idlist))))
6058 xref-hashtb)))))
6059
6748645f 6060(defun gnus-compute-read-articles (group articles)
01c52d31 6061 (let* ((entry (gnus-group-entry group))
6748645f
LMI
6062 (info (nth 2 entry))
6063 (active (gnus-active group))
6064 ninfo)
6065 (when entry
16409b0b 6066 ;; First peel off all invalid article numbers.
6748645f
LMI
6067 (when active
6068 (let ((ids articles)
6069 id first)
6070 (while (setq id (pop ids))
6071 (when (and first (> id (cdr active)))
6072 ;; We'll end up in this situation in one particular
6073 ;; obscure situation. If you re-scan a group and get
6074 ;; a new article that is cross-posted to a different
6075 ;; group that has not been re-scanned, you might get
6076 ;; crossposted article that has a higher number than
6077 ;; Gnus believes possible. So we re-activate this
6078 ;; group as well. This might mean doing the
6079 ;; crossposting thingy will *increase* the number
6080 ;; of articles in some groups. Tsk, tsk.
6081 (setq active (or (gnus-activate-group group) active)))
6082 (when (or (> id (cdr active))
6083 (< id (car active)))
6084 (setq articles (delq id articles))))))
6085 ;; If the read list is nil, we init it.
6086 (if (and active
6087 (null (gnus-info-read info))
6088 (> (car active) 1))
6089 (setq ninfo (cons 1 (1- (car active))))
6090 (setq ninfo (gnus-info-read info)))
6091 ;; Then we add the read articles to the range.
6092 (gnus-add-to-range
6093 ninfo (setq articles (sort articles '<))))))
6094
eec82323
LMI
6095(defun gnus-group-make-articles-read (group articles)
6096 "Update the info of GROUP to say that ARTICLES are read."
6097 (let* ((num 0)
01c52d31 6098 (entry (gnus-group-entry group))
eec82323
LMI
6099 (info (nth 2 entry))
6100 (active (gnus-active group))
6101 range)
6748645f
LMI
6102 (when entry
6103 (setq range (gnus-compute-read-articles group articles))
01c52d31 6104 (with-current-buffer gnus-group-buffer
6748645f
LMI
6105 (gnus-undo-register
6106 `(progn
6107 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6108 (gnus-info-set-read ',info ',(gnus-info-read info))
6109 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 6110 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
6111 (gnus-group-update-group ,group t))))
6112 ;; Add the read articles to the range.
6113 (gnus-info-set-read info range)
23f87bed 6114 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
6115 ;; Then we have to re-compute how many unread
6116 ;; articles there are in this group.
6117 (when active
6118 (cond
6119 ((not range)
6120 (setq num (- (1+ (cdr active)) (car active))))
6121 ((not (listp (cdr range)))
6122 (setq num (- (cdr active) (- (1+ (cdr range))
6123 (car range)))))
6124 (t
6125 (while range
6126 (if (numberp (car range))
6127 (setq num (1+ num))
6128 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6129 (setq range (cdr range)))
6130 (setq num (- (cdr active) num))))
6131 ;; Update the number of unread articles.
6132 (setcar entry num)
6133 ;; Update the group buffer.
23f87bed
MB
6134 (unless (gnus-ephemeral-group-p group)
6135 (gnus-group-update-group group t))))))
eec82323 6136
eec82323
LMI
6137(defvar gnus-newsgroup-none-id 0)
6138
6139(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6140 (let ((cur nntp-server-buffer)
6141 (dependencies
6142 (or dependencies
01c52d31
MB
6143 (with-current-buffer gnus-summary-buffer
6144 gnus-newsgroup-dependencies)))
6145 headers id end ref number
16409b0b
GM
6146 (mail-parse-charset gnus-newsgroup-charset)
6147 (mail-parse-ignored-charsets
6148 (save-excursion (condition-case nil
6149 (set-buffer gnus-summary-buffer)
6150 (error))
6151 gnus-newsgroup-ignored-charsets)))
eec82323
LMI
6152 (save-excursion
6153 (set-buffer nntp-server-buffer)
6154 ;; Translate all TAB characters into SPACE characters.
6155 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 6156 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 6157 (ietf-drums-unfold-fws)
6748645f 6158 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6159 (let ((case-fold-search t)
6748645f 6160 in-reply-to header p lines chars)
eec82323 6161 (goto-char (point-min))
01ccbb85 6162 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
6163 ;; do not begin with 2 or 3.
6164 (while (re-search-forward "^[23][0-9]+ " nil t)
6165 (setq id nil
6166 ref nil)
6167 ;; This implementation of this function, with nine
6168 ;; search-forwards instead of the one re-search-forward and
6169 ;; a case (which basically was the old function) is actually
01ccbb85 6170 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
6171 ;; can't have everything, I guess. Speed and elegance
6172 ;; doesn't always go hand in hand.
6173 (setq
6174 header
6175 (vector
6176 ;; Number.
6177 (prog1
01c52d31 6178 (setq number (read cur))
eec82323
LMI
6179 (end-of-line)
6180 (setq p (point))
6181 (narrow-to-region (point)
6182 (or (and (search-forward "\n.\n" nil t)
6183 (- (point) 2))
6184 (point))))
6185 ;; Subject.
6186 (progn
6187 (goto-char p)
23f87bed 6188 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
6189 (funcall gnus-decode-encoded-word-function
6190 (nnheader-header-value))
2bd3dcae 6191 "(none)"))
eec82323
LMI
6192 ;; From.
6193 (progn
6194 (goto-char p)
23f87bed 6195 (if (search-forward "\nfrom:" nil t)
343d6628 6196 (funcall gnus-decode-encoded-address-function
16409b0b 6197 (nnheader-header-value))
2bd3dcae 6198 "(nobody)"))
eec82323
LMI
6199 ;; Date.
6200 (progn
6201 (goto-char p)
23f87bed 6202 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6203 (nnheader-header-value) ""))
6204 ;; Message-ID.
6205 (progn
6206 (goto-char p)
6748645f
LMI
6207 (setq id (if (re-search-forward
6208 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6209 ;; We do it this way to make sure the Message-ID
6210 ;; is (somewhat) syntactically valid.
6211 (buffer-substring (match-beginning 1)
6212 (match-end 1))
eec82323
LMI
6213 ;; If there was no message-id, we just fake one
6214 ;; to make subsequent routines simpler.
01c52d31 6215 (nnheader-generate-fake-message-id number))))
eec82323
LMI
6216 ;; References.
6217 (progn
6218 (goto-char p)
23f87bed 6219 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6220 (progn
6221 (setq end (point))
6222 (prog1
6223 (nnheader-header-value)
6224 (setq ref
6225 (buffer-substring
6226 (progn
6227 (end-of-line)
6228 (search-backward ">" end t)
6229 (1+ (point)))
6230 (progn
6231 (search-backward "<" end t)
6232 (point))))))
6233 ;; Get the references from the in-reply-to header if there
6234 ;; were no references and the in-reply-to header looks
6235 ;; promising.
23f87bed 6236 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6237 (setq in-reply-to (nnheader-header-value))
6238 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6239 (let (ref2)
6240 (setq ref (substring in-reply-to (match-beginning 0)
6241 (match-end 0)))
6242 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6243 (setq ref2 (substring in-reply-to (match-beginning 0)
6244 (match-end 0)))
6245 (when (> (length ref2) (length ref))
6246 (setq ref ref2)))
6247 ref)
eec82323
LMI
6248 (setq ref nil))))
6249 ;; Chars.
6748645f
LMI
6250 (progn
6251 (goto-char p)
6252 (if (search-forward "\nchars: " nil t)
6253 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6254 chars -1)
6255 -1))
eec82323
LMI
6256 ;; Lines.
6257 (progn
6258 (goto-char p)
6259 (if (search-forward "\nlines: " nil t)
a8151ef7 6260 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6261 lines -1)
6262 -1))
eec82323
LMI
6263 ;; Xref.
6264 (progn
6265 (goto-char p)
23f87bed 6266 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6267 (nnheader-header-value)))
6268 ;; Extra.
6269 (when gnus-extra-headers
6270 (let ((extra gnus-extra-headers)
6271 out)
6272 (while extra
6273 (goto-char p)
6274 (when (search-forward
23f87bed 6275 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6276 (push (cons (car extra) (nnheader-header-value))
6277 out))
6278 (pop extra))
6279 out))))
eec82323
LMI
6280 (when (equal id ref)
6281 (setq ref nil))
6748645f
LMI
6282
6283 (when gnus-alter-header-function
6284 (funcall gnus-alter-header-function header)
6285 (setq id (mail-header-id header)
6286 ref (gnus-parent-id (mail-header-references header))))
6287
6288 (when (setq header
6289 (gnus-dependencies-add-header
6290 header dependencies force-new))
eec82323
LMI
6291 (push header headers))
6292 (goto-char (point-max))
6293 (widen))
6294 (nreverse headers)))))
6295
eec82323
LMI
6296;; Goes through the xover lines and returns a list of vectors
6297(defun gnus-get-newsgroup-headers-xover (sequence &optional
6298 force-new dependencies
6299 group also-fetch-heads)
16409b0b
GM
6300 "Parse the news overview data in the server buffer.
6301Return a list of headers that match SEQUENCE (see
6302`nntp-retrieve-headers')."
eec82323
LMI
6303 ;; Get the Xref when the users reads the articles since most/some
6304 ;; NNTP servers do not include Xrefs when using XOVER.
6305 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6306 (let ((mail-parse-charset gnus-newsgroup-charset)
6307 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6308 (cur nntp-server-buffer)
eec82323 6309 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6310 (allp (cond
6311 ((eq gnus-read-all-available-headers t)
6312 t)
14e6dc54
MB
6313 ((and (stringp gnus-read-all-available-headers)
6314 group)
23f87bed
MB
6315 (string-match gnus-read-all-available-headers group))
6316 (t
6317 nil)))
eec82323
LMI
6318 number headers header)
6319 (save-excursion
6320 (set-buffer nntp-server-buffer)
16409b0b 6321 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6322 ;; Allow the user to mangle the headers before parsing them.
6748645f 6323 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6324 (goto-char (point-min))
23f87bed
MB
6325 (gnus-parse-without-error
6326 (while (and (or sequence allp)
6327 (not (eobp)))
6328 (setq number (read cur))
6329 (when (not allp)
6330 (while (and sequence
6331 (< (car sequence) number))
6332 (setq sequence (cdr sequence))))
6333 (when (and (or allp
6334 (and sequence
6335 (eq number (car sequence))))
6336 (progn
6337 (setq sequence (cdr sequence))
6338 (setq header (inline
6339 (gnus-nov-parse-line
6340 number dependencies force-new)))))
6341 (push header headers))
6342 (forward-line 1)))
eec82323
LMI
6343 ;; A common bug in inn is that if you have posted an article and
6344 ;; then retrieves the active file, it will answer correctly --
6345 ;; the new article is included. However, a NOV entry for the
6346 ;; article may not have been generated yet, so this may fail.
6347 ;; We work around this problem by retrieving the last few
6348 ;; headers using HEAD.
6349 (if (or (not also-fetch-heads)
6350 (not sequence))
6351 ;; We (probably) got all the headers.
6352 (nreverse headers)
6353 (let ((gnus-nov-is-evil t))
6354 (nconc
6355 (nreverse headers)
23f87bed 6356 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6357 (gnus-get-newsgroup-headers))))))))
6358
6359(defun gnus-article-get-xrefs ()
6360 "Fill in the Xref value in `gnus-current-headers', if necessary.
6361This is meant to be called in `gnus-article-internal-prepare-hook'."
01c52d31
MB
6362 (let ((headers (with-current-buffer gnus-summary-buffer
6363 gnus-current-headers)))
eec82323
LMI
6364 (or (not gnus-use-cross-reference)
6365 (not headers)
6366 (and (mail-header-xref headers)
6367 (not (string= (mail-header-xref headers) "")))
6368 (let ((case-fold-search t)
6369 xref)
6370 (save-restriction
6371 (nnheader-narrow-to-headers)
6372 (goto-char (point-min))
16409b0b
GM
6373 (when (or (and (not (eobp))
6374 (eq (downcase (char-after)) ?x)
eec82323
LMI
6375 (looking-at "Xref:"))
6376 (search-forward "\nXref:" nil t))
6377 (goto-char (1+ (match-end 0)))
01c52d31 6378 (setq xref (buffer-substring (point) (point-at-eol)))
eec82323
LMI
6379 (mail-header-set-xref headers xref)))))))
6380
6381(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6382 "Find article ID and insert the summary line for that article.
6383OLD-HEADER can either be a header or a line number to insert
6384the subject line on."
6385 (let* ((line (and (numberp old-header) old-header))
6386 (old-header (and (vectorp old-header) old-header))
6387 (header (cond ((and old-header use-old-header)
16409b0b
GM
6388 old-header)
6389 ((and (numberp id)
6390 (gnus-number-to-header id))
6391 (gnus-number-to-header id))
6392 (t
6393 (gnus-read-header id))))
6394 (number (and (numberp id) id))
6395 d)
eec82323
LMI
6396 (when header
6397 ;; Rebuild the thread that this article is part of and go to the
6398 ;; article we have fetched.
6399 (when (and (not gnus-show-threads)
6400 old-header)
6748645f
LMI
6401 (when (and number
6402 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6403 (goto-char (gnus-data-pos d))
6404 (gnus-data-remove
6405 number
01c52d31 6406 (- (point-at-bol)
eec82323 6407 (prog1
01c52d31 6408 (1+ (point-at-eol))
eec82323 6409 (gnus-delete-line))))))
23f87bed
MB
6410 ;; Remove list identifiers from subject.
6411 (when gnus-list-identifiers
6412 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6413 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6414 (when old-header
6415 (mail-header-set-number header (mail-header-number old-header)))
6416 (setq gnus-newsgroup-sparse
6417 (delq (setq number (mail-header-number header))
6418 gnus-newsgroup-sparse))
6419 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6420 (push number gnus-newsgroup-limit)
6421 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6422 (gnus-summary-goto-subject number nil t))
6423 (when (and (numberp number)
6424 (> number 0))
6425 ;; We have to update the boundaries even if we can't fetch the
6426 ;; article if ID is a number -- so that the next `P' or `N'
6427 ;; command will fetch the previous (or next) article even
6428 ;; if the one we tried to fetch this time has been canceled.
6429 (when (> number gnus-newsgroup-end)
6430 (setq gnus-newsgroup-end number))
6431 (when (< number gnus-newsgroup-begin)
6432 (setq gnus-newsgroup-begin number))
6433 (setq gnus-newsgroup-unselected
6434 (delq number gnus-newsgroup-unselected)))
6435 ;; Report back a success?
6436 (and header (mail-header-number header))))
6437
6438;;; Process/prefix in the summary buffer
6439
6440(defun gnus-summary-work-articles (n)
6748645f
LMI
6441 "Return a list of articles to be worked upon.
6442The prefix argument, the list of process marked articles, and the
6443current article will be taken into consideration."
6444 (save-excursion
6445 (set-buffer gnus-summary-buffer)
6446 (cond
6447 (n
6448 ;; A numerical prefix has been given.
6449 (setq n (prefix-numeric-value n))
6450 (let ((backward (< n 0))
6451 (n (abs (prefix-numeric-value n)))
6452 articles article)
6453 (save-excursion
6454 (while
6455 (and (> n 0)
6456 (push (setq article (gnus-summary-article-number))
6457 articles)
6458 (if backward
6459 (gnus-summary-find-prev nil article)
6460 (gnus-summary-find-next nil article)))
6461 (decf n)))
6462 (nreverse articles)))
6463 ((and (gnus-region-active-p) (mark))
6464 (message "region active")
6465 ;; Work on the region between point and mark.
6466 (let ((max (max (point) (mark)))
6467 articles article)
6468 (save-excursion
7dafe00b 6469 (goto-char (min (point) (mark)))
6748645f
LMI
6470 (while
6471 (and
6472 (push (setq article (gnus-summary-article-number)) articles)
6473 (gnus-summary-find-next nil article)
6474 (< (point) max)))
6475 (nreverse articles))))
6476 (gnus-newsgroup-processable
6477 ;; There are process-marked articles present.
6478 ;; Save current state.
6479 (gnus-summary-save-process-mark)
6480 ;; Return the list.
6481 (reverse gnus-newsgroup-processable))
6482 (t
6483 ;; Just return the current article.
6484 (list (gnus-summary-article-number))))))
6485
6486(defmacro gnus-summary-iterate (arg &rest forms)
6487 "Iterate over the process/prefixed articles and do FORMS.
6488ARG is the interactive prefix given to the command. FORMS will be
6489executed with point over the summary line of the articles."
6490 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6491 `(let ((,articles (gnus-summary-work-articles ,arg)))
6492 (while ,articles
6493 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6494 ,@forms
6495 (pop ,articles)))))
6748645f
LMI
6496
6497(put 'gnus-summary-iterate 'lisp-indent-function 1)
6498(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6499
6500(defun gnus-summary-save-process-mark ()
6501 "Push the current set of process marked articles on the stack."
6502 (interactive)
6503 (push (copy-sequence gnus-newsgroup-processable)
6504 gnus-newsgroup-process-stack))
6505
6506(defun gnus-summary-kill-process-mark ()
6507 "Push the current set of process marked articles on the stack and unmark."
6508 (interactive)
6509 (gnus-summary-save-process-mark)
6510 (gnus-summary-unmark-all-processable))
6511
6512(defun gnus-summary-yank-process-mark ()
6513 "Pop the last process mark state off the stack and restore it."
6514 (interactive)
6515 (unless gnus-newsgroup-process-stack
6516 (error "Empty mark stack"))
6517 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6518
6519(defun gnus-summary-process-mark-set (set)
6520 "Make SET into the current process marked articles."
6521 (gnus-summary-unmark-all-processable)
01c52d31 6522 (mapc 'gnus-summary-set-process-mark set))
eec82323
LMI
6523
6524;;; Searching and stuff
6525
6526(defun gnus-summary-search-group (&optional backward use-level)
6527 "Search for next unread newsgroup.
6528If optional argument BACKWARD is non-nil, search backward instead."
6529 (save-excursion
6530 (set-buffer gnus-group-buffer)
6531 (when (gnus-group-search-forward
6532 backward nil (if use-level (gnus-group-group-level) nil))
6533 (gnus-group-group-name))))
6534
6535(defun gnus-summary-best-group (&optional exclude-group)
6536 "Find the name of the best unread group.
6537If EXCLUDE-GROUP, do not go to this group."
01c52d31 6538 (with-current-buffer gnus-group-buffer
eec82323
LMI
6539 (save-excursion
6540 (gnus-group-best-unread-group exclude-group))))
6541
23f87bed
MB
6542(defun gnus-summary-find-next (&optional unread article backward)
6543 (if backward
6544 (gnus-summary-find-prev unread article)
eec82323
LMI
6545 (let* ((dummy (gnus-summary-article-intangible-p))
6546 (article (or article (gnus-summary-article-number)))
23f87bed 6547 (data (gnus-data-find-list article))
eec82323
LMI
6548 result)
6549 (when (and (not dummy)
6550 (or (not gnus-summary-check-current)
6551 (not unread)
23f87bed
MB
6552 (not (gnus-data-unread-p (car data)))))
6553 (setq data (cdr data)))
eec82323
LMI
6554 (when (setq result
6555 (if unread
6556 (progn
23f87bed
MB
6557 (while data
6558 (unless (memq (gnus-data-number (car data))
6559 (cond
6560 ((eq gnus-auto-goto-ignores
6561 'always-undownloaded)
6562 gnus-newsgroup-undownloaded)
6563 (gnus-plugged
6564 nil)
6565 ((eq gnus-auto-goto-ignores
6566 'unfetched)
6567 gnus-newsgroup-unfetched)
6568 ((eq gnus-auto-goto-ignores
6569 'undownloaded)
6570 gnus-newsgroup-undownloaded)))
6571 (when (gnus-data-unread-p (car data))
6572 (setq result (car data)
6573 data nil)))
6574 (setq data (cdr data)))
eec82323 6575 result)
23f87bed 6576 (car data)))
eec82323
LMI
6577 (goto-char (gnus-data-pos result))
6578 (gnus-data-number result)))))
6579
6580(defun gnus-summary-find-prev (&optional unread article)
6581 (let* ((eobp (eobp))
6582 (article (or article (gnus-summary-article-number)))
23f87bed 6583 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6584 result)
6585 (when (and (not eobp)
6586 (or (not gnus-summary-check-current)
6587 (not unread)
23f87bed
MB
6588 (not (gnus-data-unread-p (car data)))))
6589 (setq data (cdr data)))
eec82323
LMI
6590 (when (setq result
6591 (if unread
6592 (progn
23f87bed
MB
6593 (while data
6594 (unless (memq (gnus-data-number (car data))
6595 (cond
6596 ((eq gnus-auto-goto-ignores
6597 'always-undownloaded)
6598 gnus-newsgroup-undownloaded)
6599 (gnus-plugged
6600 nil)
6601 ((eq gnus-auto-goto-ignores
6602 'unfetched)
6603 gnus-newsgroup-unfetched)
6604 ((eq gnus-auto-goto-ignores
6605 'undownloaded)
6606 gnus-newsgroup-undownloaded)))
6607 (when (gnus-data-unread-p (car data))
6608 (setq result (car data)
6609 data nil)))
6610 (setq data (cdr data)))
eec82323 6611 result)
23f87bed 6612 (car data)))
eec82323
LMI
6613 (goto-char (gnus-data-pos result))
6614 (gnus-data-number result))))
6615
6616(defun gnus-summary-find-subject (subject &optional unread backward article)
6617 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6618 (article (or article (gnus-summary-article-number)))
6619 (articles (gnus-data-list backward))
6620 (arts (gnus-data-find-list article articles))
6621 result)
6622 (when (or (not gnus-summary-check-current)
6623 (not unread)
6624 (not (gnus-data-unread-p (car arts))))
6625 (setq arts (cdr arts)))
6626 (while arts
6627 (and (or (not unread)
6628 (gnus-data-unread-p (car arts)))
6629 (vectorp (gnus-data-header (car arts)))
6630 (gnus-subject-equal
6631 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6632 (setq result (car arts)
6633 arts nil))
6634 (setq arts (cdr arts)))
6635 (and result
6636 (goto-char (gnus-data-pos result))
6637 (gnus-data-number result))))
6638
6639(defun gnus-summary-search-forward (&optional unread subject backward)
6640 "Search forward for an article.
6641If UNREAD, look for unread articles. If SUBJECT, look for
6642articles with that subject. If BACKWARD, search backward instead."
6643 (cond (subject (gnus-summary-find-subject subject unread backward))
6644 (backward (gnus-summary-find-prev unread))
6645 (t (gnus-summary-find-next unread))))
6646
6647(defun gnus-recenter (&optional n)
6648 "Center point in window and redisplay frame.
6649Also do horizontal recentering."
6650 (interactive "P")
6651 (when (and gnus-auto-center-summary
6652 (not (eq gnus-auto-center-summary 'vertical)))
6653 (gnus-horizontal-recenter))
6654 (recenter n))
6655
6656(defun gnus-summary-recenter ()
6657 "Center point in the summary window.
6658If `gnus-auto-center-summary' is nil, or the article buffer isn't
6659displayed, no centering will be performed."
6660 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6661 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6662 (interactive)
23f87bed
MB
6663 ;; The user has to want it.
6664 (when gnus-auto-center-summary
6665 (let* ((top (cond ((< (window-height) 4) 0)
6666 ((< (window-height) 7) 1)
6667 (t (if (numberp gnus-auto-center-summary)
6668 gnus-auto-center-summary
01c52d31 6669 (/ (1- (window-height)) 2)))))
23f87bed
MB
6670 (height (1- (window-height)))
6671 (bottom (save-excursion (goto-char (point-max))
6672 (forward-line (- height))
6673 (point)))
6674 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6675 (when (get-buffer-window gnus-article-buffer)
6676 ;; Only do recentering when the article buffer is displayed,
6677 ;; Set the window start to either `bottom', which is the biggest
6678 ;; possible valid number, or the second line from the top,
6679 ;; whichever is the least.
db7ebd73
MB
6680 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6681 (if (> bottom top-pos)
6682 ;; Keep the second line from the top visible
01c52d31 6683 (set-window-start window top-pos)
db7ebd73
MB
6684 ;; Try to keep the bottom line visible; if it's partially
6685 ;; obscured, either scroll one more line to make it fully
6686 ;; visible, or revert to using TOP-POS.
6687 (save-excursion
6688 (goto-char (point-max))
6689 (forward-line -1)
6690 (let ((last-line-start (point)))
6691 (goto-char bottom)
6692 (set-window-start window (point) t)
6693 (when (not (pos-visible-in-window-p last-line-start window))
6694 (forward-line 1)
6695 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6696 ;; Do horizontal recentering while we're at it.
6697 (when (and (get-buffer-window (current-buffer) t)
6698 (not (eq gnus-auto-center-summary 'vertical)))
6699 (let ((selected (selected-window)))
6700 (select-window (get-buffer-window (current-buffer) t))
6701 (gnus-summary-position-point)
6702 (gnus-horizontal-recenter)
6703 (select-window selected))))))
6704
6705(defun gnus-summary-jump-to-group (newsgroup)
6706 "Move point to NEWSGROUP in group mode buffer."
6707 ;; Keep update point of group mode buffer if visible.
6708 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6709 (save-window-excursion
6710 ;; Take care of tree window mode.
6711 (when (get-buffer-window gnus-group-buffer)
6712 (pop-to-buffer gnus-group-buffer))
6713 (gnus-group-jump-to-group newsgroup))
6714 (save-excursion
6715 ;; Take care of tree window mode.
6716 (if (get-buffer-window gnus-group-buffer)
6717 (pop-to-buffer gnus-group-buffer)
6718 (set-buffer gnus-group-buffer))
6719 (gnus-group-jump-to-group newsgroup))))
6720
6721;; This function returns a list of article numbers based on the
6722;; difference between the ranges of read articles in this group and
6723;; the range of active articles.
6724(defun gnus-list-of-unread-articles (group)
6725 (let* ((read (gnus-info-read (gnus-get-info group)))
6726 (active (or (gnus-active group) (gnus-activate-group group)))
01c52d31
MB
6727 (last (or (cdr active)
6728 (error "Group %s couldn't be activated " group)))
4b70e299
MB
6729 (bottom (if gnus-newsgroup-maximum-articles
6730 (max (car active)
6731 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6732 (car active)))
eec82323
LMI
6733 first nlast unread)
6734 ;; If none are read, then all are unread.
6735 (if (not read)
11abff8e 6736 (setq first bottom)
eec82323
LMI
6737 ;; If the range of read articles is a single range, then the
6738 ;; first unread article is the article after the last read
6739 ;; article. Sounds logical, doesn't it?
16409b0b 6740 (if (and (not (listp (cdr read)))
11abff8e 6741 (or (< (car read) bottom)
16409b0b
GM
6742 (progn (setq read (list read))
6743 nil)))
11abff8e 6744 (setq first (max bottom (1+ (cdr read))))
eec82323
LMI
6745 ;; `read' is a list of ranges.
6746 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6747 (caar read)))
6748 1)
11abff8e 6749 (setq first bottom))
eec82323
LMI
6750 (while read
6751 (when first
6752 (while (< first nlast)
54506618
MB
6753 (setq unread (cons first unread)
6754 first (1+ first))))
eec82323
LMI
6755 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6756 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6757 (setq read (cdr read)))))
6758 ;; And add the last unread articles.
6759 (while (<= first last)
54506618
MB
6760 (setq unread (cons first unread)
6761 first (1+ first)))
eec82323 6762 ;; Return the list of unread articles.
6748645f 6763 (delq 0 (nreverse unread))))
eec82323
LMI
6764
6765(defun gnus-list-of-read-articles (group)
6766 "Return a list of unread, unticked and non-dormant articles."
6767 (let* ((info (gnus-get-info group))
6768 (marked (gnus-info-marks info))
6769 (active (gnus-active group)))
6770 (and info active
23f87bed
MB
6771 (gnus-list-range-difference
6772 (gnus-list-range-difference
6773 (gnus-sorted-complement
11abff8e 6774 (gnus-uncompress-range
4b70e299 6775 (if gnus-newsgroup-maximum-articles
11abff8e 6776 (cons (max (car active)
4b70e299
MB
6777 (- (cdr active)
6778 gnus-newsgroup-maximum-articles
6779 -1))
11abff8e
MB
6780 (cdr active))
6781 active))
23f87bed
MB
6782 (gnus-list-of-unread-articles group))
6783 (cdr (assq 'dormant marked)))
6784 (cdr (assq 'tick marked))))))
eec82323 6785
54506618
MB
6786;; This function returns a sequence of article numbers based on the
6787;; difference between the ranges of read articles in this group and
6788;; the range of active articles.
6789(defun gnus-sequence-of-unread-articles (group)
6790 (let* ((read (gnus-info-read (gnus-get-info group)))
6791 (active (or (gnus-active group) (gnus-activate-group group)))
6792 (last (cdr active))
4b70e299
MB
6793 (bottom (if gnus-newsgroup-maximum-articles
6794 (max (car active)
6795 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6796 (car active)))
54506618
MB
6797 first nlast unread)
6798 ;; If none are read, then all are unread.
6799 (if (not read)
11abff8e 6800 (setq first bottom)
54506618
MB
6801 ;; If the range of read articles is a single range, then the
6802 ;; first unread article is the article after the last read
6803 ;; article. Sounds logical, doesn't it?
6804 (if (and (not (listp (cdr read)))
11abff8e 6805 (or (< (car read) bottom)
54506618
MB
6806 (progn (setq read (list read))
6807 nil)))
11abff8e 6808 (setq first (max bottom (1+ (cdr read))))
54506618
MB
6809 ;; `read' is a list of ranges.
6810 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6811 (caar read)))
6812 1)
11abff8e 6813 (setq first bottom))
54506618
MB
6814 (while read
6815 (when first
6816 (push (cons first nlast) unread))
6817 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6818 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6819 (setq read (cdr read)))))
6820 ;; And add the last unread articles.
ba0226dd
MB
6821 (cond ((not (and first last))
6822 nil)
6823 ((< first last)
6824 (push (cons first last) unread))
6825 ((= first last)
6826 (push first unread)))
54506618
MB
6827 ;; Return the sequence of unread articles.
6828 (delq 0 (nreverse unread))))
6829
eec82323
LMI
6830;; Various summary commands
6831
6748645f
LMI
6832(defun gnus-summary-select-article-buffer ()
6833 "Reconfigure windows to show article buffer."
6834 (interactive)
6835 (if (not (gnus-buffer-live-p gnus-article-buffer))
6836 (error "There is no article buffer for this summary buffer")
6837 (gnus-configure-windows 'article)
6838 (select-window (get-buffer-window gnus-article-buffer))))
6839
eec82323
LMI
6840(defun gnus-summary-universal-argument (arg)
6841 "Perform any operation on all articles that are process/prefixed."
6842 (interactive "P")
eec82323
LMI
6843 (let ((articles (gnus-summary-work-articles arg))
6844 func article)
6845 (if (eq
6846 (setq
6847 func
6848 (key-binding
6849 (read-key-sequence
6850 (substitute-command-keys
16409b0b 6851 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
6852 'undefined)
6853 (gnus-error 1 "Undefined key")
6854 (save-excursion
6855 (while articles
6856 (gnus-summary-goto-subject (setq article (pop articles)))
6857 (let (gnus-newsgroup-processable)
6858 (command-execute func))
6859 (gnus-summary-remove-process-mark article)))))
6860 (gnus-summary-position-point))
6861
6862(defun gnus-summary-toggle-truncation (&optional arg)
6863 "Toggle truncation of summary lines.
23f87bed 6864With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
6865 (interactive "P")
6866 (setq truncate-lines
6867 (if (null arg) (not truncate-lines)
6868 (> (prefix-numeric-value arg) 0)))
6869 (redraw-display))
6870
23f87bed
MB
6871(defun gnus-summary-find-for-reselect ()
6872 "Return the number of an article to stay on across a reselect.
6873The current article is considered, then following articles, then previous
6874articles. An article is sought which is not cancelled and isn't a temporary
6875insertion from another group. If there's no such then return a dummy 0."
6876 (let (found)
6877 (dolist (rev '(nil t))
6878 (unless found ; don't demand the reverse list if we don't need it
6879 (let ((data (gnus-data-find-list
6880 (gnus-summary-article-number) (gnus-data-list rev))))
6881 (while (and data (not found))
6882 (if (and (< 0 (gnus-data-number (car data)))
6883 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6884 (setq found (gnus-data-number (car data))))
6885 (setq data (cdr data))))))
6886 (or found 0)))
6887
eec82323
LMI
6888(defun gnus-summary-reselect-current-group (&optional all rescan)
6889 "Exit and then reselect the current newsgroup.
6890The prefix argument ALL means to select all articles."
6891 (interactive "P")
eec82323
LMI
6892 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6893 (error "Ephemeral groups can't be reselected"))
23f87bed 6894 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
6895 (group gnus-newsgroup-name))
6896 (setq gnus-newsgroup-begin nil)
23f87bed 6897 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
6898 ;; We have to adjust the point of group mode buffer because
6899 ;; point was moved to the next unread newsgroup by exiting.
6900 (gnus-summary-jump-to-group group)
6901 (when rescan
6902 (save-excursion
6903 (gnus-group-get-new-news-this-group 1)))
6904 (gnus-group-read-group all t)
6905 (gnus-summary-goto-subject current-subject nil t)))
6906
6907(defun gnus-summary-rescan-group (&optional all)
6908 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6909 (interactive "P")
6910 (gnus-summary-reselect-current-group all t))
6911
6912(defun gnus-summary-update-info (&optional non-destructive)
6913 (save-excursion
6914 (let ((group gnus-newsgroup-name))
6748645f
LMI
6915 (when group
6916 (when gnus-newsgroup-kill-headers
6917 (setq gnus-newsgroup-killed
6918 (gnus-compress-sequence
23f87bed
MB
6919 (gnus-sorted-union
6920 (gnus-list-range-intersection
6921 gnus-newsgroup-unselected gnus-newsgroup-killed)
6922 gnus-newsgroup-unreads)
6748645f
LMI
6923 t)))
6924 (unless (listp (cdr gnus-newsgroup-killed))
6925 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6926 (let ((headers gnus-newsgroup-headers))
6927 ;; Set the new ranges of read articles.
01c52d31 6928 (with-current-buffer gnus-group-buffer
6748645f
LMI
6929 (gnus-undo-force-boundary))
6930 (gnus-update-read-articles
23f87bed
MB
6931 group (gnus-sorted-union
6932 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
6933 ;; Set the current article marks.
6934 (let ((gnus-newsgroup-scored
6935 (if (and (not gnus-save-score)
6936 (not non-destructive))
6937 nil
6938 gnus-newsgroup-scored)))
6939 (save-excursion
6940 (gnus-update-marks)))
6941 ;; Do the cross-ref thing.
6942 (when gnus-use-cross-reference
6943 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6944 ;; Do not switch windows but change the buffer to work.
a8151ef7 6945 (set-buffer gnus-group-buffer)
6748645f
LMI
6946 (unless (gnus-ephemeral-group-p group)
6947 (gnus-group-update-group group)))))))
eec82323
LMI
6948
6949(defun gnus-summary-save-newsrc (&optional force)
6950 "Save the current number of read/marked articles in the dribble buffer.
6951The dribble buffer will then be saved.
6952If FORCE (the prefix), also save the .newsrc file(s)."
6953 (interactive "P")
6954 (gnus-summary-update-info t)
6955 (if force
6956 (gnus-save-newsrc-file)
6957 (gnus-dribble-save)))
6958
704f1663
GM
6959(declare-function gnus-cache-write-active "gnus-cache" (&optional force))
6960
23f87bed 6961(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 6962 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 6963`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
6964 (interactive)
6965 (gnus-set-global-variables)
16409b0b
GM
6966 (when (gnus-buffer-live-p gnus-article-buffer)
6967 (save-excursion
6968 (set-buffer gnus-article-buffer)
6969 (mm-destroy-parts gnus-article-mime-handles)
6970 ;; Set it to nil for safety reason.
6971 (setq gnus-article-mime-handle-alist nil)
6972 (setq gnus-article-mime-handles nil)))
eec82323 6973 (gnus-kill-save-kill-buffer)
6748645f 6974 (gnus-async-halt-prefetch)
eec82323
LMI
6975 (let* ((group gnus-newsgroup-name)
6976 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 6977 (gnus-group-is-exiting-p t)
eec82323 6978 (mode major-mode)
23f87bed 6979 (group-point nil)
eec82323 6980 (buf (current-buffer)))
16409b0b
GM
6981 (unless quit-config
6982 ;; Do adaptive scoring, and possibly save score files.
6983 (when gnus-newsgroup-adaptive
6984 (gnus-score-adaptive))
6985 (when gnus-use-scoring
6986 (gnus-score-save)))
6748645f 6987 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
6988 ;; If we have several article buffers, we kill them at exit.
6989 (unless gnus-single-article-buffer
01c52d31
MB
6990 (when (gnus-buffer-live-p gnus-article-buffer)
6991 (with-current-buffer gnus-article-buffer
6992 ;; Don't kill sticky article buffers
6993 (unless (eq major-mode 'gnus-sticky-article-mode)
6994 (gnus-kill-buffer gnus-article-buffer)
6995 (setq gnus-article-current nil))))
6996 (gnus-kill-buffer gnus-original-article-buffer))
eec82323
LMI
6997 (when gnus-use-cache
6998 (gnus-cache-possibly-remove-articles)
6999 (gnus-cache-save-buffers))
7000 (gnus-async-prefetch-remove-group group)
7001 (when gnus-suppress-duplicates
7002 (gnus-dup-enter-articles))
7003 (when gnus-use-trees
7004 (gnus-tree-close group))
16409b0b
GM
7005 (when gnus-use-cache
7006 (gnus-cache-write-active))
6748645f
LMI
7007 ;; Remove entries for this group.
7008 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
7009 ;; Make all changes in this group permanent.
7010 (unless quit-config
6748645f 7011 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 7012 (gnus-summary-update-info))
eec82323
LMI
7013 (gnus-close-group group)
7014 ;; Make sure where we were, and go to next newsgroup.
7015 (set-buffer gnus-group-buffer)
7016 (unless quit-config
7017 (gnus-group-jump-to-group group))
6748645f
LMI
7018 (gnus-run-hooks 'gnus-summary-exit-hook)
7019 (unless (or quit-config
01c52d31 7020 (not gnus-summary-next-group-on-exit)
6748645f
LMI
7021 ;; If this group has disappeared from the summary
7022 ;; buffer, don't skip forwards.
7023 (not (string= group (gnus-group-group-name))))
eec82323 7024 (gnus-group-next-unread-group 1))
a8151ef7 7025 (setq group-point (point))
eec82323
LMI
7026 (if temporary
7027 nil ;Nothing to do.
eec82323
LMI
7028 (set-buffer buf)
7029 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
7030 (progn
7031 (gnus-deaden-summary)
7032 (setq mode nil))
eec82323
LMI
7033 ;; We set all buffer-local variables to nil. It is unclear why
7034 ;; this is needed, but if we don't, buffer-local variables are
7035 ;; not garbage-collected, it seems. This would the lead to en
7036 ;; ever-growing Emacs.
7037 (gnus-summary-clear-local-variables)
23f87bed
MB
7038 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7039 (gnus-summary-clear-local-variables))
eec82323
LMI
7040 (when (get-buffer gnus-article-buffer)
7041 (bury-buffer gnus-article-buffer))
eec82323
LMI
7042 ;; Return to group mode buffer.
7043 (when (eq mode 'gnus-summary-mode)
7044 (gnus-kill-buffer buf)))
7045 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
7046 (set-buffer gnus-group-buffer)
7047 (if quit-config
7048 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
7049 (goto-char group-point)
7050 ;; If gnus-group-buffer is already displayed, make sure we also move
7051 ;; the cursor in the window that displays it.
7052 (let ((win (get-buffer-window (current-buffer) 0)))
7053 (if win (set-window-point win (point))))
d61c212b 7054 (unless leave-hidden
4e90f2b9 7055 (gnus-configure-windows 'group 'force)))
6748645f 7056 ;; Clear the current group name.
eec82323
LMI
7057 (unless quit-config
7058 (setq gnus-newsgroup-name nil)))))
7059
7060(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7061(defun gnus-summary-exit-no-update (&optional no-questions)
7062 "Quit reading current newsgroup without updating read article info."
7063 (interactive)
eec82323 7064 (let* ((group gnus-newsgroup-name)
23f87bed
MB
7065 (gnus-group-is-exiting-p t)
7066 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
7067 (quit-config (gnus-group-quit-config group)))
7068 (when (or no-questions
7069 gnus-expert-user
7070 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 7071 (gnus-async-halt-prefetch)
23f87bed 7072 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b
GM
7073 (when (gnus-buffer-live-p gnus-article-buffer)
7074 (save-excursion
7075 (set-buffer gnus-article-buffer)
7076 (mm-destroy-parts gnus-article-mime-handles)
7077 ;; Set it to nil for safety reason.
7078 (setq gnus-article-mime-handle-alist nil)
7079 (setq gnus-article-mime-handles nil)))
eec82323
LMI
7080 ;; If we have several article buffers, we kill them at exit.
7081 (unless gnus-single-article-buffer
7082 (gnus-kill-buffer gnus-article-buffer)
7083 (gnus-kill-buffer gnus-original-article-buffer)
7084 (setq gnus-article-current nil))
7085 (if (not gnus-kill-summary-on-exit)
7086 (gnus-deaden-summary)
7087 (gnus-close-group group)
7088 (gnus-summary-clear-local-variables)
23f87bed
MB
7089 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7090 (gnus-summary-clear-local-variables))
7091 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
7092 (unless gnus-single-article-buffer
7093 (setq gnus-article-current nil))
7094 (when gnus-use-trees
7095 (gnus-tree-close group))
7096 (gnus-async-prefetch-remove-group group)
7097 (when (get-buffer gnus-article-buffer)
7098 (bury-buffer gnus-article-buffer))
7099 ;; Return to the group buffer.
7100 (gnus-configure-windows 'group 'force)
7101 ;; Clear the current group name.
7102 (setq gnus-newsgroup-name nil)
23f87bed
MB
7103 (unless (gnus-ephemeral-group-p group)
7104 (gnus-group-update-group group))
eec82323
LMI
7105 (when (equal (gnus-group-group-name) group)
7106 (gnus-group-next-unread-group 1))
7107 (when quit-config
23f87bed 7108 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
7109
7110(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
7111 "Handle movement when leaving an ephemeral group.
7112The state which existed when entering the ephemeral is reset."
eec82323
LMI
7113 (if (not (buffer-name (car quit-config)))
7114 (gnus-configure-windows 'group 'force)
7115 (set-buffer (car quit-config))
7116 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
7117 (gnus-set-global-variables))
7118 ((eq major-mode 'gnus-article-mode)
7119 (save-excursion
7120 ;; The `gnus-summary-buffer' variable may point
7121 ;; to the old summary buffer when using a single
7122 ;; article buffer.
7123 (unless (gnus-buffer-live-p gnus-summary-buffer)
7124 (set-buffer gnus-group-buffer))
7125 (set-buffer gnus-summary-buffer)
7126 (gnus-set-global-variables))))
eec82323 7127 (if (or (eq (cdr quit-config) 'article)
23f87bed 7128 (eq (cdr quit-config) 'pick))
01c52d31
MB
7129 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7130 (gnus-configure-windows 'pick 'force)
7131 (gnus-configure-windows (cdr quit-config) 'force))
eec82323
LMI
7132 (gnus-configure-windows (cdr quit-config) 'force))
7133 (when (eq major-mode 'gnus-summary-mode)
01c52d31
MB
7134 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7135 next-unread-noselect))
7136 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7137 'next-noselect)
7138 (gnus-summary-next-subject 1 nil t))
7139 ((eq gnus-auto-select-on-ephemeral-exit
7140 'next-unread-noselect)
7141 (gnus-summary-next-subject 1 t t))))
7142 ;; Hide the article buffer which displays the article different
7143 ;; from the one that the cursor points to in the summary buffer.
7144 (gnus-configure-windows 'summary 'force))
7145 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7146 (gnus-summary-next-subject 1))
7147 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7148 (gnus-summary-next-subject 1 t))))
eec82323
LMI
7149 (gnus-summary-recenter)
7150 (gnus-summary-position-point))))
7151
7152;;; Dead summaries.
7153
7154(defvar gnus-dead-summary-mode-map nil)
7155
7156(unless gnus-dead-summary-mode-map
7157 (setq gnus-dead-summary-mode-map (make-keymap))
7158 (suppress-keymap gnus-dead-summary-mode-map)
7159 (substitute-key-definition
7160 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
23f87bed
MB
7161 (dolist (key '("\C-d" "\r" "\177" [delete]))
7162 (define-key gnus-dead-summary-mode-map
7163 key 'gnus-summary-wake-up-the-dead))
7164 (dolist (key '("q" "Q"))
7165 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
eec82323
LMI
7166
7167(defvar gnus-dead-summary-mode nil
7168 "Minor mode for Gnus summary buffers.")
7169
7170(defun gnus-dead-summary-mode (&optional arg)
7171 "Minor mode for Gnus summary buffers."
7172 (interactive "P")
7173 (when (eq major-mode 'gnus-summary-mode)
7174 (make-local-variable 'gnus-dead-summary-mode)
7175 (setq gnus-dead-summary-mode
7176 (if (null arg) (not gnus-dead-summary-mode)
7177 (> (prefix-numeric-value arg) 0)))
7178 (when gnus-dead-summary-mode
01c52d31 7179 (add-minor-mode
a8151ef7 7180 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
eec82323
LMI
7181
7182(defun gnus-deaden-summary ()
7183 "Make the current summary buffer into a dead summary buffer."
7184 ;; Kill any previous dead summary buffer.
7185 (when (and gnus-dead-summary
7186 (buffer-name gnus-dead-summary))
01c52d31 7187 (with-current-buffer gnus-dead-summary
eec82323
LMI
7188 (when gnus-dead-summary-mode
7189 (kill-buffer (current-buffer)))))
7190 ;; Make this the current dead summary.
7191 (setq gnus-dead-summary (current-buffer))
7192 (gnus-dead-summary-mode 1)
7193 (let ((name (buffer-name)))
7194 (when (string-match "Summary" name)
7195 (rename-buffer
7196 (concat (substring name 0 (match-beginning 0)) "Dead "
7197 (substring name (match-beginning 0)))
16409b0b
GM
7198 t)
7199 (bury-buffer))))
eec82323
LMI
7200
7201(defun gnus-kill-or-deaden-summary (buffer)
7202 "Kill or deaden the summary BUFFER."
6748645f
LMI
7203 (save-excursion
7204 (when (and (buffer-name buffer)
7205 (not gnus-single-article-buffer))
01c52d31 7206 (with-current-buffer buffer
6748645f
LMI
7207 (gnus-kill-buffer gnus-article-buffer)
7208 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
7209 (cond
7210 ;; Kill the buffer.
7211 (gnus-kill-summary-on-exit
7212 (when (and gnus-use-trees
7213 (gnus-buffer-exists-p buffer))
7214 (save-excursion
7215 (set-buffer buffer)
7216 (gnus-tree-close gnus-newsgroup-name)))
7217 (gnus-kill-buffer buffer))
7218 ;; Deaden the buffer.
7219 ((gnus-buffer-exists-p buffer)
7220 (save-excursion
7221 (set-buffer buffer)
7222 (gnus-deaden-summary))))))
eec82323
LMI
7223
7224(defun gnus-summary-wake-up-the-dead (&rest args)
7225 "Wake up the dead summary buffer."
7226 (interactive)
7227 (gnus-dead-summary-mode -1)
7228 (let ((name (buffer-name)))
7229 (when (string-match "Dead " name)
7230 (rename-buffer
7231 (concat (substring name 0 (match-beginning 0))
7232 (substring name (match-end 0)))
7233 t)))
7234 (gnus-message 3 "This dead summary is now alive again"))
7235
7236;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7237(defun gnus-summary-fetch-faq (&optional faq-dir)
7238 "Fetch the FAQ for the current group.
7239If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7240in."
7241 (interactive
7242 (list
7243 (when current-prefix-arg
7244 (completing-read
8f688cb0 7245 "FAQ dir: " (and (listp gnus-group-faq-directory)
01c52d31 7246 (mapcar 'list
a8151ef7 7247 gnus-group-faq-directory))))))
eec82323
LMI
7248 (let (gnus-faq-buffer)
7249 (when (setq gnus-faq-buffer
7250 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7251 (gnus-configure-windows 'summary-faq))))
7252
7253;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7254(defun gnus-summary-describe-group (&optional force)
7255 "Describe the current newsgroup."
7256 (interactive "P")
7257 (gnus-group-describe-group force gnus-newsgroup-name))
7258
7259(defun gnus-summary-describe-briefly ()
7260 "Describe summary mode commands briefly."
7261 (interactive)
16409b0b 7262 (gnus-message 6 (substitute-command-keys "\\<gnus-summary-mode-map>\\[gnus-summary-next-page]:Select \\[gnus-summary-next-unread-article]:Forward \\[gnus-summary-prev-unread-article]:Backward \\[gnus-summary-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-summary-describe-briefly]:This help")))
eec82323
LMI
7263
7264;; Walking around group mode buffer from summary mode.
7265
7266(defun gnus-summary-next-group (&optional no-article target-group backward)
7267 "Exit current newsgroup and then select next unread newsgroup.
7268If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7269initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7270previous group instead."
7271 (interactive "P")
eec82323
LMI
7272 ;; Stop pre-fetching.
7273 (gnus-async-halt-prefetch)
7274 (let ((current-group gnus-newsgroup-name)
7275 (current-buffer (current-buffer))
7276 entered)
7277 ;; First we semi-exit this group to update Xrefs and all variables.
7278 ;; We can't do a real exit, because the window conf must remain
7279 ;; the same in case the user is prompted for info, and we don't
7280 ;; want the window conf to change before that...
7281 (gnus-summary-exit t)
7282 (while (not entered)
7283 ;; Then we find what group we are supposed to enter.
7284 (set-buffer gnus-group-buffer)
7285 (gnus-group-jump-to-group current-group)
7286 (setq target-group
7287 (or target-group
7288 (if (eq gnus-keep-same-level 'best)
7289 (gnus-summary-best-group gnus-newsgroup-name)
7290 (gnus-summary-search-group backward gnus-keep-same-level))))
7291 (if (not target-group)
7292 ;; There are no further groups, so we return to the group
7293 ;; buffer.
7294 (progn
7295 (gnus-message 5 "Returning to the group buffer")
7296 (setq entered t)
7297 (when (gnus-buffer-live-p current-buffer)
7298 (set-buffer current-buffer)
7299 (gnus-summary-exit))
6748645f 7300 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7301 ;; We try to enter the target group.
7302 (gnus-group-jump-to-group target-group)
7303 (let ((unreads (gnus-group-group-unread)))
7304 (if (and (or (eq t unreads)
7305 (and unreads (not (zerop unreads))))
23f87bed
MB
7306 (gnus-summary-read-group
7307 target-group nil no-article
7308 (and (buffer-name current-buffer) current-buffer)
7309 nil backward))
eec82323
LMI
7310 (setq entered t)
7311 (setq current-group target-group
7312 target-group nil)))))))
7313
7314(defun gnus-summary-prev-group (&optional no-article)
7315 "Exit current newsgroup and then select previous unread newsgroup.
7316If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7317 (interactive "P")
7318 (gnus-summary-next-group no-article nil t))
7319
7320;; Walking around summary lines.
7321
23f87bed
MB
7322(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7323 "Go to the first subject satisfying any non-nil constraint.
7324If UNREAD is non-nil, the article should be unread.
7325If UNDOWNLOADED is non-nil, the article should be undownloaded.
7326If UNSEEN is non-nil, the article should be unseen.
7327Returns the article selected or nil if there are no matching articles."
eec82323 7328 (interactive "P")
23f87bed
MB
7329 (cond
7330 ;; Empty summary.
7331 ((null gnus-newsgroup-data)
7332 (gnus-message 3 "No articles in the group")
7333 nil)
7334 ;; Pick the first article.
7335 ((not (or unread undownloaded unseen))
7336 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7337 (gnus-data-number (car gnus-newsgroup-data)))
7338 ;; Find the first unread article.
7339 (t
7340 (let ((data gnus-newsgroup-data))
7341 (while (and data
7342 (let ((num (gnus-data-number (car data))))
7343 (or (memq num gnus-newsgroup-unfetched)
7344 (not (or (and unread
7345 (memq num gnus-newsgroup-unreads))
7346 (and undownloaded
7347 (memq num gnus-newsgroup-undownloaded))
7348 (and unseen
7349 (memq num gnus-newsgroup-unseen)))))))
7350 (setq data (cdr data)))
7351 (prog1
7352 (if data
7353 (progn
7354 (goto-char (gnus-data-pos (car data)))
7355 (gnus-data-number (car data)))
7356 (gnus-message 3 "No more%s articles"
7357 (let* ((r (when unread " unread"))
7358 (d (when undownloaded " undownloaded"))
7359 (s (when unseen " unseen"))
7360 (l (delq nil (list r d s))))
7361 (cond ((= 3 (length l))
7362 (concat r "," d ", or" s))
7363 ((= 2 (length l))
7364 (concat (car l) ", or" (cadr l)))
7365 ((= 1 (length l))
7366 (car l))
7367 (t
7368 ""))))
7369 nil
7370 )
7371 (gnus-summary-position-point))))))
eec82323
LMI
7372
7373(defun gnus-summary-next-subject (n &optional unread dont-display)
7374 "Go to next N'th summary line.
7375If N is negative, go to the previous N'th subject line.
7376If UNREAD is non-nil, only unread articles are selected.
7377The difference between N and the actual number of steps taken is
7378returned."
7379 (interactive "p")
7380 (let ((backward (< n 0))
7381 (n (abs n)))
7382 (while (and (> n 0)
7383 (if backward
7384 (gnus-summary-find-prev unread)
7385 (gnus-summary-find-next unread)))
16409b0b
GM
7386 (unless (zerop (setq n (1- n)))
7387 (gnus-summary-show-thread)))
eec82323
LMI
7388 (when (/= 0 n)
7389 (gnus-message 7 "No more%s articles"
7390 (if unread " unread" "")))
7391 (unless dont-display
7392 (gnus-summary-recenter)
7393 (gnus-summary-position-point))
7394 n))
7395
7396(defun gnus-summary-next-unread-subject (n)
7397 "Go to next N'th unread summary line."
7398 (interactive "p")
7399 (gnus-summary-next-subject n t))
7400
7401(defun gnus-summary-prev-subject (n &optional unread)
7402 "Go to previous N'th summary line.
7403If optional argument UNREAD is non-nil, only unread article is selected."
7404 (interactive "p")
7405 (gnus-summary-next-subject (- n) unread))
7406
7407(defun gnus-summary-prev-unread-subject (n)
7408 "Go to previous N'th unread summary line."
7409 (interactive "p")
7410 (gnus-summary-next-subject (- n) t))
7411
23f87bed
MB
7412(defun gnus-summary-goto-subjects (articles)
7413 "Insert the subject header for ARTICLES in the current buffer."
7414 (save-excursion
7415 (dolist (article articles)
7416 (gnus-summary-goto-subject article t)))
7417 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7418 (gnus-summary-position-point))
132cf96d 7419
eec82323
LMI
7420(defun gnus-summary-goto-subject (article &optional force silent)
7421 "Go the subject line of ARTICLE.
7422If FORCE, also allow jumping to articles not currently shown."
7423 (interactive "nArticle number: ")
23f87bed
MB
7424 (unless (numberp article)
7425 (error "Article %s is not a number" article))
eec82323
LMI
7426 (let ((b (point))
7427 (data (gnus-data-find article)))
7428 ;; We read in the article if we have to.
7429 (and (not data)
7430 force
6748645f
LMI
7431 (gnus-summary-insert-subject
7432 article
7433 (if (or (numberp force) (vectorp force)) force)
7434 t)
eec82323
LMI
7435 (setq data (gnus-data-find article)))
7436 (goto-char b)
7437 (if (not data)
7438 (progn
7439 (unless silent
7440 (gnus-message 3 "Can't find article %d" article))
7441 nil)
23f87bed
MB
7442 (let ((pt (gnus-data-pos data)))
7443 (goto-char pt)
7444 (gnus-summary-set-article-display-arrow pt))
6748645f 7445 (gnus-summary-position-point)
eec82323
LMI
7446 article)))
7447
7448;; Walking around summary lines with displaying articles.
7449
7450(defun gnus-summary-expand-window (&optional arg)
7451 "Make the summary buffer take up the entire Emacs frame.
7452Given a prefix, will force an `article' buffer configuration."
7453 (interactive "P")
eec82323
LMI
7454 (if arg
7455 (gnus-configure-windows 'article 'force)
7456 (gnus-configure-windows 'summary 'force)))
7457
7458(defun gnus-summary-display-article (article &optional all-header)
7459 "Display ARTICLE in article buffer."
01c52d31
MB
7460 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7461 (with-current-buffer gnus-article-buffer
7462 (eq major-mode 'gnus-article-mode)))
7463 (gnus-article-setup-buffer))
eec82323 7464 (gnus-set-global-variables)
01c52d31
MB
7465 (with-current-buffer gnus-article-buffer
7466 (setq gnus-article-charset gnus-newsgroup-charset)
7467 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7468 (mm-enable-multibyte))
eec82323
LMI
7469 (if (null article)
7470 nil
7471 (prog1
7472 (if gnus-summary-display-article-function
7473 (funcall gnus-summary-display-article-function article all-header)
7474 (gnus-article-prepare article all-header))
6748645f 7475 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7476 (when (and gnus-current-article
7477 (not (zerop gnus-current-article)))
7478 (gnus-summary-goto-subject gnus-current-article))
7479 (gnus-summary-recenter)
7480 (when (and gnus-use-trees gnus-show-threads)
7481 (gnus-possibly-generate-tree article)
7482 (gnus-highlight-selected-tree article))
7483 ;; Successfully display article.
7484 (gnus-article-set-window-start
7485 (cdr (assq article gnus-newsgroup-bookmarks))))))
7486
7487(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7488 "Select the current article.
7489If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7490non-nil, the article will be re-fetched even if it already present in
7491the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7492be displayed."
7493 ;; Make sure we are in the summary buffer to work around bbdb bug.
7494 (unless (eq major-mode 'gnus-summary-mode)
7495 (set-buffer gnus-summary-buffer))
7496 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7497 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7498 gnus-summary-display-article-function)
eec82323
LMI
7499 (and (not pseudo)
7500 (gnus-summary-article-pseudo-p article)
a8151ef7 7501 (error "This is a pseudo-article"))
16409b0b
GM
7502 (save-excursion
7503 (set-buffer gnus-summary-buffer)
7504 (if (or (and gnus-single-article-buffer
7505 (or (null gnus-current-article)
7506 (null gnus-article-current)
7507 (null (get-buffer gnus-article-buffer))
7508 (not (eq article (cdr gnus-article-current)))
7509 (not (equal (car gnus-article-current)
7510 gnus-newsgroup-name))))
7511 (and (not gnus-single-article-buffer)
7512 (or (null gnus-current-article)
7513 (not (eq gnus-current-article article))))
7514 force)
7515 ;; The requested article is different from the current article.
7516 (progn
16409b0b
GM
7517 (gnus-summary-display-article article all-headers)
7518 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7519 (with-current-buffer gnus-article-buffer
16409b0b 7520 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7521 (mm-disable-multibyte))))
16409b0b
GM
7522 (gnus-article-set-window-start
7523 (cdr (assq article gnus-newsgroup-bookmarks)))
7524 article)
16409b0b 7525 'old))))
eec82323 7526
23f87bed
MB
7527(defun gnus-summary-force-verify-and-decrypt ()
7528 "Display buttons for signed/encrypted parts and verify/decrypt them."
7529 (interactive)
7530 (let ((mm-verify-option 'known)
7531 (mm-decrypt-option 'known)
7532 (gnus-article-emulate-mime t)
7533 (gnus-buttonized-mime-types (append (list "multipart/signed"
7534 "multipart/encrypted")
7535 gnus-buttonized-mime-types)))
7536 (gnus-summary-select-article nil 'force)))
7537
eec82323
LMI
7538(defun gnus-summary-set-current-mark (&optional current-mark)
7539 "Obsolete function."
7540 nil)
7541
7542(defun gnus-summary-next-article (&optional unread subject backward push)
7543 "Select the next article.
7544If UNREAD, only unread articles are selected.
7545If SUBJECT, only articles with SUBJECT are selected.
7546If BACKWARD, the previous article is selected instead of the next."
7547 (interactive "P")
11e95b02
MB
7548 ;; Make sure we are in the summary buffer.
7549 (unless (eq major-mode 'gnus-summary-mode)
7550 (set-buffer gnus-summary-buffer))
eec82323
LMI
7551 (cond
7552 ;; Is there such an article?
7553 ((and (gnus-summary-search-forward unread subject backward)
7554 (or (gnus-summary-display-article (gnus-summary-article-number))
7555 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7556 (gnus-summary-position-point))
7557 ;; If not, we try the first unread, if that is wanted.
7558 ((and subject
7559 gnus-auto-select-same
7560 (gnus-summary-first-unread-article))
7561 (gnus-summary-position-point)
7562 (gnus-message 6 "Wrapped"))
7563 ;; Try to get next/previous article not displayed in this group.
7564 ((and gnus-auto-extend-newsgroup
7565 (not unread) (not subject))
7566 (gnus-summary-goto-article
7567 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7568 nil (count-lines (point-min) (point))))
eec82323
LMI
7569 ;; Go to next/previous group.
7570 (t
7571 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7572 (gnus-summary-jump-to-group gnus-newsgroup-name))
7573 (let ((cmd last-command-char)
7574 (point
01c52d31 7575 (with-current-buffer gnus-group-buffer
eec82323
LMI
7576 (point)))
7577 (group
7578 (if (eq gnus-keep-same-level 'best)
7579 (gnus-summary-best-group gnus-newsgroup-name)
7580 (gnus-summary-search-group backward gnus-keep-same-level))))
7581 ;; For some reason, the group window gets selected. We change
7582 ;; it back.
7583 (select-window (get-buffer-window (current-buffer)))
7584 ;; Select next unread newsgroup automagically.
7585 (cond
7586 ((or (not gnus-auto-select-next)
7587 (not cmd))
7588 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7589 ((or (eq gnus-auto-select-next 'quietly)
7590 (and (eq gnus-auto-select-next 'slightly-quietly)
7591 push)
7592 (and (eq gnus-auto-select-next 'almost-quietly)
7593 (gnus-summary-last-article-p)))
7594 ;; Select quietly.
7595 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7596 (gnus-summary-exit)
7597 (gnus-message 7 "No more%s articles (%s)..."
7598 (if unread " unread" "")
7599 (if group (concat "selecting " group)
7600 "exiting"))
7601 (gnus-summary-next-group nil group backward)))
7602 (t
7603 (when (gnus-key-press-event-p last-input-event)
7604 (gnus-summary-walk-group-buffer
7605 gnus-newsgroup-name cmd unread backward point))))))))
7606
7607(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7608 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7609 (?\C-p (gnus-group-prev-unread-group 1))))
7610 (cursor-in-echo-area t)
23f87bed 7611 keve key group ended prompt)
eec82323
LMI
7612 (save-excursion
7613 (set-buffer gnus-group-buffer)
7614 (goto-char start)
7615 (setq group
7616 (if (eq gnus-keep-same-level 'best)
7617 (gnus-summary-best-group gnus-newsgroup-name)
7618 (gnus-summary-search-group backward gnus-keep-same-level))))
7619 (while (not ended)
23f87bed
MB
7620 (setq prompt
7621 (format
7622 "No more%s articles%s " (if unread " unread" "")
7623 (if (and group
7624 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7625 (format " (Type %s for %s [%s])"
91472578
MB
7626 (single-key-description cmd)
7627 (gnus-group-decoded-name group)
01c52d31 7628 (gnus-group-unread group))
23f87bed
MB
7629 (format " (Type %s to exit %s)"
7630 (single-key-description cmd)
91472578 7631 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7632 ;; Confirm auto selection.
23f87bed
MB
7633 (setq key (car (setq keve (gnus-read-event-char prompt)))
7634 ended t)
eec82323
LMI
7635 (cond
7636 ((assq key keystrokes)
7637 (let ((obuf (current-buffer)))
7638 (switch-to-buffer gnus-group-buffer)
7639 (when group
7640 (gnus-group-jump-to-group group))
7641 (eval (cadr (assq key keystrokes)))
7642 (setq group (gnus-group-group-name))
7643 (switch-to-buffer obuf))
7644 (setq ended nil))
7645 ((equal key cmd)
7646 (if (or (not group)
7647 (gnus-ephemeral-group-p gnus-newsgroup-name))
7648 (gnus-summary-exit)
7649 (gnus-summary-next-group nil group backward)))
7650 (t
7651 (push (cdr keve) unread-command-events))))))
7652
7653(defun gnus-summary-next-unread-article ()
7654 "Select unread article after current one."
7655 (interactive)
7656 (gnus-summary-next-article
7657 (or (not (eq gnus-summary-goto-unread 'never))
7658 (gnus-summary-last-article-p (gnus-summary-article-number)))
7659 (and gnus-auto-select-same
7660 (gnus-summary-article-subject))))
7661
7662(defun gnus-summary-prev-article (&optional unread subject)
bbbe940b 7663 "Select the article before the current one.
eec82323
LMI
7664If UNREAD is non-nil, only unread articles are selected."
7665 (interactive "P")
7666 (gnus-summary-next-article unread subject t))
7667
7668(defun gnus-summary-prev-unread-article ()
7669 "Select unread article before current one."
7670 (interactive)
7671 (gnus-summary-prev-article
7672 (or (not (eq gnus-summary-goto-unread 'never))
7673 (gnus-summary-first-article-p (gnus-summary-article-number)))
7674 (and gnus-auto-select-same
7675 (gnus-summary-article-subject))))
7676
23f87bed 7677(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7678 "Show next page of the selected article.
7679If at the end of the current article, select the next article.
7680LINES says how many lines should be scrolled up.
7681
7682If CIRCULAR is non-nil, go to the start of the article instead of
7683selecting the next article when reaching the end of the current
23f87bed
MB
7684article.
7685
7686If STOP is non-nil, just stop when reaching the end of the message.
7687
7688Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7689 (interactive "P")
7690 (setq gnus-summary-buffer (current-buffer))
7691 (gnus-set-global-variables)
7692 (let ((article (gnus-summary-article-number))
7693 (article-window (get-buffer-window gnus-article-buffer t))
7694 endp)
6748645f
LMI
7695 ;; If the buffer is empty, we have no article.
7696 (unless article
7697 (error "No article to select"))
eec82323
LMI
7698 (gnus-configure-windows 'article)
7699 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7700 (if (and (eq gnus-summary-goto-unread 'never)
7701 (not (gnus-summary-last-article-p article)))
7702 (gnus-summary-next-article)
7703 (gnus-summary-next-unread-article))
7704 (if (or (null gnus-current-article)
7705 (null gnus-article-current)
7706 (/= article (cdr gnus-article-current))
7707 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7708 ;; Selected subject is different from current article's.
7709 (gnus-summary-display-article article)
7710 (when article-window
7711 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7712 (setq endp (or (gnus-article-next-page lines)
7713 (gnus-article-only-boring-p))))
eec82323 7714 (when endp
23f87bed
MB
7715 (cond (stop
7716 (gnus-message 3 "End of message"))
7717 (circular
eec82323
LMI
7718 (gnus-summary-beginning-of-article))
7719 (lines
7720 (gnus-message 3 "End of message"))
7721 ((null lines)
7722 (if (and (eq gnus-summary-goto-unread 'never)
7723 (not (gnus-summary-last-article-p article)))
7724 (gnus-summary-next-article)
7725 (gnus-summary-next-unread-article))))))))
7726 (gnus-summary-recenter)
7727 (gnus-summary-position-point)))
7728
7729(defun gnus-summary-prev-page (&optional lines move)
7730 "Show previous page of selected article.
7731Argument LINES specifies lines to be scrolled down.
7732If MOVE, move to the previous unread article if point is at
7733the beginning of the buffer."
7734 (interactive "P")
eec82323
LMI
7735 (let ((article (gnus-summary-article-number))
7736 (article-window (get-buffer-window gnus-article-buffer t))
7737 endp)
7738 (gnus-configure-windows 'article)
7739 (if (or (null gnus-current-article)
7740 (null gnus-article-current)
7741 (/= article (cdr gnus-article-current))
7742 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7743 ;; Selected subject is different from current article's.
7744 (gnus-summary-display-article article)
7745 (gnus-summary-recenter)
7746 (when article-window
7747 (gnus-eval-in-buffer-window gnus-article-buffer
7748 (setq endp (gnus-article-prev-page lines)))
7749 (when (and move endp)
7750 (cond (lines
7751 (gnus-message 3 "Beginning of message"))
7752 ((null lines)
7753 (if (and (eq gnus-summary-goto-unread 'never)
7754 (not (gnus-summary-first-article-p article)))
7755 (gnus-summary-prev-article)
7756 (gnus-summary-prev-unread-article))))))))
7757 (gnus-summary-position-point))
7758
7759(defun gnus-summary-prev-page-or-article (&optional lines)
7760 "Show previous page of selected article.
7761Argument LINES specifies lines to be scrolled down.
7762If at the beginning of the article, go to the next article."
7763 (interactive "P")
7764 (gnus-summary-prev-page lines t))
7765
7766(defun gnus-summary-scroll-up (lines)
7767 "Scroll up (or down) one line current article.
7768Argument LINES specifies lines to be scrolled up (or down if negative)."
7769 (interactive "p")
eec82323
LMI
7770 (gnus-configure-windows 'article)
7771 (gnus-summary-show-thread)
7772 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7773 (gnus-eval-in-buffer-window gnus-article-buffer
7774 (cond ((> lines 0)
7775 (when (gnus-article-next-page lines)
7776 (gnus-message 3 "End of message")))
7777 ((< lines 0)
7778 (gnus-article-prev-page (- lines))))))
7779 (gnus-summary-recenter)
7780 (gnus-summary-position-point))
7781
6748645f
LMI
7782(defun gnus-summary-scroll-down (lines)
7783 "Scroll down (or up) one line current article.
7784Argument LINES specifies lines to be scrolled down (or up if negative)."
7785 (interactive "p")
7786 (gnus-summary-scroll-up (- lines)))
7787
eec82323
LMI
7788(defun gnus-summary-next-same-subject ()
7789 "Select next article which has the same subject as current one."
7790 (interactive)
eec82323
LMI
7791 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7792
7793(defun gnus-summary-prev-same-subject ()
7794 "Select previous article which has the same subject as current one."
7795 (interactive)
eec82323
LMI
7796 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7797
7798(defun gnus-summary-next-unread-same-subject ()
7799 "Select next unread article which has the same subject as current one."
7800 (interactive)
eec82323
LMI
7801 (gnus-summary-next-article t (gnus-summary-article-subject)))
7802
7803(defun gnus-summary-prev-unread-same-subject ()
7804 "Select previous unread article which has the same subject as current one."
7805 (interactive)
eec82323
LMI
7806 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7807
7808(defun gnus-summary-first-unread-article ()
7809 "Select the first unread article.
7810Return nil if there are no unread articles."
7811 (interactive)
eec82323
LMI
7812 (prog1
7813 (when (gnus-summary-first-subject t)
7814 (gnus-summary-show-thread)
7815 (gnus-summary-first-subject t)
7816 (gnus-summary-display-article (gnus-summary-article-number)))
7817 (gnus-summary-position-point)))
7818
16409b0b
GM
7819(defun gnus-summary-first-unread-subject ()
7820 "Place the point on the subject line of the first unread article.
7821Return nil if there are no unread articles."
7822 (interactive)
7823 (prog1
7824 (when (gnus-summary-first-subject t)
7825 (gnus-summary-show-thread)
7826 (gnus-summary-first-subject t))
7827 (gnus-summary-position-point)))
7828
23f87bed
MB
7829(defun gnus-summary-first-unseen-subject ()
7830 "Place the point on the subject line of the first unseen article.
7831Return nil if there are no unseen articles."
7832 (interactive)
7833 (prog1
7834 (when (gnus-summary-first-subject nil nil t)
7835 (gnus-summary-show-thread)
7836 (gnus-summary-first-subject nil nil t))
7837 (gnus-summary-position-point)))
7838
7839(defun gnus-summary-first-unseen-or-unread-subject ()
7840 "Place the point on the subject line of the first unseen article or,
7841if all article have been seen, on the subject line of the first unread
7842article."
7843 (interactive)
7844 (prog1
7845 (unless (when (gnus-summary-first-subject nil nil t)
7846 (gnus-summary-show-thread)
7847 (gnus-summary-first-subject nil nil t))
7848 (when (gnus-summary-first-subject t)
7849 (gnus-summary-show-thread)
7850 (gnus-summary-first-subject t)))
7851 (gnus-summary-position-point)))
7852
eec82323
LMI
7853(defun gnus-summary-first-article ()
7854 "Select the first article.
7855Return nil if there are no articles."
7856 (interactive)
eec82323
LMI
7857 (prog1
7858 (when (gnus-summary-first-subject)
16409b0b
GM
7859 (gnus-summary-show-thread)
7860 (gnus-summary-first-subject)
7861 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
7862 (gnus-summary-position-point)))
7863
23f87bed
MB
7864(defun gnus-summary-best-unread-article (&optional arg)
7865 "Select the unread article with the highest score.
7866If given a prefix argument, select the next unread article that has a
7867score higher than the default score."
7868 (interactive "P")
7869 (let ((article (if arg
7870 (gnus-summary-better-unread-subject)
7871 (gnus-summary-best-unread-subject))))
7872 (if article
7873 (gnus-summary-goto-article article)
7874 (error "No unread articles"))))
7875
7876(defun gnus-summary-best-unread-subject ()
7877 "Select the unread subject with the highest score."
eec82323 7878 (interactive)
eec82323
LMI
7879 (let ((best -1000000)
7880 (data gnus-newsgroup-data)
7881 article score)
7882 (while data
7883 (and (gnus-data-unread-p (car data))
7884 (> (setq score
7885 (gnus-summary-article-score (gnus-data-number (car data))))
7886 best)
7887 (setq best score
7888 article (gnus-data-number (car data))))
7889 (setq data (cdr data)))
23f87bed
MB
7890 (when article
7891 (gnus-summary-goto-subject article))
7892 (gnus-summary-position-point)
7893 article))
7894
7895(defun gnus-summary-better-unread-subject ()
7896 "Select the first unread subject that has a score over the default score."
7897 (interactive)
7898 (let ((data gnus-newsgroup-data)
7899 article score)
7900 (while (and (setq article (gnus-data-number (car data)))
7901 (or (gnus-data-read-p (car data))
7902 (not (> (gnus-summary-article-score article)
7903 gnus-summary-default-score))))
7904 (setq data (cdr data)))
7905 (when article
7906 (gnus-summary-goto-subject article))
7907 (gnus-summary-position-point)
7908 article))
eec82323
LMI
7909
7910(defun gnus-summary-last-subject ()
7911 "Go to the last displayed subject line in the group."
7912 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7913 (when article
7914 (gnus-summary-goto-subject article))))
7915
7916(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
7917 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7918If ALL-HEADERS is non-nil, no header lines are hidden.
7919If FORCE, go to the article even if it isn't displayed. If FORCE
7920is a number, it is the line the article is to be displayed on."
eec82323
LMI
7921 (interactive
7922 (list
6748645f
LMI
7923 (completing-read
7924 "Article number or Message-ID: "
7925 (mapcar (lambda (number) (list (int-to-string number)))
7926 gnus-newsgroup-limit))
eec82323
LMI
7927 current-prefix-arg
7928 t))
7929 (prog1
6748645f 7930 (if (and (stringp article)
23f87bed 7931 (string-match "@\\|%40" article))
6748645f
LMI
7932 (gnus-summary-refer-article article)
7933 (when (stringp article)
7934 (setq article (string-to-number article)))
7935 (if (gnus-summary-goto-subject article force)
7936 (gnus-summary-display-article article all-headers)
7937 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
7938 (gnus-summary-position-point)))
7939
7940(defun gnus-summary-goto-last-article ()
7941 "Go to the previously read article."
7942 (interactive)
7943 (prog1
7944 (when gnus-last-article
6748645f 7945 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
7946 (gnus-summary-position-point)))
7947
7948(defun gnus-summary-pop-article (number)
7949 "Pop one article off the history and go to the previous.
7950NUMBER articles will be popped off."
7951 (interactive "p")
7952 (let (to)
7953 (setq gnus-newsgroup-history
7954 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7955 (if to
6748645f 7956 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
7957 (error "Article history empty")))
7958 (gnus-summary-position-point))
7959
7960;; Summary commands and functions for limiting the summary buffer.
7961
7962(defun gnus-summary-limit-to-articles (n)
7963 "Limit the summary buffer to the next N articles.
7964If not given a prefix, use the process marked articles instead."
7965 (interactive "P")
eec82323
LMI
7966 (prog1
7967 (let ((articles (gnus-summary-work-articles n)))
7968 (setq gnus-newsgroup-processable nil)
7969 (gnus-summary-limit articles))
7970 (gnus-summary-position-point)))
7971
7972(defun gnus-summary-pop-limit (&optional total)
7973 "Restore the previous limit.
7974If given a prefix, remove all limits."
7975 (interactive "P")
eec82323
LMI
7976 (when total
7977 (setq gnus-newsgroup-limits
7978 (list (mapcar (lambda (h) (mail-header-number h))
7979 gnus-newsgroup-headers))))
7980 (unless gnus-newsgroup-limits
7981 (error "No limit to pop"))
7982 (prog1
7983 (gnus-summary-limit nil 'pop)
7984 (gnus-summary-position-point)))
7985
47b63dfa
SZ
7986(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7987 "Limit the summary buffer to articles that have subjects that match a regexp.
7988If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 7989 (interactive
47b63dfa
SZ
7990 (list (read-string (if current-prefix-arg
7991 "Exclude subject (regexp): "
a1506d29 7992 "Limit to subject (regexp): "))
47b63dfa 7993 nil current-prefix-arg))
eec82323
LMI
7994 (unless header
7995 (setq header "subject"))
7996 (when (not (equal "" subject))
7997 (prog1
7998 (let ((articles (gnus-summary-find-matching
a1506d29 7999 (or header "subject") subject 'all nil nil
47b63dfa 8000 not-matching)))
eec82323
LMI
8001 (unless articles
8002 (error "Found no matches for \"%s\"" subject))
8003 (gnus-summary-limit articles))
8004 (gnus-summary-position-point))))
8005
ef6e0ec7 8006(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
8007 "Limit the summary buffer to articles that have authors that match a regexp.
8008If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 8009 (interactive
47b63dfa
SZ
8010 (list (read-string (if current-prefix-arg
8011 "Exclude author (regexp): "
a1506d29 8012 "Limit to author (regexp): "))
ef6e0ec7
SZ
8013 current-prefix-arg))
8014 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323 8015
01c52d31
MB
8016(defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8017 "Limit the summary buffer to articles with the given RECIPIENT.
8018
8019If NOT-MATCHING, exclude RECIPIENT.
8020
8021To and Cc headers are checked. You need to include them in
8022`nnmail-extra-headers'."
8023 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8024 (interactive
8025 (list (read-string (format "%s recipient (regexp): "
8026 (if current-prefix-arg "Exclude" "Limit to")))
8027 current-prefix-arg))
8028 (when (not (equal "" recipient))
8029 (prog1 (let* ((to
8030 (if (memq 'To nnmail-extra-headers)
8031 (gnus-summary-find-matching
8032 (cons 'extra 'To) recipient 'all nil nil
8033 not-matching)
8034 (gnus-message
8035 1 "`To' isn't present in `nnmail-extra-headers'")
8036 (sit-for 1)
8037 nil))
8038 (cc
8039 (if (memq 'Cc nnmail-extra-headers)
8040 (gnus-summary-find-matching
8041 (cons 'extra 'Cc) recipient 'all nil nil
8042 not-matching)
8043 (gnus-message
8044 1 "`Cc' isn't present in `nnmail-extra-headers'")
8045 (sit-for 1)
8046 nil))
8047 (articles
8048 (if not-matching
8049 ;; We need the numbers that are in both lists:
8050 (mapcar (lambda (a)
8051 (and (memq a to) a))
8052 cc)
8053 (nconc to cc))))
8054 (unless articles
8055 (error "Found no matches for \"%s\"" recipient))
8056 (gnus-summary-limit articles))
8057 (gnus-summary-position-point))))
8058
8059(defun gnus-summary-limit-to-address (address &optional not-matching)
8060 "Limit the summary buffer to articles with the given ADDRESS.
8061
8062If NOT-MATCHING, exclude ADDRESS.
8063
8064To, Cc and From headers are checked. You need to include `To' and `Cc'
8065in `nnmail-extra-headers'."
8066 (interactive
8067 (list (read-string (format "%s address (regexp): "
8068 (if current-prefix-arg "Exclude" "Limit to")))
8069 current-prefix-arg))
8070 (when (not (equal "" address))
8071 (prog1 (let* ((to
8072 (if (memq 'To nnmail-extra-headers)
8073 (gnus-summary-find-matching
8074 (cons 'extra 'To) address 'all nil nil
8075 not-matching)
8076 (gnus-message
8077 1 "`To' isn't present in `nnmail-extra-headers'")
8078 (sit-for 1)
8079 t))
8080 (cc
8081 (if (memq 'Cc nnmail-extra-headers)
8082 (gnus-summary-find-matching
8083 (cons 'extra 'Cc) address 'all nil nil
8084 not-matching)
8085 (gnus-message
8086 1 "`Cc' isn't present in `nnmail-extra-headers'")
8087 (sit-for 1)
8088 t))
8089 (from
8090 (gnus-summary-find-matching "from" address
8091 'all nil nil not-matching))
8092 (articles
8093 (if not-matching
8094 ;; We need the numbers that are in all lists:
8095 (if (eq cc t)
8096 (if (eq to t)
8097 from
8098 (mapcar (lambda (a) (car (memq a from))) to))
8099 (if (eq to t)
8100 (mapcar (lambda (a) (car (memq a from))) cc)
8101 (mapcar (lambda (a) (car (memq a from)))
8102 (mapcar (lambda (a) (car (memq a to)))
8103 cc))))
8104 (nconc (if (eq to t) nil to)
8105 (if (eq cc t) nil cc)
8106 from))))
8107 (unless articles
8108 (error "Found no matches for \"%s\"" address))
8109 (gnus-summary-limit articles))
8110 (gnus-summary-position-point))))
8111
8112(defun gnus-summary-limit-strange-charsets-predicate (header)
8113 (let ((string (concat (mail-header-subject header)
8114 (mail-header-from header)))
8115 charset found)
8116 (dotimes (i (1- (length string)))
8117 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8118 (when (string-match "unicode\\|big\\|japanese" charset)
8119 (setq found t)))
8120 found))
8121
8122(defun gnus-summary-limit-to-predicate (predicate)
8123 "Limit to articles where PREDICATE returns non-nil.
8124PREDICATE will be called with the header structures of the
8125articles."
8126 (let ((articles nil)
8127 (case-fold-search t))
8128 (dolist (header gnus-newsgroup-headers)
8129 (when (funcall predicate header)
8130 (push (mail-header-number header) articles)))
8131 (gnus-summary-limit (nreverse articles))))
8132
eec82323
LMI
8133(defun gnus-summary-limit-to-age (age &optional younger-p)
8134 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8135If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8136articles that are younger than AGE days."
16409b0b
GM
8137 (interactive
8138 (let ((younger current-prefix-arg)
8139 (days-got nil)
8140 days)
8141 (while (not days-got)
8142 (setq days (if younger
23f87bed
MB
8143 (read-string "Limit to articles younger than (in days, older when negative): ")
8144 (read-string
8145 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
8146 (when (> (length days) 0)
8147 (setq days (read days)))
8148 (if (numberp days)
23f87bed
MB
8149 (progn
8150 (setq days-got t)
01c52d31
MB
8151 (when (< days 0)
8152 (setq younger (not younger))
8153 (setq days (* days -1))))
16409b0b
GM
8154 (message "Please enter a number.")
8155 (sleep-for 1)))
8156 (list days younger)))
eec82323
LMI
8157 (prog1
8158 (let ((data gnus-newsgroup-data)
16409b0b 8159 (cutoff (days-to-time age))
eec82323
LMI
8160 articles d date is-younger)
8161 (while (setq d (pop data))
8162 (when (and (vectorp (gnus-data-header d))
8163 (setq date (mail-header-date (gnus-data-header d))))
16409b0b
GM
8164 (setq is-younger (time-less-p
8165 (time-since (condition-case ()
8166 (date-to-time date)
8167 (error '(0 0))))
eec82323 8168 cutoff))
6748645f
LMI
8169 (when (if younger-p
8170 is-younger
8171 (not is-younger))
eec82323
LMI
8172 (push (gnus-data-number d) articles))))
8173 (gnus-summary-limit (nreverse articles)))
8174 (gnus-summary-position-point)))
8175
47b63dfa 8176(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
8177 "Limit the summary buffer to articles that match an 'extra' header."
8178 (interactive
8179 (let ((header
8180 (intern
23f87bed 8181 (gnus-completing-read-with-default
16409b0b 8182 (symbol-name (car gnus-extra-headers))
47b63dfa 8183 (if current-prefix-arg
81df110a
RF
8184 "Exclude extra header"
8185 "Limit extra header")
16409b0b
GM
8186 (mapcar (lambda (x)
8187 (cons (symbol-name x) x))
8188 gnus-extra-headers)
8189 nil
8190 t))))
8191 (list header
a1506d29 8192 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
8193 (if current-prefix-arg "Exclude" "Limit to")
8194 header))
8195 current-prefix-arg)))
16409b0b
GM
8196 (when (not (equal "" regexp))
8197 (prog1
8198 (let ((articles (gnus-summary-find-matching
a1506d29 8199 (cons 'extra header) regexp 'all nil nil
47b63dfa 8200 not-matching)))
16409b0b
GM
8201 (unless articles
8202 (error "Found no matches for \"%s\"" regexp))
8203 (gnus-summary-limit articles))
8204 (gnus-summary-position-point))))
8205
23f87bed
MB
8206(defun gnus-summary-limit-to-display-predicate ()
8207 "Limit the summary buffer to the predicated in the `display' group parameter."
8208 (interactive)
8209 (unless gnus-newsgroup-display
8210 (error "There is no `display' group parameter"))
8211 (let (articles)
8212 (dolist (number gnus-newsgroup-articles)
8213 (when (funcall gnus-newsgroup-display)
8214 (push number articles)))
8215 (gnus-summary-limit articles))
8216 (gnus-summary-position-point))
8217
eec82323
LMI
8218(defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8219(make-obsolete
8220 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8221
8222(defun gnus-summary-limit-to-unread (&optional all)
8223 "Limit the summary buffer to articles that are not marked as read.
8224If ALL is non-nil, limit strictly to unread articles."
8225 (interactive "P")
8226 (if all
8227 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8228 (gnus-summary-limit-to-marks
8229 ;; Concat all the marks that say that an article is read and have
8230 ;; those removed.
8231 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 8232 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
8233 gnus-low-score-mark gnus-expirable-mark
8234 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8235 gnus-duplicate-mark gnus-souped-mark)
8236 'reverse)))
8237
01c52d31
MB
8238(defun gnus-summary-limit-to-headers (match &optional reverse)
8239 "Limit the summary buffer to articles that have headers that match MATCH.
8240If REVERSE (the prefix), limit to articles that don't match."
8241 (interactive "sMatch headers (regexp): \nP")
8242 (gnus-summary-limit-to-bodies match reverse t))
8243
8244(defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8245 "Limit the summary buffer to articles that have bodies that match MATCH.
8246If REVERSE (the prefix), limit to articles that don't match."
8247 (interactive "sMatch body (regexp): \nP")
8248 (let ((articles nil)
8249 (gnus-select-article-hook nil) ;Disable hook.
8250 (gnus-article-prepare-hook nil)
8251 (gnus-use-article-prefetch nil)
8252 (gnus-keep-backlog nil)
8253 (gnus-break-pages nil)
8254 (gnus-summary-display-arrow nil)
8255 (gnus-updated-mode-lines nil)
8256 (gnus-auto-center-summary nil)
8257 (gnus-display-mime-function nil))
8258 (dolist (data gnus-newsgroup-data)
8259 (let (gnus-mark-article-hook)
8260 (gnus-summary-select-article t t nil (gnus-data-number data)))
8261 (save-excursion
8262 (set-buffer gnus-article-buffer)
8263 (article-goto-body)
8264 (let* ((case-fold-search t)
8265 (found (if headersp
8266 (re-search-backward match nil t)
8267 (re-search-forward match nil t))))
8268 (when (or (and found
8269 (not reverse))
8270 (and (not found)
8271 reverse))
8272 (push (gnus-data-number data) articles)))))
8273 (if (not articles)
8274 (message "No messages matched")
8275 (gnus-summary-limit articles)))
8276 (gnus-summary-position-point))
8277
8278(defun gnus-summary-limit-to-singletons (&optional threadsp)
8279 "Limit the summary buffer to articles that aren't part on any thread.
8280If THREADSP (the prefix), limit to articles that are in threads."
8281 (interactive "P")
8282 (let ((articles nil)
8283 thread-articles
8284 threads)
8285 (dolist (thread gnus-newsgroup-threads)
8286 (if (stringp (car thread))
8287 (dolist (thread (cdr thread))
8288 (push thread threads))
8289 (push thread threads)))
8290 (dolist (thread threads)
8291 (setq thread-articles (gnus-articles-in-thread thread))
8292 (when (or (and threadsp
8293 (> (length thread-articles) 1))
8294 (and (not threadsp)
8295 (= (length thread-articles) 1)))
8296 (setq articles (nconc thread-articles articles))))
8297 (if (not articles)
8298 (message "No messages matched")
8299 (gnus-summary-limit articles))
8300 (gnus-summary-position-point)))
8301
8302(defun gnus-summary-limit-to-replied (&optional unreplied)
8303 "Limit the summary buffer to replied articles.
8304If UNREPLIED (the prefix), limit to unreplied articles."
8305 (interactive "P")
8306 (if unreplied
8307 (gnus-summary-limit
8308 (gnus-set-difference gnus-newsgroup-articles
8309 gnus-newsgroup-replied))
8310 (gnus-summary-limit gnus-newsgroup-replied))
8311 (gnus-summary-position-point))
8312
eec82323
LMI
8313(defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
8314(make-obsolete 'gnus-summary-delete-marked-with
81ceefe2 8315 'gnus-summary-limit-exclude-marks)
eec82323
LMI
8316
8317(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8318 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8319If REVERSE, limit the summary buffer to articles that are marked
8320with MARKS. MARKS can either be a string of marks or a list of marks.
8321Returns how many articles were removed."
8322 (interactive "sMarks: ")
8323 (gnus-summary-limit-to-marks marks t))
8324
8325(defun gnus-summary-limit-to-marks (marks &optional reverse)
8326 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8327If REVERSE (the prefix), limit the summary buffer to articles that are
8328not marked with MARKS. MARKS can either be a string of marks or a
8329list of marks.
8330Returns how many articles were removed."
6748645f 8331 (interactive "sMarks: \nP")
eec82323
LMI
8332 (prog1
8333 (let ((data gnus-newsgroup-data)
8334 (marks (if (listp marks) marks
8335 (append marks nil))) ; Transform to list.
8336 articles)
8337 (while data
8338 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8339 (memq (gnus-data-mark (car data)) marks))
8340 (push (gnus-data-number (car data)) articles))
8341 (setq data (cdr data)))
8342 (gnus-summary-limit articles))
8343 (gnus-summary-position-point)))
8344
23f87bed 8345(defun gnus-summary-limit-to-score (score)
eec82323 8346 "Limit to articles with score at or above SCORE."
23f87bed 8347 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
8348 (let ((data gnus-newsgroup-data)
8349 articles)
8350 (while data
8351 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8352 score)
8353 (push (gnus-data-number (car data)) articles))
8354 (setq data (cdr data)))
8355 (prog1
8356 (gnus-summary-limit articles)
8357 (gnus-summary-position-point))))
8358
23f87bed
MB
8359(defun gnus-summary-limit-to-unseen ()
8360 "Limit to unseen articles."
8361 (interactive)
8362 (prog1
8363 (gnus-summary-limit gnus-newsgroup-unseen)
8364 (gnus-summary-position-point)))
8365
6748645f 8366(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
8367 "Display all the hidden articles that is in the thread with ID in it.
8368When called interactively, ID is the Message-ID of the current
8369article."
6748645f
LMI
8370 (interactive (list (mail-header-id (gnus-summary-article-header))))
8371 (let ((articles (gnus-articles-in-thread
8372 (gnus-id-to-thread (gnus-root-id id)))))
8373 (prog1
8374 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
8375 (gnus-summary-limit-include-matching-articles
8376 "subject"
8377 (regexp-quote (gnus-simplify-subject-re
8378 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
8379 (gnus-summary-position-point))))
8380
23f87bed
MB
8381(defun gnus-summary-limit-include-matching-articles (header regexp)
8382 "Display all the hidden articles that have HEADERs that match REGEXP."
8383 (interactive (list (read-string "Match on header: ")
8384 (read-string "Regexp: ")))
8385 (let ((articles (gnus-find-matching-articles header regexp)))
8386 (prog1
8387 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8388 (gnus-summary-position-point))))
8389
8390(defun gnus-summary-insert-dormant-articles ()
8391 "Insert all the dormant articles for this group into the current buffer."
8392 (interactive)
8393 (let ((gnus-verbose (max 6 gnus-verbose)))
8394 (if (not gnus-newsgroup-dormant)
db629244 8395 (gnus-message 3 "No dormant articles for this group")
23f87bed
MB
8396 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8397
01c52d31
MB
8398(defun gnus-summary-insert-ticked-articles ()
8399 "Insert ticked articles for this group into the current buffer."
8400 (interactive)
8401 (let ((gnus-verbose (max 6 gnus-verbose)))
8402 (if (not gnus-newsgroup-marked)
8403 (gnus-message 3 "No ticked articles for this group")
8404 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8405
eec82323 8406(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
8407 "Display all the hidden articles that are marked as dormant.
8408Note that this command only works on a subset of the articles currently
8409fetched for this group."
eec82323 8410 (interactive)
eec82323
LMI
8411 (unless gnus-newsgroup-dormant
8412 (error "There are no dormant articles in this group"))
8413 (prog1
8414 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8415 (gnus-summary-position-point)))
8416
8417(defun gnus-summary-limit-exclude-dormant ()
8418 "Hide all dormant articles."
8419 (interactive)
eec82323
LMI
8420 (prog1
8421 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8422 (gnus-summary-position-point)))
8423
8424(defun gnus-summary-limit-exclude-childless-dormant ()
8425 "Hide all dormant articles that have no children."
8426 (interactive)
eec82323
LMI
8427 (let ((data (gnus-data-list t))
8428 articles d children)
8429 ;; Find all articles that are either not dormant or have
8430 ;; children.
8431 (while (setq d (pop data))
8432 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8433 (and (setq children
8434 (gnus-article-children (gnus-data-number d)))
8435 (let (found)
8436 (while children
8437 (when (memq (car children) articles)
8438 (setq children nil
8439 found t))
8440 (pop children))
8441 found)))
8442 (push (gnus-data-number d) articles)))
8443 ;; Do the limiting.
8444 (prog1
8445 (gnus-summary-limit articles)
8446 (gnus-summary-position-point))))
8447
8448(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8449 "Mark all unread excluded articles as read.
8450If ALL, mark even excluded ticked and dormants as read."
8451 (interactive "P")
23f87bed
MB
8452 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8453 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8454 (sort
8455 (mapcar (lambda (h) (mail-header-number h))
8456 gnus-newsgroup-headers)
8457 '<)
23f87bed 8458 gnus-newsgroup-limit))
eec82323 8459 article)
6748645f 8460 (setq gnus-newsgroup-unreads
23f87bed
MB
8461 (gnus-sorted-intersection gnus-newsgroup-unreads
8462 gnus-newsgroup-limit))
eec82323
LMI
8463 (if all
8464 (setq gnus-newsgroup-dormant nil
8465 gnus-newsgroup-marked nil
8466 gnus-newsgroup-reads
8467 (nconc
8468 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8469 gnus-newsgroup-reads))
8470 (while (setq article (pop articles))
8471 (unless (or (memq article gnus-newsgroup-dormant)
8472 (memq article gnus-newsgroup-marked))
8473 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8474
8475(defun gnus-summary-limit (articles &optional pop)
8476 (if pop
8477 ;; We pop the previous limit off the stack and use that.
8478 (setq articles (car gnus-newsgroup-limits)
8479 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8480 ;; We use the new limit, so we push the old limit on the stack.
8481 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8482 ;; Set the limit.
8483 (setq gnus-newsgroup-limit articles)
8484 (let ((total (length gnus-newsgroup-data))
8485 (data (gnus-data-find-list (gnus-summary-article-number)))
8486 (gnus-summary-mark-below nil) ; Inhibit this.
8487 found)
8488 ;; This will do all the work of generating the new summary buffer
8489 ;; according to the new limit.
8490 (gnus-summary-prepare)
8491 ;; Hide any threads, possibly.
23f87bed 8492 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8493 ;; Try to return to the article you were at, or one in the
8494 ;; neighborhood.
8495 (when data
8496 ;; We try to find some article after the current one.
8497 (while data
8498 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8499 (setq data nil
8500 found t))
8501 (setq data (cdr data))))
8502 (unless found
8503 ;; If there is no data, that means that we were after the last
8504 ;; article. The same goes when we can't find any articles
8505 ;; after the current one.
8506 (goto-char (point-max))
8507 (gnus-summary-find-prev))
6748645f 8508 (gnus-set-mode-line 'summary)
eec82323
LMI
8509 ;; We return how many articles were removed from the summary
8510 ;; buffer as a result of the new limit.
8511 (- total (length gnus-newsgroup-data))))
8512
8513(defsubst gnus-invisible-cut-children (threads)
8514 (let ((num 0))
8515 (while threads
8516 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8517 (incf num))
8518 (pop threads))
8519 (< num 2)))
8520
8521(defsubst gnus-cut-thread (thread)
8522 "Go forwards in the thread until we find an article that we want to display."
8523 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8524 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8525 (numberp gnus-fetch-old-headers)
eec82323
LMI
8526 (eq gnus-build-sparse-threads 'some)
8527 (eq gnus-build-sparse-threads 'more))
8528 ;; Deal with old-fetched headers and sparse threads.
8529 (while (and
8530 thread
8531 (or
8532 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8533 (gnus-summary-article-ancient-p
8534 (mail-header-number (car thread))))
6748645f
LMI
8535 (if (or (<= (length (cdr thread)) 1)
8536 (eq gnus-fetch-old-headers 'invisible))
8537 (setq gnus-newsgroup-limit
8538 (delq (mail-header-number (car thread))
8539 gnus-newsgroup-limit)
8540 thread (cadr thread))
8541 (when (gnus-invisible-cut-children (cdr thread))
8542 (let ((th (cdr thread)))
8543 (while th
8544 (if (memq (mail-header-number (caar th))
a8151ef7 8545 gnus-newsgroup-limit)
6748645f
LMI
8546 (setq thread (car th)
8547 th nil)
8548 (setq th (cdr th))))))))))
eec82323
LMI
8549 thread)
8550
8551(defun gnus-cut-threads (threads)
23f87bed 8552 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8553 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8554 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8555 (numberp gnus-fetch-old-headers)
eec82323
LMI
8556 (eq gnus-build-sparse-threads 'some)
8557 (eq gnus-build-sparse-threads 'more))
8558 (let ((th threads))
8559 (while th
8560 (setcar th (gnus-cut-thread (car th)))
8561 (setq th (cdr th)))))
8562 ;; Remove nixed out threads.
8563 (delq nil threads))
8564
8565(defun gnus-summary-initial-limit (&optional show-if-empty)
8566 "Figure out what the initial limit is supposed to be on group entry.
8567This entails weeding out unwanted dormants, low-scored articles,
8568fetch-old-headers verbiage, and so on."
8569 ;; Most groups have nothing to remove.
8570 (if (or gnus-inhibit-limiting
8571 (and (null gnus-newsgroup-dormant)
23f87bed 8572 (eq gnus-newsgroup-display 'gnus-not-ignore)
eec82323 8573 (not (eq gnus-fetch-old-headers 'some))
16409b0b 8574 (not (numberp gnus-fetch-old-headers))
6748645f 8575 (not (eq gnus-fetch-old-headers 'invisible))
eec82323
LMI
8576 (null gnus-summary-expunge-below)
8577 (not (eq gnus-build-sparse-threads 'some))
8578 (not (eq gnus-build-sparse-threads 'more))
8579 (null gnus-thread-expunge-below)
8580 (not gnus-use-nocem)))
8581 () ; Do nothing.
8582 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8583 (setq gnus-newsgroup-limit nil)
8584 (mapatoms
8585 (lambda (node)
8586 (unless (car (symbol-value node))
8587 ;; These threads have no parents -- they are roots.
8588 (let ((nodes (cdr (symbol-value node)))
8589 thread)
8590 (while nodes
8591 (if (and gnus-thread-expunge-below
8592 (< (gnus-thread-total-score (car nodes))
8593 gnus-thread-expunge-below))
8594 (gnus-expunge-thread (pop nodes))
8595 (setq thread (pop nodes))
8596 (gnus-summary-limit-children thread))))))
8597 gnus-newsgroup-dependencies)
8598 ;; If this limitation resulted in an empty group, we might
8599 ;; pop the previous limit and use it instead.
8600 (when (and (not gnus-newsgroup-limit)
8601 show-if-empty)
8602 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8603 gnus-newsgroup-limit))
8604
8605(defun gnus-summary-limit-children (thread)
8606 "Return 1 if this subthread is visible and 0 if it is not."
8607 ;; First we get the number of visible children to this thread. This
8608 ;; is done by recursing down the thread using this function, so this
8609 ;; will really go down to a leaf article first, before slowly
8610 ;; working its way up towards the root.
8611 (when thread
04b61ae9 8612 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8613 (children
eec82323
LMI
8614 (if (cdr thread)
8615 (apply '+ (mapcar 'gnus-summary-limit-children
8616 (cdr thread)))
8617 0))
8618 (number (mail-header-number (car thread)))
8619 score)
8620 (if (and
8621 (not (memq number gnus-newsgroup-marked))
8622 (or
8623 ;; If this article is dormant and has absolutely no visible
8624 ;; children, then this article isn't visible.
8625 (and (memq number gnus-newsgroup-dormant)
8626 (zerop children))
8627 ;; If this is "fetch-old-headered" and there is no
8628 ;; visible children, then we don't want this article.
16409b0b
GM
8629 (and (or (eq gnus-fetch-old-headers 'some)
8630 (numberp gnus-fetch-old-headers))
eec82323
LMI
8631 (gnus-summary-article-ancient-p number)
8632 (zerop children))
6748645f
LMI
8633 ;; If this is "fetch-old-headered" and `invisible', then
8634 ;; we don't want this article.
8635 (and (eq gnus-fetch-old-headers 'invisible)
8636 (gnus-summary-article-ancient-p number))
eec82323
LMI
8637 ;; If this is a sparsely inserted article with no children,
8638 ;; we don't want it.
8639 (and (eq gnus-build-sparse-threads 'some)
8640 (gnus-summary-article-sparse-p number)
8641 (zerop children))
8642 ;; If we use expunging, and this article is really
8643 ;; low-scored, then we don't want this article.
8644 (when (and gnus-summary-expunge-below
8645 (< (setq score
8646 (or (cdr (assq number gnus-newsgroup-scored))
8647 gnus-summary-default-score))
8648 gnus-summary-expunge-below))
8649 ;; We increase the expunge-tally here, but that has
8650 ;; nothing to do with the limits, really.
8651 (incf gnus-newsgroup-expunged-tally)
8652 ;; We also mark as read here, if that's wanted.
8653 (when (and gnus-summary-mark-below
8654 (< score gnus-summary-mark-below))
8655 (setq gnus-newsgroup-unreads
8656 (delq number gnus-newsgroup-unreads))
8657 (if gnus-newsgroup-auto-expire
8658 (push number gnus-newsgroup-expirable)
8659 (push (cons number gnus-low-score-mark)
8660 gnus-newsgroup-reads)))
8661 t)
23f87bed
MB
8662 ;; Do the `display' group parameter.
8663 (and gnus-newsgroup-display
8664 (not (funcall gnus-newsgroup-display)))
eec82323 8665 ;; Check NoCeM things.
01c52d31
MB
8666 (when (and gnus-use-nocem
8667 (gnus-nocem-unwanted-article-p
8668 (mail-header-id (car thread))))
8669 (setq gnus-newsgroup-unreads
8670 (delq number gnus-newsgroup-unreads))
8671 t)))
eec82323
LMI
8672 ;; Nope, invisible article.
8673 0
8674 ;; Ok, this article is to be visible, so we add it to the limit
8675 ;; and return 1.
8676 (push number gnus-newsgroup-limit)
8677 1))))
8678
8679(defun gnus-expunge-thread (thread)
8680 "Mark all articles in THREAD as read."
8681 (let* ((number (mail-header-number (car thread))))
8682 (incf gnus-newsgroup-expunged-tally)
8683 ;; We also mark as read here, if that's wanted.
8684 (setq gnus-newsgroup-unreads
8685 (delq number gnus-newsgroup-unreads))
8686 (if gnus-newsgroup-auto-expire
8687 (push number gnus-newsgroup-expirable)
8688 (push (cons number gnus-low-score-mark)
8689 gnus-newsgroup-reads)))
8690 ;; Go recursively through all subthreads.
8691 (mapcar 'gnus-expunge-thread (cdr thread)))
8692
8693;; Summary article oriented commands
8694
8695(defun gnus-summary-refer-parent-article (n)
8696 "Refer parent article N times.
8697If N is negative, go to ancestor -N instead.
8698The difference between N and the number of articles fetched is returned."
8699 (interactive "p")
eec82323
LMI
8700 (let ((skip 1)
8701 error header ref)
8702 (when (not (natnump n))
8703 (setq skip (abs n)
8704 n 1))
8705 (while (and (> n 0)
8706 (not error))
8707 (setq header (gnus-summary-article-header))
8708 (if (and (eq (mail-header-number header)
8709 (cdr gnus-article-current))
8710 (equal gnus-newsgroup-name
8711 (car gnus-article-current)))
8712 ;; If we try to find the parent of the currently
8713 ;; displayed article, then we take a look at the actual
8714 ;; References header, since this is slightly more
8715 ;; reliable than the References field we got from the
8716 ;; server.
8717 (save-excursion
8718 (set-buffer gnus-original-article-buffer)
8719 (nnheader-narrow-to-headers)
8720 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8721 (when (setq ref (message-fetch-field "in-reply-to"))
8722 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8723 (widen))
8724 (setq ref
8725 ;; It's not the current article, so we take a bet on
8726 ;; the value we got from the server.
8727 (mail-header-references header)))
8728 (if (and ref
8729 (not (equal ref "")))
8730 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8731 (gnus-message 1 "Couldn't find parent"))
8732 (gnus-message 1 "No references in article %d"
8733 (gnus-summary-article-number))
8734 (setq error t))
8735 (decf n))
8736 (gnus-summary-position-point)
8737 n))
8738
8739(defun gnus-summary-refer-references ()
8740 "Fetch all articles mentioned in the References header.
6748645f 8741Return the number of articles fetched."
eec82323 8742 (interactive)
eec82323
LMI
8743 (let ((ref (mail-header-references (gnus-summary-article-header)))
8744 (current (gnus-summary-article-number))
8745 (n 0))
8746 (if (or (not ref)
8747 (equal ref ""))
8748 (error "No References in the current article")
8749 ;; For each Message-ID in the References header...
8750 (while (string-match "<[^>]*>" ref)
8751 (incf n)
8752 ;; ... fetch that article.
8753 (gnus-summary-refer-article
8754 (prog1 (match-string 0 ref)
8755 (setq ref (substring ref (match-end 0))))))
8756 (gnus-summary-goto-subject current)
8757 (gnus-summary-position-point)
8758 n)))
8759
6748645f
LMI
8760(defun gnus-summary-refer-thread (&optional limit)
8761 "Fetch all articles in the current thread.
8762If LIMIT (the numerical prefix), fetch that many old headers instead
8763of what's specified by the `gnus-refer-thread-limit' variable."
8764 (interactive "P")
8765 (let ((id (mail-header-id (gnus-summary-article-header)))
8766 (limit (if limit (prefix-numeric-value limit)
8767 gnus-refer-thread-limit)))
6748645f
LMI
8768 (unless (eq gnus-fetch-old-headers 'invisible)
8769 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8770 ;; Retrieve the headers and read them in.
23f87bed
MB
8771 (if (eq (if (numberp limit)
8772 (gnus-retrieve-headers
8773 (list (min
8774 (+ (mail-header-number
8775 (gnus-summary-article-header))
8776 limit)
8777 gnus-newsgroup-end))
8778 gnus-newsgroup-name (* limit 2))
8779 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8780 ;; headers.
8781 (gnus-retrieve-headers (list gnus-newsgroup-end)
8782 gnus-newsgroup-name limit))
6748645f
LMI
8783 'nov)
8784 (gnus-build-all-threads)
23f87bed 8785 (error "Can't fetch thread from back ends that don't support NOV"))
6748645f
LMI
8786 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8787 (gnus-summary-limit-include-thread id)))
8788
16409b0b
GM
8789(defun gnus-summary-refer-article (message-id)
8790 "Fetch an article specified by MESSAGE-ID."
8791 (interactive "sMessage-ID: ")
eec82323
LMI
8792 (when (and (stringp message-id)
8793 (not (zerop (length message-id))))
23f87bed 8794 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8795 ;; Construct the correct Message-ID if necessary.
8796 ;; Suggested by tale@pawl.rpi.edu.
8797 (unless (string-match "^<" message-id)
8798 (setq message-id (concat "<" message-id)))
8799 (unless (string-match ">$" message-id)
8800 (setq message-id (concat message-id ">")))
23f87bed
MB
8801 ;; People often post MIDs from URLs, so unhex it:
8802 (unless (string-match "@" message-id)
8803 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8804 (let* ((header (gnus-id-to-header message-id))
8805 (sparse (and header
8806 (gnus-summary-article-sparse-p
a8151ef7
LMI
8807 (mail-header-number header))
8808 (memq (mail-header-number header)
16409b0b
GM
8809 gnus-newsgroup-limit)))
8810 number)
6748645f
LMI
8811 (cond
8812 ;; If the article is present in the buffer we just go to it.
8813 ((and header
8814 (or (not (gnus-summary-article-sparse-p
8815 (mail-header-number header)))
8816 sparse))
8817 (prog1
8818 (gnus-summary-goto-article
8819 (mail-header-number header) nil t)
8820 (when sparse
8821 (gnus-summary-update-article (mail-header-number header)))))
8822 (t
16409b0b
GM
8823 ;; We fetch the article.
8824 (catch 'found
8825 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8826 (when (and (gnus-check-server gnus-override-method)
8827 ;; Fetch the header,
8828 (setq number (gnus-summary-insert-subject message-id)))
8829 ;; and display the article.
eec82323 8830 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8831 (throw 'found t)))
8832 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8833
8834(defun gnus-refer-article-methods ()
8f688cb0 8835 "Return a list of referable methods."
16409b0b
GM
8836 (cond
8837 ;; No method, so we default to current and native.
8838 ((null gnus-refer-article-method)
8839 (list gnus-current-select-method gnus-select-method))
8840 ;; Current.
8841 ((eq 'current gnus-refer-article-method)
8842 (list gnus-current-select-method))
8843 ;; List of select methods.
d4dfaa19
DL
8844 ((not (and (symbolp (car gnus-refer-article-method))
8845 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
8846 (let (out)
8847 (dolist (method gnus-refer-article-method)
8848 (push (if (eq 'current method)
8849 gnus-current-select-method
8850 method)
8851 out))
8852 (nreverse out)))
8853 ;; One single select method.
8854 (t
8855 (list gnus-refer-article-method))))
6748645f
LMI
8856
8857(defun gnus-summary-edit-parameters ()
8858 "Edit the group parameters of the current group."
8859 (interactive)
8860 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 8861
16409b0b
GM
8862(defun gnus-summary-customize-parameters ()
8863 "Customize the group parameters of the current group."
8864 (interactive)
8865 (gnus-group-customize gnus-newsgroup-name))
8866
eec82323
LMI
8867(defun gnus-summary-enter-digest-group (&optional force)
8868 "Enter an nndoc group based on the current article.
8869If FORCE, force a digest interpretation. If not, try
8870to guess what the document format is."
8871 (interactive "P")
eec82323 8872 (let ((conf gnus-current-window-configuration))
23f87bed
MB
8873 (save-window-excursion
8874 (save-excursion
8875 (let (gnus-article-prepare-hook
8876 gnus-display-mime-function
8877 gnus-break-pages)
8878 (gnus-summary-select-article))))
eec82323
LMI
8879 (setq gnus-current-window-configuration conf)
8880 (let* ((name (format "%s-%d"
8881 (gnus-group-prefixed-name
8882 gnus-newsgroup-name (list 'nndoc ""))
01c52d31 8883 (with-current-buffer gnus-summary-buffer
eec82323
LMI
8884 gnus-current-article)))
8885 (ogroup gnus-newsgroup-name)
8886 (params (append (gnus-info-params (gnus-get-info ogroup))
8887 (list (cons 'to-group ogroup))
23f87bed 8888 (list (cons 'parent-group ogroup))
eec82323
LMI
8889 (list (cons 'save-article-group ogroup))))
8890 (case-fold-search t)
8891 (buf (current-buffer))
16409b0b 8892 dig to-address)
eec82323 8893 (save-excursion
16409b0b
GM
8894 (set-buffer gnus-original-article-buffer)
8895 ;; Have the digest group inherit the main mail address of
8896 ;; the parent article.
23f87bed
MB
8897 (when (setq to-address (or (gnus-fetch-field "reply-to")
8898 (gnus-fetch-field "from")))
343d6628
MB
8899 (setq params
8900 (append
8901 (list (cons 'to-address
8902 (funcall gnus-decode-encoded-address-function
8903 to-address))))))
eec82323
LMI
8904 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8905 (insert-buffer-substring gnus-original-article-buffer)
8906 ;; Remove lines that may lead nndoc to misinterpret the
8907 ;; document type.
8908 (narrow-to-region
8909 (goto-char (point-min))
8910 (or (search-forward "\n\n" nil t) (point)))
8911 (goto-char (point-min))
16409b0b 8912 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8913 (widen))
8914 (unwind-protect
23f87bed 8915 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
8916 (gnus-newsgroup-ephemeral-ignored-charsets
8917 gnus-newsgroup-ignored-charsets))
8918 (gnus-group-read-ephemeral-group
8919 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8920 (nndoc-article-type
23f87bed
MB
8921 ,(if force 'mbox 'guess)))
8922 t nil nil nil
8923 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8924 "ADAPT")))))
16409b0b 8925 ;; Make all postings to this group go to the parent group.
23f87bed
MB
8926 (nconc (gnus-info-params (gnus-get-info name))
8927 params)
8928 ;; Couldn't select this doc group.
8929 (switch-to-buffer buf)
8930 (gnus-set-global-variables)
8931 (gnus-configure-windows 'summary)
8932 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
8933 (kill-buffer dig)))))
8934
8935(defun gnus-summary-read-document (n)
8936 "Open a new group based on the current article(s).
8937This will allow you to read digests and other similar
8938documents as newsgroups.
8939Obeys the standard process/prefix convention."
8940 (interactive "P")
01c52d31 8941 (let* ((ogroup gnus-newsgroup-name)
eec82323
LMI
8942 (params (append (gnus-info-params (gnus-get-info ogroup))
8943 (list (cons 'to-group ogroup))))
01c52d31
MB
8944 group egroup groups vgroup)
8945 (dolist (article (gnus-summary-work-articles n))
eec82323
LMI
8946 (setq group (format "%s-%d" gnus-newsgroup-name article))
8947 (gnus-summary-remove-process-mark article)
8948 (when (gnus-summary-display-article article)
8949 (save-excursion
16409b0b 8950 (with-temp-buffer
eec82323
LMI
8951 (insert-buffer-substring gnus-original-article-buffer)
8952 ;; Remove some headers that may lead nndoc to make
8953 ;; the wrong guess.
8954 (message-narrow-to-head)
8955 (goto-char (point-min))
01c52d31 8956 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8957 (widen)
8958 (if (setq egroup
8959 (gnus-group-read-ephemeral-group
8960 group `(nndoc ,group (nndoc-address ,(current-buffer))
8961 (nndoc-article-type guess))
8962 t nil t))
8963 (progn
23f87bed 8964 ;; Make all postings to this group go to the parent group.
eec82323
LMI
8965 (nconc (gnus-info-params (gnus-get-info egroup))
8966 params)
8967 (push egroup groups))
8968 ;; Couldn't select this doc group.
8969 (gnus-error 3 "Article couldn't be entered"))))))
8970 ;; Now we have selected all the documents.
8971 (cond
8972 ((not groups)
8973 (error "None of the articles could be interpreted as documents"))
8974 ((gnus-group-read-ephemeral-group
8975 (setq vgroup (format
8976 "nnvirtual:%s-%s" gnus-newsgroup-name
8977 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8978 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8979 t
8980 (cons (current-buffer) 'summary)))
8981 (t
8982 (error "Couldn't select virtual nndoc group")))))
8983
8984(defun gnus-summary-isearch-article (&optional regexp-p)
8985 "Do incremental search forward on the current article.
8986If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8987 (interactive "P")
eec82323
LMI
8988 (gnus-summary-select-article)
8989 (gnus-configure-windows 'article)
8990 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
8991 (save-restriction
8992 (widen)
8993 (isearch-forward regexp-p))))
eec82323 8994
01c52d31
MB
8995(defun gnus-summary-repeat-search-article-forward ()
8996 "Repeat the previous search forwards."
8997 (interactive)
8998 (unless gnus-last-search-regexp
8999 (error "No previous search"))
9000 (gnus-summary-search-article-forward gnus-last-search-regexp))
9001
9002(defun gnus-summary-repeat-search-article-backward ()
9003 "Repeat the previous search backwards."
9004 (interactive)
9005 (unless gnus-last-search-regexp
9006 (error "No previous search"))
9007 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9008
eec82323
LMI
9009(defun gnus-summary-search-article-forward (regexp &optional backward)
9010 "Search for an article containing REGEXP forward.
9011If BACKWARD, search backward instead."
9012 (interactive
9013 (list (read-string
9014 (format "Search article %s (regexp%s): "
9015 (if current-prefix-arg "backward" "forward")
9016 (if gnus-last-search-regexp
9017 (concat ", default " gnus-last-search-regexp)
9018 "")))
9019 current-prefix-arg))
eec82323
LMI
9020 (if (string-equal regexp "")
9021 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
9022 (setq gnus-last-search-regexp regexp)
9023 (setq gnus-article-before-search gnus-current-article))
9024 ;; Intentionally set gnus-last-article.
9025 (setq gnus-last-article gnus-article-before-search)
9026 (let ((gnus-last-article gnus-last-article))
9027 (if (gnus-summary-search-article regexp backward)
9028 (gnus-summary-show-thread)
abc40aab 9029 (signal 'search-failed (list regexp)))))
eec82323
LMI
9030
9031(defun gnus-summary-search-article-backward (regexp)
9032 "Search for an article containing REGEXP backward."
9033 (interactive
9034 (list (read-string
9035 (format "Search article backward (regexp%s): "
9036 (if gnus-last-search-regexp
9037 (concat ", default " gnus-last-search-regexp)
9038 "")))))
9039 (gnus-summary-search-article-forward regexp 'backward))
9040
9041(defun gnus-summary-search-article (regexp &optional backward)
9042 "Search for an article containing REGEXP.
9043Optional argument BACKWARD means do search for backward.
9044`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
9045 ;; We have to require this here to make sure that the following
9046 ;; dynamic binding isn't shadowed by autoloading.
9047 (require 'gnus-async)
16409b0b 9048 (require 'gnus-art)
eec82323 9049 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 9050 (gnus-article-prepare-hook nil)
eec82323
LMI
9051 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9052 (gnus-use-article-prefetch nil)
9053 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 9054 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
9055 (gnus-visual nil)
9056 (gnus-keep-backlog nil)
9057 (gnus-break-pages nil)
9058 (gnus-summary-display-arrow nil)
9059 (gnus-updated-mode-lines nil)
9060 (gnus-auto-center-summary nil)
eec82323 9061 (sum (current-buffer))
16409b0b 9062 (gnus-display-mime-function nil)
eec82323
LMI
9063 (found nil)
9064 point)
9065 (gnus-save-hidden-threads
9066 (gnus-summary-select-article)
9067 (set-buffer gnus-article-buffer)
16409b0b 9068 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
9069 (when backward
9070 (forward-line -1))
9071 (while (not found)
9072 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9073 (if (if backward
9074 (re-search-backward regexp nil t)
9075 (re-search-forward regexp nil t))
9076 ;; We found the regexp.
9077 (progn
9078 (setq found 'found)
9079 (beginning-of-line)
9080 (set-window-start
9081 (get-buffer-window (current-buffer))
9082 (point))
9083 (forward-line 1)
16409b0b
GM
9084 (set-window-point
9085 (get-buffer-window (current-buffer))
9086 (point))
eec82323
LMI
9087 (set-buffer sum)
9088 (setq point (point)))
9089 ;; We didn't find it, so we go to the next article.
9090 (set-buffer sum)
9091 (setq found 'not)
9092 (while (eq found 'not)
9093 (if (not (if backward (gnus-summary-find-prev)
9094 (gnus-summary-find-next)))
9095 ;; No more articles.
9096 (setq found t)
9097 ;; Select the next article and adjust point.
9098 (unless (gnus-summary-article-sparse-p
9099 (gnus-summary-article-number))
9100 (setq found nil)
9101 (gnus-summary-select-article)
9102 (set-buffer gnus-article-buffer)
9103 (widen)
9104 (goto-char (if backward (point-max) (point-min))))))))
9105 (gnus-message 7 ""))
9106 ;; Return whether we found the regexp.
9107 (when (eq found 'found)
9108 (goto-char point)
9109 (gnus-summary-show-thread)
9110 (gnus-summary-goto-subject gnus-current-article)
9111 (gnus-summary-position-point)
9112 t)))
9113
23f87bed
MB
9114(defun gnus-find-matching-articles (header regexp)
9115 "Return a list of all articles that match REGEXP on HEADER.
9116This search includes all articles in the current group that Gnus has
9117fetched headers for, whether they are displayed or not."
9118 (let ((articles nil)
9119 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9120 (case-fold-search t))
9121 (dolist (header gnus-newsgroup-headers)
9122 (when (string-match regexp (funcall func header))
9123 (push (mail-header-number header) articles)))
9124 (nreverse articles)))
9125
eec82323 9126(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 9127 not-case-fold not-matching)
eec82323
LMI
9128 "Return a list of all articles that match REGEXP on HEADER.
9129The search stars on the current article and goes forwards unless
9130BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9131If UNREAD is non-nil, only unread articles will
9132be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 9133in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
9134not match REGEXP on HEADER."
9135 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
9136 articles d func)
9137 (if (consp header)
9138 (if (eq (car header) 'extra)
9139 (setq func
9140 `(lambda (h)
9141 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9142 "")))
9143 (error "%s is an invalid header" header))
9144 (unless (fboundp (intern (concat "mail-header-" header)))
9145 (error "%s is not a valid header" header))
9146 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
9147 (dolist (d (if (eq backward 'all)
9148 gnus-newsgroup-data
9149 (gnus-data-find-list
9150 (gnus-summary-article-number)
9151 (gnus-data-list backward))))
9152 (when (and (or (not unread) ; We want all articles...
9153 (gnus-data-unread-p d)) ; Or just unreads.
9154 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9155 (if not-matching
a1506d29 9156 (not (string-match
47b63dfa
SZ
9157 regexp
9158 (funcall func (gnus-data-header d))))
9159 (string-match regexp
9160 (funcall func (gnus-data-header d)))))
9161 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
9162 (nreverse articles)))
9163
9164(defun gnus-summary-execute-command (header regexp command &optional backward)
9165 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9166If HEADER is an empty string (or nil), the match is done on the entire
9167article. If BACKWARD (the prefix) is non-nil, search backward instead."
9168 (interactive
9169 (list (let ((completion-ignore-case t))
9170 (completing-read
9171 "Header name: "
23f87bed
MB
9172 (mapcar (lambda (header) (list (format "%s" header)))
9173 (append
9174 '("Number" "Subject" "From" "Lines" "Date"
9175 "Message-ID" "Xref" "References" "Body")
9176 gnus-extra-headers))
eec82323
LMI
9177 nil 'require-match))
9178 (read-string "Regexp: ")
9179 (read-key-sequence "Command: ")
9180 current-prefix-arg))
9181 (when (equal header "Body")
9182 (setq header ""))
eec82323
LMI
9183 ;; Hidden thread subtrees must be searched as well.
9184 (gnus-summary-show-all-threads)
9185 ;; We don't want to change current point nor window configuration.
9186 (save-excursion
9187 (save-window-excursion
23f87bed
MB
9188 (let (gnus-visual
9189 gnus-treat-strip-trailing-blank-lines
9190 gnus-treat-strip-leading-blank-lines
9191 gnus-treat-strip-multiple-blank-lines
9192 gnus-treat-hide-boring-headers
9193 gnus-treat-fold-newsgroups
9194 gnus-article-prepare-hook)
9195 (gnus-message 6 "Executing %s..." (key-description command))
9196 ;; We'd like to execute COMMAND interactively so as to give arguments.
9197 (gnus-execute header regexp
9198 `(call-interactively ',(key-binding command))
9199 backward)
9200 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
9201
9202(defun gnus-summary-beginning-of-article ()
9203 "Scroll the article back to the beginning."
9204 (interactive)
eec82323
LMI
9205 (gnus-summary-select-article)
9206 (gnus-configure-windows 'article)
9207 (gnus-eval-in-buffer-window gnus-article-buffer
9208 (widen)
9209 (goto-char (point-min))
23f87bed 9210 (when gnus-break-pages
eec82323
LMI
9211 (gnus-narrow-to-page))))
9212
9213(defun gnus-summary-end-of-article ()
9214 "Scroll to the end of the article."
9215 (interactive)
eec82323
LMI
9216 (gnus-summary-select-article)
9217 (gnus-configure-windows 'article)
9218 (gnus-eval-in-buffer-window gnus-article-buffer
9219 (widen)
9220 (goto-char (point-max))
9221 (recenter -3)
23f87bed
MB
9222 (when gnus-break-pages
9223 (when (re-search-backward page-delimiter nil t)
9224 (narrow-to-region (match-end 0) (point-max)))
eec82323
LMI
9225 (gnus-narrow-to-page))))
9226
23f87bed
MB
9227(defun gnus-summary-print-truncate-and-quote (string &optional len)
9228 "Truncate to LEN and quote all \"(\"'s in STRING."
9229 (gnus-replace-in-string (if (and len (> (length string) len))
9230 (substring string 0 len)
9231 string)
9232 "[()]" "\\\\\\&"))
9233
6748645f 9234(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
9235 "Generate and print a PostScript image of the process-marked (mail) articles.
9236
9237If used interactively, print the current article if none are
9238process-marked. With prefix arg, prompt the user for the name of the
9239file to save in.
6748645f 9240
23f87bed
MB
9241When used from Lisp, accept two optional args FILENAME and N. N means
9242to print the next N articles. If N is negative, print the N previous
9243articles. If N is nil and articles have been marked with the process
9244mark, print these instead.
eec82323 9245
16409b0b 9246If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
9247printer. If FILENAME is a string, save the PostScript image in a file with
9248that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 9249to save in."
676a7cc9 9250 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
9251 (dolist (article (gnus-summary-work-articles n))
9252 (gnus-summary-select-article nil nil 'pseudo article)
9253 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 9254 (gnus-print-buffer))
676a7cc9
SZ
9255 (gnus-summary-remove-process-mark article))
9256 (ps-despool filename))
eec82323 9257
23f87bed
MB
9258(defun gnus-print-buffer ()
9259 (let ((buffer (generate-new-buffer " *print*")))
9260 (unwind-protect
9261 (progn
9262 (copy-to-buffer buffer (point-min) (point-max))
9263 (set-buffer buffer)
9264 (gnus-remove-text-with-property 'gnus-decoration)
9265 (when (gnus-visual-p 'article-highlight 'highlight)
9266 ;; Copy-to-buffer doesn't copy overlay. So redo
9267 ;; highlight.
9268 (let ((gnus-article-buffer buffer))
9269 (gnus-article-highlight-citation t)
9270 (gnus-article-highlight-signature)
9271 (gnus-article-emphasize)
9272 (gnus-article-delete-invisible-text)))
9273 (let ((ps-left-header
9274 (list
9275 (concat "("
9276 (gnus-summary-print-truncate-and-quote
9277 (mail-header-subject gnus-current-headers)
9278 66) ")")
9279 (concat "("
9280 (gnus-summary-print-truncate-and-quote
9281 (mail-header-from gnus-current-headers)
9282 45) ")")))
9283 (ps-right-header
9284 (list
9285 "/pagenumberstring load"
9286 (concat "("
9287 (mail-header-date gnus-current-headers) ")"))))
9288 (gnus-run-hooks 'gnus-ps-print-hook)
9289 (save-excursion
9290 (if window-system
9291 (ps-spool-buffer-with-faces)
9292 (ps-spool-buffer)))))
9293 (kill-buffer buffer))))
9294
eec82323 9295(defun gnus-summary-show-article (&optional arg)
23f87bed 9296 "Force redisplaying of the current article.
16409b0b
GM
9297If ARG (the prefix) is a number, show the article with the charset
9298defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 9299input.
16409b0b 9300If ARG (the prefix) is non-nil and not a number, show the raw article
23f87bed
MB
9301without any article massaging functions being run. Normally, the key
9302strokes are `C-u g'."
eec82323 9303 (interactive "P")
16409b0b
GM
9304 (cond
9305 ((numberp arg)
23f87bed 9306 (gnus-summary-show-article t)
16409b0b
GM
9307 (let ((gnus-newsgroup-charset
9308 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
9309 (mm-read-coding-system
9310 "View as charset: " ;; actually it is coding system.
01c52d31 9311 (with-current-buffer gnus-article-buffer
23f87bed 9312 (mm-detect-coding-region (point) (point-max))))))
16409b0b 9313 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
9314 (gnus-summary-select-article nil 'force)
9315 (let ((deps gnus-newsgroup-dependencies)
9316 head header lines)
9317 (save-excursion
9318 (set-buffer gnus-original-article-buffer)
9319 (save-restriction
9320 (message-narrow-to-head)
9321 (setq head (buffer-string))
9322 (goto-char (point-min))
9323 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9324 (goto-char (point-max))
9325 (widen)
9326 (setq lines (1- (count-lines (point) (point-max))))))
9327 (with-temp-buffer
9328 (insert (format "211 %d Article retrieved.\n"
9329 (cdr gnus-article-current)))
9330 (insert head)
9331 (if lines (insert (format "Lines: %d\n" lines)))
9332 (insert ".\n")
9333 (let ((nntp-server-buffer (current-buffer)))
9334 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9335 (gnus-data-set-header
9336 (gnus-data-find (cdr gnus-article-current))
9337 header)
9338 (gnus-summary-update-article-line
9339 (cdr gnus-article-current) header)
9340 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9341 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
9342 ((not arg)
9343 ;; Select the article the normal way.
9344 (gnus-summary-select-article nil 'force))
9345 (t
9346 ;; We have to require this here to make sure that the following
9347 ;; dynamic binding isn't shadowed by autoloading.
9348 (require 'gnus-async)
9349 (require 'gnus-art)
eec82323
LMI
9350 ;; Bind the article treatment functions to nil.
9351 (let ((gnus-have-all-headers t)
eec82323 9352 gnus-article-prepare-hook
16409b0b
GM
9353 gnus-article-decode-hook
9354 gnus-display-mime-function
9355 gnus-break-pages)
9356 ;; Destroy any MIME parts.
9357 (when (gnus-buffer-live-p gnus-article-buffer)
9358 (save-excursion
9359 (set-buffer gnus-article-buffer)
9360 (mm-destroy-parts gnus-article-mime-handles)
9361 ;; Set it to nil for safety reason.
9362 (setq gnus-article-mime-handle-alist nil)
9363 (setq gnus-article-mime-handles nil)))
9364 (gnus-summary-select-article nil 'force))))
eec82323
LMI
9365 (gnus-summary-goto-subject gnus-current-article)
9366 (gnus-summary-position-point))
9367
23f87bed
MB
9368(defun gnus-summary-show-raw-article ()
9369 "Show the raw article without any article massaging functions being run."
9370 (interactive)
9371 (gnus-summary-show-article t))
9372
eec82323
LMI
9373(defun gnus-summary-verbose-headers (&optional arg)
9374 "Toggle permanent full header display.
9375If ARG is a positive number, turn header display on.
9376If ARG is a negative number, turn header display off."
9377 (interactive "P")
eec82323
LMI
9378 (setq gnus-show-all-headers
9379 (cond ((or (not (numberp arg))
9380 (zerop arg))
9381 (not gnus-show-all-headers))
9382 ((natnump arg)
9383 t)))
9384 (gnus-summary-show-article))
9385
9386(defun gnus-summary-toggle-header (&optional arg)
9387 "Show the headers if they are hidden, or hide them if they are shown.
9388If ARG is a positive number, show the entire header.
9389If ARG is a negative number, hide the unwanted header lines."
9390 (interactive "P")
23f87bed
MB
9391 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9392 (get-buffer-window gnus-article-buffer t))))
9393 (with-current-buffer gnus-article-buffer
9394 (widen)
9395 (article-narrow-to-head)
16409b0b
GM
9396 (let* ((buffer-read-only nil)
9397 (inhibit-point-motion-hooks t)
23f87bed
MB
9398 (hidden (if (numberp arg)
9399 (>= arg 0)
f0096211
MB
9400 (or (not (looking-at "[^ \t\n]+:"))
9401 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
9402 s e)
9403 (delete-region (point-min) (point-max))
667e0ba6
SM
9404 (with-current-buffer gnus-original-article-buffer
9405 (goto-char (setq s (point-min)))
23f87bed
MB
9406 (setq e (if (search-forward "\n\n" nil t)
9407 (1- (point))
9408 (point-max))))
667e0ba6 9409 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
9410 (run-hooks 'gnus-article-decode-hook)
9411 (if hidden
9412 (let ((gnus-treat-hide-headers nil)
9413 (gnus-treat-hide-boring-headers nil))
9414 (gnus-delete-wash-type 'headers)
9415 (gnus-treat-article 'head))
9416 (gnus-treat-article 'head))
9417 (widen)
9418 (if window
9419 (set-window-start window (goto-char (point-min))))
9420 (if gnus-break-pages
9421 (gnus-narrow-to-page)
9422 (when (gnus-visual-p 'page-marker)
9423 (let ((buffer-read-only nil))
9424 (gnus-remove-text-with-property 'gnus-prev)
9425 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9426 (gnus-set-mode-line 'article)))))
eec82323
LMI
9427
9428(defun gnus-summary-show-all-headers ()
9429 "Make all header lines visible."
9430 (interactive)
23f87bed 9431 (gnus-summary-toggle-header 1))
eec82323 9432
eec82323
LMI
9433(defun gnus-summary-caesar-message (&optional arg)
9434 "Caesar rotate the current article by 13.
01c52d31
MB
9435With a non-numerical prefix, also rotate headers. A numerical
9436prefix specifies how many places to rotate each letter forward."
eec82323 9437 (interactive "P")
eec82323
LMI
9438 (gnus-summary-select-article)
9439 (let ((mail-header-separator ""))
9440 (gnus-eval-in-buffer-window gnus-article-buffer
9441 (save-restriction
9442 (widen)
9443 (let ((start (window-start))
9444 buffer-read-only)
01c52d31
MB
9445 (if (equal arg '(4))
9446 (message-caesar-buffer-body nil t)
9447 (message-caesar-buffer-body arg))
ff4d3926
MB
9448 (set-window-start (get-buffer-window (current-buffer)) start)))))
9449 ;; Create buttons and stuff...
9450 (gnus-treat-article nil))
eec82323 9451
704f1663
GM
9452(declare-function idna-to-unicode "ext:idna" (str))
9453
01c52d31
MB
9454(defun gnus-summary-idna-message (&optional arg)
9455 "Decode IDNA encoded domain names in the current articles.
9456IDNA encoded domain names looks like `xn--bar'. If a string
9457remain unencoded after running this function, it is likely an
9458invalid IDNA string (`xn--bar' is invalid).
9459
9460You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
9461installed for this command to work."
9462 (interactive "P")
9463 (if (not (and (condition-case nil (require 'idna)
9464 (file-error))
9465 (mm-coding-system-p 'utf-8)
9466 (executable-find (symbol-value 'idna-program))))
9467 (gnus-message
9468 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9469 (gnus-summary-select-article)
9470 (let ((mail-header-separator ""))
9471 (gnus-eval-in-buffer-window gnus-article-buffer
9472 (save-restriction
9473 (widen)
9474 (let ((start (window-start))
9475 buffer-read-only)
9476 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9477 (replace-match (idna-to-unicode (match-string 1))))
9478 (set-window-start (get-buffer-window (current-buffer)) start)))))))
23f87bed
MB
9479
9480(defun gnus-summary-morse-message (&optional arg)
9481 "Morse decode the current article."
9482 (interactive "P")
9483 (gnus-summary-select-article)
9484 (let ((mail-header-separator ""))
9485 (gnus-eval-in-buffer-window gnus-article-buffer
9486 (save-excursion
9487 (save-restriction
9488 (widen)
9489 (let ((pos (window-start))
9490 buffer-read-only)
9491 (goto-char (point-min))
9492 (when (message-goto-body)
9493 (gnus-narrow-to-body))
9494 (goto-char (point-min))
01c52d31 9495