Fix some mis-spellings of "precede" that are not in emacs-23 branch.
[bpt/emacs.git] / lisp / gnus / gnus-sum.el
CommitLineData
eec82323 1;;; gnus-sum.el --- summary mode commands for Gnus
e84b4b86 2
73b0cd50 3;; Copyright (C) 1996-2011 Free Software Foundation, Inc.
eec82323 4
6748645f 5;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
eec82323
LMI
6;; Keywords: news
7
8;; This file is part of GNU Emacs.
9
5e809f55 10;; GNU Emacs is free software: you can redistribute it and/or modify
eec82323 11;; it under the terms of the GNU General Public License as published by
5e809f55
GM
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
eec82323
LMI
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
01ccbb85 17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eec82323
LMI
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
5e809f55 21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
eec82323
LMI
22
23;;; Commentary:
24
25;;; Code:
26
f0b7f5a8 27;; For Emacs <22.2 and XEmacs.
d09ae6ca
GM
28(eval-and-compile
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
23f87bed 30(eval-when-compile
9efa445f 31 (require 'cl))
d029b5d2
KY
32(eval-when-compile
33 (when (featurep 'xemacs)
34 (require 'easy-mmode))) ; for `define-minor-mode'
9efa445f
DN
35
36(defvar tool-bar-mode)
37(defvar gnus-tmp-header)
5ab7173c 38
eec82323
LMI
39(require 'gnus)
40(require 'gnus-group)
41(require 'gnus-spec)
42(require 'gnus-range)
43(require 'gnus-int)
44(require 'gnus-undo)
6748645f 45(require 'gnus-util)
18c06a99 46(require 'gmm-utils)
16409b0b 47(require 'mm-decode)
08c9a385 48(require 'nnoo)
23f87bed 49
6748645f 50(autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
d4dfaa19 51(autoload 'gnus-cache-write-active "gnus-cache")
23f87bed
MB
52(autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
53(autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
531e5812 54(autoload 'gnus-pick-line-number "gnus-salt" nil t)
08c9a385 55(autoload 'mm-uu-dissect "mm-uu")
23f87bed
MB
56(autoload 'gnus-article-outlook-deuglify-article "deuglify"
57 "Deuglify broken Outlook (Express) articles and redisplay."
58 t)
59(autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
60(autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
61(autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
1b811c90
AC
62(autoload 'nnir-article-rsv "nnir" nil nil 'macro)
63(autoload 'nnir-article-group "nnir" nil nil 'macro)
eec82323
LMI
64
65(defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67If nil, the summary will become a \"*Dead Summary*\" buffer, and
68it will be killed sometime later."
69 :group 'gnus-summary-exit
70 :type 'boolean)
71
01c52d31
MB
72(defcustom gnus-summary-next-group-on-exit t
73 "If non-nil, go to the next unread newsgroup on summary exit.
74See `gnus-group-goto-unread'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-exit
330f707b 77 :version "23.1" ;; No Gnus
01c52d31
MB
78 :type 'boolean)
79
b1992461
KY
80(defcustom gnus-summary-stop-at-end-of-message nil
81 "If non-nil, don't select the next message when using `SPC'."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-summary-maneuvering
1a10d421 84 :version "24.1"
b1992461
KY
85 :type 'boolean)
86
eec82323
LMI
87(defcustom gnus-fetch-old-headers nil
88 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
01c52d31
MB
89If an unread article in the group refers to an older, already
90read (or just marked as read) article, the old article will not
91normally be displayed in the Summary buffer. If this variable is
92t, Gnus will attempt to grab the headers to the old articles, and
93thereby build complete threads. If it has the value `some', all
94old headers will be fetched but only enough headers to connect
95otherwise loose threads will be displayed. This variable can
96also be a number. In that case, no more than that number of old
97headers will be fetched. If it has the value `invisible', all
6748645f 98old headers will be fetched, but none will be displayed.
eec82323 99
01c52d31
MB
100The server has to support NOV for any of this to work.
101
102This feature can seriously impact performance it ignores all
f394fa25
MB
103locally cached header entries. Setting it to t for groups for a
104server that doesn't expire articles (such as news.gmane.org),
105leads to very slow summary generation."
eec82323
LMI
106 :group 'gnus-thread
107 :type '(choice (const :tag "off" nil)
1232b9cb 108 (const :tag "on" t)
eec82323 109 (const some)
1232b9cb 110 (const invisible)
eec82323
LMI
111 number
112 (sexp :menu-tag "other" t)))
113
01c52d31 114(defcustom gnus-refer-thread-limit 500
6748645f
LMI
115 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
116If t, fetch all the available old headers."
117 :group 'gnus-thread
118 :type '(choice number
119 (sexp :menu-tag "other" t)))
120
eec82323
LMI
121(defcustom gnus-summary-make-false-root 'adopt
122 "*nil means that Gnus won't gather loose threads.
123If the root of a thread has expired or been read in a previous
124session, the information necessary to build a complete thread has been
125lost. Instead of having many small sub-threads from this original thread
126scattered all over the summary buffer, Gnus can gather them.
127
128If non-nil, Gnus will try to gather all loose sub-threads from an
129original thread into one large thread.
130
131If this variable is non-nil, it should be one of `none', `adopt',
132`dummy' or `empty'.
133
134If this variable is `none', Gnus will not make a false root, but just
135present the sub-threads after another.
136If this variable is `dummy', Gnus will create a dummy root that will
137have all the sub-threads as children.
138If this variable is `adopt', Gnus will make one of the \"children\"
139the parent and mark all the step-children as such.
140If this variable is `empty', the \"children\" are printed with empty
01ccbb85 141subject fields. (Or rather, they will be printed with a string
eec82323
LMI
142given by the `gnus-summary-same-subject' variable.)"
143 :group 'gnus-thread
144 :type '(choice (const :tag "off" nil)
145 (const none)
146 (const dummy)
147 (const adopt)
148 (const empty)))
149
23f87bed
MB
150(defcustom gnus-summary-make-false-root-always nil
151 "Always make a false dummy root."
bf247b6e 152 :version "22.1"
23f87bed
MB
153 :group 'gnus-thread
154 :type 'boolean)
155
eec82323
LMI
156(defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
157 "*A regexp to match subjects to be excluded from loose thread gathering.
158As loose thread gathering is done on subjects only, that means that
159there can be many false gatherings performed. By rooting out certain
160common subjects, gathering might become saner."
161 :group 'gnus-thread
162 :type 'regexp)
163
164(defcustom gnus-summary-gather-subject-limit nil
165 "*Maximum length of subject comparisons when gathering loose threads.
166Use nil to compare full subjects. Setting this variable to a low
167number will help gather threads that have been corrupted by
168newsreaders chopping off subject lines, but it might also mean that
169unrelated articles that have subject that happen to begin with the
170same few characters will be incorrectly gathered.
171
172If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
173comparing subjects."
174 :group 'gnus-thread
175 :type '(choice (const :tag "off" nil)
176 (const fuzzy)
177 (sexp :menu-tag "on" t)))
178
6748645f
LMI
179(defcustom gnus-simplify-subject-functions nil
180 "List of functions taking a string argument that simplify subjects.
181The functions are applied recursively.
182
23f87bed
MB
183Useful functions to put in this list include:
184`gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
185`gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
6748645f
LMI
186 :group 'gnus-thread
187 :type '(repeat function))
188
eec82323 189(defcustom gnus-simplify-ignored-prefixes nil
23f87bed 190 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
eec82323
LMI
191 :group 'gnus-thread
192 :type '(choice (const :tag "off" nil)
193 regexp))
194
195(defcustom gnus-build-sparse-threads nil
196 "*If non-nil, fill in the gaps in threads.
197If `some', only fill in the gaps that are needed to tie loose threads
198together. If `more', fill in all leaf nodes that Gnus can find. If
199non-nil and non-`some', fill in all gaps that Gnus manages to guess."
200 :group 'gnus-thread
201 :type '(choice (const :tag "off" nil)
202 (const some)
203 (const more)
204 (sexp :menu-tag "all" t)))
205
206(defcustom gnus-summary-thread-gathering-function
207 'gnus-gather-threads-by-subject
6748645f 208 "*Function used for gathering loose threads.
eec82323
LMI
209There are two pre-defined functions: `gnus-gather-threads-by-subject',
210which only takes Subjects into consideration; and
211`gnus-gather-threads-by-references', which compared the References
212headers of the articles to find matches."
213 :group 'gnus-thread
22115a9e
RS
214 :type '(radio (function-item gnus-gather-threads-by-subject)
215 (function-item gnus-gather-threads-by-references)
216 (function :tag "other")))
eec82323 217
eec82323
LMI
218(defcustom gnus-summary-same-subject ""
219 "*String indicating that the current article has the same subject as the previous.
220This variable will only be used if the value of
221`gnus-summary-make-false-root' is `empty'."
222 :group 'gnus-summary-format
223 :type 'string)
224
1d297c49 225(defcustom gnus-summary-goto-unread nil
16409b0b
GM
226 "*If t, many commands will go to the next unread article.
227This applies to marking commands as well as other commands that
228\"naturally\" select the next article, like, for instance, `SPC' at
229the end of an article.
230
231If nil, the marking commands do NOT go to the next unread article
2642ac8f 232\(they go to the next article instead). If `never', commands that
16409b0b
GM
233usually go to the next unread article, will go to the next article,
234whether it is read or not."
1d297c49 235 :version "24.1"
eec82323
LMI
236 :group 'gnus-summary-marks
237 :link '(custom-manual "(gnus)Setting Marks")
238 :type '(choice (const :tag "off" nil)
239 (const never)
240 (sexp :menu-tag "on" t)))
241
242(defcustom gnus-summary-default-score 0
243 "*Default article score level.
244All scores generated by the score files will be added to this score.
245If this variable is nil, scoring will be disabled."
246 :group 'gnus-score-default
247 :type '(choice (const :tag "disable")
248 integer))
249
23f87bed
MB
250(defcustom gnus-summary-default-high-score 0
251 "*Default threshold for a high scored article.
252An article will be highlighted as high scored if its score is greater
253than this score."
bf247b6e 254 :version "22.1"
23f87bed
MB
255 :group 'gnus-score-default
256 :type 'integer)
257
258(defcustom gnus-summary-default-low-score 0
259 "*Default threshold for a low scored article.
260An article will be highlighted as low scored if its score is smaller
261than this score."
bf247b6e 262 :version "22.1"
23f87bed
MB
263 :group 'gnus-score-default
264 :type 'integer)
265
eec82323
LMI
266(defcustom gnus-summary-zcore-fuzz 0
267 "*Fuzziness factor for the zcore in the summary buffer.
268Articles with scores closer than this to `gnus-summary-default-score'
269will not be marked."
270 :group 'gnus-summary-format
271 :type 'integer)
272
273(defcustom gnus-simplify-subject-fuzzy-regexp nil
274 "*Strings to be removed when doing fuzzy matches.
275This can either be a regular expression or list of regular expressions
276that will be removed from subject strings if fuzzy subject
277simplification is selected."
278 :group 'gnus-thread
279 :type '(repeat regexp))
280
281(defcustom gnus-show-threads t
282 "*If non-nil, display threads in summary mode."
283 :group 'gnus-thread
284 :type 'boolean)
285
286(defcustom gnus-thread-hide-subtree nil
287 "*If non-nil, hide all threads initially.
23f87bed 288This can be a predicate specifier which says which threads to hide.
eec82323 289If threads are hidden, you have to run the command
4a2358e9 290`gnus-summary-show-thread' by hand or select an article."
eec82323 291 :group 'gnus-thread
23f87bed
MB
292 :type '(radio (sexp :format "Non-nil\n"
293 :match (lambda (widget value)
294 (not (or (consp value) (functionp value))))
295 :value t)
296 (const nil)
ad136a7c 297 (sexp :tag "Predicate specifier")))
eec82323
LMI
298
299(defcustom gnus-thread-hide-killed t
300 "*If non-nil, hide killed threads automatically."
301 :group 'gnus-thread
302 :type 'boolean)
303
6748645f
LMI
304(defcustom gnus-thread-ignore-subject t
305 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
306If nil, articles that have different subjects from their parents will
307start separate threads."
eec82323
LMI
308 :group 'gnus-thread
309 :type 'boolean)
310
311(defcustom gnus-thread-operation-ignore-subject t
312 "*If non-nil, subjects will be ignored when doing thread commands.
313This affects commands like `gnus-summary-kill-thread' and
314`gnus-summary-lower-thread'.
315
316If this variable is nil, articles in the same thread with different
317subjects will not be included in the operation in question. If this
318variable is `fuzzy', only articles that have subjects that are fuzzily
319equal will be included."
320 :group 'gnus-thread
321 :type '(choice (const :tag "off" nil)
322 (const fuzzy)
323 (sexp :tag "on" t)))
324
325(defcustom gnus-thread-indent-level 4
326 "*Number that says how much each sub-thread should be indented."
327 :group 'gnus-thread
328 :type 'integer)
329
330(defcustom gnus-auto-extend-newsgroup t
331 "*If non-nil, extend newsgroup forward and backward when requested."
332 :group 'gnus-summary-choose
333 :type 'boolean)
334
335(defcustom gnus-auto-select-first t
651408cb
MB
336 "If non-nil, select an article on group entry.
337An article is selected automatically when entering a group
338e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
339`gnus-summary-catchup-and-goto-next-group'.
340
341Which article is selected is controlled by the variable
342`gnus-auto-select-subject'.
23f87bed
MB
343
344If you want to prevent automatic selection of articles in some
345newsgroups, set the variable to nil in `gnus-select-group-hook'."
651408cb
MB
346 ;; Commands include...
347 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
348 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
349 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
eec82323
LMI
350 :group 'gnus-group-select
351 :type '(choice (const :tag "none" nil)
23f87bed
MB
352 (sexp :menu-tag "first" t)))
353
a1347097 354(defcustom gnus-auto-select-subject 'unseen-or-unread
23f87bed
MB
355 "*Says what subject to place under point when entering a group.
356
357This variable can either be the symbols `first' (place point on the
358first subject), `unread' (place point on the subject line of the first
359unread article), `best' (place point on the subject line of the
360higest-scored article), `unseen' (place point on the subject line of
99b5aab7 361the first unseen article), `unseen-or-unread' (place point on the subject
647559c2 362line of the first unseen article or, if all articles have been seen, on the
23f87bed
MB
363subject line of the first unread article), or a function to be called to
364place point on some subject line."
a1347097 365 :version "24.1"
23f87bed
MB
366 :group 'gnus-group-select
367 :type '(choice (const best)
368 (const unread)
369 (const first)
370 (const unseen)
371 (const unseen-or-unread)))
eec82323
LMI
372
373(defcustom gnus-auto-select-next t
374 "*If non-nil, offer to go to the next group from the end of the previous.
375If the value is t and the next newsgroup is empty, Gnus will exit
23f87bed
MB
376summary mode and go back to group mode. If the value is neither nil
377nor t, Gnus will select the following unread newsgroup. In
eec82323
LMI
378particular, if the value is the symbol `quietly', the next unread
379newsgroup will be selected without any confirmation, and if it is
380`almost-quietly', the next group will be selected without any
381confirmation if you are located on the last article in the group.
23f87bed 382Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
eec82323
LMI
383will go to the next group without confirmation."
384 :group 'gnus-summary-maneuvering
385 :type '(choice (const :tag "off" nil)
386 (const quietly)
387 (const almost-quietly)
388 (const slightly-quietly)
389 (sexp :menu-tag "on" t)))
390
391(defcustom gnus-auto-select-same nil
6748645f
LMI
392 "*If non-nil, select the next article with the same subject.
393If there are no more articles with the same subject, go to
394the first unread article."
eec82323
LMI
395 :group 'gnus-summary-maneuvering
396 :type 'boolean)
397
01c52d31
MB
398(defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
399 "What article should be selected after exiting an ephemeral group.
400Valid values include:
401
402`next'
403 Select the next article.
404`next-unread'
405 Select the next unread article.
406`next-noselect'
407 Move the cursor to the next article. This is the default.
408`next-unread-noselect'
409 Move the cursor to the next unread article.
410
411If it has any other value or there is no next (unread) article, the
412article selected before entering to the ephemeral group will appear."
330f707b 413 :version "23.1" ;; No Gnus
01c52d31
MB
414 :group 'gnus-summary-maneuvering
415 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
416 (const next) (const next-unread)
417 (const next-noselect) (const next-unread-noselect)
418 (sexp :tag "other" :value nil)))
419
23f87bed
MB
420(defcustom gnus-auto-goto-ignores 'unfetched
421 "*Says how to handle unfetched articles when maneuvering.
422
423This variable can either be the symbols nil (maneuver to any
424article), `undownloaded' (maneuvering while unplugged ignores articles
425that have not been fetched), `always-undownloaded' (maneuvering always
426ignores articles that have not been fetched), `unfetched' (maneuvering
427ignores articles whose headers have not been fetched).
428
429NOTE: The list of unfetched articles will always be nil when plugged
430and, when unplugged, a subset of the undownloaded article list."
bf247b6e 431 :version "22.1"
23f87bed
MB
432 :group 'gnus-summary-maneuvering
433 :type '(choice (const :tag "None" nil)
434 (const :tag "Undownloaded when unplugged" undownloaded)
435 (const :tag "Undownloaded" always-undownloaded)
436 (const :tag "Unfetched" unfetched)))
437
eec82323
LMI
438(defcustom gnus-summary-check-current nil
439 "*If non-nil, consider the current article when moving.
440The \"unread\" movement commands will stay on the same line if the
441current article is unread."
442 :group 'gnus-summary-maneuvering
443 :type 'boolean)
444
01c52d31 445(defcustom gnus-auto-center-summary 2
eec82323
LMI
446 "*If non-nil, always center the current summary buffer.
447In particular, if `vertical' do only vertical recentering. If non-nil
448and non-`vertical', do both horizontal and vertical recentering."
449 :group 'gnus-summary-maneuvering
450 :type '(choice (const :tag "none" nil)
451 (const vertical)
16409b0b 452 (integer :tag "height")
eec82323
LMI
453 (sexp :menu-tag "both" t)))
454
2d04f304
G
455(defcustom gnus-auto-center-group t
456 "If non-nil, always center the group buffer."
457 :group 'gnus-summary-maneuvering
458 :type 'boolean)
23f87bed 459
eec82323
LMI
460(defcustom gnus-show-all-headers nil
461 "*If non-nil, don't hide any headers."
462 :group 'gnus-article-hiding
463 :group 'gnus-article-headers
464 :type 'boolean)
465
466(defcustom gnus-summary-ignore-duplicates nil
467 "*If non-nil, ignore articles with identical Message-ID headers."
468 :group 'gnus-summary
469 :type 'boolean)
6748645f 470
1d297c49 471(defcustom gnus-single-article-buffer nil
eec82323
LMI
472 "*If non-nil, display all articles in the same buffer.
473If nil, each group will get its own article buffer."
1d297c49 474 :version "24.1"
eec82323
LMI
475 :group 'gnus-article-various
476 :type 'boolean)
477
71e691a5
G
478(defcustom gnus-widen-article-window nil
479 "If non-nil, selecting the article buffer will display only the article buffer."
480 :version "24.1"
481 :group 'gnus-article-various
482 :type 'boolean)
483
eec82323
LMI
484(defcustom gnus-break-pages t
485 "*If non-nil, do page breaking on articles.
486The page delimiter is specified by the `gnus-page-delimiter'
487variable."
488 :group 'gnus-article-various
489 :type 'boolean)
490
eec82323
LMI
491(defcustom gnus-move-split-methods nil
492 "*Variable used to suggest where articles are to be moved to.
23f87bed
MB
493It uses the same syntax as the `gnus-split-methods' variable.
494However, whereas `gnus-split-methods' specifies file names as targets,
495this variable specifies group names."
eec82323 496 :group 'gnus-summary-mail
6748645f
LMI
497 :type '(repeat (choice (list :value (fun) function)
498 (cons :value ("" "") regexp (repeat string))
499 (sexp :value nil))))
eec82323 500
01c52d31
MB
501(defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
502 "Function used to compute default prefix for article move/copy/etc prompts.
503The function should take one argument, a group name, and return a
504string with the suggested prefix."
505 :group 'gnus-summary-mail
506 :type 'function)
507
e62e7654
MB
508;; FIXME: Although the custom type is `character' for the following variables,
509;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
510
23f87bed 511(defcustom gnus-unread-mark ? ;Whitespace
eec82323
LMI
512 "*Mark used for unread articles."
513 :group 'gnus-summary-marks
514 :type 'character)
515
516(defcustom gnus-ticked-mark ?!
517 "*Mark used for ticked articles."
518 :group 'gnus-summary-marks
519 :type 'character)
520
521(defcustom gnus-dormant-mark ??
522 "*Mark used for dormant articles."
523 :group 'gnus-summary-marks
524 :type 'character)
525
526(defcustom gnus-del-mark ?r
527 "*Mark used for del'd articles."
528 :group 'gnus-summary-marks
529 :type 'character)
530
531(defcustom gnus-read-mark ?R
532 "*Mark used for read articles."
533 :group 'gnus-summary-marks
534 :type 'character)
535
536(defcustom gnus-expirable-mark ?E
537 "*Mark used for expirable articles."
538 :group 'gnus-summary-marks
539 :type 'character)
540
541(defcustom gnus-killed-mark ?K
542 "*Mark used for killed articles."
543 :group 'gnus-summary-marks
544 :type 'character)
545
23f87bed
MB
546(defcustom gnus-spam-mark ?$
547 "*Mark used for spam articles."
bf247b6e 548 :version "22.1"
23f87bed
MB
549 :group 'gnus-summary-marks
550 :type 'character)
551
eec82323
LMI
552(defcustom gnus-kill-file-mark ?X
553 "*Mark used for articles killed by kill files."
554 :group 'gnus-summary-marks
555 :type 'character)
556
557(defcustom gnus-low-score-mark ?Y
558 "*Mark used for articles with a low score."
559 :group 'gnus-summary-marks
560 :type 'character)
561
562(defcustom gnus-catchup-mark ?C
563 "*Mark used for articles that are caught up."
564 :group 'gnus-summary-marks
565 :type 'character)
566
567(defcustom gnus-replied-mark ?A
568 "*Mark used for articles that have been replied to."
569 :group 'gnus-summary-marks
570 :type 'character)
571
23f87bed
MB
572(defcustom gnus-forwarded-mark ?F
573 "*Mark used for articles that have been forwarded."
bf247b6e 574 :version "22.1"
23f87bed
MB
575 :group 'gnus-summary-marks
576 :type 'character)
577
578(defcustom gnus-recent-mark ?N
579 "*Mark used for articles that are recent."
bf247b6e 580 :version "22.1"
23f87bed
MB
581 :group 'gnus-summary-marks
582 :type 'character)
583
eec82323
LMI
584(defcustom gnus-cached-mark ?*
585 "*Mark used for articles that are in the cache."
586 :group 'gnus-summary-marks
587 :type 'character)
588
589(defcustom gnus-saved-mark ?S
23f87bed
MB
590 "*Mark used for articles that have been saved."
591 :group 'gnus-summary-marks
592 :type 'character)
593
594(defcustom gnus-unseen-mark ?.
595 "*Mark used for articles that haven't been seen."
bf247b6e 596 :version "22.1"
23f87bed
MB
597 :group 'gnus-summary-marks
598 :type 'character)
599
600(defcustom gnus-no-mark ? ;Whitespace
601 "*Mark used for articles that have no other secondary mark."
bf247b6e 602 :version "22.1"
eec82323
LMI
603 :group 'gnus-summary-marks
604 :type 'character)
605
606(defcustom gnus-ancient-mark ?O
607 "*Mark used for ancient articles."
608 :group 'gnus-summary-marks
609 :type 'character)
610
611(defcustom gnus-sparse-mark ?Q
612 "*Mark used for sparsely reffed articles."
613 :group 'gnus-summary-marks
614 :type 'character)
615
616(defcustom gnus-canceled-mark ?G
617 "*Mark used for canceled articles."
618 :group 'gnus-summary-marks
619 :type 'character)
620
621(defcustom gnus-duplicate-mark ?M
622 "*Mark used for duplicate articles."
623 :group 'gnus-summary-marks
624 :type 'character)
625
23f87bed 626(defcustom gnus-undownloaded-mark ?-
6748645f 627 "*Mark used for articles that weren't downloaded."
bf247b6e 628 :version "22.1"
6748645f
LMI
629 :group 'gnus-summary-marks
630 :type 'character)
631
23f87bed
MB
632(defcustom gnus-downloaded-mark ?+
633 "*Mark used for articles that were downloaded."
634 :group 'gnus-summary-marks
635 :type 'character)
636
6748645f
LMI
637(defcustom gnus-downloadable-mark ?%
638 "*Mark used for articles that are to be downloaded."
639 :group 'gnus-summary-marks
640 :type 'character)
641
642(defcustom gnus-unsendable-mark ?=
643 "*Mark used for articles that won't be sent."
644 :group 'gnus-summary-marks
645 :type 'character)
646
eec82323
LMI
647(defcustom gnus-score-over-mark ?+
648 "*Score mark used for articles with high scores."
649 :group 'gnus-summary-marks
650 :type 'character)
651
652(defcustom gnus-score-below-mark ?-
653 "*Score mark used for articles with low scores."
654 :group 'gnus-summary-marks
655 :type 'character)
656
23f87bed 657(defcustom gnus-empty-thread-mark ? ;Whitespace
eec82323
LMI
658 "*There is no thread under the article."
659 :group 'gnus-summary-marks
660 :type 'character)
661
662(defcustom gnus-not-empty-thread-mark ?=
663 "*There is a thread under the article."
664 :group 'gnus-summary-marks
665 :type 'character)
666
667(defcustom gnus-view-pseudo-asynchronously nil
668 "*If non-nil, Gnus will view pseudo-articles asynchronously."
669 :group 'gnus-extract-view
670 :type 'boolean)
671
16409b0b
GM
672(defcustom gnus-auto-expirable-marks
673 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
674 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
c4d82de8 675 gnus-duplicate-mark)
16409b0b 676 "*The list of marks converted into expiration if a group is auto-expirable."
b0e30310 677 :version "24.1"
16409b0b
GM
678 :group 'gnus-summary
679 :type '(repeat character))
680
681(defcustom gnus-inhibit-user-auto-expire t
682 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
58e39d05 683 :version "21.1"
16409b0b
GM
684 :group 'gnus-summary
685 :type 'boolean)
686
b0b63450
MB
687(defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
688 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
689If nil, the expirable marks will be unchanged except that the marks
690will be removed when copying or moving articles to a group that has
691not turned auto-expire on. If non-nil, articles that have been read
692will be marked as expirable when being copied or moved to a group in
693which auto-expire is turned on."
694 :version "23.2"
695 :type 'boolean
696 :group 'gnus-summary-marks)
697
eec82323
LMI
698(defcustom gnus-view-pseudos nil
699 "*If `automatic', pseudo-articles will be viewed automatically.
700If `not-confirm', pseudos will be viewed automatically, and the user
701will not be asked to confirm the command."
702 :group 'gnus-extract-view
703 :type '(choice (const :tag "off" nil)
704 (const automatic)
705 (const not-confirm)))
706
707(defcustom gnus-view-pseudos-separately t
708 "*If non-nil, one pseudo-article will be created for each file to be viewed.
709If nil, all files that use the same viewing command will be given as a
710list of parameters to that command."
711 :group 'gnus-extract-view
712 :type 'boolean)
713
714(defcustom gnus-insert-pseudo-articles t
715 "*If non-nil, insert pseudo-articles when decoding articles."
716 :group 'gnus-extract-view
717 :type 'boolean)
718
719(defcustom gnus-summary-dummy-line-format
23f87bed 720 " %(: :%) %S\n"
eec82323
LMI
721 "*The format specification for the dummy roots in the summary buffer.
722It works along the same lines as a normal formatting string,
723with some simple extensions.
724
23f87bed
MB
725%S The subject
726
727General format specifiers can also be used.
728See `(gnus)Formatting Variables'."
729 :link '(custom-manual "(gnus)Formatting Variables")
eec82323
LMI
730 :group 'gnus-threading
731 :type 'string)
732
16409b0b 733(defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
eec82323
LMI
734 "*The format specification for the summary mode line.
735It works along the same lines as a normal formatting string,
736with some simple extensions:
737
738%G Group name
739%p Unprefixed group name
740%A Current article number
6748645f 741%z Current article score
eec82323
LMI
742%V Gnus version
743%U Number of unread articles in the group
744%e Number of unselected articles in the group
745%Z A string with unread/unselected article counts
746%g Shortish group name
747%S Subject of the current article
748%u User-defined spec
749%s Current score file name
750%d Number of dormant articles
751%r Number of articles that have been marked as read in this session
752%E Number of articles expunged by the score files"
753 :group 'gnus-summary-format
754 :type 'string)
755
16409b0b
GM
756(defcustom gnus-list-identifiers nil
757 "Regexp that matches list identifiers to be removed from subject.
758This can also be a list of regexps."
58e39d05 759 :version "21.1"
16409b0b
GM
760 :group 'gnus-summary-format
761 :group 'gnus-article-hiding
762 :type '(choice (const :tag "none" nil)
763 (regexp :value ".*")
764 (repeat :value (".*") regexp)))
765
eec82323
LMI
766(defcustom gnus-summary-mark-below 0
767 "*Mark all articles with a score below this variable as read.
768This variable is local to each summary buffer and usually set by the
769score file."
770 :group 'gnus-score-default
771 :type 'integer)
772
01c52d31
MB
773(defun gnus-widget-reversible-match (widget value)
774 "Ignoring WIDGET, convert VALUE to internal form.
775VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
776 ;; (debug value)
777 (or (symbolp value)
778 (and (listp value)
779 (eq (length value) 2)
780 (eq (nth 0 value) 'not)
781 (symbolp (nth 1 value)))))
782
783(defun gnus-widget-reversible-to-internal (widget value)
784 "Ignoring WIDGET, convert VALUE to internal form.
785VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
786FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
787 ;; (debug value)
788 (if (atom value)
789 (list value nil)
790 (list (nth 1 value) t)))
791
792(defun gnus-widget-reversible-to-external (widget value)
793 "Ignoring WIDGET, convert VALUE to external form.
794VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
795\(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
796 ;; (debug value)
797 (if (nth 1 value)
798 (list 'not (nth 0 value))
799 (nth 0 value)))
800
801(define-widget 'gnus-widget-reversible 'group
802 "A `group' that convert values."
803 :match 'gnus-widget-reversible-match
804 :value-to-internal 'gnus-widget-reversible-to-internal
805 :value-to-external 'gnus-widget-reversible-to-external)
806
eec82323
LMI
807(defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
808 "*List of functions used for sorting articles in the summary buffer.
23f87bed
MB
809
810Each function takes two articles and returns non-nil if the first
811article should be sorted before the other. If you use more than one
812function, the primary sort function should be the last. You should
813probably always include `gnus-article-sort-by-number' in the list of
814sorting functions -- preferably first. Also note that sorting by date
815is often much slower than sorting by number, and the sorting order is
816very similar. (Sorting by date means sorting by the time the message
817was sent, sorting by number means sorting by arrival time.)
818
01c52d31
MB
819Each item can also be a list `(not F)' where F is a function;
820this reverses the sort order.
821
23f87bed
MB
822Ready-made functions include `gnus-article-sort-by-number',
823`gnus-article-sort-by-author', `gnus-article-sort-by-subject',
824`gnus-article-sort-by-date', `gnus-article-sort-by-random'
825and `gnus-article-sort-by-score'.
826
827When threading is turned on, the variable `gnus-thread-sort-functions'
828controls how articles are sorted."
eec82323 829 :group 'gnus-summary-sort
01c52d31
MB
830 :type '(repeat (gnus-widget-reversible
831 (choice (function-item gnus-article-sort-by-number)
832 (function-item gnus-article-sort-by-author)
833 (function-item gnus-article-sort-by-subject)
834 (function-item gnus-article-sort-by-date)
835 (function-item gnus-article-sort-by-score)
836 (function-item gnus-article-sort-by-random)
837 (function :tag "other"))
838 (boolean :tag "Reverse order"))))
839
eec82323
LMI
840
841(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
842 "*List of functions used for sorting threads in the summary buffer.
843By default, threads are sorted by article number.
844
23f87bed
MB
845Each function takes two threads and returns non-nil if the first
846thread should be sorted before the other. If you use more than one
847function, the primary sort function should be the last. You should
848probably always include `gnus-thread-sort-by-number' in the list of
849sorting functions -- preferably first. Also note that sorting by date
850is often much slower than sorting by number, and the sorting order is
851very similar. (Sorting by date means sorting by the time the message
852was sent, sorting by number means sorting by arrival time.)
eec82323 853
01c52d31
MB
854Each list item can also be a list `(not F)' where F is a
855function; this specifies reversed sort order.
856
eec82323 857Ready-made functions include `gnus-thread-sort-by-number',
01c52d31
MB
858`gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
859`gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
860`gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
861`gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
862and `gnus-thread-sort-by-total-score' (see
863`gnus-thread-score-function').
23f87bed
MB
864
865When threading is turned off, the variable
866`gnus-article-sort-functions' controls how articles are sorted."
eec82323 867 :group 'gnus-summary-sort
01c52d31
MB
868 :type '(repeat
869 (gnus-widget-reversible
870 (choice (function-item gnus-thread-sort-by-number)
871 (function-item gnus-thread-sort-by-author)
872 (function-item gnus-thread-sort-by-recipient)
873 (function-item gnus-thread-sort-by-subject)
874 (function-item gnus-thread-sort-by-date)
875 (function-item gnus-thread-sort-by-score)
876 (function-item gnus-thread-sort-by-most-recent-number)
877 (function-item gnus-thread-sort-by-most-recent-date)
878 (function-item gnus-thread-sort-by-random)
879 (function-item gnus-thread-sort-by-total-score)
880 (function :tag "other"))
881 (boolean :tag "Reverse order"))))
eec82323
LMI
882
883(defcustom gnus-thread-score-function '+
884 "*Function used for calculating the total score of a thread.
885
886The function is called with the scores of the article and each
887subthread and should then return the score of the thread.
888
889Some functions you can use are `+', `max', or `min'."
890 :group 'gnus-summary-sort
891 :type 'function)
892
893(defcustom gnus-summary-expunge-below nil
6748645f
LMI
894 "All articles that have a score less than this variable will be expunged.
895This variable is local to the summary buffers."
eec82323
LMI
896 :group 'gnus-score-default
897 :type '(choice (const :tag "off" nil)
898 integer))
899
900(defcustom gnus-thread-expunge-below nil
901 "All threads that have a total score less than this variable will be expunged.
902See `gnus-thread-score-function' for en explanation of what a
6748645f
LMI
903\"thread score\" is.
904
905This variable is local to the summary buffers."
16409b0b 906 :group 'gnus-threading
eec82323
LMI
907 :group 'gnus-score-default
908 :type '(choice (const :tag "off" nil)
909 integer))
910
911(defcustom gnus-summary-mode-hook nil
912 "*A hook for Gnus summary mode.
913This hook is run before any variables are set in the summary buffer."
23f87bed 914 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
eec82323
LMI
915 :group 'gnus-summary-various
916 :type 'hook)
917
23f87bed
MB
918;; Extracted from gnus-xmas-redefine in order to preserve user settings
919(when (featurep 'xemacs)
920 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
921 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
922 (add-hook 'gnus-summary-mode-hook
923 'gnus-xmas-switch-horizontal-scrollbar-off))
924
eec82323
LMI
925(defcustom gnus-summary-menu-hook nil
926 "*Hook run after the creation of the summary mode menu."
927 :group 'gnus-summary-visual
928 :type 'hook)
929
930(defcustom gnus-summary-exit-hook nil
931 "*A hook called on exit from the summary buffer.
932It will be called with point in the group buffer."
933 :group 'gnus-summary-exit
934 :type 'hook)
935
936(defcustom gnus-summary-prepare-hook nil
937 "*A hook called after the summary buffer has been generated.
938If you want to modify the summary buffer, you can use this hook."
939 :group 'gnus-summary-various
940 :type 'hook)
941
6748645f
LMI
942(defcustom gnus-summary-prepared-hook nil
943 "*A hook called as the last thing after the summary buffer has been generated."
944 :group 'gnus-summary-various
945 :type 'hook)
946
eec82323
LMI
947(defcustom gnus-summary-generate-hook nil
948 "*A hook run just before generating the summary buffer.
949This hook is commonly used to customize threading variables and the
950like."
951 :group 'gnus-summary-various
952 :type 'hook)
953
954(defcustom gnus-select-group-hook nil
955 "*A hook called when a newsgroup is selected.
956
957If you'd like to simplify subjects like the
958`gnus-summary-next-same-subject' command does, you can use the
959following hook:
960
23f87bed
MB
961 (add-hook gnus-select-group-hook
962 (lambda ()
963 (mapcar (lambda (header)
964 (mail-header-set-subject
965 header
966 (gnus-simplify-subject
967 (mail-header-subject header) 're-only)))
968 gnus-newsgroup-headers)))"
eec82323
LMI
969 :group 'gnus-group-select
970 :type 'hook)
971
972(defcustom gnus-select-article-hook nil
973 "*A hook called when an article is selected."
974 :group 'gnus-summary-choose
23f87bed 975 :options '(gnus-agent-fetch-selected-article)
eec82323
LMI
976 :type 'hook)
977
978(defcustom gnus-visual-mark-article-hook
979 (list 'gnus-highlight-selected-summary)
980 "*Hook run after selecting an article in the summary buffer.
981It is meant to be used for highlighting the article in some way. It
982is not run if `gnus-visual' is nil."
983 :group 'gnus-summary-visual
984 :type 'hook)
985
16409b0b 986(defcustom gnus-parse-headers-hook nil
eec82323
LMI
987 "*A hook called before parsing the headers."
988 :group 'gnus-various
989 :type 'hook)
990
991(defcustom gnus-exit-group-hook nil
16409b0b
GM
992 "*A hook called when exiting summary mode.
993This hook is not called from the non-updating exit commands like `Q'."
eec82323
LMI
994 :group 'gnus-various
995 :type 'hook)
996
a9ec34f4 997(defcustom gnus-summary-update-hook nil
eec82323
LMI
998 "*A hook called when a summary line is changed.
999The hook will not be called if `gnus-visual' is nil.
1000
1001The default function `gnus-summary-highlight-line' will
1002highlight the line according to the `gnus-summary-highlight'
1003variable."
1004 :group 'gnus-summary-visual
1005 :type 'hook)
1006
1007(defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1008 "*A hook called when an article is selected for the first time.
1009The hook is intended to mark an article as read (or unread)
1010automatically when it is selected."
1011 :group 'gnus-summary-choose
1012 :type 'hook)
1013
1014(defcustom gnus-group-no-more-groups-hook nil
1015 "*A hook run when returning to group mode having no more (unread) groups."
1016 :group 'gnus-group-select
1017 :type 'hook)
1018
1019(defcustom gnus-ps-print-hook nil
1020 "*A hook run before ps-printing something from Gnus."
1021 :group 'gnus-summary
1022 :type 'hook)
1023
23f87bed
MB
1024(defcustom gnus-summary-article-move-hook nil
1025 "*A hook called after an article is moved, copied, respooled, or crossposted."
bf247b6e 1026 :version "22.1"
23f87bed
MB
1027 :group 'gnus-summary
1028 :type 'hook)
1029
1030(defcustom gnus-summary-article-delete-hook nil
1031 "*A hook called after an article is deleted."
bf247b6e 1032 :version "22.1"
23f87bed
MB
1033 :group 'gnus-summary
1034 :type 'hook)
1035
1036(defcustom gnus-summary-article-expire-hook nil
1037 "*A hook called after an article is expired."
bf247b6e 1038 :version "22.1"
23f87bed
MB
1039 :group 'gnus-summary
1040 :type 'hook)
1041
1042(defcustom gnus-summary-display-arrow
1043 (and (fboundp 'display-graphic-p)
1044 (display-graphic-p))
1045 "*If non-nil, display an arrow highlighting the current article."
bf247b6e 1046 :version "22.1"
23f87bed
MB
1047 :group 'gnus-summary
1048 :type 'boolean)
1049
0f49874b 1050(defcustom gnus-summary-selected-face 'gnus-summary-selected
eec82323
LMI
1051 "Face used for highlighting the current article in the summary buffer."
1052 :group 'gnus-summary-visual
1053 :type 'face)
1054
23f87bed
MB
1055(defvar gnus-tmp-downloaded nil)
1056
eec82323 1057(defcustom gnus-summary-highlight
23f87bed 1058 '(((eq mark gnus-canceled-mark)
0f49874b 1059 . gnus-summary-cancelled)
23f87bed 1060 ((and uncached (> score default-high))
0f49874b 1061 . gnus-summary-high-undownloaded)
23f87bed 1062 ((and uncached (< score default-low))
0f49874b 1063 . gnus-summary-low-undownloaded)
23f87bed 1064 (uncached
0f49874b 1065 . gnus-summary-normal-undownloaded)
23f87bed
MB
1066 ((and (> score default-high)
1067 (or (eq mark gnus-dormant-mark)
1068 (eq mark gnus-ticked-mark)))
0f49874b 1069 . gnus-summary-high-ticked)
23f87bed
MB
1070 ((and (< score default-low)
1071 (or (eq mark gnus-dormant-mark)
1072 (eq mark gnus-ticked-mark)))
0f49874b 1073 . gnus-summary-low-ticked)
23f87bed
MB
1074 ((or (eq mark gnus-dormant-mark)
1075 (eq mark gnus-ticked-mark))
0f49874b 1076 . gnus-summary-normal-ticked)
23f87bed 1077 ((and (> score default-high) (eq mark gnus-ancient-mark))
0f49874b 1078 . gnus-summary-high-ancient)
23f87bed 1079 ((and (< score default-low) (eq mark gnus-ancient-mark))
0f49874b 1080 . gnus-summary-low-ancient)
23f87bed 1081 ((eq mark gnus-ancient-mark)
0f49874b 1082 . gnus-summary-normal-ancient)
23f87bed 1083 ((and (> score default-high) (eq mark gnus-unread-mark))
0f49874b 1084 . gnus-summary-high-unread)
23f87bed 1085 ((and (< score default-low) (eq mark gnus-unread-mark))
0f49874b 1086 . gnus-summary-low-unread)
23f87bed 1087 ((eq mark gnus-unread-mark)
0f49874b 1088 . gnus-summary-normal-unread)
23f87bed 1089 ((> score default-high)
0f49874b 1090 . gnus-summary-high-read)
23f87bed 1091 ((< score default-low)
0f49874b 1092 . gnus-summary-low-read)
eec82323 1093 (t
0f49874b 1094 . gnus-summary-normal-read))
6748645f 1095 "*Controls the highlighting of summary buffer lines.
eec82323 1096
107cf8ec 1097A list of (FORM . FACE) pairs. When deciding how a particular
23f87bed
MB
1098summary line should be displayed, each form is evaluated. The content
1099of the face field after the first true form is used. You can change
1100how those summary lines are displayed, by editing the face field.
eec82323
LMI
1101
1102You can use the following variables in the FORM field.
1103
107cf8ec 1104score: The article's score.
23f87bed
MB
1105default: The default article score.
1106default-high: The default score for high scored articles.
1107default-low: The default score for low scored articles.
1108below: The score below which articles are automatically marked as read.
1109mark: The article's mark.
1110uncached: Non-nil if the article is uncached."
eec82323
LMI
1111 :group 'gnus-summary-visual
1112 :type '(repeat (cons (sexp :tag "Form" nil)
1113 face)))
c12ecb0a 1114(put 'gnus-summary-highlight 'risky-local-variable t)
eec82323 1115
6748645f
LMI
1116(defcustom gnus-alter-header-function nil
1117 "Function called to allow alteration of article header structures.
1118The function is called with one parameter, the article header vector,
0ab0f2d3
SZ
1119which it may alter in any way."
1120 :type '(choice (const :tag "None" nil)
1121 function)
1122 :group 'gnus-summary)
eec82323 1123
16409b0b 1124(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
343d6628
MB
1125 "Function used to decode a string with encoded words.")
1126
1127(defvar gnus-decode-encoded-address-function
1128 'mail-decode-encoded-address-string
1129 "Function used to decode addresses with encoded words.")
16409b0b 1130
23f87bed 1131(defcustom gnus-extra-headers '(To Newsgroups)
16409b0b 1132 "*Extra headers to parse."
58e39d05 1133 :version "21.1"
16409b0b
GM
1134 :group 'gnus-summary
1135 :type '(repeat symbol))
1136
1137(defcustom gnus-ignored-from-addresses
343d6628 1138 (and user-mail-address
7cd9f860
CY
1139 (not (string= user-mail-address ""))
1140 (regexp-quote user-mail-address))
01c52d31
MB
1141 "*From headers that may be suppressed in favor of To headers.
1142This can be a regexp or a list of regexps."
58e39d05 1143 :version "21.1"
16409b0b 1144 :group 'gnus-summary
01c52d31
MB
1145 :type '(choice regexp
1146 (repeat :tag "Regexp List" regexp)))
1147
1148(defsubst gnus-ignored-from-addresses ()
1149 (gmm-regexp-concat gnus-ignored-from-addresses))
1150
1151(defcustom gnus-summary-to-prefix "-> "
1152 "*String prefixed to the To field in the summary line when
1153using `gnus-ignored-from-addresses'."
1154 :version "22.1"
1155 :group 'gnus-summary
1156 :type 'string)
1157
1158(defcustom gnus-summary-newsgroup-prefix "=> "
1159 "*String prefixed to the Newsgroup field in the summary
1160line when using `gnus-ignored-from-addresses'."
1161 :version "22.1"
1162 :group 'gnus-summary
1163 :type 'string)
16409b0b 1164
16409b0b
GM
1165(defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1166 "List of charsets that should be ignored.
1167When these charsets are used in the \"charset\" parameter, the
1168default charset will be used instead."
58e39d05 1169 :version "21.1"
16409b0b
GM
1170 :type '(repeat symbol)
1171 :group 'gnus-charset)
1172
4b70e299
MB
1173(defcustom gnus-newsgroup-maximum-articles nil
1174 "The maximum number of articles a newsgroup.
1175If this is a number, old articles in a newsgroup exceeding this number
1176are silently ignored. If it is nil, no article is ignored. Note that
1177setting this variable to a number might prevent you from reading very
1178old articles."
1179 :group 'gnus-group-select
1180 :version "22.2"
1181 :type '(choice (const :tag "No limit" nil)
1182 integer))
1183
23f87bed
MB
1184(gnus-define-group-parameter
1185 ignored-charsets
1186 :type list
1187 :function-document
1188 "Return the ignored charsets of GROUP."
1189 :variable gnus-group-ignored-charsets-alist
1190 :variable-default
1191 '(("alt\\.chinese\\.text" iso-8859-1))
1192 :variable-document
1193 "Alist of regexps (to match group names) and charsets that should be ignored.
16409b0b
GM
1194When these charsets are used in the \"charset\" parameter, the
1195default charset will be used instead."
23f87bed
MB
1196 :variable-group gnus-charset
1197 :variable-type '(repeat (cons (regexp :tag "Group")
1198 (repeat symbol)))
1199 :parameter-type '(choice :tag "Ignored charsets"
1200 :value nil
1201 (repeat (symbol)))
1202 :parameter-document "\
1203List of charsets that should be ignored.
1204
1205When these charsets are used in the \"charset\" parameter, the
1206default charset will be used instead.")
16409b0b
GM
1207
1208(defcustom gnus-group-highlight-words-alist nil
1209 "Alist of group regexps and highlight regexps.
1210This variable uses the same syntax as `gnus-emphasis-alist'."
58e39d05 1211 :version "21.1"
16409b0b
GM
1212 :type '(repeat (cons (regexp :tag "Group")
1213 (repeat (list (regexp :tag "Highlight regexp")
1214 (number :tag "Group for entire word" 0)
1215 (number :tag "Group for displayed part" 0)
1216 (symbol :tag "Face"
1217 gnus-emphasis-highlight-words)))))
1218 :group 'gnus-summary-visual)
1219
1220(defcustom gnus-summary-show-article-charset-alist
1221 nil
1222 "Alist of number and charset.
1223The article will be shown with the charset corresponding to the
1224numbered argument.
1225For example: ((1 . cn-gb-2312) (2 . big5))."
58e39d05 1226 :version "21.1"
16409b0b
GM
1227 :type '(repeat (cons (number :tag "Argument" 1)
1228 (symbol :tag "Charset")))
1229 :group 'gnus-charset)
1230
1231(defcustom gnus-preserve-marks t
1232 "Whether marks are preserved when moving, copying and respooling messages."
58e39d05 1233 :version "21.1"
16409b0b
GM
1234 :type 'boolean
1235 :group 'gnus-summary-marks)
1236
584c9d3f 1237(defcustom gnus-propagate-marks t
5415d076
G
1238 "If non-nil, Gnus will store and retrieve marks from the backends.
1239This means that marks will be stored both in .newsrc.eld and in
1240the backend, and will slow operation down somewhat."
3a23a519
MB
1241 :type 'boolean
1242 :group 'gnus-summary-marks)
1243
16409b0b
GM
1244(defcustom gnus-alter-articles-to-read-function nil
1245 "Function to be called to alter the list of articles to be selected."
8fc7a9a1 1246 :type '(choice (const nil) function)
16409b0b
GM
1247 :group 'gnus-summary)
1248
1249(defcustom gnus-orphan-score nil
1250 "*All orphans get this score added. Set in the score file."
1251 :group 'gnus-score-default
1252 :type '(choice (const nil)
1253 integer))
1254
8b93df01 1255(defcustom gnus-summary-save-parts-default-mime "image/.*"
23f87bed
MB
1256 "*A regexp to match MIME parts when saving multiple parts of a
1257message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1258This regexp will be used by default when prompting the user for which
1259type of files to save."
8b93df01
DL
1260 :group 'gnus-summary
1261 :type 'regexp)
1262
23f87bed
MB
1263(defcustom gnus-read-all-available-headers nil
1264 "Whether Gnus should parse all headers made available to it.
1265This is mostly relevant for slow back ends where the user may
1266wish to widen the summary buffer to include all headers
c4d82de8 1267that were fetched."
bf247b6e 1268 :version "22.1"
23f87bed
MB
1269 :group 'gnus-summary
1270 :type '(choice boolean regexp))
1271
89167438
MB
1272(defcustom gnus-summary-pipe-output-default-command nil
1273 "Command (and optional arguments) used to pipe article to subprocess.
1274This will be used as the default command if it is non-nil. The value
1275will be updated if you modify it when executing the command
1276`gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1277 :version "23.1" ;; No Gnus
1278 :group 'gnus-summary
1279 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1280
23f87bed 1281(defcustom gnus-summary-muttprint-program "muttprint"
89167438
MB
1282 "Command (and optional arguments) used to run Muttprint.
1283The value will be updated if you modify it when executing the command
1284`gnus-summary-muttprint'."
bf247b6e 1285 :version "22.1"
23f87bed
MB
1286 :group 'gnus-summary
1287 :type 'string)
1288
01c52d31 1289(defcustom gnus-article-loose-mime t
23f87bed
MB
1290 "If non-nil, don't require MIME-Version header.
1291Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
a08b59c9 1292supply the MIME-Version header or deliberately strip it from the mail.
01c52d31
MB
1293If non-nil (the default), Gnus will treat some articles as MIME
1294even if the MIME-Version header is missing."
bf247b6e 1295 :version "22.1"
23f87bed
MB
1296 :type 'boolean
1297 :group 'gnus-article-mime)
1298
1299(defcustom gnus-article-emulate-mime t
1300 "If non-nil, use MIME emulation for uuencode and the like.
1301This means that Gnus will search message bodies for text that look
1302like uuencoded bits, yEncoded bits, and so on, and present that using
1303the normal Gnus MIME machinery."
bf247b6e 1304 :version "22.1"
23f87bed
MB
1305 :type 'boolean
1306 :group 'gnus-article-mime)
8b93df01 1307
eec82323
LMI
1308;;; Internal variables
1309
23f87bed 1310(defvar gnus-summary-display-cache nil)
16409b0b
GM
1311(defvar gnus-article-mime-handles nil)
1312(defvar gnus-article-decoded-p nil)
23f87bed
MB
1313(defvar gnus-article-charset nil)
1314(defvar gnus-article-ignored-charsets nil)
eec82323
LMI
1315(defvar gnus-scores-exclude-files nil)
1316(defvar gnus-page-broken nil)
1317
1318(defvar gnus-original-article nil)
1319(defvar gnus-article-internal-prepare-hook nil)
1320(defvar gnus-newsgroup-process-stack nil)
1321
1322(defvar gnus-thread-indent-array nil)
1323(defvar gnus-thread-indent-array-level gnus-thread-indent-level)
16409b0b
GM
1324(defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1325 "Function called to sort the articles within a thread after it has been gathered together.")
eec82323 1326
8b93df01 1327(defvar gnus-summary-save-parts-type-history nil)
23f87bed 1328(defvar gnus-summary-save-parts-last-directory mm-default-directory)
8b93df01 1329
eec82323
LMI
1330;; Avoid highlighting in kill files.
1331(defvar gnus-summary-inhibit-highlight nil)
1332(defvar gnus-newsgroup-selected-overlay nil)
1333(defvar gnus-inhibit-limiting nil)
1334(defvar gnus-newsgroup-adaptive-score-file nil)
1335(defvar gnus-current-score-file nil)
1336(defvar gnus-current-move-group nil)
1337(defvar gnus-current-copy-group nil)
1338(defvar gnus-current-crosspost-group nil)
23f87bed 1339(defvar gnus-newsgroup-display nil)
eec82323
LMI
1340
1341(defvar gnus-newsgroup-dependencies nil)
1342(defvar gnus-newsgroup-adaptive nil)
1343(defvar gnus-summary-display-article-function nil)
1344(defvar gnus-summary-highlight-line-function nil
1345 "Function called after highlighting a summary line.")
1346
1347(defvar gnus-summary-line-format-alist
1348 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1349 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1350 (?s gnus-tmp-subject-or-nil ?s)
1351 (?n gnus-tmp-name ?s)
1352 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1353 ?s)
1354 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1355 gnus-tmp-from) ?s)
1356 (?F gnus-tmp-from ?s)
1357 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1358 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1359 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
6748645f 1360 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
eec82323
LMI
1361 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1362 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1363 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
23f87bed
MB
1364 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1365 (?L gnus-tmp-lines ?s)
d6f6af81 1366 (?Z (or ,(gnus-macroexpand-all
ed797193
G
1367 '(nnir-article-rsv (mail-header-number gnus-tmp-header)))
1368 0) ?d)
d6f6af81 1369 (?G (or ,(gnus-macroexpand-all
ed797193
G
1370 '(nnir-article-group (mail-header-number gnus-tmp-header)))
1371 "") ?s)
d6f6af81 1372 (?g (or ,(gnus-macroexpand-all
ed797193
G
1373 '(gnus-group-short-name
1374 (nnir-article-group (mail-header-number gnus-tmp-header))))
1375 "") ?s)
23f87bed 1376 (?O gnus-tmp-downloaded ?c)
eec82323
LMI
1377 (?I gnus-tmp-indentation ?s)
1378 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1379 (?R gnus-tmp-replied ?c)
1380 (?\[ gnus-tmp-opening-bracket ?c)
1381 (?\] gnus-tmp-closing-bracket ?c)
1382 (?\> (make-string gnus-tmp-level ? ) ?s)
1383 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1384 (?i gnus-tmp-score ?d)
1385 (?z gnus-tmp-score-char ?c)
eec82323
LMI
1386 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1387 (?U gnus-tmp-unread ?c)
23f87bed
MB
1388 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1389 ?s)
eec82323
LMI
1390 (?t (gnus-summary-number-of-articles-in-thread
1391 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1392 ?d)
1393 (?e (gnus-summary-number-of-articles-in-thread
1394 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1395 ?c)
1396 (?u gnus-tmp-user-defined ?s)
23f87bed
MB
1397 (?P (gnus-pick-line-number) ?d)
1398 (?B gnus-tmp-thread-tree-header-string ?s)
ec72bf63 1399 (user-date (gnus-user-date
23f87bed 1400 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
16409b0b
GM
1401 "An alist of format specifications that can appear in summary lines.
1402These are paired with what variables they correspond with, along with
1403the type of the variable (string, integer, character, etc).")
eec82323
LMI
1404
1405(defvar gnus-summary-dummy-line-format-alist
1406 `((?S gnus-tmp-subject ?s)
1407 (?N gnus-tmp-number ?d)
1408 (?u gnus-tmp-user-defined ?s)))
1409
1410(defvar gnus-summary-mode-line-format-alist
1411 `((?G gnus-tmp-group-name ?s)
1412 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1413 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1414 (?A gnus-tmp-article-number ?d)
1415 (?Z gnus-tmp-unread-and-unselected ?s)
1416 (?V gnus-version ?s)
1417 (?U gnus-tmp-unread-and-unticked ?d)
1418 (?S gnus-tmp-subject ?s)
1419 (?e gnus-tmp-unselected ?d)
1420 (?u gnus-tmp-user-defined ?s)
1421 (?d (length gnus-newsgroup-dormant) ?d)
1422 (?t (length gnus-newsgroup-marked) ?d)
23f87bed 1423 (?h (length gnus-newsgroup-spam-marked) ?d)
eec82323 1424 (?r (length gnus-newsgroup-reads) ?d)
6748645f 1425 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
eec82323
LMI
1426 (?E gnus-newsgroup-expunged-tally ?d)
1427 (?s (gnus-current-score-file-nondirectory) ?s)))
1428
c1717fbd
GM
1429;; This is here rather than in gnus-art for compilation reasons.
1430(defvar gnus-article-mode-line-format-alist
1431 (nconc '((?w (gnus-article-wash-status) ?s)
1432 (?m (gnus-article-mime-part-status) ?s))
1433 gnus-summary-mode-line-format-alist))
1434
eec82323
LMI
1435(defvar gnus-last-search-regexp nil
1436 "Default regexp for article search command.")
1437
1438(defvar gnus-last-shell-command nil
1439 "Default shell command on article.")
1440
23f87bed
MB
1441(defvar gnus-newsgroup-agentized nil
1442 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
eec82323
LMI
1443(defvar gnus-newsgroup-begin nil)
1444(defvar gnus-newsgroup-end nil)
1445(defvar gnus-newsgroup-last-rmail nil)
1446(defvar gnus-newsgroup-last-mail nil)
1447(defvar gnus-newsgroup-last-folder nil)
1448(defvar gnus-newsgroup-last-file nil)
26c9afc3 1449(defvar gnus-newsgroup-last-directory nil)
eec82323
LMI
1450(defvar gnus-newsgroup-auto-expire nil)
1451(defvar gnus-newsgroup-active nil)
9f2d52e7 1452(defvar gnus-newsgroup-highest nil)
eec82323
LMI
1453
1454(defvar gnus-newsgroup-data nil)
1455(defvar gnus-newsgroup-data-reverse nil)
1456(defvar gnus-newsgroup-limit nil)
1457(defvar gnus-newsgroup-limits nil)
23f87bed 1458(defvar gnus-summary-use-undownloaded-faces nil)
eec82323
LMI
1459
1460(defvar gnus-newsgroup-unreads nil
23f87bed 1461 "Sorted list of unread articles in the current newsgroup.")
eec82323
LMI
1462
1463(defvar gnus-newsgroup-unselected nil
23f87bed 1464 "Sorted list of unselected unread articles in the current newsgroup.")
eec82323
LMI
1465
1466(defvar gnus-newsgroup-reads nil
1467 "Alist of read articles and article marks in the current newsgroup.")
1468
1469(defvar gnus-newsgroup-expunged-tally nil)
1470
1471(defvar gnus-newsgroup-marked nil
23f87bed
MB
1472 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1473
1474(defvar gnus-newsgroup-spam-marked nil
1475 "List of ranges of articles that have been marked as spam.")
eec82323
LMI
1476
1477(defvar gnus-newsgroup-killed nil
1478 "List of ranges of articles that have been through the scoring process.")
1479
1480(defvar gnus-newsgroup-cached nil
23f87bed 1481 "Sorted list of articles that come from the article cache.")
eec82323
LMI
1482
1483(defvar gnus-newsgroup-saved nil
1484 "List of articles that have been saved.")
1485
1486(defvar gnus-newsgroup-kill-headers nil)
1487
1488(defvar gnus-newsgroup-replied nil
1489 "List of articles that have been replied to in the current newsgroup.")
1490
23f87bed
MB
1491(defvar gnus-newsgroup-forwarded nil
1492 "List of articles that have been forwarded in the current newsgroup.")
1493
1494(defvar gnus-newsgroup-recent nil
1495 "List of articles that have are recent in the current newsgroup.")
1496
eec82323 1497(defvar gnus-newsgroup-expirable nil
23f87bed 1498 "Sorted list of articles in the current newsgroup that can be expired.")
eec82323
LMI
1499
1500(defvar gnus-newsgroup-processable nil
1501 "List of articles in the current newsgroup that can be processed.")
1502
6748645f 1503(defvar gnus-newsgroup-downloadable nil
23f87bed
MB
1504 "Sorted list of articles in the current newsgroup that can be processed.")
1505
1506(defvar gnus-newsgroup-unfetched nil
1507 "Sorted list of articles in the current newsgroup whose headers have
1508not been fetched into the agent.
1509
1510This list will always be a subset of gnus-newsgroup-undownloaded.")
6748645f
LMI
1511
1512(defvar gnus-newsgroup-undownloaded nil
23f87bed 1513 "List of articles in the current newsgroup that haven't been downloaded.")
6748645f
LMI
1514
1515(defvar gnus-newsgroup-unsendable nil
1516 "List of articles in the current newsgroup that won't be sent.")
1517
eec82323
LMI
1518(defvar gnus-newsgroup-bookmarks nil
1519 "List of articles in the current newsgroup that have bookmarks.")
1520
1521(defvar gnus-newsgroup-dormant nil
23f87bed
MB
1522 "Sorted list of dormant articles in the current newsgroup.")
1523
1524(defvar gnus-newsgroup-unseen nil
1525 "List of unseen articles in the current newsgroup.")
1526
1527(defvar gnus-newsgroup-seen nil
1528 "Range of seen articles in the current newsgroup.")
1529
1530(defvar gnus-newsgroup-articles nil
1531 "List of articles in the current newsgroup.")
eec82323
LMI
1532
1533(defvar gnus-newsgroup-scored nil
1534 "List of scored articles in the current newsgroup.")
1535
1536(defvar gnus-newsgroup-headers nil
1537 "List of article headers in the current newsgroup.")
1538
1539(defvar gnus-newsgroup-threads nil)
1540
1541(defvar gnus-newsgroup-prepared nil
1542 "Whether the current group has been prepared properly.")
1543
1544(defvar gnus-newsgroup-ancient nil
1545 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1546
1547(defvar gnus-newsgroup-sparse nil)
1548
1549(defvar gnus-current-article nil)
1550(defvar gnus-article-current nil)
1551(defvar gnus-current-headers nil)
1552(defvar gnus-have-all-headers nil)
1553(defvar gnus-last-article nil)
1554(defvar gnus-newsgroup-history nil)
16409b0b
GM
1555(defvar gnus-newsgroup-charset nil)
1556(defvar gnus-newsgroup-ephemeral-charset nil)
1557(defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
eec82323 1558
23f87bed
MB
1559(defvar gnus-article-before-search nil)
1560
1561(defvar gnus-summary-local-variables
eec82323 1562 '(gnus-newsgroup-name
b1ae92ba
G
1563
1564 ;; Marks lists
1565 gnus-newsgroup-unreads
1566 gnus-newsgroup-unselected
1567 gnus-newsgroup-marked
1568 gnus-newsgroup-spam-marked
1569 gnus-newsgroup-reads
1570 gnus-newsgroup-saved
1571 gnus-newsgroup-replied
1572 gnus-newsgroup-forwarded
1573 gnus-newsgroup-recent
1574 gnus-newsgroup-expirable
1575 gnus-newsgroup-killed
1576 gnus-newsgroup-unseen
1577 gnus-newsgroup-seen
1578 gnus-newsgroup-cached
1579 gnus-newsgroup-downloadable
1580 gnus-newsgroup-undownloaded
1581 gnus-newsgroup-unsendable
1582
eec82323
LMI
1583 gnus-newsgroup-begin gnus-newsgroup-end
1584 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1585 gnus-newsgroup-last-folder gnus-newsgroup-last-file
26c9afc3 1586 gnus-newsgroup-last-directory
b1ae92ba
G
1587 gnus-newsgroup-auto-expire
1588 gnus-newsgroup-processable
23f87bed 1589 gnus-newsgroup-unfetched
b1ae92ba 1590 gnus-newsgroup-articles
eec82323
LMI
1591 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1592 gnus-newsgroup-headers gnus-newsgroup-threads
1593 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1594 gnus-current-article gnus-current-headers gnus-have-all-headers
1595 gnus-last-article gnus-article-internal-prepare-hook
ed797193
G
1596 (gnus-summary-article-delete-hook . global)
1597 (gnus-summary-article-move-hook . global)
eec82323
LMI
1598 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1599 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1600 gnus-thread-expunge-below
16409b0b
GM
1601 gnus-score-alist gnus-current-score-file
1602 (gnus-summary-expunge-below . global)
eec82323 1603 (gnus-summary-mark-below . global)
16409b0b 1604 (gnus-orphan-score . global)
eec82323 1605 gnus-newsgroup-active gnus-scores-exclude-files
9f2d52e7 1606 gnus-newsgroup-highest
eec82323
LMI
1607 gnus-newsgroup-history gnus-newsgroup-ancient
1608 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1609 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1610 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1611 (gnus-newsgroup-expunged-tally . 0)
b1ae92ba 1612 gnus-cache-removable-articles
eec82323 1613 gnus-newsgroup-data gnus-newsgroup-data-reverse
16409b0b 1614 gnus-newsgroup-limit gnus-newsgroup-limits
23f87bed
MB
1615 gnus-newsgroup-charset gnus-newsgroup-display
1616 gnus-summary-use-undownloaded-faces)
eec82323
LMI
1617 "Variables that are buffer-local to the summary buffers.")
1618
23f87bed
MB
1619(defvar gnus-newsgroup-variables nil
1620 "A list of variables that have separate values in different newsgroups.
1621A list of newsgroup (summary buffer) local variables, or cons of
1622variables and their default expressions to be evalled (when the default
1623values are not nil), that should be made global while the summary buffer
1624is active.
1625
1626Note: The default expressions will be evaluated (using function `eval')
1627before assignment to the local variable rather than just assigned to it.
1628If the default expression is the symbol `global', that symbol will not
1629be evaluated but the global value of the local variable will be used
1630instead.
1631
1632These variables can be used to set variables in the group parameters
1633while still allowing them to affect operations done in other buffers.
1634For example:
1635
1636\(setq gnus-newsgroup-variables
1637 '(message-use-followup-to
1638 (gnus-visible-headers .
1639 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1640")
1641
23f87bed
MB
1642(eval-when-compile
1643 ;; Bind features so that require will believe that gnus-sum has
1644 ;; already been loaded (avoids infinite recursion)
1645 (let ((features (cons 'gnus-sum features)))
23f87bed 1646 (require 'gnus-art)))
eec82323 1647
16409b0b
GM
1648;; MIME stuff.
1649
1650(defvar gnus-decode-encoded-word-methods
1651 '(mail-decode-encoded-word-string)
1652 "List of methods used to decode encoded words.
1653
23f87bed
MB
1654This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1655is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1656\(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
16409b0b
GM
1657whose names match REGEXP.
1658
1659For example:
23f87bed 1660\((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
16409b0b
GM
1661 mail-decode-encoded-word-string
1662 (\"chinese\" . rfc1843-decode-string))")
1663
1664(defvar gnus-decode-encoded-word-methods-cache nil)
1665
1666(defun gnus-multi-decode-encoded-word-string (string)
1667 "Apply the functions from `gnus-encoded-word-methods' that match."
1668 (unless (and gnus-decode-encoded-word-methods-cache
1669 (eq gnus-newsgroup-name
1670 (car gnus-decode-encoded-word-methods-cache)))
1671 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
01c52d31
MB
1672 (dolist (method gnus-decode-encoded-word-methods)
1673 (if (symbolp method)
1674 (nconc gnus-decode-encoded-word-methods-cache (list method))
1675 (if (and gnus-newsgroup-name
1676 (string-match (car method) gnus-newsgroup-name))
1677 (nconc gnus-decode-encoded-word-methods-cache
1678 (list (cdr method)))))))
1679 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1680 (setq string (funcall method string))))
16409b0b 1681
eec82323
LMI
1682;; Subject simplification.
1683
6748645f 1684(defun gnus-simplify-whitespace (str)
16409b0b 1685 "Remove excessive whitespace from STR."
23f87bed
MB
1686 ;; Multiple spaces.
1687 (while (string-match "[ \t][ \t]+" str)
1688 (setq str (concat (substring str 0 (match-beginning 0))
1689 " "
1690 (substring str (match-end 0)))))
1691 ;; Leading spaces.
1692 (when (string-match "^[ \t]+" str)
1693 (setq str (substring str (match-end 0))))
1694 ;; Trailing spaces.
1695 (when (string-match "[ \t]+$" str)
1696 (setq str (substring str 0 (match-beginning 0))))
1697 str)
1698
1699(defun gnus-simplify-all-whitespace (str)
1700 "Remove all whitespace from STR."
1701 (while (string-match "[ \t\n]+" str)
1702 (setq str (replace-match "" nil nil str)))
1703 str)
6748645f 1704
eec82323
LMI
1705(defsubst gnus-simplify-subject-re (subject)
1706 "Remove \"Re:\" from subject lines."
23f87bed 1707 (if (string-match message-subject-re-regexp subject)
eec82323
LMI
1708 (substring subject (match-end 0))
1709 subject))
1710
1711(defun gnus-simplify-subject (subject &optional re-only)
1712 "Remove `Re:' and words in parentheses.
1713If RE-ONLY is non-nil, strip leading `Re:'s only."
1714 (let ((case-fold-search t)) ;Ignore case.
1715 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1716 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1717 (setq subject (substring subject (match-end 0))))
1718 ;; Remove uninteresting prefixes.
1719 (when (and (not re-only)
1720 gnus-simplify-ignored-prefixes
1721 (string-match gnus-simplify-ignored-prefixes subject))
1722 (setq subject (substring subject (match-end 0))))
1723 ;; Remove words in parentheses from end.
1724 (unless re-only
1725 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1726 (setq subject (substring subject 0 (match-beginning 0)))))
1727 ;; Return subject string.
1728 subject))
1729
1730;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1731;; all whitespace.
1732(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1733 (goto-char (point-min))
1734 (while (re-search-forward regexp nil t)
16409b0b 1735 (replace-match (or newtext ""))))
eec82323
LMI
1736
1737(defun gnus-simplify-buffer-fuzzy ()
1738 "Simplify string in the buffer fuzzily.
1739The string in the accessible portion of the current buffer is simplified.
1740It is assumed to be a single-line subject.
1741Whitespace is generally cleaned up, and miscellaneous leading/trailing
1742matter is removed. Additional things can be deleted by setting
16409b0b 1743`gnus-simplify-subject-fuzzy-regexp'."
eec82323
LMI
1744 (let ((case-fold-search t)
1745 (modified-tick))
1746 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1747
1748 (while (not (eq modified-tick (buffer-modified-tick)))
1749 (setq modified-tick (buffer-modified-tick))
1750 (cond
1751 ((listp gnus-simplify-subject-fuzzy-regexp)
01c52d31
MB
1752 (mapc 'gnus-simplify-buffer-fuzzy-step
1753 gnus-simplify-subject-fuzzy-regexp))
eec82323
LMI
1754 (gnus-simplify-subject-fuzzy-regexp
1755 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1756 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1757 (gnus-simplify-buffer-fuzzy-step
1758 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1759 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1760
1761 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1762 (gnus-simplify-buffer-fuzzy-step " +" " ")
1763 (gnus-simplify-buffer-fuzzy-step " $")
1764 (gnus-simplify-buffer-fuzzy-step "^ +")))
1765
1766(defun gnus-simplify-subject-fuzzy (subject)
1767 "Simplify a subject string fuzzily.
6748645f 1768See `gnus-simplify-buffer-fuzzy' for details."
eec82323
LMI
1769 (save-excursion
1770 (gnus-set-work-buffer)
1771 (let ((case-fold-search t))
6748645f
LMI
1772 ;; Remove uninteresting prefixes.
1773 (when (and gnus-simplify-ignored-prefixes
1774 (string-match gnus-simplify-ignored-prefixes subject))
1775 (setq subject (substring subject (match-end 0))))
eec82323
LMI
1776 (insert subject)
1777 (inline (gnus-simplify-buffer-fuzzy))
1778 (buffer-string))))
1779
1780(defsubst gnus-simplify-subject-fully (subject)
23f87bed 1781 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
eec82323 1782 (cond
6748645f
LMI
1783 (gnus-simplify-subject-functions
1784 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1785 ((null gnus-summary-gather-subject-limit)
1786 (gnus-simplify-subject-re subject))
1787 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1788 (gnus-simplify-subject-fuzzy subject))
1789 ((numberp gnus-summary-gather-subject-limit)
01c52d31
MB
1790 (truncate-string-to-width (gnus-simplify-subject-re subject)
1791 gnus-summary-gather-subject-limit))
eec82323
LMI
1792 (t
1793 subject)))
1794
1795(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f 1796 "Check whether two subjects are equal.
23f87bed 1797If optional argument SIMPLE-FIRST is t, first argument is already
6748645f 1798simplified."
eec82323
LMI
1799 (cond
1800 ((null simple-first)
1801 (equal (gnus-simplify-subject-fully s1)
1802 (gnus-simplify-subject-fully s2)))
1803 (t
1804 (equal s1
1805 (gnus-simplify-subject-fully s2)))))
1806
1807(defun gnus-summary-bubble-group ()
1808 "Increase the score of the current group.
1809This is a handy function to add to `gnus-summary-exit-hook' to
1810increase the score of each group you read."
1811 (gnus-group-add-score gnus-newsgroup-name))
1812
1813\f
1814;;;
1815;;; Gnus summary mode
1816;;;
1817
1818(put 'gnus-summary-mode 'mode-class 'special)
1819
1653df0f
SZ
1820(defvar gnus-article-commands-menu)
1821
23f87bed
MB
1822;; Non-orthogonal keys
1823
1824(gnus-define-keys gnus-summary-mode-map
1825 " " gnus-summary-next-page
1826 "\177" gnus-summary-prev-page
1827 [delete] gnus-summary-prev-page
1828 [backspace] gnus-summary-prev-page
1829 "\r" gnus-summary-scroll-up
1830 "\M-\r" gnus-summary-scroll-down
1831 "n" gnus-summary-next-unread-article
1832 "p" gnus-summary-prev-unread-article
1833 "N" gnus-summary-next-article
1834 "P" gnus-summary-prev-article
1835 "\M-\C-n" gnus-summary-next-same-subject
1836 "\M-\C-p" gnus-summary-prev-same-subject
1837 "\M-n" gnus-summary-next-unread-subject
1838 "\M-p" gnus-summary-prev-unread-subject
1839 "." gnus-summary-first-unread-article
1840 "," gnus-summary-best-unread-article
1841 "\M-s" gnus-summary-search-article-forward
1842 "\M-r" gnus-summary-search-article-backward
01c52d31
MB
1843 "\M-S" gnus-summary-repeat-search-article-forward
1844 "\M-R" gnus-summary-repeat-search-article-backward
23f87bed
MB
1845 "<" gnus-summary-beginning-of-article
1846 ">" gnus-summary-end-of-article
1847 "j" gnus-summary-goto-article
1848 "^" gnus-summary-refer-parent-article
1849 "\M-^" gnus-summary-refer-article
1850 "u" gnus-summary-tick-article-forward
1851 "!" gnus-summary-tick-article-forward
1852 "U" gnus-summary-tick-article-backward
1853 "d" gnus-summary-mark-as-read-forward
1854 "D" gnus-summary-mark-as-read-backward
1855 "E" gnus-summary-mark-as-expirable
1856 "\M-u" gnus-summary-clear-mark-forward
1857 "\M-U" gnus-summary-clear-mark-backward
1858 "k" gnus-summary-kill-same-subject-and-select
1859 "\C-k" gnus-summary-kill-same-subject
1860 "\M-\C-k" gnus-summary-kill-thread
1861 "\M-\C-l" gnus-summary-lower-thread
1862 "e" gnus-summary-edit-article
1863 "#" gnus-summary-mark-as-processable
1864 "\M-#" gnus-summary-unmark-as-processable
1865 "\M-\C-t" gnus-summary-toggle-threads
1866 "\M-\C-s" gnus-summary-show-thread
1867 "\M-\C-h" gnus-summary-hide-thread
1868 "\M-\C-f" gnus-summary-next-thread
1869 "\M-\C-b" gnus-summary-prev-thread
1870 [(meta down)] gnus-summary-next-thread
1871 [(meta up)] gnus-summary-prev-thread
1872 "\M-\C-u" gnus-summary-up-thread
1873 "\M-\C-d" gnus-summary-down-thread
1874 "&" gnus-summary-execute-command
1875 "c" gnus-summary-catchup-and-exit
1876 "\C-w" gnus-summary-mark-region-as-read
1877 "\C-t" gnus-summary-toggle-truncation
1878 "?" gnus-summary-mark-as-dormant
1879 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1880 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6ecfe5c2 1881 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
23f87bed
MB
1882 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1883 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1884 "\C-c\C-s\C-a" gnus-summary-sort-by-author
01c52d31 1885 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
23f87bed
MB
1886 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1887 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6ecfe5c2 1888 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
23f87bed
MB
1889 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1890 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1891 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1892 "=" gnus-summary-expand-window
1893 "\C-x\C-s" gnus-summary-reselect-current-group
1894 "\M-g" gnus-summary-rescan-group
23f87bed
MB
1895 "\C-c\C-r" gnus-summary-caesar-message
1896 "f" gnus-summary-followup
1897 "F" gnus-summary-followup-with-original
1898 "C" gnus-summary-cancel-article
1899 "r" gnus-summary-reply
1900 "R" gnus-summary-reply-with-original
1901 "\C-c\C-f" gnus-summary-mail-forward
1902 "o" gnus-summary-save-article
1903 "\C-o" gnus-summary-save-article-mail
1904 "|" gnus-summary-pipe-output
1905 "\M-k" gnus-summary-edit-local-kill
1906 "\M-K" gnus-summary-edit-global-kill
1907 ;; "V" gnus-version
1908 "\C-c\C-d" gnus-summary-describe-group
1909 "q" gnus-summary-exit
1910 "Q" gnus-summary-exit-no-update
1911 "\C-c\C-i" gnus-info-find-node
1912 gnus-mouse-2 gnus-mouse-pick-article
132cf96d 1913 [follow-link] mouse-face
23f87bed
MB
1914 "m" gnus-summary-mail-other-window
1915 "a" gnus-summary-post-news
23f87bed
MB
1916 "x" gnus-summary-limit-to-unread
1917 "s" gnus-summary-isearch-article
d50717f0 1918 [tab] gnus-summary-widget-forward
23f87bed
MB
1919 "t" gnus-summary-toggle-header
1920 "g" gnus-summary-show-article
1921 "l" gnus-summary-goto-last-article
1922 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1923 "\C-d" gnus-summary-enter-digest-group
1924 "\M-\C-d" gnus-summary-read-document
1925 "\M-\C-e" gnus-summary-edit-parameters
1926 "\M-\C-a" gnus-summary-customize-parameters
1927 "\C-c\C-b" gnus-bug
1928 "*" gnus-cache-enter-article
1929 "\M-*" gnus-cache-remove-article
1930 "\M-&" gnus-summary-universal-argument
1931 "\C-l" gnus-recenter
1932 "I" gnus-summary-increase-score
1933 "L" gnus-summary-lower-score
1934 "\M-i" gnus-symbolic-argument
1935 "h" gnus-summary-select-article-buffer
1936
1937 "b" gnus-article-view-part
1938 "\M-t" gnus-summary-toggle-display-buttonized
1939
1940 "V" gnus-summary-score-map
1941 "X" gnus-uu-extract-map
1942 "S" gnus-summary-send-map)
1943
1944;; Sort of orthogonal keymap
1945(gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1946 "t" gnus-summary-tick-article-forward
1947 "!" gnus-summary-tick-article-forward
1948 "d" gnus-summary-mark-as-read-forward
1949 "r" gnus-summary-mark-as-read-forward
1950 "c" gnus-summary-clear-mark-forward
1951 " " gnus-summary-clear-mark-forward
1952 "e" gnus-summary-mark-as-expirable
1953 "x" gnus-summary-mark-as-expirable
1954 "?" gnus-summary-mark-as-dormant
1955 "b" gnus-summary-set-bookmark
1956 "B" gnus-summary-remove-bookmark
1957 "#" gnus-summary-mark-as-processable
1958 "\M-#" gnus-summary-unmark-as-processable
1959 "S" gnus-summary-limit-include-expunged
1960 "C" gnus-summary-catchup
1961 "H" gnus-summary-catchup-to-here
1962 "h" gnus-summary-catchup-from-here
1963 "\C-c" gnus-summary-catchup-all
1964 "k" gnus-summary-kill-same-subject-and-select
1965 "K" gnus-summary-kill-same-subject
1966 "P" gnus-uu-mark-map)
1967
1968(gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1969 "c" gnus-summary-clear-above
1970 "u" gnus-summary-tick-above
1971 "m" gnus-summary-mark-above
1972 "k" gnus-summary-kill-below)
1973
1974(gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1975 "/" gnus-summary-limit-to-subject
1976 "n" gnus-summary-limit-to-articles
01c52d31
MB
1977 "b" gnus-summary-limit-to-bodies
1978 "h" gnus-summary-limit-to-headers
23f87bed
MB
1979 "w" gnus-summary-pop-limit
1980 "s" gnus-summary-limit-to-subject
1981 "a" gnus-summary-limit-to-author
1982 "u" gnus-summary-limit-to-unread
1983 "m" gnus-summary-limit-to-marks
1984 "M" gnus-summary-limit-exclude-marks
1985 "v" gnus-summary-limit-to-score
1986 "*" gnus-summary-limit-include-cached
1987 "D" gnus-summary-limit-include-dormant
1988 "T" gnus-summary-limit-include-thread
1989 "d" gnus-summary-limit-exclude-dormant
1990 "t" gnus-summary-limit-to-age
1991 "." gnus-summary-limit-to-unseen
1992 "x" gnus-summary-limit-to-extra
1993 "p" gnus-summary-limit-to-display-predicate
1994 "E" gnus-summary-limit-include-expunged
1995 "c" gnus-summary-limit-exclude-childless-dormant
1996 "C" gnus-summary-limit-mark-excluded-as-read
1997 "o" gnus-summary-insert-old-articles
01c52d31
MB
1998 "N" gnus-summary-insert-new-articles
1999 "S" gnus-summary-limit-to-singletons
2000 "r" gnus-summary-limit-to-replied
2001 "R" gnus-summary-limit-to-recipient
2002 "A" gnus-summary-limit-to-address)
23f87bed
MB
2003
2004(gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2005 "n" gnus-summary-next-unread-article
2006 "p" gnus-summary-prev-unread-article
2007 "N" gnus-summary-next-article
2008 "P" gnus-summary-prev-article
2009 "\C-n" gnus-summary-next-same-subject
2010 "\C-p" gnus-summary-prev-same-subject
2011 "\M-n" gnus-summary-next-unread-subject
2012 "\M-p" gnus-summary-prev-unread-subject
2013 "f" gnus-summary-first-unread-article
2014 "b" gnus-summary-best-unread-article
2015 "j" gnus-summary-goto-article
2016 "g" gnus-summary-goto-subject
2017 "l" gnus-summary-goto-last-article
2018 "o" gnus-summary-pop-article)
2019
2020(gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2021 "k" gnus-summary-kill-thread
01c52d31 2022 "E" gnus-summary-expire-thread
23f87bed
MB
2023 "l" gnus-summary-lower-thread
2024 "i" gnus-summary-raise-thread
2025 "T" gnus-summary-toggle-threads
2026 "t" gnus-summary-rethread-current
2027 "^" gnus-summary-reparent-thread
01c52d31 2028 "\M-^" gnus-summary-reparent-children
23f87bed
MB
2029 "s" gnus-summary-show-thread
2030 "S" gnus-summary-show-all-threads
2031 "h" gnus-summary-hide-thread
2032 "H" gnus-summary-hide-all-threads
2033 "n" gnus-summary-next-thread
2034 "p" gnus-summary-prev-thread
2035 "u" gnus-summary-up-thread
2036 "o" gnus-summary-top-thread
2037 "d" gnus-summary-down-thread
2038 "#" gnus-uu-mark-thread
2039 "\M-#" gnus-uu-unmark-thread)
2040
2041(gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2042 "g" gnus-summary-prepare
2043 "c" gnus-summary-insert-cached-articles
01c52d31
MB
2044 "d" gnus-summary-insert-dormant-articles
2045 "t" gnus-summary-insert-ticked-articles)
23f87bed
MB
2046
2047(gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2048 "c" gnus-summary-catchup-and-exit
2049 "C" gnus-summary-catchup-all-and-exit
2050 "E" gnus-summary-exit-no-update
2051 "Q" gnus-summary-exit
2052 "Z" gnus-summary-exit
2053 "n" gnus-summary-catchup-and-goto-next-group
01c52d31 2054 "p" gnus-summary-catchup-and-goto-prev-group
23f87bed
MB
2055 "R" gnus-summary-reselect-current-group
2056 "G" gnus-summary-rescan-group
2057 "N" gnus-summary-next-group
2058 "s" gnus-summary-save-newsrc
2059 "P" gnus-summary-prev-group)
2060
2061(gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2062 " " gnus-summary-next-page
2063 "n" gnus-summary-next-page
2064 "\177" gnus-summary-prev-page
2065 [delete] gnus-summary-prev-page
2066 "p" gnus-summary-prev-page
2067 "\r" gnus-summary-scroll-up
2068 "\M-\r" gnus-summary-scroll-down
2069 "<" gnus-summary-beginning-of-article
2070 ">" gnus-summary-end-of-article
2071 "b" gnus-summary-beginning-of-article
2072 "e" gnus-summary-end-of-article
2073 "^" gnus-summary-refer-parent-article
2074 "r" gnus-summary-refer-parent-article
8ccbef23 2075 "C" gnus-summary-show-complete-article
23f87bed
MB
2076 "D" gnus-summary-enter-digest-group
2077 "R" gnus-summary-refer-references
2078 "T" gnus-summary-refer-thread
4ddab346 2079 "W" gnus-warp-to-article
23f87bed
MB
2080 "g" gnus-summary-show-article
2081 "s" gnus-summary-isearch-article
d50717f0 2082 [tab] gnus-summary-widget-forward
23f87bed 2083 "P" gnus-summary-print-article
01c52d31 2084 "S" gnus-sticky-article
23f87bed
MB
2085 "M" gnus-mailing-list-insinuate
2086 "t" gnus-article-babel)
2087
2088(gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2089 "b" gnus-article-add-buttons
2090 "B" gnus-article-add-buttons-to-head
2091 "o" gnus-article-treat-overstrike
2092 "e" gnus-article-emphasize
2093 "w" gnus-article-fill-cited-article
2094 "Q" gnus-article-fill-long-lines
01c52d31 2095 "L" gnus-article-toggle-truncate-lines
23f87bed
MB
2096 "C" gnus-article-capitalize-sentences
2097 "c" gnus-article-remove-cr
2098 "q" gnus-article-de-quoted-unreadable
2099 "6" gnus-article-de-base64-unreadable
2100 "Z" gnus-article-decode-HZ
01c52d31 2101 "A" gnus-article-treat-ansi-sequences
23f87bed
MB
2102 "h" gnus-article-wash-html
2103 "u" gnus-article-unsplit-urls
2104 "s" gnus-summary-force-verify-and-decrypt
2105 "f" gnus-article-display-x-face
2106 "l" gnus-summary-stop-page-breaking
2107 "r" gnus-summary-caesar-message
2108 "m" gnus-summary-morse-message
2109 "t" gnus-summary-toggle-header
2110 "g" gnus-treat-smiley
2111 "v" gnus-summary-verbose-headers
2112 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2113 "p" gnus-article-verify-x-pgp-sig
01c52d31 2114 "d" gnus-article-treat-dumbquotes
be3c11b3 2115 "U" gnus-article-treat-non-ascii
01c52d31 2116 "i" gnus-summary-idna-message)
23f87bed
MB
2117
2118(gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2119 ;; mnemonic: deuglif*Y*
2120 "u" gnus-article-outlook-unwrap-lines
2121 "a" gnus-article-outlook-repair-attribution
2122 "c" gnus-article-outlook-rearrange-citation
2123 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2124
2125(gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2126 "a" gnus-article-hide
2127 "h" gnus-article-hide-headers
2128 "b" gnus-article-hide-boring-headers
2129 "s" gnus-article-hide-signature
2130 "c" gnus-article-hide-citation
2131 "C" gnus-article-hide-citation-in-followups
2132 "l" gnus-article-hide-list-identifiers
2133 "B" gnus-article-strip-banner
2134 "P" gnus-article-hide-pem
2135 "\C-c" gnus-article-hide-citation-maybe)
2136
2137(gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2138 "a" gnus-article-highlight
2139 "h" gnus-article-highlight-headers
2140 "c" gnus-article-highlight-citation
2141 "s" gnus-article-highlight-signature)
2142
2143(gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2144 "f" gnus-article-treat-fold-headers
2145 "u" gnus-article-treat-unfold-headers
2146 "n" gnus-article-treat-fold-newsgroups)
2147
2148(gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2149 "x" gnus-article-display-x-face
2150 "d" gnus-article-display-face
2151 "s" gnus-treat-smiley
2152 "D" gnus-article-remove-images
8b6f6573 2153 "W" gnus-article-show-images
23f87bed
MB
2154 "f" gnus-treat-from-picon
2155 "m" gnus-treat-mail-picon
61b1af82
G
2156 "n" gnus-treat-newsgroups-picon
2157 "g" gnus-treat-from-gravatar
2158 "h" gnus-treat-mail-gravatar)
23f87bed
MB
2159
2160(gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2161 "w" gnus-article-decode-mime-words
2162 "c" gnus-article-decode-charset
2163 "v" gnus-mime-view-all-parts
2164 "b" gnus-article-view-part)
2165
2166(gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2167 "z" gnus-article-date-ut
2168 "u" gnus-article-date-ut
2169 "l" gnus-article-date-local
2170 "p" gnus-article-date-english
2171 "e" gnus-article-date-lapsed
2172 "o" gnus-article-date-original
2173 "i" gnus-article-date-iso8601
2174 "s" gnus-article-date-user)
2175
2176(gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2177 "t" gnus-article-remove-trailing-blank-lines
2178 "l" gnus-article-strip-leading-blank-lines
2179 "m" gnus-article-strip-multiple-blank-lines
2180 "a" gnus-article-strip-blank-lines
2181 "A" gnus-article-strip-all-blank-lines
2182 "s" gnus-article-strip-leading-space
2183 "e" gnus-article-strip-trailing-space
2184 "w" gnus-article-remove-leading-whitespace)
2185
2186(gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2187 "v" gnus-version
23f87bed
MB
2188 "d" gnus-summary-describe-group
2189 "h" gnus-summary-describe-briefly
837ba704 2190 "i" gnus-info-find-node)
23f87bed
MB
2191
2192(gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2193 "e" gnus-summary-expire-articles
2194 "\M-\C-e" gnus-summary-expire-articles-now
2195 "\177" gnus-summary-delete-article
2196 [delete] gnus-summary-delete-article
2197 [backspace] gnus-summary-delete-article
2198 "m" gnus-summary-move-article
2199 "r" gnus-summary-respool-article
2200 "w" gnus-summary-edit-article
2201 "c" gnus-summary-copy-article
2202 "B" gnus-summary-crosspost-article
2203 "q" gnus-summary-respool-query
2204 "t" gnus-summary-respool-trace
2205 "i" gnus-summary-import-article
2206 "I" gnus-summary-create-article
2207 "p" gnus-summary-article-posted-p)
2208
2209(gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2210 "o" gnus-summary-save-article
2211 "m" gnus-summary-save-article-mail
2212 "F" gnus-summary-write-article-file
2213 "r" gnus-summary-save-article-rmail
2214 "f" gnus-summary-save-article-file
2215 "b" gnus-summary-save-article-body-file
26c9afc3 2216 "B" gnus-summary-write-article-body-file
23f87bed
MB
2217 "h" gnus-summary-save-article-folder
2218 "v" gnus-summary-save-article-vm
2219 "p" gnus-summary-pipe-output
c4d82de8 2220 "P" gnus-summary-muttprint)
23f87bed
MB
2221
2222(gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2223 "b" gnus-summary-display-buttonized
2224 "m" gnus-summary-repair-multipart
2225 "v" gnus-article-view-part
2226 "o" gnus-article-save-part
01c52d31
MB
2227 "O" gnus-article-save-part-and-strip
2228 "r" gnus-article-replace-part
2229 "d" gnus-article-delete-part
2230 "t" gnus-article-view-part-as-type
2231 "j" gnus-article-jump-to-part
23f87bed
MB
2232 "c" gnus-article-copy-part
2233 "C" gnus-article-view-part-as-charset
2234 "e" gnus-article-view-part-externally
01c52d31 2235 "H" gnus-article-browse-html-article
23f87bed
MB
2236 "E" gnus-article-encrypt-body
2237 "i" gnus-article-inline-part
2238 "|" gnus-article-pipe-part)
2239
2240(gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2241 "p" gnus-summary-mark-as-processable
2242 "u" gnus-summary-unmark-as-processable
2243 "U" gnus-summary-unmark-all-processable
2244 "v" gnus-uu-mark-over
2245 "s" gnus-uu-mark-series
2246 "r" gnus-uu-mark-region
2247 "g" gnus-uu-unmark-region
2248 "R" gnus-uu-mark-by-regexp
2249 "G" gnus-uu-unmark-by-regexp
2250 "t" gnus-uu-mark-thread
2251 "T" gnus-uu-unmark-thread
2252 "a" gnus-uu-mark-all
2253 "b" gnus-uu-mark-buffer
2254 "S" gnus-uu-mark-sparse
2255 "k" gnus-summary-kill-process-mark
2256 "y" gnus-summary-yank-process-mark
2257 "w" gnus-summary-save-process-mark
2258 "i" gnus-uu-invert-processable)
2259
2260(gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2261 ;;"x" gnus-uu-extract-any
2262 "m" gnus-summary-save-parts
2263 "u" gnus-uu-decode-uu
2264 "U" gnus-uu-decode-uu-and-save
2265 "s" gnus-uu-decode-unshar
2266 "S" gnus-uu-decode-unshar-and-save
2267 "o" gnus-uu-decode-save
2268 "O" gnus-uu-decode-save
2269 "b" gnus-uu-decode-binhex
2270 "B" gnus-uu-decode-binhex
b890d447 2271 "Y" gnus-uu-decode-yenc
23f87bed
MB
2272 "p" gnus-uu-decode-postscript
2273 "P" gnus-uu-decode-postscript-and-save)
2274
2275(gnus-define-keys
2276 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2277 "u" gnus-uu-decode-uu-view
2278 "U" gnus-uu-decode-uu-and-save-view
2279 "s" gnus-uu-decode-unshar-view
2280 "S" gnus-uu-decode-unshar-and-save-view
2281 "o" gnus-uu-decode-save-view
2282 "O" gnus-uu-decode-save-view
2283 "b" gnus-uu-decode-binhex-view
2284 "B" gnus-uu-decode-binhex-view
2285 "p" gnus-uu-decode-postscript-view
2286 "P" gnus-uu-decode-postscript-and-save-view)
2287
2288(defvar gnus-article-post-menu nil)
2289
2290(defconst gnus-summary-menu-maxlen 20)
2291
2292(defun gnus-summary-menu-split (menu)
2293 ;; If we have lots of elements, divide them into groups of 20
2294 ;; and make a pane (or submenu) for each one.
2295 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2296 (let ((menu menu) sublists next
2297 (i 1))
2298 (while menu
2299 ;; Pull off the next gnus-summary-menu-maxlen elements
2300 ;; and make them the next element of sublist.
2301 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2302 (if next
2303 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2304 nil))
2305 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2306 (aref (car (last menu)) 0)) menu)
2307 sublists))
2308 (setq i (1+ i))
2309 (setq menu next))
2310 (nreverse sublists))
2311 ;; Few elements--put them all in one pane.
2312 menu))
eec82323
LMI
2313
2314(defun gnus-summary-make-menu-bar ()
2315 (gnus-turn-off-edit-menu 'summary)
2316
2317 (unless (boundp 'gnus-summary-misc-menu)
2318
2319 (easy-menu-define
23f87bed
MB
2320 gnus-summary-kill-menu gnus-summary-mode-map ""
2321 (cons
2322 "Score"
2323 (nconc
2324 (list
2325 ["Customize" gnus-score-customize t])
2326 (gnus-make-score-map 'increase)
2327 (gnus-make-score-map 'lower)
2328 '(("Mark"
2329 ["Kill below" gnus-summary-kill-below t]
2330 ["Mark above" gnus-summary-mark-above t]
2331 ["Tick above" gnus-summary-tick-above t]
2332 ["Clear above" gnus-summary-clear-above t])
2333 ["Current score" gnus-summary-current-score t]
2334 ["Set score" gnus-summary-set-score t]
2335 ["Switch current score file..." gnus-score-change-score-file t]
2336 ["Set mark below..." gnus-score-set-mark-below t]
2337 ["Set expunge below..." gnus-score-set-expunge-below t]
2338 ["Edit current score file" gnus-score-edit-current-scores t]
59429511 2339 ["Edit score file..." gnus-score-edit-file t]
23f87bed
MB
2340 ["Trace score" gnus-score-find-trace t]
2341 ["Find words" gnus-score-find-favourite-words t]
2342 ["Rescore buffer" gnus-summary-rescore t]
2343 ["Increase score..." gnus-summary-increase-score t]
2344 ["Lower score..." gnus-summary-lower-score t]))))
2345
2346 ;; Define both the Article menu in the summary buffer and the
2347 ;; equivalent Commands menu in the article buffer here for
2348 ;; consistency.
6748645f 2349 (let ((innards
23f87bed
MB
2350 `(("Hide"
2351 ["All" gnus-article-hide t]
2352 ["Headers" gnus-article-hide-headers t]
2353 ["Signature" gnus-article-hide-signature t]
2354 ["Citation" gnus-article-hide-citation t]
16409b0b 2355 ["List identifiers" gnus-article-hide-list-identifiers t]
16409b0b 2356 ["Banner" gnus-article-strip-banner t]
23f87bed
MB
2357 ["Boring headers" gnus-article-hide-boring-headers t])
2358 ("Highlight"
2359 ["All" gnus-article-highlight t]
2360 ["Headers" gnus-article-highlight-headers t]
2361 ["Signature" gnus-article-highlight-signature t]
2362 ["Citation" gnus-article-highlight-citation t])
16409b0b
GM
2363 ("MIME"
2364 ["Words" gnus-article-decode-mime-words t]
2365 ["Charset" gnus-article-decode-charset t]
2366 ["QP" gnus-article-de-quoted-unreadable t]
2367 ["Base64" gnus-article-de-base64-unreadable t]
23f87bed
MB
2368 ["View MIME buttons" gnus-summary-display-buttonized t]
2369 ["View all" gnus-mime-view-all-parts t]
2370 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2371 ["Encrypt body" gnus-article-encrypt-body
2372 :active (not (gnus-group-read-only-p))
2373 ,@(if (featurep 'xemacs) nil
2374 '(:help "Encrypt the message body on disk"))]
2375 ["Extract all parts..." gnus-summary-save-parts t]
2376 ("Multipart"
2377 ["Repair multipart" gnus-summary-repair-multipart t]
2378 ["Pipe part..." gnus-article-pipe-part t]
2379 ["Inline part" gnus-article-inline-part t]
01c52d31 2380 ["View part as type..." gnus-article-view-part-as-type t]
23f87bed
MB
2381 ["Encrypt body" gnus-article-encrypt-body
2382 :active (not (gnus-group-read-only-p))
2383 ,@(if (featurep 'xemacs) nil
2384 '(:help "Encrypt the message body on disk"))]
2385 ["View part externally" gnus-article-view-part-externally t]
01c52d31 2386 ["View HTML parts in browser" gnus-article-browse-html-article t]
23f87bed
MB
2387 ["View part with charset..." gnus-article-view-part-as-charset t]
2388 ["Copy part" gnus-article-copy-part t]
2389 ["Save part..." gnus-article-save-part t]
2390 ["View part" gnus-article-view-part t]))
2391 ("Date"
2392 ["Local" gnus-article-date-local t]
2393 ["ISO8601" gnus-article-date-iso8601 t]
2394 ["UT" gnus-article-date-ut t]
2395 ["Original" gnus-article-date-original t]
2396 ["Lapsed" gnus-article-date-lapsed t]
2397 ["User-defined" gnus-article-date-user t])
2398 ("Display"
2399 ["Remove images" gnus-article-remove-images t]
2400 ["Toggle smiley" gnus-treat-smiley t]
2401 ["Show X-Face" gnus-article-display-x-face t]
2402 ["Show picons in From" gnus-treat-from-picon t]
2403 ["Show picons in mail headers" gnus-treat-mail-picon t]
2404 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
61b1af82
G
2405 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2406 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
23f87bed
MB
2407 ("View as different encoding"
2408 ,@(gnus-summary-menu-split
2409 (mapcar
2410 (lambda (cs)
2411 ;; Since easymenu under Emacs doesn't allow
2412 ;; lambda forms for menu commands, we should
2413 ;; provide intern'ed function symbols.
2414 (let ((command (intern (format "\
2415gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2416 (fset command
2417 `(lambda ()
2418 (interactive)
2419 (let ((gnus-summary-show-article-charset-alist
2420 '((1 . ,cs))))
2421 (gnus-summary-show-article 1))))
2422 `[,(symbol-name cs) ,command t]))
2423 (sort (if (fboundp 'coding-system-list)
2424 (coding-system-list)
2425 (mapcar 'car mm-mime-mule-charset-alist))
2426 'string<)))))
2427 ("Washing"
2428 ("Remove Blanks"
2429 ["Leading" gnus-article-strip-leading-blank-lines t]
2430 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2431 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2432 ["All of the above" gnus-article-strip-blank-lines t]
2433 ["All" gnus-article-strip-all-blank-lines t]
2434 ["Leading space" gnus-article-strip-leading-space t]
2435 ["Trailing space" gnus-article-strip-trailing-space t]
2436 ["Leading space in headers"
2437 gnus-article-remove-leading-whitespace t])
2438 ["Overstrike" gnus-article-treat-overstrike t]
2439 ["Dumb quotes" gnus-article-treat-dumbquotes t]
be3c11b3 2440 ["Non-ASCII" gnus-article-treat-non-ascii t]
23f87bed
MB
2441 ["Emphasis" gnus-article-emphasize t]
2442 ["Word wrap" gnus-article-fill-cited-article t]
16409b0b 2443 ["Fill long lines" gnus-article-fill-long-lines t]
01c52d31 2444 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
16409b0b 2445 ["Capitalize sentences" gnus-article-capitalize-sentences t]
23f87bed
MB
2446 ["Remove CR" gnus-article-remove-cr t]
2447 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2448 ["Base64" gnus-article-de-base64-unreadable t]
2449 ["Rot 13" gnus-summary-caesar-message
2450 ,@(if (featurep 'xemacs) '(t)
2451 '(:help "\"Caesar rotate\" article by 13"))]
01c52d31 2452 ["De-IDNA" gnus-summary-idna-message t]
23f87bed
MB
2453 ["Morse decode" gnus-summary-morse-message t]
2454 ["Unix pipe..." gnus-summary-pipe-message t]
2455 ["Add buttons" gnus-article-add-buttons t]
2456 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2457 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2458 ["Verbose header" gnus-summary-verbose-headers t]
2459 ["Toggle header" gnus-summary-toggle-header t]
2460 ["Unfold headers" gnus-article-treat-unfold-headers t]
2461 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
16409b0b 2462 ["Html" gnus-article-wash-html t]
23f87bed
MB
2463 ["Unsplit URLs" gnus-article-unsplit-urls t]
2464 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2465 ["Decode HZ" gnus-article-decode-HZ t]
01c52d31 2466 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
23f87bed
MB
2467 ("(Outlook) Deuglify"
2468 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2469 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2470 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2471 ["Full (Outlook) deuglify"
2472 gnus-article-outlook-deuglify-article t])
2473 )
2474 ("Output"
2475 ["Save in default format..." gnus-summary-save-article
2476 ,@(if (featurep 'xemacs) '(t)
2477 '(:help "Save article using default method"))]
2478 ["Save in file..." gnus-summary-save-article-file
2479 ,@(if (featurep 'xemacs) '(t)
2480 '(:help "Save article in file"))]
2481 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2482 ["Save in MH folder..." gnus-summary-save-article-folder t]
2483 ["Save in VM folder..." gnus-summary-save-article-vm t]
2484 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2485 ["Save body in file..." gnus-summary-save-article-body-file t]
2486 ["Pipe through a filter..." gnus-summary-pipe-output t]
23f87bed 2487 ["Print with Muttprint..." gnus-summary-muttprint t]
531e5812
MB
2488 ["Print" gnus-summary-print-article
2489 ,@(if (featurep 'xemacs) '(t)
2490 '(:help "Generate and print a PostScript image"))])
2491 ("Copy, move,... (Backend)"
707f2b38 2492 ,@(if (featurep 'xemacs) nil
531e5812 2493 '(:help "Copying, moving, expiring articles..."))
23f87bed
MB
2494 ["Respool article..." gnus-summary-respool-article t]
2495 ["Move article..." gnus-summary-move-article
2496 (gnus-check-backend-function
2497 'request-move-article gnus-newsgroup-name)]
2498 ["Copy article..." gnus-summary-copy-article t]
2499 ["Crosspost article..." gnus-summary-crosspost-article
2500 (gnus-check-backend-function
2501 'request-replace-article gnus-newsgroup-name)]
2502 ["Import file..." gnus-summary-import-article
2503 (gnus-check-backend-function
2504 'request-accept-article gnus-newsgroup-name)]
2505 ["Create article..." gnus-summary-create-article
2506 (gnus-check-backend-function
2507 'request-accept-article gnus-newsgroup-name)]
2508 ["Check if posted" gnus-summary-article-posted-p t]
2509 ["Edit article" gnus-summary-edit-article
2510 (not (gnus-group-read-only-p))]
2511 ["Delete article" gnus-summary-delete-article
2512 (gnus-check-backend-function
2513 'request-expire-articles gnus-newsgroup-name)]
2514 ["Query respool" gnus-summary-respool-query t]
6748645f 2515 ["Trace respool" gnus-summary-respool-trace t]
23f87bed
MB
2516 ["Delete expirable articles" gnus-summary-expire-articles-now
2517 (gnus-check-backend-function
2518 'request-expire-articles gnus-newsgroup-name)])
2519 ("Extract"
2520 ["Uudecode" gnus-uu-decode-uu
2521 ,@(if (featurep 'xemacs) '(t)
2522 '(:help "Decode uuencoded article(s)"))]
2523 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2524 ["Unshar" gnus-uu-decode-unshar t]
2525 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2526 ["Save" gnus-uu-decode-save t]
2527 ["Binhex" gnus-uu-decode-binhex t]
2528 ["Postscript" gnus-uu-decode-postscript t]
2529 ["All MIME parts" gnus-summary-save-parts t])
2530 ("Cache"
2531 ["Enter article" gnus-cache-enter-article t]
2532 ["Remove article" gnus-cache-remove-article t])
16409b0b 2533 ["Translate" gnus-article-babel t]
23f87bed 2534 ["Select article buffer" gnus-summary-select-article-buffer t]
01c52d31 2535 ["Make article buffer sticky" gnus-sticky-article t]
23f87bed
MB
2536 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2537 ["Isearch article..." gnus-summary-isearch-article t]
2538 ["Beginning of the article" gnus-summary-beginning-of-article t]
2539 ["End of the article" gnus-summary-end-of-article t]
2540 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2541 ["Fetch referenced articles" gnus-summary-refer-references t]
2542 ["Fetch current thread" gnus-summary-refer-thread t]
2543 ["Fetch article with id..." gnus-summary-refer-article t]
2544 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2545 ["Redisplay" gnus-summary-show-article t]
2546 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
6748645f 2547 (easy-menu-define
23f87bed
MB
2548 gnus-summary-article-menu gnus-summary-mode-map ""
2549 (cons "Article" innards))
6748645f 2550
1653df0f
SZ
2551 (if (not (keymapp gnus-summary-article-menu))
2552 (easy-menu-define
2553 gnus-article-commands-menu gnus-article-mode-map ""
2554 (cons "Commands" innards))
2555 ;; in Emacs, don't share menu.
a1506d29 2556 (setq gnus-article-commands-menu
1653df0f
SZ
2557 (copy-keymap gnus-summary-article-menu))
2558 (define-key gnus-article-mode-map [menu-bar commands]
2559 (cons "Commands" gnus-article-commands-menu))))
eec82323
LMI
2560
2561 (easy-menu-define
23f87bed
MB
2562 gnus-summary-thread-menu gnus-summary-mode-map ""
2563 '("Threads"
2564 ["Find all messages in thread" gnus-summary-refer-thread t]
2565 ["Toggle threading" gnus-summary-toggle-threads t]
2566 ["Hide threads" gnus-summary-hide-all-threads t]
2567 ["Show threads" gnus-summary-show-all-threads t]
2568 ["Hide thread" gnus-summary-hide-thread t]
2569 ["Show thread" gnus-summary-show-thread t]
2570 ["Go to next thread" gnus-summary-next-thread t]
2571 ["Go to previous thread" gnus-summary-prev-thread t]
2572 ["Go down thread" gnus-summary-down-thread t]
2573 ["Go up thread" gnus-summary-up-thread t]
2574 ["Top of thread" gnus-summary-top-thread t]
2575 ["Mark thread as read" gnus-summary-kill-thread t]
01c52d31 2576 ["Mark thread as expired" gnus-summary-expire-thread t]
23f87bed
MB
2577 ["Lower thread score" gnus-summary-lower-thread t]
2578 ["Raise thread score" gnus-summary-raise-thread t]
2579 ["Rethread current" gnus-summary-rethread-current t]))
eec82323
LMI
2580
2581 (easy-menu-define
23f87bed
MB
2582 gnus-summary-post-menu gnus-summary-mode-map ""
2583 `("Post"
2584 ["Send a message (mail or news)" gnus-summary-post-news
2585 ,@(if (featurep 'xemacs) '(t)
531e5812 2586 '(:help "Compose a new message (mail or news)"))]
23f87bed
MB
2587 ["Followup" gnus-summary-followup
2588 ,@(if (featurep 'xemacs) '(t)
2589 '(:help "Post followup to this article"))]
2590 ["Followup and yank" gnus-summary-followup-with-original
2591 ,@(if (featurep 'xemacs) '(t)
2592 '(:help "Post followup to this article, quoting its contents"))]
2593 ["Supersede article" gnus-summary-supersede-article t]
2594 ["Cancel article" gnus-summary-cancel-article
2595 ,@(if (featurep 'xemacs) '(t)
2596 '(:help "Cancel an article you posted"))]
2597 ["Reply" gnus-summary-reply t]
2598 ["Reply and yank" gnus-summary-reply-with-original t]
2599 ["Wide reply" gnus-summary-wide-reply t]
2600 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2601 ,@(if (featurep 'xemacs) '(t)
2602 '(:help "Mail a reply, quoting this article"))]
2603 ["Very wide reply" gnus-summary-very-wide-reply t]
2604 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2605 ,@(if (featurep 'xemacs) '(t)
2606 '(:help "Mail a very wide reply, quoting this article"))]
2607 ["Mail forward" gnus-summary-mail-forward t]
2608 ["Post forward" gnus-summary-post-forward t]
2609 ["Digest and mail" gnus-uu-digest-mail-forward t]
2610 ["Digest and post" gnus-uu-digest-post-forward t]
2611 ["Resend message" gnus-summary-resend-message t]
2612 ["Resend message edit" gnus-summary-resend-message-edit t]
2613 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2614 ["Send a mail" gnus-summary-mail-other-window t]
2615 ["Create a local message" gnus-summary-news-other-window t]
2616 ["Uuencode and post" gnus-uu-post-news
2617 ,@(if (featurep 'xemacs) '(t)
2618 '(:help "Post a uuencoded article"))]
2619 ["Followup via news" gnus-summary-followup-to-mail t]
2620 ["Followup via news and yank"
2621 gnus-summary-followup-to-mail-with-original t]
9b3ebcb6
MB
2622 ["Strip signature on reply"
2623 (lambda ()
2624 (interactive)
2625 (if (not (memq message-cite-function
2626 '(message-cite-original-without-signature
2627 message-cite-original)))
2628 ;; Stupid workaround for XEmacs not honoring :visible.
2629 (message "Can't toggle this value of `message-cite-function'")
2630 (setq message-cite-function
2631 (if (eq message-cite-function
2632 'message-cite-original-without-signature)
2633 'message-cite-original
2634 'message-cite-original-without-signature))))
2635 ;; XEmacs barfs on :visible.
2636 ,@(if (featurep 'xemacs) nil
2637 '(:visible (memq message-cite-function
2638 '(message-cite-original-without-signature
2639 message-cite-original))))
2640 :style toggle
2641 :selected (eq message-cite-function
2642 'message-cite-original-without-signature)
2643 ,@(if (featurep 'xemacs) nil
2644 '(:help "Strip signature from cited article when replying."))]
23f87bed
MB
2645 ;;("Draft"
2646 ;;["Send" gnus-summary-send-draft t]
2647 ;;["Send bounced" gnus-resend-bounced-mail t])
2648 ))
2649
2650 (cond
2651 ((not (keymapp gnus-summary-post-menu))
2652 (setq gnus-article-post-menu gnus-summary-post-menu))
2653 ((not gnus-article-post-menu)
2654 ;; Don't share post menu.
2655 (setq gnus-article-post-menu
2656 (copy-keymap gnus-summary-post-menu))))
2657 (define-key gnus-article-mode-map [menu-bar post]
2658 (cons "Post" gnus-article-post-menu))
eec82323
LMI
2659
2660 (easy-menu-define
23f87bed
MB
2661 gnus-summary-misc-menu gnus-summary-mode-map ""
2662 `("Gnus"
2663 ("Mark Read"
2664 ["Mark as read" gnus-summary-mark-as-read-forward t]
2665 ["Mark same subject and select"
2666 gnus-summary-kill-same-subject-and-select t]
2667 ["Mark same subject" gnus-summary-kill-same-subject t]
2668 ["Catchup" gnus-summary-catchup
2669 ,@(if (featurep 'xemacs) '(t)
2670 '(:help "Mark unread articles in this group as read"))]
2671 ["Catchup all" gnus-summary-catchup-all t]
2672 ["Catchup to here" gnus-summary-catchup-to-here t]
2673 ["Catchup from here" gnus-summary-catchup-from-here t]
2674 ["Catchup region" gnus-summary-mark-region-as-read
2675 (gnus-mark-active-p)]
2676 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2677 ("Mark Various"
2678 ["Tick" gnus-summary-tick-article-forward t]
2679 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2680 ["Remove marks" gnus-summary-clear-mark-forward t]
2681 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2682 ["Set bookmark" gnus-summary-set-bookmark t]
2683 ["Remove bookmark" gnus-summary-remove-bookmark t])
2684 ("Limit to"
2685 ["Marks..." gnus-summary-limit-to-marks t]
2686 ["Subject..." gnus-summary-limit-to-subject t]
2687 ["Author..." gnus-summary-limit-to-author t]
01c52d31
MB
2688 ["Recipient..." gnus-summary-limit-to-recipient t]
2689 ["Address..." gnus-summary-limit-to-address t]
23f87bed
MB
2690 ["Age..." gnus-summary-limit-to-age t]
2691 ["Extra..." gnus-summary-limit-to-extra t]
2692 ["Score..." gnus-summary-limit-to-score t]
2693 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2694 ["Unread" gnus-summary-limit-to-unread t]
2695 ["Unseen" gnus-summary-limit-to-unseen t]
01c52d31
MB
2696 ["Singletons" gnus-summary-limit-to-singletons t]
2697 ["Replied" gnus-summary-limit-to-replied t]
23f87bed 2698 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
996aa8c1 2699 ["Next or process marked articles" gnus-summary-limit-to-articles t]
23f87bed
MB
2700 ["Pop limit" gnus-summary-pop-limit t]
2701 ["Show dormant" gnus-summary-limit-include-dormant t]
2702 ["Hide childless dormant"
2703 gnus-summary-limit-exclude-childless-dormant t]
2704 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2705 ["Hide marked" gnus-summary-limit-exclude-marks t]
2706 ["Show expunged" gnus-summary-limit-include-expunged t])
2707 ("Process Mark"
2708 ["Set mark" gnus-summary-mark-as-processable t]
2709 ["Remove mark" gnus-summary-unmark-as-processable t]
2710 ["Remove all marks" gnus-summary-unmark-all-processable t]
01c52d31 2711 ["Invert marks" gnus-uu-invert-processable t]
23f87bed
MB
2712 ["Mark above" gnus-uu-mark-over t]
2713 ["Mark series" gnus-uu-mark-series t]
2714 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2715 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2716 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2717 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2718 ["Mark all" gnus-uu-mark-all t]
2719 ["Mark buffer" gnus-uu-mark-buffer t]
2720 ["Mark sparse" gnus-uu-mark-sparse t]
2721 ["Mark thread" gnus-uu-mark-thread t]
2722 ["Unmark thread" gnus-uu-unmark-thread t]
2723 ("Process Mark Sets"
2724 ["Kill" gnus-summary-kill-process-mark t]
2725 ["Yank" gnus-summary-yank-process-mark
2726 gnus-newsgroup-process-stack]
2727 ["Save" gnus-summary-save-process-mark t]
2728 ["Run command on marked..." gnus-summary-universal-argument t]))
ec7995fa 2729 ("Registry Marks")
23f87bed
MB
2730 ("Scroll article"
2731 ["Page forward" gnus-summary-next-page
2732 ,@(if (featurep 'xemacs) '(t)
2733 '(:help "Show next page of article"))]
2734 ["Page backward" gnus-summary-prev-page
2735 ,@(if (featurep 'xemacs) '(t)
2736 '(:help "Show previous page of article"))]
2737 ["Line forward" gnus-summary-scroll-up t])
2738 ("Move"
2739 ["Next unread article" gnus-summary-next-unread-article t]
2740 ["Previous unread article" gnus-summary-prev-unread-article t]
2741 ["Next article" gnus-summary-next-article t]
2742 ["Previous article" gnus-summary-prev-article t]
2743 ["Next unread subject" gnus-summary-next-unread-subject t]
2744 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2745 ["Next article same subject" gnus-summary-next-same-subject t]
2746 ["Previous article same subject" gnus-summary-prev-same-subject t]
2747 ["First unread article" gnus-summary-first-unread-article t]
2748 ["Best unread article" gnus-summary-best-unread-article t]
2749 ["Go to subject number..." gnus-summary-goto-subject t]
2750 ["Go to article number..." gnus-summary-goto-article t]
2751 ["Go to the last article" gnus-summary-goto-last-article t]
2752 ["Pop article off history" gnus-summary-pop-article t])
2753 ("Sort"
2754 ["Sort by number" gnus-summary-sort-by-number t]
6ecfe5c2 2755 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
23f87bed 2756 ["Sort by author" gnus-summary-sort-by-author t]
01c52d31 2757 ["Sort by recipient" gnus-summary-sort-by-recipient t]
23f87bed
MB
2758 ["Sort by subject" gnus-summary-sort-by-subject t]
2759 ["Sort by date" gnus-summary-sort-by-date t]
6ecfe5c2 2760 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
23f87bed
MB
2761 ["Sort by score" gnus-summary-sort-by-score t]
2762 ["Sort by lines" gnus-summary-sort-by-lines t]
2763 ["Sort by characters" gnus-summary-sort-by-chars t]
2764 ["Randomize" gnus-summary-sort-by-random t]
2765 ["Original sort" gnus-summary-sort-by-original t])
2766 ("Help"
23f87bed 2767 ["Describe group" gnus-summary-describe-group t]
23f87bed
MB
2768 ["Read manual" gnus-info-find-node t])
2769 ("Modes"
2770 ["Pick and read" gnus-pick-mode t]
2771 ["Binary" gnus-binary-mode t])
2772 ("Regeneration"
2773 ["Regenerate" gnus-summary-prepare t]
2774 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2775 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
01c52d31 2776 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
23f87bed
MB
2777 ["Toggle threading" gnus-summary-toggle-threads t])
2778 ["See old articles" gnus-summary-insert-old-articles t]
2779 ["See new articles" gnus-summary-insert-new-articles t]
2780 ["Filter articles..." gnus-summary-execute-command t]
2781 ["Run command on articles..." gnus-summary-universal-argument t]
2782 ["Search articles forward..." gnus-summary-search-article-forward t]
2783 ["Search articles backward..." gnus-summary-search-article-backward t]
2784 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2785 ["Expand window" gnus-summary-expand-window t]
2786 ["Expire expirable articles" gnus-summary-expire-articles
2787 (gnus-check-backend-function
2788 'request-expire-articles gnus-newsgroup-name)]
2789 ["Edit local kill file" gnus-summary-edit-local-kill t]
2790 ["Edit main kill file" gnus-summary-edit-global-kill t]
2791 ["Edit group parameters" gnus-summary-edit-parameters t]
2792 ["Customize group parameters" gnus-summary-customize-parameters t]
2793 ["Send a bug report" gnus-bug t]
2794 ("Exit"
2795 ["Catchup and exit" gnus-summary-catchup-and-exit
2796 ,@(if (featurep 'xemacs) '(t)
2797 '(:help "Mark unread articles in this group as read, then exit"))]
2798 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2799 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
01c52d31 2800 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
23f87bed
MB
2801 ["Exit group" gnus-summary-exit
2802 ,@(if (featurep 'xemacs) '(t)
2803 '(:help "Exit current group, return to group selection mode"))]
2804 ["Exit group without updating" gnus-summary-exit-no-update t]
2805 ["Exit and goto next group" gnus-summary-next-group t]
2806 ["Exit and goto prev group" gnus-summary-prev-group t]
2807 ["Reselect group" gnus-summary-reselect-current-group t]
2808 ["Rescan group" gnus-summary-rescan-group t]
2809 ["Update dribble" gnus-summary-save-newsrc t])))
eec82323 2810
6748645f 2811 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323 2812
60bd5589
DL
2813(defvar gnus-summary-tool-bar-map nil)
2814
18c06a99
RS
2815;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2816;; affect _new_ message buffers. We might add a function that walks thru all
2817;; summary-mode buffers and force the update.
2818(defun gnus-summary-tool-bar-update (&optional symbol value)
2819 "Update summary mode toolbar.
2820Setter function for custom variables."
2821 (setq-default gnus-summary-tool-bar-map nil)
2822 (when symbol
2823 ;; When used as ":set" function:
2824 (set-default symbol value))
2825 (when (gnus-buffer-live-p gnus-summary-buffer)
2826 (with-current-buffer gnus-summary-buffer
2827 (gnus-summary-make-tool-bar))))
2828
2829(defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2830 'gnus-summary-tool-bar-gnome
2831 'gnus-summary-tool-bar-retro)
2832 "Specifies the Gnus summary tool bar.
2833
2834It can be either a list or a symbol refering to a list. See
2835`gmm-tool-bar-from-list' for the format of the list. The
2836default key map is `gnus-summary-mode-map'.
2837
2838Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2839`gnus-summary-tool-bar-retro'."
2840 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2841 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2842 (repeat :tag "User defined list" gmm-tool-bar-item)
2843 (symbol))
330f707b 2844 :version "23.1" ;; No Gnus
18c06a99
RS
2845 :initialize 'custom-initialize-default
2846 :set 'gnus-summary-tool-bar-update
2847 :group 'gnus-summary)
2848
2849(defcustom gnus-summary-tool-bar-gnome
2850 '((gnus-summary-post-news "mail/compose" nil)
2851 (gnus-summary-insert-new-articles "mail/inbox" nil
2852 :visible (or (not gnus-agent)
2853 gnus-plugged))
2854 (gnus-summary-reply-with-original "mail/reply")
2855 (gnus-summary-reply "mail/reply" nil :visible nil)
2856 (gnus-summary-followup-with-original "mail/reply-all")
2857 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2858 (gnus-summary-mail-forward "mail/forward")
2859 (gnus-summary-save-article "mail/save")
2860 (gnus-summary-search-article-forward "search" nil :visible nil)
2861 (gnus-summary-print-article "print")
2862 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2863 ;; Some new commands that may need more suitable icons:
2864 (gnus-summary-save-newsrc "save" nil :visible nil)
2865 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2866 (gnus-summary-prev-article "left-arrow")
2867 (gnus-summary-next-article "right-arrow")
2868 (gnus-summary-next-page "next-page")
2869 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2870 ;;
2871 ;; Maybe some sort-by-... could be added:
2872 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2873 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2874 (gnus-summary-mark-as-expirable
2875 "delete" nil
2876 :visible (gnus-check-backend-function 'request-expire-articles
2877 gnus-newsgroup-name))
2878 (gnus-summary-mark-as-spam
2879 "mail/spam" t
2880 :visible (and (fboundp 'spam-group-ham-contents-p)
2881 (spam-group-ham-contents-p gnus-newsgroup-name))
2882 :help "Mark as spam")
2883 (gnus-summary-mark-as-read-forward
2884 "mail/not-spam" nil
2885 :visible (and (fboundp 'spam-group-spam-contents-p)
2886 (spam-group-spam-contents-p gnus-newsgroup-name)))
2887 ;;
2888 (gnus-summary-exit "exit")
2889 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2890 (gnus-info-find-node "help"))
2891 "List of functions for the summary tool bar (GNOME style).
2892
2893See `gmm-tool-bar-from-list' for the format of the list."
2894 :type '(repeat gmm-tool-bar-item)
330f707b 2895 :version "23.1" ;; No Gnus
18c06a99
RS
2896 :initialize 'custom-initialize-default
2897 :set 'gnus-summary-tool-bar-update
2898 :group 'gnus-summary)
2899
2900(defcustom gnus-summary-tool-bar-retro
2901 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2902 (gnus-summary-next-unread-article "gnus/next-ur")
2903 (gnus-summary-post-news "gnus/post")
2904 (gnus-summary-followup-with-original "gnus/fuwo")
2905 (gnus-summary-followup "gnus/followup")
2906 (gnus-summary-reply-with-original "gnus/reply-wo")
2907 (gnus-summary-reply "gnus/reply")
2908 (gnus-summary-caesar-message "gnus/rot13")
2909 (gnus-uu-decode-uu "gnus/uu-decode")
2910 (gnus-summary-save-article-file "gnus/save-aif")
2911 (gnus-summary-save-article "gnus/save-art")
2912 (gnus-uu-post-news "gnus/uu-post")
2913 (gnus-summary-catchup "gnus/catchup")
2914 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2915 (gnus-summary-exit "gnus/exit-summ")
2916 ;; Some new command that may need more suitable icons:
2917 (gnus-summary-print-article "gnus/print" nil :visible nil)
2918 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2919 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2920 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2921 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2922 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2923 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2924 ;;
2925 (gnus-info-find-node "gnus/help" nil :visible nil))
2926 "List of functions for the summary tool bar (retro look).
2927
2928See `gmm-tool-bar-from-list' for the format of the list."
2929 :type '(repeat gmm-tool-bar-item)
330f707b 2930 :version "23.1" ;; No Gnus
18c06a99
RS
2931 :initialize 'custom-initialize-default
2932 :set 'gnus-summary-tool-bar-update
2933 :group 'gnus-summary)
2934
2935(defcustom gnus-summary-tool-bar-zap-list t
2936 "List of icon items from the global tool bar.
2937These items are not displayed in the Gnus summary mode tool bar.
2938
2939See `gmm-tool-bar-from-list' for the format of the list."
2940 :type 'gmm-tool-bar-zap-list
330f707b 2941 :version "23.1" ;; No Gnus
18c06a99
RS
2942 :initialize 'custom-initialize-default
2943 :set 'gnus-summary-tool-bar-update
2944 :group 'gnus-summary)
2945
2946(defvar image-load-path)
f654fa04 2947(defvar tool-bar-map)
18c06a99
RS
2948
2949(defun gnus-summary-make-tool-bar (&optional force)
2950 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2951When FORCE, rebuild the tool bar."
2952 (when (and (not (featurep 'xemacs))
2953 (boundp 'tool-bar-mode)
2954 tool-bar-mode
2955 (or (not gnus-summary-tool-bar-map) force))
2956 (let* ((load-path
2957 (gmm-image-load-path-for-library "gnus"
2958 "mail/save.xpm"
2959 nil t))
2960 (image-load-path (cons (car load-path)
2961 (when (boundp 'image-load-path)
2962 image-load-path)))
2963 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2964 gnus-summary-tool-bar-zap-list
2965 'gnus-summary-mode-map)))
2966 (when map
2967 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2968 ;; uses it's value.
2969 (setq gnus-summary-tool-bar-map map))))
2970 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
60bd5589 2971
eec82323
LMI
2972(defun gnus-score-set-default (var value)
2973 "A version of set that updates the GNU Emacs menu-bar."
2974 (set var value)
2975 ;; It is the message that forces the active status to be updated.
2976 (message ""))
2977
2978(defun gnus-make-score-map (type)
2979 "Make a summary score map of type TYPE."
2980 (if t
2981 nil
2982 (let ((headers '(("author" "from" string)
2983 ("subject" "subject" string)
2984 ("article body" "body" string)
2985 ("article head" "head" string)
2986 ("xref" "xref" string)
16409b0b 2987 ("extra header" "extra" string)
eec82323
LMI
2988 ("lines" "lines" number)
2989 ("followups to author" "followup" string)))
2990 (types '((number ("less than" <)
2991 ("greater than" >)
2992 ("equal" =))
2993 (string ("substring" s)
2994 ("exact string" e)
2995 ("fuzzy string" f)
2996 ("regexp" r))))
2997 (perms '(("temporary" (current-time-string))
2998 ("permanent" nil)
2999 ("immediate" now)))
3000 header)
3001 (list
3002 (apply
3003 'nconc
3004 (list
3005 (if (eq type 'lower)
3006 "Lower score"
3007 "Increase score"))
3008 (let (outh)
3009 (while headers
3010 (setq header (car headers))
3011 (setq outh
3012 (cons
3013 (apply
3014 'nconc
3015 (list (car header))
3016 (let ((ts (cdr (assoc (nth 2 header) types)))
3017 outt)
3018 (while ts
3019 (setq outt
3020 (cons
3021 (apply
3022 'nconc
3023 (list (caar ts))
3024 (let ((ps perms)
3025 outp)
3026 (while ps
3027 (setq outp
3028 (cons
3029 (vector
3030 (caar ps)
3031 (list
3032 'gnus-summary-score-entry
3033 (nth 1 header)
3034 (if (or (string= (nth 1 header)
3035 "head")
3036 (string= (nth 1 header)
3037 "body"))
3038 ""
3039 (list 'gnus-summary-header
3040 (nth 1 header)))
3041 (list 'quote (nth 1 (car ts)))
16409b0b
GM
3042 (list 'gnus-score-delta-default
3043 nil)
eec82323
LMI
3044 (nth 1 (car ps))
3045 t)
3046 t)
3047 outp))
3048 (setq ps (cdr ps)))
3049 (list (nreverse outp))))
3050 outt))
3051 (setq ts (cdr ts)))
3052 (list (nreverse outt))))
3053 outh))
3054 (setq headers (cdr headers)))
3055 (list (nreverse outh))))))))
3056
704f1663
GM
3057
3058(declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
398a825b 3059(defvar bookmark-make-record-function)
eec82323
LMI
3060\f
3061
3062(defun gnus-summary-mode (&optional group)
3063 "Major mode for reading articles.
3064
3065All normal editing commands are switched off.
3066\\<gnus-summary-mode-map>
3067Each line in this buffer represents one article. To read an
3068article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3069and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3070respectively.
3071
3072You can also post articles and send mail from this buffer. To
23f87bed 3073follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
eec82323
LMI
3074of an article, type `\\[gnus-summary-reply]'.
3075
3076There are approx. one gazillion commands you can execute in this
3077buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3078
3079The following commands are available:
3080
3081\\{gnus-summary-mode-map}"
3082 (interactive)
eec82323 3083 (kill-all-local-variables)
01c52d31
MB
3084 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3085 (gnus-summary-make-local-variables))
3086 (gnus-summary-make-local-variables)
3087 (setq gnus-newsgroup-name group)
60bd5589
DL
3088 (when (gnus-visual-p 'summary-menu 'menu)
3089 (gnus-summary-make-menu-bar)
3090 (gnus-summary-make-tool-bar))
eec82323
LMI
3091 (gnus-make-thread-indent-array)
3092 (gnus-simplify-mode-line)
3093 (setq major-mode 'gnus-summary-mode)
3094 (setq mode-name "Summary")
eec82323 3095 (use-local-map gnus-summary-mode-map)
16409b0b 3096 (buffer-disable-undo)
01c52d31
MB
3097 (setq buffer-read-only t ;Disable modification
3098 show-trailing-whitespace nil)
eec82323 3099 (setq truncate-lines t)
9bfd9a76 3100 (add-to-invisibility-spec '(gnus-sum . t))
eec82323
LMI
3101 (gnus-summary-set-display-table)
3102 (gnus-set-default-directory)
eec82323
LMI
3103 (make-local-variable 'gnus-summary-line-format)
3104 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
3105 (make-local-variable 'gnus-summary-dummy-line-format)
3106 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323 3107 (make-local-variable 'gnus-summary-mark-positions)
23f87bed 3108 (gnus-make-local-hook 'pre-command-hook)
6748645f 3109 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
cfcd5c91 3110 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
23f87bed 3111 (turn-on-gnus-mailing-list-mode)
87545352 3112 (mm-enable-multibyte)
45be326a
TV
3113 (set (make-local-variable 'bookmark-make-record-function)
3114 'gnus-summary-bookmark-make-record)
eec82323
LMI
3115 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3116 (gnus-update-summary-mark-positions))
3117
3118(defun gnus-summary-make-local-variables ()
3119 "Make all the local summary buffer variables."
16409b0b
GM
3120 (let (global)
3121 (dolist (local gnus-summary-local-variables)
eec82323
LMI
3122 (if (consp local)
3123 (progn
3124 (if (eq (cdr local) 'global)
3125 ;; Copy the global value of the variable.
3126 (setq global (symbol-value (car local)))
3127 ;; Use the value from the list.
3128 (setq global (eval (cdr local))))
16409b0b 3129 (set (make-local-variable (car local)) global))
eec82323 3130 ;; Simple nil-valued local variable.
16409b0b 3131 (set (make-local-variable local) nil)))))
eec82323 3132
eec82323
LMI
3133;; Summary data functions.
3134
3135(defmacro gnus-data-number (data)
3136 `(car ,data))
3137
3138(defmacro gnus-data-set-number (data number)
3139 `(setcar ,data ,number))
3140
3141(defmacro gnus-data-mark (data)
3142 `(nth 1 ,data))
3143
3144(defmacro gnus-data-set-mark (data mark)
3145 `(setcar (nthcdr 1 ,data) ,mark))
3146
3147(defmacro gnus-data-pos (data)
3148 `(nth 2 ,data))
3149
3150(defmacro gnus-data-set-pos (data pos)
3151 `(setcar (nthcdr 2 ,data) ,pos))
3152
3153(defmacro gnus-data-header (data)
3154 `(nth 3 ,data))
3155
3156(defmacro gnus-data-set-header (data header)
3157 `(setf (nth 3 ,data) ,header))
3158
3159(defmacro gnus-data-level (data)
3160 `(nth 4 ,data))
3161
3162(defmacro gnus-data-unread-p (data)
3163 `(= (nth 1 ,data) gnus-unread-mark))
3164
3165(defmacro gnus-data-read-p (data)
3166 `(/= (nth 1 ,data) gnus-unread-mark))
3167
3168(defmacro gnus-data-pseudo-p (data)
3169 `(consp (nth 3 ,data)))
3170
3171(defmacro gnus-data-find (number)
3172 `(assq ,number gnus-newsgroup-data))
3173
3174(defmacro gnus-data-find-list (number &optional data)
3175 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3176 (memq (assq ,number bdata)
3177 bdata)))
3178
3179(defmacro gnus-data-make (number mark pos header level)
3180 `(list ,number ,mark ,pos ,header ,level))
3181
3182(defun gnus-data-enter (after-article number mark pos header level offset)
3183 (let ((data (gnus-data-find-list after-article)))
3184 (unless data
3185 (error "No such article: %d" after-article))
3186 (setcdr data (cons (gnus-data-make number mark pos header level)
3187 (cdr data)))
3188 (setq gnus-newsgroup-data-reverse nil)
3189 (gnus-data-update-list (cddr data) offset)))
3190
3191(defun gnus-data-enter-list (after-article list &optional offset)
3192 (when list
3193 (let ((data (and after-article (gnus-data-find-list after-article)))
3194 (ilist list))
6748645f
LMI
3195 (if (not (or data
3196 after-article))
3197 (let ((odata gnus-newsgroup-data))
3198 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 3199 (when offset
6748645f 3200 (gnus-data-update-list odata offset)))
01c52d31 3201 ;; Find the last element in the list to be spliced into the main
6748645f 3202 ;; list.
01c52d31 3203 (setq list (last list))
6748645f
LMI
3204 (if (not data)
3205 (progn
3206 (setcdr list gnus-newsgroup-data)
3207 (setq gnus-newsgroup-data ilist)
3208 (when offset
3209 (gnus-data-update-list (cdr list) offset)))
3210 (setcdr list (cdr data))
3211 (setcdr data ilist)
3212 (when offset
3213 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
3214 (setq gnus-newsgroup-data-reverse nil))))
3215
3216(defun gnus-data-remove (article &optional offset)
3217 (let ((data gnus-newsgroup-data))
3218 (if (= (gnus-data-number (car data)) article)
3219 (progn
3220 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3221 gnus-newsgroup-data-reverse nil)
3222 (when offset
3223 (gnus-data-update-list gnus-newsgroup-data offset)))
3224 (while (cdr data)
3225 (when (= (gnus-data-number (cadr data)) article)
3226 (setcdr data (cddr data))
3227 (when offset
3228 (gnus-data-update-list (cdr data) offset))
3229 (setq data nil
3230 gnus-newsgroup-data-reverse nil))
3231 (setq data (cdr data))))))
3232
3233(defmacro gnus-data-list (backward)
3234 `(if ,backward
3235 (or gnus-newsgroup-data-reverse
3236 (setq gnus-newsgroup-data-reverse
3237 (reverse gnus-newsgroup-data)))
3238 gnus-newsgroup-data))
3239
3240(defun gnus-data-update-list (data offset)
3241 "Add OFFSET to the POS of all data entries in DATA."
6748645f 3242 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
3243 (while data
3244 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3245 (setq data (cdr data))))
3246
eec82323
LMI
3247(defun gnus-summary-article-pseudo-p (article)
3248 "Say whether this article is a pseudo article or not."
3249 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3250
3251(defmacro gnus-summary-article-sparse-p (article)
3252 "Say whether this article is a sparse article or not."
a8151ef7 3253 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
3254
3255(defmacro gnus-summary-article-ancient-p (article)
3256 "Say whether this article is a sparse article or not."
3257 `(memq ,article gnus-newsgroup-ancient))
3258
3259(defun gnus-article-parent-p (number)
3260 "Say whether this article is a parent or not."
3261 (let ((data (gnus-data-find-list number)))
23f87bed 3262 (and (cdr data) ; There has to be an article after...
eec82323
LMI
3263 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3264 (gnus-data-level (nth 1 data))))))
3265
3266(defun gnus-article-children (number)
3267 "Return a list of all children to NUMBER."
3268 (let* ((data (gnus-data-find-list number))
3269 (level (gnus-data-level (car data)))
3270 children)
3271 (setq data (cdr data))
3272 (while (and data
3273 (= (gnus-data-level (car data)) (1+ level)))
3274 (push (gnus-data-number (car data)) children)
3275 (setq data (cdr data)))
3276 children))
3277
3278(defmacro gnus-summary-skip-intangible ()
3279 "If the current article is intangible, then jump to a different article."
3280 '(let ((to (get-text-property (point) 'gnus-intangible)))
3281 (and to (gnus-summary-goto-subject to))))
3282
3283(defmacro gnus-summary-article-intangible-p ()
3284 "Say whether this article is intangible or not."
3285 '(get-text-property (point) 'gnus-intangible))
3286
3287(defun gnus-article-read-p (article)
3288 "Say whether ARTICLE is read or not."
3289 (not (or (memq article gnus-newsgroup-marked)
23f87bed 3290 (memq article gnus-newsgroup-spam-marked)
eec82323
LMI
3291 (memq article gnus-newsgroup-unreads)
3292 (memq article gnus-newsgroup-unselected)
3293 (memq article gnus-newsgroup-dormant))))
3294
3295;; Some summary mode macros.
3296
3297(defmacro gnus-summary-article-number ()
3298 "The article number of the article on the current line.
8f688cb0 3299If there isn't an article number here, then we return the current
eec82323
LMI
3300article number."
3301 '(progn
3302 (gnus-summary-skip-intangible)
3303 (or (get-text-property (point) 'gnus-number)
3304 (gnus-summary-last-subject))))
3305
3306(defmacro gnus-summary-article-header (&optional number)
6748645f 3307 "Return the header of article NUMBER."
eec82323
LMI
3308 `(gnus-data-header (gnus-data-find
3309 ,(or number '(gnus-summary-article-number)))))
3310
3311(defmacro gnus-summary-thread-level (&optional number)
6748645f 3312 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
3313 `(if (and (eq gnus-summary-make-false-root 'dummy)
3314 (get-text-property (point) 'gnus-intangible))
3315 0
3316 (gnus-data-level (gnus-data-find
3317 ,(or number '(gnus-summary-article-number))))))
3318
3319(defmacro gnus-summary-article-mark (&optional number)
6748645f 3320 "Return the mark of article NUMBER."
eec82323
LMI
3321 `(gnus-data-mark (gnus-data-find
3322 ,(or number '(gnus-summary-article-number)))))
3323
3324(defmacro gnus-summary-article-pos (&optional number)
6748645f 3325 "Return the position of the line of article NUMBER."
eec82323
LMI
3326 `(gnus-data-pos (gnus-data-find
3327 ,(or number '(gnus-summary-article-number)))))
3328
3329(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3330(defmacro gnus-summary-article-subject (&optional number)
3331 "Return current subject string or nil if nothing."
3332 `(let ((headers
3333 ,(if number
3334 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3335 '(gnus-data-header (assq (gnus-summary-article-number)
3336 gnus-newsgroup-data)))))
3337 (and headers
3338 (vectorp headers)
3339 (mail-header-subject headers))))
3340
3341(defmacro gnus-summary-article-score (&optional number)
3342 "Return current article score."
3343 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3344 gnus-newsgroup-scored))
3345 gnus-summary-default-score 0))
3346
3347(defun gnus-summary-article-children (&optional number)
6748645f 3348 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
3349 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3350 (level (gnus-data-level (car data)))
3351 l children)
3352 (while (and (setq data (cdr data))
3353 (> (setq l (gnus-data-level (car data))) level))
3354 (and (= (1+ level) l)
3355 (push (gnus-data-number (car data))
3356 children)))
3357 (nreverse children)))
3358
3359(defun gnus-summary-article-parent (&optional number)
6748645f 3360 "Return the article number of the parent of article NUMBER."
eec82323
LMI
3361 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3362 (gnus-data-list t)))
3363 (level (gnus-data-level (car data))))
3364 (if (zerop level)
3365 () ; This is a root.
3366 ;; We search until we find an article with a level less than
3367 ;; this one. That function has to be the parent.
3368 (while (and (setq data (cdr data))
3369 (not (< (gnus-data-level (car data)) level))))
3370 (and data (gnus-data-number (car data))))))
3371
3372(defun gnus-unread-mark-p (mark)
3373 "Say whether MARK is the unread mark."
3374 (= mark gnus-unread-mark))
3375
3376(defun gnus-read-mark-p (mark)
3377 "Say whether MARK is one of the marks that mark as read.
3378This is all marks except unread, ticked, dormant, and expirable."
3379 (not (or (= mark gnus-unread-mark)
3380 (= mark gnus-ticked-mark)
23f87bed 3381 (= mark gnus-spam-mark)
eec82323
LMI
3382 (= mark gnus-dormant-mark)
3383 (= mark gnus-expirable-mark))))
3384
3385(defmacro gnus-article-mark (number)
6748645f
LMI
3386 "Return the MARK of article NUMBER.
3387This macro should only be used when computing the mark the \"first\"
3388time; i.e., when generating the summary lines. After that,
3389`gnus-summary-article-mark' should be used to examine the
3390marks of articles."
eec82323 3391 `(cond
6748645f 3392 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
6748645f 3393 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
3394 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3395 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
23f87bed 3396 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
eec82323
LMI
3397 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3398 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3399 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3400 gnus-ancient-mark))))
3401
3402;; Saving hidden threads.
3403
eec82323
LMI
3404(defmacro gnus-save-hidden-threads (&rest forms)
3405 "Save hidden threads, eval FORMS, and restore the hidden threads."
3406 (let ((config (make-symbol "config")))
3407 `(let ((,config (gnus-hidden-threads-configuration)))
3408 (unwind-protect
3409 (save-excursion
3410 ,@forms)
3411 (gnus-restore-hidden-threads-configuration ,config)))))
23f87bed
MB
3412(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3413(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
eec82323 3414
107ecebb
AS
3415(defun gnus-data-compute-positions ()
3416 "Compute the positions of all articles."
3417 (setq gnus-newsgroup-data-reverse nil)
3418 (let ((data gnus-newsgroup-data))
3419 (save-excursion
3420 (gnus-save-hidden-threads
3421 (gnus-summary-show-all-threads)
3422 (goto-char (point-min))
3423 (while data
3424 (while (get-text-property (point) 'gnus-intangible)
3425 (forward-line 1))
3426 (gnus-data-set-pos (car data) (+ (point) 3))
3427 (setq data (cdr data))
3428 (forward-line 1))))))
3429
16409b0b
GM
3430(defun gnus-hidden-threads-configuration ()
3431 "Return the current hidden threads configuration."
3432 (save-excursion
3433 (let (config)
3434 (goto-char (point-min))
62a83cc8
KY
3435 (while (not (eobp))
3436 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3437 (push (save-excursion (forward-line 0) (point)) config))
3438 (forward-line 1))
16409b0b
GM
3439 config)))
3440
3441(defun gnus-restore-hidden-threads-configuration (config)
3442 "Restore hidden threads configuration from CONFIG."
3443 (save-excursion
c7a91ce1 3444 (let (point (inhibit-read-only t))
16409b0b 3445 (while (setq point (pop config))
62a83cc8
KY
3446 (goto-char point)
3447 (gnus-summary-hide-thread)))))
16409b0b 3448
eec82323
LMI
3449;; Various summary mode internalish functions.
3450
3451(defun gnus-mouse-pick-article (e)
3452 (interactive "e")
3453 (mouse-set-point e)
3454 (gnus-summary-next-page nil t))
3455
3456(defun gnus-summary-set-display-table ()
16409b0b
GM
3457 "Change the display table.
3458Odd characters have a tendency to mess
3459up nicely formatted displays - we make all possible glyphs
3460display only a single character."
eec82323
LMI
3461
3462 ;; We start from the standard display table, if any.
3463 (let ((table (or (copy-sequence standard-display-table)
3464 (make-display-table)))
3465 (i 32))
3466 ;; Nix out all the control chars...
3467 (while (>= (setq i (1- i)) 0)
2b968687 3468 (gnus-put-display-table i [??] table))
23f87bed 3469 ;; ... but not newline and cr, of course. (cr is necessary for the
eec82323 3470 ;; selective display).
2b968687
MB
3471 (gnus-put-display-table ?\n nil table)
3472 (gnus-put-display-table ?\r nil table)
6748645f 3473 ;; We keep TAB as well.
2b968687 3474 (gnus-put-display-table ?\t nil table)
719120ef 3475 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
fe62aacc 3476 ;; Emacs 23 (unicode), that are not set already.
719120ef
MB
3477 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3478 160
3479 256)))
eec82323
LMI
3480 (while (>= (setq i (1- i)) 127)
3481 ;; Only modify if the entry is nil.
2b968687
MB
3482 (unless (gnus-get-display-table i table)
3483 (gnus-put-display-table i [??] table))))
eec82323
LMI
3484 (setq buffer-display-table table)))
3485
23f87bed
MB
3486(defun gnus-summary-set-article-display-arrow (pos)
3487 "Update the overlay arrow to point to line at position POS."
e3e955fe
MB
3488 (when gnus-summary-display-arrow
3489 (make-local-variable 'overlay-arrow-position)
3490 (make-local-variable 'overlay-arrow-string)
23f87bed
MB
3491 (save-excursion
3492 (goto-char pos)
3493 (beginning-of-line)
3494 (unless overlay-arrow-position
3495 (setq overlay-arrow-position (make-marker)))
3496 (setq overlay-arrow-string "=>"
3497 overlay-arrow-position (set-marker overlay-arrow-position
3498 (point)
3499 (current-buffer))))))
3500
eec82323
LMI
3501(defun gnus-summary-setup-buffer (group)
3502 "Initialize summary buffer."
23f87bed
MB
3503 (let ((buffer (gnus-summary-buffer-name group))
3504 (dead-name (concat "*Dead Summary "
3505 (gnus-group-decoded-name group) "*")))
3506 ;; If a dead summary buffer exists, we kill it.
3507 (when (gnus-buffer-live-p dead-name)
3508 (gnus-kill-buffer dead-name))
eec82323
LMI
3509 (if (get-buffer buffer)
3510 (progn
3511 (set-buffer buffer)
3512 (setq gnus-summary-buffer (current-buffer))
3513 (not gnus-newsgroup-prepared))
3514 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 3515 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323 3516 (gnus-summary-mode group)
01c52d31
MB
3517 (when (gnus-group-quit-config group)
3518 (set (make-local-variable 'gnus-single-article-buffer) nil))
3519 (make-local-variable 'gnus-article-buffer)
3520 (make-local-variable 'gnus-article-current)
3521 (make-local-variable 'gnus-original-article-buffer)
eec82323 3522 (setq gnus-newsgroup-name group)
23f87bed
MB
3523 ;; Set any local variables in the group parameters.
3524 (gnus-summary-set-local-parameters gnus-newsgroup-name)
eec82323
LMI
3525 t)))
3526
3527(defun gnus-set-global-variables ()
16409b0b
GM
3528 "Set the global equivalents of the buffer-local variables.
3529They are set to the latest values they had. These reflect the summary
3530buffer that was in action when the last article was fetched."
eec82323
LMI
3531 (when (eq major-mode 'gnus-summary-mode)
3532 (setq gnus-summary-buffer (current-buffer))
3533 (let ((name gnus-newsgroup-name)
3534 (marked gnus-newsgroup-marked)
23f87bed 3535 (spam gnus-newsgroup-spam-marked)
eec82323
LMI
3536 (unread gnus-newsgroup-unreads)
3537 (headers gnus-current-headers)
3538 (data gnus-newsgroup-data)
3539 (summary gnus-summary-buffer)
3540 (article-buffer gnus-article-buffer)
3541 (original gnus-original-article-buffer)
3542 (gac gnus-article-current)
3543 (reffed gnus-reffed-article-number)
16409b0b 3544 (score-file gnus-current-score-file)
23f87bed
MB
3545 (default-charset gnus-newsgroup-charset)
3546 vlist)
3547 (let ((locals gnus-newsgroup-variables))
3548 (while locals
3549 (if (consp (car locals))
3550 (push (eval (caar locals)) vlist)
3551 (push (eval (car locals)) vlist))
3552 (setq locals (cdr locals)))
3553 (setq vlist (nreverse vlist)))
01c52d31 3554 (with-current-buffer gnus-group-buffer
6748645f
LMI
3555 (setq gnus-newsgroup-name name
3556 gnus-newsgroup-marked marked
23f87bed 3557 gnus-newsgroup-spam-marked spam
6748645f
LMI
3558 gnus-newsgroup-unreads unread
3559 gnus-current-headers headers
3560 gnus-newsgroup-data data
3561 gnus-article-current gac
3562 gnus-summary-buffer summary
3563 gnus-article-buffer article-buffer
3564 gnus-original-article-buffer original
3565 gnus-reffed-article-number reffed
16409b0b
GM
3566 gnus-current-score-file score-file
3567 gnus-newsgroup-charset default-charset)
23f87bed
MB
3568 (let ((locals gnus-newsgroup-variables))
3569 (while locals
3570 (if (consp (car locals))
3571 (set (caar locals) (pop vlist))
3572 (set (car locals) (pop vlist)))
3573 (setq locals (cdr locals))))
eec82323
LMI
3574 ;; The article buffer also has local variables.
3575 (when (gnus-buffer-live-p gnus-article-buffer)
3576 (set-buffer gnus-article-buffer)
3577 (setq gnus-summary-buffer summary))))))
3578
3579(defun gnus-summary-article-unread-p (article)
3580 "Say whether ARTICLE is unread or not."
3581 (memq article gnus-newsgroup-unreads))
3582
3583(defun gnus-summary-first-article-p (&optional article)
3584 "Return whether ARTICLE is the first article in the buffer."
3585 (if (not (setq article (or article (gnus-summary-article-number))))
3586 nil
3587 (eq article (caar gnus-newsgroup-data))))
3588
3589(defun gnus-summary-last-article-p (&optional article)
3590 "Return whether ARTICLE is the last article in the buffer."
3591 (if (not (setq article (or article (gnus-summary-article-number))))
16409b0b
GM
3592 ;; All non-existent numbers are the last article. :-)
3593 t
eec82323
LMI
3594 (not (cdr (gnus-data-find-list article)))))
3595
4921bbdd
CY
3596(defun gnus-make-thread-indent-array (&optional n)
3597 (when (or n
3598 (progn (setq n 200) nil)
3599 (null gnus-thread-indent-array)
3600 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3601 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3602 gnus-thread-indent-array-level gnus-thread-indent-level)
3603 (while (>= n 0)
3604 (aset gnus-thread-indent-array n
6a30c01d 3605 (make-string (* n gnus-thread-indent-level) ? ))
4921bbdd 3606 (setq n (1- n)))))
eec82323
LMI
3607
3608(defun gnus-update-summary-mark-positions ()
3609 "Compute where the summary marks are to go."
3610 (save-excursion
6748645f 3611 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3612 (set-buffer gnus-summary-buffer))
5153a47a
MB
3613 (let ((spec gnus-summary-line-format-spec)
3614 pos)
eec82323
LMI
3615 (save-excursion
3616 (gnus-set-work-buffer)
5153a47a
MB
3617 (let ((gnus-tmp-unread ?Z)
3618 (gnus-replied-mark ?Z)
3619 (gnus-score-below-mark ?Z)
3620 (gnus-score-over-mark ?Z)
3621 (gnus-undownloaded-mark ?Z)
3622 (gnus-summary-line-format-spec spec)
54506618 3623 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3624 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3625 case-fold-search ignores)
3626 ;; Here, all marks are bound to Z.
3627 (gnus-summary-insert-line header
3628 0 nil t gnus-tmp-unread t nil "" nil 1)
3629 (goto-char (point-min))
3630 ;; Memorize the positions of the same characters as dummy marks.
3631 (while (re-search-forward "[A-D]" nil t)
3632 (push (point) ignores))
54506618 3633 (erase-buffer)
5153a47a
MB
3634 ;; We use A-D as dummy marks in order to know column positions
3635 ;; where marks should be inserted.
3636 (setq gnus-tmp-unread ?A
3637 gnus-replied-mark ?B
3638 gnus-score-below-mark ?C
3639 gnus-score-over-mark ?C
3640 gnus-undownloaded-mark ?D)
3641 (gnus-summary-insert-line header
3642 0 nil t gnus-tmp-unread t nil "" nil 1)
3643 ;; Ignore characters which aren't dummy marks.
3644 (dolist (p ignores)
3645 (delete-region (goto-char (1- p)) p)
3646 (insert ?Z))
eec82323 3647 (goto-char (point-min))
7c3bb5a5 3648 (setq pos (list (cons 'unread
5153a47a 3649 (and (search-forward "A" nil t)
7c3bb5a5 3650 (- (point) (point-min) 1)))))
eec82323 3651 (goto-char (point-min))
5153a47a 3652 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3653 (- (point) (point-min) 1)))
eec82323
LMI
3654 pos)
3655 (goto-char (point-min))
5153a47a 3656 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3657 (- (point) (point-min) 1)))
6748645f
LMI
3658 pos)
3659 (goto-char (point-min))
5153a47a 3660 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3661 (- (point) (point-min) 1)))
eec82323
LMI
3662 pos)))
3663 (setq gnus-summary-mark-positions pos))))
3664
3665(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3666 "Insert a dummy root in the summary buffer."
3667 (beginning-of-line)
3668 (gnus-add-text-properties
3669 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3670 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3671
23f87bed
MB
3672(defun gnus-summary-extract-address-component (from)
3673 (or (car (funcall gnus-extract-address-components from))
3674 from))
3675
3676(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3677 (let ((mail-parse-charset gnus-newsgroup-charset)
01c52d31 3678 (ignored-from-addresses (gnus-ignored-from-addresses))
23f87bed
MB
3679 ; Is it really necessary to do this next part for each summary line?
3680 ; Luckily, doesn't seem to slow things down much.
16409b0b 3681 (mail-parse-ignored-charsets
01c52d31
MB
3682 (with-current-buffer gnus-summary-buffer
3683 gnus-newsgroup-ignored-charsets)))
23f87bed 3684 (or
01c52d31
MB
3685 (and ignored-from-addresses
3686 (string-match ignored-from-addresses gnus-tmp-from)
23f87bed
MB
3687 (let ((extra-headers (mail-header-extra header))
3688 to
3689 newsgroups)
3690 (cond
3691 ((setq to (cdr (assq 'To extra-headers)))
01c52d31 3692 (concat gnus-summary-to-prefix
23f87bed
MB
3693 (inline
3694 (gnus-summary-extract-address-component
343d6628 3695 (funcall gnus-decode-encoded-address-function to)))))
01c52d31
MB
3696 ((setq newsgroups
3697 (or
3698 (cdr (assq 'Newsgroups extra-headers))
3699 (and
3700 (memq 'Newsgroups gnus-extra-headers)
3701 (eq (car (gnus-find-method-for-group
3702 gnus-newsgroup-name)) 'nntp)
3703 (gnus-group-real-name gnus-newsgroup-name))))
3704 (concat gnus-summary-newsgroup-prefix newsgroups)))))
23f87bed 3705 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3706
eec82323
LMI
3707(defun gnus-summary-insert-line (gnus-tmp-header
3708 gnus-tmp-level gnus-tmp-current
23f87bed 3709 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3710 gnus-tmp-expirable gnus-tmp-subject-or-nil
3711 &optional gnus-tmp-dummy gnus-tmp-score
3712 gnus-tmp-process)
4921bbdd
CY
3713 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3714 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3715 gnus-tmp-level)))
eec82323
LMI
3716 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3717 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3718 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3719 (gnus-tmp-score-char
3720 (if (or (null gnus-summary-default-score)
3721 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3722 gnus-summary-zcore-fuzz))
23f87bed 3723 ? ;Whitespace
eec82323
LMI
3724 (if (< gnus-tmp-score gnus-summary-default-score)
3725 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3726 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3727 (gnus-tmp-replied
3728 (cond (gnus-tmp-process gnus-process-mark)
3729 ((memq gnus-tmp-current gnus-newsgroup-cached)
3730 gnus-cached-mark)
3731 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3732 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3733 gnus-forwarded-mark)
eec82323
LMI
3734 ((memq gnus-tmp-current gnus-newsgroup-saved)
3735 gnus-saved-mark)
23f87bed
MB
3736 ((memq gnus-tmp-number gnus-newsgroup-recent)
3737 gnus-recent-mark)
3738 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3739 gnus-unseen-mark)
3740 (t gnus-no-mark)))
3741 (gnus-tmp-downloaded
3742 (cond (undownloaded
3743 gnus-undownloaded-mark)
3744 (gnus-newsgroup-agentized
3745 gnus-downloaded-mark)
3746 (t
3747 gnus-no-mark)))
eec82323
LMI
3748 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3749 (gnus-tmp-name
3750 (cond
3751 ((string-match "<[^>]+> *$" gnus-tmp-from)
3752 (let ((beg (match-beginning 0)))
23f87bed
MB
3753 (or (and (string-match "^\".+\"" gnus-tmp-from)
3754 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3755 (substring gnus-tmp-from 0 beg))))
3756 ((string-match "(.+)" gnus-tmp-from)
3757 (substring gnus-tmp-from
3758 (1+ (match-beginning 0)) (1- (match-end 0))))
3759 (t gnus-tmp-from)))
3760 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3761 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3762 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
c7a91ce1 3763 (inhibit-read-only t))
eec82323
LMI
3764 (when (string= gnus-tmp-name "")
3765 (setq gnus-tmp-name gnus-tmp-from))
3766 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3767 (setq gnus-tmp-lines -1))
3768 (if (= gnus-tmp-lines -1)
3769 (setq gnus-tmp-lines "?")
3770 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
64763fe3
MB
3771 (condition-case ()
3772 (gnus-put-text-property
3773 (point)
3774 (progn (eval gnus-summary-line-format-spec) (point))
3775 'gnus-number gnus-tmp-number)
3776 (error (gnus-message 5 "Error updating the summary line")))
eec82323
LMI
3777 (when (gnus-visual-p 'summary-highlight 'highlight)
3778 (forward-line -1)
a9ec34f4 3779 (gnus-summary-highlight-line)
6748645f 3780 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3781 (forward-line 1))))
3782
3783(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3784 "Update summary line after change."
eec82323
LMI
3785 (when (and gnus-summary-default-score
3786 (not gnus-summary-inhibit-highlight))
3787 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3788 (article (gnus-summary-article-number))
3789 (score (gnus-summary-article-score article)))
3790 (unless dont-update
3791 (if (and gnus-summary-mark-below
3792 (< (gnus-summary-article-score)
3793 gnus-summary-mark-below))
3794 ;; This article has a low score, so we mark it as read.
3795 (when (memq article gnus-newsgroup-unreads)
3796 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3797 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3798 ;; This article was previously marked as read on account
3799 ;; of a low score, but now it has risen, so we mark it as
3800 ;; unread.
3801 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3802 (gnus-summary-update-mark
3803 (if (or (null gnus-summary-default-score)
3804 (<= (abs (- score gnus-summary-default-score))
3805 gnus-summary-zcore-fuzz))
23f87bed 3806 ? ;Whitespace
eec82323
LMI
3807 (if (< score gnus-summary-default-score)
3808 gnus-score-below-mark gnus-score-over-mark))
3809 'score))
3810 ;; Do visual highlighting.
3811 (when (gnus-visual-p 'summary-highlight 'highlight)
a9ec34f4 3812 (gnus-summary-highlight-line)
6748645f 3813 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3814
3815(defvar gnus-tmp-new-adopts nil)
3816
3817(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3818 "Return the number of articles in THREAD.
3819This may be 0 in some cases -- if none of the articles in
3820the thread are to be displayed."
3821 (let* ((number
23f87bed 3822 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3823 (cond
3824 ((not (listp thread))
3825 1)
3826 ((and (consp thread) (cdr thread))
3827 (apply
3828 '+ 1 (mapcar
3829 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3830 ((null thread)
3831 1)
3832 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3833 1)
3834 (t 0))))
3835 (when (and level (zerop level) gnus-tmp-new-adopts)
3836 (incf number
3837 (apply '+ (mapcar
3838 'gnus-summary-number-of-articles-in-thread
3839 gnus-tmp-new-adopts))))
3840 (if char
3841 (if (> number 1) gnus-not-empty-thread-mark
3842 gnus-empty-thread-mark)
3843 number)))
3844
23f87bed
MB
3845(defsubst gnus-summary-line-message-size (head)
3846 "Return pretty-printed version of message size.
3847This function is intended to be used in
3848`gnus-summary-line-format-alist'."
3849 (let ((c (or (mail-header-chars head) -1)))
3850 (cond ((< c 0) "n/a") ; chars not available
3851 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3852 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3853 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3854 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3855
0d1c2cc8
G
3856(defcustom gnus-summary-user-date-format-alist
3857 '(((gnus-seconds-today) . "Today, %H:%M")
3858 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3859 (604800 . "%A %H:%M") ; That's one week
3860 ((gnus-seconds-month) . "%A %d")
3861 ((gnus-seconds-year) . "%B %d")
3862 (t . "%b %d %Y")) ; This one is used when no other
3863 ; does match
3864 "Specifies date format depending on age of article.
3865This is an alist of items (AGE . FORMAT). AGE can be a number (of
3866seconds) or a Lisp expression evaluating to a number. When the age of
3867the article is less than this number, then use `format-time-string'
3868with the corresponding FORMAT for displaying the date of the article.
3869If AGE is not a number or a Lisp expression evaluating to a
3870non-number, then the corresponding FORMAT is used as a default value.
3871
3872Note that the list is processed from the beginning, so it should be
3873sorted by ascending AGE. Also note that items following the first
3874non-number AGE will be ignored.
3875
3876You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3877and `gnus-seconds-year' in the AGE spec. They return the number of
3878seconds passed since the start of today, of this month, of this year,
3879respectively."
3880 :version "24.1"
3881 :group 'gnus-summary-format
3882 :type '(alist :key-type sexp :value-type string))
3883(make-obsolete-variable 'gnus-user-date-format-alist
3884 'gnus-summary-user-date-format-alist "24.1")
3885
ec72bf63 3886(defun gnus-user-date (messy-date)
0d1c2cc8
G
3887 "Format the messy-date according to `gnus-summary-user-date-format-alist'.
3888Returns \" ? \" if there's bad input or if another error occurs.
3889Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3890 (condition-case ()
3891 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3892 (now (gnus-float-time))
3893 ;;If we don't find something suitable we'll use this one
3894 (my-format "%b %d '%y"))
3895 (let* ((difference (- now messy-date))
3896 (templist gnus-summary-user-date-format-alist)
3897 (top (eval (caar templist))))
3898 (while (if (numberp top) (< top difference) (not top))
3899 (progn
3900 (setq templist (cdr templist))
3901 (setq top (eval (caar templist)))))
3902 (if (stringp (cdr (car templist)))
3903 (setq my-format (cdr (car templist)))))
3904 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3905 (error " ? ")))
23f87bed 3906
eec82323
LMI
3907(defun gnus-summary-set-local-parameters (group)
3908 "Go through the local params of GROUP and set all variable specs in that list."
dab0271f
G
3909 (let ((vars '(quit-config active))) ; Ignore things that aren't
3910 ; really variables.
01c52d31 3911 (dolist (elem (gnus-group-find-parameter group))
eec82323
LMI
3912 (and (consp elem) ; Has to be a cons.
3913 (consp (cdr elem)) ; The cdr has to be a list.
3914 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3915 (not (memq (car elem) vars))
e3e955fe 3916 (ignore-errors
23f87bed 3917 (push (car elem) vars)
e3e955fe
MB
3918 ;; Variables like `gnus-show-threads' that are globally
3919 ;; bound, if used as group parameters, need to get to be
3920 ;; buffer-local, whereas just parameters like `gcc-self',
3921 ;; `timestamp', etc. should not be bound as variables.
3922 (if (boundp (car elem))
3923 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3924 (eval (nth 1 elem))))))))
eec82323
LMI
3925
3926(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3927 kill-buffer no-display backward
3928 select-articles)
eec82323
LMI
3929 "Start reading news in newsgroup GROUP.
3930If SHOW-ALL is non-nil, already read articles are also listed.
3931If NO-ARTICLE is non-nil, no article is selected initially.
3932If NO-DISPLAY, don't generate a summary buffer."
3933 (let (result)
3934 (while (and group
3935 (null (setq result
3936 (let ((gnus-auto-select-next nil))
6748645f
LMI
3937 (or (gnus-summary-read-group-1
3938 group show-all no-article
3939 kill-buffer no-display
3940 select-articles)
3941 (setq show-all nil
16409b0b 3942 select-articles nil)))))
eec82323
LMI
3943 (eq gnus-auto-select-next 'quietly))
3944 (set-buffer gnus-group-buffer)
6748645f
LMI
3945 ;; The entry function called above goes to the next
3946 ;; group automatically, so we go two groups back
3947 ;; if we are searching for the previous group.
3948 (when backward
3949 (gnus-group-prev-unread-group 2))
eec82323
LMI
3950 (if (not (equal group (gnus-group-group-name)))
3951 (setq group (gnus-group-group-name))
3952 (setq group nil)))
3953 result))
3954
3955(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3956 kill-buffer no-display
3957 &optional select-articles)
eec82323 3958 ;; Killed foreign groups can't be entered.
23f87bed
MB
3959 ;; (when (and (not (gnus-group-native-p group))
3960 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3961 ;; (error "Dead non-native groups can't be entered"))
3962 (gnus-message 5 "Retrieving newsgroup: %s..."
3963 (gnus-group-decoded-name group))
eec82323
LMI
3964 (let* ((new-group (gnus-summary-setup-buffer group))
3965 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3966 (did-select (and new-group (gnus-select-newsgroup
3967 group show-all select-articles))))
eec82323
LMI
3968 (cond
3969 ;; This summary buffer exists already, so we just select it.
3970 ((not new-group)
3971 (gnus-set-global-variables)
3972 (when kill-buffer
3973 (gnus-kill-or-deaden-summary kill-buffer))
3974 (gnus-configure-windows 'summary 'force)
3975 (gnus-set-mode-line 'summary)
3976 (gnus-summary-position-point)
3977 (message "")
3978 t)
3979 ;; We couldn't select this group.
3980 ((null did-select)
3981 (when (and (eq major-mode 'gnus-summary-mode)
3982 (not (equal (current-buffer) kill-buffer)))
3983 (kill-buffer (current-buffer))
3984 (if (not quit-config)
3985 (progn
6748645f
LMI
3986 ;; Update the info -- marks might need to be removed,
3987 ;; for instance.
3988 (gnus-summary-update-info)
eec82323
LMI
3989 (set-buffer gnus-group-buffer)
3990 (gnus-group-jump-to-group group)
3991 (gnus-group-next-unread-group 1))
3992 (gnus-handle-ephemeral-exit quit-config)))
8937ef6e
LI
3993 (if (null (gnus-list-of-unread-articles group))
3994 (gnus-message 3 "Group %s contains no messages" group)
3995 (gnus-message 3 "Can't select group"))
eec82323
LMI
3996 nil)
3997 ;; The user did a `C-g' while prompting for number of articles,
3998 ;; so we exit this group.
3999 ((eq did-select 'quit)
4000 (and (eq major-mode 'gnus-summary-mode)
4001 (not (equal (current-buffer) kill-buffer))
4002 (kill-buffer (current-buffer)))
4003 (when kill-buffer
4004 (gnus-kill-or-deaden-summary kill-buffer))
4005 (if (not quit-config)
4006 (progn
4007 (set-buffer gnus-group-buffer)
4008 (gnus-group-jump-to-group group)
eec82323
LMI
4009 (gnus-configure-windows 'group 'force))
4010 (gnus-handle-ephemeral-exit quit-config))
4011 ;; Finally signal the quit.
4012 (signal 'quit nil))
4013 ;; The group was successfully selected.
4014 (t
4015 (gnus-set-global-variables)
4016 ;; Save the active value in effect when the group was entered.
4017 (setq gnus-newsgroup-active
4018 (gnus-copy-sequence
4019 (gnus-active gnus-newsgroup-name)))
9f2d52e7 4020 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
eec82323 4021 ;; You can change the summary buffer in some way with this hook.
6748645f 4022 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
4023 (when (memq 'summary (gnus-update-format-specifications
4024 nil 'summary 'summary-mode 'summary-dummy))
4025 ;; The format specification for the summary line was updated,
4026 ;; so we need to update the mark positions as well.
4027 (gnus-update-summary-mark-positions))
eec82323
LMI
4028 ;; Do score processing.
4029 (when gnus-use-scoring
4030 (gnus-possibly-score-headers))
4031 ;; Check whether to fill in the gaps in the threads.
4032 (when gnus-build-sparse-threads
4033 (gnus-build-sparse-threads))
4034 ;; Find the initial limit.
26c9afc3
MB
4035 (if show-all
4036 (let ((gnus-newsgroup-dormant nil))
eec82323 4037 (gnus-summary-initial-limit show-all))
26c9afc3 4038 (gnus-summary-initial-limit show-all))
eec82323
LMI
4039 ;; Generate the summary buffer.
4040 (unless no-display
4041 (gnus-summary-prepare))
4042 (when gnus-use-trees
4043 (gnus-tree-open group)
4044 (setq gnus-summary-highlight-line-function
4045 'gnus-tree-highlight-article))
4046 ;; If the summary buffer is empty, but there are some low-scored
4047 ;; articles or some excluded dormants, we include these in the
4048 ;; buffer.
4049 (when (and (zerop (buffer-size))
4050 (not no-display))
4051 (cond (gnus-newsgroup-dormant
4052 (gnus-summary-limit-include-dormant))
4053 ((and gnus-newsgroup-scored show-all)
4054 (gnus-summary-limit-include-expunged t))))
4055 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 4056 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
4057 (if (and (zerop (buffer-size))
4058 (not no-display))
4059 (progn
4060 ;; This newsgroup is empty.
4061 (gnus-summary-catchup-and-exit nil t)
4062 (gnus-message 6 "No unread news")
4063 (when kill-buffer
4064 (gnus-kill-or-deaden-summary kill-buffer))
4065 ;; Return nil from this function.
4066 nil)
4067 ;; Hide conversation thread subtrees. We cannot do this in
4068 ;; gnus-summary-prepare-hook since kill processing may not
4069 ;; work with hidden articles.
23f87bed 4070 (gnus-summary-maybe-hide-threads)
5415d076 4071 (gnus-configure-windows 'summary)
6748645f
LMI
4072 (when kill-buffer
4073 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 4074 (gnus-summary-auto-select-subject)
eec82323
LMI
4075 ;; Show first unread article if requested.
4076 (if (and (not no-article)
4077 (not no-display)
4078 gnus-newsgroup-unreads
4079 gnus-auto-select-first)
16409b0b 4080 (progn
23f87bed
MB
4081 (let ((art (gnus-summary-article-number)))
4082 (unless (and (not gnus-plugged)
4083 (or (memq art gnus-newsgroup-undownloaded)
4084 (memq art gnus-newsgroup-downloadable)))
4085 (gnus-summary-goto-article art))))
4086 ;; Don't select any articles.
eec82323 4087 (gnus-summary-position-point)
6748645f
LMI
4088 (gnus-configure-windows 'summary 'force)
4089 (gnus-set-mode-line 'summary))
23f87bed
MB
4090 (when (and gnus-auto-center-group
4091 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
4092 ;; Gotta use windows, because recenter does weird stuff if
4093 ;; the current buffer ain't the displayed window.
4094 (let ((owin (selected-window)))
4095 (select-window (get-buffer-window gnus-group-buffer t))
4096 (when (gnus-group-goto-group group)
4097 (recenter))
4098 (select-window owin)))
4099 ;; Mark this buffer as "prepared".
4100 (setq gnus-newsgroup-prepared t)
6748645f 4101 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
4102 (unless (gnus-ephemeral-group-p group)
4103 (gnus-group-update-group group))
eec82323
LMI
4104 t)))))
4105
23f87bed
MB
4106(defun gnus-summary-auto-select-subject ()
4107 "Select the subject line on initial group entry."
4108 (goto-char (point-min))
4109 (cond
4110 ((eq gnus-auto-select-subject 'best)
4111 (gnus-summary-best-unread-subject))
4112 ((eq gnus-auto-select-subject 'unread)
4113 (gnus-summary-first-unread-subject))
4114 ((eq gnus-auto-select-subject 'unseen)
4115 (gnus-summary-first-unseen-subject))
4116 ((eq gnus-auto-select-subject 'unseen-or-unread)
4117 (gnus-summary-first-unseen-or-unread-subject))
4118 ((eq gnus-auto-select-subject 'first)
4119 ;; Do nothing.
4120 )
4121 ((functionp gnus-auto-select-subject)
4122 (funcall gnus-auto-select-subject))))
4123
eec82323
LMI
4124(defun gnus-summary-prepare ()
4125 "Generate the summary buffer."
4126 (interactive)
c7a91ce1 4127 (let ((inhibit-read-only t))
eec82323
LMI
4128 (erase-buffer)
4129 (setq gnus-newsgroup-data nil
4130 gnus-newsgroup-data-reverse nil)
6748645f 4131 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
4132 ;; Generate the buffer, either with threads or without.
4133 (when gnus-newsgroup-headers
4134 (gnus-summary-prepare-threads
4135 (if gnus-show-threads
4136 (gnus-sort-gathered-threads
4137 (funcall gnus-summary-thread-gathering-function
4138 (gnus-sort-threads
4139 (gnus-cut-threads (gnus-make-threads)))))
4140 ;; Unthreaded display.
4141 (gnus-sort-articles gnus-newsgroup-headers))))
4142 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4143 ;; Call hooks for modifying summary buffer.
4144 (goto-char (point-min))
6748645f 4145 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
4146
4147(defsubst gnus-general-simplify-subject (subject)
23f87bed 4148 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
4149 (setq subject
4150 (cond
4151 ;; Truncate the subject.
6748645f
LMI
4152 (gnus-simplify-subject-functions
4153 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
4154 ((numberp gnus-summary-gather-subject-limit)
4155 (setq subject (gnus-simplify-subject-re subject))
4156 (if (> (length subject) gnus-summary-gather-subject-limit)
4157 (substring subject 0 gnus-summary-gather-subject-limit)
4158 subject))
4159 ;; Fuzzily simplify it.
4160 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4161 (gnus-simplify-subject-fuzzy subject))
4162 ;; Just remove the leading "Re:".
4163 (t
4164 (gnus-simplify-subject-re subject))))
4165
4166 (if (and gnus-summary-gather-exclude-subject
4167 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 4168 nil ; This article shouldn't be gathered
eec82323
LMI
4169 subject))
4170
4171(defun gnus-summary-simplify-subject-query ()
4172 "Query where the respool algorithm would put this article."
4173 (interactive)
eec82323 4174 (gnus-summary-select-article)
274f1353 4175 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
eec82323
LMI
4176
4177(defun gnus-gather-threads-by-subject (threads)
4178 "Gather threads by looking at Subject headers."
4179 (if (not gnus-summary-make-false-root)
4180 threads
4181 (let ((hashtb (gnus-make-hashtable 1024))
4182 (prev threads)
4183 (result threads)
4184 subject hthread whole-subject)
4185 (while threads
4186 (setq subject (gnus-general-simplify-subject
4187 (setq whole-subject (mail-header-subject
4188 (caar threads)))))
4189 (when subject
4190 (if (setq hthread (gnus-gethash subject hashtb))
4191 (progn
4192 ;; We enter a dummy root into the thread, if we
4193 ;; haven't done that already.
4194 (unless (stringp (caar hthread))
4195 (setcar hthread (list whole-subject (car hthread))))
4196 ;; We add this new gathered thread to this gathered
4197 ;; thread.
4198 (setcdr (car hthread)
4199 (nconc (cdar hthread) (list (car threads))))
4200 ;; Remove it from the list of threads.
4201 (setcdr prev (cdr threads))
4202 (setq threads prev))
4203 ;; Enter this thread into the hash table.
23f87bed
MB
4204 (gnus-sethash subject
4205 (if gnus-summary-make-false-root-always
4206 (progn
4207 ;; If you want a dummy root above all
4208 ;; threads...
4209 (setcar threads (list whole-subject
4210 (car threads)))
4211 threads)
4212 threads)
4213 hashtb)))
eec82323
LMI
4214 (setq prev threads)
4215 (setq threads (cdr threads)))
4216 result)))
4217
4218(defun gnus-gather-threads-by-references (threads)
4219 "Gather threads by looking at References headers."
4220 (let ((idhashtb (gnus-make-hashtable 1024))
4221 (thhashtb (gnus-make-hashtable 1024))
4222 (prev threads)
4223 (result threads)
4224 ids references id gthread gid entered ref)
4225 (while threads
4226 (when (setq references (mail-header-references (caar threads)))
4227 (setq id (mail-header-id (caar threads))
23f87bed 4228 ids (inline (gnus-split-references references))
eec82323
LMI
4229 entered nil)
4230 (while (setq ref (pop ids))
4231 (setq ids (delete ref ids))
4232 (if (not (setq gid (gnus-gethash ref idhashtb)))
4233 (progn
4234 (gnus-sethash ref id idhashtb)
4235 (gnus-sethash id threads thhashtb))
4236 (setq gthread (gnus-gethash gid thhashtb))
4237 (unless entered
4238 ;; We enter a dummy root into the thread, if we
4239 ;; haven't done that already.
4240 (unless (stringp (caar gthread))
4241 (setcar gthread (list (mail-header-subject (caar gthread))
4242 (car gthread))))
4243 ;; We add this new gathered thread to this gathered
4244 ;; thread.
4245 (setcdr (car gthread)
4246 (nconc (cdar gthread) (list (car threads)))))
4247 ;; Add it into the thread hash table.
4248 (gnus-sethash id gthread thhashtb)
4249 (setq entered t)
4250 ;; Remove it from the list of threads.
4251 (setcdr prev (cdr threads))
4252 (setq threads prev))))
4253 (setq prev threads)
4254 (setq threads (cdr threads)))
4255 result))
4256
4257(defun gnus-sort-gathered-threads (threads)
16409b0b 4258 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
4259 (let ((result threads))
4260 (while threads
4261 (when (stringp (caar threads))
4262 (setcdr (car threads)
16409b0b 4263 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
4264 (setq threads (cdr threads)))
4265 result))
4266
4267(defun gnus-thread-loop-p (root thread)
4268 "Say whether ROOT is in THREAD."
4269 (let ((stack (list thread))
4270 (infloop 0)
4271 th)
4272 (while (setq thread (pop stack))
4273 (setq th (cdr thread))
4274 (while (and th
4275 (not (eq (caar th) root)))
4276 (pop th))
4277 (if th
4278 ;; We have found a loop.
4279 (let (ref-dep)
4280 (setcdr thread (delq (car th) (cdr thread)))
4281 (if (boundp (setq ref-dep (intern "none"
4282 gnus-newsgroup-dependencies)))
4283 (setcdr (symbol-value ref-dep)
4284 (nconc (cdr (symbol-value ref-dep))
4285 (list (car th))))
4286 (set ref-dep (list nil (car th))))
4287 (setq infloop 1
4288 stack nil))
4289 ;; Push all the subthreads onto the stack.
4290 (push (cdr thread) stack)))
4291 infloop))
4292
4293(defun gnus-make-threads ()
01ccbb85 4294 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
4295 (let (threads)
4296 (while (catch 'infloop
4297 (mapatoms
4298 (lambda (refs)
4299 ;; Deal with self-referencing References loops.
4300 (when (and (car (symbol-value refs))
4301 (not (zerop
4302 (apply
4303 '+
4304 (mapcar
4305 (lambda (thread)
4306 (gnus-thread-loop-p
4307 (car (symbol-value refs)) thread))
4308 (cdr (symbol-value refs)))))))
4309 (setq threads nil)
4310 (throw 'infloop t))
4311 (unless (car (symbol-value refs))
23f87bed
MB
4312 ;; These threads do not refer back to any other
4313 ;; articles, so they're roots.
eec82323
LMI
4314 (setq threads (append (cdr (symbol-value refs)) threads))))
4315 gnus-newsgroup-dependencies)))
4316 threads))
4317
6748645f 4318;; Build the thread tree.
16409b0b 4319(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4320 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4321
4322If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4323if it was already present.
4324
4325If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4326will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4327Message-IDs will be renamed to a unique Message-ID before being
4328entered.
6748645f
LMI
4329
4330Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4331 (let* ((id (mail-header-id header))
4332 (id-dep (and id (intern id dependencies)))
23f87bed 4333 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4334 ;; Enter this `header' in the `dependencies' table.
4335 (cond
4336 ((not id-dep)
4337 (setq header nil))
4338 ;; The first two cases do the normal part: enter a new `header'
4339 ;; in the `dependencies' table.
4340 ((not (boundp id-dep))
4341 (set id-dep (list header)))
4342 ((null (car (symbol-value id-dep)))
4343 (setcar (symbol-value id-dep) header))
4344
4345 ;; From here the `header' was already present in the
4346 ;; `dependencies' table.
4347 (force-new
4348 ;; Overrides an existing entry;
4349 ;; just set the header part of the entry.
23f87bed
MB
4350 (setcar (symbol-value id-dep) header)
4351 (setq replaced t))
6748645f
LMI
4352
4353 ;; Renames the existing `header' to a unique Message-ID.
4354 ((not gnus-summary-ignore-duplicates)
4355 ;; An article with this Message-ID has already been seen.
4356 ;; We rename the Message-ID.
4357 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4358 (list header))
4359 (mail-header-set-id header id))
4360
4361 ;; The last case ignores an existing entry, except it adds any
4362 ;; additional Xrefs (in case the two articles came from different
4363 ;; servers.
4364 ;; Also sets `header' to `nil' meaning that the `dependencies'
4365 ;; table was *not* modified.
4366 (t
4367 (mail-header-set-xref
4368 (car (symbol-value id-dep))
4369 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4370 "")
4371 (or (mail-header-xref header) "")))
4372 (setq header nil)))
4373
23f87bed
MB
4374 (when (and header (not replaced))
4375 ;; First check that we are not creating a References loop.
4376 (setq parent-id (gnus-parent-id (mail-header-references header)))
4377 (setq ref parent-id)
6748645f
LMI
4378 (while (and ref
4379 (setq ref-dep (intern-soft ref dependencies))
4380 (boundp ref-dep)
4381 (setq ref-header (car (symbol-value ref-dep))))
4382 (if (string= id ref)
4383 ;; Yuk! This is a reference loop. Make the article be a
4384 ;; root article.
4385 (progn
4386 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4387 (setq ref nil)
4388 (setq parent-id nil))
6748645f 4389 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4390 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4391 (if (boundp ref-dep)
4392 (setcdr (symbol-value ref-dep)
4393 (nconc (cdr (symbol-value ref-dep))
4394 (list (symbol-value id-dep))))
4395 (set ref-dep (list nil (symbol-value id-dep)))))
4396 header))
4397
23f87bed
MB
4398(defun gnus-extract-message-id-from-in-reply-to (string)
4399 (if (string-match "<[^>]+>" string)
4400 (substring string (match-beginning 0) (match-end 0))
4401 nil))
4402
eec82323
LMI
4403(defun gnus-build-sparse-threads ()
4404 (let ((headers gnus-newsgroup-headers)
16409b0b 4405 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4406 (gnus-summary-ignore-duplicates t)
eec82323 4407 header references generation relations
6748645f 4408 subject child end new-child date)
eec82323
LMI
4409 ;; First we create an alist of generations/relations, where
4410 ;; generations is how much we trust the relation, and the relation
4411 ;; is parent/child.
4412 (gnus-message 7 "Making sparse threads...")
4413 (save-excursion
4414 (nnheader-set-temp-buffer " *gnus sparse threads*")
4415 (while (setq header (pop headers))
4416 (when (and (setq references (mail-header-references header))
4417 (not (string= references "")))
4418 (insert references)
4419 (setq child (mail-header-id header)
6748645f
LMI
4420 subject (mail-header-subject header)
4421 date (mail-header-date header)
4422 generation 0)
eec82323
LMI
4423 (while (search-backward ">" nil t)
4424 (setq end (1+ (point)))
4425 (when (search-backward "<" nil t)
6748645f 4426 (setq new-child (buffer-substring (point) end))
eec82323 4427 (push (list (incf generation)
6748645f
LMI
4428 child (setq child new-child)
4429 subject date)
eec82323 4430 relations)))
6748645f
LMI
4431 (when child
4432 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4433 (erase-buffer)))
4434 (kill-buffer (current-buffer)))
4435 ;; Sort over trustworthiness.
01c52d31
MB
4436 (dolist (relation (sort relations 'car-less-than-car))
4437 (when (gnus-dependencies-add-header
4438 (make-full-mail-header
4439 gnus-reffed-article-number
4440 (nth 3 relation) "" (or (nth 4 relation) "")
4441 (nth 1 relation)
4442 (or (nth 2 relation) "") 0 0 "")
4443 gnus-newsgroup-dependencies nil)
4444 (push gnus-reffed-article-number gnus-newsgroup-limit)
4445 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4446 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4447 gnus-newsgroup-reads)
4448 (decf gnus-reffed-article-number)))
eec82323
LMI
4449 (gnus-message 7 "Making sparse threads...done")))
4450
4451(defun gnus-build-old-threads ()
4452 ;; Look at all the articles that refer back to old articles, and
4453 ;; fetch the headers for the articles that aren't there. This will
4454 ;; build complete threads - if the roots haven't been expired by the
4455 ;; server, that is.
16409b0b
GM
4456 (let ((mail-parse-charset gnus-newsgroup-charset)
4457 id heads)
eec82323
LMI
4458 (mapatoms
4459 (lambda (refs)
4460 (when (not (car (symbol-value refs)))
4461 (setq heads (cdr (symbol-value refs)))
4462 (while heads
4463 (if (memq (mail-header-number (caar heads))
4464 gnus-newsgroup-dormant)
4465 (setq heads (cdr heads))
4466 (setq id (symbol-name refs))
4467 (while (and (setq id (gnus-build-get-header id))
6748645f 4468 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4469 (setq heads nil)))))
4470 gnus-newsgroup-dependencies)))
4471
23f87bed
MB
4472(defsubst gnus-remove-odd-characters (string)
4473 "Translate STRING into something that doesn't contain weird characters."
4474 (mm-subst-char-in-string
4475 ?\r ?\-
01c52d31 4476 (mm-subst-char-in-string ?\n ?\- string t) t))
23f87bed 4477
6748645f
LMI
4478;; This function has to be called with point after the article number
4479;; on the beginning of the line.
4480(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
01c52d31 4481 (let ((eol (point-at-eol))
6748645f 4482 (buffer (current-buffer))
23f87bed 4483 header references in-reply-to)
6748645f
LMI
4484
4485 ;; overview: [num subject from date id refs chars lines misc]
4486 (unwind-protect
23f87bed 4487 (let (x)
6748645f
LMI
4488 (narrow-to-region (point) eol)
4489 (unless (eobp)
4490 (forward-char))
4491
4492 (setq header
4493 (make-full-mail-header
4494 number ; number
23f87bed
MB
4495 (condition-case () ; subject
4496 (gnus-remove-odd-characters
4497 (funcall gnus-decode-encoded-word-function
4498 (setq x (nnheader-nov-field))))
4499 (error x))
4500 (condition-case () ; from
4501 (gnus-remove-odd-characters
343d6628 4502 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4503 (setq x (nnheader-nov-field))))
4504 (error x))
16409b0b 4505 (nnheader-nov-field) ; date
01c52d31 4506 (nnheader-nov-read-message-id number) ; id
23f87bed 4507 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4508 (nnheader-nov-read-integer) ; chars
4509 (nnheader-nov-read-integer) ; lines
4510 (unless (eobp)
8b93df01
DL
4511 (if (looking-at "Xref: ")
4512 (goto-char (match-end 0)))
4513 (nnheader-nov-field)) ; Xref
16409b0b 4514 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4515
4516 (widen))
4517
23f87bed
MB
4518 (when (and (string= references "")
4519 (setq in-reply-to (mail-header-extra header))
4520 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4521 (mail-header-set-references
4522 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4523
6748645f
LMI
4524 (when gnus-alter-header-function
4525 (funcall gnus-alter-header-function header))
4526 (gnus-dependencies-add-header header dependencies force-new)))
4527
eec82323 4528(defun gnus-build-get-header (id)
16409b0b
GM
4529 "Look through the buffer of NOV lines and find the header to ID.
4530Enter this line into the dependencies hash table, and return
4531the id of the parent article (if any)."
eec82323
LMI
4532 (let ((deps gnus-newsgroup-dependencies)
4533 found header)
4534 (prog1
c7a91ce1 4535 (with-current-buffer nntp-server-buffer
eec82323
LMI
4536 (let ((case-fold-search nil))
4537 (goto-char (point-min))
4538 (while (and (not found)
4539 (search-forward id nil t))
4540 (beginning-of-line)
4541 (setq found (looking-at
4542 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4543 (regexp-quote id))))
4544 (or found (beginning-of-line 2)))
4545 (when found
4546 (beginning-of-line)
4547 (and
4548 (setq header (gnus-nov-parse-line
4549 (read (current-buffer)) deps))
4550 (gnus-parent-id (mail-header-references header))))))
4551 (when header
4552 (let ((number (mail-header-number header)))
4553 (push number gnus-newsgroup-limit)
4554 (push header gnus-newsgroup-headers)
4555 (if (memq number gnus-newsgroup-unselected)
4556 (progn
23f87bed
MB
4557 (setq gnus-newsgroup-unreads
4558 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4559 number))
eec82323
LMI
4560 (setq gnus-newsgroup-unselected
4561 (delq number gnus-newsgroup-unselected)))
4562 (push number gnus-newsgroup-ancient)))))))
4563
6748645f
LMI
4564(defun gnus-build-all-threads ()
4565 "Read all the headers."
4566 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4567 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4568 (dependencies gnus-newsgroup-dependencies)
4569 header article)
c7a91ce1 4570 (with-current-buffer nntp-server-buffer
6748645f
LMI
4571 (let ((case-fold-search nil))
4572 (goto-char (point-min))
4573 (while (not (eobp))
4574 (ignore-errors
4575 (setq article (read (current-buffer))
181cb5fb 4576 header (gnus-nov-parse-line article dependencies t)))
6748645f 4577 (when header
01c52d31 4578 (with-current-buffer gnus-summary-buffer
6748645f
LMI
4579 (push header gnus-newsgroup-headers)
4580 (if (memq (setq article (mail-header-number header))
4581 gnus-newsgroup-unselected)
4582 (progn
23f87bed
MB
4583 (setq gnus-newsgroup-unreads
4584 (gnus-add-to-sorted-list
4585 gnus-newsgroup-unreads article))
6748645f
LMI
4586 (setq gnus-newsgroup-unselected
4587 (delq article gnus-newsgroup-unselected)))
4588 (push article gnus-newsgroup-ancient)))
4589 (forward-line 1)))))))
4590
eec82323 4591(defun gnus-summary-update-article-line (article header)
23f87bed 4592 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4593 (let* ((id (mail-header-id header))
4594 (thread (gnus-id-to-thread id)))
4595 (unless thread
4596 (error "Article in no thread"))
4597 ;; Update the thread.
4598 (setcar thread header)
4599 (gnus-summary-goto-subject article)
4600 (let* ((datal (gnus-data-find-list article))
4601 (data (car datal))
c7a91ce1 4602 (inhibit-read-only t)
eec82323
LMI
4603 (level (gnus-summary-thread-level)))
4604 (gnus-delete-line)
23f87bed
MB
4605 (let ((inserted (- (point)
4606 (progn
4607 (gnus-summary-insert-line
4608 header level nil
4609 (memq article gnus-newsgroup-undownloaded)
4610 (gnus-article-mark article)
4611 (memq article gnus-newsgroup-replied)
4612 (memq article gnus-newsgroup-expirable)
4613 ;; Only insert the Subject string when it's different
4614 ;; from the previous Subject string.
4615 (if (and
4616 gnus-show-threads
4617 (gnus-subject-equal
4618 (condition-case ()
4619 (mail-header-subject
4620 (gnus-data-header
4621 (cadr
4622 (gnus-data-find-list
4623 article
4624 (gnus-data-list t)))))
4625 ;; Error on the side of excessive subjects.
4626 (error ""))
4627 (mail-header-subject header)))
4628 ""
4629 (mail-header-subject header))
4630 nil (cdr (assq article gnus-newsgroup-scored))
4631 (memq article gnus-newsgroup-processable))
4632 (point)))))
4633 (when (cdr datal)
4634 (gnus-data-update-list
4635 (cdr datal)
4636 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4637
4638(defun gnus-summary-update-article (article &optional iheader)
4639 "Update ARTICLE in the summary buffer."
4640 (set-buffer gnus-summary-buffer)
6748645f 4641 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4642 (id (mail-header-id header))
4643 (data (gnus-data-find article))
4644 (thread (gnus-id-to-thread id))
4645 (references (mail-header-references header))
4646 (parent
4647 (gnus-id-to-thread
4648 (or (gnus-parent-id
4649 (when (and references
4650 (not (equal "" references)))
4651 references))
4652 "none")))
c7a91ce1 4653 (inhibit-read-only t)
6748645f 4654 (old (car thread)))
eec82323 4655 (when thread
eec82323 4656 (unless iheader
6748645f
LMI
4657 (setcar thread nil)
4658 (when parent
4659 (delq thread parent)))
4660 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4661 ;; Set the (possibly) new article number in the data structure.
4662 (gnus-data-set-number data (gnus-id-to-article id))
4663 (setcar thread old)
4664 nil))))
4665
6748645f
LMI
4666(defun gnus-rebuild-thread (id &optional line)
4667 "Rebuild the thread containing ID.
4668If LINE, insert the rebuilt thread starting on line LINE."
c7a91ce1 4669 (let ((inhibit-read-only t)
eec82323
LMI
4670 old-pos current thread data)
4671 (if (not gnus-show-threads)
4672 (setq thread (list (car (gnus-id-to-thread id))))
4673 ;; Get the thread this article is part of.
4674 (setq thread (gnus-remove-thread id)))
01c52d31 4675 (setq old-pos (point-at-bol))
eec82323 4676 (setq current (save-excursion
94384150 4677 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4678 (gnus-summary-article-number))))
4679 ;; If this is a gathered thread, we have to go some re-gathering.
4680 (when (stringp (car thread))
4681 (let ((subject (car thread))
4682 roots thr)
4683 (setq thread (cdr thread))
4684 (while thread
4685 (unless (memq (setq thr (gnus-id-to-thread
4686 (gnus-root-id
4687 (mail-header-id (caar thread)))))
4688 roots)
4689 (push thr roots))
4690 (setq thread (cdr thread)))
4691 ;; We now have all (unique) roots.
4692 (if (= (length roots) 1)
4693 ;; All the loose roots are now one solid root.
4694 (setq thread (car roots))
4695 (setq thread (cons subject (gnus-sort-threads roots))))))
4696 (let (threads)
4697 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4698 (when line
4699 (goto-char (point-min))
4700 (forward-line (1- line)))
eec82323
LMI
4701 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4702 (if gnus-show-threads
4703 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4704 (gnus-summary-prepare-unthreaded thread))
4705 (setq data (nreverse gnus-newsgroup-data))
4706 (setq threads gnus-newsgroup-threads))
4707 ;; We splice the new data into the data structure.
6748645f
LMI
4708 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4709 ;;!!! then we want to insert at the beginning of the buffer.
4710 ;;!!! That happens to be true with Gnus now, but that may
4711 ;;!!! change in the future. Perhaps.
4712 (gnus-data-enter-list
4713 (if line nil current) data (- (point) old-pos))
4714 (setq gnus-newsgroup-threads
4715 (nconc threads gnus-newsgroup-threads))
4716 (gnus-data-compute-positions))))
eec82323
LMI
4717
4718(defun gnus-number-to-header (number)
4719 "Return the header for article NUMBER."
4720 (let ((headers gnus-newsgroup-headers))
4721 (while (and headers
4722 (not (= number (mail-header-number (car headers)))))
4723 (pop headers))
4724 (when headers
4725 (car headers))))
4726
6748645f 4727(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4728 "Return the headers of the GENERATIONeth parent of HEADERS."
4729 (unless generation
4730 (setq generation 1))
a8151ef7 4731 (let ((parent t)
6748645f 4732 (headers in-headers)
a8151ef7 4733 references)
6748645f
LMI
4734 (while (and parent
4735 (not (zerop generation))
4736 (setq references (mail-header-references headers)))
4737 (setq headers (if (and references
4738 (setq parent (gnus-parent-id references)))
4739 (car (gnus-id-to-thread parent))
4740 nil))
4741 (decf generation))
4742 (and (not (eq headers in-headers))
4743 headers)))
eec82323
LMI
4744
4745(defun gnus-id-to-thread (id)
4746 "Return the (sub-)thread where ID appears."
4747 (gnus-gethash id gnus-newsgroup-dependencies))
4748
4749(defun gnus-id-to-article (id)
4750 "Return the article number of ID."
4751 (let ((thread (gnus-id-to-thread id)))
4752 (when (and thread
4753 (car thread))
4754 (mail-header-number (car thread)))))
4755
4756(defun gnus-id-to-header (id)
4757 "Return the article headers of ID."
4758 (car (gnus-id-to-thread id)))
4759
4760(defun gnus-article-displayed-root-p (article)
4761 "Say whether ARTICLE is a root(ish) article."
4762 (let ((level (gnus-summary-thread-level article))
4763 (refs (mail-header-references (gnus-summary-article-header article)))
4764 particle)
4765 (cond
4766 ((null level) nil)
4767 ((zerop level) t)
4768 ((null refs) t)
4769 ((null (gnus-parent-id refs)) t)
4770 ((and (= 1 level)
4771 (null (setq particle (gnus-id-to-article
4772 (gnus-parent-id refs))))
4773 (null (gnus-summary-thread-level particle)))))))
4774
4775(defun gnus-root-id (id)
4776 "Return the id of the root of the thread where ID appears."
4777 (let (last-id prev)
6748645f 4778 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4779 (setq last-id id
4780 id (gnus-parent-id (mail-header-references prev))))
4781 last-id))
4782
6748645f
LMI
4783(defun gnus-articles-in-thread (thread)
4784 "Return the list of articles in THREAD."
4785 (cons (mail-header-number (car thread))
4786 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4787
eec82323
LMI
4788(defun gnus-remove-thread (id &optional dont-remove)
4789 "Remove the thread that has ID in it."
6748645f 4790 (let (headers thread last-id)
eec82323 4791 ;; First go up in this thread until we find the root.
6748645f
LMI
4792 (setq last-id (gnus-root-id id)
4793 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4794 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4795 ;; been gathered into some loose thread, so we have to search
4796 ;; through the threads to find the thread we wanted.
4797 (let ((threads gnus-newsgroup-threads)
4798 sub)
4799 (while threads
4800 (setq sub (car threads))
4801 (if (stringp (car sub))
4802 ;; This is a gathered thread, so we look at the roots
4803 ;; below it to find whether this article is in this
4804 ;; gathered root.
4805 (progn
4806 (setq sub (cdr sub))
4807 (while sub
4808 (when (member (caar sub) headers)
4809 (setq thread (car threads)
4810 threads nil
4811 sub nil))
4812 (setq sub (cdr sub))))
4813 ;; It's an ordinary thread, so we check it.
4814 (when (eq (car sub) (car headers))
4815 (setq thread sub
4816 threads nil)))
4817 (setq threads (cdr threads)))
4818 ;; If this article is in no thread, then it's a root.
4819 (if thread
4820 (unless dont-remove
4821 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4822 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4823 (when thread
4824 (prog1
4825 thread ; We return this thread.
4826 (unless dont-remove
4827 (if (stringp (car thread))
4828 (progn
4829 ;; If we use dummy roots, then we have to remove the
4830 ;; dummy root as well.
4831 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4832 ;; We go to the dummy root by going to
4833 ;; the first sub-"thread", and then one line up.
4834 (gnus-summary-goto-article
4835 (mail-header-number (caadr thread)))
4836 (forward-line -1)
eec82323
LMI
4837 (gnus-delete-line)
4838 (gnus-data-compute-positions))
4839 (setq thread (cdr thread))
4840 (while thread
4841 (gnus-remove-thread-1 (car thread))
4842 (setq thread (cdr thread))))
4843 (gnus-remove-thread-1 thread))))))))
4844
4845(defun gnus-remove-thread-1 (thread)
4846 "Remove the thread THREAD recursively."
4847 (let ((number (mail-header-number (pop thread)))
4848 d)
4849 (setq thread (reverse thread))
4850 (while thread
4851 (gnus-remove-thread-1 (pop thread)))
4852 (when (setq d (gnus-data-find number))
4853 (goto-char (gnus-data-pos d))
16409b0b 4854 (gnus-summary-show-thread)
eec82323
LMI
4855 (gnus-data-remove
4856 number
01c52d31 4857 (- (point-at-bol)
eec82323 4858 (prog1
01c52d31 4859 (1+ (point-at-eol))
eec82323
LMI
4860 (gnus-delete-line)))))))
4861
4921bbdd 4862(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4863 (sort (mapcar (lambda (thread)
4864 (cons (car thread)
4865 (and (cdr thread)
4921bbdd 4866 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4867 threads) func))
4868
4921bbdd
CY
4869(defun gnus-sort-threads-loop (threads func)
4870 (let* ((superthread (cons nil threads))
4871 (stack (list (cons superthread threads)))
4872 remaining-threads thread)
4873 (while stack
4874 (setq remaining-threads (cdr (car stack)))
4875 (if remaining-threads
4876 (progn (setq thread (car remaining-threads))
4877 (setcdr (car stack) (cdr remaining-threads))
4878 (if (cdr thread)
4879 (push (cons thread (cdr thread)) stack)))
4880 (setq thread (caar stack))
4881 (setcdr thread (sort (cdr thread) func))
4882 (pop stack)))
4883 (cdr superthread)))
4884
eec82323
LMI
4885(defun gnus-sort-threads (threads)
4886 "Sort THREADS."
4887 (if (not gnus-thread-sort-functions)
4888 threads
6748645f 4889 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4890 (prog1
4891 (condition-case nil
4892 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4893 (gnus-sort-threads-recursive
4894 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4895 ;; Even after binding max-lisp-eval-depth, the recursive
4896 ;; sorter might fail for very long threads. In that case,
4897 ;; try using a (less well-tested) non-recursive sorter.
3d6e7a43
KY
4898 (error (gnus-message 9 "Sorting threads with loop...")
4899 (gnus-sort-threads-loop
4921bbdd
CY
4900 threads (gnus-make-sort-function
4901 gnus-thread-sort-functions))))
4902 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4903
4904(defun gnus-sort-articles (articles)
4905 "Sort ARTICLES."
4906 (when gnus-article-sort-functions
4907 (gnus-message 7 "Sorting articles...")
4908 (prog1
4909 (setq gnus-newsgroup-headers
4910 (sort articles (gnus-make-sort-function
4911 gnus-article-sort-functions)))
4912 (gnus-message 7 "Sorting articles...done"))))
4913
4914;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4915(defmacro gnus-thread-header (thread)
16409b0b
GM
4916 "Return header of first article in THREAD.
4917Note that THREAD must never, ever be anything else than a variable -
4918using some other form will lead to serious barfage."
eec82323
LMI
4919 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4920 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4921 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4922 (vector thread) 2))
4923
4924(defsubst gnus-article-sort-by-number (h1 h2)
4925 "Sort articles by article number."
4926 (< (mail-header-number h1)
4927 (mail-header-number h2)))
4928
4929(defun gnus-thread-sort-by-number (h1 h2)
4930 "Sort threads by root article number."
4931 (gnus-article-sort-by-number
4932 (gnus-thread-header h1) (gnus-thread-header h2)))
4933
23f87bed 4934(defsubst gnus-article-sort-by-random (h1 h2)
0b6799c3 4935 "Sort articles randomly."
23f87bed
MB
4936 (zerop (random 2)))
4937
4938(defun gnus-thread-sort-by-random (h1 h2)
0b6799c3 4939 "Sort threads randomly."
23f87bed
MB
4940 (gnus-article-sort-by-random
4941 (gnus-thread-header h1) (gnus-thread-header h2)))
4942
eec82323
LMI
4943(defsubst gnus-article-sort-by-lines (h1 h2)
4944 "Sort articles by article Lines header."
4945 (< (mail-header-lines h1)
4946 (mail-header-lines h2)))
4947
4948(defun gnus-thread-sort-by-lines (h1 h2)
4949 "Sort threads by root article Lines header."
4950 (gnus-article-sort-by-lines
4951 (gnus-thread-header h1) (gnus-thread-header h2)))
4952
16409b0b
GM
4953(defsubst gnus-article-sort-by-chars (h1 h2)
4954 "Sort articles by octet length."
4955 (< (mail-header-chars h1)
4956 (mail-header-chars h2)))
4957
4958(defun gnus-thread-sort-by-chars (h1 h2)
4959 "Sort threads by root article octet length."
4960 (gnus-article-sort-by-chars
4961 (gnus-thread-header h1) (gnus-thread-header h2)))
4962
eec82323
LMI
4963(defsubst gnus-article-sort-by-author (h1 h2)
4964 "Sort articles by root author."
b4fde39f 4965 (gnus-string<
eec82323
LMI
4966 (let ((extract (funcall
4967 gnus-extract-address-components
4968 (mail-header-from h1))))
4969 (or (car extract) (cadr extract) ""))
4970 (let ((extract (funcall
4971 gnus-extract-address-components
4972 (mail-header-from h2))))
4973 (or (car extract) (cadr extract) ""))))
4974
4975(defun gnus-thread-sort-by-author (h1 h2)
4976 "Sort threads by root author."
4977 (gnus-article-sort-by-author
4978 (gnus-thread-header h1) (gnus-thread-header h2)))
4979
01c52d31
MB
4980(defsubst gnus-article-sort-by-recipient (h1 h2)
4981 "Sort articles by recipient."
4982 (gnus-string<
4983 (let ((extract (funcall
4984 gnus-extract-address-components
4985 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4986 (or (car extract) (cadr extract)))
4987 (let ((extract (funcall
4988 gnus-extract-address-components
4989 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4990 (or (car extract) (cadr extract)))))
4991
4992(defun gnus-thread-sort-by-recipient (h1 h2)
4993 "Sort threads by root recipient."
4994 (gnus-article-sort-by-recipient
4995 (gnus-thread-header h1) (gnus-thread-header h2)))
4996
eec82323
LMI
4997(defsubst gnus-article-sort-by-subject (h1 h2)
4998 "Sort articles by root subject."
b4fde39f 4999 (gnus-string<
eec82323
LMI
5000 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5001 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5002
5003(defun gnus-thread-sort-by-subject (h1 h2)
5004 "Sort threads by root subject."
5005 (gnus-article-sort-by-subject
5006 (gnus-thread-header h1) (gnus-thread-header h2)))
5007
5008(defsubst gnus-article-sort-by-date (h1 h2)
5009 "Sort articles by root article date."
16409b0b 5010 (time-less-p
eec82323
LMI
5011 (gnus-date-get-time (mail-header-date h1))
5012 (gnus-date-get-time (mail-header-date h2))))
5013
5014(defun gnus-thread-sort-by-date (h1 h2)
5015 "Sort threads by root article date."
5016 (gnus-article-sort-by-date
5017 (gnus-thread-header h1) (gnus-thread-header h2)))
5018
5019(defsubst gnus-article-sort-by-score (h1 h2)
5020 "Sort articles by root article score.
5021Unscored articles will be counted as having a score of zero."
5022 (> (or (cdr (assq (mail-header-number h1)
5023 gnus-newsgroup-scored))
5024 gnus-summary-default-score 0)
5025 (or (cdr (assq (mail-header-number h2)
5026 gnus-newsgroup-scored))
5027 gnus-summary-default-score 0)))
5028
5029(defun gnus-thread-sort-by-score (h1 h2)
5030 "Sort threads by root article score."
5031 (gnus-article-sort-by-score
5032 (gnus-thread-header h1) (gnus-thread-header h2)))
5033
5034(defun gnus-thread-sort-by-total-score (h1 h2)
5035 "Sort threads by the sum of all scores in the thread.
5036Unscored articles will be counted as having a score of zero."
5037 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5038
5039(defun gnus-thread-total-score (thread)
16409b0b 5040 ;; This function find the total score of THREAD.
23f87bed
MB
5041 (cond
5042 ((null thread)
5043 0)
5044 ((consp thread)
5045 (if (stringp (car thread))
5046 (apply gnus-thread-score-function 0
5047 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5048 (gnus-thread-total-score-1 thread)))
5049 (t
5050 (gnus-thread-total-score-1 (list thread)))))
5051
130e977f
LMI
5052(defun gnus-article-sort-by-most-recent-number (h1 h2)
5053 "Sort articles by number."
5054 (gnus-article-sort-by-number h1 h2))
5055
23f87bed
MB
5056(defun gnus-thread-sort-by-most-recent-number (h1 h2)
5057 "Sort threads such that the thread with the most recently arrived article comes first."
5058 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5059
5060(defun gnus-thread-highest-number (thread)
5061 "Return the highest article number in THREAD."
5062 (apply 'max (mapcar (lambda (header)
5063 (mail-header-number header))
5064 (message-flatten-list thread))))
5065
130e977f
LMI
5066(defun gnus-article-sort-by-most-recent-date (h1 h2)
5067 "Sort articles by number."
5068 (gnus-article-sort-by-date h1 h2))
5069
23f87bed
MB
5070(defun gnus-thread-sort-by-most-recent-date (h1 h2)
5071 "Sort threads such that the thread with the most recently dated article comes first."
5072 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5073
3d6e7a43
KY
5074; Since this is called not only to sort the top-level threads, but
5075; also in recursive sorts to order the articles within a thread, each
5076; article will be processed many times. Thus it speeds things up
5077; quite a bit to use gnus-date-get-time, which caches the time value.
23f87bed
MB
5078(defun gnus-thread-latest-date (thread)
5079 "Return the highest article date in THREAD."
3d6e7a43
KY
5080 (apply 'max
5081 (mapcar (lambda (header) (gnus-float-time
5082 (gnus-date-get-time
5083 (mail-header-date header))))
5084 (message-flatten-list thread))))
eec82323
LMI
5085
5086(defun gnus-thread-total-score-1 (root)
5087 ;; This function find the total score of the thread below ROOT.
5088 (setq root (car root))
5089 (apply gnus-thread-score-function
5090 (or (append
5091 (mapcar 'gnus-thread-total-score
6748645f 5092 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
5093 (when (> (mail-header-number root) 0)
5094 (list (or (cdr (assq (mail-header-number root)
5095 gnus-newsgroup-scored))
5096 gnus-summary-default-score 0))))
5097 (list gnus-summary-default-score)
5098 '(0))))
5099
5100;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5101(defvar gnus-tmp-prev-subject nil)
5102(defvar gnus-tmp-false-parent nil)
5103(defvar gnus-tmp-root-expunged nil)
5104(defvar gnus-tmp-dummy-line nil)
5105
16409b0b
GM
5106(defun gnus-extra-header (type &optional header)
5107 "Return the extra header of TYPE."
5108 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5109 ""))
5110
23f87bed
MB
5111(defvar gnus-tmp-thread-tree-header-string "")
5112
5113(defcustom gnus-sum-thread-tree-root "> "
5114 "With %B spec, used for the root of a thread.
5115If nil, use subject instead."
bf247b6e 5116 :version "22.1"
ad136a7c 5117 :type '(radio (const :format "%v " nil) string)
23f87bed 5118 :group 'gnus-thread)
01c52d31 5119
23f87bed
MB
5120(defcustom gnus-sum-thread-tree-false-root "> "
5121 "With %B spec, used for a false root of a thread.
5122If nil, use subject instead."
bf247b6e 5123 :version "22.1"
ad136a7c 5124 :type '(radio (const :format "%v " nil) string)
23f87bed 5125 :group 'gnus-thread)
01c52d31 5126
23f87bed
MB
5127(defcustom gnus-sum-thread-tree-single-indent ""
5128 "With %B spec, used for a thread with just one message.
5129If nil, use subject instead."
bf247b6e 5130 :version "22.1"
ad136a7c 5131 :type '(radio (const :format "%v " nil) string)
23f87bed 5132 :group 'gnus-thread)
01c52d31 5133
23f87bed
MB
5134(defcustom gnus-sum-thread-tree-vertical "| "
5135 "With %B spec, used for drawing a vertical line."
bf247b6e 5136 :version "22.1"
23f87bed
MB
5137 :type 'string
5138 :group 'gnus-thread)
01c52d31 5139
23f87bed
MB
5140(defcustom gnus-sum-thread-tree-indent " "
5141 "With %B spec, used for indenting."
bf247b6e 5142 :version "22.1"
23f87bed
MB
5143 :type 'string
5144 :group 'gnus-thread)
01c52d31 5145
23f87bed
MB
5146(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5147 "With %B spec, used for a leaf with brothers."
bf247b6e 5148 :version "22.1"
23f87bed
MB
5149 :type 'string
5150 :group 'gnus-thread)
01c52d31 5151
23f87bed
MB
5152(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5153 "With %B spec, used for a leaf without brothers."
bf247b6e 5154 :version "22.1"
23f87bed
MB
5155 :type 'string
5156 :group 'gnus-thread)
5157
1fc34624
GM
5158(defcustom gnus-summary-display-while-building nil
5159 "If non-nil, show and update the summary buffer as it's being built.
5160If the value is t, update the buffer after every line is inserted. If
5161the value is an integer (N), update the display every N lines."
5162 :version "22.1"
5163 :group 'gnus-thread
5164 :type '(choice (const :tag "off" nil)
5165 number
5166 (const :tag "frequently" t)))
5167
eec82323
LMI
5168(defun gnus-summary-prepare-threads (threads)
5169 "Prepare summary buffer from THREADS and indentation LEVEL.
5170THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5171or a straight list of headers."
5172 (gnus-message 7 "Generating summary...")
5173
5174 (setq gnus-newsgroup-threads threads)
5175 (beginning-of-line)
5176
5177 (let ((gnus-tmp-level 0)
5178 (default-score (or gnus-summary-default-score 0))
5179 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
5180 (building-line-count gnus-summary-display-while-building)
5181 (building-count (integerp gnus-summary-display-while-building))
eec82323 5182 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
5183 new-roots gnus-tmp-new-adopts thread-end simp-subject
5184 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
5185 gnus-tmp-replied gnus-tmp-subject-or-nil
5186 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5187 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
5188 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5189 tree-stack)
eec82323 5190
23f87bed
MB
5191 (setq gnus-tmp-prev-subject nil
5192 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
5193
5194 (if (vectorp (car threads))
5195 ;; If this is a straight (sic) list of headers, then a
5196 ;; threaded summary display isn't required, so we just create
5197 ;; an unthreaded one.
5198 (gnus-summary-prepare-unthreaded threads)
5199
5200 ;; Do the threaded display.
5201
23f87bed
MB
5202 (if gnus-summary-display-while-building
5203 (switch-to-buffer (buffer-name)))
eec82323
LMI
5204 (while (or threads stack gnus-tmp-new-adopts new-roots)
5205
5206 (if (and (= gnus-tmp-level 0)
eec82323
LMI
5207 (or (not stack)
5208 (= (caar stack) 0))
5209 (not gnus-tmp-false-parent)
5210 (or gnus-tmp-new-adopts new-roots))
5211 (if gnus-tmp-new-adopts
5212 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5213 thread (list (car gnus-tmp-new-adopts))
5214 gnus-tmp-header (caar thread)
5215 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5216 (when new-roots
5217 (setq thread (list (car new-roots))
5218 gnus-tmp-header (caar thread)
5219 new-roots (cdr new-roots))))
5220
5221 (if threads
5222 ;; If there are some threads, we do them before the
5223 ;; threads on the stack.
5224 (setq thread threads
5225 gnus-tmp-header (caar thread))
5226 ;; There were no current threads, so we pop something off
5227 ;; the stack.
5228 (setq state (car stack)
5229 gnus-tmp-level (car state)
23f87bed
MB
5230 tree-stack (cadr state)
5231 thread (caddr state)
eec82323
LMI
5232 stack (cdr stack)
5233 gnus-tmp-header (caar thread))))
5234
5235 (setq gnus-tmp-false-parent nil)
5236 (setq gnus-tmp-root-expunged nil)
5237 (setq thread-end nil)
5238
5239 (if (stringp gnus-tmp-header)
5240 ;; The header is a dummy root.
5241 (cond
5242 ((eq gnus-summary-make-false-root 'adopt)
5243 ;; We let the first article adopt the rest.
5244 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5245 (cddar thread)))
5246 (setq gnus-tmp-gathered
5247 (nconc (mapcar
5248 (lambda (h) (mail-header-number (car h)))
5249 (cddar thread))
5250 gnus-tmp-gathered))
5251 (setq thread (cons (list (caar thread)
5252 (cadar thread))
5253 (cdr thread)))
5254 (setq gnus-tmp-level -1
5255 gnus-tmp-false-parent t))
5256 ((eq gnus-summary-make-false-root 'empty)
5257 ;; We print adopted articles with empty subject fields.
5258 (setq gnus-tmp-gathered
5259 (nconc (mapcar
5260 (lambda (h) (mail-header-number (car h)))
5261 (cddar thread))
5262 gnus-tmp-gathered))
5263 (setq gnus-tmp-level -1))
5264 ((eq gnus-summary-make-false-root 'dummy)
5265 ;; We remember that we probably want to output a dummy
5266 ;; root.
5267 (setq gnus-tmp-dummy-line gnus-tmp-header)
5268 (setq gnus-tmp-prev-subject gnus-tmp-header))
5269 (t
5270 ;; We do not make a root for the gathered
5271 ;; sub-threads at all.
5272 (setq gnus-tmp-level -1)))
5273
5274 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
5275 subject (mail-header-subject gnus-tmp-header)
5276 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
5277
5278 (cond
5279 ;; If the thread has changed subject, we might want to make
5280 ;; this subthread into a root.
5281 ((and (null gnus-thread-ignore-subject)
5282 (not (zerop gnus-tmp-level))
5283 gnus-tmp-prev-subject
23f87bed 5284 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5285 (setq new-roots (nconc new-roots (list (car thread)))
5286 thread-end t
5287 gnus-tmp-header nil))
5288 ;; If the article lies outside the current limit,
5289 ;; then we do not display it.
5290 ((not (memq number gnus-newsgroup-limit))
5291 (setq gnus-tmp-gathered
5292 (nconc (mapcar
5293 (lambda (h) (mail-header-number (car h)))
5294 (cdar thread))
5295 gnus-tmp-gathered))
5296 (setq gnus-tmp-new-adopts (if (cdar thread)
5297 (append gnus-tmp-new-adopts
5298 (cdar thread))
5299 gnus-tmp-new-adopts)
5300 thread-end t
5301 gnus-tmp-header nil)
5302 (when (zerop gnus-tmp-level)
5303 (setq gnus-tmp-root-expunged t)))
5304 ;; Perhaps this article is to be marked as read?
5305 ((and gnus-summary-mark-below
5306 (< (or (cdr (assq number gnus-newsgroup-scored))
5307 default-score)
5308 gnus-summary-mark-below)
5309 ;; Don't touch sparse articles.
5310 (not (gnus-summary-article-sparse-p number))
5311 (not (gnus-summary-article-ancient-p number)))
5312 (setq gnus-newsgroup-unreads
5313 (delq number gnus-newsgroup-unreads))
5314 (if gnus-newsgroup-auto-expire
23f87bed
MB
5315 (setq gnus-newsgroup-expirable
5316 (gnus-add-to-sorted-list
5317 gnus-newsgroup-expirable number))
eec82323
LMI
5318 (push (cons number gnus-low-score-mark)
5319 gnus-newsgroup-reads))))
5320
5321 (when gnus-tmp-header
5322 ;; We may have an old dummy line to output before this
5323 ;; article.
6748645f
LMI
5324 (when (and gnus-tmp-dummy-line
5325 (gnus-subject-equal
5326 gnus-tmp-dummy-line
5327 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
5328 (gnus-summary-insert-dummy-line
5329 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5330 (setq gnus-tmp-dummy-line nil))
5331
5332 ;; Compute the mark.
5333 (setq gnus-tmp-unread (gnus-article-mark number))
5334
5335 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5336 gnus-tmp-header gnus-tmp-level)
5337 gnus-newsgroup-data)
5338
5339 ;; Actually insert the line.
5340 (setq
5341 gnus-tmp-subject-or-nil
5342 (cond
5343 ((and gnus-thread-ignore-subject
5344 gnus-tmp-prev-subject
23f87bed 5345 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5346 subject)
5347 ((zerop gnus-tmp-level)
5348 (if (and (eq gnus-summary-make-false-root 'empty)
5349 (memq number gnus-tmp-gathered)
5350 gnus-tmp-prev-subject
23f87bed 5351 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5352 gnus-summary-same-subject
5353 subject))
5354 (t gnus-summary-same-subject)))
5355 (if (and (eq gnus-summary-make-false-root 'adopt)
5356 (= gnus-tmp-level 1)
5357 (memq number gnus-tmp-gathered))
5358 (setq gnus-tmp-opening-bracket ?\<
5359 gnus-tmp-closing-bracket ?\>)
5360 (setq gnus-tmp-opening-bracket ?\[
5361 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5362 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5363 (gnus-make-thread-indent-array
5364 (max (* 2 (length gnus-thread-indent-array))
5365 gnus-tmp-level)))
eec82323
LMI
5366 (setq
5367 gnus-tmp-indentation
5368 (aref gnus-thread-indent-array gnus-tmp-level)
5369 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5370 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5371 gnus-summary-default-score 0)
5372 gnus-tmp-score-char
5373 (if (or (null gnus-summary-default-score)
5374 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5375 gnus-summary-zcore-fuzz))
23f87bed 5376 ? ;Whitespace
eec82323
LMI
5377 (if (< gnus-tmp-score gnus-summary-default-score)
5378 gnus-score-below-mark gnus-score-over-mark))
5379 gnus-tmp-replied
5380 (cond ((memq number gnus-newsgroup-processable)
5381 gnus-process-mark)
5382 ((memq number gnus-newsgroup-cached)
5383 gnus-cached-mark)
5384 ((memq number gnus-newsgroup-replied)
5385 gnus-replied-mark)
23f87bed
MB
5386 ((memq number gnus-newsgroup-forwarded)
5387 gnus-forwarded-mark)
eec82323
LMI
5388 ((memq number gnus-newsgroup-saved)
5389 gnus-saved-mark)
23f87bed
MB
5390 ((memq number gnus-newsgroup-recent)
5391 gnus-recent-mark)
5392 ((memq number gnus-newsgroup-unseen)
5393 gnus-unseen-mark)
5394 (t gnus-no-mark))
5395 gnus-tmp-downloaded
5396 (cond ((memq number gnus-newsgroup-undownloaded)
5397 gnus-undownloaded-mark)
5398 (gnus-newsgroup-agentized
5399 gnus-downloaded-mark)
5400 (t
5401 gnus-no-mark))
eec82323
LMI
5402 gnus-tmp-from (mail-header-from gnus-tmp-header)
5403 gnus-tmp-name
5404 (cond
5405 ((string-match "<[^>]+> *$" gnus-tmp-from)
5406 (setq beg-match (match-beginning 0))
23f87bed
MB
5407 (or (and (string-match "^\".+\"" gnus-tmp-from)
5408 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5409 (substring gnus-tmp-from 0 beg-match)))
5410 ((string-match "(.+)" gnus-tmp-from)
5411 (substring gnus-tmp-from
5412 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5413 (t gnus-tmp-from))
5414
5415 ;; Do the %B string
5416 gnus-tmp-thread-tree-header-string
5417 (cond
5418 ((not gnus-show-threads) "")
5419 ((zerop gnus-tmp-level)
5420 (cond ((cdar thread)
5421 (or gnus-sum-thread-tree-root subject))
5422 (gnus-tmp-new-adopts
5423 (or gnus-sum-thread-tree-false-root subject))
5424 (t
5425 (or gnus-sum-thread-tree-single-indent subject))))
5426 (t
5427 (concat (apply 'concat
5428 (mapcar (lambda (item)
5429 (if (= item 1)
5430 gnus-sum-thread-tree-vertical
5431 gnus-sum-thread-tree-indent))
5432 (cdr (reverse tree-stack))))
5433 (if (nth 1 thread)
5434 gnus-sum-thread-tree-leaf-with-other
5435 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5436 (when (string= gnus-tmp-name "")
5437 (setq gnus-tmp-name gnus-tmp-from))
5438 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5439 (setq gnus-tmp-lines -1))
5440 (if (= gnus-tmp-lines -1)
5441 (setq gnus-tmp-lines "?")
5442 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
61b1af82
G
5443 (gnus-put-text-property
5444 (point)
5445 (progn (eval gnus-summary-line-format-spec) (point))
5446 'gnus-number number)
5447 (when gnus-visual-p
5448 (forward-line -1)
5449 (gnus-summary-highlight-line)
5450 (when gnus-summary-update-hook
5451 (gnus-run-hooks 'gnus-summary-update-hook))
5452 (forward-line 1))
5453
5454 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5455
5456 (when (nth 1 thread)
23f87bed
MB
5457 (push (list (max 0 gnus-tmp-level)
5458 (copy-sequence tree-stack)
5459 (nthcdr 1 thread))
5460 stack))
5461 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5462 (incf gnus-tmp-level)
5463 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5464 (if gnus-summary-display-while-building
5465 (if building-count
5466 (progn
5467 ;; use a set frequency
5468 (setq building-line-count (1- building-line-count))
5469 (when (= building-line-count 0)
5470 (sit-for 0)
5471 (setq building-line-count
5472 gnus-summary-display-while-building)))
5473 ;; always
5474 (sit-for 0)))
eec82323
LMI
5475 (unless threads
5476 (setq gnus-tmp-level 0)))))
5477 (gnus-message 7 "Generating summary...done"))
5478
5479(defun gnus-summary-prepare-unthreaded (headers)
5480 "Generate an unthreaded summary buffer based on HEADERS."
5481 (let (header number mark)
5482
5483 (beginning-of-line)
5484
5485 (while headers
5486 ;; We may have to root out some bad articles...
5487 (when (memq (setq number (mail-header-number
5488 (setq header (pop headers))))
5489 gnus-newsgroup-limit)
5490 ;; Mark article as read when it has a low score.
5491 (when (and gnus-summary-mark-below
5492 (< (or (cdr (assq number gnus-newsgroup-scored))
5493 gnus-summary-default-score 0)
5494 gnus-summary-mark-below)
5495 (not (gnus-summary-article-ancient-p number)))
5496 (setq gnus-newsgroup-unreads
5497 (delq number gnus-newsgroup-unreads))
5498 (if gnus-newsgroup-auto-expire
5499 (push number gnus-newsgroup-expirable)
5500 (push (cons number gnus-low-score-mark)
5501 gnus-newsgroup-reads)))
5502
5503 (setq mark (gnus-article-mark number))
5504 (push (gnus-data-make number mark (1+ (point)) header 0)
5505 gnus-newsgroup-data)
5506 (gnus-summary-insert-line
5507 header 0 number
23f87bed 5508 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5509 mark (memq number gnus-newsgroup-replied)
5510 (memq number gnus-newsgroup-expirable)
5511 (mail-header-subject header) nil
5512 (cdr (assq number gnus-newsgroup-scored))
5513 (memq number gnus-newsgroup-processable))))))
5514
16409b0b
GM
5515(defun gnus-summary-remove-list-identifiers ()
5516 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5517 (let ((regexp (if (consp gnus-list-identifiers)
5518 (mapconcat 'identity gnus-list-identifiers " *\\|")
5519 gnus-list-identifiers))
5520 changed subject)
5521 (when regexp
01c52d31 5522 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
23f87bed
MB
5523 (dolist (header gnus-newsgroup-headers)
5524 (setq subject (mail-header-subject header)
5525 changed nil)
01c52d31 5526 (while (string-match regexp subject)
23f87bed 5527 (setq subject
01c52d31 5528 (concat (substring subject 0 (match-beginning 1))
23f87bed
MB
5529 (substring subject (match-end 0)))
5530 changed t))
23f87bed 5531 (when changed
01c52d31
MB
5532 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5533 (setq subject
5534 (concat (substring subject 0 (match-beginning 1))
5535 (substring subject (match-end 1)))))
23f87bed
MB
5536 (mail-header-set-subject header subject))))))
5537
4ddab346 5538(defun gnus-fetch-headers (articles &optional limit force-new dependencies)
23f87bed
MB
5539 "Fetch headers of ARTICLES."
5540 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5541 (gnus-message 5 "Fetching headers for %s..." name)
5542 (prog1
5543 (if (eq 'nov
5544 (setq gnus-headers-retrieved-by
5545 (gnus-retrieve-headers
5546 articles gnus-newsgroup-name
4ddab346
G
5547 (or limit
5548 ;; We might want to fetch old headers, but
5549 ;; not if there is only 1 article.
5550 (and (or (and
5551 (not (eq gnus-fetch-old-headers 'some))
5552 (not (numberp gnus-fetch-old-headers)))
5553 (> (length articles) 1))
5554 gnus-fetch-old-headers)))))
23f87bed 5555 (gnus-get-newsgroup-headers-xover
4ddab346
G
5556 articles force-new dependencies gnus-newsgroup-name t)
5557 (gnus-get-newsgroup-headers dependencies force-new))
23f87bed 5558 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5559
6748645f 5560(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5561 "Select newsgroup GROUP.
6748645f
LMI
5562If READ-ALL is non-nil, all articles in the group are selected.
5563If SELECT-ARTICLES, only select those articles from GROUP."
01c52d31 5564 (let* ((entry (gnus-group-entry group))
eec82323
LMI
5565 ;;!!! Dirty hack; should be removed.
5566 (gnus-summary-ignore-duplicates
23f87bed 5567 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5568 t
5569 gnus-summary-ignore-duplicates))
5570 (info (nth 2 entry))
01c52d31 5571 charset articles fetched-articles cached)
eec82323
LMI
5572
5573 (unless (gnus-check-server
475e0e0c
GM
5574 (set (make-local-variable 'gnus-current-select-method)
5575 (gnus-find-method-for-group group)))
eec82323 5576 (error "Couldn't open server"))
01c52d31 5577 (setq charset (gnus-group-name-charset gnus-current-select-method group))
eec82323
LMI
5578
5579 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5580 (gnus-activate-group group) ; Or we can activate it...
5581 (progn ; Or we bug out.
5582 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5583 (gnus-kill-buffer (current-buffer)))
01c52d31
MB
5584 (error
5585 "Couldn't activate group %s: %s"
5586 (mm-decode-coding-string group charset)
5587 (mm-decode-coding-string (gnus-status-message group) charset))))
eec82323
LMI
5588
5589 (unless (gnus-request-group group t)
20a673b2
KY
5590 (when (equal major-mode 'gnus-summary-mode)
5591 (gnus-kill-buffer (current-buffer)))
5592 (error "Couldn't request group %s: %s"
5593 (mm-decode-coding-string group charset)
5594 (mm-decode-coding-string (gnus-status-message group) charset)))
eec82323 5595
54b6f6ed
G
5596 (when (and gnus-agent
5597 (gnus-active group))
54506618 5598 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5599
23f87bed
MB
5600 (setq gnus-summary-use-undownloaded-faces
5601 (gnus-agent-find-parameter
5602 group
5603 'agent-enable-undownloaded-faces)))
5604
5605 (setq gnus-newsgroup-name group
5606 gnus-newsgroup-unselected nil
5607 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5608
5609 (let ((display (gnus-group-find-parameter group 'display)))
5610 (setq gnus-newsgroup-display
5611 (cond
5612 ((not (zerop (or (car-safe read-all) 0)))
5613 ;; The user entered the group with C-u SPC/RET, let's show
5614 ;; all articles.
5615 'gnus-not-ignore)
5616 ((eq display 'all)
5617 'gnus-not-ignore)
5618 ((arrayp display)
5619 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5620 ((numberp display)
5621 ;; The following is probably the "correct" solution, but
5622 ;; it makes Gnus fetch all headers and then limit the
5623 ;; articles (which is slow), so instead we hack the
5624 ;; select-articles parameter instead. -- Simon Josefsson
5625 ;; <jas@kth.se>
5626 ;;
5627 ;; (gnus-byte-compile
5628 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5629 ;; display)))))
5630 (setq select-articles
5631 (gnus-uncompress-range
5632 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5633 (if (> tmp 0)
5634 tmp
5635 1))
5636 (cdr (gnus-active group)))))
5637 nil)
5638 (t
5639 nil))))
eec82323 5640
23f87bed 5641 (gnus-summary-setup-default-charset)
eec82323
LMI
5642
5643 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5644 (when (gnus-virtual-group-p group)
5645 (setq cached gnus-newsgroup-cached))
5646
5647 (setq gnus-newsgroup-unreads
23f87bed
MB
5648 (gnus-sorted-ndifference
5649 (gnus-sorted-ndifference gnus-newsgroup-unreads
5650 gnus-newsgroup-marked)
eec82323
LMI
5651 gnus-newsgroup-dormant))
5652
5653 (setq gnus-newsgroup-processable nil)
5654
bb7f5cbc 5655 (gnus-update-read-articles group gnus-newsgroup-unreads t)
eec82323 5656
23f87bed
MB
5657 ;; Adjust and set lists of article marks.
5658 (when info
5659 (gnus-adjust-marked-articles info))
6748645f
LMI
5660 (if (setq articles select-articles)
5661 (setq gnus-newsgroup-unselected
23f87bed 5662 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5663 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5664
5665 (cond
5666 ((null articles)
5667 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5668 'quit)
5669 ((eq articles 0) nil)
5670 (t
5671 ;; Init the dependencies hash table.
5672 (setq gnus-newsgroup-dependencies
5673 (gnus-make-hashtable (length articles)))
16409b0b 5674 (gnus-set-global-variables)
eec82323 5675 ;; Retrieve the headers and read them in.
23f87bed
MB
5676
5677 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5678
5679 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5680 (when cached
5681 (setq gnus-newsgroup-cached cached))
5682
5683 ;; Suppress duplicates?
5684 (when gnus-suppress-duplicates
5685 (gnus-dup-suppress-articles))
5686
5687 ;; Set the initial limit.
5688 (setq gnus-newsgroup-limit (copy-sequence articles))
5689 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5690 (setq fetched-articles
5691 (mapcar (lambda (headers) (mail-header-number headers))
5692 gnus-newsgroup-headers))
5693 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5694 (setq gnus-newsgroup-unreads
23f87bed
MB
5695 (gnus-sorted-nintersection
5696 gnus-newsgroup-unreads fetched-articles))
5697 (gnus-compute-unseen-list)
5698
eec82323
LMI
5699 ;; Removed marked articles that do not exist.
5700 (gnus-update-missing-marks
23f87bed 5701 (gnus-sorted-difference articles fetched-articles))
eec82323 5702 ;; We might want to build some more threads first.
6748645f
LMI
5703 (when (and gnus-fetch-old-headers
5704 (eq gnus-headers-retrieved-by 'nov))
5705 (if (eq gnus-fetch-old-headers 'invisible)
5706 (gnus-build-all-threads)
5707 (gnus-build-old-threads)))
5708 ;; Let the Gnus agent mark articles as read.
5709 (when gnus-agent
5710 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5711 ;; Remove list identifiers from subject
5712 (when gnus-list-identifiers
5713 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5714 ;; Check whether auto-expire is to be done in this group.
5715 (setq gnus-newsgroup-auto-expire
5716 (gnus-group-auto-expirable-p group))
5717 ;; Set up the article buffer now, if necessary.
01c52d31
MB
5718 (unless (and gnus-single-article-buffer
5719 (equal gnus-article-buffer "*Article*"))
eec82323
LMI
5720 (gnus-article-setup-buffer))
5721 ;; First and last article in this newsgroup.
5722 (when gnus-newsgroup-headers
5723 (setq gnus-newsgroup-begin
5724 (mail-header-number (car gnus-newsgroup-headers))
5725 gnus-newsgroup-end
5726 (mail-header-number
5727 (gnus-last-element gnus-newsgroup-headers))))
5728 ;; GROUP is successfully selected.
5729 (or gnus-newsgroup-headers t)))))
5730
23f87bed
MB
5731(defun gnus-compute-unseen-list ()
5732 ;; The `seen' marks are treated specially.
5733 (if (not gnus-newsgroup-seen)
5734 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5735 (setq gnus-newsgroup-unseen
5736 (gnus-inverse-list-range-intersection
5737 gnus-newsgroup-articles gnus-newsgroup-seen))))
5738
d09ae6ca
GM
5739(declare-function gnus-get-predicate "gnus-agent" (predicate))
5740
23f87bed
MB
5741(defun gnus-summary-display-make-predicate (display)
5742 (require 'gnus-agent)
5743 (when (= (length display) 1)
5744 (setq display (car display)))
5745 (unless gnus-summary-display-cache
5746 (dolist (elem (append '((unread . unread)
5747 (read . read)
5748 (unseen . unseen))
5749 gnus-article-mark-lists))
5750 (push (cons (cdr elem)
3a3cbf0a 5751 (gnus-byte-compile ;Why bother?
23f87bed
MB
5752 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5753 gnus-summary-display-cache)))
5754 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5755 (gnus-category-predicate-cache gnus-summary-display-cache))
5756 (gnus-get-predicate display)))
5757
3a3cbf0a
SM
5758;; Uses the dynamically bound `gnus-number' variable.
5759(defvar gnus-number)
23f87bed 5760(defun gnus-article-marked-p (type &optional article)
3a3cbf0a 5761 (let ((article (or article gnus-number)))
23f87bed
MB
5762 (cond
5763 ((eq type 'tick)
5764 (memq article gnus-newsgroup-marked))
5765 ((eq type 'spam)
5766 (memq article gnus-newsgroup-spam-marked))
5767 ((eq type 'unsend)
5768 (memq article gnus-newsgroup-unsendable))
5769 ((eq type 'undownload)
5770 (memq article gnus-newsgroup-undownloaded))
5771 ((eq type 'download)
5772 (memq article gnus-newsgroup-downloadable))
5773 ((eq type 'unread)
5774 (memq article gnus-newsgroup-unreads))
5775 ((eq type 'read)
5776 (memq article gnus-newsgroup-reads))
5777 ((eq type 'dormant)
5778 (memq article gnus-newsgroup-dormant) )
5779 ((eq type 'expire)
5780 (memq article gnus-newsgroup-expirable))
5781 ((eq type 'reply)
5782 (memq article gnus-newsgroup-replied))
5783 ((eq type 'killed)
5784 (memq article gnus-newsgroup-killed))
5785 ((eq type 'bookmark)
5786 (assq article gnus-newsgroup-bookmarks))
5787 ((eq type 'score)
5788 (assq article gnus-newsgroup-scored))
5789 ((eq type 'save)
5790 (memq article gnus-newsgroup-saved))
5791 ((eq type 'cache)
5792 (memq article gnus-newsgroup-cached))
5793 ((eq type 'forward)
5794 (memq article gnus-newsgroup-forwarded))
5795 ((eq type 'seen)
5796 (not (memq article gnus-newsgroup-unseen)))
5797 ((eq type 'recent)
5798 (memq article gnus-newsgroup-recent))
5799 (t t))))
5800
eec82323 5801(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5802 "Find out what articles the user wants to read."
26c9afc3 5803 (let* ((articles
eec82323
LMI
5804 ;; Select all articles if `read-all' is non-nil, or if there
5805 ;; are no unread articles.
5806 (if (or read-all
5807 (and (zerop (length gnus-newsgroup-marked))
5808 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5809 ;; Fetch all if the predicate is non-nil.
5810 gnus-newsgroup-display)
5811 ;; We want to select the headers for all the articles in
5812 ;; the group, so we select either all the active
5813 ;; articles in the group, or (if that's nil), the
5814 ;; articles in the cache.
16409b0b 5815 (or
4b70e299 5816 (if gnus-newsgroup-maximum-articles
11abff8e
MB
5817 (let ((active (gnus-active group)))
5818 (gnus-uncompress-range
5819 (cons (max (car active)
4b70e299
MB
5820 (- (cdr active)
5821 gnus-newsgroup-maximum-articles
5822 -1))
11abff8e
MB
5823 (cdr active))))
5824 (gnus-uncompress-range (gnus-active group)))
16409b0b 5825 (gnus-cache-articles-in-group group))
23f87bed
MB
5826 ;; Select only the "normal" subset of articles.
5827 (gnus-sorted-nunion
5828 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5829 gnus-newsgroup-unreads)))
eec82323
LMI
5830 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5831 (scored (length scored-list))
5832 (number (length articles))
5833 (marked (+ (length gnus-newsgroup-marked)
5834 (length gnus-newsgroup-dormant)))
5835 (select
5836 (cond
5837 ((numberp read-all)
5838 read-all)
23f87bed
MB
5839 ((numberp gnus-newsgroup-display)
5840 gnus-newsgroup-display)
eec82323
LMI
5841 (t
5842 (condition-case ()
5843 (cond
5844 ((and (or (<= scored marked) (= scored number))
5845 (numberp gnus-large-newsgroup)
5846 (> number gnus-large-newsgroup))
23f87bed
MB
5847 (let* ((cursor-in-echo-area nil)
5848 (initial (gnus-parameter-large-newsgroup-initial
5849 gnus-newsgroup-name))
5850 (input
5851 (read-string
5852 (format
5853 "How many articles from %s (%s %d): "
01c52d31 5854 (gnus-group-decoded-name gnus-newsgroup-name)
23f87bed
MB
5855 (if initial "max" "default")
5856 number)
5857 (if initial
5858 (cons (number-to-string initial)
5859 0)))))
eec82323
LMI
5860 (if (string-match "^[ \t]*$" input) number input)))
5861 ((and (> scored marked) (< scored number)
5862 (> (- scored number) 20))
5863 (let ((input
5864 (read-string
5865 (format "%s %s (%d scored, %d total): "
5866 "How many articles from"
23f87bed
MB
5867 (gnus-group-decoded-name group)
5868 scored number))))
eec82323
LMI
5869 (if (string-match "^[ \t]*$" input)
5870 number input)))
5871 (t number))
d4dfaa19
DL
5872 (quit
5873 (message "Quit getting the articles to read")
5874 nil))))))
eec82323
LMI
5875 (setq select (if (stringp select) (string-to-number select) select))
5876 (if (or (null select) (zerop select))
5877 select
5878 (if (and (not (zerop scored)) (<= (abs select) scored))
5879 (progn
5880 (setq articles (sort scored-list '<))
5881 (setq number (length articles)))
5882 (setq articles (copy-sequence articles)))
5883
5884 (when (< (abs select) number)
5885 (if (< select 0)
5886 ;; Select the N oldest articles.
5887 (setcdr (nthcdr (1- (abs select)) articles) nil)
5888 ;; Select the N most recent articles.
5889 (setq articles (nthcdr (- number select) articles))))
5890 (setq gnus-newsgroup-unselected
23f87bed 5891 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5892 (when gnus-alter-articles-to-read-function
23f87bed 5893 (setq articles
a1506d29 5894 (sort
16409b0b 5895 (funcall gnus-alter-articles-to-read-function
23f87bed 5896 gnus-newsgroup-name articles)
16409b0b 5897 '<)))
eec82323
LMI
5898 articles)))
5899
5900(defun gnus-killed-articles (killed articles)
5901 (let (out)
5902 (while articles
5903 (when (inline (gnus-member-of-range (car articles) killed))
5904 (push (car articles) out))
5905 (setq articles (cdr articles)))
5906 out))
5907
5908(defun gnus-uncompress-marks (marks)
5909 "Uncompress the mark ranges in MARKS."
5910 (let ((uncompressed '(score bookmark))
5911 out)
5912 (while marks
5913 (if (memq (caar marks) uncompressed)
5914 (push (car marks) out)
5915 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5916 (setq marks (cdr marks)))
5917 out))
5918
23f87bed
MB
5919(defun gnus-article-mark-to-type (mark)
5920 "Return the type of MARK."
5921 (or (cadr (assq mark gnus-article-special-mark-lists))
5922 'list))
5923
5924(defun gnus-article-unpropagatable-p (mark)
5925 "Return whether MARK should be propagated to back end."
5926 (memq mark gnus-article-unpropagated-mark-lists))
5927
eec82323 5928(defun gnus-adjust-marked-articles (info)
16409b0b 5929 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5930 (let* ((marked-lists (gnus-info-marks info))
5931 (active (gnus-active (gnus-info-group info)))
5932 (min (car active))
5933 (max (cdr active))
5934 (types gnus-article-mark-lists)
54506618
MB
5935 marks var articles article mark mark-type
5936 bgn end)
0617bb00
LMI
5937 ;; Hack to avoid adjusting marks for imap.
5938 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5939 'nnimap)
5940 (setq min 1))
eec82323 5941
23f87bed
MB
5942 (dolist (marks marked-lists)
5943 (setq mark (car marks)
5944 mark-type (gnus-article-mark-to-type mark)
5945 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5946
23f87bed
MB
5947 ;; We set the variable according to the type of the marks list,
5948 ;; and then adjust the marks to a subset of the active articles.
eec82323 5949 (cond
54506618 5950 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5951 ((eq mark-type 'list)
54506618
MB
5952 ;; Simultaneously uncompress and clip to active range
5953 ;; See gnus-uncompress-range for a description of possible marks
5954 (let (l lh)
5955 (if (not (cadr marks))
5956 (set var nil)
5957 (setq articles (if (numberp (cddr marks))
5958 (list (cdr marks))
5959 (cdr marks))
5960 lh (cons nil nil)
5961 l lh)
5962
5963 (while (setq article (pop articles))
5964 (cond ((consp article)
5965 (setq bgn (max (car article) min)
5966 end (min (cdr article) max))
5967 (while (<= bgn end)
5968 (setq l (setcdr l (cons bgn nil))
5969 bgn (1+ bgn))))
5970 ((and (<= min article)
5971 (>= max article))
5972 (setq l (setcdr l (cons article nil))))))
5973 (set var (cdr lh)))))
eec82323 5974 ;; Adjust assocs.
23f87bed
MB
5975 ((eq mark-type 'tuple)
5976 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5977 (when (not (listp (cdr (symbol-value var))))
5978 (set var (list (symbol-value var))))
5979 (when (not (listp (cdr articles)))
5980 (setq articles (list articles)))
eec82323
LMI
5981 (while articles
5982 (when (or (not (consp (setq article (pop articles))))
5983 (< (car article) min)
5984 (> (car article) max))
23f87bed
MB
5985 (set var (delq article (symbol-value var))))))
5986 ;; Adjust ranges (sloppily).
5987 ((eq mark-type 'range)
5988 (cond
5989 ((eq mark 'seen)
5990 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5991 ;; It should be (seen (NUM1 . NUM2)).
5992 (when (numberp (cddr marks))
5993 (setcdr marks (list (cdr marks))))
5994 (setq articles (cdr marks))
5995 (while (and articles
5996 (or (and (consp (car articles))
5997 (> min (cdar articles)))
5998 (and (numberp (car articles))
5999 (> min (car articles)))))
6000 (pop articles))
6001 (set var articles))))))))
eec82323
LMI
6002
6003(defun gnus-update-missing-marks (missing)
6748645f 6004 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 6005 (when missing
23f87bed 6006 (let (var m)
eec82323 6007 ;; Go through all types.
23f87bed
MB
6008 (dolist (elem gnus-article-mark-lists)
6009 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6010 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6011 (when (symbol-value var)
6012 ;; This list has articles. So we delete all missing
6013 ;; articles from it.
6014 (setq m missing)
6015 (while m
6016 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
6017
6018(defun gnus-update-marks ()
6019 "Enter the various lists of marked articles into the newsgroup info list."
6020 (let ((types gnus-article-mark-lists)
6021 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 6022 type list newmarked symbol delta-marks)
eec82323 6023 (when info
16409b0b 6024 ;; Add all marks lists to the list of marks lists.
eec82323 6025 (while (setq type (pop types))
16409b0b
GM
6026 (setq list (symbol-value
6027 (setq symbol
23f87bed 6028 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 6029
16409b0b 6030 (when list
eec82323
LMI
6031 ;; Get rid of the entries of the articles that have the
6032 ;; default score.
6033 (when (and (eq (cdr type) 'score)
6034 gnus-save-score
6035 list)
6036 (let* ((arts list)
6037 (prev (cons nil list))
6038 (all prev))
6039 (while arts
6040 (if (or (not (consp (car arts)))
6041 (= (cdar arts) gnus-summary-default-score))
6042 (setcdr prev (cdr arts))
6043 (setq prev arts))
6044 (setq arts (cdr arts)))
16409b0b
GM
6045 (setq list (cdr all)))))
6046
23f87bed
MB
6047 (when (eq (cdr type) 'seen)
6048 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6049
6050 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 6051 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 6052
23f87bed
MB
6053 (when (and (gnus-check-backend-function
6054 'request-set-mark gnus-newsgroup-name)
6055 (not (gnus-article-unpropagatable-p (cdr type))))
6056 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6057 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
6058 (add (gnus-remove-from-range
6059 (gnus-copy-sequence list) old)))
6060 (when add
6061 (push (list add 'add (list (cdr type))) delta-marks))
6062 (when del
b069e5a6
G
6063 ;; Don't delete marks from outside the active range. This
6064 ;; shouldn't happen, but is a sanity check.
6065 (setq del (gnus-sorted-range-intersection
6066 (gnus-active gnus-newsgroup-name) del))
23f87bed 6067 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 6068
16409b0b
GM
6069 (when list
6070 (push (cons (cdr type) list) newmarked)))
6071
6072 (when delta-marks
6073 (unless (gnus-check-group gnus-newsgroup-name)
6074 (error "Can't open server for %s" gnus-newsgroup-name))
6075 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 6076
eec82323
LMI
6077 ;; Enter these new marks into the info of the group.
6078 (if (nthcdr 3 info)
6079 (setcar (nthcdr 3 info) newmarked)
6080 ;; Add the marks lists to the end of the info.
6081 (when newmarked
6082 (setcdr (nthcdr 2 info) (list newmarked))))
6083
6084 ;; Cut off the end of the info if there's nothing else there.
6085 (let ((i 5))
6086 (while (and (> i 2)
6087 (not (nth i info)))
6088 (when (nthcdr (decf i) info)
6089 (setcdr (nthcdr i info) nil)))))))
6090
6091(defun gnus-set-mode-line (where)
16409b0b 6092 "Set the mode line of the article or summary buffers.
eec82323
LMI
6093If WHERE is `summary', the summary mode line format will be used."
6094 ;; Is this mode line one we keep updated?
16409b0b
GM
6095 (when (and (memq where gnus-updated-mode-lines)
6096 (symbol-value
6097 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323 6098 (let (mode-string)
c7a91ce1
SM
6099 ;; We evaluate this in the summary buffer since these
6100 ;; variables are buffer-local to that buffer.
6101 (with-current-buffer gnus-summary-buffer
6102 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
6103 ;; below.
6104 (let* ((mformat (symbol-value
6105 (intern
6106 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
6107 (gnus-tmp-group-name (gnus-mode-string-quote
6108 (gnus-group-decoded-name
6109 gnus-newsgroup-name)))
eec82323
LMI
6110 (gnus-tmp-article-number (or gnus-current-article 0))
6111 (gnus-tmp-unread gnus-newsgroup-unreads)
6112 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6113 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6114 (gnus-tmp-unread-and-unselected
6115 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6116 (zerop gnus-tmp-unselected))
6117 "")
6118 ((zerop gnus-tmp-unselected)
6119 (format "{%d more}" gnus-tmp-unread-and-unticked))
6120 (t (format "{%d(+%d) more}"
6121 gnus-tmp-unread-and-unticked
6122 gnus-tmp-unselected))))
6123 (gnus-tmp-subject
6124 (if (and gnus-current-headers
6125 (vectorp gnus-current-headers))
6126 (gnus-mode-string-quote
6127 (mail-header-subject gnus-current-headers))
6128 ""))
6129 bufname-length max-len
23f87bed 6130 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
6131 (setq mode-string (eval mformat))
6132 (setq bufname-length (if (string-match "%b" mode-string)
6133 (- (length
6134 (buffer-name
6135 (if (eq where 'summary)
6136 nil
6137 (get-buffer gnus-article-buffer))))
6138 2)
6139 0))
6140 (setq max-len (max 4 (if gnus-mode-non-string-length
6141 (- (window-width)
6142 gnus-mode-non-string-length
6143 bufname-length)
6144 (length mode-string))))
6145 ;; We might have to chop a bit of the string off...
6146 (when (> (length mode-string) max-len)
6147 (setq mode-string
16409b0b 6148 (concat (truncate-string-to-width mode-string (- max-len 3))
29d31b55 6149 "...")))))
eec82323
LMI
6150 ;; Update the mode line.
6151 (setq mode-line-buffer-identification
6152 (gnus-mode-line-buffer-identification (list mode-string)))
6153 (set-buffer-modified-p t))))
6154
6155(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6156 "Go through the HEADERS list and add all Xrefs to a hash table.
6157The resulting hash table is returned, or nil if no Xrefs were found."
6158 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6159 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6160 (xref-hashtb (gnus-make-hashtable))
6161 start group entry number xrefs header)
6162 (while headers
6163 (setq header (pop headers))
6164 (when (and (setq xrefs (mail-header-xref header))
6165 (not (memq (setq number (mail-header-number header))
6166 unreads)))
6167 (setq start 0)
6168 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6169 (setq start (match-end 0))
6170 (setq group (if prefix
6171 (concat prefix (substring xrefs (match-beginning 1)
6172 (match-end 1)))
6173 (substring xrefs (match-beginning 1) (match-end 1))))
6174 (setq number
e9bd5782 6175 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
6176 (match-end 2))))
6177 (if (setq entry (gnus-gethash group xref-hashtb))
6178 (setcdr entry (cons number (cdr entry)))
6179 (gnus-sethash group (cons number nil) xref-hashtb)))))
6180 (and start xref-hashtb)))
6181
6182(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6183 "Look through all the headers and mark the Xrefs as read."
6184 (let ((virtual (gnus-virtual-group-p from-newsgroup))
01c52d31 6185 name info xref-hashtb idlist method nth4)
398a825b 6186 (with-current-buffer gnus-group-buffer
eec82323
LMI
6187 (when (setq xref-hashtb
6188 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6189 (mapatoms
6190 (lambda (group)
6191 (unless (string= from-newsgroup (setq name (symbol-name group)))
6192 (setq idlist (symbol-value group))
6193 ;; Dead groups are not updated.
6194 (and (prog1
01c52d31 6195 (setq info (gnus-get-info name))
eec82323
LMI
6196 (when (stringp (setq nth4 (gnus-info-method info)))
6197 (setq nth4 (gnus-server-to-method nth4))))
6198 ;; Only do the xrefs if the group has the same
6199 ;; select method as the group we have just read.
6200 (or (gnus-methods-equal-p
6201 nth4 (gnus-find-method-for-group from-newsgroup))
6202 virtual
6203 (equal nth4 (setq method (gnus-find-method-for-group
6204 from-newsgroup)))
6205 (and (equal (car nth4) (car method))
6206 (equal (nth 1 nth4) (nth 1 method))))
6207 gnus-use-cross-reference
6208 (or (not (eq gnus-use-cross-reference t))
6209 virtual
6210 ;; Only do cross-references on subscribed
6211 ;; groups, if that is what is wanted.
6212 (<= (gnus-info-level info) gnus-level-subscribed))
6213 (gnus-group-make-articles-read name idlist))))
6214 xref-hashtb)))))
6215
6748645f 6216(defun gnus-compute-read-articles (group articles)
01c52d31 6217 (let* ((entry (gnus-group-entry group))
6748645f
LMI
6218 (info (nth 2 entry))
6219 (active (gnus-active group))
6220 ninfo)
6221 (when entry
16409b0b 6222 ;; First peel off all invalid article numbers.
6748645f
LMI
6223 (when active
6224 (let ((ids articles)
6225 id first)
6226 (while (setq id (pop ids))
6227 (when (and first (> id (cdr active)))
6228 ;; We'll end up in this situation in one particular
6229 ;; obscure situation. If you re-scan a group and get
6230 ;; a new article that is cross-posted to a different
6231 ;; group that has not been re-scanned, you might get
6232 ;; crossposted article that has a higher number than
6233 ;; Gnus believes possible. So we re-activate this
6234 ;; group as well. This might mean doing the
6235 ;; crossposting thingy will *increase* the number
6236 ;; of articles in some groups. Tsk, tsk.
6237 (setq active (or (gnus-activate-group group) active)))
6238 (when (or (> id (cdr active))
6239 (< id (car active)))
6240 (setq articles (delq id articles))))))
6241 ;; If the read list is nil, we init it.
6242 (if (and active
6243 (null (gnus-info-read info))
6244 (> (car active) 1))
6245 (setq ninfo (cons 1 (1- (car active))))
6246 (setq ninfo (gnus-info-read info)))
6247 ;; Then we add the read articles to the range.
6248 (gnus-add-to-range
6249 ninfo (setq articles (sort articles '<))))))
6250
eec82323
LMI
6251(defun gnus-group-make-articles-read (group articles)
6252 "Update the info of GROUP to say that ARTICLES are read."
6253 (let* ((num 0)
01c52d31 6254 (entry (gnus-group-entry group))
eec82323
LMI
6255 (info (nth 2 entry))
6256 (active (gnus-active group))
6257 range)
de635afe
G
6258 (if (not entry)
6259 ;; Group that Gnus doesn't know exists, but still allow the
6260 ;; backend to set marks.
6261 (gnus-request-set-mark
6262 group (list (list (gnus-compress-sequence (sort articles #'<))
6263 'add '(read))))
6264 ;; Normal, subscribed groups.
6748645f 6265 (setq range (gnus-compute-read-articles group articles))
01c52d31 6266 (with-current-buffer gnus-group-buffer
6748645f
LMI
6267 (gnus-undo-register
6268 `(progn
6269 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6270 (gnus-info-set-read ',info ',(gnus-info-read info))
6271 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 6272 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
6273 (gnus-group-update-group ,group t))))
6274 ;; Add the read articles to the range.
6275 (gnus-info-set-read info range)
23f87bed 6276 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
6277 ;; Then we have to re-compute how many unread
6278 ;; articles there are in this group.
6279 (when active
6280 (cond
6281 ((not range)
6282 (setq num (- (1+ (cdr active)) (car active))))
6283 ((not (listp (cdr range)))
6284 (setq num (- (cdr active) (- (1+ (cdr range))
6285 (car range)))))
6286 (t
6287 (while range
6288 (if (numberp (car range))
6289 (setq num (1+ num))
6290 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6291 (setq range (cdr range)))
6292 (setq num (- (cdr active) num))))
6293 ;; Update the number of unread articles.
6294 (setcar entry num)
6295 ;; Update the group buffer.
23f87bed
MB
6296 (unless (gnus-ephemeral-group-p group)
6297 (gnus-group-update-group group t))))))
eec82323 6298
eec82323
LMI
6299(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6300 (let ((cur nntp-server-buffer)
6301 (dependencies
6302 (or dependencies
01c52d31
MB
6303 (with-current-buffer gnus-summary-buffer
6304 gnus-newsgroup-dependencies)))
6305 headers id end ref number
16409b0b
GM
6306 (mail-parse-charset gnus-newsgroup-charset)
6307 (mail-parse-ignored-charsets
c7a91ce1
SM
6308 (save-current-buffer (condition-case nil
6309 (set-buffer gnus-summary-buffer)
6310 (error))
6311 gnus-newsgroup-ignored-charsets)))
6312 (with-current-buffer nntp-server-buffer
eec82323
LMI
6313 ;; Translate all TAB characters into SPACE characters.
6314 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 6315 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 6316 (ietf-drums-unfold-fws)
6748645f 6317 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6318 (let ((case-fold-search t)
6748645f 6319 in-reply-to header p lines chars)
eec82323 6320 (goto-char (point-min))
01ccbb85 6321 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
6322 ;; do not begin with 2 or 3.
6323 (while (re-search-forward "^[23][0-9]+ " nil t)
6324 (setq id nil
6325 ref nil)
6326 ;; This implementation of this function, with nine
6327 ;; search-forwards instead of the one re-search-forward and
6328 ;; a case (which basically was the old function) is actually
01ccbb85 6329 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
6330 ;; can't have everything, I guess. Speed and elegance
6331 ;; doesn't always go hand in hand.
6332 (setq
6333 header
6334 (vector
6335 ;; Number.
6336 (prog1
01c52d31 6337 (setq number (read cur))
eec82323
LMI
6338 (end-of-line)
6339 (setq p (point))
6340 (narrow-to-region (point)
6341 (or (and (search-forward "\n.\n" nil t)
6342 (- (point) 2))
6343 (point))))
6344 ;; Subject.
6345 (progn
6346 (goto-char p)
23f87bed 6347 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
6348 (funcall gnus-decode-encoded-word-function
6349 (nnheader-header-value))
2bd3dcae 6350 "(none)"))
eec82323
LMI
6351 ;; From.
6352 (progn
6353 (goto-char p)
23f87bed 6354 (if (search-forward "\nfrom:" nil t)
343d6628 6355 (funcall gnus-decode-encoded-address-function
16409b0b 6356 (nnheader-header-value))
2bd3dcae 6357 "(nobody)"))
eec82323
LMI
6358 ;; Date.
6359 (progn
6360 (goto-char p)
23f87bed 6361 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6362 (nnheader-header-value) ""))
6363 ;; Message-ID.
6364 (progn
6365 (goto-char p)
6748645f
LMI
6366 (setq id (if (re-search-forward
6367 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6368 ;; We do it this way to make sure the Message-ID
6369 ;; is (somewhat) syntactically valid.
6370 (buffer-substring (match-beginning 1)
6371 (match-end 1))
eec82323
LMI
6372 ;; If there was no message-id, we just fake one
6373 ;; to make subsequent routines simpler.
01c52d31 6374 (nnheader-generate-fake-message-id number))))
eec82323
LMI
6375 ;; References.
6376 (progn
6377 (goto-char p)
23f87bed 6378 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6379 (progn
6380 (setq end (point))
6381 (prog1
6382 (nnheader-header-value)
6383 (setq ref
6384 (buffer-substring
6385 (progn
6386 (end-of-line)
6387 (search-backward ">" end t)
6388 (1+ (point)))
6389 (progn
6390 (search-backward "<" end t)
6391 (point))))))
6392 ;; Get the references from the in-reply-to header if there
6393 ;; were no references and the in-reply-to header looks
6394 ;; promising.
23f87bed 6395 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6396 (setq in-reply-to (nnheader-header-value))
6397 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6398 (let (ref2)
6399 (setq ref (substring in-reply-to (match-beginning 0)
6400 (match-end 0)))
6401 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6402 (setq ref2 (substring in-reply-to (match-beginning 0)
6403 (match-end 0)))
6404 (when (> (length ref2) (length ref))
6405 (setq ref ref2)))
6406 ref)
eec82323
LMI
6407 (setq ref nil))))
6408 ;; Chars.
6748645f
LMI
6409 (progn
6410 (goto-char p)
6411 (if (search-forward "\nchars: " nil t)
6412 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6413 chars -1)
6414 -1))
eec82323
LMI
6415 ;; Lines.
6416 (progn
6417 (goto-char p)
6418 (if (search-forward "\nlines: " nil t)
a8151ef7 6419 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6420 lines -1)
6421 -1))
eec82323
LMI
6422 ;; Xref.
6423 (progn
6424 (goto-char p)
23f87bed 6425 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6426 (nnheader-header-value)))
6427 ;; Extra.
6428 (when gnus-extra-headers
6429 (let ((extra gnus-extra-headers)
6430 out)
6431 (while extra
6432 (goto-char p)
6433 (when (search-forward
23f87bed 6434 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6435 (push (cons (car extra) (nnheader-header-value))
6436 out))
6437 (pop extra))
6438 out))))
eec82323
LMI
6439 (when (equal id ref)
6440 (setq ref nil))
6748645f
LMI
6441
6442 (when gnus-alter-header-function
6443 (funcall gnus-alter-header-function header)
6444 (setq id (mail-header-id header)
6445 ref (gnus-parent-id (mail-header-references header))))
6446
6447 (when (setq header
6448 (gnus-dependencies-add-header
6449 header dependencies force-new))
eec82323
LMI
6450 (push header headers))
6451 (goto-char (point-max))
6452 (widen))
6453 (nreverse headers)))))
6454
eec82323
LMI
6455;; Goes through the xover lines and returns a list of vectors
6456(defun gnus-get-newsgroup-headers-xover (sequence &optional
6457 force-new dependencies
6458 group also-fetch-heads)
16409b0b
GM
6459 "Parse the news overview data in the server buffer.
6460Return a list of headers that match SEQUENCE (see
6461`nntp-retrieve-headers')."
eec82323
LMI
6462 ;; Get the Xref when the users reads the articles since most/some
6463 ;; NNTP servers do not include Xrefs when using XOVER.
6464 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6465 (let ((mail-parse-charset gnus-newsgroup-charset)
6466 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6467 (cur nntp-server-buffer)
eec82323 6468 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6469 (allp (cond
6470 ((eq gnus-read-all-available-headers t)
6471 t)
14e6dc54
MB
6472 ((and (stringp gnus-read-all-available-headers)
6473 group)
23f87bed
MB
6474 (string-match gnus-read-all-available-headers group))
6475 (t
6476 nil)))
eec82323 6477 number headers header)
c7a91ce1 6478 (with-current-buffer nntp-server-buffer
16409b0b 6479 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6480 ;; Allow the user to mangle the headers before parsing them.
6748645f 6481 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6482 (goto-char (point-min))
23f87bed
MB
6483 (gnus-parse-without-error
6484 (while (and (or sequence allp)
6485 (not (eobp)))
6486 (setq number (read cur))
6487 (when (not allp)
6488 (while (and sequence
6489 (< (car sequence) number))
6490 (setq sequence (cdr sequence))))
6491 (when (and (or allp
6492 (and sequence
6493 (eq number (car sequence))))
6494 (progn
6495 (setq sequence (cdr sequence))
6496 (setq header (inline
6497 (gnus-nov-parse-line
6498 number dependencies force-new)))))
6499 (push header headers))
6500 (forward-line 1)))
eec82323
LMI
6501 ;; A common bug in inn is that if you have posted an article and
6502 ;; then retrieves the active file, it will answer correctly --
6503 ;; the new article is included. However, a NOV entry for the
6504 ;; article may not have been generated yet, so this may fail.
6505 ;; We work around this problem by retrieving the last few
6506 ;; headers using HEAD.
6507 (if (or (not also-fetch-heads)
6508 (not sequence))
6509 ;; We (probably) got all the headers.
6510 (nreverse headers)
6511 (let ((gnus-nov-is-evil t))
6512 (nconc
6513 (nreverse headers)
23f87bed 6514 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6515 (gnus-get-newsgroup-headers))))))))
6516
6517(defun gnus-article-get-xrefs ()
6518 "Fill in the Xref value in `gnus-current-headers', if necessary.
6519This is meant to be called in `gnus-article-internal-prepare-hook'."
01c52d31
MB
6520 (let ((headers (with-current-buffer gnus-summary-buffer
6521 gnus-current-headers)))
eec82323
LMI
6522 (or (not gnus-use-cross-reference)
6523 (not headers)
6524 (and (mail-header-xref headers)
6525 (not (string= (mail-header-xref headers) "")))
6526 (let ((case-fold-search t)
6527 xref)
6528 (save-restriction
6529 (nnheader-narrow-to-headers)
6530 (goto-char (point-min))
16409b0b
GM
6531 (when (or (and (not (eobp))
6532 (eq (downcase (char-after)) ?x)
eec82323
LMI
6533 (looking-at "Xref:"))
6534 (search-forward "\nXref:" nil t))
6535 (goto-char (1+ (match-end 0)))
01c52d31 6536 (setq xref (buffer-substring (point) (point-at-eol)))
eec82323
LMI
6537 (mail-header-set-xref headers xref)))))))
6538
6539(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6540 "Find article ID and insert the summary line for that article.
6541OLD-HEADER can either be a header or a line number to insert
6542the subject line on."
6543 (let* ((line (and (numberp old-header) old-header))
6544 (old-header (and (vectorp old-header) old-header))
6545 (header (cond ((and old-header use-old-header)
16409b0b
GM
6546 old-header)
6547 ((and (numberp id)
6548 (gnus-number-to-header id))
6549 (gnus-number-to-header id))
6550 (t
6551 (gnus-read-header id))))
6552 (number (and (numberp id) id))
6553 d)
eec82323
LMI
6554 (when header
6555 ;; Rebuild the thread that this article is part of and go to the
6556 ;; article we have fetched.
6557 (when (and (not gnus-show-threads)
6558 old-header)
6748645f
LMI
6559 (when (and number
6560 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6561 (goto-char (gnus-data-pos d))
6562 (gnus-data-remove
6563 number
01c52d31 6564 (- (point-at-bol)
eec82323 6565 (prog1
01c52d31 6566 (1+ (point-at-eol))
eec82323 6567 (gnus-delete-line))))))
23f87bed
MB
6568 ;; Remove list identifiers from subject.
6569 (when gnus-list-identifiers
6570 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6571 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6572 (when old-header
6573 (mail-header-set-number header (mail-header-number old-header)))
6574 (setq gnus-newsgroup-sparse
6575 (delq (setq number (mail-header-number header))
6576 gnus-newsgroup-sparse))
6577 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6578 (push number gnus-newsgroup-limit)
6579 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6580 (gnus-summary-goto-subject number nil t))
6581 (when (and (numberp number)
6582 (> number 0))
6583 ;; We have to update the boundaries even if we can't fetch the
6584 ;; article if ID is a number -- so that the next `P' or `N'
6585 ;; command will fetch the previous (or next) article even
6586 ;; if the one we tried to fetch this time has been canceled.
6587 (when (> number gnus-newsgroup-end)
6588 (setq gnus-newsgroup-end number))
6589 (when (< number gnus-newsgroup-begin)
6590 (setq gnus-newsgroup-begin number))
6591 (setq gnus-newsgroup-unselected
6592 (delq number gnus-newsgroup-unselected)))
6593 ;; Report back a success?
6594 (and header (mail-header-number header))))
6595
6596;;; Process/prefix in the summary buffer
6597
6598(defun gnus-summary-work-articles (n)
6748645f
LMI
6599 "Return a list of articles to be worked upon.
6600The prefix argument, the list of process marked articles, and the
6601current article will be taken into consideration."
c7a91ce1 6602 (with-current-buffer gnus-summary-buffer
6748645f
LMI
6603 (cond
6604 (n
6605 ;; A numerical prefix has been given.
6606 (setq n (prefix-numeric-value n))
6607 (let ((backward (< n 0))
6608 (n (abs (prefix-numeric-value n)))
6609 articles article)
6610 (save-excursion
6611 (while
6612 (and (> n 0)
6613 (push (setq article (gnus-summary-article-number))
6614 articles)
6615 (if backward
6616 (gnus-summary-find-prev nil article)
6617 (gnus-summary-find-next nil article)))
6618 (decf n)))
6619 (nreverse articles)))
6620 ((and (gnus-region-active-p) (mark))
6621 (message "region active")
6622 ;; Work on the region between point and mark.
6623 (let ((max (max (point) (mark)))
6624 articles article)
6625 (save-excursion
7dafe00b 6626 (goto-char (min (point) (mark)))
6748645f
LMI
6627 (while
6628 (and
6629 (push (setq article (gnus-summary-article-number)) articles)
6630 (gnus-summary-find-next nil article)
6631 (< (point) max)))
6632 (nreverse articles))))
6633 (gnus-newsgroup-processable
6634 ;; There are process-marked articles present.
6635 ;; Save current state.
6636 (gnus-summary-save-process-mark)
6637 ;; Return the list.
6638 (reverse gnus-newsgroup-processable))
6639 (t
6640 ;; Just return the current article.
6641 (list (gnus-summary-article-number))))))
6642
6643(defmacro gnus-summary-iterate (arg &rest forms)
6644 "Iterate over the process/prefixed articles and do FORMS.
6645ARG is the interactive prefix given to the command. FORMS will be
6646executed with point over the summary line of the articles."
6647 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6648 `(let ((,articles (gnus-summary-work-articles ,arg)))
6649 (while ,articles
6650 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6651 ,@forms
6652 (pop ,articles)))))
6748645f
LMI
6653
6654(put 'gnus-summary-iterate 'lisp-indent-function 1)
6655(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6656
6657(defun gnus-summary-save-process-mark ()
6658 "Push the current set of process marked articles on the stack."
6659 (interactive)
6660 (push (copy-sequence gnus-newsgroup-processable)
6661 gnus-newsgroup-process-stack))
6662
6663(defun gnus-summary-kill-process-mark ()
6664 "Push the current set of process marked articles on the stack and unmark."
6665 (interactive)
6666 (gnus-summary-save-process-mark)
6667 (gnus-summary-unmark-all-processable))
6668
6669(defun gnus-summary-yank-process-mark ()
6670 "Pop the last process mark state off the stack and restore it."
6671 (interactive)
6672 (unless gnus-newsgroup-process-stack
6673 (error "Empty mark stack"))
6674 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6675
6676(defun gnus-summary-process-mark-set (set)
6677 "Make SET into the current process marked articles."
6678 (gnus-summary-unmark-all-processable)
01c52d31 6679 (mapc 'gnus-summary-set-process-mark set))
eec82323
LMI
6680
6681;;; Searching and stuff
6682
6683(defun gnus-summary-search-group (&optional backward use-level)
6684 "Search for next unread newsgroup.
6685If optional argument BACKWARD is non-nil, search backward instead."
c7a91ce1 6686 (with-current-buffer gnus-group-buffer
eec82323
LMI
6687 (when (gnus-group-search-forward
6688 backward nil (if use-level (gnus-group-group-level) nil))
6689 (gnus-group-group-name))))
6690
6691(defun gnus-summary-best-group (&optional exclude-group)
6692 "Find the name of the best unread group.
6693If EXCLUDE-GROUP, do not go to this group."
01c52d31 6694 (with-current-buffer gnus-group-buffer
eec82323
LMI
6695 (save-excursion
6696 (gnus-group-best-unread-group exclude-group))))
6697
23f87bed
MB
6698(defun gnus-summary-find-next (&optional unread article backward)
6699 (if backward
6700 (gnus-summary-find-prev unread article)
eec82323
LMI
6701 (let* ((dummy (gnus-summary-article-intangible-p))
6702 (article (or article (gnus-summary-article-number)))
23f87bed 6703 (data (gnus-data-find-list article))
eec82323
LMI
6704 result)
6705 (when (and (not dummy)
6706 (or (not gnus-summary-check-current)
6707 (not unread)
23f87bed
MB
6708 (not (gnus-data-unread-p (car data)))))
6709 (setq data (cdr data)))
eec82323
LMI
6710 (when (setq result
6711 (if unread
6712 (progn
23f87bed
MB
6713 (while data
6714 (unless (memq (gnus-data-number (car data))
6715 (cond
6716 ((eq gnus-auto-goto-ignores
6717 'always-undownloaded)
6718 gnus-newsgroup-undownloaded)
6719 (gnus-plugged
6720 nil)
6721 ((eq gnus-auto-goto-ignores
6722 'unfetched)
6723 gnus-newsgroup-unfetched)
6724 ((eq gnus-auto-goto-ignores
6725 'undownloaded)
6726 gnus-newsgroup-undownloaded)))
6727 (when (gnus-data-unread-p (car data))
6728 (setq result (car data)
6729 data nil)))
6730 (setq data (cdr data)))
eec82323 6731 result)
23f87bed 6732 (car data)))
eec82323
LMI
6733 (goto-char (gnus-data-pos result))
6734 (gnus-data-number result)))))
6735
6736(defun gnus-summary-find-prev (&optional unread article)
6737 (let* ((eobp (eobp))
6738 (article (or article (gnus-summary-article-number)))
23f87bed 6739 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6740 result)
6741 (when (and (not eobp)
6742 (or (not gnus-summary-check-current)
6743 (not unread)
23f87bed
MB
6744 (not (gnus-data-unread-p (car data)))))
6745 (setq data (cdr data)))
eec82323
LMI
6746 (when (setq result
6747 (if unread
6748 (progn
23f87bed
MB
6749 (while data
6750 (unless (memq (gnus-data-number (car data))
6751 (cond
6752 ((eq gnus-auto-goto-ignores
6753 'always-undownloaded)
6754 gnus-newsgroup-undownloaded)
6755 (gnus-plugged
6756 nil)
6757 ((eq gnus-auto-goto-ignores
6758 'unfetched)
6759 gnus-newsgroup-unfetched)
6760 ((eq gnus-auto-goto-ignores
6761 'undownloaded)
6762 gnus-newsgroup-undownloaded)))
6763 (when (gnus-data-unread-p (car data))
6764 (setq result (car data)
6765 data nil)))
6766 (setq data (cdr data)))
eec82323 6767 result)
23f87bed 6768 (car data)))
eec82323
LMI
6769 (goto-char (gnus-data-pos result))
6770 (gnus-data-number result))))
6771
6772(defun gnus-summary-find-subject (subject &optional unread backward article)
6773 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6774 (article (or article (gnus-summary-article-number)))
6775 (articles (gnus-data-list backward))
6776 (arts (gnus-data-find-list article articles))
6777 result)
6778 (when (or (not gnus-summary-check-current)
6779 (not unread)
6780 (not (gnus-data-unread-p (car arts))))
6781 (setq arts (cdr arts)))
6782 (while arts
6783 (and (or (not unread)
6784 (gnus-data-unread-p (car arts)))
6785 (vectorp (gnus-data-header (car arts)))
6786 (gnus-subject-equal
6787 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6788 (setq result (car arts)
6789 arts nil))
6790 (setq arts (cdr arts)))
6791 (and result
6792 (goto-char (gnus-data-pos result))
6793 (gnus-data-number result))))
6794
6795(defun gnus-summary-search-forward (&optional unread subject backward)
6796 "Search forward for an article.
6797If UNREAD, look for unread articles. If SUBJECT, look for
6798articles with that subject. If BACKWARD, search backward instead."
6799 (cond (subject (gnus-summary-find-subject subject unread backward))
6800 (backward (gnus-summary-find-prev unread))
6801 (t (gnus-summary-find-next unread))))
6802
6803(defun gnus-recenter (&optional n)
6804 "Center point in window and redisplay frame.
6805Also do horizontal recentering."
6806 (interactive "P")
6807 (when (and gnus-auto-center-summary
6808 (not (eq gnus-auto-center-summary 'vertical)))
6809 (gnus-horizontal-recenter))
5aa75bd8
JL
6810 (if (fboundp 'recenter-top-bottom)
6811 (recenter-top-bottom n)
6812 (recenter n)))
6813
6814(put 'gnus-recenter 'isearch-scroll t)
eec82323 6815
7b47345b
AS
6816(defun gnus-forward-line-ignore-invisible (n)
6817 "Move N lines forward (backward if N is negative).
6818Like forward-line, but skip over (and don't count) invisible lines."
6819 (let (done)
6820 (while (and (> n 0) (not done))
6821 ;; If the following character is currently invisible,
6822 ;; skip all characters with that same `invisible' property value.
770d9a1f
KY
6823 (while (gnus-invisible-p (point))
6824 (goto-char (gnus-next-char-property-change (point))))
7b47345b
AS
6825 (forward-line 1)
6826 (if (eobp)
6827 (setq done t)
6828 (setq n (1- n))))
6829 (while (and (< n 0) (not done))
6830 (forward-line -1)
6831 (if (bobp) (setq done t)
6832 (setq n (1+ n))
770d9a1f
KY
6833 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6834 (goto-char (gnus-previous-char-property-change (point))))))))
6835
eec82323
LMI
6836(defun gnus-summary-recenter ()
6837 "Center point in the summary window.
6838If `gnus-auto-center-summary' is nil, or the article buffer isn't
6839displayed, no centering will be performed."
6840 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6841 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6842 (interactive)
23f87bed
MB
6843 ;; The user has to want it.
6844 (when gnus-auto-center-summary
6845 (let* ((top (cond ((< (window-height) 4) 0)
6846 ((< (window-height) 7) 1)
6847 (t (if (numberp gnus-auto-center-summary)
6848 gnus-auto-center-summary
01c52d31 6849 (/ (1- (window-height)) 2)))))
23f87bed 6850 (height (1- (window-height)))
7b47345b
AS
6851 (bottom (save-excursion
6852 (goto-char (point-max))
6853 (gnus-forward-line-ignore-invisible (- height))
6854 (point)))
23f87bed 6855 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6856 (when (get-buffer-window gnus-article-buffer)
6857 ;; Only do recentering when the article buffer is displayed,
6858 ;; Set the window start to either `bottom', which is the biggest
6859 ;; possible valid number, or the second line from the top,
6860 ;; whichever is the least.
7b47345b
AS
6861 (let ((top-pos (save-excursion
6862 (gnus-forward-line-ignore-invisible (- top))
6863 (point))))
db7ebd73
MB
6864 (if (> bottom top-pos)
6865 ;; Keep the second line from the top visible
01c52d31 6866 (set-window-start window top-pos)
db7ebd73
MB
6867 ;; Try to keep the bottom line visible; if it's partially
6868 ;; obscured, either scroll one more line to make it fully
6869 ;; visible, or revert to using TOP-POS.
6870 (save-excursion
6871 (goto-char (point-max))
7b47345b 6872 (gnus-forward-line-ignore-invisible -1)
db7ebd73
MB
6873 (let ((last-line-start (point)))
6874 (goto-char bottom)
6875 (set-window-start window (point) t)
6876 (when (not (pos-visible-in-window-p last-line-start window))
7b47345b 6877 (gnus-forward-line-ignore-invisible 1)
db7ebd73 6878 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6879 ;; Do horizontal recentering while we're at it.
6880 (when (and (get-buffer-window (current-buffer) t)
6881 (not (eq gnus-auto-center-summary 'vertical)))
6882 (let ((selected (selected-window)))
6883 (select-window (get-buffer-window (current-buffer) t))
6884 (gnus-summary-position-point)
6885 (gnus-horizontal-recenter)
6886 (select-window selected))))))
6887
6888(defun gnus-summary-jump-to-group (newsgroup)
6889 "Move point to NEWSGROUP in group mode buffer."
6890 ;; Keep update point of group mode buffer if visible.
6891 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6892 (save-window-excursion
6893 ;; Take care of tree window mode.
6894 (when (get-buffer-window gnus-group-buffer)
6895 (pop-to-buffer gnus-group-buffer))
6896 (gnus-group-jump-to-group newsgroup))
6897 (save-excursion
6898 ;; Take care of tree window mode.
c7a91ce1 6899 (if (get-buffer-window gnus-group-buffer 0)
eec82323
LMI
6900 (pop-to-buffer gnus-group-buffer)
6901 (set-buffer gnus-group-buffer))
6902 (gnus-group-jump-to-group newsgroup))))
6903
6904;; This function returns a list of article numbers based on the
6905;; difference between the ranges of read articles in this group and
6906;; the range of active articles.
6907(defun gnus-list-of-unread-articles (group)
6908 (let* ((read (gnus-info-read (gnus-get-info group)))
6909 (active (or (gnus-active group) (gnus-activate-group group)))
01c52d31
MB
6910 (last (or (cdr active)
6911 (error "Group %s couldn't be activated " group)))
4b70e299
MB
6912 (bottom (if gnus-newsgroup-maximum-articles
6913 (max (car active)
6914 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6915 (car active)))
eec82323
LMI
6916 first nlast unread)
6917 ;; If none are read, then all are unread.
6918 (if (not read)
11abff8e 6919 (setq first bottom)
eec82323
LMI
6920 ;; If the range of read articles is a single range, then the
6921 ;; first unread article is the article after the last read
6922 ;; article. Sounds logical, doesn't it?
16409b0b 6923 (if (and (not (listp (cdr read)))
11abff8e 6924 (or (< (car read) bottom)
16409b0b
GM
6925 (progn (setq read (list read))
6926 nil)))
11abff8e 6927 (setq first (max bottom (1+ (cdr read))))
eec82323
LMI
6928 ;; `read' is a list of ranges.
6929 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6930 (caar read)))
6931 1)
11abff8e 6932 (setq first bottom))
eec82323
LMI
6933 (while read
6934 (when first
6935 (while (< first nlast)
54506618
MB
6936 (setq unread (cons first unread)
6937 first (1+ first))))
eec82323
LMI
6938 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6939 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6940 (setq read (cdr read)))))
6941 ;; And add the last unread articles.
6942 (while (<= first last)
54506618
MB
6943 (setq unread (cons first unread)
6944 first (1+ first)))
eec82323 6945 ;; Return the list of unread articles.
6748645f 6946 (delq 0 (nreverse unread))))
eec82323
LMI
6947
6948(defun gnus-list-of-read-articles (group)
6949 "Return a list of unread, unticked and non-dormant articles."
6950 (let* ((info (gnus-get-info group))
6951 (marked (gnus-info-marks info))
6952 (active (gnus-active group)))
6953 (and info active
23f87bed
MB
6954 (gnus-list-range-difference
6955 (gnus-list-range-difference
6956 (gnus-sorted-complement
11abff8e 6957 (gnus-uncompress-range
4b70e299 6958 (if gnus-newsgroup-maximum-articles
11abff8e 6959 (cons (max (car active)
4b70e299
MB
6960 (- (cdr active)
6961 gnus-newsgroup-maximum-articles
6962 -1))
11abff8e
MB
6963 (cdr active))
6964 active))
23f87bed
MB
6965 (gnus-list-of-unread-articles group))
6966 (cdr (assq 'dormant marked)))
6967 (cdr (assq 'tick marked))))))
eec82323 6968
54506618
MB
6969;; This function returns a sequence of article numbers based on the
6970;; difference between the ranges of read articles in this group and
6971;; the range of active articles.
6972(defun gnus-sequence-of-unread-articles (group)
6973 (let* ((read (gnus-info-read (gnus-get-info group)))
6974 (active (or (gnus-active group) (gnus-activate-group group)))
6975 (last (cdr active))
4b70e299
MB
6976 (bottom (if gnus-newsgroup-maximum-articles
6977 (max (car active)
6978 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6979 (car active)))
54506618
MB
6980 first nlast unread)
6981 ;; If none are read, then all are unread.
6982 (if (not read)
11abff8e 6983 (setq first bottom)
54506618
MB
6984 ;; If the range of read articles is a single range, then the
6985 ;; first unread article is the article after the last read
6986 ;; article. Sounds logical, doesn't it?
6987 (if (and (not (listp (cdr read)))
11abff8e 6988 (or (< (car read) bottom)
54506618
MB
6989 (progn (setq read (list read))
6990 nil)))
11abff8e 6991 (setq first (max bottom (1+ (cdr read))))
54506618
MB
6992 ;; `read' is a list of ranges.
6993 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6994 (caar read)))
6995 1)
11abff8e 6996 (setq first bottom))
54506618
MB
6997 (while read
6998 (when first
6999 (push (cons first nlast) unread))
7000 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7001 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7002 (setq read (cdr read)))))
7003 ;; And add the last unread articles.
ba0226dd
MB
7004 (cond ((not (and first last))
7005 nil)
7006 ((< first last)
7007 (push (cons first last) unread))
7008 ((= first last)
7009 (push first unread)))
54506618
MB
7010 ;; Return the sequence of unread articles.
7011 (delq 0 (nreverse unread))))
7012
eec82323
LMI
7013;; Various summary commands
7014
6748645f 7015(defun gnus-summary-select-article-buffer ()
de635afe
G
7016 "Reconfigure windows to show the article buffer.
7017If `gnus-widen-article-buffer' is set, show only the article
7018buffer."
6748645f
LMI
7019 (interactive)
7020 (if (not (gnus-buffer-live-p gnus-article-buffer))
7021 (error "There is no article buffer for this summary buffer")
a41c2e6d
G
7022 (unless (get-buffer-window gnus-article-buffer)
7023 (gnus-summary-show-article))
71e691a5
G
7024 (gnus-configure-windows
7025 (if gnus-widen-article-window
7026 'only-article
7027 'article)
7028 t)
a41c2e6d 7029 (select-window (get-buffer-window gnus-article-buffer))))
6748645f 7030
eec82323
LMI
7031(defun gnus-summary-universal-argument (arg)
7032 "Perform any operation on all articles that are process/prefixed."
7033 (interactive "P")
eec82323
LMI
7034 (let ((articles (gnus-summary-work-articles arg))
7035 func article)
7036 (if (eq
7037 (setq
7038 func
7039 (key-binding
7040 (read-key-sequence
7041 (substitute-command-keys
16409b0b 7042 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
7043 'undefined)
7044 (gnus-error 1 "Undefined key")
7045 (save-excursion
7046 (while articles
7047 (gnus-summary-goto-subject (setq article (pop articles)))
7048 (let (gnus-newsgroup-processable)
7049 (command-execute func))
7050 (gnus-summary-remove-process-mark article)))))
7051 (gnus-summary-position-point))
7052
7053(defun gnus-summary-toggle-truncation (&optional arg)
7054 "Toggle truncation of summary lines.
23f87bed 7055With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
7056 (interactive "P")
7057 (setq truncate-lines
7058 (if (null arg) (not truncate-lines)
7059 (> (prefix-numeric-value arg) 0)))
7060 (redraw-display))
7061
23f87bed
MB
7062(defun gnus-summary-find-for-reselect ()
7063 "Return the number of an article to stay on across a reselect.
7064The current article is considered, then following articles, then previous
7065articles. An article is sought which is not cancelled and isn't a temporary
7066insertion from another group. If there's no such then return a dummy 0."
7067 (let (found)
7068 (dolist (rev '(nil t))
7069 (unless found ; don't demand the reverse list if we don't need it
7070 (let ((data (gnus-data-find-list
7071 (gnus-summary-article-number) (gnus-data-list rev))))
7072 (while (and data (not found))
7073 (if (and (< 0 (gnus-data-number (car data)))
7074 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7075 (setq found (gnus-data-number (car data))))
7076 (setq data (cdr data))))))
7077 (or found 0)))
7078
eec82323
LMI
7079(defun gnus-summary-reselect-current-group (&optional all rescan)
7080 "Exit and then reselect the current newsgroup.
7081The prefix argument ALL means to select all articles."
7082 (interactive "P")
eec82323
LMI
7083 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7084 (error "Ephemeral groups can't be reselected"))
23f87bed 7085 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
7086 (group gnus-newsgroup-name))
7087 (setq gnus-newsgroup-begin nil)
23f87bed 7088 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
7089 ;; We have to adjust the point of group mode buffer because
7090 ;; point was moved to the next unread newsgroup by exiting.
7091 (gnus-summary-jump-to-group group)
7092 (when rescan
7093 (save-excursion
7094 (gnus-group-get-new-news-this-group 1)))
7095 (gnus-group-read-group all t)
7096 (gnus-summary-goto-subject current-subject nil t)))
7097
7098(defun gnus-summary-rescan-group (&optional all)
7099 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7100 (interactive "P")
eb9df2c9
LMI
7101 (let ((config gnus-current-window-configuration))
7102 (gnus-summary-reselect-current-group all t)
7103 (gnus-configure-windows config)
7104 (when (eq config 'article)
7105 (gnus-summary-select-article))))
eec82323
LMI
7106
7107(defun gnus-summary-update-info (&optional non-destructive)
7108 (save-excursion
7109 (let ((group gnus-newsgroup-name))
6748645f
LMI
7110 (when group
7111 (when gnus-newsgroup-kill-headers
7112 (setq gnus-newsgroup-killed
7113 (gnus-compress-sequence
23f87bed
MB
7114 (gnus-sorted-union
7115 (gnus-list-range-intersection
7116 gnus-newsgroup-unselected gnus-newsgroup-killed)
7117 gnus-newsgroup-unreads)
6748645f
LMI
7118 t)))
7119 (unless (listp (cdr gnus-newsgroup-killed))
7120 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7121 (let ((headers gnus-newsgroup-headers))
7122 ;; Set the new ranges of read articles.
01c52d31 7123 (with-current-buffer gnus-group-buffer
6748645f
LMI
7124 (gnus-undo-force-boundary))
7125 (gnus-update-read-articles
23f87bed
MB
7126 group (gnus-sorted-union
7127 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
7128 ;; Set the current article marks.
7129 (let ((gnus-newsgroup-scored
7130 (if (and (not gnus-save-score)
7131 (not non-destructive))
7132 nil
7133 gnus-newsgroup-scored)))
7134 (save-excursion
7135 (gnus-update-marks)))
7136 ;; Do the cross-ref thing.
7137 (when gnus-use-cross-reference
7138 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7139 ;; Do not switch windows but change the buffer to work.
a8151ef7 7140 (set-buffer gnus-group-buffer)
6748645f
LMI
7141 (unless (gnus-ephemeral-group-p group)
7142 (gnus-group-update-group group)))))))
eec82323
LMI
7143
7144(defun gnus-summary-save-newsrc (&optional force)
7145 "Save the current number of read/marked articles in the dribble buffer.
7146The dribble buffer will then be saved.
7147If FORCE (the prefix), also save the .newsrc file(s)."
7148 (interactive "P")
7149 (gnus-summary-update-info t)
7150 (if force
7151 (gnus-save-newsrc-file)
7152 (gnus-dribble-save)))
7153
704f1663
GM
7154(declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7155
23f87bed 7156(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 7157 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 7158`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
7159 (interactive)
7160 (gnus-set-global-variables)
16409b0b 7161 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7162 (with-current-buffer gnus-article-buffer
16409b0b
GM
7163 (mm-destroy-parts gnus-article-mime-handles)
7164 ;; Set it to nil for safety reason.
7165 (setq gnus-article-mime-handle-alist nil)
7166 (setq gnus-article-mime-handles nil)))
eec82323 7167 (gnus-kill-save-kill-buffer)
6748645f 7168 (gnus-async-halt-prefetch)
eec82323
LMI
7169 (let* ((group gnus-newsgroup-name)
7170 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 7171 (gnus-group-is-exiting-p t)
5415d076 7172 (article-buffer gnus-article-buffer)
eec82323 7173 (mode major-mode)
23f87bed 7174 (group-point nil)
eec82323 7175 (buf (current-buffer)))
16409b0b
GM
7176 (unless quit-config
7177 ;; Do adaptive scoring, and possibly save score files.
7178 (when gnus-newsgroup-adaptive
7179 (gnus-score-adaptive))
7180 (when gnus-use-scoring
7181 (gnus-score-save)))
6748645f 7182 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
7183 (when gnus-use-cache
7184 (gnus-cache-possibly-remove-articles)
7185 (gnus-cache-save-buffers))
7186 (gnus-async-prefetch-remove-group group)
7187 (when gnus-suppress-duplicates
7188 (gnus-dup-enter-articles))
7189 (when gnus-use-trees
7190 (gnus-tree-close group))
16409b0b
GM
7191 (when gnus-use-cache
7192 (gnus-cache-write-active))
6748645f
LMI
7193 ;; Remove entries for this group.
7194 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
7195 ;; Make all changes in this group permanent.
7196 (unless quit-config
6748645f 7197 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 7198 (gnus-summary-update-info))
eec82323
LMI
7199 (gnus-close-group group)
7200 ;; Make sure where we were, and go to next newsgroup.
7201 (set-buffer gnus-group-buffer)
7202 (unless quit-config
7203 (gnus-group-jump-to-group group))
6748645f
LMI
7204 (gnus-run-hooks 'gnus-summary-exit-hook)
7205 (unless (or quit-config
01c52d31 7206 (not gnus-summary-next-group-on-exit)
6748645f
LMI
7207 ;; If this group has disappeared from the summary
7208 ;; buffer, don't skip forwards.
7209 (not (string= group (gnus-group-group-name))))
eec82323 7210 (gnus-group-next-unread-group 1))
a8151ef7 7211 (setq group-point (point))
eec82323
LMI
7212 (if temporary
7213 nil ;Nothing to do.
eec82323
LMI
7214 (set-buffer buf)
7215 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
7216 (progn
7217 (gnus-deaden-summary)
7218 (setq mode nil))
eec82323
LMI
7219 (when (get-buffer gnus-article-buffer)
7220 (bury-buffer gnus-article-buffer))
eec82323
LMI
7221 ;; Return to group mode buffer.
7222 (when (eq mode 'gnus-summary-mode)
7223 (gnus-kill-buffer buf)))
9f2d52e7 7224
eec82323 7225 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
7226 (set-buffer gnus-group-buffer)
7227 (if quit-config
7228 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
7229 (goto-char group-point)
7230 ;; If gnus-group-buffer is already displayed, make sure we also move
7231 ;; the cursor in the window that displays it.
7232 (let ((win (get-buffer-window (current-buffer) 0)))
7233 (if win (set-window-point win (point))))
d61c212b 7234 (unless leave-hidden
4e90f2b9 7235 (gnus-configure-windows 'group 'force)))
5415d076
G
7236
7237 ;; If we have several article buffers, we kill them at exit.
7238 (unless gnus-single-article-buffer
7239 (when (gnus-buffer-live-p article-buffer)
7240 (with-current-buffer article-buffer
7241 ;; Don't kill sticky article buffers
7242 (unless (eq major-mode 'gnus-sticky-article-mode)
7243 (gnus-kill-buffer article-buffer)
7244 (setq gnus-article-current nil))))
7245 (gnus-kill-buffer gnus-original-article-buffer))
7246
6748645f 7247 ;; Clear the current group name.
eec82323
LMI
7248 (unless quit-config
7249 (setq gnus-newsgroup-name nil)))))
7250
7251(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7252(defun gnus-summary-exit-no-update (&optional no-questions)
7253 "Quit reading current newsgroup without updating read article info."
7254 (interactive)
eec82323 7255 (let* ((group gnus-newsgroup-name)
23f87bed
MB
7256 (gnus-group-is-exiting-p t)
7257 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
7258 (quit-config (gnus-group-quit-config group)))
7259 (when (or no-questions
7260 gnus-expert-user
7261 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 7262 (gnus-async-halt-prefetch)
23f87bed 7263 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b 7264 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7265 (with-current-buffer gnus-article-buffer
16409b0b
GM
7266 (mm-destroy-parts gnus-article-mime-handles)
7267 ;; Set it to nil for safety reason.
7268 (setq gnus-article-mime-handle-alist nil)
7269 (setq gnus-article-mime-handles nil)))
eec82323
LMI
7270 ;; If we have several article buffers, we kill them at exit.
7271 (unless gnus-single-article-buffer
7272 (gnus-kill-buffer gnus-article-buffer)
7273 (gnus-kill-buffer gnus-original-article-buffer)
7274 (setq gnus-article-current nil))
5415d076
G
7275 ;; Return to the group buffer.
7276 (gnus-configure-windows 'group 'force)
eec82323
LMI
7277 (if (not gnus-kill-summary-on-exit)
7278 (gnus-deaden-summary)
7279 (gnus-close-group group)
23f87bed 7280 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
7281 (unless gnus-single-article-buffer
7282 (setq gnus-article-current nil))
7283 (when gnus-use-trees
7284 (gnus-tree-close group))
7285 (gnus-async-prefetch-remove-group group)
7286 (when (get-buffer gnus-article-buffer)
7287 (bury-buffer gnus-article-buffer))
eec82323
LMI
7288 ;; Clear the current group name.
7289 (setq gnus-newsgroup-name nil)
23f87bed
MB
7290 (unless (gnus-ephemeral-group-p group)
7291 (gnus-group-update-group group))
eec82323
LMI
7292 (when (equal (gnus-group-group-name) group)
7293 (gnus-group-next-unread-group 1))
7294 (when quit-config
23f87bed 7295 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
7296
7297(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
7298 "Handle movement when leaving an ephemeral group.
7299The state which existed when entering the ephemeral is reset."
eec82323
LMI
7300 (if (not (buffer-name (car quit-config)))
7301 (gnus-configure-windows 'group 'force)
7302 (set-buffer (car quit-config))
7303 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
7304 (gnus-set-global-variables))
7305 ((eq major-mode 'gnus-article-mode)
c7a91ce1 7306 (save-current-buffer
23f87bed
MB
7307 ;; The `gnus-summary-buffer' variable may point
7308 ;; to the old summary buffer when using a single
7309 ;; article buffer.
7310 (unless (gnus-buffer-live-p gnus-summary-buffer)
7311 (set-buffer gnus-group-buffer))
7312 (set-buffer gnus-summary-buffer)
7313 (gnus-set-global-variables))))
eec82323 7314 (if (or (eq (cdr quit-config) 'article)
23f87bed 7315 (eq (cdr quit-config) 'pick))
01c52d31
MB
7316 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7317 (gnus-configure-windows 'pick 'force)
7318 (gnus-configure-windows (cdr quit-config) 'force))
eec82323
LMI
7319 (gnus-configure-windows (cdr quit-config) 'force))
7320 (when (eq major-mode 'gnus-summary-mode)
01c52d31
MB
7321 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7322 next-unread-noselect))
7323 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7324 'next-noselect)
7325 (gnus-summary-next-subject 1 nil t))
7326 ((eq gnus-auto-select-on-ephemeral-exit
7327 'next-unread-noselect)
7328 (gnus-summary-next-subject 1 t t))))
7329 ;; Hide the article buffer which displays the article different
7330 ;; from the one that the cursor points to in the summary buffer.
7331 (gnus-configure-windows 'summary 'force))
7332 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7333 (gnus-summary-next-subject 1))
7334 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7335 (gnus-summary-next-subject 1 t))))
eec82323
LMI
7336 (gnus-summary-recenter)
7337 (gnus-summary-position-point))))
7338
7339;;; Dead summaries.
7340
bbf52f1e
SM
7341(defvar gnus-dead-summary-mode-map
7342 (let ((map (make-keymap)))
7343 (suppress-keymap map)
7344 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7345 (dolist (key '("\C-d" "\r" "\177" [delete]))
7346 (define-key map key 'gnus-summary-wake-up-the-dead))
7347 (dolist (key '("q" "Q"))
7348 (define-key map key 'bury-buffer))
7349 map))
7350
7351(define-minor-mode gnus-dead-summary-mode
eec82323 7352 "Minor mode for Gnus summary buffers."
bbf52f1e
SM
7353 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7354 (unless (derived-mode-p 'gnus-summary-mode)
7355 (setq gnus-dead-summary-mode nil)))
eec82323
LMI
7356
7357(defun gnus-deaden-summary ()
7358 "Make the current summary buffer into a dead summary buffer."
7359 ;; Kill any previous dead summary buffer.
7360 (when (and gnus-dead-summary
7361 (buffer-name gnus-dead-summary))
01c52d31 7362 (with-current-buffer gnus-dead-summary
eec82323
LMI
7363 (when gnus-dead-summary-mode
7364 (kill-buffer (current-buffer)))))
7365 ;; Make this the current dead summary.
7366 (setq gnus-dead-summary (current-buffer))
7367 (gnus-dead-summary-mode 1)
7368 (let ((name (buffer-name)))
7369 (when (string-match "Summary" name)
7370 (rename-buffer
7371 (concat (substring name 0 (match-beginning 0)) "Dead "
7372 (substring name (match-beginning 0)))
16409b0b
GM
7373 t)
7374 (bury-buffer))))
eec82323
LMI
7375
7376(defun gnus-kill-or-deaden-summary (buffer)
7377 "Kill or deaden the summary BUFFER."
6748645f
LMI
7378 (save-excursion
7379 (when (and (buffer-name buffer)
7380 (not gnus-single-article-buffer))
01c52d31 7381 (with-current-buffer buffer
6748645f
LMI
7382 (gnus-kill-buffer gnus-article-buffer)
7383 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
7384 (cond
7385 ;; Kill the buffer.
7386 (gnus-kill-summary-on-exit
7387 (when (and gnus-use-trees
7388 (gnus-buffer-exists-p buffer))
c7a91ce1 7389 (with-current-buffer buffer
23f87bed
MB
7390 (gnus-tree-close gnus-newsgroup-name)))
7391 (gnus-kill-buffer buffer))
7392 ;; Deaden the buffer.
7393 ((gnus-buffer-exists-p buffer)
c7a91ce1 7394 (with-current-buffer buffer
23f87bed 7395 (gnus-deaden-summary))))))
eec82323
LMI
7396
7397(defun gnus-summary-wake-up-the-dead (&rest args)
7398 "Wake up the dead summary buffer."
7399 (interactive)
7400 (gnus-dead-summary-mode -1)
7401 (let ((name (buffer-name)))
7402 (when (string-match "Dead " name)
7403 (rename-buffer
7404 (concat (substring name 0 (match-beginning 0))
7405 (substring name (match-end 0)))
7406 t)))
7407 (gnus-message 3 "This dead summary is now alive again"))
7408
eec82323
LMI
7409;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7410(defun gnus-summary-describe-group (&optional force)
7411 "Describe the current newsgroup."
7412 (interactive "P")
7413 (gnus-group-describe-group force gnus-newsgroup-name))
7414
7415(defun gnus-summary-describe-briefly ()
7416 "Describe summary mode commands briefly."
7417 (interactive)
bdaa75c7 7418 (gnus-message 6 "%s" (substitute-command-keys "\\<gnus-summary-mode-map>\\[gnus-summary-next-page]:Select \\[gnus-summary-next-unread-article]:Forward \\[gnus-summary-prev-unread-article]:Backward \\[gnus-summary-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-summary-describe-briefly]:This help")))
eec82323
LMI
7419
7420;; Walking around group mode buffer from summary mode.
7421
7422(defun gnus-summary-next-group (&optional no-article target-group backward)
7423 "Exit current newsgroup and then select next unread newsgroup.
7424If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7425initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7426previous group instead."
7427 (interactive "P")
eec82323
LMI
7428 ;; Stop pre-fetching.
7429 (gnus-async-halt-prefetch)
7430 (let ((current-group gnus-newsgroup-name)
7431 (current-buffer (current-buffer))
7432 entered)
7433 ;; First we semi-exit this group to update Xrefs and all variables.
7434 ;; We can't do a real exit, because the window conf must remain
7435 ;; the same in case the user is prompted for info, and we don't
7436 ;; want the window conf to change before that...
7437 (gnus-summary-exit t)
7438 (while (not entered)
7439 ;; Then we find what group we are supposed to enter.
7440 (set-buffer gnus-group-buffer)
7441 (gnus-group-jump-to-group current-group)
7442 (setq target-group
7443 (or target-group
7444 (if (eq gnus-keep-same-level 'best)
7445 (gnus-summary-best-group gnus-newsgroup-name)
7446 (gnus-summary-search-group backward gnus-keep-same-level))))
7447 (if (not target-group)
7448 ;; There are no further groups, so we return to the group
7449 ;; buffer.
7450 (progn
7451 (gnus-message 5 "Returning to the group buffer")
7452 (setq entered t)
7453 (when (gnus-buffer-live-p current-buffer)
7454 (set-buffer current-buffer)
7455 (gnus-summary-exit))
6748645f 7456 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7457 ;; We try to enter the target group.
7458 (gnus-group-jump-to-group target-group)
7459 (let ((unreads (gnus-group-group-unread)))
7460 (if (and (or (eq t unreads)
7461 (and unreads (not (zerop unreads))))
23f87bed
MB
7462 (gnus-summary-read-group
7463 target-group nil no-article
7464 (and (buffer-name current-buffer) current-buffer)
7465 nil backward))
eec82323
LMI
7466 (setq entered t)
7467 (setq current-group target-group
7468 target-group nil)))))))
7469
7470(defun gnus-summary-prev-group (&optional no-article)
7471 "Exit current newsgroup and then select previous unread newsgroup.
7472If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7473 (interactive "P")
7474 (gnus-summary-next-group no-article nil t))
7475
7476;; Walking around summary lines.
7477
23f87bed
MB
7478(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7479 "Go to the first subject satisfying any non-nil constraint.
7480If UNREAD is non-nil, the article should be unread.
7481If UNDOWNLOADED is non-nil, the article should be undownloaded.
20a673b2 7482If UNSEEN is non-nil, the article should be unseen as well as unread.
23f87bed 7483Returns the article selected or nil if there are no matching articles."
eec82323 7484 (interactive "P")
23f87bed
MB
7485 (cond
7486 ;; Empty summary.
7487 ((null gnus-newsgroup-data)
7488 (gnus-message 3 "No articles in the group")
7489 nil)
7490 ;; Pick the first article.
7491 ((not (or unread undownloaded unseen))
7492 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7493 (gnus-data-number (car gnus-newsgroup-data)))
7494 ;; Find the first unread article.
7495 (t
7496 (let ((data gnus-newsgroup-data))
7497 (while (and data
7498 (let ((num (gnus-data-number (car data))))
7499 (or (memq num gnus-newsgroup-unfetched)
7500 (not (or (and unread
7501 (memq num gnus-newsgroup-unreads))
7502 (and undownloaded
7503 (memq num gnus-newsgroup-undownloaded))
7504 (and unseen
20a673b2
KY
7505 (memq num gnus-newsgroup-unseen)
7506 (memq num gnus-newsgroup-unreads)))))))
23f87bed
MB
7507 (setq data (cdr data)))
7508 (prog1
7509 (if data
7510 (progn
7511 (goto-char (gnus-data-pos (car data)))
7512 (gnus-data-number (car data)))
7513 (gnus-message 3 "No more%s articles"
7514 (let* ((r (when unread " unread"))
7515 (d (when undownloaded " undownloaded"))
7516 (s (when unseen " unseen"))
7517 (l (delq nil (list r d s))))
7518 (cond ((= 3 (length l))
7519 (concat r "," d ", or" s))
7520 ((= 2 (length l))
7521 (concat (car l) ", or" (cadr l)))
7522 ((= 1 (length l))
7523 (car l))
7524 (t
7525 ""))))
7526 nil
7527 )
7528 (gnus-summary-position-point))))))
eec82323
LMI
7529
7530(defun gnus-summary-next-subject (n &optional unread dont-display)
7531 "Go to next N'th summary line.
7532If N is negative, go to the previous N'th subject line.
7533If UNREAD is non-nil, only unread articles are selected.
7534The difference between N and the actual number of steps taken is
7535returned."
7536 (interactive "p")
7537 (let ((backward (< n 0))
7538 (n (abs n)))
7539 (while (and (> n 0)
7540 (if backward
7541 (gnus-summary-find-prev unread)
7542 (gnus-summary-find-next unread)))
16409b0b
GM
7543 (unless (zerop (setq n (1- n)))
7544 (gnus-summary-show-thread)))
eec82323
LMI
7545 (when (/= 0 n)
7546 (gnus-message 7 "No more%s articles"
7547 (if unread " unread" "")))
7548 (unless dont-display
7549 (gnus-summary-recenter)
7550 (gnus-summary-position-point))
7551 n))
7552
7553(defun gnus-summary-next-unread-subject (n)
7554 "Go to next N'th unread summary line."
7555 (interactive "p")
7556 (gnus-summary-next-subject n t))
7557
7558(defun gnus-summary-prev-subject (n &optional unread)
7559 "Go to previous N'th summary line.
7560If optional argument UNREAD is non-nil, only unread article is selected."
7561 (interactive "p")
7562 (gnus-summary-next-subject (- n) unread))
7563
7564(defun gnus-summary-prev-unread-subject (n)
7565 "Go to previous N'th unread summary line."
7566 (interactive "p")
7567 (gnus-summary-next-subject (- n) t))
7568
23f87bed
MB
7569(defun gnus-summary-goto-subjects (articles)
7570 "Insert the subject header for ARTICLES in the current buffer."
7571 (save-excursion
7572 (dolist (article articles)
7573 (gnus-summary-goto-subject article t)))
7574 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7575 (gnus-summary-position-point))
132cf96d 7576
eec82323 7577(defun gnus-summary-goto-subject (article &optional force silent)
d55fe5bb 7578 "Go to the subject line of ARTICLE.
eec82323
LMI
7579If FORCE, also allow jumping to articles not currently shown."
7580 (interactive "nArticle number: ")
23f87bed
MB
7581 (unless (numberp article)
7582 (error "Article %s is not a number" article))
eec82323
LMI
7583 (let ((b (point))
7584 (data (gnus-data-find article)))
7585 ;; We read in the article if we have to.
7586 (and (not data)
7587 force
6748645f
LMI
7588 (gnus-summary-insert-subject
7589 article
7590 (if (or (numberp force) (vectorp force)) force)
7591 t)
eec82323
LMI
7592 (setq data (gnus-data-find article)))
7593 (goto-char b)
7594 (if (not data)
7595 (progn
7596 (unless silent
7597 (gnus-message 3 "Can't find article %d" article))
7598 nil)
23f87bed
MB
7599 (let ((pt (gnus-data-pos data)))
7600 (goto-char pt)
7601 (gnus-summary-set-article-display-arrow pt))
6748645f 7602 (gnus-summary-position-point)
eec82323
LMI
7603 article)))
7604
7605;; Walking around summary lines with displaying articles.
7606
7607(defun gnus-summary-expand-window (&optional arg)
7608 "Make the summary buffer take up the entire Emacs frame.
7609Given a prefix, will force an `article' buffer configuration."
7610 (interactive "P")
eec82323
LMI
7611 (if arg
7612 (gnus-configure-windows 'article 'force)
7613 (gnus-configure-windows 'summary 'force)))
7614
7615(defun gnus-summary-display-article (article &optional all-header)
7616 "Display ARTICLE in article buffer."
01c52d31
MB
7617 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7618 (with-current-buffer gnus-article-buffer
7619 (eq major-mode 'gnus-article-mode)))
7620 (gnus-article-setup-buffer))
eec82323 7621 (gnus-set-global-variables)
01c52d31
MB
7622 (with-current-buffer gnus-article-buffer
7623 (setq gnus-article-charset gnus-newsgroup-charset)
7624 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7625 (mm-enable-multibyte))
eec82323
LMI
7626 (if (null article)
7627 nil
7628 (prog1
7629 (if gnus-summary-display-article-function
7630 (funcall gnus-summary-display-article-function article all-header)
7631 (gnus-article-prepare article all-header))
6748645f 7632 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7633 (when (and gnus-current-article
7634 (not (zerop gnus-current-article)))
7635 (gnus-summary-goto-subject gnus-current-article))
7636 (gnus-summary-recenter)
7637 (when (and gnus-use-trees gnus-show-threads)
7638 (gnus-possibly-generate-tree article)
7639 (gnus-highlight-selected-tree article))
7640 ;; Successfully display article.
7641 (gnus-article-set-window-start
7642 (cdr (assq article gnus-newsgroup-bookmarks))))))
7643
7644(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7645 "Select the current article.
7646If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7647non-nil, the article will be re-fetched even if it already present in
7648the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7649be displayed."
7650 ;; Make sure we are in the summary buffer to work around bbdb bug.
7651 (unless (eq major-mode 'gnus-summary-mode)
7652 (set-buffer gnus-summary-buffer))
7653 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7654 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7655 gnus-summary-display-article-function)
eec82323
LMI
7656 (and (not pseudo)
7657 (gnus-summary-article-pseudo-p article)
a8151ef7 7658 (error "This is a pseudo-article"))
c7a91ce1 7659 (with-current-buffer gnus-summary-buffer
16409b0b
GM
7660 (if (or (and gnus-single-article-buffer
7661 (or (null gnus-current-article)
7662 (null gnus-article-current)
7663 (null (get-buffer gnus-article-buffer))
7664 (not (eq article (cdr gnus-article-current)))
7665 (not (equal (car gnus-article-current)
de635afe 7666 gnus-newsgroup-name))
28090d40 7667 (not (get-buffer gnus-original-article-buffer))))
16409b0b
GM
7668 (and (not gnus-single-article-buffer)
7669 (or (null gnus-current-article)
389b76fa 7670 (not (get-buffer gnus-original-article-buffer))
16409b0b
GM
7671 (not (eq gnus-current-article article))))
7672 force)
7673 ;; The requested article is different from the current article.
7674 (progn
16409b0b
GM
7675 (gnus-summary-display-article article all-headers)
7676 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7677 (with-current-buffer gnus-article-buffer
16409b0b 7678 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7679 (mm-disable-multibyte))))
16409b0b
GM
7680 (gnus-article-set-window-start
7681 (cdr (assq article gnus-newsgroup-bookmarks)))
7682 article)
16409b0b 7683 'old))))
eec82323 7684
23f87bed
MB
7685(defun gnus-summary-force-verify-and-decrypt ()
7686 "Display buttons for signed/encrypted parts and verify/decrypt them."
7687 (interactive)
7688 (let ((mm-verify-option 'known)
7689 (mm-decrypt-option 'known)
7690 (gnus-article-emulate-mime t)
7691 (gnus-buttonized-mime-types (append (list "multipart/signed"
7692 "multipart/encrypted")
7693 gnus-buttonized-mime-types)))
7694 (gnus-summary-select-article nil 'force)))
7695
eec82323
LMI
7696(defun gnus-summary-set-current-mark (&optional current-mark)
7697 "Obsolete function."
7698 nil)
7699
7700(defun gnus-summary-next-article (&optional unread subject backward push)
7701 "Select the next article.
7702If UNREAD, only unread articles are selected.
7703If SUBJECT, only articles with SUBJECT are selected.
7704If BACKWARD, the previous article is selected instead of the next."
7705 (interactive "P")
11e95b02
MB
7706 ;; Make sure we are in the summary buffer.
7707 (unless (eq major-mode 'gnus-summary-mode)
7708 (set-buffer gnus-summary-buffer))
eec82323
LMI
7709 (cond
7710 ;; Is there such an article?
7711 ((and (gnus-summary-search-forward unread subject backward)
7712 (or (gnus-summary-display-article (gnus-summary-article-number))
7713 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7714 (gnus-summary-position-point))
7715 ;; If not, we try the first unread, if that is wanted.
7716 ((and subject
7717 gnus-auto-select-same
7718 (gnus-summary-first-unread-article))
7719 (gnus-summary-position-point)
7720 (gnus-message 6 "Wrapped"))
7721 ;; Try to get next/previous article not displayed in this group.
7722 ((and gnus-auto-extend-newsgroup
7723 (not unread) (not subject))
7724 (gnus-summary-goto-article
7725 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7726 nil (count-lines (point-min) (point))))
eec82323
LMI
7727 ;; Go to next/previous group.
7728 (t
7729 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7730 (gnus-summary-jump-to-group gnus-newsgroup-name))
49e787c9
GM
7731 (let ((cmd (if (featurep 'xemacs)
7732 last-command-char
7733 last-command-event))
eec82323 7734 (point
01c52d31 7735 (with-current-buffer gnus-group-buffer
eec82323 7736 (point)))
06b840e0 7737 (current-summary (current-buffer))
eec82323
LMI
7738 (group
7739 (if (eq gnus-keep-same-level 'best)
7740 (gnus-summary-best-group gnus-newsgroup-name)
7741 (gnus-summary-search-group backward gnus-keep-same-level))))
eec82323
LMI
7742 ;; Select next unread newsgroup automagically.
7743 (cond
7744 ((or (not gnus-auto-select-next)
7745 (not cmd))
7746 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7747 ((or (eq gnus-auto-select-next 'quietly)
7748 (and (eq gnus-auto-select-next 'slightly-quietly)
7749 push)
7750 (and (eq gnus-auto-select-next 'almost-quietly)
7751 (gnus-summary-last-article-p)))
7752 ;; Select quietly.
7753 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7754 (gnus-summary-exit)
7755 (gnus-message 7 "No more%s articles (%s)..."
7756 (if unread " unread" "")
7757 (if group (concat "selecting " group)
7758 "exiting"))
7759 (gnus-summary-next-group nil group backward)))
7760 (t
7761 (when (gnus-key-press-event-p last-input-event)
06b840e0
LI
7762 ;; Somehow or other, we may now have selected a different
7763 ;; window. Make point go back to the summary buffer.
7764 (when (eq current-summary (current-buffer))
7765 (select-window (get-buffer-window current-summary)))
eec82323
LMI
7766 (gnus-summary-walk-group-buffer
7767 gnus-newsgroup-name cmd unread backward point))))))))
7768
7769(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7770 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7771 (?\C-p (gnus-group-prev-unread-group 1))))
7772 (cursor-in-echo-area t)
23f87bed 7773 keve key group ended prompt)
c7a91ce1 7774 (with-current-buffer gnus-group-buffer
eec82323
LMI
7775 (goto-char start)
7776 (setq group
7777 (if (eq gnus-keep-same-level 'best)
7778 (gnus-summary-best-group gnus-newsgroup-name)
7779 (gnus-summary-search-group backward gnus-keep-same-level))))
7780 (while (not ended)
23f87bed
MB
7781 (setq prompt
7782 (format
7783 "No more%s articles%s " (if unread " unread" "")
7784 (if (and group
7785 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7786 (format " (Type %s for %s [%s])"
91472578
MB
7787 (single-key-description cmd)
7788 (gnus-group-decoded-name group)
01c52d31 7789 (gnus-group-unread group))
23f87bed
MB
7790 (format " (Type %s to exit %s)"
7791 (single-key-description cmd)
91472578 7792 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7793 ;; Confirm auto selection.
23f87bed
MB
7794 (setq key (car (setq keve (gnus-read-event-char prompt)))
7795 ended t)
eec82323
LMI
7796 (cond
7797 ((assq key keystrokes)
7798 (let ((obuf (current-buffer)))
7799 (switch-to-buffer gnus-group-buffer)
7800 (when group
7801 (gnus-group-jump-to-group group))
7802 (eval (cadr (assq key keystrokes)))
7803 (setq group (gnus-group-group-name))
7804 (switch-to-buffer obuf))
7805 (setq ended nil))
7806 ((equal key cmd)
7807 (if (or (not group)
7808 (gnus-ephemeral-group-p gnus-newsgroup-name))
7809 (gnus-summary-exit)
7810 (gnus-summary-next-group nil group backward)))
7811 (t
7812 (push (cdr keve) unread-command-events))))))
7813
7814(defun gnus-summary-next-unread-article ()
7815 "Select unread article after current one."
7816 (interactive)
7817 (gnus-summary-next-article
7818 (or (not (eq gnus-summary-goto-unread 'never))
7819 (gnus-summary-last-article-p (gnus-summary-article-number)))
7820 (and gnus-auto-select-same
7821 (gnus-summary-article-subject))))
7822
7823(defun gnus-summary-prev-article (&optional unread subject)
bbbe940b 7824 "Select the article before the current one.
eec82323
LMI
7825If UNREAD is non-nil, only unread articles are selected."
7826 (interactive "P")
7827 (gnus-summary-next-article unread subject t))
7828
7829(defun gnus-summary-prev-unread-article ()
7830 "Select unread article before current one."
7831 (interactive)
7832 (gnus-summary-prev-article
7833 (or (not (eq gnus-summary-goto-unread 'never))
7834 (gnus-summary-first-article-p (gnus-summary-article-number)))
7835 (and gnus-auto-select-same
7836 (gnus-summary-article-subject))))
7837
23f87bed 7838(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7839 "Show next page of the selected article.
7840If at the end of the current article, select the next article.
7841LINES says how many lines should be scrolled up.
7842
7843If CIRCULAR is non-nil, go to the start of the article instead of
7844selecting the next article when reaching the end of the current
23f87bed
MB
7845article.
7846
7847If STOP is non-nil, just stop when reaching the end of the message.
7848
7849Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7850 (interactive "P")
7851 (setq gnus-summary-buffer (current-buffer))
7852 (gnus-set-global-variables)
7853 (let ((article (gnus-summary-article-number))
7854 (article-window (get-buffer-window gnus-article-buffer t))
7855 endp)
6748645f
LMI
7856 ;; If the buffer is empty, we have no article.
7857 (unless article
7858 (error "No article to select"))
eec82323
LMI
7859 (gnus-configure-windows 'article)
7860 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7861 (if (and (eq gnus-summary-goto-unread 'never)
7862 (not (gnus-summary-last-article-p article)))
7863 (gnus-summary-next-article)
7864 (gnus-summary-next-unread-article))
7865 (if (or (null gnus-current-article)
7866 (null gnus-article-current)
7867 (/= article (cdr gnus-article-current))
7868 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7869 ;; Selected subject is different from current article's.
7870 (gnus-summary-display-article article)
7871 (when article-window
7872 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7873 (setq endp (or (gnus-article-next-page lines)
7874 (gnus-article-only-boring-p))))
eec82323 7875 (when endp
b1992461 7876 (cond ((or stop gnus-summary-stop-at-end-of-message)
23f87bed
MB
7877 (gnus-message 3 "End of message"))
7878 (circular
eec82323
LMI
7879 (gnus-summary-beginning-of-article))
7880 (lines
7881 (gnus-message 3 "End of message"))
7882 ((null lines)
7883 (if (and (eq gnus-summary-goto-unread 'never)
7884 (not (gnus-summary-last-article-p article)))
7885 (gnus-summary-next-article)
7886 (gnus-summary-next-unread-article))))))))
7887 (gnus-summary-recenter)
7888 (gnus-summary-position-point)))
7889
7890(defun gnus-summary-prev-page (&optional lines move)
7891 "Show previous page of selected article.
7892Argument LINES specifies lines to be scrolled down.
7893If MOVE, move to the previous unread article if point is at
7894the beginning of the buffer."
7895 (interactive "P")
eec82323
LMI
7896 (let ((article (gnus-summary-article-number))
7897 (article-window (get-buffer-window gnus-article-buffer t))
7898 endp)
7899 (gnus-configure-windows 'article)
7900 (if (or (null gnus-current-article)
7901 (null gnus-article-current)
7902 (/= article (cdr gnus-article-current))
7903 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7904 ;; Selected subject is different from current article's.
7905 (gnus-summary-display-article article)
7906 (gnus-summary-recenter)
7907 (when article-window
7908 (gnus-eval-in-buffer-window gnus-article-buffer
7909 (setq endp (gnus-article-prev-page lines)))
7910 (when (and move endp)
7911 (cond (lines
7912 (gnus-message 3 "Beginning of message"))
7913 ((null lines)
7914 (if (and (eq gnus-summary-goto-unread 'never)
7915 (not (gnus-summary-first-article-p article)))
7916 (gnus-summary-prev-article)
7917 (gnus-summary-prev-unread-article))))))))
7918 (gnus-summary-position-point))
7919
7920(defun gnus-summary-prev-page-or-article (&optional lines)
7921 "Show previous page of selected article.
7922Argument LINES specifies lines to be scrolled down.
7923If at the beginning of the article, go to the next article."
7924 (interactive "P")
7925 (gnus-summary-prev-page lines t))
7926
7927(defun gnus-summary-scroll-up (lines)
7928 "Scroll up (or down) one line current article.
a3f57c41
G
7929Argument LINES specifies lines to be scrolled up (or down if negative).
7930If no article is selected, then the current article will be selected first."
eec82323 7931 (interactive "p")
eec82323
LMI
7932 (gnus-configure-windows 'article)
7933 (gnus-summary-show-thread)
7934 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7935 (gnus-eval-in-buffer-window gnus-article-buffer
7936 (cond ((> lines 0)
7937 (when (gnus-article-next-page lines)
7938 (gnus-message 3 "End of message")))
7939 ((< lines 0)
7940 (gnus-article-prev-page (- lines))))))
7941 (gnus-summary-recenter)
7942 (gnus-summary-position-point))
7943
6748645f
LMI
7944(defun gnus-summary-scroll-down (lines)
7945 "Scroll down (or up) one line current article.
a3f57c41
G
7946Argument LINES specifies lines to be scrolled down (or up if negative).
7947If no article is selected, then the current article will be selected first."
6748645f
LMI
7948 (interactive "p")
7949 (gnus-summary-scroll-up (- lines)))
7950
eec82323
LMI
7951(defun gnus-summary-next-same-subject ()
7952 "Select next article which has the same subject as current one."
7953 (interactive)
eec82323
LMI
7954 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7955
7956(defun gnus-summary-prev-same-subject ()
7957 "Select previous article which has the same subject as current one."
7958 (interactive)
eec82323
LMI
7959 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7960
7961(defun gnus-summary-next-unread-same-subject ()
7962 "Select next unread article which has the same subject as current one."
7963 (interactive)
eec82323
LMI
7964 (gnus-summary-next-article t (gnus-summary-article-subject)))
7965
7966(defun gnus-summary-prev-unread-same-subject ()
7967 "Select previous unread article which has the same subject as current one."
7968 (interactive)
eec82323
LMI
7969 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7970
7971(defun gnus-summary-first-unread-article ()
7972 "Select the first unread article.
7973Return nil if there are no unread articles."
7974 (interactive)
eec82323
LMI
7975 (prog1
7976 (when (gnus-summary-first-subject t)
7977 (gnus-summary-show-thread)
7978 (gnus-summary-first-subject t)
7979 (gnus-summary-display-article (gnus-summary-article-number)))
7980 (gnus-summary-position-point)))
7981
16409b0b
GM
7982(defun gnus-summary-first-unread-subject ()
7983 "Place the point on the subject line of the first unread article.
7984Return nil if there are no unread articles."
7985 (interactive)
7986 (prog1
7987 (when (gnus-summary-first-subject t)
7988 (gnus-summary-show-thread)
7989 (gnus-summary-first-subject t))
7990 (gnus-summary-position-point)))
7991
23f87bed
MB
7992(defun gnus-summary-first-unseen-subject ()
7993 "Place the point on the subject line of the first unseen article.
7994Return nil if there are no unseen articles."
7995 (interactive)
7996 (prog1
7997 (when (gnus-summary-first-subject nil nil t)
7998 (gnus-summary-show-thread)
7999 (gnus-summary-first-subject nil nil t))
8000 (gnus-summary-position-point)))
8001
8002(defun gnus-summary-first-unseen-or-unread-subject ()
20a673b2
KY
8003 "Place the point on the subject line of the first unseen and unread article.
8004If all article have been seen, on the subject line of the first unread
23f87bed
MB
8005article."
8006 (interactive)
8007 (prog1
8008 (unless (when (gnus-summary-first-subject nil nil t)
8009 (gnus-summary-show-thread)
8010 (gnus-summary-first-subject nil nil t))
8011 (when (gnus-summary-first-subject t)
8012 (gnus-summary-show-thread)
8013 (gnus-summary-first-subject t)))
8014 (gnus-summary-position-point)))
8015
eec82323
LMI
8016(defun gnus-summary-first-article ()
8017 "Select the first article.
8018Return nil if there are no articles."
8019 (interactive)
eec82323
LMI
8020 (prog1
8021 (when (gnus-summary-first-subject)
16409b0b
GM
8022 (gnus-summary-show-thread)
8023 (gnus-summary-first-subject)
8024 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
8025 (gnus-summary-position-point)))
8026
23f87bed
MB
8027(defun gnus-summary-best-unread-article (&optional arg)
8028 "Select the unread article with the highest score.
8029If given a prefix argument, select the next unread article that has a
8030score higher than the default score."
8031 (interactive "P")
8032 (let ((article (if arg
8033 (gnus-summary-better-unread-subject)
8034 (gnus-summary-best-unread-subject))))
8035 (if article
8036 (gnus-summary-goto-article article)
8037 (error "No unread articles"))))
8038
8039(defun gnus-summary-best-unread-subject ()
8040 "Select the unread subject with the highest score."
eec82323 8041 (interactive)
eec82323
LMI
8042 (let ((best -1000000)
8043 (data gnus-newsgroup-data)
8044 article score)
8045 (while data
8046 (and (gnus-data-unread-p (car data))
8047 (> (setq score
8048 (gnus-summary-article-score (gnus-data-number (car data))))
8049 best)
8050 (setq best score
8051 article (gnus-data-number (car data))))
8052 (setq data (cdr data)))
23f87bed
MB
8053 (when article
8054 (gnus-summary-goto-subject article))
8055 (gnus-summary-position-point)
8056 article))
8057
8058(defun gnus-summary-better-unread-subject ()
8059 "Select the first unread subject that has a score over the default score."
8060 (interactive)
8061 (let ((data gnus-newsgroup-data)
8062 article score)
8063 (while (and (setq article (gnus-data-number (car data)))
8064 (or (gnus-data-read-p (car data))
8065 (not (> (gnus-summary-article-score article)
8066 gnus-summary-default-score))))
8067 (setq data (cdr data)))
8068 (when article
8069 (gnus-summary-goto-subject article))
8070 (gnus-summary-position-point)
8071 article))
eec82323
LMI
8072
8073(defun gnus-summary-last-subject ()
8074 "Go to the last displayed subject line in the group."
8075 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8076 (when article
8077 (gnus-summary-goto-subject article))))
8078
8079(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
8080 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8081If ALL-HEADERS is non-nil, no header lines are hidden.
8082If FORCE, go to the article even if it isn't displayed. If FORCE
8083is a number, it is the line the article is to be displayed on."
eec82323
LMI
8084 (interactive
8085 (list
229b59da
G
8086 (gnus-completing-read
8087 "Article number or Message-ID"
8088 (mapcar 'int-to-string gnus-newsgroup-limit))
eec82323
LMI
8089 current-prefix-arg
8090 t))
8091 (prog1
6748645f 8092 (if (and (stringp article)
23f87bed 8093 (string-match "@\\|%40" article))
6748645f
LMI
8094 (gnus-summary-refer-article article)
8095 (when (stringp article)
8096 (setq article (string-to-number article)))
8097 (if (gnus-summary-goto-subject article force)
8098 (gnus-summary-display-article article all-headers)
8099 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
8100 (gnus-summary-position-point)))
8101
8102(defun gnus-summary-goto-last-article ()
8103 "Go to the previously read article."
8104 (interactive)
8105 (prog1
8106 (when gnus-last-article
6748645f 8107 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
8108 (gnus-summary-position-point)))
8109
8110(defun gnus-summary-pop-article (number)
8111 "Pop one article off the history and go to the previous.
8112NUMBER articles will be popped off."
8113 (interactive "p")
8114 (let (to)
8115 (setq gnus-newsgroup-history
8116 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8117 (if to
6748645f 8118 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
8119 (error "Article history empty")))
8120 (gnus-summary-position-point))
8121
8122;; Summary commands and functions for limiting the summary buffer.
8123
8124(defun gnus-summary-limit-to-articles (n)
8125 "Limit the summary buffer to the next N articles.
8126If not given a prefix, use the process marked articles instead."
8127 (interactive "P")
eec82323
LMI
8128 (prog1
8129 (let ((articles (gnus-summary-work-articles n)))
8130 (setq gnus-newsgroup-processable nil)
8131 (gnus-summary-limit articles))
8132 (gnus-summary-position-point)))
8133
8134(defun gnus-summary-pop-limit (&optional total)
8135 "Restore the previous limit.
8136If given a prefix, remove all limits."
8137 (interactive "P")
eec82323
LMI
8138 (when total
8139 (setq gnus-newsgroup-limits
8140 (list (mapcar (lambda (h) (mail-header-number h))
8141 gnus-newsgroup-headers))))
8142 (unless gnus-newsgroup-limits
8143 (error "No limit to pop"))
8144 (prog1
8145 (gnus-summary-limit nil 'pop)
8146 (gnus-summary-position-point)))
8147
47b63dfa
SZ
8148(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8149 "Limit the summary buffer to articles that have subjects that match a regexp.
8150If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 8151 (interactive
47b63dfa
SZ
8152 (list (read-string (if current-prefix-arg
8153 "Exclude subject (regexp): "
a1506d29 8154 "Limit to subject (regexp): "))
47b63dfa 8155 nil current-prefix-arg))
eec82323
LMI
8156 (unless header
8157 (setq header "subject"))
8158 (when (not (equal "" subject))
8159 (prog1
8160 (let ((articles (gnus-summary-find-matching
a1506d29 8161 (or header "subject") subject 'all nil nil
47b63dfa 8162 not-matching)))
eec82323
LMI
8163 (unless articles
8164 (error "Found no matches for \"%s\"" subject))
8165 (gnus-summary-limit articles))
8166 (gnus-summary-position-point))))
8167
ef6e0ec7 8168(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
8169 "Limit the summary buffer to articles that have authors that match a regexp.
8170If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 8171 (interactive
47b63dfa
SZ
8172 (list (read-string (if current-prefix-arg
8173 "Exclude author (regexp): "
a1506d29 8174 "Limit to author (regexp): "))
ef6e0ec7
SZ
8175 current-prefix-arg))
8176 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323 8177
01c52d31
MB
8178(defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8179 "Limit the summary buffer to articles with the given RECIPIENT.
8180
8181If NOT-MATCHING, exclude RECIPIENT.
8182
8183To and Cc headers are checked. You need to include them in
8184`nnmail-extra-headers'."
8185 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8186 (interactive
8187 (list (read-string (format "%s recipient (regexp): "
8188 (if current-prefix-arg "Exclude" "Limit to")))
8189 current-prefix-arg))
8190 (when (not (equal "" recipient))
8191 (prog1 (let* ((to
8192 (if (memq 'To nnmail-extra-headers)
8193 (gnus-summary-find-matching
8194 (cons 'extra 'To) recipient 'all nil nil
8195 not-matching)
8196 (gnus-message
8197 1 "`To' isn't present in `nnmail-extra-headers'")
8198 (sit-for 1)
8199 nil))
8200 (cc
8201 (if (memq 'Cc nnmail-extra-headers)
8202 (gnus-summary-find-matching
8203 (cons 'extra 'Cc) recipient 'all nil nil
8204 not-matching)
8205 (gnus-message
8206 1 "`Cc' isn't present in `nnmail-extra-headers'")
8207 (sit-for 1)
8208 nil))
8209 (articles
8210 (if not-matching
8211 ;; We need the numbers that are in both lists:
8212 (mapcar (lambda (a)
8213 (and (memq a to) a))
8214 cc)
8215 (nconc to cc))))
8216 (unless articles
8217 (error "Found no matches for \"%s\"" recipient))
8218 (gnus-summary-limit articles))
8219 (gnus-summary-position-point))))
8220
8221(defun gnus-summary-limit-to-address (address &optional not-matching)
8222 "Limit the summary buffer to articles with the given ADDRESS.
8223
8224If NOT-MATCHING, exclude ADDRESS.
8225
8226To, Cc and From headers are checked. You need to include `To' and `Cc'
8227in `nnmail-extra-headers'."
8228 (interactive
8229 (list (read-string (format "%s address (regexp): "
8230 (if current-prefix-arg "Exclude" "Limit to")))
8231 current-prefix-arg))
8232 (when (not (equal "" address))
8233 (prog1 (let* ((to
8234 (if (memq 'To nnmail-extra-headers)
8235 (gnus-summary-find-matching
8236 (cons 'extra 'To) address 'all nil nil
8237 not-matching)
8238 (gnus-message
8239 1 "`To' isn't present in `nnmail-extra-headers'")
8240 (sit-for 1)
8241 t))
8242 (cc
8243 (if (memq 'Cc nnmail-extra-headers)
8244 (gnus-summary-find-matching
8245 (cons 'extra 'Cc) address 'all nil nil
8246 not-matching)
8247 (gnus-message
8248 1 "`Cc' isn't present in `nnmail-extra-headers'")
8249 (sit-for 1)
8250 t))
8251 (from
8252 (gnus-summary-find-matching "from" address
8253 'all nil nil not-matching))
8254 (articles
8255 (if not-matching
8256 ;; We need the numbers that are in all lists:
8257 (if (eq cc t)
8258 (if (eq to t)
8259 from
8260 (mapcar (lambda (a) (car (memq a from))) to))
8261 (if (eq to t)
8262 (mapcar (lambda (a) (car (memq a from))) cc)
8263 (mapcar (lambda (a) (car (memq a from)))
8264 (mapcar (lambda (a) (car (memq a to)))
8265 cc))))
8266 (nconc (if (eq to t) nil to)
8267 (if (eq cc t) nil cc)
8268 from))))
8269 (unless articles
8270 (error "Found no matches for \"%s\"" address))
8271 (gnus-summary-limit articles))
8272 (gnus-summary-position-point))))
8273
8274(defun gnus-summary-limit-strange-charsets-predicate (header)
765d4319
KY
8275 (when (fboundp 'char-charset)
8276 (let ((string (concat (mail-header-subject header)
8277 (mail-header-from header)))
8278 charset found)
8279 (dotimes (i (1- (length string)))
8280 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8281 (when (string-match "unicode\\|big\\|japanese" charset)
8282 (setq found t)))
8283 found)))
01c52d31
MB
8284
8285(defun gnus-summary-limit-to-predicate (predicate)
8286 "Limit to articles where PREDICATE returns non-nil.
8287PREDICATE will be called with the header structures of the
8288articles."
8289 (let ((articles nil)
8290 (case-fold-search t))
8291 (dolist (header gnus-newsgroup-headers)
8292 (when (funcall predicate header)
8293 (push (mail-header-number header) articles)))
8294 (gnus-summary-limit (nreverse articles))))
8295
eec82323
LMI
8296(defun gnus-summary-limit-to-age (age &optional younger-p)
8297 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8298If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8299articles that are younger than AGE days."
16409b0b
GM
8300 (interactive
8301 (let ((younger current-prefix-arg)
8302 (days-got nil)
8303 days)
8304 (while (not days-got)
8305 (setq days (if younger
23f87bed
MB
8306 (read-string "Limit to articles younger than (in days, older when negative): ")
8307 (read-string
8308 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
8309 (when (> (length days) 0)
8310 (setq days (read days)))
8311 (if (numberp days)
23f87bed
MB
8312 (progn
8313 (setq days-got t)
01c52d31
MB
8314 (when (< days 0)
8315 (setq younger (not younger))
8316 (setq days (* days -1))))
16409b0b
GM
8317 (message "Please enter a number.")
8318 (sleep-for 1)))
8319 (list days younger)))
eec82323
LMI
8320 (prog1
8321 (let ((data gnus-newsgroup-data)
16409b0b 8322 (cutoff (days-to-time age))
eec82323
LMI
8323 articles d date is-younger)
8324 (while (setq d (pop data))
8325 (when (and (vectorp (gnus-data-header d))
8326 (setq date (mail-header-date (gnus-data-header d))))
16409b0b 8327 (setq is-younger (time-less-p
3d6e7a43 8328 (time-since (gnus-date-get-time date))
eec82323 8329 cutoff))
6748645f
LMI
8330 (when (if younger-p
8331 is-younger
8332 (not is-younger))
eec82323
LMI
8333 (push (gnus-data-number d) articles))))
8334 (gnus-summary-limit (nreverse articles)))
8335 (gnus-summary-position-point)))
8336
47b63dfa 8337(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
8338 "Limit the summary buffer to articles that match an 'extra' header."
8339 (interactive
8340 (let ((header
8341 (intern
229b59da 8342 (gnus-completing-read
47b63dfa 8343 (if current-prefix-arg
81df110a
RF
8344 "Exclude extra header"
8345 "Limit extra header")
229b59da
G
8346 (mapcar 'symbol-name gnus-extra-headers)
8347 t nil nil
8348 (symbol-name (car gnus-extra-headers))))))
16409b0b 8349 (list header
a1506d29 8350 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
8351 (if current-prefix-arg "Exclude" "Limit to")
8352 header))
8353 current-prefix-arg)))
16409b0b
GM
8354 (when (not (equal "" regexp))
8355 (prog1
8356 (let ((articles (gnus-summary-find-matching
a1506d29 8357 (cons 'extra header) regexp 'all nil nil
47b63dfa 8358 not-matching)))
16409b0b
GM
8359 (unless articles
8360 (error "Found no matches for \"%s\"" regexp))
8361 (gnus-summary-limit articles))
8362 (gnus-summary-position-point))))
8363
23f87bed
MB
8364(defun gnus-summary-limit-to-display-predicate ()
8365 "Limit the summary buffer to the predicated in the `display' group parameter."
8366 (interactive)
8367 (unless gnus-newsgroup-display
8368 (error "There is no `display' group parameter"))
8369 (let (articles)
3a3cbf0a 8370 (dolist (gnus-number gnus-newsgroup-articles)
23f87bed 8371 (when (funcall gnus-newsgroup-display)
3a3cbf0a 8372 (push gnus-number articles)))
23f87bed
MB
8373 (gnus-summary-limit articles))
8374 (gnus-summary-position-point))
8375
eec82323
LMI
8376(defun gnus-summary-limit-to-unread (&optional all)
8377 "Limit the summary buffer to articles that are not marked as read.
8378If ALL is non-nil, limit strictly to unread articles."
8379 (interactive "P")
8380 (if all
8381 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8382 (gnus-summary-limit-to-marks
8383 ;; Concat all the marks that say that an article is read and have
8384 ;; those removed.
8385 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 8386 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
8387 gnus-low-score-mark gnus-expirable-mark
8388 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
c4d82de8 8389 gnus-duplicate-mark)
eec82323
LMI
8390 'reverse)))
8391
01c52d31
MB
8392(defun gnus-summary-limit-to-headers (match &optional reverse)
8393 "Limit the summary buffer to articles that have headers that match MATCH.
8394If REVERSE (the prefix), limit to articles that don't match."
8395 (interactive "sMatch headers (regexp): \nP")
8396 (gnus-summary-limit-to-bodies match reverse t))
8397
8398(defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8399 "Limit the summary buffer to articles that have bodies that match MATCH.
8400If REVERSE (the prefix), limit to articles that don't match."
8401 (interactive "sMatch body (regexp): \nP")
8402 (let ((articles nil)
8403 (gnus-select-article-hook nil) ;Disable hook.
8404 (gnus-article-prepare-hook nil)
8405 (gnus-use-article-prefetch nil)
8406 (gnus-keep-backlog nil)
8407 (gnus-break-pages nil)
8408 (gnus-summary-display-arrow nil)
8409 (gnus-updated-mode-lines nil)
8410 (gnus-auto-center-summary nil)
8411 (gnus-display-mime-function nil))
8412 (dolist (data gnus-newsgroup-data)
8413 (let (gnus-mark-article-hook)
8414 (gnus-summary-select-article t t nil (gnus-data-number data)))
398a825b 8415 (with-current-buffer gnus-article-buffer
01c52d31
MB
8416 (article-goto-body)
8417 (let* ((case-fold-search t)
8418 (found (if headersp
8419 (re-search-backward match nil t)
8420 (re-search-forward match nil t))))
8421 (when (or (and found
8422 (not reverse))
8423 (and (not found)
8424 reverse))
8425 (push (gnus-data-number data) articles)))))
8426 (if (not articles)
8427 (message "No messages matched")
8428 (gnus-summary-limit articles)))
8429 (gnus-summary-position-point))
8430
8431(defun gnus-summary-limit-to-singletons (&optional threadsp)
8432 "Limit the summary buffer to articles that aren't part on any thread.
8433If THREADSP (the prefix), limit to articles that are in threads."
8434 (interactive "P")
8435 (let ((articles nil)
8436 thread-articles
8437 threads)
8438 (dolist (thread gnus-newsgroup-threads)
8439 (if (stringp (car thread))
8440 (dolist (thread (cdr thread))
8441 (push thread threads))
8442 (push thread threads)))
8443 (dolist (thread threads)
8444 (setq thread-articles (gnus-articles-in-thread thread))
8445 (when (or (and threadsp
8446 (> (length thread-articles) 1))
8447 (and (not threadsp)
8448 (= (length thread-articles) 1)))
8449 (setq articles (nconc thread-articles articles))))
8450 (if (not articles)
8451 (message "No messages matched")
8452 (gnus-summary-limit articles))
8453 (gnus-summary-position-point)))
8454
8455(defun gnus-summary-limit-to-replied (&optional unreplied)
8456 "Limit the summary buffer to replied articles.
8457If UNREPLIED (the prefix), limit to unreplied articles."
8458 (interactive "P")
8459 (if unreplied
8460 (gnus-summary-limit
8461 (gnus-set-difference gnus-newsgroup-articles
8462 gnus-newsgroup-replied))
8463 (gnus-summary-limit gnus-newsgroup-replied))
8464 (gnus-summary-position-point))
8465
eec82323
LMI
8466(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8467 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8468If REVERSE, limit the summary buffer to articles that are marked
8469with MARKS. MARKS can either be a string of marks or a list of marks.
8470Returns how many articles were removed."
8471 (interactive "sMarks: ")
8472 (gnus-summary-limit-to-marks marks t))
8473
8474(defun gnus-summary-limit-to-marks (marks &optional reverse)
8475 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8476If REVERSE (the prefix), limit the summary buffer to articles that are
8477not marked with MARKS. MARKS can either be a string of marks or a
8478list of marks.
8479Returns how many articles were removed."
6748645f 8480 (interactive "sMarks: \nP")
eec82323
LMI
8481 (prog1
8482 (let ((data gnus-newsgroup-data)
8483 (marks (if (listp marks) marks
8484 (append marks nil))) ; Transform to list.
8485 articles)
8486 (while data
8487 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8488 (memq (gnus-data-mark (car data)) marks))
8489 (push (gnus-data-number (car data)) articles))
8490 (setq data (cdr data)))
8491 (gnus-summary-limit articles))
8492 (gnus-summary-position-point)))
8493
23f87bed 8494(defun gnus-summary-limit-to-score (score)
eec82323 8495 "Limit to articles with score at or above SCORE."
23f87bed 8496 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
8497 (let ((data gnus-newsgroup-data)
8498 articles)
8499 (while data
8500 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8501 score)
8502 (push (gnus-data-number (car data)) articles))
8503 (setq data (cdr data)))
8504 (prog1
8505 (gnus-summary-limit articles)
8506 (gnus-summary-position-point))))
8507
23f87bed
MB
8508(defun gnus-summary-limit-to-unseen ()
8509 "Limit to unseen articles."
8510 (interactive)
8511 (prog1
8512 (gnus-summary-limit gnus-newsgroup-unseen)
8513 (gnus-summary-position-point)))
8514
6748645f 8515(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
8516 "Display all the hidden articles that is in the thread with ID in it.
8517When called interactively, ID is the Message-ID of the current
8518article."
6748645f
LMI
8519 (interactive (list (mail-header-id (gnus-summary-article-header))))
8520 (let ((articles (gnus-articles-in-thread
181cb5fb
G
8521 (gnus-id-to-thread (gnus-root-id id))))
8522 ;;we REALLY want the whole thread---this prevents cut-threads
8523 ;;from removing the thread we want to include.
8524 (gnus-fetch-old-headers nil)
8525 (gnus-build-sparse-threads nil))
6748645f
LMI
8526 (prog1
8527 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
8528 (gnus-summary-limit-include-matching-articles
8529 "subject"
8530 (regexp-quote (gnus-simplify-subject-re
8531 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
8532 (gnus-summary-position-point))))
8533
23f87bed
MB
8534(defun gnus-summary-limit-include-matching-articles (header regexp)
8535 "Display all the hidden articles that have HEADERs that match REGEXP."
8536 (interactive (list (read-string "Match on header: ")
8537 (read-string "Regexp: ")))
8538 (let ((articles (gnus-find-matching-articles header regexp)))
8539 (prog1
8540 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8541 (gnus-summary-position-point))))
8542
8543(defun gnus-summary-insert-dormant-articles ()
8544 "Insert all the dormant articles for this group into the current buffer."
8545 (interactive)
8546 (let ((gnus-verbose (max 6 gnus-verbose)))
8547 (if (not gnus-newsgroup-dormant)
db629244 8548 (gnus-message 3 "No dormant articles for this group")
23f87bed
MB
8549 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8550
01c52d31
MB
8551(defun gnus-summary-insert-ticked-articles ()
8552 "Insert ticked articles for this group into the current buffer."
8553 (interactive)
8554 (let ((gnus-verbose (max 6 gnus-verbose)))
8555 (if (not gnus-newsgroup-marked)
8556 (gnus-message 3 "No ticked articles for this group")
8557 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8558
eec82323 8559(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
8560 "Display all the hidden articles that are marked as dormant.
8561Note that this command only works on a subset of the articles currently
8562fetched for this group."
eec82323 8563 (interactive)
eec82323
LMI
8564 (unless gnus-newsgroup-dormant
8565 (error "There are no dormant articles in this group"))
8566 (prog1
8567 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8568 (gnus-summary-position-point)))
8569
144b7b5c
G
8570(defun gnus-summary-include-articles (articles)
8571 "Fetch the headers for ARTICLES and then display the summary lines."
8572 (let ((gnus-inhibit-demon t)
8573 (gnus-agent nil)
8574 (gnus-read-all-available-headers t))
8575 (setq gnus-newsgroup-headers
8576 (gnus-merge
8577 'list gnus-newsgroup-headers
8578 (gnus-fetch-headers articles nil t)
8579 'gnus-article-sort-by-number))
8580 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8581
eec82323
LMI
8582(defun gnus-summary-limit-exclude-dormant ()
8583 "Hide all dormant articles."
8584 (interactive)
eec82323
LMI
8585 (prog1
8586 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8587 (gnus-summary-position-point)))
8588
8589(defun gnus-summary-limit-exclude-childless-dormant ()
8590 "Hide all dormant articles that have no children."
8591 (interactive)
eec82323
LMI
8592 (let ((data (gnus-data-list t))
8593 articles d children)
8594 ;; Find all articles that are either not dormant or have
8595 ;; children.
8596 (while (setq d (pop data))
8597 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8598 (and (setq children
8599 (gnus-article-children (gnus-data-number d)))
8600 (let (found)
8601 (while children
8602 (when (memq (car children) articles)
8603 (setq children nil
8604 found t))
8605 (pop children))
8606 found)))
8607 (push (gnus-data-number d) articles)))
8608 ;; Do the limiting.
8609 (prog1
8610 (gnus-summary-limit articles)
8611 (gnus-summary-position-point))))
8612
8613(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8614 "Mark all unread excluded articles as read.
8615If ALL, mark even excluded ticked and dormants as read."
8616 (interactive "P")
23f87bed
MB
8617 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8618 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8619 (sort
8620 (mapcar (lambda (h) (mail-header-number h))
8621 gnus-newsgroup-headers)
8622 '<)
23f87bed 8623 gnus-newsgroup-limit))
eec82323 8624 article)
6748645f 8625 (setq gnus-newsgroup-unreads
23f87bed
MB
8626 (gnus-sorted-intersection gnus-newsgroup-unreads
8627 gnus-newsgroup-limit))
eec82323
LMI
8628 (if all
8629 (setq gnus-newsgroup-dormant nil
8630 gnus-newsgroup-marked nil
8631 gnus-newsgroup-reads
8632 (nconc
8633 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8634 gnus-newsgroup-reads))
8635 (while (setq article (pop articles))
8636 (unless (or (memq article gnus-newsgroup-dormant)
8637 (memq article gnus-newsgroup-marked))
8638 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8639
8640(defun gnus-summary-limit (articles &optional pop)
8641 (if pop
8642 ;; We pop the previous limit off the stack and use that.
8643 (setq articles (car gnus-newsgroup-limits)
8644 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8645 ;; We use the new limit, so we push the old limit on the stack.
8646 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8647 ;; Set the limit.
8648 (setq gnus-newsgroup-limit articles)
8649 (let ((total (length gnus-newsgroup-data))
8650 (data (gnus-data-find-list (gnus-summary-article-number)))
8651 (gnus-summary-mark-below nil) ; Inhibit this.
8652 found)
8653 ;; This will do all the work of generating the new summary buffer
8654 ;; according to the new limit.
8655 (gnus-summary-prepare)
8656 ;; Hide any threads, possibly.
23f87bed 8657 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8658 ;; Try to return to the article you were at, or one in the
8659 ;; neighborhood.
8660 (when data
8661 ;; We try to find some article after the current one.
8662 (while data
8663 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8664 (setq data nil
8665 found t))
8666 (setq data (cdr data))))
8667 (unless found
8668 ;; If there is no data, that means that we were after the last
8669 ;; article. The same goes when we can't find any articles
8670 ;; after the current one.
8671 (goto-char (point-max))
8672 (gnus-summary-find-prev))
6748645f 8673 (gnus-set-mode-line 'summary)
eec82323
LMI
8674 ;; We return how many articles were removed from the summary
8675 ;; buffer as a result of the new limit.
8676 (- total (length gnus-newsgroup-data))))
8677
8678(defsubst gnus-invisible-cut-children (threads)
8679 (let ((num 0))
8680 (while threads
8681 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8682 (incf num))
8683 (pop threads))
8684 (< num 2)))
8685
8686(defsubst gnus-cut-thread (thread)
8687 "Go forwards in the thread until we find an article that we want to display."
8688 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8689 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8690 (numberp gnus-fetch-old-headers)
eec82323
LMI
8691 (eq gnus-build-sparse-threads 'some)
8692 (eq gnus-build-sparse-threads 'more))
8693 ;; Deal with old-fetched headers and sparse threads.
8694 (while (and
8695 thread
8696 (or
8697 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8698 (gnus-summary-article-ancient-p
8699 (mail-header-number (car thread))))
6748645f
LMI
8700 (if (or (<= (length (cdr thread)) 1)
8701 (eq gnus-fetch-old-headers 'invisible))
8702 (setq gnus-newsgroup-limit
8703 (delq (mail-header-number (car thread))
8704 gnus-newsgroup-limit)
8705 thread (cadr thread))
8706 (when (gnus-invisible-cut-children (cdr thread))
8707 (let ((th (cdr thread)))
8708 (while th
8709 (if (memq (mail-header-number (caar th))
a8151ef7 8710 gnus-newsgroup-limit)
6748645f
LMI
8711 (setq thread (car th)
8712 th nil)
8713 (setq th (cdr th))))))))))
eec82323
LMI
8714 thread)
8715
8716(defun gnus-cut-threads (threads)
23f87bed 8717 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8718 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8719 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8720 (numberp gnus-fetch-old-headers)
eec82323
LMI
8721 (eq gnus-build-sparse-threads 'some)
8722 (eq gnus-build-sparse-threads 'more))
8723 (let ((th threads))
8724 (while th
8725 (setcar th (gnus-cut-thread (car th)))
8726 (setq th (cdr th)))))
8727 ;; Remove nixed out threads.
8728 (delq nil threads))
8729
8730(defun gnus-summary-initial-limit (&optional show-if-empty)
8731 "Figure out what the initial limit is supposed to be on group entry.
8732This entails weeding out unwanted dormants, low-scored articles,
8733fetch-old-headers verbiage, and so on."
8734 ;; Most groups have nothing to remove.
f394fa25
MB
8735 (unless (or gnus-inhibit-limiting
8736 (and (null gnus-newsgroup-dormant)
8737 (eq gnus-newsgroup-display 'gnus-not-ignore)
8738 (not (eq gnus-fetch-old-headers 'some))
8739 (not (numberp gnus-fetch-old-headers))
8740 (not (eq gnus-fetch-old-headers 'invisible))
8741 (null gnus-summary-expunge-below)
8742 (not (eq gnus-build-sparse-threads 'some))
8743 (not (eq gnus-build-sparse-threads 'more))
8ccbef23 8744 (null gnus-thread-expunge-below)))
eec82323
LMI
8745 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8746 (setq gnus-newsgroup-limit nil)
8747 (mapatoms
8748 (lambda (node)
8749 (unless (car (symbol-value node))
8750 ;; These threads have no parents -- they are roots.
8751 (let ((nodes (cdr (symbol-value node)))
8752 thread)
8753 (while nodes
8754 (if (and gnus-thread-expunge-below
8755 (< (gnus-thread-total-score (car nodes))
8756 gnus-thread-expunge-below))
8757 (gnus-expunge-thread (pop nodes))
8758 (setq thread (pop nodes))
8759 (gnus-summary-limit-children thread))))))
8760 gnus-newsgroup-dependencies)
8761 ;; If this limitation resulted in an empty group, we might
8762 ;; pop the previous limit and use it instead.
8763 (when (and (not gnus-newsgroup-limit)
8764 show-if-empty)
8765 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8766 gnus-newsgroup-limit))
8767
8768(defun gnus-summary-limit-children (thread)
8769 "Return 1 if this subthread is visible and 0 if it is not."
8770 ;; First we get the number of visible children to this thread. This
8771 ;; is done by recursing down the thread using this function, so this
8772 ;; will really go down to a leaf article first, before slowly
8773 ;; working its way up towards the root.
8774 (when thread
04b61ae9 8775 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8776 (children
eec82323
LMI
8777 (if (cdr thread)
8778 (apply '+ (mapcar 'gnus-summary-limit-children
8779 (cdr thread)))
8780 0))
3d319c8f
LMI
8781 (number (mail-header-number (car thread)))
8782 score)
eec82323
LMI
8783 (if (and
8784 (not (memq number gnus-newsgroup-marked))
8785 (or
8786 ;; If this article is dormant and has absolutely no visible
8787 ;; children, then this article isn't visible.
8788 (and (memq number gnus-newsgroup-dormant)
8789 (zerop children))
8790 ;; If this is "fetch-old-headered" and there is no
8791 ;; visible children, then we don't want this article.
16409b0b
GM
8792 (and (or (eq gnus-fetch-old-headers 'some)
8793 (numberp gnus-fetch-old-headers))
eec82323
LMI
8794 (gnus-summary-article-ancient-p number)
8795 (zerop children))
6748645f
LMI
8796 ;; If this is "fetch-old-headered" and `invisible', then
8797 ;; we don't want this article.
8798 (and (eq gnus-fetch-old-headers 'invisible)
8799 (gnus-summary-article-ancient-p number))
eec82323
LMI
8800 ;; If this is a sparsely inserted article with no children,
8801 ;; we don't want it.
8802 (and (eq gnus-build-sparse-threads 'some)
8803 (gnus-summary-article-sparse-p number)
8804 (zerop children))
8805 ;; If we use expunging, and this article is really
8806 ;; low-scored, then we don't want this article.
8807 (when (and gnus-summary-expunge-below
8808 (< (setq score
8809 (or (cdr (assq number gnus-newsgroup-scored))
8810 gnus-summary-default-score))
8811 gnus-summary-expunge-below))
8812 ;; We increase the expunge-tally here, but that has
8813 ;; nothing to do with the limits, really.
8814 (incf gnus-newsgroup-expunged-tally)
8815 ;; We also mark as read here, if that's wanted.
8816 (when (and gnus-summary-mark-below
8817 (< score gnus-summary-mark-below))
8818 (setq gnus-newsgroup-unreads
8819 (delq number gnus-newsgroup-unreads))
8820 (if gnus-newsgroup-auto-expire
8821 (push number gnus-newsgroup-expirable)
8822 (push (cons number gnus-low-score-mark)
8823 gnus-newsgroup-reads)))
8824 t)
23f87bed
MB
8825 ;; Do the `display' group parameter.
8826 (and gnus-newsgroup-display
3d319c8f
LMI
8827 (let ((gnus-number number))
8828 (not (funcall gnus-newsgroup-display))))))
eec82323
LMI
8829 ;; Nope, invisible article.
8830 0
8831 ;; Ok, this article is to be visible, so we add it to the limit
8832 ;; and return 1.
8833 (push number gnus-newsgroup-limit)
8834 1))))
8835
8836(defun gnus-expunge-thread (thread)
8837 "Mark all articles in THREAD as read."
8838 (let* ((number (mail-header-number (car thread))))
8839 (incf gnus-newsgroup-expunged-tally)
8840 ;; We also mark as read here, if that's wanted.
8841 (setq gnus-newsgroup-unreads
8842 (delq number gnus-newsgroup-unreads))
8843 (if gnus-newsgroup-auto-expire
8844 (push number gnus-newsgroup-expirable)
8845 (push (cons number gnus-low-score-mark)
8846 gnus-newsgroup-reads)))
8847 ;; Go recursively through all subthreads.
8848 (mapcar 'gnus-expunge-thread (cdr thread)))
8849
8850;; Summary article oriented commands
8851
8852(defun gnus-summary-refer-parent-article (n)
8853 "Refer parent article N times.
8854If N is negative, go to ancestor -N instead.
8855The difference between N and the number of articles fetched is returned."
8856 (interactive "p")
eec82323
LMI
8857 (let ((skip 1)
8858 error header ref)
8859 (when (not (natnump n))
8860 (setq skip (abs n)
8861 n 1))
8862 (while (and (> n 0)
8863 (not error))
8864 (setq header (gnus-summary-article-header))
8865 (if (and (eq (mail-header-number header)
8866 (cdr gnus-article-current))
8867 (equal gnus-newsgroup-name
8868 (car gnus-article-current)))
8869 ;; If we try to find the parent of the currently
8870 ;; displayed article, then we take a look at the actual
8871 ;; References header, since this is slightly more
8872 ;; reliable than the References field we got from the
8873 ;; server.
c7a91ce1 8874 (with-current-buffer gnus-original-article-buffer
eec82323
LMI
8875 (nnheader-narrow-to-headers)
8876 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8877 (when (setq ref (message-fetch-field "in-reply-to"))
8878 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8879 (widen))
8880 (setq ref
8881 ;; It's not the current article, so we take a bet on
8882 ;; the value we got from the server.
8883 (mail-header-references header)))
8884 (if (and ref
8885 (not (equal ref "")))
8886 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8887 (gnus-message 1 "Couldn't find parent"))
8888 (gnus-message 1 "No references in article %d"
8889 (gnus-summary-article-number))
8890 (setq error t))
8891 (decf n))
8892 (gnus-summary-position-point)
8893 n))
8894
8895(defun gnus-summary-refer-references ()
8896 "Fetch all articles mentioned in the References header.
6748645f 8897Return the number of articles fetched."
eec82323 8898 (interactive)
eec82323
LMI
8899 (let ((ref (mail-header-references (gnus-summary-article-header)))
8900 (current (gnus-summary-article-number))
8901 (n 0))
8902 (if (or (not ref)
8903 (equal ref ""))
8904 (error "No References in the current article")
8905 ;; For each Message-ID in the References header...
8906 (while (string-match "<[^>]*>" ref)
8907 (incf n)
8908 ;; ... fetch that article.
8909 (gnus-summary-refer-article
8910 (prog1 (match-string 0 ref)
8911 (setq ref (substring ref (match-end 0))))))
8912 (gnus-summary-goto-subject current)
8913 (gnus-summary-position-point)
8914 n)))
8915
6748645f
LMI
8916(defun gnus-summary-refer-thread (&optional limit)
8917 "Fetch all articles in the current thread.
030158f3
G
8918If no backend-specific 'request-thread function is available
8919fetch LIMIT (the numerical prefix) old headers. If LIMIT is nil
8920fetch what's specified by the `gnus-refer-thread-limit'
8921variable."
6748645f 8922 (interactive "P")
4ddab346 8923 (gnus-warp-to-article)
70041e9a
G
8924 (let* ((header (gnus-summary-article-header))
8925 (id (mail-header-id header))
8926 (gnus-inhibit-demon t)
8927 (gnus-summary-ignore-duplicates t)
8928 (gnus-read-all-available-headers t)
8929 (limit (if limit (prefix-numeric-value limit)
8930 gnus-refer-thread-limit)))
4ddab346
G
8931 (setq gnus-newsgroup-headers
8932 (gnus-merge
8933 'list gnus-newsgroup-headers
8934 (if (gnus-check-backend-function
8935 'request-thread gnus-newsgroup-name)
70041e9a 8936 (gnus-request-thread header)
4ddab346 8937 (let* ((last (if (numberp limit)
70041e9a 8938 (min (+ (mail-header-number header)
4ddab346
G
8939 limit)
8940 gnus-newsgroup-highest)
8941 gnus-newsgroup-highest))
8942 (subject (gnus-simplify-subject
70041e9a
G
8943 (mail-header-subject header)))
8944 (refs (split-string (or (mail-header-references header)
4ddab346
G
8945 "")))
8946 (gnus-parse-headers-hook
8947 (lambda () (goto-char (point-min))
8948 (keep-lines
8949 (regexp-opt (append refs (list id subject)))))))
8950 (gnus-fetch-headers (list last) (if (numberp limit)
8951 (* 2 limit) limit) t)))
8952 'gnus-article-sort-by-number))
6748645f
LMI
8953 (gnus-summary-limit-include-thread id)))
8954
16409b0b
GM
8955(defun gnus-summary-refer-article (message-id)
8956 "Fetch an article specified by MESSAGE-ID."
8957 (interactive "sMessage-ID: ")
eec82323
LMI
8958 (when (and (stringp message-id)
8959 (not (zerop (length message-id))))
23f87bed 8960 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8961 ;; Construct the correct Message-ID if necessary.
8962 ;; Suggested by tale@pawl.rpi.edu.
8963 (unless (string-match "^<" message-id)
8964 (setq message-id (concat "<" message-id)))
8965 (unless (string-match ">$" message-id)
8966 (setq message-id (concat message-id ">")))
23f87bed
MB
8967 ;; People often post MIDs from URLs, so unhex it:
8968 (unless (string-match "@" message-id)
8969 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8970 (let* ((header (gnus-id-to-header message-id))
8971 (sparse (and header
8972 (gnus-summary-article-sparse-p
a8151ef7
LMI
8973 (mail-header-number header))
8974 (memq (mail-header-number header)
16409b0b
GM
8975 gnus-newsgroup-limit)))
8976 number)
6748645f
LMI
8977 (cond
8978 ;; If the article is present in the buffer we just go to it.
8979 ((and header
8980 (or (not (gnus-summary-article-sparse-p
8981 (mail-header-number header)))
8982 sparse))
8983 (prog1
8984 (gnus-summary-goto-article
8985 (mail-header-number header) nil t)
8986 (when sparse
8987 (gnus-summary-update-article (mail-header-number header)))))
8988 (t
16409b0b
GM
8989 ;; We fetch the article.
8990 (catch 'found
8991 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8992 (when (and (gnus-check-server gnus-override-method)
8993 ;; Fetch the header,
8994 (setq number (gnus-summary-insert-subject message-id)))
8995 ;; and display the article.
eec82323 8996 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8997 (throw 'found t)))
8998 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8999
9000(defun gnus-refer-article-methods ()
8f688cb0 9001 "Return a list of referable methods."
16409b0b
GM
9002 (cond
9003 ;; No method, so we default to current and native.
9004 ((null gnus-refer-article-method)
9005 (list gnus-current-select-method gnus-select-method))
9006 ;; Current.
9007 ((eq 'current gnus-refer-article-method)
9008 (list gnus-current-select-method))
9009 ;; List of select methods.
d4dfaa19
DL
9010 ((not (and (symbolp (car gnus-refer-article-method))
9011 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
9012 (let (out)
9013 (dolist (method gnus-refer-article-method)
9014 (push (if (eq 'current method)
9015 gnus-current-select-method
9016 method)
9017 out))
9018 (nreverse out)))
9019 ;; One single select method.
9020 (t
9021 (list gnus-refer-article-method))))
6748645f
LMI
9022
9023(defun gnus-summary-edit-parameters ()
9024 "Edit the group parameters of the current group."
9025 (interactive)
9026 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 9027
16409b0b
GM
9028(defun gnus-summary-customize-parameters ()
9029 "Customize the group parameters of the current group."
9030 (interactive)
9031 (gnus-group-customize gnus-newsgroup-name))
9032
eec82323
LMI
9033(defun gnus-summary-enter-digest-group (&optional force)
9034 "Enter an nndoc group based on the current article.
07176b2a
LMI
9035If FORCE, force a digest interpretation. If not, try to guess
9036what the document format is.
9037
9038To control what happens when you exit the group, see the
9039`gnus-auto-select-on-ephemeral-exit' variable."
eec82323 9040 (interactive "P")
eec82323 9041 (let ((conf gnus-current-window-configuration))
23f87bed
MB
9042 (save-window-excursion
9043 (save-excursion
9044 (let (gnus-article-prepare-hook
9045 gnus-display-mime-function
9046 gnus-break-pages)
9047 (gnus-summary-select-article))))
eec82323
LMI
9048 (setq gnus-current-window-configuration conf)
9049 (let* ((name (format "%s-%d"
9050 (gnus-group-prefixed-name
9051 gnus-newsgroup-name (list 'nndoc ""))
01c52d31 9052 (with-current-buffer gnus-summary-buffer
eec82323
LMI
9053 gnus-current-article)))
9054 (ogroup gnus-newsgroup-name)
9055 (params (append (gnus-info-params (gnus-get-info ogroup))
9056 (list (cons 'to-group ogroup))
23f87bed 9057 (list (cons 'parent-group ogroup))
eec82323
LMI
9058 (list (cons 'save-article-group ogroup))))
9059 (case-fold-search t)
9060 (buf (current-buffer))
16409b0b 9061 dig to-address)
c7a91ce1 9062 (with-current-buffer gnus-original-article-buffer
16409b0b
GM
9063 ;; Have the digest group inherit the main mail address of
9064 ;; the parent article.
23f87bed
MB
9065 (when (setq to-address (or (gnus-fetch-field "reply-to")
9066 (gnus-fetch-field "from")))
343d6628
MB
9067 (setq params
9068 (append
9069 (list (cons 'to-address
9070 (funcall gnus-decode-encoded-address-function
9071 to-address))))))
eec82323
LMI
9072 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9073 (insert-buffer-substring gnus-original-article-buffer)
9074 ;; Remove lines that may lead nndoc to misinterpret the
9075 ;; document type.
9076 (narrow-to-region
9077 (goto-char (point-min))
9078 (or (search-forward "\n\n" nil t) (point)))
9079 (goto-char (point-min))
16409b0b 9080 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
9081 (widen))
9082 (unwind-protect
23f87bed 9083 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
9084 (gnus-newsgroup-ephemeral-ignored-charsets
9085 gnus-newsgroup-ignored-charsets))
9086 (gnus-group-read-ephemeral-group
9087 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9088 (nndoc-article-type
23f87bed
MB
9089 ,(if force 'mbox 'guess)))
9090 t nil nil nil
9091 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9092 "ADAPT")))))
16409b0b 9093 ;; Make all postings to this group go to the parent group.
23f87bed
MB
9094 (nconc (gnus-info-params (gnus-get-info name))
9095 params)
9096 ;; Couldn't select this doc group.
9097 (switch-to-buffer buf)
9098 (gnus-set-global-variables)
9099 (gnus-configure-windows 'summary)
9100 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
9101 (kill-buffer dig)))))
9102
9103(defun gnus-summary-read-document (n)
9104 "Open a new group based on the current article(s).
9105This will allow you to read digests and other similar
9106documents as newsgroups.
9107Obeys the standard process/prefix convention."
9108 (interactive "P")
01c52d31 9109 (let* ((ogroup gnus-newsgroup-name)
eec82323
LMI
9110 (params (append (gnus-info-params (gnus-get-info ogroup))
9111 (list (cons 'to-group ogroup))))
01c52d31
MB
9112 group egroup groups vgroup)
9113 (dolist (article (gnus-summary-work-articles n))
eec82323
LMI
9114 (setq group (format "%s-%d" gnus-newsgroup-name article))
9115 (gnus-summary-remove-process-mark article)
9116 (when (gnus-summary-display-article article)
398a825b 9117 (save-excursion ;;What for?
16409b0b 9118 (with-temp-buffer
eec82323
LMI
9119 (insert-buffer-substring gnus-original-article-buffer)
9120 ;; Remove some headers that may lead nndoc to make
9121 ;; the wrong guess.
9122 (message-narrow-to-head)
9123 (goto-char (point-min))
01c52d31 9124 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
9125 (widen)
9126 (if (setq egroup
9127 (gnus-group-read-ephemeral-group
9128 group `(nndoc ,group (nndoc-address ,(current-buffer))
9129 (nndoc-article-type guess))
9130 t nil t))
9131 (progn
c7a91ce1 9132 ;; Make all postings to this group go to the parent group.
eec82323
LMI
9133 (nconc (gnus-info-params (gnus-get-info egroup))
9134 params)
9135 (push egroup groups))
9136 ;; Couldn't select this doc group.
9137 (gnus-error 3 "Article couldn't be entered"))))))
9138 ;; Now we have selected all the documents.
9139 (cond
9140 ((not groups)
9141 (error "None of the articles could be interpreted as documents"))
9142 ((gnus-group-read-ephemeral-group
9143 (setq vgroup (format
9144 "nnvirtual:%s-%s" gnus-newsgroup-name
9145 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9146 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9147 t
9148 (cons (current-buffer) 'summary)))
9149 (t
9150 (error "Couldn't select virtual nndoc group")))))
9151
d50717f0
JD
9152(defun gnus-summary-widget-forward (arg)
9153 "Move point to the next field or button in the article.
9154With optional ARG, move across that many fields."
9155 (interactive "p")
9156 (gnus-summary-select-article)
9157 (gnus-configure-windows 'article)
9158 (select-window (gnus-get-buffer-window gnus-article-buffer))
9159 (widget-forward arg))
9160
eec82323
LMI
9161(defun gnus-summary-isearch-article (&optional regexp-p)
9162 "Do incremental search forward on the current article.
9163If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9164 (interactive "P")
eec82323
LMI
9165 (gnus-summary-select-article)
9166 (gnus-configure-windows 'article)
9167 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
9168 (save-restriction
9169 (widen)
9170 (isearch-forward regexp-p))))
eec82323 9171
01c52d31
MB
9172(defun gnus-summary-repeat-search-article-forward ()
9173 "Repeat the previous search forwards."
9174 (interactive)
9175 (unless gnus-last-search-regexp
9176 (error "No previous search"))
9177 (gnus-summary-search-article-forward gnus-last-search-regexp))
9178
9179(defun gnus-summary-repeat-search-article-backward ()
9180 "Repeat the previous search backwards."
9181 (interactive)
9182 (unless gnus-last-search-regexp
9183 (error "No previous search"))
9184 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9185
eec82323
LMI
9186(defun gnus-summary-search-article-forward (regexp &optional backward)
9187 "Search for an article containing REGEXP forward.
9188If BACKWARD, search backward instead."
9189 (interactive
9190 (list (read-string
9191 (format "Search article %s (regexp%s): "
9192 (if current-prefix-arg "backward" "forward")
9193 (if gnus-last-search-regexp
9194 (concat ", default " gnus-last-search-regexp)
9195 "")))
9196 current-prefix-arg))
eec82323
LMI
9197 (if (string-equal regexp "")
9198 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
9199 (setq gnus-last-search-regexp regexp)
9200 (setq gnus-article-before-search gnus-current-article))
9201 ;; Intentionally set gnus-last-article.
9202 (setq gnus-last-article gnus-article-before-search)
9203 (let ((gnus-last-article gnus-last-article))
9204 (if (gnus-summary-search-article regexp backward)
9205 (gnus-summary-show-thread)
abc40aab 9206 (signal 'search-failed (list regexp)))))
eec82323
LMI
9207
9208(defun gnus-summary-search-article-backward (regexp)
9209 "Search for an article containing REGEXP backward."
9210 (interactive
9211 (list (read-string
9212 (format "Search article backward (regexp%s): "
9213 (if gnus-last-search-regexp
9214 (concat ", default " gnus-last-search-regexp)
9215 "")))))
9216 (gnus-summary-search-article-forward regexp 'backward))
9217
9218(defun gnus-summary-search-article (regexp &optional backward)
9219 "Search for an article containing REGEXP.
9220Optional argument BACKWARD means do search for backward.
9221`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
9222 ;; We have to require this here to make sure that the following
9223 ;; dynamic binding isn't shadowed by autoloading.
9224 (require 'gnus-async)
16409b0b 9225 (require 'gnus-art)
eec82323 9226 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 9227 (gnus-article-prepare-hook nil)
eec82323
LMI
9228 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9229 (gnus-use-article-prefetch nil)
9230 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 9231 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
9232 (gnus-visual nil)
9233 (gnus-keep-backlog nil)
9234 (gnus-break-pages nil)
9235 (gnus-summary-display-arrow nil)
9236 (gnus-updated-mode-lines nil)
9237 (gnus-auto-center-summary nil)
eec82323 9238 (sum (current-buffer))
16409b0b 9239 (gnus-display-mime-function nil)
eec82323
LMI
9240 (found nil)
9241 point)
9242 (gnus-save-hidden-threads
9243 (gnus-summary-select-article)
9244 (set-buffer gnus-article-buffer)
16409b0b 9245 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
9246 (when backward
9247 (forward-line -1))
9248 (while (not found)
9249 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9250 (if (if backward
9251 (re-search-backward regexp nil t)
9252 (re-search-forward regexp nil t))
9253 ;; We found the regexp.
9254 (progn
9255 (setq found 'found)
9256 (beginning-of-line)
9257 (set-window-start
9258 (get-buffer-window (current-buffer))
9259 (point))
9260 (forward-line 1)
16409b0b
GM
9261 (set-window-point
9262 (get-buffer-window (current-buffer))
9263 (point))
eec82323
LMI
9264 (set-buffer sum)
9265 (setq point (point)))
9266 ;; We didn't find it, so we go to the next article.
9267 (set-buffer sum)
9268 (setq found 'not)
9269 (while (eq found 'not)
9270 (if (not (if backward (gnus-summary-find-prev)
9271 (gnus-summary-find-next)))
9272 ;; No more articles.
9273 (setq found t)
9274 ;; Select the next article and adjust point.
9275 (unless (gnus-summary-article-sparse-p
9276 (gnus-summary-article-number))
9277 (setq found nil)
9278 (gnus-summary-select-article)
9279 (set-buffer gnus-article-buffer)
9280 (widen)
9281 (goto-char (if backward (point-max) (point-min))))))))
9282 (gnus-message 7 ""))
9283 ;; Return whether we found the regexp.
9284 (when (eq found 'found)
9285 (goto-char point)
9286 (gnus-summary-show-thread)
9287 (gnus-summary-goto-subject gnus-current-article)
9288 (gnus-summary-position-point)
9289 t)))
9290
23f87bed
MB
9291(defun gnus-find-matching-articles (header regexp)
9292 "Return a list of all articles that match REGEXP on HEADER.
9293This search includes all articles in the current group that Gnus has
9294fetched headers for, whether they are displayed or not."
9295 (let ((articles nil)
c7a91ce1 9296 ;; Can't eta-reduce because it's a macro.
23f87bed
MB
9297 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9298 (case-fold-search t))
9299 (dolist (header gnus-newsgroup-headers)
9300 (when (string-match regexp (funcall func header))
9301 (push (mail-header-number header) articles)))
9302 (nreverse articles)))
9303
eec82323 9304(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 9305 not-case-fold not-matching)
eec82323
LMI
9306 "Return a list of all articles that match REGEXP on HEADER.
9307The search stars on the current article and goes forwards unless
9308BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9309If UNREAD is non-nil, only unread articles will
9310be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 9311in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
9312not match REGEXP on HEADER."
9313 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
9314 articles d func)
9315 (if (consp header)
9316 (if (eq (car header) 'extra)
9317 (setq func
9318 `(lambda (h)
9319 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9320 "")))
9321 (error "%s is an invalid header" header))
9322 (unless (fboundp (intern (concat "mail-header-" header)))
9323 (error "%s is not a valid header" header))
9324 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
9325 (dolist (d (if (eq backward 'all)
9326 gnus-newsgroup-data
9327 (gnus-data-find-list
9328 (gnus-summary-article-number)
9329 (gnus-data-list backward))))
9330 (when (and (or (not unread) ; We want all articles...
9331 (gnus-data-unread-p d)) ; Or just unreads.
9332 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9333 (if not-matching
a1506d29 9334 (not (string-match
47b63dfa
SZ
9335 regexp
9336 (funcall func (gnus-data-header d))))
9337 (string-match regexp
9338 (funcall func (gnus-data-header d)))))
9339 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
9340 (nreverse articles)))
9341
9342(defun gnus-summary-execute-command (header regexp command &optional backward)
9343 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9344If HEADER is an empty string (or nil), the match is done on the entire
9345article. If BACKWARD (the prefix) is non-nil, search backward instead."
9346 (interactive
9347 (list (let ((completion-ignore-case t))
229b59da
G
9348 (gnus-completing-read
9349 "Header name"
9350 (mapcar 'symbol-name
23f87bed 9351 (append
229b59da
G
9352 '(Number Subject From Lines Date
9353 Message-ID Xref References Body)
23f87bed 9354 gnus-extra-headers))
229b59da 9355 'require-match))
eec82323
LMI
9356 (read-string "Regexp: ")
9357 (read-key-sequence "Command: ")
9358 current-prefix-arg))
9359 (when (equal header "Body")
9360 (setq header ""))
eec82323
LMI
9361 ;; Hidden thread subtrees must be searched as well.
9362 (gnus-summary-show-all-threads)
9363 ;; We don't want to change current point nor window configuration.
9364 (save-excursion
9365 (save-window-excursion
23f87bed
MB
9366 (let (gnus-visual
9367 gnus-treat-strip-trailing-blank-lines
9368 gnus-treat-strip-leading-blank-lines
9369 gnus-treat-strip-multiple-blank-lines
9370 gnus-treat-hide-boring-headers
9371 gnus-treat-fold-newsgroups
9372 gnus-article-prepare-hook)
9373 (gnus-message 6 "Executing %s..." (key-description command))
9374 ;; We'd like to execute COMMAND interactively so as to give arguments.
9375 (gnus-execute header regexp
9376 `(call-interactively ',(key-binding command))
9377 backward)
9378 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
9379
9380(defun gnus-summary-beginning-of-article ()
9381 "Scroll the article back to the beginning."
9382 (interactive)
eec82323
LMI
9383 (gnus-summary-select-article)
9384 (gnus-configure-windows 'article)
9385 (gnus-eval-in-buffer-window gnus-article-buffer
9386 (widen)
9387 (goto-char (point-min))
23f87bed 9388 (when gnus-break-pages
eec82323
LMI
9389 (gnus-narrow-to-page))))
9390
9391(defun gnus-summary-end-of-article ()
9392 "Scroll to the end of the article."
9393 (interactive)
eec82323
LMI
9394 (gnus-summary-select-article)
9395 (gnus-configure-windows 'article)
9396 (gnus-eval-in-buffer-window gnus-article-buffer
9397 (widen)
9398 (goto-char (point-max))
9399 (recenter -3)
23f87bed 9400 (when gnus-break-pages
eec82323
LMI
9401 (gnus-narrow-to-page))))
9402
23f87bed
MB
9403(defun gnus-summary-print-truncate-and-quote (string &optional len)
9404 "Truncate to LEN and quote all \"(\"'s in STRING."
9405 (gnus-replace-in-string (if (and len (> (length string) len))
9406 (substring string 0 len)
9407 string)
9408 "[()]" "\\\\\\&"))
9409
6748645f 9410(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
9411 "Generate and print a PostScript image of the process-marked (mail) articles.
9412
9413If used interactively, print the current article if none are
9414process-marked. With prefix arg, prompt the user for the name of the
9415file to save in.
6748645f 9416
23f87bed
MB
9417When used from Lisp, accept two optional args FILENAME and N. N means
9418to print the next N articles. If N is negative, print the N previous
9419articles. If N is nil and articles have been marked with the process
9420mark, print these instead.
eec82323 9421
16409b0b 9422If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
9423printer. If FILENAME is a string, save the PostScript image in a file with
9424that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 9425to save in."
676a7cc9 9426 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
9427 (dolist (article (gnus-summary-work-articles n))
9428 (gnus-summary-select-article nil nil 'pseudo article)
9429 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 9430 (gnus-print-buffer))
676a7cc9
SZ
9431 (gnus-summary-remove-process-mark article))
9432 (ps-despool filename))
eec82323 9433
23f87bed 9434(defun gnus-print-buffer ()
285cf7c8
LMI
9435 (let ((ps-left-header
9436 (list
9437 (concat "("
9438 (gnus-summary-print-truncate-and-quote
9439 (mail-header-subject gnus-current-headers)
9440 66) ")")
9441 (concat "("
9442 (gnus-summary-print-truncate-and-quote
9443 (mail-header-from gnus-current-headers)
9444 45) ")")))
9445 (ps-right-header
9446 (list
9447 "/pagenumberstring load"
9448 (concat "("
9449 (mail-header-date gnus-current-headers) ")"))))
9450 (gnus-run-hooks 'gnus-ps-print-hook)
9451 (save-excursion
9452 (if ps-print-color-p
9453 (ps-spool-buffer-with-faces)
9454 (ps-spool-buffer)))))
23f87bed 9455
8ccbef23
G
9456(defun gnus-summary-show-complete-article ()
9457 "Show a complete version of the current article.
9458This is only useful if you're looking at a partial version of the
9459article currently."
9460 (interactive)
9461 (let ((gnus-keep-backlog nil)
9462 (gnus-use-cache nil)
9463 (gnus-agent nil)
9f2d52e7
G
9464 (variable (intern
9465 (format "%s-fetch-partial-articles"
9466 (car (gnus-find-method-for-group
9467 gnus-newsgroup-name)))
9468 obarray))
9469 old-val)
9470 (unwind-protect
9471 (progn
9472 (setq old-val (symbol-value variable))
9473 (set variable nil)
9474 (gnus-flush-original-article-buffer)
9475 (gnus-summary-show-article))
9476 (set variable old-val))))
8ccbef23 9477
eec82323 9478(defun gnus-summary-show-article (&optional arg)
23f87bed 9479 "Force redisplaying of the current article.
16409b0b
GM
9480If ARG (the prefix) is a number, show the article with the charset
9481defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 9482input.
389b76fa
G
9483If ARG (the prefix) is non-nil and not a number, show the article,
9484but without running any of the article treatment functions
9485article. Normally, the keystroke is `C-u g'. When using `C-u
9486C-u g', show the raw article."
eec82323 9487 (interactive "P")
16409b0b
GM
9488 (cond
9489 ((numberp arg)
23f87bed 9490 (gnus-summary-show-article t)
16409b0b
GM
9491 (let ((gnus-newsgroup-charset
9492 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
9493 (mm-read-coding-system
9494 "View as charset: " ;; actually it is coding system.
01c52d31 9495 (with-current-buffer gnus-article-buffer
23f87bed 9496 (mm-detect-coding-region (point) (point-max))))))
16409b0b 9497 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
9498 (gnus-summary-select-article nil 'force)
9499 (let ((deps gnus-newsgroup-dependencies)
9500 head header lines)
c7a91ce1 9501 (with-current-buffer gnus-original-article-buffer
23f87bed
MB
9502 (save-restriction
9503 (message-narrow-to-head)
9504 (setq head (buffer-string))
9505 (goto-char (point-min))
9506 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9507 (goto-char (point-max))
9508 (widen)
9509 (setq lines (1- (count-lines (point) (point-max))))))
9510 (with-temp-buffer
9511 (insert (format "211 %d Article retrieved.\n"
9512 (cdr gnus-article-current)))
9513 (insert head)
9514 (if lines (insert (format "Lines: %d\n" lines)))
9515 (insert ".\n")
9516 (let ((nntp-server-buffer (current-buffer)))
9517 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9518 (gnus-data-set-header
9519 (gnus-data-find (cdr gnus-article-current))
9520 header)
9521 (gnus-summary-update-article-line
9522 (cdr gnus-article-current) header)
9523 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9524 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
9525 ((not arg)
9526 ;; Select the article the normal way.
9527 (gnus-summary-select-article nil 'force))
8e22bee0 9528 ((equal arg '(16))
389b76fa 9529 ;; C-u C-u g
04db63bc
G
9530 (let ((gnus-inhibit-article-treatments t))
9531 (gnus-summary-select-article nil 'force)))
9532 (t
16409b0b
GM
9533 ;; We have to require this here to make sure that the following
9534 ;; dynamic binding isn't shadowed by autoloading.
9535 (require 'gnus-async)
9536 (require 'gnus-art)
eec82323
LMI
9537 ;; Bind the article treatment functions to nil.
9538 (let ((gnus-have-all-headers t)
eec82323 9539 gnus-article-prepare-hook
16409b0b
GM
9540 gnus-article-decode-hook
9541 gnus-display-mime-function
9542 gnus-break-pages)
9543 ;; Destroy any MIME parts.
9544 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 9545 (with-current-buffer gnus-article-buffer
16409b0b
GM
9546 (mm-destroy-parts gnus-article-mime-handles)
9547 ;; Set it to nil for safety reason.
9548 (setq gnus-article-mime-handle-alist nil)
9549 (setq gnus-article-mime-handles nil)))
9550 (gnus-summary-select-article nil 'force))))
eec82323
LMI
9551 (gnus-summary-goto-subject gnus-current-article)
9552 (gnus-summary-position-point))
9553
23f87bed
MB
9554(defun gnus-summary-show-raw-article ()
9555 "Show the raw article without any article massaging functions being run."
9556 (interactive)
9557 (gnus-summary-show-article t))
9558
eec82323
LMI
9559(defun gnus-summary-verbose-headers (&optional arg)
9560 "Toggle permanent full header display.
9561If ARG is a positive number, turn header display on.
9562If ARG is a negative number, turn header display off."
9563 (interactive "P")
eec82323
LMI
9564 (setq gnus-show-all-headers
9565 (cond ((or (not (numberp arg))
9566 (zerop arg))
9567 (not gnus-show-all-headers))
9568 ((natnump arg)
9569 t)))
9570 (gnus-summary-show-article))
9571
9572(defun gnus-summary-toggle-header (&optional arg)
9573 "Show the headers if they are hidden, or hide them if they are shown.
9574If ARG is a positive number, show the entire header.
9575If ARG is a negative number, hide the unwanted header lines."
9576 (interactive "P")
23f87bed
MB
9577 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9578 (get-buffer-window gnus-article-buffer t))))
9579 (with-current-buffer gnus-article-buffer
9580 (widen)
9581 (article-narrow-to-head)
c7a91ce1 9582 (let* ((inhibit-read-only t)
16409b0b 9583 (inhibit-point-motion-hooks t)
23f87bed
MB
9584 (hidden (if (numberp arg)
9585 (>= arg 0)
f0096211
MB
9586 (or (not (looking-at "[^ \t\n]+:"))
9587 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
9588 s e)
9589 (delete-region (point-min) (point-max))
667e0ba6
SM
9590 (with-current-buffer gnus-original-article-buffer
9591 (goto-char (setq s (point-min)))
23f87bed
MB
9592 (setq e (if (search-forward "\n\n" nil t)
9593 (1- (point))
9594 (point-max))))
667e0ba6 9595 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
9596 (run-hooks 'gnus-article-decode-hook)
9597 (if hidden
9598 (let ((gnus-treat-hide-headers nil)
9599 (gnus-treat-hide-boring-headers nil))
9600 (gnus-delete-wash-type 'headers)
9601 (gnus-treat-article 'head))
9602 (gnus-treat-article 'head))
9603 (widen)
9604 (if window
9605 (set-window-start window (goto-char (point-min))))
9606 (if gnus-break-pages
9607 (gnus-narrow-to-page)
9608 (when (gnus-visual-p 'page-marker)
c7a91ce1 9609 (let ((inhibit-read-only t))
23f87bed
MB
9610 (gnus-remove-text-with-property 'gnus-prev)
9611 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9612 (gnus-set-mode-line 'article)))))
eec82323
LMI
9613
9614(defun gnus-summary-show-all-headers ()
9615 "Make all header lines visible."
9616 (interactive)
23f87bed 9617 (gnus-summary-toggle-header 1))
eec82323 9618
eec82323
LMI
9619(defun gnus-summary-caesar-message (&optional arg)
9620 "Caesar rotate the current article by 13.
01c52d31
MB
9621With a non-numerical prefix, also rotate headers. A numerical
9622prefix specifies how many places to rotate each letter forward."
eec82323 9623 (interactive "P")
eec82323
LMI
9624 (gnus-summary-select-article)
9625 (let ((mail-header-separator ""))
9626 (gnus-eval-in-buffer-window gnus-article-buffer
9627 (save-restriction
9628 (widen)
9629 (let ((start (window-start))
c7a91ce1 9630 (inhibit-read-only t))
01c52d31
MB
9631 (if (equal arg '(4))
9632 (message-caesar-buffer-body nil t)
9633 (message-caesar-buffer-body arg))
ff4d3926
MB
9634 (set-window-start (get-buffer-window (current-buffer)) start)))))
9635 ;; Create buttons and stuff...
9636 (gnus-treat-article nil))
eec82323 9637
704f1663
GM
9638(declare-function idna-to-unicode "ext:idna" (str))
9639
01c52d31
MB
9640(defun gnus-summary-idna-message (&optional arg)
9641 "Decode IDNA encoded domain names in the current articles.
9642IDNA encoded domain names looks like `xn--bar'. If a string
9643remain unencoded after running this function, it is likely an
9644invalid IDNA string (`xn--bar' is invalid).
9645
0b10e437 9646You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
01c52d31
MB
9647installed for this command to work."
9648 (interactive "P")
9649 (if (not (and (condition-case nil (require 'idna)
9650 (file-error))
9651 (mm-coding-system-p 'utf-8)
9652 (executable-find (symbol-value 'idna-program))))
9653 (gnus-message
9654 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9655 (gnus-summary-select-article)
9656 (let ((mail-header-separator ""))
9657 (gnus-eval-in-buffer-window gnus-article-buffer
9658 (save-restriction
9659 (widen)
9660 (let ((start (window-start))
9661 buffer-read-only)
9662 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9663 (replace-match (idna-to-unicode (match-string 1))))
9664 (set-window-start (get-buffer-window (current-buffer)) start)))))))
23f87bed
MB
9665
9666(defun gnus-summary-morse-message (&optional arg)
9667 "Morse decode the current article."
9668 (interactive "P")
9669 (gnus-summary-select-article)
9670 (let ((mail-header-separator ""))
9671 (gnus-eval-in-buffer-window gnus-article-buffer
9672 (save-excursion
9673 (save-restriction
9674 (widen)
9675 (let ((pos (window-start))
c7a91ce1 9676 (inhibit-read-only t))
23f87bed
MB
9677 (goto-char (point-min))
9678 (when (message-goto-body)
9679 (gnus-narrow-to-body))
9680 (goto-char (point-min))
01c52d31 9681