2005-10-04 Reiner Steib <Reiner.Steib@gmx.de>
[gnus] / lisp / gnus-sum.el
1 ;;; gnus-sum.el --- summary mode commands for Gnus
2
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;;   2005 Free Software Foundation, Inc.
5
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
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
13 ;; the Free Software Foundation; either version 2, or (at your option)
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
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
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
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile
31   (require 'cl)
32   (defvar tool-bar-map))
33
34 (require 'gnus)
35 (require 'gnus-group)
36 (require 'gnus-spec)
37 (require 'gnus-range)
38 (require 'gnus-int)
39 (require 'gnus-undo)
40 (require 'gnus-util)
41 (require 'mm-decode)
42 (require 'nnoo)
43
44 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
45 (autoload 'gnus-cache-write-active "gnus-cache")
46 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
47 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
48 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
49 (autoload 'mm-uu-dissect "mm-uu")
50 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
51   "Deuglify broken Outlook (Express) articles and redisplay."
52   t)
53 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
54 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
55 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
56
57 (defcustom gnus-kill-summary-on-exit t
58   "*If non-nil, kill the summary buffer when you exit from it.
59 If nil, the summary will become a \"*Dead Summary*\" buffer, and
60 it will be killed sometime later."
61   :group 'gnus-summary-exit
62   :type 'boolean)
63
64 (defcustom gnus-fetch-old-headers nil
65   "*Non-nil means that Gnus will try to build threads by grabbing old headers.
66 If an unread article in the group refers to an older, already read (or
67 just marked as read) article, the old article will not normally be
68 displayed in the Summary buffer.  If this variable is t, Gnus
69 will attempt to grab the headers to the old articles, and thereby
70 build complete threads.  If it has the value `some', only enough
71 headers to connect otherwise loose threads will be displayed.  This
72 variable can also be a number.  In that case, no more than that number
73 of old headers will be fetched.  If it has the value `invisible', all
74 old headers will be fetched, but none will be displayed.
75
76 The server has to support NOV for any of this to work."
77   :group 'gnus-thread
78   :type '(choice (const :tag "off" nil)
79                  (const :tag "on" t)
80                  (const some)
81                  (const invisible)
82                  number
83                  (sexp :menu-tag "other" t)))
84
85 (defcustom gnus-refer-thread-limit 200
86   "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
87 If t, fetch all the available old headers."
88   :group 'gnus-thread
89   :type '(choice number
90                  (sexp :menu-tag "other" t)))
91
92 (defcustom gnus-summary-make-false-root 'adopt
93   "*nil means that Gnus won't gather loose threads.
94 If the root of a thread has expired or been read in a previous
95 session, the information necessary to build a complete thread has been
96 lost.  Instead of having many small sub-threads from this original thread
97 scattered all over the summary buffer, Gnus can gather them.
98
99 If non-nil, Gnus will try to gather all loose sub-threads from an
100 original thread into one large thread.
101
102 If this variable is non-nil, it should be one of `none', `adopt',
103 `dummy' or `empty'.
104
105 If this variable is `none', Gnus will not make a false root, but just
106 present the sub-threads after another.
107 If this variable is `dummy', Gnus will create a dummy root that will
108 have all the sub-threads as children.
109 If this variable is `adopt', Gnus will make one of the \"children\"
110 the parent and mark all the step-children as such.
111 If this variable is `empty', the \"children\" are printed with empty
112 subject fields.  (Or rather, they will be printed with a string
113 given by the `gnus-summary-same-subject' variable.)"
114   :group 'gnus-thread
115   :type '(choice (const :tag "off" nil)
116                  (const none)
117                  (const dummy)
118                  (const adopt)
119                  (const empty)))
120
121 (defcustom gnus-summary-make-false-root-always nil
122   "Always make a false dummy root."
123   :version "22.1"
124   :group 'gnus-thread
125   :type 'boolean)
126
127 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
128   "*A regexp to match subjects to be excluded from loose thread gathering.
129 As loose thread gathering is done on subjects only, that means that
130 there can be many false gatherings performed.  By rooting out certain
131 common subjects, gathering might become saner."
132   :group 'gnus-thread
133   :type 'regexp)
134
135 (defcustom gnus-summary-gather-subject-limit nil
136   "*Maximum length of subject comparisons when gathering loose threads.
137 Use nil to compare full subjects.  Setting this variable to a low
138 number will help gather threads that have been corrupted by
139 newsreaders chopping off subject lines, but it might also mean that
140 unrelated articles that have subject that happen to begin with the
141 same few characters will be incorrectly gathered.
142
143 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
144 comparing subjects."
145   :group 'gnus-thread
146   :type '(choice (const :tag "off" nil)
147                  (const fuzzy)
148                  (sexp :menu-tag "on" t)))
149
150 (defcustom gnus-simplify-subject-functions nil
151   "List of functions taking a string argument that simplify subjects.
152 The functions are applied recursively.
153
154 Useful functions to put in this list include:
155 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
156 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
157   :group 'gnus-thread
158   :type '(repeat function))
159
160 (defcustom gnus-simplify-ignored-prefixes nil
161   "*Remove matches for this regexp from subject lines when simplifying fuzzily."
162   :group 'gnus-thread
163   :type '(choice (const :tag "off" nil)
164                  regexp))
165
166 (defcustom gnus-build-sparse-threads nil
167   "*If non-nil, fill in the gaps in threads.
168 If `some', only fill in the gaps that are needed to tie loose threads
169 together.  If `more', fill in all leaf nodes that Gnus can find.  If
170 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
171   :group 'gnus-thread
172   :type '(choice (const :tag "off" nil)
173                  (const some)
174                  (const more)
175                  (sexp :menu-tag "all" t)))
176
177 (defcustom gnus-summary-thread-gathering-function
178   'gnus-gather-threads-by-subject
179   "*Function used for gathering loose threads.
180 There are two pre-defined functions: `gnus-gather-threads-by-subject',
181 which only takes Subjects into consideration; and
182 `gnus-gather-threads-by-references', which compared the References
183 headers of the articles to find matches."
184   :group 'gnus-thread
185   :type '(radio (function-item gnus-gather-threads-by-subject)
186                 (function-item gnus-gather-threads-by-references)
187                 (function :tag "other")))
188
189 (defcustom gnus-summary-same-subject ""
190   "*String indicating that the current article has the same subject as the previous.
191 This variable will only be used if the value of
192 `gnus-summary-make-false-root' is `empty'."
193   :group 'gnus-summary-format
194   :type 'string)
195
196 (defcustom gnus-summary-goto-unread t
197   "*If t, many commands will go to the next unread article.
198 This applies to marking commands as well as other commands that
199 \"naturally\" select the next article, like, for instance, `SPC' at
200 the end of an article.
201
202 If nil, the marking commands do NOT go to the next unread article
203 \(they go to the next article instead).  If `never', commands that
204 usually go to the next unread article, will go to the next article,
205 whether it is read or not."
206   :group 'gnus-summary-marks
207   :link '(custom-manual "(gnus)Setting Marks")
208   :type '(choice (const :tag "off" nil)
209                  (const never)
210                  (sexp :menu-tag "on" t)))
211
212 (defcustom gnus-summary-default-score 0
213   "*Default article score level.
214 All scores generated by the score files will be added to this score.
215 If this variable is nil, scoring will be disabled."
216   :group 'gnus-score-default
217   :type '(choice (const :tag "disable")
218                  integer))
219
220 (defcustom gnus-summary-default-high-score 0
221   "*Default threshold for a high scored article.
222 An article will be highlighted as high scored if its score is greater
223 than this score."
224   :version "22.1"
225   :group 'gnus-score-default
226   :type 'integer)
227
228 (defcustom gnus-summary-default-low-score 0
229   "*Default threshold for a low scored article.
230 An article will be highlighted as low scored if its score is smaller
231 than this score."
232   :version "22.1"
233   :group 'gnus-score-default
234   :type 'integer)
235
236 (defcustom gnus-summary-zcore-fuzz 0
237   "*Fuzziness factor for the zcore in the summary buffer.
238 Articles with scores closer than this to `gnus-summary-default-score'
239 will not be marked."
240   :group 'gnus-summary-format
241   :type 'integer)
242
243 (defcustom gnus-simplify-subject-fuzzy-regexp nil
244   "*Strings to be removed when doing fuzzy matches.
245 This can either be a regular expression or list of regular expressions
246 that will be removed from subject strings if fuzzy subject
247 simplification is selected."
248   :group 'gnus-thread
249   :type '(repeat regexp))
250
251 (defcustom gnus-show-threads t
252   "*If non-nil, display threads in summary mode."
253   :group 'gnus-thread
254   :type 'boolean)
255
256 (defcustom gnus-thread-hide-subtree nil
257   "*If non-nil, hide all threads initially.
258 This can be a predicate specifier which says which threads to hide.
259 If threads are hidden, you have to run the command
260 `gnus-summary-show-thread' by hand or select an article."
261   :group 'gnus-thread
262   :type '(radio (sexp :format "Non-nil\n"
263                       :match (lambda (widget value)
264                                (not (or (consp value) (functionp value))))
265                       :value t)
266                 (const nil)
267                 (sexp :tag "Predicate specifier")))
268
269 (defcustom gnus-thread-hide-killed t
270   "*If non-nil, hide killed threads automatically."
271   :group 'gnus-thread
272   :type 'boolean)
273
274 (defcustom gnus-thread-ignore-subject t
275   "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
276 If nil, articles that have different subjects from their parents will
277 start separate threads."
278   :group 'gnus-thread
279   :type 'boolean)
280
281 (defcustom gnus-thread-operation-ignore-subject t
282   "*If non-nil, subjects will be ignored when doing thread commands.
283 This affects commands like `gnus-summary-kill-thread' and
284 `gnus-summary-lower-thread'.
285
286 If this variable is nil, articles in the same thread with different
287 subjects will not be included in the operation in question.  If this
288 variable is `fuzzy', only articles that have subjects that are fuzzily
289 equal will be included."
290   :group 'gnus-thread
291   :type '(choice (const :tag "off" nil)
292                  (const fuzzy)
293                  (sexp :tag "on" t)))
294
295 (defcustom gnus-thread-indent-level 4
296   "*Number that says how much each sub-thread should be indented."
297   :group 'gnus-thread
298   :type 'integer)
299
300 (defcustom gnus-auto-extend-newsgroup t
301   "*If non-nil, extend newsgroup forward and backward when requested."
302   :group 'gnus-summary-choose
303   :type 'boolean)
304
305 (defcustom gnus-auto-select-first t
306   "*If non-nil, select the article under point.
307 Which article this is is controlled by the `gnus-auto-select-subject'
308 variable.
309
310 If you want to prevent automatic selection of articles in some
311 newsgroups, set the variable to nil in `gnus-select-group-hook'."
312   :group 'gnus-group-select
313   :type '(choice (const :tag "none" nil)
314                  (sexp :menu-tag "first" t)))
315
316 (defcustom gnus-auto-select-subject 'unread
317   "*Says what subject to place under point when entering a group.
318
319 This variable can either be the symbols `first' (place point on the
320 first subject), `unread' (place point on the subject line of the first
321 unread article), `best' (place point on the subject line of the
322 higest-scored article), `unseen' (place point on the subject line of
323 the first unseen article), `unseen-or-unread' (place point on the subject
324 line of the first unseen article or, if all article have been seen, on the
325 subject line of the first unread article), or a function to be called to
326 place point on some subject line."
327   :version "22.1"
328   :group 'gnus-group-select
329   :type '(choice (const best)
330                  (const unread)
331                  (const first)
332                  (const unseen)
333                  (const unseen-or-unread)))
334
335 (defcustom gnus-auto-select-next t
336   "*If non-nil, offer to go to the next group from the end of the previous.
337 If the value is t and the next newsgroup is empty, Gnus will exit
338 summary mode and go back to group mode.  If the value is neither nil
339 nor t, Gnus will select the following unread newsgroup.  In
340 particular, if the value is the symbol `quietly', the next unread
341 newsgroup will be selected without any confirmation, and if it is
342 `almost-quietly', the next group will be selected without any
343 confirmation if you are located on the last article in the group.
344 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
345 will go to the next group without confirmation."
346   :group 'gnus-summary-maneuvering
347   :type '(choice (const :tag "off" nil)
348                  (const quietly)
349                  (const almost-quietly)
350                  (const slightly-quietly)
351                  (sexp :menu-tag "on" t)))
352
353 (defcustom gnus-auto-select-same nil
354   "*If non-nil, select the next article with the same subject.
355 If there are no more articles with the same subject, go to
356 the first unread article."
357   :group 'gnus-summary-maneuvering
358   :type 'boolean)
359
360 (defcustom gnus-auto-goto-ignores 'unfetched
361   "*Says how to handle unfetched articles when maneuvering.
362
363 This variable can either be the symbols nil (maneuver to any
364 article), `undownloaded' (maneuvering while unplugged ignores articles
365 that have not been fetched), `always-undownloaded' (maneuvering always
366 ignores articles that have not been fetched), `unfetched' (maneuvering
367 ignores articles whose headers have not been fetched).
368
369 NOTE: The list of unfetched articles will always be nil when plugged
370 and, when unplugged, a subset of the undownloaded article list."
371   :version "22.1"
372   :group 'gnus-summary-maneuvering
373   :type '(choice (const :tag "None" nil)
374                  (const :tag "Undownloaded when unplugged" undownloaded)
375                  (const :tag "Undownloaded" always-undownloaded)
376                  (const :tag "Unfetched" unfetched)))
377
378 (defcustom gnus-summary-check-current nil
379   "*If non-nil, consider the current article when moving.
380 The \"unread\" movement commands will stay on the same line if the
381 current article is unread."
382   :group 'gnus-summary-maneuvering
383   :type 'boolean)
384
385 (defcustom gnus-auto-center-summary 2
386   "*If non-nil, always center the current summary buffer.
387 In particular, if `vertical' do only vertical recentering.  If non-nil
388 and non-`vertical', do both horizontal and vertical recentering."
389   :group 'gnus-summary-maneuvering
390   :type '(choice (const :tag "none" nil)
391                  (const vertical)
392                  (integer :tag "height")
393                  (sexp :menu-tag "both" t)))
394
395 (defvar gnus-auto-center-group t
396   "*If non-nil, always center the group buffer.")
397
398 (defcustom gnus-show-all-headers nil
399   "*If non-nil, don't hide any headers."
400   :group 'gnus-article-hiding
401   :group 'gnus-article-headers
402   :type 'boolean)
403
404 (defcustom gnus-summary-ignore-duplicates nil
405   "*If non-nil, ignore articles with identical Message-ID headers."
406   :group 'gnus-summary
407   :type 'boolean)
408
409 (defcustom gnus-single-article-buffer t
410   "*If non-nil, display all articles in the same buffer.
411 If nil, each group will get its own article buffer."
412   :group 'gnus-article-various
413   :type 'boolean)
414
415 (defcustom gnus-break-pages t
416   "*If non-nil, do page breaking on articles.
417 The page delimiter is specified by the `gnus-page-delimiter'
418 variable."
419   :group 'gnus-article-various
420   :type 'boolean)
421
422 (defcustom gnus-move-split-methods nil
423   "*Variable used to suggest where articles are to be moved to.
424 It uses the same syntax as the `gnus-split-methods' variable.
425 However, whereas `gnus-split-methods' specifies file names as targets,
426 this variable specifies group names."
427   :group 'gnus-summary-mail
428   :type '(repeat (choice (list :value (fun) function)
429                          (cons :value ("" "") regexp (repeat string))
430                          (sexp :value nil))))
431
432 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
433   "Function used to compute default prefix for article move/copy/etc prompts.
434 The function should take one argument, a group name, and return a
435 string with the suggested prefix."
436   :group 'gnus-summary-mail
437   :type 'function)
438
439 ;; FIXME: Although the custom type is `character' for the following variables,
440 ;; using multibyte characters (Latin-1, UTF-8) doesn't work.  -- rs
441
442 (defcustom gnus-unread-mark ?           ;Whitespace
443   "*Mark used for unread articles."
444   :group 'gnus-summary-marks
445   :type 'character)
446
447 (defcustom gnus-ticked-mark ?!
448   "*Mark used for ticked articles."
449   :group 'gnus-summary-marks
450   :type 'character)
451
452 (defcustom gnus-dormant-mark ??
453   "*Mark used for dormant articles."
454   :group 'gnus-summary-marks
455   :type 'character)
456
457 (defcustom gnus-del-mark ?r
458   "*Mark used for del'd articles."
459   :group 'gnus-summary-marks
460   :type 'character)
461
462 (defcustom gnus-read-mark ?R
463   "*Mark used for read articles."
464   :group 'gnus-summary-marks
465   :type 'character)
466
467 (defcustom gnus-expirable-mark ?E
468   "*Mark used for expirable articles."
469   :group 'gnus-summary-marks
470   :type 'character)
471
472 (defcustom gnus-killed-mark ?K
473   "*Mark used for killed articles."
474   :group 'gnus-summary-marks
475   :type 'character)
476
477 (defcustom gnus-spam-mark ?$
478   "*Mark used for spam articles."
479   :version "22.1"
480   :group 'gnus-summary-marks
481   :type 'character)
482
483 (defcustom gnus-souped-mark ?F
484   "*Mark used for souped articles."
485   :group 'gnus-summary-marks
486   :type 'character)
487
488 (defcustom gnus-kill-file-mark ?X
489   "*Mark used for articles killed by kill files."
490   :group 'gnus-summary-marks
491   :type 'character)
492
493 (defcustom gnus-low-score-mark ?Y
494   "*Mark used for articles with a low score."
495   :group 'gnus-summary-marks
496   :type 'character)
497
498 (defcustom gnus-catchup-mark ?C
499   "*Mark used for articles that are caught up."
500   :group 'gnus-summary-marks
501   :type 'character)
502
503 (defcustom gnus-replied-mark ?A
504   "*Mark used for articles that have been replied to."
505   :group 'gnus-summary-marks
506   :type 'character)
507
508 (defcustom gnus-forwarded-mark ?F
509   "*Mark used for articles that have been forwarded."
510   :version "22.1"
511   :group 'gnus-summary-marks
512   :type 'character)
513
514 (defcustom gnus-recent-mark ?N
515   "*Mark used for articles that are recent."
516   :version "22.1"
517   :group 'gnus-summary-marks
518   :type 'character)
519
520 (defcustom gnus-cached-mark ?*
521   "*Mark used for articles that are in the cache."
522   :group 'gnus-summary-marks
523   :type 'character)
524
525 (defcustom gnus-saved-mark ?S
526   "*Mark used for articles that have been saved."
527   :group 'gnus-summary-marks
528   :type 'character)
529
530 (defcustom gnus-unseen-mark ?.
531   "*Mark used for articles that haven't been seen."
532   :version "22.1"
533   :group 'gnus-summary-marks
534   :type 'character)
535
536 (defcustom gnus-no-mark ?               ;Whitespace
537   "*Mark used for articles that have no other secondary mark."
538   :version "22.1"
539   :group 'gnus-summary-marks
540   :type 'character)
541
542 (defcustom gnus-ancient-mark ?O
543   "*Mark used for ancient articles."
544   :group 'gnus-summary-marks
545   :type 'character)
546
547 (defcustom gnus-sparse-mark ?Q
548   "*Mark used for sparsely reffed articles."
549   :group 'gnus-summary-marks
550   :type 'character)
551
552 (defcustom gnus-canceled-mark ?G
553   "*Mark used for canceled articles."
554   :group 'gnus-summary-marks
555   :type 'character)
556
557 (defcustom gnus-duplicate-mark ?M
558   "*Mark used for duplicate articles."
559   :group 'gnus-summary-marks
560   :type 'character)
561
562 (defcustom gnus-undownloaded-mark ?-
563   "*Mark used for articles that weren't downloaded."
564   :version "22.1"
565   :group 'gnus-summary-marks
566   :type 'character)
567
568 (defcustom gnus-downloaded-mark ?+
569   "*Mark used for articles that were downloaded."
570   :group 'gnus-summary-marks
571   :type 'character)
572
573 (defcustom gnus-downloadable-mark ?%
574   "*Mark used for articles that are to be downloaded."
575   :group 'gnus-summary-marks
576   :type 'character)
577
578 (defcustom gnus-unsendable-mark ?=
579   "*Mark used for articles that won't be sent."
580   :group 'gnus-summary-marks
581   :type 'character)
582
583 (defcustom gnus-score-over-mark ?+
584   "*Score mark used for articles with high scores."
585   :group 'gnus-summary-marks
586   :type 'character)
587
588 (defcustom gnus-score-below-mark ?-
589   "*Score mark used for articles with low scores."
590   :group 'gnus-summary-marks
591   :type 'character)
592
593 (defcustom gnus-empty-thread-mark ?     ;Whitespace
594   "*There is no thread under the article."
595   :group 'gnus-summary-marks
596   :type 'character)
597
598 (defcustom gnus-not-empty-thread-mark ?=
599   "*There is a thread under the article."
600   :group 'gnus-summary-marks
601   :type 'character)
602
603 (defcustom gnus-view-pseudo-asynchronously nil
604   "*If non-nil, Gnus will view pseudo-articles asynchronously."
605   :group 'gnus-extract-view
606   :type 'boolean)
607
608 (defcustom gnus-auto-expirable-marks
609   (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
610         gnus-low-score-mark gnus-ancient-mark gnus-read-mark
611         gnus-souped-mark gnus-duplicate-mark)
612   "*The list of marks converted into expiration if a group is auto-expirable."
613   :version "21.1"
614   :group 'gnus-summary
615   :type '(repeat character))
616
617 (defcustom gnus-inhibit-user-auto-expire t
618   "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
619   :version "21.1"
620   :group 'gnus-summary
621   :type 'boolean)
622
623 (defcustom gnus-view-pseudos nil
624   "*If `automatic', pseudo-articles will be viewed automatically.
625 If `not-confirm', pseudos will be viewed automatically, and the user
626 will not be asked to confirm the command."
627   :group 'gnus-extract-view
628   :type '(choice (const :tag "off" nil)
629                  (const automatic)
630                  (const not-confirm)))
631
632 (defcustom gnus-view-pseudos-separately t
633   "*If non-nil, one pseudo-article will be created for each file to be viewed.
634 If nil, all files that use the same viewing command will be given as a
635 list of parameters to that command."
636   :group 'gnus-extract-view
637   :type 'boolean)
638
639 (defcustom gnus-insert-pseudo-articles t
640   "*If non-nil, insert pseudo-articles when decoding articles."
641   :group 'gnus-extract-view
642   :type 'boolean)
643
644 (defcustom gnus-summary-dummy-line-format
645   "   %(:                             :%) %S\n"
646   "*The format specification for the dummy roots in the summary buffer.
647 It works along the same lines as a normal formatting string,
648 with some simple extensions.
649
650 %S  The subject
651
652 General format specifiers can also be used.
653 See `(gnus)Formatting Variables'."
654   :link '(custom-manual "(gnus)Formatting Variables")
655   :group 'gnus-threading
656   :type 'string)
657
658 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
659   "*The format specification for the summary mode line.
660 It works along the same lines as a normal formatting string,
661 with some simple extensions:
662
663 %G  Group name
664 %p  Unprefixed group name
665 %A  Current article number
666 %z  Current article score
667 %V  Gnus version
668 %U  Number of unread articles in the group
669 %e  Number of unselected articles in the group
670 %Z  A string with unread/unselected article counts
671 %g  Shortish group name
672 %S  Subject of the current article
673 %u  User-defined spec
674 %s  Current score file name
675 %d  Number of dormant articles
676 %r  Number of articles that have been marked as read in this session
677 %E  Number of articles expunged by the score files"
678   :group 'gnus-summary-format
679   :type 'string)
680
681 (defcustom gnus-list-identifiers nil
682   "Regexp that matches list identifiers to be removed from subject.
683 This can also be a list of regexps."
684   :version "21.1"
685   :group 'gnus-summary-format
686   :group 'gnus-article-hiding
687   :type '(choice (const :tag "none" nil)
688                  (regexp :value ".*")
689                  (repeat :value (".*") regexp)))
690
691 (defcustom gnus-summary-mark-below 0
692   "*Mark all articles with a score below this variable as read.
693 This variable is local to each summary buffer and usually set by the
694 score file."
695   :group 'gnus-score-default
696   :type 'integer)
697
698 (defun gnus-widget-reversible-match (widget value)
699   "Ignoring WIDGET, convert VALUE to internal form.
700 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
701   ;; (debug value)
702   (or (symbolp value)
703       (and (listp value)
704            (eq (length value) 2)
705            (eq (nth 0 value) 'not)
706            (symbolp (nth 1 value)))))
707
708 (defun gnus-widget-reversible-to-internal (widget value)
709   "Ignoring WIDGET, convert VALUE to internal form.
710 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
711 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
712   ;; (debug value)
713   (if (atom value)
714       (list value nil)
715     (list (nth 1 value) t)))
716
717 (defun gnus-widget-reversible-to-external (widget value)
718   "Ignoring WIDGET, convert VALUE to external form.
719 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
720 \(FOO  nil) is converted to FOO and (FOO t) is converted to (not FOO)."
721   ;; (debug value)
722   (if (nth 1 value)
723       (list 'not (nth 0 value))
724     (nth 0 value)))
725
726 (define-widget 'gnus-widget-reversible 'group
727   "A `group' that convert values."
728   :match 'gnus-widget-reversible-match
729   :value-to-internal 'gnus-widget-reversible-to-internal
730   :value-to-external 'gnus-widget-reversible-to-external)
731
732 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
733   "*List of functions used for sorting articles in the summary buffer.
734
735 Each function takes two articles and returns non-nil if the first
736 article should be sorted before the other.  If you use more than one
737 function, the primary sort function should be the last.  You should
738 probably always include `gnus-article-sort-by-number' in the list of
739 sorting functions -- preferably first.  Also note that sorting by date
740 is often much slower than sorting by number, and the sorting order is
741 very similar.  (Sorting by date means sorting by the time the message
742 was sent, sorting by number means sorting by arrival time.)
743
744 Each item can also be a list `(not F)' where F is a function;
745 this reverses the sort order.
746
747 Ready-made functions include `gnus-article-sort-by-number',
748 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
749 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
750 and `gnus-article-sort-by-score'.
751
752 When threading is turned on, the variable `gnus-thread-sort-functions'
753 controls how articles are sorted."
754   :group 'gnus-summary-sort
755   :type '(repeat (gnus-widget-reversible
756                   (choice (function-item gnus-article-sort-by-number)
757                           (function-item gnus-article-sort-by-author)
758                           (function-item gnus-article-sort-by-subject)
759                           (function-item gnus-article-sort-by-date)
760                           (function-item gnus-article-sort-by-score)
761                           (function-item gnus-article-sort-by-random)
762                           (function :tag "other"))
763                   (boolean :tag "Reverse order"))))
764
765
766 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
767   "*List of functions used for sorting threads in the summary buffer.
768 By default, threads are sorted by article number.
769
770 Each function takes two threads and returns non-nil if the first
771 thread should be sorted before the other.  If you use more than one
772 function, the primary sort function should be the last.  You should
773 probably always include `gnus-thread-sort-by-number' in the list of
774 sorting functions -- preferably first.  Also note that sorting by date
775 is often much slower than sorting by number, and the sorting order is
776 very similar.  (Sorting by date means sorting by the time the message
777 was sent, sorting by number means sorting by arrival time.)
778
779 Each list item can also be a list `(not F)' where F is a
780 function; this specifies reversed sort order.
781
782 Ready-made functions include `gnus-thread-sort-by-number',
783 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
784 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
785 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
786 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
787 and `gnus-thread-sort-by-total-score' (see
788 `gnus-thread-score-function').
789
790 When threading is turned off, the variable
791 `gnus-article-sort-functions' controls how articles are sorted."
792   :group 'gnus-summary-sort
793   :type '(repeat
794           (gnus-widget-reversible
795            (choice (function-item gnus-thread-sort-by-number)
796                    (function-item gnus-thread-sort-by-author)
797                    (function-item gnus-thread-sort-by-recipient)
798                    (function-item gnus-thread-sort-by-subject)
799                    (function-item gnus-thread-sort-by-date)
800                    (function-item gnus-thread-sort-by-score)
801                    (function-item gnus-thread-sort-by-most-recent-number)
802                    (function-item gnus-thread-sort-by-most-recent-date)
803                    (function-item gnus-thread-sort-by-random)
804                    (function-item gnus-thread-sort-by-total-score)
805                    (function :tag "other"))
806            (boolean :tag "Reverse order"))))
807
808 (defcustom gnus-thread-score-function '+
809   "*Function used for calculating the total score of a thread.
810
811 The function is called with the scores of the article and each
812 subthread and should then return the score of the thread.
813
814 Some functions you can use are `+', `max', or `min'."
815   :group 'gnus-summary-sort
816   :type 'function)
817
818 (defcustom gnus-summary-expunge-below nil
819   "All articles that have a score less than this variable will be expunged.
820 This variable is local to the summary buffers."
821   :group 'gnus-score-default
822   :type '(choice (const :tag "off" nil)
823                  integer))
824
825 (defcustom gnus-thread-expunge-below nil
826   "All threads that have a total score less than this variable will be expunged.
827 See `gnus-thread-score-function' for en explanation of what a
828 \"thread score\" is.
829
830 This variable is local to the summary buffers."
831   :group 'gnus-threading
832   :group 'gnus-score-default
833   :type '(choice (const :tag "off" nil)
834                  integer))
835
836 (defcustom gnus-summary-mode-hook nil
837   "*A hook for Gnus summary mode.
838 This hook is run before any variables are set in the summary buffer."
839   :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
840   :group 'gnus-summary-various
841   :type 'hook)
842
843 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
844 (when (featurep 'xemacs)
845   (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
846   (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
847   (add-hook 'gnus-summary-mode-hook
848             'gnus-xmas-switch-horizontal-scrollbar-off))
849
850 (defcustom gnus-summary-menu-hook nil
851   "*Hook run after the creation of the summary mode menu."
852   :group 'gnus-summary-visual
853   :type 'hook)
854
855 (defcustom gnus-summary-exit-hook nil
856   "*A hook called on exit from the summary buffer.
857 It will be called with point in the group buffer."
858   :group 'gnus-summary-exit
859   :type 'hook)
860
861 (defcustom gnus-summary-prepare-hook nil
862   "*A hook called after the summary buffer has been generated.
863 If you want to modify the summary buffer, you can use this hook."
864   :group 'gnus-summary-various
865   :type 'hook)
866
867 (defcustom gnus-summary-prepared-hook nil
868   "*A hook called as the last thing after the summary buffer has been generated."
869   :group 'gnus-summary-various
870   :type 'hook)
871
872 (defcustom gnus-summary-generate-hook nil
873   "*A hook run just before generating the summary buffer.
874 This hook is commonly used to customize threading variables and the
875 like."
876   :group 'gnus-summary-various
877   :type 'hook)
878
879 (defcustom gnus-select-group-hook nil
880   "*A hook called when a newsgroup is selected.
881
882 If you'd like to simplify subjects like the
883 `gnus-summary-next-same-subject' command does, you can use the
884 following hook:
885
886  (add-hook gnus-select-group-hook
887            (lambda ()
888              (mapcar (lambda (header)
889                        (mail-header-set-subject
890                         header
891                         (gnus-simplify-subject
892                          (mail-header-subject header) 're-only)))
893                      gnus-newsgroup-headers)))"
894   :group 'gnus-group-select
895   :type 'hook)
896
897 (defcustom gnus-select-article-hook nil
898   "*A hook called when an article is selected."
899   :group 'gnus-summary-choose
900   :options '(gnus-agent-fetch-selected-article)
901   :type 'hook)
902
903 (defcustom gnus-visual-mark-article-hook
904   (list 'gnus-highlight-selected-summary)
905   "*Hook run after selecting an article in the summary buffer.
906 It is meant to be used for highlighting the article in some way.  It
907 is not run if `gnus-visual' is nil."
908   :group 'gnus-summary-visual
909   :type 'hook)
910
911 (defcustom gnus-parse-headers-hook nil
912   "*A hook called before parsing the headers."
913   :group 'gnus-various
914   :type 'hook)
915
916 (defcustom gnus-exit-group-hook nil
917   "*A hook called when exiting summary mode.
918 This hook is not called from the non-updating exit commands like `Q'."
919   :group 'gnus-various
920   :type 'hook)
921
922 (defcustom gnus-summary-update-hook
923   (list 'gnus-summary-highlight-line)
924   "*A hook called when a summary line is changed.
925 The hook will not be called if `gnus-visual' is nil.
926
927 The default function `gnus-summary-highlight-line' will
928 highlight the line according to the `gnus-summary-highlight'
929 variable."
930   :group 'gnus-summary-visual
931   :type 'hook)
932
933 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
934   "*A hook called when an article is selected for the first time.
935 The hook is intended to mark an article as read (or unread)
936 automatically when it is selected."
937   :group 'gnus-summary-choose
938   :type 'hook)
939
940 (defcustom gnus-group-no-more-groups-hook nil
941   "*A hook run when returning to group mode having no more (unread) groups."
942   :group 'gnus-group-select
943   :type 'hook)
944
945 (defcustom gnus-ps-print-hook nil
946   "*A hook run before ps-printing something from Gnus."
947   :group 'gnus-summary
948   :type 'hook)
949
950 (defcustom gnus-summary-article-move-hook nil
951   "*A hook called after an article is moved, copied, respooled, or crossposted."
952   :version "22.1"
953   :group 'gnus-summary
954   :type 'hook)
955
956 (defcustom gnus-summary-article-delete-hook nil
957   "*A hook called after an article is deleted."
958   :version "22.1"
959   :group 'gnus-summary
960   :type 'hook)
961
962 (defcustom gnus-summary-article-expire-hook nil
963   "*A hook called after an article is expired."
964   :version "22.1"
965   :group 'gnus-summary
966   :type 'hook)
967
968 (defcustom gnus-summary-display-arrow
969   (and (fboundp 'display-graphic-p)
970        (display-graphic-p))
971   "*If non-nil, display an arrow highlighting the current article."
972   :version "22.1"
973   :group 'gnus-summary
974   :type 'boolean)
975
976 (defcustom gnus-summary-selected-face 'gnus-summary-selected
977   "Face used for highlighting the current article in the summary buffer."
978   :group 'gnus-summary-visual
979   :type 'face)
980
981 (defvar gnus-tmp-downloaded nil)
982
983 (defcustom gnus-summary-highlight
984   '(((eq mark gnus-canceled-mark)
985      . gnus-summary-cancelled)
986     ((and uncached (> score default-high))
987      . gnus-summary-high-undownloaded)
988     ((and uncached (< score default-low))
989      . gnus-summary-low-undownloaded)
990     (uncached
991      . gnus-summary-normal-undownloaded)
992     ((and (> score default-high)
993           (or (eq mark gnus-dormant-mark)
994               (eq mark gnus-ticked-mark)))
995      . gnus-summary-high-ticked)
996     ((and (< score default-low)
997           (or (eq mark gnus-dormant-mark)
998               (eq mark gnus-ticked-mark)))
999      . gnus-summary-low-ticked)
1000     ((or (eq mark gnus-dormant-mark)
1001          (eq mark gnus-ticked-mark))
1002      . gnus-summary-normal-ticked)
1003     ((and (> score default-high) (eq mark gnus-ancient-mark))
1004      . gnus-summary-high-ancient)
1005     ((and (< score default-low) (eq mark gnus-ancient-mark))
1006      . gnus-summary-low-ancient)
1007     ((eq mark gnus-ancient-mark)
1008      . gnus-summary-normal-ancient)
1009     ((and (> score default-high) (eq mark gnus-unread-mark))
1010      . gnus-summary-high-unread)
1011     ((and (< score default-low) (eq mark gnus-unread-mark))
1012      . gnus-summary-low-unread)
1013     ((eq mark gnus-unread-mark)
1014      . gnus-summary-normal-unread)
1015     ((> score default-high)
1016      . gnus-summary-high-read)
1017     ((< score default-low)
1018      . gnus-summary-low-read)
1019     (t
1020      . gnus-summary-normal-read))
1021   "*Controls the highlighting of summary buffer lines.
1022
1023 A list of (FORM . FACE) pairs.  When deciding how a a particular
1024 summary line should be displayed, each form is evaluated.  The content
1025 of the face field after the first true form is used.  You can change
1026 how those summary lines are displayed, by editing the face field.
1027
1028 You can use the following variables in the FORM field.
1029
1030 score:        The article's score
1031 default:      The default article score.
1032 default-high: The default score for high scored articles.
1033 default-low:  The default score for low scored articles.
1034 below:        The score below which articles are automatically marked as read.
1035 mark:         The article's mark.
1036 uncached:     Non-nil if the article is uncached."
1037   :group 'gnus-summary-visual
1038   :type '(repeat (cons (sexp :tag "Form" nil)
1039                        face)))
1040
1041 (defcustom gnus-alter-header-function nil
1042   "Function called to allow alteration of article header structures.
1043 The function is called with one parameter, the article header vector,
1044 which it may alter in any way."
1045   :type '(choice (const :tag "None" nil)
1046                  function)
1047   :group 'gnus-summary)
1048
1049 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1050   "Variable that says which function should be used to decode a string with encoded words.")
1051
1052 (defcustom gnus-extra-headers '(To Newsgroups)
1053   "*Extra headers to parse."
1054   :version "21.1"
1055   :group 'gnus-summary
1056   :type '(repeat symbol))
1057
1058 (defcustom gnus-ignored-from-addresses
1059   (and user-mail-address (regexp-quote user-mail-address))
1060   "*Regexp of From headers that may be suppressed in favor of To headers."
1061   :version "21.1"
1062   :group 'gnus-summary
1063   :type 'regexp)
1064
1065 (defcustom gnus-summary-to-prefix "-> "
1066   "*String prefixed to the To field in the summary line when
1067 using `gnus-ignored-from-addresses'."
1068   :version "22.1"
1069   :group 'gnus-summary
1070   :type 'string)
1071
1072 (defcustom gnus-summary-newsgroup-prefix "=> "
1073   "*String prefixed to the Newsgroup field in the summary
1074 line when using `gnus-ignored-from-addresses'."
1075   :version "22.1"
1076   :group 'gnus-summary
1077   :type 'string)
1078
1079 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1080   "List of charsets that should be ignored.
1081 When these charsets are used in the \"charset\" parameter, the
1082 default charset will be used instead."
1083   :version "21.1"
1084   :type '(repeat symbol)
1085   :group 'gnus-charset)
1086
1087 (gnus-define-group-parameter
1088  ignored-charsets
1089  :type list
1090  :function-document
1091  "Return the ignored charsets of GROUP."
1092  :variable gnus-group-ignored-charsets-alist
1093  :variable-default
1094  '(("alt\\.chinese\\.text" iso-8859-1))
1095  :variable-document
1096  "Alist of regexps (to match group names) and charsets that should be ignored.
1097 When these charsets are used in the \"charset\" parameter, the
1098 default charset will be used instead."
1099  :variable-group gnus-charset
1100  :variable-type '(repeat (cons (regexp :tag "Group")
1101                                (repeat symbol)))
1102  :parameter-type '(choice :tag "Ignored charsets"
1103                           :value nil
1104                           (repeat (symbol)))
1105  :parameter-document       "\
1106 List of charsets that should be ignored.
1107
1108 When these charsets are used in the \"charset\" parameter, the
1109 default charset will be used instead.")
1110
1111 (defcustom gnus-group-highlight-words-alist nil
1112   "Alist of group regexps and highlight regexps.
1113 This variable uses the same syntax as `gnus-emphasis-alist'."
1114   :version "21.1"
1115   :type '(repeat (cons (regexp :tag "Group")
1116                        (repeat (list (regexp :tag "Highlight regexp")
1117                                      (number :tag "Group for entire word" 0)
1118                                      (number :tag "Group for displayed part" 0)
1119                                      (symbol :tag "Face"
1120                                              gnus-emphasis-highlight-words)))))
1121   :group 'gnus-summary-visual)
1122
1123 (defcustom gnus-summary-show-article-charset-alist
1124   nil
1125   "Alist of number and charset.
1126 The article will be shown with the charset corresponding to the
1127 numbered argument.
1128 For example: ((1 . cn-gb-2312) (2 . big5))."
1129   :version "21.1"
1130   :type '(repeat (cons (number :tag "Argument" 1)
1131                        (symbol :tag "Charset")))
1132   :group 'gnus-charset)
1133
1134 (defcustom gnus-preserve-marks t
1135   "Whether marks are preserved when moving, copying and respooling messages."
1136   :version "21.1"
1137   :type 'boolean
1138   :group 'gnus-summary-marks)
1139
1140 (defcustom gnus-alter-articles-to-read-function nil
1141   "Function to be called to alter the list of articles to be selected."
1142   :type '(choice (const nil) function)
1143   :group 'gnus-summary)
1144
1145 (defcustom gnus-orphan-score nil
1146   "*All orphans get this score added.  Set in the score file."
1147   :group 'gnus-score-default
1148   :type '(choice (const nil)
1149                  integer))
1150
1151 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1152   "*A regexp to match MIME parts when saving multiple parts of a
1153 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1154 This regexp will be used by default when prompting the user for which
1155 type of files to save."
1156   :group 'gnus-summary
1157   :type 'regexp)
1158
1159 (defcustom gnus-read-all-available-headers nil
1160   "Whether Gnus should parse all headers made available to it.
1161 This is mostly relevant for slow back ends where the user may
1162 wish to widen the summary buffer to include all headers
1163 that were fetched.  Say, for nnultimate groups."
1164   :version "22.1"
1165   :group 'gnus-summary
1166   :type '(choice boolean regexp))
1167
1168 (defcustom gnus-summary-muttprint-program "muttprint"
1169   "Command (and optional arguments) used to run Muttprint."
1170   :version "22.1"
1171   :group 'gnus-summary
1172   :type 'string)
1173
1174 (defcustom gnus-article-loose-mime t
1175   "If non-nil, don't require MIME-Version header.
1176 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1177 supply the MIME-Version header or deliberately strip it from the mail.
1178 If non-nil (the default), Gnus will treat some articles as MIME
1179 even if the MIME-Version header is missing."
1180   :version "22.1"
1181   :type 'boolean
1182   :group 'gnus-article-mime)
1183
1184 (defcustom gnus-article-emulate-mime t
1185   "If non-nil, use MIME emulation for uuencode and the like.
1186 This means that Gnus will search message bodies for text that look
1187 like uuencoded bits, yEncoded bits, and so on, and present that using
1188 the normal Gnus MIME machinery."
1189   :version "22.1"
1190   :type 'boolean
1191   :group 'gnus-article-mime)
1192
1193 ;;; Internal variables
1194
1195 (defvar gnus-summary-display-cache nil)
1196 (defvar gnus-article-mime-handles nil)
1197 (defvar gnus-article-decoded-p nil)
1198 (defvar gnus-article-charset nil)
1199 (defvar gnus-article-ignored-charsets nil)
1200 (defvar gnus-scores-exclude-files nil)
1201 (defvar gnus-page-broken nil)
1202
1203 (defvar gnus-original-article nil)
1204 (defvar gnus-article-internal-prepare-hook nil)
1205 (defvar gnus-newsgroup-process-stack nil)
1206
1207 (defvar gnus-thread-indent-array nil)
1208 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1209 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1210   "Function called to sort the articles within a thread after it has been gathered together.")
1211
1212 (defvar gnus-summary-save-parts-type-history nil)
1213 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1214
1215 ;; Avoid highlighting in kill files.
1216 (defvar gnus-summary-inhibit-highlight nil)
1217 (defvar gnus-newsgroup-selected-overlay nil)
1218 (defvar gnus-inhibit-limiting nil)
1219 (defvar gnus-newsgroup-adaptive-score-file nil)
1220 (defvar gnus-current-score-file nil)
1221 (defvar gnus-current-move-group nil)
1222 (defvar gnus-current-copy-group nil)
1223 (defvar gnus-current-crosspost-group nil)
1224 (defvar gnus-newsgroup-display nil)
1225
1226 (defvar gnus-newsgroup-dependencies nil)
1227 (defvar gnus-newsgroup-adaptive nil)
1228 (defvar gnus-summary-display-article-function nil)
1229 (defvar gnus-summary-highlight-line-function nil
1230   "Function called after highlighting a summary line.")
1231
1232 (defvar gnus-summary-line-format-alist
1233   `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1234     (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1235     (?s gnus-tmp-subject-or-nil ?s)
1236     (?n gnus-tmp-name ?s)
1237     (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1238         ?s)
1239     (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1240             gnus-tmp-from) ?s)
1241     (?F gnus-tmp-from ?s)
1242     (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1243     (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1244     (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1245     (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1246     (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1247     (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1248     (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1249     (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1250     (?L gnus-tmp-lines ?s)
1251     (?O gnus-tmp-downloaded ?c)
1252     (?I gnus-tmp-indentation ?s)
1253     (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1254     (?R gnus-tmp-replied ?c)
1255     (?\[ gnus-tmp-opening-bracket ?c)
1256     (?\] gnus-tmp-closing-bracket ?c)
1257     (?\> (make-string gnus-tmp-level ? ) ?s)
1258     (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1259     (?i gnus-tmp-score ?d)
1260     (?z gnus-tmp-score-char ?c)
1261     (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1262     (?U gnus-tmp-unread ?c)
1263     (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1264         ?s)
1265     (?t (gnus-summary-number-of-articles-in-thread
1266          (and (boundp 'thread) (car thread)) gnus-tmp-level)
1267         ?d)
1268     (?e (gnus-summary-number-of-articles-in-thread
1269          (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1270         ?c)
1271     (?u gnus-tmp-user-defined ?s)
1272     (?P (gnus-pick-line-number) ?d)
1273     (?B gnus-tmp-thread-tree-header-string ?s)
1274     (user-date (gnus-user-date
1275                 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1276   "An alist of format specifications that can appear in summary lines.
1277 These are paired with what variables they correspond with, along with
1278 the type of the variable (string, integer, character, etc).")
1279
1280 (defvar gnus-summary-dummy-line-format-alist
1281   `((?S gnus-tmp-subject ?s)
1282     (?N gnus-tmp-number ?d)
1283     (?u gnus-tmp-user-defined ?s)))
1284
1285 (defvar gnus-summary-mode-line-format-alist
1286   `((?G gnus-tmp-group-name ?s)
1287     (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1288     (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1289     (?A gnus-tmp-article-number ?d)
1290     (?Z gnus-tmp-unread-and-unselected ?s)
1291     (?V gnus-version ?s)
1292     (?U gnus-tmp-unread-and-unticked ?d)
1293     (?S gnus-tmp-subject ?s)
1294     (?e gnus-tmp-unselected ?d)
1295     (?u gnus-tmp-user-defined ?s)
1296     (?d (length gnus-newsgroup-dormant) ?d)
1297     (?t (length gnus-newsgroup-marked) ?d)
1298     (?h (length gnus-newsgroup-spam-marked) ?d)
1299     (?r (length gnus-newsgroup-reads) ?d)
1300     (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1301     (?E gnus-newsgroup-expunged-tally ?d)
1302     (?s (gnus-current-score-file-nondirectory) ?s)))
1303
1304 (defvar gnus-last-search-regexp nil
1305   "Default regexp for article search command.")
1306
1307 (defvar gnus-last-shell-command nil
1308   "Default shell command on article.")
1309
1310 (defvar gnus-newsgroup-agentized nil
1311   "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1312 (defvar gnus-newsgroup-begin nil)
1313 (defvar gnus-newsgroup-end nil)
1314 (defvar gnus-newsgroup-last-rmail nil)
1315 (defvar gnus-newsgroup-last-mail nil)
1316 (defvar gnus-newsgroup-last-folder nil)
1317 (defvar gnus-newsgroup-last-file nil)
1318 (defvar gnus-newsgroup-auto-expire nil)
1319 (defvar gnus-newsgroup-active nil)
1320
1321 (defvar gnus-newsgroup-data nil)
1322 (defvar gnus-newsgroup-data-reverse nil)
1323 (defvar gnus-newsgroup-limit nil)
1324 (defvar gnus-newsgroup-limits nil)
1325 (defvar gnus-summary-use-undownloaded-faces nil)
1326
1327 (defvar gnus-newsgroup-unreads nil
1328   "Sorted list of unread articles in the current newsgroup.")
1329
1330 (defvar gnus-newsgroup-unselected nil
1331   "Sorted list of unselected unread articles in the current newsgroup.")
1332
1333 (defvar gnus-newsgroup-reads nil
1334   "Alist of read articles and article marks in the current newsgroup.")
1335
1336 (defvar gnus-newsgroup-expunged-tally nil)
1337
1338 (defvar gnus-newsgroup-marked nil
1339   "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1340
1341 (defvar gnus-newsgroup-spam-marked nil
1342   "List of ranges of articles that have been marked as spam.")
1343
1344 (defvar gnus-newsgroup-killed nil
1345   "List of ranges of articles that have been through the scoring process.")
1346
1347 (defvar gnus-newsgroup-cached nil
1348   "Sorted list of articles that come from the article cache.")
1349
1350 (defvar gnus-newsgroup-saved nil
1351   "List of articles that have been saved.")
1352
1353 (defvar gnus-newsgroup-kill-headers nil)
1354
1355 (defvar gnus-newsgroup-replied nil
1356   "List of articles that have been replied to in the current newsgroup.")
1357
1358 (defvar gnus-newsgroup-forwarded nil
1359   "List of articles that have been forwarded in the current newsgroup.")
1360
1361 (defvar gnus-newsgroup-recent nil
1362   "List of articles that have are recent in the current newsgroup.")
1363
1364 (defvar gnus-newsgroup-expirable nil
1365   "Sorted list of articles in the current newsgroup that can be expired.")
1366
1367 (defvar gnus-newsgroup-processable nil
1368   "List of articles in the current newsgroup that can be processed.")
1369
1370 (defvar gnus-newsgroup-downloadable nil
1371   "Sorted list of articles in the current newsgroup that can be processed.")
1372
1373 (defvar gnus-newsgroup-unfetched nil
1374   "Sorted list of articles in the current newsgroup whose headers have
1375 not been fetched into the agent.
1376
1377 This list will always be a subset of gnus-newsgroup-undownloaded.")
1378
1379 (defvar gnus-newsgroup-undownloaded nil
1380   "List of articles in the current newsgroup that haven't been downloaded.")
1381
1382 (defvar gnus-newsgroup-unsendable nil
1383   "List of articles in the current newsgroup that won't be sent.")
1384
1385 (defvar gnus-newsgroup-bookmarks nil
1386   "List of articles in the current newsgroup that have bookmarks.")
1387
1388 (defvar gnus-newsgroup-dormant nil
1389   "Sorted list of dormant articles in the current newsgroup.")
1390
1391 (defvar gnus-newsgroup-unseen nil
1392   "List of unseen articles in the current newsgroup.")
1393
1394 (defvar gnus-newsgroup-seen nil
1395   "Range of seen articles in the current newsgroup.")
1396
1397 (defvar gnus-newsgroup-articles nil
1398   "List of articles in the current newsgroup.")
1399
1400 (defvar gnus-newsgroup-scored nil
1401   "List of scored articles in the current newsgroup.")
1402
1403 (defvar gnus-newsgroup-headers nil
1404   "List of article headers in the current newsgroup.")
1405
1406 (defvar gnus-newsgroup-threads nil)
1407
1408 (defvar gnus-newsgroup-prepared nil
1409   "Whether the current group has been prepared properly.")
1410
1411 (defvar gnus-newsgroup-ancient nil
1412   "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1413
1414 (defvar gnus-newsgroup-sparse nil)
1415
1416 (defvar gnus-current-article nil)
1417 (defvar gnus-article-current nil)
1418 (defvar gnus-current-headers nil)
1419 (defvar gnus-have-all-headers nil)
1420 (defvar gnus-last-article nil)
1421 (defvar gnus-newsgroup-history nil)
1422 (defvar gnus-newsgroup-charset nil)
1423 (defvar gnus-newsgroup-ephemeral-charset nil)
1424 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1425
1426 (defvar gnus-article-before-search nil)
1427
1428 (defvar gnus-summary-local-variables
1429   '(gnus-newsgroup-name
1430     gnus-newsgroup-begin gnus-newsgroup-end
1431     gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1432     gnus-newsgroup-last-folder gnus-newsgroup-last-file
1433     gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1434     gnus-newsgroup-unselected gnus-newsgroup-marked
1435     gnus-newsgroup-spam-marked
1436     gnus-newsgroup-reads gnus-newsgroup-saved
1437     gnus-newsgroup-replied gnus-newsgroup-forwarded
1438     gnus-newsgroup-recent
1439     gnus-newsgroup-expirable
1440     gnus-newsgroup-processable gnus-newsgroup-killed
1441     gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1442     gnus-newsgroup-unfetched
1443     gnus-newsgroup-unsendable gnus-newsgroup-unseen
1444     gnus-newsgroup-seen gnus-newsgroup-articles
1445     gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1446     gnus-newsgroup-headers gnus-newsgroup-threads
1447     gnus-newsgroup-prepared gnus-summary-highlight-line-function
1448     gnus-current-article gnus-current-headers gnus-have-all-headers
1449     gnus-last-article gnus-article-internal-prepare-hook
1450     gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1451     gnus-newsgroup-scored gnus-newsgroup-kill-headers
1452     gnus-thread-expunge-below
1453     gnus-score-alist gnus-current-score-file
1454     (gnus-summary-expunge-below . global)
1455     (gnus-summary-mark-below . global)
1456     (gnus-orphan-score . global)
1457     gnus-newsgroup-active gnus-scores-exclude-files
1458     gnus-newsgroup-history gnus-newsgroup-ancient
1459     gnus-newsgroup-sparse gnus-newsgroup-process-stack
1460     (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1461     gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1462     (gnus-newsgroup-expunged-tally . 0)
1463     gnus-cache-removable-articles gnus-newsgroup-cached
1464     gnus-newsgroup-data gnus-newsgroup-data-reverse
1465     gnus-newsgroup-limit gnus-newsgroup-limits
1466     gnus-newsgroup-charset gnus-newsgroup-display
1467     gnus-summary-use-undownloaded-faces)
1468   "Variables that are buffer-local to the summary buffers.")
1469
1470 (defvar gnus-newsgroup-variables nil
1471   "A list of variables that have separate values in different newsgroups.
1472 A list of newsgroup (summary buffer) local variables, or cons of
1473 variables and their default expressions to be evalled (when the default
1474 values are not nil), that should be made global while the summary buffer
1475 is active.
1476
1477 Note: The default expressions will be evaluated (using function `eval')
1478 before assignment to the local variable rather than just assigned to it.
1479 If the default expression is the symbol `global', that symbol will not
1480 be evaluated but the global value of the local variable will be used
1481 instead.
1482
1483 These variables can be used to set variables in the group parameters
1484 while still allowing them to affect operations done in other buffers.
1485 For example:
1486
1487 \(setq gnus-newsgroup-variables
1488      '(message-use-followup-to
1489        (gnus-visible-headers .
1490          \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1491 ")
1492
1493 ;; Byte-compiler warning.
1494 (eval-when-compile
1495   ;; Bind features so that require will believe that gnus-sum has
1496   ;; already been loaded (avoids infinite recursion)
1497   (let ((features (cons 'gnus-sum features)))
1498     ;; Several of the declarations in gnus-sum are needed to load the
1499     ;; following files. Right now, these definitions have been
1500     ;; compiled but not defined (evaluated).  We could either do a
1501     ;; eval-and-compile about all of the declarations or evaluate the
1502     ;; source file.
1503     (if (boundp 'gnus-newsgroup-variables)
1504         nil
1505       (load "gnus-sum.el" t t t))
1506     (require 'gnus)
1507     (require 'gnus-art)))
1508
1509 ;; MIME stuff.
1510
1511 (defvar gnus-decode-encoded-word-methods
1512   '(mail-decode-encoded-word-string)
1513   "List of methods used to decode encoded words.
1514
1515 This variable is a list of FUNCTION or (REGEXP . FUNCTION).  If item
1516 is FUNCTION, FUNCTION will be apply to all newsgroups.  If item is a
1517 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1518 whose names match REGEXP.
1519
1520 For example:
1521 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1522  mail-decode-encoded-word-string
1523  (\"chinese\" . rfc1843-decode-string))")
1524
1525 (defvar gnus-decode-encoded-word-methods-cache nil)
1526
1527 (defun gnus-multi-decode-encoded-word-string (string)
1528   "Apply the functions from `gnus-encoded-word-methods' that match."
1529   (unless (and gnus-decode-encoded-word-methods-cache
1530                (eq gnus-newsgroup-name
1531                    (car gnus-decode-encoded-word-methods-cache)))
1532     (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1533     (mapcar (lambda (x)
1534               (if (symbolp x)
1535                   (nconc gnus-decode-encoded-word-methods-cache (list x))
1536                 (if (and gnus-newsgroup-name
1537                          (string-match (car x) gnus-newsgroup-name))
1538                     (nconc gnus-decode-encoded-word-methods-cache
1539                            (list (cdr x))))))
1540             gnus-decode-encoded-word-methods))
1541   (let ((xlist gnus-decode-encoded-word-methods-cache))
1542     (pop xlist)
1543     (while xlist
1544       (setq string (funcall (pop xlist) string))))
1545   string)
1546
1547 ;; Subject simplification.
1548
1549 (defun gnus-simplify-whitespace (str)
1550   "Remove excessive whitespace from STR."
1551   ;; Multiple spaces.
1552   (while (string-match "[ \t][ \t]+" str)
1553     (setq str (concat (substring str 0 (match-beginning 0))
1554                         " "
1555                         (substring str (match-end 0)))))
1556   ;; Leading spaces.
1557   (when (string-match "^[ \t]+" str)
1558     (setq str (substring str (match-end 0))))
1559   ;; Trailing spaces.
1560   (when (string-match "[ \t]+$" str)
1561     (setq str (substring str 0 (match-beginning 0))))
1562   str)
1563
1564 (defun gnus-simplify-all-whitespace (str)
1565   "Remove all whitespace from STR."
1566   (while (string-match "[ \t\n]+" str)
1567     (setq str (replace-match "" nil nil str)))
1568   str)
1569
1570 (defsubst gnus-simplify-subject-re (subject)
1571   "Remove \"Re:\" from subject lines."
1572   (if (string-match message-subject-re-regexp subject)
1573       (substring subject (match-end 0))
1574     subject))
1575
1576 (defun gnus-simplify-subject (subject &optional re-only)
1577   "Remove `Re:' and words in parentheses.
1578 If RE-ONLY is non-nil, strip leading `Re:'s only."
1579   (let ((case-fold-search t))           ;Ignore case.
1580     ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1581     (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1582       (setq subject (substring subject (match-end 0))))
1583     ;; Remove uninteresting prefixes.
1584     (when (and (not re-only)
1585                gnus-simplify-ignored-prefixes
1586                (string-match gnus-simplify-ignored-prefixes subject))
1587       (setq subject (substring subject (match-end 0))))
1588     ;; Remove words in parentheses from end.
1589     (unless re-only
1590       (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1591         (setq subject (substring subject 0 (match-beginning 0)))))
1592     ;; Return subject string.
1593     subject))
1594
1595 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1596 ;; all whitespace.
1597 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1598   (goto-char (point-min))
1599   (while (re-search-forward regexp nil t)
1600     (replace-match (or newtext ""))))
1601
1602 (defun gnus-simplify-buffer-fuzzy ()
1603   "Simplify string in the buffer fuzzily.
1604 The string in the accessible portion of the current buffer is simplified.
1605 It is assumed to be a single-line subject.
1606 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1607 matter is removed.  Additional things can be deleted by setting
1608 `gnus-simplify-subject-fuzzy-regexp'."
1609   (let ((case-fold-search t)
1610         (modified-tick))
1611     (gnus-simplify-buffer-fuzzy-step "\t" " ")
1612
1613     (while (not (eq modified-tick (buffer-modified-tick)))
1614       (setq modified-tick (buffer-modified-tick))
1615       (cond
1616        ((listp gnus-simplify-subject-fuzzy-regexp)
1617         (mapcar 'gnus-simplify-buffer-fuzzy-step
1618                 gnus-simplify-subject-fuzzy-regexp))
1619        (gnus-simplify-subject-fuzzy-regexp
1620         (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1621       (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1622       (gnus-simplify-buffer-fuzzy-step
1623        "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1624       (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1625
1626     (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1627     (gnus-simplify-buffer-fuzzy-step "  +" " ")
1628     (gnus-simplify-buffer-fuzzy-step " $")
1629     (gnus-simplify-buffer-fuzzy-step "^ +")))
1630
1631 (defun gnus-simplify-subject-fuzzy (subject)
1632   "Simplify a subject string fuzzily.
1633 See `gnus-simplify-buffer-fuzzy' for details."
1634   (save-excursion
1635     (gnus-set-work-buffer)
1636     (let ((case-fold-search t))
1637       ;; Remove uninteresting prefixes.
1638       (when (and gnus-simplify-ignored-prefixes
1639                  (string-match gnus-simplify-ignored-prefixes subject))
1640         (setq subject (substring subject (match-end 0))))
1641       (insert subject)
1642       (inline (gnus-simplify-buffer-fuzzy))
1643       (buffer-string))))
1644
1645 (defsubst gnus-simplify-subject-fully (subject)
1646   "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1647   (cond
1648    (gnus-simplify-subject-functions
1649     (gnus-map-function gnus-simplify-subject-functions subject))
1650    ((null gnus-summary-gather-subject-limit)
1651     (gnus-simplify-subject-re subject))
1652    ((eq gnus-summary-gather-subject-limit 'fuzzy)
1653     (gnus-simplify-subject-fuzzy subject))
1654    ((numberp gnus-summary-gather-subject-limit)
1655     (gnus-limit-string (gnus-simplify-subject-re subject)
1656                        gnus-summary-gather-subject-limit))
1657    (t
1658     subject)))
1659
1660 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1661   "Check whether two subjects are equal.
1662 If optional argument SIMPLE-FIRST is t, first argument is already
1663 simplified."
1664   (cond
1665    ((null simple-first)
1666     (equal (gnus-simplify-subject-fully s1)
1667            (gnus-simplify-subject-fully s2)))
1668    (t
1669     (equal s1
1670            (gnus-simplify-subject-fully s2)))))
1671
1672 (defun gnus-summary-bubble-group ()
1673   "Increase the score of the current group.
1674 This is a handy function to add to `gnus-summary-exit-hook' to
1675 increase the score of each group you read."
1676   (gnus-group-add-score gnus-newsgroup-name))
1677
1678 \f
1679 ;;;
1680 ;;; Gnus summary mode
1681 ;;;
1682
1683 (put 'gnus-summary-mode 'mode-class 'special)
1684
1685 (defvar gnus-article-commands-menu)
1686
1687 ;; Non-orthogonal keys
1688
1689 (gnus-define-keys gnus-summary-mode-map
1690   " " gnus-summary-next-page
1691   "\177" gnus-summary-prev-page
1692   [delete] gnus-summary-prev-page
1693   [backspace] gnus-summary-prev-page
1694   "\r" gnus-summary-scroll-up
1695   "\M-\r" gnus-summary-scroll-down
1696   "n" gnus-summary-next-unread-article
1697   "p" gnus-summary-prev-unread-article
1698   "N" gnus-summary-next-article
1699   "P" gnus-summary-prev-article
1700   "\M-\C-n" gnus-summary-next-same-subject
1701   "\M-\C-p" gnus-summary-prev-same-subject
1702   "\M-n" gnus-summary-next-unread-subject
1703   "\M-p" gnus-summary-prev-unread-subject
1704   "." gnus-summary-first-unread-article
1705   "," gnus-summary-best-unread-article
1706   "\M-s" gnus-summary-search-article-forward
1707   "\M-r" gnus-summary-search-article-backward
1708   "<" gnus-summary-beginning-of-article
1709   ">" gnus-summary-end-of-article
1710   "j" gnus-summary-goto-article
1711   "^" gnus-summary-refer-parent-article
1712   "\M-^" gnus-summary-refer-article
1713   "u" gnus-summary-tick-article-forward
1714   "!" gnus-summary-tick-article-forward
1715   "U" gnus-summary-tick-article-backward
1716   "d" gnus-summary-mark-as-read-forward
1717   "D" gnus-summary-mark-as-read-backward
1718   "E" gnus-summary-mark-as-expirable
1719   "\M-u" gnus-summary-clear-mark-forward
1720   "\M-U" gnus-summary-clear-mark-backward
1721   "k" gnus-summary-kill-same-subject-and-select
1722   "\C-k" gnus-summary-kill-same-subject
1723   "\M-\C-k" gnus-summary-kill-thread
1724   "\M-\C-l" gnus-summary-lower-thread
1725   "e" gnus-summary-edit-article
1726   "#" gnus-summary-mark-as-processable
1727   "\M-#" gnus-summary-unmark-as-processable
1728   "\M-\C-t" gnus-summary-toggle-threads
1729   "\M-\C-s" gnus-summary-show-thread
1730   "\M-\C-h" gnus-summary-hide-thread
1731   "\M-\C-f" gnus-summary-next-thread
1732   "\M-\C-b" gnus-summary-prev-thread
1733   [(meta down)] gnus-summary-next-thread
1734   [(meta up)] gnus-summary-prev-thread
1735   "\M-\C-u" gnus-summary-up-thread
1736   "\M-\C-d" gnus-summary-down-thread
1737   "&" gnus-summary-execute-command
1738   "c" gnus-summary-catchup-and-exit
1739   "\C-w" gnus-summary-mark-region-as-read
1740   "\C-t" gnus-summary-toggle-truncation
1741   "?" gnus-summary-mark-as-dormant
1742   "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1743   "\C-c\C-s\C-n" gnus-summary-sort-by-number
1744   "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1745   "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1746   "\C-c\C-s\C-a" gnus-summary-sort-by-author
1747   "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1748   "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1749   "\C-c\C-s\C-d" gnus-summary-sort-by-date
1750   "\C-c\C-s\C-i" gnus-summary-sort-by-score
1751   "\C-c\C-s\C-o" gnus-summary-sort-by-original
1752   "\C-c\C-s\C-r" gnus-summary-sort-by-random
1753   "=" gnus-summary-expand-window
1754   "\C-x\C-s" gnus-summary-reselect-current-group
1755   "\M-g" gnus-summary-rescan-group
1756   "w" gnus-summary-stop-page-breaking
1757   "\C-c\C-r" gnus-summary-caesar-message
1758   "f" gnus-summary-followup
1759   "F" gnus-summary-followup-with-original
1760   "C" gnus-summary-cancel-article
1761   "r" gnus-summary-reply
1762   "R" gnus-summary-reply-with-original
1763   "\C-c\C-f" gnus-summary-mail-forward
1764   "o" gnus-summary-save-article
1765   "\C-o" gnus-summary-save-article-mail
1766   "|" gnus-summary-pipe-output
1767   "\M-k" gnus-summary-edit-local-kill
1768   "\M-K" gnus-summary-edit-global-kill
1769   ;; "V" gnus-version
1770   "\C-c\C-d" gnus-summary-describe-group
1771   "q" gnus-summary-exit
1772   "Q" gnus-summary-exit-no-update
1773   "\C-c\C-i" gnus-info-find-node
1774   gnus-mouse-2 gnus-mouse-pick-article
1775   [follow-link] mouse-face
1776   "m" gnus-summary-mail-other-window
1777   "a" gnus-summary-post-news
1778   "i" gnus-summary-news-other-window
1779   "x" gnus-summary-limit-to-unread
1780   "s" gnus-summary-isearch-article
1781   "t" gnus-summary-toggle-header
1782   "g" gnus-summary-show-article
1783   "l" gnus-summary-goto-last-article
1784   "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1785   "\C-d" gnus-summary-enter-digest-group
1786   "\M-\C-d" gnus-summary-read-document
1787   "\M-\C-e" gnus-summary-edit-parameters
1788   "\M-\C-a" gnus-summary-customize-parameters
1789   "\C-c\C-b" gnus-bug
1790   "*" gnus-cache-enter-article
1791   "\M-*" gnus-cache-remove-article
1792   "\M-&" gnus-summary-universal-argument
1793   "\C-l" gnus-recenter
1794   "I" gnus-summary-increase-score
1795   "L" gnus-summary-lower-score
1796   "\M-i" gnus-symbolic-argument
1797   "h" gnus-summary-select-article-buffer
1798
1799   "b" gnus-article-view-part
1800   "\M-t" gnus-summary-toggle-display-buttonized
1801
1802   "V" gnus-summary-score-map
1803   "X" gnus-uu-extract-map
1804   "S" gnus-summary-send-map)
1805
1806 ;; Sort of orthogonal keymap
1807 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1808   "t" gnus-summary-tick-article-forward
1809   "!" gnus-summary-tick-article-forward
1810   "d" gnus-summary-mark-as-read-forward
1811   "r" gnus-summary-mark-as-read-forward
1812   "c" gnus-summary-clear-mark-forward
1813   " " gnus-summary-clear-mark-forward
1814   "e" gnus-summary-mark-as-expirable
1815   "x" gnus-summary-mark-as-expirable
1816   "?" gnus-summary-mark-as-dormant
1817   "b" gnus-summary-set-bookmark
1818   "B" gnus-summary-remove-bookmark
1819   "#" gnus-summary-mark-as-processable
1820   "\M-#" gnus-summary-unmark-as-processable
1821   "S" gnus-summary-limit-include-expunged
1822   "C" gnus-summary-catchup
1823   "H" gnus-summary-catchup-to-here
1824   "h" gnus-summary-catchup-from-here
1825   "\C-c" gnus-summary-catchup-all
1826   "k" gnus-summary-kill-same-subject-and-select
1827   "K" gnus-summary-kill-same-subject
1828   "P" gnus-uu-mark-map)
1829
1830 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1831   "c" gnus-summary-clear-above
1832   "u" gnus-summary-tick-above
1833   "m" gnus-summary-mark-above
1834   "k" gnus-summary-kill-below)
1835
1836 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1837   "/" gnus-summary-limit-to-subject
1838   "n" gnus-summary-limit-to-articles
1839   "w" gnus-summary-pop-limit
1840   "s" gnus-summary-limit-to-subject
1841   "a" gnus-summary-limit-to-author
1842   "u" gnus-summary-limit-to-unread
1843   "m" gnus-summary-limit-to-marks
1844   "M" gnus-summary-limit-exclude-marks
1845   "v" gnus-summary-limit-to-score
1846   "*" gnus-summary-limit-include-cached
1847   "D" gnus-summary-limit-include-dormant
1848   "T" gnus-summary-limit-include-thread
1849   "d" gnus-summary-limit-exclude-dormant
1850   "t" gnus-summary-limit-to-age
1851   "." gnus-summary-limit-to-unseen
1852   "x" gnus-summary-limit-to-extra
1853   "p" gnus-summary-limit-to-display-predicate
1854   "E" gnus-summary-limit-include-expunged
1855   "c" gnus-summary-limit-exclude-childless-dormant
1856   "C" gnus-summary-limit-mark-excluded-as-read
1857   "o" gnus-summary-insert-old-articles
1858   "N" gnus-summary-insert-new-articles
1859   "r" gnus-summary-limit-to-replied
1860   "R" gnus-summary-limit-to-recipient)
1861
1862 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1863   "n" gnus-summary-next-unread-article
1864   "p" gnus-summary-prev-unread-article
1865   "N" gnus-summary-next-article
1866   "P" gnus-summary-prev-article
1867   "\C-n" gnus-summary-next-same-subject
1868   "\C-p" gnus-summary-prev-same-subject
1869   "\M-n" gnus-summary-next-unread-subject
1870   "\M-p" gnus-summary-prev-unread-subject
1871   "f" gnus-summary-first-unread-article
1872   "b" gnus-summary-best-unread-article
1873   "j" gnus-summary-goto-article
1874   "g" gnus-summary-goto-subject
1875   "l" gnus-summary-goto-last-article
1876   "o" gnus-summary-pop-article)
1877
1878 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1879   "k" gnus-summary-kill-thread
1880   "l" gnus-summary-lower-thread
1881   "i" gnus-summary-raise-thread
1882   "T" gnus-summary-toggle-threads
1883   "t" gnus-summary-rethread-current
1884   "^" gnus-summary-reparent-thread
1885   "s" gnus-summary-show-thread
1886   "S" gnus-summary-show-all-threads
1887   "h" gnus-summary-hide-thread
1888   "H" gnus-summary-hide-all-threads
1889   "n" gnus-summary-next-thread
1890   "p" gnus-summary-prev-thread
1891   "u" gnus-summary-up-thread
1892   "o" gnus-summary-top-thread
1893   "d" gnus-summary-down-thread
1894   "#" gnus-uu-mark-thread
1895   "\M-#" gnus-uu-unmark-thread)
1896
1897 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1898   "g" gnus-summary-prepare
1899   "c" gnus-summary-insert-cached-articles
1900   "d" gnus-summary-insert-dormant-articles)
1901
1902 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1903   "c" gnus-summary-catchup-and-exit
1904   "C" gnus-summary-catchup-all-and-exit
1905   "E" gnus-summary-exit-no-update
1906   "Q" gnus-summary-exit
1907   "Z" gnus-summary-exit
1908   "n" gnus-summary-catchup-and-goto-next-group
1909   "R" gnus-summary-reselect-current-group
1910   "G" gnus-summary-rescan-group
1911   "N" gnus-summary-next-group
1912   "s" gnus-summary-save-newsrc
1913   "P" gnus-summary-prev-group)
1914
1915 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1916   " " gnus-summary-next-page
1917   "n" gnus-summary-next-page
1918   "\177" gnus-summary-prev-page
1919   [delete] gnus-summary-prev-page
1920   "p" gnus-summary-prev-page
1921   "\r" gnus-summary-scroll-up
1922   "\M-\r" gnus-summary-scroll-down
1923   "<" gnus-summary-beginning-of-article
1924   ">" gnus-summary-end-of-article
1925   "b" gnus-summary-beginning-of-article
1926   "e" gnus-summary-end-of-article
1927   "^" gnus-summary-refer-parent-article
1928   "r" gnus-summary-refer-parent-article
1929   "D" gnus-summary-enter-digest-group
1930   "R" gnus-summary-refer-references
1931   "T" gnus-summary-refer-thread
1932   "g" gnus-summary-show-article
1933   "s" gnus-summary-isearch-article
1934   "P" gnus-summary-print-article
1935   "M" gnus-mailing-list-insinuate
1936   "t" gnus-article-babel)
1937
1938 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1939   "b" gnus-article-add-buttons
1940   "B" gnus-article-add-buttons-to-head
1941   "o" gnus-article-treat-overstrike
1942   "e" gnus-article-emphasize
1943   "w" gnus-article-fill-cited-article
1944   "Q" gnus-article-fill-long-lines
1945   "C" gnus-article-capitalize-sentences
1946   "c" gnus-article-remove-cr
1947   "q" gnus-article-de-quoted-unreadable
1948   "6" gnus-article-de-base64-unreadable
1949   "Z" gnus-article-decode-HZ
1950   "A" gnus-article-treat-ansi-sequences
1951   "h" gnus-article-wash-html
1952   "u" gnus-article-unsplit-urls
1953   "s" gnus-summary-force-verify-and-decrypt
1954   "f" gnus-article-display-x-face
1955   "l" gnus-summary-stop-page-breaking
1956   "r" gnus-summary-caesar-message
1957   "m" gnus-summary-morse-message
1958   "t" gnus-summary-toggle-header
1959   "g" gnus-treat-smiley
1960   "v" gnus-summary-verbose-headers
1961   "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1962   "p" gnus-article-verify-x-pgp-sig
1963   "d" gnus-article-treat-dumbquotes
1964   "i" gnus-summary-idna-message)
1965
1966 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1967   ;; mnemonic: deuglif*Y*
1968   "u" gnus-article-outlook-unwrap-lines
1969   "a" gnus-article-outlook-repair-attribution
1970   "c" gnus-article-outlook-rearrange-citation
1971   "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1972
1973 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1974   "a" gnus-article-hide
1975   "h" gnus-article-hide-headers
1976   "b" gnus-article-hide-boring-headers
1977   "s" gnus-article-hide-signature
1978   "c" gnus-article-hide-citation
1979   "C" gnus-article-hide-citation-in-followups
1980   "l" gnus-article-hide-list-identifiers
1981   "B" gnus-article-strip-banner
1982   "P" gnus-article-hide-pem
1983   "\C-c" gnus-article-hide-citation-maybe)
1984
1985 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1986   "a" gnus-article-highlight
1987   "h" gnus-article-highlight-headers
1988   "c" gnus-article-highlight-citation
1989   "s" gnus-article-highlight-signature)
1990
1991 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1992   "f" gnus-article-treat-fold-headers
1993   "u" gnus-article-treat-unfold-headers
1994   "n" gnus-article-treat-fold-newsgroups)
1995
1996 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1997   "x" gnus-article-display-x-face
1998   "d" gnus-article-display-face
1999   "s" gnus-treat-smiley
2000   "D" gnus-article-remove-images
2001   "f" gnus-treat-from-picon
2002   "m" gnus-treat-mail-picon
2003   "n" gnus-treat-newsgroups-picon)
2004
2005 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2006   "w" gnus-article-decode-mime-words
2007   "c" gnus-article-decode-charset
2008   "v" gnus-mime-view-all-parts
2009   "b" gnus-article-view-part)
2010
2011 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2012   "z" gnus-article-date-ut
2013   "u" gnus-article-date-ut
2014   "l" gnus-article-date-local
2015   "p" gnus-article-date-english
2016   "e" gnus-article-date-lapsed
2017   "o" gnus-article-date-original
2018   "i" gnus-article-date-iso8601
2019   "s" gnus-article-date-user)
2020
2021 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2022   "t" gnus-article-remove-trailing-blank-lines
2023   "l" gnus-article-strip-leading-blank-lines
2024   "m" gnus-article-strip-multiple-blank-lines
2025   "a" gnus-article-strip-blank-lines
2026   "A" gnus-article-strip-all-blank-lines
2027   "s" gnus-article-strip-leading-space
2028   "e" gnus-article-strip-trailing-space
2029   "w" gnus-article-remove-leading-whitespace)
2030
2031 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2032   "v" gnus-version
2033   "f" gnus-summary-fetch-faq
2034   "d" gnus-summary-describe-group
2035   "h" gnus-summary-describe-briefly
2036   "i" gnus-info-find-node
2037   "c" gnus-group-fetch-charter
2038   "C" gnus-group-fetch-control)
2039
2040 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2041   "e" gnus-summary-expire-articles
2042   "\M-\C-e" gnus-summary-expire-articles-now
2043   "\177" gnus-summary-delete-article
2044   [delete] gnus-summary-delete-article
2045   [backspace] gnus-summary-delete-article
2046   "m" gnus-summary-move-article
2047   "r" gnus-summary-respool-article
2048   "w" gnus-summary-edit-article
2049   "c" gnus-summary-copy-article
2050   "B" gnus-summary-crosspost-article
2051   "q" gnus-summary-respool-query
2052   "t" gnus-summary-respool-trace
2053   "i" gnus-summary-import-article
2054   "I" gnus-summary-create-article
2055   "p" gnus-summary-article-posted-p)
2056
2057 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2058   "o" gnus-summary-save-article
2059   "m" gnus-summary-save-article-mail
2060   "F" gnus-summary-write-article-file
2061   "r" gnus-summary-save-article-rmail
2062   "f" gnus-summary-save-article-file
2063   "b" gnus-summary-save-article-body-file
2064   "h" gnus-summary-save-article-folder
2065   "v" gnus-summary-save-article-vm
2066   "p" gnus-summary-pipe-output
2067   "P" gnus-summary-muttprint
2068   "s" gnus-soup-add-article)
2069
2070 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2071   "b" gnus-summary-display-buttonized
2072   "m" gnus-summary-repair-multipart
2073   "v" gnus-article-view-part
2074   "o" gnus-article-save-part
2075   "O" gnus-article-save-part-and-strip
2076   "r" gnus-article-replace-part
2077   "d" gnus-article-delete-part
2078   "j" gnus-article-jump-to-part
2079   "c" gnus-article-copy-part
2080   "C" gnus-article-view-part-as-charset
2081   "e" gnus-article-view-part-externally
2082   "E" gnus-article-encrypt-body
2083   "i" gnus-article-inline-part
2084   "|" gnus-article-pipe-part)
2085
2086 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2087   "p" gnus-summary-mark-as-processable
2088   "u" gnus-summary-unmark-as-processable
2089   "U" gnus-summary-unmark-all-processable
2090   "v" gnus-uu-mark-over
2091   "s" gnus-uu-mark-series
2092   "r" gnus-uu-mark-region
2093   "g" gnus-uu-unmark-region
2094   "R" gnus-uu-mark-by-regexp
2095   "G" gnus-uu-unmark-by-regexp
2096   "t" gnus-uu-mark-thread
2097   "T" gnus-uu-unmark-thread
2098   "a" gnus-uu-mark-all
2099   "b" gnus-uu-mark-buffer
2100   "S" gnus-uu-mark-sparse
2101   "k" gnus-summary-kill-process-mark
2102   "y" gnus-summary-yank-process-mark
2103   "w" gnus-summary-save-process-mark
2104   "i" gnus-uu-invert-processable)
2105
2106 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2107   ;;"x" gnus-uu-extract-any
2108   "m" gnus-summary-save-parts
2109   "u" gnus-uu-decode-uu
2110   "U" gnus-uu-decode-uu-and-save
2111   "s" gnus-uu-decode-unshar
2112   "S" gnus-uu-decode-unshar-and-save
2113   "o" gnus-uu-decode-save
2114   "O" gnus-uu-decode-save
2115   "b" gnus-uu-decode-binhex
2116   "B" gnus-uu-decode-binhex
2117   "p" gnus-uu-decode-postscript
2118   "P" gnus-uu-decode-postscript-and-save)
2119
2120 (gnus-define-keys
2121     (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2122   "u" gnus-uu-decode-uu-view
2123   "U" gnus-uu-decode-uu-and-save-view
2124   "s" gnus-uu-decode-unshar-view
2125   "S" gnus-uu-decode-unshar-and-save-view
2126   "o" gnus-uu-decode-save-view
2127   "O" gnus-uu-decode-save-view
2128   "b" gnus-uu-decode-binhex-view
2129   "B" gnus-uu-decode-binhex-view
2130   "p" gnus-uu-decode-postscript-view
2131   "P" gnus-uu-decode-postscript-and-save-view)
2132
2133 (defvar gnus-article-post-menu nil)
2134
2135 (defconst gnus-summary-menu-maxlen 20)
2136
2137 (defun gnus-summary-menu-split (menu)
2138   ;; If we have lots of elements, divide them into groups of 20
2139   ;; and make a pane (or submenu) for each one.
2140   (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2141       (let ((menu menu) sublists next
2142             (i 1))
2143         (while menu
2144           ;; Pull off the next gnus-summary-menu-maxlen elements
2145           ;; and make them the next element of sublist.
2146           (setq next (nthcdr gnus-summary-menu-maxlen menu))
2147           (if next
2148               (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2149                       nil))
2150           (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2151                                              (aref (car (last menu)) 0)) menu)
2152                                sublists))
2153           (setq i (1+ i))
2154           (setq menu next))
2155         (nreverse sublists))
2156     ;; Few elements--put them all in one pane.
2157     menu))
2158
2159 (defun gnus-summary-make-menu-bar ()
2160   (gnus-turn-off-edit-menu 'summary)
2161
2162   (unless (boundp 'gnus-summary-misc-menu)
2163
2164     (easy-menu-define
2165       gnus-summary-kill-menu gnus-summary-mode-map ""
2166       (cons
2167        "Score"
2168        (nconc
2169         (list
2170          ["Customize" gnus-score-customize t])
2171         (gnus-make-score-map 'increase)
2172         (gnus-make-score-map 'lower)
2173         '(("Mark"
2174            ["Kill below" gnus-summary-kill-below t]
2175            ["Mark above" gnus-summary-mark-above t]
2176            ["Tick above" gnus-summary-tick-above t]
2177            ["Clear above" gnus-summary-clear-above t])
2178           ["Current score" gnus-summary-current-score t]
2179           ["Set score" gnus-summary-set-score t]
2180           ["Switch current score file..." gnus-score-change-score-file t]
2181           ["Set mark below..." gnus-score-set-mark-below t]
2182           ["Set expunge below..." gnus-score-set-expunge-below t]
2183           ["Edit current score file" gnus-score-edit-current-scores t]
2184           ["Edit score file" gnus-score-edit-file t]
2185           ["Trace score" gnus-score-find-trace t]
2186           ["Find words" gnus-score-find-favourite-words t]
2187           ["Rescore buffer" gnus-summary-rescore t]
2188           ["Increase score..." gnus-summary-increase-score t]
2189           ["Lower score..." gnus-summary-lower-score t]))))
2190
2191     ;; Define both the Article menu in the summary buffer and the
2192     ;; equivalent Commands menu in the article buffer here for
2193     ;; consistency.
2194     (let ((innards
2195            `(("Hide"
2196               ["All" gnus-article-hide t]
2197               ["Headers" gnus-article-hide-headers t]
2198               ["Signature" gnus-article-hide-signature t]
2199               ["Citation" gnus-article-hide-citation t]
2200               ["List identifiers" gnus-article-hide-list-identifiers t]
2201               ["Banner" gnus-article-strip-banner t]
2202               ["Boring headers" gnus-article-hide-boring-headers t])
2203              ("Highlight"
2204               ["All" gnus-article-highlight t]
2205               ["Headers" gnus-article-highlight-headers t]
2206               ["Signature" gnus-article-highlight-signature t]
2207               ["Citation" gnus-article-highlight-citation t])
2208              ("MIME"
2209               ["Words" gnus-article-decode-mime-words t]
2210               ["Charset" gnus-article-decode-charset t]
2211               ["QP" gnus-article-de-quoted-unreadable t]
2212               ["Base64" gnus-article-de-base64-unreadable t]
2213               ["View MIME buttons" gnus-summary-display-buttonized t]
2214               ["View all" gnus-mime-view-all-parts t]
2215               ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2216               ["Encrypt body" gnus-article-encrypt-body
2217                :active (not (gnus-group-read-only-p))
2218                ,@(if (featurep 'xemacs) nil
2219                    '(:help "Encrypt the message body on disk"))]
2220               ["Extract all parts..." gnus-summary-save-parts t]
2221               ("Multipart"
2222                ["Repair multipart" gnus-summary-repair-multipart t]
2223                ["Pipe part..." gnus-article-pipe-part t]
2224                ["Inline part" gnus-article-inline-part t]
2225                ["Encrypt body" gnus-article-encrypt-body
2226                 :active (not (gnus-group-read-only-p))
2227                ,@(if (featurep 'xemacs) nil
2228                    '(:help "Encrypt the message body on disk"))]
2229                ["View part externally" gnus-article-view-part-externally t]
2230                ["View part with charset..." gnus-article-view-part-as-charset t]
2231                ["Copy part" gnus-article-copy-part t]
2232                ["Save part..." gnus-article-save-part t]
2233                ["View part" gnus-article-view-part t]))
2234              ("Date"
2235               ["Local" gnus-article-date-local t]
2236               ["ISO8601" gnus-article-date-iso8601 t]
2237               ["UT" gnus-article-date-ut t]
2238               ["Original" gnus-article-date-original t]
2239               ["Lapsed" gnus-article-date-lapsed t]
2240               ["User-defined" gnus-article-date-user t])
2241              ("Display"
2242               ["Remove images" gnus-article-remove-images t]
2243               ["Toggle smiley" gnus-treat-smiley t]
2244               ["Show X-Face" gnus-article-display-x-face t]
2245               ["Show picons in From" gnus-treat-from-picon t]
2246               ["Show picons in mail headers" gnus-treat-mail-picon t]
2247               ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2248               ("View as different encoding"
2249                ,@(gnus-summary-menu-split
2250                   (mapcar
2251                    (lambda (cs)
2252                      ;; Since easymenu under Emacs doesn't allow
2253                      ;; lambda forms for menu commands, we should
2254                      ;; provide intern'ed function symbols.
2255                      (let ((command (intern (format "\
2256 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2257                        (fset command
2258                              `(lambda ()
2259                                 (interactive)
2260                                 (let ((gnus-summary-show-article-charset-alist
2261                                        '((1 . ,cs))))
2262                                   (gnus-summary-show-article 1))))
2263                        `[,(symbol-name cs) ,command t]))
2264                    (sort (if (fboundp 'coding-system-list)
2265                              (coding-system-list)
2266                            (mapcar 'car mm-mime-mule-charset-alist))
2267                          'string<)))))
2268              ("Washing"
2269               ("Remove Blanks"
2270                ["Leading" gnus-article-strip-leading-blank-lines t]
2271                ["Multiple" gnus-article-strip-multiple-blank-lines t]
2272                ["Trailing" gnus-article-remove-trailing-blank-lines t]
2273                ["All of the above" gnus-article-strip-blank-lines t]
2274                ["All" gnus-article-strip-all-blank-lines t]
2275                ["Leading space" gnus-article-strip-leading-space t]
2276                ["Trailing space" gnus-article-strip-trailing-space t]
2277                ["Leading space in headers"
2278                 gnus-article-remove-leading-whitespace t])
2279               ["Overstrike" gnus-article-treat-overstrike t]
2280               ["Dumb quotes" gnus-article-treat-dumbquotes t]
2281               ["Emphasis" gnus-article-emphasize t]
2282               ["Word wrap" gnus-article-fill-cited-article t]
2283               ["Fill long lines" gnus-article-fill-long-lines t]
2284               ["Capitalize sentences" gnus-article-capitalize-sentences t]
2285               ["Remove CR" gnus-article-remove-cr t]
2286               ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2287               ["Base64" gnus-article-de-base64-unreadable t]
2288               ["Rot 13" gnus-summary-caesar-message
2289                ,@(if (featurep 'xemacs) '(t)
2290                    '(:help "\"Caesar rotate\" article by 13"))]
2291               ["De-IDNA" gnus-summary-idna-message t]
2292               ["Morse decode" gnus-summary-morse-message t]
2293               ["Unix pipe..." gnus-summary-pipe-message t]
2294               ["Add buttons" gnus-article-add-buttons t]
2295               ["Add buttons to head" gnus-article-add-buttons-to-head t]
2296               ["Stop page breaking" gnus-summary-stop-page-breaking t]
2297               ["Verbose header" gnus-summary-verbose-headers t]
2298               ["Toggle header" gnus-summary-toggle-header t]
2299               ["Unfold headers" gnus-article-treat-unfold-headers t]
2300               ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2301               ["Html" gnus-article-wash-html t]
2302               ["Unsplit URLs" gnus-article-unsplit-urls t]
2303               ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2304               ["Decode HZ" gnus-article-decode-HZ t]
2305               ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2306               ("(Outlook) Deuglify"
2307                ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2308                ["Repair attribution" gnus-article-outlook-repair-attribution t]
2309                ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2310                ["Full (Outlook) deuglify"
2311                 gnus-article-outlook-deuglify-article t])
2312               )
2313              ("Output"
2314               ["Save in default format..." gnus-summary-save-article
2315                ,@(if (featurep 'xemacs) '(t)
2316                    '(:help "Save article using default method"))]
2317               ["Save in file..." gnus-summary-save-article-file
2318                ,@(if (featurep 'xemacs) '(t)
2319                    '(:help "Save article in file"))]
2320               ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2321               ["Save in MH folder..." gnus-summary-save-article-folder t]
2322               ["Save in VM folder..." gnus-summary-save-article-vm t]
2323               ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2324               ["Save body in file..." gnus-summary-save-article-body-file t]
2325               ["Pipe through a filter..." gnus-summary-pipe-output t]
2326               ["Add to SOUP packet" gnus-soup-add-article t]
2327               ["Print with Muttprint..." gnus-summary-muttprint t]
2328               ["Print" gnus-summary-print-article
2329                ,@(if (featurep 'xemacs) '(t)
2330                    '(:help "Generate and print a PostScript image"))])
2331              ("Copy, move,... (Backend)"
2332               ,@(if (featurep 'xemacs) nil
2333                   '(:help "Copying, moving, expiring articles..."))
2334               ["Respool article..." gnus-summary-respool-article t]
2335               ["Move article..." gnus-summary-move-article
2336                (gnus-check-backend-function
2337                 'request-move-article gnus-newsgroup-name)]
2338               ["Copy article..." gnus-summary-copy-article t]
2339               ["Crosspost article..." gnus-summary-crosspost-article
2340                (gnus-check-backend-function
2341                 'request-replace-article gnus-newsgroup-name)]
2342               ["Import file..." gnus-summary-import-article
2343                (gnus-check-backend-function
2344                 'request-accept-article gnus-newsgroup-name)]
2345               ["Create article..." gnus-summary-create-article
2346                (gnus-check-backend-function
2347                 'request-accept-article gnus-newsgroup-name)]
2348               ["Check if posted" gnus-summary-article-posted-p t]
2349               ["Edit article" gnus-summary-edit-article
2350                (not (gnus-group-read-only-p))]
2351               ["Delete article" gnus-summary-delete-article
2352                (gnus-check-backend-function
2353                 'request-expire-articles gnus-newsgroup-name)]
2354               ["Query respool" gnus-summary-respool-query t]
2355               ["Trace respool" gnus-summary-respool-trace t]
2356               ["Delete expirable articles" gnus-summary-expire-articles-now
2357                (gnus-check-backend-function
2358                 'request-expire-articles gnus-newsgroup-name)])
2359              ("Extract"
2360               ["Uudecode" gnus-uu-decode-uu
2361                ,@(if (featurep 'xemacs) '(t)
2362                    '(:help "Decode uuencoded article(s)"))]
2363               ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2364               ["Unshar" gnus-uu-decode-unshar t]
2365               ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2366               ["Save" gnus-uu-decode-save t]
2367               ["Binhex" gnus-uu-decode-binhex t]
2368               ["Postscript" gnus-uu-decode-postscript t]
2369               ["All MIME parts" gnus-summary-save-parts t])
2370              ("Cache"
2371               ["Enter article" gnus-cache-enter-article t]
2372               ["Remove article" gnus-cache-remove-article t])
2373              ["Translate" gnus-article-babel t]
2374              ["Select article buffer" gnus-summary-select-article-buffer t]
2375              ["Enter digest buffer" gnus-summary-enter-digest-group t]
2376              ["Isearch article..." gnus-summary-isearch-article t]
2377              ["Beginning of the article" gnus-summary-beginning-of-article t]
2378              ["End of the article" gnus-summary-end-of-article t]
2379              ["Fetch parent of article" gnus-summary-refer-parent-article t]
2380              ["Fetch referenced articles" gnus-summary-refer-references t]
2381              ["Fetch current thread" gnus-summary-refer-thread t]
2382              ["Fetch article with id..." gnus-summary-refer-article t]
2383              ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2384              ["Redisplay" gnus-summary-show-article t]
2385              ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2386       (easy-menu-define
2387         gnus-summary-article-menu gnus-summary-mode-map ""
2388         (cons "Article" innards))
2389
2390       (if (not (keymapp gnus-summary-article-menu))
2391           (easy-menu-define
2392             gnus-article-commands-menu gnus-article-mode-map ""
2393             (cons "Commands" innards))
2394         ;; in Emacs, don't share menu.
2395         (setq gnus-article-commands-menu
2396               (copy-keymap gnus-summary-article-menu))
2397         (define-key gnus-article-mode-map [menu-bar commands]
2398           (cons "Commands" gnus-article-commands-menu))))
2399
2400     (easy-menu-define
2401       gnus-summary-thread-menu gnus-summary-mode-map ""
2402       '("Threads"
2403         ["Find all messages in thread" gnus-summary-refer-thread t]
2404         ["Toggle threading" gnus-summary-toggle-threads t]
2405         ["Hide threads" gnus-summary-hide-all-threads t]
2406         ["Show threads" gnus-summary-show-all-threads t]
2407         ["Hide thread" gnus-summary-hide-thread t]
2408         ["Show thread" gnus-summary-show-thread t]
2409         ["Go to next thread" gnus-summary-next-thread t]
2410         ["Go to previous thread" gnus-summary-prev-thread t]
2411         ["Go down thread" gnus-summary-down-thread t]
2412         ["Go up thread" gnus-summary-up-thread t]
2413         ["Top of thread" gnus-summary-top-thread t]
2414         ["Mark thread as read" gnus-summary-kill-thread t]
2415         ["Lower thread score" gnus-summary-lower-thread t]
2416         ["Raise thread score" gnus-summary-raise-thread t]
2417         ["Rethread current" gnus-summary-rethread-current t]))
2418
2419     (easy-menu-define
2420       gnus-summary-post-menu gnus-summary-mode-map ""
2421       `("Post"
2422         ["Send a message (mail or news)" gnus-summary-post-news
2423          ,@(if (featurep 'xemacs) '(t)
2424              '(:help "Compose a new message (mail or news)"))]
2425         ["Followup" gnus-summary-followup
2426          ,@(if (featurep 'xemacs) '(t)
2427              '(:help "Post followup to this article"))]
2428         ["Followup and yank" gnus-summary-followup-with-original
2429          ,@(if (featurep 'xemacs) '(t)
2430              '(:help "Post followup to this article, quoting its contents"))]
2431         ["Supersede article" gnus-summary-supersede-article t]
2432         ["Cancel article" gnus-summary-cancel-article
2433          ,@(if (featurep 'xemacs) '(t)
2434              '(:help "Cancel an article you posted"))]
2435         ["Reply" gnus-summary-reply t]
2436         ["Reply and yank" gnus-summary-reply-with-original t]
2437         ["Wide reply" gnus-summary-wide-reply t]
2438         ["Wide reply and yank" gnus-summary-wide-reply-with-original
2439          ,@(if (featurep 'xemacs) '(t)
2440              '(:help "Mail a reply, quoting this article"))]
2441         ["Very wide reply" gnus-summary-very-wide-reply t]
2442         ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2443          ,@(if (featurep 'xemacs) '(t)
2444              '(:help "Mail a very wide reply, quoting this article"))]
2445         ["Mail forward" gnus-summary-mail-forward t]
2446         ["Post forward" gnus-summary-post-forward t]
2447         ["Digest and mail" gnus-uu-digest-mail-forward t]
2448         ["Digest and post" gnus-uu-digest-post-forward t]
2449         ["Resend message" gnus-summary-resend-message t]
2450         ["Resend message edit" gnus-summary-resend-message-edit t]
2451         ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2452         ["Send a mail" gnus-summary-mail-other-window t]
2453         ["Create a local message" gnus-summary-news-other-window t]
2454         ["Uuencode and post" gnus-uu-post-news
2455          ,@(if (featurep 'xemacs) '(t)
2456              '(:help "Post a uuencoded article"))]
2457         ["Followup via news" gnus-summary-followup-to-mail t]
2458         ["Followup via news and yank"
2459          gnus-summary-followup-to-mail-with-original t]
2460         ;;("Draft"
2461         ;;["Send" gnus-summary-send-draft t]
2462         ;;["Send bounced" gnus-resend-bounced-mail t])
2463         ))
2464
2465     (cond
2466      ((not (keymapp gnus-summary-post-menu))
2467       (setq gnus-article-post-menu gnus-summary-post-menu))
2468      ((not gnus-article-post-menu)
2469       ;; Don't share post menu.
2470       (setq gnus-article-post-menu
2471             (copy-keymap gnus-summary-post-menu))))
2472     (define-key gnus-article-mode-map [menu-bar post]
2473       (cons "Post" gnus-article-post-menu))
2474
2475     (easy-menu-define
2476       gnus-summary-misc-menu gnus-summary-mode-map ""
2477       `("Gnus"
2478         ("Mark Read"
2479          ["Mark as read" gnus-summary-mark-as-read-forward t]
2480          ["Mark same subject and select"
2481           gnus-summary-kill-same-subject-and-select t]
2482          ["Mark same subject" gnus-summary-kill-same-subject t]
2483          ["Catchup" gnus-summary-catchup
2484           ,@(if (featurep 'xemacs) '(t)
2485               '(:help "Mark unread articles in this group as read"))]
2486          ["Catchup all" gnus-summary-catchup-all t]
2487          ["Catchup to here" gnus-summary-catchup-to-here t]
2488          ["Catchup from here" gnus-summary-catchup-from-here t]
2489          ["Catchup region" gnus-summary-mark-region-as-read
2490           (gnus-mark-active-p)]
2491          ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2492         ("Mark Various"
2493          ["Tick" gnus-summary-tick-article-forward t]
2494          ["Mark as dormant" gnus-summary-mark-as-dormant t]
2495          ["Remove marks" gnus-summary-clear-mark-forward t]
2496          ["Set expirable mark" gnus-summary-mark-as-expirable t]
2497          ["Set bookmark" gnus-summary-set-bookmark t]
2498          ["Remove bookmark" gnus-summary-remove-bookmark t])
2499         ("Limit to"
2500          ["Marks..." gnus-summary-limit-to-marks t]
2501          ["Subject..." gnus-summary-limit-to-subject t]
2502          ["Author..." gnus-summary-limit-to-author t]
2503          ["Recipient..." gnus-summary-limit-to-recipient t]
2504          ["Age..." gnus-summary-limit-to-age t]
2505          ["Extra..." gnus-summary-limit-to-extra t]
2506          ["Score..." gnus-summary-limit-to-score t]
2507          ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2508          ["Unread" gnus-summary-limit-to-unread t]
2509          ["Unseen" gnus-summary-limit-to-unseen t]
2510          ["Replied" gnus-summary-limit-to-replied t]
2511          ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2512          ["Next articles" gnus-summary-limit-to-articles t]
2513          ["Pop limit" gnus-summary-pop-limit t]
2514          ["Show dormant" gnus-summary-limit-include-dormant t]
2515          ["Hide childless dormant"
2516           gnus-summary-limit-exclude-childless-dormant t]
2517          ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2518          ["Hide marked" gnus-summary-limit-exclude-marks t]
2519          ["Show expunged" gnus-summary-limit-include-expunged t])
2520         ("Process Mark"
2521          ["Set mark" gnus-summary-mark-as-processable t]
2522          ["Remove mark" gnus-summary-unmark-as-processable t]
2523          ["Remove all marks" gnus-summary-unmark-all-processable t]
2524          ["Invert marks" gnus-uu-invert-processable t]
2525          ["Mark above" gnus-uu-mark-over t]
2526          ["Mark series" gnus-uu-mark-series t]
2527          ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2528          ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2529          ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2530          ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2531          ["Mark all" gnus-uu-mark-all t]
2532          ["Mark buffer" gnus-uu-mark-buffer t]
2533          ["Mark sparse" gnus-uu-mark-sparse t]
2534          ["Mark thread" gnus-uu-mark-thread t]
2535          ["Unmark thread" gnus-uu-unmark-thread t]
2536          ("Process Mark Sets"
2537           ["Kill" gnus-summary-kill-process-mark t]
2538           ["Yank" gnus-summary-yank-process-mark
2539            gnus-newsgroup-process-stack]
2540           ["Save" gnus-summary-save-process-mark t]
2541           ["Run command on marked..." gnus-summary-universal-argument t]))
2542         ("Scroll article"
2543          ["Page forward" gnus-summary-next-page
2544           ,@(if (featurep 'xemacs) '(t)
2545               '(:help "Show next page of article"))]
2546          ["Page backward" gnus-summary-prev-page
2547           ,@(if (featurep 'xemacs) '(t)
2548               '(:help "Show previous page of article"))]
2549          ["Line forward" gnus-summary-scroll-up t])
2550         ("Move"
2551          ["Next unread article" gnus-summary-next-unread-article t]
2552          ["Previous unread article" gnus-summary-prev-unread-article t]
2553          ["Next article" gnus-summary-next-article t]
2554          ["Previous article" gnus-summary-prev-article t]
2555          ["Next unread subject" gnus-summary-next-unread-subject t]
2556          ["Previous unread subject" gnus-summary-prev-unread-subject t]
2557          ["Next article same subject" gnus-summary-next-same-subject t]
2558          ["Previous article same subject" gnus-summary-prev-same-subject t]
2559          ["First unread article" gnus-summary-first-unread-article t]
2560          ["Best unread article" gnus-summary-best-unread-article t]
2561          ["Go to subject number..." gnus-summary-goto-subject t]
2562          ["Go to article number..." gnus-summary-goto-article t]
2563          ["Go to the last article" gnus-summary-goto-last-article t]
2564          ["Pop article off history" gnus-summary-pop-article t])
2565         ("Sort"
2566          ["Sort by number" gnus-summary-sort-by-number t]
2567          ["Sort by author" gnus-summary-sort-by-author t]
2568          ["Sort by recipient" gnus-summary-sort-by-recipient t]
2569          ["Sort by subject" gnus-summary-sort-by-subject t]
2570          ["Sort by date" gnus-summary-sort-by-date t]
2571          ["Sort by score" gnus-summary-sort-by-score t]
2572          ["Sort by lines" gnus-summary-sort-by-lines t]
2573          ["Sort by characters" gnus-summary-sort-by-chars t]
2574          ["Randomize" gnus-summary-sort-by-random t]
2575          ["Original sort" gnus-summary-sort-by-original t])
2576         ("Help"
2577          ["Fetch group FAQ" gnus-summary-fetch-faq t]
2578          ["Describe group" gnus-summary-describe-group t]
2579          ["Fetch charter" gnus-group-fetch-charter
2580           ,@(if (featurep 'xemacs) nil
2581               '(:help "Display the charter of the current group"))]
2582          ["Fetch control message" gnus-group-fetch-control
2583           ,@(if (featurep 'xemacs) nil
2584               '(:help "Display the archived control message for the current group"))]
2585          ["Read manual" gnus-info-find-node t])
2586         ("Modes"
2587          ["Pick and read" gnus-pick-mode t]
2588          ["Binary" gnus-binary-mode t])
2589         ("Regeneration"
2590          ["Regenerate" gnus-summary-prepare t]
2591          ["Insert cached articles" gnus-summary-insert-cached-articles t]
2592          ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2593          ["Toggle threading" gnus-summary-toggle-threads t])
2594         ["See old articles" gnus-summary-insert-old-articles t]
2595         ["See new articles" gnus-summary-insert-new-articles t]
2596         ["Filter articles..." gnus-summary-execute-command t]
2597         ["Run command on articles..." gnus-summary-universal-argument t]
2598         ["Search articles forward..." gnus-summary-search-article-forward t]
2599         ["Search articles backward..." gnus-summary-search-article-backward t]
2600         ["Toggle line truncation" gnus-summary-toggle-truncation t]
2601         ["Expand window" gnus-summary-expand-window t]
2602         ["Expire expirable articles" gnus-summary-expire-articles
2603          (gnus-check-backend-function
2604           'request-expire-articles gnus-newsgroup-name)]
2605         ["Edit local kill file" gnus-summary-edit-local-kill t]
2606         ["Edit main kill file" gnus-summary-edit-global-kill t]
2607         ["Edit group parameters" gnus-summary-edit-parameters t]
2608         ["Customize group parameters" gnus-summary-customize-parameters t]
2609         ["Send a bug report" gnus-bug t]
2610         ("Exit"
2611          ["Catchup and exit" gnus-summary-catchup-and-exit
2612           ,@(if (featurep 'xemacs) '(t)
2613               '(:help "Mark unread articles in this group as read, then exit"))]
2614          ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2615          ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2616          ["Exit group" gnus-summary-exit
2617           ,@(if (featurep 'xemacs) '(t)
2618               '(:help "Exit current group, return to group selection mode"))]
2619          ["Exit group without updating" gnus-summary-exit-no-update t]
2620          ["Exit and goto next group" gnus-summary-next-group t]
2621          ["Exit and goto prev group" gnus-summary-prev-group t]
2622          ["Reselect group" gnus-summary-reselect-current-group t]
2623          ["Rescan group" gnus-summary-rescan-group t]
2624          ["Update dribble" gnus-summary-save-newsrc t])))
2625
2626     (gnus-run-hooks 'gnus-summary-menu-hook)))
2627
2628 (defvar gnus-summary-tool-bar-map nil)
2629
2630 ;; Emacs 21 tool bar.  Should be no-op otherwise.
2631 (defun gnus-summary-make-tool-bar ()
2632   (if (and (fboundp 'tool-bar-add-item-from-menu)
2633            (default-value 'tool-bar-mode)
2634            (not gnus-summary-tool-bar-map))
2635       (setq gnus-summary-tool-bar-map
2636             (let ((tool-bar-map (make-sparse-keymap))
2637                   (load-path (mm-image-load-path)))
2638               (tool-bar-add-item-from-menu
2639                'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2640               (tool-bar-add-item-from-menu
2641                'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2642               (tool-bar-add-item-from-menu
2643                'gnus-summary-post-news "post" gnus-summary-mode-map)
2644               (tool-bar-add-item-from-menu
2645                'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2646               (tool-bar-add-item-from-menu
2647                'gnus-summary-followup "followup" gnus-summary-mode-map)
2648               (tool-bar-add-item-from-menu
2649                'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2650               (tool-bar-add-item-from-menu
2651                'gnus-summary-reply "reply" gnus-summary-mode-map)
2652               (tool-bar-add-item-from-menu
2653                'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2654               (tool-bar-add-item-from-menu
2655                'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2656               (tool-bar-add-item-from-menu
2657                'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2658               (tool-bar-add-item-from-menu
2659                'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2660               (tool-bar-add-item-from-menu
2661                'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2662               (tool-bar-add-item-from-menu
2663                'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2664               (tool-bar-add-item-from-menu
2665                'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2666               (tool-bar-add-item-from-menu
2667                'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2668               (tool-bar-add-item-from-menu
2669                'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2670               tool-bar-map)))
2671   (if gnus-summary-tool-bar-map
2672       (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2673
2674 (defun gnus-score-set-default (var value)
2675   "A version of set that updates the GNU Emacs menu-bar."
2676   (set var value)
2677   ;; It is the message that forces the active status to be updated.
2678   (message ""))
2679
2680 (defun gnus-make-score-map (type)
2681   "Make a summary score map of type TYPE."
2682   (if t
2683       nil
2684     (let ((headers '(("author" "from" string)
2685                      ("subject" "subject" string)
2686                      ("article body" "body" string)
2687                      ("article head" "head" string)
2688                      ("xref" "xref" string)
2689                      ("extra header" "extra" string)
2690                      ("lines" "lines" number)
2691                      ("followups to author" "followup" string)))
2692           (types '((number ("less than" <)
2693                            ("greater than" >)
2694                            ("equal" =))
2695                    (string ("substring" s)
2696                            ("exact string" e)
2697                            ("fuzzy string" f)
2698                            ("regexp" r))))
2699           (perms '(("temporary" (current-time-string))
2700                    ("permanent" nil)
2701                    ("immediate" now)))
2702           header)
2703       (list
2704        (apply
2705         'nconc
2706         (list
2707          (if (eq type 'lower)
2708              "Lower score"
2709            "Increase score"))
2710         (let (outh)
2711           (while headers
2712             (setq header (car headers))
2713             (setq outh
2714                   (cons
2715                    (apply
2716                     'nconc
2717                     (list (car header))
2718                     (let ((ts (cdr (assoc (nth 2 header) types)))
2719                           outt)
2720                       (while ts
2721                         (setq outt
2722                               (cons
2723                                (apply
2724                                 'nconc
2725                                 (list (caar ts))
2726                                 (let ((ps perms)
2727                                       outp)
2728                                   (while ps
2729                                     (setq outp
2730                                           (cons
2731                                            (vector
2732                                             (caar ps)
2733                                             (list
2734                                              'gnus-summary-score-entry
2735                                              (nth 1 header)
2736                                              (if (or (string= (nth 1 header)
2737                                                               "head")
2738                                                      (string= (nth 1 header)
2739                                                               "body"))
2740                                                  ""
2741                                                (list 'gnus-summary-header
2742                                                      (nth 1 header)))
2743                                              (list 'quote (nth 1 (car ts)))
2744                                              (list 'gnus-score-delta-default
2745                                                    nil)
2746                                              (nth 1 (car ps))
2747                                              t)
2748                                             t)
2749                                            outp))
2750                                     (setq ps (cdr ps)))
2751                                   (list (nreverse outp))))
2752                                outt))
2753                         (setq ts (cdr ts)))
2754                       (list (nreverse outt))))
2755                    outh))
2756             (setq headers (cdr headers)))
2757           (list (nreverse outh))))))))
2758
2759 \f
2760
2761 (defun gnus-summary-mode (&optional group)
2762   "Major mode for reading articles.
2763
2764 All normal editing commands are switched off.
2765 \\<gnus-summary-mode-map>
2766 Each line in this buffer represents one article.  To read an
2767 article, you can, for instance, type `\\[gnus-summary-next-page]'.  To move forwards
2768 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2769 respectively.
2770
2771 You can also post articles and send mail from this buffer.  To
2772 follow up an article, type `\\[gnus-summary-followup]'.  To mail a reply to the author
2773 of an article, type `\\[gnus-summary-reply]'.
2774
2775 There are approx. one gazillion commands you can execute in this
2776 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2777
2778 The following commands are available:
2779
2780 \\{gnus-summary-mode-map}"
2781   (interactive)
2782   (kill-all-local-variables)
2783   (when (gnus-visual-p 'summary-menu 'menu)
2784     (gnus-summary-make-menu-bar)
2785     (gnus-summary-make-tool-bar))
2786   (gnus-summary-make-local-variables)
2787   (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2788     (gnus-summary-make-local-variables))
2789   (gnus-make-thread-indent-array)
2790   (gnus-simplify-mode-line)
2791   (setq major-mode 'gnus-summary-mode)
2792   (setq mode-name "Summary")
2793   (make-local-variable 'minor-mode-alist)
2794   (use-local-map gnus-summary-mode-map)
2795   (buffer-disable-undo)
2796   (setq buffer-read-only t              ;Disable modification
2797         show-trailing-whitespace nil)
2798   (setq truncate-lines t)
2799   (setq selective-display t)
2800   (setq selective-display-ellipses t)   ;Display `...'
2801   (gnus-summary-set-display-table)
2802   (gnus-set-default-directory)
2803   (setq gnus-newsgroup-name group)
2804   (make-local-variable 'gnus-summary-line-format)
2805   (make-local-variable 'gnus-summary-line-format-spec)
2806   (make-local-variable 'gnus-summary-dummy-line-format)
2807   (make-local-variable 'gnus-summary-dummy-line-format-spec)
2808   (make-local-variable 'gnus-summary-mark-positions)
2809   (gnus-make-local-hook 'pre-command-hook)
2810   (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2811   (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2812   (turn-on-gnus-mailing-list-mode)
2813   (mm-enable-multibyte)
2814   (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2815   (gnus-update-summary-mark-positions))
2816
2817 (defun gnus-summary-make-local-variables ()
2818   "Make all the local summary buffer variables."
2819   (let (global)
2820     (dolist (local gnus-summary-local-variables)
2821       (if (consp local)
2822           (progn
2823             (if (eq (cdr local) 'global)
2824                 ;; Copy the global value of the variable.
2825                 (setq global (symbol-value (car local)))
2826               ;; Use the value from the list.
2827               (setq global (eval (cdr local))))
2828             (set (make-local-variable (car local)) global))
2829         ;; Simple nil-valued local variable.
2830         (set (make-local-variable local) nil)))))
2831
2832 (defun gnus-summary-clear-local-variables ()
2833   (let ((locals gnus-summary-local-variables))
2834     (while locals
2835       (if (consp (car locals))
2836           (and (symbolp (caar locals))
2837                (set (caar locals) nil))
2838         (and (symbolp (car locals))
2839              (set (car locals) nil)))
2840       (setq locals (cdr locals)))))
2841
2842 ;; Summary data functions.
2843
2844 (defmacro gnus-data-number (data)
2845   `(car ,data))
2846
2847 (defmacro gnus-data-set-number (data number)
2848   `(setcar ,data ,number))
2849
2850 (defmacro gnus-data-mark (data)
2851   `(nth 1 ,data))
2852
2853 (defmacro gnus-data-set-mark (data mark)
2854   `(setcar (nthcdr 1 ,data) ,mark))
2855
2856 (defmacro gnus-data-pos (data)
2857   `(nth 2 ,data))
2858
2859 (defmacro gnus-data-set-pos (data pos)
2860   `(setcar (nthcdr 2 ,data) ,pos))
2861
2862 (defmacro gnus-data-header (data)
2863   `(nth 3 ,data))
2864
2865 (defmacro gnus-data-set-header (data header)
2866   `(setf (nth 3 ,data) ,header))
2867
2868 (defmacro gnus-data-level (data)
2869   `(nth 4 ,data))
2870
2871 (defmacro gnus-data-unread-p (data)
2872   `(= (nth 1 ,data) gnus-unread-mark))
2873
2874 (defmacro gnus-data-read-p (data)
2875   `(/= (nth 1 ,data) gnus-unread-mark))
2876
2877 (defmacro gnus-data-pseudo-p (data)
2878   `(consp (nth 3 ,data)))
2879
2880 (defmacro gnus-data-find (number)
2881   `(assq ,number gnus-newsgroup-data))
2882
2883 (defmacro gnus-data-find-list (number &optional data)
2884   `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2885      (memq (assq ,number bdata)
2886            bdata)))
2887
2888 (defmacro gnus-data-make (number mark pos header level)
2889   `(list ,number ,mark ,pos ,header ,level))
2890
2891 (defun gnus-data-enter (after-article number mark pos header level offset)
2892   (let ((data (gnus-data-find-list after-article)))
2893     (unless data
2894       (error "No such article: %d" after-article))
2895     (setcdr data (cons (gnus-data-make number mark pos header level)
2896                        (cdr data)))
2897     (setq gnus-newsgroup-data-reverse nil)
2898     (gnus-data-update-list (cddr data) offset)))
2899
2900 (defun gnus-data-enter-list (after-article list &optional offset)
2901   (when list
2902     (let ((data (and after-article (gnus-data-find-list after-article)))
2903           (ilist list))
2904       (if (not (or data
2905                    after-article))
2906           (let ((odata gnus-newsgroup-data))
2907             (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2908             (when offset
2909               (gnus-data-update-list odata offset)))
2910         ;; Find the last element in the list to be spliced into the main
2911         ;; list.
2912         (setq list (last list))
2913         (if (not data)
2914             (progn
2915               (setcdr list gnus-newsgroup-data)
2916               (setq gnus-newsgroup-data ilist)
2917               (when offset
2918                 (gnus-data-update-list (cdr list) offset)))
2919           (setcdr list (cdr data))
2920           (setcdr data ilist)
2921           (when offset
2922             (gnus-data-update-list (cdr list) offset))))
2923       (setq gnus-newsgroup-data-reverse nil))))
2924
2925 (defun gnus-data-remove (article &optional offset)
2926   (let ((data gnus-newsgroup-data))
2927     (if (= (gnus-data-number (car data)) article)
2928         (progn
2929           (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2930                 gnus-newsgroup-data-reverse nil)
2931           (when offset
2932             (gnus-data-update-list gnus-newsgroup-data offset)))
2933       (while (cdr data)
2934         (when (= (gnus-data-number (cadr data)) article)
2935           (setcdr data (cddr data))
2936           (when offset
2937             (gnus-data-update-list (cdr data) offset))
2938           (setq data nil
2939                 gnus-newsgroup-data-reverse nil))
2940         (setq data (cdr data))))))
2941
2942 (defmacro gnus-data-list (backward)
2943   `(if ,backward
2944        (or gnus-newsgroup-data-reverse
2945            (setq gnus-newsgroup-data-reverse
2946                  (reverse gnus-newsgroup-data)))
2947      gnus-newsgroup-data))
2948
2949 (defun gnus-data-update-list (data offset)
2950   "Add OFFSET to the POS of all data entries in DATA."
2951   (setq gnus-newsgroup-data-reverse nil)
2952   (while data
2953     (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2954     (setq data (cdr data))))
2955
2956 (defun gnus-summary-article-pseudo-p (article)
2957   "Say whether this article is a pseudo article or not."
2958   (not (vectorp (gnus-data-header (gnus-data-find article)))))
2959
2960 (defmacro gnus-summary-article-sparse-p (article)
2961   "Say whether this article is a sparse article or not."
2962   `(memq ,article gnus-newsgroup-sparse))
2963
2964 (defmacro gnus-summary-article-ancient-p (article)
2965   "Say whether this article is a sparse article or not."
2966   `(memq ,article gnus-newsgroup-ancient))
2967
2968 (defun gnus-article-parent-p (number)
2969   "Say whether this article is a parent or not."
2970   (let ((data (gnus-data-find-list number)))
2971     (and (cdr data)              ; There has to be an article after...
2972          (< (gnus-data-level (car data)) ; And it has to have a higher level.
2973             (gnus-data-level (nth 1 data))))))
2974
2975 (defun gnus-article-children (number)
2976   "Return a list of all children to NUMBER."
2977   (let* ((data (gnus-data-find-list number))
2978          (level (gnus-data-level (car data)))
2979          children)
2980     (setq data (cdr data))
2981     (while (and data
2982                 (= (gnus-data-level (car data)) (1+ level)))
2983       (push (gnus-data-number (car data)) children)
2984       (setq data (cdr data)))
2985     children))
2986
2987 (defmacro gnus-summary-skip-intangible ()
2988   "If the current article is intangible, then jump to a different article."
2989   '(let ((to (get-text-property (point) 'gnus-intangible)))
2990      (and to (gnus-summary-goto-subject to))))
2991
2992 (defmacro gnus-summary-article-intangible-p ()
2993   "Say whether this article is intangible or not."
2994   '(get-text-property (point) 'gnus-intangible))
2995
2996 (defun gnus-article-read-p (article)
2997   "Say whether ARTICLE is read or not."
2998   (not (or (memq article gnus-newsgroup-marked)
2999            (memq article gnus-newsgroup-spam-marked)
3000            (memq article gnus-newsgroup-unreads)
3001            (memq article gnus-newsgroup-unselected)
3002            (memq article gnus-newsgroup-dormant))))
3003
3004 ;; Some summary mode macros.
3005
3006 (defmacro gnus-summary-article-number ()
3007   "The article number of the article on the current line.
3008 If there isn't an article number here, then we return the current
3009 article number."
3010   '(progn
3011      (gnus-summary-skip-intangible)
3012      (or (get-text-property (point) 'gnus-number)
3013          (gnus-summary-last-subject))))
3014
3015 (defmacro gnus-summary-article-header (&optional number)
3016   "Return the header of article NUMBER."
3017   `(gnus-data-header (gnus-data-find
3018                       ,(or number '(gnus-summary-article-number)))))
3019
3020 (defmacro gnus-summary-thread-level (&optional number)
3021   "Return the level of thread that starts with article NUMBER."
3022   `(if (and (eq gnus-summary-make-false-root 'dummy)
3023             (get-text-property (point) 'gnus-intangible))
3024        0
3025      (gnus-data-level (gnus-data-find
3026                        ,(or number '(gnus-summary-article-number))))))
3027
3028 (defmacro gnus-summary-article-mark (&optional number)
3029   "Return the mark of article NUMBER."
3030   `(gnus-data-mark (gnus-data-find
3031                     ,(or number '(gnus-summary-article-number)))))
3032
3033 (defmacro gnus-summary-article-pos (&optional number)
3034   "Return the position of the line of article NUMBER."
3035   `(gnus-data-pos (gnus-data-find
3036                    ,(or number '(gnus-summary-article-number)))))
3037
3038 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3039 (defmacro gnus-summary-article-subject (&optional number)
3040   "Return current subject string or nil if nothing."
3041   `(let ((headers
3042           ,(if number
3043                `(gnus-data-header (assq ,number gnus-newsgroup-data))
3044              '(gnus-data-header (assq (gnus-summary-article-number)
3045                                       gnus-newsgroup-data)))))
3046      (and headers
3047           (vectorp headers)
3048           (mail-header-subject headers))))
3049
3050 (defmacro gnus-summary-article-score (&optional number)
3051   "Return current article score."
3052   `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3053                   gnus-newsgroup-scored))
3054        gnus-summary-default-score 0))
3055
3056 (defun gnus-summary-article-children (&optional number)
3057   "Return a list of article numbers that are children of article NUMBER."
3058   (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3059          (level (gnus-data-level (car data)))
3060          l children)
3061     (while (and (setq data (cdr data))
3062                 (> (setq l (gnus-data-level (car data))) level))
3063       (and (= (1+ level) l)
3064            (push (gnus-data-number (car data))
3065                  children)))
3066     (nreverse children)))
3067
3068 (defun gnus-summary-article-parent (&optional number)
3069   "Return the article number of the parent of article NUMBER."
3070   (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3071                                     (gnus-data-list t)))
3072          (level (gnus-data-level (car data))))
3073     (if (zerop level)
3074         ()                              ; This is a root.
3075       ;; We search until we find an article with a level less than
3076       ;; this one.  That function has to be the parent.
3077       (while (and (setq data (cdr data))
3078                   (not (< (gnus-data-level (car data)) level))))
3079       (and data (gnus-data-number (car data))))))
3080
3081 (defun gnus-unread-mark-p (mark)
3082   "Say whether MARK is the unread mark."
3083   (= mark gnus-unread-mark))
3084
3085 (defun gnus-read-mark-p (mark)
3086   "Say whether MARK is one of the marks that mark as read.
3087 This is all marks except unread, ticked, dormant, and expirable."
3088   (not (or (= mark gnus-unread-mark)
3089            (= mark gnus-ticked-mark)
3090            (= mark gnus-spam-mark)
3091            (= mark gnus-dormant-mark)
3092            (= mark gnus-expirable-mark))))
3093
3094 (defmacro gnus-article-mark (number)
3095   "Return the MARK of article NUMBER.
3096 This macro should only be used when computing the mark the \"first\"
3097 time; i.e., when generating the summary lines.  After that,
3098 `gnus-summary-article-mark' should be used to examine the
3099 marks of articles."
3100   `(cond
3101     ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3102     ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3103     ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3104     ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3105     ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3106     ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3107     ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3108     (t (or (cdr (assq ,number gnus-newsgroup-reads))
3109            gnus-ancient-mark))))
3110
3111 ;; Saving hidden threads.
3112
3113 (defmacro gnus-save-hidden-threads (&rest forms)
3114   "Save hidden threads, eval FORMS, and restore the hidden threads."
3115   (let ((config (make-symbol "config")))
3116     `(let ((,config (gnus-hidden-threads-configuration)))
3117        (unwind-protect
3118            (save-excursion
3119              ,@forms)
3120          (gnus-restore-hidden-threads-configuration ,config)))))
3121 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3122 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3123
3124 (defun gnus-data-compute-positions ()
3125   "Compute the positions of all articles."
3126   (setq gnus-newsgroup-data-reverse nil)
3127   (let ((data gnus-newsgroup-data))
3128     (save-excursion
3129       (gnus-save-hidden-threads
3130         (gnus-summary-show-all-threads)
3131         (goto-char (point-min))
3132         (while data
3133           (while (get-text-property (point) 'gnus-intangible)
3134             (forward-line 1))
3135           (gnus-data-set-pos (car data) (+ (point) 3))
3136           (setq data (cdr data))
3137           (forward-line 1))))))
3138
3139 (defun gnus-hidden-threads-configuration ()
3140   "Return the current hidden threads configuration."
3141   (save-excursion
3142     (let (config)
3143       (goto-char (point-min))
3144       (while (search-forward "\r" nil t)
3145         (push (1- (point)) config))
3146       config)))
3147
3148 (defun gnus-restore-hidden-threads-configuration (config)
3149   "Restore hidden threads configuration from CONFIG."
3150   (save-excursion
3151     (let (point buffer-read-only)
3152       (while (setq point (pop config))
3153         (when (and (< point (point-max))
3154                    (goto-char point)
3155                    (eq (char-after) ?\n))
3156           (subst-char-in-region point (1+ point) ?\n ?\r))))))
3157
3158 ;; Various summary mode internalish functions.
3159
3160 (defun gnus-mouse-pick-article (e)
3161   (interactive "e")
3162   (mouse-set-point e)
3163   (gnus-summary-next-page nil t))
3164
3165 (defun gnus-summary-set-display-table ()
3166   "Change the display table.
3167 Odd characters have a tendency to mess
3168 up nicely formatted displays - we make all possible glyphs
3169 display only a single character."
3170
3171   ;; We start from the standard display table, if any.
3172   (let ((table (or (copy-sequence standard-display-table)
3173                    (make-display-table)))
3174         (i 32))
3175     ;; Nix out all the control chars...
3176     (while (>= (setq i (1- i)) 0)
3177       (aset table i [??]))
3178    ;; ... but not newline and cr, of course.  (cr is necessary for the
3179     ;; selective display).
3180     (aset table ?\n nil)
3181     (aset table ?\r nil)
3182     ;; We keep TAB as well.
3183     (aset table ?\t nil)
3184     ;; We nix out any glyphs over 126 that are not set already.
3185     (let ((i 256))
3186       (while (>= (setq i (1- i)) 127)
3187         ;; Only modify if the entry is nil.
3188         (unless (aref table i)
3189           (aset table i [??]))))
3190     (setq buffer-display-table table)))
3191
3192 (defun gnus-summary-set-article-display-arrow (pos)
3193   "Update the overlay arrow to point to line at position POS."
3194   (when (and gnus-summary-display-arrow
3195              (boundp 'overlay-arrow-position)
3196              (boundp 'overlay-arrow-string))
3197     (save-excursion
3198       (goto-char pos)
3199       (beginning-of-line)
3200       (unless overlay-arrow-position
3201         (setq overlay-arrow-position (make-marker)))
3202       (setq overlay-arrow-string "=>"
3203             overlay-arrow-position (set-marker overlay-arrow-position
3204                                                (point)
3205                                                (current-buffer))))))
3206
3207 (defun gnus-summary-setup-buffer (group)
3208   "Initialize summary buffer."
3209   (let ((buffer (gnus-summary-buffer-name group))
3210         (dead-name (concat "*Dead Summary "
3211                            (gnus-group-decoded-name group) "*")))
3212     ;; If a dead summary buffer exists, we kill it.
3213     (when (gnus-buffer-live-p dead-name)
3214       (gnus-kill-buffer dead-name))
3215     (if (get-buffer buffer)
3216         (progn
3217           (set-buffer buffer)
3218           (setq gnus-summary-buffer (current-buffer))
3219           (not gnus-newsgroup-prepared))
3220       ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3221       (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3222       (gnus-summary-mode group)
3223       (when gnus-carpal
3224         (gnus-carpal-setup-buffer 'summary))
3225       (unless gnus-single-article-buffer
3226         (make-local-variable 'gnus-article-buffer)
3227         (make-local-variable 'gnus-article-current)
3228         (make-local-variable 'gnus-original-article-buffer))
3229       (setq gnus-newsgroup-name group)
3230       ;; Set any local variables in the group parameters.
3231       (gnus-summary-set-local-parameters gnus-newsgroup-name)
3232       t)))
3233
3234 (defun gnus-set-global-variables ()
3235   "Set the global equivalents of the buffer-local variables.
3236 They are set to the latest values they had.  These reflect the summary
3237 buffer that was in action when the last article was fetched."
3238   (when (eq major-mode 'gnus-summary-mode)
3239     (setq gnus-summary-buffer (current-buffer))
3240     (let ((name gnus-newsgroup-name)
3241           (marked gnus-newsgroup-marked)
3242           (spam gnus-newsgroup-spam-marked)
3243           (unread gnus-newsgroup-unreads)
3244           (headers gnus-current-headers)
3245           (data gnus-newsgroup-data)
3246           (summary gnus-summary-buffer)
3247           (article-buffer gnus-article-buffer)
3248           (original gnus-original-article-buffer)
3249           (gac gnus-article-current)
3250           (reffed gnus-reffed-article-number)
3251           (score-file gnus-current-score-file)
3252           (default-charset gnus-newsgroup-charset)
3253           vlist)
3254       (let ((locals gnus-newsgroup-variables))
3255         (while locals
3256           (if (consp (car locals))
3257               (push (eval (caar locals)) vlist)
3258             (push (eval (car locals)) vlist))
3259           (setq locals (cdr locals)))
3260         (setq vlist (nreverse vlist)))
3261       (with-current-buffer gnus-group-buffer
3262         (setq gnus-newsgroup-name name
3263               gnus-newsgroup-marked marked
3264               gnus-newsgroup-spam-marked spam
3265               gnus-newsgroup-unreads unread
3266               gnus-current-headers headers
3267               gnus-newsgroup-data data
3268               gnus-article-current gac
3269               gnus-summary-buffer summary
3270               gnus-article-buffer article-buffer
3271               gnus-original-article-buffer original
3272               gnus-reffed-article-number reffed
3273               gnus-current-score-file score-file
3274               gnus-newsgroup-charset default-charset)
3275         (let ((locals gnus-newsgroup-variables))
3276           (while locals
3277             (if (consp (car locals))
3278                 (set (caar locals) (pop vlist))
3279               (set (car locals) (pop vlist)))
3280             (setq locals (cdr locals))))
3281         ;; The article buffer also has local variables.
3282         (when (gnus-buffer-live-p gnus-article-buffer)
3283           (set-buffer gnus-article-buffer)
3284           (setq gnus-summary-buffer summary))))))
3285
3286 (defun gnus-summary-article-unread-p (article)
3287   "Say whether ARTICLE is unread or not."
3288   (memq article gnus-newsgroup-unreads))
3289
3290 (defun gnus-summary-first-article-p (&optional article)
3291   "Return whether ARTICLE is the first article in the buffer."
3292   (if (not (setq article (or article (gnus-summary-article-number))))
3293       nil
3294     (eq article (caar gnus-newsgroup-data))))
3295
3296 (defun gnus-summary-last-article-p (&optional article)
3297   "Return whether ARTICLE is the last article in the buffer."
3298   (if (not (setq article (or article (gnus-summary-article-number))))
3299       ;; All non-existent numbers are the last article.  :-)
3300       t
3301     (not (cdr (gnus-data-find-list article)))))
3302
3303 (defun gnus-make-thread-indent-array ()
3304   (let ((n 200))
3305     (unless (and gnus-thread-indent-array
3306                  (= gnus-thread-indent-level gnus-thread-indent-array-level))
3307       (setq gnus-thread-indent-array (make-vector 201 "")
3308             gnus-thread-indent-array-level gnus-thread-indent-level)
3309       (while (>= n 0)
3310         (aset gnus-thread-indent-array n
3311               (make-string (* n gnus-thread-indent-level) ? ))
3312         (setq n (1- n))))))
3313
3314 (defun gnus-update-summary-mark-positions ()
3315   "Compute where the summary marks are to go."
3316   (save-excursion
3317     (when (gnus-buffer-exists-p gnus-summary-buffer)
3318       (set-buffer gnus-summary-buffer))
3319     (let ((spec gnus-summary-line-format-spec)
3320           pos)
3321       (save-excursion
3322         (gnus-set-work-buffer)
3323         (let ((gnus-tmp-unread ?Z)
3324               (gnus-replied-mark ?Z)
3325               (gnus-score-below-mark ?Z)
3326               (gnus-score-over-mark ?Z)
3327               (gnus-undownloaded-mark ?Z)
3328               (gnus-summary-line-format-spec spec)
3329               (gnus-newsgroup-downloadable '(0))
3330               (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3331               case-fold-search ignores)
3332           ;; Here, all marks are bound to Z.
3333           (gnus-summary-insert-line header
3334                                     0 nil t gnus-tmp-unread t nil "" nil 1)
3335           (goto-char (point-min))
3336           ;; Memorize the positions of the same characters as dummy marks.
3337           (while (re-search-forward "[A-D]" nil t)
3338             (push (point) ignores))
3339           (erase-buffer)
3340           ;; We use A-D as dummy marks in order to know column positions
3341           ;; where marks should be inserted.
3342           (setq gnus-tmp-unread ?A
3343                 gnus-replied-mark ?B
3344                 gnus-score-below-mark ?C
3345                 gnus-score-over-mark ?C
3346                 gnus-undownloaded-mark ?D)
3347           (gnus-summary-insert-line header
3348                                     0 nil t gnus-tmp-unread t nil "" nil 1)
3349           ;; Ignore characters which aren't dummy marks.
3350           (dolist (p ignores)
3351             (delete-region (goto-char (1- p)) p)
3352             (insert ?Z))
3353           (goto-char (point-min))
3354           (setq pos (list (cons 'unread
3355                                 (and (search-forward "A" nil t)
3356                                      (- (point) (point-min) 1)))))
3357           (goto-char (point-min))
3358           (push (cons 'replied (and (search-forward "B" nil t)
3359                                     (- (point) (point-min) 1)))
3360                 pos)
3361           (goto-char (point-min))
3362           (push (cons 'score (and (search-forward "C" nil t)
3363                                   (- (point) (point-min) 1)))
3364                 pos)
3365           (goto-char (point-min))
3366           (push (cons 'download (and (search-forward "D" nil t)
3367                                      (- (point) (point-min) 1)))
3368                 pos)))
3369       (setq gnus-summary-mark-positions pos))))
3370
3371 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3372   "Insert a dummy root in the summary buffer."
3373   (beginning-of-line)
3374   (gnus-add-text-properties
3375    (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3376    (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3377
3378 (defun gnus-summary-extract-address-component (from)
3379   (or (car (funcall gnus-extract-address-components from))
3380       from))
3381
3382 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3383   (let ((mail-parse-charset gnus-newsgroup-charset)
3384         ; Is it really necessary to do this next part for each summary line?
3385         ; Luckily, doesn't seem to slow things down much.
3386         (mail-parse-ignored-charsets
3387          (with-current-buffer gnus-summary-buffer
3388            gnus-newsgroup-ignored-charsets)))
3389     (or
3390      (and gnus-ignored-from-addresses
3391           (string-match gnus-ignored-from-addresses gnus-tmp-from)
3392           (let ((extra-headers (mail-header-extra header))
3393                 to
3394                 newsgroups)
3395             (cond
3396              ((setq to (cdr (assq 'To extra-headers)))
3397               (concat gnus-summary-to-prefix
3398                       (inline
3399                         (gnus-summary-extract-address-component
3400                          (funcall gnus-decode-encoded-word-function to)))))
3401              ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3402               (concat gnus-summary-newsgroup-prefix newsgroups)))))
3403      (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3404
3405 (defun gnus-summary-insert-line (gnus-tmp-header
3406                                  gnus-tmp-level gnus-tmp-current
3407                                  undownloaded gnus-tmp-unread gnus-tmp-replied
3408                                  gnus-tmp-expirable gnus-tmp-subject-or-nil
3409                                  &optional gnus-tmp-dummy gnus-tmp-score
3410                                  gnus-tmp-process)
3411   (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3412          (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3413          (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3414          (gnus-tmp-score-char
3415           (if (or (null gnus-summary-default-score)
3416                   (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3417                       gnus-summary-zcore-fuzz))
3418               ?                         ;Whitespace
3419             (if (< gnus-tmp-score gnus-summary-default-score)
3420                 gnus-score-below-mark gnus-score-over-mark)))
3421          (gnus-tmp-number (mail-header-number gnus-tmp-header))
3422          (gnus-tmp-replied
3423           (cond (gnus-tmp-process gnus-process-mark)
3424                 ((memq gnus-tmp-current gnus-newsgroup-cached)
3425                  gnus-cached-mark)
3426                 (gnus-tmp-replied gnus-replied-mark)
3427                 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3428                  gnus-forwarded-mark)
3429                 ((memq gnus-tmp-current gnus-newsgroup-saved)
3430                  gnus-saved-mark)
3431                 ((memq gnus-tmp-number gnus-newsgroup-recent)
3432                  gnus-recent-mark)
3433                 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3434                  gnus-unseen-mark)
3435                 (t gnus-no-mark)))
3436          (gnus-tmp-downloaded
3437           (cond (undownloaded
3438                  gnus-undownloaded-mark)
3439                 (gnus-newsgroup-agentized
3440                  gnus-downloaded-mark)
3441                 (t
3442                  gnus-no-mark)))
3443          (gnus-tmp-from (mail-header-from gnus-tmp-header))
3444          (gnus-tmp-name
3445           (cond
3446            ((string-match "<[^>]+> *$" gnus-tmp-from)
3447             (let ((beg (match-beginning 0)))
3448               (or (and (string-match "^\".+\"" gnus-tmp-from)
3449                        (substring gnus-tmp-from 1 (1- (match-end 0))))
3450                   (substring gnus-tmp-from 0 beg))))
3451            ((string-match "(.+)" gnus-tmp-from)
3452             (substring gnus-tmp-from
3453                        (1+ (match-beginning 0)) (1- (match-end 0))))
3454            (t gnus-tmp-from)))
3455          (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3456          (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3457          (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3458          (buffer-read-only nil))
3459     (when (string= gnus-tmp-name "")
3460       (setq gnus-tmp-name gnus-tmp-from))
3461     (unless (numberp gnus-tmp-lines)
3462       (setq gnus-tmp-lines -1))
3463     (if (= gnus-tmp-lines -1)
3464         (setq gnus-tmp-lines "?")
3465       (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3466       (gnus-put-text-property
3467      (point)
3468      (progn (eval gnus-summary-line-format-spec) (point))
3469        'gnus-number gnus-tmp-number)
3470     (when (gnus-visual-p 'summary-highlight 'highlight)
3471       (forward-line -1)
3472       (gnus-run-hooks 'gnus-summary-update-hook)
3473       (forward-line 1))))
3474
3475 (defun gnus-summary-update-line (&optional dont-update)
3476   "Update summary line after change."
3477   (when (and gnus-summary-default-score
3478              (not gnus-summary-inhibit-highlight))
3479     (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3480            (article (gnus-summary-article-number))
3481            (score (gnus-summary-article-score article)))
3482       (unless dont-update
3483         (if (and gnus-summary-mark-below
3484                  (< (gnus-summary-article-score)
3485                     gnus-summary-mark-below))
3486             ;; This article has a low score, so we mark it as read.
3487             (when (memq article gnus-newsgroup-unreads)
3488               (gnus-summary-mark-article-as-read gnus-low-score-mark))
3489           (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3490             ;; This article was previously marked as read on account
3491             ;; of a low score, but now it has risen, so we mark it as
3492             ;; unread.
3493             (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3494         (gnus-summary-update-mark
3495          (if (or (null gnus-summary-default-score)
3496                  (<= (abs (- score gnus-summary-default-score))
3497                      gnus-summary-zcore-fuzz))
3498              ?                          ;Whitespace
3499            (if (< score gnus-summary-default-score)
3500                gnus-score-below-mark gnus-score-over-mark))
3501          'score))
3502       ;; Do visual highlighting.
3503       (when (gnus-visual-p 'summary-highlight 'highlight)
3504         (gnus-run-hooks 'gnus-summary-update-hook)))))
3505
3506 (defvar gnus-tmp-new-adopts nil)
3507
3508 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3509   "Return the number of articles in THREAD.
3510 This may be 0 in some cases -- if none of the articles in
3511 the thread are to be displayed."
3512   (let* ((number
3513          ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3514           (cond
3515            ((not (listp thread))
3516             1)
3517            ((and (consp thread) (cdr thread))
3518             (apply
3519              '+ 1 (mapcar
3520                    'gnus-summary-number-of-articles-in-thread (cdr thread))))
3521            ((null thread)
3522             1)
3523            ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3524             1)
3525            (t 0))))
3526     (when (and level (zerop level) gnus-tmp-new-adopts)
3527       (incf number
3528             (apply '+ (mapcar
3529                        'gnus-summary-number-of-articles-in-thread
3530                        gnus-tmp-new-adopts))))
3531     (if char
3532         (if (> number 1) gnus-not-empty-thread-mark
3533           gnus-empty-thread-mark)
3534       number)))
3535
3536 (defsubst gnus-summary-line-message-size (head)
3537   "Return pretty-printed version of message size.
3538 This function is intended to be used in
3539 `gnus-summary-line-format-alist'."
3540   (let ((c (or (mail-header-chars head) -1)))
3541     (cond ((< c 0) "n/a&qu