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