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