Merge from emacs-23
[bpt/emacs.git] / lisp / gnus / gnus-sum.el
CommitLineData
eec82323 1;;; gnus-sum.el --- summary mode commands for Gnus
e84b4b86
TTN
2
3;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5df4f04c 4;; 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
eec82323 5
6748645f 6;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
eec82323
LMI
7;; Keywords: news
8
9;; This file is part of GNU Emacs.
10
5e809f55 11;; GNU Emacs is free software: you can redistribute it and/or modify
eec82323 12;; it under the terms of the GNU General Public License as published by
5e809f55
GM
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
eec82323
LMI
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
01ccbb85 18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eec82323
LMI
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
5e809f55 22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
eec82323
LMI
23
24;;; Commentary:
25
26;;; Code:
27
f0b7f5a8 28;; For Emacs <22.2 and XEmacs.
d09ae6ca
GM
29(eval-and-compile
30 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
23f87bed 31(eval-when-compile
9efa445f 32 (require 'cl))
d029b5d2
KY
33(eval-when-compile
34 (when (featurep 'xemacs)
35 (require 'easy-mmode))) ; for `define-minor-mode'
9efa445f
DN
36
37(defvar tool-bar-mode)
38(defvar gnus-tmp-header)
5ab7173c 39
eec82323
LMI
40(require 'gnus)
41(require 'gnus-group)
42(require 'gnus-spec)
43(require 'gnus-range)
44(require 'gnus-int)
45(require 'gnus-undo)
6748645f 46(require 'gnus-util)
18c06a99 47(require 'gmm-utils)
16409b0b 48(require 'mm-decode)
08c9a385 49(require 'nnoo)
23f87bed 50
6748645f 51(autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
d4dfaa19 52(autoload 'gnus-cache-write-active "gnus-cache")
23f87bed
MB
53(autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
54(autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
531e5812 55(autoload 'gnus-pick-line-number "gnus-salt" nil t)
08c9a385 56(autoload 'mm-uu-dissect "mm-uu")
23f87bed
MB
57(autoload 'gnus-article-outlook-deuglify-article "deuglify"
58 "Deuglify broken Outlook (Express) articles and redisplay."
59 t)
60(autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
61(autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
62(autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
1b811c90
AC
63(autoload 'nnir-article-rsv "nnir" nil nil 'macro)
64(autoload 'nnir-article-group "nnir" nil nil 'macro)
eec82323
LMI
65
66(defcustom gnus-kill-summary-on-exit t
67 "*If non-nil, kill the summary buffer when you exit from it.
68If nil, the summary will become a \"*Dead Summary*\" buffer, and
69it will be killed sometime later."
70 :group 'gnus-summary-exit
71 :type 'boolean)
72
01c52d31
MB
73(defcustom gnus-summary-next-group-on-exit t
74 "If non-nil, go to the next unread newsgroup on summary exit.
75See `gnus-group-goto-unread'."
76 :link '(custom-manual "(gnus)Group Maneuvering")
77 :group 'gnus-summary-exit
330f707b 78 :version "23.1" ;; No Gnus
01c52d31
MB
79 :type 'boolean)
80
b1992461
KY
81(defcustom gnus-summary-stop-at-end-of-message nil
82 "If non-nil, don't select the next message when using `SPC'."
83 :link '(custom-manual "(gnus)Group Maneuvering")
84 :group 'gnus-summary-maneuvering
1a10d421 85 :version "24.1"
b1992461
KY
86 :type 'boolean)
87
eec82323
LMI
88(defcustom gnus-fetch-old-headers nil
89 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
01c52d31
MB
90If an unread article in the group refers to an older, already
91read (or just marked as read) article, the old article will not
92normally be displayed in the Summary buffer. If this variable is
93t, Gnus will attempt to grab the headers to the old articles, and
94thereby build complete threads. If it has the value `some', all
95old headers will be fetched but only enough headers to connect
96otherwise loose threads will be displayed. This variable can
97also be a number. In that case, no more than that number of old
98headers will be fetched. If it has the value `invisible', all
6748645f 99old headers will be fetched, but none will be displayed.
eec82323 100
01c52d31
MB
101The server has to support NOV for any of this to work.
102
103This feature can seriously impact performance it ignores all
f394fa25
MB
104locally cached header entries. Setting it to t for groups for a
105server that doesn't expire articles (such as news.gmane.org),
106leads to very slow summary generation."
eec82323
LMI
107 :group 'gnus-thread
108 :type '(choice (const :tag "off" nil)
1232b9cb 109 (const :tag "on" t)
eec82323 110 (const some)
1232b9cb 111 (const invisible)
eec82323
LMI
112 number
113 (sexp :menu-tag "other" t)))
114
01c52d31 115(defcustom gnus-refer-thread-limit 500
6748645f
LMI
116 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
117If t, fetch all the available old headers."
118 :group 'gnus-thread
119 :type '(choice number
120 (sexp :menu-tag "other" t)))
121
eec82323
LMI
122(defcustom gnus-summary-make-false-root 'adopt
123 "*nil means that Gnus won't gather loose threads.
124If the root of a thread has expired or been read in a previous
125session, the information necessary to build a complete thread has been
126lost. Instead of having many small sub-threads from this original thread
127scattered all over the summary buffer, Gnus can gather them.
128
129If non-nil, Gnus will try to gather all loose sub-threads from an
130original thread into one large thread.
131
132If this variable is non-nil, it should be one of `none', `adopt',
133`dummy' or `empty'.
134
135If this variable is `none', Gnus will not make a false root, but just
136present the sub-threads after another.
137If this variable is `dummy', Gnus will create a dummy root that will
138have all the sub-threads as children.
139If this variable is `adopt', Gnus will make one of the \"children\"
140the parent and mark all the step-children as such.
141If this variable is `empty', the \"children\" are printed with empty
01ccbb85 142subject fields. (Or rather, they will be printed with a string
eec82323
LMI
143given by the `gnus-summary-same-subject' variable.)"
144 :group 'gnus-thread
145 :type '(choice (const :tag "off" nil)
146 (const none)
147 (const dummy)
148 (const adopt)
149 (const empty)))
150
23f87bed
MB
151(defcustom gnus-summary-make-false-root-always nil
152 "Always make a false dummy root."
bf247b6e 153 :version "22.1"
23f87bed
MB
154 :group 'gnus-thread
155 :type 'boolean)
156
eec82323
LMI
157(defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
158 "*A regexp to match subjects to be excluded from loose thread gathering.
159As loose thread gathering is done on subjects only, that means that
160there can be many false gatherings performed. By rooting out certain
161common subjects, gathering might become saner."
162 :group 'gnus-thread
163 :type 'regexp)
164
165(defcustom gnus-summary-gather-subject-limit nil
166 "*Maximum length of subject comparisons when gathering loose threads.
167Use nil to compare full subjects. Setting this variable to a low
168number will help gather threads that have been corrupted by
169newsreaders chopping off subject lines, but it might also mean that
170unrelated articles that have subject that happen to begin with the
171same few characters will be incorrectly gathered.
172
173If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
174comparing subjects."
175 :group 'gnus-thread
176 :type '(choice (const :tag "off" nil)
177 (const fuzzy)
178 (sexp :menu-tag "on" t)))
179
6748645f
LMI
180(defcustom gnus-simplify-subject-functions nil
181 "List of functions taking a string argument that simplify subjects.
182The functions are applied recursively.
183
23f87bed
MB
184Useful functions to put in this list include:
185`gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
186`gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
6748645f
LMI
187 :group 'gnus-thread
188 :type '(repeat function))
189
eec82323 190(defcustom gnus-simplify-ignored-prefixes nil
23f87bed 191 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
eec82323
LMI
192 :group 'gnus-thread
193 :type '(choice (const :tag "off" nil)
194 regexp))
195
196(defcustom gnus-build-sparse-threads nil
197 "*If non-nil, fill in the gaps in threads.
198If `some', only fill in the gaps that are needed to tie loose threads
199together. If `more', fill in all leaf nodes that Gnus can find. If
200non-nil and non-`some', fill in all gaps that Gnus manages to guess."
201 :group 'gnus-thread
202 :type '(choice (const :tag "off" nil)
203 (const some)
204 (const more)
205 (sexp :menu-tag "all" t)))
206
207(defcustom gnus-summary-thread-gathering-function
208 'gnus-gather-threads-by-subject
6748645f 209 "*Function used for gathering loose threads.
eec82323
LMI
210There are two pre-defined functions: `gnus-gather-threads-by-subject',
211which only takes Subjects into consideration; and
212`gnus-gather-threads-by-references', which compared the References
213headers of the articles to find matches."
214 :group 'gnus-thread
22115a9e
RS
215 :type '(radio (function-item gnus-gather-threads-by-subject)
216 (function-item gnus-gather-threads-by-references)
217 (function :tag "other")))
eec82323 218
eec82323
LMI
219(defcustom gnus-summary-same-subject ""
220 "*String indicating that the current article has the same subject as the previous.
221This variable will only be used if the value of
222`gnus-summary-make-false-root' is `empty'."
223 :group 'gnus-summary-format
224 :type 'string)
225
1d297c49 226(defcustom gnus-summary-goto-unread nil
16409b0b
GM
227 "*If t, many commands will go to the next unread article.
228This applies to marking commands as well as other commands that
229\"naturally\" select the next article, like, for instance, `SPC' at
230the end of an article.
231
232If nil, the marking commands do NOT go to the next unread article
2642ac8f 233\(they go to the next article instead). If `never', commands that
16409b0b
GM
234usually go to the next unread article, will go to the next article,
235whether it is read or not."
1d297c49 236 :version "24.1"
eec82323
LMI
237 :group 'gnus-summary-marks
238 :link '(custom-manual "(gnus)Setting Marks")
239 :type '(choice (const :tag "off" nil)
240 (const never)
241 (sexp :menu-tag "on" t)))
242
243(defcustom gnus-summary-default-score 0
244 "*Default article score level.
245All scores generated by the score files will be added to this score.
246If this variable is nil, scoring will be disabled."
247 :group 'gnus-score-default
248 :type '(choice (const :tag "disable")
249 integer))
250
23f87bed
MB
251(defcustom gnus-summary-default-high-score 0
252 "*Default threshold for a high scored article.
253An article will be highlighted as high scored if its score is greater
254than this score."
bf247b6e 255 :version "22.1"
23f87bed
MB
256 :group 'gnus-score-default
257 :type 'integer)
258
259(defcustom gnus-summary-default-low-score 0
260 "*Default threshold for a low scored article.
261An article will be highlighted as low scored if its score is smaller
262than this score."
bf247b6e 263 :version "22.1"
23f87bed
MB
264 :group 'gnus-score-default
265 :type 'integer)
266
eec82323
LMI
267(defcustom gnus-summary-zcore-fuzz 0
268 "*Fuzziness factor for the zcore in the summary buffer.
269Articles with scores closer than this to `gnus-summary-default-score'
270will not be marked."
271 :group 'gnus-summary-format
272 :type 'integer)
273
274(defcustom gnus-simplify-subject-fuzzy-regexp nil
275 "*Strings to be removed when doing fuzzy matches.
276This can either be a regular expression or list of regular expressions
277that will be removed from subject strings if fuzzy subject
278simplification is selected."
279 :group 'gnus-thread
280 :type '(repeat regexp))
281
282(defcustom gnus-show-threads t
283 "*If non-nil, display threads in summary mode."
284 :group 'gnus-thread
285 :type 'boolean)
286
287(defcustom gnus-thread-hide-subtree nil
288 "*If non-nil, hide all threads initially.
23f87bed 289This can be a predicate specifier which says which threads to hide.
eec82323 290If threads are hidden, you have to run the command
4a2358e9 291`gnus-summary-show-thread' by hand or select an article."
eec82323 292 :group 'gnus-thread
23f87bed
MB
293 :type '(radio (sexp :format "Non-nil\n"
294 :match (lambda (widget value)
295 (not (or (consp value) (functionp value))))
296 :value t)
297 (const nil)
ad136a7c 298 (sexp :tag "Predicate specifier")))
eec82323
LMI
299
300(defcustom gnus-thread-hide-killed t
301 "*If non-nil, hide killed threads automatically."
302 :group 'gnus-thread
303 :type 'boolean)
304
6748645f
LMI
305(defcustom gnus-thread-ignore-subject t
306 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
307If nil, articles that have different subjects from their parents will
308start separate threads."
eec82323
LMI
309 :group 'gnus-thread
310 :type 'boolean)
311
312(defcustom gnus-thread-operation-ignore-subject t
313 "*If non-nil, subjects will be ignored when doing thread commands.
314This affects commands like `gnus-summary-kill-thread' and
315`gnus-summary-lower-thread'.
316
317If this variable is nil, articles in the same thread with different
318subjects will not be included in the operation in question. If this
319variable is `fuzzy', only articles that have subjects that are fuzzily
320equal will be included."
321 :group 'gnus-thread
322 :type '(choice (const :tag "off" nil)
323 (const fuzzy)
324 (sexp :tag "on" t)))
325
326(defcustom gnus-thread-indent-level 4
327 "*Number that says how much each sub-thread should be indented."
328 :group 'gnus-thread
329 :type 'integer)
330
331(defcustom gnus-auto-extend-newsgroup t
332 "*If non-nil, extend newsgroup forward and backward when requested."
333 :group 'gnus-summary-choose
334 :type 'boolean)
335
336(defcustom gnus-auto-select-first t
651408cb
MB
337 "If non-nil, select an article on group entry.
338An article is selected automatically when entering a group
339e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
340`gnus-summary-catchup-and-goto-next-group'.
341
342Which article is selected is controlled by the variable
343`gnus-auto-select-subject'.
23f87bed
MB
344
345If you want to prevent automatic selection of articles in some
346newsgroups, set the variable to nil in `gnus-select-group-hook'."
651408cb
MB
347 ;; Commands include...
348 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
349 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
350 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
eec82323
LMI
351 :group 'gnus-group-select
352 :type '(choice (const :tag "none" nil)
23f87bed
MB
353 (sexp :menu-tag "first" t)))
354
a1347097 355(defcustom gnus-auto-select-subject 'unseen-or-unread
23f87bed
MB
356 "*Says what subject to place under point when entering a group.
357
358This variable can either be the symbols `first' (place point on the
359first subject), `unread' (place point on the subject line of the first
360unread article), `best' (place point on the subject line of the
361higest-scored article), `unseen' (place point on the subject line of
99b5aab7 362the first unseen article), `unseen-or-unread' (place point on the subject
23f87bed
MB
363line of the first unseen article or, if all article have been seen, on the
364subject line of the first unread article), or a function to be called to
365place point on some subject line."
a1347097 366 :version "24.1"
23f87bed
MB
367 :group 'gnus-group-select
368 :type '(choice (const best)
369 (const unread)
370 (const first)
371 (const unseen)
372 (const unseen-or-unread)))
eec82323
LMI
373
374(defcustom gnus-auto-select-next t
375 "*If non-nil, offer to go to the next group from the end of the previous.
376If the value is t and the next newsgroup is empty, Gnus will exit
23f87bed
MB
377summary mode and go back to group mode. If the value is neither nil
378nor t, Gnus will select the following unread newsgroup. In
eec82323
LMI
379particular, if the value is the symbol `quietly', the next unread
380newsgroup will be selected without any confirmation, and if it is
381`almost-quietly', the next group will be selected without any
382confirmation if you are located on the last article in the group.
23f87bed 383Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
eec82323
LMI
384will go to the next group without confirmation."
385 :group 'gnus-summary-maneuvering
386 :type '(choice (const :tag "off" nil)
387 (const quietly)
388 (const almost-quietly)
389 (const slightly-quietly)
390 (sexp :menu-tag "on" t)))
391
392(defcustom gnus-auto-select-same nil
6748645f
LMI
393 "*If non-nil, select the next article with the same subject.
394If there are no more articles with the same subject, go to
395the first unread article."
eec82323
LMI
396 :group 'gnus-summary-maneuvering
397 :type 'boolean)
398
01c52d31
MB
399(defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
400 "What article should be selected after exiting an ephemeral group.
401Valid values include:
402
403`next'
404 Select the next article.
405`next-unread'
406 Select the next unread article.
407`next-noselect'
408 Move the cursor to the next article. This is the default.
409`next-unread-noselect'
410 Move the cursor to the next unread article.
411
412If it has any other value or there is no next (unread) article, the
413article selected before entering to the ephemeral group will appear."
330f707b 414 :version "23.1" ;; No Gnus
01c52d31
MB
415 :group 'gnus-summary-maneuvering
416 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
417 (const next) (const next-unread)
418 (const next-noselect) (const next-unread-noselect)
419 (sexp :tag "other" :value nil)))
420
23f87bed
MB
421(defcustom gnus-auto-goto-ignores 'unfetched
422 "*Says how to handle unfetched articles when maneuvering.
423
424This variable can either be the symbols nil (maneuver to any
425article), `undownloaded' (maneuvering while unplugged ignores articles
426that have not been fetched), `always-undownloaded' (maneuvering always
427ignores articles that have not been fetched), `unfetched' (maneuvering
428ignores articles whose headers have not been fetched).
429
430NOTE: The list of unfetched articles will always be nil when plugged
431and, when unplugged, a subset of the undownloaded article list."
bf247b6e 432 :version "22.1"
23f87bed
MB
433 :group 'gnus-summary-maneuvering
434 :type '(choice (const :tag "None" nil)
435 (const :tag "Undownloaded when unplugged" undownloaded)
436 (const :tag "Undownloaded" always-undownloaded)
437 (const :tag "Unfetched" unfetched)))
438
eec82323
LMI
439(defcustom gnus-summary-check-current nil
440 "*If non-nil, consider the current article when moving.
441The \"unread\" movement commands will stay on the same line if the
442current article is unread."
443 :group 'gnus-summary-maneuvering
444 :type 'boolean)
445
01c52d31 446(defcustom gnus-auto-center-summary 2
eec82323
LMI
447 "*If non-nil, always center the current summary buffer.
448In particular, if `vertical' do only vertical recentering. If non-nil
449and non-`vertical', do both horizontal and vertical recentering."
450 :group 'gnus-summary-maneuvering
451 :type '(choice (const :tag "none" nil)
452 (const vertical)
16409b0b 453 (integer :tag "height")
eec82323
LMI
454 (sexp :menu-tag "both" t)))
455
2d04f304
G
456(defcustom gnus-auto-center-group t
457 "If non-nil, always center the group buffer."
458 :group 'gnus-summary-maneuvering
459 :type 'boolean)
23f87bed 460
eec82323
LMI
461(defcustom gnus-show-all-headers nil
462 "*If non-nil, don't hide any headers."
463 :group 'gnus-article-hiding
464 :group 'gnus-article-headers
465 :type 'boolean)
466
467(defcustom gnus-summary-ignore-duplicates nil
468 "*If non-nil, ignore articles with identical Message-ID headers."
469 :group 'gnus-summary
470 :type 'boolean)
6748645f 471
1d297c49 472(defcustom gnus-single-article-buffer nil
eec82323
LMI
473 "*If non-nil, display all articles in the same buffer.
474If nil, each group will get its own article buffer."
1d297c49 475 :version "24.1"
eec82323
LMI
476 :group 'gnus-article-various
477 :type 'boolean)
478
71e691a5
G
479(defcustom gnus-widen-article-window nil
480 "If non-nil, selecting the article buffer will display only the article buffer."
481 :version "24.1"
482 :group 'gnus-article-various
483 :type 'boolean)
484
eec82323
LMI
485(defcustom gnus-break-pages t
486 "*If non-nil, do page breaking on articles.
487The page delimiter is specified by the `gnus-page-delimiter'
488variable."
489 :group 'gnus-article-various
490 :type 'boolean)
491
eec82323
LMI
492(defcustom gnus-move-split-methods nil
493 "*Variable used to suggest where articles are to be moved to.
23f87bed
MB
494It uses the same syntax as the `gnus-split-methods' variable.
495However, whereas `gnus-split-methods' specifies file names as targets,
496this variable specifies group names."
eec82323 497 :group 'gnus-summary-mail
6748645f
LMI
498 :type '(repeat (choice (list :value (fun) function)
499 (cons :value ("" "") regexp (repeat string))
500 (sexp :value nil))))
eec82323 501
01c52d31
MB
502(defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
503 "Function used to compute default prefix for article move/copy/etc prompts.
504The function should take one argument, a group name, and return a
505string with the suggested prefix."
506 :group 'gnus-summary-mail
507 :type 'function)
508
e62e7654
MB
509;; FIXME: Although the custom type is `character' for the following variables,
510;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
511
23f87bed 512(defcustom gnus-unread-mark ? ;Whitespace
eec82323
LMI
513 "*Mark used for unread articles."
514 :group 'gnus-summary-marks
515 :type 'character)
516
517(defcustom gnus-ticked-mark ?!
518 "*Mark used for ticked articles."
519 :group 'gnus-summary-marks
520 :type 'character)
521
522(defcustom gnus-dormant-mark ??
523 "*Mark used for dormant articles."
524 :group 'gnus-summary-marks
525 :type 'character)
526
527(defcustom gnus-del-mark ?r
528 "*Mark used for del'd articles."
529 :group 'gnus-summary-marks
530 :type 'character)
531
532(defcustom gnus-read-mark ?R
533 "*Mark used for read articles."
534 :group 'gnus-summary-marks
535 :type 'character)
536
537(defcustom gnus-expirable-mark ?E
538 "*Mark used for expirable articles."
539 :group 'gnus-summary-marks
540 :type 'character)
541
542(defcustom gnus-killed-mark ?K
543 "*Mark used for killed articles."
544 :group 'gnus-summary-marks
545 :type 'character)
546
23f87bed
MB
547(defcustom gnus-spam-mark ?$
548 "*Mark used for spam articles."
bf247b6e 549 :version "22.1"
23f87bed
MB
550 :group 'gnus-summary-marks
551 :type 'character)
552
eec82323
LMI
553(defcustom gnus-kill-file-mark ?X
554 "*Mark used for articles killed by kill files."
555 :group 'gnus-summary-marks
556 :type 'character)
557
558(defcustom gnus-low-score-mark ?Y
559 "*Mark used for articles with a low score."
560 :group 'gnus-summary-marks
561 :type 'character)
562
563(defcustom gnus-catchup-mark ?C
564 "*Mark used for articles that are caught up."
565 :group 'gnus-summary-marks
566 :type 'character)
567
568(defcustom gnus-replied-mark ?A
569 "*Mark used for articles that have been replied to."
570 :group 'gnus-summary-marks
571 :type 'character)
572
23f87bed
MB
573(defcustom gnus-forwarded-mark ?F
574 "*Mark used for articles that have been forwarded."
bf247b6e 575 :version "22.1"
23f87bed
MB
576 :group 'gnus-summary-marks
577 :type 'character)
578
579(defcustom gnus-recent-mark ?N
580 "*Mark used for articles that are recent."
bf247b6e 581 :version "22.1"
23f87bed
MB
582 :group 'gnus-summary-marks
583 :type 'character)
584
eec82323
LMI
585(defcustom gnus-cached-mark ?*
586 "*Mark used for articles that are in the cache."
587 :group 'gnus-summary-marks
588 :type 'character)
589
590(defcustom gnus-saved-mark ?S
23f87bed
MB
591 "*Mark used for articles that have been saved."
592 :group 'gnus-summary-marks
593 :type 'character)
594
595(defcustom gnus-unseen-mark ?.
596 "*Mark used for articles that haven't been seen."
bf247b6e 597 :version "22.1"
23f87bed
MB
598 :group 'gnus-summary-marks
599 :type 'character)
600
601(defcustom gnus-no-mark ? ;Whitespace
602 "*Mark used for articles that have no other secondary mark."
bf247b6e 603 :version "22.1"
eec82323
LMI
604 :group 'gnus-summary-marks
605 :type 'character)
606
607(defcustom gnus-ancient-mark ?O
608 "*Mark used for ancient articles."
609 :group 'gnus-summary-marks
610 :type 'character)
611
612(defcustom gnus-sparse-mark ?Q
613 "*Mark used for sparsely reffed articles."
614 :group 'gnus-summary-marks
615 :type 'character)
616
617(defcustom gnus-canceled-mark ?G
618 "*Mark used for canceled articles."
619 :group 'gnus-summary-marks
620 :type 'character)
621
622(defcustom gnus-duplicate-mark ?M
623 "*Mark used for duplicate articles."
624 :group 'gnus-summary-marks
625 :type 'character)
626
23f87bed 627(defcustom gnus-undownloaded-mark ?-
6748645f 628 "*Mark used for articles that weren't downloaded."
bf247b6e 629 :version "22.1"
6748645f
LMI
630 :group 'gnus-summary-marks
631 :type 'character)
632
23f87bed
MB
633(defcustom gnus-downloaded-mark ?+
634 "*Mark used for articles that were downloaded."
635 :group 'gnus-summary-marks
636 :type 'character)
637
6748645f
LMI
638(defcustom gnus-downloadable-mark ?%
639 "*Mark used for articles that are to be downloaded."
640 :group 'gnus-summary-marks
641 :type 'character)
642
643(defcustom gnus-unsendable-mark ?=
644 "*Mark used for articles that won't be sent."
645 :group 'gnus-summary-marks
646 :type 'character)
647
eec82323
LMI
648(defcustom gnus-score-over-mark ?+
649 "*Score mark used for articles with high scores."
650 :group 'gnus-summary-marks
651 :type 'character)
652
653(defcustom gnus-score-below-mark ?-
654 "*Score mark used for articles with low scores."
655 :group 'gnus-summary-marks
656 :type 'character)
657
23f87bed 658(defcustom gnus-empty-thread-mark ? ;Whitespace
eec82323
LMI
659 "*There is no thread under the article."
660 :group 'gnus-summary-marks
661 :type 'character)
662
663(defcustom gnus-not-empty-thread-mark ?=
664 "*There is a thread under the article."
665 :group 'gnus-summary-marks
666 :type 'character)
667
668(defcustom gnus-view-pseudo-asynchronously nil
669 "*If non-nil, Gnus will view pseudo-articles asynchronously."
670 :group 'gnus-extract-view
671 :type 'boolean)
672
16409b0b
GM
673(defcustom gnus-auto-expirable-marks
674 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
675 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
c4d82de8 676 gnus-duplicate-mark)
16409b0b 677 "*The list of marks converted into expiration if a group is auto-expirable."
b0e30310 678 :version "24.1"
16409b0b
GM
679 :group 'gnus-summary
680 :type '(repeat character))
681
682(defcustom gnus-inhibit-user-auto-expire t
683 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
58e39d05 684 :version "21.1"
16409b0b
GM
685 :group 'gnus-summary
686 :type 'boolean)
687
b0b63450
MB
688(defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
689 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
690If nil, the expirable marks will be unchanged except that the marks
691will be removed when copying or moving articles to a group that has
692not turned auto-expire on. If non-nil, articles that have been read
693will be marked as expirable when being copied or moved to a group in
694which auto-expire is turned on."
695 :version "23.2"
696 :type 'boolean
697 :group 'gnus-summary-marks)
698
eec82323
LMI
699(defcustom gnus-view-pseudos nil
700 "*If `automatic', pseudo-articles will be viewed automatically.
701If `not-confirm', pseudos will be viewed automatically, and the user
702will not be asked to confirm the command."
703 :group 'gnus-extract-view
704 :type '(choice (const :tag "off" nil)
705 (const automatic)
706 (const not-confirm)))
707
708(defcustom gnus-view-pseudos-separately t
709 "*If non-nil, one pseudo-article will be created for each file to be viewed.
710If nil, all files that use the same viewing command will be given as a
711list of parameters to that command."
712 :group 'gnus-extract-view
713 :type 'boolean)
714
715(defcustom gnus-insert-pseudo-articles t
716 "*If non-nil, insert pseudo-articles when decoding articles."
717 :group 'gnus-extract-view
718 :type 'boolean)
719
720(defcustom gnus-summary-dummy-line-format
23f87bed 721 " %(: :%) %S\n"
eec82323
LMI
722 "*The format specification for the dummy roots in the summary buffer.
723It works along the same lines as a normal formatting string,
724with some simple extensions.
725
23f87bed
MB
726%S The subject
727
728General format specifiers can also be used.
729See `(gnus)Formatting Variables'."
730 :link '(custom-manual "(gnus)Formatting Variables")
eec82323
LMI
731 :group 'gnus-threading
732 :type 'string)
733
16409b0b 734(defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
eec82323
LMI
735 "*The format specification for the summary mode line.
736It works along the same lines as a normal formatting string,
737with some simple extensions:
738
739%G Group name
740%p Unprefixed group name
741%A Current article number
6748645f 742%z Current article score
eec82323
LMI
743%V Gnus version
744%U Number of unread articles in the group
745%e Number of unselected articles in the group
746%Z A string with unread/unselected article counts
747%g Shortish group name
748%S Subject of the current article
749%u User-defined spec
750%s Current score file name
751%d Number of dormant articles
752%r Number of articles that have been marked as read in this session
753%E Number of articles expunged by the score files"
754 :group 'gnus-summary-format
755 :type 'string)
756
16409b0b
GM
757(defcustom gnus-list-identifiers nil
758 "Regexp that matches list identifiers to be removed from subject.
759This can also be a list of regexps."
58e39d05 760 :version "21.1"
16409b0b
GM
761 :group 'gnus-summary-format
762 :group 'gnus-article-hiding
763 :type '(choice (const :tag "none" nil)
764 (regexp :value ".*")
765 (repeat :value (".*") regexp)))
766
eec82323
LMI
767(defcustom gnus-summary-mark-below 0
768 "*Mark all articles with a score below this variable as read.
769This variable is local to each summary buffer and usually set by the
770score file."
771 :group 'gnus-score-default
772 :type 'integer)
773
01c52d31
MB
774(defun gnus-widget-reversible-match (widget value)
775 "Ignoring WIDGET, convert VALUE to internal form.
776VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
777 ;; (debug value)
778 (or (symbolp value)
779 (and (listp value)
780 (eq (length value) 2)
781 (eq (nth 0 value) 'not)
782 (symbolp (nth 1 value)))))
783
784(defun gnus-widget-reversible-to-internal (widget value)
785 "Ignoring WIDGET, convert VALUE to internal form.
786VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
787FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
788 ;; (debug value)
789 (if (atom value)
790 (list value nil)
791 (list (nth 1 value) t)))
792
793(defun gnus-widget-reversible-to-external (widget value)
794 "Ignoring WIDGET, convert VALUE to external form.
795VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
796\(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
797 ;; (debug value)
798 (if (nth 1 value)
799 (list 'not (nth 0 value))
800 (nth 0 value)))
801
802(define-widget 'gnus-widget-reversible 'group
803 "A `group' that convert values."
804 :match 'gnus-widget-reversible-match
805 :value-to-internal 'gnus-widget-reversible-to-internal
806 :value-to-external 'gnus-widget-reversible-to-external)
807
eec82323
LMI
808(defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
809 "*List of functions used for sorting articles in the summary buffer.
23f87bed
MB
810
811Each function takes two articles and returns non-nil if the first
812article should be sorted before the other. If you use more than one
813function, the primary sort function should be the last. You should
814probably always include `gnus-article-sort-by-number' in the list of
815sorting functions -- preferably first. Also note that sorting by date
816is often much slower than sorting by number, and the sorting order is
817very similar. (Sorting by date means sorting by the time the message
818was sent, sorting by number means sorting by arrival time.)
819
01c52d31
MB
820Each item can also be a list `(not F)' where F is a function;
821this reverses the sort order.
822
23f87bed
MB
823Ready-made functions include `gnus-article-sort-by-number',
824`gnus-article-sort-by-author', `gnus-article-sort-by-subject',
825`gnus-article-sort-by-date', `gnus-article-sort-by-random'
826and `gnus-article-sort-by-score'.
827
828When threading is turned on, the variable `gnus-thread-sort-functions'
829controls how articles are sorted."
eec82323 830 :group 'gnus-summary-sort
01c52d31
MB
831 :type '(repeat (gnus-widget-reversible
832 (choice (function-item gnus-article-sort-by-number)
833 (function-item gnus-article-sort-by-author)
834 (function-item gnus-article-sort-by-subject)
835 (function-item gnus-article-sort-by-date)
836 (function-item gnus-article-sort-by-score)
837 (function-item gnus-article-sort-by-random)
838 (function :tag "other"))
839 (boolean :tag "Reverse order"))))
840
eec82323
LMI
841
842(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
843 "*List of functions used for sorting threads in the summary buffer.
844By default, threads are sorted by article number.
845
23f87bed
MB
846Each function takes two threads and returns non-nil if the first
847thread should be sorted before the other. If you use more than one
848function, the primary sort function should be the last. You should
849probably always include `gnus-thread-sort-by-number' in the list of
850sorting functions -- preferably first. Also note that sorting by date
851is often much slower than sorting by number, and the sorting order is
852very similar. (Sorting by date means sorting by the time the message
853was sent, sorting by number means sorting by arrival time.)
eec82323 854
01c52d31
MB
855Each list item can also be a list `(not F)' where F is a
856function; this specifies reversed sort order.
857
eec82323 858Ready-made functions include `gnus-thread-sort-by-number',
01c52d31
MB
859`gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
860`gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
861`gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
862`gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
863and `gnus-thread-sort-by-total-score' (see
864`gnus-thread-score-function').
23f87bed
MB
865
866When threading is turned off, the variable
867`gnus-article-sort-functions' controls how articles are sorted."
eec82323 868 :group 'gnus-summary-sort
01c52d31
MB
869 :type '(repeat
870 (gnus-widget-reversible
871 (choice (function-item gnus-thread-sort-by-number)
872 (function-item gnus-thread-sort-by-author)
873 (function-item gnus-thread-sort-by-recipient)
874 (function-item gnus-thread-sort-by-subject)
875 (function-item gnus-thread-sort-by-date)
876 (function-item gnus-thread-sort-by-score)
877 (function-item gnus-thread-sort-by-most-recent-number)
878 (function-item gnus-thread-sort-by-most-recent-date)
879 (function-item gnus-thread-sort-by-random)
880 (function-item gnus-thread-sort-by-total-score)
881 (function :tag "other"))
882 (boolean :tag "Reverse order"))))
eec82323
LMI
883
884(defcustom gnus-thread-score-function '+
885 "*Function used for calculating the total score of a thread.
886
887The function is called with the scores of the article and each
888subthread and should then return the score of the thread.
889
890Some functions you can use are `+', `max', or `min'."
891 :group 'gnus-summary-sort
892 :type 'function)
893
894(defcustom gnus-summary-expunge-below nil
6748645f
LMI
895 "All articles that have a score less than this variable will be expunged.
896This variable is local to the summary buffers."
eec82323
LMI
897 :group 'gnus-score-default
898 :type '(choice (const :tag "off" nil)
899 integer))
900
901(defcustom gnus-thread-expunge-below nil
902 "All threads that have a total score less than this variable will be expunged.
903See `gnus-thread-score-function' for en explanation of what a
6748645f
LMI
904\"thread score\" is.
905
906This variable is local to the summary buffers."
16409b0b 907 :group 'gnus-threading
eec82323
LMI
908 :group 'gnus-score-default
909 :type '(choice (const :tag "off" nil)
910 integer))
911
912(defcustom gnus-summary-mode-hook nil
913 "*A hook for Gnus summary mode.
914This hook is run before any variables are set in the summary buffer."
23f87bed 915 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
eec82323
LMI
916 :group 'gnus-summary-various
917 :type 'hook)
918
23f87bed
MB
919;; Extracted from gnus-xmas-redefine in order to preserve user settings
920(when (featurep 'xemacs)
921 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
922 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
923 (add-hook 'gnus-summary-mode-hook
924 'gnus-xmas-switch-horizontal-scrollbar-off))
925
eec82323
LMI
926(defcustom gnus-summary-menu-hook nil
927 "*Hook run after the creation of the summary mode menu."
928 :group 'gnus-summary-visual
929 :type 'hook)
930
931(defcustom gnus-summary-exit-hook nil
932 "*A hook called on exit from the summary buffer.
933It will be called with point in the group buffer."
934 :group 'gnus-summary-exit
935 :type 'hook)
936
937(defcustom gnus-summary-prepare-hook nil
938 "*A hook called after the summary buffer has been generated.
939If you want to modify the summary buffer, you can use this hook."
940 :group 'gnus-summary-various
941 :type 'hook)
942
6748645f
LMI
943(defcustom gnus-summary-prepared-hook nil
944 "*A hook called as the last thing after the summary buffer has been generated."
945 :group 'gnus-summary-various
946 :type 'hook)
947
eec82323
LMI
948(defcustom gnus-summary-generate-hook nil
949 "*A hook run just before generating the summary buffer.
950This hook is commonly used to customize threading variables and the
951like."
952 :group 'gnus-summary-various
953 :type 'hook)
954
955(defcustom gnus-select-group-hook nil
956 "*A hook called when a newsgroup is selected.
957
958If you'd like to simplify subjects like the
959`gnus-summary-next-same-subject' command does, you can use the
960following hook:
961
23f87bed
MB
962 (add-hook gnus-select-group-hook
963 (lambda ()
964 (mapcar (lambda (header)
965 (mail-header-set-subject
966 header
967 (gnus-simplify-subject
968 (mail-header-subject header) 're-only)))
969 gnus-newsgroup-headers)))"
eec82323
LMI
970 :group 'gnus-group-select
971 :type 'hook)
972
973(defcustom gnus-select-article-hook nil
974 "*A hook called when an article is selected."
975 :group 'gnus-summary-choose
23f87bed 976 :options '(gnus-agent-fetch-selected-article)
eec82323
LMI
977 :type 'hook)
978
979(defcustom gnus-visual-mark-article-hook
980 (list 'gnus-highlight-selected-summary)
981 "*Hook run after selecting an article in the summary buffer.
982It is meant to be used for highlighting the article in some way. It
983is not run if `gnus-visual' is nil."
984 :group 'gnus-summary-visual
985 :type 'hook)
986
16409b0b 987(defcustom gnus-parse-headers-hook nil
eec82323
LMI
988 "*A hook called before parsing the headers."
989 :group 'gnus-various
990 :type 'hook)
991
992(defcustom gnus-exit-group-hook nil
16409b0b
GM
993 "*A hook called when exiting summary mode.
994This hook is not called from the non-updating exit commands like `Q'."
eec82323
LMI
995 :group 'gnus-various
996 :type 'hook)
997
a9ec34f4 998(defcustom gnus-summary-update-hook nil
eec82323
LMI
999 "*A hook called when a summary line is changed.
1000The hook will not be called if `gnus-visual' is nil.
1001
1002The default function `gnus-summary-highlight-line' will
1003highlight the line according to the `gnus-summary-highlight'
1004variable."
1005 :group 'gnus-summary-visual
1006 :type 'hook)
1007
1008(defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1009 "*A hook called when an article is selected for the first time.
1010The hook is intended to mark an article as read (or unread)
1011automatically when it is selected."
1012 :group 'gnus-summary-choose
1013 :type 'hook)
1014
1015(defcustom gnus-group-no-more-groups-hook nil
1016 "*A hook run when returning to group mode having no more (unread) groups."
1017 :group 'gnus-group-select
1018 :type 'hook)
1019
1020(defcustom gnus-ps-print-hook nil
1021 "*A hook run before ps-printing something from Gnus."
1022 :group 'gnus-summary
1023 :type 'hook)
1024
23f87bed
MB
1025(defcustom gnus-summary-article-move-hook nil
1026 "*A hook called after an article is moved, copied, respooled, or crossposted."
bf247b6e 1027 :version "22.1"
23f87bed
MB
1028 :group 'gnus-summary
1029 :type 'hook)
1030
1031(defcustom gnus-summary-article-delete-hook nil
1032 "*A hook called after an article is deleted."
bf247b6e 1033 :version "22.1"
23f87bed
MB
1034 :group 'gnus-summary
1035 :type 'hook)
1036
1037(defcustom gnus-summary-article-expire-hook nil
1038 "*A hook called after an article is expired."
bf247b6e 1039 :version "22.1"
23f87bed
MB
1040 :group 'gnus-summary
1041 :type 'hook)
1042
1043(defcustom gnus-summary-display-arrow
1044 (and (fboundp 'display-graphic-p)
1045 (display-graphic-p))
1046 "*If non-nil, display an arrow highlighting the current article."
bf247b6e 1047 :version "22.1"
23f87bed
MB
1048 :group 'gnus-summary
1049 :type 'boolean)
1050
0f49874b 1051(defcustom gnus-summary-selected-face 'gnus-summary-selected
eec82323
LMI
1052 "Face used for highlighting the current article in the summary buffer."
1053 :group 'gnus-summary-visual
1054 :type 'face)
1055
23f87bed
MB
1056(defvar gnus-tmp-downloaded nil)
1057
eec82323 1058(defcustom gnus-summary-highlight
23f87bed 1059 '(((eq mark gnus-canceled-mark)
0f49874b 1060 . gnus-summary-cancelled)
23f87bed 1061 ((and uncached (> score default-high))
0f49874b 1062 . gnus-summary-high-undownloaded)
23f87bed 1063 ((and uncached (< score default-low))
0f49874b 1064 . gnus-summary-low-undownloaded)
23f87bed 1065 (uncached
0f49874b 1066 . gnus-summary-normal-undownloaded)
23f87bed
MB
1067 ((and (> score default-high)
1068 (or (eq mark gnus-dormant-mark)
1069 (eq mark gnus-ticked-mark)))
0f49874b 1070 . gnus-summary-high-ticked)
23f87bed
MB
1071 ((and (< score default-low)
1072 (or (eq mark gnus-dormant-mark)
1073 (eq mark gnus-ticked-mark)))
0f49874b 1074 . gnus-summary-low-ticked)
23f87bed
MB
1075 ((or (eq mark gnus-dormant-mark)
1076 (eq mark gnus-ticked-mark))
0f49874b 1077 . gnus-summary-normal-ticked)
23f87bed 1078 ((and (> score default-high) (eq mark gnus-ancient-mark))
0f49874b 1079 . gnus-summary-high-ancient)
23f87bed 1080 ((and (< score default-low) (eq mark gnus-ancient-mark))
0f49874b 1081 . gnus-summary-low-ancient)
23f87bed 1082 ((eq mark gnus-ancient-mark)
0f49874b 1083 . gnus-summary-normal-ancient)
23f87bed 1084 ((and (> score default-high) (eq mark gnus-unread-mark))
0f49874b 1085 . gnus-summary-high-unread)
23f87bed 1086 ((and (< score default-low) (eq mark gnus-unread-mark))
0f49874b 1087 . gnus-summary-low-unread)
23f87bed 1088 ((eq mark gnus-unread-mark)
0f49874b 1089 . gnus-summary-normal-unread)
23f87bed 1090 ((> score default-high)
0f49874b 1091 . gnus-summary-high-read)
23f87bed 1092 ((< score default-low)
0f49874b 1093 . gnus-summary-low-read)
eec82323 1094 (t
0f49874b 1095 . gnus-summary-normal-read))
6748645f 1096 "*Controls the highlighting of summary buffer lines.
eec82323 1097
107cf8ec 1098A list of (FORM . FACE) pairs. When deciding how a particular
23f87bed
MB
1099summary line should be displayed, each form is evaluated. The content
1100of the face field after the first true form is used. You can change
1101how those summary lines are displayed, by editing the face field.
eec82323
LMI
1102
1103You can use the following variables in the FORM field.
1104
107cf8ec 1105score: The article's score.
23f87bed
MB
1106default: The default article score.
1107default-high: The default score for high scored articles.
1108default-low: The default score for low scored articles.
1109below: The score below which articles are automatically marked as read.
1110mark: The article's mark.
1111uncached: Non-nil if the article is uncached."
eec82323
LMI
1112 :group 'gnus-summary-visual
1113 :type '(repeat (cons (sexp :tag "Form" nil)
1114 face)))
c12ecb0a 1115(put 'gnus-summary-highlight 'risky-local-variable t)
eec82323 1116
6748645f
LMI
1117(defcustom gnus-alter-header-function nil
1118 "Function called to allow alteration of article header structures.
1119The function is called with one parameter, the article header vector,
0ab0f2d3
SZ
1120which it may alter in any way."
1121 :type '(choice (const :tag "None" nil)
1122 function)
1123 :group 'gnus-summary)
eec82323 1124
16409b0b 1125(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
343d6628
MB
1126 "Function used to decode a string with encoded words.")
1127
1128(defvar gnus-decode-encoded-address-function
1129 'mail-decode-encoded-address-string
1130 "Function used to decode addresses with encoded words.")
16409b0b 1131
23f87bed 1132(defcustom gnus-extra-headers '(To Newsgroups)
16409b0b 1133 "*Extra headers to parse."
58e39d05 1134 :version "21.1"
16409b0b
GM
1135 :group 'gnus-summary
1136 :type '(repeat symbol))
1137
1138(defcustom gnus-ignored-from-addresses
343d6628 1139 (and user-mail-address
7cd9f860
CY
1140 (not (string= user-mail-address ""))
1141 (regexp-quote user-mail-address))
01c52d31
MB
1142 "*From headers that may be suppressed in favor of To headers.
1143This can be a regexp or a list of regexps."
58e39d05 1144 :version "21.1"
16409b0b 1145 :group 'gnus-summary
01c52d31
MB
1146 :type '(choice regexp
1147 (repeat :tag "Regexp List" regexp)))
1148
1149(defsubst gnus-ignored-from-addresses ()
1150 (gmm-regexp-concat gnus-ignored-from-addresses))
1151
1152(defcustom gnus-summary-to-prefix "-> "
1153 "*String prefixed to the To field in the summary line when
1154using `gnus-ignored-from-addresses'."
1155 :version "22.1"
1156 :group 'gnus-summary
1157 :type 'string)
1158
1159(defcustom gnus-summary-newsgroup-prefix "=> "
1160 "*String prefixed to the Newsgroup field in the summary
1161line when using `gnus-ignored-from-addresses'."
1162 :version "22.1"
1163 :group 'gnus-summary
1164 :type 'string)
16409b0b 1165
16409b0b
GM
1166(defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1167 "List of charsets that should be ignored.
1168When these charsets are used in the \"charset\" parameter, the
1169default charset will be used instead."
58e39d05 1170 :version "21.1"
16409b0b
GM
1171 :type '(repeat symbol)
1172 :group 'gnus-charset)
1173
4b70e299
MB
1174(defcustom gnus-newsgroup-maximum-articles nil
1175 "The maximum number of articles a newsgroup.
1176If this is a number, old articles in a newsgroup exceeding this number
1177are silently ignored. If it is nil, no article is ignored. Note that
1178setting this variable to a number might prevent you from reading very
1179old articles."
1180 :group 'gnus-group-select
1181 :version "22.2"
1182 :type '(choice (const :tag "No limit" nil)
1183 integer))
1184
23f87bed
MB
1185(gnus-define-group-parameter
1186 ignored-charsets
1187 :type list
1188 :function-document
1189 "Return the ignored charsets of GROUP."
1190 :variable gnus-group-ignored-charsets-alist
1191 :variable-default
1192 '(("alt\\.chinese\\.text" iso-8859-1))
1193 :variable-document
1194 "Alist of regexps (to match group names) and charsets that should be ignored.
16409b0b
GM
1195When these charsets are used in the \"charset\" parameter, the
1196default charset will be used instead."
23f87bed
MB
1197 :variable-group gnus-charset
1198 :variable-type '(repeat (cons (regexp :tag "Group")
1199 (repeat symbol)))
1200 :parameter-type '(choice :tag "Ignored charsets"
1201 :value nil
1202 (repeat (symbol)))
1203 :parameter-document "\
1204List of charsets that should be ignored.
1205
1206When these charsets are used in the \"charset\" parameter, the
1207default charset will be used instead.")
16409b0b
GM
1208
1209(defcustom gnus-group-highlight-words-alist nil
1210 "Alist of group regexps and highlight regexps.
1211This variable uses the same syntax as `gnus-emphasis-alist'."
58e39d05 1212 :version "21.1"
16409b0b
GM
1213 :type '(repeat (cons (regexp :tag "Group")
1214 (repeat (list (regexp :tag "Highlight regexp")
1215 (number :tag "Group for entire word" 0)
1216 (number :tag "Group for displayed part" 0)
1217 (symbol :tag "Face"
1218 gnus-emphasis-highlight-words)))))
1219 :group 'gnus-summary-visual)
1220
1221(defcustom gnus-summary-show-article-charset-alist
1222 nil
1223 "Alist of number and charset.
1224The article will be shown with the charset corresponding to the
1225numbered argument.
1226For example: ((1 . cn-gb-2312) (2 . big5))."
58e39d05 1227 :version "21.1"
16409b0b
GM
1228 :type '(repeat (cons (number :tag "Argument" 1)
1229 (symbol :tag "Charset")))
1230 :group 'gnus-charset)
1231
1232(defcustom gnus-preserve-marks t
1233 "Whether marks are preserved when moving, copying and respooling messages."
58e39d05 1234 :version "21.1"
16409b0b
GM
1235 :type 'boolean
1236 :group 'gnus-summary-marks)
1237
3a23a519
MB
1238(defcustom gnus-propagate-marks t
1239 "If non-nil, do not propagate marks to the backends."
f8a29505 1240 :version "23.1" ;; No Gnus
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)
1399 (user-date (gnus-user-date
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
3856
eec82323
LMI
3857(defun gnus-summary-set-local-parameters (group)
3858 "Go through the local params of GROUP and set all variable specs in that list."
dab0271f
G
3859 (let ((vars '(quit-config active))) ; Ignore things that aren't
3860 ; really variables.
01c52d31 3861 (dolist (elem (gnus-group-find-parameter group))
eec82323
LMI
3862 (and (consp elem) ; Has to be a cons.
3863 (consp (cdr elem)) ; The cdr has to be a list.
3864 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3865 (not (memq (car elem) vars))
e3e955fe 3866 (ignore-errors
23f87bed 3867 (push (car elem) vars)
e3e955fe
MB
3868 ;; Variables like `gnus-show-threads' that are globally
3869 ;; bound, if used as group parameters, need to get to be
3870 ;; buffer-local, whereas just parameters like `gcc-self',
3871 ;; `timestamp', etc. should not be bound as variables.
3872 (if (boundp (car elem))
3873 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3874 (eval (nth 1 elem))))))))
eec82323
LMI
3875
3876(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3877 kill-buffer no-display backward
3878 select-articles)
eec82323
LMI
3879 "Start reading news in newsgroup GROUP.
3880If SHOW-ALL is non-nil, already read articles are also listed.
3881If NO-ARTICLE is non-nil, no article is selected initially.
3882If NO-DISPLAY, don't generate a summary buffer."
3883 (let (result)
3884 (while (and group
3885 (null (setq result
3886 (let ((gnus-auto-select-next nil))
6748645f
LMI
3887 (or (gnus-summary-read-group-1
3888 group show-all no-article
3889 kill-buffer no-display
3890 select-articles)
3891 (setq show-all nil
16409b0b 3892 select-articles nil)))))
eec82323
LMI
3893 (eq gnus-auto-select-next 'quietly))
3894 (set-buffer gnus-group-buffer)
6748645f
LMI
3895 ;; The entry function called above goes to the next
3896 ;; group automatically, so we go two groups back
3897 ;; if we are searching for the previous group.
3898 (when backward
3899 (gnus-group-prev-unread-group 2))
eec82323
LMI
3900 (if (not (equal group (gnus-group-group-name)))
3901 (setq group (gnus-group-group-name))
3902 (setq group nil)))
3903 result))
3904
3905(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3906 kill-buffer no-display
3907 &optional select-articles)
eec82323 3908 ;; Killed foreign groups can't be entered.
23f87bed
MB
3909 ;; (when (and (not (gnus-group-native-p group))
3910 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3911 ;; (error "Dead non-native groups can't be entered"))
3912 (gnus-message 5 "Retrieving newsgroup: %s..."
3913 (gnus-group-decoded-name group))
eec82323
LMI
3914 (let* ((new-group (gnus-summary-setup-buffer group))
3915 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3916 (did-select (and new-group (gnus-select-newsgroup
3917 group show-all select-articles))))
eec82323
LMI
3918 (cond
3919 ;; This summary buffer exists already, so we just select it.
3920 ((not new-group)
3921 (gnus-set-global-variables)
3922 (when kill-buffer
3923 (gnus-kill-or-deaden-summary kill-buffer))
3924 (gnus-configure-windows 'summary 'force)
3925 (gnus-set-mode-line 'summary)
3926 (gnus-summary-position-point)
3927 (message "")
3928 t)
3929 ;; We couldn't select this group.
3930 ((null did-select)
3931 (when (and (eq major-mode 'gnus-summary-mode)
3932 (not (equal (current-buffer) kill-buffer)))
3933 (kill-buffer (current-buffer))
3934 (if (not quit-config)
3935 (progn
6748645f
LMI
3936 ;; Update the info -- marks might need to be removed,
3937 ;; for instance.
3938 (gnus-summary-update-info)
eec82323
LMI
3939 (set-buffer gnus-group-buffer)
3940 (gnus-group-jump-to-group group)
3941 (gnus-group-next-unread-group 1))
3942 (gnus-handle-ephemeral-exit quit-config)))
23f87bed
MB
3943 (let ((grpinfo (gnus-get-info group)))
3944 (if (null (gnus-info-read grpinfo))
3945 (gnus-message 3 "Group %s contains no messages"
3946 (gnus-group-decoded-name group))
3947 (gnus-message 3 "Can't select group")))
eec82323
LMI
3948 nil)
3949 ;; The user did a `C-g' while prompting for number of articles,
3950 ;; so we exit this group.
3951 ((eq did-select 'quit)
3952 (and (eq major-mode 'gnus-summary-mode)
3953 (not (equal (current-buffer) kill-buffer))
3954 (kill-buffer (current-buffer)))
3955 (when kill-buffer
3956 (gnus-kill-or-deaden-summary kill-buffer))
3957 (if (not quit-config)
3958 (progn
3959 (set-buffer gnus-group-buffer)
3960 (gnus-group-jump-to-group group)
eec82323
LMI
3961 (gnus-configure-windows 'group 'force))
3962 (gnus-handle-ephemeral-exit quit-config))
3963 ;; Finally signal the quit.
3964 (signal 'quit nil))
3965 ;; The group was successfully selected.
3966 (t
3967 (gnus-set-global-variables)
3968 ;; Save the active value in effect when the group was entered.
3969 (setq gnus-newsgroup-active
3970 (gnus-copy-sequence
3971 (gnus-active gnus-newsgroup-name)))
9f2d52e7 3972 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
eec82323 3973 ;; You can change the summary buffer in some way with this hook.
6748645f 3974 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
3975 (when (memq 'summary (gnus-update-format-specifications
3976 nil 'summary 'summary-mode 'summary-dummy))
3977 ;; The format specification for the summary line was updated,
3978 ;; so we need to update the mark positions as well.
3979 (gnus-update-summary-mark-positions))
eec82323
LMI
3980 ;; Do score processing.
3981 (when gnus-use-scoring
3982 (gnus-possibly-score-headers))
3983 ;; Check whether to fill in the gaps in the threads.
3984 (when gnus-build-sparse-threads
3985 (gnus-build-sparse-threads))
3986 ;; Find the initial limit.
26c9afc3
MB
3987 (if show-all
3988 (let ((gnus-newsgroup-dormant nil))
eec82323 3989 (gnus-summary-initial-limit show-all))
26c9afc3 3990 (gnus-summary-initial-limit show-all))
eec82323
LMI
3991 ;; Generate the summary buffer.
3992 (unless no-display
3993 (gnus-summary-prepare))
3994 (when gnus-use-trees
3995 (gnus-tree-open group)
3996 (setq gnus-summary-highlight-line-function
3997 'gnus-tree-highlight-article))
3998 ;; If the summary buffer is empty, but there are some low-scored
3999 ;; articles or some excluded dormants, we include these in the
4000 ;; buffer.
4001 (when (and (zerop (buffer-size))
4002 (not no-display))
4003 (cond (gnus-newsgroup-dormant
4004 (gnus-summary-limit-include-dormant))
4005 ((and gnus-newsgroup-scored show-all)
4006 (gnus-summary-limit-include-expunged t))))
4007 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 4008 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
4009 (if (and (zerop (buffer-size))
4010 (not no-display))
4011 (progn
4012 ;; This newsgroup is empty.
4013 (gnus-summary-catchup-and-exit nil t)
4014 (gnus-message 6 "No unread news")
4015 (when kill-buffer
4016 (gnus-kill-or-deaden-summary kill-buffer))
4017 ;; Return nil from this function.
4018 nil)
4019 ;; Hide conversation thread subtrees. We cannot do this in
4020 ;; gnus-summary-prepare-hook since kill processing may not
4021 ;; work with hidden articles.
23f87bed 4022 (gnus-summary-maybe-hide-threads)
6748645f
LMI
4023 (when kill-buffer
4024 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 4025 (gnus-summary-auto-select-subject)
eec82323
LMI
4026 ;; Show first unread article if requested.
4027 (if (and (not no-article)
4028 (not no-display)
4029 gnus-newsgroup-unreads
4030 gnus-auto-select-first)
16409b0b
GM
4031 (progn
4032 (gnus-configure-windows 'summary)
23f87bed
MB
4033 (let ((art (gnus-summary-article-number)))
4034 (unless (and (not gnus-plugged)
4035 (or (memq art gnus-newsgroup-undownloaded)
4036 (memq art gnus-newsgroup-downloadable)))
4037 (gnus-summary-goto-article art))))
4038 ;; Don't select any articles.
eec82323 4039 (gnus-summary-position-point)
6748645f
LMI
4040 (gnus-configure-windows 'summary 'force)
4041 (gnus-set-mode-line 'summary))
23f87bed
MB
4042 (when (and gnus-auto-center-group
4043 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
4044 ;; Gotta use windows, because recenter does weird stuff if
4045 ;; the current buffer ain't the displayed window.
4046 (let ((owin (selected-window)))
4047 (select-window (get-buffer-window gnus-group-buffer t))
4048 (when (gnus-group-goto-group group)
4049 (recenter))
4050 (select-window owin)))
4051 ;; Mark this buffer as "prepared".
4052 (setq gnus-newsgroup-prepared t)
6748645f 4053 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
4054 (unless (gnus-ephemeral-group-p group)
4055 (gnus-group-update-group group))
eec82323
LMI
4056 t)))))
4057
23f87bed
MB
4058(defun gnus-summary-auto-select-subject ()
4059 "Select the subject line on initial group entry."
4060 (goto-char (point-min))
4061 (cond
4062 ((eq gnus-auto-select-subject 'best)
4063 (gnus-summary-best-unread-subject))
4064 ((eq gnus-auto-select-subject 'unread)
4065 (gnus-summary-first-unread-subject))
4066 ((eq gnus-auto-select-subject 'unseen)
4067 (gnus-summary-first-unseen-subject))
4068 ((eq gnus-auto-select-subject 'unseen-or-unread)
4069 (gnus-summary-first-unseen-or-unread-subject))
4070 ((eq gnus-auto-select-subject 'first)
4071 ;; Do nothing.
4072 )
4073 ((functionp gnus-auto-select-subject)
4074 (funcall gnus-auto-select-subject))))
4075
eec82323
LMI
4076(defun gnus-summary-prepare ()
4077 "Generate the summary buffer."
4078 (interactive)
c7a91ce1 4079 (let ((inhibit-read-only t))
eec82323
LMI
4080 (erase-buffer)
4081 (setq gnus-newsgroup-data nil
4082 gnus-newsgroup-data-reverse nil)
6748645f 4083 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
4084 ;; Generate the buffer, either with threads or without.
4085 (when gnus-newsgroup-headers
4086 (gnus-summary-prepare-threads
4087 (if gnus-show-threads
4088 (gnus-sort-gathered-threads
4089 (funcall gnus-summary-thread-gathering-function
4090 (gnus-sort-threads
4091 (gnus-cut-threads (gnus-make-threads)))))
4092 ;; Unthreaded display.
4093 (gnus-sort-articles gnus-newsgroup-headers))))
4094 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4095 ;; Call hooks for modifying summary buffer.
4096 (goto-char (point-min))
6748645f 4097 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
4098
4099(defsubst gnus-general-simplify-subject (subject)
23f87bed 4100 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
4101 (setq subject
4102 (cond
4103 ;; Truncate the subject.
6748645f
LMI
4104 (gnus-simplify-subject-functions
4105 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
4106 ((numberp gnus-summary-gather-subject-limit)
4107 (setq subject (gnus-simplify-subject-re subject))
4108 (if (> (length subject) gnus-summary-gather-subject-limit)
4109 (substring subject 0 gnus-summary-gather-subject-limit)
4110 subject))
4111 ;; Fuzzily simplify it.
4112 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4113 (gnus-simplify-subject-fuzzy subject))
4114 ;; Just remove the leading "Re:".
4115 (t
4116 (gnus-simplify-subject-re subject))))
4117
4118 (if (and gnus-summary-gather-exclude-subject
4119 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 4120 nil ; This article shouldn't be gathered
eec82323
LMI
4121 subject))
4122
4123(defun gnus-summary-simplify-subject-query ()
4124 "Query where the respool algorithm would put this article."
4125 (interactive)
eec82323 4126 (gnus-summary-select-article)
274f1353 4127 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
eec82323
LMI
4128
4129(defun gnus-gather-threads-by-subject (threads)
4130 "Gather threads by looking at Subject headers."
4131 (if (not gnus-summary-make-false-root)
4132 threads
4133 (let ((hashtb (gnus-make-hashtable 1024))
4134 (prev threads)
4135 (result threads)
4136 subject hthread whole-subject)
4137 (while threads
4138 (setq subject (gnus-general-simplify-subject
4139 (setq whole-subject (mail-header-subject
4140 (caar threads)))))
4141 (when subject
4142 (if (setq hthread (gnus-gethash subject hashtb))
4143 (progn
4144 ;; We enter a dummy root into the thread, if we
4145 ;; haven't done that already.
4146 (unless (stringp (caar hthread))
4147 (setcar hthread (list whole-subject (car hthread))))
4148 ;; We add this new gathered thread to this gathered
4149 ;; thread.
4150 (setcdr (car hthread)
4151 (nconc (cdar hthread) (list (car threads))))
4152 ;; Remove it from the list of threads.
4153 (setcdr prev (cdr threads))
4154 (setq threads prev))
4155 ;; Enter this thread into the hash table.
23f87bed
MB
4156 (gnus-sethash subject
4157 (if gnus-summary-make-false-root-always
4158 (progn
4159 ;; If you want a dummy root above all
4160 ;; threads...
4161 (setcar threads (list whole-subject
4162 (car threads)))
4163 threads)
4164 threads)
4165 hashtb)))
eec82323
LMI
4166 (setq prev threads)
4167 (setq threads (cdr threads)))
4168 result)))
4169
4170(defun gnus-gather-threads-by-references (threads)
4171 "Gather threads by looking at References headers."
4172 (let ((idhashtb (gnus-make-hashtable 1024))
4173 (thhashtb (gnus-make-hashtable 1024))
4174 (prev threads)
4175 (result threads)
4176 ids references id gthread gid entered ref)
4177 (while threads
4178 (when (setq references (mail-header-references (caar threads)))
4179 (setq id (mail-header-id (caar threads))
23f87bed 4180 ids (inline (gnus-split-references references))
eec82323
LMI
4181 entered nil)
4182 (while (setq ref (pop ids))
4183 (setq ids (delete ref ids))
4184 (if (not (setq gid (gnus-gethash ref idhashtb)))
4185 (progn
4186 (gnus-sethash ref id idhashtb)
4187 (gnus-sethash id threads thhashtb))
4188 (setq gthread (gnus-gethash gid thhashtb))
4189 (unless entered
4190 ;; We enter a dummy root into the thread, if we
4191 ;; haven't done that already.
4192 (unless (stringp (caar gthread))
4193 (setcar gthread (list (mail-header-subject (caar gthread))
4194 (car gthread))))
4195 ;; We add this new gathered thread to this gathered
4196 ;; thread.
4197 (setcdr (car gthread)
4198 (nconc (cdar gthread) (list (car threads)))))
4199 ;; Add it into the thread hash table.
4200 (gnus-sethash id gthread thhashtb)
4201 (setq entered t)
4202 ;; Remove it from the list of threads.
4203 (setcdr prev (cdr threads))
4204 (setq threads prev))))
4205 (setq prev threads)
4206 (setq threads (cdr threads)))
4207 result))
4208
4209(defun gnus-sort-gathered-threads (threads)
16409b0b 4210 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
4211 (let ((result threads))
4212 (while threads
4213 (when (stringp (caar threads))
4214 (setcdr (car threads)
16409b0b 4215 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
4216 (setq threads (cdr threads)))
4217 result))
4218
4219(defun gnus-thread-loop-p (root thread)
4220 "Say whether ROOT is in THREAD."
4221 (let ((stack (list thread))
4222 (infloop 0)
4223 th)
4224 (while (setq thread (pop stack))
4225 (setq th (cdr thread))
4226 (while (and th
4227 (not (eq (caar th) root)))
4228 (pop th))
4229 (if th
4230 ;; We have found a loop.
4231 (let (ref-dep)
4232 (setcdr thread (delq (car th) (cdr thread)))
4233 (if (boundp (setq ref-dep (intern "none"
4234 gnus-newsgroup-dependencies)))
4235 (setcdr (symbol-value ref-dep)
4236 (nconc (cdr (symbol-value ref-dep))
4237 (list (car th))))
4238 (set ref-dep (list nil (car th))))
4239 (setq infloop 1
4240 stack nil))
4241 ;; Push all the subthreads onto the stack.
4242 (push (cdr thread) stack)))
4243 infloop))
4244
4245(defun gnus-make-threads ()
01ccbb85 4246 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
4247 (let (threads)
4248 (while (catch 'infloop
4249 (mapatoms
4250 (lambda (refs)
4251 ;; Deal with self-referencing References loops.
4252 (when (and (car (symbol-value refs))
4253 (not (zerop
4254 (apply
4255 '+
4256 (mapcar
4257 (lambda (thread)
4258 (gnus-thread-loop-p
4259 (car (symbol-value refs)) thread))
4260 (cdr (symbol-value refs)))))))
4261 (setq threads nil)
4262 (throw 'infloop t))
4263 (unless (car (symbol-value refs))
23f87bed
MB
4264 ;; These threads do not refer back to any other
4265 ;; articles, so they're roots.
eec82323
LMI
4266 (setq threads (append (cdr (symbol-value refs)) threads))))
4267 gnus-newsgroup-dependencies)))
4268 threads))
4269
6748645f 4270;; Build the thread tree.
16409b0b 4271(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4272 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4273
4274If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4275if it was already present.
4276
4277If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4278will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4279Message-IDs will be renamed to a unique Message-ID before being
4280entered.
6748645f
LMI
4281
4282Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4283 (let* ((id (mail-header-id header))
4284 (id-dep (and id (intern id dependencies)))
23f87bed 4285 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4286 ;; Enter this `header' in the `dependencies' table.
4287 (cond
4288 ((not id-dep)
4289 (setq header nil))
4290 ;; The first two cases do the normal part: enter a new `header'
4291 ;; in the `dependencies' table.
4292 ((not (boundp id-dep))
4293 (set id-dep (list header)))
4294 ((null (car (symbol-value id-dep)))
4295 (setcar (symbol-value id-dep) header))
4296
4297 ;; From here the `header' was already present in the
4298 ;; `dependencies' table.
4299 (force-new
4300 ;; Overrides an existing entry;
4301 ;; just set the header part of the entry.
23f87bed
MB
4302 (setcar (symbol-value id-dep) header)
4303 (setq replaced t))
6748645f
LMI
4304
4305 ;; Renames the existing `header' to a unique Message-ID.
4306 ((not gnus-summary-ignore-duplicates)
4307 ;; An article with this Message-ID has already been seen.
4308 ;; We rename the Message-ID.
4309 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4310 (list header))
4311 (mail-header-set-id header id))
4312
4313 ;; The last case ignores an existing entry, except it adds any
4314 ;; additional Xrefs (in case the two articles came from different
4315 ;; servers.
4316 ;; Also sets `header' to `nil' meaning that the `dependencies'
4317 ;; table was *not* modified.
4318 (t
4319 (mail-header-set-xref
4320 (car (symbol-value id-dep))
4321 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4322 "")
4323 (or (mail-header-xref header) "")))
4324 (setq header nil)))
4325
23f87bed
MB
4326 (when (and header (not replaced))
4327 ;; First check that we are not creating a References loop.
4328 (setq parent-id (gnus-parent-id (mail-header-references header)))
4329 (setq ref parent-id)
6748645f
LMI
4330 (while (and ref
4331 (setq ref-dep (intern-soft ref dependencies))
4332 (boundp ref-dep)
4333 (setq ref-header (car (symbol-value ref-dep))))
4334 (if (string= id ref)
4335 ;; Yuk! This is a reference loop. Make the article be a
4336 ;; root article.
4337 (progn
4338 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4339 (setq ref nil)
4340 (setq parent-id nil))
6748645f 4341 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4342 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4343 (if (boundp ref-dep)
4344 (setcdr (symbol-value ref-dep)
4345 (nconc (cdr (symbol-value ref-dep))
4346 (list (symbol-value id-dep))))
4347 (set ref-dep (list nil (symbol-value id-dep)))))
4348 header))
4349
23f87bed
MB
4350(defun gnus-extract-message-id-from-in-reply-to (string)
4351 (if (string-match "<[^>]+>" string)
4352 (substring string (match-beginning 0) (match-end 0))
4353 nil))
4354
eec82323
LMI
4355(defun gnus-build-sparse-threads ()
4356 (let ((headers gnus-newsgroup-headers)
16409b0b 4357 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4358 (gnus-summary-ignore-duplicates t)
eec82323 4359 header references generation relations
6748645f 4360 subject child end new-child date)
eec82323
LMI
4361 ;; First we create an alist of generations/relations, where
4362 ;; generations is how much we trust the relation, and the relation
4363 ;; is parent/child.
4364 (gnus-message 7 "Making sparse threads...")
4365 (save-excursion
4366 (nnheader-set-temp-buffer " *gnus sparse threads*")
4367 (while (setq header (pop headers))
4368 (when (and (setq references (mail-header-references header))
4369 (not (string= references "")))
4370 (insert references)
4371 (setq child (mail-header-id header)
6748645f
LMI
4372 subject (mail-header-subject header)
4373 date (mail-header-date header)
4374 generation 0)
eec82323
LMI
4375 (while (search-backward ">" nil t)
4376 (setq end (1+ (point)))
4377 (when (search-backward "<" nil t)
6748645f 4378 (setq new-child (buffer-substring (point) end))
eec82323 4379 (push (list (incf generation)
6748645f
LMI
4380 child (setq child new-child)
4381 subject date)
eec82323 4382 relations)))
6748645f
LMI
4383 (when child
4384 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4385 (erase-buffer)))
4386 (kill-buffer (current-buffer)))
4387 ;; Sort over trustworthiness.
01c52d31
MB
4388 (dolist (relation (sort relations 'car-less-than-car))
4389 (when (gnus-dependencies-add-header
4390 (make-full-mail-header
4391 gnus-reffed-article-number
4392 (nth 3 relation) "" (or (nth 4 relation) "")
4393 (nth 1 relation)
4394 (or (nth 2 relation) "") 0 0 "")
4395 gnus-newsgroup-dependencies nil)
4396 (push gnus-reffed-article-number gnus-newsgroup-limit)
4397 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4398 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4399 gnus-newsgroup-reads)
4400 (decf gnus-reffed-article-number)))
eec82323
LMI
4401 (gnus-message 7 "Making sparse threads...done")))
4402
4403(defun gnus-build-old-threads ()
4404 ;; Look at all the articles that refer back to old articles, and
4405 ;; fetch the headers for the articles that aren't there. This will
4406 ;; build complete threads - if the roots haven't been expired by the
4407 ;; server, that is.
16409b0b
GM
4408 (let ((mail-parse-charset gnus-newsgroup-charset)
4409 id heads)
eec82323
LMI
4410 (mapatoms
4411 (lambda (refs)
4412 (when (not (car (symbol-value refs)))
4413 (setq heads (cdr (symbol-value refs)))
4414 (while heads
4415 (if (memq (mail-header-number (caar heads))
4416 gnus-newsgroup-dormant)
4417 (setq heads (cdr heads))
4418 (setq id (symbol-name refs))
4419 (while (and (setq id (gnus-build-get-header id))
6748645f 4420 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4421 (setq heads nil)))))
4422 gnus-newsgroup-dependencies)))
4423
23f87bed
MB
4424(defsubst gnus-remove-odd-characters (string)
4425 "Translate STRING into something that doesn't contain weird characters."
4426 (mm-subst-char-in-string
4427 ?\r ?\-
01c52d31 4428 (mm-subst-char-in-string ?\n ?\- string t) t))
23f87bed 4429
6748645f
LMI
4430;; This function has to be called with point after the article number
4431;; on the beginning of the line.
4432(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
01c52d31 4433 (let ((eol (point-at-eol))
6748645f 4434 (buffer (current-buffer))
23f87bed 4435 header references in-reply-to)
6748645f
LMI
4436
4437 ;; overview: [num subject from date id refs chars lines misc]
4438 (unwind-protect
23f87bed 4439 (let (x)
6748645f
LMI
4440 (narrow-to-region (point) eol)
4441 (unless (eobp)
4442 (forward-char))
4443
4444 (setq header
4445 (make-full-mail-header
4446 number ; number
23f87bed
MB
4447 (condition-case () ; subject
4448 (gnus-remove-odd-characters
4449 (funcall gnus-decode-encoded-word-function
4450 (setq x (nnheader-nov-field))))
4451 (error x))
4452 (condition-case () ; from
4453 (gnus-remove-odd-characters
343d6628 4454 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4455 (setq x (nnheader-nov-field))))
4456 (error x))
16409b0b 4457 (nnheader-nov-field) ; date
01c52d31 4458 (nnheader-nov-read-message-id number) ; id
23f87bed 4459 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4460 (nnheader-nov-read-integer) ; chars
4461 (nnheader-nov-read-integer) ; lines
4462 (unless (eobp)
8b93df01
DL
4463 (if (looking-at "Xref: ")
4464 (goto-char (match-end 0)))
4465 (nnheader-nov-field)) ; Xref
16409b0b 4466 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4467
4468 (widen))
4469
23f87bed
MB
4470 (when (and (string= references "")
4471 (setq in-reply-to (mail-header-extra header))
4472 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4473 (mail-header-set-references
4474 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4475
6748645f
LMI
4476 (when gnus-alter-header-function
4477 (funcall gnus-alter-header-function header))
4478 (gnus-dependencies-add-header header dependencies force-new)))
4479
eec82323 4480(defun gnus-build-get-header (id)
16409b0b
GM
4481 "Look through the buffer of NOV lines and find the header to ID.
4482Enter this line into the dependencies hash table, and return
4483the id of the parent article (if any)."
eec82323
LMI
4484 (let ((deps gnus-newsgroup-dependencies)
4485 found header)
4486 (prog1
c7a91ce1 4487 (with-current-buffer nntp-server-buffer
eec82323
LMI
4488 (let ((case-fold-search nil))
4489 (goto-char (point-min))
4490 (while (and (not found)
4491 (search-forward id nil t))
4492 (beginning-of-line)
4493 (setq found (looking-at
4494 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4495 (regexp-quote id))))
4496 (or found (beginning-of-line 2)))
4497 (when found
4498 (beginning-of-line)
4499 (and
4500 (setq header (gnus-nov-parse-line
4501 (read (current-buffer)) deps))
4502 (gnus-parent-id (mail-header-references header))))))
4503 (when header
4504 (let ((number (mail-header-number header)))
4505 (push number gnus-newsgroup-limit)
4506 (push header gnus-newsgroup-headers)
4507 (if (memq number gnus-newsgroup-unselected)
4508 (progn
23f87bed
MB
4509 (setq gnus-newsgroup-unreads
4510 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4511 number))
eec82323
LMI
4512 (setq gnus-newsgroup-unselected
4513 (delq number gnus-newsgroup-unselected)))
4514 (push number gnus-newsgroup-ancient)))))))
4515
6748645f
LMI
4516(defun gnus-build-all-threads ()
4517 "Read all the headers."
4518 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4519 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4520 (dependencies gnus-newsgroup-dependencies)
4521 header article)
c7a91ce1 4522 (with-current-buffer nntp-server-buffer
6748645f
LMI
4523 (let ((case-fold-search nil))
4524 (goto-char (point-min))
4525 (while (not (eobp))
4526 (ignore-errors
4527 (setq article (read (current-buffer))
181cb5fb 4528 header (gnus-nov-parse-line article dependencies t)))
6748645f 4529 (when header
01c52d31 4530 (with-current-buffer gnus-summary-buffer
6748645f
LMI
4531 (push header gnus-newsgroup-headers)
4532 (if (memq (setq article (mail-header-number header))
4533 gnus-newsgroup-unselected)
4534 (progn
23f87bed
MB
4535 (setq gnus-newsgroup-unreads
4536 (gnus-add-to-sorted-list
4537 gnus-newsgroup-unreads article))
6748645f
LMI
4538 (setq gnus-newsgroup-unselected
4539 (delq article gnus-newsgroup-unselected)))
4540 (push article gnus-newsgroup-ancient)))
4541 (forward-line 1)))))))
4542
eec82323 4543(defun gnus-summary-update-article-line (article header)
23f87bed 4544 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4545 (let* ((id (mail-header-id header))
4546 (thread (gnus-id-to-thread id)))
4547 (unless thread
4548 (error "Article in no thread"))
4549 ;; Update the thread.
4550 (setcar thread header)
4551 (gnus-summary-goto-subject article)
4552 (let* ((datal (gnus-data-find-list article))
4553 (data (car datal))
c7a91ce1 4554 (inhibit-read-only t)
eec82323
LMI
4555 (level (gnus-summary-thread-level)))
4556 (gnus-delete-line)
23f87bed
MB
4557 (let ((inserted (- (point)
4558 (progn
4559 (gnus-summary-insert-line
4560 header level nil
4561 (memq article gnus-newsgroup-undownloaded)
4562 (gnus-article-mark article)
4563 (memq article gnus-newsgroup-replied)
4564 (memq article gnus-newsgroup-expirable)
4565 ;; Only insert the Subject string when it's different
4566 ;; from the previous Subject string.
4567 (if (and
4568 gnus-show-threads
4569 (gnus-subject-equal
4570 (condition-case ()
4571 (mail-header-subject
4572 (gnus-data-header
4573 (cadr
4574 (gnus-data-find-list
4575 article
4576 (gnus-data-list t)))))
4577 ;; Error on the side of excessive subjects.
4578 (error ""))
4579 (mail-header-subject header)))
4580 ""
4581 (mail-header-subject header))
4582 nil (cdr (assq article gnus-newsgroup-scored))
4583 (memq article gnus-newsgroup-processable))
4584 (point)))))
4585 (when (cdr datal)
4586 (gnus-data-update-list
4587 (cdr datal)
4588 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4589
4590(defun gnus-summary-update-article (article &optional iheader)
4591 "Update ARTICLE in the summary buffer."
4592 (set-buffer gnus-summary-buffer)
6748645f 4593 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4594 (id (mail-header-id header))
4595 (data (gnus-data-find article))
4596 (thread (gnus-id-to-thread id))
4597 (references (mail-header-references header))
4598 (parent
4599 (gnus-id-to-thread
4600 (or (gnus-parent-id
4601 (when (and references
4602 (not (equal "" references)))
4603 references))
4604 "none")))
c7a91ce1 4605 (inhibit-read-only t)
6748645f 4606 (old (car thread)))
eec82323 4607 (when thread
eec82323 4608 (unless iheader
6748645f
LMI
4609 (setcar thread nil)
4610 (when parent
4611 (delq thread parent)))
4612 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4613 ;; Set the (possibly) new article number in the data structure.
4614 (gnus-data-set-number data (gnus-id-to-article id))
4615 (setcar thread old)
4616 nil))))
4617
6748645f
LMI
4618(defun gnus-rebuild-thread (id &optional line)
4619 "Rebuild the thread containing ID.
4620If LINE, insert the rebuilt thread starting on line LINE."
c7a91ce1 4621 (let ((inhibit-read-only t)
eec82323
LMI
4622 old-pos current thread data)
4623 (if (not gnus-show-threads)
4624 (setq thread (list (car (gnus-id-to-thread id))))
4625 ;; Get the thread this article is part of.
4626 (setq thread (gnus-remove-thread id)))
01c52d31 4627 (setq old-pos (point-at-bol))
eec82323 4628 (setq current (save-excursion
94384150 4629 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4630 (gnus-summary-article-number))))
4631 ;; If this is a gathered thread, we have to go some re-gathering.
4632 (when (stringp (car thread))
4633 (let ((subject (car thread))
4634 roots thr)
4635 (setq thread (cdr thread))
4636 (while thread
4637 (unless (memq (setq thr (gnus-id-to-thread
4638 (gnus-root-id
4639 (mail-header-id (caar thread)))))
4640 roots)
4641 (push thr roots))
4642 (setq thread (cdr thread)))
4643 ;; We now have all (unique) roots.
4644 (if (= (length roots) 1)
4645 ;; All the loose roots are now one solid root.
4646 (setq thread (car roots))
4647 (setq thread (cons subject (gnus-sort-threads roots))))))
4648 (let (threads)
4649 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4650 (when line
4651 (goto-char (point-min))
4652 (forward-line (1- line)))
eec82323
LMI
4653 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4654 (if gnus-show-threads
4655 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4656 (gnus-summary-prepare-unthreaded thread))
4657 (setq data (nreverse gnus-newsgroup-data))
4658 (setq threads gnus-newsgroup-threads))
4659 ;; We splice the new data into the data structure.
6748645f
LMI
4660 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4661 ;;!!! then we want to insert at the beginning of the buffer.
4662 ;;!!! That happens to be true with Gnus now, but that may
4663 ;;!!! change in the future. Perhaps.
4664 (gnus-data-enter-list
4665 (if line nil current) data (- (point) old-pos))
4666 (setq gnus-newsgroup-threads
4667 (nconc threads gnus-newsgroup-threads))
4668 (gnus-data-compute-positions))))
eec82323
LMI
4669
4670(defun gnus-number-to-header (number)
4671 "Return the header for article NUMBER."
4672 (let ((headers gnus-newsgroup-headers))
4673 (while (and headers
4674 (not (= number (mail-header-number (car headers)))))
4675 (pop headers))
4676 (when headers
4677 (car headers))))
4678
6748645f 4679(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4680 "Return the headers of the GENERATIONeth parent of HEADERS."
4681 (unless generation
4682 (setq generation 1))
a8151ef7 4683 (let ((parent t)
6748645f 4684 (headers in-headers)
a8151ef7 4685 references)
6748645f
LMI
4686 (while (and parent
4687 (not (zerop generation))
4688 (setq references (mail-header-references headers)))
4689 (setq headers (if (and references
4690 (setq parent (gnus-parent-id references)))
4691 (car (gnus-id-to-thread parent))
4692 nil))
4693 (decf generation))
4694 (and (not (eq headers in-headers))
4695 headers)))
eec82323
LMI
4696
4697(defun gnus-id-to-thread (id)
4698 "Return the (sub-)thread where ID appears."
4699 (gnus-gethash id gnus-newsgroup-dependencies))
4700
4701(defun gnus-id-to-article (id)
4702 "Return the article number of ID."
4703 (let ((thread (gnus-id-to-thread id)))
4704 (when (and thread
4705 (car thread))
4706 (mail-header-number (car thread)))))
4707
4708(defun gnus-id-to-header (id)
4709 "Return the article headers of ID."
4710 (car (gnus-id-to-thread id)))
4711
4712(defun gnus-article-displayed-root-p (article)
4713 "Say whether ARTICLE is a root(ish) article."
4714 (let ((level (gnus-summary-thread-level article))
4715 (refs (mail-header-references (gnus-summary-article-header article)))
4716 particle)
4717 (cond
4718 ((null level) nil)
4719 ((zerop level) t)
4720 ((null refs) t)
4721 ((null (gnus-parent-id refs)) t)
4722 ((and (= 1 level)
4723 (null (setq particle (gnus-id-to-article
4724 (gnus-parent-id refs))))
4725 (null (gnus-summary-thread-level particle)))))))
4726
4727(defun gnus-root-id (id)
4728 "Return the id of the root of the thread where ID appears."
4729 (let (last-id prev)
6748645f 4730 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4731 (setq last-id id
4732 id (gnus-parent-id (mail-header-references prev))))
4733 last-id))
4734
6748645f
LMI
4735(defun gnus-articles-in-thread (thread)
4736 "Return the list of articles in THREAD."
4737 (cons (mail-header-number (car thread))
4738 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4739
eec82323
LMI
4740(defun gnus-remove-thread (id &optional dont-remove)
4741 "Remove the thread that has ID in it."
6748645f 4742 (let (headers thread last-id)
eec82323 4743 ;; First go up in this thread until we find the root.
6748645f
LMI
4744 (setq last-id (gnus-root-id id)
4745 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4746 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4747 ;; been gathered into some loose thread, so we have to search
4748 ;; through the threads to find the thread we wanted.
4749 (let ((threads gnus-newsgroup-threads)
4750 sub)
4751 (while threads
4752 (setq sub (car threads))
4753 (if (stringp (car sub))
4754 ;; This is a gathered thread, so we look at the roots
4755 ;; below it to find whether this article is in this
4756 ;; gathered root.
4757 (progn
4758 (setq sub (cdr sub))
4759 (while sub
4760 (when (member (caar sub) headers)
4761 (setq thread (car threads)
4762 threads nil
4763 sub nil))
4764 (setq sub (cdr sub))))
4765 ;; It's an ordinary thread, so we check it.
4766 (when (eq (car sub) (car headers))
4767 (setq thread sub
4768 threads nil)))
4769 (setq threads (cdr threads)))
4770 ;; If this article is in no thread, then it's a root.
4771 (if thread
4772 (unless dont-remove
4773 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4774 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4775 (when thread
4776 (prog1
4777 thread ; We return this thread.
4778 (unless dont-remove
4779 (if (stringp (car thread))
4780 (progn
4781 ;; If we use dummy roots, then we have to remove the
4782 ;; dummy root as well.
4783 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4784 ;; We go to the dummy root by going to
4785 ;; the first sub-"thread", and then one line up.
4786 (gnus-summary-goto-article
4787 (mail-header-number (caadr thread)))
4788 (forward-line -1)
eec82323
LMI
4789 (gnus-delete-line)
4790 (gnus-data-compute-positions))
4791 (setq thread (cdr thread))
4792 (while thread
4793 (gnus-remove-thread-1 (car thread))
4794 (setq thread (cdr thread))))
4795 (gnus-remove-thread-1 thread))))))))
4796
4797(defun gnus-remove-thread-1 (thread)
4798 "Remove the thread THREAD recursively."
4799 (let ((number (mail-header-number (pop thread)))
4800 d)
4801 (setq thread (reverse thread))
4802 (while thread
4803 (gnus-remove-thread-1 (pop thread)))
4804 (when (setq d (gnus-data-find number))
4805 (goto-char (gnus-data-pos d))
16409b0b 4806 (gnus-summary-show-thread)
eec82323
LMI
4807 (gnus-data-remove
4808 number
01c52d31 4809 (- (point-at-bol)
eec82323 4810 (prog1
01c52d31 4811 (1+ (point-at-eol))
eec82323
LMI
4812 (gnus-delete-line)))))))
4813
4921bbdd 4814(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4815 (sort (mapcar (lambda (thread)
4816 (cons (car thread)
4817 (and (cdr thread)
4921bbdd 4818 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4819 threads) func))
4820
4921bbdd
CY
4821(defun gnus-sort-threads-loop (threads func)
4822 (let* ((superthread (cons nil threads))
4823 (stack (list (cons superthread threads)))
4824 remaining-threads thread)
4825 (while stack
4826 (setq remaining-threads (cdr (car stack)))
4827 (if remaining-threads
4828 (progn (setq thread (car remaining-threads))
4829 (setcdr (car stack) (cdr remaining-threads))
4830 (if (cdr thread)
4831 (push (cons thread (cdr thread)) stack)))
4832 (setq thread (caar stack))
4833 (setcdr thread (sort (cdr thread) func))
4834 (pop stack)))
4835 (cdr superthread)))
4836
eec82323
LMI
4837(defun gnus-sort-threads (threads)
4838 "Sort THREADS."
4839 (if (not gnus-thread-sort-functions)
4840 threads
6748645f 4841 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4842 (prog1
4843 (condition-case nil
4844 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4845 (gnus-sort-threads-recursive
4846 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4847 ;; Even after binding max-lisp-eval-depth, the recursive
4848 ;; sorter might fail for very long threads. In that case,
4849 ;; try using a (less well-tested) non-recursive sorter.
3d6e7a43
KY
4850 (error (gnus-message 9 "Sorting threads with loop...")
4851 (gnus-sort-threads-loop
4921bbdd
CY
4852 threads (gnus-make-sort-function
4853 gnus-thread-sort-functions))))
4854 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4855
4856(defun gnus-sort-articles (articles)
4857 "Sort ARTICLES."
4858 (when gnus-article-sort-functions
4859 (gnus-message 7 "Sorting articles...")
4860 (prog1
4861 (setq gnus-newsgroup-headers
4862 (sort articles (gnus-make-sort-function
4863 gnus-article-sort-functions)))
4864 (gnus-message 7 "Sorting articles...done"))))
4865
4866;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4867(defmacro gnus-thread-header (thread)
16409b0b
GM
4868 "Return header of first article in THREAD.
4869Note that THREAD must never, ever be anything else than a variable -
4870using some other form will lead to serious barfage."
eec82323
LMI
4871 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4872 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4873 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4874 (vector thread) 2))
4875
4876(defsubst gnus-article-sort-by-number (h1 h2)
4877 "Sort articles by article number."
4878 (< (mail-header-number h1)
4879 (mail-header-number h2)))
4880
4881(defun gnus-thread-sort-by-number (h1 h2)
4882 "Sort threads by root article number."
4883 (gnus-article-sort-by-number
4884 (gnus-thread-header h1) (gnus-thread-header h2)))
4885
23f87bed 4886(defsubst gnus-article-sort-by-random (h1 h2)
0b6799c3 4887 "Sort articles randomly."
23f87bed
MB
4888 (zerop (random 2)))
4889
4890(defun gnus-thread-sort-by-random (h1 h2)
0b6799c3 4891 "Sort threads randomly."
23f87bed
MB
4892 (gnus-article-sort-by-random
4893 (gnus-thread-header h1) (gnus-thread-header h2)))
4894
eec82323
LMI
4895(defsubst gnus-article-sort-by-lines (h1 h2)
4896 "Sort articles by article Lines header."
4897 (< (mail-header-lines h1)
4898 (mail-header-lines h2)))
4899
4900(defun gnus-thread-sort-by-lines (h1 h2)
4901 "Sort threads by root article Lines header."
4902 (gnus-article-sort-by-lines
4903 (gnus-thread-header h1) (gnus-thread-header h2)))
4904
16409b0b
GM
4905(defsubst gnus-article-sort-by-chars (h1 h2)
4906 "Sort articles by octet length."
4907 (< (mail-header-chars h1)
4908 (mail-header-chars h2)))
4909
4910(defun gnus-thread-sort-by-chars (h1 h2)
4911 "Sort threads by root article octet length."
4912 (gnus-article-sort-by-chars
4913 (gnus-thread-header h1) (gnus-thread-header h2)))
4914
eec82323
LMI
4915(defsubst gnus-article-sort-by-author (h1 h2)
4916 "Sort articles by root author."
b4fde39f 4917 (gnus-string<
eec82323
LMI
4918 (let ((extract (funcall
4919 gnus-extract-address-components
4920 (mail-header-from h1))))
4921 (or (car extract) (cadr extract) ""))
4922 (let ((extract (funcall
4923 gnus-extract-address-components
4924 (mail-header-from h2))))
4925 (or (car extract) (cadr extract) ""))))
4926
4927(defun gnus-thread-sort-by-author (h1 h2)
4928 "Sort threads by root author."
4929 (gnus-article-sort-by-author
4930 (gnus-thread-header h1) (gnus-thread-header h2)))
4931
01c52d31
MB
4932(defsubst gnus-article-sort-by-recipient (h1 h2)
4933 "Sort articles by recipient."
4934 (gnus-string<
4935 (let ((extract (funcall
4936 gnus-extract-address-components
4937 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4938 (or (car extract) (cadr extract)))
4939 (let ((extract (funcall
4940 gnus-extract-address-components
4941 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4942 (or (car extract) (cadr extract)))))
4943
4944(defun gnus-thread-sort-by-recipient (h1 h2)
4945 "Sort threads by root recipient."
4946 (gnus-article-sort-by-recipient
4947 (gnus-thread-header h1) (gnus-thread-header h2)))
4948
eec82323
LMI
4949(defsubst gnus-article-sort-by-subject (h1 h2)
4950 "Sort articles by root subject."
b4fde39f 4951 (gnus-string<
eec82323
LMI
4952 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4953 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4954
4955(defun gnus-thread-sort-by-subject (h1 h2)
4956 "Sort threads by root subject."
4957 (gnus-article-sort-by-subject
4958 (gnus-thread-header h1) (gnus-thread-header h2)))
4959
4960(defsubst gnus-article-sort-by-date (h1 h2)
4961 "Sort articles by root article date."
16409b0b 4962 (time-less-p
eec82323
LMI
4963 (gnus-date-get-time (mail-header-date h1))
4964 (gnus-date-get-time (mail-header-date h2))))
4965
4966(defun gnus-thread-sort-by-date (h1 h2)
4967 "Sort threads by root article date."
4968 (gnus-article-sort-by-date
4969 (gnus-thread-header h1) (gnus-thread-header h2)))
4970
4971(defsubst gnus-article-sort-by-score (h1 h2)
4972 "Sort articles by root article score.
4973Unscored articles will be counted as having a score of zero."
4974 (> (or (cdr (assq (mail-header-number h1)
4975 gnus-newsgroup-scored))
4976 gnus-summary-default-score 0)
4977 (or (cdr (assq (mail-header-number h2)
4978 gnus-newsgroup-scored))
4979 gnus-summary-default-score 0)))
4980
4981(defun gnus-thread-sort-by-score (h1 h2)
4982 "Sort threads by root article score."
4983 (gnus-article-sort-by-score
4984 (gnus-thread-header h1) (gnus-thread-header h2)))
4985
4986(defun gnus-thread-sort-by-total-score (h1 h2)
4987 "Sort threads by the sum of all scores in the thread.
4988Unscored articles will be counted as having a score of zero."
4989 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4990
4991(defun gnus-thread-total-score (thread)
16409b0b 4992 ;; This function find the total score of THREAD.
23f87bed
MB
4993 (cond
4994 ((null thread)
4995 0)
4996 ((consp thread)
4997 (if (stringp (car thread))
4998 (apply gnus-thread-score-function 0
4999 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5000 (gnus-thread-total-score-1 thread)))
5001 (t
5002 (gnus-thread-total-score-1 (list thread)))))
5003
130e977f
LMI
5004(defun gnus-article-sort-by-most-recent-number (h1 h2)
5005 "Sort articles by number."
5006 (gnus-article-sort-by-number h1 h2))
5007
23f87bed
MB
5008(defun gnus-thread-sort-by-most-recent-number (h1 h2)
5009 "Sort threads such that the thread with the most recently arrived article comes first."
5010 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5011
5012(defun gnus-thread-highest-number (thread)
5013 "Return the highest article number in THREAD."
5014 (apply 'max (mapcar (lambda (header)
5015 (mail-header-number header))
5016 (message-flatten-list thread))))
5017
130e977f
LMI
5018(defun gnus-article-sort-by-most-recent-date (h1 h2)
5019 "Sort articles by number."
5020 (gnus-article-sort-by-date h1 h2))
5021
23f87bed
MB
5022(defun gnus-thread-sort-by-most-recent-date (h1 h2)
5023 "Sort threads such that the thread with the most recently dated article comes first."
5024 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5025
3d6e7a43
KY
5026; Since this is called not only to sort the top-level threads, but
5027; also in recursive sorts to order the articles within a thread, each
5028; article will be processed many times. Thus it speeds things up
5029; quite a bit to use gnus-date-get-time, which caches the time value.
23f87bed
MB
5030(defun gnus-thread-latest-date (thread)
5031 "Return the highest article date in THREAD."
3d6e7a43
KY
5032 (apply 'max
5033 (mapcar (lambda (header) (gnus-float-time
5034 (gnus-date-get-time
5035 (mail-header-date header))))
5036 (message-flatten-list thread))))
eec82323
LMI
5037
5038(defun gnus-thread-total-score-1 (root)
5039 ;; This function find the total score of the thread below ROOT.
5040 (setq root (car root))
5041 (apply gnus-thread-score-function
5042 (or (append
5043 (mapcar 'gnus-thread-total-score
6748645f 5044 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
5045 (when (> (mail-header-number root) 0)
5046 (list (or (cdr (assq (mail-header-number root)
5047 gnus-newsgroup-scored))
5048 gnus-summary-default-score 0))))
5049 (list gnus-summary-default-score)
5050 '(0))))
5051
5052;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5053(defvar gnus-tmp-prev-subject nil)
5054(defvar gnus-tmp-false-parent nil)
5055(defvar gnus-tmp-root-expunged nil)
5056(defvar gnus-tmp-dummy-line nil)
5057
16409b0b
GM
5058(defun gnus-extra-header (type &optional header)
5059 "Return the extra header of TYPE."
5060 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5061 ""))
5062
23f87bed
MB
5063(defvar gnus-tmp-thread-tree-header-string "")
5064
5065(defcustom gnus-sum-thread-tree-root "> "
5066 "With %B spec, used for the root of a thread.
5067If nil, use subject instead."
bf247b6e 5068 :version "22.1"
ad136a7c 5069 :type '(radio (const :format "%v " nil) string)
23f87bed 5070 :group 'gnus-thread)
01c52d31 5071
23f87bed
MB
5072(defcustom gnus-sum-thread-tree-false-root "> "
5073 "With %B spec, used for a false root of a thread.
5074If nil, use subject instead."
bf247b6e 5075 :version "22.1"
ad136a7c 5076 :type '(radio (const :format "%v " nil) string)
23f87bed 5077 :group 'gnus-thread)
01c52d31 5078
23f87bed
MB
5079(defcustom gnus-sum-thread-tree-single-indent ""
5080 "With %B spec, used for a thread with just one message.
5081If nil, use subject instead."
bf247b6e 5082 :version "22.1"
ad136a7c 5083 :type '(radio (const :format "%v " nil) string)
23f87bed 5084 :group 'gnus-thread)
01c52d31 5085
23f87bed
MB
5086(defcustom gnus-sum-thread-tree-vertical "| "
5087 "With %B spec, used for drawing a vertical line."
bf247b6e 5088 :version "22.1"
23f87bed
MB
5089 :type 'string
5090 :group 'gnus-thread)
01c52d31 5091
23f87bed
MB
5092(defcustom gnus-sum-thread-tree-indent " "
5093 "With %B spec, used for indenting."
bf247b6e 5094 :version "22.1"
23f87bed
MB
5095 :type 'string
5096 :group 'gnus-thread)
01c52d31 5097
23f87bed
MB
5098(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5099 "With %B spec, used for a leaf with brothers."
bf247b6e 5100 :version "22.1"
23f87bed
MB
5101 :type 'string
5102 :group 'gnus-thread)
01c52d31 5103
23f87bed
MB
5104(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5105 "With %B spec, used for a leaf without brothers."
bf247b6e 5106 :version "22.1"
23f87bed
MB
5107 :type 'string
5108 :group 'gnus-thread)
5109
1fc34624
GM
5110(defcustom gnus-summary-display-while-building nil
5111 "If non-nil, show and update the summary buffer as it's being built.
5112If the value is t, update the buffer after every line is inserted. If
5113the value is an integer (N), update the display every N lines."
5114 :version "22.1"
5115 :group 'gnus-thread
5116 :type '(choice (const :tag "off" nil)
5117 number
5118 (const :tag "frequently" t)))
5119
eec82323
LMI
5120(defun gnus-summary-prepare-threads (threads)
5121 "Prepare summary buffer from THREADS and indentation LEVEL.
5122THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5123or a straight list of headers."
5124 (gnus-message 7 "Generating summary...")
5125
5126 (setq gnus-newsgroup-threads threads)
5127 (beginning-of-line)
5128
5129 (let ((gnus-tmp-level 0)
5130 (default-score (or gnus-summary-default-score 0))
5131 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
5132 (building-line-count gnus-summary-display-while-building)
5133 (building-count (integerp gnus-summary-display-while-building))
eec82323 5134 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
5135 new-roots gnus-tmp-new-adopts thread-end simp-subject
5136 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
5137 gnus-tmp-replied gnus-tmp-subject-or-nil
5138 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5139 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
5140 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5141 tree-stack)
eec82323 5142
23f87bed
MB
5143 (setq gnus-tmp-prev-subject nil
5144 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
5145
5146 (if (vectorp (car threads))
5147 ;; If this is a straight (sic) list of headers, then a
5148 ;; threaded summary display isn't required, so we just create
5149 ;; an unthreaded one.
5150 (gnus-summary-prepare-unthreaded threads)
5151
5152 ;; Do the threaded display.
5153
23f87bed
MB
5154 (if gnus-summary-display-while-building
5155 (switch-to-buffer (buffer-name)))
eec82323
LMI
5156 (while (or threads stack gnus-tmp-new-adopts new-roots)
5157
5158 (if (and (= gnus-tmp-level 0)
eec82323
LMI
5159 (or (not stack)
5160 (= (caar stack) 0))
5161 (not gnus-tmp-false-parent)
5162 (or gnus-tmp-new-adopts new-roots))
5163 (if gnus-tmp-new-adopts
5164 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5165 thread (list (car gnus-tmp-new-adopts))
5166 gnus-tmp-header (caar thread)
5167 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5168 (when new-roots
5169 (setq thread (list (car new-roots))
5170 gnus-tmp-header (caar thread)
5171 new-roots (cdr new-roots))))
5172
5173 (if threads
5174 ;; If there are some threads, we do them before the
5175 ;; threads on the stack.
5176 (setq thread threads
5177 gnus-tmp-header (caar thread))
5178 ;; There were no current threads, so we pop something off
5179 ;; the stack.
5180 (setq state (car stack)
5181 gnus-tmp-level (car state)
23f87bed
MB
5182 tree-stack (cadr state)
5183 thread (caddr state)
eec82323
LMI
5184 stack (cdr stack)
5185 gnus-tmp-header (caar thread))))
5186
5187 (setq gnus-tmp-false-parent nil)
5188 (setq gnus-tmp-root-expunged nil)
5189 (setq thread-end nil)
5190
5191 (if (stringp gnus-tmp-header)
5192 ;; The header is a dummy root.
5193 (cond
5194 ((eq gnus-summary-make-false-root 'adopt)
5195 ;; We let the first article adopt the rest.
5196 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5197 (cddar thread)))
5198 (setq gnus-tmp-gathered
5199 (nconc (mapcar
5200 (lambda (h) (mail-header-number (car h)))
5201 (cddar thread))
5202 gnus-tmp-gathered))
5203 (setq thread (cons (list (caar thread)
5204 (cadar thread))
5205 (cdr thread)))
5206 (setq gnus-tmp-level -1
5207 gnus-tmp-false-parent t))
5208 ((eq gnus-summary-make-false-root 'empty)
5209 ;; We print adopted articles with empty subject fields.
5210 (setq gnus-tmp-gathered
5211 (nconc (mapcar
5212 (lambda (h) (mail-header-number (car h)))
5213 (cddar thread))
5214 gnus-tmp-gathered))
5215 (setq gnus-tmp-level -1))
5216 ((eq gnus-summary-make-false-root 'dummy)
5217 ;; We remember that we probably want to output a dummy
5218 ;; root.
5219 (setq gnus-tmp-dummy-line gnus-tmp-header)
5220 (setq gnus-tmp-prev-subject gnus-tmp-header))
5221 (t
5222 ;; We do not make a root for the gathered
5223 ;; sub-threads at all.
5224 (setq gnus-tmp-level -1)))
5225
5226 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
5227 subject (mail-header-subject gnus-tmp-header)
5228 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
5229
5230 (cond
5231 ;; If the thread has changed subject, we might want to make
5232 ;; this subthread into a root.
5233 ((and (null gnus-thread-ignore-subject)
5234 (not (zerop gnus-tmp-level))
5235 gnus-tmp-prev-subject
23f87bed 5236 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5237 (setq new-roots (nconc new-roots (list (car thread)))
5238 thread-end t
5239 gnus-tmp-header nil))
5240 ;; If the article lies outside the current limit,
5241 ;; then we do not display it.
5242 ((not (memq number gnus-newsgroup-limit))
5243 (setq gnus-tmp-gathered
5244 (nconc (mapcar
5245 (lambda (h) (mail-header-number (car h)))
5246 (cdar thread))
5247 gnus-tmp-gathered))
5248 (setq gnus-tmp-new-adopts (if (cdar thread)
5249 (append gnus-tmp-new-adopts
5250 (cdar thread))
5251 gnus-tmp-new-adopts)
5252 thread-end t
5253 gnus-tmp-header nil)
5254 (when (zerop gnus-tmp-level)
5255 (setq gnus-tmp-root-expunged t)))
5256 ;; Perhaps this article is to be marked as read?
5257 ((and gnus-summary-mark-below
5258 (< (or (cdr (assq number gnus-newsgroup-scored))
5259 default-score)
5260 gnus-summary-mark-below)
5261 ;; Don't touch sparse articles.
5262 (not (gnus-summary-article-sparse-p number))
5263 (not (gnus-summary-article-ancient-p number)))
5264 (setq gnus-newsgroup-unreads
5265 (delq number gnus-newsgroup-unreads))
5266 (if gnus-newsgroup-auto-expire
23f87bed
MB
5267 (setq gnus-newsgroup-expirable
5268 (gnus-add-to-sorted-list
5269 gnus-newsgroup-expirable number))
eec82323
LMI
5270 (push (cons number gnus-low-score-mark)
5271 gnus-newsgroup-reads))))
5272
5273 (when gnus-tmp-header
5274 ;; We may have an old dummy line to output before this
5275 ;; article.
6748645f
LMI
5276 (when (and gnus-tmp-dummy-line
5277 (gnus-subject-equal
5278 gnus-tmp-dummy-line
5279 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
5280 (gnus-summary-insert-dummy-line
5281 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5282 (setq gnus-tmp-dummy-line nil))
5283
5284 ;; Compute the mark.
5285 (setq gnus-tmp-unread (gnus-article-mark number))
5286
5287 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5288 gnus-tmp-header gnus-tmp-level)
5289 gnus-newsgroup-data)
5290
5291 ;; Actually insert the line.
5292 (setq
5293 gnus-tmp-subject-or-nil
5294 (cond
5295 ((and gnus-thread-ignore-subject
5296 gnus-tmp-prev-subject
23f87bed 5297 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5298 subject)
5299 ((zerop gnus-tmp-level)
5300 (if (and (eq gnus-summary-make-false-root 'empty)
5301 (memq number gnus-tmp-gathered)
5302 gnus-tmp-prev-subject
23f87bed 5303 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5304 gnus-summary-same-subject
5305 subject))
5306 (t gnus-summary-same-subject)))
5307 (if (and (eq gnus-summary-make-false-root 'adopt)
5308 (= gnus-tmp-level 1)
5309 (memq number gnus-tmp-gathered))
5310 (setq gnus-tmp-opening-bracket ?\<
5311 gnus-tmp-closing-bracket ?\>)
5312 (setq gnus-tmp-opening-bracket ?\[
5313 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5314 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5315 (gnus-make-thread-indent-array
5316 (max (* 2 (length gnus-thread-indent-array))
5317 gnus-tmp-level)))
eec82323
LMI
5318 (setq
5319 gnus-tmp-indentation
5320 (aref gnus-thread-indent-array gnus-tmp-level)
5321 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5322 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5323 gnus-summary-default-score 0)
5324 gnus-tmp-score-char
5325 (if (or (null gnus-summary-default-score)
5326 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5327 gnus-summary-zcore-fuzz))
23f87bed 5328 ? ;Whitespace
eec82323
LMI
5329 (if (< gnus-tmp-score gnus-summary-default-score)
5330 gnus-score-below-mark gnus-score-over-mark))
5331 gnus-tmp-replied
5332 (cond ((memq number gnus-newsgroup-processable)
5333 gnus-process-mark)
5334 ((memq number gnus-newsgroup-cached)
5335 gnus-cached-mark)
5336 ((memq number gnus-newsgroup-replied)
5337 gnus-replied-mark)
23f87bed
MB
5338 ((memq number gnus-newsgroup-forwarded)
5339 gnus-forwarded-mark)
eec82323
LMI
5340 ((memq number gnus-newsgroup-saved)
5341 gnus-saved-mark)
23f87bed
MB
5342 ((memq number gnus-newsgroup-recent)
5343 gnus-recent-mark)
5344 ((memq number gnus-newsgroup-unseen)
5345 gnus-unseen-mark)
5346 (t gnus-no-mark))
5347 gnus-tmp-downloaded
5348 (cond ((memq number gnus-newsgroup-undownloaded)
5349 gnus-undownloaded-mark)
5350 (gnus-newsgroup-agentized
5351 gnus-downloaded-mark)
5352 (t
5353 gnus-no-mark))
eec82323
LMI
5354 gnus-tmp-from (mail-header-from gnus-tmp-header)
5355 gnus-tmp-name
5356 (cond
5357 ((string-match "<[^>]+> *$" gnus-tmp-from)
5358 (setq beg-match (match-beginning 0))
23f87bed
MB
5359 (or (and (string-match "^\".+\"" gnus-tmp-from)
5360 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5361 (substring gnus-tmp-from 0 beg-match)))
5362 ((string-match "(.+)" gnus-tmp-from)
5363 (substring gnus-tmp-from
5364 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5365 (t gnus-tmp-from))
5366
5367 ;; Do the %B string
5368 gnus-tmp-thread-tree-header-string
5369 (cond
5370 ((not gnus-show-threads) "")
5371 ((zerop gnus-tmp-level)
5372 (cond ((cdar thread)
5373 (or gnus-sum-thread-tree-root subject))
5374 (gnus-tmp-new-adopts
5375 (or gnus-sum-thread-tree-false-root subject))
5376 (t
5377 (or gnus-sum-thread-tree-single-indent subject))))
5378 (t
5379 (concat (apply 'concat
5380 (mapcar (lambda (item)
5381 (if (= item 1)
5382 gnus-sum-thread-tree-vertical
5383 gnus-sum-thread-tree-indent))
5384 (cdr (reverse tree-stack))))
5385 (if (nth 1 thread)
5386 gnus-sum-thread-tree-leaf-with-other
5387 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5388 (when (string= gnus-tmp-name "")
5389 (setq gnus-tmp-name gnus-tmp-from))
5390 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5391 (setq gnus-tmp-lines -1))
5392 (if (= gnus-tmp-lines -1)
5393 (setq gnus-tmp-lines "?")
5394 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
61b1af82
G
5395 (gnus-put-text-property
5396 (point)
5397 (progn (eval gnus-summary-line-format-spec) (point))
5398 'gnus-number number)
5399 (when gnus-visual-p
5400 (forward-line -1)
5401 (gnus-summary-highlight-line)
5402 (when gnus-summary-update-hook
5403 (gnus-run-hooks 'gnus-summary-update-hook))
5404 (forward-line 1))
5405
5406 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5407
5408 (when (nth 1 thread)
23f87bed
MB
5409 (push (list (max 0 gnus-tmp-level)
5410 (copy-sequence tree-stack)
5411 (nthcdr 1 thread))
5412 stack))
5413 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5414 (incf gnus-tmp-level)
5415 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5416 (if gnus-summary-display-while-building
5417 (if building-count
5418 (progn
5419 ;; use a set frequency
5420 (setq building-line-count (1- building-line-count))
5421 (when (= building-line-count 0)
5422 (sit-for 0)
5423 (setq building-line-count
5424 gnus-summary-display-while-building)))
5425 ;; always
5426 (sit-for 0)))
eec82323
LMI
5427 (unless threads
5428 (setq gnus-tmp-level 0)))))
5429 (gnus-message 7 "Generating summary...done"))
5430
5431(defun gnus-summary-prepare-unthreaded (headers)
5432 "Generate an unthreaded summary buffer based on HEADERS."
5433 (let (header number mark)
5434
5435 (beginning-of-line)
5436
5437 (while headers
5438 ;; We may have to root out some bad articles...
5439 (when (memq (setq number (mail-header-number
5440 (setq header (pop headers))))
5441 gnus-newsgroup-limit)
5442 ;; Mark article as read when it has a low score.
5443 (when (and gnus-summary-mark-below
5444 (< (or (cdr (assq number gnus-newsgroup-scored))
5445 gnus-summary-default-score 0)
5446 gnus-summary-mark-below)
5447 (not (gnus-summary-article-ancient-p number)))
5448 (setq gnus-newsgroup-unreads
5449 (delq number gnus-newsgroup-unreads))
5450 (if gnus-newsgroup-auto-expire
5451 (push number gnus-newsgroup-expirable)
5452 (push (cons number gnus-low-score-mark)
5453 gnus-newsgroup-reads)))
5454
5455 (setq mark (gnus-article-mark number))
5456 (push (gnus-data-make number mark (1+ (point)) header 0)
5457 gnus-newsgroup-data)
5458 (gnus-summary-insert-line
5459 header 0 number
23f87bed 5460 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5461 mark (memq number gnus-newsgroup-replied)
5462 (memq number gnus-newsgroup-expirable)
5463 (mail-header-subject header) nil
5464 (cdr (assq number gnus-newsgroup-scored))
5465 (memq number gnus-newsgroup-processable))))))
5466
16409b0b
GM
5467(defun gnus-summary-remove-list-identifiers ()
5468 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5469 (let ((regexp (if (consp gnus-list-identifiers)
5470 (mapconcat 'identity gnus-list-identifiers " *\\|")
5471 gnus-list-identifiers))
5472 changed subject)
5473 (when regexp
01c52d31 5474 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
23f87bed
MB
5475 (dolist (header gnus-newsgroup-headers)
5476 (setq subject (mail-header-subject header)
5477 changed nil)
01c52d31 5478 (while (string-match regexp subject)
23f87bed 5479 (setq subject
01c52d31 5480 (concat (substring subject 0 (match-beginning 1))
23f87bed
MB
5481 (substring subject (match-end 0)))
5482 changed t))
23f87bed 5483 (when changed
01c52d31
MB
5484 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5485 (setq subject
5486 (concat (substring subject 0 (match-beginning 1))
5487 (substring subject (match-end 1)))))
23f87bed
MB
5488 (mail-header-set-subject header subject))))))
5489
4ddab346 5490(defun gnus-fetch-headers (articles &optional limit force-new dependencies)
23f87bed
MB
5491 "Fetch headers of ARTICLES."
5492 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5493 (gnus-message 5 "Fetching headers for %s..." name)
5494 (prog1
5495 (if (eq 'nov
5496 (setq gnus-headers-retrieved-by
5497 (gnus-retrieve-headers
5498 articles gnus-newsgroup-name
4ddab346
G
5499 (or limit
5500 ;; We might want to fetch old headers, but
5501 ;; not if there is only 1 article.
5502 (and (or (and
5503 (not (eq gnus-fetch-old-headers 'some))
5504 (not (numberp gnus-fetch-old-headers)))
5505 (> (length articles) 1))
5506 gnus-fetch-old-headers)))))
23f87bed 5507 (gnus-get-newsgroup-headers-xover
4ddab346
G
5508 articles force-new dependencies gnus-newsgroup-name t)
5509 (gnus-get-newsgroup-headers dependencies force-new))
23f87bed 5510 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5511
6748645f 5512(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5513 "Select newsgroup GROUP.
6748645f
LMI
5514If READ-ALL is non-nil, all articles in the group are selected.
5515If SELECT-ARTICLES, only select those articles from GROUP."
01c52d31 5516 (let* ((entry (gnus-group-entry group))
eec82323
LMI
5517 ;;!!! Dirty hack; should be removed.
5518 (gnus-summary-ignore-duplicates
23f87bed 5519 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5520 t
5521 gnus-summary-ignore-duplicates))
5522 (info (nth 2 entry))
01c52d31 5523 charset articles fetched-articles cached)
eec82323
LMI
5524
5525 (unless (gnus-check-server
475e0e0c
GM
5526 (set (make-local-variable 'gnus-current-select-method)
5527 (gnus-find-method-for-group group)))
eec82323 5528 (error "Couldn't open server"))
01c52d31 5529 (setq charset (gnus-group-name-charset gnus-current-select-method group))
eec82323
LMI
5530
5531 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5532 (gnus-activate-group group) ; Or we can activate it...
5533 (progn ; Or we bug out.
5534 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5535 (gnus-kill-buffer (current-buffer)))
01c52d31
MB
5536 (error
5537 "Couldn't activate group %s: %s"
5538 (mm-decode-coding-string group charset)
5539 (mm-decode-coding-string (gnus-status-message group) charset))))
eec82323
LMI
5540
5541 (unless (gnus-request-group group t)
20a673b2
KY
5542 (when (equal major-mode 'gnus-summary-mode)
5543 (gnus-kill-buffer (current-buffer)))
5544 (error "Couldn't request group %s: %s"
5545 (mm-decode-coding-string group charset)
5546 (mm-decode-coding-string (gnus-status-message group) charset)))
eec82323 5547
23f87bed 5548 (when gnus-agent
54506618 5549 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5550
23f87bed
MB
5551 (setq gnus-summary-use-undownloaded-faces
5552 (gnus-agent-find-parameter
5553 group
5554 'agent-enable-undownloaded-faces)))
5555
5556 (setq gnus-newsgroup-name group
5557 gnus-newsgroup-unselected nil
5558 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5559
5560 (let ((display (gnus-group-find-parameter group 'display)))
5561 (setq gnus-newsgroup-display
5562 (cond
5563 ((not (zerop (or (car-safe read-all) 0)))
5564 ;; The user entered the group with C-u SPC/RET, let's show
5565 ;; all articles.
5566 'gnus-not-ignore)
5567 ((eq display 'all)
5568 'gnus-not-ignore)
5569 ((arrayp display)
5570 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5571 ((numberp display)
5572 ;; The following is probably the "correct" solution, but
5573 ;; it makes Gnus fetch all headers and then limit the
5574 ;; articles (which is slow), so instead we hack the
5575 ;; select-articles parameter instead. -- Simon Josefsson
5576 ;; <jas@kth.se>
5577 ;;
5578 ;; (gnus-byte-compile
5579 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5580 ;; display)))))
5581 (setq select-articles
5582 (gnus-uncompress-range
5583 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5584 (if (> tmp 0)
5585 tmp
5586 1))
5587 (cdr (gnus-active group)))))
5588 nil)
5589 (t
5590 nil))))
eec82323 5591
23f87bed 5592 (gnus-summary-setup-default-charset)
eec82323
LMI
5593
5594 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5595 (when (gnus-virtual-group-p group)
5596 (setq cached gnus-newsgroup-cached))
5597
5598 (setq gnus-newsgroup-unreads
23f87bed
MB
5599 (gnus-sorted-ndifference
5600 (gnus-sorted-ndifference gnus-newsgroup-unreads
5601 gnus-newsgroup-marked)
eec82323
LMI
5602 gnus-newsgroup-dormant))
5603
5604 (setq gnus-newsgroup-processable nil)
5605
bb7f5cbc 5606 (gnus-update-read-articles group gnus-newsgroup-unreads t)
eec82323 5607
23f87bed
MB
5608 ;; Adjust and set lists of article marks.
5609 (when info
5610 (gnus-adjust-marked-articles info))
6748645f
LMI
5611 (if (setq articles select-articles)
5612 (setq gnus-newsgroup-unselected
23f87bed 5613 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5614 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5615
5616 (cond
5617 ((null articles)
5618 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5619 'quit)
5620 ((eq articles 0) nil)
5621 (t
5622 ;; Init the dependencies hash table.
5623 (setq gnus-newsgroup-dependencies
5624 (gnus-make-hashtable (length articles)))
16409b0b 5625 (gnus-set-global-variables)
eec82323 5626 ;; Retrieve the headers and read them in.
23f87bed
MB
5627
5628 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5629
5630 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5631 (when cached
5632 (setq gnus-newsgroup-cached cached))
5633
5634 ;; Suppress duplicates?
5635 (when gnus-suppress-duplicates
5636 (gnus-dup-suppress-articles))
5637
5638 ;; Set the initial limit.
5639 (setq gnus-newsgroup-limit (copy-sequence articles))
5640 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5641 (setq fetched-articles
5642 (mapcar (lambda (headers) (mail-header-number headers))
5643 gnus-newsgroup-headers))
5644 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5645 (setq gnus-newsgroup-unreads
23f87bed
MB
5646 (gnus-sorted-nintersection
5647 gnus-newsgroup-unreads fetched-articles))
5648 (gnus-compute-unseen-list)
5649
eec82323
LMI
5650 ;; Removed marked articles that do not exist.
5651 (gnus-update-missing-marks
23f87bed 5652 (gnus-sorted-difference articles fetched-articles))
eec82323 5653 ;; We might want to build some more threads first.
6748645f
LMI
5654 (when (and gnus-fetch-old-headers
5655 (eq gnus-headers-retrieved-by 'nov))
5656 (if (eq gnus-fetch-old-headers 'invisible)
5657 (gnus-build-all-threads)
5658 (gnus-build-old-threads)))
5659 ;; Let the Gnus agent mark articles as read.
5660 (when gnus-agent
5661 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5662 ;; Remove list identifiers from subject
5663 (when gnus-list-identifiers
5664 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5665 ;; Check whether auto-expire is to be done in this group.
5666 (setq gnus-newsgroup-auto-expire
5667 (gnus-group-auto-expirable-p group))
5668 ;; Set up the article buffer now, if necessary.
01c52d31
MB
5669 (unless (and gnus-single-article-buffer
5670 (equal gnus-article-buffer "*Article*"))
eec82323
LMI
5671 (gnus-article-setup-buffer))
5672 ;; First and last article in this newsgroup.
5673 (when gnus-newsgroup-headers
5674 (setq gnus-newsgroup-begin
5675 (mail-header-number (car gnus-newsgroup-headers))
5676 gnus-newsgroup-end
5677 (mail-header-number
5678 (gnus-last-element gnus-newsgroup-headers))))
5679 ;; GROUP is successfully selected.
5680 (or gnus-newsgroup-headers t)))))
5681
23f87bed
MB
5682(defun gnus-compute-unseen-list ()
5683 ;; The `seen' marks are treated specially.
5684 (if (not gnus-newsgroup-seen)
5685 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5686 (setq gnus-newsgroup-unseen
5687 (gnus-inverse-list-range-intersection
5688 gnus-newsgroup-articles gnus-newsgroup-seen))))
5689
d09ae6ca
GM
5690(declare-function gnus-get-predicate "gnus-agent" (predicate))
5691
23f87bed
MB
5692(defun gnus-summary-display-make-predicate (display)
5693 (require 'gnus-agent)
5694 (when (= (length display) 1)
5695 (setq display (car display)))
5696 (unless gnus-summary-display-cache
5697 (dolist (elem (append '((unread . unread)
5698 (read . read)
5699 (unseen . unseen))
5700 gnus-article-mark-lists))
5701 (push (cons (cdr elem)
3a3cbf0a 5702 (gnus-byte-compile ;Why bother?
23f87bed
MB
5703 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5704 gnus-summary-display-cache)))
5705 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5706 (gnus-category-predicate-cache gnus-summary-display-cache))
5707 (gnus-get-predicate display)))
5708
3a3cbf0a
SM
5709;; Uses the dynamically bound `gnus-number' variable.
5710(defvar gnus-number)
23f87bed 5711(defun gnus-article-marked-p (type &optional article)
3a3cbf0a 5712 (let ((article (or article gnus-number)))
23f87bed
MB
5713 (cond
5714 ((eq type 'tick)
5715 (memq article gnus-newsgroup-marked))
5716 ((eq type 'spam)
5717 (memq article gnus-newsgroup-spam-marked))
5718 ((eq type 'unsend)
5719 (memq article gnus-newsgroup-unsendable))
5720 ((eq type 'undownload)
5721 (memq article gnus-newsgroup-undownloaded))
5722 ((eq type 'download)
5723 (memq article gnus-newsgroup-downloadable))
5724 ((eq type 'unread)
5725 (memq article gnus-newsgroup-unreads))
5726 ((eq type 'read)
5727 (memq article gnus-newsgroup-reads))
5728 ((eq type 'dormant)
5729 (memq article gnus-newsgroup-dormant) )
5730 ((eq type 'expire)
5731 (memq article gnus-newsgroup-expirable))
5732 ((eq type 'reply)
5733 (memq article gnus-newsgroup-replied))
5734 ((eq type 'killed)
5735 (memq article gnus-newsgroup-killed))
5736 ((eq type 'bookmark)
5737 (assq article gnus-newsgroup-bookmarks))
5738 ((eq type 'score)
5739 (assq article gnus-newsgroup-scored))
5740 ((eq type 'save)
5741 (memq article gnus-newsgroup-saved))
5742 ((eq type 'cache)
5743 (memq article gnus-newsgroup-cached))
5744 ((eq type 'forward)
5745 (memq article gnus-newsgroup-forwarded))
5746 ((eq type 'seen)
5747 (not (memq article gnus-newsgroup-unseen)))
5748 ((eq type 'recent)
5749 (memq article gnus-newsgroup-recent))
5750 (t t))))
5751
eec82323 5752(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5753 "Find out what articles the user wants to read."
26c9afc3 5754 (let* ((articles
eec82323
LMI
5755 ;; Select all articles if `read-all' is non-nil, or if there
5756 ;; are no unread articles.
5757 (if (or read-all
5758 (and (zerop (length gnus-newsgroup-marked))
5759 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5760 ;; Fetch all if the predicate is non-nil.
5761 gnus-newsgroup-display)
5762 ;; We want to select the headers for all the articles in
5763 ;; the group, so we select either all the active
5764 ;; articles in the group, or (if that's nil), the
5765 ;; articles in the cache.
16409b0b 5766 (or
4b70e299 5767 (if gnus-newsgroup-maximum-articles
11abff8e
MB
5768 (let ((active (gnus-active group)))
5769 (gnus-uncompress-range
5770 (cons (max (car active)
4b70e299
MB
5771 (- (cdr active)
5772 gnus-newsgroup-maximum-articles
5773 -1))
11abff8e
MB
5774 (cdr active))))
5775 (gnus-uncompress-range (gnus-active group)))
16409b0b 5776 (gnus-cache-articles-in-group group))
23f87bed
MB
5777 ;; Select only the "normal" subset of articles.
5778 (gnus-sorted-nunion
5779 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5780 gnus-newsgroup-unreads)))
eec82323
LMI
5781 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5782 (scored (length scored-list))
5783 (number (length articles))
5784 (marked (+ (length gnus-newsgroup-marked)
5785 (length gnus-newsgroup-dormant)))
5786 (select
5787 (cond
5788 ((numberp read-all)
5789 read-all)
23f87bed
MB
5790 ((numberp gnus-newsgroup-display)
5791 gnus-newsgroup-display)
eec82323
LMI
5792 (t
5793 (condition-case ()
5794 (cond
5795 ((and (or (<= scored marked) (= scored number))
5796 (numberp gnus-large-newsgroup)
5797 (> number gnus-large-newsgroup))
23f87bed
MB
5798 (let* ((cursor-in-echo-area nil)
5799 (initial (gnus-parameter-large-newsgroup-initial
5800 gnus-newsgroup-name))
5801 (input
5802 (read-string
5803 (format
5804 "How many articles from %s (%s %d): "
01c52d31 5805 (gnus-group-decoded-name gnus-newsgroup-name)
23f87bed
MB
5806 (if initial "max" "default")
5807 number)
5808 (if initial
5809 (cons (number-to-string initial)
5810 0)))))
eec82323
LMI
5811 (if (string-match "^[ \t]*$" input) number input)))
5812 ((and (> scored marked) (< scored number)
5813 (> (- scored number) 20))
5814 (let ((input
5815 (read-string
5816 (format "%s %s (%d scored, %d total): "
5817 "How many articles from"
23f87bed
MB
5818 (gnus-group-decoded-name group)
5819 scored number))))
eec82323
LMI
5820 (if (string-match "^[ \t]*$" input)
5821 number input)))
5822 (t number))
d4dfaa19
DL
5823 (quit
5824 (message "Quit getting the articles to read")
5825 nil))))))
eec82323
LMI
5826 (setq select (if (stringp select) (string-to-number select) select))
5827 (if (or (null select) (zerop select))
5828 select
5829 (if (and (not (zerop scored)) (<= (abs select) scored))
5830 (progn
5831 (setq articles (sort scored-list '<))
5832 (setq number (length articles)))
5833 (setq articles (copy-sequence articles)))
5834
5835 (when (< (abs select) number)
5836 (if (< select 0)
5837 ;; Select the N oldest articles.
5838 (setcdr (nthcdr (1- (abs select)) articles) nil)
5839 ;; Select the N most recent articles.
5840 (setq articles (nthcdr (- number select) articles))))
5841 (setq gnus-newsgroup-unselected
23f87bed 5842 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5843 (when gnus-alter-articles-to-read-function
23f87bed 5844 (setq articles
a1506d29 5845 (sort
16409b0b 5846 (funcall gnus-alter-articles-to-read-function
23f87bed 5847 gnus-newsgroup-name articles)
16409b0b 5848 '<)))
eec82323
LMI
5849 articles)))
5850
5851(defun gnus-killed-articles (killed articles)
5852 (let (out)
5853 (while articles
5854 (when (inline (gnus-member-of-range (car articles) killed))
5855 (push (car articles) out))
5856 (setq articles (cdr articles)))
5857 out))
5858
5859(defun gnus-uncompress-marks (marks)
5860 "Uncompress the mark ranges in MARKS."
5861 (let ((uncompressed '(score bookmark))
5862 out)
5863 (while marks
5864 (if (memq (caar marks) uncompressed)
5865 (push (car marks) out)
5866 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5867 (setq marks (cdr marks)))
5868 out))
5869
23f87bed
MB
5870(defun gnus-article-mark-to-type (mark)
5871 "Return the type of MARK."
5872 (or (cadr (assq mark gnus-article-special-mark-lists))
5873 'list))
5874
5875(defun gnus-article-unpropagatable-p (mark)
5876 "Return whether MARK should be propagated to back end."
5877 (memq mark gnus-article-unpropagated-mark-lists))
5878
eec82323 5879(defun gnus-adjust-marked-articles (info)
16409b0b 5880 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5881 (let* ((marked-lists (gnus-info-marks info))
5882 (active (gnus-active (gnus-info-group info)))
5883 (min (car active))
5884 (max (cdr active))
5885 (types gnus-article-mark-lists)
54506618
MB
5886 marks var articles article mark mark-type
5887 bgn end)
0617bb00
LMI
5888 ;; Hack to avoid adjusting marks for imap.
5889 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5890 'nnimap)
5891 (setq min 1))
eec82323 5892
23f87bed
MB
5893 (dolist (marks marked-lists)
5894 (setq mark (car marks)
5895 mark-type (gnus-article-mark-to-type mark)
5896 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5897
23f87bed
MB
5898 ;; We set the variable according to the type of the marks list,
5899 ;; and then adjust the marks to a subset of the active articles.
eec82323 5900 (cond
54506618 5901 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5902 ((eq mark-type 'list)
54506618
MB
5903 ;; Simultaneously uncompress and clip to active range
5904 ;; See gnus-uncompress-range for a description of possible marks
5905 (let (l lh)
5906 (if (not (cadr marks))
5907 (set var nil)
5908 (setq articles (if (numberp (cddr marks))
5909 (list (cdr marks))
5910 (cdr marks))
5911 lh (cons nil nil)
5912 l lh)
5913
5914 (while (setq article (pop articles))
5915 (cond ((consp article)
5916 (setq bgn (max (car article) min)
5917 end (min (cdr article) max))
5918 (while (<= bgn end)
5919 (setq l (setcdr l (cons bgn nil))
5920 bgn (1+ bgn))))
5921 ((and (<= min article)
5922 (>= max article))
5923 (setq l (setcdr l (cons article nil))))))
5924 (set var (cdr lh)))))
eec82323 5925 ;; Adjust assocs.
23f87bed
MB
5926 ((eq mark-type 'tuple)
5927 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5928 (when (not (listp (cdr (symbol-value var))))
5929 (set var (list (symbol-value var))))
5930 (when (not (listp (cdr articles)))
5931 (setq articles (list articles)))
eec82323
LMI
5932 (while articles
5933 (when (or (not (consp (setq article (pop articles))))
5934 (< (car article) min)
5935 (> (car article) max))
23f87bed
MB
5936 (set var (delq article (symbol-value var))))))
5937 ;; Adjust ranges (sloppily).
5938 ((eq mark-type 'range)
5939 (cond
5940 ((eq mark 'seen)
5941 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5942 ;; It should be (seen (NUM1 . NUM2)).
5943 (when (numberp (cddr marks))
5944 (setcdr marks (list (cdr marks))))
5945 (setq articles (cdr marks))
5946 (while (and articles
5947 (or (and (consp (car articles))
5948 (> min (cdar articles)))
5949 (and (numberp (car articles))
5950 (> min (car articles)))))
5951 (pop articles))
5952 (set var articles))))))))
eec82323
LMI
5953
5954(defun gnus-update-missing-marks (missing)
6748645f 5955 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 5956 (when missing
23f87bed 5957 (let (var m)
eec82323 5958 ;; Go through all types.
23f87bed
MB
5959 (dolist (elem gnus-article-mark-lists)
5960 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5961 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5962 (when (symbol-value var)
5963 ;; This list has articles. So we delete all missing
5964 ;; articles from it.
5965 (setq m missing)
5966 (while m
5967 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
5968
5969(defun gnus-update-marks ()
5970 "Enter the various lists of marked articles into the newsgroup info list."
5971 (let ((types gnus-article-mark-lists)
5972 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 5973 type list newmarked symbol delta-marks)
eec82323 5974 (when info
16409b0b 5975 ;; Add all marks lists to the list of marks lists.
eec82323 5976 (while (setq type (pop types))
16409b0b
GM
5977 (setq list (symbol-value
5978 (setq symbol
23f87bed 5979 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 5980
16409b0b 5981 (when list
eec82323
LMI
5982 ;; Get rid of the entries of the articles that have the
5983 ;; default score.
5984 (when (and (eq (cdr type) 'score)
5985 gnus-save-score
5986 list)
5987 (let* ((arts list)
5988 (prev (cons nil list))
5989 (all prev))
5990 (while arts
5991 (if (or (not (consp (car arts)))
5992 (= (cdar arts) gnus-summary-default-score))
5993 (setcdr prev (cdr arts))
5994 (setq prev arts))
5995 (setq arts (cdr arts)))
16409b0b
GM
5996 (setq list (cdr all)))))
5997
23f87bed
MB
5998 (when (eq (cdr type) 'seen)
5999 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6000
6001 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 6002 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 6003
23f87bed
MB
6004 (when (and (gnus-check-backend-function
6005 'request-set-mark gnus-newsgroup-name)
6006 (not (gnus-article-unpropagatable-p (cdr type))))
6007 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6008 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
6009 (add (gnus-remove-from-range
6010 (gnus-copy-sequence list) old)))
6011 (when add
6012 (push (list add 'add (list (cdr type))) delta-marks))
6013 (when del
b069e5a6
G
6014 ;; Don't delete marks from outside the active range. This
6015 ;; shouldn't happen, but is a sanity check.
6016 (setq del (gnus-sorted-range-intersection
6017 (gnus-active gnus-newsgroup-name) del))
23f87bed 6018 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 6019
16409b0b
GM
6020 (when list
6021 (push (cons (cdr type) list) newmarked)))
6022
6023 (when delta-marks
6024 (unless (gnus-check-group gnus-newsgroup-name)
6025 (error "Can't open server for %s" gnus-newsgroup-name))
6026 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 6027
eec82323
LMI
6028 ;; Enter these new marks into the info of the group.
6029 (if (nthcdr 3 info)
6030 (setcar (nthcdr 3 info) newmarked)
6031 ;; Add the marks lists to the end of the info.
6032 (when newmarked
6033 (setcdr (nthcdr 2 info) (list newmarked))))
6034
6035 ;; Cut off the end of the info if there's nothing else there.
6036 (let ((i 5))
6037 (while (and (> i 2)
6038 (not (nth i info)))
6039 (when (nthcdr (decf i) info)
6040 (setcdr (nthcdr i info) nil)))))))
6041
6042(defun gnus-set-mode-line (where)
16409b0b 6043 "Set the mode line of the article or summary buffers.
eec82323
LMI
6044If WHERE is `summary', the summary mode line format will be used."
6045 ;; Is this mode line one we keep updated?
16409b0b
GM
6046 (when (and (memq where gnus-updated-mode-lines)
6047 (symbol-value
6048 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323 6049 (let (mode-string)
c7a91ce1
SM
6050 ;; We evaluate this in the summary buffer since these
6051 ;; variables are buffer-local to that buffer.
6052 (with-current-buffer gnus-summary-buffer
6053 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
6054 ;; below.
6055 (let* ((mformat (symbol-value
6056 (intern
6057 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
6058 (gnus-tmp-group-name (gnus-mode-string-quote
6059 (gnus-group-decoded-name
6060 gnus-newsgroup-name)))
eec82323
LMI
6061 (gnus-tmp-article-number (or gnus-current-article 0))
6062 (gnus-tmp-unread gnus-newsgroup-unreads)
6063 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6064 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6065 (gnus-tmp-unread-and-unselected
6066 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6067 (zerop gnus-tmp-unselected))
6068 "")
6069 ((zerop gnus-tmp-unselected)
6070 (format "{%d more}" gnus-tmp-unread-and-unticked))
6071 (t (format "{%d(+%d) more}"
6072 gnus-tmp-unread-and-unticked
6073 gnus-tmp-unselected))))
6074 (gnus-tmp-subject
6075 (if (and gnus-current-headers
6076 (vectorp gnus-current-headers))
6077 (gnus-mode-string-quote
6078 (mail-header-subject gnus-current-headers))
6079 ""))
6080 bufname-length max-len
23f87bed 6081 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
6082 (setq mode-string (eval mformat))
6083 (setq bufname-length (if (string-match "%b" mode-string)
6084 (- (length
6085 (buffer-name
6086 (if (eq where 'summary)
6087 nil
6088 (get-buffer gnus-article-buffer))))
6089 2)
6090 0))
6091 (setq max-len (max 4 (if gnus-mode-non-string-length
6092 (- (window-width)
6093 gnus-mode-non-string-length
6094 bufname-length)
6095 (length mode-string))))
6096 ;; We might have to chop a bit of the string off...
6097 (when (> (length mode-string) max-len)
6098 (setq mode-string
16409b0b 6099 (concat (truncate-string-to-width mode-string (- max-len 3))
29d31b55 6100 "...")))))
eec82323
LMI
6101 ;; Update the mode line.
6102 (setq mode-line-buffer-identification
6103 (gnus-mode-line-buffer-identification (list mode-string)))
6104 (set-buffer-modified-p t))))
6105
6106(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6107 "Go through the HEADERS list and add all Xrefs to a hash table.
6108The resulting hash table is returned, or nil if no Xrefs were found."
6109 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6110 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6111 (xref-hashtb (gnus-make-hashtable))
6112 start group entry number xrefs header)
6113 (while headers
6114 (setq header (pop headers))
6115 (when (and (setq xrefs (mail-header-xref header))
6116 (not (memq (setq number (mail-header-number header))
6117 unreads)))
6118 (setq start 0)
6119 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6120 (setq start (match-end 0))
6121 (setq group (if prefix
6122 (concat prefix (substring xrefs (match-beginning 1)
6123 (match-end 1)))
6124 (substring xrefs (match-beginning 1) (match-end 1))))
6125 (setq number
e9bd5782 6126 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
6127 (match-end 2))))
6128 (if (setq entry (gnus-gethash group xref-hashtb))
6129 (setcdr entry (cons number (cdr entry)))
6130 (gnus-sethash group (cons number nil) xref-hashtb)))))
6131 (and start xref-hashtb)))
6132
6133(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6134 "Look through all the headers and mark the Xrefs as read."
6135 (let ((virtual (gnus-virtual-group-p from-newsgroup))
01c52d31 6136 name info xref-hashtb idlist method nth4)
398a825b 6137 (with-current-buffer gnus-group-buffer
eec82323
LMI
6138 (when (setq xref-hashtb
6139 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6140 (mapatoms
6141 (lambda (group)
6142 (unless (string= from-newsgroup (setq name (symbol-name group)))
6143 (setq idlist (symbol-value group))
6144 ;; Dead groups are not updated.
6145 (and (prog1
01c52d31 6146 (setq info (gnus-get-info name))
eec82323
LMI
6147 (when (stringp (setq nth4 (gnus-info-method info)))
6148 (setq nth4 (gnus-server-to-method nth4))))
6149 ;; Only do the xrefs if the group has the same
6150 ;; select method as the group we have just read.
6151 (or (gnus-methods-equal-p
6152 nth4 (gnus-find-method-for-group from-newsgroup))
6153 virtual
6154 (equal nth4 (setq method (gnus-find-method-for-group
6155 from-newsgroup)))
6156 (and (equal (car nth4) (car method))
6157 (equal (nth 1 nth4) (nth 1 method))))
6158 gnus-use-cross-reference
6159 (or (not (eq gnus-use-cross-reference t))
6160 virtual
6161 ;; Only do cross-references on subscribed
6162 ;; groups, if that is what is wanted.
6163 (<= (gnus-info-level info) gnus-level-subscribed))
6164 (gnus-group-make-articles-read name idlist))))
6165 xref-hashtb)))))
6166
6748645f 6167(defun gnus-compute-read-articles (group articles)
01c52d31 6168 (let* ((entry (gnus-group-entry group))
6748645f
LMI
6169 (info (nth 2 entry))
6170 (active (gnus-active group))
6171 ninfo)
6172 (when entry
16409b0b 6173 ;; First peel off all invalid article numbers.
6748645f
LMI
6174 (when active
6175 (let ((ids articles)
6176 id first)
6177 (while (setq id (pop ids))
6178 (when (and first (> id (cdr active)))
6179 ;; We'll end up in this situation in one particular
6180 ;; obscure situation. If you re-scan a group and get
6181 ;; a new article that is cross-posted to a different
6182 ;; group that has not been re-scanned, you might get
6183 ;; crossposted article that has a higher number than
6184 ;; Gnus believes possible. So we re-activate this
6185 ;; group as well. This might mean doing the
6186 ;; crossposting thingy will *increase* the number
6187 ;; of articles in some groups. Tsk, tsk.
6188 (setq active (or (gnus-activate-group group) active)))
6189 (when (or (> id (cdr active))
6190 (< id (car active)))
6191 (setq articles (delq id articles))))))
6192 ;; If the read list is nil, we init it.
6193 (if (and active
6194 (null (gnus-info-read info))
6195 (> (car active) 1))
6196 (setq ninfo (cons 1 (1- (car active))))
6197 (setq ninfo (gnus-info-read info)))
6198 ;; Then we add the read articles to the range.
6199 (gnus-add-to-range
6200 ninfo (setq articles (sort articles '<))))))
6201
eec82323
LMI
6202(defun gnus-group-make-articles-read (group articles)
6203 "Update the info of GROUP to say that ARTICLES are read."
6204 (let* ((num 0)
01c52d31 6205 (entry (gnus-group-entry group))
eec82323
LMI
6206 (info (nth 2 entry))
6207 (active (gnus-active group))
6208 range)
de635afe
G
6209 (if (not entry)
6210 ;; Group that Gnus doesn't know exists, but still allow the
6211 ;; backend to set marks.
6212 (gnus-request-set-mark
6213 group (list (list (gnus-compress-sequence (sort articles #'<))
6214 'add '(read))))
6215 ;; Normal, subscribed groups.
6748645f 6216 (setq range (gnus-compute-read-articles group articles))
01c52d31 6217 (with-current-buffer gnus-group-buffer
6748645f
LMI
6218 (gnus-undo-register
6219 `(progn
6220 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6221 (gnus-info-set-read ',info ',(gnus-info-read info))
6222 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 6223 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
6224 (gnus-group-update-group ,group t))))
6225 ;; Add the read articles to the range.
6226 (gnus-info-set-read info range)
23f87bed 6227 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
6228 ;; Then we have to re-compute how many unread
6229 ;; articles there are in this group.
6230 (when active
6231 (cond
6232 ((not range)
6233 (setq num (- (1+ (cdr active)) (car active))))
6234 ((not (listp (cdr range)))
6235 (setq num (- (cdr active) (- (1+ (cdr range))
6236 (car range)))))
6237 (t
6238 (while range
6239 (if (numberp (car range))
6240 (setq num (1+ num))
6241 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6242 (setq range (cdr range)))
6243 (setq num (- (cdr active) num))))
6244 ;; Update the number of unread articles.
6245 (setcar entry num)
6246 ;; Update the group buffer.
23f87bed
MB
6247 (unless (gnus-ephemeral-group-p group)
6248 (gnus-group-update-group group t))))))
eec82323 6249
eec82323
LMI
6250(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6251 (let ((cur nntp-server-buffer)
6252 (dependencies
6253 (or dependencies
01c52d31
MB
6254 (with-current-buffer gnus-summary-buffer
6255 gnus-newsgroup-dependencies)))
6256 headers id end ref number
16409b0b
GM
6257 (mail-parse-charset gnus-newsgroup-charset)
6258 (mail-parse-ignored-charsets
c7a91ce1
SM
6259 (save-current-buffer (condition-case nil
6260 (set-buffer gnus-summary-buffer)
6261 (error))
6262 gnus-newsgroup-ignored-charsets)))
6263 (with-current-buffer nntp-server-buffer
eec82323
LMI
6264 ;; Translate all TAB characters into SPACE characters.
6265 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 6266 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 6267 (ietf-drums-unfold-fws)
6748645f 6268 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6269 (let ((case-fold-search t)
6748645f 6270 in-reply-to header p lines chars)
eec82323 6271 (goto-char (point-min))
01ccbb85 6272 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
6273 ;; do not begin with 2 or 3.
6274 (while (re-search-forward "^[23][0-9]+ " nil t)
6275 (setq id nil
6276 ref nil)
6277 ;; This implementation of this function, with nine
6278 ;; search-forwards instead of the one re-search-forward and
6279 ;; a case (which basically was the old function) is actually
01ccbb85 6280 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
6281 ;; can't have everything, I guess. Speed and elegance
6282 ;; doesn't always go hand in hand.
6283 (setq
6284 header
6285 (vector
6286 ;; Number.
6287 (prog1
01c52d31 6288 (setq number (read cur))
eec82323
LMI
6289 (end-of-line)
6290 (setq p (point))
6291 (narrow-to-region (point)
6292 (or (and (search-forward "\n.\n" nil t)
6293 (- (point) 2))
6294 (point))))
6295 ;; Subject.
6296 (progn
6297 (goto-char p)
23f87bed 6298 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
6299 (funcall gnus-decode-encoded-word-function
6300 (nnheader-header-value))
2bd3dcae 6301 "(none)"))
eec82323
LMI
6302 ;; From.
6303 (progn
6304 (goto-char p)
23f87bed 6305 (if (search-forward "\nfrom:" nil t)
343d6628 6306 (funcall gnus-decode-encoded-address-function
16409b0b 6307 (nnheader-header-value))
2bd3dcae 6308 "(nobody)"))
eec82323
LMI
6309 ;; Date.
6310 (progn
6311 (goto-char p)
23f87bed 6312 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6313 (nnheader-header-value) ""))
6314 ;; Message-ID.
6315 (progn
6316 (goto-char p)
6748645f
LMI
6317 (setq id (if (re-search-forward
6318 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6319 ;; We do it this way to make sure the Message-ID
6320 ;; is (somewhat) syntactically valid.
6321 (buffer-substring (match-beginning 1)
6322 (match-end 1))
eec82323
LMI
6323 ;; If there was no message-id, we just fake one
6324 ;; to make subsequent routines simpler.
01c52d31 6325 (nnheader-generate-fake-message-id number))))
eec82323
LMI
6326 ;; References.
6327 (progn
6328 (goto-char p)
23f87bed 6329 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6330 (progn
6331 (setq end (point))
6332 (prog1
6333 (nnheader-header-value)
6334 (setq ref
6335 (buffer-substring
6336 (progn
6337 (end-of-line)
6338 (search-backward ">" end t)
6339 (1+ (point)))
6340 (progn
6341 (search-backward "<" end t)
6342 (point))))))
6343 ;; Get the references from the in-reply-to header if there
6344 ;; were no references and the in-reply-to header looks
6345 ;; promising.
23f87bed 6346 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6347 (setq in-reply-to (nnheader-header-value))
6348 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6349 (let (ref2)
6350 (setq ref (substring in-reply-to (match-beginning 0)
6351 (match-end 0)))
6352 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6353 (setq ref2 (substring in-reply-to (match-beginning 0)
6354 (match-end 0)))
6355 (when (> (length ref2) (length ref))
6356 (setq ref ref2)))
6357 ref)
eec82323
LMI
6358 (setq ref nil))))
6359 ;; Chars.
6748645f
LMI
6360 (progn
6361 (goto-char p)
6362 (if (search-forward "\nchars: " nil t)
6363 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6364 chars -1)
6365 -1))
eec82323
LMI
6366 ;; Lines.
6367 (progn
6368 (goto-char p)
6369 (if (search-forward "\nlines: " nil t)
a8151ef7 6370 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6371 lines -1)
6372 -1))
eec82323
LMI
6373 ;; Xref.
6374 (progn
6375 (goto-char p)
23f87bed 6376 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6377 (nnheader-header-value)))
6378 ;; Extra.
6379 (when gnus-extra-headers
6380 (let ((extra gnus-extra-headers)
6381 out)
6382 (while extra
6383 (goto-char p)
6384 (when (search-forward
23f87bed 6385 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6386 (push (cons (car extra) (nnheader-header-value))
6387 out))
6388 (pop extra))
6389 out))))
eec82323
LMI
6390 (when (equal id ref)
6391 (setq ref nil))
6748645f
LMI
6392
6393 (when gnus-alter-header-function
6394 (funcall gnus-alter-header-function header)
6395 (setq id (mail-header-id header)
6396 ref (gnus-parent-id (mail-header-references header))))
6397
6398 (when (setq header
6399 (gnus-dependencies-add-header
6400 header dependencies force-new))
eec82323
LMI
6401 (push header headers))
6402 (goto-char (point-max))
6403 (widen))
6404 (nreverse headers)))))
6405
eec82323
LMI
6406;; Goes through the xover lines and returns a list of vectors
6407(defun gnus-get-newsgroup-headers-xover (sequence &optional
6408 force-new dependencies
6409 group also-fetch-heads)
16409b0b
GM
6410 "Parse the news overview data in the server buffer.
6411Return a list of headers that match SEQUENCE (see
6412`nntp-retrieve-headers')."
eec82323
LMI
6413 ;; Get the Xref when the users reads the articles since most/some
6414 ;; NNTP servers do not include Xrefs when using XOVER.
6415 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6416 (let ((mail-parse-charset gnus-newsgroup-charset)
6417 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6418 (cur nntp-server-buffer)
eec82323 6419 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6420 (allp (cond
6421 ((eq gnus-read-all-available-headers t)
6422 t)
14e6dc54
MB
6423 ((and (stringp gnus-read-all-available-headers)
6424 group)
23f87bed
MB
6425 (string-match gnus-read-all-available-headers group))
6426 (t
6427 nil)))
eec82323 6428 number headers header)
c7a91ce1 6429 (with-current-buffer nntp-server-buffer
16409b0b 6430 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6431 ;; Allow the user to mangle the headers before parsing them.
6748645f 6432 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6433 (goto-char (point-min))
23f87bed
MB
6434 (gnus-parse-without-error
6435 (while (and (or sequence allp)
6436 (not (eobp)))
6437 (setq number (read cur))
6438 (when (not allp)
6439 (while (and sequence
6440 (< (car sequence) number))
6441 (setq sequence (cdr sequence))))
6442 (when (and (or allp
6443 (and sequence
6444 (eq number (car sequence))))
6445 (progn
6446 (setq sequence (cdr sequence))
6447 (setq header (inline
6448 (gnus-nov-parse-line
6449 number dependencies force-new)))))
6450 (push header headers))
6451 (forward-line 1)))
eec82323
LMI
6452 ;; A common bug in inn is that if you have posted an article and
6453 ;; then retrieves the active file, it will answer correctly --
6454 ;; the new article is included. However, a NOV entry for the
6455 ;; article may not have been generated yet, so this may fail.
6456 ;; We work around this problem by retrieving the last few
6457 ;; headers using HEAD.
6458 (if (or (not also-fetch-heads)
6459 (not sequence))
6460 ;; We (probably) got all the headers.
6461 (nreverse headers)
6462 (let ((gnus-nov-is-evil t))
6463 (nconc
6464 (nreverse headers)
23f87bed 6465 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6466 (gnus-get-newsgroup-headers))))))))
6467
6468(defun gnus-article-get-xrefs ()
6469 "Fill in the Xref value in `gnus-current-headers', if necessary.
6470This is meant to be called in `gnus-article-internal-prepare-hook'."
01c52d31
MB
6471 (let ((headers (with-current-buffer gnus-summary-buffer
6472 gnus-current-headers)))
eec82323
LMI
6473 (or (not gnus-use-cross-reference)
6474 (not headers)
6475 (and (mail-header-xref headers)
6476 (not (string= (mail-header-xref headers) "")))
6477 (let ((case-fold-search t)
6478 xref)
6479 (save-restriction
6480 (nnheader-narrow-to-headers)
6481 (goto-char (point-min))
16409b0b
GM
6482 (when (or (and (not (eobp))
6483 (eq (downcase (char-after)) ?x)
eec82323
LMI
6484 (looking-at "Xref:"))
6485 (search-forward "\nXref:" nil t))
6486 (goto-char (1+ (match-end 0)))
01c52d31 6487 (setq xref (buffer-substring (point) (point-at-eol)))
eec82323
LMI
6488 (mail-header-set-xref headers xref)))))))
6489
6490(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6491 "Find article ID and insert the summary line for that article.
6492OLD-HEADER can either be a header or a line number to insert
6493the subject line on."
6494 (let* ((line (and (numberp old-header) old-header))
6495 (old-header (and (vectorp old-header) old-header))
6496 (header (cond ((and old-header use-old-header)
16409b0b
GM
6497 old-header)
6498 ((and (numberp id)
6499 (gnus-number-to-header id))
6500 (gnus-number-to-header id))
6501 (t
6502 (gnus-read-header id))))
6503 (number (and (numberp id) id))
6504 d)
eec82323
LMI
6505 (when header
6506 ;; Rebuild the thread that this article is part of and go to the
6507 ;; article we have fetched.
6508 (when (and (not gnus-show-threads)
6509 old-header)
6748645f
LMI
6510 (when (and number
6511 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6512 (goto-char (gnus-data-pos d))
6513 (gnus-data-remove
6514 number
01c52d31 6515 (- (point-at-bol)
eec82323 6516 (prog1
01c52d31 6517 (1+ (point-at-eol))
eec82323 6518 (gnus-delete-line))))))
23f87bed
MB
6519 ;; Remove list identifiers from subject.
6520 (when gnus-list-identifiers
6521 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6522 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6523 (when old-header
6524 (mail-header-set-number header (mail-header-number old-header)))
6525 (setq gnus-newsgroup-sparse
6526 (delq (setq number (mail-header-number header))
6527 gnus-newsgroup-sparse))
6528 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6529 (push number gnus-newsgroup-limit)
6530 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6531 (gnus-summary-goto-subject number nil t))
6532 (when (and (numberp number)
6533 (> number 0))
6534 ;; We have to update the boundaries even if we can't fetch the
6535 ;; article if ID is a number -- so that the next `P' or `N'
6536 ;; command will fetch the previous (or next) article even
6537 ;; if the one we tried to fetch this time has been canceled.
6538 (when (> number gnus-newsgroup-end)
6539 (setq gnus-newsgroup-end number))
6540 (when (< number gnus-newsgroup-begin)
6541 (setq gnus-newsgroup-begin number))
6542 (setq gnus-newsgroup-unselected
6543 (delq number gnus-newsgroup-unselected)))
6544 ;; Report back a success?
6545 (and header (mail-header-number header))))
6546
6547;;; Process/prefix in the summary buffer
6548
6549(defun gnus-summary-work-articles (n)
6748645f
LMI
6550 "Return a list of articles to be worked upon.
6551The prefix argument, the list of process marked articles, and the
6552current article will be taken into consideration."
c7a91ce1 6553 (with-current-buffer gnus-summary-buffer
6748645f
LMI
6554 (cond
6555 (n
6556 ;; A numerical prefix has been given.
6557 (setq n (prefix-numeric-value n))
6558 (let ((backward (< n 0))
6559 (n (abs (prefix-numeric-value n)))
6560 articles article)
6561 (save-excursion
6562 (while
6563 (and (> n 0)
6564 (push (setq article (gnus-summary-article-number))
6565 articles)
6566 (if backward
6567 (gnus-summary-find-prev nil article)
6568 (gnus-summary-find-next nil article)))
6569 (decf n)))
6570 (nreverse articles)))
6571 ((and (gnus-region-active-p) (mark))
6572 (message "region active")
6573 ;; Work on the region between point and mark.
6574 (let ((max (max (point) (mark)))
6575 articles article)
6576 (save-excursion
7dafe00b 6577 (goto-char (min (point) (mark)))
6748645f
LMI
6578 (while
6579 (and
6580 (push (setq article (gnus-summary-article-number)) articles)
6581 (gnus-summary-find-next nil article)
6582 (< (point) max)))
6583 (nreverse articles))))
6584 (gnus-newsgroup-processable
6585 ;; There are process-marked articles present.
6586 ;; Save current state.
6587 (gnus-summary-save-process-mark)
6588 ;; Return the list.
6589 (reverse gnus-newsgroup-processable))
6590 (t
6591 ;; Just return the current article.
6592 (list (gnus-summary-article-number))))))
6593
6594(defmacro gnus-summary-iterate (arg &rest forms)
6595 "Iterate over the process/prefixed articles and do FORMS.
6596ARG is the interactive prefix given to the command. FORMS will be
6597executed with point over the summary line of the articles."
6598 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6599 `(let ((,articles (gnus-summary-work-articles ,arg)))
6600 (while ,articles
6601 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6602 ,@forms
6603 (pop ,articles)))))
6748645f
LMI
6604
6605(put 'gnus-summary-iterate 'lisp-indent-function 1)
6606(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6607
6608(defun gnus-summary-save-process-mark ()
6609 "Push the current set of process marked articles on the stack."
6610 (interactive)
6611 (push (copy-sequence gnus-newsgroup-processable)
6612 gnus-newsgroup-process-stack))
6613
6614(defun gnus-summary-kill-process-mark ()
6615 "Push the current set of process marked articles on the stack and unmark."
6616 (interactive)
6617 (gnus-summary-save-process-mark)
6618 (gnus-summary-unmark-all-processable))
6619
6620(defun gnus-summary-yank-process-mark ()
6621 "Pop the last process mark state off the stack and restore it."
6622 (interactive)
6623 (unless gnus-newsgroup-process-stack
6624 (error "Empty mark stack"))
6625 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6626
6627(defun gnus-summary-process-mark-set (set)
6628 "Make SET into the current process marked articles."
6629 (gnus-summary-unmark-all-processable)
01c52d31 6630 (mapc 'gnus-summary-set-process-mark set))
eec82323
LMI
6631
6632;;; Searching and stuff
6633
6634(defun gnus-summary-search-group (&optional backward use-level)
6635 "Search for next unread newsgroup.
6636If optional argument BACKWARD is non-nil, search backward instead."
c7a91ce1 6637 (with-current-buffer gnus-group-buffer
eec82323
LMI
6638 (when (gnus-group-search-forward
6639 backward nil (if use-level (gnus-group-group-level) nil))
6640 (gnus-group-group-name))))
6641
6642(defun gnus-summary-best-group (&optional exclude-group)
6643 "Find the name of the best unread group.
6644If EXCLUDE-GROUP, do not go to this group."
01c52d31 6645 (with-current-buffer gnus-group-buffer
eec82323
LMI
6646 (save-excursion
6647 (gnus-group-best-unread-group exclude-group))))
6648
23f87bed
MB
6649(defun gnus-summary-find-next (&optional unread article backward)
6650 (if backward
6651 (gnus-summary-find-prev unread article)
eec82323
LMI
6652 (let* ((dummy (gnus-summary-article-intangible-p))
6653 (article (or article (gnus-summary-article-number)))
23f87bed 6654 (data (gnus-data-find-list article))
eec82323
LMI
6655 result)
6656 (when (and (not dummy)
6657 (or (not gnus-summary-check-current)
6658 (not unread)
23f87bed
MB
6659 (not (gnus-data-unread-p (car data)))))
6660 (setq data (cdr data)))
eec82323
LMI
6661 (when (setq result
6662 (if unread
6663 (progn
23f87bed
MB
6664 (while data
6665 (unless (memq (gnus-data-number (car data))
6666 (cond
6667 ((eq gnus-auto-goto-ignores
6668 'always-undownloaded)
6669 gnus-newsgroup-undownloaded)
6670 (gnus-plugged
6671 nil)
6672 ((eq gnus-auto-goto-ignores
6673 'unfetched)
6674 gnus-newsgroup-unfetched)
6675 ((eq gnus-auto-goto-ignores
6676 'undownloaded)
6677 gnus-newsgroup-undownloaded)))
6678 (when (gnus-data-unread-p (car data))
6679 (setq result (car data)
6680 data nil)))
6681 (setq data (cdr data)))
eec82323 6682 result)
23f87bed 6683 (car data)))
eec82323
LMI
6684 (goto-char (gnus-data-pos result))
6685 (gnus-data-number result)))))
6686
6687(defun gnus-summary-find-prev (&optional unread article)
6688 (let* ((eobp (eobp))
6689 (article (or article (gnus-summary-article-number)))
23f87bed 6690 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6691 result)
6692 (when (and (not eobp)
6693 (or (not gnus-summary-check-current)
6694 (not unread)
23f87bed
MB
6695 (not (gnus-data-unread-p (car data)))))
6696 (setq data (cdr data)))
eec82323
LMI
6697 (when (setq result
6698 (if unread
6699 (progn
23f87bed
MB
6700 (while data
6701 (unless (memq (gnus-data-number (car data))
6702 (cond
6703 ((eq gnus-auto-goto-ignores
6704 'always-undownloaded)
6705 gnus-newsgroup-undownloaded)
6706 (gnus-plugged
6707 nil)
6708 ((eq gnus-auto-goto-ignores
6709 'unfetched)
6710 gnus-newsgroup-unfetched)
6711 ((eq gnus-auto-goto-ignores
6712 'undownloaded)
6713 gnus-newsgroup-undownloaded)))
6714 (when (gnus-data-unread-p (car data))
6715 (setq result (car data)
6716 data nil)))
6717 (setq data (cdr data)))
eec82323 6718 result)
23f87bed 6719 (car data)))
eec82323
LMI
6720 (goto-char (gnus-data-pos result))
6721 (gnus-data-number result))))
6722
6723(defun gnus-summary-find-subject (subject &optional unread backward article)
6724 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6725 (article (or article (gnus-summary-article-number)))
6726 (articles (gnus-data-list backward))
6727 (arts (gnus-data-find-list article articles))
6728 result)
6729 (when (or (not gnus-summary-check-current)
6730 (not unread)
6731 (not (gnus-data-unread-p (car arts))))
6732 (setq arts (cdr arts)))
6733 (while arts
6734 (and (or (not unread)
6735 (gnus-data-unread-p (car arts)))
6736 (vectorp (gnus-data-header (car arts)))
6737 (gnus-subject-equal
6738 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6739 (setq result (car arts)
6740 arts nil))
6741 (setq arts (cdr arts)))
6742 (and result
6743 (goto-char (gnus-data-pos result))
6744 (gnus-data-number result))))
6745
6746(defun gnus-summary-search-forward (&optional unread subject backward)
6747 "Search forward for an article.
6748If UNREAD, look for unread articles. If SUBJECT, look for
6749articles with that subject. If BACKWARD, search backward instead."
6750 (cond (subject (gnus-summary-find-subject subject unread backward))
6751 (backward (gnus-summary-find-prev unread))
6752 (t (gnus-summary-find-next unread))))
6753
6754(defun gnus-recenter (&optional n)
6755 "Center point in window and redisplay frame.
6756Also do horizontal recentering."
6757 (interactive "P")
6758 (when (and gnus-auto-center-summary
6759 (not (eq gnus-auto-center-summary 'vertical)))
6760 (gnus-horizontal-recenter))
5aa75bd8
JL
6761 (if (fboundp 'recenter-top-bottom)
6762 (recenter-top-bottom n)
6763 (recenter n)))
6764
6765(put 'gnus-recenter 'isearch-scroll t)
eec82323 6766
7b47345b
AS
6767(defun gnus-forward-line-ignore-invisible (n)
6768 "Move N lines forward (backward if N is negative).
6769Like forward-line, but skip over (and don't count) invisible lines."
6770 (let (done)
6771 (while (and (> n 0) (not done))
6772 ;; If the following character is currently invisible,
6773 ;; skip all characters with that same `invisible' property value.
770d9a1f
KY
6774 (while (gnus-invisible-p (point))
6775 (goto-char (gnus-next-char-property-change (point))))
7b47345b
AS
6776 (forward-line 1)
6777 (if (eobp)
6778 (setq done t)
6779 (setq n (1- n))))
6780 (while (and (< n 0) (not done))
6781 (forward-line -1)
6782 (if (bobp) (setq done t)
6783 (setq n (1+ n))
770d9a1f
KY
6784 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6785 (goto-char (gnus-previous-char-property-change (point))))))))
6786
eec82323
LMI
6787(defun gnus-summary-recenter ()
6788 "Center point in the summary window.
6789If `gnus-auto-center-summary' is nil, or the article buffer isn't
6790displayed, no centering will be performed."
6791 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6792 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6793 (interactive)
23f87bed
MB
6794 ;; The user has to want it.
6795 (when gnus-auto-center-summary
6796 (let* ((top (cond ((< (window-height) 4) 0)
6797 ((< (window-height) 7) 1)
6798 (t (if (numberp gnus-auto-center-summary)
6799 gnus-auto-center-summary
01c52d31 6800 (/ (1- (window-height)) 2)))))
23f87bed 6801 (height (1- (window-height)))
7b47345b
AS
6802 (bottom (save-excursion
6803 (goto-char (point-max))
6804 (gnus-forward-line-ignore-invisible (- height))
6805 (point)))
23f87bed 6806 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6807 (when (get-buffer-window gnus-article-buffer)
6808 ;; Only do recentering when the article buffer is displayed,
6809 ;; Set the window start to either `bottom', which is the biggest
6810 ;; possible valid number, or the second line from the top,
6811 ;; whichever is the least.
7b47345b
AS
6812 (let ((top-pos (save-excursion
6813 (gnus-forward-line-ignore-invisible (- top))
6814 (point))))
db7ebd73
MB
6815 (if (> bottom top-pos)
6816 ;; Keep the second line from the top visible
01c52d31 6817 (set-window-start window top-pos)
db7ebd73
MB
6818 ;; Try to keep the bottom line visible; if it's partially
6819 ;; obscured, either scroll one more line to make it fully
6820 ;; visible, or revert to using TOP-POS.
6821 (save-excursion
6822 (goto-char (point-max))
7b47345b 6823 (gnus-forward-line-ignore-invisible -1)
db7ebd73
MB
6824 (let ((last-line-start (point)))
6825 (goto-char bottom)
6826 (set-window-start window (point) t)
6827 (when (not (pos-visible-in-window-p last-line-start window))
7b47345b 6828 (gnus-forward-line-ignore-invisible 1)
db7ebd73 6829 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6830 ;; Do horizontal recentering while we're at it.
6831 (when (and (get-buffer-window (current-buffer) t)
6832 (not (eq gnus-auto-center-summary 'vertical)))
6833 (let ((selected (selected-window)))
6834 (select-window (get-buffer-window (current-buffer) t))
6835 (gnus-summary-position-point)
6836 (gnus-horizontal-recenter)
6837 (select-window selected))))))
6838
6839(defun gnus-summary-jump-to-group (newsgroup)
6840 "Move point to NEWSGROUP in group mode buffer."
6841 ;; Keep update point of group mode buffer if visible.
6842 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6843 (save-window-excursion
6844 ;; Take care of tree window mode.
6845 (when (get-buffer-window gnus-group-buffer)
6846 (pop-to-buffer gnus-group-buffer))
6847 (gnus-group-jump-to-group newsgroup))
6848 (save-excursion
6849 ;; Take care of tree window mode.
c7a91ce1 6850 (if (get-buffer-window gnus-group-buffer 0)
eec82323
LMI
6851 (pop-to-buffer gnus-group-buffer)
6852 (set-buffer gnus-group-buffer))
6853 (gnus-group-jump-to-group newsgroup))))
6854
6855;; This function returns a list of article numbers based on the
6856;; difference between the ranges of read articles in this group and
6857;; the range of active articles.
6858(defun gnus-list-of-unread-articles (group)
6859 (let* ((read (gnus-info-read (gnus-get-info group)))
6860 (active (or (gnus-active group) (gnus-activate-group group)))
01c52d31
MB
6861 (last (or (cdr active)
6862 (error "Group %s couldn't be activated " group)))
4b70e299
MB
6863 (bottom (if gnus-newsgroup-maximum-articles
6864 (max (car active)
6865 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6866 (car active)))
eec82323
LMI
6867 first nlast unread)
6868 ;; If none are read, then all are unread.
6869 (if (not read)
11abff8e 6870 (setq first bottom)
eec82323
LMI
6871 ;; If the range of read articles is a single range, then the
6872 ;; first unread article is the article after the last read
6873 ;; article. Sounds logical, doesn't it?
16409b0b 6874 (if (and (not (listp (cdr read)))
11abff8e 6875 (or (< (car read) bottom)
16409b0b
GM
6876 (progn (setq read (list read))
6877 nil)))
11abff8e 6878 (setq first (max bottom (1+ (cdr read))))
eec82323
LMI
6879 ;; `read' is a list of ranges.
6880 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6881 (caar read)))
6882 1)
11abff8e 6883 (setq first bottom))
eec82323
LMI
6884 (while read
6885 (when first
6886 (while (< first nlast)
54506618
MB
6887 (setq unread (cons first unread)
6888 first (1+ first))))
eec82323
LMI
6889 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6890 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6891 (setq read (cdr read)))))
6892 ;; And add the last unread articles.
6893 (while (<= first last)
54506618
MB
6894 (setq unread (cons first unread)
6895 first (1+ first)))
eec82323 6896 ;; Return the list of unread articles.
6748645f 6897 (delq 0 (nreverse unread))))
eec82323
LMI
6898
6899(defun gnus-list-of-read-articles (group)
6900 "Return a list of unread, unticked and non-dormant articles."
6901 (let* ((info (gnus-get-info group))
6902 (marked (gnus-info-marks info))
6903 (active (gnus-active group)))
6904 (and info active
23f87bed
MB
6905 (gnus-list-range-difference
6906 (gnus-list-range-difference
6907 (gnus-sorted-complement
11abff8e 6908 (gnus-uncompress-range
4b70e299 6909 (if gnus-newsgroup-maximum-articles
11abff8e 6910 (cons (max (car active)
4b70e299
MB
6911 (- (cdr active)
6912 gnus-newsgroup-maximum-articles
6913 -1))
11abff8e
MB
6914 (cdr active))
6915 active))
23f87bed
MB
6916 (gnus-list-of-unread-articles group))
6917 (cdr (assq 'dormant marked)))
6918 (cdr (assq 'tick marked))))))
eec82323 6919
54506618
MB
6920;; This function returns a sequence of article numbers based on the
6921;; difference between the ranges of read articles in this group and
6922;; the range of active articles.
6923(defun gnus-sequence-of-unread-articles (group)
6924 (let* ((read (gnus-info-read (gnus-get-info group)))
6925 (active (or (gnus-active group) (gnus-activate-group group)))
6926 (last (cdr active))
4b70e299
MB
6927 (bottom (if gnus-newsgroup-maximum-articles
6928 (max (car active)
6929 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6930 (car active)))
54506618
MB
6931 first nlast unread)
6932 ;; If none are read, then all are unread.
6933 (if (not read)
11abff8e 6934 (setq first bottom)
54506618
MB
6935 ;; If the range of read articles is a single range, then the
6936 ;; first unread article is the article after the last read
6937 ;; article. Sounds logical, doesn't it?
6938 (if (and (not (listp (cdr read)))
11abff8e 6939 (or (< (car read) bottom)
54506618
MB
6940 (progn (setq read (list read))
6941 nil)))
11abff8e 6942 (setq first (max bottom (1+ (cdr read))))
54506618
MB
6943 ;; `read' is a list of ranges.
6944 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6945 (caar read)))
6946 1)
11abff8e 6947 (setq first bottom))
54506618
MB
6948 (while read
6949 (when first
6950 (push (cons first nlast) unread))
6951 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6952 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6953 (setq read (cdr read)))))
6954 ;; And add the last unread articles.
ba0226dd
MB
6955 (cond ((not (and first last))
6956 nil)
6957 ((< first last)
6958 (push (cons first last) unread))
6959 ((= first last)
6960 (push first unread)))
54506618
MB
6961 ;; Return the sequence of unread articles.
6962 (delq 0 (nreverse unread))))
6963
eec82323
LMI
6964;; Various summary commands
6965
6748645f 6966(defun gnus-summary-select-article-buffer ()
de635afe
G
6967 "Reconfigure windows to show the article buffer.
6968If `gnus-widen-article-buffer' is set, show only the article
6969buffer."
6748645f
LMI
6970 (interactive)
6971 (if (not (gnus-buffer-live-p gnus-article-buffer))
6972 (error "There is no article buffer for this summary buffer")
a41c2e6d
G
6973 (unless (get-buffer-window gnus-article-buffer)
6974 (gnus-summary-show-article))
71e691a5
G
6975 (gnus-configure-windows
6976 (if gnus-widen-article-window
6977 'only-article
6978 'article)
6979 t)
a41c2e6d 6980 (select-window (get-buffer-window gnus-article-buffer))))
6748645f 6981
eec82323
LMI
6982(defun gnus-summary-universal-argument (arg)
6983 "Perform any operation on all articles that are process/prefixed."
6984 (interactive "P")
eec82323
LMI
6985 (let ((articles (gnus-summary-work-articles arg))
6986 func article)
6987 (if (eq
6988 (setq
6989 func
6990 (key-binding
6991 (read-key-sequence
6992 (substitute-command-keys
16409b0b 6993 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
6994 'undefined)
6995 (gnus-error 1 "Undefined key")
6996 (save-excursion
6997 (while articles
6998 (gnus-summary-goto-subject (setq article (pop articles)))
6999 (let (gnus-newsgroup-processable)
7000 (command-execute func))
7001 (gnus-summary-remove-process-mark article)))))
7002 (gnus-summary-position-point))
7003
7004(defun gnus-summary-toggle-truncation (&optional arg)
7005 "Toggle truncation of summary lines.
23f87bed 7006With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
7007 (interactive "P")
7008 (setq truncate-lines
7009 (if (null arg) (not truncate-lines)
7010 (> (prefix-numeric-value arg) 0)))
7011 (redraw-display))
7012
23f87bed
MB
7013(defun gnus-summary-find-for-reselect ()
7014 "Return the number of an article to stay on across a reselect.
7015The current article is considered, then following articles, then previous
7016articles. An article is sought which is not cancelled and isn't a temporary
7017insertion from another group. If there's no such then return a dummy 0."
7018 (let (found)
7019 (dolist (rev '(nil t))
7020 (unless found ; don't demand the reverse list if we don't need it
7021 (let ((data (gnus-data-find-list
7022 (gnus-summary-article-number) (gnus-data-list rev))))
7023 (while (and data (not found))
7024 (if (and (< 0 (gnus-data-number (car data)))
7025 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7026 (setq found (gnus-data-number (car data))))
7027 (setq data (cdr data))))))
7028 (or found 0)))
7029
eec82323
LMI
7030(defun gnus-summary-reselect-current-group (&optional all rescan)
7031 "Exit and then reselect the current newsgroup.
7032The prefix argument ALL means to select all articles."
7033 (interactive "P")
eec82323
LMI
7034 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7035 (error "Ephemeral groups can't be reselected"))
23f87bed 7036 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
7037 (group gnus-newsgroup-name))
7038 (setq gnus-newsgroup-begin nil)
23f87bed 7039 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
7040 ;; We have to adjust the point of group mode buffer because
7041 ;; point was moved to the next unread newsgroup by exiting.
7042 (gnus-summary-jump-to-group group)
7043 (when rescan
7044 (save-excursion
7045 (gnus-group-get-new-news-this-group 1)))
7046 (gnus-group-read-group all t)
7047 (gnus-summary-goto-subject current-subject nil t)))
7048
7049(defun gnus-summary-rescan-group (&optional all)
7050 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7051 (interactive "P")
eb9df2c9
LMI
7052 (let ((config gnus-current-window-configuration))
7053 (gnus-summary-reselect-current-group all t)
7054 (gnus-configure-windows config)
7055 (when (eq config 'article)
7056 (gnus-summary-select-article))))
eec82323
LMI
7057
7058(defun gnus-summary-update-info (&optional non-destructive)
7059 (save-excursion
7060 (let ((group gnus-newsgroup-name))
6748645f
LMI
7061 (when group
7062 (when gnus-newsgroup-kill-headers
7063 (setq gnus-newsgroup-killed
7064 (gnus-compress-sequence
23f87bed
MB
7065 (gnus-sorted-union
7066 (gnus-list-range-intersection
7067 gnus-newsgroup-unselected gnus-newsgroup-killed)
7068 gnus-newsgroup-unreads)
6748645f
LMI
7069 t)))
7070 (unless (listp (cdr gnus-newsgroup-killed))
7071 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7072 (let ((headers gnus-newsgroup-headers))
7073 ;; Set the new ranges of read articles.
01c52d31 7074 (with-current-buffer gnus-group-buffer
6748645f
LMI
7075 (gnus-undo-force-boundary))
7076 (gnus-update-read-articles
23f87bed
MB
7077 group (gnus-sorted-union
7078 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
7079 ;; Set the current article marks.
7080 (let ((gnus-newsgroup-scored
7081 (if (and (not gnus-save-score)
7082 (not non-destructive))
7083 nil
7084 gnus-newsgroup-scored)))
7085 (save-excursion
7086 (gnus-update-marks)))
7087 ;; Do the cross-ref thing.
7088 (when gnus-use-cross-reference
7089 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7090 ;; Do not switch windows but change the buffer to work.
a8151ef7 7091 (set-buffer gnus-group-buffer)
6748645f
LMI
7092 (unless (gnus-ephemeral-group-p group)
7093 (gnus-group-update-group group)))))))
eec82323
LMI
7094
7095(defun gnus-summary-save-newsrc (&optional force)
7096 "Save the current number of read/marked articles in the dribble buffer.
7097The dribble buffer will then be saved.
7098If FORCE (the prefix), also save the .newsrc file(s)."
7099 (interactive "P")
7100 (gnus-summary-update-info t)
7101 (if force
7102 (gnus-save-newsrc-file)
7103 (gnus-dribble-save)))
7104
704f1663
GM
7105(declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7106
23f87bed 7107(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 7108 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 7109`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
7110 (interactive)
7111 (gnus-set-global-variables)
16409b0b 7112 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7113 (with-current-buffer gnus-article-buffer
16409b0b
GM
7114 (mm-destroy-parts gnus-article-mime-handles)
7115 ;; Set it to nil for safety reason.
7116 (setq gnus-article-mime-handle-alist nil)
7117 (setq gnus-article-mime-handles nil)))
eec82323 7118 (gnus-kill-save-kill-buffer)
6748645f 7119 (gnus-async-halt-prefetch)
eec82323
LMI
7120 (let* ((group gnus-newsgroup-name)
7121 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 7122 (gnus-group-is-exiting-p t)
eec82323 7123 (mode major-mode)
23f87bed 7124 (group-point nil)
eec82323 7125 (buf (current-buffer)))
16409b0b
GM
7126 (unless quit-config
7127 ;; Do adaptive scoring, and possibly save score files.
7128 (when gnus-newsgroup-adaptive
7129 (gnus-score-adaptive))
7130 (when gnus-use-scoring
7131 (gnus-score-save)))
6748645f 7132 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
7133 (when gnus-use-cache
7134 (gnus-cache-possibly-remove-articles)
7135 (gnus-cache-save-buffers))
7136 (gnus-async-prefetch-remove-group group)
7137 (when gnus-suppress-duplicates
7138 (gnus-dup-enter-articles))
7139 (when gnus-use-trees
7140 (gnus-tree-close group))
16409b0b
GM
7141 (when gnus-use-cache
7142 (gnus-cache-write-active))
6748645f
LMI
7143 ;; Remove entries for this group.
7144 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
7145 ;; Make all changes in this group permanent.
7146 (unless quit-config
6748645f 7147 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 7148 (gnus-summary-update-info))
eec82323
LMI
7149 (gnus-close-group group)
7150 ;; Make sure where we were, and go to next newsgroup.
7151 (set-buffer gnus-group-buffer)
7152 (unless quit-config
7153 (gnus-group-jump-to-group group))
6748645f
LMI
7154 (gnus-run-hooks 'gnus-summary-exit-hook)
7155 (unless (or quit-config
01c52d31 7156 (not gnus-summary-next-group-on-exit)
6748645f
LMI
7157 ;; If this group has disappeared from the summary
7158 ;; buffer, don't skip forwards.
7159 (not (string= group (gnus-group-group-name))))
eec82323 7160 (gnus-group-next-unread-group 1))
a8151ef7 7161 (setq group-point (point))
eec82323
LMI
7162 (if temporary
7163 nil ;Nothing to do.
eec82323
LMI
7164 (set-buffer buf)
7165 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
7166 (progn
7167 (gnus-deaden-summary)
7168 (setq mode nil))
eec82323
LMI
7169 (when (get-buffer gnus-article-buffer)
7170 (bury-buffer gnus-article-buffer))
eec82323
LMI
7171 ;; Return to group mode buffer.
7172 (when (eq mode 'gnus-summary-mode)
7173 (gnus-kill-buffer buf)))
9f2d52e7
G
7174
7175 ;; If we have several article buffers, we kill them at exit.
7176 (unless gnus-single-article-buffer
7177 (when (gnus-buffer-live-p gnus-article-buffer)
7178 (with-current-buffer gnus-article-buffer
7179 ;; Don't kill sticky article buffers
7180 (unless (eq major-mode 'gnus-sticky-article-mode)
7181 (gnus-kill-buffer gnus-article-buffer)
7182 (setq gnus-article-current nil))))
7183 (gnus-kill-buffer gnus-original-article-buffer))
7184
eec82323 7185 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
7186 (set-buffer gnus-group-buffer)
7187 (if quit-config
7188 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
7189 (goto-char group-point)
7190 ;; If gnus-group-buffer is already displayed, make sure we also move
7191 ;; the cursor in the window that displays it.
7192 (let ((win (get-buffer-window (current-buffer) 0)))
7193 (if win (set-window-point win (point))))
d61c212b 7194 (unless leave-hidden
4e90f2b9 7195 (gnus-configure-windows 'group 'force)))
6748645f 7196 ;; Clear the current group name.
eec82323
LMI
7197 (unless quit-config
7198 (setq gnus-newsgroup-name nil)))))
7199
7200(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7201(defun gnus-summary-exit-no-update (&optional no-questions)
7202 "Quit reading current newsgroup without updating read article info."
7203 (interactive)
eec82323 7204 (let* ((group gnus-newsgroup-name)
23f87bed
MB
7205 (gnus-group-is-exiting-p t)
7206 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
7207 (quit-config (gnus-group-quit-config group)))
7208 (when (or no-questions
7209 gnus-expert-user
7210 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 7211 (gnus-async-halt-prefetch)
23f87bed 7212 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b 7213 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7214 (with-current-buffer gnus-article-buffer
16409b0b
GM
7215 (mm-destroy-parts gnus-article-mime-handles)
7216 ;; Set it to nil for safety reason.
7217 (setq gnus-article-mime-handle-alist nil)
7218 (setq gnus-article-mime-handles nil)))
eec82323
LMI
7219 ;; If we have several article buffers, we kill them at exit.
7220 (unless gnus-single-article-buffer
7221 (gnus-kill-buffer gnus-article-buffer)
7222 (gnus-kill-buffer gnus-original-article-buffer)
7223 (setq gnus-article-current nil))
7224 (if (not gnus-kill-summary-on-exit)
7225 (gnus-deaden-summary)
7226 (gnus-close-group group)
23f87bed 7227 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
7228 (unless gnus-single-article-buffer
7229 (setq gnus-article-current nil))
7230 (when gnus-use-trees
7231 (gnus-tree-close group))
7232 (gnus-async-prefetch-remove-group group)
7233 (when (get-buffer gnus-article-buffer)
7234 (bury-buffer gnus-article-buffer))
7235 ;; Return to the group buffer.
7236 (gnus-configure-windows 'group 'force)
7237 ;; Clear the current group name.
7238 (setq gnus-newsgroup-name nil)
23f87bed
MB
7239 (unless (gnus-ephemeral-group-p group)
7240 (gnus-group-update-group group))
eec82323
LMI
7241 (when (equal (gnus-group-group-name) group)
7242 (gnus-group-next-unread-group 1))
7243 (when quit-config
23f87bed 7244 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
7245
7246(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
7247 "Handle movement when leaving an ephemeral group.
7248The state which existed when entering the ephemeral is reset."
eec82323
LMI
7249 (if (not (buffer-name (car quit-config)))
7250 (gnus-configure-windows 'group 'force)
7251 (set-buffer (car quit-config))
7252 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
7253 (gnus-set-global-variables))
7254 ((eq major-mode 'gnus-article-mode)
c7a91ce1 7255 (save-current-buffer
23f87bed
MB
7256 ;; The `gnus-summary-buffer' variable may point
7257 ;; to the old summary buffer when using a single
7258 ;; article buffer.
7259 (unless (gnus-buffer-live-p gnus-summary-buffer)
7260 (set-buffer gnus-group-buffer))
7261 (set-buffer gnus-summary-buffer)
7262 (gnus-set-global-variables))))
eec82323 7263 (if (or (eq (cdr quit-config) 'article)
23f87bed 7264 (eq (cdr quit-config) 'pick))
01c52d31
MB
7265 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7266 (gnus-configure-windows 'pick 'force)
7267 (gnus-configure-windows (cdr quit-config) 'force))
eec82323
LMI
7268 (gnus-configure-windows (cdr quit-config) 'force))
7269 (when (eq major-mode 'gnus-summary-mode)
01c52d31
MB
7270 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7271 next-unread-noselect))
7272 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7273 'next-noselect)
7274 (gnus-summary-next-subject 1 nil t))
7275 ((eq gnus-auto-select-on-ephemeral-exit
7276 'next-unread-noselect)
7277 (gnus-summary-next-subject 1 t t))))
7278 ;; Hide the article buffer which displays the article different
7279 ;; from the one that the cursor points to in the summary buffer.
7280 (gnus-configure-windows 'summary 'force))
7281 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7282 (gnus-summary-next-subject 1))
7283 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7284 (gnus-summary-next-subject 1 t))))
eec82323
LMI
7285 (gnus-summary-recenter)
7286 (gnus-summary-position-point))))
7287
7288;;; Dead summaries.
7289
bbf52f1e
SM
7290(defvar gnus-dead-summary-mode-map
7291 (let ((map (make-keymap)))
7292 (suppress-keymap map)
7293 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7294 (dolist (key '("\C-d" "\r" "\177" [delete]))
7295 (define-key map key 'gnus-summary-wake-up-the-dead))
7296 (dolist (key '("q" "Q"))
7297 (define-key map key 'bury-buffer))
7298 map))
7299
7300(define-minor-mode gnus-dead-summary-mode
eec82323 7301 "Minor mode for Gnus summary buffers."
bbf52f1e
SM
7302 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7303 (unless (derived-mode-p 'gnus-summary-mode)
7304 (setq gnus-dead-summary-mode nil)))
eec82323
LMI
7305
7306(defun gnus-deaden-summary ()
7307 "Make the current summary buffer into a dead summary buffer."
7308 ;; Kill any previous dead summary buffer.
7309 (when (and gnus-dead-summary
7310 (buffer-name gnus-dead-summary))
01c52d31 7311 (with-current-buffer gnus-dead-summary
eec82323
LMI
7312 (when gnus-dead-summary-mode
7313 (kill-buffer (current-buffer)))))
7314 ;; Make this the current dead summary.
7315 (setq gnus-dead-summary (current-buffer))
7316 (gnus-dead-summary-mode 1)
7317 (let ((name (buffer-name)))
7318 (when (string-match "Summary" name)
7319 (rename-buffer
7320 (concat (substring name 0 (match-beginning 0)) "Dead "
7321 (substring name (match-beginning 0)))
16409b0b
GM
7322 t)
7323 (bury-buffer))))
eec82323
LMI
7324
7325(defun gnus-kill-or-deaden-summary (buffer)
7326 "Kill or deaden the summary BUFFER."
6748645f
LMI
7327 (save-excursion
7328 (when (and (buffer-name buffer)
7329 (not gnus-single-article-buffer))
01c52d31 7330 (with-current-buffer buffer
6748645f
LMI
7331 (gnus-kill-buffer gnus-article-buffer)
7332 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
7333 (cond
7334 ;; Kill the buffer.
7335 (gnus-kill-summary-on-exit
7336 (when (and gnus-use-trees
7337 (gnus-buffer-exists-p buffer))
c7a91ce1 7338 (with-current-buffer buffer
23f87bed
MB
7339 (gnus-tree-close gnus-newsgroup-name)))
7340 (gnus-kill-buffer buffer))
7341 ;; Deaden the buffer.
7342 ((gnus-buffer-exists-p buffer)
c7a91ce1 7343 (with-current-buffer buffer
23f87bed 7344 (gnus-deaden-summary))))))
eec82323
LMI
7345
7346(defun gnus-summary-wake-up-the-dead (&rest args)
7347 "Wake up the dead summary buffer."
7348 (interactive)
7349 (gnus-dead-summary-mode -1)
7350 (let ((name (buffer-name)))
7351 (when (string-match "Dead " name)
7352 (rename-buffer
7353 (concat (substring name 0 (match-beginning 0))
7354 (substring name (match-end 0)))
7355 t)))
7356 (gnus-message 3 "This dead summary is now alive again"))
7357
eec82323
LMI
7358;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7359(defun gnus-summary-describe-group (&optional force)
7360 "Describe the current newsgroup."
7361 (interactive "P")
7362 (gnus-group-describe-group force gnus-newsgroup-name))
7363
7364(defun gnus-summary-describe-briefly ()
7365 "Describe summary mode commands briefly."
7366 (interactive)
bdaa75c7 7367 (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
7368
7369;; Walking around group mode buffer from summary mode.
7370
7371(defun gnus-summary-next-group (&optional no-article target-group backward)
7372 "Exit current newsgroup and then select next unread newsgroup.
7373If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7374initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7375previous group instead."
7376 (interactive "P")
eec82323
LMI
7377 ;; Stop pre-fetching.
7378 (gnus-async-halt-prefetch)
7379 (let ((current-group gnus-newsgroup-name)
7380 (current-buffer (current-buffer))
7381 entered)
7382 ;; First we semi-exit this group to update Xrefs and all variables.
7383 ;; We can't do a real exit, because the window conf must remain
7384 ;; the same in case the user is prompted for info, and we don't
7385 ;; want the window conf to change before that...
7386 (gnus-summary-exit t)
7387 (while (not entered)
7388 ;; Then we find what group we are supposed to enter.
7389 (set-buffer gnus-group-buffer)
7390 (gnus-group-jump-to-group current-group)
7391 (setq target-group
7392 (or target-group
7393 (if (eq gnus-keep-same-level 'best)
7394 (gnus-summary-best-group gnus-newsgroup-name)
7395 (gnus-summary-search-group backward gnus-keep-same-level))))
7396 (if (not target-group)
7397 ;; There are no further groups, so we return to the group
7398 ;; buffer.
7399 (progn
7400 (gnus-message 5 "Returning to the group buffer")
7401 (setq entered t)
7402 (when (gnus-buffer-live-p current-buffer)
7403 (set-buffer current-buffer)
7404 (gnus-summary-exit))
6748645f 7405 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7406 ;; We try to enter the target group.
7407 (gnus-group-jump-to-group target-group)
7408 (let ((unreads (gnus-group-group-unread)))
7409 (if (and (or (eq t unreads)
7410 (and unreads (not (zerop unreads))))
23f87bed
MB
7411 (gnus-summary-read-group
7412 target-group nil no-article
7413 (and (buffer-name current-buffer) current-buffer)
7414 nil backward))
eec82323
LMI
7415 (setq entered t)
7416 (setq current-group target-group
7417 target-group nil)))))))
7418
7419(defun gnus-summary-prev-group (&optional no-article)
7420 "Exit current newsgroup and then select previous unread newsgroup.
7421If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7422 (interactive "P")
7423 (gnus-summary-next-group no-article nil t))
7424
7425;; Walking around summary lines.
7426
23f87bed
MB
7427(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7428 "Go to the first subject satisfying any non-nil constraint.
7429If UNREAD is non-nil, the article should be unread.
7430If UNDOWNLOADED is non-nil, the article should be undownloaded.
20a673b2 7431If UNSEEN is non-nil, the article should be unseen as well as unread.
23f87bed 7432Returns the article selected or nil if there are no matching articles."
eec82323 7433 (interactive "P")
23f87bed
MB
7434 (cond
7435 ;; Empty summary.
7436 ((null gnus-newsgroup-data)
7437 (gnus-message 3 "No articles in the group")
7438 nil)
7439 ;; Pick the first article.
7440 ((not (or unread undownloaded unseen))
7441 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7442 (gnus-data-number (car gnus-newsgroup-data)))
7443 ;; Find the first unread article.
7444 (t
7445 (let ((data gnus-newsgroup-data))
7446 (while (and data
7447 (let ((num (gnus-data-number (car data))))
7448 (or (memq num gnus-newsgroup-unfetched)
7449 (not (or (and unread
7450 (memq num gnus-newsgroup-unreads))
7451 (and undownloaded
7452 (memq num gnus-newsgroup-undownloaded))
7453 (and unseen
20a673b2
KY
7454 (memq num gnus-newsgroup-unseen)
7455 (memq num gnus-newsgroup-unreads)))))))
23f87bed
MB
7456 (setq data (cdr data)))
7457 (prog1
7458 (if data
7459 (progn
7460 (goto-char (gnus-data-pos (car data)))
7461 (gnus-data-number (car data)))
7462 (gnus-message 3 "No more%s articles"
7463 (let* ((r (when unread " unread"))
7464 (d (when undownloaded " undownloaded"))
7465 (s (when unseen " unseen"))
7466 (l (delq nil (list r d s))))
7467 (cond ((= 3 (length l))
7468 (concat r "," d ", or" s))
7469 ((= 2 (length l))
7470 (concat (car l) ", or" (cadr l)))
7471 ((= 1 (length l))
7472 (car l))
7473 (t
7474 ""))))
7475 nil
7476 )
7477 (gnus-summary-position-point))))))
eec82323
LMI
7478
7479(defun gnus-summary-next-subject (n &optional unread dont-display)
7480 "Go to next N'th summary line.
7481If N is negative, go to the previous N'th subject line.
7482If UNREAD is non-nil, only unread articles are selected.
7483The difference between N and the actual number of steps taken is
7484returned."
7485 (interactive "p")
7486 (let ((backward (< n 0))
7487 (n (abs n)))
7488 (while (and (> n 0)
7489 (if backward
7490 (gnus-summary-find-prev unread)
7491 (gnus-summary-find-next unread)))
16409b0b
GM
7492 (unless (zerop (setq n (1- n)))
7493 (gnus-summary-show-thread)))
eec82323
LMI
7494 (when (/= 0 n)
7495 (gnus-message 7 "No more%s articles"
7496 (if unread " unread" "")))
7497 (unless dont-display
7498 (gnus-summary-recenter)
7499 (gnus-summary-position-point))
7500 n))
7501
7502(defun gnus-summary-next-unread-subject (n)
7503 "Go to next N'th unread summary line."
7504 (interactive "p")
7505 (gnus-summary-next-subject n t))
7506
7507(defun gnus-summary-prev-subject (n &optional unread)
7508 "Go to previous N'th summary line.
7509If optional argument UNREAD is non-nil, only unread article is selected."
7510 (interactive "p")
7511 (gnus-summary-next-subject (- n) unread))
7512
7513(defun gnus-summary-prev-unread-subject (n)
7514 "Go to previous N'th unread summary line."
7515 (interactive "p")
7516 (gnus-summary-next-subject (- n) t))
7517
23f87bed
MB
7518(defun gnus-summary-goto-subjects (articles)
7519 "Insert the subject header for ARTICLES in the current buffer."
7520 (save-excursion
7521 (dolist (article articles)
7522 (gnus-summary-goto-subject article t)))
7523 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7524 (gnus-summary-position-point))
132cf96d 7525
eec82323 7526(defun gnus-summary-goto-subject (article &optional force silent)
d55fe5bb 7527 "Go to the subject line of ARTICLE.
eec82323
LMI
7528If FORCE, also allow jumping to articles not currently shown."
7529 (interactive "nArticle number: ")
23f87bed
MB
7530 (unless (numberp article)
7531 (error "Article %s is not a number" article))
eec82323
LMI
7532 (let ((b (point))
7533 (data (gnus-data-find article)))
7534 ;; We read in the article if we have to.
7535 (and (not data)
7536 force
6748645f
LMI
7537 (gnus-summary-insert-subject
7538 article
7539 (if (or (numberp force) (vectorp force)) force)
7540 t)
eec82323
LMI
7541 (setq data (gnus-data-find article)))
7542 (goto-char b)
7543 (if (not data)
7544 (progn
7545 (unless silent
7546 (gnus-message 3 "Can't find article %d" article))
7547 nil)
23f87bed
MB
7548 (let ((pt (gnus-data-pos data)))
7549 (goto-char pt)
7550 (gnus-summary-set-article-display-arrow pt))
6748645f 7551 (gnus-summary-position-point)
eec82323
LMI
7552 article)))
7553
7554;; Walking around summary lines with displaying articles.
7555
7556(defun gnus-summary-expand-window (&optional arg)
7557 "Make the summary buffer take up the entire Emacs frame.
7558Given a prefix, will force an `article' buffer configuration."
7559 (interactive "P")
eec82323
LMI
7560 (if arg
7561 (gnus-configure-windows 'article 'force)
7562 (gnus-configure-windows 'summary 'force)))
7563
7564(defun gnus-summary-display-article (article &optional all-header)
7565 "Display ARTICLE in article buffer."
01c52d31
MB
7566 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7567 (with-current-buffer gnus-article-buffer
7568 (eq major-mode 'gnus-article-mode)))
7569 (gnus-article-setup-buffer))
eec82323 7570 (gnus-set-global-variables)
01c52d31
MB
7571 (with-current-buffer gnus-article-buffer
7572 (setq gnus-article-charset gnus-newsgroup-charset)
7573 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7574 (mm-enable-multibyte))
eec82323
LMI
7575 (if (null article)
7576 nil
7577 (prog1
7578 (if gnus-summary-display-article-function
7579 (funcall gnus-summary-display-article-function article all-header)
7580 (gnus-article-prepare article all-header))
6748645f 7581 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7582 (when (and gnus-current-article
7583 (not (zerop gnus-current-article)))
7584 (gnus-summary-goto-subject gnus-current-article))
7585 (gnus-summary-recenter)
7586 (when (and gnus-use-trees gnus-show-threads)
7587 (gnus-possibly-generate-tree article)
7588 (gnus-highlight-selected-tree article))
7589 ;; Successfully display article.
7590 (gnus-article-set-window-start
7591 (cdr (assq article gnus-newsgroup-bookmarks))))))
7592
7593(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7594 "Select the current article.
7595If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7596non-nil, the article will be re-fetched even if it already present in
7597the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7598be displayed."
7599 ;; Make sure we are in the summary buffer to work around bbdb bug.
7600 (unless (eq major-mode 'gnus-summary-mode)
7601 (set-buffer gnus-summary-buffer))
7602 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7603 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7604 gnus-summary-display-article-function)
eec82323
LMI
7605 (and (not pseudo)
7606 (gnus-summary-article-pseudo-p article)
a8151ef7 7607 (error "This is a pseudo-article"))
c7a91ce1 7608 (with-current-buffer gnus-summary-buffer
16409b0b
GM
7609 (if (or (and gnus-single-article-buffer
7610 (or (null gnus-current-article)
7611 (null gnus-article-current)
7612 (null (get-buffer gnus-article-buffer))
7613 (not (eq article (cdr gnus-article-current)))
7614 (not (equal (car gnus-article-current)
de635afe 7615 gnus-newsgroup-name))
28090d40 7616 (not (get-buffer gnus-original-article-buffer))))
16409b0b
GM
7617 (and (not gnus-single-article-buffer)
7618 (or (null gnus-current-article)
389b76fa 7619 (not (get-buffer gnus-original-article-buffer))
16409b0b
GM
7620 (not (eq gnus-current-article article))))
7621 force)
7622 ;; The requested article is different from the current article.
7623 (progn
16409b0b
GM
7624 (gnus-summary-display-article article all-headers)
7625 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7626 (with-current-buffer gnus-article-buffer
16409b0b 7627 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7628 (mm-disable-multibyte))))
16409b0b
GM
7629 (gnus-article-set-window-start
7630 (cdr (assq article gnus-newsgroup-bookmarks)))
7631 article)
16409b0b 7632 'old))))
eec82323 7633
23f87bed
MB
7634(defun gnus-summary-force-verify-and-decrypt ()
7635 "Display buttons for signed/encrypted parts and verify/decrypt them."
7636 (interactive)
7637 (let ((mm-verify-option 'known)
7638 (mm-decrypt-option 'known)
7639 (gnus-article-emulate-mime t)
7640 (gnus-buttonized-mime-types (append (list "multipart/signed"
7641 "multipart/encrypted")
7642 gnus-buttonized-mime-types)))
7643 (gnus-summary-select-article nil 'force)))
7644
eec82323
LMI
7645(defun gnus-summary-set-current-mark (&optional current-mark)
7646 "Obsolete function."
7647 nil)
7648
7649(defun gnus-summary-next-article (&optional unread subject backward push)
7650 "Select the next article.
7651If UNREAD, only unread articles are selected.
7652If SUBJECT, only articles with SUBJECT are selected.
7653If BACKWARD, the previous article is selected instead of the next."
7654 (interactive "P")
11e95b02
MB
7655 ;; Make sure we are in the summary buffer.
7656 (unless (eq major-mode 'gnus-summary-mode)
7657 (set-buffer gnus-summary-buffer))
eec82323
LMI
7658 (cond
7659 ;; Is there such an article?
7660 ((and (gnus-summary-search-forward unread subject backward)
7661 (or (gnus-summary-display-article (gnus-summary-article-number))
7662 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7663 (gnus-summary-position-point))
7664 ;; If not, we try the first unread, if that is wanted.
7665 ((and subject
7666 gnus-auto-select-same
7667 (gnus-summary-first-unread-article))
7668 (gnus-summary-position-point)
7669 (gnus-message 6 "Wrapped"))
7670 ;; Try to get next/previous article not displayed in this group.
7671 ((and gnus-auto-extend-newsgroup
7672 (not unread) (not subject))
7673 (gnus-summary-goto-article
7674 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7675 nil (count-lines (point-min) (point))))
eec82323
LMI
7676 ;; Go to next/previous group.
7677 (t
7678 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7679 (gnus-summary-jump-to-group gnus-newsgroup-name))
49e787c9
GM
7680 (let ((cmd (if (featurep 'xemacs)
7681 last-command-char
7682 last-command-event))
eec82323 7683 (point
01c52d31 7684 (with-current-buffer gnus-group-buffer
eec82323
LMI
7685 (point)))
7686 (group
7687 (if (eq gnus-keep-same-level 'best)
7688 (gnus-summary-best-group gnus-newsgroup-name)
7689 (gnus-summary-search-group backward gnus-keep-same-level))))
eec82323
LMI
7690 ;; Select next unread newsgroup automagically.
7691 (cond
7692 ((or (not gnus-auto-select-next)
7693 (not cmd))
7694 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7695 ((or (eq gnus-auto-select-next 'quietly)
7696 (and (eq gnus-auto-select-next 'slightly-quietly)
7697 push)
7698 (and (eq gnus-auto-select-next 'almost-quietly)
7699 (gnus-summary-last-article-p)))
7700 ;; Select quietly.
7701 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7702 (gnus-summary-exit)
7703 (gnus-message 7 "No more%s articles (%s)..."
7704 (if unread " unread" "")
7705 (if group (concat "selecting " group)
7706 "exiting"))
7707 (gnus-summary-next-group nil group backward)))
7708 (t
7709 (when (gnus-key-press-event-p last-input-event)
7710 (gnus-summary-walk-group-buffer
7711 gnus-newsgroup-name cmd unread backward point))))))))
7712
7713(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7714 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7715 (?\C-p (gnus-group-prev-unread-group 1))))
7716 (cursor-in-echo-area t)
23f87bed 7717 keve key group ended prompt)
c7a91ce1 7718 (with-current-buffer gnus-group-buffer
eec82323
LMI
7719 (goto-char start)
7720 (setq group
7721 (if (eq gnus-keep-same-level 'best)
7722 (gnus-summary-best-group gnus-newsgroup-name)
7723 (gnus-summary-search-group backward gnus-keep-same-level))))
7724 (while (not ended)
23f87bed
MB
7725 (setq prompt
7726 (format
7727 "No more%s articles%s " (if unread " unread" "")
7728 (if (and group
7729 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7730 (format " (Type %s for %s [%s])"
91472578
MB
7731 (single-key-description cmd)
7732 (gnus-group-decoded-name group)
01c52d31 7733 (gnus-group-unread group))
23f87bed
MB
7734 (format " (Type %s to exit %s)"
7735 (single-key-description cmd)
91472578 7736 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7737 ;; Confirm auto selection.
23f87bed
MB
7738 (setq key (car (setq keve (gnus-read-event-char prompt)))
7739 ended t)
eec82323
LMI
7740 (cond
7741 ((assq key keystrokes)
7742 (let ((obuf (current-buffer)))
7743 (switch-to-buffer gnus-group-buffer)
7744 (when group
7745 (gnus-group-jump-to-group group))
7746 (eval (cadr (assq key keystrokes)))
7747 (setq group (gnus-group-group-name))
7748 (switch-to-buffer obuf))
7749 (setq ended nil))
7750 ((equal key cmd)
7751 (if (or (not group)
7752 (gnus-ephemeral-group-p gnus-newsgroup-name))
7753 (gnus-summary-exit)
7754 (gnus-summary-next-group nil group backward)))
7755 (t
7756 (push (cdr keve) unread-command-events))))))
7757
7758(defun gnus-summary-next-unread-article ()
7759 "Select unread article after current one."
7760 (interactive)
7761 (gnus-summary-next-article
7762 (or (not (eq gnus-summary-goto-unread 'never))
7763 (gnus-summary-last-article-p (gnus-summary-article-number)))
7764 (and gnus-auto-select-same
7765 (gnus-summary-article-subject))))
7766
7767(defun gnus-summary-prev-article (&optional unread subject)
bbbe940b 7768 "Select the article before the current one.
eec82323
LMI
7769If UNREAD is non-nil, only unread articles are selected."
7770 (interactive "P")
7771 (gnus-summary-next-article unread subject t))
7772
7773(defun gnus-summary-prev-unread-article ()
7774 "Select unread article before current one."
7775 (interactive)
7776 (gnus-summary-prev-article
7777 (or (not (eq gnus-summary-goto-unread 'never))
7778 (gnus-summary-first-article-p (gnus-summary-article-number)))
7779 (and gnus-auto-select-same
7780 (gnus-summary-article-subject))))
7781
23f87bed 7782(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7783 "Show next page of the selected article.
7784If at the end of the current article, select the next article.
7785LINES says how many lines should be scrolled up.
7786
7787If CIRCULAR is non-nil, go to the start of the article instead of
7788selecting the next article when reaching the end of the current
23f87bed
MB
7789article.
7790
7791If STOP is non-nil, just stop when reaching the end of the message.
7792
7793Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7794 (interactive "P")
7795 (setq gnus-summary-buffer (current-buffer))
7796 (gnus-set-global-variables)
7797 (let ((article (gnus-summary-article-number))
7798 (article-window (get-buffer-window gnus-article-buffer t))
7799 endp)
6748645f
LMI
7800 ;; If the buffer is empty, we have no article.
7801 (unless article
7802 (error "No article to select"))
eec82323
LMI
7803 (gnus-configure-windows 'article)
7804 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7805 (if (and (eq gnus-summary-goto-unread 'never)
7806 (not (gnus-summary-last-article-p article)))
7807 (gnus-summary-next-article)
7808 (gnus-summary-next-unread-article))
7809 (if (or (null gnus-current-article)
7810 (null gnus-article-current)
7811 (/= article (cdr gnus-article-current))
7812 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7813 ;; Selected subject is different from current article's.
7814 (gnus-summary-display-article article)
7815 (when article-window
7816 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7817 (setq endp (or (gnus-article-next-page lines)
7818 (gnus-article-only-boring-p))))
eec82323 7819 (when endp
b1992461 7820 (cond ((or stop gnus-summary-stop-at-end-of-message)
23f87bed
MB
7821 (gnus-message 3 "End of message"))
7822 (circular
eec82323
LMI
7823 (gnus-summary-beginning-of-article))
7824 (lines
7825 (gnus-message 3 "End of message"))
7826 ((null lines)
7827 (if (and (eq gnus-summary-goto-unread 'never)
7828 (not (gnus-summary-last-article-p article)))
7829 (gnus-summary-next-article)
7830 (gnus-summary-next-unread-article))))))))
7831 (gnus-summary-recenter)
7832 (gnus-summary-position-point)))
7833
7834(defun gnus-summary-prev-page (&optional lines move)
7835 "Show previous page of selected article.
7836Argument LINES specifies lines to be scrolled down.
7837If MOVE, move to the previous unread article if point is at
7838the beginning of the buffer."
7839 (interactive "P")
eec82323
LMI
7840 (let ((article (gnus-summary-article-number))
7841 (article-window (get-buffer-window gnus-article-buffer t))
7842 endp)
7843 (gnus-configure-windows 'article)
7844 (if (or (null gnus-current-article)
7845 (null gnus-article-current)
7846 (/= article (cdr gnus-article-current))
7847 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7848 ;; Selected subject is different from current article's.
7849 (gnus-summary-display-article article)
7850 (gnus-summary-recenter)
7851 (when article-window
7852 (gnus-eval-in-buffer-window gnus-article-buffer
7853 (setq endp (gnus-article-prev-page lines)))
7854 (when (and move endp)
7855 (cond (lines
7856 (gnus-message 3 "Beginning of message"))
7857 ((null lines)
7858 (if (and (eq gnus-summary-goto-unread 'never)
7859 (not (gnus-summary-first-article-p article)))
7860 (gnus-summary-prev-article)
7861 (gnus-summary-prev-unread-article))))))))
7862 (gnus-summary-position-point))
7863
7864(defun gnus-summary-prev-page-or-article (&optional lines)
7865 "Show previous page of selected article.
7866Argument LINES specifies lines to be scrolled down.
7867If at the beginning of the article, go to the next article."
7868 (interactive "P")
7869 (gnus-summary-prev-page lines t))
7870
7871(defun gnus-summary-scroll-up (lines)
7872 "Scroll up (or down) one line current article.
a3f57c41
G
7873Argument LINES specifies lines to be scrolled up (or down if negative).
7874If no article is selected, then the current article will be selected first."
eec82323 7875 (interactive "p")
eec82323
LMI
7876 (gnus-configure-windows 'article)
7877 (gnus-summary-show-thread)
7878 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7879 (gnus-eval-in-buffer-window gnus-article-buffer
7880 (cond ((> lines 0)
7881 (when (gnus-article-next-page lines)
7882 (gnus-message 3 "End of message")))
7883 ((< lines 0)
7884 (gnus-article-prev-page (- lines))))))
7885 (gnus-summary-recenter)
7886 (gnus-summary-position-point))
7887
6748645f
LMI
7888(defun gnus-summary-scroll-down (lines)
7889 "Scroll down (or up) one line current article.
a3f57c41
G
7890Argument LINES specifies lines to be scrolled down (or up if negative).
7891If no article is selected, then the current article will be selected first."
6748645f
LMI
7892 (interactive "p")
7893 (gnus-summary-scroll-up (- lines)))
7894
eec82323
LMI
7895(defun gnus-summary-next-same-subject ()
7896 "Select next article which has the same subject as current one."
7897 (interactive)
eec82323
LMI
7898 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7899
7900(defun gnus-summary-prev-same-subject ()
7901 "Select previous article which has the same subject as current one."
7902 (interactive)
eec82323
LMI
7903 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7904
7905(defun gnus-summary-next-unread-same-subject ()
7906 "Select next unread article which has the same subject as current one."
7907 (interactive)
eec82323
LMI
7908 (gnus-summary-next-article t (gnus-summary-article-subject)))
7909
7910(defun gnus-summary-prev-unread-same-subject ()
7911 "Select previous unread article which has the same subject as current one."
7912 (interactive)
eec82323
LMI
7913 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7914
7915(defun gnus-summary-first-unread-article ()
7916 "Select the first unread article.
7917Return nil if there are no unread articles."
7918 (interactive)
eec82323
LMI
7919 (prog1
7920 (when (gnus-summary-first-subject t)
7921 (gnus-summary-show-thread)
7922 (gnus-summary-first-subject t)
7923 (gnus-summary-display-article (gnus-summary-article-number)))
7924 (gnus-summary-position-point)))
7925
16409b0b
GM
7926(defun gnus-summary-first-unread-subject ()
7927 "Place the point on the subject line of the first unread article.
7928Return nil if there are no unread articles."
7929 (interactive)
7930 (prog1
7931 (when (gnus-summary-first-subject t)
7932 (gnus-summary-show-thread)
7933 (gnus-summary-first-subject t))
7934 (gnus-summary-position-point)))
7935
23f87bed
MB
7936(defun gnus-summary-first-unseen-subject ()
7937 "Place the point on the subject line of the first unseen article.
7938Return nil if there are no unseen articles."
7939 (interactive)
7940 (prog1
7941 (when (gnus-summary-first-subject nil nil t)
7942 (gnus-summary-show-thread)
7943 (gnus-summary-first-subject nil nil t))
7944 (gnus-summary-position-point)))
7945
7946(defun gnus-summary-first-unseen-or-unread-subject ()
20a673b2
KY
7947 "Place the point on the subject line of the first unseen and unread article.
7948If all article have been seen, on the subject line of the first unread
23f87bed
MB
7949article."
7950 (interactive)
7951 (prog1
7952 (unless (when (gnus-summary-first-subject nil nil t)
7953 (gnus-summary-show-thread)
7954 (gnus-summary-first-subject nil nil t))
7955 (when (gnus-summary-first-subject t)
7956 (gnus-summary-show-thread)
7957 (gnus-summary-first-subject t)))
7958 (gnus-summary-position-point)))
7959
eec82323
LMI
7960(defun gnus-summary-first-article ()
7961 "Select the first article.
7962Return nil if there are no articles."
7963 (interactive)
eec82323
LMI
7964 (prog1
7965 (when (gnus-summary-first-subject)
16409b0b
GM
7966 (gnus-summary-show-thread)
7967 (gnus-summary-first-subject)
7968 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
7969 (gnus-summary-position-point)))
7970
23f87bed
MB
7971(defun gnus-summary-best-unread-article (&optional arg)
7972 "Select the unread article with the highest score.
7973If given a prefix argument, select the next unread article that has a
7974score higher than the default score."
7975 (interactive "P")
7976 (let ((article (if arg
7977 (gnus-summary-better-unread-subject)
7978 (gnus-summary-best-unread-subject))))
7979 (if article
7980 (gnus-summary-goto-article article)
7981 (error "No unread articles"))))
7982
7983(defun gnus-summary-best-unread-subject ()
7984 "Select the unread subject with the highest score."
eec82323 7985 (interactive)
eec82323
LMI
7986 (let ((best -1000000)
7987 (data gnus-newsgroup-data)
7988 article score)
7989 (while data
7990 (and (gnus-data-unread-p (car data))
7991 (> (setq score
7992 (gnus-summary-article-score (gnus-data-number (car data))))
7993 best)
7994 (setq best score
7995 article (gnus-data-number (car data))))
7996 (setq data (cdr data)))
23f87bed
MB
7997 (when article
7998 (gnus-summary-goto-subject article))
7999 (gnus-summary-position-point)
8000 article))
8001
8002(defun gnus-summary-better-unread-subject ()
8003 "Select the first unread subject that has a score over the default score."
8004 (interactive)
8005 (let ((data gnus-newsgroup-data)
8006 article score)
8007 (while (and (setq article (gnus-data-number (car data)))
8008 (or (gnus-data-read-p (car data))
8009 (not (> (gnus-summary-article-score article)
8010 gnus-summary-default-score))))
8011 (setq data (cdr data)))
8012 (when article
8013 (gnus-summary-goto-subject article))
8014 (gnus-summary-position-point)
8015 article))
eec82323
LMI
8016
8017(defun gnus-summary-last-subject ()
8018 "Go to the last displayed subject line in the group."
8019 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8020 (when article
8021 (gnus-summary-goto-subject article))))
8022
8023(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
8024 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8025If ALL-HEADERS is non-nil, no header lines are hidden.
8026If FORCE, go to the article even if it isn't displayed. If FORCE
8027is a number, it is the line the article is to be displayed on."
eec82323
LMI
8028 (interactive
8029 (list
229b59da
G
8030 (gnus-completing-read
8031 "Article number or Message-ID"
8032 (mapcar 'int-to-string gnus-newsgroup-limit))
eec82323
LMI
8033 current-prefix-arg
8034 t))
8035 (prog1
6748645f 8036 (if (and (stringp article)
23f87bed 8037 (string-match "@\\|%40" article))
6748645f
LMI
8038 (gnus-summary-refer-article article)
8039 (when (stringp article)
8040 (setq article (string-to-number article)))
8041 (if (gnus-summary-goto-subject article force)
8042 (gnus-summary-display-article article all-headers)
8043 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
8044 (gnus-summary-position-point)))
8045
8046(defun gnus-summary-goto-last-article ()
8047 "Go to the previously read article."
8048 (interactive)
8049 (prog1
8050 (when gnus-last-article
6748645f 8051 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
8052 (gnus-summary-position-point)))
8053
8054(defun gnus-summary-pop-article (number)
8055 "Pop one article off the history and go to the previous.
8056NUMBER articles will be popped off."
8057 (interactive "p")
8058 (let (to)
8059 (setq gnus-newsgroup-history
8060 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8061 (if to
6748645f 8062 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
8063 (error "Article history empty")))
8064 (gnus-summary-position-point))
8065
8066;; Summary commands and functions for limiting the summary buffer.
8067
8068(defun gnus-summary-limit-to-articles (n)
8069 "Limit the summary buffer to the next N articles.
8070If not given a prefix, use the process marked articles instead."
8071 (interactive "P")
eec82323
LMI
8072 (prog1
8073 (let ((articles (gnus-summary-work-articles n)))
8074 (setq gnus-newsgroup-processable nil)
8075 (gnus-summary-limit articles))
8076 (gnus-summary-position-point)))
8077
8078(defun gnus-summary-pop-limit (&optional total)
8079 "Restore the previous limit.
8080If given a prefix, remove all limits."
8081 (interactive "P")
eec82323
LMI
8082 (when total
8083 (setq gnus-newsgroup-limits
8084 (list (mapcar (lambda (h) (mail-header-number h))
8085 gnus-newsgroup-headers))))
8086 (unless gnus-newsgroup-limits
8087 (error "No limit to pop"))
8088 (prog1
8089 (gnus-summary-limit nil 'pop)
8090 (gnus-summary-position-point)))
8091
47b63dfa
SZ
8092(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8093 "Limit the summary buffer to articles that have subjects that match a regexp.
8094If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 8095 (interactive
47b63dfa
SZ
8096 (list (read-string (if current-prefix-arg
8097 "Exclude subject (regexp): "
a1506d29 8098 "Limit to subject (regexp): "))
47b63dfa 8099 nil current-prefix-arg))
eec82323
LMI
8100 (unless header
8101 (setq header "subject"))
8102 (when (not (equal "" subject))
8103 (prog1
8104 (let ((articles (gnus-summary-find-matching
a1506d29 8105 (or header "subject") subject 'all nil nil
47b63dfa 8106 not-matching)))
eec82323
LMI
8107 (unless articles
8108 (error "Found no matches for \"%s\"" subject))
8109 (gnus-summary-limit articles))
8110 (gnus-summary-position-point))))
8111
ef6e0ec7 8112(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
8113 "Limit the summary buffer to articles that have authors that match a regexp.
8114If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 8115 (interactive
47b63dfa
SZ
8116 (list (read-string (if current-prefix-arg
8117 "Exclude author (regexp): "
a1506d29 8118 "Limit to author (regexp): "))
ef6e0ec7
SZ
8119 current-prefix-arg))
8120 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323 8121
01c52d31
MB
8122(defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8123 "Limit the summary buffer to articles with the given RECIPIENT.
8124
8125If NOT-MATCHING, exclude RECIPIENT.
8126
8127To and Cc headers are checked. You need to include them in
8128`nnmail-extra-headers'."
8129 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8130 (interactive
8131 (list (read-string (format "%s recipient (regexp): "
8132 (if current-prefix-arg "Exclude" "Limit to")))
8133 current-prefix-arg))
8134 (when (not (equal "" recipient))
8135 (prog1 (let* ((to
8136 (if (memq 'To nnmail-extra-headers)
8137 (gnus-summary-find-matching
8138 (cons 'extra 'To) recipient 'all nil nil
8139 not-matching)
8140 (gnus-message
8141 1 "`To' isn't present in `nnmail-extra-headers'")
8142 (sit-for 1)
8143 nil))
8144 (cc
8145 (if (memq 'Cc nnmail-extra-headers)
8146 (gnus-summary-find-matching
8147 (cons 'extra 'Cc) recipient 'all nil nil
8148 not-matching)
8149 (gnus-message
8150 1 "`Cc' isn't present in `nnmail-extra-headers'")
8151 (sit-for 1)
8152 nil))
8153 (articles
8154 (if not-matching
8155 ;; We need the numbers that are in both lists:
8156 (mapcar (lambda (a)
8157 (and (memq a to) a))
8158 cc)
8159 (nconc to cc))))
8160 (unless articles
8161 (error "Found no matches for \"%s\"" recipient))
8162 (gnus-summary-limit articles))
8163 (gnus-summary-position-point))))
8164
8165(defun gnus-summary-limit-to-address (address &optional not-matching)
8166 "Limit the summary buffer to articles with the given ADDRESS.
8167
8168If NOT-MATCHING, exclude ADDRESS.
8169
8170To, Cc and From headers are checked. You need to include `To' and `Cc'
8171in `nnmail-extra-headers'."
8172 (interactive
8173 (list (read-string (format "%s address (regexp): "
8174 (if current-prefix-arg "Exclude" "Limit to")))
8175 current-prefix-arg))
8176 (when (not (equal "" address))
8177 (prog1 (let* ((to
8178 (if (memq 'To nnmail-extra-headers)
8179 (gnus-summary-find-matching
8180 (cons 'extra 'To) address 'all nil nil
8181 not-matching)
8182 (gnus-message
8183 1 "`To' isn't present in `nnmail-extra-headers'")
8184 (sit-for 1)
8185 t))
8186 (cc
8187 (if (memq 'Cc nnmail-extra-headers)
8188 (gnus-summary-find-matching
8189 (cons 'extra 'Cc) address 'all nil nil
8190 not-matching)
8191 (gnus-message
8192 1 "`Cc' isn't present in `nnmail-extra-headers'")
8193 (sit-for 1)
8194 t))
8195 (from
8196 (gnus-summary-find-matching "from" address
8197 'all nil nil not-matching))
8198 (articles
8199 (if not-matching
8200 ;; We need the numbers that are in all lists:
8201 (if (eq cc t)
8202 (if (eq to t)
8203 from
8204 (mapcar (lambda (a) (car (memq a from))) to))
8205 (if (eq to t)
8206 (mapcar (lambda (a) (car (memq a from))) cc)
8207 (mapcar (lambda (a) (car (memq a from)))
8208 (mapcar (lambda (a) (car (memq a to)))
8209 cc))))
8210 (nconc (if (eq to t) nil to)
8211 (if (eq cc t) nil cc)
8212 from))))
8213 (unless articles
8214 (error "Found no matches for \"%s\"" address))
8215 (gnus-summary-limit articles))
8216 (gnus-summary-position-point))))
8217
8218(defun gnus-summary-limit-strange-charsets-predicate (header)
765d4319
KY
8219 (when (fboundp 'char-charset)
8220 (let ((string (concat (mail-header-subject header)
8221 (mail-header-from header)))
8222 charset found)
8223 (dotimes (i (1- (length string)))
8224 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8225 (when (string-match "unicode\\|big\\|japanese" charset)
8226 (setq found t)))
8227 found)))
01c52d31
MB
8228
8229(defun gnus-summary-limit-to-predicate (predicate)
8230 "Limit to articles where PREDICATE returns non-nil.
8231PREDICATE will be called with the header structures of the
8232articles."
8233 (let ((articles nil)
8234 (case-fold-search t))
8235 (dolist (header gnus-newsgroup-headers)
8236 (when (funcall predicate header)
8237 (push (mail-header-number header) articles)))
8238 (gnus-summary-limit (nreverse articles))))
8239
eec82323
LMI
8240(defun gnus-summary-limit-to-age (age &optional younger-p)
8241 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8242If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8243articles that are younger than AGE days."
16409b0b
GM
8244 (interactive
8245 (let ((younger current-prefix-arg)
8246 (days-got nil)
8247 days)
8248 (while (not days-got)
8249 (setq days (if younger
23f87bed
MB
8250 (read-string "Limit to articles younger than (in days, older when negative): ")
8251 (read-string
8252 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
8253 (when (> (length days) 0)
8254 (setq days (read days)))
8255 (if (numberp days)
23f87bed
MB
8256 (progn
8257 (setq days-got t)
01c52d31
MB
8258 (when (< days 0)
8259 (setq younger (not younger))
8260 (setq days (* days -1))))
16409b0b
GM
8261 (message "Please enter a number.")
8262 (sleep-for 1)))
8263 (list days younger)))
eec82323
LMI
8264 (prog1
8265 (let ((data gnus-newsgroup-data)
16409b0b 8266 (cutoff (days-to-time age))
eec82323
LMI
8267 articles d date is-younger)
8268 (while (setq d (pop data))
8269 (when (and (vectorp (gnus-data-header d))
8270 (setq date (mail-header-date (gnus-data-header d))))
16409b0b 8271 (setq is-younger (time-less-p
3d6e7a43 8272 (time-since (gnus-date-get-time date))
eec82323 8273 cutoff))
6748645f
LMI
8274 (when (if younger-p
8275 is-younger
8276 (not is-younger))
eec82323
LMI
8277 (push (gnus-data-number d) articles))))
8278 (gnus-summary-limit (nreverse articles)))
8279 (gnus-summary-position-point)))
8280
47b63dfa 8281(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
8282 "Limit the summary buffer to articles that match an 'extra' header."
8283 (interactive
8284 (let ((header
8285 (intern
229b59da 8286 (gnus-completing-read
47b63dfa 8287 (if current-prefix-arg
81df110a
RF
8288 "Exclude extra header"
8289 "Limit extra header")
229b59da
G
8290 (mapcar 'symbol-name gnus-extra-headers)
8291 t nil nil
8292 (symbol-name (car gnus-extra-headers))))))
16409b0b 8293 (list header
a1506d29 8294 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
8295 (if current-prefix-arg "Exclude" "Limit to")
8296 header))
8297 current-prefix-arg)))
16409b0b
GM
8298 (when (not (equal "" regexp))
8299 (prog1
8300 (let ((articles (gnus-summary-find-matching
a1506d29 8301 (cons 'extra header) regexp 'all nil nil
47b63dfa 8302 not-matching)))
16409b0b
GM
8303 (unless articles
8304 (error "Found no matches for \"%s\"" regexp))
8305 (gnus-summary-limit articles))
8306 (gnus-summary-position-point))))
8307
23f87bed
MB
8308(defun gnus-summary-limit-to-display-predicate ()
8309 "Limit the summary buffer to the predicated in the `display' group parameter."
8310 (interactive)
8311 (unless gnus-newsgroup-display
8312 (error "There is no `display' group parameter"))
8313 (let (articles)
3a3cbf0a 8314 (dolist (gnus-number gnus-newsgroup-articles)
23f87bed 8315 (when (funcall gnus-newsgroup-display)
3a3cbf0a 8316 (push gnus-number articles)))
23f87bed
MB
8317 (gnus-summary-limit articles))
8318 (gnus-summary-position-point))
8319
eec82323
LMI
8320(defun gnus-summary-limit-to-unread (&optional all)
8321 "Limit the summary buffer to articles that are not marked as read.
8322If ALL is non-nil, limit strictly to unread articles."
8323 (interactive "P")
8324 (if all
8325 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8326 (gnus-summary-limit-to-marks
8327 ;; Concat all the marks that say that an article is read and have
8328 ;; those removed.
8329 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 8330 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
8331 gnus-low-score-mark gnus-expirable-mark
8332 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
c4d82de8 8333 gnus-duplicate-mark)
eec82323
LMI
8334 'reverse)))
8335
01c52d31
MB
8336(defun gnus-summary-limit-to-headers (match &optional reverse)
8337 "Limit the summary buffer to articles that have headers that match MATCH.
8338If REVERSE (the prefix), limit to articles that don't match."
8339 (interactive "sMatch headers (regexp): \nP")
8340 (gnus-summary-limit-to-bodies match reverse t))
8341
8342(defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8343 "Limit the summary buffer to articles that have bodies that match MATCH.
8344If REVERSE (the prefix), limit to articles that don't match."
8345 (interactive "sMatch body (regexp): \nP")
8346 (let ((articles nil)
8347 (gnus-select-article-hook nil) ;Disable hook.
8348 (gnus-article-prepare-hook nil)
8349 (gnus-use-article-prefetch nil)
8350 (gnus-keep-backlog nil)
8351 (gnus-break-pages nil)
8352 (gnus-summary-display-arrow nil)
8353 (gnus-updated-mode-lines nil)
8354 (gnus-auto-center-summary nil)
8355 (gnus-display-mime-function nil))
8356 (dolist (data gnus-newsgroup-data)
8357 (let (gnus-mark-article-hook)
8358 (gnus-summary-select-article t t nil (gnus-data-number data)))
398a825b 8359 (with-current-buffer gnus-article-buffer
01c52d31
MB
8360 (article-goto-body)
8361 (let* ((case-fold-search t)
8362 (found (if headersp
8363 (re-search-backward match nil t)
8364 (re-search-forward match nil t))))
8365 (when (or (and found
8366 (not reverse))
8367 (and (not found)
8368 reverse))
8369 (push (gnus-data-number data) articles)))))
8370 (if (not articles)
8371 (message "No messages matched")
8372 (gnus-summary-limit articles)))
8373 (gnus-summary-position-point))
8374
8375(defun gnus-summary-limit-to-singletons (&optional threadsp)
8376 "Limit the summary buffer to articles that aren't part on any thread.
8377If THREADSP (the prefix), limit to articles that are in threads."
8378 (interactive "P")
8379 (let ((articles nil)
8380 thread-articles
8381 threads)
8382 (dolist (thread gnus-newsgroup-threads)
8383 (if (stringp (car thread))
8384 (dolist (thread (cdr thread))
8385 (push thread threads))
8386 (push thread threads)))
8387 (dolist (thread threads)
8388 (setq thread-articles (gnus-articles-in-thread thread))
8389 (when (or (and threadsp
8390 (> (length thread-articles) 1))
8391 (and (not threadsp)
8392 (= (length thread-articles) 1)))
8393 (setq articles (nconc thread-articles articles))))
8394 (if (not articles)
8395 (message "No messages matched")
8396 (gnus-summary-limit articles))
8397 (gnus-summary-position-point)))
8398
8399(defun gnus-summary-limit-to-replied (&optional unreplied)
8400 "Limit the summary buffer to replied articles.
8401If UNREPLIED (the prefix), limit to unreplied articles."
8402 (interactive "P")
8403 (if unreplied
8404 (gnus-summary-limit
8405 (gnus-set-difference gnus-newsgroup-articles
8406 gnus-newsgroup-replied))
8407 (gnus-summary-limit gnus-newsgroup-replied))
8408 (gnus-summary-position-point))
8409
eec82323
LMI
8410(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8411 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8412If REVERSE, limit the summary buffer to articles that are marked
8413with MARKS. MARKS can either be a string of marks or a list of marks.
8414Returns how many articles were removed."
8415 (interactive "sMarks: ")
8416 (gnus-summary-limit-to-marks marks t))
8417
8418(defun gnus-summary-limit-to-marks (marks &optional reverse)
8419 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8420If REVERSE (the prefix), limit the summary buffer to articles that are
8421not marked with MARKS. MARKS can either be a string of marks or a
8422list of marks.
8423Returns how many articles were removed."
6748645f 8424 (interactive "sMarks: \nP")
eec82323
LMI
8425 (prog1
8426 (let ((data gnus-newsgroup-data)
8427 (marks (if (listp marks) marks
8428 (append marks nil))) ; Transform to list.
8429 articles)
8430 (while data
8431 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8432 (memq (gnus-data-mark (car data)) marks))
8433 (push (gnus-data-number (car data)) articles))
8434 (setq data (cdr data)))
8435 (gnus-summary-limit articles))
8436 (gnus-summary-position-point)))
8437
23f87bed 8438(defun gnus-summary-limit-to-score (score)
eec82323 8439 "Limit to articles with score at or above SCORE."
23f87bed 8440 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
8441 (let ((data gnus-newsgroup-data)
8442 articles)
8443 (while data
8444 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8445 score)
8446 (push (gnus-data-number (car data)) articles))
8447 (setq data (cdr data)))
8448 (prog1
8449 (gnus-summary-limit articles)
8450 (gnus-summary-position-point))))
8451
23f87bed
MB
8452(defun gnus-summary-limit-to-unseen ()
8453 "Limit to unseen articles."
8454 (interactive)
8455 (prog1
8456 (gnus-summary-limit gnus-newsgroup-unseen)
8457 (gnus-summary-position-point)))
8458
6748645f 8459(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
8460 "Display all the hidden articles that is in the thread with ID in it.
8461When called interactively, ID is the Message-ID of the current
8462article."
6748645f
LMI
8463 (interactive (list (mail-header-id (gnus-summary-article-header))))
8464 (let ((articles (gnus-articles-in-thread
181cb5fb
G
8465 (gnus-id-to-thread (gnus-root-id id))))
8466 ;;we REALLY want the whole thread---this prevents cut-threads
8467 ;;from removing the thread we want to include.
8468 (gnus-fetch-old-headers nil)
8469 (gnus-build-sparse-threads nil))
6748645f
LMI
8470 (prog1
8471 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
8472 (gnus-summary-limit-include-matching-articles
8473 "subject"
8474 (regexp-quote (gnus-simplify-subject-re
8475 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
8476 (gnus-summary-position-point))))
8477
23f87bed
MB
8478(defun gnus-summary-limit-include-matching-articles (header regexp)
8479 "Display all the hidden articles that have HEADERs that match REGEXP."
8480 (interactive (list (read-string "Match on header: ")
8481 (read-string "Regexp: ")))
8482 (let ((articles (gnus-find-matching-articles header regexp)))
8483 (prog1
8484 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8485 (gnus-summary-position-point))))
8486
8487(defun gnus-summary-insert-dormant-articles ()
8488 "Insert all the dormant articles for this group into the current buffer."
8489 (interactive)
8490 (let ((gnus-verbose (max 6 gnus-verbose)))
8491 (if (not gnus-newsgroup-dormant)
db629244 8492 (gnus-message 3 "No dormant articles for this group")
23f87bed
MB
8493 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8494
01c52d31
MB
8495(defun gnus-summary-insert-ticked-articles ()
8496 "Insert ticked articles for this group into the current buffer."
8497 (interactive)
8498 (let ((gnus-verbose (max 6 gnus-verbose)))
8499 (if (not gnus-newsgroup-marked)
8500 (gnus-message 3 "No ticked articles for this group")
8501 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8502
eec82323 8503(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
8504 "Display all the hidden articles that are marked as dormant.
8505Note that this command only works on a subset of the articles currently
8506fetched for this group."
eec82323 8507 (interactive)
eec82323
LMI
8508 (unless gnus-newsgroup-dormant
8509 (error "There are no dormant articles in this group"))
8510 (prog1
8511 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8512 (gnus-summary-position-point)))
8513
144b7b5c
G
8514(defun gnus-summary-include-articles (articles)
8515 "Fetch the headers for ARTICLES and then display the summary lines."
8516 (let ((gnus-inhibit-demon t)
8517 (gnus-agent nil)
8518 (gnus-read-all-available-headers t))
8519 (setq gnus-newsgroup-headers
8520 (gnus-merge
8521 'list gnus-newsgroup-headers
8522 (gnus-fetch-headers articles nil t)
8523 'gnus-article-sort-by-number))
8524 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8525
eec82323
LMI
8526(defun gnus-summary-limit-exclude-dormant ()
8527 "Hide all dormant articles."
8528 (interactive)
eec82323
LMI
8529 (prog1
8530 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8531 (gnus-summary-position-point)))
8532
8533(defun gnus-summary-limit-exclude-childless-dormant ()
8534 "Hide all dormant articles that have no children."
8535 (interactive)
eec82323
LMI
8536 (let ((data (gnus-data-list t))
8537 articles d children)
8538 ;; Find all articles that are either not dormant or have
8539 ;; children.
8540 (while (setq d (pop data))
8541 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8542 (and (setq children
8543 (gnus-article-children (gnus-data-number d)))
8544 (let (found)
8545 (while children
8546 (when (memq (car children) articles)
8547 (setq children nil
8548 found t))
8549 (pop children))
8550 found)))
8551 (push (gnus-data-number d) articles)))
8552 ;; Do the limiting.
8553 (prog1
8554 (gnus-summary-limit articles)
8555 (gnus-summary-position-point))))
8556
8557(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8558 "Mark all unread excluded articles as read.
8559If ALL, mark even excluded ticked and dormants as read."
8560 (interactive "P")
23f87bed
MB
8561 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8562 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8563 (sort
8564 (mapcar (lambda (h) (mail-header-number h))
8565 gnus-newsgroup-headers)
8566 '<)
23f87bed 8567 gnus-newsgroup-limit))
eec82323 8568 article)
6748645f 8569 (setq gnus-newsgroup-unreads
23f87bed
MB
8570 (gnus-sorted-intersection gnus-newsgroup-unreads
8571 gnus-newsgroup-limit))
eec82323
LMI
8572 (if all
8573 (setq gnus-newsgroup-dormant nil
8574 gnus-newsgroup-marked nil
8575 gnus-newsgroup-reads
8576 (nconc
8577 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8578 gnus-newsgroup-reads))
8579 (while (setq article (pop articles))
8580 (unless (or (memq article gnus-newsgroup-dormant)
8581 (memq article gnus-newsgroup-marked))
8582 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8583
8584(defun gnus-summary-limit (articles &optional pop)
8585 (if pop
8586 ;; We pop the previous limit off the stack and use that.
8587 (setq articles (car gnus-newsgroup-limits)
8588 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8589 ;; We use the new limit, so we push the old limit on the stack.
8590 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8591 ;; Set the limit.
8592 (setq gnus-newsgroup-limit articles)
8593 (let ((total (length gnus-newsgroup-data))
8594 (data (gnus-data-find-list (gnus-summary-article-number)))
8595 (gnus-summary-mark-below nil) ; Inhibit this.
8596 found)
8597 ;; This will do all the work of generating the new summary buffer
8598 ;; according to the new limit.
8599 (gnus-summary-prepare)
8600 ;; Hide any threads, possibly.
23f87bed 8601 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8602 ;; Try to return to the article you were at, or one in the
8603 ;; neighborhood.
8604 (when data
8605 ;; We try to find some article after the current one.
8606 (while data
8607 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8608 (setq data nil
8609 found t))
8610 (setq data (cdr data))))
8611 (unless found
8612 ;; If there is no data, that means that we were after the last
8613 ;; article. The same goes when we can't find any articles
8614 ;; after the current one.
8615 (goto-char (point-max))
8616 (gnus-summary-find-prev))
6748645f 8617 (gnus-set-mode-line 'summary)
eec82323
LMI
8618 ;; We return how many articles were removed from the summary
8619 ;; buffer as a result of the new limit.
8620 (- total (length gnus-newsgroup-data))))
8621
8622(defsubst gnus-invisible-cut-children (threads)
8623 (let ((num 0))
8624 (while threads
8625 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8626 (incf num))
8627 (pop threads))
8628 (< num 2)))
8629
8630(defsubst gnus-cut-thread (thread)
8631 "Go forwards in the thread until we find an article that we want to display."
8632 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8633 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8634 (numberp gnus-fetch-old-headers)
eec82323
LMI
8635 (eq gnus-build-sparse-threads 'some)
8636 (eq gnus-build-sparse-threads 'more))
8637 ;; Deal with old-fetched headers and sparse threads.
8638 (while (and
8639 thread
8640 (or
8641 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8642 (gnus-summary-article-ancient-p
8643 (mail-header-number (car thread))))
6748645f
LMI
8644 (if (or (<= (length (cdr thread)) 1)
8645 (eq gnus-fetch-old-headers 'invisible))
8646 (setq gnus-newsgroup-limit
8647 (delq (mail-header-number (car thread))
8648 gnus-newsgroup-limit)
8649 thread (cadr thread))
8650 (when (gnus-invisible-cut-children (cdr thread))
8651 (let ((th (cdr thread)))
8652 (while th
8653 (if (memq (mail-header-number (caar th))
a8151ef7 8654 gnus-newsgroup-limit)
6748645f
LMI
8655 (setq thread (car th)
8656 th nil)
8657 (setq th (cdr th))))))))))
eec82323
LMI
8658 thread)
8659
8660(defun gnus-cut-threads (threads)
23f87bed 8661 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8662 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8663 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8664 (numberp gnus-fetch-old-headers)
eec82323
LMI
8665 (eq gnus-build-sparse-threads 'some)
8666 (eq gnus-build-sparse-threads 'more))
8667 (let ((th threads))
8668 (while th
8669 (setcar th (gnus-cut-thread (car th)))
8670 (setq th (cdr th)))))
8671 ;; Remove nixed out threads.
8672 (delq nil threads))
8673
8674(defun gnus-summary-initial-limit (&optional show-if-empty)
8675 "Figure out what the initial limit is supposed to be on group entry.
8676This entails weeding out unwanted dormants, low-scored articles,
8677fetch-old-headers verbiage, and so on."
8678 ;; Most groups have nothing to remove.
f394fa25
MB
8679 (unless (or gnus-inhibit-limiting
8680 (and (null gnus-newsgroup-dormant)
8681 (eq gnus-newsgroup-display 'gnus-not-ignore)
8682 (not (eq gnus-fetch-old-headers 'some))
8683 (not (numberp gnus-fetch-old-headers))
8684 (not (eq gnus-fetch-old-headers 'invisible))
8685 (null gnus-summary-expunge-below)
8686 (not (eq gnus-build-sparse-threads 'some))
8687 (not (eq gnus-build-sparse-threads 'more))
8ccbef23 8688 (null gnus-thread-expunge-below)))
eec82323
LMI
8689 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8690 (setq gnus-newsgroup-limit nil)
8691 (mapatoms
8692 (lambda (node)
8693 (unless (car (symbol-value node))
8694 ;; These threads have no parents -- they are roots.
8695 (let ((nodes (cdr (symbol-value node)))
8696 thread)
8697 (while nodes
8698 (if (and gnus-thread-expunge-below
8699 (< (gnus-thread-total-score (car nodes))
8700 gnus-thread-expunge-below))
8701 (gnus-expunge-thread (pop nodes))
8702 (setq thread (pop nodes))
8703 (gnus-summary-limit-children thread))))))
8704 gnus-newsgroup-dependencies)
8705 ;; If this limitation resulted in an empty group, we might
8706 ;; pop the previous limit and use it instead.
8707 (when (and (not gnus-newsgroup-limit)
8708 show-if-empty)
8709 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8710 gnus-newsgroup-limit))
8711
8712(defun gnus-summary-limit-children (thread)
8713 "Return 1 if this subthread is visible and 0 if it is not."
8714 ;; First we get the number of visible children to this thread. This
8715 ;; is done by recursing down the thread using this function, so this
8716 ;; will really go down to a leaf article first, before slowly
8717 ;; working its way up towards the root.
8718 (when thread
04b61ae9 8719 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8720 (children
eec82323
LMI
8721 (if (cdr thread)
8722 (apply '+ (mapcar 'gnus-summary-limit-children
8723 (cdr thread)))
8724 0))
3d319c8f
LMI
8725 (number (mail-header-number (car thread)))
8726 score)
eec82323
LMI
8727 (if (and
8728 (not (memq number gnus-newsgroup-marked))
8729 (or
8730 ;; If this article is dormant and has absolutely no visible
8731 ;; children, then this article isn't visible.
8732 (and (memq number gnus-newsgroup-dormant)
8733 (zerop children))
8734 ;; If this is "fetch-old-headered" and there is no
8735 ;; visible children, then we don't want this article.
16409b0b
GM
8736 (and (or (eq gnus-fetch-old-headers 'some)
8737 (numberp gnus-fetch-old-headers))
eec82323
LMI
8738 (gnus-summary-article-ancient-p number)
8739 (zerop children))
6748645f
LMI
8740 ;; If this is "fetch-old-headered" and `invisible', then
8741 ;; we don't want this article.
8742 (and (eq gnus-fetch-old-headers 'invisible)
8743 (gnus-summary-article-ancient-p number))
eec82323
LMI
8744 ;; If this is a sparsely inserted article with no children,
8745 ;; we don't want it.
8746 (and (eq gnus-build-sparse-threads 'some)
8747 (gnus-summary-article-sparse-p number)
8748 (zerop children))
8749 ;; If we use expunging, and this article is really
8750 ;; low-scored, then we don't want this article.
8751 (when (and gnus-summary-expunge-below
8752 (< (setq score
8753 (or (cdr (assq number gnus-newsgroup-scored))
8754 gnus-summary-default-score))
8755 gnus-summary-expunge-below))
8756 ;; We increase the expunge-tally here, but that has
8757 ;; nothing to do with the limits, really.
8758 (incf gnus-newsgroup-expunged-tally)
8759 ;; We also mark as read here, if that's wanted.
8760 (when (and gnus-summary-mark-below
8761 (< score gnus-summary-mark-below))
8762 (setq gnus-newsgroup-unreads
8763 (delq number gnus-newsgroup-unreads))
8764 (if gnus-newsgroup-auto-expire
8765 (push number gnus-newsgroup-expirable)
8766 (push (cons number gnus-low-score-mark)
8767 gnus-newsgroup-reads)))
8768 t)
23f87bed
MB
8769 ;; Do the `display' group parameter.
8770 (and gnus-newsgroup-display
3d319c8f
LMI
8771 (let ((gnus-number number))
8772 (not (funcall gnus-newsgroup-display))))))
eec82323
LMI
8773 ;; Nope, invisible article.
8774 0
8775 ;; Ok, this article is to be visible, so we add it to the limit
8776 ;; and return 1.
8777 (push number gnus-newsgroup-limit)
8778 1))))
8779
8780(defun gnus-expunge-thread (thread)
8781 "Mark all articles in THREAD as read."
8782 (let* ((number (mail-header-number (car thread))))
8783 (incf gnus-newsgroup-expunged-tally)
8784 ;; We also mark as read here, if that's wanted.
8785 (setq gnus-newsgroup-unreads
8786 (delq number gnus-newsgroup-unreads))
8787 (if gnus-newsgroup-auto-expire
8788 (push number gnus-newsgroup-expirable)
8789 (push (cons number gnus-low-score-mark)
8790 gnus-newsgroup-reads)))
8791 ;; Go recursively through all subthreads.
8792 (mapcar 'gnus-expunge-thread (cdr thread)))
8793
8794;; Summary article oriented commands
8795
8796(defun gnus-summary-refer-parent-article (n)
8797 "Refer parent article N times.
8798If N is negative, go to ancestor -N instead.
8799The difference between N and the number of articles fetched is returned."
8800 (interactive "p")
eec82323
LMI
8801 (let ((skip 1)
8802 error header ref)
8803 (when (not (natnump n))
8804 (setq skip (abs n)
8805 n 1))
8806 (while (and (> n 0)
8807 (not error))
8808 (setq header (gnus-summary-article-header))
8809 (if (and (eq (mail-header-number header)
8810 (cdr gnus-article-current))
8811 (equal gnus-newsgroup-name
8812 (car gnus-article-current)))
8813 ;; If we try to find the parent of the currently
8814 ;; displayed article, then we take a look at the actual
8815 ;; References header, since this is slightly more
8816 ;; reliable than the References field we got from the
8817 ;; server.
c7a91ce1 8818 (with-current-buffer gnus-original-article-buffer
eec82323
LMI
8819 (nnheader-narrow-to-headers)
8820 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8821 (when (setq ref (message-fetch-field "in-reply-to"))
8822 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8823 (widen))
8824 (setq ref
8825 ;; It's not the current article, so we take a bet on
8826 ;; the value we got from the server.
8827 (mail-header-references header)))
8828 (if (and ref
8829 (not (equal ref "")))
8830 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8831 (gnus-message 1 "Couldn't find parent"))
8832 (gnus-message 1 "No references in article %d"
8833 (gnus-summary-article-number))
8834 (setq error t))
8835 (decf n))
8836 (gnus-summary-position-point)
8837 n))
8838
8839(defun gnus-summary-refer-references ()
8840 "Fetch all articles mentioned in the References header.
6748645f 8841Return the number of articles fetched."
eec82323 8842 (interactive)
eec82323
LMI
8843 (let ((ref (mail-header-references (gnus-summary-article-header)))
8844 (current (gnus-summary-article-number))
8845 (n 0))
8846 (if (or (not ref)
8847 (equal ref ""))
8848 (error "No References in the current article")
8849 ;; For each Message-ID in the References header...
8850 (while (string-match "<[^>]*>" ref)
8851 (incf n)
8852 ;; ... fetch that article.
8853 (gnus-summary-refer-article
8854 (prog1 (match-string 0 ref)
8855 (setq ref (substring ref (match-end 0))))))
8856 (gnus-summary-goto-subject current)
8857 (gnus-summary-position-point)
8858 n)))
8859
6748645f
LMI
8860(defun gnus-summary-refer-thread (&optional limit)
8861 "Fetch all articles in the current thread.
030158f3
G
8862If no backend-specific 'request-thread function is available
8863fetch LIMIT (the numerical prefix) old headers. If LIMIT is nil
8864fetch what's specified by the `gnus-refer-thread-limit'
8865variable."
6748645f 8866 (interactive "P")
4ddab346 8867 (gnus-warp-to-article)
70041e9a
G
8868 (let* ((header (gnus-summary-article-header))
8869 (id (mail-header-id header))
8870 (gnus-inhibit-demon t)
8871 (gnus-summary-ignore-duplicates t)
8872 (gnus-read-all-available-headers t)
8873 (limit (if limit (prefix-numeric-value limit)
8874 gnus-refer-thread-limit)))
4ddab346
G
8875 (setq gnus-newsgroup-headers
8876 (gnus-merge
8877 'list gnus-newsgroup-headers
8878 (if (gnus-check-backend-function
8879 'request-thread gnus-newsgroup-name)
70041e9a 8880 (gnus-request-thread header)
4ddab346 8881 (let* ((last (if (numberp limit)
70041e9a 8882 (min (+ (mail-header-number header)
4ddab346
G
8883 limit)
8884 gnus-newsgroup-highest)
8885 gnus-newsgroup-highest))
8886 (subject (gnus-simplify-subject
70041e9a
G
8887 (mail-header-subject header)))
8888 (refs (split-string (or (mail-header-references header)
4ddab346
G
8889 "")))
8890 (gnus-parse-headers-hook
8891 (lambda () (goto-char (point-min))
8892 (keep-lines
8893 (regexp-opt (append refs (list id subject)))))))
8894 (gnus-fetch-headers (list last) (if (numberp limit)
8895 (* 2 limit) limit) t)))
8896 'gnus-article-sort-by-number))
6748645f
LMI
8897 (gnus-summary-limit-include-thread id)))
8898
16409b0b
GM
8899(defun gnus-summary-refer-article (message-id)
8900 "Fetch an article specified by MESSAGE-ID."
8901 (interactive "sMessage-ID: ")
eec82323
LMI
8902 (when (and (stringp message-id)
8903 (not (zerop (length message-id))))
23f87bed 8904 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8905 ;; Construct the correct Message-ID if necessary.
8906 ;; Suggested by tale@pawl.rpi.edu.
8907 (unless (string-match "^<" message-id)
8908 (setq message-id (concat "<" message-id)))
8909 (unless (string-match ">$" message-id)
8910 (setq message-id (concat message-id ">")))
23f87bed
MB
8911 ;; People often post MIDs from URLs, so unhex it:
8912 (unless (string-match "@" message-id)
8913 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8914 (let* ((header (gnus-id-to-header message-id))
8915 (sparse (and header
8916 (gnus-summary-article-sparse-p
a8151ef7
LMI
8917 (mail-header-number header))
8918 (memq (mail-header-number header)
16409b0b
GM
8919 gnus-newsgroup-limit)))
8920 number)
6748645f
LMI
8921 (cond
8922 ;; If the article is present in the buffer we just go to it.
8923 ((and header
8924 (or (not (gnus-summary-article-sparse-p
8925 (mail-header-number header)))
8926 sparse))
8927 (prog1
8928 (gnus-summary-goto-article
8929 (mail-header-number header) nil t)
8930 (when sparse
8931 (gnus-summary-update-article (mail-header-number header)))))
8932 (t
16409b0b
GM
8933 ;; We fetch the article.
8934 (catch 'found
8935 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8936 (when (and (gnus-check-server gnus-override-method)
8937 ;; Fetch the header,
8938 (setq number (gnus-summary-insert-subject message-id)))
8939 ;; and display the article.
eec82323 8940 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8941 (throw 'found t)))
8942 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8943
8944(defun gnus-refer-article-methods ()
8f688cb0 8945 "Return a list of referable methods."
16409b0b
GM
8946 (cond
8947 ;; No method, so we default to current and native.
8948 ((null gnus-refer-article-method)
8949 (list gnus-current-select-method gnus-select-method))
8950 ;; Current.
8951 ((eq 'current gnus-refer-article-method)
8952 (list gnus-current-select-method))
8953 ;; List of select methods.
d4dfaa19
DL
8954 ((not (and (symbolp (car gnus-refer-article-method))
8955 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
8956 (let (out)
8957 (dolist (method gnus-refer-article-method)
8958 (push (if (eq 'current method)
8959 gnus-current-select-method
8960 method)
8961 out))
8962 (nreverse out)))
8963 ;; One single select method.
8964 (t
8965 (list gnus-refer-article-method))))
6748645f
LMI
8966
8967(defun gnus-summary-edit-parameters ()
8968 "Edit the group parameters of the current group."
8969 (interactive)
8970 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 8971
16409b0b
GM
8972(defun gnus-summary-customize-parameters ()
8973 "Customize the group parameters of the current group."
8974 (interactive)
8975 (gnus-group-customize gnus-newsgroup-name))
8976
eec82323
LMI
8977(defun gnus-summary-enter-digest-group (&optional force)
8978 "Enter an nndoc group based on the current article.
07176b2a
LMI
8979If FORCE, force a digest interpretation. If not, try to guess
8980what the document format is.
8981
8982To control what happens when you exit the group, see the
8983`gnus-auto-select-on-ephemeral-exit' variable."
eec82323 8984 (interactive "P")
eec82323 8985 (let ((conf gnus-current-window-configuration))
23f87bed
MB
8986 (save-window-excursion
8987 (save-excursion
8988 (let (gnus-article-prepare-hook
8989 gnus-display-mime-function
8990 gnus-break-pages)
8991 (gnus-summary-select-article))))
eec82323
LMI
8992 (setq gnus-current-window-configuration conf)
8993 (let* ((name (format "%s-%d"
8994 (gnus-group-prefixed-name
8995 gnus-newsgroup-name (list 'nndoc ""))
01c52d31 8996 (with-current-buffer gnus-summary-buffer
eec82323
LMI
8997 gnus-current-article)))
8998 (ogroup gnus-newsgroup-name)
8999 (params (append (gnus-info-params (gnus-get-info ogroup))
9000 (list (cons 'to-group ogroup))
23f87bed 9001 (list (cons 'parent-group ogroup))
eec82323
LMI
9002 (list (cons 'save-article-group ogroup))))
9003 (case-fold-search t)
9004 (buf (current-buffer))
16409b0b 9005 dig to-address)
c7a91ce1 9006 (with-current-buffer gnus-original-article-buffer
16409b0b
GM
9007 ;; Have the digest group inherit the main mail address of
9008 ;; the parent article.
23f87bed
MB
9009 (when (setq to-address (or (gnus-fetch-field "reply-to")
9010 (gnus-fetch-field "from")))
343d6628
MB
9011 (setq params
9012 (append
9013 (list (cons 'to-address
9014 (funcall gnus-decode-encoded-address-function
9015 to-address))))))
eec82323
LMI
9016 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9017 (insert-buffer-substring gnus-original-article-buffer)
9018 ;; Remove lines that may lead nndoc to misinterpret the
9019 ;; document type.
9020 (narrow-to-region
9021 (goto-char (point-min))
9022 (or (search-forward "\n\n" nil t) (point)))
9023 (goto-char (point-min))
16409b0b 9024 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
9025 (widen))
9026 (unwind-protect
23f87bed 9027 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
9028 (gnus-newsgroup-ephemeral-ignored-charsets
9029 gnus-newsgroup-ignored-charsets))
9030 (gnus-group-read-ephemeral-group
9031 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9032 (nndoc-article-type
23f87bed
MB
9033 ,(if force 'mbox 'guess)))
9034 t nil nil nil
9035 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9036 "ADAPT")))))
16409b0b 9037 ;; Make all postings to this group go to the parent group.
23f87bed
MB
9038 (nconc (gnus-info-params (gnus-get-info name))
9039 params)
9040 ;; Couldn't select this doc group.
9041 (switch-to-buffer buf)
9042 (gnus-set-global-variables)
9043 (gnus-configure-windows 'summary)
9044 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
9045 (kill-buffer dig)))))
9046
9047(defun gnus-summary-read-document (n)
9048 "Open a new group based on the current article(s).
9049This will allow you to read digests and other similar
9050documents as newsgroups.
9051Obeys the standard process/prefix convention."
9052 (interactive "P")
01c52d31 9053 (let* ((ogroup gnus-newsgroup-name)
eec82323
LMI
9054 (params (append (gnus-info-params (gnus-get-info ogroup))
9055 (list (cons 'to-group ogroup))))
01c52d31
MB
9056 group egroup groups vgroup)
9057 (dolist (article (gnus-summary-work-articles n))
eec82323
LMI
9058 (setq group (format "%s-%d" gnus-newsgroup-name article))
9059 (gnus-summary-remove-process-mark article)
9060 (when (gnus-summary-display-article article)
398a825b 9061 (save-excursion ;;What for?
16409b0b 9062 (with-temp-buffer
eec82323
LMI
9063 (insert-buffer-substring gnus-original-article-buffer)
9064 ;; Remove some headers that may lead nndoc to make
9065 ;; the wrong guess.
9066 (message-narrow-to-head)
9067 (goto-char (point-min))
01c52d31 9068 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
9069 (widen)
9070 (if (setq egroup
9071 (gnus-group-read-ephemeral-group
9072 group `(nndoc ,group (nndoc-address ,(current-buffer))
9073 (nndoc-article-type guess))
9074 t nil t))
9075 (progn
c7a91ce1 9076 ;; Make all postings to this group go to the parent group.
eec82323
LMI
9077 (nconc (gnus-info-params (gnus-get-info egroup))
9078 params)
9079 (push egroup groups))
9080 ;; Couldn't select this doc group.
9081 (gnus-error 3 "Article couldn't be entered"))))))
9082 ;; Now we have selected all the documents.
9083 (cond
9084 ((not groups)
9085 (error "None of the articles could be interpreted as documents"))
9086 ((gnus-group-read-ephemeral-group
9087 (setq vgroup (format
9088 "nnvirtual:%s-%s" gnus-newsgroup-name
9089 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9090 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9091 t
9092 (cons (current-buffer) 'summary)))
9093 (t
9094 (error "Couldn't select virtual nndoc group")))))
9095
d50717f0
JD
9096(defun gnus-summary-widget-forward (arg)
9097 "Move point to the next field or button in the article.
9098With optional ARG, move across that many fields."
9099 (interactive "p")
9100 (gnus-summary-select-article)
9101 (gnus-configure-windows 'article)
9102 (select-window (gnus-get-buffer-window gnus-article-buffer))
9103 (widget-forward arg))
9104
eec82323
LMI
9105(defun gnus-summary-isearch-article (&optional regexp-p)
9106 "Do incremental search forward on the current article.
9107If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9108 (interactive "P")
eec82323
LMI
9109 (gnus-summary-select-article)
9110 (gnus-configure-windows 'article)
9111 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
9112 (save-restriction
9113 (widen)
9114 (isearch-forward regexp-p))))
eec82323 9115
01c52d31
MB
9116(defun gnus-summary-repeat-search-article-forward ()
9117 "Repeat the previous search forwards."
9118 (interactive)
9119 (unless gnus-last-search-regexp
9120 (error "No previous search"))
9121 (gnus-summary-search-article-forward gnus-last-search-regexp))
9122
9123(defun gnus-summary-repeat-search-article-backward ()
9124 "Repeat the previous search backwards."
9125 (interactive)
9126 (unless gnus-last-search-regexp
9127 (error "No previous search"))
9128 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9129
eec82323
LMI
9130(defun gnus-summary-search-article-forward (regexp &optional backward)
9131 "Search for an article containing REGEXP forward.
9132If BACKWARD, search backward instead."
9133 (interactive
9134 (list (read-string
9135 (format "Search article %s (regexp%s): "
9136 (if current-prefix-arg "backward" "forward")
9137 (if gnus-last-search-regexp
9138 (concat ", default " gnus-last-search-regexp)
9139 "")))
9140 current-prefix-arg))
eec82323
LMI
9141 (if (string-equal regexp "")
9142 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
9143 (setq gnus-last-search-regexp regexp)
9144 (setq gnus-article-before-search gnus-current-article))
9145 ;; Intentionally set gnus-last-article.
9146 (setq gnus-last-article gnus-article-before-search)
9147 (let ((gnus-last-article gnus-last-article))
9148 (if (gnus-summary-search-article regexp backward)
9149 (gnus-summary-show-thread)
abc40aab 9150 (signal 'search-failed (list regexp)))))
eec82323
LMI
9151
9152(defun gnus-summary-search-article-backward (regexp)
9153 "Search for an article containing REGEXP backward."
9154 (interactive
9155 (list (read-string
9156 (format "Search article backward (regexp%s): "
9157 (if gnus-last-search-regexp
9158 (concat ", default " gnus-last-search-regexp)
9159 "")))))
9160 (gnus-summary-search-article-forward regexp 'backward))
9161
9162(defun gnus-summary-search-article (regexp &optional backward)
9163 "Search for an article containing REGEXP.
9164Optional argument BACKWARD means do search for backward.
9165`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
9166 ;; We have to require this here to make sure that the following
9167 ;; dynamic binding isn't shadowed by autoloading.
9168 (require 'gnus-async)
16409b0b 9169 (require 'gnus-art)
eec82323 9170 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 9171 (gnus-article-prepare-hook nil)
eec82323
LMI
9172 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9173 (gnus-use-article-prefetch nil)
9174 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 9175 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
9176 (gnus-visual nil)
9177 (gnus-keep-backlog nil)
9178 (gnus-break-pages nil)
9179 (gnus-summary-display-arrow nil)
9180 (gnus-updated-mode-lines nil)
9181 (gnus-auto-center-summary nil)
eec82323 9182 (sum (current-buffer))
16409b0b 9183 (gnus-display-mime-function nil)
eec82323
LMI
9184 (found nil)
9185 point)
9186 (gnus-save-hidden-threads
9187 (gnus-summary-select-article)
9188 (set-buffer gnus-article-buffer)
16409b0b 9189 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
9190 (when backward
9191 (forward-line -1))
9192 (while (not found)
9193 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9194 (if (if backward
9195 (re-search-backward regexp nil t)
9196 (re-search-forward regexp nil t))
9197 ;; We found the regexp.
9198 (progn
9199 (setq found 'found)
9200 (beginning-of-line)
9201 (set-window-start
9202 (get-buffer-window (current-buffer))
9203 (point))
9204 (forward-line 1)
16409b0b
GM
9205 (set-window-point
9206 (get-buffer-window (current-buffer))
9207 (point))
eec82323
LMI
9208 (set-buffer sum)
9209 (setq point (point)))
9210 ;; We didn't find it, so we go to the next article.
9211 (set-buffer sum)
9212 (setq found 'not)
9213 (while (eq found 'not)
9214 (if (not (if backward (gnus-summary-find-prev)
9215 (gnus-summary-find-next)))
9216 ;; No more articles.
9217 (setq found t)
9218 ;; Select the next article and adjust point.
9219 (unless (gnus-summary-article-sparse-p
9220 (gnus-summary-article-number))
9221 (setq found nil)
9222 (gnus-summary-select-article)
9223 (set-buffer gnus-article-buffer)
9224 (widen)
9225 (goto-char (if backward (point-max) (point-min))))))))
9226 (gnus-message 7 ""))
9227 ;; Return whether we found the regexp.
9228 (when (eq found 'found)
9229 (goto-char point)
9230 (gnus-summary-show-thread)
9231 (gnus-summary-goto-subject gnus-current-article)
9232 (gnus-summary-position-point)
9233 t)))
9234
23f87bed
MB
9235(defun gnus-find-matching-articles (header regexp)
9236 "Return a list of all articles that match REGEXP on HEADER.
9237This search includes all articles in the current group that Gnus has
9238fetched headers for, whether they are displayed or not."
9239 (let ((articles nil)
c7a91ce1 9240 ;; Can't eta-reduce because it's a macro.
23f87bed
MB
9241 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9242 (case-fold-search t))
9243 (dolist (header gnus-newsgroup-headers)
9244 (when (string-match regexp (funcall func header))
9245 (push (mail-header-number header) articles)))
9246 (nreverse articles)))
9247
eec82323 9248(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 9249 not-case-fold not-matching)
eec82323
LMI
9250 "Return a list of all articles that match REGEXP on HEADER.
9251The search stars on the current article and goes forwards unless
9252BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9253If UNREAD is non-nil, only unread articles will
9254be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 9255in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
9256not match REGEXP on HEADER."
9257 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
9258 articles d func)
9259 (if (consp header)
9260 (if (eq (car header) 'extra)
9261 (setq func
9262 `(lambda (h)
9263 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9264 "")))
9265 (error "%s is an invalid header" header))
9266 (unless (fboundp (intern (concat "mail-header-" header)))
9267 (error "%s is not a valid header" header))
9268 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
9269 (dolist (d (if (eq backward 'all)
9270 gnus-newsgroup-data
9271 (gnus-data-find-list
9272 (gnus-summary-article-number)
9273 (gnus-data-list backward))))
9274 (when (and (or (not unread) ; We want all articles...
9275 (gnus-data-unread-p d)) ; Or just unreads.
9276 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9277 (if not-matching
a1506d29 9278 (not (string-match
47b63dfa
SZ
9279 regexp
9280 (funcall func (gnus-data-header d))))
9281 (string-match regexp
9282 (funcall func (gnus-data-header d)))))
9283 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
9284 (nreverse articles)))
9285
9286(defun gnus-summary-execute-command (header regexp command &optional backward)
9287 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9288If HEADER is an empty string (or nil), the match is done on the entire
9289article. If BACKWARD (the prefix) is non-nil, search backward instead."
9290 (interactive
9291 (list (let ((completion-ignore-case t))
229b59da
G
9292 (gnus-completing-read
9293 "Header name"
9294 (mapcar 'symbol-name
23f87bed 9295 (append
229b59da
G
9296 '(Number Subject From Lines Date
9297 Message-ID Xref References Body)
23f87bed 9298 gnus-extra-headers))
229b59da 9299 'require-match))
eec82323
LMI
9300 (read-string "Regexp: ")
9301 (read-key-sequence "Command: ")
9302 current-prefix-arg))
9303 (when (equal header "Body")
9304 (setq header ""))
eec82323
LMI
9305 ;; Hidden thread subtrees must be searched as well.
9306 (gnus-summary-show-all-threads)
9307 ;; We don't want to change current point nor window configuration.
9308 (save-excursion
9309 (save-window-excursion
23f87bed
MB
9310 (let (gnus-visual
9311 gnus-treat-strip-trailing-blank-lines
9312 gnus-treat-strip-leading-blank-lines
9313 gnus-treat-strip-multiple-blank-lines
9314 gnus-treat-hide-boring-headers
9315 gnus-treat-fold-newsgroups
9316 gnus-article-prepare-hook)
9317 (gnus-message 6 "Executing %s..." (key-description command))
9318 ;; We'd like to execute COMMAND interactively so as to give arguments.
9319 (gnus-execute header regexp
9320 `(call-interactively ',(key-binding command))
9321 backward)
9322 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
9323
9324(defun gnus-summary-beginning-of-article ()
9325 "Scroll the article back to the beginning."
9326 (interactive)
eec82323
LMI
9327 (gnus-summary-select-article)
9328 (gnus-configure-windows 'article)
9329 (gnus-eval-in-buffer-window gnus-article-buffer
9330 (widen)
9331 (goto-char (point-min))
23f87bed 9332 (when gnus-break-pages
eec82323
LMI
9333 (gnus-narrow-to-page))))
9334
9335(defun gnus-summary-end-of-article ()
9336 "Scroll to the end of the article."
9337 (interactive)
eec82323
LMI
9338 (gnus-summary-select-article)
9339 (gnus-configure-windows 'article)
9340 (gnus-eval-in-buffer-window gnus-article-buffer
9341 (widen)
9342 (goto-char (point-max))
9343 (recenter -3)
23f87bed 9344 (when gnus-break-pages
eec82323
LMI
9345 (gnus-narrow-to-page))))
9346
23f87bed
MB
9347(defun gnus-summary-print-truncate-and-quote (string &optional len)
9348 "Truncate to LEN and quote all \"(\"'s in STRING."
9349 (gnus-replace-in-string (if (and len (> (length string) len))
9350 (substring string 0 len)
9351 string)
9352 "[()]" "\\\\\\&"))
9353
6748645f 9354(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
9355 "Generate and print a PostScript image of the process-marked (mail) articles.
9356
9357If used interactively, print the current article if none are
9358process-marked. With prefix arg, prompt the user for the name of the
9359file to save in.
6748645f 9360
23f87bed
MB
9361When used from Lisp, accept two optional args FILENAME and N. N means
9362to print the next N articles. If N is negative, print the N previous
9363articles. If N is nil and articles have been marked with the process
9364mark, print these instead.
eec82323 9365
16409b0b 9366If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
9367printer. If FILENAME is a string, save the PostScript image in a file with
9368that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 9369to save in."
676a7cc9 9370 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
9371 (dolist (article (gnus-summary-work-articles n))
9372 (gnus-summary-select-article nil nil 'pseudo article)
9373 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 9374 (gnus-print-buffer))
676a7cc9
SZ
9375 (gnus-summary-remove-process-mark article))
9376 (ps-despool filename))
eec82323 9377
23f87bed 9378(defun gnus-print-buffer ()
285cf7c8
LMI
9379 (let ((ps-left-header
9380 (list
9381 (concat "("
9382 (gnus-summary-print-truncate-and-quote
9383 (mail-header-subject gnus-current-headers)
9384 66) ")")
9385 (concat "("
9386 (gnus-summary-print-truncate-and-quote
9387 (mail-header-from gnus-current-headers)
9388 45) ")")))
9389 (ps-right-header
9390 (list
9391 "/pagenumberstring load"
9392 (concat "("
9393 (mail-header-date gnus-current-headers) ")"))))
9394 (gnus-run-hooks 'gnus-ps-print-hook)
9395 (save-excursion
9396 (if ps-print-color-p
9397 (ps-spool-buffer-with-faces)
9398 (ps-spool-buffer)))))
23f87bed 9399
8ccbef23
G
9400(defun gnus-summary-show-complete-article ()
9401 "Show a complete version of the current article.
9402This is only useful if you're looking at a partial version of the
9403article currently."
9404 (interactive)
9405 (let ((gnus-keep-backlog nil)
9406 (gnus-use-cache nil)
9407 (gnus-agent nil)
9f2d52e7
G
9408 (variable (intern
9409 (format "%s-fetch-partial-articles"
9410 (car (gnus-find-method-for-group
9411 gnus-newsgroup-name)))
9412 obarray))
9413 old-val)
9414 (unwind-protect
9415 (progn
9416 (setq old-val (symbol-value variable))
9417 (set variable nil)
9418 (gnus-flush-original-article-buffer)
9419 (gnus-summary-show-article))
9420 (set variable old-val))))
8ccbef23 9421
eec82323 9422(defun gnus-summary-show-article (&optional arg)
23f87bed 9423 "Force redisplaying of the current article.
16409b0b
GM
9424If ARG (the prefix) is a number, show the article with the charset
9425defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 9426input.
389b76fa
G
9427If ARG (the prefix) is non-nil and not a number, show the article,
9428but without running any of the article treatment functions
9429article. Normally, the keystroke is `C-u g'. When using `C-u
9430C-u g', show the raw article."
eec82323 9431 (interactive "P")
16409b0b
GM
9432 (cond
9433 ((numberp arg)
23f87bed 9434 (gnus-summary-show-article t)
16409b0b
GM
9435 (let ((gnus-newsgroup-charset
9436 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
9437 (mm-read-coding-system
9438 "View as charset: " ;; actually it is coding system.
01c52d31 9439 (with-current-buffer gnus-article-buffer
23f87bed 9440 (mm-detect-coding-region (point) (point-max))))))
16409b0b 9441 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
9442 (gnus-summary-select-article nil 'force)
9443 (let ((deps gnus-newsgroup-dependencies)
9444 head header lines)
c7a91ce1 9445 (with-current-buffer gnus-original-article-buffer
23f87bed
MB
9446 (save-restriction
9447 (message-narrow-to-head)
9448 (setq head (buffer-string))
9449 (goto-char (point-min))
9450 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9451 (goto-char (point-max))
9452 (widen)
9453 (setq lines (1- (count-lines (point) (point-max))))))
9454 (with-temp-buffer
9455 (insert (format "211 %d Article retrieved.\n"
9456 (cdr gnus-article-current)))
9457 (insert head)
9458 (if lines (insert (format "Lines: %d\n" lines)))
9459 (insert ".\n")
9460 (let ((nntp-server-buffer (current-buffer)))
9461 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9462 (gnus-data-set-header
9463 (gnus-data-find (cdr gnus-article-current))
9464 header)
9465 (gnus-summary-update-article-line
9466 (cdr gnus-article-current) header)
9467 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9468 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
9469 ((not arg)
9470 ;; Select the article the normal way.
9471 (gnus-summary-select-article nil 'force))
181cb5fb
G
9472 ((or (equal arg '(16))
9473 (eq arg t))
389b76fa 9474 ;; C-u C-u g
04db63bc
G
9475 (let ((gnus-inhibit-article-treatments t))
9476 (gnus-summary-select-article nil 'force)))
9477 (t
16409b0b
GM
9478 ;; We have to require this here to make sure that the following
9479 ;; dynamic binding isn't shadowed by autoloading.
9480 (require 'gnus-async)
9481 (require 'gnus-art)
eec82323
LMI
9482 ;; Bind the article treatment functions to nil.
9483 (let ((gnus-have-all-headers t)
eec82323 9484 gnus-article-prepare-hook
16409b0b
GM
9485 gnus-article-decode-hook
9486 gnus-display-mime-function
9487 gnus-break-pages)
9488 ;; Destroy any MIME parts.
9489 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 9490 (with-current-buffer gnus-article-buffer
16409b0b
GM
9491 (mm-destroy-parts gnus-article-mime-handles)
9492 ;; Set it to nil for safety reason.
9493 (setq gnus-article-mime-handle-alist nil)
9494 (setq gnus-article-mime-handles nil)))
9495 (gnus-summary-select-article nil 'force))))
eec82323
LMI
9496 (gnus-summary-goto-subject gnus-current-article)
9497 (gnus-summary-position-point))
9498
23f87bed
MB
9499(defun gnus-summary-show-raw-article ()
9500 "Show the raw article without any article massaging functions being run."
9501 (interactive)
9502 (gnus-summary-show-article t))
9503
eec82323
LMI
9504(defun gnus-summary-verbose-headers (&optional arg)
9505 "Toggle permanent full header display.
9506If ARG is a positive number, turn header display on.
9507If ARG is a negative number, turn header display off."
9508 (interactive "P")
eec82323
LMI
9509 (setq gnus-show-all-headers
9510 (cond ((or (not (numberp arg))
9511 (zerop arg))
9512 (not gnus-show-all-headers))
9513 ((natnump arg)
9514 t)))
9515 (gnus-summary-show-article))
9516
9517(defun gnus-summary-toggle-header (&optional arg)
9518 "Show the headers if they are hidden, or hide them if they are shown.
9519If ARG is a positive number, show the entire header.
9520If ARG is a negative number, hide the unwanted header lines."
9521 (interactive "P")
23f87bed
MB
9522 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9523 (get-buffer-window gnus-article-buffer t))))
9524 (with-current-buffer gnus-article-buffer
9525 (widen)
9526 (article-narrow-to-head)
c7a91ce1 9527 (let* ((inhibit-read-only t)
16409b0b 9528 (inhibit-point-motion-hooks t)
23f87bed
MB
9529 (hidden (if (numberp arg)
9530 (>= arg 0)
f0096211
MB
9531 (or (not (looking-at "[^ \t\n]+:"))
9532 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
9533 s e)
9534 (delete-region (point-min) (point-max))
667e0ba6
SM
9535 (with-current-buffer gnus-original-article-buffer
9536 (goto-char (setq s (point-min)))
23f87bed
MB
9537 (setq e (if (search-forward "\n\n" nil t)
9538 (1- (point))
9539 (point-max))))
667e0ba6 9540 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
9541 (run-hooks 'gnus-article-decode-hook)
9542 (if hidden
9543 (let ((gnus-treat-hide-headers nil)
9544 (gnus-treat-hide-boring-headers nil))
9545 (gnus-delete-wash-type 'headers)
9546 (gnus-treat-article 'head))
9547 (gnus-treat-article 'head))
9548 (widen)
9549 (if window
9550 (set-window-start window (goto-char (point-min))))
9551 (if gnus-break-pages
9552 (gnus-narrow-to-page)
9553 (when (gnus-visual-p 'page-marker)
c7a91ce1 9554 (let ((inhibit-read-only t))
23f87bed
MB
9555 (gnus-remove-text-with-property 'gnus-prev)
9556 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9557 (gnus-set-mode-line 'article)))))
eec82323
LMI
9558
9559(defun gnus-summary-show-all-headers ()
9560 "Make all header lines visible."
9561 (interactive)
23f87bed 9562 (gnus-summary-toggle-header 1))
eec82323 9563
eec82323
LMI
9564(defun gnus-summary-caesar-message (&optional arg)
9565 "Caesar rotate the current article by 13.
01c52d31
MB
9566With a non-numerical prefix, also rotate headers. A numerical
9567prefix specifies how many places to rotate each letter forward."
eec82323 9568 (interactive "P")
eec82323
LMI
9569 (gnus-summary-select-article)
9570 (let ((mail-header-separator ""))
9571 (gnus-eval-in-buffer-window gnus-article-buffer
9572 (save-restriction
9573 (widen)
9574 (let ((start (window-start))
c7a91ce1 9575 (inhibit-read-only t))
01c52d31
MB
9576 (if (equal arg '(4))
9577 (message-caesar-buffer-body nil t)
9578 (message-caesar-buffer-body arg))
ff4d3926
MB
9579 (set-window-start (get-buffer-window (current-buffer)) start)))))
9580 ;; Create buttons and stuff...
9581 (gnus-treat-article nil))
eec82323 9582
704f1663
GM
9583(declare-function idna-to-unicode "ext:idna" (str))
9584
01c52d31
MB
9585(defun gnus-summary-idna-message (&optional arg)
9586 "Decode IDNA encoded domain names in the current articles.
9587IDNA encoded domain names looks like `xn--bar'. If a string
9588remain unencoded after running this function, it is likely an
9589invalid IDNA string (`xn--bar' is invalid).
9590
0b10e437 9591You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
01c52d31
MB
9592installed for this command to work."
9593 (interactive "P")
9594 (if (not (and (condition-case nil (require 'idna)
9595 (file-error))
9596 (mm-coding-system-p 'utf-8)
9597 (executable-find (symbol-value 'idna-program))))
9598 (gnus-message
9599 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9600 (gnus-summary-select-article)
9601 (let ((mail-header-separator ""))
9602 (gnus-eval-in-buffer-window gnus-article-buffer
9603 (save-restriction
9604 (widen)
9605 (let ((start (window-start))
9606 buffer-read-only)
9607 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9608 (replace-match (idna-to-unicode (match-string 1))))
9609 (set-window-start (get-buffer-window (current-buffer)) start)))))))
23f87bed
MB
9610
9611(defun gnus-summary-morse-message (&optional arg)
9612 "Morse decode the current article."
9613 (interactive "P")
9614 (gnus-summary-select-article)
9615 (let ((mail-header-separator ""))
9616 (gnus-eval-in-buffer-window gnus-article-buffer
9617 (save-excursion
9618 (save-restriction
9619 (widen)
9620 (let ((pos (window-start))
c7a91ce1 9621 (inhibit-read-only t))
23f87bed
MB
9622 (goto-char (point-min))
9623 (when (message-goto-body)
9624 (gnus-narrow-to-body))
9625 (goto-char (point-min))
01c52d31 9626