Add declare-function compatibility definition.
[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,
d7a0267c 4;; 2005, 2006, 2007 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
eec82323 1566;; Byte-compiler warning.
23f87bed
MB
1567(eval-when-compile
1568 ;; Bind features so that require will believe that gnus-sum has
1569 ;; already been loaded (avoids infinite recursion)
1570 (let ((features (cons 'gnus-sum features)))
1571 ;; Several of the declarations in gnus-sum are needed to load the
1572 ;; following files. Right now, these definitions have been
1573 ;; compiled but not defined (evaluated). We could either do a
1574 ;; eval-and-compile about all of the declarations or evaluate the
1575 ;; source file.
1576 (if (boundp 'gnus-newsgroup-variables)
1577 nil
1578 (load "gnus-sum.el" t t t))
1579 (require 'gnus)
23f87bed 1580 (require 'gnus-art)))
eec82323 1581
16409b0b
GM
1582;; MIME stuff.
1583
1584(defvar gnus-decode-encoded-word-methods
1585 '(mail-decode-encoded-word-string)
1586 "List of methods used to decode encoded words.
1587
23f87bed
MB
1588This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1589is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1590\(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
16409b0b
GM
1591whose names match REGEXP.
1592
1593For example:
23f87bed 1594\((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
16409b0b
GM
1595 mail-decode-encoded-word-string
1596 (\"chinese\" . rfc1843-decode-string))")
1597
1598(defvar gnus-decode-encoded-word-methods-cache nil)
1599
1600(defun gnus-multi-decode-encoded-word-string (string)
1601 "Apply the functions from `gnus-encoded-word-methods' that match."
1602 (unless (and gnus-decode-encoded-word-methods-cache
1603 (eq gnus-newsgroup-name
1604 (car gnus-decode-encoded-word-methods-cache)))
1605 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
01c52d31
MB
1606 (dolist (method gnus-decode-encoded-word-methods)
1607 (if (symbolp method)
1608 (nconc gnus-decode-encoded-word-methods-cache (list method))
1609 (if (and gnus-newsgroup-name
1610 (string-match (car method) gnus-newsgroup-name))
1611 (nconc gnus-decode-encoded-word-methods-cache
1612 (list (cdr method)))))))
1613 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1614 (setq string (funcall method string))))
16409b0b 1615
eec82323
LMI
1616;; Subject simplification.
1617
6748645f 1618(defun gnus-simplify-whitespace (str)
16409b0b 1619 "Remove excessive whitespace from STR."
23f87bed
MB
1620 ;; Multiple spaces.
1621 (while (string-match "[ \t][ \t]+" str)
1622 (setq str (concat (substring str 0 (match-beginning 0))
1623 " "
1624 (substring str (match-end 0)))))
1625 ;; Leading spaces.
1626 (when (string-match "^[ \t]+" str)
1627 (setq str (substring str (match-end 0))))
1628 ;; Trailing spaces.
1629 (when (string-match "[ \t]+$" str)
1630 (setq str (substring str 0 (match-beginning 0))))
1631 str)
1632
1633(defun gnus-simplify-all-whitespace (str)
1634 "Remove all whitespace from STR."
1635 (while (string-match "[ \t\n]+" str)
1636 (setq str (replace-match "" nil nil str)))
1637 str)
6748645f 1638
eec82323
LMI
1639(defsubst gnus-simplify-subject-re (subject)
1640 "Remove \"Re:\" from subject lines."
23f87bed 1641 (if (string-match message-subject-re-regexp subject)
eec82323
LMI
1642 (substring subject (match-end 0))
1643 subject))
1644
1645(defun gnus-simplify-subject (subject &optional re-only)
1646 "Remove `Re:' and words in parentheses.
1647If RE-ONLY is non-nil, strip leading `Re:'s only."
1648 (let ((case-fold-search t)) ;Ignore case.
1649 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1650 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1651 (setq subject (substring subject (match-end 0))))
1652 ;; Remove uninteresting prefixes.
1653 (when (and (not re-only)
1654 gnus-simplify-ignored-prefixes
1655 (string-match gnus-simplify-ignored-prefixes subject))
1656 (setq subject (substring subject (match-end 0))))
1657 ;; Remove words in parentheses from end.
1658 (unless re-only
1659 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1660 (setq subject (substring subject 0 (match-beginning 0)))))
1661 ;; Return subject string.
1662 subject))
1663
1664;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1665;; all whitespace.
1666(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1667 (goto-char (point-min))
1668 (while (re-search-forward regexp nil t)
16409b0b 1669 (replace-match (or newtext ""))))
eec82323
LMI
1670
1671(defun gnus-simplify-buffer-fuzzy ()
1672 "Simplify string in the buffer fuzzily.
1673The string in the accessible portion of the current buffer is simplified.
1674It is assumed to be a single-line subject.
1675Whitespace is generally cleaned up, and miscellaneous leading/trailing
1676matter is removed. Additional things can be deleted by setting
16409b0b 1677`gnus-simplify-subject-fuzzy-regexp'."
eec82323
LMI
1678 (let ((case-fold-search t)
1679 (modified-tick))
1680 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1681
1682 (while (not (eq modified-tick (buffer-modified-tick)))
1683 (setq modified-tick (buffer-modified-tick))
1684 (cond
1685 ((listp gnus-simplify-subject-fuzzy-regexp)
01c52d31
MB
1686 (mapc 'gnus-simplify-buffer-fuzzy-step
1687 gnus-simplify-subject-fuzzy-regexp))
eec82323
LMI
1688 (gnus-simplify-subject-fuzzy-regexp
1689 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1690 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1691 (gnus-simplify-buffer-fuzzy-step
1692 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1693 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1694
1695 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1696 (gnus-simplify-buffer-fuzzy-step " +" " ")
1697 (gnus-simplify-buffer-fuzzy-step " $")
1698 (gnus-simplify-buffer-fuzzy-step "^ +")))
1699
1700(defun gnus-simplify-subject-fuzzy (subject)
1701 "Simplify a subject string fuzzily.
6748645f 1702See `gnus-simplify-buffer-fuzzy' for details."
eec82323
LMI
1703 (save-excursion
1704 (gnus-set-work-buffer)
1705 (let ((case-fold-search t))
6748645f
LMI
1706 ;; Remove uninteresting prefixes.
1707 (when (and gnus-simplify-ignored-prefixes
1708 (string-match gnus-simplify-ignored-prefixes subject))
1709 (setq subject (substring subject (match-end 0))))
eec82323
LMI
1710 (insert subject)
1711 (inline (gnus-simplify-buffer-fuzzy))
1712 (buffer-string))))
1713
1714(defsubst gnus-simplify-subject-fully (subject)
23f87bed 1715 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
eec82323 1716 (cond
6748645f
LMI
1717 (gnus-simplify-subject-functions
1718 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1719 ((null gnus-summary-gather-subject-limit)
1720 (gnus-simplify-subject-re subject))
1721 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1722 (gnus-simplify-subject-fuzzy subject))
1723 ((numberp gnus-summary-gather-subject-limit)
01c52d31
MB
1724 (truncate-string-to-width (gnus-simplify-subject-re subject)
1725 gnus-summary-gather-subject-limit))
eec82323
LMI
1726 (t
1727 subject)))
1728
1729(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f 1730 "Check whether two subjects are equal.
23f87bed 1731If optional argument SIMPLE-FIRST is t, first argument is already
6748645f 1732simplified."
eec82323
LMI
1733 (cond
1734 ((null simple-first)
1735 (equal (gnus-simplify-subject-fully s1)
1736 (gnus-simplify-subject-fully s2)))
1737 (t
1738 (equal s1
1739 (gnus-simplify-subject-fully s2)))))
1740
1741(defun gnus-summary-bubble-group ()
1742 "Increase the score of the current group.
1743This is a handy function to add to `gnus-summary-exit-hook' to
1744increase the score of each group you read."
1745 (gnus-group-add-score gnus-newsgroup-name))
1746
1747\f
1748;;;
1749;;; Gnus summary mode
1750;;;
1751
1752(put 'gnus-summary-mode 'mode-class 'special)
1753
1653df0f
SZ
1754(defvar gnus-article-commands-menu)
1755
23f87bed
MB
1756;; Non-orthogonal keys
1757
1758(gnus-define-keys gnus-summary-mode-map
1759 " " gnus-summary-next-page
1760 "\177" gnus-summary-prev-page
1761 [delete] gnus-summary-prev-page
1762 [backspace] gnus-summary-prev-page
1763 "\r" gnus-summary-scroll-up
1764 "\M-\r" gnus-summary-scroll-down
1765 "n" gnus-summary-next-unread-article
1766 "p" gnus-summary-prev-unread-article
1767 "N" gnus-summary-next-article
1768 "P" gnus-summary-prev-article
1769 "\M-\C-n" gnus-summary-next-same-subject
1770 "\M-\C-p" gnus-summary-prev-same-subject
1771 "\M-n" gnus-summary-next-unread-subject
1772 "\M-p" gnus-summary-prev-unread-subject
1773 "." gnus-summary-first-unread-article
1774 "," gnus-summary-best-unread-article
1775 "\M-s" gnus-summary-search-article-forward
1776 "\M-r" gnus-summary-search-article-backward
01c52d31
MB
1777 "\M-S" gnus-summary-repeat-search-article-forward
1778 "\M-R" gnus-summary-repeat-search-article-backward
23f87bed
MB
1779 "<" gnus-summary-beginning-of-article
1780 ">" gnus-summary-end-of-article
1781 "j" gnus-summary-goto-article
1782 "^" gnus-summary-refer-parent-article
1783 "\M-^" gnus-summary-refer-article
1784 "u" gnus-summary-tick-article-forward
1785 "!" gnus-summary-tick-article-forward
1786 "U" gnus-summary-tick-article-backward
1787 "d" gnus-summary-mark-as-read-forward
1788 "D" gnus-summary-mark-as-read-backward
1789 "E" gnus-summary-mark-as-expirable
1790 "\M-u" gnus-summary-clear-mark-forward
1791 "\M-U" gnus-summary-clear-mark-backward
1792 "k" gnus-summary-kill-same-subject-and-select
1793 "\C-k" gnus-summary-kill-same-subject
1794 "\M-\C-k" gnus-summary-kill-thread
1795 "\M-\C-l" gnus-summary-lower-thread
1796 "e" gnus-summary-edit-article
1797 "#" gnus-summary-mark-as-processable
1798 "\M-#" gnus-summary-unmark-as-processable
1799 "\M-\C-t" gnus-summary-toggle-threads
1800 "\M-\C-s" gnus-summary-show-thread
1801 "\M-\C-h" gnus-summary-hide-thread
1802 "\M-\C-f" gnus-summary-next-thread
1803 "\M-\C-b" gnus-summary-prev-thread
1804 [(meta down)] gnus-summary-next-thread
1805 [(meta up)] gnus-summary-prev-thread
1806 "\M-\C-u" gnus-summary-up-thread
1807 "\M-\C-d" gnus-summary-down-thread
1808 "&" gnus-summary-execute-command
1809 "c" gnus-summary-catchup-and-exit
1810 "\C-w" gnus-summary-mark-region-as-read
1811 "\C-t" gnus-summary-toggle-truncation
1812 "?" gnus-summary-mark-as-dormant
1813 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1814 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1815 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1816 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1817 "\C-c\C-s\C-a" gnus-summary-sort-by-author
01c52d31 1818 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
23f87bed
MB
1819 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1820 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1821 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1822 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1823 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1824 "=" gnus-summary-expand-window
1825 "\C-x\C-s" gnus-summary-reselect-current-group
1826 "\M-g" gnus-summary-rescan-group
1827 "w" gnus-summary-stop-page-breaking
1828 "\C-c\C-r" gnus-summary-caesar-message
1829 "f" gnus-summary-followup
1830 "F" gnus-summary-followup-with-original
1831 "C" gnus-summary-cancel-article
1832 "r" gnus-summary-reply
1833 "R" gnus-summary-reply-with-original
1834 "\C-c\C-f" gnus-summary-mail-forward
1835 "o" gnus-summary-save-article
1836 "\C-o" gnus-summary-save-article-mail
1837 "|" gnus-summary-pipe-output
1838 "\M-k" gnus-summary-edit-local-kill
1839 "\M-K" gnus-summary-edit-global-kill
1840 ;; "V" gnus-version
1841 "\C-c\C-d" gnus-summary-describe-group
1842 "q" gnus-summary-exit
1843 "Q" gnus-summary-exit-no-update
1844 "\C-c\C-i" gnus-info-find-node
1845 gnus-mouse-2 gnus-mouse-pick-article
132cf96d 1846 [follow-link] mouse-face
23f87bed
MB
1847 "m" gnus-summary-mail-other-window
1848 "a" gnus-summary-post-news
1849 "i" gnus-summary-news-other-window
1850 "x" gnus-summary-limit-to-unread
1851 "s" gnus-summary-isearch-article
1852 "t" gnus-summary-toggle-header
1853 "g" gnus-summary-show-article
1854 "l" gnus-summary-goto-last-article
1855 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1856 "\C-d" gnus-summary-enter-digest-group
1857 "\M-\C-d" gnus-summary-read-document
1858 "\M-\C-e" gnus-summary-edit-parameters
1859 "\M-\C-a" gnus-summary-customize-parameters
1860 "\C-c\C-b" gnus-bug
1861 "*" gnus-cache-enter-article
1862 "\M-*" gnus-cache-remove-article
1863 "\M-&" gnus-summary-universal-argument
1864 "\C-l" gnus-recenter
1865 "I" gnus-summary-increase-score
1866 "L" gnus-summary-lower-score
1867 "\M-i" gnus-symbolic-argument
1868 "h" gnus-summary-select-article-buffer
1869
1870 "b" gnus-article-view-part
1871 "\M-t" gnus-summary-toggle-display-buttonized
1872
1873 "V" gnus-summary-score-map
1874 "X" gnus-uu-extract-map
1875 "S" gnus-summary-send-map)
1876
1877;; Sort of orthogonal keymap
1878(gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1879 "t" gnus-summary-tick-article-forward
1880 "!" gnus-summary-tick-article-forward
1881 "d" gnus-summary-mark-as-read-forward
1882 "r" gnus-summary-mark-as-read-forward
1883 "c" gnus-summary-clear-mark-forward
1884 " " gnus-summary-clear-mark-forward
1885 "e" gnus-summary-mark-as-expirable
1886 "x" gnus-summary-mark-as-expirable
1887 "?" gnus-summary-mark-as-dormant
1888 "b" gnus-summary-set-bookmark
1889 "B" gnus-summary-remove-bookmark
1890 "#" gnus-summary-mark-as-processable
1891 "\M-#" gnus-summary-unmark-as-processable
1892 "S" gnus-summary-limit-include-expunged
1893 "C" gnus-summary-catchup
1894 "H" gnus-summary-catchup-to-here
1895 "h" gnus-summary-catchup-from-here
1896 "\C-c" gnus-summary-catchup-all
1897 "k" gnus-summary-kill-same-subject-and-select
1898 "K" gnus-summary-kill-same-subject
1899 "P" gnus-uu-mark-map)
1900
1901(gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1902 "c" gnus-summary-clear-above
1903 "u" gnus-summary-tick-above
1904 "m" gnus-summary-mark-above
1905 "k" gnus-summary-kill-below)
1906
1907(gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1908 "/" gnus-summary-limit-to-subject
1909 "n" gnus-summary-limit-to-articles
01c52d31
MB
1910 "b" gnus-summary-limit-to-bodies
1911 "h" gnus-summary-limit-to-headers
23f87bed
MB
1912 "w" gnus-summary-pop-limit
1913 "s" gnus-summary-limit-to-subject
1914 "a" gnus-summary-limit-to-author
1915 "u" gnus-summary-limit-to-unread
1916 "m" gnus-summary-limit-to-marks
1917 "M" gnus-summary-limit-exclude-marks
1918 "v" gnus-summary-limit-to-score
1919 "*" gnus-summary-limit-include-cached
1920 "D" gnus-summary-limit-include-dormant
1921 "T" gnus-summary-limit-include-thread
1922 "d" gnus-summary-limit-exclude-dormant
1923 "t" gnus-summary-limit-to-age
1924 "." gnus-summary-limit-to-unseen
1925 "x" gnus-summary-limit-to-extra
1926 "p" gnus-summary-limit-to-display-predicate
1927 "E" gnus-summary-limit-include-expunged
1928 "c" gnus-summary-limit-exclude-childless-dormant
1929 "C" gnus-summary-limit-mark-excluded-as-read
1930 "o" gnus-summary-insert-old-articles
01c52d31
MB
1931 "N" gnus-summary-insert-new-articles
1932 "S" gnus-summary-limit-to-singletons
1933 "r" gnus-summary-limit-to-replied
1934 "R" gnus-summary-limit-to-recipient
1935 "A" gnus-summary-limit-to-address)
23f87bed
MB
1936
1937(gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1938 "n" gnus-summary-next-unread-article
1939 "p" gnus-summary-prev-unread-article
1940 "N" gnus-summary-next-article
1941 "P" gnus-summary-prev-article
1942 "\C-n" gnus-summary-next-same-subject
1943 "\C-p" gnus-summary-prev-same-subject
1944 "\M-n" gnus-summary-next-unread-subject
1945 "\M-p" gnus-summary-prev-unread-subject
1946 "f" gnus-summary-first-unread-article
1947 "b" gnus-summary-best-unread-article
1948 "j" gnus-summary-goto-article
1949 "g" gnus-summary-goto-subject
1950 "l" gnus-summary-goto-last-article
1951 "o" gnus-summary-pop-article)
1952
1953(gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1954 "k" gnus-summary-kill-thread
01c52d31 1955 "E" gnus-summary-expire-thread
23f87bed
MB
1956 "l" gnus-summary-lower-thread
1957 "i" gnus-summary-raise-thread
1958 "T" gnus-summary-toggle-threads
1959 "t" gnus-summary-rethread-current
1960 "^" gnus-summary-reparent-thread
01c52d31 1961 "\M-^" gnus-summary-reparent-children
23f87bed
MB
1962 "s" gnus-summary-show-thread
1963 "S" gnus-summary-show-all-threads
1964 "h" gnus-summary-hide-thread
1965 "H" gnus-summary-hide-all-threads
1966 "n" gnus-summary-next-thread
1967 "p" gnus-summary-prev-thread
1968 "u" gnus-summary-up-thread
1969 "o" gnus-summary-top-thread
1970 "d" gnus-summary-down-thread
1971 "#" gnus-uu-mark-thread
1972 "\M-#" gnus-uu-unmark-thread)
1973
1974(gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1975 "g" gnus-summary-prepare
1976 "c" gnus-summary-insert-cached-articles
01c52d31
MB
1977 "d" gnus-summary-insert-dormant-articles
1978 "t" gnus-summary-insert-ticked-articles)
23f87bed
MB
1979
1980(gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1981 "c" gnus-summary-catchup-and-exit
1982 "C" gnus-summary-catchup-all-and-exit
1983 "E" gnus-summary-exit-no-update
1984 "Q" gnus-summary-exit
1985 "Z" gnus-summary-exit
1986 "n" gnus-summary-catchup-and-goto-next-group
01c52d31 1987 "p" gnus-summary-catchup-and-goto-prev-group
23f87bed
MB
1988 "R" gnus-summary-reselect-current-group
1989 "G" gnus-summary-rescan-group
1990 "N" gnus-summary-next-group
1991 "s" gnus-summary-save-newsrc
1992 "P" gnus-summary-prev-group)
1993
1994(gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1995 " " gnus-summary-next-page
1996 "n" gnus-summary-next-page
1997 "\177" gnus-summary-prev-page
1998 [delete] gnus-summary-prev-page
1999 "p" gnus-summary-prev-page
2000 "\r" gnus-summary-scroll-up
2001 "\M-\r" gnus-summary-scroll-down
2002 "<" gnus-summary-beginning-of-article
2003 ">" gnus-summary-end-of-article
2004 "b" gnus-summary-beginning-of-article
2005 "e" gnus-summary-end-of-article
2006 "^" gnus-summary-refer-parent-article
2007 "r" gnus-summary-refer-parent-article
2008 "D" gnus-summary-enter-digest-group
2009 "R" gnus-summary-refer-references
2010 "T" gnus-summary-refer-thread
2011 "g" gnus-summary-show-article
2012 "s" gnus-summary-isearch-article
2013 "P" gnus-summary-print-article
01c52d31 2014 "S" gnus-sticky-article
23f87bed
MB
2015 "M" gnus-mailing-list-insinuate
2016 "t" gnus-article-babel)
2017
2018(gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2019 "b" gnus-article-add-buttons
2020 "B" gnus-article-add-buttons-to-head
2021 "o" gnus-article-treat-overstrike
2022 "e" gnus-article-emphasize
2023 "w" gnus-article-fill-cited-article
2024 "Q" gnus-article-fill-long-lines
01c52d31 2025 "L" gnus-article-toggle-truncate-lines
23f87bed
MB
2026 "C" gnus-article-capitalize-sentences
2027 "c" gnus-article-remove-cr
2028 "q" gnus-article-de-quoted-unreadable
2029 "6" gnus-article-de-base64-unreadable
2030 "Z" gnus-article-decode-HZ
01c52d31 2031 "A" gnus-article-treat-ansi-sequences
23f87bed
MB
2032 "h" gnus-article-wash-html
2033 "u" gnus-article-unsplit-urls
2034 "s" gnus-summary-force-verify-and-decrypt
2035 "f" gnus-article-display-x-face
2036 "l" gnus-summary-stop-page-breaking
2037 "r" gnus-summary-caesar-message
2038 "m" gnus-summary-morse-message
2039 "t" gnus-summary-toggle-header
2040 "g" gnus-treat-smiley
2041 "v" gnus-summary-verbose-headers
2042 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2043 "p" gnus-article-verify-x-pgp-sig
01c52d31
MB
2044 "d" gnus-article-treat-dumbquotes
2045 "i" gnus-summary-idna-message)
23f87bed
MB
2046
2047(gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2048 ;; mnemonic: deuglif*Y*
2049 "u" gnus-article-outlook-unwrap-lines
2050 "a" gnus-article-outlook-repair-attribution
2051 "c" gnus-article-outlook-rearrange-citation
2052 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2053
2054(gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2055 "a" gnus-article-hide
2056 "h" gnus-article-hide-headers
2057 "b" gnus-article-hide-boring-headers
2058 "s" gnus-article-hide-signature
2059 "c" gnus-article-hide-citation
2060 "C" gnus-article-hide-citation-in-followups
2061 "l" gnus-article-hide-list-identifiers
2062 "B" gnus-article-strip-banner
2063 "P" gnus-article-hide-pem
2064 "\C-c" gnus-article-hide-citation-maybe)
2065
2066(gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2067 "a" gnus-article-highlight
2068 "h" gnus-article-highlight-headers
2069 "c" gnus-article-highlight-citation
2070 "s" gnus-article-highlight-signature)
2071
2072(gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2073 "f" gnus-article-treat-fold-headers
2074 "u" gnus-article-treat-unfold-headers
2075 "n" gnus-article-treat-fold-newsgroups)
2076
2077(gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2078 "x" gnus-article-display-x-face
2079 "d" gnus-article-display-face
2080 "s" gnus-treat-smiley
2081 "D" gnus-article-remove-images
2082 "f" gnus-treat-from-picon
2083 "m" gnus-treat-mail-picon
2084 "n" gnus-treat-newsgroups-picon)
2085
2086(gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2087 "w" gnus-article-decode-mime-words
2088 "c" gnus-article-decode-charset
2089 "v" gnus-mime-view-all-parts
2090 "b" gnus-article-view-part)
2091
2092(gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2093 "z" gnus-article-date-ut
2094 "u" gnus-article-date-ut
2095 "l" gnus-article-date-local
2096 "p" gnus-article-date-english
2097 "e" gnus-article-date-lapsed
2098 "o" gnus-article-date-original
2099 "i" gnus-article-date-iso8601
2100 "s" gnus-article-date-user)
2101
2102(gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2103 "t" gnus-article-remove-trailing-blank-lines
2104 "l" gnus-article-strip-leading-blank-lines
2105 "m" gnus-article-strip-multiple-blank-lines
2106 "a" gnus-article-strip-blank-lines
2107 "A" gnus-article-strip-all-blank-lines
2108 "s" gnus-article-strip-leading-space
2109 "e" gnus-article-strip-trailing-space
2110 "w" gnus-article-remove-leading-whitespace)
2111
2112(gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2113 "v" gnus-version
2114 "f" gnus-summary-fetch-faq
2115 "d" gnus-summary-describe-group
2116 "h" gnus-summary-describe-briefly
2117 "i" gnus-info-find-node
2118 "c" gnus-group-fetch-charter
2119 "C" gnus-group-fetch-control)
2120
2121(gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2122 "e" gnus-summary-expire-articles
2123 "\M-\C-e" gnus-summary-expire-articles-now
2124 "\177" gnus-summary-delete-article
2125 [delete] gnus-summary-delete-article
2126 [backspace] gnus-summary-delete-article
2127 "m" gnus-summary-move-article
2128 "r" gnus-summary-respool-article
2129 "w" gnus-summary-edit-article
2130 "c" gnus-summary-copy-article
2131 "B" gnus-summary-crosspost-article
2132 "q" gnus-summary-respool-query
2133 "t" gnus-summary-respool-trace
2134 "i" gnus-summary-import-article
2135 "I" gnus-summary-create-article
2136 "p" gnus-summary-article-posted-p)
2137
2138(gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2139 "o" gnus-summary-save-article
2140 "m" gnus-summary-save-article-mail
2141 "F" gnus-summary-write-article-file
2142 "r" gnus-summary-save-article-rmail
2143 "f" gnus-summary-save-article-file
2144 "b" gnus-summary-save-article-body-file
26c9afc3 2145 "B" gnus-summary-write-article-body-file
23f87bed
MB
2146 "h" gnus-summary-save-article-folder
2147 "v" gnus-summary-save-article-vm
2148 "p" gnus-summary-pipe-output
2149 "P" gnus-summary-muttprint
2150 "s" gnus-soup-add-article)
2151
2152(gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2153 "b" gnus-summary-display-buttonized
2154 "m" gnus-summary-repair-multipart
2155 "v" gnus-article-view-part
2156 "o" gnus-article-save-part
01c52d31
MB
2157 "O" gnus-article-save-part-and-strip
2158 "r" gnus-article-replace-part
2159 "d" gnus-article-delete-part
2160 "t" gnus-article-view-part-as-type
2161 "j" gnus-article-jump-to-part
23f87bed
MB
2162 "c" gnus-article-copy-part
2163 "C" gnus-article-view-part-as-charset
2164 "e" gnus-article-view-part-externally
01c52d31 2165 "H" gnus-article-browse-html-article
23f87bed
MB
2166 "E" gnus-article-encrypt-body
2167 "i" gnus-article-inline-part
2168 "|" gnus-article-pipe-part)
2169
2170(gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2171 "p" gnus-summary-mark-as-processable
2172 "u" gnus-summary-unmark-as-processable
2173 "U" gnus-summary-unmark-all-processable
2174 "v" gnus-uu-mark-over
2175 "s" gnus-uu-mark-series
2176 "r" gnus-uu-mark-region
2177 "g" gnus-uu-unmark-region
2178 "R" gnus-uu-mark-by-regexp
2179 "G" gnus-uu-unmark-by-regexp
2180 "t" gnus-uu-mark-thread
2181 "T" gnus-uu-unmark-thread
2182 "a" gnus-uu-mark-all
2183 "b" gnus-uu-mark-buffer
2184 "S" gnus-uu-mark-sparse
2185 "k" gnus-summary-kill-process-mark
2186 "y" gnus-summary-yank-process-mark
2187 "w" gnus-summary-save-process-mark
2188 "i" gnus-uu-invert-processable)
2189
2190(gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2191 ;;"x" gnus-uu-extract-any
2192 "m" gnus-summary-save-parts
2193 "u" gnus-uu-decode-uu
2194 "U" gnus-uu-decode-uu-and-save
2195 "s" gnus-uu-decode-unshar
2196 "S" gnus-uu-decode-unshar-and-save
2197 "o" gnus-uu-decode-save
2198 "O" gnus-uu-decode-save
2199 "b" gnus-uu-decode-binhex
2200 "B" gnus-uu-decode-binhex
b890d447 2201 "Y" gnus-uu-decode-yenc
23f87bed
MB
2202 "p" gnus-uu-decode-postscript
2203 "P" gnus-uu-decode-postscript-and-save)
2204
2205(gnus-define-keys
2206 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2207 "u" gnus-uu-decode-uu-view
2208 "U" gnus-uu-decode-uu-and-save-view
2209 "s" gnus-uu-decode-unshar-view
2210 "S" gnus-uu-decode-unshar-and-save-view
2211 "o" gnus-uu-decode-save-view
2212 "O" gnus-uu-decode-save-view
2213 "b" gnus-uu-decode-binhex-view
2214 "B" gnus-uu-decode-binhex-view
2215 "p" gnus-uu-decode-postscript-view
2216 "P" gnus-uu-decode-postscript-and-save-view)
2217
2218(defvar gnus-article-post-menu nil)
2219
2220(defconst gnus-summary-menu-maxlen 20)
2221
2222(defun gnus-summary-menu-split (menu)
2223 ;; If we have lots of elements, divide them into groups of 20
2224 ;; and make a pane (or submenu) for each one.
2225 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2226 (let ((menu menu) sublists next
2227 (i 1))
2228 (while menu
2229 ;; Pull off the next gnus-summary-menu-maxlen elements
2230 ;; and make them the next element of sublist.
2231 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2232 (if next
2233 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2234 nil))
2235 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2236 (aref (car (last menu)) 0)) menu)
2237 sublists))
2238 (setq i (1+ i))
2239 (setq menu next))
2240 (nreverse sublists))
2241 ;; Few elements--put them all in one pane.
2242 menu))
eec82323
LMI
2243
2244(defun gnus-summary-make-menu-bar ()
2245 (gnus-turn-off-edit-menu 'summary)
2246
2247 (unless (boundp 'gnus-summary-misc-menu)
2248
2249 (easy-menu-define
23f87bed
MB
2250 gnus-summary-kill-menu gnus-summary-mode-map ""
2251 (cons
2252 "Score"
2253 (nconc
2254 (list
2255 ["Customize" gnus-score-customize t])
2256 (gnus-make-score-map 'increase)
2257 (gnus-make-score-map 'lower)
2258 '(("Mark"
2259 ["Kill below" gnus-summary-kill-below t]
2260 ["Mark above" gnus-summary-mark-above t]
2261 ["Tick above" gnus-summary-tick-above t]
2262 ["Clear above" gnus-summary-clear-above t])
2263 ["Current score" gnus-summary-current-score t]
2264 ["Set score" gnus-summary-set-score t]
2265 ["Switch current score file..." gnus-score-change-score-file t]
2266 ["Set mark below..." gnus-score-set-mark-below t]
2267 ["Set expunge below..." gnus-score-set-expunge-below t]
2268 ["Edit current score file" gnus-score-edit-current-scores t]
2269 ["Edit score file" gnus-score-edit-file t]
2270 ["Trace score" gnus-score-find-trace t]
2271 ["Find words" gnus-score-find-favourite-words t]
2272 ["Rescore buffer" gnus-summary-rescore t]
2273 ["Increase score..." gnus-summary-increase-score t]
2274 ["Lower score..." gnus-summary-lower-score t]))))
2275
2276 ;; Define both the Article menu in the summary buffer and the
2277 ;; equivalent Commands menu in the article buffer here for
2278 ;; consistency.
6748645f 2279 (let ((innards
23f87bed
MB
2280 `(("Hide"
2281 ["All" gnus-article-hide t]
2282 ["Headers" gnus-article-hide-headers t]
2283 ["Signature" gnus-article-hide-signature t]
2284 ["Citation" gnus-article-hide-citation t]
16409b0b 2285 ["List identifiers" gnus-article-hide-list-identifiers t]
16409b0b 2286 ["Banner" gnus-article-strip-banner t]
23f87bed
MB
2287 ["Boring headers" gnus-article-hide-boring-headers t])
2288 ("Highlight"
2289 ["All" gnus-article-highlight t]
2290 ["Headers" gnus-article-highlight-headers t]
2291 ["Signature" gnus-article-highlight-signature t]
2292 ["Citation" gnus-article-highlight-citation t])
16409b0b
GM
2293 ("MIME"
2294 ["Words" gnus-article-decode-mime-words t]
2295 ["Charset" gnus-article-decode-charset t]
2296 ["QP" gnus-article-de-quoted-unreadable t]
2297 ["Base64" gnus-article-de-base64-unreadable t]
23f87bed
MB
2298 ["View MIME buttons" gnus-summary-display-buttonized t]
2299 ["View all" gnus-mime-view-all-parts t]
2300 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2301 ["Encrypt body" gnus-article-encrypt-body
2302 :active (not (gnus-group-read-only-p))
2303 ,@(if (featurep 'xemacs) nil
2304 '(:help "Encrypt the message body on disk"))]
2305 ["Extract all parts..." gnus-summary-save-parts t]
2306 ("Multipart"
2307 ["Repair multipart" gnus-summary-repair-multipart t]
2308 ["Pipe part..." gnus-article-pipe-part t]
2309 ["Inline part" gnus-article-inline-part t]
01c52d31 2310 ["View part as type..." gnus-article-view-part-as-type t]
23f87bed
MB
2311 ["Encrypt body" gnus-article-encrypt-body
2312 :active (not (gnus-group-read-only-p))
2313 ,@(if (featurep 'xemacs) nil
2314 '(:help "Encrypt the message body on disk"))]
2315 ["View part externally" gnus-article-view-part-externally t]
01c52d31 2316 ["View HTML parts in browser" gnus-article-browse-html-article t]
23f87bed
MB
2317 ["View part with charset..." gnus-article-view-part-as-charset t]
2318 ["Copy part" gnus-article-copy-part t]
2319 ["Save part..." gnus-article-save-part t]
2320 ["View part" gnus-article-view-part t]))
2321 ("Date"
2322 ["Local" gnus-article-date-local t]
2323 ["ISO8601" gnus-article-date-iso8601 t]
2324 ["UT" gnus-article-date-ut t]
2325 ["Original" gnus-article-date-original t]
2326 ["Lapsed" gnus-article-date-lapsed t]
2327 ["User-defined" gnus-article-date-user t])
2328 ("Display"
2329 ["Remove images" gnus-article-remove-images t]
2330 ["Toggle smiley" gnus-treat-smiley t]
2331 ["Show X-Face" gnus-article-display-x-face t]
2332 ["Show picons in From" gnus-treat-from-picon t]
2333 ["Show picons in mail headers" gnus-treat-mail-picon t]
2334 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2335 ("View as different encoding"
2336 ,@(gnus-summary-menu-split
2337 (mapcar
2338 (lambda (cs)
2339 ;; Since easymenu under Emacs doesn't allow
2340 ;; lambda forms for menu commands, we should
2341 ;; provide intern'ed function symbols.
2342 (let ((command (intern (format "\
2343gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2344 (fset command
2345 `(lambda ()
2346 (interactive)
2347 (let ((gnus-summary-show-article-charset-alist
2348 '((1 . ,cs))))
2349 (gnus-summary-show-article 1))))
2350 `[,(symbol-name cs) ,command t]))
2351 (sort (if (fboundp 'coding-system-list)
2352 (coding-system-list)
2353 (mapcar 'car mm-mime-mule-charset-alist))
2354 'string<)))))
2355 ("Washing"
2356 ("Remove Blanks"
2357 ["Leading" gnus-article-strip-leading-blank-lines t]
2358 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2359 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2360 ["All of the above" gnus-article-strip-blank-lines t]
2361 ["All" gnus-article-strip-all-blank-lines t]
2362 ["Leading space" gnus-article-strip-leading-space t]
2363 ["Trailing space" gnus-article-strip-trailing-space t]
2364 ["Leading space in headers"
2365 gnus-article-remove-leading-whitespace t])
2366 ["Overstrike" gnus-article-treat-overstrike t]
2367 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2368 ["Emphasis" gnus-article-emphasize t]
2369 ["Word wrap" gnus-article-fill-cited-article t]
16409b0b 2370 ["Fill long lines" gnus-article-fill-long-lines t]
01c52d31 2371 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
16409b0b 2372 ["Capitalize sentences" gnus-article-capitalize-sentences t]
23f87bed
MB
2373 ["Remove CR" gnus-article-remove-cr t]
2374 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2375 ["Base64" gnus-article-de-base64-unreadable t]
2376 ["Rot 13" gnus-summary-caesar-message
2377 ,@(if (featurep 'xemacs) '(t)
2378 '(:help "\"Caesar rotate\" article by 13"))]
01c52d31 2379 ["De-IDNA" gnus-summary-idna-message t]
23f87bed
MB
2380 ["Morse decode" gnus-summary-morse-message t]
2381 ["Unix pipe..." gnus-summary-pipe-message t]
2382 ["Add buttons" gnus-article-add-buttons t]
2383 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2384 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2385 ["Verbose header" gnus-summary-verbose-headers t]
2386 ["Toggle header" gnus-summary-toggle-header t]
2387 ["Unfold headers" gnus-article-treat-unfold-headers t]
2388 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
16409b0b 2389 ["Html" gnus-article-wash-html t]
23f87bed
MB
2390 ["Unsplit URLs" gnus-article-unsplit-urls t]
2391 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2392 ["Decode HZ" gnus-article-decode-HZ t]
01c52d31 2393 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
23f87bed
MB
2394 ("(Outlook) Deuglify"
2395 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2396 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2397 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2398 ["Full (Outlook) deuglify"
2399 gnus-article-outlook-deuglify-article t])
2400 )
2401 ("Output"
2402 ["Save in default format..." gnus-summary-save-article
2403 ,@(if (featurep 'xemacs) '(t)
2404 '(:help "Save article using default method"))]
2405 ["Save in file..." gnus-summary-save-article-file
2406 ,@(if (featurep 'xemacs) '(t)
2407 '(:help "Save article in file"))]
2408 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2409 ["Save in MH folder..." gnus-summary-save-article-folder t]
2410 ["Save in VM folder..." gnus-summary-save-article-vm t]
2411 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2412 ["Save body in file..." gnus-summary-save-article-body-file t]
2413 ["Pipe through a filter..." gnus-summary-pipe-output t]
2414 ["Add to SOUP packet" gnus-soup-add-article t]
2415 ["Print with Muttprint..." gnus-summary-muttprint t]
531e5812
MB
2416 ["Print" gnus-summary-print-article
2417 ,@(if (featurep 'xemacs) '(t)
2418 '(:help "Generate and print a PostScript image"))])
2419 ("Copy, move,... (Backend)"
707f2b38 2420 ,@(if (featurep 'xemacs) nil
531e5812 2421 '(:help "Copying, moving, expiring articles..."))
23f87bed
MB
2422 ["Respool article..." gnus-summary-respool-article t]
2423 ["Move article..." gnus-summary-move-article
2424 (gnus-check-backend-function
2425 'request-move-article gnus-newsgroup-name)]
2426 ["Copy article..." gnus-summary-copy-article t]
2427 ["Crosspost article..." gnus-summary-crosspost-article
2428 (gnus-check-backend-function
2429 'request-replace-article gnus-newsgroup-name)]
2430 ["Import file..." gnus-summary-import-article
2431 (gnus-check-backend-function
2432 'request-accept-article gnus-newsgroup-name)]
2433 ["Create article..." gnus-summary-create-article
2434 (gnus-check-backend-function
2435 'request-accept-article gnus-newsgroup-name)]
2436 ["Check if posted" gnus-summary-article-posted-p t]
2437 ["Edit article" gnus-summary-edit-article
2438 (not (gnus-group-read-only-p))]
2439 ["Delete article" gnus-summary-delete-article
2440 (gnus-check-backend-function
2441 'request-expire-articles gnus-newsgroup-name)]
2442 ["Query respool" gnus-summary-respool-query t]
6748645f 2443 ["Trace respool" gnus-summary-respool-trace t]
23f87bed
MB
2444 ["Delete expirable articles" gnus-summary-expire-articles-now
2445 (gnus-check-backend-function
2446 'request-expire-articles gnus-newsgroup-name)])
2447 ("Extract"
2448 ["Uudecode" gnus-uu-decode-uu
2449 ,@(if (featurep 'xemacs) '(t)
2450 '(:help "Decode uuencoded article(s)"))]
2451 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2452 ["Unshar" gnus-uu-decode-unshar t]
2453 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2454 ["Save" gnus-uu-decode-save t]
2455 ["Binhex" gnus-uu-decode-binhex t]
2456 ["Postscript" gnus-uu-decode-postscript t]
2457 ["All MIME parts" gnus-summary-save-parts t])
2458 ("Cache"
2459 ["Enter article" gnus-cache-enter-article t]
2460 ["Remove article" gnus-cache-remove-article t])
16409b0b 2461 ["Translate" gnus-article-babel t]
23f87bed 2462 ["Select article buffer" gnus-summary-select-article-buffer t]
01c52d31 2463 ["Make article buffer sticky" gnus-sticky-article t]
23f87bed
MB
2464 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2465 ["Isearch article..." gnus-summary-isearch-article t]
2466 ["Beginning of the article" gnus-summary-beginning-of-article t]
2467 ["End of the article" gnus-summary-end-of-article t]
2468 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2469 ["Fetch referenced articles" gnus-summary-refer-references t]
2470 ["Fetch current thread" gnus-summary-refer-thread t]
2471 ["Fetch article with id..." gnus-summary-refer-article t]
2472 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2473 ["Redisplay" gnus-summary-show-article t]
2474 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
6748645f 2475 (easy-menu-define
23f87bed
MB
2476 gnus-summary-article-menu gnus-summary-mode-map ""
2477 (cons "Article" innards))
6748645f 2478
1653df0f
SZ
2479 (if (not (keymapp gnus-summary-article-menu))
2480 (easy-menu-define
2481 gnus-article-commands-menu gnus-article-mode-map ""
2482 (cons "Commands" innards))
2483 ;; in Emacs, don't share menu.
a1506d29 2484 (setq gnus-article-commands-menu
1653df0f
SZ
2485 (copy-keymap gnus-summary-article-menu))
2486 (define-key gnus-article-mode-map [menu-bar commands]
2487 (cons "Commands" gnus-article-commands-menu))))
eec82323
LMI
2488
2489 (easy-menu-define
23f87bed
MB
2490 gnus-summary-thread-menu gnus-summary-mode-map ""
2491 '("Threads"
2492 ["Find all messages in thread" gnus-summary-refer-thread t]
2493 ["Toggle threading" gnus-summary-toggle-threads t]
2494 ["Hide threads" gnus-summary-hide-all-threads t]
2495 ["Show threads" gnus-summary-show-all-threads t]
2496 ["Hide thread" gnus-summary-hide-thread t]
2497 ["Show thread" gnus-summary-show-thread t]
2498 ["Go to next thread" gnus-summary-next-thread t]
2499 ["Go to previous thread" gnus-summary-prev-thread t]
2500 ["Go down thread" gnus-summary-down-thread t]
2501 ["Go up thread" gnus-summary-up-thread t]
2502 ["Top of thread" gnus-summary-top-thread t]
2503 ["Mark thread as read" gnus-summary-kill-thread t]
01c52d31 2504 ["Mark thread as expired" gnus-summary-expire-thread t]
23f87bed
MB
2505 ["Lower thread score" gnus-summary-lower-thread t]
2506 ["Raise thread score" gnus-summary-raise-thread t]
2507 ["Rethread current" gnus-summary-rethread-current t]))
eec82323
LMI
2508
2509 (easy-menu-define
23f87bed
MB
2510 gnus-summary-post-menu gnus-summary-mode-map ""
2511 `("Post"
2512 ["Send a message (mail or news)" gnus-summary-post-news
2513 ,@(if (featurep 'xemacs) '(t)
531e5812 2514 '(:help "Compose a new message (mail or news)"))]
23f87bed
MB
2515 ["Followup" gnus-summary-followup
2516 ,@(if (featurep 'xemacs) '(t)
2517 '(:help "Post followup to this article"))]
2518 ["Followup and yank" gnus-summary-followup-with-original
2519 ,@(if (featurep 'xemacs) '(t)
2520 '(:help "Post followup to this article, quoting its contents"))]
2521 ["Supersede article" gnus-summary-supersede-article t]
2522 ["Cancel article" gnus-summary-cancel-article
2523 ,@(if (featurep 'xemacs) '(t)
2524 '(:help "Cancel an article you posted"))]
2525 ["Reply" gnus-summary-reply t]
2526 ["Reply and yank" gnus-summary-reply-with-original t]
2527 ["Wide reply" gnus-summary-wide-reply t]
2528 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2529 ,@(if (featurep 'xemacs) '(t)
2530 '(:help "Mail a reply, quoting this article"))]
2531 ["Very wide reply" gnus-summary-very-wide-reply t]
2532 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2533 ,@(if (featurep 'xemacs) '(t)
2534 '(:help "Mail a very wide reply, quoting this article"))]
2535 ["Mail forward" gnus-summary-mail-forward t]
2536 ["Post forward" gnus-summary-post-forward t]
2537 ["Digest and mail" gnus-uu-digest-mail-forward t]
2538 ["Digest and post" gnus-uu-digest-post-forward t]
2539 ["Resend message" gnus-summary-resend-message t]
2540 ["Resend message edit" gnus-summary-resend-message-edit t]
2541 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2542 ["Send a mail" gnus-summary-mail-other-window t]
2543 ["Create a local message" gnus-summary-news-other-window t]
2544 ["Uuencode and post" gnus-uu-post-news
2545 ,@(if (featurep 'xemacs) '(t)
2546 '(:help "Post a uuencoded article"))]
2547 ["Followup via news" gnus-summary-followup-to-mail t]
2548 ["Followup via news and yank"
2549 gnus-summary-followup-to-mail-with-original t]
2550 ;;("Draft"
2551 ;;["Send" gnus-summary-send-draft t]
2552 ;;["Send bounced" gnus-resend-bounced-mail t])
2553 ))
2554
2555 (cond
2556 ((not (keymapp gnus-summary-post-menu))
2557 (setq gnus-article-post-menu gnus-summary-post-menu))
2558 ((not gnus-article-post-menu)
2559 ;; Don't share post menu.
2560 (setq gnus-article-post-menu
2561 (copy-keymap gnus-summary-post-menu))))
2562 (define-key gnus-article-mode-map [menu-bar post]
2563 (cons "Post" gnus-article-post-menu))
eec82323
LMI
2564
2565 (easy-menu-define
23f87bed
MB
2566 gnus-summary-misc-menu gnus-summary-mode-map ""
2567 `("Gnus"
2568 ("Mark Read"
2569 ["Mark as read" gnus-summary-mark-as-read-forward t]
2570 ["Mark same subject and select"
2571 gnus-summary-kill-same-subject-and-select t]
2572 ["Mark same subject" gnus-summary-kill-same-subject t]
2573 ["Catchup" gnus-summary-catchup
2574 ,@(if (featurep 'xemacs) '(t)
2575 '(:help "Mark unread articles in this group as read"))]
2576 ["Catchup all" gnus-summary-catchup-all t]
2577 ["Catchup to here" gnus-summary-catchup-to-here t]
2578 ["Catchup from here" gnus-summary-catchup-from-here t]
2579 ["Catchup region" gnus-summary-mark-region-as-read
2580 (gnus-mark-active-p)]
2581 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2582 ("Mark Various"
2583 ["Tick" gnus-summary-tick-article-forward t]
2584 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2585 ["Remove marks" gnus-summary-clear-mark-forward t]
2586 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2587 ["Set bookmark" gnus-summary-set-bookmark t]
2588 ["Remove bookmark" gnus-summary-remove-bookmark t])
2589 ("Limit to"
2590 ["Marks..." gnus-summary-limit-to-marks t]
2591 ["Subject..." gnus-summary-limit-to-subject t]
2592 ["Author..." gnus-summary-limit-to-author t]
01c52d31
MB
2593 ["Recipient..." gnus-summary-limit-to-recipient t]
2594 ["Address..." gnus-summary-limit-to-address t]
23f87bed
MB
2595 ["Age..." gnus-summary-limit-to-age t]
2596 ["Extra..." gnus-summary-limit-to-extra t]
2597 ["Score..." gnus-summary-limit-to-score t]
2598 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2599 ["Unread" gnus-summary-limit-to-unread t]
2600 ["Unseen" gnus-summary-limit-to-unseen t]
01c52d31
MB
2601 ["Singletons" gnus-summary-limit-to-singletons t]
2602 ["Replied" gnus-summary-limit-to-replied t]
23f87bed 2603 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
996aa8c1 2604 ["Next or process marked articles" gnus-summary-limit-to-articles t]
23f87bed
MB
2605 ["Pop limit" gnus-summary-pop-limit t]
2606 ["Show dormant" gnus-summary-limit-include-dormant t]
2607 ["Hide childless dormant"
2608 gnus-summary-limit-exclude-childless-dormant t]
2609 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2610 ["Hide marked" gnus-summary-limit-exclude-marks t]
2611 ["Show expunged" gnus-summary-limit-include-expunged t])
2612 ("Process Mark"
2613 ["Set mark" gnus-summary-mark-as-processable t]
2614 ["Remove mark" gnus-summary-unmark-as-processable t]
2615 ["Remove all marks" gnus-summary-unmark-all-processable t]
01c52d31 2616 ["Invert marks" gnus-uu-invert-processable t]
23f87bed
MB
2617 ["Mark above" gnus-uu-mark-over t]
2618 ["Mark series" gnus-uu-mark-series t]
2619 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2620 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2621 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2622 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2623 ["Mark all" gnus-uu-mark-all t]
2624 ["Mark buffer" gnus-uu-mark-buffer t]
2625 ["Mark sparse" gnus-uu-mark-sparse t]
2626 ["Mark thread" gnus-uu-mark-thread t]
2627 ["Unmark thread" gnus-uu-unmark-thread t]
2628 ("Process Mark Sets"
2629 ["Kill" gnus-summary-kill-process-mark t]
2630 ["Yank" gnus-summary-yank-process-mark
2631 gnus-newsgroup-process-stack]
2632 ["Save" gnus-summary-save-process-mark t]
2633 ["Run command on marked..." gnus-summary-universal-argument t]))
2634 ("Scroll article"
2635 ["Page forward" gnus-summary-next-page
2636 ,@(if (featurep 'xemacs) '(t)
2637 '(:help "Show next page of article"))]
2638 ["Page backward" gnus-summary-prev-page
2639 ,@(if (featurep 'xemacs) '(t)
2640 '(:help "Show previous page of article"))]
2641 ["Line forward" gnus-summary-scroll-up t])
2642 ("Move"
2643 ["Next unread article" gnus-summary-next-unread-article t]
2644 ["Previous unread article" gnus-summary-prev-unread-article t]
2645 ["Next article" gnus-summary-next-article t]
2646 ["Previous article" gnus-summary-prev-article t]
2647 ["Next unread subject" gnus-summary-next-unread-subject t]
2648 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2649 ["Next article same subject" gnus-summary-next-same-subject t]
2650 ["Previous article same subject" gnus-summary-prev-same-subject t]
2651 ["First unread article" gnus-summary-first-unread-article t]
2652 ["Best unread article" gnus-summary-best-unread-article t]
2653 ["Go to subject number..." gnus-summary-goto-subject t]
2654 ["Go to article number..." gnus-summary-goto-article t]
2655 ["Go to the last article" gnus-summary-goto-last-article t]
2656 ["Pop article off history" gnus-summary-pop-article t])
2657 ("Sort"
2658 ["Sort by number" gnus-summary-sort-by-number t]
2659 ["Sort by author" gnus-summary-sort-by-author t]
01c52d31 2660 ["Sort by recipient" gnus-summary-sort-by-recipient t]
23f87bed
MB
2661 ["Sort by subject" gnus-summary-sort-by-subject t]
2662 ["Sort by date" gnus-summary-sort-by-date t]
2663 ["Sort by score" gnus-summary-sort-by-score t]
2664 ["Sort by lines" gnus-summary-sort-by-lines t]
2665 ["Sort by characters" gnus-summary-sort-by-chars t]
2666 ["Randomize" gnus-summary-sort-by-random t]
2667 ["Original sort" gnus-summary-sort-by-original t])
2668 ("Help"
2669 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2670 ["Describe group" gnus-summary-describe-group t]
2671 ["Fetch charter" gnus-group-fetch-charter
2672 ,@(if (featurep 'xemacs) nil
2673 '(:help "Display the charter of the current group"))]
2674 ["Fetch control message" gnus-group-fetch-control
2675 ,@(if (featurep 'xemacs) nil
2676 '(:help "Display the archived control message for the current group"))]
2677 ["Read manual" gnus-info-find-node t])
2678 ("Modes"
2679 ["Pick and read" gnus-pick-mode t]
2680 ["Binary" gnus-binary-mode t])
2681 ("Regeneration"
2682 ["Regenerate" gnus-summary-prepare t]
2683 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2684 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
01c52d31 2685 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
23f87bed
MB
2686 ["Toggle threading" gnus-summary-toggle-threads t])
2687 ["See old articles" gnus-summary-insert-old-articles t]
2688 ["See new articles" gnus-summary-insert-new-articles t]
2689 ["Filter articles..." gnus-summary-execute-command t]
2690 ["Run command on articles..." gnus-summary-universal-argument t]
2691 ["Search articles forward..." gnus-summary-search-article-forward t]
2692 ["Search articles backward..." gnus-summary-search-article-backward t]
2693 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2694 ["Expand window" gnus-summary-expand-window t]
2695 ["Expire expirable articles" gnus-summary-expire-articles
2696 (gnus-check-backend-function
2697 'request-expire-articles gnus-newsgroup-name)]
2698 ["Edit local kill file" gnus-summary-edit-local-kill t]
2699 ["Edit main kill file" gnus-summary-edit-global-kill t]
2700 ["Edit group parameters" gnus-summary-edit-parameters t]
2701 ["Customize group parameters" gnus-summary-customize-parameters t]
2702 ["Send a bug report" gnus-bug t]
2703 ("Exit"
2704 ["Catchup and exit" gnus-summary-catchup-and-exit
2705 ,@(if (featurep 'xemacs) '(t)
2706 '(:help "Mark unread articles in this group as read, then exit"))]
2707 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2708 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
01c52d31 2709 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
23f87bed
MB
2710 ["Exit group" gnus-summary-exit
2711 ,@(if (featurep 'xemacs) '(t)
2712 '(:help "Exit current group, return to group selection mode"))]
2713 ["Exit group without updating" gnus-summary-exit-no-update t]
2714 ["Exit and goto next group" gnus-summary-next-group t]
2715 ["Exit and goto prev group" gnus-summary-prev-group t]
2716 ["Reselect group" gnus-summary-reselect-current-group t]
2717 ["Rescan group" gnus-summary-rescan-group t]
2718 ["Update dribble" gnus-summary-save-newsrc t])))
eec82323 2719
6748645f 2720 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323 2721
60bd5589
DL
2722(defvar gnus-summary-tool-bar-map nil)
2723
18c06a99
RS
2724;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2725;; affect _new_ message buffers. We might add a function that walks thru all
2726;; summary-mode buffers and force the update.
2727(defun gnus-summary-tool-bar-update (&optional symbol value)
2728 "Update summary mode toolbar.
2729Setter function for custom variables."
2730 (setq-default gnus-summary-tool-bar-map nil)
2731 (when symbol
2732 ;; When used as ":set" function:
2733 (set-default symbol value))
2734 (when (gnus-buffer-live-p gnus-summary-buffer)
2735 (with-current-buffer gnus-summary-buffer
2736 (gnus-summary-make-tool-bar))))
2737
2738(defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2739 'gnus-summary-tool-bar-gnome
2740 'gnus-summary-tool-bar-retro)
2741 "Specifies the Gnus summary tool bar.
2742
2743It can be either a list or a symbol refering to a list. See
2744`gmm-tool-bar-from-list' for the format of the list. The
2745default key map is `gnus-summary-mode-map'.
2746
2747Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2748`gnus-summary-tool-bar-retro'."
2749 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2750 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2751 (repeat :tag "User defined list" gmm-tool-bar-item)
2752 (symbol))
01c52d31 2753 :version "23.0" ;; No Gnus
18c06a99
RS
2754 :initialize 'custom-initialize-default
2755 :set 'gnus-summary-tool-bar-update
2756 :group 'gnus-summary)
2757
2758(defcustom gnus-summary-tool-bar-gnome
2759 '((gnus-summary-post-news "mail/compose" nil)
2760 (gnus-summary-insert-new-articles "mail/inbox" nil
2761 :visible (or (not gnus-agent)
2762 gnus-plugged))
2763 (gnus-summary-reply-with-original "mail/reply")
2764 (gnus-summary-reply "mail/reply" nil :visible nil)
2765 (gnus-summary-followup-with-original "mail/reply-all")
2766 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2767 (gnus-summary-mail-forward "mail/forward")
2768 (gnus-summary-save-article "mail/save")
2769 (gnus-summary-search-article-forward "search" nil :visible nil)
2770 (gnus-summary-print-article "print")
2771 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2772 ;; Some new commands that may need more suitable icons:
2773 (gnus-summary-save-newsrc "save" nil :visible nil)
2774 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2775 (gnus-summary-prev-article "left-arrow")
2776 (gnus-summary-next-article "right-arrow")
2777 (gnus-summary-next-page "next-page")
2778 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2779 ;;
2780 ;; Maybe some sort-by-... could be added:
2781 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2782 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2783 (gnus-summary-mark-as-expirable
2784 "delete" nil
2785 :visible (gnus-check-backend-function 'request-expire-articles
2786 gnus-newsgroup-name))
2787 (gnus-summary-mark-as-spam
2788 "mail/spam" t
2789 :visible (and (fboundp 'spam-group-ham-contents-p)
2790 (spam-group-ham-contents-p gnus-newsgroup-name))
2791 :help "Mark as spam")
2792 (gnus-summary-mark-as-read-forward
2793 "mail/not-spam" nil
2794 :visible (and (fboundp 'spam-group-spam-contents-p)
2795 (spam-group-spam-contents-p gnus-newsgroup-name)))
2796 ;;
2797 (gnus-summary-exit "exit")
2798 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2799 (gnus-info-find-node "help"))
2800 "List of functions for the summary tool bar (GNOME style).
2801
2802See `gmm-tool-bar-from-list' for the format of the list."
2803 :type '(repeat gmm-tool-bar-item)
01c52d31 2804 :version "23.0" ;; No Gnus
18c06a99
RS
2805 :initialize 'custom-initialize-default
2806 :set 'gnus-summary-tool-bar-update
2807 :group 'gnus-summary)
2808
2809(defcustom gnus-summary-tool-bar-retro
2810 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2811 (gnus-summary-next-unread-article "gnus/next-ur")
2812 (gnus-summary-post-news "gnus/post")
2813 (gnus-summary-followup-with-original "gnus/fuwo")
2814 (gnus-summary-followup "gnus/followup")
2815 (gnus-summary-reply-with-original "gnus/reply-wo")
2816 (gnus-summary-reply "gnus/reply")
2817 (gnus-summary-caesar-message "gnus/rot13")
2818 (gnus-uu-decode-uu "gnus/uu-decode")
2819 (gnus-summary-save-article-file "gnus/save-aif")
2820 (gnus-summary-save-article "gnus/save-art")
2821 (gnus-uu-post-news "gnus/uu-post")
2822 (gnus-summary-catchup "gnus/catchup")
2823 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2824 (gnus-summary-exit "gnus/exit-summ")
2825 ;; Some new command that may need more suitable icons:
2826 (gnus-summary-print-article "gnus/print" nil :visible nil)
2827 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2828 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2829 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2830 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2831 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2832 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2833 ;;
2834 (gnus-info-find-node "gnus/help" nil :visible nil))
2835 "List of functions for the summary tool bar (retro look).
2836
2837See `gmm-tool-bar-from-list' for the format of the list."
2838 :type '(repeat gmm-tool-bar-item)
01c52d31 2839 :version "23.0" ;; No Gnus
18c06a99
RS
2840 :initialize 'custom-initialize-default
2841 :set 'gnus-summary-tool-bar-update
2842 :group 'gnus-summary)
2843
2844(defcustom gnus-summary-tool-bar-zap-list t
2845 "List of icon items from the global tool bar.
2846These items are not displayed in the Gnus summary mode tool bar.
2847
2848See `gmm-tool-bar-from-list' for the format of the list."
2849 :type 'gmm-tool-bar-zap-list
01c52d31 2850 :version "23.0" ;; No Gnus
18c06a99
RS
2851 :initialize 'custom-initialize-default
2852 :set 'gnus-summary-tool-bar-update
2853 :group 'gnus-summary)
2854
2855(defvar image-load-path)
2856
2857(defun gnus-summary-make-tool-bar (&optional force)
2858 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2859When FORCE, rebuild the tool bar."
2860 (when (and (not (featurep 'xemacs))
2861 (boundp 'tool-bar-mode)
2862 tool-bar-mode
2863 (or (not gnus-summary-tool-bar-map) force))
2864 (let* ((load-path
2865 (gmm-image-load-path-for-library "gnus"
2866 "mail/save.xpm"
2867 nil t))
2868 (image-load-path (cons (car load-path)
2869 (when (boundp 'image-load-path)
2870 image-load-path)))
2871 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2872 gnus-summary-tool-bar-zap-list
2873 'gnus-summary-mode-map)))
2874 (when map
2875 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2876 ;; uses it's value.
2877 (setq gnus-summary-tool-bar-map map))))
2878 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
60bd5589 2879
eec82323
LMI
2880(defun gnus-score-set-default (var value)
2881 "A version of set that updates the GNU Emacs menu-bar."
2882 (set var value)
2883 ;; It is the message that forces the active status to be updated.
2884 (message ""))
2885
2886(defun gnus-make-score-map (type)
2887 "Make a summary score map of type TYPE."
2888 (if t
2889 nil
2890 (let ((headers '(("author" "from" string)
2891 ("subject" "subject" string)
2892 ("article body" "body" string)
2893 ("article head" "head" string)
2894 ("xref" "xref" string)
16409b0b 2895 ("extra header" "extra" string)
eec82323
LMI
2896 ("lines" "lines" number)
2897 ("followups to author" "followup" string)))
2898 (types '((number ("less than" <)
2899 ("greater than" >)
2900 ("equal" =))
2901 (string ("substring" s)
2902 ("exact string" e)
2903 ("fuzzy string" f)
2904 ("regexp" r))))
2905 (perms '(("temporary" (current-time-string))
2906 ("permanent" nil)
2907 ("immediate" now)))
2908 header)
2909 (list
2910 (apply
2911 'nconc
2912 (list
2913 (if (eq type 'lower)
2914 "Lower score"
2915 "Increase score"))
2916 (let (outh)
2917 (while headers
2918 (setq header (car headers))
2919 (setq outh
2920 (cons
2921 (apply
2922 'nconc
2923 (list (car header))
2924 (let ((ts (cdr (assoc (nth 2 header) types)))
2925 outt)
2926 (while ts
2927 (setq outt
2928 (cons
2929 (apply
2930 'nconc
2931 (list (caar ts))
2932 (let ((ps perms)
2933 outp)
2934 (while ps
2935 (setq outp
2936 (cons
2937 (vector
2938 (caar ps)
2939 (list
2940 'gnus-summary-score-entry
2941 (nth 1 header)
2942 (if (or (string= (nth 1 header)
2943 "head")
2944 (string= (nth 1 header)
2945 "body"))
2946 ""
2947 (list 'gnus-summary-header
2948 (nth 1 header)))
2949 (list 'quote (nth 1 (car ts)))
16409b0b
GM
2950 (list 'gnus-score-delta-default
2951 nil)
eec82323
LMI
2952 (nth 1 (car ps))
2953 t)
2954 t)
2955 outp))
2956 (setq ps (cdr ps)))
2957 (list (nreverse outp))))
2958 outt))
2959 (setq ts (cdr ts)))
2960 (list (nreverse outt))))
2961 outh))
2962 (setq headers (cdr headers)))
2963 (list (nreverse outh))))))))
2964
2965\f
2966
2967(defun gnus-summary-mode (&optional group)
2968 "Major mode for reading articles.
2969
2970All normal editing commands are switched off.
2971\\<gnus-summary-mode-map>
2972Each line in this buffer represents one article. To read an
2973article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2974and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2975respectively.
2976
2977You can also post articles and send mail from this buffer. To
23f87bed 2978follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
eec82323
LMI
2979of an article, type `\\[gnus-summary-reply]'.
2980
2981There are approx. one gazillion commands you can execute in this
2982buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2983
2984The following commands are available:
2985
2986\\{gnus-summary-mode-map}"
2987 (interactive)
eec82323 2988 (kill-all-local-variables)
01c52d31
MB
2989 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2990 (gnus-summary-make-local-variables))
2991 (gnus-summary-make-local-variables)
2992 (setq gnus-newsgroup-name group)
60bd5589
DL
2993 (when (gnus-visual-p 'summary-menu 'menu)
2994 (gnus-summary-make-menu-bar)
2995 (gnus-summary-make-tool-bar))
eec82323
LMI
2996 (gnus-make-thread-indent-array)
2997 (gnus-simplify-mode-line)
2998 (setq major-mode 'gnus-summary-mode)
2999 (setq mode-name "Summary")
3000 (make-local-variable 'minor-mode-alist)
3001 (use-local-map gnus-summary-mode-map)
16409b0b 3002 (buffer-disable-undo)
01c52d31
MB
3003 (setq buffer-read-only t ;Disable modification
3004 show-trailing-whitespace nil)
eec82323
LMI
3005 (setq truncate-lines t)
3006 (setq selective-display t)
3007 (setq selective-display-ellipses t) ;Display `...'
3008 (gnus-summary-set-display-table)
3009 (gnus-set-default-directory)
eec82323
LMI
3010 (make-local-variable 'gnus-summary-line-format)
3011 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
3012 (make-local-variable 'gnus-summary-dummy-line-format)
3013 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323 3014 (make-local-variable 'gnus-summary-mark-positions)
23f87bed 3015 (gnus-make-local-hook 'pre-command-hook)
6748645f 3016 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
cfcd5c91 3017 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
23f87bed 3018 (turn-on-gnus-mailing-list-mode)
87545352 3019 (mm-enable-multibyte)
eec82323
LMI
3020 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3021 (gnus-update-summary-mark-positions))
3022
3023(defun gnus-summary-make-local-variables ()
3024 "Make all the local summary buffer variables."
16409b0b
GM
3025 (let (global)
3026 (dolist (local gnus-summary-local-variables)
eec82323
LMI
3027 (if (consp local)
3028 (progn
3029 (if (eq (cdr local) 'global)
3030 ;; Copy the global value of the variable.
3031 (setq global (symbol-value (car local)))
3032 ;; Use the value from the list.
3033 (setq global (eval (cdr local))))
16409b0b 3034 (set (make-local-variable (car local)) global))
eec82323 3035 ;; Simple nil-valued local variable.
16409b0b 3036 (set (make-local-variable local) nil)))))
eec82323
LMI
3037
3038(defun gnus-summary-clear-local-variables ()
3039 (let ((locals gnus-summary-local-variables))
3040 (while locals
3041 (if (consp (car locals))
01c52d31 3042 (and (symbolp (caar locals))
eec82323 3043 (set (caar locals) nil))
01c52d31 3044 (and (symbolp (car locals))
eec82323
LMI
3045 (set (car locals) nil)))
3046 (setq locals (cdr locals)))))
3047
3048;; Summary data functions.
3049
3050(defmacro gnus-data-number (data)
3051 `(car ,data))
3052
3053(defmacro gnus-data-set-number (data number)
3054 `(setcar ,data ,number))
3055
3056(defmacro gnus-data-mark (data)
3057 `(nth 1 ,data))
3058
3059(defmacro gnus-data-set-mark (data mark)
3060 `(setcar (nthcdr 1 ,data) ,mark))
3061
3062(defmacro gnus-data-pos (data)
3063 `(nth 2 ,data))
3064
3065(defmacro gnus-data-set-pos (data pos)
3066 `(setcar (nthcdr 2 ,data) ,pos))
3067
3068(defmacro gnus-data-header (data)
3069 `(nth 3 ,data))
3070
3071(defmacro gnus-data-set-header (data header)
3072 `(setf (nth 3 ,data) ,header))
3073
3074(defmacro gnus-data-level (data)
3075 `(nth 4 ,data))
3076
3077(defmacro gnus-data-unread-p (data)
3078 `(= (nth 1 ,data) gnus-unread-mark))
3079
3080(defmacro gnus-data-read-p (data)
3081 `(/= (nth 1 ,data) gnus-unread-mark))
3082
3083(defmacro gnus-data-pseudo-p (data)
3084 `(consp (nth 3 ,data)))
3085
3086(defmacro gnus-data-find (number)
3087 `(assq ,number gnus-newsgroup-data))
3088
3089(defmacro gnus-data-find-list (number &optional data)
3090 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3091 (memq (assq ,number bdata)
3092 bdata)))
3093
3094(defmacro gnus-data-make (number mark pos header level)
3095 `(list ,number ,mark ,pos ,header ,level))
3096
3097(defun gnus-data-enter (after-article number mark pos header level offset)
3098 (let ((data (gnus-data-find-list after-article)))
3099 (unless data
3100 (error "No such article: %d" after-article))
3101 (setcdr data (cons (gnus-data-make number mark pos header level)
3102 (cdr data)))
3103 (setq gnus-newsgroup-data-reverse nil)
3104 (gnus-data-update-list (cddr data) offset)))
3105
3106(defun gnus-data-enter-list (after-article list &optional offset)
3107 (when list
3108 (let ((data (and after-article (gnus-data-find-list after-article)))
3109 (ilist list))
6748645f
LMI
3110 (if (not (or data
3111 after-article))
3112 (let ((odata gnus-newsgroup-data))
3113 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 3114 (when offset
6748645f 3115 (gnus-data-update-list odata offset)))
01c52d31 3116 ;; Find the last element in the list to be spliced into the main
6748645f 3117 ;; list.
01c52d31 3118 (setq list (last list))
6748645f
LMI
3119 (if (not data)
3120 (progn
3121 (setcdr list gnus-newsgroup-data)
3122 (setq gnus-newsgroup-data ilist)
3123 (when offset
3124 (gnus-data-update-list (cdr list) offset)))
3125 (setcdr list (cdr data))
3126 (setcdr data ilist)
3127 (when offset
3128 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
3129 (setq gnus-newsgroup-data-reverse nil))))
3130
3131(defun gnus-data-remove (article &optional offset)
3132 (let ((data gnus-newsgroup-data))
3133 (if (= (gnus-data-number (car data)) article)
3134 (progn
3135 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3136 gnus-newsgroup-data-reverse nil)
3137 (when offset
3138 (gnus-data-update-list gnus-newsgroup-data offset)))
3139 (while (cdr data)
3140 (when (= (gnus-data-number (cadr data)) article)
3141 (setcdr data (cddr data))
3142 (when offset
3143 (gnus-data-update-list (cdr data) offset))
3144 (setq data nil
3145 gnus-newsgroup-data-reverse nil))
3146 (setq data (cdr data))))))
3147
3148(defmacro gnus-data-list (backward)
3149 `(if ,backward
3150 (or gnus-newsgroup-data-reverse
3151 (setq gnus-newsgroup-data-reverse
3152 (reverse gnus-newsgroup-data)))
3153 gnus-newsgroup-data))
3154
3155(defun gnus-data-update-list (data offset)
3156 "Add OFFSET to the POS of all data entries in DATA."
6748645f 3157 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
3158 (while data
3159 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3160 (setq data (cdr data))))
3161
eec82323
LMI
3162(defun gnus-summary-article-pseudo-p (article)
3163 "Say whether this article is a pseudo article or not."
3164 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3165
3166(defmacro gnus-summary-article-sparse-p (article)
3167 "Say whether this article is a sparse article or not."
a8151ef7 3168 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
3169
3170(defmacro gnus-summary-article-ancient-p (article)
3171 "Say whether this article is a sparse article or not."
3172 `(memq ,article gnus-newsgroup-ancient))
3173
3174(defun gnus-article-parent-p (number)
3175 "Say whether this article is a parent or not."
3176 (let ((data (gnus-data-find-list number)))
23f87bed 3177 (and (cdr data) ; There has to be an article after...
eec82323
LMI
3178 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3179 (gnus-data-level (nth 1 data))))))
3180
3181(defun gnus-article-children (number)
3182 "Return a list of all children to NUMBER."
3183 (let* ((data (gnus-data-find-list number))
3184 (level (gnus-data-level (car data)))
3185 children)
3186 (setq data (cdr data))
3187 (while (and data
3188 (= (gnus-data-level (car data)) (1+ level)))
3189 (push (gnus-data-number (car data)) children)
3190 (setq data (cdr data)))
3191 children))
3192
3193(defmacro gnus-summary-skip-intangible ()
3194 "If the current article is intangible, then jump to a different article."
3195 '(let ((to (get-text-property (point) 'gnus-intangible)))
3196 (and to (gnus-summary-goto-subject to))))
3197
3198(defmacro gnus-summary-article-intangible-p ()
3199 "Say whether this article is intangible or not."
3200 '(get-text-property (point) 'gnus-intangible))
3201
3202(defun gnus-article-read-p (article)
3203 "Say whether ARTICLE is read or not."
3204 (not (or (memq article gnus-newsgroup-marked)
23f87bed 3205 (memq article gnus-newsgroup-spam-marked)
eec82323
LMI
3206 (memq article gnus-newsgroup-unreads)
3207 (memq article gnus-newsgroup-unselected)
3208 (memq article gnus-newsgroup-dormant))))
3209
3210;; Some summary mode macros.
3211
3212(defmacro gnus-summary-article-number ()
3213 "The article number of the article on the current line.
8f688cb0 3214If there isn't an article number here, then we return the current
eec82323
LMI
3215article number."
3216 '(progn
3217 (gnus-summary-skip-intangible)
3218 (or (get-text-property (point) 'gnus-number)
3219 (gnus-summary-last-subject))))
3220
3221(defmacro gnus-summary-article-header (&optional number)
6748645f 3222 "Return the header of article NUMBER."
eec82323
LMI
3223 `(gnus-data-header (gnus-data-find
3224 ,(or number '(gnus-summary-article-number)))))
3225
3226(defmacro gnus-summary-thread-level (&optional number)
6748645f 3227 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
3228 `(if (and (eq gnus-summary-make-false-root 'dummy)
3229 (get-text-property (point) 'gnus-intangible))
3230 0
3231 (gnus-data-level (gnus-data-find
3232 ,(or number '(gnus-summary-article-number))))))
3233
3234(defmacro gnus-summary-article-mark (&optional number)
6748645f 3235 "Return the mark of article NUMBER."
eec82323
LMI
3236 `(gnus-data-mark (gnus-data-find
3237 ,(or number '(gnus-summary-article-number)))))
3238
3239(defmacro gnus-summary-article-pos (&optional number)
6748645f 3240 "Return the position of the line of article NUMBER."
eec82323
LMI
3241 `(gnus-data-pos (gnus-data-find
3242 ,(or number '(gnus-summary-article-number)))))
3243
3244(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3245(defmacro gnus-summary-article-subject (&optional number)
3246 "Return current subject string or nil if nothing."
3247 `(let ((headers
3248 ,(if number
3249 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3250 '(gnus-data-header (assq (gnus-summary-article-number)
3251 gnus-newsgroup-data)))))
3252 (and headers
3253 (vectorp headers)
3254 (mail-header-subject headers))))
3255
3256(defmacro gnus-summary-article-score (&optional number)
3257 "Return current article score."
3258 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3259 gnus-newsgroup-scored))
3260 gnus-summary-default-score 0))
3261
3262(defun gnus-summary-article-children (&optional number)
6748645f 3263 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
3264 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3265 (level (gnus-data-level (car data)))
3266 l children)
3267 (while (and (setq data (cdr data))
3268 (> (setq l (gnus-data-level (car data))) level))
3269 (and (= (1+ level) l)
3270 (push (gnus-data-number (car data))
3271 children)))
3272 (nreverse children)))
3273
3274(defun gnus-summary-article-parent (&optional number)
6748645f 3275 "Return the article number of the parent of article NUMBER."
eec82323
LMI
3276 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3277 (gnus-data-list t)))
3278 (level (gnus-data-level (car data))))
3279 (if (zerop level)
3280 () ; This is a root.
3281 ;; We search until we find an article with a level less than
3282 ;; this one. That function has to be the parent.
3283 (while (and (setq data (cdr data))
3284 (not (< (gnus-data-level (car data)) level))))
3285 (and data (gnus-data-number (car data))))))
3286
3287(defun gnus-unread-mark-p (mark)
3288 "Say whether MARK is the unread mark."
3289 (= mark gnus-unread-mark))
3290
3291(defun gnus-read-mark-p (mark)
3292 "Say whether MARK is one of the marks that mark as read.
3293This is all marks except unread, ticked, dormant, and expirable."
3294 (not (or (= mark gnus-unread-mark)
3295 (= mark gnus-ticked-mark)
23f87bed 3296 (= mark gnus-spam-mark)
eec82323
LMI
3297 (= mark gnus-dormant-mark)
3298 (= mark gnus-expirable-mark))))
3299
3300(defmacro gnus-article-mark (number)
6748645f
LMI
3301 "Return the MARK of article NUMBER.
3302This macro should only be used when computing the mark the \"first\"
3303time; i.e., when generating the summary lines. After that,
3304`gnus-summary-article-mark' should be used to examine the
3305marks of articles."
eec82323 3306 `(cond
6748645f 3307 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
6748645f 3308 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
3309 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3310 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
23f87bed 3311 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
eec82323
LMI
3312 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3313 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3314 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3315 gnus-ancient-mark))))
3316
3317;; Saving hidden threads.
3318
eec82323
LMI
3319(defmacro gnus-save-hidden-threads (&rest forms)
3320 "Save hidden threads, eval FORMS, and restore the hidden threads."
3321 (let ((config (make-symbol "config")))
3322 `(let ((,config (gnus-hidden-threads-configuration)))
3323 (unwind-protect
3324 (save-excursion
3325 ,@forms)
3326 (gnus-restore-hidden-threads-configuration ,config)))))
23f87bed
MB
3327(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3328(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
eec82323 3329
107ecebb
AS
3330(defun gnus-data-compute-positions ()
3331 "Compute the positions of all articles."
3332 (setq gnus-newsgroup-data-reverse nil)
3333 (let ((data gnus-newsgroup-data))
3334 (save-excursion
3335 (gnus-save-hidden-threads
3336 (gnus-summary-show-all-threads)
3337 (goto-char (point-min))
3338 (while data
3339 (while (get-text-property (point) 'gnus-intangible)
3340 (forward-line 1))
3341 (gnus-data-set-pos (car data) (+ (point) 3))
3342 (setq data (cdr data))
3343 (forward-line 1))))))
3344
16409b0b
GM
3345(defun gnus-hidden-threads-configuration ()
3346 "Return the current hidden threads configuration."
3347 (save-excursion
3348 (let (config)
3349 (goto-char (point-min))
3350 (while (search-forward "\r" nil t)
3351 (push (1- (point)) config))
3352 config)))
3353
3354(defun gnus-restore-hidden-threads-configuration (config)
3355 "Restore hidden threads configuration from CONFIG."
3356 (save-excursion
3357 (let (point buffer-read-only)
3358 (while (setq point (pop config))
3359 (when (and (< point (point-max))
3360 (goto-char point)
3361 (eq (char-after) ?\n))
3362 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3363
eec82323
LMI
3364;; Various summary mode internalish functions.
3365
3366(defun gnus-mouse-pick-article (e)
3367 (interactive "e")
3368 (mouse-set-point e)
3369 (gnus-summary-next-page nil t))
3370
3371(defun gnus-summary-set-display-table ()
16409b0b
GM
3372 "Change the display table.
3373Odd characters have a tendency to mess
3374up nicely formatted displays - we make all possible glyphs
3375display only a single character."
eec82323
LMI
3376
3377 ;; We start from the standard display table, if any.
3378 (let ((table (or (copy-sequence standard-display-table)
3379 (make-display-table)))
3380 (i 32))
3381 ;; Nix out all the control chars...
3382 (while (>= (setq i (1- i)) 0)
3383 (aset table i [??]))
23f87bed 3384 ;; ... but not newline and cr, of course. (cr is necessary for the
eec82323
LMI
3385 ;; selective display).
3386 (aset table ?\n nil)
3387 (aset table ?\r nil)
6748645f
LMI
3388 ;; We keep TAB as well.
3389 (aset table ?\t nil)
719120ef 3390 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
fe62aacc 3391 ;; Emacs 23 (unicode), that are not set already.
719120ef
MB
3392 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3393 160
3394 256)))
eec82323
LMI
3395 (while (>= (setq i (1- i)) 127)
3396 ;; Only modify if the entry is nil.
3397 (unless (aref table i)
3398 (aset table i [??]))))
3399 (setq buffer-display-table table)))
3400
23f87bed
MB
3401(defun gnus-summary-set-article-display-arrow (pos)
3402 "Update the overlay arrow to point to line at position POS."
3403 (when (and gnus-summary-display-arrow
3404 (boundp 'overlay-arrow-position)
3405 (boundp 'overlay-arrow-string))
3406 (save-excursion
3407 (goto-char pos)
3408 (beginning-of-line)
3409 (unless overlay-arrow-position
3410 (setq overlay-arrow-position (make-marker)))
3411 (setq overlay-arrow-string "=>"
3412 overlay-arrow-position (set-marker overlay-arrow-position
3413 (point)
3414 (current-buffer))))))
3415
eec82323
LMI
3416(defun gnus-summary-setup-buffer (group)
3417 "Initialize summary buffer."
23f87bed
MB
3418 (let ((buffer (gnus-summary-buffer-name group))
3419 (dead-name (concat "*Dead Summary "
3420 (gnus-group-decoded-name group) "*")))
3421 ;; If a dead summary buffer exists, we kill it.
3422 (when (gnus-buffer-live-p dead-name)
3423 (gnus-kill-buffer dead-name))
eec82323
LMI
3424 (if (get-buffer buffer)
3425 (progn
3426 (set-buffer buffer)
3427 (setq gnus-summary-buffer (current-buffer))
3428 (not gnus-newsgroup-prepared))
3429 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 3430 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323
LMI
3431 (gnus-summary-mode group)
3432 (when gnus-carpal
3433 (gnus-carpal-setup-buffer 'summary))
01c52d31
MB
3434 (when (gnus-group-quit-config group)
3435 (set (make-local-variable 'gnus-single-article-buffer) nil))
3436 (make-local-variable 'gnus-article-buffer)
3437 (make-local-variable 'gnus-article-current)
3438 (make-local-variable 'gnus-original-article-buffer)
eec82323 3439 (setq gnus-newsgroup-name group)
23f87bed
MB
3440 ;; Set any local variables in the group parameters.
3441 (gnus-summary-set-local-parameters gnus-newsgroup-name)
eec82323
LMI
3442 t)))
3443
3444(defun gnus-set-global-variables ()
16409b0b
GM
3445 "Set the global equivalents of the buffer-local variables.
3446They are set to the latest values they had. These reflect the summary
3447buffer that was in action when the last article was fetched."
eec82323
LMI
3448 (when (eq major-mode 'gnus-summary-mode)
3449 (setq gnus-summary-buffer (current-buffer))
3450 (let ((name gnus-newsgroup-name)
3451 (marked gnus-newsgroup-marked)
23f87bed 3452 (spam gnus-newsgroup-spam-marked)
eec82323
LMI
3453 (unread gnus-newsgroup-unreads)
3454 (headers gnus-current-headers)
3455 (data gnus-newsgroup-data)
3456 (summary gnus-summary-buffer)
3457 (article-buffer gnus-article-buffer)
3458 (original gnus-original-article-buffer)
3459 (gac gnus-article-current)
3460 (reffed gnus-reffed-article-number)
16409b0b 3461 (score-file gnus-current-score-file)
23f87bed
MB
3462 (default-charset gnus-newsgroup-charset)
3463 vlist)
3464 (let ((locals gnus-newsgroup-variables))
3465 (while locals
3466 (if (consp (car locals))
3467 (push (eval (caar locals)) vlist)
3468 (push (eval (car locals)) vlist))
3469 (setq locals (cdr locals)))
3470 (setq vlist (nreverse vlist)))
01c52d31 3471 (with-current-buffer gnus-group-buffer
6748645f
LMI
3472 (setq gnus-newsgroup-name name
3473 gnus-newsgroup-marked marked
23f87bed 3474 gnus-newsgroup-spam-marked spam
6748645f
LMI
3475 gnus-newsgroup-unreads unread
3476 gnus-current-headers headers
3477 gnus-newsgroup-data data
3478 gnus-article-current gac
3479 gnus-summary-buffer summary
3480 gnus-article-buffer article-buffer
3481 gnus-original-article-buffer original
3482 gnus-reffed-article-number reffed
16409b0b
GM
3483 gnus-current-score-file score-file
3484 gnus-newsgroup-charset default-charset)
23f87bed
MB
3485 (let ((locals gnus-newsgroup-variables))
3486 (while locals
3487 (if (consp (car locals))
3488 (set (caar locals) (pop vlist))
3489 (set (car locals) (pop vlist)))
3490 (setq locals (cdr locals))))
eec82323
LMI
3491 ;; The article buffer also has local variables.
3492 (when (gnus-buffer-live-p gnus-article-buffer)
3493 (set-buffer gnus-article-buffer)
3494 (setq gnus-summary-buffer summary))))))
3495
3496(defun gnus-summary-article-unread-p (article)
3497 "Say whether ARTICLE is unread or not."
3498 (memq article gnus-newsgroup-unreads))
3499
3500(defun gnus-summary-first-article-p (&optional article)
3501 "Return whether ARTICLE is the first article in the buffer."
3502 (if (not (setq article (or article (gnus-summary-article-number))))
3503 nil
3504 (eq article (caar gnus-newsgroup-data))))
3505
3506(defun gnus-summary-last-article-p (&optional article)
3507 "Return whether ARTICLE is the last article in the buffer."
3508 (if (not (setq article (or article (gnus-summary-article-number))))
16409b0b
GM
3509 ;; All non-existent numbers are the last article. :-)
3510 t
eec82323
LMI
3511 (not (cdr (gnus-data-find-list article)))))
3512
4921bbdd
CY
3513(defun gnus-make-thread-indent-array (&optional n)
3514 (when (or n
3515 (progn (setq n 200) nil)
3516 (null gnus-thread-indent-array)
3517 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3518 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3519 gnus-thread-indent-array-level gnus-thread-indent-level)
3520 (while (>= n 0)
3521 (aset gnus-thread-indent-array n
6a30c01d 3522 (make-string (* n gnus-thread-indent-level) ? ))
4921bbdd 3523 (setq n (1- n)))))
eec82323
LMI
3524
3525(defun gnus-update-summary-mark-positions ()
3526 "Compute where the summary marks are to go."
3527 (save-excursion
6748645f 3528 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3529 (set-buffer gnus-summary-buffer))
5153a47a
MB
3530 (let ((spec gnus-summary-line-format-spec)
3531 pos)
eec82323
LMI
3532 (save-excursion
3533 (gnus-set-work-buffer)
5153a47a
MB
3534 (let ((gnus-tmp-unread ?Z)
3535 (gnus-replied-mark ?Z)
3536 (gnus-score-below-mark ?Z)
3537 (gnus-score-over-mark ?Z)
3538 (gnus-undownloaded-mark ?Z)
3539 (gnus-summary-line-format-spec spec)
54506618 3540 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3541 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3542 case-fold-search ignores)
3543 ;; Here, all marks are bound to Z.
3544 (gnus-summary-insert-line header
3545 0 nil t gnus-tmp-unread t nil "" nil 1)
3546 (goto-char (point-min))
3547 ;; Memorize the positions of the same characters as dummy marks.
3548 (while (re-search-forward "[A-D]" nil t)
3549 (push (point) ignores))
54506618 3550 (erase-buffer)
5153a47a
MB
3551 ;; We use A-D as dummy marks in order to know column positions
3552 ;; where marks should be inserted.
3553 (setq gnus-tmp-unread ?A
3554 gnus-replied-mark ?B
3555 gnus-score-below-mark ?C
3556 gnus-score-over-mark ?C
3557 gnus-undownloaded-mark ?D)
3558 (gnus-summary-insert-line header
3559 0 nil t gnus-tmp-unread t nil "" nil 1)
3560 ;; Ignore characters which aren't dummy marks.
3561 (dolist (p ignores)
3562 (delete-region (goto-char (1- p)) p)
3563 (insert ?Z))
eec82323 3564 (goto-char (point-min))
7c3bb5a5 3565 (setq pos (list (cons 'unread
5153a47a 3566 (and (search-forward "A" nil t)
7c3bb5a5 3567 (- (point) (point-min) 1)))))
eec82323 3568 (goto-char (point-min))
5153a47a 3569 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3570 (- (point) (point-min) 1)))
eec82323
LMI
3571 pos)
3572 (goto-char (point-min))
5153a47a 3573 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3574 (- (point) (point-min) 1)))
6748645f
LMI
3575 pos)
3576 (goto-char (point-min))
5153a47a 3577 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3578 (- (point) (point-min) 1)))
eec82323
LMI
3579 pos)))
3580 (setq gnus-summary-mark-positions pos))))
3581
3582(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3583 "Insert a dummy root in the summary buffer."
3584 (beginning-of-line)
3585 (gnus-add-text-properties
3586 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3587 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3588
23f87bed
MB
3589(defun gnus-summary-extract-address-component (from)
3590 (or (car (funcall gnus-extract-address-components from))
3591 from))
3592
3593(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3594 (let ((mail-parse-charset gnus-newsgroup-charset)
01c52d31 3595 (ignored-from-addresses (gnus-ignored-from-addresses))
23f87bed
MB
3596 ; Is it really necessary to do this next part for each summary line?
3597 ; Luckily, doesn't seem to slow things down much.
16409b0b 3598 (mail-parse-ignored-charsets
01c52d31
MB
3599 (with-current-buffer gnus-summary-buffer
3600 gnus-newsgroup-ignored-charsets)))
23f87bed 3601 (or
01c52d31
MB
3602 (and ignored-from-addresses
3603 (string-match ignored-from-addresses gnus-tmp-from)
23f87bed
MB
3604 (let ((extra-headers (mail-header-extra header))
3605 to
3606 newsgroups)
3607 (cond
3608 ((setq to (cdr (assq 'To extra-headers)))
01c52d31 3609 (concat gnus-summary-to-prefix
23f87bed
MB
3610 (inline
3611 (gnus-summary-extract-address-component
343d6628 3612 (funcall gnus-decode-encoded-address-function to)))))
01c52d31
MB
3613 ((setq newsgroups
3614 (or
3615 (cdr (assq 'Newsgroups extra-headers))
3616 (and
3617 (memq 'Newsgroups gnus-extra-headers)
3618 (eq (car (gnus-find-method-for-group
3619 gnus-newsgroup-name)) 'nntp)
3620 (gnus-group-real-name gnus-newsgroup-name))))
3621 (concat gnus-summary-newsgroup-prefix newsgroups)))))
23f87bed 3622 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3623
eec82323
LMI
3624(defun gnus-summary-insert-line (gnus-tmp-header
3625 gnus-tmp-level gnus-tmp-current
23f87bed 3626 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3627 gnus-tmp-expirable gnus-tmp-subject-or-nil
3628 &optional gnus-tmp-dummy gnus-tmp-score
3629 gnus-tmp-process)
4921bbdd
CY
3630 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3631 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3632 gnus-tmp-level)))
eec82323
LMI
3633 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3634 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3635 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3636 (gnus-tmp-score-char
3637 (if (or (null gnus-summary-default-score)
3638 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3639 gnus-summary-zcore-fuzz))
23f87bed 3640 ? ;Whitespace
eec82323
LMI
3641 (if (< gnus-tmp-score gnus-summary-default-score)
3642 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3643 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3644 (gnus-tmp-replied
3645 (cond (gnus-tmp-process gnus-process-mark)
3646 ((memq gnus-tmp-current gnus-newsgroup-cached)
3647 gnus-cached-mark)
3648 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3649 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3650 gnus-forwarded-mark)
eec82323
LMI
3651 ((memq gnus-tmp-current gnus-newsgroup-saved)
3652 gnus-saved-mark)
23f87bed
MB
3653 ((memq gnus-tmp-number gnus-newsgroup-recent)
3654 gnus-recent-mark)
3655 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3656 gnus-unseen-mark)
3657 (t gnus-no-mark)))
3658 (gnus-tmp-downloaded
3659 (cond (undownloaded
3660 gnus-undownloaded-mark)
3661 (gnus-newsgroup-agentized
3662 gnus-downloaded-mark)
3663 (t
3664 gnus-no-mark)))
eec82323
LMI
3665 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3666 (gnus-tmp-name
3667 (cond
3668 ((string-match "<[^>]+> *$" gnus-tmp-from)
3669 (let ((beg (match-beginning 0)))
23f87bed
MB
3670 (or (and (string-match "^\".+\"" gnus-tmp-from)
3671 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3672 (substring gnus-tmp-from 0 beg))))
3673 ((string-match "(.+)" gnus-tmp-from)
3674 (substring gnus-tmp-from
3675 (1+ (match-beginning 0)) (1- (match-end 0))))
3676 (t gnus-tmp-from)))
3677 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3678 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3679 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3680 (buffer-read-only nil))
3681 (when (string= gnus-tmp-name "")
3682 (setq gnus-tmp-name gnus-tmp-from))
3683 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3684 (setq gnus-tmp-lines -1))
3685 (if (= gnus-tmp-lines -1)
3686 (setq gnus-tmp-lines "?")
3687 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3688 (gnus-put-text-property
eec82323
LMI
3689 (point)
3690 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 3691 'gnus-number gnus-tmp-number)
eec82323
LMI
3692 (when (gnus-visual-p 'summary-highlight 'highlight)
3693 (forward-line -1)
6748645f 3694 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3695 (forward-line 1))))
3696
3697(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3698 "Update summary line after change."
eec82323
LMI
3699 (when (and gnus-summary-default-score
3700 (not gnus-summary-inhibit-highlight))
3701 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3702 (article (gnus-summary-article-number))
3703 (score (gnus-summary-article-score article)))
3704 (unless dont-update
3705 (if (and gnus-summary-mark-below
3706 (< (gnus-summary-article-score)
3707 gnus-summary-mark-below))
3708 ;; This article has a low score, so we mark it as read.
3709 (when (memq article gnus-newsgroup-unreads)
3710 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3711 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3712 ;; This article was previously marked as read on account
3713 ;; of a low score, but now it has risen, so we mark it as
3714 ;; unread.
3715 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3716 (gnus-summary-update-mark
3717 (if (or (null gnus-summary-default-score)
3718 (<= (abs (- score gnus-summary-default-score))
3719 gnus-summary-zcore-fuzz))
23f87bed 3720 ? ;Whitespace
eec82323
LMI
3721 (if (< score gnus-summary-default-score)
3722 gnus-score-below-mark gnus-score-over-mark))
3723 'score))
3724 ;; Do visual highlighting.
3725 (when (gnus-visual-p 'summary-highlight 'highlight)
6748645f 3726 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3727
3728(defvar gnus-tmp-new-adopts nil)
3729
3730(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3731 "Return the number of articles in THREAD.
3732This may be 0 in some cases -- if none of the articles in
3733the thread are to be displayed."
3734 (let* ((number
23f87bed 3735 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3736 (cond
3737 ((not (listp thread))
3738 1)
3739 ((and (consp thread) (cdr thread))
3740 (apply
3741 '+ 1 (mapcar
3742 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3743 ((null thread)
3744 1)
3745 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3746 1)
3747 (t 0))))
3748 (when (and level (zerop level) gnus-tmp-new-adopts)
3749 (incf number
3750 (apply '+ (mapcar
3751 'gnus-summary-number-of-articles-in-thread
3752 gnus-tmp-new-adopts))))
3753 (if char
3754 (if (> number 1) gnus-not-empty-thread-mark
3755 gnus-empty-thread-mark)
3756 number)))
3757
23f87bed
MB
3758(defsubst gnus-summary-line-message-size (head)
3759 "Return pretty-printed version of message size.
3760This function is intended to be used in
3761`gnus-summary-line-format-alist'."
3762 (let ((c (or (mail-header-chars head) -1)))
3763 (cond ((< c 0) "n/a") ; chars not available
3764 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3765 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3766 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3767 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3768
3769
eec82323
LMI
3770(defun gnus-summary-set-local-parameters (group)
3771 "Go through the local params of GROUP and set all variable specs in that list."
01c52d31
MB
3772 (let ((vars '(quit-config))) ; Ignore quit-config.
3773 (dolist (elem (gnus-group-find-parameter group))
eec82323
LMI
3774 (and (consp elem) ; Has to be a cons.
3775 (consp (cdr elem)) ; The cdr has to be a list.
3776 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3777 (not (memq (car elem) vars))
eec82323 3778 (ignore-errors ; So we set it.
23f87bed 3779 (push (car elem) vars)
eec82323
LMI
3780 (make-local-variable (car elem))
3781 (set (car elem) (eval (nth 1 elem))))))))
3782
3783(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3784 kill-buffer no-display backward
3785 select-articles)
eec82323
LMI
3786 "Start reading news in newsgroup GROUP.
3787If SHOW-ALL is non-nil, already read articles are also listed.
3788If NO-ARTICLE is non-nil, no article is selected initially.
3789If NO-DISPLAY, don't generate a summary buffer."
3790 (let (result)
3791 (while (and group
3792 (null (setq result
3793 (let ((gnus-auto-select-next nil))
6748645f
LMI
3794 (or (gnus-summary-read-group-1
3795 group show-all no-article
3796 kill-buffer no-display
3797 select-articles)
3798 (setq show-all nil
16409b0b 3799 select-articles nil)))))
eec82323
LMI
3800 (eq gnus-auto-select-next 'quietly))
3801 (set-buffer gnus-group-buffer)
6748645f
LMI
3802 ;; The entry function called above goes to the next
3803 ;; group automatically, so we go two groups back
3804 ;; if we are searching for the previous group.
3805 (when backward
3806 (gnus-group-prev-unread-group 2))
eec82323
LMI
3807 (if (not (equal group (gnus-group-group-name)))
3808 (setq group (gnus-group-group-name))
3809 (setq group nil)))
3810 result))
3811
3812(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3813 kill-buffer no-display
3814 &optional select-articles)
eec82323 3815 ;; Killed foreign groups can't be entered.
23f87bed
MB
3816 ;; (when (and (not (gnus-group-native-p group))
3817 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3818 ;; (error "Dead non-native groups can't be entered"))
3819 (gnus-message 5 "Retrieving newsgroup: %s..."
3820 (gnus-group-decoded-name group))
eec82323
LMI
3821 (let* ((new-group (gnus-summary-setup-buffer group))
3822 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3823 (did-select (and new-group (gnus-select-newsgroup
3824 group show-all select-articles))))
eec82323
LMI
3825 (cond
3826 ;; This summary buffer exists already, so we just select it.
3827 ((not new-group)
3828 (gnus-set-global-variables)
3829 (when kill-buffer
3830 (gnus-kill-or-deaden-summary kill-buffer))
3831 (gnus-configure-windows 'summary 'force)
3832 (gnus-set-mode-line 'summary)
3833 (gnus-summary-position-point)
3834 (message "")
3835 t)
3836 ;; We couldn't select this group.
3837 ((null did-select)
3838 (when (and (eq major-mode 'gnus-summary-mode)
3839 (not (equal (current-buffer) kill-buffer)))
3840 (kill-buffer (current-buffer))
3841 (if (not quit-config)
3842 (progn
6748645f
LMI
3843 ;; Update the info -- marks might need to be removed,
3844 ;; for instance.
3845 (gnus-summary-update-info)
eec82323
LMI
3846 (set-buffer gnus-group-buffer)
3847 (gnus-group-jump-to-group group)
3848 (gnus-group-next-unread-group 1))
3849 (gnus-handle-ephemeral-exit quit-config)))
23f87bed
MB
3850 (let ((grpinfo (gnus-get-info group)))
3851 (if (null (gnus-info-read grpinfo))
3852 (gnus-message 3 "Group %s contains no messages"
3853 (gnus-group-decoded-name group))
3854 (gnus-message 3 "Can't select group")))
eec82323
LMI
3855 nil)
3856 ;; The user did a `C-g' while prompting for number of articles,
3857 ;; so we exit this group.
3858 ((eq did-select 'quit)
3859 (and (eq major-mode 'gnus-summary-mode)
3860 (not (equal (current-buffer) kill-buffer))
3861 (kill-buffer (current-buffer)))
3862 (when kill-buffer
3863 (gnus-kill-or-deaden-summary kill-buffer))
3864 (if (not quit-config)
3865 (progn
3866 (set-buffer gnus-group-buffer)
3867 (gnus-group-jump-to-group group)
3868 (gnus-group-next-unread-group 1)
3869 (gnus-configure-windows 'group 'force))
3870 (gnus-handle-ephemeral-exit quit-config))
3871 ;; Finally signal the quit.
3872 (signal 'quit nil))
3873 ;; The group was successfully selected.
3874 (t
3875 (gnus-set-global-variables)
3876 ;; Save the active value in effect when the group was entered.
3877 (setq gnus-newsgroup-active
3878 (gnus-copy-sequence
3879 (gnus-active gnus-newsgroup-name)))
3880 ;; You can change the summary buffer in some way with this hook.
6748645f 3881 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
3882 (when (memq 'summary (gnus-update-format-specifications
3883 nil 'summary 'summary-mode 'summary-dummy))
3884 ;; The format specification for the summary line was updated,
3885 ;; so we need to update the mark positions as well.
3886 (gnus-update-summary-mark-positions))
eec82323
LMI
3887 ;; Do score processing.
3888 (when gnus-use-scoring
3889 (gnus-possibly-score-headers))
3890 ;; Check whether to fill in the gaps in the threads.
3891 (when gnus-build-sparse-threads
3892 (gnus-build-sparse-threads))
3893 ;; Find the initial limit.
26c9afc3
MB
3894 (if show-all
3895 (let ((gnus-newsgroup-dormant nil))
eec82323 3896 (gnus-summary-initial-limit show-all))
26c9afc3 3897 (gnus-summary-initial-limit show-all))
eec82323
LMI
3898 ;; Generate the summary buffer.
3899 (unless no-display
3900 (gnus-summary-prepare))
3901 (when gnus-use-trees
3902 (gnus-tree-open group)
3903 (setq gnus-summary-highlight-line-function
3904 'gnus-tree-highlight-article))
3905 ;; If the summary buffer is empty, but there are some low-scored
3906 ;; articles or some excluded dormants, we include these in the
3907 ;; buffer.
3908 (when (and (zerop (buffer-size))
3909 (not no-display))
3910 (cond (gnus-newsgroup-dormant
3911 (gnus-summary-limit-include-dormant))
3912 ((and gnus-newsgroup-scored show-all)
3913 (gnus-summary-limit-include-expunged t))))
3914 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 3915 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
3916 (if (and (zerop (buffer-size))
3917 (not no-display))
3918 (progn
3919 ;; This newsgroup is empty.
3920 (gnus-summary-catchup-and-exit nil t)
3921 (gnus-message 6 "No unread news")
3922 (when kill-buffer
3923 (gnus-kill-or-deaden-summary kill-buffer))
3924 ;; Return nil from this function.
3925 nil)
3926 ;; Hide conversation thread subtrees. We cannot do this in
3927 ;; gnus-summary-prepare-hook since kill processing may not
3928 ;; work with hidden articles.
23f87bed 3929 (gnus-summary-maybe-hide-threads)
6748645f
LMI
3930 (when kill-buffer
3931 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 3932 (gnus-summary-auto-select-subject)
eec82323
LMI
3933 ;; Show first unread article if requested.
3934 (if (and (not no-article)
3935 (not no-display)
3936 gnus-newsgroup-unreads
3937 gnus-auto-select-first)
16409b0b
GM
3938 (progn
3939 (gnus-configure-windows 'summary)
23f87bed
MB
3940 (let ((art (gnus-summary-article-number)))
3941 (unless (and (not gnus-plugged)
3942 (or (memq art gnus-newsgroup-undownloaded)
3943 (memq art gnus-newsgroup-downloadable)))
3944 (gnus-summary-goto-article art))))
3945 ;; Don't select any articles.
eec82323 3946 (gnus-summary-position-point)
6748645f
LMI
3947 (gnus-configure-windows 'summary 'force)
3948 (gnus-set-mode-line 'summary))
23f87bed
MB
3949 (when (and gnus-auto-center-group
3950 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
3951 ;; Gotta use windows, because recenter does weird stuff if
3952 ;; the current buffer ain't the displayed window.
3953 (let ((owin (selected-window)))
3954 (select-window (get-buffer-window gnus-group-buffer t))
3955 (when (gnus-group-goto-group group)
3956 (recenter))
3957 (select-window owin)))
3958 ;; Mark this buffer as "prepared".
3959 (setq gnus-newsgroup-prepared t)
6748645f 3960 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
3961 (unless (gnus-ephemeral-group-p group)
3962 (gnus-group-update-group group))
eec82323
LMI
3963 t)))))
3964
23f87bed
MB
3965(defun gnus-summary-auto-select-subject ()
3966 "Select the subject line on initial group entry."
3967 (goto-char (point-min))
3968 (cond
3969 ((eq gnus-auto-select-subject 'best)
3970 (gnus-summary-best-unread-subject))
3971 ((eq gnus-auto-select-subject 'unread)
3972 (gnus-summary-first-unread-subject))
3973 ((eq gnus-auto-select-subject 'unseen)
3974 (gnus-summary-first-unseen-subject))
3975 ((eq gnus-auto-select-subject 'unseen-or-unread)
3976 (gnus-summary-first-unseen-or-unread-subject))
3977 ((eq gnus-auto-select-subject 'first)
3978 ;; Do nothing.
3979 )
3980 ((functionp gnus-auto-select-subject)
3981 (funcall gnus-auto-select-subject))))
3982
eec82323
LMI
3983(defun gnus-summary-prepare ()
3984 "Generate the summary buffer."
3985 (interactive)
3986 (let ((buffer-read-only nil))
3987 (erase-buffer)
3988 (setq gnus-newsgroup-data nil
3989 gnus-newsgroup-data-reverse nil)
6748645f 3990 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
3991 ;; Generate the buffer, either with threads or without.
3992 (when gnus-newsgroup-headers
3993 (gnus-summary-prepare-threads
3994 (if gnus-show-threads
3995 (gnus-sort-gathered-threads
3996 (funcall gnus-summary-thread-gathering-function
3997 (gnus-sort-threads
3998 (gnus-cut-threads (gnus-make-threads)))))
3999 ;; Unthreaded display.
4000 (gnus-sort-articles gnus-newsgroup-headers))))
4001 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4002 ;; Call hooks for modifying summary buffer.
4003 (goto-char (point-min))
6748645f 4004 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
4005
4006(defsubst gnus-general-simplify-subject (subject)
23f87bed 4007 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
4008 (setq subject
4009 (cond
4010 ;; Truncate the subject.
6748645f
LMI
4011 (gnus-simplify-subject-functions
4012 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
4013 ((numberp gnus-summary-gather-subject-limit)
4014 (setq subject (gnus-simplify-subject-re subject))
4015 (if (> (length subject) gnus-summary-gather-subject-limit)
4016 (substring subject 0 gnus-summary-gather-subject-limit)
4017 subject))
4018 ;; Fuzzily simplify it.
4019 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4020 (gnus-simplify-subject-fuzzy subject))
4021 ;; Just remove the leading "Re:".
4022 (t
4023 (gnus-simplify-subject-re subject))))
4024
4025 (if (and gnus-summary-gather-exclude-subject
4026 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 4027 nil ; This article shouldn't be gathered
eec82323
LMI
4028 subject))
4029
4030(defun gnus-summary-simplify-subject-query ()
4031 "Query where the respool algorithm would put this article."
4032 (interactive)
eec82323 4033 (gnus-summary-select-article)
274f1353 4034 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
eec82323
LMI
4035
4036(defun gnus-gather-threads-by-subject (threads)
4037 "Gather threads by looking at Subject headers."
4038 (if (not gnus-summary-make-false-root)
4039 threads
4040 (let ((hashtb (gnus-make-hashtable 1024))
4041 (prev threads)
4042 (result threads)
4043 subject hthread whole-subject)
4044 (while threads
4045 (setq subject (gnus-general-simplify-subject
4046 (setq whole-subject (mail-header-subject
4047 (caar threads)))))
4048 (when subject
4049 (if (setq hthread (gnus-gethash subject hashtb))
4050 (progn
4051 ;; We enter a dummy root into the thread, if we
4052 ;; haven't done that already.
4053 (unless (stringp (caar hthread))
4054 (setcar hthread (list whole-subject (car hthread))))
4055 ;; We add this new gathered thread to this gathered
4056 ;; thread.
4057 (setcdr (car hthread)
4058 (nconc (cdar hthread) (list (car threads))))
4059 ;; Remove it from the list of threads.
4060 (setcdr prev (cdr threads))
4061 (setq threads prev))
4062 ;; Enter this thread into the hash table.
23f87bed
MB
4063 (gnus-sethash subject
4064 (if gnus-summary-make-false-root-always
4065 (progn
4066 ;; If you want a dummy root above all
4067 ;; threads...
4068 (setcar threads (list whole-subject
4069 (car threads)))
4070 threads)
4071 threads)
4072 hashtb)))
eec82323
LMI
4073 (setq prev threads)
4074 (setq threads (cdr threads)))
4075 result)))
4076
4077(defun gnus-gather-threads-by-references (threads)
4078 "Gather threads by looking at References headers."
4079 (let ((idhashtb (gnus-make-hashtable 1024))
4080 (thhashtb (gnus-make-hashtable 1024))
4081 (prev threads)
4082 (result threads)
4083 ids references id gthread gid entered ref)
4084 (while threads
4085 (when (setq references (mail-header-references (caar threads)))
4086 (setq id (mail-header-id (caar threads))
23f87bed 4087 ids (inline (gnus-split-references references))
eec82323
LMI
4088 entered nil)
4089 (while (setq ref (pop ids))
4090 (setq ids (delete ref ids))
4091 (if (not (setq gid (gnus-gethash ref idhashtb)))
4092 (progn
4093 (gnus-sethash ref id idhashtb)
4094 (gnus-sethash id threads thhashtb))
4095 (setq gthread (gnus-gethash gid thhashtb))
4096 (unless entered
4097 ;; We enter a dummy root into the thread, if we
4098 ;; haven't done that already.
4099 (unless (stringp (caar gthread))
4100 (setcar gthread (list (mail-header-subject (caar gthread))
4101 (car gthread))))
4102 ;; We add this new gathered thread to this gathered
4103 ;; thread.
4104 (setcdr (car gthread)
4105 (nconc (cdar gthread) (list (car threads)))))
4106 ;; Add it into the thread hash table.
4107 (gnus-sethash id gthread thhashtb)
4108 (setq entered t)
4109 ;; Remove it from the list of threads.
4110 (setcdr prev (cdr threads))
4111 (setq threads prev))))
4112 (setq prev threads)
4113 (setq threads (cdr threads)))
4114 result))
4115
4116(defun gnus-sort-gathered-threads (threads)
16409b0b 4117 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
4118 (let ((result threads))
4119 (while threads
4120 (when (stringp (caar threads))
4121 (setcdr (car threads)
16409b0b 4122 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
4123 (setq threads (cdr threads)))
4124 result))
4125
4126(defun gnus-thread-loop-p (root thread)
4127 "Say whether ROOT is in THREAD."
4128 (let ((stack (list thread))
4129 (infloop 0)
4130 th)
4131 (while (setq thread (pop stack))
4132 (setq th (cdr thread))
4133 (while (and th
4134 (not (eq (caar th) root)))
4135 (pop th))
4136 (if th
4137 ;; We have found a loop.
4138 (let (ref-dep)
4139 (setcdr thread (delq (car th) (cdr thread)))
4140 (if (boundp (setq ref-dep (intern "none"
4141 gnus-newsgroup-dependencies)))
4142 (setcdr (symbol-value ref-dep)
4143 (nconc (cdr (symbol-value ref-dep))
4144 (list (car th))))
4145 (set ref-dep (list nil (car th))))
4146 (setq infloop 1
4147 stack nil))
4148 ;; Push all the subthreads onto the stack.
4149 (push (cdr thread) stack)))
4150 infloop))
4151
4152(defun gnus-make-threads ()
01ccbb85 4153 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
4154 (let (threads)
4155 (while (catch 'infloop
4156 (mapatoms
4157 (lambda (refs)
4158 ;; Deal with self-referencing References loops.
4159 (when (and (car (symbol-value refs))
4160 (not (zerop
4161 (apply
4162 '+
4163 (mapcar
4164 (lambda (thread)
4165 (gnus-thread-loop-p
4166 (car (symbol-value refs)) thread))
4167 (cdr (symbol-value refs)))))))
4168 (setq threads nil)
4169 (throw 'infloop t))
4170 (unless (car (symbol-value refs))
23f87bed
MB
4171 ;; These threads do not refer back to any other
4172 ;; articles, so they're roots.
eec82323
LMI
4173 (setq threads (append (cdr (symbol-value refs)) threads))))
4174 gnus-newsgroup-dependencies)))
4175 threads))
4176
6748645f 4177;; Build the thread tree.
16409b0b 4178(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4179 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4180
4181If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4182if it was already present.
4183
4184If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4185will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4186Message-IDs will be renamed to a unique Message-ID before being
4187entered.
6748645f
LMI
4188
4189Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4190 (let* ((id (mail-header-id header))
4191 (id-dep (and id (intern id dependencies)))
23f87bed 4192 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4193 ;; Enter this `header' in the `dependencies' table.
4194 (cond
4195 ((not id-dep)
4196 (setq header nil))
4197 ;; The first two cases do the normal part: enter a new `header'
4198 ;; in the `dependencies' table.
4199 ((not (boundp id-dep))
4200 (set id-dep (list header)))
4201 ((null (car (symbol-value id-dep)))
4202 (setcar (symbol-value id-dep) header))
4203
4204 ;; From here the `header' was already present in the
4205 ;; `dependencies' table.
4206 (force-new
4207 ;; Overrides an existing entry;
4208 ;; just set the header part of the entry.
23f87bed
MB
4209 (setcar (symbol-value id-dep) header)
4210 (setq replaced t))
6748645f
LMI
4211
4212 ;; Renames the existing `header' to a unique Message-ID.
4213 ((not gnus-summary-ignore-duplicates)
4214 ;; An article with this Message-ID has already been seen.
4215 ;; We rename the Message-ID.
4216 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4217 (list header))
4218 (mail-header-set-id header id))
4219
4220 ;; The last case ignores an existing entry, except it adds any
4221 ;; additional Xrefs (in case the two articles came from different
4222 ;; servers.
4223 ;; Also sets `header' to `nil' meaning that the `dependencies'
4224 ;; table was *not* modified.
4225 (t
4226 (mail-header-set-xref
4227 (car (symbol-value id-dep))
4228 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4229 "")
4230 (or (mail-header-xref header) "")))
4231 (setq header nil)))
4232
23f87bed
MB
4233 (when (and header (not replaced))
4234 ;; First check that we are not creating a References loop.
4235 (setq parent-id (gnus-parent-id (mail-header-references header)))
4236 (setq ref parent-id)
6748645f
LMI
4237 (while (and ref
4238 (setq ref-dep (intern-soft ref dependencies))
4239 (boundp ref-dep)
4240 (setq ref-header (car (symbol-value ref-dep))))
4241 (if (string= id ref)
4242 ;; Yuk! This is a reference loop. Make the article be a
4243 ;; root article.
4244 (progn
4245 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4246 (setq ref nil)
4247 (setq parent-id nil))
6748645f 4248 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4249 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4250 (if (boundp ref-dep)
4251 (setcdr (symbol-value ref-dep)
4252 (nconc (cdr (symbol-value ref-dep))
4253 (list (symbol-value id-dep))))
4254 (set ref-dep (list nil (symbol-value id-dep)))))
4255 header))
4256
23f87bed
MB
4257(defun gnus-extract-message-id-from-in-reply-to (string)
4258 (if (string-match "<[^>]+>" string)
4259 (substring string (match-beginning 0) (match-end 0))
4260 nil))
4261
eec82323
LMI
4262(defun gnus-build-sparse-threads ()
4263 (let ((headers gnus-newsgroup-headers)
16409b0b 4264 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4265 (gnus-summary-ignore-duplicates t)
eec82323 4266 header references generation relations
6748645f 4267 subject child end new-child date)
eec82323
LMI
4268 ;; First we create an alist of generations/relations, where
4269 ;; generations is how much we trust the relation, and the relation
4270 ;; is parent/child.
4271 (gnus-message 7 "Making sparse threads...")
4272 (save-excursion
4273 (nnheader-set-temp-buffer " *gnus sparse threads*")
4274 (while (setq header (pop headers))
4275 (when (and (setq references (mail-header-references header))
4276 (not (string= references "")))
4277 (insert references)
4278 (setq child (mail-header-id header)
6748645f
LMI
4279 subject (mail-header-subject header)
4280 date (mail-header-date header)
4281 generation 0)
eec82323
LMI
4282 (while (search-backward ">" nil t)
4283 (setq end (1+ (point)))
4284 (when (search-backward "<" nil t)
6748645f 4285 (setq new-child (buffer-substring (point) end))
eec82323 4286 (push (list (incf generation)
6748645f
LMI
4287 child (setq child new-child)
4288 subject date)
eec82323 4289 relations)))
6748645f
LMI
4290 (when child
4291 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4292 (erase-buffer)))
4293 (kill-buffer (current-buffer)))
4294 ;; Sort over trustworthiness.
01c52d31
MB
4295 (dolist (relation (sort relations 'car-less-than-car))
4296 (when (gnus-dependencies-add-header
4297 (make-full-mail-header
4298 gnus-reffed-article-number
4299 (nth 3 relation) "" (or (nth 4 relation) "")
4300 (nth 1 relation)
4301 (or (nth 2 relation) "") 0 0 "")
4302 gnus-newsgroup-dependencies nil)
4303 (push gnus-reffed-article-number gnus-newsgroup-limit)
4304 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4305 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4306 gnus-newsgroup-reads)
4307 (decf gnus-reffed-article-number)))
eec82323
LMI
4308 (gnus-message 7 "Making sparse threads...done")))
4309
4310(defun gnus-build-old-threads ()
4311 ;; Look at all the articles that refer back to old articles, and
4312 ;; fetch the headers for the articles that aren't there. This will
4313 ;; build complete threads - if the roots haven't been expired by the
4314 ;; server, that is.
16409b0b
GM
4315 (let ((mail-parse-charset gnus-newsgroup-charset)
4316 id heads)
eec82323
LMI
4317 (mapatoms
4318 (lambda (refs)
4319 (when (not (car (symbol-value refs)))
4320 (setq heads (cdr (symbol-value refs)))
4321 (while heads
4322 (if (memq (mail-header-number (caar heads))
4323 gnus-newsgroup-dormant)
4324 (setq heads (cdr heads))
4325 (setq id (symbol-name refs))
4326 (while (and (setq id (gnus-build-get-header id))
6748645f 4327 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4328 (setq heads nil)))))
4329 gnus-newsgroup-dependencies)))
4330
23f87bed
MB
4331(defsubst gnus-remove-odd-characters (string)
4332 "Translate STRING into something that doesn't contain weird characters."
4333 (mm-subst-char-in-string
4334 ?\r ?\-
01c52d31 4335 (mm-subst-char-in-string ?\n ?\- string t) t))
23f87bed 4336
6748645f
LMI
4337;; This function has to be called with point after the article number
4338;; on the beginning of the line.
4339(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
01c52d31 4340 (let ((eol (point-at-eol))
6748645f 4341 (buffer (current-buffer))
23f87bed 4342 header references in-reply-to)
6748645f
LMI
4343
4344 ;; overview: [num subject from date id refs chars lines misc]
4345 (unwind-protect
23f87bed 4346 (let (x)
6748645f
LMI
4347 (narrow-to-region (point) eol)
4348 (unless (eobp)
4349 (forward-char))
4350
4351 (setq header
4352 (make-full-mail-header
4353 number ; number
23f87bed
MB
4354 (condition-case () ; subject
4355 (gnus-remove-odd-characters
4356 (funcall gnus-decode-encoded-word-function
4357 (setq x (nnheader-nov-field))))
4358 (error x))
4359 (condition-case () ; from
4360 (gnus-remove-odd-characters
343d6628 4361 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4362 (setq x (nnheader-nov-field))))
4363 (error x))
16409b0b 4364 (nnheader-nov-field) ; date
01c52d31 4365 (nnheader-nov-read-message-id number) ; id
23f87bed 4366 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4367 (nnheader-nov-read-integer) ; chars
4368 (nnheader-nov-read-integer) ; lines
4369 (unless (eobp)
8b93df01
DL
4370 (if (looking-at "Xref: ")
4371 (goto-char (match-end 0)))
4372 (nnheader-nov-field)) ; Xref
16409b0b 4373 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4374
4375 (widen))
4376
23f87bed
MB
4377 (when (and (string= references "")
4378 (setq in-reply-to (mail-header-extra header))
4379 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4380 (mail-header-set-references
4381 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4382
6748645f
LMI
4383 (when gnus-alter-header-function
4384 (funcall gnus-alter-header-function header))
4385 (gnus-dependencies-add-header header dependencies force-new)))
4386
eec82323 4387(defun gnus-build-get-header (id)
16409b0b
GM
4388 "Look through the buffer of NOV lines and find the header to ID.
4389Enter this line into the dependencies hash table, and return
4390the id of the parent article (if any)."
eec82323
LMI
4391 (let ((deps gnus-newsgroup-dependencies)
4392 found header)
4393 (prog1
4394 (save-excursion
4395 (set-buffer nntp-server-buffer)
4396 (let ((case-fold-search nil))
4397 (goto-char (point-min))
4398 (while (and (not found)
4399 (search-forward id nil t))
4400 (beginning-of-line)
4401 (setq found (looking-at
4402 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4403 (regexp-quote id))))
4404 (or found (beginning-of-line 2)))
4405 (when found
4406 (beginning-of-line)
4407 (and
4408 (setq header (gnus-nov-parse-line
4409 (read (current-buffer)) deps))
4410 (gnus-parent-id (mail-header-references header))))))
4411 (when header
4412 (let ((number (mail-header-number header)))
4413 (push number gnus-newsgroup-limit)
4414 (push header gnus-newsgroup-headers)
4415 (if (memq number gnus-newsgroup-unselected)
4416 (progn
23f87bed
MB
4417 (setq gnus-newsgroup-unreads
4418 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4419 number))
eec82323
LMI
4420 (setq gnus-newsgroup-unselected
4421 (delq number gnus-newsgroup-unselected)))
4422 (push number gnus-newsgroup-ancient)))))))
4423
6748645f
LMI
4424(defun gnus-build-all-threads ()
4425 "Read all the headers."
4426 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4427 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4428 (dependencies gnus-newsgroup-dependencies)
4429 header article)
4430 (save-excursion
4431 (set-buffer nntp-server-buffer)
4432 (let ((case-fold-search nil))
4433 (goto-char (point-min))
4434 (while (not (eobp))
4435 (ignore-errors
4436 (setq article (read (current-buffer))
16409b0b 4437 header (gnus-nov-parse-line article dependencies)))
6748645f 4438 (when header
01c52d31 4439 (with-current-buffer gnus-summary-buffer
6748645f
LMI
4440 (push header gnus-newsgroup-headers)
4441 (if (memq (setq article (mail-header-number header))
4442 gnus-newsgroup-unselected)
4443 (progn
23f87bed
MB
4444 (setq gnus-newsgroup-unreads
4445 (gnus-add-to-sorted-list
4446 gnus-newsgroup-unreads article))
6748645f
LMI
4447 (setq gnus-newsgroup-unselected
4448 (delq article gnus-newsgroup-unselected)))
4449 (push article gnus-newsgroup-ancient)))
4450 (forward-line 1)))))))
4451
eec82323 4452(defun gnus-summary-update-article-line (article header)
23f87bed 4453 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4454 (let* ((id (mail-header-id header))
4455 (thread (gnus-id-to-thread id)))
4456 (unless thread
4457 (error "Article in no thread"))
4458 ;; Update the thread.
4459 (setcar thread header)
4460 (gnus-summary-goto-subject article)
4461 (let* ((datal (gnus-data-find-list article))
4462 (data (car datal))
eec82323
LMI
4463 (buffer-read-only nil)
4464 (level (gnus-summary-thread-level)))
4465 (gnus-delete-line)
23f87bed
MB
4466 (let ((inserted (- (point)
4467 (progn
4468 (gnus-summary-insert-line
4469 header level nil
4470 (memq article gnus-newsgroup-undownloaded)
4471 (gnus-article-mark article)
4472 (memq article gnus-newsgroup-replied)
4473 (memq article gnus-newsgroup-expirable)
4474 ;; Only insert the Subject string when it's different
4475 ;; from the previous Subject string.
4476 (if (and
4477 gnus-show-threads
4478 (gnus-subject-equal
4479 (condition-case ()
4480 (mail-header-subject
4481 (gnus-data-header
4482 (cadr
4483 (gnus-data-find-list
4484 article
4485 (gnus-data-list t)))))
4486 ;; Error on the side of excessive subjects.
4487 (error ""))
4488 (mail-header-subject header)))
4489 ""
4490 (mail-header-subject header))
4491 nil (cdr (assq article gnus-newsgroup-scored))
4492 (memq article gnus-newsgroup-processable))
4493 (point)))))
4494 (when (cdr datal)
4495 (gnus-data-update-list
4496 (cdr datal)
4497 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4498
4499(defun gnus-summary-update-article (article &optional iheader)
4500 "Update ARTICLE in the summary buffer."
4501 (set-buffer gnus-summary-buffer)
6748645f 4502 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4503 (id (mail-header-id header))
4504 (data (gnus-data-find article))
4505 (thread (gnus-id-to-thread id))
4506 (references (mail-header-references header))
4507 (parent
4508 (gnus-id-to-thread
4509 (or (gnus-parent-id
4510 (when (and references
4511 (not (equal "" references)))
4512 references))
4513 "none")))
4514 (buffer-read-only nil)
6748645f 4515 (old (car thread)))
eec82323 4516 (when thread
eec82323 4517 (unless iheader
6748645f
LMI
4518 (setcar thread nil)
4519 (when parent
4520 (delq thread parent)))
4521 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4522 ;; Set the (possibly) new article number in the data structure.
4523 (gnus-data-set-number data (gnus-id-to-article id))
4524 (setcar thread old)
4525 nil))))
4526
6748645f
LMI
4527(defun gnus-rebuild-thread (id &optional line)
4528 "Rebuild the thread containing ID.
4529If LINE, insert the rebuilt thread starting on line LINE."
eec82323
LMI
4530 (let ((buffer-read-only nil)
4531 old-pos current thread data)
4532 (if (not gnus-show-threads)
4533 (setq thread (list (car (gnus-id-to-thread id))))
4534 ;; Get the thread this article is part of.
4535 (setq thread (gnus-remove-thread id)))
01c52d31 4536 (setq old-pos (point-at-bol))
eec82323 4537 (setq current (save-excursion
94384150 4538 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4539 (gnus-summary-article-number))))
4540 ;; If this is a gathered thread, we have to go some re-gathering.
4541 (when (stringp (car thread))
4542 (let ((subject (car thread))
4543 roots thr)
4544 (setq thread (cdr thread))
4545 (while thread
4546 (unless (memq (setq thr (gnus-id-to-thread
4547 (gnus-root-id
4548 (mail-header-id (caar thread)))))
4549 roots)
4550 (push thr roots))
4551 (setq thread (cdr thread)))
4552 ;; We now have all (unique) roots.
4553 (if (= (length roots) 1)
4554 ;; All the loose roots are now one solid root.
4555 (setq thread (car roots))
4556 (setq thread (cons subject (gnus-sort-threads roots))))))
4557 (let (threads)
4558 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4559 (when line
4560 (goto-char (point-min))
4561 (forward-line (1- line)))
eec82323
LMI
4562 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4563 (if gnus-show-threads
4564 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4565 (gnus-summary-prepare-unthreaded thread))
4566 (setq data (nreverse gnus-newsgroup-data))
4567 (setq threads gnus-newsgroup-threads))
4568 ;; We splice the new data into the data structure.
6748645f
LMI
4569 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4570 ;;!!! then we want to insert at the beginning of the buffer.
4571 ;;!!! That happens to be true with Gnus now, but that may
4572 ;;!!! change in the future. Perhaps.
4573 (gnus-data-enter-list
4574 (if line nil current) data (- (point) old-pos))
4575 (setq gnus-newsgroup-threads
4576 (nconc threads gnus-newsgroup-threads))
4577 (gnus-data-compute-positions))))
eec82323
LMI
4578
4579(defun gnus-number-to-header (number)
4580 "Return the header for article NUMBER."
4581 (let ((headers gnus-newsgroup-headers))
4582 (while (and headers
4583 (not (= number (mail-header-number (car headers)))))
4584 (pop headers))
4585 (when headers
4586 (car headers))))
4587
6748645f 4588(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4589 "Return the headers of the GENERATIONeth parent of HEADERS."
4590 (unless generation
4591 (setq generation 1))
a8151ef7 4592 (let ((parent t)
6748645f 4593 (headers in-headers)
a8151ef7 4594 references)
6748645f
LMI
4595 (while (and parent
4596 (not (zerop generation))
4597 (setq references (mail-header-references headers)))
4598 (setq headers (if (and references
4599 (setq parent (gnus-parent-id references)))
4600 (car (gnus-id-to-thread parent))
4601 nil))
4602 (decf generation))
4603 (and (not (eq headers in-headers))
4604 headers)))
eec82323
LMI
4605
4606(defun gnus-id-to-thread (id)
4607 "Return the (sub-)thread where ID appears."
4608 (gnus-gethash id gnus-newsgroup-dependencies))
4609
4610(defun gnus-id-to-article (id)
4611 "Return the article number of ID."
4612 (let ((thread (gnus-id-to-thread id)))
4613 (when (and thread
4614 (car thread))
4615 (mail-header-number (car thread)))))
4616
4617(defun gnus-id-to-header (id)
4618 "Return the article headers of ID."
4619 (car (gnus-id-to-thread id)))
4620
4621(defun gnus-article-displayed-root-p (article)
4622 "Say whether ARTICLE is a root(ish) article."
4623 (let ((level (gnus-summary-thread-level article))
4624 (refs (mail-header-references (gnus-summary-article-header article)))
4625 particle)
4626 (cond
4627 ((null level) nil)
4628 ((zerop level) t)
4629 ((null refs) t)
4630 ((null (gnus-parent-id refs)) t)
4631 ((and (= 1 level)
4632 (null (setq particle (gnus-id-to-article
4633 (gnus-parent-id refs))))
4634 (null (gnus-summary-thread-level particle)))))))
4635
4636(defun gnus-root-id (id)
4637 "Return the id of the root of the thread where ID appears."
4638 (let (last-id prev)
6748645f 4639 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4640 (setq last-id id
4641 id (gnus-parent-id (mail-header-references prev))))
4642 last-id))
4643
6748645f
LMI
4644(defun gnus-articles-in-thread (thread)
4645 "Return the list of articles in THREAD."
4646 (cons (mail-header-number (car thread))
4647 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4648
eec82323
LMI
4649(defun gnus-remove-thread (id &optional dont-remove)
4650 "Remove the thread that has ID in it."
6748645f 4651 (let (headers thread last-id)
eec82323 4652 ;; First go up in this thread until we find the root.
6748645f
LMI
4653 (setq last-id (gnus-root-id id)
4654 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4655 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4656 ;; been gathered into some loose thread, so we have to search
4657 ;; through the threads to find the thread we wanted.
4658 (let ((threads gnus-newsgroup-threads)
4659 sub)
4660 (while threads
4661 (setq sub (car threads))
4662 (if (stringp (car sub))
4663 ;; This is a gathered thread, so we look at the roots
4664 ;; below it to find whether this article is in this
4665 ;; gathered root.
4666 (progn
4667 (setq sub (cdr sub))
4668 (while sub
4669 (when (member (caar sub) headers)
4670 (setq thread (car threads)
4671 threads nil
4672 sub nil))
4673 (setq sub (cdr sub))))
4674 ;; It's an ordinary thread, so we check it.
4675 (when (eq (car sub) (car headers))
4676 (setq thread sub
4677 threads nil)))
4678 (setq threads (cdr threads)))
4679 ;; If this article is in no thread, then it's a root.
4680 (if thread
4681 (unless dont-remove
4682 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4683 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4684 (when thread
4685 (prog1
4686 thread ; We return this thread.
4687 (unless dont-remove
4688 (if (stringp (car thread))
4689 (progn
4690 ;; If we use dummy roots, then we have to remove the
4691 ;; dummy root as well.
4692 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4693 ;; We go to the dummy root by going to
4694 ;; the first sub-"thread", and then one line up.
4695 (gnus-summary-goto-article
4696 (mail-header-number (caadr thread)))
4697 (forward-line -1)
eec82323
LMI
4698 (gnus-delete-line)
4699 (gnus-data-compute-positions))
4700 (setq thread (cdr thread))
4701 (while thread
4702 (gnus-remove-thread-1 (car thread))
4703 (setq thread (cdr thread))))
4704 (gnus-remove-thread-1 thread))))))))
4705
4706(defun gnus-remove-thread-1 (thread)
4707 "Remove the thread THREAD recursively."
4708 (let ((number (mail-header-number (pop thread)))
4709 d)
4710 (setq thread (reverse thread))
4711 (while thread
4712 (gnus-remove-thread-1 (pop thread)))
4713 (when (setq d (gnus-data-find number))
4714 (goto-char (gnus-data-pos d))
16409b0b 4715 (gnus-summary-show-thread)
eec82323
LMI
4716 (gnus-data-remove
4717 number
01c52d31 4718 (- (point-at-bol)
eec82323 4719 (prog1
01c52d31 4720 (1+ (point-at-eol))
eec82323
LMI
4721 (gnus-delete-line)))))))
4722
4921bbdd 4723(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4724 (sort (mapcar (lambda (thread)
4725 (cons (car thread)
4726 (and (cdr thread)
4921bbdd 4727 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4728 threads) func))
4729
4921bbdd
CY
4730(defun gnus-sort-threads-loop (threads func)
4731 (let* ((superthread (cons nil threads))
4732 (stack (list (cons superthread threads)))
4733 remaining-threads thread)
4734 (while stack
4735 (setq remaining-threads (cdr (car stack)))
4736 (if remaining-threads
4737 (progn (setq thread (car remaining-threads))
4738 (setcdr (car stack) (cdr remaining-threads))
4739 (if (cdr thread)
4740 (push (cons thread (cdr thread)) stack)))
4741 (setq thread (caar stack))
4742 (setcdr thread (sort (cdr thread) func))
4743 (pop stack)))
4744 (cdr superthread)))
4745
eec82323
LMI
4746(defun gnus-sort-threads (threads)
4747 "Sort THREADS."
4748 (if (not gnus-thread-sort-functions)
4749 threads
6748645f 4750 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4751 (prog1
4752 (condition-case nil
4753 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4754 (gnus-sort-threads-recursive
4755 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4756 ;; Even after binding max-lisp-eval-depth, the recursive
4757 ;; sorter might fail for very long threads. In that case,
4758 ;; try using a (less well-tested) non-recursive sorter.
4759 (error (gnus-sort-threads-loop
4760 threads (gnus-make-sort-function
4761 gnus-thread-sort-functions))))
4762 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4763
4764(defun gnus-sort-articles (articles)
4765 "Sort ARTICLES."
4766 (when gnus-article-sort-functions
4767 (gnus-message 7 "Sorting articles...")
4768 (prog1
4769 (setq gnus-newsgroup-headers
4770 (sort articles (gnus-make-sort-function
4771 gnus-article-sort-functions)))
4772 (gnus-message 7 "Sorting articles...done"))))
4773
4774;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4775(defmacro gnus-thread-header (thread)
16409b0b
GM
4776 "Return header of first article in THREAD.
4777Note that THREAD must never, ever be anything else than a variable -
4778using some other form will lead to serious barfage."
eec82323
LMI
4779 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4780 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4781 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4782 (vector thread) 2))
4783
4784(defsubst gnus-article-sort-by-number (h1 h2)
4785 "Sort articles by article number."
4786 (< (mail-header-number h1)
4787 (mail-header-number h2)))
4788
4789(defun gnus-thread-sort-by-number (h1 h2)
4790 "Sort threads by root article number."
4791 (gnus-article-sort-by-number
4792 (gnus-thread-header h1) (gnus-thread-header h2)))
4793
23f87bed
MB
4794(defsubst gnus-article-sort-by-random (h1 h2)
4795 "Sort articles by article number."
4796 (zerop (random 2)))
4797
4798(defun gnus-thread-sort-by-random (h1 h2)
4799 "Sort threads by root article number."
4800 (gnus-article-sort-by-random
4801 (gnus-thread-header h1) (gnus-thread-header h2)))
4802
eec82323
LMI
4803(defsubst gnus-article-sort-by-lines (h1 h2)
4804 "Sort articles by article Lines header."
4805 (< (mail-header-lines h1)
4806 (mail-header-lines h2)))
4807
4808(defun gnus-thread-sort-by-lines (h1 h2)
4809 "Sort threads by root article Lines header."
4810 (gnus-article-sort-by-lines
4811 (gnus-thread-header h1) (gnus-thread-header h2)))
4812
16409b0b
GM
4813(defsubst gnus-article-sort-by-chars (h1 h2)
4814 "Sort articles by octet length."
4815 (< (mail-header-chars h1)
4816 (mail-header-chars h2)))
4817
4818(defun gnus-thread-sort-by-chars (h1 h2)
4819 "Sort threads by root article octet length."
4820 (gnus-article-sort-by-chars
4821 (gnus-thread-header h1) (gnus-thread-header h2)))
4822
eec82323
LMI
4823(defsubst gnus-article-sort-by-author (h1 h2)
4824 "Sort articles by root author."
b4fde39f 4825 (gnus-string<
eec82323
LMI
4826 (let ((extract (funcall
4827 gnus-extract-address-components
4828 (mail-header-from h1))))
4829 (or (car extract) (cadr extract) ""))
4830 (let ((extract (funcall
4831 gnus-extract-address-components
4832 (mail-header-from h2))))
4833 (or (car extract) (cadr extract) ""))))
4834
4835(defun gnus-thread-sort-by-author (h1 h2)
4836 "Sort threads by root author."
4837 (gnus-article-sort-by-author
4838 (gnus-thread-header h1) (gnus-thread-header h2)))
4839
01c52d31
MB
4840(defsubst gnus-article-sort-by-recipient (h1 h2)
4841 "Sort articles by recipient."
4842 (gnus-string<
4843 (let ((extract (funcall
4844 gnus-extract-address-components
4845 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4846 (or (car extract) (cadr extract)))
4847 (let ((extract (funcall
4848 gnus-extract-address-components
4849 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4850 (or (car extract) (cadr extract)))))
4851
4852(defun gnus-thread-sort-by-recipient (h1 h2)
4853 "Sort threads by root recipient."
4854 (gnus-article-sort-by-recipient
4855 (gnus-thread-header h1) (gnus-thread-header h2)))
4856
eec82323
LMI
4857(defsubst gnus-article-sort-by-subject (h1 h2)
4858 "Sort articles by root subject."
b4fde39f 4859 (gnus-string<
eec82323
LMI
4860 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4861 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4862
4863(defun gnus-thread-sort-by-subject (h1 h2)
4864 "Sort threads by root subject."
4865 (gnus-article-sort-by-subject
4866 (gnus-thread-header h1) (gnus-thread-header h2)))
4867
4868(defsubst gnus-article-sort-by-date (h1 h2)
4869 "Sort articles by root article date."
16409b0b 4870 (time-less-p
eec82323
LMI
4871 (gnus-date-get-time (mail-header-date h1))
4872 (gnus-date-get-time (mail-header-date h2))))
4873
4874(defun gnus-thread-sort-by-date (h1 h2)
4875 "Sort threads by root article date."
4876 (gnus-article-sort-by-date
4877 (gnus-thread-header h1) (gnus-thread-header h2)))
4878
4879(defsubst gnus-article-sort-by-score (h1 h2)
4880 "Sort articles by root article score.
4881Unscored articles will be counted as having a score of zero."
4882 (> (or (cdr (assq (mail-header-number h1)
4883 gnus-newsgroup-scored))
4884 gnus-summary-default-score 0)
4885 (or (cdr (assq (mail-header-number h2)
4886 gnus-newsgroup-scored))
4887 gnus-summary-default-score 0)))
4888
4889(defun gnus-thread-sort-by-score (h1 h2)
4890 "Sort threads by root article score."
4891 (gnus-article-sort-by-score
4892 (gnus-thread-header h1) (gnus-thread-header h2)))
4893
4894(defun gnus-thread-sort-by-total-score (h1 h2)
4895 "Sort threads by the sum of all scores in the thread.
4896Unscored articles will be counted as having a score of zero."
4897 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4898
4899(defun gnus-thread-total-score (thread)
16409b0b 4900 ;; This function find the total score of THREAD.
23f87bed
MB
4901 (cond
4902 ((null thread)
4903 0)
4904 ((consp thread)
4905 (if (stringp (car thread))
4906 (apply gnus-thread-score-function 0
4907 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4908 (gnus-thread-total-score-1 thread)))
4909 (t
4910 (gnus-thread-total-score-1 (list thread)))))
4911
4912(defun gnus-thread-sort-by-most-recent-number (h1 h2)
4913 "Sort threads such that the thread with the most recently arrived article comes first."
4914 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4915
4916(defun gnus-thread-highest-number (thread)
4917 "Return the highest article number in THREAD."
4918 (apply 'max (mapcar (lambda (header)
4919 (mail-header-number header))
4920 (message-flatten-list thread))))
4921
4922(defun gnus-thread-sort-by-most-recent-date (h1 h2)
4923 "Sort threads such that the thread with the most recently dated article comes first."
4924 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4925
4926(defun gnus-thread-latest-date (thread)
4927 "Return the highest article date in THREAD."
4928 (let ((previous-time 0))
4929 (apply 'max
4930 (mapcar
4931 (lambda (header)
4932 (setq previous-time
4933 (condition-case ()
4934 (time-to-seconds (mail-header-parse-date
4935 (mail-header-date header)))
4936 (error previous-time))))
4937 (sort
4938 (message-flatten-list thread)
4939 (lambda (h1 h2)
4940 (< (mail-header-number h1)
4941 (mail-header-number h2))))))))
eec82323
LMI
4942
4943(defun gnus-thread-total-score-1 (root)
4944 ;; This function find the total score of the thread below ROOT.
4945 (setq root (car root))
4946 (apply gnus-thread-score-function
4947 (or (append
4948 (mapcar 'gnus-thread-total-score
6748645f 4949 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
4950 (when (> (mail-header-number root) 0)
4951 (list (or (cdr (assq (mail-header-number root)
4952 gnus-newsgroup-scored))
4953 gnus-summary-default-score 0))))
4954 (list gnus-summary-default-score)
4955 '(0))))
4956
4957;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4958(defvar gnus-tmp-prev-subject nil)
4959(defvar gnus-tmp-false-parent nil)
4960(defvar gnus-tmp-root-expunged nil)
4961(defvar gnus-tmp-dummy-line nil)
4962
16409b0b
GM
4963(defun gnus-extra-header (type &optional header)
4964 "Return the extra header of TYPE."
4965 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4966 ""))
4967
23f87bed
MB
4968(defvar gnus-tmp-thread-tree-header-string "")
4969
4970(defcustom gnus-sum-thread-tree-root "> "
4971 "With %B spec, used for the root of a thread.
4972If nil, use subject instead."
bf247b6e 4973 :version "22.1"
ad136a7c 4974 :type '(radio (const :format "%v " nil) string)
23f87bed 4975 :group 'gnus-thread)
01c52d31 4976
23f87bed
MB
4977(defcustom gnus-sum-thread-tree-false-root "> "
4978 "With %B spec, used for a false root of a thread.
4979If nil, use subject instead."
bf247b6e 4980 :version "22.1"
ad136a7c 4981 :type '(radio (const :format "%v " nil) string)
23f87bed 4982 :group 'gnus-thread)
01c52d31 4983
23f87bed
MB
4984(defcustom gnus-sum-thread-tree-single-indent ""
4985 "With %B spec, used for a thread with just one message.
4986If nil, use subject instead."
bf247b6e 4987 :version "22.1"
ad136a7c 4988 :type '(radio (const :format "%v " nil) string)
23f87bed 4989 :group 'gnus-thread)
01c52d31 4990
23f87bed
MB
4991(defcustom gnus-sum-thread-tree-vertical "| "
4992 "With %B spec, used for drawing a vertical line."
bf247b6e 4993 :version "22.1"
23f87bed
MB
4994 :type 'string
4995 :group 'gnus-thread)
01c52d31 4996
23f87bed
MB
4997(defcustom gnus-sum-thread-tree-indent " "
4998 "With %B spec, used for indenting."
bf247b6e 4999 :version "22.1"
23f87bed
MB
5000 :type 'string
5001 :group 'gnus-thread)
01c52d31 5002
23f87bed
MB
5003(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5004 "With %B spec, used for a leaf with brothers."
bf247b6e 5005 :version "22.1"
23f87bed
MB
5006 :type 'string
5007 :group 'gnus-thread)
01c52d31 5008
23f87bed
MB
5009(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5010 "With %B spec, used for a leaf without brothers."
bf247b6e 5011 :version "22.1"
23f87bed
MB
5012 :type 'string
5013 :group 'gnus-thread)
5014
eec82323
LMI
5015(defun gnus-summary-prepare-threads (threads)
5016 "Prepare summary buffer from THREADS and indentation LEVEL.
5017THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5018or a straight list of headers."
5019 (gnus-message 7 "Generating summary...")
5020
5021 (setq gnus-newsgroup-threads threads)
5022 (beginning-of-line)
5023
5024 (let ((gnus-tmp-level 0)
5025 (default-score (or gnus-summary-default-score 0))
5026 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
5027 (building-line-count gnus-summary-display-while-building)
5028 (building-count (integerp gnus-summary-display-while-building))
eec82323 5029 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
5030 new-roots gnus-tmp-new-adopts thread-end simp-subject
5031 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
5032 gnus-tmp-replied gnus-tmp-subject-or-nil
5033 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5034 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
5035 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5036 tree-stack)
eec82323 5037
23f87bed
MB
5038 (setq gnus-tmp-prev-subject nil
5039 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
5040
5041 (if (vectorp (car threads))
5042 ;; If this is a straight (sic) list of headers, then a
5043 ;; threaded summary display isn't required, so we just create
5044 ;; an unthreaded one.
5045 (gnus-summary-prepare-unthreaded threads)
5046
5047 ;; Do the threaded display.
5048
23f87bed
MB
5049 (if gnus-summary-display-while-building
5050 (switch-to-buffer (buffer-name)))
eec82323
LMI
5051 (while (or threads stack gnus-tmp-new-adopts new-roots)
5052
5053 (if (and (= gnus-tmp-level 0)
eec82323
LMI
5054 (or (not stack)
5055 (= (caar stack) 0))
5056 (not gnus-tmp-false-parent)
5057 (or gnus-tmp-new-adopts new-roots))
5058 (if gnus-tmp-new-adopts
5059 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5060 thread (list (car gnus-tmp-new-adopts))
5061 gnus-tmp-header (caar thread)
5062 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5063 (when new-roots
5064 (setq thread (list (car new-roots))
5065 gnus-tmp-header (caar thread)
5066 new-roots (cdr new-roots))))
5067
5068 (if threads
5069 ;; If there are some threads, we do them before the
5070 ;; threads on the stack.
5071 (setq thread threads
5072 gnus-tmp-header (caar thread))
5073 ;; There were no current threads, so we pop something off
5074 ;; the stack.
5075 (setq state (car stack)
5076 gnus-tmp-level (car state)
23f87bed
MB
5077 tree-stack (cadr state)
5078 thread (caddr state)
eec82323
LMI
5079 stack (cdr stack)
5080 gnus-tmp-header (caar thread))))
5081
5082 (setq gnus-tmp-false-parent nil)
5083 (setq gnus-tmp-root-expunged nil)
5084 (setq thread-end nil)
5085
5086 (if (stringp gnus-tmp-header)
5087 ;; The header is a dummy root.
5088 (cond
5089 ((eq gnus-summary-make-false-root 'adopt)
5090 ;; We let the first article adopt the rest.
5091 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5092 (cddar thread)))
5093 (setq gnus-tmp-gathered
5094 (nconc (mapcar
5095 (lambda (h) (mail-header-number (car h)))
5096 (cddar thread))
5097 gnus-tmp-gathered))
5098 (setq thread (cons (list (caar thread)
5099 (cadar thread))
5100 (cdr thread)))
5101 (setq gnus-tmp-level -1
5102 gnus-tmp-false-parent t))
5103 ((eq gnus-summary-make-false-root 'empty)
5104 ;; We print adopted articles with empty subject fields.
5105 (setq gnus-tmp-gathered
5106 (nconc (mapcar
5107 (lambda (h) (mail-header-number (car h)))
5108 (cddar thread))
5109 gnus-tmp-gathered))
5110 (setq gnus-tmp-level -1))
5111 ((eq gnus-summary-make-false-root 'dummy)
5112 ;; We remember that we probably want to output a dummy
5113 ;; root.
5114 (setq gnus-tmp-dummy-line gnus-tmp-header)
5115 (setq gnus-tmp-prev-subject gnus-tmp-header))
5116 (t
5117 ;; We do not make a root for the gathered
5118 ;; sub-threads at all.
5119 (setq gnus-tmp-level -1)))
5120
5121 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
5122 subject (mail-header-subject gnus-tmp-header)
5123 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
5124
5125 (cond
5126 ;; If the thread has changed subject, we might want to make
5127 ;; this subthread into a root.
5128 ((and (null gnus-thread-ignore-subject)
5129 (not (zerop gnus-tmp-level))
5130 gnus-tmp-prev-subject
23f87bed 5131 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5132 (setq new-roots (nconc new-roots (list (car thread)))
5133 thread-end t
5134 gnus-tmp-header nil))
5135 ;; If the article lies outside the current limit,
5136 ;; then we do not display it.
5137 ((not (memq number gnus-newsgroup-limit))
5138 (setq gnus-tmp-gathered
5139 (nconc (mapcar
5140 (lambda (h) (mail-header-number (car h)))
5141 (cdar thread))
5142 gnus-tmp-gathered))
5143 (setq gnus-tmp-new-adopts (if (cdar thread)
5144 (append gnus-tmp-new-adopts
5145 (cdar thread))
5146 gnus-tmp-new-adopts)
5147 thread-end t
5148 gnus-tmp-header nil)
5149 (when (zerop gnus-tmp-level)
5150 (setq gnus-tmp-root-expunged t)))
5151 ;; Perhaps this article is to be marked as read?
5152 ((and gnus-summary-mark-below
5153 (< (or (cdr (assq number gnus-newsgroup-scored))
5154 default-score)
5155 gnus-summary-mark-below)
5156 ;; Don't touch sparse articles.
5157 (not (gnus-summary-article-sparse-p number))
5158 (not (gnus-summary-article-ancient-p number)))
5159 (setq gnus-newsgroup-unreads
5160 (delq number gnus-newsgroup-unreads))
5161 (if gnus-newsgroup-auto-expire
23f87bed
MB
5162 (setq gnus-newsgroup-expirable
5163 (gnus-add-to-sorted-list
5164 gnus-newsgroup-expirable number))
eec82323
LMI
5165 (push (cons number gnus-low-score-mark)
5166 gnus-newsgroup-reads))))
5167
5168 (when gnus-tmp-header
5169 ;; We may have an old dummy line to output before this
5170 ;; article.
6748645f
LMI
5171 (when (and gnus-tmp-dummy-line
5172 (gnus-subject-equal
5173 gnus-tmp-dummy-line
5174 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
5175 (gnus-summary-insert-dummy-line
5176 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5177 (setq gnus-tmp-dummy-line nil))
5178
5179 ;; Compute the mark.
5180 (setq gnus-tmp-unread (gnus-article-mark number))
5181
5182 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5183 gnus-tmp-header gnus-tmp-level)
5184 gnus-newsgroup-data)
5185
5186 ;; Actually insert the line.
5187 (setq
5188 gnus-tmp-subject-or-nil
5189 (cond
5190 ((and gnus-thread-ignore-subject
5191 gnus-tmp-prev-subject
23f87bed 5192 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5193 subject)
5194 ((zerop gnus-tmp-level)
5195 (if (and (eq gnus-summary-make-false-root 'empty)
5196 (memq number gnus-tmp-gathered)
5197 gnus-tmp-prev-subject
23f87bed 5198 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5199 gnus-summary-same-subject
5200 subject))
5201 (t gnus-summary-same-subject)))
5202 (if (and (eq gnus-summary-make-false-root 'adopt)
5203 (= gnus-tmp-level 1)
5204 (memq number gnus-tmp-gathered))
5205 (setq gnus-tmp-opening-bracket ?\<
5206 gnus-tmp-closing-bracket ?\>)
5207 (setq gnus-tmp-opening-bracket ?\[
5208 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5209 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5210 (gnus-make-thread-indent-array
5211 (max (* 2 (length gnus-thread-indent-array))
5212 gnus-tmp-level)))
eec82323
LMI
5213 (setq
5214 gnus-tmp-indentation
5215 (aref gnus-thread-indent-array gnus-tmp-level)
5216 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5217 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5218 gnus-summary-default-score 0)
5219 gnus-tmp-score-char
5220 (if (or (null gnus-summary-default-score)
5221 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5222 gnus-summary-zcore-fuzz))
23f87bed 5223 ? ;Whitespace
eec82323
LMI
5224 (if (< gnus-tmp-score gnus-summary-default-score)
5225 gnus-score-below-mark gnus-score-over-mark))
5226 gnus-tmp-replied
5227 (cond ((memq number gnus-newsgroup-processable)
5228 gnus-process-mark)
5229 ((memq number gnus-newsgroup-cached)
5230 gnus-cached-mark)
5231 ((memq number gnus-newsgroup-replied)
5232 gnus-replied-mark)
23f87bed
MB
5233 ((memq number gnus-newsgroup-forwarded)
5234 gnus-forwarded-mark)
eec82323
LMI
5235 ((memq number gnus-newsgroup-saved)
5236 gnus-saved-mark)
23f87bed
MB
5237 ((memq number gnus-newsgroup-recent)
5238 gnus-recent-mark)
5239 ((memq number gnus-newsgroup-unseen)
5240 gnus-unseen-mark)
5241 (t gnus-no-mark))
5242 gnus-tmp-downloaded
5243 (cond ((memq number gnus-newsgroup-undownloaded)
5244 gnus-undownloaded-mark)
5245 (gnus-newsgroup-agentized
5246 gnus-downloaded-mark)
5247 (t
5248 gnus-no-mark))
eec82323
LMI
5249 gnus-tmp-from (mail-header-from gnus-tmp-header)
5250 gnus-tmp-name
5251 (cond
5252 ((string-match "<[^>]+> *$" gnus-tmp-from)
5253 (setq beg-match (match-beginning 0))
23f87bed
MB
5254 (or (and (string-match "^\".+\"" gnus-tmp-from)
5255 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5256 (substring gnus-tmp-from 0 beg-match)))
5257 ((string-match "(.+)" gnus-tmp-from)
5258 (substring gnus-tmp-from
5259 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5260 (t gnus-tmp-from))
5261
5262 ;; Do the %B string
5263 gnus-tmp-thread-tree-header-string
5264 (cond
5265 ((not gnus-show-threads) "")
5266 ((zerop gnus-tmp-level)
5267 (cond ((cdar thread)
5268 (or gnus-sum-thread-tree-root subject))
5269 (gnus-tmp-new-adopts
5270 (or gnus-sum-thread-tree-false-root subject))
5271 (t
5272 (or gnus-sum-thread-tree-single-indent subject))))
5273 (t
5274 (concat (apply 'concat
5275 (mapcar (lambda (item)
5276 (if (= item 1)
5277 gnus-sum-thread-tree-vertical
5278 gnus-sum-thread-tree-indent))
5279 (cdr (reverse tree-stack))))
5280 (if (nth 1 thread)
5281 gnus-sum-thread-tree-leaf-with-other
5282 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5283 (when (string= gnus-tmp-name "")
5284 (setq gnus-tmp-name gnus-tmp-from))
5285 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5286 (setq gnus-tmp-lines -1))
5287 (if (= gnus-tmp-lines -1)
5288 (setq gnus-tmp-lines "?")
5289 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5290 (gnus-put-text-property
eec82323
LMI
5291 (point)
5292 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 5293 'gnus-number number)
eec82323
LMI
5294 (when gnus-visual-p
5295 (forward-line -1)
6748645f 5296 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
5297 (forward-line 1))
5298
23f87bed 5299 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5300
5301 (when (nth 1 thread)
23f87bed
MB
5302 (push (list (max 0 gnus-tmp-level)
5303 (copy-sequence tree-stack)
5304 (nthcdr 1 thread))
5305 stack))
5306 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5307 (incf gnus-tmp-level)
5308 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5309 (if gnus-summary-display-while-building
5310 (if building-count
5311 (progn
5312 ;; use a set frequency
5313 (setq building-line-count (1- building-line-count))
5314 (when (= building-line-count 0)
5315 (sit-for 0)
5316 (setq building-line-count
5317 gnus-summary-display-while-building)))
5318 ;; always
5319 (sit-for 0)))
eec82323
LMI
5320 (unless threads
5321 (setq gnus-tmp-level 0)))))
5322 (gnus-message 7 "Generating summary...done"))
5323
5324(defun gnus-summary-prepare-unthreaded (headers)
5325 "Generate an unthreaded summary buffer based on HEADERS."
5326 (let (header number mark)
5327
5328 (beginning-of-line)
5329
5330 (while headers
5331 ;; We may have to root out some bad articles...
5332 (when (memq (setq number (mail-header-number
5333 (setq header (pop headers))))
5334 gnus-newsgroup-limit)
5335 ;; Mark article as read when it has a low score.
5336 (when (and gnus-summary-mark-below
5337 (< (or (cdr (assq number gnus-newsgroup-scored))
5338 gnus-summary-default-score 0)
5339 gnus-summary-mark-below)
5340 (not (gnus-summary-article-ancient-p number)))
5341 (setq gnus-newsgroup-unreads
5342 (delq number gnus-newsgroup-unreads))
5343 (if gnus-newsgroup-auto-expire
5344 (push number gnus-newsgroup-expirable)
5345 (push (cons number gnus-low-score-mark)
5346 gnus-newsgroup-reads)))
5347
5348 (setq mark (gnus-article-mark number))
5349 (push (gnus-data-make number mark (1+ (point)) header 0)
5350 gnus-newsgroup-data)
5351 (gnus-summary-insert-line
5352 header 0 number
23f87bed 5353 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5354 mark (memq number gnus-newsgroup-replied)
5355 (memq number gnus-newsgroup-expirable)
5356 (mail-header-subject header) nil
5357 (cdr (assq number gnus-newsgroup-scored))
5358 (memq number gnus-newsgroup-processable))))))
5359
16409b0b
GM
5360(defun gnus-summary-remove-list-identifiers ()
5361 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5362 (let ((regexp (if (consp gnus-list-identifiers)
5363 (mapconcat 'identity gnus-list-identifiers " *\\|")
5364 gnus-list-identifiers))
5365 changed subject)
5366 (when regexp
01c52d31 5367 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
23f87bed
MB
5368 (dolist (header gnus-newsgroup-headers)
5369 (setq subject (mail-header-subject header)
5370 changed nil)
01c52d31 5371 (while (string-match regexp subject)
23f87bed 5372 (setq subject
01c52d31 5373 (concat (substring subject 0 (match-beginning 1))
23f87bed
MB
5374 (substring subject (match-end 0)))
5375 changed t))
23f87bed 5376 (when changed
01c52d31
MB
5377 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5378 (setq subject
5379 (concat (substring subject 0 (match-beginning 1))
5380 (substring subject (match-end 1)))))
23f87bed
MB
5381 (mail-header-set-subject header subject))))))
5382
5383(defun gnus-fetch-headers (articles)
5384 "Fetch headers of ARTICLES."
5385 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5386 (gnus-message 5 "Fetching headers for %s..." name)
5387 (prog1
5388 (if (eq 'nov
5389 (setq gnus-headers-retrieved-by
5390 (gnus-retrieve-headers
5391 articles gnus-newsgroup-name
5392 ;; We might want to fetch old headers, but
5393 ;; not if there is only 1 article.
5394 (and (or (and
5395 (not (eq gnus-fetch-old-headers 'some))
5396 (not (numberp gnus-fetch-old-headers)))
5397 (> (length articles) 1))
5398 gnus-fetch-old-headers))))
5399 (gnus-get-newsgroup-headers-xover
5400 articles nil nil gnus-newsgroup-name t)
5401 (gnus-get-newsgroup-headers))
5402 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5403
6748645f 5404(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5405 "Select newsgroup GROUP.
6748645f
LMI
5406If READ-ALL is non-nil, all articles in the group are selected.
5407If SELECT-ARTICLES, only select those articles from GROUP."
01c52d31 5408 (let* ((entry (gnus-group-entry group))
eec82323
LMI
5409 ;;!!! Dirty hack; should be removed.
5410 (gnus-summary-ignore-duplicates
23f87bed 5411 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5412 t
5413 gnus-summary-ignore-duplicates))
5414 (info (nth 2 entry))
01c52d31 5415 charset articles fetched-articles cached)
eec82323
LMI
5416
5417 (unless (gnus-check-server
475e0e0c
GM
5418 (set (make-local-variable 'gnus-current-select-method)
5419 (gnus-find-method-for-group group)))
eec82323 5420 (error "Couldn't open server"))
01c52d31 5421 (setq charset (gnus-group-name-charset gnus-current-select-method group))
eec82323
LMI
5422
5423 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5424 (gnus-activate-group group) ; Or we can activate it...
5425 (progn ; Or we bug out.
5426 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5427 (gnus-kill-buffer (current-buffer)))
01c52d31
MB
5428 (error
5429 "Couldn't activate group %s: %s"
5430 (mm-decode-coding-string group charset)
5431 (mm-decode-coding-string (gnus-status-message group) charset))))
eec82323
LMI
5432
5433 (unless (gnus-request-group group t)
01c52d31
MB
5434 (when (equal major-mode 'gnus-summary-mode)
5435 (gnus-kill-buffer (current-buffer)))
5436 (error "Couldn't request group %s: %s"
5437 (mm-decode-coding-string group charset)
5438 (mm-decode-coding-string (gnus-status-message group) charset)))
eec82323 5439
23f87bed 5440 (when gnus-agent
54506618 5441 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5442
23f87bed
MB
5443 (setq gnus-summary-use-undownloaded-faces
5444 (gnus-agent-find-parameter
5445 group
5446 'agent-enable-undownloaded-faces)))
5447
5448 (setq gnus-newsgroup-name group
5449 gnus-newsgroup-unselected nil
5450 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5451
5452 (let ((display (gnus-group-find-parameter group 'display)))
5453 (setq gnus-newsgroup-display
5454 (cond
5455 ((not (zerop (or (car-safe read-all) 0)))
5456 ;; The user entered the group with C-u SPC/RET, let's show
5457 ;; all articles.
5458 'gnus-not-ignore)
5459 ((eq display 'all)
5460 'gnus-not-ignore)
5461 ((arrayp display)
5462 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5463 ((numberp display)
5464 ;; The following is probably the "correct" solution, but
5465 ;; it makes Gnus fetch all headers and then limit the
5466 ;; articles (which is slow), so instead we hack the
5467 ;; select-articles parameter instead. -- Simon Josefsson
5468 ;; <jas@kth.se>
5469 ;;
5470 ;; (gnus-byte-compile
5471 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5472 ;; display)))))
5473 (setq select-articles
5474 (gnus-uncompress-range
5475 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5476 (if (> tmp 0)
5477 tmp
5478 1))
5479 (cdr (gnus-active group)))))
5480 nil)
5481 (t
5482 nil))))
eec82323 5483
23f87bed 5484 (gnus-summary-setup-default-charset)
eec82323
LMI
5485
5486 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5487 (when (gnus-virtual-group-p group)
5488 (setq cached gnus-newsgroup-cached))
5489
5490 (setq gnus-newsgroup-unreads
23f87bed
MB
5491 (gnus-sorted-ndifference
5492 (gnus-sorted-ndifference gnus-newsgroup-unreads
5493 gnus-newsgroup-marked)
eec82323
LMI
5494 gnus-newsgroup-dormant))
5495
5496 (setq gnus-newsgroup-processable nil)
5497
5498 (gnus-update-read-articles group gnus-newsgroup-unreads)
eec82323 5499
23f87bed
MB
5500 ;; Adjust and set lists of article marks.
5501 (when info
5502 (gnus-adjust-marked-articles info))
6748645f
LMI
5503 (if (setq articles select-articles)
5504 (setq gnus-newsgroup-unselected
23f87bed 5505 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5506 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5507
5508 (cond
5509 ((null articles)
5510 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5511 'quit)
5512 ((eq articles 0) nil)
5513 (t
5514 ;; Init the dependencies hash table.
5515 (setq gnus-newsgroup-dependencies
5516 (gnus-make-hashtable (length articles)))
16409b0b 5517 (gnus-set-global-variables)
eec82323 5518 ;; Retrieve the headers and read them in.
23f87bed
MB
5519
5520 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5521
5522 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5523 (when cached
5524 (setq gnus-newsgroup-cached cached))
5525
5526 ;; Suppress duplicates?
5527 (when gnus-suppress-duplicates
5528 (gnus-dup-suppress-articles))
5529
5530 ;; Set the initial limit.
5531 (setq gnus-newsgroup-limit (copy-sequence articles))
5532 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5533 (setq fetched-articles
5534 (mapcar (lambda (headers) (mail-header-number headers))
5535 gnus-newsgroup-headers))
5536 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5537 (setq gnus-newsgroup-unreads
23f87bed
MB
5538 (gnus-sorted-nintersection
5539 gnus-newsgroup-unreads fetched-articles))
5540 (gnus-compute-unseen-list)
5541
eec82323
LMI
5542 ;; Removed marked articles that do not exist.
5543 (gnus-update-missing-marks
23f87bed 5544 (gnus-sorted-difference articles fetched-articles))
eec82323 5545 ;; We might want to build some more threads first.
6748645f
LMI
5546 (when (and gnus-fetch-old-headers
5547 (eq gnus-headers-retrieved-by 'nov))
5548 (if (eq gnus-fetch-old-headers 'invisible)
5549 (gnus-build-all-threads)
5550 (gnus-build-old-threads)))
5551 ;; Let the Gnus agent mark articles as read.
5552 (when gnus-agent
5553 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5554 ;; Remove list identifiers from subject
5555 (when gnus-list-identifiers
5556 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5557 ;; Check whether auto-expire is to be done in this group.
5558 (setq gnus-newsgroup-auto-expire
5559 (gnus-group-auto-expirable-p group))
5560 ;; Set up the article buffer now, if necessary.
01c52d31
MB
5561 (unless (and gnus-single-article-buffer
5562 (equal gnus-article-buffer "*Article*"))
eec82323
LMI
5563 (gnus-article-setup-buffer))
5564 ;; First and last article in this newsgroup.
5565 (when gnus-newsgroup-headers
5566 (setq gnus-newsgroup-begin
5567 (mail-header-number (car gnus-newsgroup-headers))
5568 gnus-newsgroup-end
5569 (mail-header-number
5570 (gnus-last-element gnus-newsgroup-headers))))
5571 ;; GROUP is successfully selected.
5572 (or gnus-newsgroup-headers t)))))
5573
23f87bed
MB
5574(defun gnus-compute-unseen-list ()
5575 ;; The `seen' marks are treated specially.
5576 (if (not gnus-newsgroup-seen)
5577 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5578 (setq gnus-newsgroup-unseen
5579 (gnus-inverse-list-range-intersection
5580 gnus-newsgroup-articles gnus-newsgroup-seen))))
5581
d09ae6ca
GM
5582(declare-function gnus-get-predicate "gnus-agent" (predicate))
5583
23f87bed
MB
5584(defun gnus-summary-display-make-predicate (display)
5585 (require 'gnus-agent)
5586 (when (= (length display) 1)
5587 (setq display (car display)))
5588 (unless gnus-summary-display-cache
5589 (dolist (elem (append '((unread . unread)
5590 (read . read)
5591 (unseen . unseen))
5592 gnus-article-mark-lists))
5593 (push (cons (cdr elem)
5594 (gnus-byte-compile
5595 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5596 gnus-summary-display-cache)))
5597 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5598 (gnus-category-predicate-cache gnus-summary-display-cache))
5599 (gnus-get-predicate display)))
5600
5601;; Uses the dynamically bound `number' variable.
9efa445f 5602(defvar number)
23f87bed
MB
5603(defun gnus-article-marked-p (type &optional article)
5604 (let ((article (or article number)))
5605 (cond
5606 ((eq type 'tick)
5607 (memq article gnus-newsgroup-marked))
5608 ((eq type 'spam)
5609 (memq article gnus-newsgroup-spam-marked))
5610 ((eq type 'unsend)
5611 (memq article gnus-newsgroup-unsendable))
5612 ((eq type 'undownload)
5613 (memq article gnus-newsgroup-undownloaded))
5614 ((eq type 'download)
5615 (memq article gnus-newsgroup-downloadable))
5616 ((eq type 'unread)
5617 (memq article gnus-newsgroup-unreads))
5618 ((eq type 'read)
5619 (memq article gnus-newsgroup-reads))
5620 ((eq type 'dormant)
5621 (memq article gnus-newsgroup-dormant) )
5622 ((eq type 'expire)
5623 (memq article gnus-newsgroup-expirable))
5624 ((eq type 'reply)
5625 (memq article gnus-newsgroup-replied))
5626 ((eq type 'killed)
5627 (memq article gnus-newsgroup-killed))
5628 ((eq type 'bookmark)
5629 (assq article gnus-newsgroup-bookmarks))
5630 ((eq type 'score)
5631 (assq article gnus-newsgroup-scored))
5632 ((eq type 'save)
5633 (memq article gnus-newsgroup-saved))
5634 ((eq type 'cache)
5635 (memq article gnus-newsgroup-cached))
5636 ((eq type 'forward)
5637 (memq article gnus-newsgroup-forwarded))
5638 ((eq type 'seen)
5639 (not (memq article gnus-newsgroup-unseen)))
5640 ((eq type 'recent)
5641 (memq article gnus-newsgroup-recent))
5642 (t t))))
5643
eec82323 5644(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5645 "Find out what articles the user wants to read."
26c9afc3 5646 (let* ((articles
eec82323
LMI
5647 ;; Select all articles if `read-all' is non-nil, or if there
5648 ;; are no unread articles.
5649 (if (or read-all
5650 (and (zerop (length gnus-newsgroup-marked))
5651 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5652 ;; Fetch all if the predicate is non-nil.
5653 gnus-newsgroup-display)
5654 ;; We want to select the headers for all the articles in
5655 ;; the group, so we select either all the active
5656 ;; articles in the group, or (if that's nil), the
5657 ;; articles in the cache.
16409b0b 5658 (or
4b70e299 5659 (if gnus-newsgroup-maximum-articles
11abff8e
MB
5660 (let ((active (gnus-active group)))
5661 (gnus-uncompress-range
5662 (cons (max (car active)
4b70e299
MB
5663 (- (cdr active)
5664 gnus-newsgroup-maximum-articles
5665 -1))
11abff8e
MB
5666 (cdr active))))
5667 (gnus-uncompress-range (gnus-active group)))
16409b0b 5668 (gnus-cache-articles-in-group group))
23f87bed
MB
5669 ;; Select only the "normal" subset of articles.
5670 (gnus-sorted-nunion
5671 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5672 gnus-newsgroup-unreads)))
eec82323
LMI
5673 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5674 (scored (length scored-list))
5675 (number (length articles))
5676 (marked (+ (length gnus-newsgroup-marked)
5677 (length gnus-newsgroup-dormant)))
5678 (select
5679 (cond
5680 ((numberp read-all)
5681 read-all)
23f87bed
MB
5682 ((numberp gnus-newsgroup-display)
5683 gnus-newsgroup-display)
eec82323
LMI
5684 (t
5685 (condition-case ()
5686 (cond
5687 ((and (or (<= scored marked) (= scored number))
5688 (numberp gnus-large-newsgroup)
5689 (> number gnus-large-newsgroup))
23f87bed
MB
5690 (let* ((cursor-in-echo-area nil)
5691 (initial (gnus-parameter-large-newsgroup-initial
5692 gnus-newsgroup-name))
5693 (input
5694 (read-string
5695 (format
5696 "How many articles from %s (%s %d): "
01c52d31 5697 (gnus-group-decoded-name gnus-newsgroup-name)
23f87bed
MB
5698 (if initial "max" "default")
5699 number)
5700 (if initial
5701 (cons (number-to-string initial)
5702 0)))))
eec82323
LMI
5703 (if (string-match "^[ \t]*$" input) number input)))
5704 ((and (> scored marked) (< scored number)
5705 (> (- scored number) 20))
5706 (let ((input
5707 (read-string
5708 (format "%s %s (%d scored, %d total): "
5709 "How many articles from"
23f87bed
MB
5710 (gnus-group-decoded-name group)
5711 scored number))))
eec82323
LMI
5712 (if (string-match "^[ \t]*$" input)
5713 number input)))
5714 (t number))
d4dfaa19
DL
5715 (quit
5716 (message "Quit getting the articles to read")
5717 nil))))))
eec82323
LMI
5718 (setq select (if (stringp select) (string-to-number select) select))
5719 (if (or (null select) (zerop select))
5720 select
5721 (if (and (not (zerop scored)) (<= (abs select) scored))
5722 (progn
5723 (setq articles (sort scored-list '<))
5724 (setq number (length articles)))
5725 (setq articles (copy-sequence articles)))
5726
5727 (when (< (abs select) number)
5728 (if (< select 0)
5729 ;; Select the N oldest articles.
5730 (setcdr (nthcdr (1- (abs select)) articles) nil)
5731 ;; Select the N most recent articles.
5732 (setq articles (nthcdr (- number select) articles))))
5733 (setq gnus-newsgroup-unselected
23f87bed 5734 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5735 (when gnus-alter-articles-to-read-function
23f87bed 5736 (setq articles
a1506d29 5737 (sort
16409b0b 5738 (funcall gnus-alter-articles-to-read-function
23f87bed 5739 gnus-newsgroup-name articles)
16409b0b 5740 '<)))
eec82323
LMI
5741 articles)))
5742
5743(defun gnus-killed-articles (killed articles)
5744 (let (out)
5745 (while articles
5746 (when (inline (gnus-member-of-range (car articles) killed))
5747 (push (car articles) out))
5748 (setq articles (cdr articles)))
5749 out))
5750
5751(defun gnus-uncompress-marks (marks)
5752 "Uncompress the mark ranges in MARKS."
5753 (let ((uncompressed '(score bookmark))
5754 out)
5755 (while marks
5756 (if (memq (caar marks) uncompressed)
5757 (push (car marks) out)
5758 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5759 (setq marks (cdr marks)))
5760 out))
5761
23f87bed
MB
5762(defun gnus-article-mark-to-type (mark)
5763 "Return the type of MARK."
5764 (or (cadr (assq mark gnus-article-special-mark-lists))
5765 'list))
5766
5767(defun gnus-article-unpropagatable-p (mark)
5768 "Return whether MARK should be propagated to back end."
5769 (memq mark gnus-article-unpropagated-mark-lists))
5770
eec82323 5771(defun gnus-adjust-marked-articles (info)
16409b0b 5772 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5773 (let* ((marked-lists (gnus-info-marks info))
5774 (active (gnus-active (gnus-info-group info)))
5775 (min (car active))
5776 (max (cdr active))
5777 (types gnus-article-mark-lists)
54506618
MB
5778 marks var articles article mark mark-type
5779 bgn end)
eec82323 5780
23f87bed
MB
5781 (dolist (marks marked-lists)
5782 (setq mark (car marks)
5783 mark-type (gnus-article-mark-to-type mark)
5784 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5785
23f87bed
MB
5786 ;; We set the variable according to the type of the marks list,
5787 ;; and then adjust the marks to a subset of the active articles.
eec82323 5788 (cond
54506618 5789 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5790 ((eq mark-type 'list)
54506618
MB
5791 ;; Simultaneously uncompress and clip to active range
5792 ;; See gnus-uncompress-range for a description of possible marks
5793 (let (l lh)
5794 (if (not (cadr marks))
5795 (set var nil)
5796 (setq articles (if (numberp (cddr marks))
5797 (list (cdr marks))
5798 (cdr marks))
5799 lh (cons nil nil)
5800 l lh)
5801
5802 (while (setq article (pop articles))
5803 (cond ((consp article)
5804 (setq bgn (max (car article) min)
5805 end (min (cdr article) max))
5806 (while (<= bgn end)
5807 (setq l (setcdr l (cons bgn nil))
5808 bgn (1+ bgn))))
5809 ((and (<= min article)
5810 (>= max article))
5811 (setq l (setcdr l (cons article nil))))))
5812 (set var (cdr lh)))))
eec82323 5813 ;; Adjust assocs.
23f87bed
MB
5814 ((eq mark-type 'tuple)
5815 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5816 (when (not (listp (cdr (symbol-value var))))
5817 (set var (list (symbol-value var))))
5818 (when (not (listp (cdr articles)))
5819 (setq articles (list articles)))
eec82323
LMI
5820 (while articles
5821 (when (or (not (consp (setq article (pop articles))))
5822 (< (car article) min)
5823 (> (car article) max))
23f87bed
MB
5824 (set var (delq article (symbol-value var))))))
5825 ;; Adjust ranges (sloppily).
5826 ((eq mark-type 'range)
5827 (cond
5828 ((eq mark 'seen)
5829 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5830 ;; It should be (seen (NUM1 . NUM2)).
5831 (when (numberp (cddr marks))
5832 (setcdr marks (list (cdr marks))))
5833 (setq articles (cdr marks))
5834 (while (and articles
5835 (or (and (consp (car articles))
5836 (> min (cdar articles)))
5837 (and (numberp (car articles))
5838 (> min (car articles)))))
5839 (pop articles))
5840 (set var articles))))))))
eec82323
LMI
5841
5842(defun gnus-update-missing-marks (missing)
6748645f 5843 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 5844 (when missing
23f87bed 5845 (let (var m)
eec82323 5846 ;; Go through all types.
23f87bed
MB
5847 (dolist (elem gnus-article-mark-lists)
5848 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5849 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5850 (when (symbol-value var)
5851 ;; This list has articles. So we delete all missing
5852 ;; articles from it.
5853 (setq m missing)
5854 (while m
5855 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
5856
5857(defun gnus-update-marks ()
5858 "Enter the various lists of marked articles into the newsgroup info list."
5859 (let ((types gnus-article-mark-lists)
5860 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 5861 type list newmarked symbol delta-marks)
eec82323 5862 (when info
16409b0b 5863 ;; Add all marks lists to the list of marks lists.
eec82323 5864 (while (setq type (pop types))
16409b0b
GM
5865 (setq list (symbol-value
5866 (setq symbol
23f87bed 5867 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 5868
16409b0b 5869 (when list
eec82323
LMI
5870 ;; Get rid of the entries of the articles that have the
5871 ;; default score.
5872 (when (and (eq (cdr type) 'score)
5873 gnus-save-score
5874 list)
5875 (let* ((arts list)
5876 (prev (cons nil list))
5877 (all prev))
5878 (while arts
5879 (if (or (not (consp (car arts)))
5880 (= (cdar arts) gnus-summary-default-score))
5881 (setcdr prev (cdr arts))
5882 (setq prev arts))
5883 (setq arts (cdr arts)))
16409b0b
GM
5884 (setq list (cdr all)))))
5885
23f87bed
MB
5886 (when (eq (cdr type) 'seen)
5887 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5888
5889 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 5890 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 5891
23f87bed
MB
5892 (when (and (gnus-check-backend-function
5893 'request-set-mark gnus-newsgroup-name)
5894 (not (gnus-article-unpropagatable-p (cdr type))))
5895 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5896 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5897 (add (gnus-remove-from-range
5898 (gnus-copy-sequence list) old)))
5899 (when add
5900 (push (list add 'add (list (cdr type))) delta-marks))
5901 (when del
5902 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 5903
16409b0b
GM
5904 (when list
5905 (push (cons (cdr type) list) newmarked)))
5906
5907 (when delta-marks
5908 (unless (gnus-check-group gnus-newsgroup-name)
5909 (error "Can't open server for %s" gnus-newsgroup-name))
5910 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 5911
eec82323
LMI
5912 ;; Enter these new marks into the info of the group.
5913 (if (nthcdr 3 info)
5914 (setcar (nthcdr 3 info) newmarked)
5915 ;; Add the marks lists to the end of the info.
5916 (when newmarked
5917 (setcdr (nthcdr 2 info) (list newmarked))))
5918
5919 ;; Cut off the end of the info if there's nothing else there.
5920 (let ((i 5))
5921 (while (and (> i 2)
5922 (not (nth i info)))
5923 (when (nthcdr (decf i) info)
5924 (setcdr (nthcdr i info) nil)))))))
5925
5926(defun gnus-set-mode-line (where)
16409b0b 5927 "Set the mode line of the article or summary buffers.
eec82323
LMI
5928If WHERE is `summary', the summary mode line format will be used."
5929 ;; Is this mode line one we keep updated?
16409b0b
GM
5930 (when (and (memq where gnus-updated-mode-lines)
5931 (symbol-value
5932 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323
LMI
5933 (let (mode-string)
5934 (save-excursion
5935 ;; We evaluate this in the summary buffer since these
5936 ;; variables are buffer-local to that buffer.
5937 (set-buffer gnus-summary-buffer)
23f87bed 5938 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
5939 ;; below.
5940 (let* ((mformat (symbol-value
5941 (intern
5942 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
5943 (gnus-tmp-group-name (gnus-mode-string-quote
5944 (gnus-group-decoded-name
5945 gnus-newsgroup-name)))
eec82323
LMI
5946 (gnus-tmp-article-number (or gnus-current-article 0))
5947 (gnus-tmp-unread gnus-newsgroup-unreads)
5948 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5949 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5950 (gnus-tmp-unread-and-unselected
5951 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5952 (zerop gnus-tmp-unselected))
5953 "")
5954 ((zerop gnus-tmp-unselected)
5955 (format "{%d more}" gnus-tmp-unread-and-unticked))
5956 (t (format "{%d(+%d) more}"
5957 gnus-tmp-unread-and-unticked
5958 gnus-tmp-unselected))))
5959 (gnus-tmp-subject
5960 (if (and gnus-current-headers
5961 (vectorp gnus-current-headers))
5962 (gnus-mode-string-quote
5963 (mail-header-subject gnus-current-headers))
5964 ""))
5965 bufname-length max-len
23f87bed 5966 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
5967 (setq mode-string (eval mformat))
5968 (setq bufname-length (if (string-match "%b" mode-string)
5969 (- (length
5970 (buffer-name
5971 (if (eq where 'summary)
5972 nil
5973 (get-buffer gnus-article-buffer))))
5974 2)
5975 0))
5976 (setq max-len (max 4 (if gnus-mode-non-string-length
5977 (- (window-width)
5978 gnus-mode-non-string-length
5979 bufname-length)
5980 (length mode-string))))
5981 ;; We might have to chop a bit of the string off...
5982 (when (> (length mode-string) max-len)
5983 (setq mode-string
16409b0b 5984 (concat (truncate-string-to-width mode-string (- max-len 3))
eec82323
LMI
5985 "...")))
5986 ;; Pad the mode string a bit.
5987 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5988 ;; Update the mode line.
5989 (setq mode-line-buffer-identification
5990 (gnus-mode-line-buffer-identification (list mode-string)))
5991 (set-buffer-modified-p t))))
5992
5993(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5994 "Go through the HEADERS list and add all Xrefs to a hash table.
5995The resulting hash table is returned, or nil if no Xrefs were found."
5996 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5997 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5998 (xref-hashtb (gnus-make-hashtable))
5999 start group entry number xrefs header)
6000 (while headers
6001 (setq header (pop headers))
6002 (when (and (setq xrefs (mail-header-xref header))
6003 (not (memq (setq number (mail-header-number header))
6004 unreads)))
6005 (setq start 0)
6006 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6007 (setq start (match-end 0))
6008 (setq group (if prefix
6009 (concat prefix (substring xrefs (match-beginning 1)
6010 (match-end 1)))
6011 (substring xrefs (match-beginning 1) (match-end 1))))
6012 (setq number
e9bd5782 6013 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
6014 (match-end 2))))
6015 (if (setq entry (gnus-gethash group xref-hashtb))
6016 (setcdr entry (cons number (cdr entry)))
6017 (gnus-sethash group (cons number nil) xref-hashtb)))))
6018 (and start xref-hashtb)))
6019
6020(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6021 "Look through all the headers and mark the Xrefs as read."
6022 (let ((virtual (gnus-virtual-group-p from-newsgroup))
01c52d31 6023 name info xref-hashtb idlist method nth4)
eec82323
LMI
6024 (save-excursion
6025 (set-buffer gnus-group-buffer)
6026 (when (setq xref-hashtb
6027 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6028 (mapatoms
6029 (lambda (group)
6030 (unless (string= from-newsgroup (setq name (symbol-name group)))
6031 (setq idlist (symbol-value group))
6032 ;; Dead groups are not updated.
6033 (and (prog1
01c52d31 6034 (setq info (gnus-get-info name))
eec82323
LMI
6035 (when (stringp (setq nth4 (gnus-info-method info)))
6036 (setq nth4 (gnus-server-to-method nth4))))
6037 ;; Only do the xrefs if the group has the same
6038 ;; select method as the group we have just read.
6039 (or (gnus-methods-equal-p
6040 nth4 (gnus-find-method-for-group from-newsgroup))
6041 virtual
6042 (equal nth4 (setq method (gnus-find-method-for-group
6043 from-newsgroup)))
6044 (and (equal (car nth4) (car method))
6045 (equal (nth 1 nth4) (nth 1 method))))
6046 gnus-use-cross-reference
6047 (or (not (eq gnus-use-cross-reference t))
6048 virtual
6049 ;; Only do cross-references on subscribed
6050 ;; groups, if that is what is wanted.
6051 (<= (gnus-info-level info) gnus-level-subscribed))
6052 (gnus-group-make-articles-read name idlist))))
6053 xref-hashtb)))))
6054
6748645f 6055(defun gnus-compute-read-articles (group articles)
01c52d31 6056 (let* ((entry (gnus-group-entry group))
6748645f
LMI
6057 (info (nth 2 entry))
6058 (active (gnus-active group))
6059 ninfo)
6060 (when entry
16409b0b 6061 ;; First peel off all invalid article numbers.
6748645f
LMI
6062 (when active
6063 (let ((ids articles)
6064 id first)
6065 (while (setq id (pop ids))
6066 (when (and first (> id (cdr active)))
6067 ;; We'll end up in this situation in one particular
6068 ;; obscure situation. If you re-scan a group and get
6069 ;; a new article that is cross-posted to a different
6070 ;; group that has not been re-scanned, you might get
6071 ;; crossposted article that has a higher number than
6072 ;; Gnus believes possible. So we re-activate this
6073 ;; group as well. This might mean doing the
6074 ;; crossposting thingy will *increase* the number
6075 ;; of articles in some groups. Tsk, tsk.
6076 (setq active (or (gnus-activate-group group) active)))
6077 (when (or (> id (cdr active))
6078 (< id (car active)))
6079 (setq articles (delq id articles))))))
6080 ;; If the read list is nil, we init it.
6081 (if (and active
6082 (null (gnus-info-read info))
6083 (> (car active) 1))
6084 (setq ninfo (cons 1 (1- (car active))))
6085 (setq ninfo (gnus-info-read info)))
6086 ;; Then we add the read articles to the range.
6087 (gnus-add-to-range
6088 ninfo (setq articles (sort articles '<))))))
6089
eec82323
LMI
6090(defun gnus-group-make-articles-read (group articles)
6091 "Update the info of GROUP to say that ARTICLES are read."
6092 (let* ((num 0)
01c52d31 6093 (entry (gnus-group-entry group))
eec82323
LMI
6094 (info (nth 2 entry))
6095 (active (gnus-active group))
6096 range)
6748645f
LMI
6097 (when entry
6098 (setq range (gnus-compute-read-articles group articles))
01c52d31 6099 (with-current-buffer gnus-group-buffer
6748645f
LMI
6100 (gnus-undo-register
6101 `(progn
6102 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6103 (gnus-info-set-read ',info ',(gnus-info-read info))
6104 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 6105 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
6106 (gnus-group-update-group ,group t))))
6107 ;; Add the read articles to the range.
6108 (gnus-info-set-read info range)
23f87bed 6109 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
6110 ;; Then we have to re-compute how many unread
6111 ;; articles there are in this group.
6112 (when active
6113 (cond
6114 ((not range)
6115 (setq num (- (1+ (cdr active)) (car active))))
6116 ((not (listp (cdr range)))
6117 (setq num (- (cdr active) (- (1+ (cdr range))
6118 (car range)))))
6119 (t
6120 (while range
6121 (if (numberp (car range))
6122 (setq num (1+ num))
6123 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6124 (setq range (cdr range)))
6125 (setq num (- (cdr active) num))))
6126 ;; Update the number of unread articles.
6127 (setcar entry num)
6128 ;; Update the group buffer.
23f87bed
MB
6129 (unless (gnus-ephemeral-group-p group)
6130 (gnus-group-update-group group t))))))
eec82323 6131
eec82323
LMI
6132(defvar gnus-newsgroup-none-id 0)
6133
6134(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6135 (let ((cur nntp-server-buffer)
6136 (dependencies
6137 (or dependencies
01c52d31
MB
6138 (with-current-buffer gnus-summary-buffer
6139 gnus-newsgroup-dependencies)))
6140 headers id end ref number
16409b0b
GM
6141 (mail-parse-charset gnus-newsgroup-charset)
6142 (mail-parse-ignored-charsets
6143 (save-excursion (condition-case nil
6144 (set-buffer gnus-summary-buffer)
6145 (error))
6146 gnus-newsgroup-ignored-charsets)))
eec82323
LMI
6147 (save-excursion
6148 (set-buffer nntp-server-buffer)
6149 ;; Translate all TAB characters into SPACE characters.
6150 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 6151 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 6152 (ietf-drums-unfold-fws)
6748645f 6153 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6154 (let ((case-fold-search t)
6748645f 6155 in-reply-to header p lines chars)
eec82323 6156 (goto-char (point-min))
01ccbb85 6157 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
6158 ;; do not begin with 2 or 3.
6159 (while (re-search-forward "^[23][0-9]+ " nil t)
6160 (setq id nil
6161 ref nil)
6162 ;; This implementation of this function, with nine
6163 ;; search-forwards instead of the one re-search-forward and
6164 ;; a case (which basically was the old function) is actually
01ccbb85 6165 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
6166 ;; can't have everything, I guess. Speed and elegance
6167 ;; doesn't always go hand in hand.
6168 (setq
6169 header
6170 (vector
6171 ;; Number.
6172 (prog1
01c52d31 6173 (setq number (read cur))
eec82323
LMI
6174 (end-of-line)
6175 (setq p (point))
6176 (narrow-to-region (point)
6177 (or (and (search-forward "\n.\n" nil t)
6178 (- (point) 2))
6179 (point))))
6180 ;; Subject.
6181 (progn
6182 (goto-char p)
23f87bed 6183 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
6184 (funcall gnus-decode-encoded-word-function
6185 (nnheader-header-value))
2bd3dcae 6186 "(none)"))
eec82323
LMI
6187 ;; From.
6188 (progn
6189 (goto-char p)
23f87bed 6190 (if (search-forward "\nfrom:" nil t)
343d6628 6191 (funcall gnus-decode-encoded-address-function
16409b0b 6192 (nnheader-header-value))
2bd3dcae 6193 "(nobody)"))
eec82323
LMI
6194 ;; Date.
6195 (progn
6196 (goto-char p)
23f87bed 6197 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6198 (nnheader-header-value) ""))
6199 ;; Message-ID.
6200 (progn
6201 (goto-char p)
6748645f
LMI
6202 (setq id (if (re-search-forward
6203 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6204 ;; We do it this way to make sure the Message-ID
6205 ;; is (somewhat) syntactically valid.
6206 (buffer-substring (match-beginning 1)
6207 (match-end 1))
eec82323
LMI
6208 ;; If there was no message-id, we just fake one
6209 ;; to make subsequent routines simpler.
01c52d31 6210 (nnheader-generate-fake-message-id number))))
eec82323
LMI
6211 ;; References.
6212 (progn
6213 (goto-char p)
23f87bed 6214 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6215 (progn
6216 (setq end (point))
6217 (prog1
6218 (nnheader-header-value)
6219 (setq ref
6220 (buffer-substring
6221 (progn
6222 (end-of-line)
6223 (search-backward ">" end t)
6224 (1+ (point)))
6225 (progn
6226 (search-backward "<" end t)
6227 (point))))))
6228 ;; Get the references from the in-reply-to header if there
6229 ;; were no references and the in-reply-to header looks
6230 ;; promising.
23f87bed 6231 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6232 (setq in-reply-to (nnheader-header-value))
6233 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6234 (let (ref2)
6235 (setq ref (substring in-reply-to (match-beginning 0)
6236 (match-end 0)))
6237 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6238 (setq ref2 (substring in-reply-to (match-beginning 0)
6239 (match-end 0)))
6240 (when (> (length ref2) (length ref))
6241 (setq ref ref2)))
6242 ref)
eec82323
LMI
6243 (setq ref nil))))
6244 ;; Chars.
6748645f
LMI
6245 (progn
6246 (goto-char p)
6247 (if (search-forward "\nchars: " nil t)
6248 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6249 chars -1)
6250 -1))
eec82323
LMI
6251 ;; Lines.
6252 (progn
6253 (goto-char p)
6254 (if (search-forward "\nlines: " nil t)
a8151ef7 6255 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6256 lines -1)
6257 -1))
eec82323
LMI
6258 ;; Xref.
6259 (progn
6260 (goto-char p)
23f87bed 6261 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6262 (nnheader-header-value)))
6263 ;; Extra.
6264 (when gnus-extra-headers
6265 (let ((extra gnus-extra-headers)
6266 out)
6267 (while extra
6268 (goto-char p)
6269 (when (search-forward
23f87bed 6270 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6271 (push (cons (car extra) (nnheader-header-value))
6272 out))
6273 (pop extra))
6274 out))))
eec82323
LMI
6275 (when (equal id ref)
6276 (setq ref nil))
6748645f
LMI
6277
6278 (when gnus-alter-header-function
6279 (funcall gnus-alter-header-function header)
6280 (setq id (mail-header-id header)
6281 ref (gnus-parent-id (mail-header-references header))))
6282
6283 (when (setq header
6284 (gnus-dependencies-add-header
6285 header dependencies force-new))
eec82323
LMI
6286 (push header headers))
6287 (goto-char (point-max))
6288 (widen))
6289 (nreverse headers)))))
6290
eec82323
LMI
6291;; Goes through the xover lines and returns a list of vectors
6292(defun gnus-get-newsgroup-headers-xover (sequence &optional
6293 force-new dependencies
6294 group also-fetch-heads)
16409b0b
GM
6295 "Parse the news overview data in the server buffer.
6296Return a list of headers that match SEQUENCE (see
6297`nntp-retrieve-headers')."
eec82323
LMI
6298 ;; Get the Xref when the users reads the articles since most/some
6299 ;; NNTP servers do not include Xrefs when using XOVER.
6300 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6301 (let ((mail-parse-charset gnus-newsgroup-charset)
6302 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6303 (cur nntp-server-buffer)
eec82323 6304 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6305 (allp (cond
6306 ((eq gnus-read-all-available-headers t)
6307 t)
14e6dc54
MB
6308 ((and (stringp gnus-read-all-available-headers)
6309 group)
23f87bed
MB
6310 (string-match gnus-read-all-available-headers group))
6311 (t
6312 nil)))
eec82323
LMI
6313 number headers header)
6314 (save-excursion
6315 (set-buffer nntp-server-buffer)
16409b0b 6316 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6317 ;; Allow the user to mangle the headers before parsing them.
6748645f 6318 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6319 (goto-char (point-min))
23f87bed
MB
6320 (gnus-parse-without-error
6321 (while (and (or sequence allp)
6322 (not (eobp)))
6323 (setq number (read cur))
6324 (when (not allp)
6325 (while (and sequence
6326 (< (car sequence) number))
6327 (setq sequence (cdr sequence))))
6328 (when (and (or allp
6329 (and sequence
6330 (eq number (car sequence))))
6331 (progn
6332 (setq sequence (cdr sequence))
6333 (setq header (inline
6334 (gnus-nov-parse-line
6335 number dependencies force-new)))))
6336 (push header headers))
6337 (forward-line 1)))
eec82323
LMI
6338 ;; A common bug in inn is that if you have posted an article and
6339 ;; then retrieves the active file, it will answer correctly --
6340 ;; the new article is included. However, a NOV entry for the
6341 ;; article may not have been generated yet, so this may fail.
6342 ;; We work around this problem by retrieving the last few
6343 ;; headers using HEAD.
6344 (if (or (not also-fetch-heads)
6345 (not sequence))
6346 ;; We (probably) got all the headers.
6347 (nreverse headers)
6348 (let ((gnus-nov-is-evil t))
6349 (nconc
6350 (nreverse headers)
23f87bed 6351 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6352 (gnus-get-newsgroup-headers))))))))
6353
6354(defun gnus-article-get-xrefs ()
6355 "Fill in the Xref value in `gnus-current-headers', if necessary.
6356This is meant to be called in `gnus-article-internal-prepare-hook'."
01c52d31
MB
6357 (let ((headers (with-current-buffer gnus-summary-buffer
6358 gnus-current-headers)))
eec82323
LMI
6359 (or (not gnus-use-cross-reference)
6360 (not headers)
6361 (and (mail-header-xref headers)
6362 (not (string= (mail-header-xref headers) "")))
6363 (let ((case-fold-search t)
6364 xref)
6365 (save-restriction
6366 (nnheader-narrow-to-headers)
6367 (goto-char (point-min))
16409b0b
GM
6368 (when (or (and (not (eobp))
6369 (eq (downcase (char-after)) ?x)
eec82323
LMI
6370 (looking-at "Xref:"))
6371 (search-forward "\nXref:" nil t))
6372 (goto-char (1+ (match-end 0)))
01c52d31 6373 (setq xref (buffer-substring (point) (point-at-eol)))
eec82323
LMI
6374 (mail-header-set-xref headers xref)))))))
6375
6376(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6377 "Find article ID and insert the summary line for that article.
6378OLD-HEADER can either be a header or a line number to insert
6379the subject line on."
6380 (let* ((line (and (numberp old-header) old-header))
6381 (old-header (and (vectorp old-header) old-header))
6382 (header (cond ((and old-header use-old-header)
16409b0b
GM
6383 old-header)
6384 ((and (numberp id)
6385 (gnus-number-to-header id))
6386 (gnus-number-to-header id))
6387 (t
6388 (gnus-read-header id))))
6389 (number (and (numberp id) id))
6390 d)
eec82323
LMI
6391 (when header
6392 ;; Rebuild the thread that this article is part of and go to the
6393 ;; article we have fetched.
6394 (when (and (not gnus-show-threads)
6395 old-header)
6748645f
LMI
6396 (when (and number
6397 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6398 (goto-char (gnus-data-pos d))
6399 (gnus-data-remove
6400 number
01c52d31 6401 (- (point-at-bol)
eec82323 6402 (prog1
01c52d31 6403 (1+ (point-at-eol))
eec82323 6404 (gnus-delete-line))))))
23f87bed
MB
6405 ;; Remove list identifiers from subject.
6406 (when gnus-list-identifiers
6407 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6408 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6409 (when old-header
6410 (mail-header-set-number header (mail-header-number old-header)))
6411 (setq gnus-newsgroup-sparse
6412 (delq (setq number (mail-header-number header))
6413 gnus-newsgroup-sparse))
6414 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6415 (push number gnus-newsgroup-limit)
6416 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6417 (gnus-summary-goto-subject number nil t))
6418 (when (and (numberp number)
6419 (> number 0))
6420 ;; We have to update the boundaries even if we can't fetch the
6421 ;; article if ID is a number -- so that the next `P' or `N'
6422 ;; command will fetch the previous (or next) article even
6423 ;; if the one we tried to fetch this time has been canceled.
6424 (when (> number gnus-newsgroup-end)
6425 (setq gnus-newsgroup-end number))
6426 (when (< number gnus-newsgroup-begin)
6427 (setq gnus-newsgroup-begin number))
6428 (setq gnus-newsgroup-unselected
6429 (delq number gnus-newsgroup-unselected)))
6430 ;; Report back a success?
6431 (and header (mail-header-number header))))
6432
6433;;; Process/prefix in the summary buffer
6434
6435(defun gnus-summary-work-articles (n)
6748645f
LMI
6436 "Return a list of articles to be worked upon.
6437The prefix argument, the list of process marked articles, and the
6438current article will be taken into consideration."
6439 (save-excursion
6440 (set-buffer gnus-summary-buffer)
6441 (cond
6442 (n
6443 ;; A numerical prefix has been given.
6444 (setq n (prefix-numeric-value n))
6445 (let ((backward (< n 0))
6446 (n (abs (prefix-numeric-value n)))
6447 articles article)
6448 (save-excursion
6449 (while
6450 (and (> n 0)
6451 (push (setq article (gnus-summary-article-number))
6452 articles)
6453 (if backward
6454 (gnus-summary-find-prev nil article)
6455 (gnus-summary-find-next nil article)))
6456 (decf n)))
6457 (nreverse articles)))
6458 ((and (gnus-region-active-p) (mark))
6459 (message "region active")
6460 ;; Work on the region between point and mark.
6461 (let ((max (max (point) (mark)))
6462 articles article)
6463 (save-excursion
7dafe00b 6464 (goto-char (min (point) (mark)))
6748645f
LMI
6465 (while
6466 (and
6467 (push (setq article (gnus-summary-article-number)) articles)
6468 (gnus-summary-find-next nil article)
6469 (< (point) max)))
6470 (nreverse articles))))
6471 (gnus-newsgroup-processable
6472 ;; There are process-marked articles present.
6473 ;; Save current state.
6474 (gnus-summary-save-process-mark)
6475 ;; Return the list.
6476 (reverse gnus-newsgroup-processable))
6477 (t
6478 ;; Just return the current article.
6479 (list (gnus-summary-article-number))))))
6480
6481(defmacro gnus-summary-iterate (arg &rest forms)
6482 "Iterate over the process/prefixed articles and do FORMS.
6483ARG is the interactive prefix given to the command. FORMS will be
6484executed with point over the summary line of the articles."
6485 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6486 `(let ((,articles (gnus-summary-work-articles ,arg)))
6487 (while ,articles
6488 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6489 ,@forms
6490 (pop ,articles)))))
6748645f
LMI
6491
6492(put 'gnus-summary-iterate 'lisp-indent-function 1)
6493(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6494
6495(defun gnus-summary-save-process-mark ()
6496 "Push the current set of process marked articles on the stack."
6497 (interactive)
6498 (push (copy-sequence gnus-newsgroup-processable)
6499 gnus-newsgroup-process-stack))
6500
6501(defun gnus-summary-kill-process-mark ()
6502 "Push the current set of process marked articles on the stack and unmark."
6503 (interactive)
6504 (gnus-summary-save-process-mark)
6505 (gnus-summary-unmark-all-processable))
6506
6507(defun gnus-summary-yank-process-mark ()
6508 "Pop the last process mark state off the stack and restore it."
6509 (interactive)
6510 (unless gnus-newsgroup-process-stack
6511 (error "Empty mark stack"))
6512 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6513
6514(defun gnus-summary-process-mark-set (set)
6515 "Make SET into the current process marked articles."
6516 (gnus-summary-unmark-all-processable)
01c52d31 6517 (mapc 'gnus-summary-set-process-mark set))
eec82323
LMI
6518
6519;;; Searching and stuff
6520
6521(defun gnus-summary-search-group (&optional backward use-level)
6522 "Search for next unread newsgroup.
6523If optional argument BACKWARD is non-nil, search backward instead."
6524 (save-excursion
6525 (set-buffer gnus-group-buffer)
6526 (when (gnus-group-search-forward
6527 backward nil (if use-level (gnus-group-group-level) nil))
6528 (gnus-group-group-name))))
6529
6530(defun gnus-summary-best-group (&optional exclude-group)
6531 "Find the name of the best unread group.
6532If EXCLUDE-GROUP, do not go to this group."
01c52d31 6533 (with-current-buffer gnus-group-buffer
eec82323
LMI
6534 (save-excursion
6535 (gnus-group-best-unread-group exclude-group))))
6536
23f87bed
MB
6537(defun gnus-summary-find-next (&optional unread article backward)
6538 (if backward
6539 (gnus-summary-find-prev unread article)
eec82323
LMI
6540 (let* ((dummy (gnus-summary-article-intangible-p))
6541 (article (or article (gnus-summary-article-number)))
23f87bed 6542 (data (gnus-data-find-list article))
eec82323
LMI
6543 result)
6544 (when (and (not dummy)
6545 (or (not gnus-summary-check-current)
6546 (not unread)
23f87bed
MB
6547 (not (gnus-data-unread-p (car data)))))
6548 (setq data (cdr data)))
eec82323
LMI
6549 (when (setq result
6550 (if unread
6551 (progn
23f87bed
MB
6552 (while data
6553 (unless (memq (gnus-data-number (car data))
6554 (cond
6555 ((eq gnus-auto-goto-ignores
6556 'always-undownloaded)
6557 gnus-newsgroup-undownloaded)
6558 (gnus-plugged
6559 nil)
6560 ((eq gnus-auto-goto-ignores
6561 'unfetched)
6562 gnus-newsgroup-unfetched)
6563 ((eq gnus-auto-goto-ignores
6564 'undownloaded)
6565 gnus-newsgroup-undownloaded)))
6566 (when (gnus-data-unread-p (car data))
6567 (setq result (car data)
6568 data nil)))
6569 (setq data (cdr data)))
eec82323 6570 result)
23f87bed 6571 (car data)))
eec82323
LMI
6572 (goto-char (gnus-data-pos result))
6573 (gnus-data-number result)))))
6574
6575(defun gnus-summary-find-prev (&optional unread article)
6576 (let* ((eobp (eobp))
6577 (article (or article (gnus-summary-article-number)))
23f87bed 6578 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6579 result)
6580 (when (and (not eobp)
6581 (or (not gnus-summary-check-current)
6582 (not unread)
23f87bed
MB
6583 (not (gnus-data-unread-p (car data)))))
6584 (setq data (cdr data)))
eec82323
LMI
6585 (when (setq result
6586 (if unread
6587 (progn
23f87bed
MB
6588 (while data
6589 (unless (memq (gnus-data-number (car data))
6590 (cond
6591 ((eq gnus-auto-goto-ignores
6592 'always-undownloaded)
6593 gnus-newsgroup-undownloaded)
6594 (gnus-plugged
6595 nil)
6596 ((eq gnus-auto-goto-ignores
6597 'unfetched)
6598 gnus-newsgroup-unfetched)
6599 ((eq gnus-auto-goto-ignores
6600 'undownloaded)
6601 gnus-newsgroup-undownloaded)))
6602 (when (gnus-data-unread-p (car data))
6603 (setq result (car data)
6604 data nil)))
6605 (setq data (cdr data)))
eec82323 6606 result)
23f87bed 6607 (car data)))
eec82323
LMI
6608 (goto-char (gnus-data-pos result))
6609 (gnus-data-number result))))
6610
6611(defun gnus-summary-find-subject (subject &optional unread backward article)
6612 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6613 (article (or article (gnus-summary-article-number)))
6614 (articles (gnus-data-list backward))
6615 (arts (gnus-data-find-list article articles))
6616 result)
6617 (when (or (not gnus-summary-check-current)
6618 (not unread)
6619 (not (gnus-data-unread-p (car arts))))
6620 (setq arts (cdr arts)))
6621 (while arts
6622 (and (or (not unread)
6623 (gnus-data-unread-p (car arts)))
6624 (vectorp (gnus-data-header (car arts)))
6625 (gnus-subject-equal
6626 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6627 (setq result (car arts)
6628 arts nil))
6629 (setq arts (cdr arts)))
6630 (and result
6631 (goto-char (gnus-data-pos result))
6632 (gnus-data-number result))))
6633
6634(defun gnus-summary-search-forward (&optional unread subject backward)
6635 "Search forward for an article.
6636If UNREAD, look for unread articles. If SUBJECT, look for
6637articles with that subject. If BACKWARD, search backward instead."
6638 (cond (subject (gnus-summary-find-subject subject unread backward))
6639 (backward (gnus-summary-find-prev unread))
6640 (t (gnus-summary-find-next unread))))
6641
6642(defun gnus-recenter (&optional n)
6643 "Center point in window and redisplay frame.
6644Also do horizontal recentering."
6645 (interactive "P")
6646 (when (and gnus-auto-center-summary
6647 (not (eq gnus-auto-center-summary 'vertical)))
6648 (gnus-horizontal-recenter))
6649 (recenter n))
6650
6651(defun gnus-summary-recenter ()
6652 "Center point in the summary window.
6653If `gnus-auto-center-summary' is nil, or the article buffer isn't
6654displayed, no centering will be performed."
6655 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6656 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6657 (interactive)
23f87bed
MB
6658 ;; The user has to want it.
6659 (when gnus-auto-center-summary
6660 (let* ((top (cond ((< (window-height) 4) 0)
6661 ((< (window-height) 7) 1)
6662 (t (if (numberp gnus-auto-center-summary)
6663 gnus-auto-center-summary
01c52d31 6664 (/ (1- (window-height)) 2)))))
23f87bed
MB
6665 (height (1- (window-height)))
6666 (bottom (save-excursion (goto-char (point-max))
6667 (forward-line (- height))
6668 (point)))
6669 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6670 (when (get-buffer-window gnus-article-buffer)
6671 ;; Only do recentering when the article buffer is displayed,
6672 ;; Set the window start to either `bottom', which is the biggest
6673 ;; possible valid number, or the second line from the top,
6674 ;; whichever is the least.
db7ebd73
MB
6675 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6676 (if (> bottom top-pos)
6677 ;; Keep the second line from the top visible
01c52d31 6678 (set-window-start window top-pos)
db7ebd73
MB
6679 ;; Try to keep the bottom line visible; if it's partially
6680 ;; obscured, either scroll one more line to make it fully
6681 ;; visible, or revert to using TOP-POS.
6682 (save-excursion
6683 (goto-char (point-max))
6684 (forward-line -1)
6685 (let ((last-line-start (point)))
6686 (goto-char bottom)
6687 (set-window-start window (point) t)
6688 (when (not (pos-visible-in-window-p last-line-start window))
6689 (forward-line 1)
6690 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6691 ;; Do horizontal recentering while we're at it.
6692 (when (and (get-buffer-window (current-buffer) t)
6693 (not (eq gnus-auto-center-summary 'vertical)))
6694 (let ((selected (selected-window)))
6695 (select-window (get-buffer-window (current-buffer) t))
6696 (gnus-summary-position-point)
6697 (gnus-horizontal-recenter)
6698 (select-window selected))))))
6699
6700(defun gnus-summary-jump-to-group (newsgroup)
6701 "Move point to NEWSGROUP in group mode buffer."
6702 ;; Keep update point of group mode buffer if visible.
6703 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6704 (save-window-excursion
6705 ;; Take care of tree window mode.
6706 (when (get-buffer-window gnus-group-buffer)
6707 (pop-to-buffer gnus-group-buffer))
6708 (gnus-group-jump-to-group newsgroup))
6709 (save-excursion
6710 ;; Take care of tree window mode.
6711 (if (get-buffer-window gnus-group-buffer)
6712 (pop-to-buffer gnus-group-buffer)
6713 (set-buffer gnus-group-buffer))
6714 (gnus-group-jump-to-group newsgroup))))
6715
6716;; This function returns a list of article numbers based on the
6717;; difference between the ranges of read articles in this group and
6718;; the range of active articles.
6719(defun gnus-list-of-unread-articles (group)
6720 (let* ((read (gnus-info-read (gnus-get-info group)))
6721 (active (or (gnus-active group) (gnus-activate-group group)))
01c52d31
MB
6722 (last (or (cdr active)
6723 (error "Group %s couldn't be activated " group)))
4b70e299
MB
6724 (bottom (if gnus-newsgroup-maximum-articles
6725 (max (car active)
6726 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6727 (car active)))
eec82323
LMI
6728 first nlast unread)
6729 ;; If none are read, then all are unread.
6730 (if (not read)
11abff8e 6731 (setq first bottom)
eec82323
LMI
6732 ;; If the range of read articles is a single range, then the
6733 ;; first unread article is the article after the last read
6734 ;; article. Sounds logical, doesn't it?
16409b0b 6735 (if (and (not (listp (cdr read)))
11abff8e 6736 (or (< (car read) bottom)
16409b0b
GM
6737 (progn (setq read (list read))
6738 nil)))
11abff8e 6739 (setq first (max bottom (1+ (cdr read))))
eec82323
LMI
6740 ;; `read' is a list of ranges.
6741 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6742 (caar read)))
6743 1)
11abff8e 6744 (setq first bottom))
eec82323
LMI
6745 (while read
6746 (when first
6747 (while (< first nlast)
54506618
MB
6748 (setq unread (cons first unread)
6749 first (1+ first))))
eec82323
LMI
6750 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6751 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6752 (setq read (cdr read)))))
6753 ;; And add the last unread articles.
6754 (while (<= first last)
54506618
MB
6755 (setq unread (cons first unread)
6756 first (1+ first)))
eec82323 6757 ;; Return the list of unread articles.
6748645f 6758 (delq 0 (nreverse unread))))
eec82323
LMI
6759
6760(defun gnus-list-of-read-articles (group)
6761 "Return a list of unread, unticked and non-dormant articles."
6762 (let* ((info (gnus-get-info group))
6763 (marked (gnus-info-marks info))
6764 (active (gnus-active group)))
6765 (and info active
23f87bed
MB
6766 (gnus-list-range-difference
6767 (gnus-list-range-difference
6768 (gnus-sorted-complement
11abff8e 6769 (gnus-uncompress-range
4b70e299 6770 (if gnus-newsgroup-maximum-articles
11abff8e 6771 (cons (max (car active)
4b70e299
MB
6772 (- (cdr active)
6773 gnus-newsgroup-maximum-articles
6774 -1))
11abff8e
MB
6775 (cdr active))
6776 active))
23f87bed
MB
6777 (gnus-list-of-unread-articles group))
6778 (cdr (assq 'dormant marked)))
6779 (cdr (assq 'tick marked))))))
eec82323 6780
54506618
MB
6781;; This function returns a sequence of article numbers based on the
6782;; difference between the ranges of read articles in this group and
6783;; the range of active articles.
6784(defun gnus-sequence-of-unread-articles (group)
6785 (let* ((read (gnus-info-read (gnus-get-info group)))
6786 (active (or (gnus-active group) (gnus-activate-group group)))
6787 (last (cdr active))
4b70e299
MB
6788 (bottom (if gnus-newsgroup-maximum-articles
6789 (max (car active)
6790 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6791 (car active)))
54506618
MB
6792 first nlast unread)
6793 ;; If none are read, then all are unread.
6794 (if (not read)
11abff8e 6795 (setq first bottom)
54506618
MB
6796 ;; If the range of read articles is a single range, then the
6797 ;; first unread article is the article after the last read
6798 ;; article. Sounds logical, doesn't it?
6799 (if (and (not (listp (cdr read)))
11abff8e 6800 (or (< (car read) bottom)
54506618
MB
6801 (progn (setq read (list read))
6802 nil)))
11abff8e 6803 (setq first (max bottom (1+ (cdr read))))
54506618
MB
6804 ;; `read' is a list of ranges.
6805 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6806 (caar read)))
6807 1)
11abff8e 6808 (setq first bottom))
54506618
MB
6809 (while read
6810 (when first
6811 (push (cons first nlast) unread))
6812 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6813 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6814 (setq read (cdr read)))))
6815 ;; And add the last unread articles.
ba0226dd
MB
6816 (cond ((not (and first last))
6817 nil)
6818 ((< first last)
6819 (push (cons first last) unread))
6820 ((= first last)
6821 (push first unread)))
54506618
MB
6822 ;; Return the sequence of unread articles.
6823 (delq 0 (nreverse unread))))
6824
eec82323
LMI
6825;; Various summary commands
6826
6748645f
LMI
6827(defun gnus-summary-select-article-buffer ()
6828 "Reconfigure windows to show article buffer."
6829 (interactive)
6830 (if (not (gnus-buffer-live-p gnus-article-buffer))
6831 (error "There is no article buffer for this summary buffer")
6832 (gnus-configure-windows 'article)
6833 (select-window (get-buffer-window gnus-article-buffer))))
6834
eec82323
LMI
6835(defun gnus-summary-universal-argument (arg)
6836 "Perform any operation on all articles that are process/prefixed."
6837 (interactive "P")
eec82323
LMI
6838 (let ((articles (gnus-summary-work-articles arg))
6839 func article)
6840 (if (eq
6841 (setq
6842 func
6843 (key-binding
6844 (read-key-sequence
6845 (substitute-command-keys
16409b0b 6846 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
6847 'undefined)
6848 (gnus-error 1 "Undefined key")
6849 (save-excursion
6850 (while articles
6851 (gnus-summary-goto-subject (setq article (pop articles)))
6852 (let (gnus-newsgroup-processable)
6853 (command-execute func))
6854 (gnus-summary-remove-process-mark article)))))
6855 (gnus-summary-position-point))
6856
6857(defun gnus-summary-toggle-truncation (&optional arg)
6858 "Toggle truncation of summary lines.
23f87bed 6859With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
6860 (interactive "P")
6861 (setq truncate-lines
6862 (if (null arg) (not truncate-lines)
6863 (> (prefix-numeric-value arg) 0)))
6864 (redraw-display))
6865
23f87bed
MB
6866(defun gnus-summary-find-for-reselect ()
6867 "Return the number of an article to stay on across a reselect.
6868The current article is considered, then following articles, then previous
6869articles. An article is sought which is not cancelled and isn't a temporary
6870insertion from another group. If there's no such then return a dummy 0."
6871 (let (found)
6872 (dolist (rev '(nil t))
6873 (unless found ; don't demand the reverse list if we don't need it
6874 (let ((data (gnus-data-find-list
6875 (gnus-summary-article-number) (gnus-data-list rev))))
6876 (while (and data (not found))
6877 (if (and (< 0 (gnus-data-number (car data)))
6878 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6879 (setq found (gnus-data-number (car data))))
6880 (setq data (cdr data))))))
6881 (or found 0)))
6882
eec82323
LMI
6883(defun gnus-summary-reselect-current-group (&optional all rescan)
6884 "Exit and then reselect the current newsgroup.
6885The prefix argument ALL means to select all articles."
6886 (interactive "P")
eec82323
LMI
6887 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6888 (error "Ephemeral groups can't be reselected"))
23f87bed 6889 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
6890 (group gnus-newsgroup-name))
6891 (setq gnus-newsgroup-begin nil)
23f87bed 6892 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
6893 ;; We have to adjust the point of group mode buffer because
6894 ;; point was moved to the next unread newsgroup by exiting.
6895 (gnus-summary-jump-to-group group)
6896 (when rescan
6897 (save-excursion
6898 (gnus-group-get-new-news-this-group 1)))
6899 (gnus-group-read-group all t)
6900 (gnus-summary-goto-subject current-subject nil t)))
6901
6902(defun gnus-summary-rescan-group (&optional all)
6903 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6904 (interactive "P")
6905 (gnus-summary-reselect-current-group all t))
6906
6907(defun gnus-summary-update-info (&optional non-destructive)
6908 (save-excursion
6909 (let ((group gnus-newsgroup-name))
6748645f
LMI
6910 (when group
6911 (when gnus-newsgroup-kill-headers
6912 (setq gnus-newsgroup-killed
6913 (gnus-compress-sequence
23f87bed
MB
6914 (gnus-sorted-union
6915 (gnus-list-range-intersection
6916 gnus-newsgroup-unselected gnus-newsgroup-killed)
6917 gnus-newsgroup-unreads)
6748645f
LMI
6918 t)))
6919 (unless (listp (cdr gnus-newsgroup-killed))
6920 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6921 (let ((headers gnus-newsgroup-headers))
6922 ;; Set the new ranges of read articles.
01c52d31 6923 (with-current-buffer gnus-group-buffer
6748645f
LMI
6924 (gnus-undo-force-boundary))
6925 (gnus-update-read-articles
23f87bed
MB
6926 group (gnus-sorted-union
6927 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
6928 ;; Set the current article marks.
6929 (let ((gnus-newsgroup-scored
6930 (if (and (not gnus-save-score)
6931 (not non-destructive))
6932 nil
6933 gnus-newsgroup-scored)))
6934 (save-excursion
6935 (gnus-update-marks)))
6936 ;; Do the cross-ref thing.
6937 (when gnus-use-cross-reference
6938 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6939 ;; Do not switch windows but change the buffer to work.
a8151ef7 6940 (set-buffer gnus-group-buffer)
6748645f
LMI
6941 (unless (gnus-ephemeral-group-p group)
6942 (gnus-group-update-group group)))))))
eec82323
LMI
6943
6944(defun gnus-summary-save-newsrc (&optional force)
6945 "Save the current number of read/marked articles in the dribble buffer.
6946The dribble buffer will then be saved.
6947If FORCE (the prefix), also save the .newsrc file(s)."
6948 (interactive "P")
6949 (gnus-summary-update-info t)
6950 (if force
6951 (gnus-save-newsrc-file)
6952 (gnus-dribble-save)))
6953
23f87bed 6954(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 6955 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 6956`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
6957 (interactive)
6958 (gnus-set-global-variables)
16409b0b
GM
6959 (when (gnus-buffer-live-p gnus-article-buffer)
6960 (save-excursion
6961 (set-buffer gnus-article-buffer)
6962 (mm-destroy-parts gnus-article-mime-handles)
6963 ;; Set it to nil for safety reason.
6964 (setq gnus-article-mime-handle-alist nil)
6965 (setq gnus-article-mime-handles nil)))
eec82323 6966 (gnus-kill-save-kill-buffer)
6748645f 6967 (gnus-async-halt-prefetch)
eec82323
LMI
6968 (let* ((group gnus-newsgroup-name)
6969 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 6970 (gnus-group-is-exiting-p t)
eec82323 6971 (mode major-mode)
23f87bed 6972 (group-point nil)
eec82323 6973 (buf (current-buffer)))
16409b0b
GM
6974 (unless quit-config
6975 ;; Do adaptive scoring, and possibly save score files.
6976 (when gnus-newsgroup-adaptive
6977 (gnus-score-adaptive))
6978 (when gnus-use-scoring
6979 (gnus-score-save)))
6748645f 6980 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
6981 ;; If we have several article buffers, we kill them at exit.
6982 (unless gnus-single-article-buffer
01c52d31
MB
6983 (when (gnus-buffer-live-p gnus-article-buffer)
6984 (with-current-buffer gnus-article-buffer
6985 ;; Don't kill sticky article buffers
6986 (unless (eq major-mode 'gnus-sticky-article-mode)
6987 (gnus-kill-buffer gnus-article-buffer)
6988 (setq gnus-article-current nil))))
6989 (gnus-kill-buffer gnus-original-article-buffer))
eec82323
LMI
6990 (when gnus-use-cache
6991 (gnus-cache-possibly-remove-articles)
6992 (gnus-cache-save-buffers))
6993 (gnus-async-prefetch-remove-group group)
6994 (when gnus-suppress-duplicates
6995 (gnus-dup-enter-articles))
6996 (when gnus-use-trees
6997 (gnus-tree-close group))
16409b0b
GM
6998 (when gnus-use-cache
6999 (gnus-cache-write-active))
6748645f
LMI
7000 ;; Remove entries for this group.
7001 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
7002 ;; Make all changes in this group permanent.
7003 (unless quit-config
6748645f 7004 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 7005 (gnus-summary-update-info))
eec82323
LMI
7006 (gnus-close-group group)
7007 ;; Make sure where we were, and go to next newsgroup.
7008 (set-buffer gnus-group-buffer)
7009 (unless quit-config
7010 (gnus-group-jump-to-group group))
6748645f
LMI
7011 (gnus-run-hooks 'gnus-summary-exit-hook)
7012 (unless (or quit-config
01c52d31 7013 (not gnus-summary-next-group-on-exit)
6748645f
LMI
7014 ;; If this group has disappeared from the summary
7015 ;; buffer, don't skip forwards.
7016 (not (string= group (gnus-group-group-name))))
eec82323 7017 (gnus-group-next-unread-group 1))
a8151ef7 7018 (setq group-point (point))
eec82323
LMI
7019 (if temporary
7020 nil ;Nothing to do.
eec82323
LMI
7021 (set-buffer buf)
7022 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
7023 (progn
7024 (gnus-deaden-summary)
7025 (setq mode nil))
eec82323
LMI
7026 ;; We set all buffer-local variables to nil. It is unclear why
7027 ;; this is needed, but if we don't, buffer-local variables are
7028 ;; not garbage-collected, it seems. This would the lead to en
7029 ;; ever-growing Emacs.
7030 (gnus-summary-clear-local-variables)
23f87bed
MB
7031 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7032 (gnus-summary-clear-local-variables))
eec82323
LMI
7033 (when (get-buffer gnus-article-buffer)
7034 (bury-buffer gnus-article-buffer))
eec82323
LMI
7035 ;; Return to group mode buffer.
7036 (when (eq mode 'gnus-summary-mode)
7037 (gnus-kill-buffer buf)))
7038 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
7039 (set-buffer gnus-group-buffer)
7040 (if quit-config
7041 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
7042 (goto-char group-point)
7043 ;; If gnus-group-buffer is already displayed, make sure we also move
7044 ;; the cursor in the window that displays it.
7045 (let ((win (get-buffer-window (current-buffer) 0)))
7046 (if win (set-window-point win (point))))
d61c212b 7047 (unless leave-hidden
4e90f2b9 7048 (gnus-configure-windows 'group 'force)))
6748645f 7049 ;; Clear the current group name.
eec82323
LMI
7050 (unless quit-config
7051 (setq gnus-newsgroup-name nil)))))
7052
7053(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7054(defun gnus-summary-exit-no-update (&optional no-questions)
7055 "Quit reading current newsgroup without updating read article info."
7056 (interactive)
eec82323 7057 (let* ((group gnus-newsgroup-name)
23f87bed
MB
7058 (gnus-group-is-exiting-p t)
7059 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
7060 (quit-config (gnus-group-quit-config group)))
7061 (when (or no-questions
7062 gnus-expert-user
7063 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 7064 (gnus-async-halt-prefetch)
23f87bed 7065 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b
GM
7066 (when (gnus-buffer-live-p gnus-article-buffer)
7067 (save-excursion
7068 (set-buffer gnus-article-buffer)
7069 (mm-destroy-parts gnus-article-mime-handles)
7070 ;; Set it to nil for safety reason.
7071 (setq gnus-article-mime-handle-alist nil)
7072 (setq gnus-article-mime-handles nil)))
eec82323
LMI
7073 ;; If we have several article buffers, we kill them at exit.
7074 (unless gnus-single-article-buffer
7075 (gnus-kill-buffer gnus-article-buffer)
7076 (gnus-kill-buffer gnus-original-article-buffer)
7077 (setq gnus-article-current nil))
7078 (if (not gnus-kill-summary-on-exit)
7079 (gnus-deaden-summary)
7080 (gnus-close-group group)
7081 (gnus-summary-clear-local-variables)
23f87bed
MB
7082 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7083 (gnus-summary-clear-local-variables))
7084 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
7085 (unless gnus-single-article-buffer
7086 (setq gnus-article-current nil))
7087 (when gnus-use-trees
7088 (gnus-tree-close group))
7089 (gnus-async-prefetch-remove-group group)
7090 (when (get-buffer gnus-article-buffer)
7091 (bury-buffer gnus-article-buffer))
7092 ;; Return to the group buffer.
7093 (gnus-configure-windows 'group 'force)
7094 ;; Clear the current group name.
7095 (setq gnus-newsgroup-name nil)
23f87bed
MB
7096 (unless (gnus-ephemeral-group-p group)
7097 (gnus-group-update-group group))
eec82323
LMI
7098 (when (equal (gnus-group-group-name) group)
7099 (gnus-group-next-unread-group 1))
7100 (when quit-config
23f87bed 7101 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
7102
7103(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
7104 "Handle movement when leaving an ephemeral group.
7105The state which existed when entering the ephemeral is reset."
eec82323
LMI
7106 (if (not (buffer-name (car quit-config)))
7107 (gnus-configure-windows 'group 'force)
7108 (set-buffer (car quit-config))
7109 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
7110 (gnus-set-global-variables))
7111 ((eq major-mode 'gnus-article-mode)
7112 (save-excursion
7113 ;; The `gnus-summary-buffer' variable may point
7114 ;; to the old summary buffer when using a single
7115 ;; article buffer.
7116 (unless (gnus-buffer-live-p gnus-summary-buffer)
7117 (set-buffer gnus-group-buffer))
7118 (set-buffer gnus-summary-buffer)
7119 (gnus-set-global-variables))))
eec82323 7120 (if (or (eq (cdr quit-config) 'article)
23f87bed 7121 (eq (cdr quit-config) 'pick))
01c52d31
MB
7122 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7123 (gnus-configure-windows 'pick 'force)
7124 (gnus-configure-windows (cdr quit-config) 'force))
eec82323
LMI
7125 (gnus-configure-windows (cdr quit-config) 'force))
7126 (when (eq major-mode 'gnus-summary-mode)
01c52d31
MB
7127 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7128 next-unread-noselect))
7129 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7130 'next-noselect)
7131 (gnus-summary-next-subject 1 nil t))
7132 ((eq gnus-auto-select-on-ephemeral-exit
7133 'next-unread-noselect)
7134 (gnus-summary-next-subject 1 t t))))
7135 ;; Hide the article buffer which displays the article different
7136 ;; from the one that the cursor points to in the summary buffer.
7137 (gnus-configure-windows 'summary 'force))
7138 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7139 (gnus-summary-next-subject 1))
7140 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7141 (gnus-summary-next-subject 1 t))))
eec82323
LMI
7142 (gnus-summary-recenter)
7143 (gnus-summary-position-point))))
7144
7145;;; Dead summaries.
7146
7147(defvar gnus-dead-summary-mode-map nil)
7148
7149(unless gnus-dead-summary-mode-map
7150 (setq gnus-dead-summary-mode-map (make-keymap))
7151 (suppress-keymap gnus-dead-summary-mode-map)
7152 (substitute-key-definition
7153 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
23f87bed
MB
7154 (dolist (key '("\C-d" "\r" "\177" [delete]))
7155 (define-key gnus-dead-summary-mode-map
7156 key 'gnus-summary-wake-up-the-dead))
7157 (dolist (key '("q" "Q"))
7158 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
eec82323
LMI
7159
7160(defvar gnus-dead-summary-mode nil
7161 "Minor mode for Gnus summary buffers.")
7162
7163(defun gnus-dead-summary-mode (&optional arg)
7164 "Minor mode for Gnus summary buffers."
7165 (interactive "P")
7166 (when (eq major-mode 'gnus-summary-mode)
7167 (make-local-variable 'gnus-dead-summary-mode)
7168 (setq gnus-dead-summary-mode
7169 (if (null arg) (not gnus-dead-summary-mode)
7170 (> (prefix-numeric-value arg) 0)))
7171 (when gnus-dead-summary-mode
01c52d31 7172 (add-minor-mode
a8151ef7 7173 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
eec82323
LMI
7174
7175(defun gnus-deaden-summary ()
7176 "Make the current summary buffer into a dead summary buffer."
7177 ;; Kill any previous dead summary buffer.
7178 (when (and gnus-dead-summary
7179 (buffer-name gnus-dead-summary))
01c52d31 7180 (with-current-buffer gnus-dead-summary
eec82323
LMI
7181 (when gnus-dead-summary-mode
7182 (kill-buffer (current-buffer)))))
7183 ;; Make this the current dead summary.
7184 (setq gnus-dead-summary (current-buffer))
7185 (gnus-dead-summary-mode 1)
7186 (let ((name (buffer-name)))
7187 (when (string-match "Summary" name)
7188 (rename-buffer
7189 (concat (substring name 0 (match-beginning 0)) "Dead "
7190 (substring name (match-beginning 0)))
16409b0b
GM
7191 t)
7192 (bury-buffer))))
eec82323
LMI
7193
7194(defun gnus-kill-or-deaden-summary (buffer)
7195 "Kill or deaden the summary BUFFER."
6748645f
LMI
7196 (save-excursion
7197 (when (and (buffer-name buffer)
7198 (not gnus-single-article-buffer))
01c52d31 7199 (with-current-buffer buffer
6748645f
LMI
7200 (gnus-kill-buffer gnus-article-buffer)
7201 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
7202 (cond
7203 ;; Kill the buffer.
7204 (gnus-kill-summary-on-exit
7205 (when (and gnus-use-trees
7206 (gnus-buffer-exists-p buffer))
7207 (save-excursion
7208 (set-buffer buffer)
7209 (gnus-tree-close gnus-newsgroup-name)))
7210 (gnus-kill-buffer buffer))
7211 ;; Deaden the buffer.
7212 ((gnus-buffer-exists-p buffer)
7213 (save-excursion
7214 (set-buffer buffer)
7215 (gnus-deaden-summary))))))
eec82323
LMI
7216
7217(defun gnus-summary-wake-up-the-dead (&rest args)
7218 "Wake up the dead summary buffer."
7219 (interactive)
7220 (gnus-dead-summary-mode -1)
7221 (let ((name (buffer-name)))
7222 (when (string-match "Dead " name)
7223 (rename-buffer
7224 (concat (substring name 0 (match-beginning 0))
7225 (substring name (match-end 0)))
7226 t)))
7227 (gnus-message 3 "This dead summary is now alive again"))
7228
7229;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7230(defun gnus-summary-fetch-faq (&optional faq-dir)
7231 "Fetch the FAQ for the current group.
7232If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7233in."
7234 (interactive
7235 (list
7236 (when current-prefix-arg
7237 (completing-read
8f688cb0 7238 "FAQ dir: " (and (listp gnus-group-faq-directory)
01c52d31 7239 (mapcar 'list
a8151ef7 7240 gnus-group-faq-directory))))))
eec82323
LMI
7241 (let (gnus-faq-buffer)
7242 (when (setq gnus-faq-buffer
7243 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7244 (gnus-configure-windows 'summary-faq))))
7245
7246;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7247(defun gnus-summary-describe-group (&optional force)
7248 "Describe the current newsgroup."
7249 (interactive "P")
7250 (gnus-group-describe-group force gnus-newsgroup-name))
7251
7252(defun gnus-summary-describe-briefly ()
7253 "Describe summary mode commands briefly."
7254 (interactive)
16409b0b 7255 (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
7256
7257;; Walking around group mode buffer from summary mode.
7258
7259(defun gnus-summary-next-group (&optional no-article target-group backward)
7260 "Exit current newsgroup and then select next unread newsgroup.
7261If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7262initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7263previous group instead."
7264 (interactive "P")
eec82323
LMI
7265 ;; Stop pre-fetching.
7266 (gnus-async-halt-prefetch)
7267 (let ((current-group gnus-newsgroup-name)
7268 (current-buffer (current-buffer))
7269 entered)
7270 ;; First we semi-exit this group to update Xrefs and all variables.
7271 ;; We can't do a real exit, because the window conf must remain
7272 ;; the same in case the user is prompted for info, and we don't
7273 ;; want the window conf to change before that...
7274 (gnus-summary-exit t)
7275 (while (not entered)
7276 ;; Then we find what group we are supposed to enter.
7277 (set-buffer gnus-group-buffer)
7278 (gnus-group-jump-to-group current-group)
7279 (setq target-group
7280 (or target-group
7281 (if (eq gnus-keep-same-level 'best)
7282 (gnus-summary-best-group gnus-newsgroup-name)
7283 (gnus-summary-search-group backward gnus-keep-same-level))))
7284 (if (not target-group)
7285 ;; There are no further groups, so we return to the group
7286 ;; buffer.
7287 (progn
7288 (gnus-message 5 "Returning to the group buffer")
7289 (setq entered t)
7290 (when (gnus-buffer-live-p current-buffer)
7291 (set-buffer current-buffer)
7292 (gnus-summary-exit))
6748645f 7293 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7294 ;; We try to enter the target group.
7295 (gnus-group-jump-to-group target-group)
7296 (let ((unreads (gnus-group-group-unread)))
7297 (if (and (or (eq t unreads)
7298 (and unreads (not (zerop unreads))))
23f87bed
MB
7299 (gnus-summary-read-group
7300 target-group nil no-article
7301 (and (buffer-name current-buffer) current-buffer)
7302 nil backward))
eec82323
LMI
7303 (setq entered t)
7304 (setq current-group target-group
7305 target-group nil)))))))
7306
7307(defun gnus-summary-prev-group (&optional no-article)
7308 "Exit current newsgroup and then select previous unread newsgroup.
7309If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7310 (interactive "P")
7311 (gnus-summary-next-group no-article nil t))
7312
7313;; Walking around summary lines.
7314
23f87bed
MB
7315(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7316 "Go to the first subject satisfying any non-nil constraint.
7317If UNREAD is non-nil, the article should be unread.
7318If UNDOWNLOADED is non-nil, the article should be undownloaded.
7319If UNSEEN is non-nil, the article should be unseen.
7320Returns the article selected or nil if there are no matching articles."
eec82323 7321 (interactive "P")
23f87bed
MB
7322 (cond
7323 ;; Empty summary.
7324 ((null gnus-newsgroup-data)
7325 (gnus-message 3 "No articles in the group")
7326 nil)
7327 ;; Pick the first article.
7328 ((not (or unread undownloaded unseen))
7329 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7330 (gnus-data-number (car gnus-newsgroup-data)))
7331 ;; Find the first unread article.
7332 (t
7333 (let ((data gnus-newsgroup-data))
7334 (while (and data
7335 (let ((num (gnus-data-number (car data))))
7336 (or (memq num gnus-newsgroup-unfetched)
7337 (not (or (and unread
7338 (memq num gnus-newsgroup-unreads))
7339 (and undownloaded
7340 (memq num gnus-newsgroup-undownloaded))
7341 (and unseen
7342 (memq num gnus-newsgroup-unseen)))))))
7343 (setq data (cdr data)))
7344 (prog1
7345 (if data
7346 (progn
7347 (goto-char (gnus-data-pos (car data)))
7348 (gnus-data-number (car data)))
7349 (gnus-message 3 "No more%s articles"
7350 (let* ((r (when unread " unread"))
7351 (d (when undownloaded " undownloaded"))
7352 (s (when unseen " unseen"))
7353 (l (delq nil (list r d s))))
7354 (cond ((= 3 (length l))
7355 (concat r "," d ", or" s))
7356 ((= 2 (length l))
7357 (concat (car l) ", or" (cadr l)))
7358 ((= 1 (length l))
7359 (car l))
7360 (t
7361 ""))))
7362 nil
7363 )
7364 (gnus-summary-position-point))))))
eec82323
LMI
7365
7366(defun gnus-summary-next-subject (n &optional unread dont-display)
7367 "Go to next N'th summary line.
7368If N is negative, go to the previous N'th subject line.
7369If UNREAD is non-nil, only unread articles are selected.
7370The difference between N and the actual number of steps taken is
7371returned."
7372 (interactive "p")
7373 (let ((backward (< n 0))
7374 (n (abs n)))
7375 (while (and (> n 0)
7376 (if backward
7377 (gnus-summary-find-prev unread)
7378 (gnus-summary-find-next unread)))
16409b0b
GM
7379 (unless (zerop (setq n (1- n)))
7380 (gnus-summary-show-thread)))
eec82323
LMI
7381 (when (/= 0 n)
7382 (gnus-message 7 "No more%s articles"
7383 (if unread " unread" "")))
7384 (unless dont-display
7385 (gnus-summary-recenter)
7386 (gnus-summary-position-point))
7387 n))
7388
7389(defun gnus-summary-next-unread-subject (n)
7390 "Go to next N'th unread summary line."
7391 (interactive "p")
7392 (gnus-summary-next-subject n t))
7393
7394(defun gnus-summary-prev-subject (n &optional unread)
7395 "Go to previous N'th summary line.
7396If optional argument UNREAD is non-nil, only unread article is selected."
7397 (interactive "p")
7398 (gnus-summary-next-subject (- n) unread))
7399
7400(defun gnus-summary-prev-unread-subject (n)
7401 "Go to previous N'th unread summary line."
7402 (interactive "p")
7403 (gnus-summary-next-subject (- n) t))
7404
23f87bed
MB
7405(defun gnus-summary-goto-subjects (articles)
7406 "Insert the subject header for ARTICLES in the current buffer."
7407 (save-excursion
7408 (dolist (article articles)
7409 (gnus-summary-goto-subject article t)))
7410 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7411 (gnus-summary-position-point))
132cf96d 7412
eec82323
LMI
7413(defun gnus-summary-goto-subject (article &optional force silent)
7414 "Go the subject line of ARTICLE.
7415If FORCE, also allow jumping to articles not currently shown."
7416 (interactive "nArticle number: ")
23f87bed
MB
7417 (unless (numberp article)
7418 (error "Article %s is not a number" article))
eec82323
LMI
7419 (let ((b (point))
7420 (data (gnus-data-find article)))
7421 ;; We read in the article if we have to.
7422 (and (not data)
7423 force
6748645f
LMI
7424 (gnus-summary-insert-subject
7425 article
7426 (if (or (numberp force) (vectorp force)) force)
7427 t)
eec82323
LMI
7428 (setq data (gnus-data-find article)))
7429 (goto-char b)
7430 (if (not data)
7431 (progn
7432 (unless silent
7433 (gnus-message 3 "Can't find article %d" article))
7434 nil)
23f87bed
MB
7435 (let ((pt (gnus-data-pos data)))
7436 (goto-char pt)
7437 (gnus-summary-set-article-display-arrow pt))
6748645f 7438 (gnus-summary-position-point)
eec82323
LMI
7439 article)))
7440
7441;; Walking around summary lines with displaying articles.
7442
7443(defun gnus-summary-expand-window (&optional arg)
7444 "Make the summary buffer take up the entire Emacs frame.
7445Given a prefix, will force an `article' buffer configuration."
7446 (interactive "P")
eec82323
LMI
7447 (if arg
7448 (gnus-configure-windows 'article 'force)
7449 (gnus-configure-windows 'summary 'force)))
7450
7451(defun gnus-summary-display-article (article &optional all-header)
7452 "Display ARTICLE in article buffer."
01c52d31
MB
7453 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7454 (with-current-buffer gnus-article-buffer
7455 (eq major-mode 'gnus-article-mode)))
7456 (gnus-article-setup-buffer))
eec82323 7457 (gnus-set-global-variables)
01c52d31
MB
7458 (with-current-buffer gnus-article-buffer
7459 (setq gnus-article-charset gnus-newsgroup-charset)
7460 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7461 (mm-enable-multibyte))
eec82323
LMI
7462 (if (null article)
7463 nil
7464 (prog1
7465 (if gnus-summary-display-article-function
7466 (funcall gnus-summary-display-article-function article all-header)
7467 (gnus-article-prepare article all-header))
6748645f 7468 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7469 (when (and gnus-current-article
7470 (not (zerop gnus-current-article)))
7471 (gnus-summary-goto-subject gnus-current-article))
7472 (gnus-summary-recenter)
7473 (when (and gnus-use-trees gnus-show-threads)
7474 (gnus-possibly-generate-tree article)
7475 (gnus-highlight-selected-tree article))
7476 ;; Successfully display article.
7477 (gnus-article-set-window-start
7478 (cdr (assq article gnus-newsgroup-bookmarks))))))
7479
7480(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7481 "Select the current article.
7482If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7483non-nil, the article will be re-fetched even if it already present in
7484the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7485be displayed."
7486 ;; Make sure we are in the summary buffer to work around bbdb bug.
7487 (unless (eq major-mode 'gnus-summary-mode)
7488 (set-buffer gnus-summary-buffer))
7489 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7490 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7491 gnus-summary-display-article-function)
eec82323
LMI
7492 (and (not pseudo)
7493 (gnus-summary-article-pseudo-p article)
a8151ef7 7494 (error "This is a pseudo-article"))
16409b0b
GM
7495 (save-excursion
7496 (set-buffer gnus-summary-buffer)
7497 (if (or (and gnus-single-article-buffer
7498 (or (null gnus-current-article)
7499 (null gnus-article-current)
7500 (null (get-buffer gnus-article-buffer))
7501 (not (eq article (cdr gnus-article-current)))
7502 (not (equal (car gnus-article-current)
7503 gnus-newsgroup-name))))
7504 (and (not gnus-single-article-buffer)
7505 (or (null gnus-current-article)
7506 (not (eq gnus-current-article article))))
7507 force)
7508 ;; The requested article is different from the current article.
7509 (progn
16409b0b
GM
7510 (gnus-summary-display-article article all-headers)
7511 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7512 (with-current-buffer gnus-article-buffer
16409b0b 7513 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7514 (mm-disable-multibyte))))
16409b0b
GM
7515 (gnus-article-set-window-start
7516 (cdr (assq article gnus-newsgroup-bookmarks)))
7517 article)
16409b0b 7518 'old))))
eec82323 7519
23f87bed
MB
7520(defun gnus-summary-force-verify-and-decrypt ()
7521 "Display buttons for signed/encrypted parts and verify/decrypt them."
7522 (interactive)
7523 (let ((mm-verify-option 'known)
7524 (mm-decrypt-option 'known)
7525 (gnus-article-emulate-mime t)
7526 (gnus-buttonized-mime-types (append (list "multipart/signed"
7527 "multipart/encrypted")
7528 gnus-buttonized-mime-types)))
7529 (gnus-summary-select-article nil 'force)))
7530
eec82323
LMI
7531(defun gnus-summary-set-current-mark (&optional current-mark)
7532 "Obsolete function."
7533 nil)
7534
7535(defun gnus-summary-next-article (&optional unread subject backward push)
7536 "Select the next article.
7537If UNREAD, only unread articles are selected.
7538If SUBJECT, only articles with SUBJECT are selected.
7539If BACKWARD, the previous article is selected instead of the next."
7540 (interactive "P")
11e95b02
MB
7541 ;; Make sure we are in the summary buffer.
7542 (unless (eq major-mode 'gnus-summary-mode)
7543 (set-buffer gnus-summary-buffer))
eec82323
LMI
7544 (cond
7545 ;; Is there such an article?
7546 ((and (gnus-summary-search-forward unread subject backward)
7547 (or (gnus-summary-display-article (gnus-summary-article-number))
7548 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7549 (gnus-summary-position-point))
7550 ;; If not, we try the first unread, if that is wanted.
7551 ((and subject
7552 gnus-auto-select-same
7553 (gnus-summary-first-unread-article))
7554 (gnus-summary-position-point)
7555 (gnus-message 6 "Wrapped"))
7556 ;; Try to get next/previous article not displayed in this group.
7557 ((and gnus-auto-extend-newsgroup
7558 (not unread) (not subject))
7559 (gnus-summary-goto-article
7560 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7561 nil (count-lines (point-min) (point))))
eec82323
LMI
7562 ;; Go to next/previous group.
7563 (t
7564 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7565 (gnus-summary-jump-to-group gnus-newsgroup-name))
7566 (let ((cmd last-command-char)
7567 (point
01c52d31 7568 (with-current-buffer gnus-group-buffer
eec82323
LMI
7569 (point)))
7570 (group
7571 (if (eq gnus-keep-same-level 'best)
7572 (gnus-summary-best-group gnus-newsgroup-name)
7573 (gnus-summary-search-group backward gnus-keep-same-level))))
7574 ;; For some reason, the group window gets selected. We change
7575 ;; it back.
7576 (select-window (get-buffer-window (current-buffer)))
7577 ;; Select next unread newsgroup automagically.
7578 (cond
7579 ((or (not gnus-auto-select-next)
7580 (not cmd))
7581 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7582 ((or (eq gnus-auto-select-next 'quietly)
7583 (and (eq gnus-auto-select-next 'slightly-quietly)
7584 push)
7585 (and (eq gnus-auto-select-next 'almost-quietly)
7586 (gnus-summary-last-article-p)))
7587 ;; Select quietly.
7588 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7589 (gnus-summary-exit)
7590 (gnus-message 7 "No more%s articles (%s)..."
7591 (if unread " unread" "")
7592 (if group (concat "selecting " group)
7593 "exiting"))
7594 (gnus-summary-next-group nil group backward)))
7595 (t
7596 (when (gnus-key-press-event-p last-input-event)
7597 (gnus-summary-walk-group-buffer
7598 gnus-newsgroup-name cmd unread backward point))))))))
7599
7600(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7601 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7602 (?\C-p (gnus-group-prev-unread-group 1))))
7603 (cursor-in-echo-area t)
23f87bed 7604 keve key group ended prompt)
eec82323
LMI
7605 (save-excursion
7606 (set-buffer gnus-group-buffer)
7607 (goto-char start)
7608 (setq group
7609 (if (eq gnus-keep-same-level 'best)
7610 (gnus-summary-best-group gnus-newsgroup-name)
7611 (gnus-summary-search-group backward gnus-keep-same-level))))
7612 (while (not ended)
23f87bed
MB
7613 (setq prompt
7614 (format
7615 "No more%s articles%s " (if unread " unread" "")
7616 (if (and group
7617 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7618 (format " (Type %s for %s [%s])"
91472578
MB
7619 (single-key-description cmd)
7620 (gnus-group-decoded-name group)
01c52d31 7621 (gnus-group-unread group))
23f87bed
MB
7622 (format " (Type %s to exit %s)"
7623 (single-key-description cmd)
91472578 7624 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7625 ;; Confirm auto selection.
23f87bed
MB
7626 (setq key (car (setq keve (gnus-read-event-char prompt)))
7627 ended t)
eec82323
LMI
7628 (cond
7629 ((assq key keystrokes)
7630 (let ((obuf (current-buffer)))
7631 (switch-to-buffer gnus-group-buffer)
7632 (when group
7633 (gnus-group-jump-to-group group))
7634 (eval (cadr (assq key keystrokes)))
7635 (setq group (gnus-group-group-name))
7636 (switch-to-buffer obuf))
7637 (setq ended nil))
7638 ((equal key cmd)
7639 (if (or (not group)
7640 (gnus-ephemeral-group-p gnus-newsgroup-name))
7641 (gnus-summary-exit)
7642 (gnus-summary-next-group nil group backward)))
7643 (t
7644 (push (cdr keve) unread-command-events))))))
7645
7646(defun gnus-summary-next-unread-article ()
7647 "Select unread article after current one."
7648 (interactive)
7649 (gnus-summary-next-article
7650 (or (not (eq gnus-summary-goto-unread 'never))
7651 (gnus-summary-last-article-p (gnus-summary-article-number)))
7652 (and gnus-auto-select-same
7653 (gnus-summary-article-subject))))
7654
7655(defun gnus-summary-prev-article (&optional unread subject)
7656 "Select the article after the current one.
7657If UNREAD is non-nil, only unread articles are selected."
7658 (interactive "P")
7659 (gnus-summary-next-article unread subject t))
7660
7661(defun gnus-summary-prev-unread-article ()
7662 "Select unread article before current one."
7663 (interactive)
7664 (gnus-summary-prev-article
7665 (or (not (eq gnus-summary-goto-unread 'never))
7666 (gnus-summary-first-article-p (gnus-summary-article-number)))
7667 (and gnus-auto-select-same
7668 (gnus-summary-article-subject))))
7669
23f87bed 7670(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7671 "Show next page of the selected article.
7672If at the end of the current article, select the next article.
7673LINES says how many lines should be scrolled up.
7674
7675If CIRCULAR is non-nil, go to the start of the article instead of
7676selecting the next article when reaching the end of the current
23f87bed
MB
7677article.
7678
7679If STOP is non-nil, just stop when reaching the end of the message.
7680
7681Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7682 (interactive "P")
7683 (setq gnus-summary-buffer (current-buffer))
7684 (gnus-set-global-variables)
7685 (let ((article (gnus-summary-article-number))
7686 (article-window (get-buffer-window gnus-article-buffer t))
7687 endp)
6748645f
LMI
7688 ;; If the buffer is empty, we have no article.
7689 (unless article
7690 (error "No article to select"))
eec82323
LMI
7691 (gnus-configure-windows 'article)
7692 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7693 (if (and (eq gnus-summary-goto-unread 'never)
7694 (not (gnus-summary-last-article-p article)))
7695 (gnus-summary-next-article)
7696 (gnus-summary-next-unread-article))
7697 (if (or (null gnus-current-article)
7698 (null gnus-article-current)
7699 (/= article (cdr gnus-article-current))
7700 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7701 ;; Selected subject is different from current article's.
7702 (gnus-summary-display-article article)
7703 (when article-window
7704 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7705 (setq endp (or (gnus-article-next-page lines)
7706 (gnus-article-only-boring-p))))
eec82323 7707 (when endp
23f87bed
MB
7708 (cond (stop
7709 (gnus-message 3 "End of message"))
7710 (circular
eec82323
LMI
7711 (gnus-summary-beginning-of-article))
7712 (lines
7713 (gnus-message 3 "End of message"))
7714 ((null lines)
7715 (if (and (eq gnus-summary-goto-unread 'never)
7716 (not (gnus-summary-last-article-p article)))
7717 (gnus-summary-next-article)
7718 (gnus-summary-next-unread-article))))))))
7719 (gnus-summary-recenter)
7720 (gnus-summary-position-point)))
7721
7722(defun gnus-summary-prev-page (&optional lines move)
7723 "Show previous page of selected article.
7724Argument LINES specifies lines to be scrolled down.
7725If MOVE, move to the previous unread article if point is at
7726the beginning of the buffer."
7727 (interactive "P")
eec82323
LMI
7728 (let ((article (gnus-summary-article-number))
7729 (article-window (get-buffer-window gnus-article-buffer t))
7730 endp)
7731 (gnus-configure-windows 'article)
7732 (if (or (null gnus-current-article)
7733 (null gnus-article-current)
7734 (/= article (cdr gnus-article-current))
7735 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7736 ;; Selected subject is different from current article's.
7737 (gnus-summary-display-article article)
7738 (gnus-summary-recenter)
7739 (when article-window
7740 (gnus-eval-in-buffer-window gnus-article-buffer
7741 (setq endp (gnus-article-prev-page lines)))
7742 (when (and move endp)
7743 (cond (lines
7744 (gnus-message 3 "Beginning of message"))
7745 ((null lines)
7746 (if (and (eq gnus-summary-goto-unread 'never)
7747 (not (gnus-summary-first-article-p article)))
7748 (gnus-summary-prev-article)
7749 (gnus-summary-prev-unread-article))))))))
7750 (gnus-summary-position-point))
7751
7752(defun gnus-summary-prev-page-or-article (&optional lines)
7753 "Show previous page of selected article.
7754Argument LINES specifies lines to be scrolled down.
7755If at the beginning of the article, go to the next article."
7756 (interactive "P")
7757 (gnus-summary-prev-page lines t))
7758
7759(defun gnus-summary-scroll-up (lines)
7760 "Scroll up (or down) one line current article.
7761Argument LINES specifies lines to be scrolled up (or down if negative)."
7762 (interactive "p")
eec82323
LMI
7763 (gnus-configure-windows 'article)
7764 (gnus-summary-show-thread)
7765 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7766 (gnus-eval-in-buffer-window gnus-article-buffer
7767 (cond ((> lines 0)
7768 (when (gnus-article-next-page lines)
7769 (gnus-message 3 "End of message")))
7770 ((< lines 0)
7771 (gnus-article-prev-page (- lines))))))
7772 (gnus-summary-recenter)
7773 (gnus-summary-position-point))
7774
6748645f
LMI
7775(defun gnus-summary-scroll-down (lines)
7776 "Scroll down (or up) one line current article.
7777Argument LINES specifies lines to be scrolled down (or up if negative)."
7778 (interactive "p")
7779 (gnus-summary-scroll-up (- lines)))
7780
eec82323
LMI
7781(defun gnus-summary-next-same-subject ()
7782 "Select next article which has the same subject as current one."
7783 (interactive)
eec82323
LMI
7784 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7785
7786(defun gnus-summary-prev-same-subject ()
7787 "Select previous article which has the same subject as current one."
7788 (interactive)
eec82323
LMI
7789 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7790
7791(defun gnus-summary-next-unread-same-subject ()
7792 "Select next unread article which has the same subject as current one."
7793 (interactive)
eec82323
LMI
7794 (gnus-summary-next-article t (gnus-summary-article-subject)))
7795
7796(defun gnus-summary-prev-unread-same-subject ()
7797 "Select previous unread article which has the same subject as current one."
7798 (interactive)
eec82323
LMI
7799 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7800
7801(defun gnus-summary-first-unread-article ()
7802 "Select the first unread article.
7803Return nil if there are no unread articles."
7804 (interactive)
eec82323
LMI
7805 (prog1
7806 (when (gnus-summary-first-subject t)
7807 (gnus-summary-show-thread)
7808 (gnus-summary-first-subject t)
7809 (gnus-summary-display-article (gnus-summary-article-number)))
7810 (gnus-summary-position-point)))
7811
16409b0b
GM
7812(defun gnus-summary-first-unread-subject ()
7813 "Place the point on the subject line of the first unread article.
7814Return nil if there are no unread articles."
7815 (interactive)
7816 (prog1
7817 (when (gnus-summary-first-subject t)
7818 (gnus-summary-show-thread)
7819 (gnus-summary-first-subject t))
7820 (gnus-summary-position-point)))
7821
23f87bed
MB
7822(defun gnus-summary-first-unseen-subject ()
7823 "Place the point on the subject line of the first unseen article.
7824Return nil if there are no unseen articles."
7825 (interactive)
7826 (prog1
7827 (when (gnus-summary-first-subject nil nil t)
7828 (gnus-summary-show-thread)
7829 (gnus-summary-first-subject nil nil t))
7830 (gnus-summary-position-point)))
7831
7832(defun gnus-summary-first-unseen-or-unread-subject ()
7833 "Place the point on the subject line of the first unseen article or,
7834if all article have been seen, on the subject line of the first unread
7835article."
7836 (interactive)
7837 (prog1
7838 (unless (when (gnus-summary-first-subject nil nil t)
7839 (gnus-summary-show-thread)
7840 (gnus-summary-first-subject nil nil t))
7841 (when (gnus-summary-first-subject t)
7842 (gnus-summary-show-thread)
7843 (gnus-summary-first-subject t)))
7844 (gnus-summary-position-point)))
7845
eec82323
LMI
7846(defun gnus-summary-first-article ()
7847 "Select the first article.
7848Return nil if there are no articles."
7849 (interactive)
eec82323
LMI
7850 (prog1
7851 (when (gnus-summary-first-subject)
16409b0b
GM
7852 (gnus-summary-show-thread)
7853 (gnus-summary-first-subject)
7854 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
7855 (gnus-summary-position-point)))
7856
23f87bed
MB
7857(defun gnus-summary-best-unread-article (&optional arg)
7858 "Select the unread article with the highest score.
7859If given a prefix argument, select the next unread article that has a
7860score higher than the default score."
7861 (interactive "P")
7862 (let ((article (if arg
7863 (gnus-summary-better-unread-subject)
7864 (gnus-summary-best-unread-subject))))
7865 (if article
7866 (gnus-summary-goto-article article)
7867 (error "No unread articles"))))
7868
7869(defun gnus-summary-best-unread-subject ()
7870 "Select the unread subject with the highest score."
eec82323 7871 (interactive)
eec82323
LMI
7872 (let ((best -1000000)
7873 (data gnus-newsgroup-data)
7874 article score)
7875 (while data
7876 (and (gnus-data-unread-p (car data))
7877 (> (setq score
7878 (gnus-summary-article-score (gnus-data-number (car data))))
7879 best)
7880 (setq best score
7881 article (gnus-data-number (car data))))
7882 (setq data (cdr data)))
23f87bed
MB
7883 (when article
7884 (gnus-summary-goto-subject article))
7885 (gnus-summary-position-point)
7886 article))
7887
7888(defun gnus-summary-better-unread-subject ()
7889 "Select the first unread subject that has a score over the default score."
7890 (interactive)
7891 (let ((data gnus-newsgroup-data)
7892 article score)
7893 (while (and (setq article (gnus-data-number (car data)))
7894 (or (gnus-data-read-p (car data))
7895 (not (> (gnus-summary-article-score article)
7896 gnus-summary-default-score))))
7897 (setq data (cdr data)))
7898 (when article
7899 (gnus-summary-goto-subject article))
7900 (gnus-summary-position-point)
7901 article))
eec82323
LMI
7902
7903(defun gnus-summary-last-subject ()
7904 "Go to the last displayed subject line in the group."
7905 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7906 (when article
7907 (gnus-summary-goto-subject article))))
7908
7909(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
7910 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7911If ALL-HEADERS is non-nil, no header lines are hidden.
7912If FORCE, go to the article even if it isn't displayed. If FORCE
7913is a number, it is the line the article is to be displayed on."
eec82323
LMI
7914 (interactive
7915 (list
6748645f
LMI
7916 (completing-read
7917 "Article number or Message-ID: "
7918 (mapcar (lambda (number) (list (int-to-string number)))
7919 gnus-newsgroup-limit))
eec82323
LMI
7920 current-prefix-arg
7921 t))
7922 (prog1
6748645f 7923 (if (and (stringp article)
23f87bed 7924 (string-match "@\\|%40" article))
6748645f
LMI
7925 (gnus-summary-refer-article article)
7926 (when (stringp article)
7927 (setq article (string-to-number article)))
7928 (if (gnus-summary-goto-subject article force)
7929 (gnus-summary-display-article article all-headers)
7930 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
7931 (gnus-summary-position-point)))
7932
7933(defun gnus-summary-goto-last-article ()
7934 "Go to the previously read article."
7935 (interactive)
7936 (prog1
7937 (when gnus-last-article
6748645f 7938 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
7939 (gnus-summary-position-point)))
7940
7941(defun gnus-summary-pop-article (number)
7942 "Pop one article off the history and go to the previous.
7943NUMBER articles will be popped off."
7944 (interactive "p")
7945 (let (to)
7946 (setq gnus-newsgroup-history
7947 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7948 (if to
6748645f 7949 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
7950 (error "Article history empty")))
7951 (gnus-summary-position-point))
7952
7953;; Summary commands and functions for limiting the summary buffer.
7954
7955(defun gnus-summary-limit-to-articles (n)
7956 "Limit the summary buffer to the next N articles.
7957If not given a prefix, use the process marked articles instead."
7958 (interactive "P")
eec82323
LMI
7959 (prog1
7960 (let ((articles (gnus-summary-work-articles n)))
7961 (setq gnus-newsgroup-processable nil)
7962 (gnus-summary-limit articles))
7963 (gnus-summary-position-point)))
7964
7965(defun gnus-summary-pop-limit (&optional total)
7966 "Restore the previous limit.
7967If given a prefix, remove all limits."
7968 (interactive "P")
eec82323
LMI
7969 (when total
7970 (setq gnus-newsgroup-limits
7971 (list (mapcar (lambda (h) (mail-header-number h))
7972 gnus-newsgroup-headers))))
7973 (unless gnus-newsgroup-limits
7974 (error "No limit to pop"))
7975 (prog1
7976 (gnus-summary-limit nil 'pop)
7977 (gnus-summary-position-point)))
7978
47b63dfa
SZ
7979(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7980 "Limit the summary buffer to articles that have subjects that match a regexp.
7981If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 7982 (interactive
47b63dfa
SZ
7983 (list (read-string (if current-prefix-arg
7984 "Exclude subject (regexp): "
a1506d29 7985 "Limit to subject (regexp): "))
47b63dfa 7986 nil current-prefix-arg))
eec82323
LMI
7987 (unless header
7988 (setq header "subject"))
7989 (when (not (equal "" subject))
7990 (prog1
7991 (let ((articles (gnus-summary-find-matching
a1506d29 7992 (or header "subject") subject 'all nil nil
47b63dfa 7993 not-matching)))
eec82323
LMI
7994 (unless articles
7995 (error "Found no matches for \"%s\"" subject))
7996 (gnus-summary-limit articles))
7997 (gnus-summary-position-point))))
7998
ef6e0ec7 7999(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
8000 "Limit the summary buffer to articles that have authors that match a regexp.
8001If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 8002 (interactive
47b63dfa
SZ
8003 (list (read-string (if current-prefix-arg
8004 "Exclude author (regexp): "
a1506d29 8005 "Limit to author (regexp): "))
ef6e0ec7
SZ
8006 current-prefix-arg))
8007 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323 8008
01c52d31
MB
8009(defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8010 "Limit the summary buffer to articles with the given RECIPIENT.
8011
8012If NOT-MATCHING, exclude RECIPIENT.
8013
8014To and Cc headers are checked. You need to include them in
8015`nnmail-extra-headers'."
8016 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8017 (interactive
8018 (list (read-string (format "%s recipient (regexp): "
8019 (if current-prefix-arg "Exclude" "Limit to")))
8020 current-prefix-arg))
8021 (when (not (equal "" recipient))
8022 (prog1 (let* ((to
8023 (if (memq 'To nnmail-extra-headers)
8024 (gnus-summary-find-matching
8025 (cons 'extra 'To) recipient 'all nil nil
8026 not-matching)
8027 (gnus-message
8028 1 "`To' isn't present in `nnmail-extra-headers'")
8029 (sit-for 1)
8030 nil))
8031 (cc
8032 (if (memq 'Cc nnmail-extra-headers)
8033 (gnus-summary-find-matching
8034 (cons 'extra 'Cc) recipient 'all nil nil
8035 not-matching)
8036 (gnus-message
8037 1 "`Cc' isn't present in `nnmail-extra-headers'")
8038 (sit-for 1)
8039 nil))
8040 (articles
8041 (if not-matching
8042 ;; We need the numbers that are in both lists:
8043 (mapcar (lambda (a)
8044 (and (memq a to) a))
8045 cc)
8046 (nconc to cc))))
8047 (unless articles
8048 (error "Found no matches for \"%s\"" recipient))
8049 (gnus-summary-limit articles))
8050 (gnus-summary-position-point))))
8051
8052(defun gnus-summary-limit-to-address (address &optional not-matching)
8053 "Limit the summary buffer to articles with the given ADDRESS.
8054
8055If NOT-MATCHING, exclude ADDRESS.
8056
8057To, Cc and From headers are checked. You need to include `To' and `Cc'
8058in `nnmail-extra-headers'."
8059 (interactive
8060 (list (read-string (format "%s address (regexp): "
8061 (if current-prefix-arg "Exclude" "Limit to")))
8062 current-prefix-arg))
8063 (when (not (equal "" address))
8064 (prog1 (let* ((to
8065 (if (memq 'To nnmail-extra-headers)
8066 (gnus-summary-find-matching
8067 (cons 'extra 'To) address 'all nil nil
8068 not-matching)
8069 (gnus-message
8070 1 "`To' isn't present in `nnmail-extra-headers'")
8071 (sit-for 1)
8072 t))
8073 (cc
8074 (if (memq 'Cc nnmail-extra-headers)
8075 (gnus-summary-find-matching
8076 (cons 'extra 'Cc) address 'all nil nil
8077 not-matching)
8078 (gnus-message
8079 1 "`Cc' isn't present in `nnmail-extra-headers'")
8080 (sit-for 1)
8081 t))
8082 (from
8083 (gnus-summary-find-matching "from" address
8084 'all nil nil not-matching))
8085 (articles
8086 (if not-matching
8087 ;; We need the numbers that are in all lists:
8088 (if (eq cc t)
8089 (if (eq to t)
8090 from
8091 (mapcar (lambda (a) (car (memq a from))) to))
8092 (if (eq to t)
8093 (mapcar (lambda (a) (car (memq a from))) cc)
8094 (mapcar (lambda (a) (car (memq a from)))
8095 (mapcar (lambda (a) (car (memq a to)))
8096 cc))))
8097 (nconc (if (eq to t) nil to)
8098 (if (eq cc t) nil cc)
8099 from))))
8100 (unless articles
8101 (error "Found no matches for \"%s\"" address))
8102 (gnus-summary-limit articles))
8103 (gnus-summary-position-point))))
8104
8105(defun gnus-summary-limit-strange-charsets-predicate (header)
8106 (let ((string (concat (mail-header-subject header)
8107 (mail-header-from header)))
8108 charset found)
8109 (dotimes (i (1- (length string)))
8110 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8111 (when (string-match "unicode\\|big\\|japanese" charset)
8112 (setq found t)))
8113 found))
8114
8115(defun gnus-summary-limit-to-predicate (predicate)
8116 "Limit to articles where PREDICATE returns non-nil.
8117PREDICATE will be called with the header structures of the
8118articles."
8119 (let ((articles nil)
8120 (case-fold-search t))
8121 (dolist (header gnus-newsgroup-headers)
8122 (when (funcall predicate header)
8123 (push (mail-header-number header) articles)))
8124 (gnus-summary-limit (nreverse articles))))
8125
eec82323
LMI
8126(defun gnus-summary-limit-to-age (age &optional younger-p)
8127 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8128If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8129articles that are younger than AGE days."
16409b0b
GM
8130 (interactive
8131 (let ((younger current-prefix-arg)
8132 (days-got nil)
8133 days)
8134 (while (not days-got)
8135 (setq days (if younger
23f87bed
MB
8136 (read-string "Limit to articles younger than (in days, older when negative): ")
8137 (read-string
8138 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
8139 (when (> (length days) 0)
8140 (setq days (read days)))
8141 (if (numberp days)
23f87bed
MB
8142 (progn
8143 (setq days-got t)
01c52d31
MB
8144 (when (< days 0)
8145 (setq younger (not younger))
8146 (setq days (* days -1))))
16409b0b
GM
8147 (message "Please enter a number.")
8148 (sleep-for 1)))
8149 (list days younger)))
eec82323
LMI
8150 (prog1
8151 (let ((data gnus-newsgroup-data)
16409b0b 8152 (cutoff (days-to-time age))
eec82323
LMI
8153 articles d date is-younger)
8154 (while (setq d (pop data))
8155 (when (and (vectorp (gnus-data-header d))
8156 (setq date (mail-header-date (gnus-data-header d))))
16409b0b
GM
8157 (setq is-younger (time-less-p
8158 (time-since (condition-case ()
8159 (date-to-time date)
8160 (error '(0 0))))
eec82323 8161 cutoff))
6748645f
LMI
8162 (when (if younger-p
8163 is-younger
8164 (not is-younger))
eec82323
LMI
8165 (push (gnus-data-number d) articles))))
8166 (gnus-summary-limit (nreverse articles)))
8167 (gnus-summary-position-point)))
8168
47b63dfa 8169(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
8170 "Limit the summary buffer to articles that match an 'extra' header."
8171 (interactive
8172 (let ((header
8173 (intern
23f87bed 8174 (gnus-completing-read-with-default
16409b0b 8175 (symbol-name (car gnus-extra-headers))
47b63dfa 8176 (if current-prefix-arg
81df110a
RF
8177 "Exclude extra header"
8178 "Limit extra header")
16409b0b
GM
8179 (mapcar (lambda (x)
8180 (cons (symbol-name x) x))
8181 gnus-extra-headers)
8182 nil
8183 t))))
8184 (list header
a1506d29 8185 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
8186 (if current-prefix-arg "Exclude" "Limit to")
8187 header))
8188 current-prefix-arg)))
16409b0b
GM
8189 (when (not (equal "" regexp))
8190 (prog1
8191 (let ((articles (gnus-summary-find-matching
a1506d29 8192 (cons 'extra header) regexp 'all nil nil
47b63dfa 8193 not-matching)))
16409b0b
GM
8194 (unless articles
8195 (error "Found no matches for \"%s\"" regexp))
8196 (gnus-summary-limit articles))
8197 (gnus-summary-position-point))))
8198
23f87bed
MB
8199(defun gnus-summary-limit-to-display-predicate ()
8200 "Limit the summary buffer to the predicated in the `display' group parameter."
8201 (interactive)
8202 (unless gnus-newsgroup-display
8203 (error "There is no `display' group parameter"))
8204 (let (articles)
8205 (dolist (number gnus-newsgroup-articles)
8206 (when (funcall gnus-newsgroup-display)
8207 (push number articles)))
8208 (gnus-summary-limit articles))
8209 (gnus-summary-position-point))
8210
eec82323
LMI
8211(defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8212(make-obsolete
8213 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8214
8215(defun gnus-summary-limit-to-unread (&optional all)
8216 "Limit the summary buffer to articles that are not marked as read.
8217If ALL is non-nil, limit strictly to unread articles."
8218 (interactive "P")
8219 (if all
8220 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8221 (gnus-summary-limit-to-marks
8222 ;; Concat all the marks that say that an article is read and have
8223 ;; those removed.
8224 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 8225 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
8226 gnus-low-score-mark gnus-expirable-mark
8227 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8228 gnus-duplicate-mark gnus-souped-mark)
8229 'reverse)))
8230
01c52d31
MB
8231(defun gnus-summary-limit-to-headers (match &optional reverse)
8232 "Limit the summary buffer to articles that have headers that match MATCH.
8233If REVERSE (the prefix), limit to articles that don't match."
8234 (interactive "sMatch headers (regexp): \nP")
8235 (gnus-summary-limit-to-bodies match reverse t))
8236
8237(defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8238 "Limit the summary buffer to articles that have bodies that match MATCH.
8239If REVERSE (the prefix), limit to articles that don't match."
8240 (interactive "sMatch body (regexp): \nP")
8241 (let ((articles nil)
8242 (gnus-select-article-hook nil) ;Disable hook.
8243 (gnus-article-prepare-hook nil)
8244 (gnus-use-article-prefetch nil)
8245 (gnus-keep-backlog nil)
8246 (gnus-break-pages nil)
8247 (gnus-summary-display-arrow nil)
8248 (gnus-updated-mode-lines nil)
8249 (gnus-auto-center-summary nil)
8250 (gnus-display-mime-function nil))
8251 (dolist (data gnus-newsgroup-data)
8252 (let (gnus-mark-article-hook)
8253 (gnus-summary-select-article t t nil (gnus-data-number data)))
8254 (save-excursion
8255 (set-buffer gnus-article-buffer)
8256 (article-goto-body)
8257 (let* ((case-fold-search t)
8258 (found (if headersp
8259 (re-search-backward match nil t)
8260 (re-search-forward match nil t))))
8261 (when (or (and found
8262 (not reverse))
8263 (and (not found)
8264 reverse))
8265 (push (gnus-data-number data) articles)))))
8266 (if (not articles)
8267 (message "No messages matched")
8268 (gnus-summary-limit articles)))
8269 (gnus-summary-position-point))
8270
8271(defun gnus-summary-limit-to-singletons (&optional threadsp)
8272 "Limit the summary buffer to articles that aren't part on any thread.
8273If THREADSP (the prefix), limit to articles that are in threads."
8274 (interactive "P")
8275 (let ((articles nil)
8276 thread-articles
8277 threads)
8278 (dolist (thread gnus-newsgroup-threads)
8279 (if (stringp (car thread))
8280 (dolist (thread (cdr thread))
8281 (push thread threads))
8282 (push thread threads)))
8283 (dolist (thread threads)
8284 (setq thread-articles (gnus-articles-in-thread thread))
8285 (when (or (and threadsp
8286 (> (length thread-articles) 1))
8287 (and (not threadsp)
8288 (= (length thread-articles) 1)))
8289 (setq articles (nconc thread-articles articles))))
8290 (if (not articles)
8291 (message "No messages matched")
8292 (gnus-summary-limit articles))
8293 (gnus-summary-position-point)))
8294
8295(defun gnus-summary-limit-to-replied (&optional unreplied)
8296 "Limit the summary buffer to replied articles.
8297If UNREPLIED (the prefix), limit to unreplied articles."
8298 (interactive "P")
8299 (if unreplied
8300 (gnus-summary-limit
8301 (gnus-set-difference gnus-newsgroup-articles
8302 gnus-newsgroup-replied))
8303 (gnus-summary-limit gnus-newsgroup-replied))
8304 (gnus-summary-position-point))
8305
eec82323
LMI
8306(defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
8307(make-obsolete 'gnus-summary-delete-marked-with
81ceefe2 8308 'gnus-summary-limit-exclude-marks)
eec82323
LMI
8309
8310(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8311 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8312If REVERSE, limit the summary buffer to articles that are marked
8313with MARKS. MARKS can either be a string of marks or a list of marks.
8314Returns how many articles were removed."
8315 (interactive "sMarks: ")
8316 (gnus-summary-limit-to-marks marks t))
8317
8318(defun gnus-summary-limit-to-marks (marks &optional reverse)
8319 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8320If REVERSE (the prefix), limit the summary buffer to articles that are
8321not marked with MARKS. MARKS can either be a string of marks or a
8322list of marks.
8323Returns how many articles were removed."
6748645f 8324 (interactive "sMarks: \nP")
eec82323
LMI
8325 (prog1
8326 (let ((data gnus-newsgroup-data)
8327 (marks (if (listp marks) marks
8328 (append marks nil))) ; Transform to list.
8329 articles)
8330 (while data
8331 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8332 (memq (gnus-data-mark (car data)) marks))
8333 (push (gnus-data-number (car data)) articles))
8334 (setq data (cdr data)))
8335 (gnus-summary-limit articles))
8336 (gnus-summary-position-point)))
8337
23f87bed 8338(defun gnus-summary-limit-to-score (score)
eec82323 8339 "Limit to articles with score at or above SCORE."
23f87bed 8340 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
8341 (let ((data gnus-newsgroup-data)
8342 articles)
8343 (while data
8344 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8345 score)
8346 (push (gnus-data-number (car data)) articles))
8347 (setq data (cdr data)))
8348 (prog1
8349 (gnus-summary-limit articles)
8350 (gnus-summary-position-point))))
8351
23f87bed
MB
8352(defun gnus-summary-limit-to-unseen ()
8353 "Limit to unseen articles."
8354 (interactive)
8355 (prog1
8356 (gnus-summary-limit gnus-newsgroup-unseen)
8357 (gnus-summary-position-point)))
8358
6748645f 8359(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
8360 "Display all the hidden articles that is in the thread with ID in it.
8361When called interactively, ID is the Message-ID of the current
8362article."
6748645f
LMI
8363 (interactive (list (mail-header-id (gnus-summary-article-header))))
8364 (let ((articles (gnus-articles-in-thread
8365 (gnus-id-to-thread (gnus-root-id id)))))
8366 (prog1
8367 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
8368 (gnus-summary-limit-include-matching-articles
8369 "subject"
8370 (regexp-quote (gnus-simplify-subject-re
8371 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
8372 (gnus-summary-position-point))))
8373
23f87bed
MB
8374(defun gnus-summary-limit-include-matching-articles (header regexp)
8375 "Display all the hidden articles that have HEADERs that match REGEXP."
8376 (interactive (list (read-string "Match on header: ")
8377 (read-string "Regexp: ")))
8378 (let ((articles (gnus-find-matching-articles header regexp)))
8379 (prog1
8380 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8381 (gnus-summary-position-point))))
8382
8383(defun gnus-summary-insert-dormant-articles ()
8384 "Insert all the dormant articles for this group into the current buffer."
8385 (interactive)
8386 (let ((gnus-verbose (max 6 gnus-verbose)))
8387 (if (not gnus-newsgroup-dormant)
db629244 8388 (gnus-message 3 "No dormant articles for this group")
23f87bed
MB
8389 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8390
01c52d31
MB
8391(defun gnus-summary-insert-ticked-articles ()
8392 "Insert ticked articles for this group into the current buffer."
8393 (interactive)
8394 (let ((gnus-verbose (max 6 gnus-verbose)))
8395 (if (not gnus-newsgroup-marked)
8396 (gnus-message 3 "No ticked articles for this group")
8397 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8398
eec82323 8399(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
8400 "Display all the hidden articles that are marked as dormant.
8401Note that this command only works on a subset of the articles currently
8402fetched for this group."
eec82323 8403 (interactive)
eec82323
LMI
8404 (unless gnus-newsgroup-dormant
8405 (error "There are no dormant articles in this group"))
8406 (prog1
8407 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8408 (gnus-summary-position-point)))
8409
8410(defun gnus-summary-limit-exclude-dormant ()
8411 "Hide all dormant articles."
8412 (interactive)
eec82323
LMI
8413 (prog1
8414 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8415 (gnus-summary-position-point)))
8416
8417(defun gnus-summary-limit-exclude-childless-dormant ()
8418 "Hide all dormant articles that have no children."
8419 (interactive)
eec82323
LMI
8420 (let ((data (gnus-data-list t))
8421 articles d children)
8422 ;; Find all articles that are either not dormant or have
8423 ;; children.
8424 (while (setq d (pop data))
8425 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8426 (and (setq children
8427 (gnus-article-children (gnus-data-number d)))
8428 (let (found)
8429 (while children
8430 (when (memq (car children) articles)
8431 (setq children nil
8432 found t))
8433 (pop children))
8434 found)))
8435 (push (gnus-data-number d) articles)))
8436 ;; Do the limiting.
8437 (prog1
8438 (gnus-summary-limit articles)
8439 (gnus-summary-position-point))))
8440
8441(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8442 "Mark all unread excluded articles as read.
8443If ALL, mark even excluded ticked and dormants as read."
8444 (interactive "P")
23f87bed
MB
8445 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8446 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8447 (sort
8448 (mapcar (lambda (h) (mail-header-number h))
8449 gnus-newsgroup-headers)
8450 '<)
23f87bed 8451 gnus-newsgroup-limit))
eec82323 8452 article)
6748645f 8453 (setq gnus-newsgroup-unreads
23f87bed
MB
8454 (gnus-sorted-intersection gnus-newsgroup-unreads
8455 gnus-newsgroup-limit))
eec82323
LMI
8456 (if all
8457 (setq gnus-newsgroup-dormant nil
8458 gnus-newsgroup-marked nil
8459 gnus-newsgroup-reads
8460 (nconc
8461 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8462 gnus-newsgroup-reads))
8463 (while (setq article (pop articles))
8464 (unless (or (memq article gnus-newsgroup-dormant)
8465 (memq article gnus-newsgroup-marked))
8466 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8467
8468(defun gnus-summary-limit (articles &optional pop)
8469 (if pop
8470 ;; We pop the previous limit off the stack and use that.
8471 (setq articles (car gnus-newsgroup-limits)
8472 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8473 ;; We use the new limit, so we push the old limit on the stack.
8474 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8475 ;; Set the limit.
8476 (setq gnus-newsgroup-limit articles)
8477 (let ((total (length gnus-newsgroup-data))
8478 (data (gnus-data-find-list (gnus-summary-article-number)))
8479 (gnus-summary-mark-below nil) ; Inhibit this.
8480 found)
8481 ;; This will do all the work of generating the new summary buffer
8482 ;; according to the new limit.
8483 (gnus-summary-prepare)
8484 ;; Hide any threads, possibly.
23f87bed 8485 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8486 ;; Try to return to the article you were at, or one in the
8487 ;; neighborhood.
8488 (when data
8489 ;; We try to find some article after the current one.
8490 (while data
8491 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8492 (setq data nil
8493 found t))
8494 (setq data (cdr data))))
8495 (unless found
8496 ;; If there is no data, that means that we were after the last
8497 ;; article. The same goes when we can't find any articles
8498 ;; after the current one.
8499 (goto-char (point-max))
8500 (gnus-summary-find-prev))
6748645f 8501 (gnus-set-mode-line 'summary)
eec82323
LMI
8502 ;; We return how many articles were removed from the summary
8503 ;; buffer as a result of the new limit.
8504 (- total (length gnus-newsgroup-data))))
8505
8506(defsubst gnus-invisible-cut-children (threads)
8507 (let ((num 0))
8508 (while threads
8509 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8510 (incf num))
8511 (pop threads))
8512 (< num 2)))
8513
8514(defsubst gnus-cut-thread (thread)
8515 "Go forwards in the thread until we find an article that we want to display."
8516 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8517 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8518 (numberp gnus-fetch-old-headers)
eec82323
LMI
8519 (eq gnus-build-sparse-threads 'some)
8520 (eq gnus-build-sparse-threads 'more))
8521 ;; Deal with old-fetched headers and sparse threads.
8522 (while (and
8523 thread
8524 (or
8525 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8526 (gnus-summary-article-ancient-p
8527 (mail-header-number (car thread))))
6748645f
LMI
8528 (if (or (<= (length (cdr thread)) 1)
8529 (eq gnus-fetch-old-headers 'invisible))
8530 (setq gnus-newsgroup-limit
8531 (delq (mail-header-number (car thread))
8532 gnus-newsgroup-limit)
8533 thread (cadr thread))
8534 (when (gnus-invisible-cut-children (cdr thread))
8535 (let ((th (cdr thread)))
8536 (while th
8537 (if (memq (mail-header-number (caar th))
a8151ef7 8538 gnus-newsgroup-limit)
6748645f
LMI
8539 (setq thread (car th)
8540 th nil)
8541 (setq th (cdr th))))))))))
eec82323
LMI
8542 thread)
8543
8544(defun gnus-cut-threads (threads)
23f87bed 8545 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8546 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8547 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8548 (numberp gnus-fetch-old-headers)
eec82323
LMI
8549 (eq gnus-build-sparse-threads 'some)
8550 (eq gnus-build-sparse-threads 'more))
8551 (let ((th threads))
8552 (while th
8553 (setcar th (gnus-cut-thread (car th)))
8554 (setq th (cdr th)))))
8555 ;; Remove nixed out threads.
8556 (delq nil threads))
8557
8558(defun gnus-summary-initial-limit (&optional show-if-empty)
8559 "Figure out what the initial limit is supposed to be on group entry.
8560This entails weeding out unwanted dormants, low-scored articles,
8561fetch-old-headers verbiage, and so on."
8562 ;; Most groups have nothing to remove.
8563 (if (or gnus-inhibit-limiting
8564 (and (null gnus-newsgroup-dormant)
23f87bed 8565 (eq gnus-newsgroup-display 'gnus-not-ignore)
eec82323 8566 (not (eq gnus-fetch-old-headers 'some))
16409b0b 8567 (not (numberp gnus-fetch-old-headers))
6748645f 8568 (not (eq gnus-fetch-old-headers 'invisible))
eec82323
LMI
8569 (null gnus-summary-expunge-below)
8570 (not (eq gnus-build-sparse-threads 'some))
8571 (not (eq gnus-build-sparse-threads 'more))
8572 (null gnus-thread-expunge-below)
8573 (not gnus-use-nocem)))
8574 () ; Do nothing.
8575 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8576 (setq gnus-newsgroup-limit nil)
8577 (mapatoms
8578 (lambda (node)
8579 (unless (car (symbol-value node))
8580 ;; These threads have no parents -- they are roots.
8581 (let ((nodes (cdr (symbol-value node)))
8582 thread)
8583 (while nodes
8584 (if (and gnus-thread-expunge-below
8585 (< (gnus-thread-total-score (car nodes))
8586 gnus-thread-expunge-below))
8587 (gnus-expunge-thread (pop nodes))
8588 (setq thread (pop nodes))
8589 (gnus-summary-limit-children thread))))))
8590 gnus-newsgroup-dependencies)
8591 ;; If this limitation resulted in an empty group, we might
8592 ;; pop the previous limit and use it instead.
8593 (when (and (not gnus-newsgroup-limit)
8594 show-if-empty)
8595 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8596 gnus-newsgroup-limit))
8597
8598(defun gnus-summary-limit-children (thread)
8599 "Return 1 if this subthread is visible and 0 if it is not."
8600 ;; First we get the number of visible children to this thread. This
8601 ;; is done by recursing down the thread using this function, so this
8602 ;; will really go down to a leaf article first, before slowly
8603 ;; working its way up towards the root.
8604 (when thread
04b61ae9 8605 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8606 (children
eec82323
LMI
8607 (if (cdr thread)
8608 (apply '+ (mapcar 'gnus-summary-limit-children
8609 (cdr thread)))
8610 0))
8611 (number (mail-header-number (car thread)))
8612 score)
8613 (if (and
8614 (not (memq number gnus-newsgroup-marked))
8615 (or
8616 ;; If this article is dormant and has absolutely no visible
8617 ;; children, then this article isn't visible.
8618 (and (memq number gnus-newsgroup-dormant)
8619 (zerop children))
8620 ;; If this is "fetch-old-headered" and there is no
8621 ;; visible children, then we don't want this article.
16409b0b
GM
8622 (and (or (eq gnus-fetch-old-headers 'some)
8623 (numberp gnus-fetch-old-headers))
eec82323
LMI
8624 (gnus-summary-article-ancient-p number)
8625 (zerop children))
6748645f
LMI
8626 ;; If this is "fetch-old-headered" and `invisible', then
8627 ;; we don't want this article.
8628 (and (eq gnus-fetch-old-headers 'invisible)
8629 (gnus-summary-article-ancient-p number))
eec82323
LMI
8630 ;; If this is a sparsely inserted article with no children,
8631 ;; we don't want it.
8632 (and (eq gnus-build-sparse-threads 'some)
8633 (gnus-summary-article-sparse-p number)
8634 (zerop children))
8635 ;; If we use expunging, and this article is really
8636 ;; low-scored, then we don't want this article.
8637 (when (and gnus-summary-expunge-below
8638 (< (setq score
8639 (or (cdr (assq number gnus-newsgroup-scored))
8640 gnus-summary-default-score))
8641 gnus-summary-expunge-below))
8642 ;; We increase the expunge-tally here, but that has
8643 ;; nothing to do with the limits, really.
8644 (incf gnus-newsgroup-expunged-tally)
8645 ;; We also mark as read here, if that's wanted.
8646 (when (and gnus-summary-mark-below
8647 (< score gnus-summary-mark-below))
8648 (setq gnus-newsgroup-unreads
8649 (delq number gnus-newsgroup-unreads))
8650 (if gnus-newsgroup-auto-expire
8651 (push number gnus-newsgroup-expirable)
8652 (push (cons number gnus-low-score-mark)
8653 gnus-newsgroup-reads)))
8654 t)
23f87bed
MB
8655 ;; Do the `display' group parameter.
8656 (and gnus-newsgroup-display
8657 (not (funcall gnus-newsgroup-display)))
eec82323 8658 ;; Check NoCeM things.
01c52d31
MB
8659 (when (and gnus-use-nocem
8660 (gnus-nocem-unwanted-article-p
8661 (mail-header-id (car thread))))
8662 (setq gnus-newsgroup-unreads
8663 (delq number gnus-newsgroup-unreads))
8664 t)))
eec82323
LMI
8665 ;; Nope, invisible article.
8666 0
8667 ;; Ok, this article is to be visible, so we add it to the limit
8668 ;; and return 1.
8669 (push number gnus-newsgroup-limit)
8670 1))))
8671
8672(defun gnus-expunge-thread (thread)
8673 "Mark all articles in THREAD as read."
8674 (let* ((number (mail-header-number (car thread))))
8675 (incf gnus-newsgroup-expunged-tally)
8676 ;; We also mark as read here, if that's wanted.
8677 (setq gnus-newsgroup-unreads
8678 (delq number gnus-newsgroup-unreads))
8679 (if gnus-newsgroup-auto-expire
8680 (push number gnus-newsgroup-expirable)
8681 (push (cons number gnus-low-score-mark)
8682 gnus-newsgroup-reads)))
8683 ;; Go recursively through all subthreads.
8684 (mapcar 'gnus-expunge-thread (cdr thread)))
8685
8686;; Summary article oriented commands
8687
8688(defun gnus-summary-refer-parent-article (n)
8689 "Refer parent article N times.
8690If N is negative, go to ancestor -N instead.
8691The difference between N and the number of articles fetched is returned."
8692 (interactive "p")
eec82323
LMI
8693 (let ((skip 1)
8694 error header ref)
8695 (when (not (natnump n))
8696 (setq skip (abs n)
8697 n 1))
8698 (while (and (> n 0)
8699 (not error))
8700 (setq header (gnus-summary-article-header))
8701 (if (and (eq (mail-header-number header)
8702 (cdr gnus-article-current))
8703 (equal gnus-newsgroup-name
8704 (car gnus-article-current)))
8705 ;; If we try to find the parent of the currently
8706 ;; displayed article, then we take a look at the actual
8707 ;; References header, since this is slightly more
8708 ;; reliable than the References field we got from the
8709 ;; server.
8710 (save-excursion
8711 (set-buffer gnus-original-article-buffer)
8712 (nnheader-narrow-to-headers)
8713 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8714 (when (setq ref (message-fetch-field "in-reply-to"))
8715 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8716 (widen))
8717 (setq ref
8718 ;; It's not the current article, so we take a bet on
8719 ;; the value we got from the server.
8720 (mail-header-references header)))
8721 (if (and ref
8722 (not (equal ref "")))
8723 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8724 (gnus-message 1 "Couldn't find parent"))
8725 (gnus-message 1 "No references in article %d"
8726 (gnus-summary-article-number))
8727 (setq error t))
8728 (decf n))
8729 (gnus-summary-position-point)
8730 n))
8731
8732(defun gnus-summary-refer-references ()
8733 "Fetch all articles mentioned in the References header.
6748645f 8734Return the number of articles fetched."
eec82323 8735 (interactive)
eec82323
LMI
8736 (let ((ref (mail-header-references (gnus-summary-article-header)))
8737 (current (gnus-summary-article-number))
8738 (n 0))
8739 (if (or (not ref)
8740 (equal ref ""))
8741 (error "No References in the current article")
8742 ;; For each Message-ID in the References header...
8743 (while (string-match "<[^>]*>" ref)
8744 (incf n)
8745 ;; ... fetch that article.
8746 (gnus-summary-refer-article
8747 (prog1 (match-string 0 ref)
8748 (setq ref (substring ref (match-end 0))))))
8749 (gnus-summary-goto-subject current)
8750 (gnus-summary-position-point)
8751 n)))
8752
6748645f
LMI
8753(defun gnus-summary-refer-thread (&optional limit)
8754 "Fetch all articles in the current thread.
8755If LIMIT (the numerical prefix), fetch that many old headers instead
8756of what's specified by the `gnus-refer-thread-limit' variable."
8757 (interactive "P")
8758 (let ((id (mail-header-id (gnus-summary-article-header)))
8759 (limit (if limit (prefix-numeric-value limit)
8760 gnus-refer-thread-limit)))
6748645f
LMI
8761 (unless (eq gnus-fetch-old-headers 'invisible)
8762 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8763 ;; Retrieve the headers and read them in.
23f87bed
MB
8764 (if (eq (if (numberp limit)
8765 (gnus-retrieve-headers
8766 (list (min
8767 (+ (mail-header-number
8768 (gnus-summary-article-header))
8769 limit)
8770 gnus-newsgroup-end))
8771 gnus-newsgroup-name (* limit 2))
8772 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8773 ;; headers.
8774 (gnus-retrieve-headers (list gnus-newsgroup-end)
8775 gnus-newsgroup-name limit))
6748645f
LMI
8776 'nov)
8777 (gnus-build-all-threads)
23f87bed 8778 (error "Can't fetch thread from back ends that don't support NOV"))
6748645f
LMI
8779 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8780 (gnus-summary-limit-include-thread id)))
8781
16409b0b
GM
8782(defun gnus-summary-refer-article (message-id)
8783 "Fetch an article specified by MESSAGE-ID."
8784 (interactive "sMessage-ID: ")
eec82323
LMI
8785 (when (and (stringp message-id)
8786 (not (zerop (length message-id))))
23f87bed 8787 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8788 ;; Construct the correct Message-ID if necessary.
8789 ;; Suggested by tale@pawl.rpi.edu.
8790 (unless (string-match "^<" message-id)
8791 (setq message-id (concat "<" message-id)))
8792 (unless (string-match ">$" message-id)
8793 (setq message-id (concat message-id ">")))
23f87bed
MB
8794 ;; People often post MIDs from URLs, so unhex it:
8795 (unless (string-match "@" message-id)
8796 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8797 (let* ((header (gnus-id-to-header message-id))
8798 (sparse (and header
8799 (gnus-summary-article-sparse-p
a8151ef7
LMI
8800 (mail-header-number header))
8801 (memq (mail-header-number header)
16409b0b
GM
8802 gnus-newsgroup-limit)))
8803 number)
6748645f
LMI
8804 (cond
8805 ;; If the article is present in the buffer we just go to it.
8806 ((and header
8807 (or (not (gnus-summary-article-sparse-p
8808 (mail-header-number header)))
8809 sparse))
8810 (prog1
8811 (gnus-summary-goto-article
8812 (mail-header-number header) nil t)
8813 (when sparse
8814 (gnus-summary-update-article (mail-header-number header)))))
8815 (t
16409b0b
GM
8816 ;; We fetch the article.
8817 (catch 'found
8818 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8819 (when (and (gnus-check-server gnus-override-method)
8820 ;; Fetch the header,
8821 (setq number (gnus-summary-insert-subject message-id)))
8822 ;; and display the article.
eec82323 8823 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8824 (throw 'found t)))
8825 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8826
8827(defun gnus-refer-article-methods ()
8f688cb0 8828 "Return a list of referable methods."
16409b0b
GM
8829 (cond
8830 ;; No method, so we default to current and native.
8831 ((null gnus-refer-article-method)
8832 (list gnus-current-select-method gnus-select-method))
8833 ;; Current.
8834 ((eq 'current gnus-refer-article-method)
8835 (list gnus-current-select-method))
8836 ;; List of select methods.
d4dfaa19
DL
8837 ((not (and (symbolp (car gnus-refer-article-method))
8838 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
8839 (let (out)
8840 (dolist (method gnus-refer-article-method)
8841 (push (if (eq 'current method)
8842 gnus-current-select-method
8843 method)
8844 out))
8845 (nreverse out)))
8846 ;; One single select method.
8847 (t
8848 (list gnus-refer-article-method))))
6748645f
LMI
8849
8850(defun gnus-summary-edit-parameters ()
8851 "Edit the group parameters of the current group."
8852 (interactive)
8853 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 8854
16409b0b
GM
8855(defun gnus-summary-customize-parameters ()
8856 "Customize the group parameters of the current group."
8857 (interactive)
8858 (gnus-group-customize gnus-newsgroup-name))
8859
eec82323
LMI
8860(defun gnus-summary-enter-digest-group (&optional force)
8861 "Enter an nndoc group based on the current article.
8862If FORCE, force a digest interpretation. If not, try
8863to guess what the document format is."
8864 (interactive "P")
eec82323 8865 (let ((conf gnus-current-window-configuration))
23f87bed
MB
8866 (save-window-excursion
8867 (save-excursion
8868 (let (gnus-article-prepare-hook
8869 gnus-display-mime-function
8870 gnus-break-pages)
8871 (gnus-summary-select-article))))
eec82323
LMI
8872 (setq gnus-current-window-configuration conf)
8873 (let* ((name (format "%s-%d"
8874 (gnus-group-prefixed-name
8875 gnus-newsgroup-name (list 'nndoc ""))
01c52d31 8876 (with-current-buffer gnus-summary-buffer
eec82323
LMI
8877 gnus-current-article)))
8878 (ogroup gnus-newsgroup-name)
8879 (params (append (gnus-info-params (gnus-get-info ogroup))
8880 (list (cons 'to-group ogroup))
23f87bed 8881 (list (cons 'parent-group ogroup))
eec82323
LMI
8882 (list (cons 'save-article-group ogroup))))
8883 (case-fold-search t)
8884 (buf (current-buffer))
16409b0b 8885 dig to-address)
eec82323 8886 (save-excursion
16409b0b
GM
8887 (set-buffer gnus-original-article-buffer)
8888 ;; Have the digest group inherit the main mail address of
8889 ;; the parent article.
23f87bed
MB
8890 (when (setq to-address (or (gnus-fetch-field "reply-to")
8891 (gnus-fetch-field "from")))
343d6628
MB
8892 (setq params
8893 (append
8894 (list (cons 'to-address
8895 (funcall gnus-decode-encoded-address-function
8896 to-address))))))
eec82323
LMI
8897 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8898 (insert-buffer-substring gnus-original-article-buffer)
8899 ;; Remove lines that may lead nndoc to misinterpret the
8900 ;; document type.
8901 (narrow-to-region
8902 (goto-char (point-min))
8903 (or (search-forward "\n\n" nil t) (point)))
8904 (goto-char (point-min))
16409b0b 8905 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8906 (widen))
8907 (unwind-protect
23f87bed 8908 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
8909 (gnus-newsgroup-ephemeral-ignored-charsets
8910 gnus-newsgroup-ignored-charsets))
8911 (gnus-group-read-ephemeral-group
8912 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8913 (nndoc-article-type
23f87bed
MB
8914 ,(if force 'mbox 'guess)))
8915 t nil nil nil
8916 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8917 "ADAPT")))))
16409b0b 8918 ;; Make all postings to this group go to the parent group.
23f87bed
MB
8919 (nconc (gnus-info-params (gnus-get-info name))
8920 params)
8921 ;; Couldn't select this doc group.
8922 (switch-to-buffer buf)
8923 (gnus-set-global-variables)
8924 (gnus-configure-windows 'summary)
8925 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
8926 (kill-buffer dig)))))
8927
8928(defun gnus-summary-read-document (n)
8929 "Open a new group based on the current article(s).
8930This will allow you to read digests and other similar
8931documents as newsgroups.
8932Obeys the standard process/prefix convention."
8933 (interactive "P")
01c52d31 8934 (let* ((ogroup gnus-newsgroup-name)
eec82323
LMI
8935 (params (append (gnus-info-params (gnus-get-info ogroup))
8936 (list (cons 'to-group ogroup))))
01c52d31
MB
8937 group egroup groups vgroup)
8938 (dolist (article (gnus-summary-work-articles n))
eec82323
LMI
8939 (setq group (format "%s-%d" gnus-newsgroup-name article))
8940 (gnus-summary-remove-process-mark article)
8941 (when (gnus-summary-display-article article)
8942 (save-excursion
16409b0b 8943 (with-temp-buffer
eec82323
LMI
8944 (insert-buffer-substring gnus-original-article-buffer)
8945 ;; Remove some headers that may lead nndoc to make
8946 ;; the wrong guess.
8947 (message-narrow-to-head)
8948 (goto-char (point-min))
01c52d31 8949 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8950 (widen)
8951 (if (setq egroup
8952 (gnus-group-read-ephemeral-group
8953 group `(nndoc ,group (nndoc-address ,(current-buffer))
8954 (nndoc-article-type guess))
8955 t nil t))
8956 (progn
23f87bed 8957 ;; Make all postings to this group go to the parent group.
eec82323
LMI
8958 (nconc (gnus-info-params (gnus-get-info egroup))
8959 params)
8960 (push egroup groups))
8961 ;; Couldn't select this doc group.
8962 (gnus-error 3 "Article couldn't be entered"))))))
8963 ;; Now we have selected all the documents.
8964 (cond
8965 ((not groups)
8966 (error "None of the articles could be interpreted as documents"))
8967 ((gnus-group-read-ephemeral-group
8968 (setq vgroup (format
8969 "nnvirtual:%s-%s" gnus-newsgroup-name
8970 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8971 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8972 t
8973 (cons (current-buffer) 'summary)))
8974 (t
8975 (error "Couldn't select virtual nndoc group")))))
8976
8977(defun gnus-summary-isearch-article (&optional regexp-p)
8978 "Do incremental search forward on the current article.
8979If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8980 (interactive "P")
eec82323
LMI
8981 (gnus-summary-select-article)
8982 (gnus-configure-windows 'article)
8983 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
8984 (save-restriction
8985 (widen)
8986 (isearch-forward regexp-p))))
eec82323 8987
01c52d31
MB
8988(defun gnus-summary-repeat-search-article-forward ()
8989 "Repeat the previous search forwards."
8990 (interactive)
8991 (unless gnus-last-search-regexp
8992 (error "No previous search"))
8993 (gnus-summary-search-article-forward gnus-last-search-regexp))
8994
8995(defun gnus-summary-repeat-search-article-backward ()
8996 "Repeat the previous search backwards."
8997 (interactive)
8998 (unless gnus-last-search-regexp
8999 (error "No previous search"))
9000 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9001
eec82323
LMI
9002(defun gnus-summary-search-article-forward (regexp &optional backward)
9003 "Search for an article containing REGEXP forward.
9004If BACKWARD, search backward instead."
9005 (interactive
9006 (list (read-string
9007 (format "Search article %s (regexp%s): "
9008 (if current-prefix-arg "backward" "forward")
9009 (if gnus-last-search-regexp
9010 (concat ", default " gnus-last-search-regexp)
9011 "")))
9012 current-prefix-arg))
eec82323
LMI
9013 (if (string-equal regexp "")
9014 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
9015 (setq gnus-last-search-regexp regexp)
9016 (setq gnus-article-before-search gnus-current-article))
9017 ;; Intentionally set gnus-last-article.
9018 (setq gnus-last-article gnus-article-before-search)
9019 (let ((gnus-last-article gnus-last-article))
9020 (if (gnus-summary-search-article regexp backward)
9021 (gnus-summary-show-thread)
abc40aab 9022 (signal 'search-failed (list regexp)))))
eec82323
LMI
9023
9024(defun gnus-summary-search-article-backward (regexp)
9025 "Search for an article containing REGEXP backward."
9026 (interactive
9027 (list (read-string
9028 (format "Search article backward (regexp%s): "
9029 (if gnus-last-search-regexp
9030 (concat ", default " gnus-last-search-regexp)
9031 "")))))
9032 (gnus-summary-search-article-forward regexp 'backward))
9033
9034(defun gnus-summary-search-article (regexp &optional backward)
9035 "Search for an article containing REGEXP.
9036Optional argument BACKWARD means do search for backward.
9037`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
9038 ;; We have to require this here to make sure that the following
9039 ;; dynamic binding isn't shadowed by autoloading.
9040 (require 'gnus-async)
16409b0b 9041 (require 'gnus-art)
eec82323 9042 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 9043 (gnus-article-prepare-hook nil)
eec82323
LMI
9044 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9045 (gnus-use-article-prefetch nil)
9046 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 9047 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
9048 (gnus-visual nil)
9049 (gnus-keep-backlog nil)
9050 (gnus-break-pages nil)
9051 (gnus-summary-display-arrow nil)
9052 (gnus-updated-mode-lines nil)
9053 (gnus-auto-center-summary nil)
eec82323 9054 (sum (current-buffer))
16409b0b 9055 (gnus-display-mime-function nil)
eec82323
LMI
9056 (found nil)
9057 point)
9058 (gnus-save-hidden-threads
9059 (gnus-summary-select-article)
9060 (set-buffer gnus-article-buffer)
16409b0b 9061 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
9062 (when backward
9063 (forward-line -1))
9064 (while (not found)
9065 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9066 (if (if backward
9067 (re-search-backward regexp nil t)
9068 (re-search-forward regexp nil t))
9069 ;; We found the regexp.
9070 (progn
9071 (setq found 'found)
9072 (beginning-of-line)
9073 (set-window-start
9074 (get-buffer-window (current-buffer))
9075 (point))
9076 (forward-line 1)
16409b0b
GM
9077 (set-window-point
9078 (get-buffer-window (current-buffer))
9079 (point))
eec82323
LMI
9080 (set-buffer sum)
9081 (setq point (point)))
9082 ;; We didn't find it, so we go to the next article.
9083 (set-buffer sum)
9084 (setq found 'not)
9085 (while (eq found 'not)
9086 (if (not (if backward (gnus-summary-find-prev)
9087 (gnus-summary-find-next)))
9088 ;; No more articles.
9089 (setq found t)
9090 ;; Select the next article and adjust point.
9091 (unless (gnus-summary-article-sparse-p
9092 (gnus-summary-article-number))
9093 (setq found nil)
9094 (gnus-summary-select-article)
9095 (set-buffer gnus-article-buffer)
9096 (widen)
9097 (goto-char (if backward (point-max) (point-min))))))))
9098 (gnus-message 7 ""))
9099 ;; Return whether we found the regexp.
9100 (when (eq found 'found)
9101 (goto-char point)
9102 (gnus-summary-show-thread)
9103 (gnus-summary-goto-subject gnus-current-article)
9104 (gnus-summary-position-point)
9105 t)))
9106
23f87bed
MB
9107(defun gnus-find-matching-articles (header regexp)
9108 "Return a list of all articles that match REGEXP on HEADER.
9109This search includes all articles in the current group that Gnus has
9110fetched headers for, whether they are displayed or not."
9111 (let ((articles nil)
9112 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9113 (case-fold-search t))
9114 (dolist (header gnus-newsgroup-headers)
9115 (when (string-match regexp (funcall func header))
9116 (push (mail-header-number header) articles)))
9117 (nreverse articles)))
9118
eec82323 9119(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 9120 not-case-fold not-matching)
eec82323
LMI
9121 "Return a list of all articles that match REGEXP on HEADER.
9122The search stars on the current article and goes forwards unless
9123BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9124If UNREAD is non-nil, only unread articles will
9125be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 9126in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
9127not match REGEXP on HEADER."
9128 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
9129 articles d func)
9130 (if (consp header)
9131 (if (eq (car header) 'extra)
9132 (setq func
9133 `(lambda (h)
9134 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9135 "")))
9136 (error "%s is an invalid header" header))
9137 (unless (fboundp (intern (concat "mail-header-" header)))
9138 (error "%s is not a valid header" header))
9139 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
9140 (dolist (d (if (eq backward 'all)
9141 gnus-newsgroup-data
9142 (gnus-data-find-list
9143 (gnus-summary-article-number)
9144 (gnus-data-list backward))))
9145 (when (and (or (not unread) ; We want all articles...
9146 (gnus-data-unread-p d)) ; Or just unreads.
9147 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9148 (if not-matching
a1506d29 9149 (not (string-match
47b63dfa
SZ
9150 regexp
9151 (funcall func (gnus-data-header d))))
9152 (string-match regexp
9153 (funcall func (gnus-data-header d)))))
9154 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
9155 (nreverse articles)))
9156
9157(defun gnus-summary-execute-command (header regexp command &optional backward)
9158 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9159If HEADER is an empty string (or nil), the match is done on the entire
9160article. If BACKWARD (the prefix) is non-nil, search backward instead."
9161 (interactive
9162 (list (let ((completion-ignore-case t))
9163 (completing-read
9164 "Header name: "
23f87bed
MB
9165 (mapcar (lambda (header) (list (format "%s" header)))
9166 (append
9167 '("Number" "Subject" "From" "Lines" "Date"
9168 "Message-ID" "Xref" "References" "Body")
9169 gnus-extra-headers))
eec82323
LMI
9170 nil 'require-match))
9171 (read-string "Regexp: ")
9172 (read-key-sequence "Command: ")
9173 current-prefix-arg))
9174 (when (equal header "Body")
9175 (setq header ""))
eec82323
LMI
9176 ;; Hidden thread subtrees must be searched as well.
9177 (gnus-summary-show-all-threads)
9178 ;; We don't want to change current point nor window configuration.
9179 (save-excursion
9180 (save-window-excursion
23f87bed
MB
9181 (let (gnus-visual
9182 gnus-treat-strip-trailing-blank-lines
9183 gnus-treat-strip-leading-blank-lines
9184 gnus-treat-strip-multiple-blank-lines
9185 gnus-treat-hide-boring-headers
9186 gnus-treat-fold-newsgroups
9187 gnus-article-prepare-hook)
9188 (gnus-message 6 "Executing %s..." (key-description command))
9189 ;; We'd like to execute COMMAND interactively so as to give arguments.
9190 (gnus-execute header regexp
9191 `(call-interactively ',(key-binding command))
9192 backward)
9193 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
9194
9195(defun gnus-summary-beginning-of-article ()
9196 "Scroll the article back to the beginning."
9197 (interactive)
eec82323
LMI
9198 (gnus-summary-select-article)
9199 (gnus-configure-windows 'article)
9200 (gnus-eval-in-buffer-window gnus-article-buffer
9201 (widen)
9202 (goto-char (point-min))
23f87bed 9203 (when gnus-break-pages
eec82323
LMI
9204 (gnus-narrow-to-page))))
9205
9206(defun gnus-summary-end-of-article ()
9207 "Scroll to the end of the article."
9208 (interactive)
eec82323
LMI
9209 (gnus-summary-select-article)
9210 (gnus-configure-windows 'article)
9211 (gnus-eval-in-buffer-window gnus-article-buffer
9212 (widen)
9213 (goto-char (point-max))
9214 (recenter -3)
23f87bed
MB
9215 (when gnus-break-pages
9216 (when (re-search-backward page-delimiter nil t)
9217 (narrow-to-region (match-end 0) (point-max)))
eec82323
LMI
9218 (gnus-narrow-to-page))))
9219
23f87bed
MB
9220(defun gnus-summary-print-truncate-and-quote (string &optional len)
9221 "Truncate to LEN and quote all \"(\"'s in STRING."
9222 (gnus-replace-in-string (if (and len (> (length string) len))
9223 (substring string 0 len)
9224 string)
9225 "[()]" "\\\\\\&"))
9226
6748645f 9227(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
9228 "Generate and print a PostScript image of the process-marked (mail) articles.
9229
9230If used interactively, print the current article if none are
9231process-marked. With prefix arg, prompt the user for the name of the
9232file to save in.
6748645f 9233
23f87bed
MB
9234When used from Lisp, accept two optional args FILENAME and N. N means
9235to print the next N articles. If N is negative, print the N previous
9236articles. If N is nil and articles have been marked with the process
9237mark, print these instead.
eec82323 9238
16409b0b 9239If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
9240printer. If FILENAME is a string, save the PostScript image in a file with
9241that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 9242to save in."
676a7cc9 9243 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
9244 (dolist (article (gnus-summary-work-articles n))
9245 (gnus-summary-select-article nil nil 'pseudo article)
9246 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 9247 (gnus-print-buffer))
676a7cc9
SZ
9248 (gnus-summary-remove-process-mark article))
9249 (ps-despool filename))
eec82323 9250
23f87bed
MB
9251(defun gnus-print-buffer ()
9252 (let ((buffer (generate-new-buffer " *print*")))
9253 (unwind-protect
9254 (progn
9255 (copy-to-buffer buffer (point-min) (point-max))
9256 (set-buffer buffer)
9257 (gnus-remove-text-with-property 'gnus-decoration)
9258 (when (gnus-visual-p 'article-highlight 'highlight)
9259 ;; Copy-to-buffer doesn't copy overlay. So redo
9260 ;; highlight.
9261 (let ((gnus-article-buffer buffer))
9262 (gnus-article-highlight-citation t)
9263 (gnus-article-highlight-signature)
9264 (gnus-article-emphasize)
9265 (gnus-article-delete-invisible-text)))
9266 (let ((ps-left-header
9267 (list
9268 (concat "("
9269 (gnus-summary-print-truncate-and-quote
9270 (mail-header-subject gnus-current-headers)
9271 66) ")")
9272 (concat "("
9273 (gnus-summary-print-truncate-and-quote
9274 (mail-header-from gnus-current-headers)
9275 45) ")")))
9276 (ps-right-header
9277 (list
9278 "/pagenumberstring load"
9279 (concat "("
9280 (mail-header-date gnus-current-headers) ")"))))
9281 (gnus-run-hooks 'gnus-ps-print-hook)
9282 (save-excursion
9283 (if window-system
9284 (ps-spool-buffer-with-faces)
9285 (ps-spool-buffer)))))
9286 (kill-buffer buffer))))
9287
eec82323 9288(defun gnus-summary-show-article (&optional arg)
23f87bed 9289 "Force redisplaying of the current article.
16409b0b
GM
9290If ARG (the prefix) is a number, show the article with the charset
9291defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 9292input.
16409b0b 9293If ARG (the prefix) is non-nil and not a number, show the raw article
23f87bed
MB
9294without any article massaging functions being run. Normally, the key
9295strokes are `C-u g'."
eec82323 9296 (interactive "P")
16409b0b
GM
9297 (cond
9298 ((numberp arg)
23f87bed 9299 (gnus-summary-show-article t)
16409b0b
GM
9300 (let ((gnus-newsgroup-charset
9301 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
9302 (mm-read-coding-system
9303 "View as charset: " ;; actually it is coding system.
01c52d31 9304 (with-current-buffer gnus-article-buffer
23f87bed 9305 (mm-detect-coding-region (point) (point-max))))))
16409b0b 9306 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
9307 (gnus-summary-select-article nil 'force)
9308 (let ((deps gnus-newsgroup-dependencies)
9309 head header lines)
9310 (save-excursion
9311 (set-buffer gnus-original-article-buffer)
9312 (save-restriction
9313 (message-narrow-to-head)
9314 (setq head (buffer-string))
9315 (goto-char (point-min))
9316 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9317 (goto-char (point-max))
9318 (widen)
9319 (setq lines (1- (count-lines (point) (point-max))))))
9320 (with-temp-buffer
9321 (insert (format "211 %d Article retrieved.\n"
9322 (cdr gnus-article-current)))
9323 (insert head)
9324 (if lines (insert (format "Lines: %d\n" lines)))
9325 (insert ".\n")
9326 (let ((nntp-server-buffer (current-buffer)))
9327 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9328 (gnus-data-set-header
9329 (gnus-data-find (cdr gnus-article-current))
9330 header)
9331 (gnus-summary-update-article-line
9332 (cdr gnus-article-current) header)
9333 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9334 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
9335 ((not arg)
9336 ;; Select the article the normal way.
9337 (gnus-summary-select-article nil 'force))
9338 (t
9339 ;; We have to require this here to make sure that the following
9340 ;; dynamic binding isn't shadowed by autoloading.
9341 (require 'gnus-async)
9342 (require 'gnus-art)
eec82323
LMI
9343 ;; Bind the article treatment functions to nil.
9344 (let ((gnus-have-all-headers t)
eec82323 9345 gnus-article-prepare-hook
16409b0b
GM
9346 gnus-article-decode-hook
9347 gnus-display-mime-function
9348 gnus-break-pages)
9349 ;; Destroy any MIME parts.
9350 (when (gnus-buffer-live-p gnus-article-buffer)
9351 (save-excursion
9352 (set-buffer gnus-article-buffer)
9353 (mm-destroy-parts gnus-article-mime-handles)
9354 ;; Set it to nil for safety reason.
9355 (setq gnus-article-mime-handle-alist nil)
9356 (setq gnus-article-mime-handles nil)))
9357 (gnus-summary-select-article nil 'force))))
eec82323
LMI
9358 (gnus-summary-goto-subject gnus-current-article)
9359 (gnus-summary-position-point))
9360
23f87bed
MB
9361(defun gnus-summary-show-raw-article ()
9362 "Show the raw article without any article massaging functions being run."
9363 (interactive)
9364 (gnus-summary-show-article t))
9365
eec82323
LMI
9366(defun gnus-summary-verbose-headers (&optional arg)
9367 "Toggle permanent full header display.
9368If ARG is a positive number, turn header display on.
9369If ARG is a negative number, turn header display off."
9370 (interactive "P")
eec82323
LMI
9371 (setq gnus-show-all-headers
9372 (cond ((or (not (numberp arg))
9373 (zerop arg))
9374 (not gnus-show-all-headers))
9375 ((natnump arg)
9376 t)))
9377 (gnus-summary-show-article))
9378
9379(defun gnus-summary-toggle-header (&optional arg)
9380 "Show the headers if they are hidden, or hide them if they are shown.
9381If ARG is a positive number, show the entire header.
9382If ARG is a negative number, hide the unwanted header lines."
9383 (interactive "P")
23f87bed
MB
9384 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9385 (get-buffer-window gnus-article-buffer t))))
9386 (with-current-buffer gnus-article-buffer
9387 (widen)
9388 (article-narrow-to-head)
16409b0b
GM
9389 (let* ((buffer-read-only nil)
9390 (inhibit-point-motion-hooks t)
23f87bed
MB
9391 (hidden (if (numberp arg)
9392 (>= arg 0)
f0096211
MB
9393 (or (not (looking-at "[^ \t\n]+:"))
9394 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
9395 s e)
9396 (delete-region (point-min) (point-max))
667e0ba6
SM
9397 (with-current-buffer gnus-original-article-buffer
9398 (goto-char (setq s (point-min)))
23f87bed
MB
9399 (setq e (if (search-forward "\n\n" nil t)
9400 (1- (point))
9401 (point-max))))
667e0ba6 9402 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
9403 (run-hooks 'gnus-article-decode-hook)
9404 (if hidden
9405 (let ((gnus-treat-hide-headers nil)
9406 (gnus-treat-hide-boring-headers nil))
9407 (gnus-delete-wash-type 'headers)
9408 (gnus-treat-article 'head))
9409 (gnus-treat-article 'head))
9410 (widen)
9411 (if window
9412 (set-window-start window (goto-char (point-min))))
9413 (if gnus-break-pages
9414 (gnus-narrow-to-page)
9415 (when (gnus-visual-p 'page-marker)
9416 (let ((buffer-read-only nil))
9417 (gnus-remove-text-with-property 'gnus-prev)
9418 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9419 (gnus-set-mode-line 'article)))))
eec82323
LMI
9420
9421(defun gnus-summary-show-all-headers ()
9422 "Make all header lines visible."
9423 (interactive)
23f87bed 9424 (gnus-summary-toggle-header 1))
eec82323 9425
eec82323
LMI
9426(defun gnus-summary-caesar-message (&optional arg)
9427 "Caesar rotate the current article by 13.
01c52d31
MB
9428With a non-numerical prefix, also rotate headers. A numerical
9429prefix specifies how many places to rotate each letter forward."
eec82323 9430 (interactive "P")
eec82323
LMI
9431 (gnus-summary-select-article)
9432 (let ((mail-header-separator ""))
9433 (gnus-eval-in-buffer-window gnus-article-buffer
9434 (save-restriction
9435 (widen)
9436 (let ((start (window-start))
9437 buffer-read-only)
01c52d31
MB
9438 (if (equal arg '(4))
9439 (message-caesar-buffer-body nil t)
9440 (message-caesar-buffer-body arg))
ff4d3926
MB
9441 (set-window-start (get-buffer-window (current-buffer)) start)))))
9442 ;; Create buttons and stuff...
9443 (gnus-treat-article nil))
eec82323 9444
01c52d31
MB
9445(defun gnus-summary-idna-message (&optional arg)
9446 "Decode IDNA encoded domain names in the current articles.
9447IDNA encoded domain names looks like `xn--bar'. If a string
9448remain unencoded after running this function, it is likely an
9449invalid IDNA string (`xn--bar' is invalid).
9450
9451You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
9452installed for this command to work."
9453 (interactive "P")
9454 (if (not (and (condition-case nil (require 'idna)
9455 (file-error))
9456 (mm-coding-system-p 'utf-8)
9457 (executable-find (symbol-value 'idna-program))))
9458 (gnus-message
9459 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9460 (gnus-summary-select-article)
9461 (let ((mail-header-separator ""))
9462 (gnus-eval-in-buffer-window gnus-article-buffer
9463 (save-restriction
9464 (widen)
9465 (let ((start (window-start))
9466 buffer-read-only)
9467 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9468 (replace-match (idna-to-unicode (match-string 1))))
9469 (set-window-start (get-buffer-window (current-buffer)) start)))))))
23f87bed
MB
9470
9471(defun gnus-summary-morse-message (&optional arg)
9472 "Morse decode the current article."
9473 (interactive "P")
9474 (gnus-summary-select-article)
9475 (let ((mail-header-separator ""))
9476 (gnus-eval-in-buffer-window gnus-article-buffer
9477 (save-excursion
9478 (save-restriction
9479 (widen)
9480 (let ((pos (window-start))
9481 buffer-read-only)
9482 (goto-char (point-min))
9483 (when (message-goto-body)
9484 (gnus-narrow-to-body))
9485 (goto-char (point-min))
01c52d31 9486