* progmodes/js.el: Make indentation more customizable (Bug#6914).
[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,
114f9c96 4;; 2005, 2006, 2007, 2008, 2009, 2010 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
d09ae6ca
GM
28;; For Emacs < 22.2.
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)
eec82323
LMI
63
64(defcustom gnus-kill-summary-on-exit t
65 "*If non-nil, kill the summary buffer when you exit from it.
66If nil, the summary will become a \"*Dead Summary*\" buffer, and
67it will be killed sometime later."
68 :group 'gnus-summary-exit
69 :type 'boolean)
70
01c52d31
MB
71(defcustom gnus-summary-next-group-on-exit t
72 "If non-nil, go to the next unread newsgroup on summary exit.
73See `gnus-group-goto-unread'."
74 :link '(custom-manual "(gnus)Group Maneuvering")
75 :group 'gnus-summary-exit
330f707b 76 :version "23.1" ;; No Gnus
01c52d31
MB
77 :type 'boolean)
78
eec82323
LMI
79(defcustom gnus-fetch-old-headers nil
80 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
01c52d31
MB
81If an unread article in the group refers to an older, already
82read (or just marked as read) article, the old article will not
83normally be displayed in the Summary buffer. If this variable is
84t, Gnus will attempt to grab the headers to the old articles, and
85thereby build complete threads. If it has the value `some', all
86old headers will be fetched but only enough headers to connect
87otherwise loose threads will be displayed. This variable can
88also be a number. In that case, no more than that number of old
89headers will be fetched. If it has the value `invisible', all
6748645f 90old headers will be fetched, but none will be displayed.
eec82323 91
01c52d31
MB
92The server has to support NOV for any of this to work.
93
94This feature can seriously impact performance it ignores all
f394fa25
MB
95locally cached header entries. Setting it to t for groups for a
96server that doesn't expire articles (such as news.gmane.org),
97leads to very slow summary generation."
eec82323
LMI
98 :group 'gnus-thread
99 :type '(choice (const :tag "off" nil)
1232b9cb 100 (const :tag "on" t)
eec82323 101 (const some)
1232b9cb 102 (const invisible)
eec82323
LMI
103 number
104 (sexp :menu-tag "other" t)))
105
01c52d31 106(defcustom gnus-refer-thread-limit 500
6748645f
LMI
107 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
108If t, fetch all the available old headers."
109 :group 'gnus-thread
110 :type '(choice number
111 (sexp :menu-tag "other" t)))
112
eec82323
LMI
113(defcustom gnus-summary-make-false-root 'adopt
114 "*nil means that Gnus won't gather loose threads.
115If the root of a thread has expired or been read in a previous
116session, the information necessary to build a complete thread has been
117lost. Instead of having many small sub-threads from this original thread
118scattered all over the summary buffer, Gnus can gather them.
119
120If non-nil, Gnus will try to gather all loose sub-threads from an
121original thread into one large thread.
122
123If this variable is non-nil, it should be one of `none', `adopt',
124`dummy' or `empty'.
125
126If this variable is `none', Gnus will not make a false root, but just
127present the sub-threads after another.
128If this variable is `dummy', Gnus will create a dummy root that will
129have all the sub-threads as children.
130If this variable is `adopt', Gnus will make one of the \"children\"
131the parent and mark all the step-children as such.
132If this variable is `empty', the \"children\" are printed with empty
01ccbb85 133subject fields. (Or rather, they will be printed with a string
eec82323
LMI
134given by the `gnus-summary-same-subject' variable.)"
135 :group 'gnus-thread
136 :type '(choice (const :tag "off" nil)
137 (const none)
138 (const dummy)
139 (const adopt)
140 (const empty)))
141
23f87bed
MB
142(defcustom gnus-summary-make-false-root-always nil
143 "Always make a false dummy root."
bf247b6e 144 :version "22.1"
23f87bed
MB
145 :group 'gnus-thread
146 :type 'boolean)
147
eec82323
LMI
148(defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
149 "*A regexp to match subjects to be excluded from loose thread gathering.
150As loose thread gathering is done on subjects only, that means that
151there can be many false gatherings performed. By rooting out certain
152common subjects, gathering might become saner."
153 :group 'gnus-thread
154 :type 'regexp)
155
156(defcustom gnus-summary-gather-subject-limit nil
157 "*Maximum length of subject comparisons when gathering loose threads.
158Use nil to compare full subjects. Setting this variable to a low
159number will help gather threads that have been corrupted by
160newsreaders chopping off subject lines, but it might also mean that
161unrelated articles that have subject that happen to begin with the
162same few characters will be incorrectly gathered.
163
164If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
165comparing subjects."
166 :group 'gnus-thread
167 :type '(choice (const :tag "off" nil)
168 (const fuzzy)
169 (sexp :menu-tag "on" t)))
170
6748645f
LMI
171(defcustom gnus-simplify-subject-functions nil
172 "List of functions taking a string argument that simplify subjects.
173The functions are applied recursively.
174
23f87bed
MB
175Useful functions to put in this list include:
176`gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
177`gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
6748645f
LMI
178 :group 'gnus-thread
179 :type '(repeat function))
180
eec82323 181(defcustom gnus-simplify-ignored-prefixes nil
23f87bed 182 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
eec82323
LMI
183 :group 'gnus-thread
184 :type '(choice (const :tag "off" nil)
185 regexp))
186
187(defcustom gnus-build-sparse-threads nil
188 "*If non-nil, fill in the gaps in threads.
189If `some', only fill in the gaps that are needed to tie loose threads
190together. If `more', fill in all leaf nodes that Gnus can find. If
191non-nil and non-`some', fill in all gaps that Gnus manages to guess."
192 :group 'gnus-thread
193 :type '(choice (const :tag "off" nil)
194 (const some)
195 (const more)
196 (sexp :menu-tag "all" t)))
197
198(defcustom gnus-summary-thread-gathering-function
199 'gnus-gather-threads-by-subject
6748645f 200 "*Function used for gathering loose threads.
eec82323
LMI
201There are two pre-defined functions: `gnus-gather-threads-by-subject',
202which only takes Subjects into consideration; and
203`gnus-gather-threads-by-references', which compared the References
204headers of the articles to find matches."
205 :group 'gnus-thread
22115a9e
RS
206 :type '(radio (function-item gnus-gather-threads-by-subject)
207 (function-item gnus-gather-threads-by-references)
208 (function :tag "other")))
eec82323 209
eec82323
LMI
210(defcustom gnus-summary-same-subject ""
211 "*String indicating that the current article has the same subject as the previous.
212This variable will only be used if the value of
213`gnus-summary-make-false-root' is `empty'."
214 :group 'gnus-summary-format
215 :type 'string)
216
217(defcustom gnus-summary-goto-unread t
16409b0b
GM
218 "*If t, many commands will go to the next unread article.
219This applies to marking commands as well as other commands that
220\"naturally\" select the next article, like, for instance, `SPC' at
221the end of an article.
222
223If nil, the marking commands do NOT go to the next unread article
2642ac8f 224\(they go to the next article instead). If `never', commands that
16409b0b
GM
225usually go to the next unread article, will go to the next article,
226whether it is read or not."
eec82323
LMI
227 :group 'gnus-summary-marks
228 :link '(custom-manual "(gnus)Setting Marks")
229 :type '(choice (const :tag "off" nil)
230 (const never)
231 (sexp :menu-tag "on" t)))
232
233(defcustom gnus-summary-default-score 0
234 "*Default article score level.
235All scores generated by the score files will be added to this score.
236If this variable is nil, scoring will be disabled."
237 :group 'gnus-score-default
238 :type '(choice (const :tag "disable")
239 integer))
240
23f87bed
MB
241(defcustom gnus-summary-default-high-score 0
242 "*Default threshold for a high scored article.
243An article will be highlighted as high scored if its score is greater
244than this score."
bf247b6e 245 :version "22.1"
23f87bed
MB
246 :group 'gnus-score-default
247 :type 'integer)
248
249(defcustom gnus-summary-default-low-score 0
250 "*Default threshold for a low scored article.
251An article will be highlighted as low scored if its score is smaller
252than this score."
bf247b6e 253 :version "22.1"
23f87bed
MB
254 :group 'gnus-score-default
255 :type 'integer)
256
eec82323
LMI
257(defcustom gnus-summary-zcore-fuzz 0
258 "*Fuzziness factor for the zcore in the summary buffer.
259Articles with scores closer than this to `gnus-summary-default-score'
260will not be marked."
261 :group 'gnus-summary-format
262 :type 'integer)
263
264(defcustom gnus-simplify-subject-fuzzy-regexp nil
265 "*Strings to be removed when doing fuzzy matches.
266This can either be a regular expression or list of regular expressions
267that will be removed from subject strings if fuzzy subject
268simplification is selected."
269 :group 'gnus-thread
270 :type '(repeat regexp))
271
272(defcustom gnus-show-threads t
273 "*If non-nil, display threads in summary mode."
274 :group 'gnus-thread
275 :type 'boolean)
276
277(defcustom gnus-thread-hide-subtree nil
278 "*If non-nil, hide all threads initially.
23f87bed 279This can be a predicate specifier which says which threads to hide.
eec82323 280If threads are hidden, you have to run the command
4a2358e9 281`gnus-summary-show-thread' by hand or select an article."
eec82323 282 :group 'gnus-thread
23f87bed
MB
283 :type '(radio (sexp :format "Non-nil\n"
284 :match (lambda (widget value)
285 (not (or (consp value) (functionp value))))
286 :value t)
287 (const nil)
ad136a7c 288 (sexp :tag "Predicate specifier")))
eec82323
LMI
289
290(defcustom gnus-thread-hide-killed t
291 "*If non-nil, hide killed threads automatically."
292 :group 'gnus-thread
293 :type 'boolean)
294
6748645f
LMI
295(defcustom gnus-thread-ignore-subject t
296 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
297If nil, articles that have different subjects from their parents will
298start separate threads."
eec82323
LMI
299 :group 'gnus-thread
300 :type 'boolean)
301
302(defcustom gnus-thread-operation-ignore-subject t
303 "*If non-nil, subjects will be ignored when doing thread commands.
304This affects commands like `gnus-summary-kill-thread' and
305`gnus-summary-lower-thread'.
306
307If this variable is nil, articles in the same thread with different
308subjects will not be included in the operation in question. If this
309variable is `fuzzy', only articles that have subjects that are fuzzily
310equal will be included."
311 :group 'gnus-thread
312 :type '(choice (const :tag "off" nil)
313 (const fuzzy)
314 (sexp :tag "on" t)))
315
316(defcustom gnus-thread-indent-level 4
317 "*Number that says how much each sub-thread should be indented."
318 :group 'gnus-thread
319 :type 'integer)
320
321(defcustom gnus-auto-extend-newsgroup t
322 "*If non-nil, extend newsgroup forward and backward when requested."
323 :group 'gnus-summary-choose
324 :type 'boolean)
325
326(defcustom gnus-auto-select-first t
651408cb
MB
327 "If non-nil, select an article on group entry.
328An article is selected automatically when entering a group
329e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
330`gnus-summary-catchup-and-goto-next-group'.
331
332Which article is selected is controlled by the variable
333`gnus-auto-select-subject'.
23f87bed
MB
334
335If you want to prevent automatic selection of articles in some
336newsgroups, set the variable to nil in `gnus-select-group-hook'."
651408cb
MB
337 ;; Commands include...
338 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
339 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
340 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
eec82323
LMI
341 :group 'gnus-group-select
342 :type '(choice (const :tag "none" nil)
23f87bed
MB
343 (sexp :menu-tag "first" t)))
344
345(defcustom gnus-auto-select-subject 'unread
346 "*Says what subject to place under point when entering a group.
347
348This variable can either be the symbols `first' (place point on the
349first subject), `unread' (place point on the subject line of the first
350unread article), `best' (place point on the subject line of the
351higest-scored article), `unseen' (place point on the subject line of
99b5aab7 352the first unseen article), `unseen-or-unread' (place point on the subject
23f87bed
MB
353line of the first unseen article or, if all article have been seen, on the
354subject line of the first unread article), or a function to be called to
355place point on some subject line."
bf247b6e 356 :version "22.1"
23f87bed
MB
357 :group 'gnus-group-select
358 :type '(choice (const best)
359 (const unread)
360 (const first)
361 (const unseen)
362 (const unseen-or-unread)))
eec82323
LMI
363
364(defcustom gnus-auto-select-next t
365 "*If non-nil, offer to go to the next group from the end of the previous.
366If the value is t and the next newsgroup is empty, Gnus will exit
23f87bed
MB
367summary mode and go back to group mode. If the value is neither nil
368nor t, Gnus will select the following unread newsgroup. In
eec82323
LMI
369particular, if the value is the symbol `quietly', the next unread
370newsgroup will be selected without any confirmation, and if it is
371`almost-quietly', the next group will be selected without any
372confirmation if you are located on the last article in the group.
23f87bed 373Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
eec82323
LMI
374will go to the next group without confirmation."
375 :group 'gnus-summary-maneuvering
376 :type '(choice (const :tag "off" nil)
377 (const quietly)
378 (const almost-quietly)
379 (const slightly-quietly)
380 (sexp :menu-tag "on" t)))
381
382(defcustom gnus-auto-select-same nil
6748645f
LMI
383 "*If non-nil, select the next article with the same subject.
384If there are no more articles with the same subject, go to
385the first unread article."
eec82323
LMI
386 :group 'gnus-summary-maneuvering
387 :type 'boolean)
388
01c52d31
MB
389(defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
390 "What article should be selected after exiting an ephemeral group.
391Valid values include:
392
393`next'
394 Select the next article.
395`next-unread'
396 Select the next unread article.
397`next-noselect'
398 Move the cursor to the next article. This is the default.
399`next-unread-noselect'
400 Move the cursor to the next unread article.
401
402If it has any other value or there is no next (unread) article, the
403article selected before entering to the ephemeral group will appear."
330f707b 404 :version "23.1" ;; No Gnus
01c52d31
MB
405 :group 'gnus-summary-maneuvering
406 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
407 (const next) (const next-unread)
408 (const next-noselect) (const next-unread-noselect)
409 (sexp :tag "other" :value nil)))
410
23f87bed
MB
411(defcustom gnus-auto-goto-ignores 'unfetched
412 "*Says how to handle unfetched articles when maneuvering.
413
414This variable can either be the symbols nil (maneuver to any
415article), `undownloaded' (maneuvering while unplugged ignores articles
416that have not been fetched), `always-undownloaded' (maneuvering always
417ignores articles that have not been fetched), `unfetched' (maneuvering
418ignores articles whose headers have not been fetched).
419
420NOTE: The list of unfetched articles will always be nil when plugged
421and, when unplugged, a subset of the undownloaded article list."
bf247b6e 422 :version "22.1"
23f87bed
MB
423 :group 'gnus-summary-maneuvering
424 :type '(choice (const :tag "None" nil)
425 (const :tag "Undownloaded when unplugged" undownloaded)
426 (const :tag "Undownloaded" always-undownloaded)
427 (const :tag "Unfetched" unfetched)))
428
eec82323
LMI
429(defcustom gnus-summary-check-current nil
430 "*If non-nil, consider the current article when moving.
431The \"unread\" movement commands will stay on the same line if the
432current article is unread."
433 :group 'gnus-summary-maneuvering
434 :type 'boolean)
435
01c52d31 436(defcustom gnus-auto-center-summary 2
eec82323
LMI
437 "*If non-nil, always center the current summary buffer.
438In particular, if `vertical' do only vertical recentering. If non-nil
439and non-`vertical', do both horizontal and vertical recentering."
440 :group 'gnus-summary-maneuvering
441 :type '(choice (const :tag "none" nil)
442 (const vertical)
16409b0b 443 (integer :tag "height")
eec82323
LMI
444 (sexp :menu-tag "both" t)))
445
23f87bed
MB
446(defvar gnus-auto-center-group t
447 "*If non-nil, always center the group buffer.")
448
eec82323
LMI
449(defcustom gnus-show-all-headers nil
450 "*If non-nil, don't hide any headers."
451 :group 'gnus-article-hiding
452 :group 'gnus-article-headers
453 :type 'boolean)
454
455(defcustom gnus-summary-ignore-duplicates nil
456 "*If non-nil, ignore articles with identical Message-ID headers."
457 :group 'gnus-summary
458 :type 'boolean)
6748645f 459
eec82323
LMI
460(defcustom gnus-single-article-buffer t
461 "*If non-nil, display all articles in the same buffer.
462If nil, each group will get its own article buffer."
463 :group 'gnus-article-various
464 :type 'boolean)
465
466(defcustom gnus-break-pages t
467 "*If non-nil, do page breaking on articles.
468The page delimiter is specified by the `gnus-page-delimiter'
469variable."
470 :group 'gnus-article-various
471 :type 'boolean)
472
eec82323
LMI
473(defcustom gnus-move-split-methods nil
474 "*Variable used to suggest where articles are to be moved to.
23f87bed
MB
475It uses the same syntax as the `gnus-split-methods' variable.
476However, whereas `gnus-split-methods' specifies file names as targets,
477this variable specifies group names."
eec82323 478 :group 'gnus-summary-mail
6748645f
LMI
479 :type '(repeat (choice (list :value (fun) function)
480 (cons :value ("" "") regexp (repeat string))
481 (sexp :value nil))))
eec82323 482
01c52d31
MB
483(defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
484 "Function used to compute default prefix for article move/copy/etc prompts.
485The function should take one argument, a group name, and return a
486string with the suggested prefix."
487 :group 'gnus-summary-mail
488 :type 'function)
489
e62e7654
MB
490;; FIXME: Although the custom type is `character' for the following variables,
491;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
492
23f87bed 493(defcustom gnus-unread-mark ? ;Whitespace
eec82323
LMI
494 "*Mark used for unread articles."
495 :group 'gnus-summary-marks
496 :type 'character)
497
498(defcustom gnus-ticked-mark ?!
499 "*Mark used for ticked articles."
500 :group 'gnus-summary-marks
501 :type 'character)
502
503(defcustom gnus-dormant-mark ??
504 "*Mark used for dormant articles."
505 :group 'gnus-summary-marks
506 :type 'character)
507
508(defcustom gnus-del-mark ?r
509 "*Mark used for del'd articles."
510 :group 'gnus-summary-marks
511 :type 'character)
512
513(defcustom gnus-read-mark ?R
514 "*Mark used for read articles."
515 :group 'gnus-summary-marks
516 :type 'character)
517
518(defcustom gnus-expirable-mark ?E
519 "*Mark used for expirable articles."
520 :group 'gnus-summary-marks
521 :type 'character)
522
523(defcustom gnus-killed-mark ?K
524 "*Mark used for killed articles."
525 :group 'gnus-summary-marks
526 :type 'character)
527
23f87bed
MB
528(defcustom gnus-spam-mark ?$
529 "*Mark used for spam articles."
bf247b6e 530 :version "22.1"
23f87bed
MB
531 :group 'gnus-summary-marks
532 :type 'character)
533
eec82323 534(defcustom gnus-souped-mark ?F
23f87bed 535 "*Mark used for souped articles."
eec82323
LMI
536 :group 'gnus-summary-marks
537 :type 'character)
538
539(defcustom gnus-kill-file-mark ?X
540 "*Mark used for articles killed by kill files."
541 :group 'gnus-summary-marks
542 :type 'character)
543
544(defcustom gnus-low-score-mark ?Y
545 "*Mark used for articles with a low score."
546 :group 'gnus-summary-marks
547 :type 'character)
548
549(defcustom gnus-catchup-mark ?C
550 "*Mark used for articles that are caught up."
551 :group 'gnus-summary-marks
552 :type 'character)
553
554(defcustom gnus-replied-mark ?A
555 "*Mark used for articles that have been replied to."
556 :group 'gnus-summary-marks
557 :type 'character)
558
23f87bed
MB
559(defcustom gnus-forwarded-mark ?F
560 "*Mark used for articles that have been forwarded."
bf247b6e 561 :version "22.1"
23f87bed
MB
562 :group 'gnus-summary-marks
563 :type 'character)
564
565(defcustom gnus-recent-mark ?N
566 "*Mark used for articles that are recent."
bf247b6e 567 :version "22.1"
23f87bed
MB
568 :group 'gnus-summary-marks
569 :type 'character)
570
eec82323
LMI
571(defcustom gnus-cached-mark ?*
572 "*Mark used for articles that are in the cache."
573 :group 'gnus-summary-marks
574 :type 'character)
575
576(defcustom gnus-saved-mark ?S
23f87bed
MB
577 "*Mark used for articles that have been saved."
578 :group 'gnus-summary-marks
579 :type 'character)
580
581(defcustom gnus-unseen-mark ?.
582 "*Mark used for articles that haven't been seen."
bf247b6e 583 :version "22.1"
23f87bed
MB
584 :group 'gnus-summary-marks
585 :type 'character)
586
587(defcustom gnus-no-mark ? ;Whitespace
588 "*Mark used for articles that have no other secondary mark."
bf247b6e 589 :version "22.1"
eec82323
LMI
590 :group 'gnus-summary-marks
591 :type 'character)
592
593(defcustom gnus-ancient-mark ?O
594 "*Mark used for ancient articles."
595 :group 'gnus-summary-marks
596 :type 'character)
597
598(defcustom gnus-sparse-mark ?Q
599 "*Mark used for sparsely reffed articles."
600 :group 'gnus-summary-marks
601 :type 'character)
602
603(defcustom gnus-canceled-mark ?G
604 "*Mark used for canceled articles."
605 :group 'gnus-summary-marks
606 :type 'character)
607
608(defcustom gnus-duplicate-mark ?M
609 "*Mark used for duplicate articles."
610 :group 'gnus-summary-marks
611 :type 'character)
612
23f87bed 613(defcustom gnus-undownloaded-mark ?-
6748645f 614 "*Mark used for articles that weren't downloaded."
bf247b6e 615 :version "22.1"
6748645f
LMI
616 :group 'gnus-summary-marks
617 :type 'character)
618
23f87bed
MB
619(defcustom gnus-downloaded-mark ?+
620 "*Mark used for articles that were downloaded."
621 :group 'gnus-summary-marks
622 :type 'character)
623
6748645f
LMI
624(defcustom gnus-downloadable-mark ?%
625 "*Mark used for articles that are to be downloaded."
626 :group 'gnus-summary-marks
627 :type 'character)
628
629(defcustom gnus-unsendable-mark ?=
630 "*Mark used for articles that won't be sent."
631 :group 'gnus-summary-marks
632 :type 'character)
633
eec82323
LMI
634(defcustom gnus-score-over-mark ?+
635 "*Score mark used for articles with high scores."
636 :group 'gnus-summary-marks
637 :type 'character)
638
639(defcustom gnus-score-below-mark ?-
640 "*Score mark used for articles with low scores."
641 :group 'gnus-summary-marks
642 :type 'character)
643
23f87bed 644(defcustom gnus-empty-thread-mark ? ;Whitespace
eec82323
LMI
645 "*There is no thread under the article."
646 :group 'gnus-summary-marks
647 :type 'character)
648
649(defcustom gnus-not-empty-thread-mark ?=
650 "*There is a thread under the article."
651 :group 'gnus-summary-marks
652 :type 'character)
653
654(defcustom gnus-view-pseudo-asynchronously nil
655 "*If non-nil, Gnus will view pseudo-articles asynchronously."
656 :group 'gnus-extract-view
657 :type 'boolean)
658
16409b0b
GM
659(defcustom gnus-auto-expirable-marks
660 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
661 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
662 gnus-souped-mark gnus-duplicate-mark)
663 "*The list of marks converted into expiration if a group is auto-expirable."
58e39d05 664 :version "21.1"
16409b0b
GM
665 :group 'gnus-summary
666 :type '(repeat character))
667
668(defcustom gnus-inhibit-user-auto-expire t
669 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
58e39d05 670 :version "21.1"
16409b0b
GM
671 :group 'gnus-summary
672 :type 'boolean)
673
b0b63450
MB
674(defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
675 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
676If nil, the expirable marks will be unchanged except that the marks
677will be removed when copying or moving articles to a group that has
678not turned auto-expire on. If non-nil, articles that have been read
679will be marked as expirable when being copied or moved to a group in
680which auto-expire is turned on."
681 :version "23.2"
682 :type 'boolean
683 :group 'gnus-summary-marks)
684
eec82323
LMI
685(defcustom gnus-view-pseudos nil
686 "*If `automatic', pseudo-articles will be viewed automatically.
687If `not-confirm', pseudos will be viewed automatically, and the user
688will not be asked to confirm the command."
689 :group 'gnus-extract-view
690 :type '(choice (const :tag "off" nil)
691 (const automatic)
692 (const not-confirm)))
693
694(defcustom gnus-view-pseudos-separately t
695 "*If non-nil, one pseudo-article will be created for each file to be viewed.
696If nil, all files that use the same viewing command will be given as a
697list of parameters to that command."
698 :group 'gnus-extract-view
699 :type 'boolean)
700
701(defcustom gnus-insert-pseudo-articles t
702 "*If non-nil, insert pseudo-articles when decoding articles."
703 :group 'gnus-extract-view
704 :type 'boolean)
705
706(defcustom gnus-summary-dummy-line-format
23f87bed 707 " %(: :%) %S\n"
eec82323
LMI
708 "*The format specification for the dummy roots in the summary buffer.
709It works along the same lines as a normal formatting string,
710with some simple extensions.
711
23f87bed
MB
712%S The subject
713
714General format specifiers can also be used.
715See `(gnus)Formatting Variables'."
716 :link '(custom-manual "(gnus)Formatting Variables")
eec82323
LMI
717 :group 'gnus-threading
718 :type 'string)
719
16409b0b 720(defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
eec82323
LMI
721 "*The format specification for the summary mode line.
722It works along the same lines as a normal formatting string,
723with some simple extensions:
724
725%G Group name
726%p Unprefixed group name
727%A Current article number
6748645f 728%z Current article score
eec82323
LMI
729%V Gnus version
730%U Number of unread articles in the group
731%e Number of unselected articles in the group
732%Z A string with unread/unselected article counts
733%g Shortish group name
734%S Subject of the current article
735%u User-defined spec
736%s Current score file name
737%d Number of dormant articles
738%r Number of articles that have been marked as read in this session
739%E Number of articles expunged by the score files"
740 :group 'gnus-summary-format
741 :type 'string)
742
16409b0b
GM
743(defcustom gnus-list-identifiers nil
744 "Regexp that matches list identifiers to be removed from subject.
745This can also be a list of regexps."
58e39d05 746 :version "21.1"
16409b0b
GM
747 :group 'gnus-summary-format
748 :group 'gnus-article-hiding
749 :type '(choice (const :tag "none" nil)
750 (regexp :value ".*")
751 (repeat :value (".*") regexp)))
752
eec82323
LMI
753(defcustom gnus-summary-mark-below 0
754 "*Mark all articles with a score below this variable as read.
755This variable is local to each summary buffer and usually set by the
756score file."
757 :group 'gnus-score-default
758 :type 'integer)
759
01c52d31
MB
760(defun gnus-widget-reversible-match (widget value)
761 "Ignoring WIDGET, convert VALUE to internal form.
762VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
763 ;; (debug value)
764 (or (symbolp value)
765 (and (listp value)
766 (eq (length value) 2)
767 (eq (nth 0 value) 'not)
768 (symbolp (nth 1 value)))))
769
770(defun gnus-widget-reversible-to-internal (widget value)
771 "Ignoring WIDGET, convert VALUE to internal form.
772VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
773FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
774 ;; (debug value)
775 (if (atom value)
776 (list value nil)
777 (list (nth 1 value) t)))
778
779(defun gnus-widget-reversible-to-external (widget value)
780 "Ignoring WIDGET, convert VALUE to external form.
781VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
782\(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
783 ;; (debug value)
784 (if (nth 1 value)
785 (list 'not (nth 0 value))
786 (nth 0 value)))
787
788(define-widget 'gnus-widget-reversible 'group
789 "A `group' that convert values."
790 :match 'gnus-widget-reversible-match
791 :value-to-internal 'gnus-widget-reversible-to-internal
792 :value-to-external 'gnus-widget-reversible-to-external)
793
eec82323
LMI
794(defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
795 "*List of functions used for sorting articles in the summary buffer.
23f87bed
MB
796
797Each function takes two articles and returns non-nil if the first
798article should be sorted before the other. If you use more than one
799function, the primary sort function should be the last. You should
800probably always include `gnus-article-sort-by-number' in the list of
801sorting functions -- preferably first. Also note that sorting by date
802is often much slower than sorting by number, and the sorting order is
803very similar. (Sorting by date means sorting by the time the message
804was sent, sorting by number means sorting by arrival time.)
805
01c52d31
MB
806Each item can also be a list `(not F)' where F is a function;
807this reverses the sort order.
808
23f87bed
MB
809Ready-made functions include `gnus-article-sort-by-number',
810`gnus-article-sort-by-author', `gnus-article-sort-by-subject',
811`gnus-article-sort-by-date', `gnus-article-sort-by-random'
812and `gnus-article-sort-by-score'.
813
814When threading is turned on, the variable `gnus-thread-sort-functions'
815controls how articles are sorted."
eec82323 816 :group 'gnus-summary-sort
01c52d31
MB
817 :type '(repeat (gnus-widget-reversible
818 (choice (function-item gnus-article-sort-by-number)
819 (function-item gnus-article-sort-by-author)
820 (function-item gnus-article-sort-by-subject)
821 (function-item gnus-article-sort-by-date)
822 (function-item gnus-article-sort-by-score)
823 (function-item gnus-article-sort-by-random)
824 (function :tag "other"))
825 (boolean :tag "Reverse order"))))
826
eec82323
LMI
827
828(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
829 "*List of functions used for sorting threads in the summary buffer.
830By default, threads are sorted by article number.
831
23f87bed
MB
832Each function takes two threads and returns non-nil if the first
833thread should be sorted before the other. If you use more than one
834function, the primary sort function should be the last. You should
835probably always include `gnus-thread-sort-by-number' in the list of
836sorting functions -- preferably first. Also note that sorting by date
837is often much slower than sorting by number, and the sorting order is
838very similar. (Sorting by date means sorting by the time the message
839was sent, sorting by number means sorting by arrival time.)
eec82323 840
01c52d31
MB
841Each list item can also be a list `(not F)' where F is a
842function; this specifies reversed sort order.
843
eec82323 844Ready-made functions include `gnus-thread-sort-by-number',
01c52d31
MB
845`gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
846`gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
847`gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
848`gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
849and `gnus-thread-sort-by-total-score' (see
850`gnus-thread-score-function').
23f87bed
MB
851
852When threading is turned off, the variable
853`gnus-article-sort-functions' controls how articles are sorted."
eec82323 854 :group 'gnus-summary-sort
01c52d31
MB
855 :type '(repeat
856 (gnus-widget-reversible
857 (choice (function-item gnus-thread-sort-by-number)
858 (function-item gnus-thread-sort-by-author)
859 (function-item gnus-thread-sort-by-recipient)
860 (function-item gnus-thread-sort-by-subject)
861 (function-item gnus-thread-sort-by-date)
862 (function-item gnus-thread-sort-by-score)
863 (function-item gnus-thread-sort-by-most-recent-number)
864 (function-item gnus-thread-sort-by-most-recent-date)
865 (function-item gnus-thread-sort-by-random)
866 (function-item gnus-thread-sort-by-total-score)
867 (function :tag "other"))
868 (boolean :tag "Reverse order"))))
eec82323
LMI
869
870(defcustom gnus-thread-score-function '+
871 "*Function used for calculating the total score of a thread.
872
873The function is called with the scores of the article and each
874subthread and should then return the score of the thread.
875
876Some functions you can use are `+', `max', or `min'."
877 :group 'gnus-summary-sort
878 :type 'function)
879
880(defcustom gnus-summary-expunge-below nil
6748645f
LMI
881 "All articles that have a score less than this variable will be expunged.
882This variable is local to the summary buffers."
eec82323
LMI
883 :group 'gnus-score-default
884 :type '(choice (const :tag "off" nil)
885 integer))
886
887(defcustom gnus-thread-expunge-below nil
888 "All threads that have a total score less than this variable will be expunged.
889See `gnus-thread-score-function' for en explanation of what a
6748645f
LMI
890\"thread score\" is.
891
892This variable is local to the summary buffers."
16409b0b 893 :group 'gnus-threading
eec82323
LMI
894 :group 'gnus-score-default
895 :type '(choice (const :tag "off" nil)
896 integer))
897
898(defcustom gnus-summary-mode-hook nil
899 "*A hook for Gnus summary mode.
900This hook is run before any variables are set in the summary buffer."
23f87bed 901 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
eec82323
LMI
902 :group 'gnus-summary-various
903 :type 'hook)
904
23f87bed
MB
905;; Extracted from gnus-xmas-redefine in order to preserve user settings
906(when (featurep 'xemacs)
907 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
908 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
909 (add-hook 'gnus-summary-mode-hook
910 'gnus-xmas-switch-horizontal-scrollbar-off))
911
eec82323
LMI
912(defcustom gnus-summary-menu-hook nil
913 "*Hook run after the creation of the summary mode menu."
914 :group 'gnus-summary-visual
915 :type 'hook)
916
917(defcustom gnus-summary-exit-hook nil
918 "*A hook called on exit from the summary buffer.
919It will be called with point in the group buffer."
920 :group 'gnus-summary-exit
921 :type 'hook)
922
923(defcustom gnus-summary-prepare-hook nil
924 "*A hook called after the summary buffer has been generated.
925If you want to modify the summary buffer, you can use this hook."
926 :group 'gnus-summary-various
927 :type 'hook)
928
6748645f
LMI
929(defcustom gnus-summary-prepared-hook nil
930 "*A hook called as the last thing after the summary buffer has been generated."
931 :group 'gnus-summary-various
932 :type 'hook)
933
eec82323
LMI
934(defcustom gnus-summary-generate-hook nil
935 "*A hook run just before generating the summary buffer.
936This hook is commonly used to customize threading variables and the
937like."
938 :group 'gnus-summary-various
939 :type 'hook)
940
941(defcustom gnus-select-group-hook nil
942 "*A hook called when a newsgroup is selected.
943
944If you'd like to simplify subjects like the
945`gnus-summary-next-same-subject' command does, you can use the
946following hook:
947
23f87bed
MB
948 (add-hook gnus-select-group-hook
949 (lambda ()
950 (mapcar (lambda (header)
951 (mail-header-set-subject
952 header
953 (gnus-simplify-subject
954 (mail-header-subject header) 're-only)))
955 gnus-newsgroup-headers)))"
eec82323
LMI
956 :group 'gnus-group-select
957 :type 'hook)
958
959(defcustom gnus-select-article-hook nil
960 "*A hook called when an article is selected."
961 :group 'gnus-summary-choose
23f87bed 962 :options '(gnus-agent-fetch-selected-article)
eec82323
LMI
963 :type 'hook)
964
965(defcustom gnus-visual-mark-article-hook
966 (list 'gnus-highlight-selected-summary)
967 "*Hook run after selecting an article in the summary buffer.
968It is meant to be used for highlighting the article in some way. It
969is not run if `gnus-visual' is nil."
970 :group 'gnus-summary-visual
971 :type 'hook)
972
16409b0b 973(defcustom gnus-parse-headers-hook nil
eec82323
LMI
974 "*A hook called before parsing the headers."
975 :group 'gnus-various
976 :type 'hook)
977
978(defcustom gnus-exit-group-hook nil
16409b0b
GM
979 "*A hook called when exiting summary mode.
980This hook is not called from the non-updating exit commands like `Q'."
eec82323
LMI
981 :group 'gnus-various
982 :type 'hook)
983
984(defcustom gnus-summary-update-hook
985 (list 'gnus-summary-highlight-line)
986 "*A hook called when a summary line is changed.
987The hook will not be called if `gnus-visual' is nil.
988
989The default function `gnus-summary-highlight-line' will
990highlight the line according to the `gnus-summary-highlight'
991variable."
992 :group 'gnus-summary-visual
993 :type 'hook)
994
995(defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
996 "*A hook called when an article is selected for the first time.
997The hook is intended to mark an article as read (or unread)
998automatically when it is selected."
999 :group 'gnus-summary-choose
1000 :type 'hook)
1001
1002(defcustom gnus-group-no-more-groups-hook nil
1003 "*A hook run when returning to group mode having no more (unread) groups."
1004 :group 'gnus-group-select
1005 :type 'hook)
1006
1007(defcustom gnus-ps-print-hook nil
1008 "*A hook run before ps-printing something from Gnus."
1009 :group 'gnus-summary
1010 :type 'hook)
1011
23f87bed
MB
1012(defcustom gnus-summary-article-move-hook nil
1013 "*A hook called after an article is moved, copied, respooled, or crossposted."
bf247b6e 1014 :version "22.1"
23f87bed
MB
1015 :group 'gnus-summary
1016 :type 'hook)
1017
1018(defcustom gnus-summary-article-delete-hook nil
1019 "*A hook called after an article is deleted."
bf247b6e 1020 :version "22.1"
23f87bed
MB
1021 :group 'gnus-summary
1022 :type 'hook)
1023
1024(defcustom gnus-summary-article-expire-hook nil
1025 "*A hook called after an article is expired."
bf247b6e 1026 :version "22.1"
23f87bed
MB
1027 :group 'gnus-summary
1028 :type 'hook)
1029
1030(defcustom gnus-summary-display-arrow
1031 (and (fboundp 'display-graphic-p)
1032 (display-graphic-p))
1033 "*If non-nil, display an arrow highlighting the current article."
bf247b6e 1034 :version "22.1"
23f87bed
MB
1035 :group 'gnus-summary
1036 :type 'boolean)
1037
0f49874b 1038(defcustom gnus-summary-selected-face 'gnus-summary-selected
eec82323
LMI
1039 "Face used for highlighting the current article in the summary buffer."
1040 :group 'gnus-summary-visual
1041 :type 'face)
1042
23f87bed
MB
1043(defvar gnus-tmp-downloaded nil)
1044
eec82323 1045(defcustom gnus-summary-highlight
23f87bed 1046 '(((eq mark gnus-canceled-mark)
0f49874b 1047 . gnus-summary-cancelled)
23f87bed 1048 ((and uncached (> score default-high))
0f49874b 1049 . gnus-summary-high-undownloaded)
23f87bed 1050 ((and uncached (< score default-low))
0f49874b 1051 . gnus-summary-low-undownloaded)
23f87bed 1052 (uncached
0f49874b 1053 . gnus-summary-normal-undownloaded)
23f87bed
MB
1054 ((and (> score default-high)
1055 (or (eq mark gnus-dormant-mark)
1056 (eq mark gnus-ticked-mark)))
0f49874b 1057 . gnus-summary-high-ticked)
23f87bed
MB
1058 ((and (< score default-low)
1059 (or (eq mark gnus-dormant-mark)
1060 (eq mark gnus-ticked-mark)))
0f49874b 1061 . gnus-summary-low-ticked)
23f87bed
MB
1062 ((or (eq mark gnus-dormant-mark)
1063 (eq mark gnus-ticked-mark))
0f49874b 1064 . gnus-summary-normal-ticked)
23f87bed 1065 ((and (> score default-high) (eq mark gnus-ancient-mark))
0f49874b 1066 . gnus-summary-high-ancient)
23f87bed 1067 ((and (< score default-low) (eq mark gnus-ancient-mark))
0f49874b 1068 . gnus-summary-low-ancient)
23f87bed 1069 ((eq mark gnus-ancient-mark)
0f49874b 1070 . gnus-summary-normal-ancient)
23f87bed 1071 ((and (> score default-high) (eq mark gnus-unread-mark))
0f49874b 1072 . gnus-summary-high-unread)
23f87bed 1073 ((and (< score default-low) (eq mark gnus-unread-mark))
0f49874b 1074 . gnus-summary-low-unread)
23f87bed 1075 ((eq mark gnus-unread-mark)
0f49874b 1076 . gnus-summary-normal-unread)
23f87bed 1077 ((> score default-high)
0f49874b 1078 . gnus-summary-high-read)
23f87bed 1079 ((< score default-low)
0f49874b 1080 . gnus-summary-low-read)
eec82323 1081 (t
0f49874b 1082 . gnus-summary-normal-read))
6748645f 1083 "*Controls the highlighting of summary buffer lines.
eec82323 1084
107cf8ec 1085A list of (FORM . FACE) pairs. When deciding how a particular
23f87bed
MB
1086summary line should be displayed, each form is evaluated. The content
1087of the face field after the first true form is used. You can change
1088how those summary lines are displayed, by editing the face field.
eec82323
LMI
1089
1090You can use the following variables in the FORM field.
1091
107cf8ec 1092score: The article's score.
23f87bed
MB
1093default: The default article score.
1094default-high: The default score for high scored articles.
1095default-low: The default score for low scored articles.
1096below: The score below which articles are automatically marked as read.
1097mark: The article's mark.
1098uncached: Non-nil if the article is uncached."
eec82323
LMI
1099 :group 'gnus-summary-visual
1100 :type '(repeat (cons (sexp :tag "Form" nil)
1101 face)))
c12ecb0a 1102(put 'gnus-summary-highlight 'risky-local-variable t)
eec82323 1103
6748645f
LMI
1104(defcustom gnus-alter-header-function nil
1105 "Function called to allow alteration of article header structures.
1106The function is called with one parameter, the article header vector,
0ab0f2d3
SZ
1107which it may alter in any way."
1108 :type '(choice (const :tag "None" nil)
1109 function)
1110 :group 'gnus-summary)
eec82323 1111
16409b0b 1112(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
343d6628
MB
1113 "Function used to decode a string with encoded words.")
1114
1115(defvar gnus-decode-encoded-address-function
1116 'mail-decode-encoded-address-string
1117 "Function used to decode addresses with encoded words.")
16409b0b 1118
23f87bed 1119(defcustom gnus-extra-headers '(To Newsgroups)
16409b0b 1120 "*Extra headers to parse."
58e39d05 1121 :version "21.1"
16409b0b
GM
1122 :group 'gnus-summary
1123 :type '(repeat symbol))
1124
1125(defcustom gnus-ignored-from-addresses
343d6628 1126 (and user-mail-address
7cd9f860
CY
1127 (not (string= user-mail-address ""))
1128 (regexp-quote user-mail-address))
01c52d31
MB
1129 "*From headers that may be suppressed in favor of To headers.
1130This can be a regexp or a list of regexps."
58e39d05 1131 :version "21.1"
16409b0b 1132 :group 'gnus-summary
01c52d31
MB
1133 :type '(choice regexp
1134 (repeat :tag "Regexp List" regexp)))
1135
1136(defsubst gnus-ignored-from-addresses ()
1137 (gmm-regexp-concat gnus-ignored-from-addresses))
1138
1139(defcustom gnus-summary-to-prefix "-> "
1140 "*String prefixed to the To field in the summary line when
1141using `gnus-ignored-from-addresses'."
1142 :version "22.1"
1143 :group 'gnus-summary
1144 :type 'string)
1145
1146(defcustom gnus-summary-newsgroup-prefix "=> "
1147 "*String prefixed to the Newsgroup field in the summary
1148line when using `gnus-ignored-from-addresses'."
1149 :version "22.1"
1150 :group 'gnus-summary
1151 :type 'string)
16409b0b 1152
16409b0b
GM
1153(defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1154 "List of charsets that should be ignored.
1155When these charsets are used in the \"charset\" parameter, the
1156default charset will be used instead."
58e39d05 1157 :version "21.1"
16409b0b
GM
1158 :type '(repeat symbol)
1159 :group 'gnus-charset)
1160
4b70e299
MB
1161(defcustom gnus-newsgroup-maximum-articles nil
1162 "The maximum number of articles a newsgroup.
1163If this is a number, old articles in a newsgroup exceeding this number
1164are silently ignored. If it is nil, no article is ignored. Note that
1165setting this variable to a number might prevent you from reading very
1166old articles."
1167 :group 'gnus-group-select
1168 :version "22.2"
1169 :type '(choice (const :tag "No limit" nil)
1170 integer))
1171
23f87bed
MB
1172(gnus-define-group-parameter
1173 ignored-charsets
1174 :type list
1175 :function-document
1176 "Return the ignored charsets of GROUP."
1177 :variable gnus-group-ignored-charsets-alist
1178 :variable-default
1179 '(("alt\\.chinese\\.text" iso-8859-1))
1180 :variable-document
1181 "Alist of regexps (to match group names) and charsets that should be ignored.
16409b0b
GM
1182When these charsets are used in the \"charset\" parameter, the
1183default charset will be used instead."
23f87bed
MB
1184 :variable-group gnus-charset
1185 :variable-type '(repeat (cons (regexp :tag "Group")
1186 (repeat symbol)))
1187 :parameter-type '(choice :tag "Ignored charsets"
1188 :value nil
1189 (repeat (symbol)))
1190 :parameter-document "\
1191List of charsets that should be ignored.
1192
1193When these charsets are used in the \"charset\" parameter, the
1194default charset will be used instead.")
16409b0b
GM
1195
1196(defcustom gnus-group-highlight-words-alist nil
1197 "Alist of group regexps and highlight regexps.
1198This variable uses the same syntax as `gnus-emphasis-alist'."
58e39d05 1199 :version "21.1"
16409b0b
GM
1200 :type '(repeat (cons (regexp :tag "Group")
1201 (repeat (list (regexp :tag "Highlight regexp")
1202 (number :tag "Group for entire word" 0)
1203 (number :tag "Group for displayed part" 0)
1204 (symbol :tag "Face"
1205 gnus-emphasis-highlight-words)))))
1206 :group 'gnus-summary-visual)
1207
1208(defcustom gnus-summary-show-article-charset-alist
1209 nil
1210 "Alist of number and charset.
1211The article will be shown with the charset corresponding to the
1212numbered argument.
1213For example: ((1 . cn-gb-2312) (2 . big5))."
58e39d05 1214 :version "21.1"
16409b0b
GM
1215 :type '(repeat (cons (number :tag "Argument" 1)
1216 (symbol :tag "Charset")))
1217 :group 'gnus-charset)
1218
1219(defcustom gnus-preserve-marks t
1220 "Whether marks are preserved when moving, copying and respooling messages."
58e39d05 1221 :version "21.1"
16409b0b
GM
1222 :type 'boolean
1223 :group 'gnus-summary-marks)
1224
3a23a519
MB
1225(defcustom gnus-propagate-marks t
1226 "If non-nil, do not propagate marks to the backends."
f8a29505 1227 :version "23.1" ;; No Gnus
3a23a519
MB
1228 :type 'boolean
1229 :group 'gnus-summary-marks)
1230
16409b0b
GM
1231(defcustom gnus-alter-articles-to-read-function nil
1232 "Function to be called to alter the list of articles to be selected."
8fc7a9a1 1233 :type '(choice (const nil) function)
16409b0b
GM
1234 :group 'gnus-summary)
1235
1236(defcustom gnus-orphan-score nil
1237 "*All orphans get this score added. Set in the score file."
1238 :group 'gnus-score-default
1239 :type '(choice (const nil)
1240 integer))
1241
8b93df01 1242(defcustom gnus-summary-save-parts-default-mime "image/.*"
23f87bed
MB
1243 "*A regexp to match MIME parts when saving multiple parts of a
1244message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1245This regexp will be used by default when prompting the user for which
1246type of files to save."
8b93df01
DL
1247 :group 'gnus-summary
1248 :type 'regexp)
1249
23f87bed
MB
1250(defcustom gnus-read-all-available-headers nil
1251 "Whether Gnus should parse all headers made available to it.
1252This is mostly relevant for slow back ends where the user may
1253wish to widen the summary buffer to include all headers
1254that were fetched. Say, for nnultimate groups."
bf247b6e 1255 :version "22.1"
23f87bed
MB
1256 :group 'gnus-summary
1257 :type '(choice boolean regexp))
1258
89167438
MB
1259(defcustom gnus-summary-pipe-output-default-command nil
1260 "Command (and optional arguments) used to pipe article to subprocess.
1261This will be used as the default command if it is non-nil. The value
1262will be updated if you modify it when executing the command
1263`gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1264 :version "23.1" ;; No Gnus
1265 :group 'gnus-summary
1266 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1267
23f87bed 1268(defcustom gnus-summary-muttprint-program "muttprint"
89167438
MB
1269 "Command (and optional arguments) used to run Muttprint.
1270The value will be updated if you modify it when executing the command
1271`gnus-summary-muttprint'."
bf247b6e 1272 :version "22.1"
23f87bed
MB
1273 :group 'gnus-summary
1274 :type 'string)
1275
01c52d31 1276(defcustom gnus-article-loose-mime t
23f87bed
MB
1277 "If non-nil, don't require MIME-Version header.
1278Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
a08b59c9 1279supply the MIME-Version header or deliberately strip it from the mail.
01c52d31
MB
1280If non-nil (the default), Gnus will treat some articles as MIME
1281even if the MIME-Version header is missing."
bf247b6e 1282 :version "22.1"
23f87bed
MB
1283 :type 'boolean
1284 :group 'gnus-article-mime)
1285
1286(defcustom gnus-article-emulate-mime t
1287 "If non-nil, use MIME emulation for uuencode and the like.
1288This means that Gnus will search message bodies for text that look
1289like uuencoded bits, yEncoded bits, and so on, and present that using
1290the normal Gnus MIME machinery."
bf247b6e 1291 :version "22.1"
23f87bed
MB
1292 :type 'boolean
1293 :group 'gnus-article-mime)
8b93df01 1294
eec82323
LMI
1295;;; Internal variables
1296
23f87bed 1297(defvar gnus-summary-display-cache nil)
16409b0b
GM
1298(defvar gnus-article-mime-handles nil)
1299(defvar gnus-article-decoded-p nil)
23f87bed
MB
1300(defvar gnus-article-charset nil)
1301(defvar gnus-article-ignored-charsets nil)
eec82323
LMI
1302(defvar gnus-scores-exclude-files nil)
1303(defvar gnus-page-broken nil)
1304
1305(defvar gnus-original-article nil)
1306(defvar gnus-article-internal-prepare-hook nil)
1307(defvar gnus-newsgroup-process-stack nil)
1308
1309(defvar gnus-thread-indent-array nil)
1310(defvar gnus-thread-indent-array-level gnus-thread-indent-level)
16409b0b
GM
1311(defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1312 "Function called to sort the articles within a thread after it has been gathered together.")
eec82323 1313
8b93df01 1314(defvar gnus-summary-save-parts-type-history nil)
23f87bed 1315(defvar gnus-summary-save-parts-last-directory mm-default-directory)
8b93df01 1316
eec82323
LMI
1317;; Avoid highlighting in kill files.
1318(defvar gnus-summary-inhibit-highlight nil)
1319(defvar gnus-newsgroup-selected-overlay nil)
1320(defvar gnus-inhibit-limiting nil)
1321(defvar gnus-newsgroup-adaptive-score-file nil)
1322(defvar gnus-current-score-file nil)
1323(defvar gnus-current-move-group nil)
1324(defvar gnus-current-copy-group nil)
1325(defvar gnus-current-crosspost-group nil)
23f87bed 1326(defvar gnus-newsgroup-display nil)
eec82323
LMI
1327
1328(defvar gnus-newsgroup-dependencies nil)
1329(defvar gnus-newsgroup-adaptive nil)
1330(defvar gnus-summary-display-article-function nil)
1331(defvar gnus-summary-highlight-line-function nil
1332 "Function called after highlighting a summary line.")
1333
1334(defvar gnus-summary-line-format-alist
1335 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1336 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1337 (?s gnus-tmp-subject-or-nil ?s)
1338 (?n gnus-tmp-name ?s)
1339 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1340 ?s)
1341 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1342 gnus-tmp-from) ?s)
1343 (?F gnus-tmp-from ?s)
1344 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1345 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1346 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
6748645f 1347 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
eec82323
LMI
1348 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1349 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1350 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
23f87bed
MB
1351 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1352 (?L gnus-tmp-lines ?s)
1353 (?O gnus-tmp-downloaded ?c)
eec82323
LMI
1354 (?I gnus-tmp-indentation ?s)
1355 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1356 (?R gnus-tmp-replied ?c)
1357 (?\[ gnus-tmp-opening-bracket ?c)
1358 (?\] gnus-tmp-closing-bracket ?c)
1359 (?\> (make-string gnus-tmp-level ? ) ?s)
1360 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1361 (?i gnus-tmp-score ?d)
1362 (?z gnus-tmp-score-char ?c)
eec82323
LMI
1363 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1364 (?U gnus-tmp-unread ?c)
23f87bed
MB
1365 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1366 ?s)
eec82323
LMI
1367 (?t (gnus-summary-number-of-articles-in-thread
1368 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1369 ?d)
1370 (?e (gnus-summary-number-of-articles-in-thread
1371 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1372 ?c)
1373 (?u gnus-tmp-user-defined ?s)
23f87bed
MB
1374 (?P (gnus-pick-line-number) ?d)
1375 (?B gnus-tmp-thread-tree-header-string ?s)
1376 (user-date (gnus-user-date
1377 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
16409b0b
GM
1378 "An alist of format specifications that can appear in summary lines.
1379These are paired with what variables they correspond with, along with
1380the type of the variable (string, integer, character, etc).")
eec82323
LMI
1381
1382(defvar gnus-summary-dummy-line-format-alist
1383 `((?S gnus-tmp-subject ?s)
1384 (?N gnus-tmp-number ?d)
1385 (?u gnus-tmp-user-defined ?s)))
1386
1387(defvar gnus-summary-mode-line-format-alist
1388 `((?G gnus-tmp-group-name ?s)
1389 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1390 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1391 (?A gnus-tmp-article-number ?d)
1392 (?Z gnus-tmp-unread-and-unselected ?s)
1393 (?V gnus-version ?s)
1394 (?U gnus-tmp-unread-and-unticked ?d)
1395 (?S gnus-tmp-subject ?s)
1396 (?e gnus-tmp-unselected ?d)
1397 (?u gnus-tmp-user-defined ?s)
1398 (?d (length gnus-newsgroup-dormant) ?d)
1399 (?t (length gnus-newsgroup-marked) ?d)
23f87bed 1400 (?h (length gnus-newsgroup-spam-marked) ?d)
eec82323 1401 (?r (length gnus-newsgroup-reads) ?d)
6748645f 1402 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
eec82323
LMI
1403 (?E gnus-newsgroup-expunged-tally ?d)
1404 (?s (gnus-current-score-file-nondirectory) ?s)))
1405
c1717fbd
GM
1406;; This is here rather than in gnus-art for compilation reasons.
1407(defvar gnus-article-mode-line-format-alist
1408 (nconc '((?w (gnus-article-wash-status) ?s)
1409 (?m (gnus-article-mime-part-status) ?s))
1410 gnus-summary-mode-line-format-alist))
1411
eec82323
LMI
1412(defvar gnus-last-search-regexp nil
1413 "Default regexp for article search command.")
1414
1415(defvar gnus-last-shell-command nil
1416 "Default shell command on article.")
1417
23f87bed
MB
1418(defvar gnus-newsgroup-agentized nil
1419 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
eec82323
LMI
1420(defvar gnus-newsgroup-begin nil)
1421(defvar gnus-newsgroup-end nil)
1422(defvar gnus-newsgroup-last-rmail nil)
1423(defvar gnus-newsgroup-last-mail nil)
1424(defvar gnus-newsgroup-last-folder nil)
1425(defvar gnus-newsgroup-last-file nil)
26c9afc3 1426(defvar gnus-newsgroup-last-directory nil)
eec82323
LMI
1427(defvar gnus-newsgroup-auto-expire nil)
1428(defvar gnus-newsgroup-active nil)
1429
1430(defvar gnus-newsgroup-data nil)
1431(defvar gnus-newsgroup-data-reverse nil)
1432(defvar gnus-newsgroup-limit nil)
1433(defvar gnus-newsgroup-limits nil)
23f87bed 1434(defvar gnus-summary-use-undownloaded-faces nil)
eec82323
LMI
1435
1436(defvar gnus-newsgroup-unreads nil
23f87bed 1437 "Sorted list of unread articles in the current newsgroup.")
eec82323
LMI
1438
1439(defvar gnus-newsgroup-unselected nil
23f87bed 1440 "Sorted list of unselected unread articles in the current newsgroup.")
eec82323
LMI
1441
1442(defvar gnus-newsgroup-reads nil
1443 "Alist of read articles and article marks in the current newsgroup.")
1444
1445(defvar gnus-newsgroup-expunged-tally nil)
1446
1447(defvar gnus-newsgroup-marked nil
23f87bed
MB
1448 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1449
1450(defvar gnus-newsgroup-spam-marked nil
1451 "List of ranges of articles that have been marked as spam.")
eec82323
LMI
1452
1453(defvar gnus-newsgroup-killed nil
1454 "List of ranges of articles that have been through the scoring process.")
1455
1456(defvar gnus-newsgroup-cached nil
23f87bed 1457 "Sorted list of articles that come from the article cache.")
eec82323
LMI
1458
1459(defvar gnus-newsgroup-saved nil
1460 "List of articles that have been saved.")
1461
1462(defvar gnus-newsgroup-kill-headers nil)
1463
1464(defvar gnus-newsgroup-replied nil
1465 "List of articles that have been replied to in the current newsgroup.")
1466
23f87bed
MB
1467(defvar gnus-newsgroup-forwarded nil
1468 "List of articles that have been forwarded in the current newsgroup.")
1469
1470(defvar gnus-newsgroup-recent nil
1471 "List of articles that have are recent in the current newsgroup.")
1472
eec82323 1473(defvar gnus-newsgroup-expirable nil
23f87bed 1474 "Sorted list of articles in the current newsgroup that can be expired.")
eec82323
LMI
1475
1476(defvar gnus-newsgroup-processable nil
1477 "List of articles in the current newsgroup that can be processed.")
1478
6748645f 1479(defvar gnus-newsgroup-downloadable nil
23f87bed
MB
1480 "Sorted list of articles in the current newsgroup that can be processed.")
1481
1482(defvar gnus-newsgroup-unfetched nil
1483 "Sorted list of articles in the current newsgroup whose headers have
1484not been fetched into the agent.
1485
1486This list will always be a subset of gnus-newsgroup-undownloaded.")
6748645f
LMI
1487
1488(defvar gnus-newsgroup-undownloaded nil
23f87bed 1489 "List of articles in the current newsgroup that haven't been downloaded.")
6748645f
LMI
1490
1491(defvar gnus-newsgroup-unsendable nil
1492 "List of articles in the current newsgroup that won't be sent.")
1493
eec82323
LMI
1494(defvar gnus-newsgroup-bookmarks nil
1495 "List of articles in the current newsgroup that have bookmarks.")
1496
1497(defvar gnus-newsgroup-dormant nil
23f87bed
MB
1498 "Sorted list of dormant articles in the current newsgroup.")
1499
1500(defvar gnus-newsgroup-unseen nil
1501 "List of unseen articles in the current newsgroup.")
1502
1503(defvar gnus-newsgroup-seen nil
1504 "Range of seen articles in the current newsgroup.")
1505
1506(defvar gnus-newsgroup-articles nil
1507 "List of articles in the current newsgroup.")
eec82323
LMI
1508
1509(defvar gnus-newsgroup-scored nil
1510 "List of scored articles in the current newsgroup.")
1511
1512(defvar gnus-newsgroup-headers nil
1513 "List of article headers in the current newsgroup.")
1514
1515(defvar gnus-newsgroup-threads nil)
1516
1517(defvar gnus-newsgroup-prepared nil
1518 "Whether the current group has been prepared properly.")
1519
1520(defvar gnus-newsgroup-ancient nil
1521 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1522
1523(defvar gnus-newsgroup-sparse nil)
1524
1525(defvar gnus-current-article nil)
1526(defvar gnus-article-current nil)
1527(defvar gnus-current-headers nil)
1528(defvar gnus-have-all-headers nil)
1529(defvar gnus-last-article nil)
1530(defvar gnus-newsgroup-history nil)
16409b0b
GM
1531(defvar gnus-newsgroup-charset nil)
1532(defvar gnus-newsgroup-ephemeral-charset nil)
1533(defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
eec82323 1534
23f87bed
MB
1535(defvar gnus-article-before-search nil)
1536
1537(defvar gnus-summary-local-variables
eec82323
LMI
1538 '(gnus-newsgroup-name
1539 gnus-newsgroup-begin gnus-newsgroup-end
1540 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1541 gnus-newsgroup-last-folder gnus-newsgroup-last-file
26c9afc3 1542 gnus-newsgroup-last-directory
eec82323
LMI
1543 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1544 gnus-newsgroup-unselected gnus-newsgroup-marked
23f87bed 1545 gnus-newsgroup-spam-marked
eec82323 1546 gnus-newsgroup-reads gnus-newsgroup-saved
23f87bed
MB
1547 gnus-newsgroup-replied gnus-newsgroup-forwarded
1548 gnus-newsgroup-recent
1549 gnus-newsgroup-expirable
eec82323 1550 gnus-newsgroup-processable gnus-newsgroup-killed
6748645f 1551 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
23f87bed
MB
1552 gnus-newsgroup-unfetched
1553 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1554 gnus-newsgroup-seen gnus-newsgroup-articles
eec82323
LMI
1555 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1556 gnus-newsgroup-headers gnus-newsgroup-threads
1557 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1558 gnus-current-article gnus-current-headers gnus-have-all-headers
1559 gnus-last-article gnus-article-internal-prepare-hook
1560 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1561 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1562 gnus-thread-expunge-below
16409b0b
GM
1563 gnus-score-alist gnus-current-score-file
1564 (gnus-summary-expunge-below . global)
eec82323 1565 (gnus-summary-mark-below . global)
16409b0b 1566 (gnus-orphan-score . global)
eec82323
LMI
1567 gnus-newsgroup-active gnus-scores-exclude-files
1568 gnus-newsgroup-history gnus-newsgroup-ancient
1569 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1570 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1571 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1572 (gnus-newsgroup-expunged-tally . 0)
1573 gnus-cache-removable-articles gnus-newsgroup-cached
1574 gnus-newsgroup-data gnus-newsgroup-data-reverse
16409b0b 1575 gnus-newsgroup-limit gnus-newsgroup-limits
23f87bed
MB
1576 gnus-newsgroup-charset gnus-newsgroup-display
1577 gnus-summary-use-undownloaded-faces)
eec82323
LMI
1578 "Variables that are buffer-local to the summary buffers.")
1579
23f87bed
MB
1580(defvar gnus-newsgroup-variables nil
1581 "A list of variables that have separate values in different newsgroups.
1582A list of newsgroup (summary buffer) local variables, or cons of
1583variables and their default expressions to be evalled (when the default
1584values are not nil), that should be made global while the summary buffer
1585is active.
1586
1587Note: The default expressions will be evaluated (using function `eval')
1588before assignment to the local variable rather than just assigned to it.
1589If the default expression is the symbol `global', that symbol will not
1590be evaluated but the global value of the local variable will be used
1591instead.
1592
1593These variables can be used to set variables in the group parameters
1594while still allowing them to affect operations done in other buffers.
1595For example:
1596
1597\(setq gnus-newsgroup-variables
1598 '(message-use-followup-to
1599 (gnus-visible-headers .
1600 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1601")
1602
23f87bed
MB
1603(eval-when-compile
1604 ;; Bind features so that require will believe that gnus-sum has
1605 ;; already been loaded (avoids infinite recursion)
1606 (let ((features (cons 'gnus-sum features)))
23f87bed 1607 (require 'gnus-art)))
eec82323 1608
16409b0b
GM
1609;; MIME stuff.
1610
1611(defvar gnus-decode-encoded-word-methods
1612 '(mail-decode-encoded-word-string)
1613 "List of methods used to decode encoded words.
1614
23f87bed
MB
1615This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1616is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1617\(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
16409b0b
GM
1618whose names match REGEXP.
1619
1620For example:
23f87bed 1621\((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
16409b0b
GM
1622 mail-decode-encoded-word-string
1623 (\"chinese\" . rfc1843-decode-string))")
1624
1625(defvar gnus-decode-encoded-word-methods-cache nil)
1626
1627(defun gnus-multi-decode-encoded-word-string (string)
1628 "Apply the functions from `gnus-encoded-word-methods' that match."
1629 (unless (and gnus-decode-encoded-word-methods-cache
1630 (eq gnus-newsgroup-name
1631 (car gnus-decode-encoded-word-methods-cache)))
1632 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
01c52d31
MB
1633 (dolist (method gnus-decode-encoded-word-methods)
1634 (if (symbolp method)
1635 (nconc gnus-decode-encoded-word-methods-cache (list method))
1636 (if (and gnus-newsgroup-name
1637 (string-match (car method) gnus-newsgroup-name))
1638 (nconc gnus-decode-encoded-word-methods-cache
1639 (list (cdr method)))))))
1640 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1641 (setq string (funcall method string))))
16409b0b 1642
eec82323
LMI
1643;; Subject simplification.
1644
6748645f 1645(defun gnus-simplify-whitespace (str)
16409b0b 1646 "Remove excessive whitespace from STR."
23f87bed
MB
1647 ;; Multiple spaces.
1648 (while (string-match "[ \t][ \t]+" str)
1649 (setq str (concat (substring str 0 (match-beginning 0))
1650 " "
1651 (substring str (match-end 0)))))
1652 ;; Leading spaces.
1653 (when (string-match "^[ \t]+" str)
1654 (setq str (substring str (match-end 0))))
1655 ;; Trailing spaces.
1656 (when (string-match "[ \t]+$" str)
1657 (setq str (substring str 0 (match-beginning 0))))
1658 str)
1659
1660(defun gnus-simplify-all-whitespace (str)
1661 "Remove all whitespace from STR."
1662 (while (string-match "[ \t\n]+" str)
1663 (setq str (replace-match "" nil nil str)))
1664 str)
6748645f 1665
eec82323
LMI
1666(defsubst gnus-simplify-subject-re (subject)
1667 "Remove \"Re:\" from subject lines."
23f87bed 1668 (if (string-match message-subject-re-regexp subject)
eec82323
LMI
1669 (substring subject (match-end 0))
1670 subject))
1671
1672(defun gnus-simplify-subject (subject &optional re-only)
1673 "Remove `Re:' and words in parentheses.
1674If RE-ONLY is non-nil, strip leading `Re:'s only."
1675 (let ((case-fold-search t)) ;Ignore case.
1676 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1677 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1678 (setq subject (substring subject (match-end 0))))
1679 ;; Remove uninteresting prefixes.
1680 (when (and (not re-only)
1681 gnus-simplify-ignored-prefixes
1682 (string-match gnus-simplify-ignored-prefixes subject))
1683 (setq subject (substring subject (match-end 0))))
1684 ;; Remove words in parentheses from end.
1685 (unless re-only
1686 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1687 (setq subject (substring subject 0 (match-beginning 0)))))
1688 ;; Return subject string.
1689 subject))
1690
1691;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1692;; all whitespace.
1693(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1694 (goto-char (point-min))
1695 (while (re-search-forward regexp nil t)
16409b0b 1696 (replace-match (or newtext ""))))
eec82323
LMI
1697
1698(defun gnus-simplify-buffer-fuzzy ()
1699 "Simplify string in the buffer fuzzily.
1700The string in the accessible portion of the current buffer is simplified.
1701It is assumed to be a single-line subject.
1702Whitespace is generally cleaned up, and miscellaneous leading/trailing
1703matter is removed. Additional things can be deleted by setting
16409b0b 1704`gnus-simplify-subject-fuzzy-regexp'."
eec82323
LMI
1705 (let ((case-fold-search t)
1706 (modified-tick))
1707 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1708
1709 (while (not (eq modified-tick (buffer-modified-tick)))
1710 (setq modified-tick (buffer-modified-tick))
1711 (cond
1712 ((listp gnus-simplify-subject-fuzzy-regexp)
01c52d31
MB
1713 (mapc 'gnus-simplify-buffer-fuzzy-step
1714 gnus-simplify-subject-fuzzy-regexp))
eec82323
LMI
1715 (gnus-simplify-subject-fuzzy-regexp
1716 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1717 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1718 (gnus-simplify-buffer-fuzzy-step
1719 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1720 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1721
1722 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1723 (gnus-simplify-buffer-fuzzy-step " +" " ")
1724 (gnus-simplify-buffer-fuzzy-step " $")
1725 (gnus-simplify-buffer-fuzzy-step "^ +")))
1726
1727(defun gnus-simplify-subject-fuzzy (subject)
1728 "Simplify a subject string fuzzily.
6748645f 1729See `gnus-simplify-buffer-fuzzy' for details."
eec82323
LMI
1730 (save-excursion
1731 (gnus-set-work-buffer)
1732 (let ((case-fold-search t))
6748645f
LMI
1733 ;; Remove uninteresting prefixes.
1734 (when (and gnus-simplify-ignored-prefixes
1735 (string-match gnus-simplify-ignored-prefixes subject))
1736 (setq subject (substring subject (match-end 0))))
eec82323
LMI
1737 (insert subject)
1738 (inline (gnus-simplify-buffer-fuzzy))
1739 (buffer-string))))
1740
1741(defsubst gnus-simplify-subject-fully (subject)
23f87bed 1742 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
eec82323 1743 (cond
6748645f
LMI
1744 (gnus-simplify-subject-functions
1745 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1746 ((null gnus-summary-gather-subject-limit)
1747 (gnus-simplify-subject-re subject))
1748 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1749 (gnus-simplify-subject-fuzzy subject))
1750 ((numberp gnus-summary-gather-subject-limit)
01c52d31
MB
1751 (truncate-string-to-width (gnus-simplify-subject-re subject)
1752 gnus-summary-gather-subject-limit))
eec82323
LMI
1753 (t
1754 subject)))
1755
1756(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f 1757 "Check whether two subjects are equal.
23f87bed 1758If optional argument SIMPLE-FIRST is t, first argument is already
6748645f 1759simplified."
eec82323
LMI
1760 (cond
1761 ((null simple-first)
1762 (equal (gnus-simplify-subject-fully s1)
1763 (gnus-simplify-subject-fully s2)))
1764 (t
1765 (equal s1
1766 (gnus-simplify-subject-fully s2)))))
1767
1768(defun gnus-summary-bubble-group ()
1769 "Increase the score of the current group.
1770This is a handy function to add to `gnus-summary-exit-hook' to
1771increase the score of each group you read."
1772 (gnus-group-add-score gnus-newsgroup-name))
1773
1774\f
1775;;;
1776;;; Gnus summary mode
1777;;;
1778
1779(put 'gnus-summary-mode 'mode-class 'special)
1780
1653df0f
SZ
1781(defvar gnus-article-commands-menu)
1782
23f87bed
MB
1783;; Non-orthogonal keys
1784
1785(gnus-define-keys gnus-summary-mode-map
1786 " " gnus-summary-next-page
1787 "\177" gnus-summary-prev-page
1788 [delete] gnus-summary-prev-page
1789 [backspace] gnus-summary-prev-page
1790 "\r" gnus-summary-scroll-up
1791 "\M-\r" gnus-summary-scroll-down
1792 "n" gnus-summary-next-unread-article
1793 "p" gnus-summary-prev-unread-article
1794 "N" gnus-summary-next-article
1795 "P" gnus-summary-prev-article
1796 "\M-\C-n" gnus-summary-next-same-subject
1797 "\M-\C-p" gnus-summary-prev-same-subject
1798 "\M-n" gnus-summary-next-unread-subject
1799 "\M-p" gnus-summary-prev-unread-subject
1800 "." gnus-summary-first-unread-article
1801 "," gnus-summary-best-unread-article
1802 "\M-s" gnus-summary-search-article-forward
1803 "\M-r" gnus-summary-search-article-backward
01c52d31
MB
1804 "\M-S" gnus-summary-repeat-search-article-forward
1805 "\M-R" gnus-summary-repeat-search-article-backward
23f87bed
MB
1806 "<" gnus-summary-beginning-of-article
1807 ">" gnus-summary-end-of-article
1808 "j" gnus-summary-goto-article
1809 "^" gnus-summary-refer-parent-article
1810 "\M-^" gnus-summary-refer-article
1811 "u" gnus-summary-tick-article-forward
1812 "!" gnus-summary-tick-article-forward
1813 "U" gnus-summary-tick-article-backward
1814 "d" gnus-summary-mark-as-read-forward
1815 "D" gnus-summary-mark-as-read-backward
1816 "E" gnus-summary-mark-as-expirable
1817 "\M-u" gnus-summary-clear-mark-forward
1818 "\M-U" gnus-summary-clear-mark-backward
1819 "k" gnus-summary-kill-same-subject-and-select
1820 "\C-k" gnus-summary-kill-same-subject
1821 "\M-\C-k" gnus-summary-kill-thread
1822 "\M-\C-l" gnus-summary-lower-thread
1823 "e" gnus-summary-edit-article
1824 "#" gnus-summary-mark-as-processable
1825 "\M-#" gnus-summary-unmark-as-processable
1826 "\M-\C-t" gnus-summary-toggle-threads
1827 "\M-\C-s" gnus-summary-show-thread
1828 "\M-\C-h" gnus-summary-hide-thread
1829 "\M-\C-f" gnus-summary-next-thread
1830 "\M-\C-b" gnus-summary-prev-thread
1831 [(meta down)] gnus-summary-next-thread
1832 [(meta up)] gnus-summary-prev-thread
1833 "\M-\C-u" gnus-summary-up-thread
1834 "\M-\C-d" gnus-summary-down-thread
1835 "&" gnus-summary-execute-command
1836 "c" gnus-summary-catchup-and-exit
1837 "\C-w" gnus-summary-mark-region-as-read
1838 "\C-t" gnus-summary-toggle-truncation
1839 "?" gnus-summary-mark-as-dormant
1840 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1841 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6ecfe5c2 1842 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
23f87bed
MB
1843 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1844 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1845 "\C-c\C-s\C-a" gnus-summary-sort-by-author
01c52d31 1846 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
23f87bed
MB
1847 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1848 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6ecfe5c2 1849 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
23f87bed
MB
1850 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1851 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1852 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1853 "=" gnus-summary-expand-window
1854 "\C-x\C-s" gnus-summary-reselect-current-group
1855 "\M-g" gnus-summary-rescan-group
1856 "w" gnus-summary-stop-page-breaking
1857 "\C-c\C-r" gnus-summary-caesar-message
1858 "f" gnus-summary-followup
1859 "F" gnus-summary-followup-with-original
1860 "C" gnus-summary-cancel-article
1861 "r" gnus-summary-reply
1862 "R" gnus-summary-reply-with-original
1863 "\C-c\C-f" gnus-summary-mail-forward
1864 "o" gnus-summary-save-article
1865 "\C-o" gnus-summary-save-article-mail
1866 "|" gnus-summary-pipe-output
1867 "\M-k" gnus-summary-edit-local-kill
1868 "\M-K" gnus-summary-edit-global-kill
1869 ;; "V" gnus-version
1870 "\C-c\C-d" gnus-summary-describe-group
1871 "q" gnus-summary-exit
1872 "Q" gnus-summary-exit-no-update
1873 "\C-c\C-i" gnus-info-find-node
1874 gnus-mouse-2 gnus-mouse-pick-article
132cf96d 1875 [follow-link] mouse-face
23f87bed
MB
1876 "m" gnus-summary-mail-other-window
1877 "a" gnus-summary-post-news
1878 "i" gnus-summary-news-other-window
1879 "x" gnus-summary-limit-to-unread
1880 "s" gnus-summary-isearch-article
1881 "t" gnus-summary-toggle-header
1882 "g" gnus-summary-show-article
1883 "l" gnus-summary-goto-last-article
1884 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1885 "\C-d" gnus-summary-enter-digest-group
1886 "\M-\C-d" gnus-summary-read-document
1887 "\M-\C-e" gnus-summary-edit-parameters
1888 "\M-\C-a" gnus-summary-customize-parameters
1889 "\C-c\C-b" gnus-bug
1890 "*" gnus-cache-enter-article
1891 "\M-*" gnus-cache-remove-article
1892 "\M-&" gnus-summary-universal-argument
1893 "\C-l" gnus-recenter
1894 "I" gnus-summary-increase-score
1895 "L" gnus-summary-lower-score
1896 "\M-i" gnus-symbolic-argument
1897 "h" gnus-summary-select-article-buffer
1898
1899 "b" gnus-article-view-part
1900 "\M-t" gnus-summary-toggle-display-buttonized
1901
1902 "V" gnus-summary-score-map
1903 "X" gnus-uu-extract-map
1904 "S" gnus-summary-send-map)
1905
1906;; Sort of orthogonal keymap
1907(gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1908 "t" gnus-summary-tick-article-forward
1909 "!" gnus-summary-tick-article-forward
1910 "d" gnus-summary-mark-as-read-forward
1911 "r" gnus-summary-mark-as-read-forward
1912 "c" gnus-summary-clear-mark-forward
1913 " " gnus-summary-clear-mark-forward
1914 "e" gnus-summary-mark-as-expirable
1915 "x" gnus-summary-mark-as-expirable
1916 "?" gnus-summary-mark-as-dormant
1917 "b" gnus-summary-set-bookmark
1918 "B" gnus-summary-remove-bookmark
1919 "#" gnus-summary-mark-as-processable
1920 "\M-#" gnus-summary-unmark-as-processable
1921 "S" gnus-summary-limit-include-expunged
1922 "C" gnus-summary-catchup
1923 "H" gnus-summary-catchup-to-here
1924 "h" gnus-summary-catchup-from-here
1925 "\C-c" gnus-summary-catchup-all
1926 "k" gnus-summary-kill-same-subject-and-select
1927 "K" gnus-summary-kill-same-subject
1928 "P" gnus-uu-mark-map)
1929
1930(gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1931 "c" gnus-summary-clear-above
1932 "u" gnus-summary-tick-above
1933 "m" gnus-summary-mark-above
1934 "k" gnus-summary-kill-below)
1935
1936(gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1937 "/" gnus-summary-limit-to-subject
1938 "n" gnus-summary-limit-to-articles
01c52d31
MB
1939 "b" gnus-summary-limit-to-bodies
1940 "h" gnus-summary-limit-to-headers
23f87bed
MB
1941 "w" gnus-summary-pop-limit
1942 "s" gnus-summary-limit-to-subject
1943 "a" gnus-summary-limit-to-author
1944 "u" gnus-summary-limit-to-unread
1945 "m" gnus-summary-limit-to-marks
1946 "M" gnus-summary-limit-exclude-marks
1947 "v" gnus-summary-limit-to-score
1948 "*" gnus-summary-limit-include-cached
1949 "D" gnus-summary-limit-include-dormant
1950 "T" gnus-summary-limit-include-thread
1951 "d" gnus-summary-limit-exclude-dormant
1952 "t" gnus-summary-limit-to-age
1953 "." gnus-summary-limit-to-unseen
1954 "x" gnus-summary-limit-to-extra
1955 "p" gnus-summary-limit-to-display-predicate
1956 "E" gnus-summary-limit-include-expunged
1957 "c" gnus-summary-limit-exclude-childless-dormant
1958 "C" gnus-summary-limit-mark-excluded-as-read
1959 "o" gnus-summary-insert-old-articles
01c52d31
MB
1960 "N" gnus-summary-insert-new-articles
1961 "S" gnus-summary-limit-to-singletons
1962 "r" gnus-summary-limit-to-replied
1963 "R" gnus-summary-limit-to-recipient
1964 "A" gnus-summary-limit-to-address)
23f87bed
MB
1965
1966(gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1967 "n" gnus-summary-next-unread-article
1968 "p" gnus-summary-prev-unread-article
1969 "N" gnus-summary-next-article
1970 "P" gnus-summary-prev-article
1971 "\C-n" gnus-summary-next-same-subject
1972 "\C-p" gnus-summary-prev-same-subject
1973 "\M-n" gnus-summary-next-unread-subject
1974 "\M-p" gnus-summary-prev-unread-subject
1975 "f" gnus-summary-first-unread-article
1976 "b" gnus-summary-best-unread-article
1977 "j" gnus-summary-goto-article
1978 "g" gnus-summary-goto-subject
1979 "l" gnus-summary-goto-last-article
1980 "o" gnus-summary-pop-article)
1981
1982(gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1983 "k" gnus-summary-kill-thread
01c52d31 1984 "E" gnus-summary-expire-thread
23f87bed
MB
1985 "l" gnus-summary-lower-thread
1986 "i" gnus-summary-raise-thread
1987 "T" gnus-summary-toggle-threads
1988 "t" gnus-summary-rethread-current
1989 "^" gnus-summary-reparent-thread
01c52d31 1990 "\M-^" gnus-summary-reparent-children
23f87bed
MB
1991 "s" gnus-summary-show-thread
1992 "S" gnus-summary-show-all-threads
1993 "h" gnus-summary-hide-thread
1994 "H" gnus-summary-hide-all-threads
1995 "n" gnus-summary-next-thread
1996 "p" gnus-summary-prev-thread
1997 "u" gnus-summary-up-thread
1998 "o" gnus-summary-top-thread
1999 "d" gnus-summary-down-thread
2000 "#" gnus-uu-mark-thread
2001 "\M-#" gnus-uu-unmark-thread)
2002
2003(gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2004 "g" gnus-summary-prepare
2005 "c" gnus-summary-insert-cached-articles
01c52d31
MB
2006 "d" gnus-summary-insert-dormant-articles
2007 "t" gnus-summary-insert-ticked-articles)
23f87bed
MB
2008
2009(gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2010 "c" gnus-summary-catchup-and-exit
2011 "C" gnus-summary-catchup-all-and-exit
2012 "E" gnus-summary-exit-no-update
2013 "Q" gnus-summary-exit
2014 "Z" gnus-summary-exit
2015 "n" gnus-summary-catchup-and-goto-next-group
01c52d31 2016 "p" gnus-summary-catchup-and-goto-prev-group
23f87bed
MB
2017 "R" gnus-summary-reselect-current-group
2018 "G" gnus-summary-rescan-group
2019 "N" gnus-summary-next-group
2020 "s" gnus-summary-save-newsrc
2021 "P" gnus-summary-prev-group)
2022
2023(gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2024 " " gnus-summary-next-page
2025 "n" gnus-summary-next-page
2026 "\177" gnus-summary-prev-page
2027 [delete] gnus-summary-prev-page
2028 "p" gnus-summary-prev-page
2029 "\r" gnus-summary-scroll-up
2030 "\M-\r" gnus-summary-scroll-down
2031 "<" gnus-summary-beginning-of-article
2032 ">" gnus-summary-end-of-article
2033 "b" gnus-summary-beginning-of-article
2034 "e" gnus-summary-end-of-article
2035 "^" gnus-summary-refer-parent-article
2036 "r" gnus-summary-refer-parent-article
2037 "D" gnus-summary-enter-digest-group
2038 "R" gnus-summary-refer-references
2039 "T" gnus-summary-refer-thread
2040 "g" gnus-summary-show-article
2041 "s" gnus-summary-isearch-article
2042 "P" gnus-summary-print-article
01c52d31 2043 "S" gnus-sticky-article
23f87bed
MB
2044 "M" gnus-mailing-list-insinuate
2045 "t" gnus-article-babel)
2046
2047(gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2048 "b" gnus-article-add-buttons
2049 "B" gnus-article-add-buttons-to-head
2050 "o" gnus-article-treat-overstrike
2051 "e" gnus-article-emphasize
2052 "w" gnus-article-fill-cited-article
2053 "Q" gnus-article-fill-long-lines
01c52d31 2054 "L" gnus-article-toggle-truncate-lines
23f87bed
MB
2055 "C" gnus-article-capitalize-sentences
2056 "c" gnus-article-remove-cr
2057 "q" gnus-article-de-quoted-unreadable
2058 "6" gnus-article-de-base64-unreadable
2059 "Z" gnus-article-decode-HZ
01c52d31 2060 "A" gnus-article-treat-ansi-sequences
23f87bed
MB
2061 "h" gnus-article-wash-html
2062 "u" gnus-article-unsplit-urls
2063 "s" gnus-summary-force-verify-and-decrypt
2064 "f" gnus-article-display-x-face
2065 "l" gnus-summary-stop-page-breaking
2066 "r" gnus-summary-caesar-message
2067 "m" gnus-summary-morse-message
2068 "t" gnus-summary-toggle-header
2069 "g" gnus-treat-smiley
2070 "v" gnus-summary-verbose-headers
2071 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2072 "p" gnus-article-verify-x-pgp-sig
01c52d31
MB
2073 "d" gnus-article-treat-dumbquotes
2074 "i" gnus-summary-idna-message)
23f87bed
MB
2075
2076(gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2077 ;; mnemonic: deuglif*Y*
2078 "u" gnus-article-outlook-unwrap-lines
2079 "a" gnus-article-outlook-repair-attribution
2080 "c" gnus-article-outlook-rearrange-citation
2081 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2082
2083(gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2084 "a" gnus-article-hide
2085 "h" gnus-article-hide-headers
2086 "b" gnus-article-hide-boring-headers
2087 "s" gnus-article-hide-signature
2088 "c" gnus-article-hide-citation
2089 "C" gnus-article-hide-citation-in-followups
2090 "l" gnus-article-hide-list-identifiers
2091 "B" gnus-article-strip-banner
2092 "P" gnus-article-hide-pem
2093 "\C-c" gnus-article-hide-citation-maybe)
2094
2095(gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2096 "a" gnus-article-highlight
2097 "h" gnus-article-highlight-headers
2098 "c" gnus-article-highlight-citation
2099 "s" gnus-article-highlight-signature)
2100
2101(gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2102 "f" gnus-article-treat-fold-headers
2103 "u" gnus-article-treat-unfold-headers
2104 "n" gnus-article-treat-fold-newsgroups)
2105
2106(gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2107 "x" gnus-article-display-x-face
2108 "d" gnus-article-display-face
2109 "s" gnus-treat-smiley
2110 "D" gnus-article-remove-images
2111 "f" gnus-treat-from-picon
2112 "m" gnus-treat-mail-picon
2113 "n" gnus-treat-newsgroups-picon)
2114
2115(gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2116 "w" gnus-article-decode-mime-words
2117 "c" gnus-article-decode-charset
2118 "v" gnus-mime-view-all-parts
2119 "b" gnus-article-view-part)
2120
2121(gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2122 "z" gnus-article-date-ut
2123 "u" gnus-article-date-ut
2124 "l" gnus-article-date-local
2125 "p" gnus-article-date-english
2126 "e" gnus-article-date-lapsed
2127 "o" gnus-article-date-original
2128 "i" gnus-article-date-iso8601
2129 "s" gnus-article-date-user)
2130
2131(gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2132 "t" gnus-article-remove-trailing-blank-lines
2133 "l" gnus-article-strip-leading-blank-lines
2134 "m" gnus-article-strip-multiple-blank-lines
2135 "a" gnus-article-strip-blank-lines
2136 "A" gnus-article-strip-all-blank-lines
2137 "s" gnus-article-strip-leading-space
2138 "e" gnus-article-strip-trailing-space
2139 "w" gnus-article-remove-leading-whitespace)
2140
2141(gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2142 "v" gnus-version
2143 "f" gnus-summary-fetch-faq
2144 "d" gnus-summary-describe-group
2145 "h" gnus-summary-describe-briefly
2146 "i" gnus-info-find-node
2147 "c" gnus-group-fetch-charter
2148 "C" gnus-group-fetch-control)
2149
2150(gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2151 "e" gnus-summary-expire-articles
2152 "\M-\C-e" gnus-summary-expire-articles-now
2153 "\177" gnus-summary-delete-article
2154 [delete] gnus-summary-delete-article
2155 [backspace] gnus-summary-delete-article
2156 "m" gnus-summary-move-article
2157 "r" gnus-summary-respool-article
2158 "w" gnus-summary-edit-article
2159 "c" gnus-summary-copy-article
2160 "B" gnus-summary-crosspost-article
2161 "q" gnus-summary-respool-query
2162 "t" gnus-summary-respool-trace
2163 "i" gnus-summary-import-article
2164 "I" gnus-summary-create-article
2165 "p" gnus-summary-article-posted-p)
2166
2167(gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2168 "o" gnus-summary-save-article
2169 "m" gnus-summary-save-article-mail
2170 "F" gnus-summary-write-article-file
2171 "r" gnus-summary-save-article-rmail
2172 "f" gnus-summary-save-article-file
2173 "b" gnus-summary-save-article-body-file
26c9afc3 2174 "B" gnus-summary-write-article-body-file
23f87bed
MB
2175 "h" gnus-summary-save-article-folder
2176 "v" gnus-summary-save-article-vm
2177 "p" gnus-summary-pipe-output
2178 "P" gnus-summary-muttprint
2179 "s" gnus-soup-add-article)
2180
2181(gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2182 "b" gnus-summary-display-buttonized
2183 "m" gnus-summary-repair-multipart
2184 "v" gnus-article-view-part
2185 "o" gnus-article-save-part
01c52d31
MB
2186 "O" gnus-article-save-part-and-strip
2187 "r" gnus-article-replace-part
2188 "d" gnus-article-delete-part
2189 "t" gnus-article-view-part-as-type
2190 "j" gnus-article-jump-to-part
23f87bed
MB
2191 "c" gnus-article-copy-part
2192 "C" gnus-article-view-part-as-charset
2193 "e" gnus-article-view-part-externally
01c52d31 2194 "H" gnus-article-browse-html-article
23f87bed
MB
2195 "E" gnus-article-encrypt-body
2196 "i" gnus-article-inline-part
2197 "|" gnus-article-pipe-part)
2198
2199(gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2200 "p" gnus-summary-mark-as-processable
2201 "u" gnus-summary-unmark-as-processable
2202 "U" gnus-summary-unmark-all-processable
2203 "v" gnus-uu-mark-over
2204 "s" gnus-uu-mark-series
2205 "r" gnus-uu-mark-region
2206 "g" gnus-uu-unmark-region
2207 "R" gnus-uu-mark-by-regexp
2208 "G" gnus-uu-unmark-by-regexp
2209 "t" gnus-uu-mark-thread
2210 "T" gnus-uu-unmark-thread
2211 "a" gnus-uu-mark-all
2212 "b" gnus-uu-mark-buffer
2213 "S" gnus-uu-mark-sparse
2214 "k" gnus-summary-kill-process-mark
2215 "y" gnus-summary-yank-process-mark
2216 "w" gnus-summary-save-process-mark
2217 "i" gnus-uu-invert-processable)
2218
2219(gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2220 ;;"x" gnus-uu-extract-any
2221 "m" gnus-summary-save-parts
2222 "u" gnus-uu-decode-uu
2223 "U" gnus-uu-decode-uu-and-save
2224 "s" gnus-uu-decode-unshar
2225 "S" gnus-uu-decode-unshar-and-save
2226 "o" gnus-uu-decode-save
2227 "O" gnus-uu-decode-save
2228 "b" gnus-uu-decode-binhex
2229 "B" gnus-uu-decode-binhex
b890d447 2230 "Y" gnus-uu-decode-yenc
23f87bed
MB
2231 "p" gnus-uu-decode-postscript
2232 "P" gnus-uu-decode-postscript-and-save)
2233
2234(gnus-define-keys
2235 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2236 "u" gnus-uu-decode-uu-view
2237 "U" gnus-uu-decode-uu-and-save-view
2238 "s" gnus-uu-decode-unshar-view
2239 "S" gnus-uu-decode-unshar-and-save-view
2240 "o" gnus-uu-decode-save-view
2241 "O" gnus-uu-decode-save-view
2242 "b" gnus-uu-decode-binhex-view
2243 "B" gnus-uu-decode-binhex-view
2244 "p" gnus-uu-decode-postscript-view
2245 "P" gnus-uu-decode-postscript-and-save-view)
2246
2247(defvar gnus-article-post-menu nil)
2248
2249(defconst gnus-summary-menu-maxlen 20)
2250
2251(defun gnus-summary-menu-split (menu)
2252 ;; If we have lots of elements, divide them into groups of 20
2253 ;; and make a pane (or submenu) for each one.
2254 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2255 (let ((menu menu) sublists next
2256 (i 1))
2257 (while menu
2258 ;; Pull off the next gnus-summary-menu-maxlen elements
2259 ;; and make them the next element of sublist.
2260 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2261 (if next
2262 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2263 nil))
2264 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2265 (aref (car (last menu)) 0)) menu)
2266 sublists))
2267 (setq i (1+ i))
2268 (setq menu next))
2269 (nreverse sublists))
2270 ;; Few elements--put them all in one pane.
2271 menu))
eec82323
LMI
2272
2273(defun gnus-summary-make-menu-bar ()
2274 (gnus-turn-off-edit-menu 'summary)
2275
2276 (unless (boundp 'gnus-summary-misc-menu)
2277
2278 (easy-menu-define
23f87bed
MB
2279 gnus-summary-kill-menu gnus-summary-mode-map ""
2280 (cons
2281 "Score"
2282 (nconc
2283 (list
2284 ["Customize" gnus-score-customize t])
2285 (gnus-make-score-map 'increase)
2286 (gnus-make-score-map 'lower)
2287 '(("Mark"
2288 ["Kill below" gnus-summary-kill-below t]
2289 ["Mark above" gnus-summary-mark-above t]
2290 ["Tick above" gnus-summary-tick-above t]
2291 ["Clear above" gnus-summary-clear-above t])
2292 ["Current score" gnus-summary-current-score t]
2293 ["Set score" gnus-summary-set-score t]
2294 ["Switch current score file..." gnus-score-change-score-file t]
2295 ["Set mark below..." gnus-score-set-mark-below t]
2296 ["Set expunge below..." gnus-score-set-expunge-below t]
2297 ["Edit current score file" gnus-score-edit-current-scores t]
59429511 2298 ["Edit score file..." gnus-score-edit-file t]
23f87bed
MB
2299 ["Trace score" gnus-score-find-trace t]
2300 ["Find words" gnus-score-find-favourite-words t]
2301 ["Rescore buffer" gnus-summary-rescore t]
2302 ["Increase score..." gnus-summary-increase-score t]
2303 ["Lower score..." gnus-summary-lower-score t]))))
2304
2305 ;; Define both the Article menu in the summary buffer and the
2306 ;; equivalent Commands menu in the article buffer here for
2307 ;; consistency.
6748645f 2308 (let ((innards
23f87bed
MB
2309 `(("Hide"
2310 ["All" gnus-article-hide t]
2311 ["Headers" gnus-article-hide-headers t]
2312 ["Signature" gnus-article-hide-signature t]
2313 ["Citation" gnus-article-hide-citation t]
16409b0b 2314 ["List identifiers" gnus-article-hide-list-identifiers t]
16409b0b 2315 ["Banner" gnus-article-strip-banner t]
23f87bed
MB
2316 ["Boring headers" gnus-article-hide-boring-headers t])
2317 ("Highlight"
2318 ["All" gnus-article-highlight t]
2319 ["Headers" gnus-article-highlight-headers t]
2320 ["Signature" gnus-article-highlight-signature t]
2321 ["Citation" gnus-article-highlight-citation t])
16409b0b
GM
2322 ("MIME"
2323 ["Words" gnus-article-decode-mime-words t]
2324 ["Charset" gnus-article-decode-charset t]
2325 ["QP" gnus-article-de-quoted-unreadable t]
2326 ["Base64" gnus-article-de-base64-unreadable t]
23f87bed
MB
2327 ["View MIME buttons" gnus-summary-display-buttonized t]
2328 ["View all" gnus-mime-view-all-parts t]
2329 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2330 ["Encrypt body" gnus-article-encrypt-body
2331 :active (not (gnus-group-read-only-p))
2332 ,@(if (featurep 'xemacs) nil
2333 '(:help "Encrypt the message body on disk"))]
2334 ["Extract all parts..." gnus-summary-save-parts t]
2335 ("Multipart"
2336 ["Repair multipart" gnus-summary-repair-multipart t]
2337 ["Pipe part..." gnus-article-pipe-part t]
2338 ["Inline part" gnus-article-inline-part t]
01c52d31 2339 ["View part as type..." gnus-article-view-part-as-type t]
23f87bed
MB
2340 ["Encrypt body" gnus-article-encrypt-body
2341 :active (not (gnus-group-read-only-p))
2342 ,@(if (featurep 'xemacs) nil
2343 '(:help "Encrypt the message body on disk"))]
2344 ["View part externally" gnus-article-view-part-externally t]
01c52d31 2345 ["View HTML parts in browser" gnus-article-browse-html-article t]
23f87bed
MB
2346 ["View part with charset..." gnus-article-view-part-as-charset t]
2347 ["Copy part" gnus-article-copy-part t]
2348 ["Save part..." gnus-article-save-part t]
2349 ["View part" gnus-article-view-part t]))
2350 ("Date"
2351 ["Local" gnus-article-date-local t]
2352 ["ISO8601" gnus-article-date-iso8601 t]
2353 ["UT" gnus-article-date-ut t]
2354 ["Original" gnus-article-date-original t]
2355 ["Lapsed" gnus-article-date-lapsed t]
2356 ["User-defined" gnus-article-date-user t])
2357 ("Display"
2358 ["Remove images" gnus-article-remove-images t]
2359 ["Toggle smiley" gnus-treat-smiley t]
2360 ["Show X-Face" gnus-article-display-x-face t]
2361 ["Show picons in From" gnus-treat-from-picon t]
2362 ["Show picons in mail headers" gnus-treat-mail-picon t]
2363 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2364 ("View as different encoding"
2365 ,@(gnus-summary-menu-split
2366 (mapcar
2367 (lambda (cs)
2368 ;; Since easymenu under Emacs doesn't allow
2369 ;; lambda forms for menu commands, we should
2370 ;; provide intern'ed function symbols.
2371 (let ((command (intern (format "\
2372gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2373 (fset command
2374 `(lambda ()
2375 (interactive)
2376 (let ((gnus-summary-show-article-charset-alist
2377 '((1 . ,cs))))
2378 (gnus-summary-show-article 1))))
2379 `[,(symbol-name cs) ,command t]))
2380 (sort (if (fboundp 'coding-system-list)
2381 (coding-system-list)
2382 (mapcar 'car mm-mime-mule-charset-alist))
2383 'string<)))))
2384 ("Washing"
2385 ("Remove Blanks"
2386 ["Leading" gnus-article-strip-leading-blank-lines t]
2387 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2388 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2389 ["All of the above" gnus-article-strip-blank-lines t]
2390 ["All" gnus-article-strip-all-blank-lines t]
2391 ["Leading space" gnus-article-strip-leading-space t]
2392 ["Trailing space" gnus-article-strip-trailing-space t]
2393 ["Leading space in headers"
2394 gnus-article-remove-leading-whitespace t])
2395 ["Overstrike" gnus-article-treat-overstrike t]
2396 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2397 ["Emphasis" gnus-article-emphasize t]
2398 ["Word wrap" gnus-article-fill-cited-article t]
16409b0b 2399 ["Fill long lines" gnus-article-fill-long-lines t]
01c52d31 2400 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
16409b0b 2401 ["Capitalize sentences" gnus-article-capitalize-sentences t]
23f87bed
MB
2402 ["Remove CR" gnus-article-remove-cr t]
2403 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2404 ["Base64" gnus-article-de-base64-unreadable t]
2405 ["Rot 13" gnus-summary-caesar-message
2406 ,@(if (featurep 'xemacs) '(t)
2407 '(:help "\"Caesar rotate\" article by 13"))]
01c52d31 2408 ["De-IDNA" gnus-summary-idna-message t]
23f87bed
MB
2409 ["Morse decode" gnus-summary-morse-message t]
2410 ["Unix pipe..." gnus-summary-pipe-message t]
2411 ["Add buttons" gnus-article-add-buttons t]
2412 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2413 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2414 ["Verbose header" gnus-summary-verbose-headers t]
2415 ["Toggle header" gnus-summary-toggle-header t]
2416 ["Unfold headers" gnus-article-treat-unfold-headers t]
2417 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
16409b0b 2418 ["Html" gnus-article-wash-html t]
23f87bed
MB
2419 ["Unsplit URLs" gnus-article-unsplit-urls t]
2420 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2421 ["Decode HZ" gnus-article-decode-HZ t]
01c52d31 2422 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
23f87bed
MB
2423 ("(Outlook) Deuglify"
2424 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2425 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2426 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2427 ["Full (Outlook) deuglify"
2428 gnus-article-outlook-deuglify-article t])
2429 )
2430 ("Output"
2431 ["Save in default format..." gnus-summary-save-article
2432 ,@(if (featurep 'xemacs) '(t)
2433 '(:help "Save article using default method"))]
2434 ["Save in file..." gnus-summary-save-article-file
2435 ,@(if (featurep 'xemacs) '(t)
2436 '(:help "Save article in file"))]
2437 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2438 ["Save in MH folder..." gnus-summary-save-article-folder t]
2439 ["Save in VM folder..." gnus-summary-save-article-vm t]
2440 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2441 ["Save body in file..." gnus-summary-save-article-body-file t]
2442 ["Pipe through a filter..." gnus-summary-pipe-output t]
2443 ["Add to SOUP packet" gnus-soup-add-article t]
2444 ["Print with Muttprint..." gnus-summary-muttprint t]
531e5812
MB
2445 ["Print" gnus-summary-print-article
2446 ,@(if (featurep 'xemacs) '(t)
2447 '(:help "Generate and print a PostScript image"))])
2448 ("Copy, move,... (Backend)"
707f2b38 2449 ,@(if (featurep 'xemacs) nil
531e5812 2450 '(:help "Copying, moving, expiring articles..."))
23f87bed
MB
2451 ["Respool article..." gnus-summary-respool-article t]
2452 ["Move article..." gnus-summary-move-article
2453 (gnus-check-backend-function
2454 'request-move-article gnus-newsgroup-name)]
2455 ["Copy article..." gnus-summary-copy-article t]
2456 ["Crosspost article..." gnus-summary-crosspost-article
2457 (gnus-check-backend-function
2458 'request-replace-article gnus-newsgroup-name)]
2459 ["Import file..." gnus-summary-import-article
2460 (gnus-check-backend-function
2461 'request-accept-article gnus-newsgroup-name)]
2462 ["Create article..." gnus-summary-create-article
2463 (gnus-check-backend-function
2464 'request-accept-article gnus-newsgroup-name)]
2465 ["Check if posted" gnus-summary-article-posted-p t]
2466 ["Edit article" gnus-summary-edit-article
2467 (not (gnus-group-read-only-p))]
2468 ["Delete article" gnus-summary-delete-article
2469 (gnus-check-backend-function
2470 'request-expire-articles gnus-newsgroup-name)]
2471 ["Query respool" gnus-summary-respool-query t]
6748645f 2472 ["Trace respool" gnus-summary-respool-trace t]
23f87bed
MB
2473 ["Delete expirable articles" gnus-summary-expire-articles-now
2474 (gnus-check-backend-function
2475 'request-expire-articles gnus-newsgroup-name)])
2476 ("Extract"
2477 ["Uudecode" gnus-uu-decode-uu
2478 ,@(if (featurep 'xemacs) '(t)
2479 '(:help "Decode uuencoded article(s)"))]
2480 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2481 ["Unshar" gnus-uu-decode-unshar t]
2482 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2483 ["Save" gnus-uu-decode-save t]
2484 ["Binhex" gnus-uu-decode-binhex t]
2485 ["Postscript" gnus-uu-decode-postscript t]
2486 ["All MIME parts" gnus-summary-save-parts t])
2487 ("Cache"
2488 ["Enter article" gnus-cache-enter-article t]
2489 ["Remove article" gnus-cache-remove-article t])
16409b0b 2490 ["Translate" gnus-article-babel t]
23f87bed 2491 ["Select article buffer" gnus-summary-select-article-buffer t]
01c52d31 2492 ["Make article buffer sticky" gnus-sticky-article t]
23f87bed
MB
2493 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2494 ["Isearch article..." gnus-summary-isearch-article t]
2495 ["Beginning of the article" gnus-summary-beginning-of-article t]
2496 ["End of the article" gnus-summary-end-of-article t]
2497 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2498 ["Fetch referenced articles" gnus-summary-refer-references t]
2499 ["Fetch current thread" gnus-summary-refer-thread t]
2500 ["Fetch article with id..." gnus-summary-refer-article t]
2501 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2502 ["Redisplay" gnus-summary-show-article t]
2503 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
6748645f 2504 (easy-menu-define
23f87bed
MB
2505 gnus-summary-article-menu gnus-summary-mode-map ""
2506 (cons "Article" innards))
6748645f 2507
1653df0f
SZ
2508 (if (not (keymapp gnus-summary-article-menu))
2509 (easy-menu-define
2510 gnus-article-commands-menu gnus-article-mode-map ""
2511 (cons "Commands" innards))
2512 ;; in Emacs, don't share menu.
a1506d29 2513 (setq gnus-article-commands-menu
1653df0f
SZ
2514 (copy-keymap gnus-summary-article-menu))
2515 (define-key gnus-article-mode-map [menu-bar commands]
2516 (cons "Commands" gnus-article-commands-menu))))
eec82323
LMI
2517
2518 (easy-menu-define
23f87bed
MB
2519 gnus-summary-thread-menu gnus-summary-mode-map ""
2520 '("Threads"
2521 ["Find all messages in thread" gnus-summary-refer-thread t]
2522 ["Toggle threading" gnus-summary-toggle-threads t]
2523 ["Hide threads" gnus-summary-hide-all-threads t]
2524 ["Show threads" gnus-summary-show-all-threads t]
2525 ["Hide thread" gnus-summary-hide-thread t]
2526 ["Show thread" gnus-summary-show-thread t]
2527 ["Go to next thread" gnus-summary-next-thread t]
2528 ["Go to previous thread" gnus-summary-prev-thread t]
2529 ["Go down thread" gnus-summary-down-thread t]
2530 ["Go up thread" gnus-summary-up-thread t]
2531 ["Top of thread" gnus-summary-top-thread t]
2532 ["Mark thread as read" gnus-summary-kill-thread t]
01c52d31 2533 ["Mark thread as expired" gnus-summary-expire-thread t]
23f87bed
MB
2534 ["Lower thread score" gnus-summary-lower-thread t]
2535 ["Raise thread score" gnus-summary-raise-thread t]
2536 ["Rethread current" gnus-summary-rethread-current t]))
eec82323
LMI
2537
2538 (easy-menu-define
23f87bed
MB
2539 gnus-summary-post-menu gnus-summary-mode-map ""
2540 `("Post"
2541 ["Send a message (mail or news)" gnus-summary-post-news
2542 ,@(if (featurep 'xemacs) '(t)
531e5812 2543 '(:help "Compose a new message (mail or news)"))]
23f87bed
MB
2544 ["Followup" gnus-summary-followup
2545 ,@(if (featurep 'xemacs) '(t)
2546 '(:help "Post followup to this article"))]
2547 ["Followup and yank" gnus-summary-followup-with-original
2548 ,@(if (featurep 'xemacs) '(t)
2549 '(:help "Post followup to this article, quoting its contents"))]
2550 ["Supersede article" gnus-summary-supersede-article t]
2551 ["Cancel article" gnus-summary-cancel-article
2552 ,@(if (featurep 'xemacs) '(t)
2553 '(:help "Cancel an article you posted"))]
2554 ["Reply" gnus-summary-reply t]
2555 ["Reply and yank" gnus-summary-reply-with-original t]
2556 ["Wide reply" gnus-summary-wide-reply t]
2557 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2558 ,@(if (featurep 'xemacs) '(t)
2559 '(:help "Mail a reply, quoting this article"))]
2560 ["Very wide reply" gnus-summary-very-wide-reply t]
2561 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2562 ,@(if (featurep 'xemacs) '(t)
2563 '(:help "Mail a very wide reply, quoting this article"))]
2564 ["Mail forward" gnus-summary-mail-forward t]
2565 ["Post forward" gnus-summary-post-forward t]
2566 ["Digest and mail" gnus-uu-digest-mail-forward t]
2567 ["Digest and post" gnus-uu-digest-post-forward t]
2568 ["Resend message" gnus-summary-resend-message t]
2569 ["Resend message edit" gnus-summary-resend-message-edit t]
2570 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2571 ["Send a mail" gnus-summary-mail-other-window t]
2572 ["Create a local message" gnus-summary-news-other-window t]
2573 ["Uuencode and post" gnus-uu-post-news
2574 ,@(if (featurep 'xemacs) '(t)
2575 '(:help "Post a uuencoded article"))]
2576 ["Followup via news" gnus-summary-followup-to-mail t]
2577 ["Followup via news and yank"
2578 gnus-summary-followup-to-mail-with-original t]
9b3ebcb6
MB
2579 ["Strip signature on reply"
2580 (lambda ()
2581 (interactive)
2582 (if (not (memq message-cite-function
2583 '(message-cite-original-without-signature
2584 message-cite-original)))
2585 ;; Stupid workaround for XEmacs not honoring :visible.
2586 (message "Can't toggle this value of `message-cite-function'")
2587 (setq message-cite-function
2588 (if (eq message-cite-function
2589 'message-cite-original-without-signature)
2590 'message-cite-original
2591 'message-cite-original-without-signature))))
2592 ;; XEmacs barfs on :visible.
2593 ,@(if (featurep 'xemacs) nil
2594 '(:visible (memq message-cite-function
2595 '(message-cite-original-without-signature
2596 message-cite-original))))
2597 :style toggle
2598 :selected (eq message-cite-function
2599 'message-cite-original-without-signature)
2600 ,@(if (featurep 'xemacs) nil
2601 '(:help "Strip signature from cited article when replying."))]
23f87bed
MB
2602 ;;("Draft"
2603 ;;["Send" gnus-summary-send-draft t]
2604 ;;["Send bounced" gnus-resend-bounced-mail t])
2605 ))
2606
2607 (cond
2608 ((not (keymapp gnus-summary-post-menu))
2609 (setq gnus-article-post-menu gnus-summary-post-menu))
2610 ((not gnus-article-post-menu)
2611 ;; Don't share post menu.
2612 (setq gnus-article-post-menu
2613 (copy-keymap gnus-summary-post-menu))))
2614 (define-key gnus-article-mode-map [menu-bar post]
2615 (cons "Post" gnus-article-post-menu))
eec82323
LMI
2616
2617 (easy-menu-define
23f87bed
MB
2618 gnus-summary-misc-menu gnus-summary-mode-map ""
2619 `("Gnus"
2620 ("Mark Read"
2621 ["Mark as read" gnus-summary-mark-as-read-forward t]
2622 ["Mark same subject and select"
2623 gnus-summary-kill-same-subject-and-select t]
2624 ["Mark same subject" gnus-summary-kill-same-subject t]
2625 ["Catchup" gnus-summary-catchup
2626 ,@(if (featurep 'xemacs) '(t)
2627 '(:help "Mark unread articles in this group as read"))]
2628 ["Catchup all" gnus-summary-catchup-all t]
2629 ["Catchup to here" gnus-summary-catchup-to-here t]
2630 ["Catchup from here" gnus-summary-catchup-from-here t]
2631 ["Catchup region" gnus-summary-mark-region-as-read
2632 (gnus-mark-active-p)]
2633 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2634 ("Mark Various"
2635 ["Tick" gnus-summary-tick-article-forward t]
2636 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2637 ["Remove marks" gnus-summary-clear-mark-forward t]
2638 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2639 ["Set bookmark" gnus-summary-set-bookmark t]
2640 ["Remove bookmark" gnus-summary-remove-bookmark t])
2641 ("Limit to"
2642 ["Marks..." gnus-summary-limit-to-marks t]
2643 ["Subject..." gnus-summary-limit-to-subject t]
2644 ["Author..." gnus-summary-limit-to-author t]
01c52d31
MB
2645 ["Recipient..." gnus-summary-limit-to-recipient t]
2646 ["Address..." gnus-summary-limit-to-address t]
23f87bed
MB
2647 ["Age..." gnus-summary-limit-to-age t]
2648 ["Extra..." gnus-summary-limit-to-extra t]
2649 ["Score..." gnus-summary-limit-to-score t]
2650 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2651 ["Unread" gnus-summary-limit-to-unread t]
2652 ["Unseen" gnus-summary-limit-to-unseen t]
01c52d31
MB
2653 ["Singletons" gnus-summary-limit-to-singletons t]
2654 ["Replied" gnus-summary-limit-to-replied t]
23f87bed 2655 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
996aa8c1 2656 ["Next or process marked articles" gnus-summary-limit-to-articles t]
23f87bed
MB
2657 ["Pop limit" gnus-summary-pop-limit t]
2658 ["Show dormant" gnus-summary-limit-include-dormant t]
2659 ["Hide childless dormant"
2660 gnus-summary-limit-exclude-childless-dormant t]
2661 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2662 ["Hide marked" gnus-summary-limit-exclude-marks t]
2663 ["Show expunged" gnus-summary-limit-include-expunged t])
2664 ("Process Mark"
2665 ["Set mark" gnus-summary-mark-as-processable t]
2666 ["Remove mark" gnus-summary-unmark-as-processable t]
2667 ["Remove all marks" gnus-summary-unmark-all-processable t]
01c52d31 2668 ["Invert marks" gnus-uu-invert-processable t]
23f87bed
MB
2669 ["Mark above" gnus-uu-mark-over t]
2670 ["Mark series" gnus-uu-mark-series t]
2671 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2672 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2673 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2674 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2675 ["Mark all" gnus-uu-mark-all t]
2676 ["Mark buffer" gnus-uu-mark-buffer t]
2677 ["Mark sparse" gnus-uu-mark-sparse t]
2678 ["Mark thread" gnus-uu-mark-thread t]
2679 ["Unmark thread" gnus-uu-unmark-thread t]
2680 ("Process Mark Sets"
2681 ["Kill" gnus-summary-kill-process-mark t]
2682 ["Yank" gnus-summary-yank-process-mark
2683 gnus-newsgroup-process-stack]
2684 ["Save" gnus-summary-save-process-mark t]
2685 ["Run command on marked..." gnus-summary-universal-argument t]))
ec7995fa 2686 ("Registry Marks")
23f87bed
MB
2687 ("Scroll article"
2688 ["Page forward" gnus-summary-next-page
2689 ,@(if (featurep 'xemacs) '(t)
2690 '(:help "Show next page of article"))]
2691 ["Page backward" gnus-summary-prev-page
2692 ,@(if (featurep 'xemacs) '(t)
2693 '(:help "Show previous page of article"))]
2694 ["Line forward" gnus-summary-scroll-up t])
2695 ("Move"
2696 ["Next unread article" gnus-summary-next-unread-article t]
2697 ["Previous unread article" gnus-summary-prev-unread-article t]
2698 ["Next article" gnus-summary-next-article t]
2699 ["Previous article" gnus-summary-prev-article t]
2700 ["Next unread subject" gnus-summary-next-unread-subject t]
2701 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2702 ["Next article same subject" gnus-summary-next-same-subject t]
2703 ["Previous article same subject" gnus-summary-prev-same-subject t]
2704 ["First unread article" gnus-summary-first-unread-article t]
2705 ["Best unread article" gnus-summary-best-unread-article t]
2706 ["Go to subject number..." gnus-summary-goto-subject t]
2707 ["Go to article number..." gnus-summary-goto-article t]
2708 ["Go to the last article" gnus-summary-goto-last-article t]
2709 ["Pop article off history" gnus-summary-pop-article t])
2710 ("Sort"
2711 ["Sort by number" gnus-summary-sort-by-number t]
6ecfe5c2 2712 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
23f87bed 2713 ["Sort by author" gnus-summary-sort-by-author t]
01c52d31 2714 ["Sort by recipient" gnus-summary-sort-by-recipient t]
23f87bed
MB
2715 ["Sort by subject" gnus-summary-sort-by-subject t]
2716 ["Sort by date" gnus-summary-sort-by-date t]
6ecfe5c2 2717 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
23f87bed
MB
2718 ["Sort by score" gnus-summary-sort-by-score t]
2719 ["Sort by lines" gnus-summary-sort-by-lines t]
2720 ["Sort by characters" gnus-summary-sort-by-chars t]
2721 ["Randomize" gnus-summary-sort-by-random t]
2722 ["Original sort" gnus-summary-sort-by-original t])
2723 ("Help"
2724 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2725 ["Describe group" gnus-summary-describe-group t]
2726 ["Fetch charter" gnus-group-fetch-charter
2727 ,@(if (featurep 'xemacs) nil
2728 '(:help "Display the charter of the current group"))]
2729 ["Fetch control message" gnus-group-fetch-control
2730 ,@(if (featurep 'xemacs) nil
2731 '(:help "Display the archived control message for the current group"))]
2732 ["Read manual" gnus-info-find-node t])
2733 ("Modes"
2734 ["Pick and read" gnus-pick-mode t]
2735 ["Binary" gnus-binary-mode t])
2736 ("Regeneration"
2737 ["Regenerate" gnus-summary-prepare t]
2738 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2739 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
01c52d31 2740 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
23f87bed
MB
2741 ["Toggle threading" gnus-summary-toggle-threads t])
2742 ["See old articles" gnus-summary-insert-old-articles t]
2743 ["See new articles" gnus-summary-insert-new-articles t]
2744 ["Filter articles..." gnus-summary-execute-command t]
2745 ["Run command on articles..." gnus-summary-universal-argument t]
2746 ["Search articles forward..." gnus-summary-search-article-forward t]
2747 ["Search articles backward..." gnus-summary-search-article-backward t]
2748 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2749 ["Expand window" gnus-summary-expand-window t]
2750 ["Expire expirable articles" gnus-summary-expire-articles
2751 (gnus-check-backend-function
2752 'request-expire-articles gnus-newsgroup-name)]
2753 ["Edit local kill file" gnus-summary-edit-local-kill t]
2754 ["Edit main kill file" gnus-summary-edit-global-kill t]
2755 ["Edit group parameters" gnus-summary-edit-parameters t]
2756 ["Customize group parameters" gnus-summary-customize-parameters t]
2757 ["Send a bug report" gnus-bug t]
2758 ("Exit"
2759 ["Catchup and exit" gnus-summary-catchup-and-exit
2760 ,@(if (featurep 'xemacs) '(t)
2761 '(:help "Mark unread articles in this group as read, then exit"))]
2762 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2763 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
01c52d31 2764 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
23f87bed
MB
2765 ["Exit group" gnus-summary-exit
2766 ,@(if (featurep 'xemacs) '(t)
2767 '(:help "Exit current group, return to group selection mode"))]
2768 ["Exit group without updating" gnus-summary-exit-no-update t]
2769 ["Exit and goto next group" gnus-summary-next-group t]
2770 ["Exit and goto prev group" gnus-summary-prev-group t]
2771 ["Reselect group" gnus-summary-reselect-current-group t]
2772 ["Rescan group" gnus-summary-rescan-group t]
2773 ["Update dribble" gnus-summary-save-newsrc t])))
eec82323 2774
6748645f 2775 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323 2776
60bd5589
DL
2777(defvar gnus-summary-tool-bar-map nil)
2778
18c06a99
RS
2779;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2780;; affect _new_ message buffers. We might add a function that walks thru all
2781;; summary-mode buffers and force the update.
2782(defun gnus-summary-tool-bar-update (&optional symbol value)
2783 "Update summary mode toolbar.
2784Setter function for custom variables."
2785 (setq-default gnus-summary-tool-bar-map nil)
2786 (when symbol
2787 ;; When used as ":set" function:
2788 (set-default symbol value))
2789 (when (gnus-buffer-live-p gnus-summary-buffer)
2790 (with-current-buffer gnus-summary-buffer
2791 (gnus-summary-make-tool-bar))))
2792
2793(defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2794 'gnus-summary-tool-bar-gnome
2795 'gnus-summary-tool-bar-retro)
2796 "Specifies the Gnus summary tool bar.
2797
2798It can be either a list or a symbol refering to a list. See
2799`gmm-tool-bar-from-list' for the format of the list. The
2800default key map is `gnus-summary-mode-map'.
2801
2802Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2803`gnus-summary-tool-bar-retro'."
2804 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2805 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2806 (repeat :tag "User defined list" gmm-tool-bar-item)
2807 (symbol))
330f707b 2808 :version "23.1" ;; No Gnus
18c06a99
RS
2809 :initialize 'custom-initialize-default
2810 :set 'gnus-summary-tool-bar-update
2811 :group 'gnus-summary)
2812
2813(defcustom gnus-summary-tool-bar-gnome
2814 '((gnus-summary-post-news "mail/compose" nil)
2815 (gnus-summary-insert-new-articles "mail/inbox" nil
2816 :visible (or (not gnus-agent)
2817 gnus-plugged))
2818 (gnus-summary-reply-with-original "mail/reply")
2819 (gnus-summary-reply "mail/reply" nil :visible nil)
2820 (gnus-summary-followup-with-original "mail/reply-all")
2821 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2822 (gnus-summary-mail-forward "mail/forward")
2823 (gnus-summary-save-article "mail/save")
2824 (gnus-summary-search-article-forward "search" nil :visible nil)
2825 (gnus-summary-print-article "print")
2826 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2827 ;; Some new commands that may need more suitable icons:
2828 (gnus-summary-save-newsrc "save" nil :visible nil)
2829 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2830 (gnus-summary-prev-article "left-arrow")
2831 (gnus-summary-next-article "right-arrow")
2832 (gnus-summary-next-page "next-page")
2833 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2834 ;;
2835 ;; Maybe some sort-by-... could be added:
2836 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2837 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2838 (gnus-summary-mark-as-expirable
2839 "delete" nil
2840 :visible (gnus-check-backend-function 'request-expire-articles
2841 gnus-newsgroup-name))
2842 (gnus-summary-mark-as-spam
2843 "mail/spam" t
2844 :visible (and (fboundp 'spam-group-ham-contents-p)
2845 (spam-group-ham-contents-p gnus-newsgroup-name))
2846 :help "Mark as spam")
2847 (gnus-summary-mark-as-read-forward
2848 "mail/not-spam" nil
2849 :visible (and (fboundp 'spam-group-spam-contents-p)
2850 (spam-group-spam-contents-p gnus-newsgroup-name)))
2851 ;;
2852 (gnus-summary-exit "exit")
2853 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2854 (gnus-info-find-node "help"))
2855 "List of functions for the summary tool bar (GNOME style).
2856
2857See `gmm-tool-bar-from-list' for the format of the list."
2858 :type '(repeat gmm-tool-bar-item)
330f707b 2859 :version "23.1" ;; No Gnus
18c06a99
RS
2860 :initialize 'custom-initialize-default
2861 :set 'gnus-summary-tool-bar-update
2862 :group 'gnus-summary)
2863
2864(defcustom gnus-summary-tool-bar-retro
2865 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2866 (gnus-summary-next-unread-article "gnus/next-ur")
2867 (gnus-summary-post-news "gnus/post")
2868 (gnus-summary-followup-with-original "gnus/fuwo")
2869 (gnus-summary-followup "gnus/followup")
2870 (gnus-summary-reply-with-original "gnus/reply-wo")
2871 (gnus-summary-reply "gnus/reply")
2872 (gnus-summary-caesar-message "gnus/rot13")
2873 (gnus-uu-decode-uu "gnus/uu-decode")
2874 (gnus-summary-save-article-file "gnus/save-aif")
2875 (gnus-summary-save-article "gnus/save-art")
2876 (gnus-uu-post-news "gnus/uu-post")
2877 (gnus-summary-catchup "gnus/catchup")
2878 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2879 (gnus-summary-exit "gnus/exit-summ")
2880 ;; Some new command that may need more suitable icons:
2881 (gnus-summary-print-article "gnus/print" nil :visible nil)
2882 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2883 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2884 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2885 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2886 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2887 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2888 ;;
2889 (gnus-info-find-node "gnus/help" nil :visible nil))
2890 "List of functions for the summary tool bar (retro look).
2891
2892See `gmm-tool-bar-from-list' for the format of the list."
2893 :type '(repeat gmm-tool-bar-item)
330f707b 2894 :version "23.1" ;; No Gnus
18c06a99
RS
2895 :initialize 'custom-initialize-default
2896 :set 'gnus-summary-tool-bar-update
2897 :group 'gnus-summary)
2898
2899(defcustom gnus-summary-tool-bar-zap-list t
2900 "List of icon items from the global tool bar.
2901These items are not displayed in the Gnus summary mode tool bar.
2902
2903See `gmm-tool-bar-from-list' for the format of the list."
2904 :type 'gmm-tool-bar-zap-list
330f707b 2905 :version "23.1" ;; No Gnus
18c06a99
RS
2906 :initialize 'custom-initialize-default
2907 :set 'gnus-summary-tool-bar-update
2908 :group 'gnus-summary)
2909
2910(defvar image-load-path)
f654fa04 2911(defvar tool-bar-map)
18c06a99
RS
2912
2913(defun gnus-summary-make-tool-bar (&optional force)
2914 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2915When FORCE, rebuild the tool bar."
2916 (when (and (not (featurep 'xemacs))
2917 (boundp 'tool-bar-mode)
2918 tool-bar-mode
2919 (or (not gnus-summary-tool-bar-map) force))
2920 (let* ((load-path
2921 (gmm-image-load-path-for-library "gnus"
2922 "mail/save.xpm"
2923 nil t))
2924 (image-load-path (cons (car load-path)
2925 (when (boundp 'image-load-path)
2926 image-load-path)))
2927 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2928 gnus-summary-tool-bar-zap-list
2929 'gnus-summary-mode-map)))
2930 (when map
2931 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2932 ;; uses it's value.
2933 (setq gnus-summary-tool-bar-map map))))
2934 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
60bd5589 2935
eec82323
LMI
2936(defun gnus-score-set-default (var value)
2937 "A version of set that updates the GNU Emacs menu-bar."
2938 (set var value)
2939 ;; It is the message that forces the active status to be updated.
2940 (message ""))
2941
2942(defun gnus-make-score-map (type)
2943 "Make a summary score map of type TYPE."
2944 (if t
2945 nil
2946 (let ((headers '(("author" "from" string)
2947 ("subject" "subject" string)
2948 ("article body" "body" string)
2949 ("article head" "head" string)
2950 ("xref" "xref" string)
16409b0b 2951 ("extra header" "extra" string)
eec82323
LMI
2952 ("lines" "lines" number)
2953 ("followups to author" "followup" string)))
2954 (types '((number ("less than" <)
2955 ("greater than" >)
2956 ("equal" =))
2957 (string ("substring" s)
2958 ("exact string" e)
2959 ("fuzzy string" f)
2960 ("regexp" r))))
2961 (perms '(("temporary" (current-time-string))
2962 ("permanent" nil)
2963 ("immediate" now)))
2964 header)
2965 (list
2966 (apply
2967 'nconc
2968 (list
2969 (if (eq type 'lower)
2970 "Lower score"
2971 "Increase score"))
2972 (let (outh)
2973 (while headers
2974 (setq header (car headers))
2975 (setq outh
2976 (cons
2977 (apply
2978 'nconc
2979 (list (car header))
2980 (let ((ts (cdr (assoc (nth 2 header) types)))
2981 outt)
2982 (while ts
2983 (setq outt
2984 (cons
2985 (apply
2986 'nconc
2987 (list (caar ts))
2988 (let ((ps perms)
2989 outp)
2990 (while ps
2991 (setq outp
2992 (cons
2993 (vector
2994 (caar ps)
2995 (list
2996 'gnus-summary-score-entry
2997 (nth 1 header)
2998 (if (or (string= (nth 1 header)
2999 "head")
3000 (string= (nth 1 header)
3001 "body"))
3002 ""
3003 (list 'gnus-summary-header
3004 (nth 1 header)))
3005 (list 'quote (nth 1 (car ts)))
16409b0b
GM
3006 (list 'gnus-score-delta-default
3007 nil)
eec82323
LMI
3008 (nth 1 (car ps))
3009 t)
3010 t)
3011 outp))
3012 (setq ps (cdr ps)))
3013 (list (nreverse outp))))
3014 outt))
3015 (setq ts (cdr ts)))
3016 (list (nreverse outt))))
3017 outh))
3018 (setq headers (cdr headers)))
3019 (list (nreverse outh))))))))
3020
704f1663
GM
3021
3022(declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
398a825b 3023(defvar bookmark-make-record-function)
eec82323
LMI
3024\f
3025
3026(defun gnus-summary-mode (&optional group)
3027 "Major mode for reading articles.
3028
3029All normal editing commands are switched off.
3030\\<gnus-summary-mode-map>
3031Each line in this buffer represents one article. To read an
3032article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3033and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3034respectively.
3035
3036You can also post articles and send mail from this buffer. To
23f87bed 3037follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
eec82323
LMI
3038of an article, type `\\[gnus-summary-reply]'.
3039
3040There are approx. one gazillion commands you can execute in this
3041buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3042
3043The following commands are available:
3044
3045\\{gnus-summary-mode-map}"
3046 (interactive)
eec82323 3047 (kill-all-local-variables)
01c52d31
MB
3048 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3049 (gnus-summary-make-local-variables))
3050 (gnus-summary-make-local-variables)
3051 (setq gnus-newsgroup-name group)
60bd5589
DL
3052 (when (gnus-visual-p 'summary-menu 'menu)
3053 (gnus-summary-make-menu-bar)
3054 (gnus-summary-make-tool-bar))
eec82323
LMI
3055 (gnus-make-thread-indent-array)
3056 (gnus-simplify-mode-line)
3057 (setq major-mode 'gnus-summary-mode)
3058 (setq mode-name "Summary")
eec82323 3059 (use-local-map gnus-summary-mode-map)
16409b0b 3060 (buffer-disable-undo)
01c52d31
MB
3061 (setq buffer-read-only t ;Disable modification
3062 show-trailing-whitespace nil)
eec82323 3063 (setq truncate-lines t)
9bfd9a76 3064 (add-to-invisibility-spec '(gnus-sum . t))
eec82323
LMI
3065 (gnus-summary-set-display-table)
3066 (gnus-set-default-directory)
eec82323
LMI
3067 (make-local-variable 'gnus-summary-line-format)
3068 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
3069 (make-local-variable 'gnus-summary-dummy-line-format)
3070 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323 3071 (make-local-variable 'gnus-summary-mark-positions)
23f87bed 3072 (gnus-make-local-hook 'pre-command-hook)
6748645f 3073 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
cfcd5c91 3074 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
23f87bed 3075 (turn-on-gnus-mailing-list-mode)
87545352 3076 (mm-enable-multibyte)
45be326a
TV
3077 (set (make-local-variable 'bookmark-make-record-function)
3078 'gnus-summary-bookmark-make-record)
eec82323
LMI
3079 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3080 (gnus-update-summary-mark-positions))
3081
3082(defun gnus-summary-make-local-variables ()
3083 "Make all the local summary buffer variables."
16409b0b
GM
3084 (let (global)
3085 (dolist (local gnus-summary-local-variables)
eec82323
LMI
3086 (if (consp local)
3087 (progn
3088 (if (eq (cdr local) 'global)
3089 ;; Copy the global value of the variable.
3090 (setq global (symbol-value (car local)))
3091 ;; Use the value from the list.
3092 (setq global (eval (cdr local))))
16409b0b 3093 (set (make-local-variable (car local)) global))
eec82323 3094 ;; Simple nil-valued local variable.
16409b0b 3095 (set (make-local-variable local) nil)))))
eec82323
LMI
3096
3097(defun gnus-summary-clear-local-variables ()
3098 (let ((locals gnus-summary-local-variables))
3099 (while locals
3100 (if (consp (car locals))
01c52d31 3101 (and (symbolp (caar locals))
eec82323 3102 (set (caar locals) nil))
01c52d31 3103 (and (symbolp (car locals))
eec82323
LMI
3104 (set (car locals) nil)))
3105 (setq locals (cdr locals)))))
3106
3107;; Summary data functions.
3108
3109(defmacro gnus-data-number (data)
3110 `(car ,data))
3111
3112(defmacro gnus-data-set-number (data number)
3113 `(setcar ,data ,number))
3114
3115(defmacro gnus-data-mark (data)
3116 `(nth 1 ,data))
3117
3118(defmacro gnus-data-set-mark (data mark)
3119 `(setcar (nthcdr 1 ,data) ,mark))
3120
3121(defmacro gnus-data-pos (data)
3122 `(nth 2 ,data))
3123
3124(defmacro gnus-data-set-pos (data pos)
3125 `(setcar (nthcdr 2 ,data) ,pos))
3126
3127(defmacro gnus-data-header (data)
3128 `(nth 3 ,data))
3129
3130(defmacro gnus-data-set-header (data header)
3131 `(setf (nth 3 ,data) ,header))
3132
3133(defmacro gnus-data-level (data)
3134 `(nth 4 ,data))
3135
3136(defmacro gnus-data-unread-p (data)
3137 `(= (nth 1 ,data) gnus-unread-mark))
3138
3139(defmacro gnus-data-read-p (data)
3140 `(/= (nth 1 ,data) gnus-unread-mark))
3141
3142(defmacro gnus-data-pseudo-p (data)
3143 `(consp (nth 3 ,data)))
3144
3145(defmacro gnus-data-find (number)
3146 `(assq ,number gnus-newsgroup-data))
3147
3148(defmacro gnus-data-find-list (number &optional data)
3149 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3150 (memq (assq ,number bdata)
3151 bdata)))
3152
3153(defmacro gnus-data-make (number mark pos header level)
3154 `(list ,number ,mark ,pos ,header ,level))
3155
3156(defun gnus-data-enter (after-article number mark pos header level offset)
3157 (let ((data (gnus-data-find-list after-article)))
3158 (unless data
3159 (error "No such article: %d" after-article))
3160 (setcdr data (cons (gnus-data-make number mark pos header level)
3161 (cdr data)))
3162 (setq gnus-newsgroup-data-reverse nil)
3163 (gnus-data-update-list (cddr data) offset)))
3164
3165(defun gnus-data-enter-list (after-article list &optional offset)
3166 (when list
3167 (let ((data (and after-article (gnus-data-find-list after-article)))
3168 (ilist list))
6748645f
LMI
3169 (if (not (or data
3170 after-article))
3171 (let ((odata gnus-newsgroup-data))
3172 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 3173 (when offset
6748645f 3174 (gnus-data-update-list odata offset)))
01c52d31 3175 ;; Find the last element in the list to be spliced into the main
6748645f 3176 ;; list.
01c52d31 3177 (setq list (last list))
6748645f
LMI
3178 (if (not data)
3179 (progn
3180 (setcdr list gnus-newsgroup-data)
3181 (setq gnus-newsgroup-data ilist)
3182 (when offset
3183 (gnus-data-update-list (cdr list) offset)))
3184 (setcdr list (cdr data))
3185 (setcdr data ilist)
3186 (when offset
3187 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
3188 (setq gnus-newsgroup-data-reverse nil))))
3189
3190(defun gnus-data-remove (article &optional offset)
3191 (let ((data gnus-newsgroup-data))
3192 (if (= (gnus-data-number (car data)) article)
3193 (progn
3194 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3195 gnus-newsgroup-data-reverse nil)
3196 (when offset
3197 (gnus-data-update-list gnus-newsgroup-data offset)))
3198 (while (cdr data)
3199 (when (= (gnus-data-number (cadr data)) article)
3200 (setcdr data (cddr data))
3201 (when offset
3202 (gnus-data-update-list (cdr data) offset))
3203 (setq data nil
3204 gnus-newsgroup-data-reverse nil))
3205 (setq data (cdr data))))))
3206
3207(defmacro gnus-data-list (backward)
3208 `(if ,backward
3209 (or gnus-newsgroup-data-reverse
3210 (setq gnus-newsgroup-data-reverse
3211 (reverse gnus-newsgroup-data)))
3212 gnus-newsgroup-data))
3213
3214(defun gnus-data-update-list (data offset)
3215 "Add OFFSET to the POS of all data entries in DATA."
6748645f 3216 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
3217 (while data
3218 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3219 (setq data (cdr data))))
3220
eec82323
LMI
3221(defun gnus-summary-article-pseudo-p (article)
3222 "Say whether this article is a pseudo article or not."
3223 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3224
3225(defmacro gnus-summary-article-sparse-p (article)
3226 "Say whether this article is a sparse article or not."
a8151ef7 3227 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
3228
3229(defmacro gnus-summary-article-ancient-p (article)
3230 "Say whether this article is a sparse article or not."
3231 `(memq ,article gnus-newsgroup-ancient))
3232
3233(defun gnus-article-parent-p (number)
3234 "Say whether this article is a parent or not."
3235 (let ((data (gnus-data-find-list number)))
23f87bed 3236 (and (cdr data) ; There has to be an article after...
eec82323
LMI
3237 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3238 (gnus-data-level (nth 1 data))))))
3239
3240(defun gnus-article-children (number)
3241 "Return a list of all children to NUMBER."
3242 (let* ((data (gnus-data-find-list number))
3243 (level (gnus-data-level (car data)))
3244 children)
3245 (setq data (cdr data))
3246 (while (and data
3247 (= (gnus-data-level (car data)) (1+ level)))
3248 (push (gnus-data-number (car data)) children)
3249 (setq data (cdr data)))
3250 children))
3251
3252(defmacro gnus-summary-skip-intangible ()
3253 "If the current article is intangible, then jump to a different article."
3254 '(let ((to (get-text-property (point) 'gnus-intangible)))
3255 (and to (gnus-summary-goto-subject to))))
3256
3257(defmacro gnus-summary-article-intangible-p ()
3258 "Say whether this article is intangible or not."
3259 '(get-text-property (point) 'gnus-intangible))
3260
3261(defun gnus-article-read-p (article)
3262 "Say whether ARTICLE is read or not."
3263 (not (or (memq article gnus-newsgroup-marked)
23f87bed 3264 (memq article gnus-newsgroup-spam-marked)
eec82323
LMI
3265 (memq article gnus-newsgroup-unreads)
3266 (memq article gnus-newsgroup-unselected)
3267 (memq article gnus-newsgroup-dormant))))
3268
3269;; Some summary mode macros.
3270
3271(defmacro gnus-summary-article-number ()
3272 "The article number of the article on the current line.
8f688cb0 3273If there isn't an article number here, then we return the current
eec82323
LMI
3274article number."
3275 '(progn
3276 (gnus-summary-skip-intangible)
3277 (or (get-text-property (point) 'gnus-number)
3278 (gnus-summary-last-subject))))
3279
3280(defmacro gnus-summary-article-header (&optional number)
6748645f 3281 "Return the header of article NUMBER."
eec82323
LMI
3282 `(gnus-data-header (gnus-data-find
3283 ,(or number '(gnus-summary-article-number)))))
3284
3285(defmacro gnus-summary-thread-level (&optional number)
6748645f 3286 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
3287 `(if (and (eq gnus-summary-make-false-root 'dummy)
3288 (get-text-property (point) 'gnus-intangible))
3289 0
3290 (gnus-data-level (gnus-data-find
3291 ,(or number '(gnus-summary-article-number))))))
3292
3293(defmacro gnus-summary-article-mark (&optional number)
6748645f 3294 "Return the mark of article NUMBER."
eec82323
LMI
3295 `(gnus-data-mark (gnus-data-find
3296 ,(or number '(gnus-summary-article-number)))))
3297
3298(defmacro gnus-summary-article-pos (&optional number)
6748645f 3299 "Return the position of the line of article NUMBER."
eec82323
LMI
3300 `(gnus-data-pos (gnus-data-find
3301 ,(or number '(gnus-summary-article-number)))))
3302
3303(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3304(defmacro gnus-summary-article-subject (&optional number)
3305 "Return current subject string or nil if nothing."
3306 `(let ((headers
3307 ,(if number
3308 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3309 '(gnus-data-header (assq (gnus-summary-article-number)
3310 gnus-newsgroup-data)))))
3311 (and headers
3312 (vectorp headers)
3313 (mail-header-subject headers))))
3314
3315(defmacro gnus-summary-article-score (&optional number)
3316 "Return current article score."
3317 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3318 gnus-newsgroup-scored))
3319 gnus-summary-default-score 0))
3320
3321(defun gnus-summary-article-children (&optional number)
6748645f 3322 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
3323 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3324 (level (gnus-data-level (car data)))
3325 l children)
3326 (while (and (setq data (cdr data))
3327 (> (setq l (gnus-data-level (car data))) level))
3328 (and (= (1+ level) l)
3329 (push (gnus-data-number (car data))
3330 children)))
3331 (nreverse children)))
3332
3333(defun gnus-summary-article-parent (&optional number)
6748645f 3334 "Return the article number of the parent of article NUMBER."
eec82323
LMI
3335 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3336 (gnus-data-list t)))
3337 (level (gnus-data-level (car data))))
3338 (if (zerop level)
3339 () ; This is a root.
3340 ;; We search until we find an article with a level less than
3341 ;; this one. That function has to be the parent.
3342 (while (and (setq data (cdr data))
3343 (not (< (gnus-data-level (car data)) level))))
3344 (and data (gnus-data-number (car data))))))
3345
3346(defun gnus-unread-mark-p (mark)
3347 "Say whether MARK is the unread mark."
3348 (= mark gnus-unread-mark))
3349
3350(defun gnus-read-mark-p (mark)
3351 "Say whether MARK is one of the marks that mark as read.
3352This is all marks except unread, ticked, dormant, and expirable."
3353 (not (or (= mark gnus-unread-mark)
3354 (= mark gnus-ticked-mark)
23f87bed 3355 (= mark gnus-spam-mark)
eec82323
LMI
3356 (= mark gnus-dormant-mark)
3357 (= mark gnus-expirable-mark))))
3358
3359(defmacro gnus-article-mark (number)
6748645f
LMI
3360 "Return the MARK of article NUMBER.
3361This macro should only be used when computing the mark the \"first\"
3362time; i.e., when generating the summary lines. After that,
3363`gnus-summary-article-mark' should be used to examine the
3364marks of articles."
eec82323 3365 `(cond
6748645f 3366 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
6748645f 3367 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
3368 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3369 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
23f87bed 3370 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
eec82323
LMI
3371 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3372 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3373 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3374 gnus-ancient-mark))))
3375
3376;; Saving hidden threads.
3377
eec82323
LMI
3378(defmacro gnus-save-hidden-threads (&rest forms)
3379 "Save hidden threads, eval FORMS, and restore the hidden threads."
3380 (let ((config (make-symbol "config")))
3381 `(let ((,config (gnus-hidden-threads-configuration)))
3382 (unwind-protect
3383 (save-excursion
3384 ,@forms)
3385 (gnus-restore-hidden-threads-configuration ,config)))))
23f87bed
MB
3386(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3387(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
eec82323 3388
107ecebb
AS
3389(defun gnus-data-compute-positions ()
3390 "Compute the positions of all articles."
3391 (setq gnus-newsgroup-data-reverse nil)
3392 (let ((data gnus-newsgroup-data))
3393 (save-excursion
3394 (gnus-save-hidden-threads
3395 (gnus-summary-show-all-threads)
3396 (goto-char (point-min))
3397 (while data
3398 (while (get-text-property (point) 'gnus-intangible)
3399 (forward-line 1))
3400 (gnus-data-set-pos (car data) (+ (point) 3))
3401 (setq data (cdr data))
3402 (forward-line 1))))))
3403
16409b0b
GM
3404(defun gnus-hidden-threads-configuration ()
3405 "Return the current hidden threads configuration."
3406 (save-excursion
3407 (let (config)
3408 (goto-char (point-min))
62a83cc8
KY
3409 (while (not (eobp))
3410 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3411 (push (save-excursion (forward-line 0) (point)) config))
3412 (forward-line 1))
16409b0b
GM
3413 config)))
3414
3415(defun gnus-restore-hidden-threads-configuration (config)
3416 "Restore hidden threads configuration from CONFIG."
3417 (save-excursion
c7a91ce1 3418 (let (point (inhibit-read-only t))
16409b0b 3419 (while (setq point (pop config))
62a83cc8
KY
3420 (goto-char point)
3421 (gnus-summary-hide-thread)))))
16409b0b 3422
eec82323
LMI
3423;; Various summary mode internalish functions.
3424
3425(defun gnus-mouse-pick-article (e)
3426 (interactive "e")
3427 (mouse-set-point e)
3428 (gnus-summary-next-page nil t))
3429
3430(defun gnus-summary-set-display-table ()
16409b0b
GM
3431 "Change the display table.
3432Odd characters have a tendency to mess
3433up nicely formatted displays - we make all possible glyphs
3434display only a single character."
eec82323
LMI
3435
3436 ;; We start from the standard display table, if any.
3437 (let ((table (or (copy-sequence standard-display-table)
3438 (make-display-table)))
3439 (i 32))
3440 ;; Nix out all the control chars...
3441 (while (>= (setq i (1- i)) 0)
2b968687 3442 (gnus-put-display-table i [??] table))
23f87bed 3443 ;; ... but not newline and cr, of course. (cr is necessary for the
eec82323 3444 ;; selective display).
2b968687
MB
3445 (gnus-put-display-table ?\n nil table)
3446 (gnus-put-display-table ?\r nil table)
6748645f 3447 ;; We keep TAB as well.
2b968687 3448 (gnus-put-display-table ?\t nil table)
719120ef 3449 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
fe62aacc 3450 ;; Emacs 23 (unicode), that are not set already.
719120ef
MB
3451 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3452 160
3453 256)))
eec82323
LMI
3454 (while (>= (setq i (1- i)) 127)
3455 ;; Only modify if the entry is nil.
2b968687
MB
3456 (unless (gnus-get-display-table i table)
3457 (gnus-put-display-table i [??] table))))
eec82323
LMI
3458 (setq buffer-display-table table)))
3459
23f87bed
MB
3460(defun gnus-summary-set-article-display-arrow (pos)
3461 "Update the overlay arrow to point to line at position POS."
e3e955fe
MB
3462 (when gnus-summary-display-arrow
3463 (make-local-variable 'overlay-arrow-position)
3464 (make-local-variable 'overlay-arrow-string)
23f87bed
MB
3465 (save-excursion
3466 (goto-char pos)
3467 (beginning-of-line)
3468 (unless overlay-arrow-position
3469 (setq overlay-arrow-position (make-marker)))
3470 (setq overlay-arrow-string "=>"
3471 overlay-arrow-position (set-marker overlay-arrow-position
3472 (point)
3473 (current-buffer))))))
3474
eec82323
LMI
3475(defun gnus-summary-setup-buffer (group)
3476 "Initialize summary buffer."
23f87bed
MB
3477 (let ((buffer (gnus-summary-buffer-name group))
3478 (dead-name (concat "*Dead Summary "
3479 (gnus-group-decoded-name group) "*")))
3480 ;; If a dead summary buffer exists, we kill it.
3481 (when (gnus-buffer-live-p dead-name)
3482 (gnus-kill-buffer dead-name))
eec82323
LMI
3483 (if (get-buffer buffer)
3484 (progn
3485 (set-buffer buffer)
3486 (setq gnus-summary-buffer (current-buffer))
3487 (not gnus-newsgroup-prepared))
3488 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 3489 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323
LMI
3490 (gnus-summary-mode group)
3491 (when gnus-carpal
3492 (gnus-carpal-setup-buffer 'summary))
01c52d31
MB
3493 (when (gnus-group-quit-config group)
3494 (set (make-local-variable 'gnus-single-article-buffer) nil))
3495 (make-local-variable 'gnus-article-buffer)
3496 (make-local-variable 'gnus-article-current)
3497 (make-local-variable 'gnus-original-article-buffer)
eec82323 3498 (setq gnus-newsgroup-name group)
23f87bed
MB
3499 ;; Set any local variables in the group parameters.
3500 (gnus-summary-set-local-parameters gnus-newsgroup-name)
eec82323
LMI
3501 t)))
3502
3503(defun gnus-set-global-variables ()
16409b0b
GM
3504 "Set the global equivalents of the buffer-local variables.
3505They are set to the latest values they had. These reflect the summary
3506buffer that was in action when the last article was fetched."
eec82323
LMI
3507 (when (eq major-mode 'gnus-summary-mode)
3508 (setq gnus-summary-buffer (current-buffer))
3509 (let ((name gnus-newsgroup-name)
3510 (marked gnus-newsgroup-marked)
23f87bed 3511 (spam gnus-newsgroup-spam-marked)
eec82323
LMI
3512 (unread gnus-newsgroup-unreads)
3513 (headers gnus-current-headers)
3514 (data gnus-newsgroup-data)
3515 (summary gnus-summary-buffer)
3516 (article-buffer gnus-article-buffer)
3517 (original gnus-original-article-buffer)
3518 (gac gnus-article-current)
3519 (reffed gnus-reffed-article-number)
16409b0b 3520 (score-file gnus-current-score-file)
23f87bed
MB
3521 (default-charset gnus-newsgroup-charset)
3522 vlist)
3523 (let ((locals gnus-newsgroup-variables))
3524 (while locals
3525 (if (consp (car locals))
3526 (push (eval (caar locals)) vlist)
3527 (push (eval (car locals)) vlist))
3528 (setq locals (cdr locals)))
3529 (setq vlist (nreverse vlist)))
01c52d31 3530 (with-current-buffer gnus-group-buffer
6748645f
LMI
3531 (setq gnus-newsgroup-name name
3532 gnus-newsgroup-marked marked
23f87bed 3533 gnus-newsgroup-spam-marked spam
6748645f
LMI
3534 gnus-newsgroup-unreads unread
3535 gnus-current-headers headers
3536 gnus-newsgroup-data data
3537 gnus-article-current gac
3538 gnus-summary-buffer summary
3539 gnus-article-buffer article-buffer
3540 gnus-original-article-buffer original
3541 gnus-reffed-article-number reffed
16409b0b
GM
3542 gnus-current-score-file score-file
3543 gnus-newsgroup-charset default-charset)
23f87bed
MB
3544 (let ((locals gnus-newsgroup-variables))
3545 (while locals
3546 (if (consp (car locals))
3547 (set (caar locals) (pop vlist))
3548 (set (car locals) (pop vlist)))
3549 (setq locals (cdr locals))))
eec82323
LMI
3550 ;; The article buffer also has local variables.
3551 (when (gnus-buffer-live-p gnus-article-buffer)
3552 (set-buffer gnus-article-buffer)
3553 (setq gnus-summary-buffer summary))))))
3554
3555(defun gnus-summary-article-unread-p (article)
3556 "Say whether ARTICLE is unread or not."
3557 (memq article gnus-newsgroup-unreads))
3558
3559(defun gnus-summary-first-article-p (&optional article)
3560 "Return whether ARTICLE is the first article in the buffer."
3561 (if (not (setq article (or article (gnus-summary-article-number))))
3562 nil
3563 (eq article (caar gnus-newsgroup-data))))
3564
3565(defun gnus-summary-last-article-p (&optional article)
3566 "Return whether ARTICLE is the last article in the buffer."
3567 (if (not (setq article (or article (gnus-summary-article-number))))
16409b0b
GM
3568 ;; All non-existent numbers are the last article. :-)
3569 t
eec82323
LMI
3570 (not (cdr (gnus-data-find-list article)))))
3571
4921bbdd
CY
3572(defun gnus-make-thread-indent-array (&optional n)
3573 (when (or n
3574 (progn (setq n 200) nil)
3575 (null gnus-thread-indent-array)
3576 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3577 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3578 gnus-thread-indent-array-level gnus-thread-indent-level)
3579 (while (>= n 0)
3580 (aset gnus-thread-indent-array n
6a30c01d 3581 (make-string (* n gnus-thread-indent-level) ? ))
4921bbdd 3582 (setq n (1- n)))))
eec82323
LMI
3583
3584(defun gnus-update-summary-mark-positions ()
3585 "Compute where the summary marks are to go."
3586 (save-excursion
6748645f 3587 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3588 (set-buffer gnus-summary-buffer))
5153a47a
MB
3589 (let ((spec gnus-summary-line-format-spec)
3590 pos)
eec82323
LMI
3591 (save-excursion
3592 (gnus-set-work-buffer)
5153a47a
MB
3593 (let ((gnus-tmp-unread ?Z)
3594 (gnus-replied-mark ?Z)
3595 (gnus-score-below-mark ?Z)
3596 (gnus-score-over-mark ?Z)
3597 (gnus-undownloaded-mark ?Z)
3598 (gnus-summary-line-format-spec spec)
54506618 3599 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3600 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3601 case-fold-search ignores)
3602 ;; Here, all marks are bound to Z.
3603 (gnus-summary-insert-line header
3604 0 nil t gnus-tmp-unread t nil "" nil 1)
3605 (goto-char (point-min))
3606 ;; Memorize the positions of the same characters as dummy marks.
3607 (while (re-search-forward "[A-D]" nil t)
3608 (push (point) ignores))
54506618 3609 (erase-buffer)
5153a47a
MB
3610 ;; We use A-D as dummy marks in order to know column positions
3611 ;; where marks should be inserted.
3612 (setq gnus-tmp-unread ?A
3613 gnus-replied-mark ?B
3614 gnus-score-below-mark ?C
3615 gnus-score-over-mark ?C
3616 gnus-undownloaded-mark ?D)
3617 (gnus-summary-insert-line header
3618 0 nil t gnus-tmp-unread t nil "" nil 1)
3619 ;; Ignore characters which aren't dummy marks.
3620 (dolist (p ignores)
3621 (delete-region (goto-char (1- p)) p)
3622 (insert ?Z))
eec82323 3623 (goto-char (point-min))
7c3bb5a5 3624 (setq pos (list (cons 'unread
5153a47a 3625 (and (search-forward "A" nil t)
7c3bb5a5 3626 (- (point) (point-min) 1)))))
eec82323 3627 (goto-char (point-min))
5153a47a 3628 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3629 (- (point) (point-min) 1)))
eec82323
LMI
3630 pos)
3631 (goto-char (point-min))
5153a47a 3632 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3633 (- (point) (point-min) 1)))
6748645f
LMI
3634 pos)
3635 (goto-char (point-min))
5153a47a 3636 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3637 (- (point) (point-min) 1)))
eec82323
LMI
3638 pos)))
3639 (setq gnus-summary-mark-positions pos))))
3640
3641(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3642 "Insert a dummy root in the summary buffer."
3643 (beginning-of-line)
3644 (gnus-add-text-properties
3645 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3646 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3647
23f87bed
MB
3648(defun gnus-summary-extract-address-component (from)
3649 (or (car (funcall gnus-extract-address-components from))
3650 from))
3651
3652(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3653 (let ((mail-parse-charset gnus-newsgroup-charset)
01c52d31 3654 (ignored-from-addresses (gnus-ignored-from-addresses))
23f87bed
MB
3655 ; Is it really necessary to do this next part for each summary line?
3656 ; Luckily, doesn't seem to slow things down much.
16409b0b 3657 (mail-parse-ignored-charsets
01c52d31
MB
3658 (with-current-buffer gnus-summary-buffer
3659 gnus-newsgroup-ignored-charsets)))
23f87bed 3660 (or
01c52d31
MB
3661 (and ignored-from-addresses
3662 (string-match ignored-from-addresses gnus-tmp-from)
23f87bed
MB
3663 (let ((extra-headers (mail-header-extra header))
3664 to
3665 newsgroups)
3666 (cond
3667 ((setq to (cdr (assq 'To extra-headers)))
01c52d31 3668 (concat gnus-summary-to-prefix
23f87bed
MB
3669 (inline
3670 (gnus-summary-extract-address-component
343d6628 3671 (funcall gnus-decode-encoded-address-function to)))))
01c52d31
MB
3672 ((setq newsgroups
3673 (or
3674 (cdr (assq 'Newsgroups extra-headers))
3675 (and
3676 (memq 'Newsgroups gnus-extra-headers)
3677 (eq (car (gnus-find-method-for-group
3678 gnus-newsgroup-name)) 'nntp)
3679 (gnus-group-real-name gnus-newsgroup-name))))
3680 (concat gnus-summary-newsgroup-prefix newsgroups)))))
23f87bed 3681 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3682
eec82323
LMI
3683(defun gnus-summary-insert-line (gnus-tmp-header
3684 gnus-tmp-level gnus-tmp-current
23f87bed 3685 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3686 gnus-tmp-expirable gnus-tmp-subject-or-nil
3687 &optional gnus-tmp-dummy gnus-tmp-score
3688 gnus-tmp-process)
4921bbdd
CY
3689 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3690 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3691 gnus-tmp-level)))
eec82323
LMI
3692 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3693 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3694 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3695 (gnus-tmp-score-char
3696 (if (or (null gnus-summary-default-score)
3697 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3698 gnus-summary-zcore-fuzz))
23f87bed 3699 ? ;Whitespace
eec82323
LMI
3700 (if (< gnus-tmp-score gnus-summary-default-score)
3701 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3702 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3703 (gnus-tmp-replied
3704 (cond (gnus-tmp-process gnus-process-mark)
3705 ((memq gnus-tmp-current gnus-newsgroup-cached)
3706 gnus-cached-mark)
3707 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3708 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3709 gnus-forwarded-mark)
eec82323
LMI
3710 ((memq gnus-tmp-current gnus-newsgroup-saved)
3711 gnus-saved-mark)
23f87bed
MB
3712 ((memq gnus-tmp-number gnus-newsgroup-recent)
3713 gnus-recent-mark)
3714 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3715 gnus-unseen-mark)
3716 (t gnus-no-mark)))
3717 (gnus-tmp-downloaded
3718 (cond (undownloaded
3719 gnus-undownloaded-mark)
3720 (gnus-newsgroup-agentized
3721 gnus-downloaded-mark)
3722 (t
3723 gnus-no-mark)))
eec82323
LMI
3724 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3725 (gnus-tmp-name
3726 (cond
3727 ((string-match "<[^>]+> *$" gnus-tmp-from)
3728 (let ((beg (match-beginning 0)))
23f87bed
MB
3729 (or (and (string-match "^\".+\"" gnus-tmp-from)
3730 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3731 (substring gnus-tmp-from 0 beg))))
3732 ((string-match "(.+)" gnus-tmp-from)
3733 (substring gnus-tmp-from
3734 (1+ (match-beginning 0)) (1- (match-end 0))))
3735 (t gnus-tmp-from)))
3736 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3737 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3738 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
c7a91ce1 3739 (inhibit-read-only t))
eec82323
LMI
3740 (when (string= gnus-tmp-name "")
3741 (setq gnus-tmp-name gnus-tmp-from))
3742 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3743 (setq gnus-tmp-lines -1))
3744 (if (= gnus-tmp-lines -1)
3745 (setq gnus-tmp-lines "?")
3746 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
64763fe3
MB
3747 (condition-case ()
3748 (gnus-put-text-property
3749 (point)
3750 (progn (eval gnus-summary-line-format-spec) (point))
3751 'gnus-number gnus-tmp-number)
3752 (error (gnus-message 5 "Error updating the summary line")))
eec82323
LMI
3753 (when (gnus-visual-p 'summary-highlight 'highlight)
3754 (forward-line -1)
6748645f 3755 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3756 (forward-line 1))))
3757
3758(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3759 "Update summary line after change."
eec82323
LMI
3760 (when (and gnus-summary-default-score
3761 (not gnus-summary-inhibit-highlight))
3762 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3763 (article (gnus-summary-article-number))
3764 (score (gnus-summary-article-score article)))
3765 (unless dont-update
3766 (if (and gnus-summary-mark-below
3767 (< (gnus-summary-article-score)
3768 gnus-summary-mark-below))
3769 ;; This article has a low score, so we mark it as read.
3770 (when (memq article gnus-newsgroup-unreads)
3771 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3772 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3773 ;; This article was previously marked as read on account
3774 ;; of a low score, but now it has risen, so we mark it as
3775 ;; unread.
3776 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3777 (gnus-summary-update-mark
3778 (if (or (null gnus-summary-default-score)
3779 (<= (abs (- score gnus-summary-default-score))
3780 gnus-summary-zcore-fuzz))
23f87bed 3781 ? ;Whitespace
eec82323
LMI
3782 (if (< score gnus-summary-default-score)
3783 gnus-score-below-mark gnus-score-over-mark))
3784 'score))
3785 ;; Do visual highlighting.
3786 (when (gnus-visual-p 'summary-highlight 'highlight)
6748645f 3787 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3788
3789(defvar gnus-tmp-new-adopts nil)
3790
3791(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3792 "Return the number of articles in THREAD.
3793This may be 0 in some cases -- if none of the articles in
3794the thread are to be displayed."
3795 (let* ((number
23f87bed 3796 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3797 (cond
3798 ((not (listp thread))
3799 1)
3800 ((and (consp thread) (cdr thread))
3801 (apply
3802 '+ 1 (mapcar
3803 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3804 ((null thread)
3805 1)
3806 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3807 1)
3808 (t 0))))
3809 (when (and level (zerop level) gnus-tmp-new-adopts)
3810 (incf number
3811 (apply '+ (mapcar
3812 'gnus-summary-number-of-articles-in-thread
3813 gnus-tmp-new-adopts))))
3814 (if char
3815 (if (> number 1) gnus-not-empty-thread-mark
3816 gnus-empty-thread-mark)
3817 number)))
3818
23f87bed
MB
3819(defsubst gnus-summary-line-message-size (head)
3820 "Return pretty-printed version of message size.
3821This function is intended to be used in
3822`gnus-summary-line-format-alist'."
3823 (let ((c (or (mail-header-chars head) -1)))
3824 (cond ((< c 0) "n/a") ; chars not available
3825 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3826 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3827 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3828 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3829
3830
eec82323
LMI
3831(defun gnus-summary-set-local-parameters (group)
3832 "Go through the local params of GROUP and set all variable specs in that list."
01c52d31
MB
3833 (let ((vars '(quit-config))) ; Ignore quit-config.
3834 (dolist (elem (gnus-group-find-parameter group))
eec82323
LMI
3835 (and (consp elem) ; Has to be a cons.
3836 (consp (cdr elem)) ; The cdr has to be a list.
3837 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3838 (not (memq (car elem) vars))
e3e955fe 3839 (ignore-errors
23f87bed 3840 (push (car elem) vars)
e3e955fe
MB
3841 ;; Variables like `gnus-show-threads' that are globally
3842 ;; bound, if used as group parameters, need to get to be
3843 ;; buffer-local, whereas just parameters like `gcc-self',
3844 ;; `timestamp', etc. should not be bound as variables.
3845 (if (boundp (car elem))
3846 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3847 (eval (nth 1 elem))))))))
eec82323
LMI
3848
3849(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3850 kill-buffer no-display backward
3851 select-articles)
eec82323
LMI
3852 "Start reading news in newsgroup GROUP.
3853If SHOW-ALL is non-nil, already read articles are also listed.
3854If NO-ARTICLE is non-nil, no article is selected initially.
3855If NO-DISPLAY, don't generate a summary buffer."
3856 (let (result)
3857 (while (and group
3858 (null (setq result
3859 (let ((gnus-auto-select-next nil))
6748645f
LMI
3860 (or (gnus-summary-read-group-1
3861 group show-all no-article
3862 kill-buffer no-display
3863 select-articles)
3864 (setq show-all nil
16409b0b 3865 select-articles nil)))))
eec82323
LMI
3866 (eq gnus-auto-select-next 'quietly))
3867 (set-buffer gnus-group-buffer)
6748645f
LMI
3868 ;; The entry function called above goes to the next
3869 ;; group automatically, so we go two groups back
3870 ;; if we are searching for the previous group.
3871 (when backward
3872 (gnus-group-prev-unread-group 2))
eec82323
LMI
3873 (if (not (equal group (gnus-group-group-name)))
3874 (setq group (gnus-group-group-name))
3875 (setq group nil)))
3876 result))
3877
3878(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3879 kill-buffer no-display
3880 &optional select-articles)
eec82323 3881 ;; Killed foreign groups can't be entered.
23f87bed
MB
3882 ;; (when (and (not (gnus-group-native-p group))
3883 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3884 ;; (error "Dead non-native groups can't be entered"))
3885 (gnus-message 5 "Retrieving newsgroup: %s..."
3886 (gnus-group-decoded-name group))
eec82323
LMI
3887 (let* ((new-group (gnus-summary-setup-buffer group))
3888 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3889 (did-select (and new-group (gnus-select-newsgroup
3890 group show-all select-articles))))
eec82323
LMI
3891 (cond
3892 ;; This summary buffer exists already, so we just select it.
3893 ((not new-group)
3894 (gnus-set-global-variables)
3895 (when kill-buffer
3896 (gnus-kill-or-deaden-summary kill-buffer))
3897 (gnus-configure-windows 'summary 'force)
3898 (gnus-set-mode-line 'summary)
3899 (gnus-summary-position-point)
3900 (message "")
3901 t)
3902 ;; We couldn't select this group.
3903 ((null did-select)
3904 (when (and (eq major-mode 'gnus-summary-mode)
3905 (not (equal (current-buffer) kill-buffer)))
3906 (kill-buffer (current-buffer))
3907 (if (not quit-config)
3908 (progn
6748645f
LMI
3909 ;; Update the info -- marks might need to be removed,
3910 ;; for instance.
3911 (gnus-summary-update-info)
eec82323
LMI
3912 (set-buffer gnus-group-buffer)
3913 (gnus-group-jump-to-group group)
3914 (gnus-group-next-unread-group 1))
3915 (gnus-handle-ephemeral-exit quit-config)))
23f87bed
MB
3916 (let ((grpinfo (gnus-get-info group)))
3917 (if (null (gnus-info-read grpinfo))
3918 (gnus-message 3 "Group %s contains no messages"
3919 (gnus-group-decoded-name group))
3920 (gnus-message 3 "Can't select group")))
eec82323
LMI
3921 nil)
3922 ;; The user did a `C-g' while prompting for number of articles,
3923 ;; so we exit this group.
3924 ((eq did-select 'quit)
3925 (and (eq major-mode 'gnus-summary-mode)
3926 (not (equal (current-buffer) kill-buffer))
3927 (kill-buffer (current-buffer)))
3928 (when kill-buffer
3929 (gnus-kill-or-deaden-summary kill-buffer))
3930 (if (not quit-config)
3931 (progn
3932 (set-buffer gnus-group-buffer)
3933 (gnus-group-jump-to-group group)
eec82323
LMI
3934 (gnus-configure-windows 'group 'force))
3935 (gnus-handle-ephemeral-exit quit-config))
3936 ;; Finally signal the quit.
3937 (signal 'quit nil))
3938 ;; The group was successfully selected.
3939 (t
3940 (gnus-set-global-variables)
3941 ;; Save the active value in effect when the group was entered.
3942 (setq gnus-newsgroup-active
3943 (gnus-copy-sequence
3944 (gnus-active gnus-newsgroup-name)))
3945 ;; You can change the summary buffer in some way with this hook.
6748645f 3946 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
3947 (when (memq 'summary (gnus-update-format-specifications
3948 nil 'summary 'summary-mode 'summary-dummy))
3949 ;; The format specification for the summary line was updated,
3950 ;; so we need to update the mark positions as well.
3951 (gnus-update-summary-mark-positions))
eec82323
LMI
3952 ;; Do score processing.
3953 (when gnus-use-scoring
3954 (gnus-possibly-score-headers))
3955 ;; Check whether to fill in the gaps in the threads.
3956 (when gnus-build-sparse-threads
3957 (gnus-build-sparse-threads))
3958 ;; Find the initial limit.
26c9afc3
MB
3959 (if show-all
3960 (let ((gnus-newsgroup-dormant nil))
eec82323 3961 (gnus-summary-initial-limit show-all))
26c9afc3 3962 (gnus-summary-initial-limit show-all))
eec82323
LMI
3963 ;; Generate the summary buffer.
3964 (unless no-display
3965 (gnus-summary-prepare))
3966 (when gnus-use-trees
3967 (gnus-tree-open group)
3968 (setq gnus-summary-highlight-line-function
3969 'gnus-tree-highlight-article))
3970 ;; If the summary buffer is empty, but there are some low-scored
3971 ;; articles or some excluded dormants, we include these in the
3972 ;; buffer.
3973 (when (and (zerop (buffer-size))
3974 (not no-display))
3975 (cond (gnus-newsgroup-dormant
3976 (gnus-summary-limit-include-dormant))
3977 ((and gnus-newsgroup-scored show-all)
3978 (gnus-summary-limit-include-expunged t))))
3979 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 3980 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
3981 (if (and (zerop (buffer-size))
3982 (not no-display))
3983 (progn
3984 ;; This newsgroup is empty.
3985 (gnus-summary-catchup-and-exit nil t)
3986 (gnus-message 6 "No unread news")
3987 (when kill-buffer
3988 (gnus-kill-or-deaden-summary kill-buffer))
3989 ;; Return nil from this function.
3990 nil)
3991 ;; Hide conversation thread subtrees. We cannot do this in
3992 ;; gnus-summary-prepare-hook since kill processing may not
3993 ;; work with hidden articles.
23f87bed 3994 (gnus-summary-maybe-hide-threads)
6748645f
LMI
3995 (when kill-buffer
3996 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 3997 (gnus-summary-auto-select-subject)
eec82323
LMI
3998 ;; Show first unread article if requested.
3999 (if (and (not no-article)
4000 (not no-display)
4001 gnus-newsgroup-unreads
4002 gnus-auto-select-first)
16409b0b
GM
4003 (progn
4004 (gnus-configure-windows 'summary)
23f87bed
MB
4005 (let ((art (gnus-summary-article-number)))
4006 (unless (and (not gnus-plugged)
4007 (or (memq art gnus-newsgroup-undownloaded)
4008 (memq art gnus-newsgroup-downloadable)))
4009 (gnus-summary-goto-article art))))
4010 ;; Don't select any articles.
eec82323 4011 (gnus-summary-position-point)
6748645f
LMI
4012 (gnus-configure-windows 'summary 'force)
4013 (gnus-set-mode-line 'summary))
23f87bed
MB
4014 (when (and gnus-auto-center-group
4015 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
4016 ;; Gotta use windows, because recenter does weird stuff if
4017 ;; the current buffer ain't the displayed window.
4018 (let ((owin (selected-window)))
4019 (select-window (get-buffer-window gnus-group-buffer t))
4020 (when (gnus-group-goto-group group)
4021 (recenter))
4022 (select-window owin)))
4023 ;; Mark this buffer as "prepared".
4024 (setq gnus-newsgroup-prepared t)
6748645f 4025 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
4026 (unless (gnus-ephemeral-group-p group)
4027 (gnus-group-update-group group))
eec82323
LMI
4028 t)))))
4029
23f87bed
MB
4030(defun gnus-summary-auto-select-subject ()
4031 "Select the subject line on initial group entry."
4032 (goto-char (point-min))
4033 (cond
4034 ((eq gnus-auto-select-subject 'best)
4035 (gnus-summary-best-unread-subject))
4036 ((eq gnus-auto-select-subject 'unread)
4037 (gnus-summary-first-unread-subject))
4038 ((eq gnus-auto-select-subject 'unseen)
4039 (gnus-summary-first-unseen-subject))
4040 ((eq gnus-auto-select-subject 'unseen-or-unread)
4041 (gnus-summary-first-unseen-or-unread-subject))
4042 ((eq gnus-auto-select-subject 'first)
4043 ;; Do nothing.
4044 )
4045 ((functionp gnus-auto-select-subject)
4046 (funcall gnus-auto-select-subject))))
4047
eec82323
LMI
4048(defun gnus-summary-prepare ()
4049 "Generate the summary buffer."
4050 (interactive)
c7a91ce1 4051 (let ((inhibit-read-only t))
eec82323
LMI
4052 (erase-buffer)
4053 (setq gnus-newsgroup-data nil
4054 gnus-newsgroup-data-reverse nil)
6748645f 4055 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
4056 ;; Generate the buffer, either with threads or without.
4057 (when gnus-newsgroup-headers
4058 (gnus-summary-prepare-threads
4059 (if gnus-show-threads
4060 (gnus-sort-gathered-threads
4061 (funcall gnus-summary-thread-gathering-function
4062 (gnus-sort-threads
4063 (gnus-cut-threads (gnus-make-threads)))))
4064 ;; Unthreaded display.
4065 (gnus-sort-articles gnus-newsgroup-headers))))
4066 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4067 ;; Call hooks for modifying summary buffer.
4068 (goto-char (point-min))
6748645f 4069 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
4070
4071(defsubst gnus-general-simplify-subject (subject)
23f87bed 4072 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
4073 (setq subject
4074 (cond
4075 ;; Truncate the subject.
6748645f
LMI
4076 (gnus-simplify-subject-functions
4077 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
4078 ((numberp gnus-summary-gather-subject-limit)
4079 (setq subject (gnus-simplify-subject-re subject))
4080 (if (> (length subject) gnus-summary-gather-subject-limit)
4081 (substring subject 0 gnus-summary-gather-subject-limit)
4082 subject))
4083 ;; Fuzzily simplify it.
4084 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4085 (gnus-simplify-subject-fuzzy subject))
4086 ;; Just remove the leading "Re:".
4087 (t
4088 (gnus-simplify-subject-re subject))))
4089
4090 (if (and gnus-summary-gather-exclude-subject
4091 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 4092 nil ; This article shouldn't be gathered
eec82323
LMI
4093 subject))
4094
4095(defun gnus-summary-simplify-subject-query ()
4096 "Query where the respool algorithm would put this article."
4097 (interactive)
eec82323 4098 (gnus-summary-select-article)
274f1353 4099 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
eec82323
LMI
4100
4101(defun gnus-gather-threads-by-subject (threads)
4102 "Gather threads by looking at Subject headers."
4103 (if (not gnus-summary-make-false-root)
4104 threads
4105 (let ((hashtb (gnus-make-hashtable 1024))
4106 (prev threads)
4107 (result threads)
4108 subject hthread whole-subject)
4109 (while threads
4110 (setq subject (gnus-general-simplify-subject
4111 (setq whole-subject (mail-header-subject
4112 (caar threads)))))
4113 (when subject
4114 (if (setq hthread (gnus-gethash subject hashtb))
4115 (progn
4116 ;; We enter a dummy root into the thread, if we
4117 ;; haven't done that already.
4118 (unless (stringp (caar hthread))
4119 (setcar hthread (list whole-subject (car hthread))))
4120 ;; We add this new gathered thread to this gathered
4121 ;; thread.
4122 (setcdr (car hthread)
4123 (nconc (cdar hthread) (list (car threads))))
4124 ;; Remove it from the list of threads.
4125 (setcdr prev (cdr threads))
4126 (setq threads prev))
4127 ;; Enter this thread into the hash table.
23f87bed
MB
4128 (gnus-sethash subject
4129 (if gnus-summary-make-false-root-always
4130 (progn
4131 ;; If you want a dummy root above all
4132 ;; threads...
4133 (setcar threads (list whole-subject
4134 (car threads)))
4135 threads)
4136 threads)
4137 hashtb)))
eec82323
LMI
4138 (setq prev threads)
4139 (setq threads (cdr threads)))
4140 result)))
4141
4142(defun gnus-gather-threads-by-references (threads)
4143 "Gather threads by looking at References headers."
4144 (let ((idhashtb (gnus-make-hashtable 1024))
4145 (thhashtb (gnus-make-hashtable 1024))
4146 (prev threads)
4147 (result threads)
4148 ids references id gthread gid entered ref)
4149 (while threads
4150 (when (setq references (mail-header-references (caar threads)))
4151 (setq id (mail-header-id (caar threads))
23f87bed 4152 ids (inline (gnus-split-references references))
eec82323
LMI
4153 entered nil)
4154 (while (setq ref (pop ids))
4155 (setq ids (delete ref ids))
4156 (if (not (setq gid (gnus-gethash ref idhashtb)))
4157 (progn
4158 (gnus-sethash ref id idhashtb)
4159 (gnus-sethash id threads thhashtb))
4160 (setq gthread (gnus-gethash gid thhashtb))
4161 (unless entered
4162 ;; We enter a dummy root into the thread, if we
4163 ;; haven't done that already.
4164 (unless (stringp (caar gthread))
4165 (setcar gthread (list (mail-header-subject (caar gthread))
4166 (car gthread))))
4167 ;; We add this new gathered thread to this gathered
4168 ;; thread.
4169 (setcdr (car gthread)
4170 (nconc (cdar gthread) (list (car threads)))))
4171 ;; Add it into the thread hash table.
4172 (gnus-sethash id gthread thhashtb)
4173 (setq entered t)
4174 ;; Remove it from the list of threads.
4175 (setcdr prev (cdr threads))
4176 (setq threads prev))))
4177 (setq prev threads)
4178 (setq threads (cdr threads)))
4179 result))
4180
4181(defun gnus-sort-gathered-threads (threads)
16409b0b 4182 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
4183 (let ((result threads))
4184 (while threads
4185 (when (stringp (caar threads))
4186 (setcdr (car threads)
16409b0b 4187 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
4188 (setq threads (cdr threads)))
4189 result))
4190
4191(defun gnus-thread-loop-p (root thread)
4192 "Say whether ROOT is in THREAD."
4193 (let ((stack (list thread))
4194 (infloop 0)
4195 th)
4196 (while (setq thread (pop stack))
4197 (setq th (cdr thread))
4198 (while (and th
4199 (not (eq (caar th) root)))
4200 (pop th))
4201 (if th
4202 ;; We have found a loop.
4203 (let (ref-dep)
4204 (setcdr thread (delq (car th) (cdr thread)))
4205 (if (boundp (setq ref-dep (intern "none"
4206 gnus-newsgroup-dependencies)))
4207 (setcdr (symbol-value ref-dep)
4208 (nconc (cdr (symbol-value ref-dep))
4209 (list (car th))))
4210 (set ref-dep (list nil (car th))))
4211 (setq infloop 1
4212 stack nil))
4213 ;; Push all the subthreads onto the stack.
4214 (push (cdr thread) stack)))
4215 infloop))
4216
4217(defun gnus-make-threads ()
01ccbb85 4218 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
4219 (let (threads)
4220 (while (catch 'infloop
4221 (mapatoms
4222 (lambda (refs)
4223 ;; Deal with self-referencing References loops.
4224 (when (and (car (symbol-value refs))
4225 (not (zerop
4226 (apply
4227 '+
4228 (mapcar
4229 (lambda (thread)
4230 (gnus-thread-loop-p
4231 (car (symbol-value refs)) thread))
4232 (cdr (symbol-value refs)))))))
4233 (setq threads nil)
4234 (throw 'infloop t))
4235 (unless (car (symbol-value refs))
23f87bed
MB
4236 ;; These threads do not refer back to any other
4237 ;; articles, so they're roots.
eec82323
LMI
4238 (setq threads (append (cdr (symbol-value refs)) threads))))
4239 gnus-newsgroup-dependencies)))
4240 threads))
4241
6748645f 4242;; Build the thread tree.
16409b0b 4243(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4244 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4245
4246If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4247if it was already present.
4248
4249If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4250will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4251Message-IDs will be renamed to a unique Message-ID before being
4252entered.
6748645f
LMI
4253
4254Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4255 (let* ((id (mail-header-id header))
4256 (id-dep (and id (intern id dependencies)))
23f87bed 4257 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4258 ;; Enter this `header' in the `dependencies' table.
4259 (cond
4260 ((not id-dep)
4261 (setq header nil))
4262 ;; The first two cases do the normal part: enter a new `header'
4263 ;; in the `dependencies' table.
4264 ((not (boundp id-dep))
4265 (set id-dep (list header)))
4266 ((null (car (symbol-value id-dep)))
4267 (setcar (symbol-value id-dep) header))
4268
4269 ;; From here the `header' was already present in the
4270 ;; `dependencies' table.
4271 (force-new
4272 ;; Overrides an existing entry;
4273 ;; just set the header part of the entry.
23f87bed
MB
4274 (setcar (symbol-value id-dep) header)
4275 (setq replaced t))
6748645f
LMI
4276
4277 ;; Renames the existing `header' to a unique Message-ID.
4278 ((not gnus-summary-ignore-duplicates)
4279 ;; An article with this Message-ID has already been seen.
4280 ;; We rename the Message-ID.
4281 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4282 (list header))
4283 (mail-header-set-id header id))
4284
4285 ;; The last case ignores an existing entry, except it adds any
4286 ;; additional Xrefs (in case the two articles came from different
4287 ;; servers.
4288 ;; Also sets `header' to `nil' meaning that the `dependencies'
4289 ;; table was *not* modified.
4290 (t
4291 (mail-header-set-xref
4292 (car (symbol-value id-dep))
4293 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4294 "")
4295 (or (mail-header-xref header) "")))
4296 (setq header nil)))
4297
23f87bed
MB
4298 (when (and header (not replaced))
4299 ;; First check that we are not creating a References loop.
4300 (setq parent-id (gnus-parent-id (mail-header-references header)))
4301 (setq ref parent-id)
6748645f
LMI
4302 (while (and ref
4303 (setq ref-dep (intern-soft ref dependencies))
4304 (boundp ref-dep)
4305 (setq ref-header (car (symbol-value ref-dep))))
4306 (if (string= id ref)
4307 ;; Yuk! This is a reference loop. Make the article be a
4308 ;; root article.
4309 (progn
4310 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4311 (setq ref nil)
4312 (setq parent-id nil))
6748645f 4313 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4314 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4315 (if (boundp ref-dep)
4316 (setcdr (symbol-value ref-dep)
4317 (nconc (cdr (symbol-value ref-dep))
4318 (list (symbol-value id-dep))))
4319 (set ref-dep (list nil (symbol-value id-dep)))))
4320 header))
4321
23f87bed
MB
4322(defun gnus-extract-message-id-from-in-reply-to (string)
4323 (if (string-match "<[^>]+>" string)
4324 (substring string (match-beginning 0) (match-end 0))
4325 nil))
4326
eec82323
LMI
4327(defun gnus-build-sparse-threads ()
4328 (let ((headers gnus-newsgroup-headers)
16409b0b 4329 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4330 (gnus-summary-ignore-duplicates t)
eec82323 4331 header references generation relations
6748645f 4332 subject child end new-child date)
eec82323
LMI
4333 ;; First we create an alist of generations/relations, where
4334 ;; generations is how much we trust the relation, and the relation
4335 ;; is parent/child.
4336 (gnus-message 7 "Making sparse threads...")
4337 (save-excursion
4338 (nnheader-set-temp-buffer " *gnus sparse threads*")
4339 (while (setq header (pop headers))
4340 (when (and (setq references (mail-header-references header))
4341 (not (string= references "")))
4342 (insert references)
4343 (setq child (mail-header-id header)
6748645f
LMI
4344 subject (mail-header-subject header)
4345 date (mail-header-date header)
4346 generation 0)
eec82323
LMI
4347 (while (search-backward ">" nil t)
4348 (setq end (1+ (point)))
4349 (when (search-backward "<" nil t)
6748645f 4350 (setq new-child (buffer-substring (point) end))
eec82323 4351 (push (list (incf generation)
6748645f
LMI
4352 child (setq child new-child)
4353 subject date)
eec82323 4354 relations)))
6748645f
LMI
4355 (when child
4356 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4357 (erase-buffer)))
4358 (kill-buffer (current-buffer)))
4359 ;; Sort over trustworthiness.
01c52d31
MB
4360 (dolist (relation (sort relations 'car-less-than-car))
4361 (when (gnus-dependencies-add-header
4362 (make-full-mail-header
4363 gnus-reffed-article-number
4364 (nth 3 relation) "" (or (nth 4 relation) "")
4365 (nth 1 relation)
4366 (or (nth 2 relation) "") 0 0 "")
4367 gnus-newsgroup-dependencies nil)
4368 (push gnus-reffed-article-number gnus-newsgroup-limit)
4369 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4370 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4371 gnus-newsgroup-reads)
4372 (decf gnus-reffed-article-number)))
eec82323
LMI
4373 (gnus-message 7 "Making sparse threads...done")))
4374
4375(defun gnus-build-old-threads ()
4376 ;; Look at all the articles that refer back to old articles, and
4377 ;; fetch the headers for the articles that aren't there. This will
4378 ;; build complete threads - if the roots haven't been expired by the
4379 ;; server, that is.
16409b0b
GM
4380 (let ((mail-parse-charset gnus-newsgroup-charset)
4381 id heads)
eec82323
LMI
4382 (mapatoms
4383 (lambda (refs)
4384 (when (not (car (symbol-value refs)))
4385 (setq heads (cdr (symbol-value refs)))
4386 (while heads
4387 (if (memq (mail-header-number (caar heads))
4388 gnus-newsgroup-dormant)
4389 (setq heads (cdr heads))
4390 (setq id (symbol-name refs))
4391 (while (and (setq id (gnus-build-get-header id))
6748645f 4392 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4393 (setq heads nil)))))
4394 gnus-newsgroup-dependencies)))
4395
23f87bed
MB
4396(defsubst gnus-remove-odd-characters (string)
4397 "Translate STRING into something that doesn't contain weird characters."
4398 (mm-subst-char-in-string
4399 ?\r ?\-
01c52d31 4400 (mm-subst-char-in-string ?\n ?\- string t) t))
23f87bed 4401
6748645f
LMI
4402;; This function has to be called with point after the article number
4403;; on the beginning of the line.
4404(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
01c52d31 4405 (let ((eol (point-at-eol))
6748645f 4406 (buffer (current-buffer))
23f87bed 4407 header references in-reply-to)
6748645f
LMI
4408
4409 ;; overview: [num subject from date id refs chars lines misc]
4410 (unwind-protect
23f87bed 4411 (let (x)
6748645f
LMI
4412 (narrow-to-region (point) eol)
4413 (unless (eobp)
4414 (forward-char))
4415
4416 (setq header
4417 (make-full-mail-header
4418 number ; number
23f87bed
MB
4419 (condition-case () ; subject
4420 (gnus-remove-odd-characters
4421 (funcall gnus-decode-encoded-word-function
4422 (setq x (nnheader-nov-field))))
4423 (error x))
4424 (condition-case () ; from
4425 (gnus-remove-odd-characters
343d6628 4426 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4427 (setq x (nnheader-nov-field))))
4428 (error x))
16409b0b 4429 (nnheader-nov-field) ; date
01c52d31 4430 (nnheader-nov-read-message-id number) ; id
23f87bed 4431 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4432 (nnheader-nov-read-integer) ; chars
4433 (nnheader-nov-read-integer) ; lines
4434 (unless (eobp)
8b93df01
DL
4435 (if (looking-at "Xref: ")
4436 (goto-char (match-end 0)))
4437 (nnheader-nov-field)) ; Xref
16409b0b 4438 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4439
4440 (widen))
4441
23f87bed
MB
4442 (when (and (string= references "")
4443 (setq in-reply-to (mail-header-extra header))
4444 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4445 (mail-header-set-references
4446 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4447
6748645f
LMI
4448 (when gnus-alter-header-function
4449 (funcall gnus-alter-header-function header))
4450 (gnus-dependencies-add-header header dependencies force-new)))
4451
eec82323 4452(defun gnus-build-get-header (id)
16409b0b
GM
4453 "Look through the buffer of NOV lines and find the header to ID.
4454Enter this line into the dependencies hash table, and return
4455the id of the parent article (if any)."
eec82323
LMI
4456 (let ((deps gnus-newsgroup-dependencies)
4457 found header)
4458 (prog1
c7a91ce1 4459 (with-current-buffer nntp-server-buffer
eec82323
LMI
4460 (let ((case-fold-search nil))
4461 (goto-char (point-min))
4462 (while (and (not found)
4463 (search-forward id nil t))
4464 (beginning-of-line)
4465 (setq found (looking-at
4466 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4467 (regexp-quote id))))
4468 (or found (beginning-of-line 2)))
4469 (when found
4470 (beginning-of-line)
4471 (and
4472 (setq header (gnus-nov-parse-line
4473 (read (current-buffer)) deps))
4474 (gnus-parent-id (mail-header-references header))))))
4475 (when header
4476 (let ((number (mail-header-number header)))
4477 (push number gnus-newsgroup-limit)
4478 (push header gnus-newsgroup-headers)
4479 (if (memq number gnus-newsgroup-unselected)
4480 (progn
23f87bed
MB
4481 (setq gnus-newsgroup-unreads
4482 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4483 number))
eec82323
LMI
4484 (setq gnus-newsgroup-unselected
4485 (delq number gnus-newsgroup-unselected)))
4486 (push number gnus-newsgroup-ancient)))))))
4487
6748645f
LMI
4488(defun gnus-build-all-threads ()
4489 "Read all the headers."
4490 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4491 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4492 (dependencies gnus-newsgroup-dependencies)
4493 header article)
c7a91ce1 4494 (with-current-buffer nntp-server-buffer
6748645f
LMI
4495 (let ((case-fold-search nil))
4496 (goto-char (point-min))
4497 (while (not (eobp))
4498 (ignore-errors
4499 (setq article (read (current-buffer))
16409b0b 4500 header (gnus-nov-parse-line article dependencies)))
6748645f 4501 (when header
01c52d31 4502 (with-current-buffer gnus-summary-buffer
6748645f
LMI
4503 (push header gnus-newsgroup-headers)
4504 (if (memq (setq article (mail-header-number header))
4505 gnus-newsgroup-unselected)
4506 (progn
23f87bed
MB
4507 (setq gnus-newsgroup-unreads
4508 (gnus-add-to-sorted-list
4509 gnus-newsgroup-unreads article))
6748645f
LMI
4510 (setq gnus-newsgroup-unselected
4511 (delq article gnus-newsgroup-unselected)))
4512 (push article gnus-newsgroup-ancient)))
4513 (forward-line 1)))))))
4514
eec82323 4515(defun gnus-summary-update-article-line (article header)
23f87bed 4516 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4517 (let* ((id (mail-header-id header))
4518 (thread (gnus-id-to-thread id)))
4519 (unless thread
4520 (error "Article in no thread"))
4521 ;; Update the thread.
4522 (setcar thread header)
4523 (gnus-summary-goto-subject article)
4524 (let* ((datal (gnus-data-find-list article))
4525 (data (car datal))
c7a91ce1 4526 (inhibit-read-only t)
eec82323
LMI
4527 (level (gnus-summary-thread-level)))
4528 (gnus-delete-line)
23f87bed
MB
4529 (let ((inserted (- (point)
4530 (progn
4531 (gnus-summary-insert-line
4532 header level nil
4533 (memq article gnus-newsgroup-undownloaded)
4534 (gnus-article-mark article)
4535 (memq article gnus-newsgroup-replied)
4536 (memq article gnus-newsgroup-expirable)
4537 ;; Only insert the Subject string when it's different
4538 ;; from the previous Subject string.
4539 (if (and
4540 gnus-show-threads
4541 (gnus-subject-equal
4542 (condition-case ()
4543 (mail-header-subject
4544 (gnus-data-header
4545 (cadr
4546 (gnus-data-find-list
4547 article
4548 (gnus-data-list t)))))
4549 ;; Error on the side of excessive subjects.
4550 (error ""))
4551 (mail-header-subject header)))
4552 ""
4553 (mail-header-subject header))
4554 nil (cdr (assq article gnus-newsgroup-scored))
4555 (memq article gnus-newsgroup-processable))
4556 (point)))))
4557 (when (cdr datal)
4558 (gnus-data-update-list
4559 (cdr datal)
4560 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4561
4562(defun gnus-summary-update-article (article &optional iheader)
4563 "Update ARTICLE in the summary buffer."
4564 (set-buffer gnus-summary-buffer)
6748645f 4565 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4566 (id (mail-header-id header))
4567 (data (gnus-data-find article))
4568 (thread (gnus-id-to-thread id))
4569 (references (mail-header-references header))
4570 (parent
4571 (gnus-id-to-thread
4572 (or (gnus-parent-id
4573 (when (and references
4574 (not (equal "" references)))
4575 references))
4576 "none")))
c7a91ce1 4577 (inhibit-read-only t)
6748645f 4578 (old (car thread)))
eec82323 4579 (when thread
eec82323 4580 (unless iheader
6748645f
LMI
4581 (setcar thread nil)
4582 (when parent
4583 (delq thread parent)))
4584 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4585 ;; Set the (possibly) new article number in the data structure.
4586 (gnus-data-set-number data (gnus-id-to-article id))
4587 (setcar thread old)
4588 nil))))
4589
6748645f
LMI
4590(defun gnus-rebuild-thread (id &optional line)
4591 "Rebuild the thread containing ID.
4592If LINE, insert the rebuilt thread starting on line LINE."
c7a91ce1 4593 (let ((inhibit-read-only t)
eec82323
LMI
4594 old-pos current thread data)
4595 (if (not gnus-show-threads)
4596 (setq thread (list (car (gnus-id-to-thread id))))
4597 ;; Get the thread this article is part of.
4598 (setq thread (gnus-remove-thread id)))
01c52d31 4599 (setq old-pos (point-at-bol))
eec82323 4600 (setq current (save-excursion
94384150 4601 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4602 (gnus-summary-article-number))))
4603 ;; If this is a gathered thread, we have to go some re-gathering.
4604 (when (stringp (car thread))
4605 (let ((subject (car thread))
4606 roots thr)
4607 (setq thread (cdr thread))
4608 (while thread
4609 (unless (memq (setq thr (gnus-id-to-thread
4610 (gnus-root-id
4611 (mail-header-id (caar thread)))))
4612 roots)
4613 (push thr roots))
4614 (setq thread (cdr thread)))
4615 ;; We now have all (unique) roots.
4616 (if (= (length roots) 1)
4617 ;; All the loose roots are now one solid root.
4618 (setq thread (car roots))
4619 (setq thread (cons subject (gnus-sort-threads roots))))))
4620 (let (threads)
4621 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4622 (when line
4623 (goto-char (point-min))
4624 (forward-line (1- line)))
eec82323
LMI
4625 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4626 (if gnus-show-threads
4627 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4628 (gnus-summary-prepare-unthreaded thread))
4629 (setq data (nreverse gnus-newsgroup-data))
4630 (setq threads gnus-newsgroup-threads))
4631 ;; We splice the new data into the data structure.
6748645f
LMI
4632 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4633 ;;!!! then we want to insert at the beginning of the buffer.
4634 ;;!!! That happens to be true with Gnus now, but that may
4635 ;;!!! change in the future. Perhaps.
4636 (gnus-data-enter-list
4637 (if line nil current) data (- (point) old-pos))
4638 (setq gnus-newsgroup-threads
4639 (nconc threads gnus-newsgroup-threads))
4640 (gnus-data-compute-positions))))
eec82323
LMI
4641
4642(defun gnus-number-to-header (number)
4643 "Return the header for article NUMBER."
4644 (let ((headers gnus-newsgroup-headers))
4645 (while (and headers
4646 (not (= number (mail-header-number (car headers)))))
4647 (pop headers))
4648 (when headers
4649 (car headers))))
4650
6748645f 4651(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4652 "Return the headers of the GENERATIONeth parent of HEADERS."
4653 (unless generation
4654 (setq generation 1))
a8151ef7 4655 (let ((parent t)
6748645f 4656 (headers in-headers)
a8151ef7 4657 references)
6748645f
LMI
4658 (while (and parent
4659 (not (zerop generation))
4660 (setq references (mail-header-references headers)))
4661 (setq headers (if (and references
4662 (setq parent (gnus-parent-id references)))
4663 (car (gnus-id-to-thread parent))
4664 nil))
4665 (decf generation))
4666 (and (not (eq headers in-headers))
4667 headers)))
eec82323
LMI
4668
4669(defun gnus-id-to-thread (id)
4670 "Return the (sub-)thread where ID appears."
4671 (gnus-gethash id gnus-newsgroup-dependencies))
4672
4673(defun gnus-id-to-article (id)
4674 "Return the article number of ID."
4675 (let ((thread (gnus-id-to-thread id)))
4676 (when (and thread
4677 (car thread))
4678 (mail-header-number (car thread)))))
4679
4680(defun gnus-id-to-header (id)
4681 "Return the article headers of ID."
4682 (car (gnus-id-to-thread id)))
4683
4684(defun gnus-article-displayed-root-p (article)
4685 "Say whether ARTICLE is a root(ish) article."
4686 (let ((level (gnus-summary-thread-level article))
4687 (refs (mail-header-references (gnus-summary-article-header article)))
4688 particle)
4689 (cond
4690 ((null level) nil)
4691 ((zerop level) t)
4692 ((null refs) t)
4693 ((null (gnus-parent-id refs)) t)
4694 ((and (= 1 level)
4695 (null (setq particle (gnus-id-to-article
4696 (gnus-parent-id refs))))
4697 (null (gnus-summary-thread-level particle)))))))
4698
4699(defun gnus-root-id (id)
4700 "Return the id of the root of the thread where ID appears."
4701 (let (last-id prev)
6748645f 4702 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4703 (setq last-id id
4704 id (gnus-parent-id (mail-header-references prev))))
4705 last-id))
4706
6748645f
LMI
4707(defun gnus-articles-in-thread (thread)
4708 "Return the list of articles in THREAD."
4709 (cons (mail-header-number (car thread))
4710 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4711
eec82323
LMI
4712(defun gnus-remove-thread (id &optional dont-remove)
4713 "Remove the thread that has ID in it."
6748645f 4714 (let (headers thread last-id)
eec82323 4715 ;; First go up in this thread until we find the root.
6748645f
LMI
4716 (setq last-id (gnus-root-id id)
4717 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4718 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4719 ;; been gathered into some loose thread, so we have to search
4720 ;; through the threads to find the thread we wanted.
4721 (let ((threads gnus-newsgroup-threads)
4722 sub)
4723 (while threads
4724 (setq sub (car threads))
4725 (if (stringp (car sub))
4726 ;; This is a gathered thread, so we look at the roots
4727 ;; below it to find whether this article is in this
4728 ;; gathered root.
4729 (progn
4730 (setq sub (cdr sub))
4731 (while sub
4732 (when (member (caar sub) headers)
4733 (setq thread (car threads)
4734 threads nil
4735 sub nil))
4736 (setq sub (cdr sub))))
4737 ;; It's an ordinary thread, so we check it.
4738 (when (eq (car sub) (car headers))
4739 (setq thread sub
4740 threads nil)))
4741 (setq threads (cdr threads)))
4742 ;; If this article is in no thread, then it's a root.
4743 (if thread
4744 (unless dont-remove
4745 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4746 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4747 (when thread
4748 (prog1
4749 thread ; We return this thread.
4750 (unless dont-remove
4751 (if (stringp (car thread))
4752 (progn
4753 ;; If we use dummy roots, then we have to remove the
4754 ;; dummy root as well.
4755 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4756 ;; We go to the dummy root by going to
4757 ;; the first sub-"thread", and then one line up.
4758 (gnus-summary-goto-article
4759 (mail-header-number (caadr thread)))
4760 (forward-line -1)
eec82323
LMI
4761 (gnus-delete-line)
4762 (gnus-data-compute-positions))
4763 (setq thread (cdr thread))
4764 (while thread
4765 (gnus-remove-thread-1 (car thread))
4766 (setq thread (cdr thread))))
4767 (gnus-remove-thread-1 thread))))))))
4768
4769(defun gnus-remove-thread-1 (thread)
4770 "Remove the thread THREAD recursively."
4771 (let ((number (mail-header-number (pop thread)))
4772 d)
4773 (setq thread (reverse thread))
4774 (while thread
4775 (gnus-remove-thread-1 (pop thread)))
4776 (when (setq d (gnus-data-find number))
4777 (goto-char (gnus-data-pos d))
16409b0b 4778 (gnus-summary-show-thread)
eec82323
LMI
4779 (gnus-data-remove
4780 number
01c52d31 4781 (- (point-at-bol)
eec82323 4782 (prog1
01c52d31 4783 (1+ (point-at-eol))
eec82323
LMI
4784 (gnus-delete-line)))))))
4785
4921bbdd 4786(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4787 (sort (mapcar (lambda (thread)
4788 (cons (car thread)
4789 (and (cdr thread)
4921bbdd 4790 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4791 threads) func))
4792
4921bbdd
CY
4793(defun gnus-sort-threads-loop (threads func)
4794 (let* ((superthread (cons nil threads))
4795 (stack (list (cons superthread threads)))
4796 remaining-threads thread)
4797 (while stack
4798 (setq remaining-threads (cdr (car stack)))
4799 (if remaining-threads
4800 (progn (setq thread (car remaining-threads))
4801 (setcdr (car stack) (cdr remaining-threads))
4802 (if (cdr thread)
4803 (push (cons thread (cdr thread)) stack)))
4804 (setq thread (caar stack))
4805 (setcdr thread (sort (cdr thread) func))
4806 (pop stack)))
4807 (cdr superthread)))
4808
eec82323
LMI
4809(defun gnus-sort-threads (threads)
4810 "Sort THREADS."
4811 (if (not gnus-thread-sort-functions)
4812 threads
6748645f 4813 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4814 (prog1
4815 (condition-case nil
4816 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4817 (gnus-sort-threads-recursive
4818 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4819 ;; Even after binding max-lisp-eval-depth, the recursive
4820 ;; sorter might fail for very long threads. In that case,
4821 ;; try using a (less well-tested) non-recursive sorter.
3d6e7a43
KY
4822 (error (gnus-message 9 "Sorting threads with loop...")
4823 (gnus-sort-threads-loop
4921bbdd
CY
4824 threads (gnus-make-sort-function
4825 gnus-thread-sort-functions))))
4826 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4827
4828(defun gnus-sort-articles (articles)
4829 "Sort ARTICLES."
4830 (when gnus-article-sort-functions
4831 (gnus-message 7 "Sorting articles...")
4832 (prog1
4833 (setq gnus-newsgroup-headers
4834 (sort articles (gnus-make-sort-function
4835 gnus-article-sort-functions)))
4836 (gnus-message 7 "Sorting articles...done"))))
4837
4838;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4839(defmacro gnus-thread-header (thread)
16409b0b
GM
4840 "Return header of first article in THREAD.
4841Note that THREAD must never, ever be anything else than a variable -
4842using some other form will lead to serious barfage."
eec82323
LMI
4843 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4844 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4845 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4846 (vector thread) 2))
4847
4848(defsubst gnus-article-sort-by-number (h1 h2)
4849 "Sort articles by article number."
4850 (< (mail-header-number h1)
4851 (mail-header-number h2)))
4852
4853(defun gnus-thread-sort-by-number (h1 h2)
4854 "Sort threads by root article number."
4855 (gnus-article-sort-by-number
4856 (gnus-thread-header h1) (gnus-thread-header h2)))
4857
23f87bed 4858(defsubst gnus-article-sort-by-random (h1 h2)
0b6799c3 4859 "Sort articles randomly."
23f87bed
MB
4860 (zerop (random 2)))
4861
4862(defun gnus-thread-sort-by-random (h1 h2)
0b6799c3 4863 "Sort threads randomly."
23f87bed
MB
4864 (gnus-article-sort-by-random
4865 (gnus-thread-header h1) (gnus-thread-header h2)))
4866
eec82323
LMI
4867(defsubst gnus-article-sort-by-lines (h1 h2)
4868 "Sort articles by article Lines header."
4869 (< (mail-header-lines h1)
4870 (mail-header-lines h2)))
4871
4872(defun gnus-thread-sort-by-lines (h1 h2)
4873 "Sort threads by root article Lines header."
4874 (gnus-article-sort-by-lines
4875 (gnus-thread-header h1) (gnus-thread-header h2)))
4876
16409b0b
GM
4877(defsubst gnus-article-sort-by-chars (h1 h2)
4878 "Sort articles by octet length."
4879 (< (mail-header-chars h1)
4880 (mail-header-chars h2)))
4881
4882(defun gnus-thread-sort-by-chars (h1 h2)
4883 "Sort threads by root article octet length."
4884 (gnus-article-sort-by-chars
4885 (gnus-thread-header h1) (gnus-thread-header h2)))
4886
eec82323
LMI
4887(defsubst gnus-article-sort-by-author (h1 h2)
4888 "Sort articles by root author."
b4fde39f 4889 (gnus-string<
eec82323
LMI
4890 (let ((extract (funcall
4891 gnus-extract-address-components
4892 (mail-header-from h1))))
4893 (or (car extract) (cadr extract) ""))
4894 (let ((extract (funcall
4895 gnus-extract-address-components
4896 (mail-header-from h2))))
4897 (or (car extract) (cadr extract) ""))))
4898
4899(defun gnus-thread-sort-by-author (h1 h2)
4900 "Sort threads by root author."
4901 (gnus-article-sort-by-author
4902 (gnus-thread-header h1) (gnus-thread-header h2)))
4903
01c52d31
MB
4904(defsubst gnus-article-sort-by-recipient (h1 h2)
4905 "Sort articles by recipient."
4906 (gnus-string<
4907 (let ((extract (funcall
4908 gnus-extract-address-components
4909 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4910 (or (car extract) (cadr extract)))
4911 (let ((extract (funcall
4912 gnus-extract-address-components
4913 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4914 (or (car extract) (cadr extract)))))
4915
4916(defun gnus-thread-sort-by-recipient (h1 h2)
4917 "Sort threads by root recipient."
4918 (gnus-article-sort-by-recipient
4919 (gnus-thread-header h1) (gnus-thread-header h2)))
4920
eec82323
LMI
4921(defsubst gnus-article-sort-by-subject (h1 h2)
4922 "Sort articles by root subject."
b4fde39f 4923 (gnus-string<
eec82323
LMI
4924 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4925 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4926
4927(defun gnus-thread-sort-by-subject (h1 h2)
4928 "Sort threads by root subject."
4929 (gnus-article-sort-by-subject
4930 (gnus-thread-header h1) (gnus-thread-header h2)))
4931
4932(defsubst gnus-article-sort-by-date (h1 h2)
4933 "Sort articles by root article date."
16409b0b 4934 (time-less-p
eec82323
LMI
4935 (gnus-date-get-time (mail-header-date h1))
4936 (gnus-date-get-time (mail-header-date h2))))
4937
4938(defun gnus-thread-sort-by-date (h1 h2)
4939 "Sort threads by root article date."
4940 (gnus-article-sort-by-date
4941 (gnus-thread-header h1) (gnus-thread-header h2)))
4942
4943(defsubst gnus-article-sort-by-score (h1 h2)
4944 "Sort articles by root article score.
4945Unscored articles will be counted as having a score of zero."
4946 (> (or (cdr (assq (mail-header-number h1)
4947 gnus-newsgroup-scored))
4948 gnus-summary-default-score 0)
4949 (or (cdr (assq (mail-header-number h2)
4950 gnus-newsgroup-scored))
4951 gnus-summary-default-score 0)))
4952
4953(defun gnus-thread-sort-by-score (h1 h2)
4954 "Sort threads by root article score."
4955 (gnus-article-sort-by-score
4956 (gnus-thread-header h1) (gnus-thread-header h2)))
4957
4958(defun gnus-thread-sort-by-total-score (h1 h2)
4959 "Sort threads by the sum of all scores in the thread.
4960Unscored articles will be counted as having a score of zero."
4961 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4962
4963(defun gnus-thread-total-score (thread)
16409b0b 4964 ;; This function find the total score of THREAD.
23f87bed
MB
4965 (cond
4966 ((null thread)
4967 0)
4968 ((consp thread)
4969 (if (stringp (car thread))
4970 (apply gnus-thread-score-function 0
4971 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4972 (gnus-thread-total-score-1 thread)))
4973 (t
4974 (gnus-thread-total-score-1 (list thread)))))
4975
4976(defun gnus-thread-sort-by-most-recent-number (h1 h2)
4977 "Sort threads such that the thread with the most recently arrived article comes first."
4978 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4979
4980(defun gnus-thread-highest-number (thread)
4981 "Return the highest article number in THREAD."
4982 (apply 'max (mapcar (lambda (header)
4983 (mail-header-number header))
4984 (message-flatten-list thread))))
4985
4986(defun gnus-thread-sort-by-most-recent-date (h1 h2)
4987 "Sort threads such that the thread with the most recently dated article comes first."
4988 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4989
3d6e7a43
KY
4990; Since this is called not only to sort the top-level threads, but
4991; also in recursive sorts to order the articles within a thread, each
4992; article will be processed many times. Thus it speeds things up
4993; quite a bit to use gnus-date-get-time, which caches the time value.
23f87bed
MB
4994(defun gnus-thread-latest-date (thread)
4995 "Return the highest article date in THREAD."
3d6e7a43
KY
4996 (apply 'max
4997 (mapcar (lambda (header) (gnus-float-time
4998 (gnus-date-get-time
4999 (mail-header-date header))))
5000 (message-flatten-list thread))))
eec82323
LMI
5001
5002(defun gnus-thread-total-score-1 (root)
5003 ;; This function find the total score of the thread below ROOT.
5004 (setq root (car root))
5005 (apply gnus-thread-score-function
5006 (or (append
5007 (mapcar 'gnus-thread-total-score
6748645f 5008 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
5009 (when (> (mail-header-number root) 0)
5010 (list (or (cdr (assq (mail-header-number root)
5011 gnus-newsgroup-scored))
5012 gnus-summary-default-score 0))))
5013 (list gnus-summary-default-score)
5014 '(0))))
5015
5016;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5017(defvar gnus-tmp-prev-subject nil)
5018(defvar gnus-tmp-false-parent nil)
5019(defvar gnus-tmp-root-expunged nil)
5020(defvar gnus-tmp-dummy-line nil)
5021
16409b0b
GM
5022(defun gnus-extra-header (type &optional header)
5023 "Return the extra header of TYPE."
5024 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5025 ""))
5026
23f87bed
MB
5027(defvar gnus-tmp-thread-tree-header-string "")
5028
5029(defcustom gnus-sum-thread-tree-root "> "
5030 "With %B spec, used for the root of a thread.
5031If nil, use subject instead."
bf247b6e 5032 :version "22.1"
ad136a7c 5033 :type '(radio (const :format "%v " nil) string)
23f87bed 5034 :group 'gnus-thread)
01c52d31 5035
23f87bed
MB
5036(defcustom gnus-sum-thread-tree-false-root "> "
5037 "With %B spec, used for a false root of a thread.
5038If nil, use subject instead."
bf247b6e 5039 :version "22.1"
ad136a7c 5040 :type '(radio (const :format "%v " nil) string)
23f87bed 5041 :group 'gnus-thread)
01c52d31 5042
23f87bed
MB
5043(defcustom gnus-sum-thread-tree-single-indent ""
5044 "With %B spec, used for a thread with just one message.
5045If nil, use subject instead."
bf247b6e 5046 :version "22.1"
ad136a7c 5047 :type '(radio (const :format "%v " nil) string)
23f87bed 5048 :group 'gnus-thread)
01c52d31 5049
23f87bed
MB
5050(defcustom gnus-sum-thread-tree-vertical "| "
5051 "With %B spec, used for drawing a vertical line."
bf247b6e 5052 :version "22.1"
23f87bed
MB
5053 :type 'string
5054 :group 'gnus-thread)
01c52d31 5055
23f87bed
MB
5056(defcustom gnus-sum-thread-tree-indent " "
5057 "With %B spec, used for indenting."
bf247b6e 5058 :version "22.1"
23f87bed
MB
5059 :type 'string
5060 :group 'gnus-thread)
01c52d31 5061
23f87bed
MB
5062(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5063 "With %B spec, used for a leaf with brothers."
bf247b6e 5064 :version "22.1"
23f87bed
MB
5065 :type 'string
5066 :group 'gnus-thread)
01c52d31 5067
23f87bed
MB
5068(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5069 "With %B spec, used for a leaf without brothers."
bf247b6e 5070 :version "22.1"
23f87bed
MB
5071 :type 'string
5072 :group 'gnus-thread)
5073
1fc34624
GM
5074(defcustom gnus-summary-display-while-building nil
5075 "If non-nil, show and update the summary buffer as it's being built.
5076If the value is t, update the buffer after every line is inserted. If
5077the value is an integer (N), update the display every N lines."
5078 :version "22.1"
5079 :group 'gnus-thread
5080 :type '(choice (const :tag "off" nil)
5081 number
5082 (const :tag "frequently" t)))
5083
eec82323
LMI
5084(defun gnus-summary-prepare-threads (threads)
5085 "Prepare summary buffer from THREADS and indentation LEVEL.
5086THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5087or a straight list of headers."
5088 (gnus-message 7 "Generating summary...")
5089
5090 (setq gnus-newsgroup-threads threads)
5091 (beginning-of-line)
5092
5093 (let ((gnus-tmp-level 0)
5094 (default-score (or gnus-summary-default-score 0))
5095 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
5096 (building-line-count gnus-summary-display-while-building)
5097 (building-count (integerp gnus-summary-display-while-building))
eec82323 5098 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
5099 new-roots gnus-tmp-new-adopts thread-end simp-subject
5100 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
5101 gnus-tmp-replied gnus-tmp-subject-or-nil
5102 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5103 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
5104 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5105 tree-stack)
eec82323 5106
23f87bed
MB
5107 (setq gnus-tmp-prev-subject nil
5108 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
5109
5110 (if (vectorp (car threads))
5111 ;; If this is a straight (sic) list of headers, then a
5112 ;; threaded summary display isn't required, so we just create
5113 ;; an unthreaded one.
5114 (gnus-summary-prepare-unthreaded threads)
5115
5116 ;; Do the threaded display.
5117
23f87bed
MB
5118 (if gnus-summary-display-while-building
5119 (switch-to-buffer (buffer-name)))
eec82323
LMI
5120 (while (or threads stack gnus-tmp-new-adopts new-roots)
5121
5122 (if (and (= gnus-tmp-level 0)
eec82323
LMI
5123 (or (not stack)
5124 (= (caar stack) 0))
5125 (not gnus-tmp-false-parent)
5126 (or gnus-tmp-new-adopts new-roots))
5127 (if gnus-tmp-new-adopts
5128 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5129 thread (list (car gnus-tmp-new-adopts))
5130 gnus-tmp-header (caar thread)
5131 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5132 (when new-roots
5133 (setq thread (list (car new-roots))
5134 gnus-tmp-header (caar thread)
5135 new-roots (cdr new-roots))))
5136
5137 (if threads
5138 ;; If there are some threads, we do them before the
5139 ;; threads on the stack.
5140 (setq thread threads
5141 gnus-tmp-header (caar thread))
5142 ;; There were no current threads, so we pop something off
5143 ;; the stack.
5144 (setq state (car stack)
5145 gnus-tmp-level (car state)
23f87bed
MB
5146 tree-stack (cadr state)
5147 thread (caddr state)
eec82323
LMI
5148 stack (cdr stack)
5149 gnus-tmp-header (caar thread))))
5150
5151 (setq gnus-tmp-false-parent nil)
5152 (setq gnus-tmp-root-expunged nil)
5153 (setq thread-end nil)
5154
5155 (if (stringp gnus-tmp-header)
5156 ;; The header is a dummy root.
5157 (cond
5158 ((eq gnus-summary-make-false-root 'adopt)
5159 ;; We let the first article adopt the rest.
5160 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5161 (cddar thread)))
5162 (setq gnus-tmp-gathered
5163 (nconc (mapcar
5164 (lambda (h) (mail-header-number (car h)))
5165 (cddar thread))
5166 gnus-tmp-gathered))
5167 (setq thread (cons (list (caar thread)
5168 (cadar thread))
5169 (cdr thread)))
5170 (setq gnus-tmp-level -1
5171 gnus-tmp-false-parent t))
5172 ((eq gnus-summary-make-false-root 'empty)
5173 ;; We print adopted articles with empty subject fields.
5174 (setq gnus-tmp-gathered
5175 (nconc (mapcar
5176 (lambda (h) (mail-header-number (car h)))
5177 (cddar thread))
5178 gnus-tmp-gathered))
5179 (setq gnus-tmp-level -1))
5180 ((eq gnus-summary-make-false-root 'dummy)
5181 ;; We remember that we probably want to output a dummy
5182 ;; root.
5183 (setq gnus-tmp-dummy-line gnus-tmp-header)
5184 (setq gnus-tmp-prev-subject gnus-tmp-header))
5185 (t
5186 ;; We do not make a root for the gathered
5187 ;; sub-threads at all.
5188 (setq gnus-tmp-level -1)))
5189
5190 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
5191 subject (mail-header-subject gnus-tmp-header)
5192 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
5193
5194 (cond
5195 ;; If the thread has changed subject, we might want to make
5196 ;; this subthread into a root.
5197 ((and (null gnus-thread-ignore-subject)
5198 (not (zerop gnus-tmp-level))
5199 gnus-tmp-prev-subject
23f87bed 5200 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5201 (setq new-roots (nconc new-roots (list (car thread)))
5202 thread-end t
5203 gnus-tmp-header nil))
5204 ;; If the article lies outside the current limit,
5205 ;; then we do not display it.
5206 ((not (memq number gnus-newsgroup-limit))
5207 (setq gnus-tmp-gathered
5208 (nconc (mapcar
5209 (lambda (h) (mail-header-number (car h)))
5210 (cdar thread))
5211 gnus-tmp-gathered))
5212 (setq gnus-tmp-new-adopts (if (cdar thread)
5213 (append gnus-tmp-new-adopts
5214 (cdar thread))
5215 gnus-tmp-new-adopts)
5216 thread-end t
5217 gnus-tmp-header nil)
5218 (when (zerop gnus-tmp-level)
5219 (setq gnus-tmp-root-expunged t)))
5220 ;; Perhaps this article is to be marked as read?
5221 ((and gnus-summary-mark-below
5222 (< (or (cdr (assq number gnus-newsgroup-scored))
5223 default-score)
5224 gnus-summary-mark-below)
5225 ;; Don't touch sparse articles.
5226 (not (gnus-summary-article-sparse-p number))
5227 (not (gnus-summary-article-ancient-p number)))
5228 (setq gnus-newsgroup-unreads
5229 (delq number gnus-newsgroup-unreads))
5230 (if gnus-newsgroup-auto-expire
23f87bed
MB
5231 (setq gnus-newsgroup-expirable
5232 (gnus-add-to-sorted-list
5233 gnus-newsgroup-expirable number))
eec82323
LMI
5234 (push (cons number gnus-low-score-mark)
5235 gnus-newsgroup-reads))))
5236
5237 (when gnus-tmp-header
5238 ;; We may have an old dummy line to output before this
5239 ;; article.
6748645f
LMI
5240 (when (and gnus-tmp-dummy-line
5241 (gnus-subject-equal
5242 gnus-tmp-dummy-line
5243 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
5244 (gnus-summary-insert-dummy-line
5245 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5246 (setq gnus-tmp-dummy-line nil))
5247
5248 ;; Compute the mark.
5249 (setq gnus-tmp-unread (gnus-article-mark number))
5250
5251 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5252 gnus-tmp-header gnus-tmp-level)
5253 gnus-newsgroup-data)
5254
5255 ;; Actually insert the line.
5256 (setq
5257 gnus-tmp-subject-or-nil
5258 (cond
5259 ((and gnus-thread-ignore-subject
5260 gnus-tmp-prev-subject
23f87bed 5261 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5262 subject)
5263 ((zerop gnus-tmp-level)
5264 (if (and (eq gnus-summary-make-false-root 'empty)
5265 (memq number gnus-tmp-gathered)
5266 gnus-tmp-prev-subject
23f87bed 5267 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5268 gnus-summary-same-subject
5269 subject))
5270 (t gnus-summary-same-subject)))
5271 (if (and (eq gnus-summary-make-false-root 'adopt)
5272 (= gnus-tmp-level 1)
5273 (memq number gnus-tmp-gathered))
5274 (setq gnus-tmp-opening-bracket ?\<
5275 gnus-tmp-closing-bracket ?\>)
5276 (setq gnus-tmp-opening-bracket ?\[
5277 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5278 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5279 (gnus-make-thread-indent-array
5280 (max (* 2 (length gnus-thread-indent-array))
5281 gnus-tmp-level)))
eec82323
LMI
5282 (setq
5283 gnus-tmp-indentation
5284 (aref gnus-thread-indent-array gnus-tmp-level)
5285 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5286 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5287 gnus-summary-default-score 0)
5288 gnus-tmp-score-char
5289 (if (or (null gnus-summary-default-score)
5290 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5291 gnus-summary-zcore-fuzz))
23f87bed 5292 ? ;Whitespace
eec82323
LMI
5293 (if (< gnus-tmp-score gnus-summary-default-score)
5294 gnus-score-below-mark gnus-score-over-mark))
5295 gnus-tmp-replied
5296 (cond ((memq number gnus-newsgroup-processable)
5297 gnus-process-mark)
5298 ((memq number gnus-newsgroup-cached)
5299 gnus-cached-mark)
5300 ((memq number gnus-newsgroup-replied)
5301 gnus-replied-mark)
23f87bed
MB
5302 ((memq number gnus-newsgroup-forwarded)
5303 gnus-forwarded-mark)
eec82323
LMI
5304 ((memq number gnus-newsgroup-saved)
5305 gnus-saved-mark)
23f87bed
MB
5306 ((memq number gnus-newsgroup-recent)
5307 gnus-recent-mark)
5308 ((memq number gnus-newsgroup-unseen)
5309 gnus-unseen-mark)
5310 (t gnus-no-mark))
5311 gnus-tmp-downloaded
5312 (cond ((memq number gnus-newsgroup-undownloaded)
5313 gnus-undownloaded-mark)
5314 (gnus-newsgroup-agentized
5315 gnus-downloaded-mark)
5316 (t
5317 gnus-no-mark))
eec82323
LMI
5318 gnus-tmp-from (mail-header-from gnus-tmp-header)
5319 gnus-tmp-name
5320 (cond
5321 ((string-match "<[^>]+> *$" gnus-tmp-from)
5322 (setq beg-match (match-beginning 0))
23f87bed
MB
5323 (or (and (string-match "^\".+\"" gnus-tmp-from)
5324 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5325 (substring gnus-tmp-from 0 beg-match)))
5326 ((string-match "(.+)" gnus-tmp-from)
5327 (substring gnus-tmp-from
5328 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5329 (t gnus-tmp-from))
5330
5331 ;; Do the %B string
5332 gnus-tmp-thread-tree-header-string
5333 (cond
5334 ((not gnus-show-threads) "")
5335 ((zerop gnus-tmp-level)
5336 (cond ((cdar thread)
5337 (or gnus-sum-thread-tree-root subject))
5338 (gnus-tmp-new-adopts
5339 (or gnus-sum-thread-tree-false-root subject))
5340 (t
5341 (or gnus-sum-thread-tree-single-indent subject))))
5342 (t
5343 (concat (apply 'concat
5344 (mapcar (lambda (item)
5345 (if (= item 1)
5346 gnus-sum-thread-tree-vertical
5347 gnus-sum-thread-tree-indent))
5348 (cdr (reverse tree-stack))))
5349 (if (nth 1 thread)
5350 gnus-sum-thread-tree-leaf-with-other
5351 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5352 (when (string= gnus-tmp-name "")
5353 (setq gnus-tmp-name gnus-tmp-from))
5354 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5355 (setq gnus-tmp-lines -1))
5356 (if (= gnus-tmp-lines -1)
5357 (setq gnus-tmp-lines "?")
5358 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5359 (gnus-put-text-property
64763fe3
MB
5360 (point)
5361 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 5362 'gnus-number number)
64763fe3
MB
5363 (when gnus-visual-p
5364 (forward-line -1)
5365 (gnus-run-hooks 'gnus-summary-update-hook)
5366 (forward-line 1))
eec82323 5367
64763fe3 5368 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5369
5370 (when (nth 1 thread)
23f87bed
MB
5371 (push (list (max 0 gnus-tmp-level)
5372 (copy-sequence tree-stack)
5373 (nthcdr 1 thread))
5374 stack))
5375 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5376 (incf gnus-tmp-level)
5377 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5378 (if gnus-summary-display-while-building
5379 (if building-count
5380 (progn
5381 ;; use a set frequency
5382 (setq building-line-count (1- building-line-count))
5383 (when (= building-line-count 0)
5384 (sit-for 0)
5385 (setq building-line-count
5386 gnus-summary-display-while-building)))
5387 ;; always
5388 (sit-for 0)))
eec82323
LMI
5389 (unless threads
5390 (setq gnus-tmp-level 0)))))
5391 (gnus-message 7 "Generating summary...done"))
5392
5393(defun gnus-summary-prepare-unthreaded (headers)
5394 "Generate an unthreaded summary buffer based on HEADERS."
5395 (let (header number mark)
5396
5397 (beginning-of-line)
5398
5399 (while headers
5400 ;; We may have to root out some bad articles...
5401 (when (memq (setq number (mail-header-number
5402 (setq header (pop headers))))
5403 gnus-newsgroup-limit)
5404 ;; Mark article as read when it has a low score.
5405 (when (and gnus-summary-mark-below
5406 (< (or (cdr (assq number gnus-newsgroup-scored))
5407 gnus-summary-default-score 0)
5408 gnus-summary-mark-below)
5409 (not (gnus-summary-article-ancient-p number)))
5410 (setq gnus-newsgroup-unreads
5411 (delq number gnus-newsgroup-unreads))
5412 (if gnus-newsgroup-auto-expire
5413 (push number gnus-newsgroup-expirable)
5414 (push (cons number gnus-low-score-mark)
5415 gnus-newsgroup-reads)))
5416
5417 (setq mark (gnus-article-mark number))
5418 (push (gnus-data-make number mark (1+ (point)) header 0)
5419 gnus-newsgroup-data)
5420 (gnus-summary-insert-line
5421 header 0 number
23f87bed 5422 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5423 mark (memq number gnus-newsgroup-replied)
5424 (memq number gnus-newsgroup-expirable)
5425 (mail-header-subject header) nil
5426 (cdr (assq number gnus-newsgroup-scored))
5427 (memq number gnus-newsgroup-processable))))))
5428
16409b0b
GM
5429(defun gnus-summary-remove-list-identifiers ()
5430 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5431 (let ((regexp (if (consp gnus-list-identifiers)
5432 (mapconcat 'identity gnus-list-identifiers " *\\|")
5433 gnus-list-identifiers))
5434 changed subject)
5435 (when regexp
01c52d31 5436 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
23f87bed
MB
5437 (dolist (header gnus-newsgroup-headers)
5438 (setq subject (mail-header-subject header)
5439 changed nil)
01c52d31 5440 (while (string-match regexp subject)
23f87bed 5441 (setq subject
01c52d31 5442 (concat (substring subject 0 (match-beginning 1))
23f87bed
MB
5443 (substring subject (match-end 0)))
5444 changed t))
23f87bed 5445 (when changed
01c52d31
MB
5446 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5447 (setq subject
5448 (concat (substring subject 0 (match-beginning 1))
5449 (substring subject (match-end 1)))))
23f87bed
MB
5450 (mail-header-set-subject header subject))))))
5451
5452(defun gnus-fetch-headers (articles)
5453 "Fetch headers of ARTICLES."
5454 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5455 (gnus-message 5 "Fetching headers for %s..." name)
5456 (prog1
5457 (if (eq 'nov
5458 (setq gnus-headers-retrieved-by
5459 (gnus-retrieve-headers
5460 articles gnus-newsgroup-name
5461 ;; We might want to fetch old headers, but
5462 ;; not if there is only 1 article.
5463 (and (or (and
5464 (not (eq gnus-fetch-old-headers 'some))
5465 (not (numberp gnus-fetch-old-headers)))
5466 (> (length articles) 1))
5467 gnus-fetch-old-headers))))
5468 (gnus-get-newsgroup-headers-xover
5469 articles nil nil gnus-newsgroup-name t)
5470 (gnus-get-newsgroup-headers))
5471 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5472
6748645f 5473(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5474 "Select newsgroup GROUP.
6748645f
LMI
5475If READ-ALL is non-nil, all articles in the group are selected.
5476If SELECT-ARTICLES, only select those articles from GROUP."
01c52d31 5477 (let* ((entry (gnus-group-entry group))
eec82323
LMI
5478 ;;!!! Dirty hack; should be removed.
5479 (gnus-summary-ignore-duplicates
23f87bed 5480 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5481 t
5482 gnus-summary-ignore-duplicates))
5483 (info (nth 2 entry))
01c52d31 5484 charset articles fetched-articles cached)
eec82323
LMI
5485
5486 (unless (gnus-check-server
475e0e0c
GM
5487 (set (make-local-variable 'gnus-current-select-method)
5488 (gnus-find-method-for-group group)))
eec82323 5489 (error "Couldn't open server"))
01c52d31 5490 (setq charset (gnus-group-name-charset gnus-current-select-method group))
eec82323
LMI
5491
5492 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5493 (gnus-activate-group group) ; Or we can activate it...
5494 (progn ; Or we bug out.
5495 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5496 (gnus-kill-buffer (current-buffer)))
01c52d31
MB
5497 (error
5498 "Couldn't activate group %s: %s"
5499 (mm-decode-coding-string group charset)
5500 (mm-decode-coding-string (gnus-status-message group) charset))))
eec82323
LMI
5501
5502 (unless (gnus-request-group group t)
01c52d31
MB
5503 (when (equal major-mode 'gnus-summary-mode)
5504 (gnus-kill-buffer (current-buffer)))
5505 (error "Couldn't request group %s: %s"
5506 (mm-decode-coding-string group charset)
5507 (mm-decode-coding-string (gnus-status-message group) charset)))
eec82323 5508
23f87bed 5509 (when gnus-agent
54506618 5510 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5511
23f87bed
MB
5512 (setq gnus-summary-use-undownloaded-faces
5513 (gnus-agent-find-parameter
5514 group
5515 'agent-enable-undownloaded-faces)))
5516
5517 (setq gnus-newsgroup-name group
5518 gnus-newsgroup-unselected nil
5519 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5520
5521 (let ((display (gnus-group-find-parameter group 'display)))
5522 (setq gnus-newsgroup-display
5523 (cond
5524 ((not (zerop (or (car-safe read-all) 0)))
5525 ;; The user entered the group with C-u SPC/RET, let's show
5526 ;; all articles.
5527 'gnus-not-ignore)
5528 ((eq display 'all)
5529 'gnus-not-ignore)
5530 ((arrayp display)
5531 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5532 ((numberp display)
5533 ;; The following is probably the "correct" solution, but
5534 ;; it makes Gnus fetch all headers and then limit the
5535 ;; articles (which is slow), so instead we hack the
5536 ;; select-articles parameter instead. -- Simon Josefsson
5537 ;; <jas@kth.se>
5538 ;;
5539 ;; (gnus-byte-compile
5540 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5541 ;; display)))))
5542 (setq select-articles
5543 (gnus-uncompress-range
5544 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5545 (if (> tmp 0)
5546 tmp
5547 1))
5548 (cdr (gnus-active group)))))
5549 nil)
5550 (t
5551 nil))))
eec82323 5552
23f87bed 5553 (gnus-summary-setup-default-charset)
eec82323
LMI
5554
5555 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5556 (when (gnus-virtual-group-p group)
5557 (setq cached gnus-newsgroup-cached))
5558
5559 (setq gnus-newsgroup-unreads
23f87bed
MB
5560 (gnus-sorted-ndifference
5561 (gnus-sorted-ndifference gnus-newsgroup-unreads
5562 gnus-newsgroup-marked)
eec82323
LMI
5563 gnus-newsgroup-dormant))
5564
5565 (setq gnus-newsgroup-processable nil)
5566
5567 (gnus-update-read-articles group gnus-newsgroup-unreads)
eec82323 5568
23f87bed
MB
5569 ;; Adjust and set lists of article marks.
5570 (when info
5571 (gnus-adjust-marked-articles info))
6748645f
LMI
5572 (if (setq articles select-articles)
5573 (setq gnus-newsgroup-unselected
23f87bed 5574 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5575 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5576
5577 (cond
5578 ((null articles)
5579 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5580 'quit)
5581 ((eq articles 0) nil)
5582 (t
5583 ;; Init the dependencies hash table.
5584 (setq gnus-newsgroup-dependencies
5585 (gnus-make-hashtable (length articles)))
16409b0b 5586 (gnus-set-global-variables)
eec82323 5587 ;; Retrieve the headers and read them in.
23f87bed
MB
5588
5589 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5590
5591 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5592 (when cached
5593 (setq gnus-newsgroup-cached cached))
5594
5595 ;; Suppress duplicates?
5596 (when gnus-suppress-duplicates
5597 (gnus-dup-suppress-articles))
5598
5599 ;; Set the initial limit.
5600 (setq gnus-newsgroup-limit (copy-sequence articles))
5601 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5602 (setq fetched-articles
5603 (mapcar (lambda (headers) (mail-header-number headers))
5604 gnus-newsgroup-headers))
5605 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5606 (setq gnus-newsgroup-unreads
23f87bed
MB
5607 (gnus-sorted-nintersection
5608 gnus-newsgroup-unreads fetched-articles))
5609 (gnus-compute-unseen-list)
5610
eec82323
LMI
5611 ;; Removed marked articles that do not exist.
5612 (gnus-update-missing-marks
23f87bed 5613 (gnus-sorted-difference articles fetched-articles))
eec82323 5614 ;; We might want to build some more threads first.
6748645f
LMI
5615 (when (and gnus-fetch-old-headers
5616 (eq gnus-headers-retrieved-by 'nov))
5617 (if (eq gnus-fetch-old-headers 'invisible)
5618 (gnus-build-all-threads)
5619 (gnus-build-old-threads)))
5620 ;; Let the Gnus agent mark articles as read.
5621 (when gnus-agent
5622 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5623 ;; Remove list identifiers from subject
5624 (when gnus-list-identifiers
5625 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5626 ;; Check whether auto-expire is to be done in this group.
5627 (setq gnus-newsgroup-auto-expire
5628 (gnus-group-auto-expirable-p group))
5629 ;; Set up the article buffer now, if necessary.
01c52d31
MB
5630 (unless (and gnus-single-article-buffer
5631 (equal gnus-article-buffer "*Article*"))
eec82323
LMI
5632 (gnus-article-setup-buffer))
5633 ;; First and last article in this newsgroup.
5634 (when gnus-newsgroup-headers
5635 (setq gnus-newsgroup-begin
5636 (mail-header-number (car gnus-newsgroup-headers))
5637 gnus-newsgroup-end
5638 (mail-header-number
5639 (gnus-last-element gnus-newsgroup-headers))))
5640 ;; GROUP is successfully selected.
5641 (or gnus-newsgroup-headers t)))))
5642
23f87bed
MB
5643(defun gnus-compute-unseen-list ()
5644 ;; The `seen' marks are treated specially.
5645 (if (not gnus-newsgroup-seen)
5646 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5647 (setq gnus-newsgroup-unseen
5648 (gnus-inverse-list-range-intersection
5649 gnus-newsgroup-articles gnus-newsgroup-seen))))
5650
d09ae6ca
GM
5651(declare-function gnus-get-predicate "gnus-agent" (predicate))
5652
23f87bed
MB
5653(defun gnus-summary-display-make-predicate (display)
5654 (require 'gnus-agent)
5655 (when (= (length display) 1)
5656 (setq display (car display)))
5657 (unless gnus-summary-display-cache
5658 (dolist (elem (append '((unread . unread)
5659 (read . read)
5660 (unseen . unseen))
5661 gnus-article-mark-lists))
5662 (push (cons (cdr elem)
5663 (gnus-byte-compile
5664 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5665 gnus-summary-display-cache)))
5666 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5667 (gnus-category-predicate-cache gnus-summary-display-cache))
5668 (gnus-get-predicate display)))
5669
5670;; Uses the dynamically bound `number' variable.
9efa445f 5671(defvar number)
23f87bed
MB
5672(defun gnus-article-marked-p (type &optional article)
5673 (let ((article (or article number)))
5674 (cond
5675 ((eq type 'tick)
5676 (memq article gnus-newsgroup-marked))
5677 ((eq type 'spam)
5678 (memq article gnus-newsgroup-spam-marked))
5679 ((eq type 'unsend)
5680 (memq article gnus-newsgroup-unsendable))
5681 ((eq type 'undownload)
5682 (memq article gnus-newsgroup-undownloaded))
5683 ((eq type 'download)
5684 (memq article gnus-newsgroup-downloadable))
5685 ((eq type 'unread)
5686 (memq article gnus-newsgroup-unreads))
5687 ((eq type 'read)
5688 (memq article gnus-newsgroup-reads))
5689 ((eq type 'dormant)
5690 (memq article gnus-newsgroup-dormant) )
5691 ((eq type 'expire)
5692 (memq article gnus-newsgroup-expirable))
5693 ((eq type 'reply)
5694 (memq article gnus-newsgroup-replied))
5695 ((eq type 'killed)
5696 (memq article gnus-newsgroup-killed))
5697 ((eq type 'bookmark)
5698 (assq article gnus-newsgroup-bookmarks))
5699 ((eq type 'score)
5700 (assq article gnus-newsgroup-scored))
5701 ((eq type 'save)
5702 (memq article gnus-newsgroup-saved))
5703 ((eq type 'cache)
5704 (memq article gnus-newsgroup-cached))
5705 ((eq type 'forward)
5706 (memq article gnus-newsgroup-forwarded))
5707 ((eq type 'seen)
5708 (not (memq article gnus-newsgroup-unseen)))
5709 ((eq type 'recent)
5710 (memq article gnus-newsgroup-recent))
5711 (t t))))
5712
eec82323 5713(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5714 "Find out what articles the user wants to read."
26c9afc3 5715 (let* ((articles
eec82323
LMI
5716 ;; Select all articles if `read-all' is non-nil, or if there
5717 ;; are no unread articles.
5718 (if (or read-all
5719 (and (zerop (length gnus-newsgroup-marked))
5720 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5721 ;; Fetch all if the predicate is non-nil.
5722 gnus-newsgroup-display)
5723 ;; We want to select the headers for all the articles in
5724 ;; the group, so we select either all the active
5725 ;; articles in the group, or (if that's nil), the
5726 ;; articles in the cache.
16409b0b 5727 (or
4b70e299 5728 (if gnus-newsgroup-maximum-articles
11abff8e
MB
5729 (let ((active (gnus-active group)))
5730 (gnus-uncompress-range
5731 (cons (max (car active)
4b70e299
MB
5732 (- (cdr active)
5733 gnus-newsgroup-maximum-articles
5734 -1))
11abff8e
MB
5735 (cdr active))))
5736 (gnus-uncompress-range (gnus-active group)))
16409b0b 5737 (gnus-cache-articles-in-group group))
23f87bed
MB
5738 ;; Select only the "normal" subset of articles.
5739 (gnus-sorted-nunion
5740 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5741 gnus-newsgroup-unreads)))
eec82323
LMI
5742 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5743 (scored (length scored-list))
5744 (number (length articles))
5745 (marked (+ (length gnus-newsgroup-marked)
5746 (length gnus-newsgroup-dormant)))
5747 (select
5748 (cond
5749 ((numberp read-all)
5750 read-all)
23f87bed
MB
5751 ((numberp gnus-newsgroup-display)
5752 gnus-newsgroup-display)
eec82323
LMI
5753 (t
5754 (condition-case ()
5755 (cond
5756 ((and (or (<= scored marked) (= scored number))
5757 (numberp gnus-large-newsgroup)
5758 (> number gnus-large-newsgroup))
23f87bed
MB
5759 (let* ((cursor-in-echo-area nil)
5760 (initial (gnus-parameter-large-newsgroup-initial
5761 gnus-newsgroup-name))
5762 (input
5763 (read-string
5764 (format
5765 "How many articles from %s (%s %d): "
01c52d31 5766 (gnus-group-decoded-name gnus-newsgroup-name)
23f87bed
MB
5767 (if initial "max" "default")
5768 number)
5769 (if initial
5770 (cons (number-to-string initial)
5771 0)))))
eec82323
LMI
5772 (if (string-match "^[ \t]*$" input) number input)))
5773 ((and (> scored marked) (< scored number)
5774 (> (- scored number) 20))
5775 (let ((input
5776 (read-string
5777 (format "%s %s (%d scored, %d total): "
5778 "How many articles from"
23f87bed
MB
5779 (gnus-group-decoded-name group)
5780 scored number))))
eec82323
LMI
5781 (if (string-match "^[ \t]*$" input)
5782 number input)))
5783 (t number))
d4dfaa19
DL
5784 (quit
5785 (message "Quit getting the articles to read")
5786 nil))))))
eec82323
LMI
5787 (setq select (if (stringp select) (string-to-number select) select))
5788 (if (or (null select) (zerop select))
5789 select
5790 (if (and (not (zerop scored)) (<= (abs select) scored))
5791 (progn
5792 (setq articles (sort scored-list '<))
5793 (setq number (length articles)))
5794 (setq articles (copy-sequence articles)))
5795
5796 (when (< (abs select) number)
5797 (if (< select 0)
5798 ;; Select the N oldest articles.
5799 (setcdr (nthcdr (1- (abs select)) articles) nil)
5800 ;; Select the N most recent articles.
5801 (setq articles (nthcdr (- number select) articles))))
5802 (setq gnus-newsgroup-unselected
23f87bed 5803 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5804 (when gnus-alter-articles-to-read-function
23f87bed 5805 (setq articles
a1506d29 5806 (sort
16409b0b 5807 (funcall gnus-alter-articles-to-read-function
23f87bed 5808 gnus-newsgroup-name articles)
16409b0b 5809 '<)))
eec82323
LMI
5810 articles)))
5811
5812(defun gnus-killed-articles (killed articles)
5813 (let (out)
5814 (while articles
5815 (when (inline (gnus-member-of-range (car articles) killed))
5816 (push (car articles) out))
5817 (setq articles (cdr articles)))
5818 out))
5819
5820(defun gnus-uncompress-marks (marks)
5821 "Uncompress the mark ranges in MARKS."
5822 (let ((uncompressed '(score bookmark))
5823 out)
5824 (while marks
5825 (if (memq (caar marks) uncompressed)
5826 (push (car marks) out)
5827 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5828 (setq marks (cdr marks)))
5829 out))
5830
23f87bed
MB
5831(defun gnus-article-mark-to-type (mark)
5832 "Return the type of MARK."
5833 (or (cadr (assq mark gnus-article-special-mark-lists))
5834 'list))
5835
5836(defun gnus-article-unpropagatable-p (mark)
5837 "Return whether MARK should be propagated to back end."
5838 (memq mark gnus-article-unpropagated-mark-lists))
5839
eec82323 5840(defun gnus-adjust-marked-articles (info)
16409b0b 5841 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5842 (let* ((marked-lists (gnus-info-marks info))
5843 (active (gnus-active (gnus-info-group info)))
5844 (min (car active))
5845 (max (cdr active))
5846 (types gnus-article-mark-lists)
54506618
MB
5847 marks var articles article mark mark-type
5848 bgn end)
eec82323 5849
23f87bed
MB
5850 (dolist (marks marked-lists)
5851 (setq mark (car marks)
5852 mark-type (gnus-article-mark-to-type mark)
5853 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5854
23f87bed
MB
5855 ;; We set the variable according to the type of the marks list,
5856 ;; and then adjust the marks to a subset of the active articles.
eec82323 5857 (cond
54506618 5858 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5859 ((eq mark-type 'list)
54506618
MB
5860 ;; Simultaneously uncompress and clip to active range
5861 ;; See gnus-uncompress-range for a description of possible marks
5862 (let (l lh)
5863 (if (not (cadr marks))
5864 (set var nil)
5865 (setq articles (if (numberp (cddr marks))
5866 (list (cdr marks))
5867 (cdr marks))
5868 lh (cons nil nil)
5869 l lh)
5870
5871 (while (setq article (pop articles))
5872 (cond ((consp article)
5873 (setq bgn (max (car article) min)
5874 end (min (cdr article) max))
5875 (while (<= bgn end)
5876 (setq l (setcdr l (cons bgn nil))
5877 bgn (1+ bgn))))
5878 ((and (<= min article)
5879 (>= max article))
5880 (setq l (setcdr l (cons article nil))))))
5881 (set var (cdr lh)))))
eec82323 5882 ;; Adjust assocs.
23f87bed
MB
5883 ((eq mark-type 'tuple)
5884 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5885 (when (not (listp (cdr (symbol-value var))))
5886 (set var (list (symbol-value var))))
5887 (when (not (listp (cdr articles)))
5888 (setq articles (list articles)))
eec82323
LMI
5889 (while articles
5890 (when (or (not (consp (setq article (pop articles))))
5891 (< (car article) min)
5892 (> (car article) max))
23f87bed
MB
5893 (set var (delq article (symbol-value var))))))
5894 ;; Adjust ranges (sloppily).
5895 ((eq mark-type 'range)
5896 (cond
5897 ((eq mark 'seen)
5898 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5899 ;; It should be (seen (NUM1 . NUM2)).
5900 (when (numberp (cddr marks))
5901 (setcdr marks (list (cdr marks))))
5902 (setq articles (cdr marks))
5903 (while (and articles
5904 (or (and (consp (car articles))
5905 (> min (cdar articles)))
5906 (and (numberp (car articles))
5907 (> min (car articles)))))
5908 (pop articles))
5909 (set var articles))))))))
eec82323
LMI
5910
5911(defun gnus-update-missing-marks (missing)
6748645f 5912 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 5913 (when missing
23f87bed 5914 (let (var m)
eec82323 5915 ;; Go through all types.
23f87bed
MB
5916 (dolist (elem gnus-article-mark-lists)
5917 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5918 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5919 (when (symbol-value var)
5920 ;; This list has articles. So we delete all missing
5921 ;; articles from it.
5922 (setq m missing)
5923 (while m
5924 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
5925
5926(defun gnus-update-marks ()
5927 "Enter the various lists of marked articles into the newsgroup info list."
5928 (let ((types gnus-article-mark-lists)
5929 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 5930 type list newmarked symbol delta-marks)
eec82323 5931 (when info
16409b0b 5932 ;; Add all marks lists to the list of marks lists.
eec82323 5933 (while (setq type (pop types))
16409b0b
GM
5934 (setq list (symbol-value
5935 (setq symbol
23f87bed 5936 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 5937
16409b0b 5938 (when list
eec82323
LMI
5939 ;; Get rid of the entries of the articles that have the
5940 ;; default score.
5941 (when (and (eq (cdr type) 'score)
5942 gnus-save-score
5943 list)
5944 (let* ((arts list)
5945 (prev (cons nil list))
5946 (all prev))
5947 (while arts
5948 (if (or (not (consp (car arts)))
5949 (= (cdar arts) gnus-summary-default-score))
5950 (setcdr prev (cdr arts))
5951 (setq prev arts))
5952 (setq arts (cdr arts)))
16409b0b
GM
5953 (setq list (cdr all)))))
5954
23f87bed
MB
5955 (when (eq (cdr type) 'seen)
5956 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5957
5958 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 5959 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 5960
23f87bed
MB
5961 (when (and (gnus-check-backend-function
5962 'request-set-mark gnus-newsgroup-name)
5963 (not (gnus-article-unpropagatable-p (cdr type))))
5964 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5965 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5966 (add (gnus-remove-from-range
5967 (gnus-copy-sequence list) old)))
5968 (when add
5969 (push (list add 'add (list (cdr type))) delta-marks))
5970 (when del
5971 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 5972
16409b0b
GM
5973 (when list
5974 (push (cons (cdr type) list) newmarked)))
5975
5976 (when delta-marks
5977 (unless (gnus-check-group gnus-newsgroup-name)
5978 (error "Can't open server for %s" gnus-newsgroup-name))
5979 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 5980
eec82323
LMI
5981 ;; Enter these new marks into the info of the group.
5982 (if (nthcdr 3 info)
5983 (setcar (nthcdr 3 info) newmarked)
5984 ;; Add the marks lists to the end of the info.
5985 (when newmarked
5986 (setcdr (nthcdr 2 info) (list newmarked))))
5987
5988 ;; Cut off the end of the info if there's nothing else there.
5989 (let ((i 5))
5990 (while (and (> i 2)
5991 (not (nth i info)))
5992 (when (nthcdr (decf i) info)
5993 (setcdr (nthcdr i info) nil)))))))
5994
5995(defun gnus-set-mode-line (where)
16409b0b 5996 "Set the mode line of the article or summary buffers.
eec82323
LMI
5997If WHERE is `summary', the summary mode line format will be used."
5998 ;; Is this mode line one we keep updated?
16409b0b
GM
5999 (when (and (memq where gnus-updated-mode-lines)
6000 (symbol-value
6001 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323 6002 (let (mode-string)
c7a91ce1
SM
6003 ;; We evaluate this in the summary buffer since these
6004 ;; variables are buffer-local to that buffer.
6005 (with-current-buffer gnus-summary-buffer
6006 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
6007 ;; below.
6008 (let* ((mformat (symbol-value
6009 (intern
6010 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
6011 (gnus-tmp-group-name (gnus-mode-string-quote
6012 (gnus-group-decoded-name
6013 gnus-newsgroup-name)))
eec82323
LMI
6014 (gnus-tmp-article-number (or gnus-current-article 0))
6015 (gnus-tmp-unread gnus-newsgroup-unreads)
6016 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6017 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6018 (gnus-tmp-unread-and-unselected
6019 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6020 (zerop gnus-tmp-unselected))
6021 "")
6022 ((zerop gnus-tmp-unselected)
6023 (format "{%d more}" gnus-tmp-unread-and-unticked))
6024 (t (format "{%d(+%d) more}"
6025 gnus-tmp-unread-and-unticked
6026 gnus-tmp-unselected))))
6027 (gnus-tmp-subject
6028 (if (and gnus-current-headers
6029 (vectorp gnus-current-headers))
6030 (gnus-mode-string-quote
6031 (mail-header-subject gnus-current-headers))
6032 ""))
6033 bufname-length max-len
23f87bed 6034 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
6035 (setq mode-string (eval mformat))
6036 (setq bufname-length (if (string-match "%b" mode-string)
6037 (- (length
6038 (buffer-name
6039 (if (eq where 'summary)
6040 nil
6041 (get-buffer gnus-article-buffer))))
6042 2)
6043 0))
6044 (setq max-len (max 4 (if gnus-mode-non-string-length
6045 (- (window-width)
6046 gnus-mode-non-string-length
6047 bufname-length)
6048 (length mode-string))))
6049 ;; We might have to chop a bit of the string off...
6050 (when (> (length mode-string) max-len)
6051 (setq mode-string
16409b0b 6052 (concat (truncate-string-to-width mode-string (- max-len 3))
eec82323
LMI
6053 "...")))
6054 ;; Pad the mode string a bit.
6055 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
6056 ;; Update the mode line.
6057 (setq mode-line-buffer-identification
6058 (gnus-mode-line-buffer-identification (list mode-string)))
6059 (set-buffer-modified-p t))))
6060
6061(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6062 "Go through the HEADERS list and add all Xrefs to a hash table.
6063The resulting hash table is returned, or nil if no Xrefs were found."
6064 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6065 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6066 (xref-hashtb (gnus-make-hashtable))
6067 start group entry number xrefs header)
6068 (while headers
6069 (setq header (pop headers))
6070 (when (and (setq xrefs (mail-header-xref header))
6071 (not (memq (setq number (mail-header-number header))
6072 unreads)))
6073 (setq start 0)
6074 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6075 (setq start (match-end 0))
6076 (setq group (if prefix
6077 (concat prefix (substring xrefs (match-beginning 1)
6078 (match-end 1)))
6079 (substring xrefs (match-beginning 1) (match-end 1))))
6080 (setq number
e9bd5782 6081 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
6082 (match-end 2))))
6083 (if (setq entry (gnus-gethash group xref-hashtb))
6084 (setcdr entry (cons number (cdr entry)))
6085 (gnus-sethash group (cons number nil) xref-hashtb)))))
6086 (and start xref-hashtb)))
6087
6088(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6089 "Look through all the headers and mark the Xrefs as read."
6090 (let ((virtual (gnus-virtual-group-p from-newsgroup))
01c52d31 6091 name info xref-hashtb idlist method nth4)
398a825b 6092 (with-current-buffer gnus-group-buffer
eec82323
LMI
6093 (when (setq xref-hashtb
6094 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6095 (mapatoms
6096 (lambda (group)
6097 (unless (string= from-newsgroup (setq name (symbol-name group)))
6098 (setq idlist (symbol-value group))
6099 ;; Dead groups are not updated.
6100 (and (prog1
01c52d31 6101 (setq info (gnus-get-info name))
eec82323
LMI
6102 (when (stringp (setq nth4 (gnus-info-method info)))
6103 (setq nth4 (gnus-server-to-method nth4))))
6104 ;; Only do the xrefs if the group has the same
6105 ;; select method as the group we have just read.
6106 (or (gnus-methods-equal-p
6107 nth4 (gnus-find-method-for-group from-newsgroup))
6108 virtual
6109 (equal nth4 (setq method (gnus-find-method-for-group
6110 from-newsgroup)))
6111 (and (equal (car nth4) (car method))
6112 (equal (nth 1 nth4) (nth 1 method))))
6113 gnus-use-cross-reference
6114 (or (not (eq gnus-use-cross-reference t))
6115 virtual
6116 ;; Only do cross-references on subscribed
6117 ;; groups, if that is what is wanted.
6118 (<= (gnus-info-level info) gnus-level-subscribed))
6119 (gnus-group-make-articles-read name idlist))))
6120 xref-hashtb)))))
6121
6748645f 6122(defun gnus-compute-read-articles (group articles)
01c52d31 6123 (let* ((entry (gnus-group-entry group))
6748645f
LMI
6124 (info (nth 2 entry))
6125 (active (gnus-active group))
6126 ninfo)
6127 (when entry
16409b0b 6128 ;; First peel off all invalid article numbers.
6748645f
LMI
6129 (when active
6130 (let ((ids articles)
6131 id first)
6132 (while (setq id (pop ids))
6133 (when (and first (> id (cdr active)))
6134 ;; We'll end up in this situation in one particular
6135 ;; obscure situation. If you re-scan a group and get
6136 ;; a new article that is cross-posted to a different
6137 ;; group that has not been re-scanned, you might get
6138 ;; crossposted article that has a higher number than
6139 ;; Gnus believes possible. So we re-activate this
6140 ;; group as well. This might mean doing the
6141 ;; crossposting thingy will *increase* the number
6142 ;; of articles in some groups. Tsk, tsk.
6143 (setq active (or (gnus-activate-group group) active)))
6144 (when (or (> id (cdr active))
6145 (< id (car active)))
6146 (setq articles (delq id articles))))))
6147 ;; If the read list is nil, we init it.
6148 (if (and active
6149 (null (gnus-info-read info))
6150 (> (car active) 1))
6151 (setq ninfo (cons 1 (1- (car active))))
6152 (setq ninfo (gnus-info-read info)))
6153 ;; Then we add the read articles to the range.
6154 (gnus-add-to-range
6155 ninfo (setq articles (sort articles '<))))))
6156
eec82323
LMI
6157(defun gnus-group-make-articles-read (group articles)
6158 "Update the info of GROUP to say that ARTICLES are read."
6159 (let* ((num 0)
01c52d31 6160 (entry (gnus-group-entry group))
eec82323
LMI
6161 (info (nth 2 entry))
6162 (active (gnus-active group))
6163 range)
6748645f
LMI
6164 (when entry
6165 (setq range (gnus-compute-read-articles group articles))
01c52d31 6166 (with-current-buffer gnus-group-buffer
6748645f
LMI
6167 (gnus-undo-register
6168 `(progn
6169 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6170 (gnus-info-set-read ',info ',(gnus-info-read info))
6171 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 6172 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
6173 (gnus-group-update-group ,group t))))
6174 ;; Add the read articles to the range.
6175 (gnus-info-set-read info range)
23f87bed 6176 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
6177 ;; Then we have to re-compute how many unread
6178 ;; articles there are in this group.
6179 (when active
6180 (cond
6181 ((not range)
6182 (setq num (- (1+ (cdr active)) (car active))))
6183 ((not (listp (cdr range)))
6184 (setq num (- (cdr active) (- (1+ (cdr range))
6185 (car range)))))
6186 (t
6187 (while range
6188 (if (numberp (car range))
6189 (setq num (1+ num))
6190 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6191 (setq range (cdr range)))
6192 (setq num (- (cdr active) num))))
6193 ;; Update the number of unread articles.
6194 (setcar entry num)
6195 ;; Update the group buffer.
23f87bed
MB
6196 (unless (gnus-ephemeral-group-p group)
6197 (gnus-group-update-group group t))))))
eec82323 6198
eec82323
LMI
6199(defvar gnus-newsgroup-none-id 0)
6200
6201(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6202 (let ((cur nntp-server-buffer)
6203 (dependencies
6204 (or dependencies
01c52d31
MB
6205 (with-current-buffer gnus-summary-buffer
6206 gnus-newsgroup-dependencies)))
6207 headers id end ref number
16409b0b
GM
6208 (mail-parse-charset gnus-newsgroup-charset)
6209 (mail-parse-ignored-charsets
c7a91ce1
SM
6210 (save-current-buffer (condition-case nil
6211 (set-buffer gnus-summary-buffer)
6212 (error))
6213 gnus-newsgroup-ignored-charsets)))
6214 (with-current-buffer nntp-server-buffer
eec82323
LMI
6215 ;; Translate all TAB characters into SPACE characters.
6216 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 6217 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 6218 (ietf-drums-unfold-fws)
6748645f 6219 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6220 (let ((case-fold-search t)
6748645f 6221 in-reply-to header p lines chars)
eec82323 6222 (goto-char (point-min))
01ccbb85 6223 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
6224 ;; do not begin with 2 or 3.
6225 (while (re-search-forward "^[23][0-9]+ " nil t)
6226 (setq id nil
6227 ref nil)
6228 ;; This implementation of this function, with nine
6229 ;; search-forwards instead of the one re-search-forward and
6230 ;; a case (which basically was the old function) is actually
01ccbb85 6231 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
6232 ;; can't have everything, I guess. Speed and elegance
6233 ;; doesn't always go hand in hand.
6234 (setq
6235 header
6236 (vector
6237 ;; Number.
6238 (prog1
01c52d31 6239 (setq number (read cur))
eec82323
LMI
6240 (end-of-line)
6241 (setq p (point))
6242 (narrow-to-region (point)
6243 (or (and (search-forward "\n.\n" nil t)
6244 (- (point) 2))
6245 (point))))
6246 ;; Subject.
6247 (progn
6248 (goto-char p)
23f87bed 6249 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
6250 (funcall gnus-decode-encoded-word-function
6251 (nnheader-header-value))
2bd3dcae 6252 "(none)"))
eec82323
LMI
6253 ;; From.
6254 (progn
6255 (goto-char p)
23f87bed 6256 (if (search-forward "\nfrom:" nil t)
343d6628 6257 (funcall gnus-decode-encoded-address-function
16409b0b 6258 (nnheader-header-value))
2bd3dcae 6259 "(nobody)"))
eec82323
LMI
6260 ;; Date.
6261 (progn
6262 (goto-char p)
23f87bed 6263 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6264 (nnheader-header-value) ""))
6265 ;; Message-ID.
6266 (progn
6267 (goto-char p)
6748645f
LMI
6268 (setq id (if (re-search-forward
6269 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6270 ;; We do it this way to make sure the Message-ID
6271 ;; is (somewhat) syntactically valid.
6272 (buffer-substring (match-beginning 1)
6273 (match-end 1))
eec82323
LMI
6274 ;; If there was no message-id, we just fake one
6275 ;; to make subsequent routines simpler.
01c52d31 6276 (nnheader-generate-fake-message-id number))))
eec82323
LMI
6277 ;; References.
6278 (progn
6279 (goto-char p)
23f87bed 6280 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6281 (progn
6282 (setq end (point))
6283 (prog1
6284 (nnheader-header-value)
6285 (setq ref
6286 (buffer-substring
6287 (progn
6288 (end-of-line)
6289 (search-backward ">" end t)
6290 (1+ (point)))
6291 (progn
6292 (search-backward "<" end t)
6293 (point))))))
6294 ;; Get the references from the in-reply-to header if there
6295 ;; were no references and the in-reply-to header looks
6296 ;; promising.
23f87bed 6297 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6298 (setq in-reply-to (nnheader-header-value))
6299 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6300 (let (ref2)
6301 (setq ref (substring in-reply-to (match-beginning 0)
6302 (match-end 0)))
6303 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6304 (setq ref2 (substring in-reply-to (match-beginning 0)
6305 (match-end 0)))
6306 (when (> (length ref2) (length ref))
6307 (setq ref ref2)))
6308 ref)
eec82323
LMI
6309 (setq ref nil))))
6310 ;; Chars.
6748645f
LMI
6311 (progn
6312 (goto-char p)
6313 (if (search-forward "\nchars: " nil t)
6314 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6315 chars -1)
6316 -1))
eec82323
LMI
6317 ;; Lines.
6318 (progn
6319 (goto-char p)
6320 (if (search-forward "\nlines: " nil t)
a8151ef7 6321 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6322 lines -1)
6323 -1))
eec82323
LMI
6324 ;; Xref.
6325 (progn
6326 (goto-char p)
23f87bed 6327 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6328 (nnheader-header-value)))
6329 ;; Extra.
6330 (when gnus-extra-headers
6331 (let ((extra gnus-extra-headers)
6332 out)
6333 (while extra
6334 (goto-char p)
6335 (when (search-forward
23f87bed 6336 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6337 (push (cons (car extra) (nnheader-header-value))
6338 out))
6339 (pop extra))
6340 out))))
eec82323
LMI
6341 (when (equal id ref)
6342 (setq ref nil))
6748645f
LMI
6343
6344 (when gnus-alter-header-function
6345 (funcall gnus-alter-header-function header)
6346 (setq id (mail-header-id header)
6347 ref (gnus-parent-id (mail-header-references header))))
6348
6349 (when (setq header
6350 (gnus-dependencies-add-header
6351 header dependencies force-new))
eec82323
LMI
6352 (push header headers))
6353 (goto-char (point-max))
6354 (widen))
6355 (nreverse headers)))))
6356
eec82323
LMI
6357;; Goes through the xover lines and returns a list of vectors
6358(defun gnus-get-newsgroup-headers-xover (sequence &optional
6359 force-new dependencies
6360 group also-fetch-heads)
16409b0b
GM
6361 "Parse the news overview data in the server buffer.
6362Return a list of headers that match SEQUENCE (see
6363`nntp-retrieve-headers')."
eec82323
LMI
6364 ;; Get the Xref when the users reads the articles since most/some
6365 ;; NNTP servers do not include Xrefs when using XOVER.
6366 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6367 (let ((mail-parse-charset gnus-newsgroup-charset)
6368 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6369 (cur nntp-server-buffer)
eec82323 6370 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6371 (allp (cond
6372 ((eq gnus-read-all-available-headers t)
6373 t)
14e6dc54
MB
6374 ((and (stringp gnus-read-all-available-headers)
6375 group)
23f87bed
MB
6376 (string-match gnus-read-all-available-headers group))
6377 (t
6378 nil)))
eec82323 6379 number headers header)
c7a91ce1 6380 (with-current-buffer nntp-server-buffer
16409b0b 6381 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6382 ;; Allow the user to mangle the headers before parsing them.
6748645f 6383 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6384 (goto-char (point-min))
23f87bed
MB
6385 (gnus-parse-without-error
6386 (while (and (or sequence allp)
6387 (not (eobp)))
6388 (setq number (read cur))
6389 (when (not allp)
6390 (while (and sequence
6391 (< (car sequence) number))
6392 (setq sequence (cdr sequence))))
6393 (when (and (or allp
6394 (and sequence
6395 (eq number (car sequence))))
6396 (progn
6397 (setq sequence (cdr sequence))
6398 (setq header (inline
6399 (gnus-nov-parse-line
6400 number dependencies force-new)))))
6401 (push header headers))
6402 (forward-line 1)))
eec82323
LMI
6403 ;; A common bug in inn is that if you have posted an article and
6404 ;; then retrieves the active file, it will answer correctly --
6405 ;; the new article is included. However, a NOV entry for the
6406 ;; article may not have been generated yet, so this may fail.
6407 ;; We work around this problem by retrieving the last few
6408 ;; headers using HEAD.
6409 (if (or (not also-fetch-heads)
6410 (not sequence))
6411 ;; We (probably) got all the headers.
6412 (nreverse headers)
6413 (let ((gnus-nov-is-evil t))
6414 (nconc
6415 (nreverse headers)
23f87bed 6416 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6417 (gnus-get-newsgroup-headers))))))))
6418
6419(defun gnus-article-get-xrefs ()
6420 "Fill in the Xref value in `gnus-current-headers', if necessary.
6421This is meant to be called in `gnus-article-internal-prepare-hook'."
01c52d31
MB
6422 (let ((headers (with-current-buffer gnus-summary-buffer
6423 gnus-current-headers)))
eec82323
LMI
6424 (or (not gnus-use-cross-reference)
6425 (not headers)
6426 (and (mail-header-xref headers)
6427 (not (string= (mail-header-xref headers) "")))
6428 (let ((case-fold-search t)
6429 xref)
6430 (save-restriction
6431 (nnheader-narrow-to-headers)
6432 (goto-char (point-min))
16409b0b
GM
6433 (when (or (and (not (eobp))
6434 (eq (downcase (char-after)) ?x)
eec82323
LMI
6435 (looking-at "Xref:"))
6436 (search-forward "\nXref:" nil t))
6437 (goto-char (1+ (match-end 0)))
01c52d31 6438 (setq xref (buffer-substring (point) (point-at-eol)))
eec82323
LMI
6439 (mail-header-set-xref headers xref)))))))
6440
6441(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6442 "Find article ID and insert the summary line for that article.
6443OLD-HEADER can either be a header or a line number to insert
6444the subject line on."
6445 (let* ((line (and (numberp old-header) old-header))
6446 (old-header (and (vectorp old-header) old-header))
6447 (header (cond ((and old-header use-old-header)
16409b0b
GM
6448 old-header)
6449 ((and (numberp id)
6450 (gnus-number-to-header id))
6451 (gnus-number-to-header id))
6452 (t
6453 (gnus-read-header id))))
6454 (number (and (numberp id) id))
6455 d)
eec82323
LMI
6456 (when header
6457 ;; Rebuild the thread that this article is part of and go to the
6458 ;; article we have fetched.
6459 (when (and (not gnus-show-threads)
6460 old-header)
6748645f
LMI
6461 (when (and number
6462 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6463 (goto-char (gnus-data-pos d))
6464 (gnus-data-remove
6465 number
01c52d31 6466 (- (point-at-bol)
eec82323 6467 (prog1
01c52d31 6468 (1+ (point-at-eol))
eec82323 6469 (gnus-delete-line))))))
23f87bed
MB
6470 ;; Remove list identifiers from subject.
6471 (when gnus-list-identifiers
6472 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6473 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6474 (when old-header
6475 (mail-header-set-number header (mail-header-number old-header)))
6476 (setq gnus-newsgroup-sparse
6477 (delq (setq number (mail-header-number header))
6478 gnus-newsgroup-sparse))
6479 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6480 (push number gnus-newsgroup-limit)
6481 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6482 (gnus-summary-goto-subject number nil t))
6483 (when (and (numberp number)
6484 (> number 0))
6485 ;; We have to update the boundaries even if we can't fetch the
6486 ;; article if ID is a number -- so that the next `P' or `N'
6487 ;; command will fetch the previous (or next) article even
6488 ;; if the one we tried to fetch this time has been canceled.
6489 (when (> number gnus-newsgroup-end)
6490 (setq gnus-newsgroup-end number))
6491 (when (< number gnus-newsgroup-begin)
6492 (setq gnus-newsgroup-begin number))
6493 (setq gnus-newsgroup-unselected
6494 (delq number gnus-newsgroup-unselected)))
6495 ;; Report back a success?
6496 (and header (mail-header-number header))))
6497
6498;;; Process/prefix in the summary buffer
6499
6500(defun gnus-summary-work-articles (n)
6748645f
LMI
6501 "Return a list of articles to be worked upon.
6502The prefix argument, the list of process marked articles, and the
6503current article will be taken into consideration."
c7a91ce1 6504 (with-current-buffer gnus-summary-buffer
6748645f
LMI
6505 (cond
6506 (n
6507 ;; A numerical prefix has been given.
6508 (setq n (prefix-numeric-value n))
6509 (let ((backward (< n 0))
6510 (n (abs (prefix-numeric-value n)))
6511 articles article)
6512 (save-excursion
6513 (while
6514 (and (> n 0)
6515 (push (setq article (gnus-summary-article-number))
6516 articles)
6517 (if backward
6518 (gnus-summary-find-prev nil article)
6519 (gnus-summary-find-next nil article)))
6520 (decf n)))
6521 (nreverse articles)))
6522 ((and (gnus-region-active-p) (mark))
6523 (message "region active")
6524 ;; Work on the region between point and mark.
6525 (let ((max (max (point) (mark)))
6526 articles article)
6527 (save-excursion
7dafe00b 6528 (goto-char (min (point) (mark)))
6748645f
LMI
6529 (while
6530 (and
6531 (push (setq article (gnus-summary-article-number)) articles)
6532 (gnus-summary-find-next nil article)
6533 (< (point) max)))
6534 (nreverse articles))))
6535 (gnus-newsgroup-processable
6536 ;; There are process-marked articles present.
6537 ;; Save current state.
6538 (gnus-summary-save-process-mark)
6539 ;; Return the list.
6540 (reverse gnus-newsgroup-processable))
6541 (t
6542 ;; Just return the current article.
6543 (list (gnus-summary-article-number))))))
6544
6545(defmacro gnus-summary-iterate (arg &rest forms)
6546 "Iterate over the process/prefixed articles and do FORMS.
6547ARG is the interactive prefix given to the command. FORMS will be
6548executed with point over the summary line of the articles."
6549 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6550 `(let ((,articles (gnus-summary-work-articles ,arg)))
6551 (while ,articles
6552 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6553 ,@forms
6554 (pop ,articles)))))
6748645f
LMI
6555
6556(put 'gnus-summary-iterate 'lisp-indent-function 1)
6557(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6558
6559(defun gnus-summary-save-process-mark ()
6560 "Push the current set of process marked articles on the stack."
6561 (interactive)
6562 (push (copy-sequence gnus-newsgroup-processable)
6563 gnus-newsgroup-process-stack))
6564
6565(defun gnus-summary-kill-process-mark ()
6566 "Push the current set of process marked articles on the stack and unmark."
6567 (interactive)
6568 (gnus-summary-save-process-mark)
6569 (gnus-summary-unmark-all-processable))
6570
6571(defun gnus-summary-yank-process-mark ()
6572 "Pop the last process mark state off the stack and restore it."
6573 (interactive)
6574 (unless gnus-newsgroup-process-stack
6575 (error "Empty mark stack"))
6576 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6577
6578(defun gnus-summary-process-mark-set (set)
6579 "Make SET into the current process marked articles."
6580 (gnus-summary-unmark-all-processable)
01c52d31 6581 (mapc 'gnus-summary-set-process-mark set))
eec82323
LMI
6582
6583;;; Searching and stuff
6584
6585(defun gnus-summary-search-group (&optional backward use-level)
6586 "Search for next unread newsgroup.
6587If optional argument BACKWARD is non-nil, search backward instead."
c7a91ce1 6588 (with-current-buffer gnus-group-buffer
eec82323
LMI
6589 (when (gnus-group-search-forward
6590 backward nil (if use-level (gnus-group-group-level) nil))
6591 (gnus-group-group-name))))
6592
6593(defun gnus-summary-best-group (&optional exclude-group)
6594 "Find the name of the best unread group.
6595If EXCLUDE-GROUP, do not go to this group."
01c52d31 6596 (with-current-buffer gnus-group-buffer
eec82323
LMI
6597 (save-excursion
6598 (gnus-group-best-unread-group exclude-group))))
6599
23f87bed
MB
6600(defun gnus-summary-find-next (&optional unread article backward)
6601 (if backward
6602 (gnus-summary-find-prev unread article)
eec82323
LMI
6603 (let* ((dummy (gnus-summary-article-intangible-p))
6604 (article (or article (gnus-summary-article-number)))
23f87bed 6605 (data (gnus-data-find-list article))
eec82323
LMI
6606 result)
6607 (when (and (not dummy)
6608 (or (not gnus-summary-check-current)
6609 (not unread)
23f87bed
MB
6610 (not (gnus-data-unread-p (car data)))))
6611 (setq data (cdr data)))
eec82323
LMI
6612 (when (setq result
6613 (if unread
6614 (progn
23f87bed
MB
6615 (while data
6616 (unless (memq (gnus-data-number (car data))
6617 (cond
6618 ((eq gnus-auto-goto-ignores
6619 'always-undownloaded)
6620 gnus-newsgroup-undownloaded)
6621 (gnus-plugged
6622 nil)
6623 ((eq gnus-auto-goto-ignores
6624 'unfetched)
6625 gnus-newsgroup-unfetched)
6626 ((eq gnus-auto-goto-ignores
6627 'undownloaded)
6628 gnus-newsgroup-undownloaded)))
6629 (when (gnus-data-unread-p (car data))
6630 (setq result (car data)
6631 data nil)))
6632 (setq data (cdr data)))
eec82323 6633 result)
23f87bed 6634 (car data)))
eec82323
LMI
6635 (goto-char (gnus-data-pos result))
6636 (gnus-data-number result)))))
6637
6638(defun gnus-summary-find-prev (&optional unread article)
6639 (let* ((eobp (eobp))
6640 (article (or article (gnus-summary-article-number)))
23f87bed 6641 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6642 result)
6643 (when (and (not eobp)
6644 (or (not gnus-summary-check-current)
6645 (not unread)
23f87bed
MB
6646 (not (gnus-data-unread-p (car data)))))
6647 (setq data (cdr data)))
eec82323
LMI
6648 (when (setq result
6649 (if unread
6650 (progn
23f87bed
MB
6651 (while data
6652 (unless (memq (gnus-data-number (car data))
6653 (cond
6654 ((eq gnus-auto-goto-ignores
6655 'always-undownloaded)
6656 gnus-newsgroup-undownloaded)
6657 (gnus-plugged
6658 nil)
6659 ((eq gnus-auto-goto-ignores
6660 'unfetched)
6661 gnus-newsgroup-unfetched)
6662 ((eq gnus-auto-goto-ignores
6663 'undownloaded)
6664 gnus-newsgroup-undownloaded)))
6665 (when (gnus-data-unread-p (car data))
6666 (setq result (car data)
6667 data nil)))
6668 (setq data (cdr data)))
eec82323 6669 result)
23f87bed 6670 (car data)))
eec82323
LMI
6671 (goto-char (gnus-data-pos result))
6672 (gnus-data-number result))))
6673
6674(defun gnus-summary-find-subject (subject &optional unread backward article)
6675 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6676 (article (or article (gnus-summary-article-number)))
6677 (articles (gnus-data-list backward))
6678 (arts (gnus-data-find-list article articles))
6679 result)
6680 (when (or (not gnus-summary-check-current)
6681 (not unread)
6682 (not (gnus-data-unread-p (car arts))))
6683 (setq arts (cdr arts)))
6684 (while arts
6685 (and (or (not unread)
6686 (gnus-data-unread-p (car arts)))
6687 (vectorp (gnus-data-header (car arts)))
6688 (gnus-subject-equal
6689 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6690 (setq result (car arts)
6691 arts nil))
6692 (setq arts (cdr arts)))
6693 (and result
6694 (goto-char (gnus-data-pos result))
6695 (gnus-data-number result))))
6696
6697(defun gnus-summary-search-forward (&optional unread subject backward)
6698 "Search forward for an article.
6699If UNREAD, look for unread articles. If SUBJECT, look for
6700articles with that subject. If BACKWARD, search backward instead."
6701 (cond (subject (gnus-summary-find-subject subject unread backward))
6702 (backward (gnus-summary-find-prev unread))
6703 (t (gnus-summary-find-next unread))))
6704
6705(defun gnus-recenter (&optional n)
6706 "Center point in window and redisplay frame.
6707Also do horizontal recentering."
6708 (interactive "P")
6709 (when (and gnus-auto-center-summary
6710 (not (eq gnus-auto-center-summary 'vertical)))
6711 (gnus-horizontal-recenter))
5aa75bd8
JL
6712 (if (fboundp 'recenter-top-bottom)
6713 (recenter-top-bottom n)
6714 (recenter n)))
6715
6716(put 'gnus-recenter 'isearch-scroll t)
eec82323 6717
7b47345b
AS
6718(defun gnus-forward-line-ignore-invisible (n)
6719 "Move N lines forward (backward if N is negative).
6720Like forward-line, but skip over (and don't count) invisible lines."
6721 (let (done)
6722 (while (and (> n 0) (not done))
6723 ;; If the following character is currently invisible,
6724 ;; skip all characters with that same `invisible' property value.
770d9a1f
KY
6725 (while (gnus-invisible-p (point))
6726 (goto-char (gnus-next-char-property-change (point))))
7b47345b
AS
6727 (forward-line 1)
6728 (if (eobp)
6729 (setq done t)
6730 (setq n (1- n))))
6731 (while (and (< n 0) (not done))
6732 (forward-line -1)
6733 (if (bobp) (setq done t)
6734 (setq n (1+ n))
770d9a1f
KY
6735 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6736 (goto-char (gnus-previous-char-property-change (point))))))))
6737
eec82323
LMI
6738(defun gnus-summary-recenter ()
6739 "Center point in the summary window.
6740If `gnus-auto-center-summary' is nil, or the article buffer isn't
6741displayed, no centering will be performed."
6742 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6743 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6744 (interactive)
23f87bed
MB
6745 ;; The user has to want it.
6746 (when gnus-auto-center-summary
6747 (let* ((top (cond ((< (window-height) 4) 0)
6748 ((< (window-height) 7) 1)
6749 (t (if (numberp gnus-auto-center-summary)
6750 gnus-auto-center-summary
01c52d31 6751 (/ (1- (window-height)) 2)))))
23f87bed 6752 (height (1- (window-height)))
7b47345b
AS
6753 (bottom (save-excursion
6754 (goto-char (point-max))
6755 (gnus-forward-line-ignore-invisible (- height))
6756 (point)))
23f87bed 6757 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6758 (when (get-buffer-window gnus-article-buffer)
6759 ;; Only do recentering when the article buffer is displayed,
6760 ;; Set the window start to either `bottom', which is the biggest
6761 ;; possible valid number, or the second line from the top,
6762 ;; whichever is the least.
7b47345b
AS
6763 (let ((top-pos (save-excursion
6764 (gnus-forward-line-ignore-invisible (- top))
6765 (point))))
db7ebd73
MB
6766 (if (> bottom top-pos)
6767 ;; Keep the second line from the top visible
01c52d31 6768 (set-window-start window top-pos)
db7ebd73
MB
6769 ;; Try to keep the bottom line visible; if it's partially
6770 ;; obscured, either scroll one more line to make it fully
6771 ;; visible, or revert to using TOP-POS.
6772 (save-excursion
6773 (goto-char (point-max))
7b47345b 6774 (gnus-forward-line-ignore-invisible -1)
db7ebd73
MB
6775 (let ((last-line-start (point)))
6776 (goto-char bottom)
6777 (set-window-start window (point) t)
6778 (when (not (pos-visible-in-window-p last-line-start window))
7b47345b 6779 (gnus-forward-line-ignore-invisible 1)
db7ebd73 6780 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6781 ;; Do horizontal recentering while we're at it.
6782 (when (and (get-buffer-window (current-buffer) t)
6783 (not (eq gnus-auto-center-summary 'vertical)))
6784 (let ((selected (selected-window)))
6785 (select-window (get-buffer-window (current-buffer) t))
6786 (gnus-summary-position-point)
6787 (gnus-horizontal-recenter)
6788 (select-window selected))))))
6789
6790(defun gnus-summary-jump-to-group (newsgroup)
6791 "Move point to NEWSGROUP in group mode buffer."
6792 ;; Keep update point of group mode buffer if visible.
6793 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6794 (save-window-excursion
6795 ;; Take care of tree window mode.
6796 (when (get-buffer-window gnus-group-buffer)
6797 (pop-to-buffer gnus-group-buffer))
6798 (gnus-group-jump-to-group newsgroup))
6799 (save-excursion
6800 ;; Take care of tree window mode.
c7a91ce1 6801 (if (get-buffer-window gnus-group-buffer 0)
eec82323
LMI
6802 (pop-to-buffer gnus-group-buffer)
6803 (set-buffer gnus-group-buffer))
6804 (gnus-group-jump-to-group newsgroup))))
6805
6806;; This function returns a list of article numbers based on the
6807;; difference between the ranges of read articles in this group and
6808;; the range of active articles.
6809(defun gnus-list-of-unread-articles (group)
6810 (let* ((read (gnus-info-read (gnus-get-info group)))
6811 (active (or (gnus-active group) (gnus-activate-group group)))
01c52d31
MB
6812 (last (or (cdr active)
6813 (error "Group %s couldn't be activated " group)))
4b70e299
MB
6814 (bottom (if gnus-newsgroup-maximum-articles
6815 (max (car active)
6816 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6817 (car active)))
eec82323
LMI
6818 first nlast unread)
6819 ;; If none are read, then all are unread.
6820 (if (not read)
11abff8e 6821 (setq first bottom)
eec82323
LMI
6822 ;; If the range of read articles is a single range, then the
6823 ;; first unread article is the article after the last read
6824 ;; article. Sounds logical, doesn't it?
16409b0b 6825 (if (and (not (listp (cdr read)))
11abff8e 6826 (or (< (car read) bottom)
16409b0b
GM
6827 (progn (setq read (list read))
6828 nil)))
11abff8e 6829 (setq first (max bottom (1+ (cdr read))))
eec82323
LMI
6830 ;; `read' is a list of ranges.
6831 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6832 (caar read)))
6833 1)
11abff8e 6834 (setq first bottom))
eec82323
LMI
6835 (while read
6836 (when first
6837 (while (< first nlast)
54506618
MB
6838 (setq unread (cons first unread)
6839 first (1+ first))))
eec82323
LMI
6840 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6841 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6842 (setq read (cdr read)))))
6843 ;; And add the last unread articles.
6844 (while (<= first last)
54506618
MB
6845 (setq unread (cons first unread)
6846 first (1+ first)))
eec82323 6847 ;; Return the list of unread articles.
6748645f 6848 (delq 0 (nreverse unread))))
eec82323
LMI
6849
6850(defun gnus-list-of-read-articles (group)
6851 "Return a list of unread, unticked and non-dormant articles."
6852 (let* ((info (gnus-get-info group))
6853 (marked (gnus-info-marks info))
6854 (active (gnus-active group)))
6855 (and info active
23f87bed
MB
6856 (gnus-list-range-difference
6857 (gnus-list-range-difference
6858 (gnus-sorted-complement
11abff8e 6859 (gnus-uncompress-range
4b70e299 6860 (if gnus-newsgroup-maximum-articles
11abff8e 6861 (cons (max (car active)
4b70e299
MB
6862 (- (cdr active)
6863 gnus-newsgroup-maximum-articles
6864 -1))
11abff8e
MB
6865 (cdr active))
6866 active))
23f87bed
MB
6867 (gnus-list-of-unread-articles group))
6868 (cdr (assq 'dormant marked)))
6869 (cdr (assq 'tick marked))))))
eec82323 6870
54506618
MB
6871;; This function returns a sequence of article numbers based on the
6872;; difference between the ranges of read articles in this group and
6873;; the range of active articles.
6874(defun gnus-sequence-of-unread-articles (group)
6875 (let* ((read (gnus-info-read (gnus-get-info group)))
6876 (active (or (gnus-active group) (gnus-activate-group group)))
6877 (last (cdr active))
4b70e299
MB
6878 (bottom (if gnus-newsgroup-maximum-articles
6879 (max (car active)
6880 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6881 (car active)))
54506618
MB
6882 first nlast unread)
6883 ;; If none are read, then all are unread.
6884 (if (not read)
11abff8e 6885 (setq first bottom)
54506618
MB
6886 ;; If the range of read articles is a single range, then the
6887 ;; first unread article is the article after the last read
6888 ;; article. Sounds logical, doesn't it?
6889 (if (and (not (listp (cdr read)))
11abff8e 6890 (or (< (car read) bottom)
54506618
MB
6891 (progn (setq read (list read))
6892 nil)))
11abff8e 6893 (setq first (max bottom (1+ (cdr read))))
54506618
MB
6894 ;; `read' is a list of ranges.
6895 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6896 (caar read)))
6897 1)
11abff8e 6898 (setq first bottom))
54506618
MB
6899 (while read
6900 (when first
6901 (push (cons first nlast) unread))
6902 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6903 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6904 (setq read (cdr read)))))
6905 ;; And add the last unread articles.
ba0226dd
MB
6906 (cond ((not (and first last))
6907 nil)
6908 ((< first last)
6909 (push (cons first last) unread))
6910 ((= first last)
6911 (push first unread)))
54506618
MB
6912 ;; Return the sequence of unread articles.
6913 (delq 0 (nreverse unread))))
6914
eec82323
LMI
6915;; Various summary commands
6916
6748645f
LMI
6917(defun gnus-summary-select-article-buffer ()
6918 "Reconfigure windows to show article buffer."
6919 (interactive)
6920 (if (not (gnus-buffer-live-p gnus-article-buffer))
6921 (error "There is no article buffer for this summary buffer")
6922 (gnus-configure-windows 'article)
6923 (select-window (get-buffer-window gnus-article-buffer))))
6924
eec82323
LMI
6925(defun gnus-summary-universal-argument (arg)
6926 "Perform any operation on all articles that are process/prefixed."
6927 (interactive "P")
eec82323
LMI
6928 (let ((articles (gnus-summary-work-articles arg))
6929 func article)
6930 (if (eq
6931 (setq
6932 func
6933 (key-binding
6934 (read-key-sequence
6935 (substitute-command-keys
16409b0b 6936 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
6937 'undefined)
6938 (gnus-error 1 "Undefined key")
6939 (save-excursion
6940 (while articles
6941 (gnus-summary-goto-subject (setq article (pop articles)))
6942 (let (gnus-newsgroup-processable)
6943 (command-execute func))
6944 (gnus-summary-remove-process-mark article)))))
6945 (gnus-summary-position-point))
6946
6947(defun gnus-summary-toggle-truncation (&optional arg)
6948 "Toggle truncation of summary lines.
23f87bed 6949With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
6950 (interactive "P")
6951 (setq truncate-lines
6952 (if (null arg) (not truncate-lines)
6953 (> (prefix-numeric-value arg) 0)))
6954 (redraw-display))
6955
23f87bed
MB
6956(defun gnus-summary-find-for-reselect ()
6957 "Return the number of an article to stay on across a reselect.
6958The current article is considered, then following articles, then previous
6959articles. An article is sought which is not cancelled and isn't a temporary
6960insertion from another group. If there's no such then return a dummy 0."
6961 (let (found)
6962 (dolist (rev '(nil t))
6963 (unless found ; don't demand the reverse list if we don't need it
6964 (let ((data (gnus-data-find-list
6965 (gnus-summary-article-number) (gnus-data-list rev))))
6966 (while (and data (not found))
6967 (if (and (< 0 (gnus-data-number (car data)))
6968 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6969 (setq found (gnus-data-number (car data))))
6970 (setq data (cdr data))))))
6971 (or found 0)))
6972
eec82323
LMI
6973(defun gnus-summary-reselect-current-group (&optional all rescan)
6974 "Exit and then reselect the current newsgroup.
6975The prefix argument ALL means to select all articles."
6976 (interactive "P")
eec82323
LMI
6977 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6978 (error "Ephemeral groups can't be reselected"))
23f87bed 6979 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
6980 (group gnus-newsgroup-name))
6981 (setq gnus-newsgroup-begin nil)
23f87bed 6982 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
6983 ;; We have to adjust the point of group mode buffer because
6984 ;; point was moved to the next unread newsgroup by exiting.
6985 (gnus-summary-jump-to-group group)
6986 (when rescan
6987 (save-excursion
6988 (gnus-group-get-new-news-this-group 1)))
6989 (gnus-group-read-group all t)
6990 (gnus-summary-goto-subject current-subject nil t)))
6991
6992(defun gnus-summary-rescan-group (&optional all)
6993 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6994 (interactive "P")
6995 (gnus-summary-reselect-current-group all t))
6996
6997(defun gnus-summary-update-info (&optional non-destructive)
6998 (save-excursion
6999 (let ((group gnus-newsgroup-name))
6748645f
LMI
7000 (when group
7001 (when gnus-newsgroup-kill-headers
7002 (setq gnus-newsgroup-killed
7003 (gnus-compress-sequence
23f87bed
MB
7004 (gnus-sorted-union
7005 (gnus-list-range-intersection
7006 gnus-newsgroup-unselected gnus-newsgroup-killed)
7007 gnus-newsgroup-unreads)
6748645f
LMI
7008 t)))
7009 (unless (listp (cdr gnus-newsgroup-killed))
7010 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7011 (let ((headers gnus-newsgroup-headers))
7012 ;; Set the new ranges of read articles.
01c52d31 7013 (with-current-buffer gnus-group-buffer
6748645f
LMI
7014 (gnus-undo-force-boundary))
7015 (gnus-update-read-articles
23f87bed
MB
7016 group (gnus-sorted-union
7017 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
7018 ;; Set the current article marks.
7019 (let ((gnus-newsgroup-scored
7020 (if (and (not gnus-save-score)
7021 (not non-destructive))
7022 nil
7023 gnus-newsgroup-scored)))
7024 (save-excursion
7025 (gnus-update-marks)))
7026 ;; Do the cross-ref thing.
7027 (when gnus-use-cross-reference
7028 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7029 ;; Do not switch windows but change the buffer to work.
a8151ef7 7030 (set-buffer gnus-group-buffer)
6748645f
LMI
7031 (unless (gnus-ephemeral-group-p group)
7032 (gnus-group-update-group group)))))))
eec82323
LMI
7033
7034(defun gnus-summary-save-newsrc (&optional force)
7035 "Save the current number of read/marked articles in the dribble buffer.
7036The dribble buffer will then be saved.
7037If FORCE (the prefix), also save the .newsrc file(s)."
7038 (interactive "P")
7039 (gnus-summary-update-info t)
7040 (if force
7041 (gnus-save-newsrc-file)
7042 (gnus-dribble-save)))
7043
704f1663
GM
7044(declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7045
23f87bed 7046(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 7047 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 7048`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
7049 (interactive)
7050 (gnus-set-global-variables)
16409b0b 7051 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7052 (with-current-buffer gnus-article-buffer
16409b0b
GM
7053 (mm-destroy-parts gnus-article-mime-handles)
7054 ;; Set it to nil for safety reason.
7055 (setq gnus-article-mime-handle-alist nil)
7056 (setq gnus-article-mime-handles nil)))
eec82323 7057 (gnus-kill-save-kill-buffer)
6748645f 7058 (gnus-async-halt-prefetch)
eec82323
LMI
7059 (let* ((group gnus-newsgroup-name)
7060 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 7061 (gnus-group-is-exiting-p t)
eec82323 7062 (mode major-mode)
23f87bed 7063 (group-point nil)
eec82323 7064 (buf (current-buffer)))
16409b0b
GM
7065 (unless quit-config
7066 ;; Do adaptive scoring, and possibly save score files.
7067 (when gnus-newsgroup-adaptive
7068 (gnus-score-adaptive))
7069 (when gnus-use-scoring
7070 (gnus-score-save)))
6748645f 7071 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
7072 ;; If we have several article buffers, we kill them at exit.
7073 (unless gnus-single-article-buffer
01c52d31
MB
7074 (when (gnus-buffer-live-p gnus-article-buffer)
7075 (with-current-buffer gnus-article-buffer
7076 ;; Don't kill sticky article buffers
7077 (unless (eq major-mode 'gnus-sticky-article-mode)
7078 (gnus-kill-buffer gnus-article-buffer)
7079 (setq gnus-article-current nil))))
7080 (gnus-kill-buffer gnus-original-article-buffer))
eec82323
LMI
7081 (when gnus-use-cache
7082 (gnus-cache-possibly-remove-articles)
7083 (gnus-cache-save-buffers))
7084 (gnus-async-prefetch-remove-group group)
7085 (when gnus-suppress-duplicates
7086 (gnus-dup-enter-articles))
7087 (when gnus-use-trees
7088 (gnus-tree-close group))
16409b0b
GM
7089 (when gnus-use-cache
7090 (gnus-cache-write-active))
6748645f
LMI
7091 ;; Remove entries for this group.
7092 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
7093 ;; Make all changes in this group permanent.
7094 (unless quit-config
6748645f 7095 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 7096 (gnus-summary-update-info))
eec82323
LMI
7097 (gnus-close-group group)
7098 ;; Make sure where we were, and go to next newsgroup.
7099 (set-buffer gnus-group-buffer)
7100 (unless quit-config
7101 (gnus-group-jump-to-group group))
6748645f
LMI
7102 (gnus-run-hooks 'gnus-summary-exit-hook)
7103 (unless (or quit-config
01c52d31 7104 (not gnus-summary-next-group-on-exit)
6748645f
LMI
7105 ;; If this group has disappeared from the summary
7106 ;; buffer, don't skip forwards.
7107 (not (string= group (gnus-group-group-name))))
eec82323 7108 (gnus-group-next-unread-group 1))
a8151ef7 7109 (setq group-point (point))
eec82323
LMI
7110 (if temporary
7111 nil ;Nothing to do.
eec82323
LMI
7112 (set-buffer buf)
7113 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
7114 (progn
7115 (gnus-deaden-summary)
7116 (setq mode nil))
eec82323
LMI
7117 ;; We set all buffer-local variables to nil. It is unclear why
7118 ;; this is needed, but if we don't, buffer-local variables are
7119 ;; not garbage-collected, it seems. This would the lead to en
7120 ;; ever-growing Emacs.
7121 (gnus-summary-clear-local-variables)
23f87bed
MB
7122 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7123 (gnus-summary-clear-local-variables))
eec82323
LMI
7124 (when (get-buffer gnus-article-buffer)
7125 (bury-buffer gnus-article-buffer))
eec82323
LMI
7126 ;; Return to group mode buffer.
7127 (when (eq mode 'gnus-summary-mode)
7128 (gnus-kill-buffer buf)))
7129 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
7130 (set-buffer gnus-group-buffer)
7131 (if quit-config
7132 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
7133 (goto-char group-point)
7134 ;; If gnus-group-buffer is already displayed, make sure we also move
7135 ;; the cursor in the window that displays it.
7136 (let ((win (get-buffer-window (current-buffer) 0)))
7137 (if win (set-window-point win (point))))
d61c212b 7138 (unless leave-hidden
4e90f2b9 7139 (gnus-configure-windows 'group 'force)))
6748645f 7140 ;; Clear the current group name.
eec82323
LMI
7141 (unless quit-config
7142 (setq gnus-newsgroup-name nil)))))
7143
7144(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7145(defun gnus-summary-exit-no-update (&optional no-questions)
7146 "Quit reading current newsgroup without updating read article info."
7147 (interactive)
eec82323 7148 (let* ((group gnus-newsgroup-name)
23f87bed
MB
7149 (gnus-group-is-exiting-p t)
7150 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
7151 (quit-config (gnus-group-quit-config group)))
7152 (when (or no-questions
7153 gnus-expert-user
7154 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 7155 (gnus-async-halt-prefetch)
23f87bed 7156 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b 7157 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7158 (with-current-buffer gnus-article-buffer
16409b0b
GM
7159 (mm-destroy-parts gnus-article-mime-handles)
7160 ;; Set it to nil for safety reason.
7161 (setq gnus-article-mime-handle-alist nil)
7162 (setq gnus-article-mime-handles nil)))
eec82323
LMI
7163 ;; If we have several article buffers, we kill them at exit.
7164 (unless gnus-single-article-buffer
7165 (gnus-kill-buffer gnus-article-buffer)
7166 (gnus-kill-buffer gnus-original-article-buffer)
7167 (setq gnus-article-current nil))
7168 (if (not gnus-kill-summary-on-exit)
7169 (gnus-deaden-summary)
7170 (gnus-close-group group)
7171 (gnus-summary-clear-local-variables)
23f87bed
MB
7172 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7173 (gnus-summary-clear-local-variables))
7174 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
7175 (unless gnus-single-article-buffer
7176 (setq gnus-article-current nil))
7177 (when gnus-use-trees
7178 (gnus-tree-close group))
7179 (gnus-async-prefetch-remove-group group)
7180 (when (get-buffer gnus-article-buffer)
7181 (bury-buffer gnus-article-buffer))
7182 ;; Return to the group buffer.
7183 (gnus-configure-windows 'group 'force)
7184 ;; Clear the current group name.
7185 (setq gnus-newsgroup-name nil)
23f87bed
MB
7186 (unless (gnus-ephemeral-group-p group)
7187 (gnus-group-update-group group))
eec82323
LMI
7188 (when (equal (gnus-group-group-name) group)
7189 (gnus-group-next-unread-group 1))
7190 (when quit-config
23f87bed 7191 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
7192
7193(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
7194 "Handle movement when leaving an ephemeral group.
7195The state which existed when entering the ephemeral is reset."
eec82323
LMI
7196 (if (not (buffer-name (car quit-config)))
7197 (gnus-configure-windows 'group 'force)
7198 (set-buffer (car quit-config))
7199 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
7200 (gnus-set-global-variables))
7201 ((eq major-mode 'gnus-article-mode)
c7a91ce1 7202 (save-current-buffer
23f87bed
MB
7203 ;; The `gnus-summary-buffer' variable may point
7204 ;; to the old summary buffer when using a single
7205 ;; article buffer.
7206 (unless (gnus-buffer-live-p gnus-summary-buffer)
7207 (set-buffer gnus-group-buffer))
7208 (set-buffer gnus-summary-buffer)
7209 (gnus-set-global-variables))))
eec82323 7210 (if (or (eq (cdr quit-config) 'article)
23f87bed 7211 (eq (cdr quit-config) 'pick))
01c52d31
MB
7212 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7213 (gnus-configure-windows 'pick 'force)
7214 (gnus-configure-windows (cdr quit-config) 'force))
eec82323
LMI
7215 (gnus-configure-windows (cdr quit-config) 'force))
7216 (when (eq major-mode 'gnus-summary-mode)
01c52d31
MB
7217 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7218 next-unread-noselect))
7219 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7220 'next-noselect)
7221 (gnus-summary-next-subject 1 nil t))
7222 ((eq gnus-auto-select-on-ephemeral-exit
7223 'next-unread-noselect)
7224 (gnus-summary-next-subject 1 t t))))
7225 ;; Hide the article buffer which displays the article different
7226 ;; from the one that the cursor points to in the summary buffer.
7227 (gnus-configure-windows 'summary 'force))
7228 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7229 (gnus-summary-next-subject 1))
7230 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7231 (gnus-summary-next-subject 1 t))))
eec82323
LMI
7232 (gnus-summary-recenter)
7233 (gnus-summary-position-point))))
7234
7235;;; Dead summaries.
7236
bbf52f1e
SM
7237(defvar gnus-dead-summary-mode-map
7238 (let ((map (make-keymap)))
7239 (suppress-keymap map)
7240 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7241 (dolist (key '("\C-d" "\r" "\177" [delete]))
7242 (define-key map key 'gnus-summary-wake-up-the-dead))
7243 (dolist (key '("q" "Q"))
7244 (define-key map key 'bury-buffer))
7245 map))
7246
7247(define-minor-mode gnus-dead-summary-mode
eec82323 7248 "Minor mode for Gnus summary buffers."
bbf52f1e
SM
7249 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7250 (unless (derived-mode-p 'gnus-summary-mode)
7251 (setq gnus-dead-summary-mode nil)))
eec82323
LMI
7252
7253(defun gnus-deaden-summary ()
7254 "Make the current summary buffer into a dead summary buffer."
7255 ;; Kill any previous dead summary buffer.
7256 (when (and gnus-dead-summary
7257 (buffer-name gnus-dead-summary))
01c52d31 7258 (with-current-buffer gnus-dead-summary
eec82323
LMI
7259 (when gnus-dead-summary-mode
7260 (kill-buffer (current-buffer)))))
7261 ;; Make this the current dead summary.
7262 (setq gnus-dead-summary (current-buffer))
7263 (gnus-dead-summary-mode 1)
7264 (let ((name (buffer-name)))
7265 (when (string-match "Summary" name)
7266 (rename-buffer
7267 (concat (substring name 0 (match-beginning 0)) "Dead "
7268 (substring name (match-beginning 0)))
16409b0b
GM
7269 t)
7270 (bury-buffer))))
eec82323
LMI
7271
7272(defun gnus-kill-or-deaden-summary (buffer)
7273 "Kill or deaden the summary BUFFER."
6748645f
LMI
7274 (save-excursion
7275 (when (and (buffer-name buffer)
7276 (not gnus-single-article-buffer))
01c52d31 7277 (with-current-buffer buffer
6748645f
LMI
7278 (gnus-kill-buffer gnus-article-buffer)
7279 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
7280 (cond
7281 ;; Kill the buffer.
7282 (gnus-kill-summary-on-exit
7283 (when (and gnus-use-trees
7284 (gnus-buffer-exists-p buffer))
c7a91ce1 7285 (with-current-buffer buffer
23f87bed
MB
7286 (gnus-tree-close gnus-newsgroup-name)))
7287 (gnus-kill-buffer buffer))
7288 ;; Deaden the buffer.
7289 ((gnus-buffer-exists-p buffer)
c7a91ce1 7290 (with-current-buffer buffer
23f87bed 7291 (gnus-deaden-summary))))))
eec82323
LMI
7292
7293(defun gnus-summary-wake-up-the-dead (&rest args)
7294 "Wake up the dead summary buffer."
7295 (interactive)
7296 (gnus-dead-summary-mode -1)
7297 (let ((name (buffer-name)))
7298 (when (string-match "Dead " name)
7299 (rename-buffer
7300 (concat (substring name 0 (match-beginning 0))
7301 (substring name (match-end 0)))
7302 t)))
7303 (gnus-message 3 "This dead summary is now alive again"))
7304
7305;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7306(defun gnus-summary-fetch-faq (&optional faq-dir)
7307 "Fetch the FAQ for the current group.
7308If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7309in."
7310 (interactive
7311 (list
7312 (when current-prefix-arg
7313 (completing-read
8f688cb0 7314 "FAQ dir: " (and (listp gnus-group-faq-directory)
01c52d31 7315 (mapcar 'list
a8151ef7 7316 gnus-group-faq-directory))))))
eec82323
LMI
7317 (let (gnus-faq-buffer)
7318 (when (setq gnus-faq-buffer
7319 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7320 (gnus-configure-windows 'summary-faq))))
7321
7322;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7323(defun gnus-summary-describe-group (&optional force)
7324 "Describe the current newsgroup."
7325 (interactive "P")
7326 (gnus-group-describe-group force gnus-newsgroup-name))
7327
7328(defun gnus-summary-describe-briefly ()
7329 "Describe summary mode commands briefly."
7330 (interactive)
16409b0b 7331 (gnus-message 6 (substitute-command-keys "\\<gnus-summary-mode-map>\\[gnus-summary-next-page]:Select \\[gnus-summary-next-unread-article]:Forward \\[gnus-summary-prev-unread-article]:Backward \\[gnus-summary-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-summary-describe-briefly]:This help")))
eec82323
LMI
7332
7333;; Walking around group mode buffer from summary mode.
7334
7335(defun gnus-summary-next-group (&optional no-article target-group backward)
7336 "Exit current newsgroup and then select next unread newsgroup.
7337If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7338initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7339previous group instead."
7340 (interactive "P")
eec82323
LMI
7341 ;; Stop pre-fetching.
7342 (gnus-async-halt-prefetch)
7343 (let ((current-group gnus-newsgroup-name)
7344 (current-buffer (current-buffer))
7345 entered)
7346 ;; First we semi-exit this group to update Xrefs and all variables.
7347 ;; We can't do a real exit, because the window conf must remain
7348 ;; the same in case the user is prompted for info, and we don't
7349 ;; want the window conf to change before that...
7350 (gnus-summary-exit t)
7351 (while (not entered)
7352 ;; Then we find what group we are supposed to enter.
7353 (set-buffer gnus-group-buffer)
7354 (gnus-group-jump-to-group current-group)
7355 (setq target-group
7356 (or target-group
7357 (if (eq gnus-keep-same-level 'best)
7358 (gnus-summary-best-group gnus-newsgroup-name)
7359 (gnus-summary-search-group backward gnus-keep-same-level))))
7360 (if (not target-group)
7361 ;; There are no further groups, so we return to the group
7362 ;; buffer.
7363 (progn
7364 (gnus-message 5 "Returning to the group buffer")
7365 (setq entered t)
7366 (when (gnus-buffer-live-p current-buffer)
7367 (set-buffer current-buffer)
7368 (gnus-summary-exit))
6748645f 7369 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7370 ;; We try to enter the target group.
7371 (gnus-group-jump-to-group target-group)
7372 (let ((unreads (gnus-group-group-unread)))
7373 (if (and (or (eq t unreads)
7374 (and unreads (not (zerop unreads))))
23f87bed
MB
7375 (gnus-summary-read-group
7376 target-group nil no-article
7377 (and (buffer-name current-buffer) current-buffer)
7378 nil backward))
eec82323
LMI
7379 (setq entered t)
7380 (setq current-group target-group
7381 target-group nil)))))))
7382
7383(defun gnus-summary-prev-group (&optional no-article)
7384 "Exit current newsgroup and then select previous unread newsgroup.
7385If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7386 (interactive "P")
7387 (gnus-summary-next-group no-article nil t))
7388
7389;; Walking around summary lines.
7390
23f87bed
MB
7391(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7392 "Go to the first subject satisfying any non-nil constraint.
7393If UNREAD is non-nil, the article should be unread.
7394If UNDOWNLOADED is non-nil, the article should be undownloaded.
7395If UNSEEN is non-nil, the article should be unseen.
7396Returns the article selected or nil if there are no matching articles."
eec82323 7397 (interactive "P")
23f87bed
MB
7398 (cond
7399 ;; Empty summary.
7400 ((null gnus-newsgroup-data)
7401 (gnus-message 3 "No articles in the group")
7402 nil)
7403 ;; Pick the first article.
7404 ((not (or unread undownloaded unseen))
7405 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7406 (gnus-data-number (car gnus-newsgroup-data)))
7407 ;; Find the first unread article.
7408 (t
7409 (let ((data gnus-newsgroup-data))
7410 (while (and data
7411 (let ((num (gnus-data-number (car data))))
7412 (or (memq num gnus-newsgroup-unfetched)
7413 (not (or (and unread
7414 (memq num gnus-newsgroup-unreads))
7415 (and undownloaded
7416 (memq num gnus-newsgroup-undownloaded))
7417 (and unseen
7418 (memq num gnus-newsgroup-unseen)))))))
7419 (setq data (cdr data)))
7420 (prog1
7421 (if data
7422 (progn
7423 (goto-char (gnus-data-pos (car data)))
7424 (gnus-data-number (car data)))
7425 (gnus-message 3 "No more%s articles"
7426 (let* ((r (when unread " unread"))
7427 (d (when undownloaded " undownloaded"))
7428 (s (when unseen " unseen"))
7429 (l (delq nil (list r d s))))
7430 (cond ((= 3 (length l))
7431 (concat r "," d ", or" s))
7432 ((= 2 (length l))
7433 (concat (car l) ", or" (cadr l)))
7434 ((= 1 (length l))
7435 (car l))
7436 (t
7437 ""))))
7438 nil
7439 )
7440 (gnus-summary-position-point))))))
eec82323
LMI
7441
7442(defun gnus-summary-next-subject (n &optional unread dont-display)
7443 "Go to next N'th summary line.
7444If N is negative, go to the previous N'th subject line.
7445If UNREAD is non-nil, only unread articles are selected.
7446The difference between N and the actual number of steps taken is
7447returned."
7448 (interactive "p")
7449 (let ((backward (< n 0))
7450 (n (abs n)))
7451 (while (and (> n 0)
7452 (if backward
7453 (gnus-summary-find-prev unread)
7454 (gnus-summary-find-next unread)))
16409b0b
GM
7455 (unless (zerop (setq n (1- n)))
7456 (gnus-summary-show-thread)))
eec82323
LMI
7457 (when (/= 0 n)
7458 (gnus-message 7 "No more%s articles"
7459 (if unread " unread" "")))
7460 (unless dont-display
7461 (gnus-summary-recenter)
7462 (gnus-summary-position-point))
7463 n))
7464
7465(defun gnus-summary-next-unread-subject (n)
7466 "Go to next N'th unread summary line."
7467 (interactive "p")
7468 (gnus-summary-next-subject n t))
7469
7470(defun gnus-summary-prev-subject (n &optional unread)
7471 "Go to previous N'th summary line.
7472If optional argument UNREAD is non-nil, only unread article is selected."
7473 (interactive "p")
7474 (gnus-summary-next-subject (- n) unread))
7475
7476(defun gnus-summary-prev-unread-subject (n)
7477 "Go to previous N'th unread summary line."
7478 (interactive "p")
7479 (gnus-summary-next-subject (- n) t))
7480
23f87bed
MB
7481(defun gnus-summary-goto-subjects (articles)
7482 "Insert the subject header for ARTICLES in the current buffer."
7483 (save-excursion
7484 (dolist (article articles)
7485 (gnus-summary-goto-subject article t)))
7486 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7487 (gnus-summary-position-point))
132cf96d 7488
eec82323 7489(defun gnus-summary-goto-subject (article &optional force silent)
d55fe5bb 7490 "Go to the subject line of ARTICLE.
eec82323
LMI
7491If FORCE, also allow jumping to articles not currently shown."
7492 (interactive "nArticle number: ")
23f87bed
MB
7493 (unless (numberp article)
7494 (error "Article %s is not a number" article))
eec82323
LMI
7495 (let ((b (point))
7496 (data (gnus-data-find article)))
7497 ;; We read in the article if we have to.
7498 (and (not data)
7499 force
6748645f
LMI
7500 (gnus-summary-insert-subject
7501 article
7502 (if (or (numberp force) (vectorp force)) force)
7503 t)
eec82323
LMI
7504 (setq data (gnus-data-find article)))
7505 (goto-char b)
7506 (if (not data)
7507 (progn
7508 (unless silent
7509 (gnus-message 3 "Can't find article %d" article))
7510 nil)
23f87bed
MB
7511 (let ((pt (gnus-data-pos data)))
7512 (goto-char pt)
7513 (gnus-summary-set-article-display-arrow pt))
6748645f 7514 (gnus-summary-position-point)
eec82323
LMI
7515 article)))
7516
7517;; Walking around summary lines with displaying articles.
7518
7519(defun gnus-summary-expand-window (&optional arg)
7520 "Make the summary buffer take up the entire Emacs frame.
7521Given a prefix, will force an `article' buffer configuration."
7522 (interactive "P")
eec82323
LMI
7523 (if arg
7524 (gnus-configure-windows 'article 'force)
7525 (gnus-configure-windows 'summary 'force)))
7526
7527(defun gnus-summary-display-article (article &optional all-header)
7528 "Display ARTICLE in article buffer."
01c52d31
MB
7529 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7530 (with-current-buffer gnus-article-buffer
7531 (eq major-mode 'gnus-article-mode)))
7532 (gnus-article-setup-buffer))
eec82323 7533 (gnus-set-global-variables)
01c52d31
MB
7534 (with-current-buffer gnus-article-buffer
7535 (setq gnus-article-charset gnus-newsgroup-charset)
7536 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7537 (mm-enable-multibyte))
eec82323
LMI
7538 (if (null article)
7539 nil
7540 (prog1
7541 (if gnus-summary-display-article-function
7542 (funcall gnus-summary-display-article-function article all-header)
7543 (gnus-article-prepare article all-header))
6748645f 7544 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7545 (when (and gnus-current-article
7546 (not (zerop gnus-current-article)))
7547 (gnus-summary-goto-subject gnus-current-article))
7548 (gnus-summary-recenter)
7549 (when (and gnus-use-trees gnus-show-threads)
7550 (gnus-possibly-generate-tree article)
7551 (gnus-highlight-selected-tree article))
7552 ;; Successfully display article.
7553 (gnus-article-set-window-start
7554 (cdr (assq article gnus-newsgroup-bookmarks))))))
7555
7556(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7557 "Select the current article.
7558If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7559non-nil, the article will be re-fetched even if it already present in
7560the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7561be displayed."
7562 ;; Make sure we are in the summary buffer to work around bbdb bug.
7563 (unless (eq major-mode 'gnus-summary-mode)
7564 (set-buffer gnus-summary-buffer))
7565 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7566 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7567 gnus-summary-display-article-function)
eec82323
LMI
7568 (and (not pseudo)
7569 (gnus-summary-article-pseudo-p article)
a8151ef7 7570 (error "This is a pseudo-article"))
c7a91ce1 7571 (with-current-buffer gnus-summary-buffer
16409b0b
GM
7572 (if (or (and gnus-single-article-buffer
7573 (or (null gnus-current-article)
7574 (null gnus-article-current)
7575 (null (get-buffer gnus-article-buffer))
7576 (not (eq article (cdr gnus-article-current)))
7577 (not (equal (car gnus-article-current)
7578 gnus-newsgroup-name))))
7579 (and (not gnus-single-article-buffer)
7580 (or (null gnus-current-article)
7581 (not (eq gnus-current-article article))))
7582 force)
7583 ;; The requested article is different from the current article.
7584 (progn
16409b0b
GM
7585 (gnus-summary-display-article article all-headers)
7586 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7587 (with-current-buffer gnus-article-buffer
16409b0b 7588 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7589 (mm-disable-multibyte))))
16409b0b
GM
7590 (gnus-article-set-window-start
7591 (cdr (assq article gnus-newsgroup-bookmarks)))
7592 article)
16409b0b 7593 'old))))
eec82323 7594
23f87bed
MB
7595(defun gnus-summary-force-verify-and-decrypt ()
7596 "Display buttons for signed/encrypted parts and verify/decrypt them."
7597 (interactive)
7598 (let ((mm-verify-option 'known)
7599 (mm-decrypt-option 'known)
7600 (gnus-article-emulate-mime t)
7601 (gnus-buttonized-mime-types (append (list "multipart/signed"
7602 "multipart/encrypted")
7603 gnus-buttonized-mime-types)))
7604 (gnus-summary-select-article nil 'force)))
7605
eec82323
LMI
7606(defun gnus-summary-set-current-mark (&optional current-mark)
7607 "Obsolete function."
7608 nil)
7609
7610(defun gnus-summary-next-article (&optional unread subject backward push)
7611 "Select the next article.
7612If UNREAD, only unread articles are selected.
7613If SUBJECT, only articles with SUBJECT are selected.
7614If BACKWARD, the previous article is selected instead of the next."
7615 (interactive "P")
11e95b02
MB
7616 ;; Make sure we are in the summary buffer.
7617 (unless (eq major-mode 'gnus-summary-mode)
7618 (set-buffer gnus-summary-buffer))
eec82323
LMI
7619 (cond
7620 ;; Is there such an article?
7621 ((and (gnus-summary-search-forward unread subject backward)
7622 (or (gnus-summary-display-article (gnus-summary-article-number))
7623 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7624 (gnus-summary-position-point))
7625 ;; If not, we try the first unread, if that is wanted.
7626 ((and subject
7627 gnus-auto-select-same
7628 (gnus-summary-first-unread-article))
7629 (gnus-summary-position-point)
7630 (gnus-message 6 "Wrapped"))
7631 ;; Try to get next/previous article not displayed in this group.
7632 ((and gnus-auto-extend-newsgroup
7633 (not unread) (not subject))
7634 (gnus-summary-goto-article
7635 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7636 nil (count-lines (point-min) (point))))
eec82323
LMI
7637 ;; Go to next/previous group.
7638 (t
7639 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7640 (gnus-summary-jump-to-group gnus-newsgroup-name))
49e787c9
GM
7641 (let ((cmd (if (featurep 'xemacs)
7642 last-command-char
7643 last-command-event))
eec82323 7644 (point
01c52d31 7645 (with-current-buffer gnus-group-buffer
eec82323
LMI
7646 (point)))
7647 (group
7648 (if (eq gnus-keep-same-level 'best)
7649 (gnus-summary-best-group gnus-newsgroup-name)
7650 (gnus-summary-search-group backward gnus-keep-same-level))))
7651 ;; For some reason, the group window gets selected. We change
7652 ;; it back.
7653 (select-window (get-buffer-window (current-buffer)))
7654 ;; Select next unread newsgroup automagically.
7655 (cond
7656 ((or (not gnus-auto-select-next)
7657 (not cmd))
7658 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7659 ((or (eq gnus-auto-select-next 'quietly)
7660 (and (eq gnus-auto-select-next 'slightly-quietly)
7661 push)
7662 (and (eq gnus-auto-select-next 'almost-quietly)
7663 (gnus-summary-last-article-p)))
7664 ;; Select quietly.
7665 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7666 (gnus-summary-exit)
7667 (gnus-message 7 "No more%s articles (%s)..."
7668 (if unread " unread" "")
7669 (if group (concat "selecting " group)
7670 "exiting"))
7671 (gnus-summary-next-group nil group backward)))
7672 (t
7673 (when (gnus-key-press-event-p last-input-event)
7674 (gnus-summary-walk-group-buffer
7675 gnus-newsgroup-name cmd unread backward point))))))))
7676
7677(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7678 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7679 (?\C-p (gnus-group-prev-unread-group 1))))
7680 (cursor-in-echo-area t)
23f87bed 7681 keve key group ended prompt)
c7a91ce1 7682 (with-current-buffer gnus-group-buffer
eec82323
LMI
7683 (goto-char start)
7684 (setq group
7685 (if (eq gnus-keep-same-level 'best)
7686 (gnus-summary-best-group gnus-newsgroup-name)
7687 (gnus-summary-search-group backward gnus-keep-same-level))))
7688 (while (not ended)
23f87bed
MB
7689 (setq prompt
7690 (format
7691 "No more%s articles%s " (if unread " unread" "")
7692 (if (and group
7693 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7694 (format " (Type %s for %s [%s])"
91472578
MB
7695 (single-key-description cmd)
7696 (gnus-group-decoded-name group)
01c52d31 7697 (gnus-group-unread group))
23f87bed
MB
7698 (format " (Type %s to exit %s)"
7699 (single-key-description cmd)
91472578 7700 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7701 ;; Confirm auto selection.
23f87bed
MB
7702 (setq key (car (setq keve (gnus-read-event-char prompt)))
7703 ended t)
eec82323
LMI
7704 (cond
7705 ((assq key keystrokes)
7706 (let ((obuf (current-buffer)))
7707 (switch-to-buffer gnus-group-buffer)
7708 (when group
7709 (gnus-group-jump-to-group group))
7710 (eval (cadr (assq key keystrokes)))
7711 (setq group (gnus-group-group-name))
7712 (switch-to-buffer obuf))
7713 (setq ended nil))
7714 ((equal key cmd)
7715 (if (or (not group)
7716 (gnus-ephemeral-group-p gnus-newsgroup-name))
7717 (gnus-summary-exit)
7718 (gnus-summary-next-group nil group backward)))
7719 (t
7720 (push (cdr keve) unread-command-events))))))
7721
7722(defun gnus-summary-next-unread-article ()
7723 "Select unread article after current one."
7724 (interactive)
7725 (gnus-summary-next-article
7726 (or (not (eq gnus-summary-goto-unread 'never))
7727 (gnus-summary-last-article-p (gnus-summary-article-number)))
7728 (and gnus-auto-select-same
7729 (gnus-summary-article-subject))))
7730
7731(defun gnus-summary-prev-article (&optional unread subject)
bbbe940b 7732 "Select the article before the current one.
eec82323
LMI
7733If UNREAD is non-nil, only unread articles are selected."
7734 (interactive "P")
7735 (gnus-summary-next-article unread subject t))
7736
7737(defun gnus-summary-prev-unread-article ()
7738 "Select unread article before current one."
7739 (interactive)
7740 (gnus-summary-prev-article
7741 (or (not (eq gnus-summary-goto-unread 'never))
7742 (gnus-summary-first-article-p (gnus-summary-article-number)))
7743 (and gnus-auto-select-same
7744 (gnus-summary-article-subject))))
7745
23f87bed 7746(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7747 "Show next page of the selected article.
7748If at the end of the current article, select the next article.
7749LINES says how many lines should be scrolled up.
7750
7751If CIRCULAR is non-nil, go to the start of the article instead of
7752selecting the next article when reaching the end of the current
23f87bed
MB
7753article.
7754
7755If STOP is non-nil, just stop when reaching the end of the message.
7756
7757Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7758 (interactive "P")
7759 (setq gnus-summary-buffer (current-buffer))
7760 (gnus-set-global-variables)
7761 (let ((article (gnus-summary-article-number))
7762 (article-window (get-buffer-window gnus-article-buffer t))
7763 endp)
6748645f
LMI
7764 ;; If the buffer is empty, we have no article.
7765 (unless article
7766 (error "No article to select"))
eec82323
LMI
7767 (gnus-configure-windows 'article)
7768 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7769 (if (and (eq gnus-summary-goto-unread 'never)
7770 (not (gnus-summary-last-article-p article)))
7771 (gnus-summary-next-article)
7772 (gnus-summary-next-unread-article))
7773 (if (or (null gnus-current-article)
7774 (null gnus-article-current)
7775 (/= article (cdr gnus-article-current))
7776 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7777 ;; Selected subject is different from current article's.
7778 (gnus-summary-display-article article)
7779 (when article-window
7780 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7781 (setq endp (or (gnus-article-next-page lines)
7782 (gnus-article-only-boring-p))))
eec82323 7783 (when endp
23f87bed
MB
7784 (cond (stop
7785 (gnus-message 3 "End of message"))
7786 (circular
eec82323
LMI
7787 (gnus-summary-beginning-of-article))
7788 (lines
7789 (gnus-message 3 "End of message"))
7790 ((null lines)
7791 (if (and (eq gnus-summary-goto-unread 'never)
7792 (not (gnus-summary-last-article-p article)))
7793 (gnus-summary-next-article)
7794 (gnus-summary-next-unread-article))))))))
7795 (gnus-summary-recenter)
7796 (gnus-summary-position-point)))
7797
7798(defun gnus-summary-prev-page (&optional lines move)
7799 "Show previous page of selected article.
7800Argument LINES specifies lines to be scrolled down.
7801If MOVE, move to the previous unread article if point is at
7802the beginning of the buffer."
7803 (interactive "P")
eec82323
LMI
7804 (let ((article (gnus-summary-article-number))
7805 (article-window (get-buffer-window gnus-article-buffer t))
7806 endp)
7807 (gnus-configure-windows 'article)
7808 (if (or (null gnus-current-article)
7809 (null gnus-article-current)
7810 (/= article (cdr gnus-article-current))
7811 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7812 ;; Selected subject is different from current article's.
7813 (gnus-summary-display-article article)
7814 (gnus-summary-recenter)
7815 (when article-window
7816 (gnus-eval-in-buffer-window gnus-article-buffer
7817 (setq endp (gnus-article-prev-page lines)))
7818 (when (and move endp)
7819 (cond (lines
7820 (gnus-message 3 "Beginning of message"))
7821 ((null lines)
7822 (if (and (eq gnus-summary-goto-unread 'never)
7823 (not (gnus-summary-first-article-p article)))
7824 (gnus-summary-prev-article)
7825 (gnus-summary-prev-unread-article))))))))
7826 (gnus-summary-position-point))
7827
7828(defun gnus-summary-prev-page-or-article (&optional lines)
7829 "Show previous page of selected article.
7830Argument LINES specifies lines to be scrolled down.
7831If at the beginning of the article, go to the next article."
7832 (interactive "P")
7833 (gnus-summary-prev-page lines t))
7834
7835(defun gnus-summary-scroll-up (lines)
7836 "Scroll up (or down) one line current article.
7837Argument LINES specifies lines to be scrolled up (or down if negative)."
7838 (interactive "p")
eec82323
LMI
7839 (gnus-configure-windows 'article)
7840 (gnus-summary-show-thread)
7841 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7842 (gnus-eval-in-buffer-window gnus-article-buffer
7843 (cond ((> lines 0)
7844 (when (gnus-article-next-page lines)
7845 (gnus-message 3 "End of message")))
7846 ((< lines 0)
7847 (gnus-article-prev-page (- lines))))))
7848 (gnus-summary-recenter)
7849 (gnus-summary-position-point))
7850
6748645f
LMI
7851(defun gnus-summary-scroll-down (lines)
7852 "Scroll down (or up) one line current article.
7853Argument LINES specifies lines to be scrolled down (or up if negative)."
7854 (interactive "p")
7855 (gnus-summary-scroll-up (- lines)))
7856
eec82323
LMI
7857(defun gnus-summary-next-same-subject ()
7858 "Select next article which has the same subject as current one."
7859 (interactive)
eec82323
LMI
7860 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7861
7862(defun gnus-summary-prev-same-subject ()
7863 "Select previous article which has the same subject as current one."
7864 (interactive)
eec82323
LMI
7865 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7866
7867(defun gnus-summary-next-unread-same-subject ()
7868 "Select next unread article which has the same subject as current one."
7869 (interactive)
eec82323
LMI
7870 (gnus-summary-next-article t (gnus-summary-article-subject)))
7871
7872(defun gnus-summary-prev-unread-same-subject ()
7873 "Select previous unread article which has the same subject as current one."
7874 (interactive)
eec82323
LMI
7875 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7876
7877(defun gnus-summary-first-unread-article ()
7878 "Select the first unread article.
7879Return nil if there are no unread articles."
7880 (interactive)
eec82323
LMI
7881 (prog1
7882 (when (gnus-summary-first-subject t)
7883 (gnus-summary-show-thread)
7884 (gnus-summary-first-subject t)
7885 (gnus-summary-display-article (gnus-summary-article-number)))
7886 (gnus-summary-position-point)))
7887
16409b0b
GM
7888(defun gnus-summary-first-unread-subject ()
7889 "Place the point on the subject line of the first unread article.
7890Return nil if there are no unread articles."
7891 (interactive)
7892 (prog1
7893 (when (gnus-summary-first-subject t)
7894 (gnus-summary-show-thread)
7895 (gnus-summary-first-subject t))
7896 (gnus-summary-position-point)))
7897
23f87bed
MB
7898(defun gnus-summary-first-unseen-subject ()
7899 "Place the point on the subject line of the first unseen article.
7900Return nil if there are no unseen articles."
7901 (interactive)
7902 (prog1
7903 (when (gnus-summary-first-subject nil nil t)
7904 (gnus-summary-show-thread)
7905 (gnus-summary-first-subject nil nil t))
7906 (gnus-summary-position-point)))
7907
7908(defun gnus-summary-first-unseen-or-unread-subject ()
7909 "Place the point on the subject line of the first unseen article or,
7910if all article have been seen, on the subject line of the first unread
7911article."
7912 (interactive)
7913 (prog1
7914 (unless (when (gnus-summary-first-subject nil nil t)
7915 (gnus-summary-show-thread)
7916 (gnus-summary-first-subject nil nil t))
7917 (when (gnus-summary-first-subject t)
7918 (gnus-summary-show-thread)
7919 (gnus-summary-first-subject t)))
7920 (gnus-summary-position-point)))
7921
eec82323
LMI
7922(defun gnus-summary-first-article ()
7923 "Select the first article.
7924Return nil if there are no articles."
7925 (interactive)
eec82323
LMI
7926 (prog1
7927 (when (gnus-summary-first-subject)
16409b0b
GM
7928 (gnus-summary-show-thread)
7929 (gnus-summary-first-subject)
7930 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
7931 (gnus-summary-position-point)))
7932
23f87bed
MB
7933(defun gnus-summary-best-unread-article (&optional arg)
7934 "Select the unread article with the highest score.
7935If given a prefix argument, select the next unread article that has a
7936score higher than the default score."
7937 (interactive "P")
7938 (let ((article (if arg
7939 (gnus-summary-better-unread-subject)
7940 (gnus-summary-best-unread-subject))))
7941 (if article
7942 (gnus-summary-goto-article article)
7943 (error "No unread articles"))))
7944
7945(defun gnus-summary-best-unread-subject ()
7946 "Select the unread subject with the highest score."
eec82323 7947 (interactive)
eec82323
LMI
7948 (let ((best -1000000)
7949 (data gnus-newsgroup-data)
7950 article score)
7951 (while data
7952 (and (gnus-data-unread-p (car data))
7953 (> (setq score
7954 (gnus-summary-article-score (gnus-data-number (car data))))
7955 best)
7956 (setq best score
7957 article (gnus-data-number (car data))))
7958 (setq data (cdr data)))
23f87bed
MB
7959 (when article
7960 (gnus-summary-goto-subject article))
7961 (gnus-summary-position-point)
7962 article))
7963
7964(defun gnus-summary-better-unread-subject ()
7965 "Select the first unread subject that has a score over the default score."
7966 (interactive)
7967 (let ((data gnus-newsgroup-data)
7968 article score)
7969 (while (and (setq article (gnus-data-number (car data)))
7970 (or (gnus-data-read-p (car data))
7971 (not (> (gnus-summary-article-score article)
7972 gnus-summary-default-score))))
7973 (setq data (cdr data)))
7974 (when article
7975 (gnus-summary-goto-subject article))
7976 (gnus-summary-position-point)
7977 article))
eec82323
LMI
7978
7979(defun gnus-summary-last-subject ()
7980 "Go to the last displayed subject line in the group."
7981 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7982 (when article
7983 (gnus-summary-goto-subject article))))
7984
7985(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
7986 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7987If ALL-HEADERS is non-nil, no header lines are hidden.
7988If FORCE, go to the article even if it isn't displayed. If FORCE
7989is a number, it is the line the article is to be displayed on."
eec82323
LMI
7990 (interactive
7991 (list
6748645f
LMI
7992 (completing-read
7993 "Article number or Message-ID: "
7994 (mapcar (lambda (number) (list (int-to-string number)))
7995 gnus-newsgroup-limit))
eec82323
LMI
7996 current-prefix-arg
7997 t))
7998 (prog1
6748645f 7999 (if (and (stringp article)
23f87bed 8000 (string-match "@\\|%40" article))
6748645f
LMI
8001 (gnus-summary-refer-article article)
8002 (when (stringp article)
8003 (setq article (string-to-number article)))
8004 (if (gnus-summary-goto-subject article force)
8005 (gnus-summary-display-article article all-headers)
8006 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
8007 (gnus-summary-position-point)))
8008
8009(defun gnus-summary-goto-last-article ()
8010 "Go to the previously read article."
8011 (interactive)
8012 (prog1
8013 (when gnus-last-article
6748645f 8014 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
8015 (gnus-summary-position-point)))
8016
8017(defun gnus-summary-pop-article (number)
8018 "Pop one article off the history and go to the previous.
8019NUMBER articles will be popped off."
8020 (interactive "p")
8021 (let (to)
8022 (setq gnus-newsgroup-history
8023 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8024 (if to
6748645f 8025 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
8026 (error "Article history empty")))
8027 (gnus-summary-position-point))
8028
8029;; Summary commands and functions for limiting the summary buffer.
8030
8031(defun gnus-summary-limit-to-articles (n)
8032 "Limit the summary buffer to the next N articles.
8033If not given a prefix, use the process marked articles instead."
8034 (interactive "P")
eec82323
LMI
8035 (prog1
8036 (let ((articles (gnus-summary-work-articles n)))
8037 (setq gnus-newsgroup-processable nil)
8038 (gnus-summary-limit articles))
8039 (gnus-summary-position-point)))
8040
8041(defun gnus-summary-pop-limit (&optional total)
8042 "Restore the previous limit.
8043If given a prefix, remove all limits."
8044 (interactive "P")
eec82323
LMI
8045 (when total
8046 (setq gnus-newsgroup-limits
8047 (list (mapcar (lambda (h) (mail-header-number h))
8048 gnus-newsgroup-headers))))
8049 (unless gnus-newsgroup-limits
8050 (error "No limit to pop"))
8051 (prog1
8052 (gnus-summary-limit nil 'pop)
8053 (gnus-summary-position-point)))
8054
47b63dfa
SZ
8055(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8056 "Limit the summary buffer to articles that have subjects that match a regexp.
8057If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 8058 (interactive
47b63dfa
SZ
8059 (list (read-string (if current-prefix-arg
8060 "Exclude subject (regexp): "
a1506d29 8061 "Limit to subject (regexp): "))
47b63dfa 8062 nil current-prefix-arg))
eec82323
LMI
8063 (unless header
8064 (setq header "subject"))
8065 (when (not (equal "" subject))
8066 (prog1
8067 (let ((articles (gnus-summary-find-matching
a1506d29 8068 (or header "subject") subject 'all nil nil
47b63dfa 8069 not-matching)))
eec82323
LMI
8070 (unless articles
8071 (error "Found no matches for \"%s\"" subject))
8072 (gnus-summary-limit articles))
8073 (gnus-summary-position-point))))
8074
ef6e0ec7 8075(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
8076 "Limit the summary buffer to articles that have authors that match a regexp.
8077If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 8078 (interactive
47b63dfa
SZ
8079 (list (read-string (if current-prefix-arg
8080 "Exclude author (regexp): "
a1506d29 8081 "Limit to author (regexp): "))
ef6e0ec7
SZ
8082 current-prefix-arg))
8083 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323 8084
01c52d31
MB
8085(defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8086 "Limit the summary buffer to articles with the given RECIPIENT.
8087
8088If NOT-MATCHING, exclude RECIPIENT.
8089
8090To and Cc headers are checked. You need to include them in
8091`nnmail-extra-headers'."
8092 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8093 (interactive
8094 (list (read-string (format "%s recipient (regexp): "
8095 (if current-prefix-arg "Exclude" "Limit to")))
8096 current-prefix-arg))
8097 (when (not (equal "" recipient))
8098 (prog1 (let* ((to
8099 (if (memq 'To nnmail-extra-headers)
8100 (gnus-summary-find-matching
8101 (cons 'extra 'To) recipient 'all nil nil
8102 not-matching)
8103 (gnus-message
8104 1 "`To' isn't present in `nnmail-extra-headers'")
8105 (sit-for 1)
8106 nil))
8107 (cc
8108 (if (memq 'Cc nnmail-extra-headers)
8109 (gnus-summary-find-matching
8110 (cons 'extra 'Cc) recipient 'all nil nil
8111 not-matching)
8112 (gnus-message
8113 1 "`Cc' isn't present in `nnmail-extra-headers'")
8114 (sit-for 1)
8115 nil))
8116 (articles
8117 (if not-matching
8118 ;; We need the numbers that are in both lists:
8119 (mapcar (lambda (a)
8120 (and (memq a to) a))
8121 cc)
8122 (nconc to cc))))
8123 (unless articles
8124 (error "Found no matches for \"%s\"" recipient))
8125 (gnus-summary-limit articles))
8126 (gnus-summary-position-point))))
8127
8128(defun gnus-summary-limit-to-address (address &optional not-matching)
8129 "Limit the summary buffer to articles with the given ADDRESS.
8130
8131If NOT-MATCHING, exclude ADDRESS.
8132
8133To, Cc and From headers are checked. You need to include `To' and `Cc'
8134in `nnmail-extra-headers'."
8135 (interactive
8136 (list (read-string (format "%s address (regexp): "
8137 (if current-prefix-arg "Exclude" "Limit to")))
8138 current-prefix-arg))
8139 (when (not (equal "" address))
8140 (prog1 (let* ((to
8141 (if (memq 'To nnmail-extra-headers)
8142 (gnus-summary-find-matching
8143 (cons 'extra 'To) address 'all nil nil
8144 not-matching)
8145 (gnus-message
8146 1 "`To' isn't present in `nnmail-extra-headers'")
8147 (sit-for 1)
8148 t))
8149 (cc
8150 (if (memq 'Cc nnmail-extra-headers)
8151 (gnus-summary-find-matching
8152 (cons 'extra 'Cc) address 'all nil nil
8153 not-matching)
8154 (gnus-message
8155 1 "`Cc' isn't present in `nnmail-extra-headers'")
8156 (sit-for 1)
8157 t))
8158 (from
8159 (gnus-summary-find-matching "from" address
8160 'all nil nil not-matching))
8161 (articles
8162 (if not-matching
8163 ;; We need the numbers that are in all lists:
8164 (if (eq cc t)
8165 (if (eq to t)
8166 from
8167 (mapcar (lambda (a) (car (memq a from))) to))
8168 (if (eq to t)
8169 (mapcar (lambda (a) (car (memq a from))) cc)
8170 (mapcar (lambda (a) (car (memq a from)))
8171 (mapcar (lambda (a) (car (memq a to)))
8172 cc))))
8173 (nconc (if (eq to t) nil to)
8174 (if (eq cc t) nil cc)
8175 from))))
8176 (unless articles
8177 (error "Found no matches for \"%s\"" address))
8178 (gnus-summary-limit articles))
8179 (gnus-summary-position-point))))
8180
8181(defun gnus-summary-limit-strange-charsets-predicate (header)
765d4319
KY
8182 (when (fboundp 'char-charset)
8183 (let ((string (concat (mail-header-subject header)
8184 (mail-header-from header)))
8185 charset found)
8186 (dotimes (i (1- (length string)))
8187 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8188 (when (string-match "unicode\\|big\\|japanese" charset)
8189 (setq found t)))
8190 found)))
01c52d31
MB
8191
8192(defun gnus-summary-limit-to-predicate (predicate)
8193 "Limit to articles where PREDICATE returns non-nil.
8194PREDICATE will be called with the header structures of the
8195articles."
8196 (let ((articles nil)
8197 (case-fold-search t))
8198 (dolist (header gnus-newsgroup-headers)
8199 (when (funcall predicate header)
8200 (push (mail-header-number header) articles)))
8201 (gnus-summary-limit (nreverse articles))))
8202
eec82323
LMI
8203(defun gnus-summary-limit-to-age (age &optional younger-p)
8204 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8205If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8206articles that are younger than AGE days."
16409b0b
GM
8207 (interactive
8208 (let ((younger current-prefix-arg)
8209 (days-got nil)
8210 days)
8211 (while (not days-got)
8212 (setq days (if younger
23f87bed
MB
8213 (read-string "Limit to articles younger than (in days, older when negative): ")
8214 (read-string
8215 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
8216 (when (> (length days) 0)
8217 (setq days (read days)))
8218 (if (numberp days)
23f87bed
MB
8219 (progn
8220 (setq days-got t)
01c52d31
MB
8221 (when (< days 0)
8222 (setq younger (not younger))
8223 (setq days (* days -1))))
16409b0b
GM
8224 (message "Please enter a number.")
8225 (sleep-for 1)))
8226 (list days younger)))
eec82323
LMI
8227 (prog1
8228 (let ((data gnus-newsgroup-data)
16409b0b 8229 (cutoff (days-to-time age))
eec82323
LMI
8230 articles d date is-younger)
8231 (while (setq d (pop data))
8232 (when (and (vectorp (gnus-data-header d))
8233 (setq date (mail-header-date (gnus-data-header d))))
16409b0b 8234 (setq is-younger (time-less-p
3d6e7a43 8235 (time-since (gnus-date-get-time date))
eec82323 8236 cutoff))
6748645f
LMI
8237 (when (if younger-p
8238 is-younger
8239 (not is-younger))
eec82323
LMI
8240 (push (gnus-data-number d) articles))))
8241 (gnus-summary-limit (nreverse articles)))
8242 (gnus-summary-position-point)))
8243
47b63dfa 8244(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
8245 "Limit the summary buffer to articles that match an 'extra' header."
8246 (interactive
8247 (let ((header
8248 (intern
23f87bed 8249 (gnus-completing-read-with-default
16409b0b 8250 (symbol-name (car gnus-extra-headers))
47b63dfa 8251 (if current-prefix-arg
81df110a
RF
8252 "Exclude extra header"
8253 "Limit extra header")
16409b0b
GM
8254 (mapcar (lambda (x)
8255 (cons (symbol-name x) x))
8256 gnus-extra-headers)
8257 nil
8258 t))))
8259 (list header
a1506d29 8260 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
8261 (if current-prefix-arg "Exclude" "Limit to")
8262 header))
8263 current-prefix-arg)))
16409b0b
GM
8264 (when (not (equal "" regexp))
8265 (prog1
8266 (let ((articles (gnus-summary-find-matching
a1506d29 8267 (cons 'extra header) regexp 'all nil nil
47b63dfa 8268 not-matching)))
16409b0b
GM
8269 (unless articles
8270 (error "Found no matches for \"%s\"" regexp))
8271 (gnus-summary-limit articles))
8272 (gnus-summary-position-point))))
8273
23f87bed
MB
8274(defun gnus-summary-limit-to-display-predicate ()
8275 "Limit the summary buffer to the predicated in the `display' group parameter."
8276 (interactive)
8277 (unless gnus-newsgroup-display
8278 (error "There is no `display' group parameter"))
8279 (let (articles)
8280 (dolist (number gnus-newsgroup-articles)
8281 (when (funcall gnus-newsgroup-display)
8282 (push number articles)))
8283 (gnus-summary-limit articles))
8284 (gnus-summary-position-point))
8285
eec82323
LMI
8286(defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8287(make-obsolete
265ac10b 8288 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread "Emacs 20.4")
eec82323
LMI
8289
8290(defun gnus-summary-limit-to-unread (&optional all)
8291 "Limit the summary buffer to articles that are not marked as read.
8292If ALL is non-nil, limit strictly to unread articles."
8293 (interactive "P")
8294 (if all
8295 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8296 (gnus-summary-limit-to-marks
8297 ;; Concat all the marks that say that an article is read and have
8298 ;; those removed.
8299 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 8300 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
8301 gnus-low-score-mark gnus-expirable-mark
8302 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8303 gnus-duplicate-mark gnus-souped-mark)
8304 'reverse)))
8305
01c52d31
MB
8306(defun gnus-summary-limit-to-headers (match &optional reverse)
8307 "Limit the summary buffer to articles that have headers that match MATCH.
8308If REVERSE (the prefix), limit to articles that don't match."
8309 (interactive "sMatch headers (regexp): \nP")
8310 (gnus-summary-limit-to-bodies match reverse t))
8311
8312(defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8313 "Limit the summary buffer to articles that have bodies that match MATCH.
8314If REVERSE (the prefix), limit to articles that don't match."
8315 (interactive "sMatch body (regexp): \nP")
8316 (let ((articles nil)
8317 (gnus-select-article-hook nil) ;Disable hook.
8318 (gnus-article-prepare-hook nil)
8319 (gnus-use-article-prefetch nil)
8320 (gnus-keep-backlog nil)
8321 (gnus-break-pages nil)
8322 (gnus-summary-display-arrow nil)
8323 (gnus-updated-mode-lines nil)
8324 (gnus-auto-center-summary nil)
8325 (gnus-display-mime-function nil))
8326 (dolist (data gnus-newsgroup-data)
8327 (let (gnus-mark-article-hook)
8328 (gnus-summary-select-article t t nil (gnus-data-number data)))
398a825b 8329 (with-current-buffer gnus-article-buffer
01c52d31
MB
8330 (article-goto-body)
8331 (let* ((case-fold-search t)
8332 (found (if headersp
8333 (re-search-backward match nil t)
8334 (re-search-forward match nil t))))
8335 (when (or (and found
8336 (not reverse))
8337 (and (not found)
8338 reverse))
8339 (push (gnus-data-number data) articles)))))
8340 (if (not articles)
8341 (message "No messages matched")
8342 (gnus-summary-limit articles)))
8343 (gnus-summary-position-point))
8344
8345(defun gnus-summary-limit-to-singletons (&optional threadsp)
8346 "Limit the summary buffer to articles that aren't part on any thread.
8347If THREADSP (the prefix), limit to articles that are in threads."
8348 (interactive "P")
8349 (let ((articles nil)
8350 thread-articles
8351 threads)
8352 (dolist (thread gnus-newsgroup-threads)
8353 (if (stringp (car thread))
8354 (dolist (thread (cdr thread))
8355 (push thread threads))
8356 (push thread threads)))
8357 (dolist (thread threads)
8358 (setq thread-articles (gnus-articles-in-thread thread))
8359 (when (or (and threadsp
8360 (> (length thread-articles) 1))
8361 (and (not threadsp)
8362 (= (length thread-articles) 1)))
8363 (setq articles (nconc thread-articles articles))))
8364 (if (not articles)
8365 (message "No messages matched")
8366 (gnus-summary-limit articles))
8367 (gnus-summary-position-point)))
8368
8369(defun gnus-summary-limit-to-replied (&optional unreplied)
8370 "Limit the summary buffer to replied articles.
8371If UNREPLIED (the prefix), limit to unreplied articles."
8372 (interactive "P")
8373 (if unreplied
8374 (gnus-summary-limit
8375 (gnus-set-difference gnus-newsgroup-articles
8376 gnus-newsgroup-replied))
8377 (gnus-summary-limit gnus-newsgroup-replied))
8378 (gnus-summary-position-point))
8379
eec82323
LMI
8380(defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
8381(make-obsolete 'gnus-summary-delete-marked-with
265ac10b 8382 'gnus-summary-limit-exclude-marks "Emacs 20.4")
eec82323
LMI
8383
8384(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8385 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8386If REVERSE, limit the summary buffer to articles that are marked
8387with MARKS. MARKS can either be a string of marks or a list of marks.
8388Returns how many articles were removed."
8389 (interactive "sMarks: ")
8390 (gnus-summary-limit-to-marks marks t))
8391
8392(defun gnus-summary-limit-to-marks (marks &optional reverse)
8393 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8394If REVERSE (the prefix), limit the summary buffer to articles that are
8395not marked with MARKS. MARKS can either be a string of marks or a
8396list of marks.
8397Returns how many articles were removed."
6748645f 8398 (interactive "sMarks: \nP")
eec82323
LMI
8399 (prog1
8400 (let ((data gnus-newsgroup-data)
8401 (marks (if (listp marks) marks
8402 (append marks nil))) ; Transform to list.
8403 articles)
8404 (while data
8405 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8406 (memq (gnus-data-mark (car data)) marks))
8407 (push (gnus-data-number (car data)) articles))
8408 (setq data (cdr data)))
8409 (gnus-summary-limit articles))
8410 (gnus-summary-position-point)))
8411
23f87bed 8412(defun gnus-summary-limit-to-score (score)
eec82323 8413 "Limit to articles with score at or above SCORE."
23f87bed 8414 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
8415 (let ((data gnus-newsgroup-data)
8416 articles)
8417 (while data
8418 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8419 score)
8420 (push (gnus-data-number (car data)) articles))
8421 (setq data (cdr data)))
8422 (prog1
8423 (gnus-summary-limit articles)
8424 (gnus-summary-position-point))))
8425
23f87bed
MB
8426(defun gnus-summary-limit-to-unseen ()
8427 "Limit to unseen articles."
8428 (interactive)
8429 (prog1
8430 (gnus-summary-limit gnus-newsgroup-unseen)
8431 (gnus-summary-position-point)))
8432
6748645f 8433(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
8434 "Display all the hidden articles that is in the thread with ID in it.
8435When called interactively, ID is the Message-ID of the current
8436article."
6748645f
LMI
8437 (interactive (list (mail-header-id (gnus-summary-article-header))))
8438 (let ((articles (gnus-articles-in-thread
8439 (gnus-id-to-thread (gnus-root-id id)))))
8440 (prog1
8441 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
8442 (gnus-summary-limit-include-matching-articles
8443 "subject"
8444 (regexp-quote (gnus-simplify-subject-re
8445 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
8446 (gnus-summary-position-point))))
8447
23f87bed
MB
8448(defun gnus-summary-limit-include-matching-articles (header regexp)
8449 "Display all the hidden articles that have HEADERs that match REGEXP."
8450 (interactive (list (read-string "Match on header: ")
8451 (read-string "Regexp: ")))
8452 (let ((articles (gnus-find-matching-articles header regexp)))
8453 (prog1
8454 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8455 (gnus-summary-position-point))))
8456
8457(defun gnus-summary-insert-dormant-articles ()
8458 "Insert all the dormant articles for this group into the current buffer."
8459 (interactive)
8460 (let ((gnus-verbose (max 6 gnus-verbose)))
8461 (if (not gnus-newsgroup-dormant)
db629244 8462 (gnus-message 3 "No dormant articles for this group")
23f87bed
MB
8463 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8464
01c52d31
MB
8465(defun gnus-summary-insert-ticked-articles ()
8466 "Insert ticked articles for this group into the current buffer."
8467 (interactive)
8468 (let ((gnus-verbose (max 6 gnus-verbose)))
8469 (if (not gnus-newsgroup-marked)
8470 (gnus-message 3 "No ticked articles for this group")
8471 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8472
eec82323 8473(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
8474 "Display all the hidden articles that are marked as dormant.
8475Note that this command only works on a subset of the articles currently
8476fetched for this group."
eec82323 8477 (interactive)
eec82323
LMI
8478 (unless gnus-newsgroup-dormant
8479 (error "There are no dormant articles in this group"))
8480 (prog1
8481 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8482 (gnus-summary-position-point)))
8483
8484(defun gnus-summary-limit-exclude-dormant ()
8485 "Hide all dormant articles."
8486 (interactive)
eec82323
LMI
8487 (prog1
8488 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8489 (gnus-summary-position-point)))
8490
8491(defun gnus-summary-limit-exclude-childless-dormant ()
8492 "Hide all dormant articles that have no children."
8493 (interactive)
eec82323
LMI
8494 (let ((data (gnus-data-list t))
8495 articles d children)
8496 ;; Find all articles that are either not dormant or have
8497 ;; children.
8498 (while (setq d (pop data))
8499 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8500 (and (setq children
8501 (gnus-article-children (gnus-data-number d)))
8502 (let (found)
8503 (while children
8504 (when (memq (car children) articles)
8505 (setq children nil
8506 found t))
8507 (pop children))
8508 found)))
8509 (push (gnus-data-number d) articles)))
8510 ;; Do the limiting.
8511 (prog1
8512 (gnus-summary-limit articles)
8513 (gnus-summary-position-point))))
8514
8515(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8516 "Mark all unread excluded articles as read.
8517If ALL, mark even excluded ticked and dormants as read."
8518 (interactive "P")
23f87bed
MB
8519 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8520 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8521 (sort
8522 (mapcar (lambda (h) (mail-header-number h))
8523 gnus-newsgroup-headers)
8524 '<)
23f87bed 8525 gnus-newsgroup-limit))
eec82323 8526 article)
6748645f 8527 (setq gnus-newsgroup-unreads
23f87bed
MB
8528 (gnus-sorted-intersection gnus-newsgroup-unreads
8529 gnus-newsgroup-limit))
eec82323
LMI
8530 (if all
8531 (setq gnus-newsgroup-dormant nil
8532 gnus-newsgroup-marked nil
8533 gnus-newsgroup-reads
8534 (nconc
8535 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8536 gnus-newsgroup-reads))
8537 (while (setq article (pop articles))
8538 (unless (or (memq article gnus-newsgroup-dormant)
8539 (memq article gnus-newsgroup-marked))
8540 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8541
8542(defun gnus-summary-limit (articles &optional pop)
8543 (if pop
8544 ;; We pop the previous limit off the stack and use that.
8545 (setq articles (car gnus-newsgroup-limits)
8546 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8547 ;; We use the new limit, so we push the old limit on the stack.
8548 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8549 ;; Set the limit.
8550 (setq gnus-newsgroup-limit articles)
8551 (let ((total (length gnus-newsgroup-data))
8552 (data (gnus-data-find-list (gnus-summary-article-number)))
8553 (gnus-summary-mark-below nil) ; Inhibit this.
8554 found)
8555 ;; This will do all the work of generating the new summary buffer
8556 ;; according to the new limit.
8557 (gnus-summary-prepare)
8558 ;; Hide any threads, possibly.
23f87bed 8559 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8560 ;; Try to return to the article you were at, or one in the
8561 ;; neighborhood.
8562 (when data
8563 ;; We try to find some article after the current one.
8564 (while data
8565 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8566 (setq data nil
8567 found t))
8568 (setq data (cdr data))))
8569 (unless found
8570 ;; If there is no data, that means that we were after the last
8571 ;; article. The same goes when we can't find any articles
8572 ;; after the current one.
8573 (goto-char (point-max))
8574 (gnus-summary-find-prev))
6748645f 8575 (gnus-set-mode-line 'summary)
eec82323
LMI
8576 ;; We return how many articles were removed from the summary
8577 ;; buffer as a result of the new limit.
8578 (- total (length gnus-newsgroup-data))))
8579
8580(defsubst gnus-invisible-cut-children (threads)
8581 (let ((num 0))
8582 (while threads
8583 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8584 (incf num))
8585 (pop threads))
8586 (< num 2)))
8587
8588(defsubst gnus-cut-thread (thread)
8589 "Go forwards in the thread until we find an article that we want to display."
8590 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8591 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8592 (numberp gnus-fetch-old-headers)
eec82323
LMI
8593 (eq gnus-build-sparse-threads 'some)
8594 (eq gnus-build-sparse-threads 'more))
8595 ;; Deal with old-fetched headers and sparse threads.
8596 (while (and
8597 thread
8598 (or
8599 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8600 (gnus-summary-article-ancient-p
8601 (mail-header-number (car thread))))
6748645f
LMI
8602 (if (or (<= (length (cdr thread)) 1)
8603 (eq gnus-fetch-old-headers 'invisible))
8604 (setq gnus-newsgroup-limit
8605 (delq (mail-header-number (car thread))
8606 gnus-newsgroup-limit)
8607 thread (cadr thread))
8608 (when (gnus-invisible-cut-children (cdr thread))
8609 (let ((th (cdr thread)))
8610 (while th
8611 (if (memq (mail-header-number (caar th))
a8151ef7 8612 gnus-newsgroup-limit)
6748645f
LMI
8613 (setq thread (car th)
8614 th nil)
8615 (setq th (cdr th))))))))))
eec82323
LMI
8616 thread)
8617
8618(defun gnus-cut-threads (threads)
23f87bed 8619 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8620 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8621 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8622 (numberp gnus-fetch-old-headers)
eec82323
LMI
8623 (eq gnus-build-sparse-threads 'some)
8624 (eq gnus-build-sparse-threads 'more))
8625 (let ((th threads))
8626 (while th
8627 (setcar th (gnus-cut-thread (car th)))
8628 (setq th (cdr th)))))
8629 ;; Remove nixed out threads.
8630 (delq nil threads))
8631
8632(defun gnus-summary-initial-limit (&optional show-if-empty)
8633 "Figure out what the initial limit is supposed to be on group entry.
8634This entails weeding out unwanted dormants, low-scored articles,
8635fetch-old-headers verbiage, and so on."
8636 ;; Most groups have nothing to remove.
f394fa25
MB
8637 (unless (or gnus-inhibit-limiting
8638 (and (null gnus-newsgroup-dormant)
8639 (eq gnus-newsgroup-display 'gnus-not-ignore)
8640 (not (eq gnus-fetch-old-headers 'some))
8641 (not (numberp gnus-fetch-old-headers))
8642 (not (eq gnus-fetch-old-headers 'invisible))
8643 (null gnus-summary-expunge-below)
8644 (not (eq gnus-build-sparse-threads 'some))
8645 (not (eq gnus-build-sparse-threads 'more))
8646 (null gnus-thread-expunge-below)
8647 (not gnus-use-nocem)))
eec82323
LMI
8648 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8649 (setq gnus-newsgroup-limit nil)
8650 (mapatoms
8651 (lambda (node)
8652 (unless (car (symbol-value node))
8653 ;; These threads have no parents -- they are roots.
8654 (let ((nodes (cdr (symbol-value node)))
8655 thread)
8656 (while nodes
8657 (if (and gnus-thread-expunge-below
8658 (< (gnus-thread-total-score (car nodes))
8659 gnus-thread-expunge-below))
8660 (gnus-expunge-thread (pop nodes))
8661 (setq thread (pop nodes))
8662 (gnus-summary-limit-children thread))))))
8663 gnus-newsgroup-dependencies)
8664 ;; If this limitation resulted in an empty group, we might
8665 ;; pop the previous limit and use it instead.
8666 (when (and (not gnus-newsgroup-limit)
8667 show-if-empty)
8668 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8669 gnus-newsgroup-limit))
8670
8671(defun gnus-summary-limit-children (thread)
8672 "Return 1 if this subthread is visible and 0 if it is not."
8673 ;; First we get the number of visible children to this thread. This
8674 ;; is done by recursing down the thread using this function, so this
8675 ;; will really go down to a leaf article first, before slowly
8676 ;; working its way up towards the root.
8677 (when thread
04b61ae9 8678 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8679 (children
eec82323
LMI
8680 (if (cdr thread)
8681 (apply '+ (mapcar 'gnus-summary-limit-children
8682 (cdr thread)))
8683 0))
8684 (number (mail-header-number (car thread)))
8685 score)
8686 (if (and
8687 (not (memq number gnus-newsgroup-marked))
8688 (or
8689 ;; If this article is dormant and has absolutely no visible
8690 ;; children, then this article isn't visible.
8691 (and (memq number gnus-newsgroup-dormant)
8692 (zerop children))
8693 ;; If this is "fetch-old-headered" and there is no
8694 ;; visible children, then we don't want this article.
16409b0b
GM
8695 (and (or (eq gnus-fetch-old-headers 'some)
8696 (numberp gnus-fetch-old-headers))
eec82323
LMI
8697 (gnus-summary-article-ancient-p number)
8698 (zerop children))
6748645f
LMI
8699 ;; If this is "fetch-old-headered" and `invisible', then
8700 ;; we don't want this article.
8701 (and (eq gnus-fetch-old-headers 'invisible)
8702 (gnus-summary-article-ancient-p number))
eec82323
LMI
8703 ;; If this is a sparsely inserted article with no children,
8704 ;; we don't want it.
8705 (and (eq gnus-build-sparse-threads 'some)
8706 (gnus-summary-article-sparse-p number)
8707 (zerop children))
8708 ;; If we use expunging, and this article is really
8709 ;; low-scored, then we don't want this article.
8710 (when (and gnus-summary-expunge-below
8711 (< (setq score
8712 (or (cdr (assq number gnus-newsgroup-scored))
8713 gnus-summary-default-score))
8714 gnus-summary-expunge-below))
8715 ;; We increase the expunge-tally here, but that has
8716 ;; nothing to do with the limits, really.
8717 (incf gnus-newsgroup-expunged-tally)
8718 ;; We also mark as read here, if that's wanted.
8719 (when (and gnus-summary-mark-below
8720 (< score gnus-summary-mark-below))
8721 (setq gnus-newsgroup-unreads
8722 (delq number gnus-newsgroup-unreads))
8723 (if gnus-newsgroup-auto-expire
8724 (push number gnus-newsgroup-expirable)
8725 (push (cons number gnus-low-score-mark)
8726 gnus-newsgroup-reads)))
8727 t)
23f87bed
MB
8728 ;; Do the `display' group parameter.
8729 (and gnus-newsgroup-display
8730 (not (funcall gnus-newsgroup-display)))
eec82323 8731 ;; Check NoCeM things.
01c52d31
MB
8732 (when (and gnus-use-nocem
8733 (gnus-nocem-unwanted-article-p
8734 (mail-header-id (car thread))))
8735 (setq gnus-newsgroup-unreads
8736 (delq number gnus-newsgroup-unreads))
8737 t)))
eec82323
LMI
8738 ;; Nope, invisible article.
8739 0
8740 ;; Ok, this article is to be visible, so we add it to the limit
8741 ;; and return 1.
8742 (push number gnus-newsgroup-limit)
8743 1))))
8744
8745(defun gnus-expunge-thread (thread)
8746 "Mark all articles in THREAD as read."
8747 (let* ((number (mail-header-number (car thread))))
8748 (incf gnus-newsgroup-expunged-tally)
8749 ;; We also mark as read here, if that's wanted.
8750 (setq gnus-newsgroup-unreads
8751 (delq number gnus-newsgroup-unreads))
8752 (if gnus-newsgroup-auto-expire
8753 (push number gnus-newsgroup-expirable)
8754 (push (cons number gnus-low-score-mark)
8755 gnus-newsgroup-reads)))
8756 ;; Go recursively through all subthreads.
8757 (mapcar 'gnus-expunge-thread (cdr thread)))
8758
8759;; Summary article oriented commands
8760
8761(defun gnus-summary-refer-parent-article (n)
8762 "Refer parent article N times.
8763If N is negative, go to ancestor -N instead.
8764The difference between N and the number of articles fetched is returned."
8765 (interactive "p")
eec82323
LMI
8766 (let ((skip 1)
8767 error header ref)
8768 (when (not (natnump n))
8769 (setq skip (abs n)
8770 n 1))
8771 (while (and (> n 0)
8772 (not error))
8773 (setq header (gnus-summary-article-header))
8774 (if (and (eq (mail-header-number header)
8775 (cdr gnus-article-current))
8776 (equal gnus-newsgroup-name
8777 (car gnus-article-current)))
8778 ;; If we try to find the parent of the currently
8779 ;; displayed article, then we take a look at the actual
8780 ;; References header, since this is slightly more
8781 ;; reliable than the References field we got from the
8782 ;; server.
c7a91ce1 8783 (with-current-buffer gnus-original-article-buffer
eec82323
LMI
8784 (nnheader-narrow-to-headers)
8785 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8786 (when (setq ref (message-fetch-field "in-reply-to"))
8787 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8788 (widen))
8789 (setq ref
8790 ;; It's not the current article, so we take a bet on
8791 ;; the value we got from the server.
8792 (mail-header-references header)))
8793 (if (and ref
8794 (not (equal ref "")))
8795 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8796 (gnus-message 1 "Couldn't find parent"))
8797 (gnus-message 1 "No references in article %d"
8798 (gnus-summary-article-number))
8799 (setq error t))
8800 (decf n))
8801 (gnus-summary-position-point)
8802 n))
8803
8804(defun gnus-summary-refer-references ()
8805 "Fetch all articles mentioned in the References header.
6748645f 8806Return the number of articles fetched."
eec82323 8807 (interactive)
eec82323
LMI
8808 (let ((ref (mail-header-references (gnus-summary-article-header)))
8809 (current (gnus-summary-article-number))
8810 (n 0))
8811 (if (or (not ref)
8812 (equal ref ""))
8813 (error "No References in the current article")
8814 ;; For each Message-ID in the References header...
8815 (while (string-match "<[^>]*>" ref)
8816 (incf n)
8817 ;; ... fetch that article.
8818 (gnus-summary-refer-article
8819 (prog1 (match-string 0 ref)
8820 (setq ref (substring ref (match-end 0))))))
8821 (gnus-summary-goto-subject current)
8822 (gnus-summary-position-point)
8823 n)))
8824
6748645f
LMI
8825(defun gnus-summary-refer-thread (&optional limit)
8826 "Fetch all articles in the current thread.
8827If LIMIT (the numerical prefix), fetch that many old headers instead
8828of what's specified by the `gnus-refer-thread-limit' variable."
8829 (interactive "P")
8830 (let ((id (mail-header-id (gnus-summary-article-header)))
8831 (limit (if limit (prefix-numeric-value limit)
8832 gnus-refer-thread-limit)))
6748645f
LMI
8833 (unless (eq gnus-fetch-old-headers 'invisible)
8834 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8835 ;; Retrieve the headers and read them in.
23f87bed
MB
8836 (if (eq (if (numberp limit)
8837 (gnus-retrieve-headers
8838 (list (min
8839 (+ (mail-header-number
8840 (gnus-summary-article-header))
8841 limit)
8842 gnus-newsgroup-end))
8843 gnus-newsgroup-name (* limit 2))
8844 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8845 ;; headers.
8846 (gnus-retrieve-headers (list gnus-newsgroup-end)
8847 gnus-newsgroup-name limit))
6748645f
LMI
8848 'nov)
8849 (gnus-build-all-threads)
23f87bed 8850 (error "Can't fetch thread from back ends that don't support NOV"))
6748645f
LMI
8851 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8852 (gnus-summary-limit-include-thread id)))
8853
16409b0b
GM
8854(defun gnus-summary-refer-article (message-id)
8855 "Fetch an article specified by MESSAGE-ID."
8856 (interactive "sMessage-ID: ")
eec82323
LMI
8857 (when (and (stringp message-id)
8858 (not (zerop (length message-id))))
23f87bed 8859 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8860 ;; Construct the correct Message-ID if necessary.
8861 ;; Suggested by tale@pawl.rpi.edu.
8862 (unless (string-match "^<" message-id)
8863 (setq message-id (concat "<" message-id)))
8864 (unless (string-match ">$" message-id)
8865 (setq message-id (concat message-id ">")))
23f87bed
MB
8866 ;; People often post MIDs from URLs, so unhex it:
8867 (unless (string-match "@" message-id)
8868 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8869 (let* ((header (gnus-id-to-header message-id))
8870 (sparse (and header
8871 (gnus-summary-article-sparse-p
a8151ef7
LMI
8872 (mail-header-number header))
8873 (memq (mail-header-number header)
16409b0b
GM
8874 gnus-newsgroup-limit)))
8875 number)
6748645f
LMI
8876 (cond
8877 ;; If the article is present in the buffer we just go to it.
8878 ((and header
8879 (or (not (gnus-summary-article-sparse-p
8880 (mail-header-number header)))
8881 sparse))
8882 (prog1
8883 (gnus-summary-goto-article
8884 (mail-header-number header) nil t)
8885 (when sparse
8886 (gnus-summary-update-article (mail-header-number header)))))
8887 (t
16409b0b
GM
8888 ;; We fetch the article.
8889 (catch 'found
8890 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8891 (when (and (gnus-check-server gnus-override-method)
8892 ;; Fetch the header,
8893 (setq number (gnus-summary-insert-subject message-id)))
8894 ;; and display the article.
eec82323 8895 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8896 (throw 'found t)))
8897 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8898
8899(defun gnus-refer-article-methods ()
8f688cb0 8900 "Return a list of referable methods."
16409b0b
GM
8901 (cond
8902 ;; No method, so we default to current and native.
8903 ((null gnus-refer-article-method)
8904 (list gnus-current-select-method gnus-select-method))
8905 ;; Current.
8906 ((eq 'current gnus-refer-article-method)
8907 (list gnus-current-select-method))
8908 ;; List of select methods.
d4dfaa19
DL
8909 ((not (and (symbolp (car gnus-refer-article-method))
8910 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
8911 (let (out)
8912 (dolist (method gnus-refer-article-method)
8913 (push (if (eq 'current method)
8914 gnus-current-select-method
8915 method)
8916 out))
8917 (nreverse out)))
8918 ;; One single select method.
8919 (t
8920 (list gnus-refer-article-method))))
6748645f
LMI
8921
8922(defun gnus-summary-edit-parameters ()
8923 "Edit the group parameters of the current group."
8924 (interactive)
8925 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 8926
16409b0b
GM
8927(defun gnus-summary-customize-parameters ()
8928 "Customize the group parameters of the current group."
8929 (interactive)
8930 (gnus-group-customize gnus-newsgroup-name))
8931
eec82323
LMI
8932(defun gnus-summary-enter-digest-group (&optional force)
8933 "Enter an nndoc group based on the current article.
8934If FORCE, force a digest interpretation. If not, try
8935to guess what the document format is."
8936 (interactive "P")
eec82323 8937 (let ((conf gnus-current-window-configuration))
23f87bed
MB
8938 (save-window-excursion
8939 (save-excursion
8940 (let (gnus-article-prepare-hook
8941 gnus-display-mime-function
8942 gnus-break-pages)
8943 (gnus-summary-select-article))))
eec82323
LMI
8944 (setq gnus-current-window-configuration conf)
8945 (let* ((name (format "%s-%d"
8946 (gnus-group-prefixed-name
8947 gnus-newsgroup-name (list 'nndoc ""))
01c52d31 8948 (with-current-buffer gnus-summary-buffer
eec82323
LMI
8949 gnus-current-article)))
8950 (ogroup gnus-newsgroup-name)
8951 (params (append (gnus-info-params (gnus-get-info ogroup))
8952 (list (cons 'to-group ogroup))
23f87bed 8953 (list (cons 'parent-group ogroup))
eec82323
LMI
8954 (list (cons 'save-article-group ogroup))))
8955 (case-fold-search t)
8956 (buf (current-buffer))
16409b0b 8957 dig to-address)
c7a91ce1 8958 (with-current-buffer gnus-original-article-buffer
16409b0b
GM
8959 ;; Have the digest group inherit the main mail address of
8960 ;; the parent article.
23f87bed
MB
8961 (when (setq to-address (or (gnus-fetch-field "reply-to")
8962 (gnus-fetch-field "from")))
343d6628
MB
8963 (setq params
8964 (append
8965 (list (cons 'to-address
8966 (funcall gnus-decode-encoded-address-function
8967 to-address))))))
eec82323
LMI
8968 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8969 (insert-buffer-substring gnus-original-article-buffer)
8970 ;; Remove lines that may lead nndoc to misinterpret the
8971 ;; document type.
8972 (narrow-to-region
8973 (goto-char (point-min))
8974 (or (search-forward "\n\n" nil t) (point)))
8975 (goto-char (point-min))
16409b0b 8976 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8977 (widen))
8978 (unwind-protect
23f87bed 8979 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
8980 (gnus-newsgroup-ephemeral-ignored-charsets
8981 gnus-newsgroup-ignored-charsets))
8982 (gnus-group-read-ephemeral-group
8983 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8984 (nndoc-article-type
23f87bed
MB
8985 ,(if force 'mbox 'guess)))
8986 t nil nil nil
8987 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8988 "ADAPT")))))
16409b0b 8989 ;; Make all postings to this group go to the parent group.
23f87bed
MB
8990 (nconc (gnus-info-params (gnus-get-info name))
8991 params)
8992 ;; Couldn't select this doc group.
8993 (switch-to-buffer buf)
8994 (gnus-set-global-variables)
8995 (gnus-configure-windows 'summary)
8996 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
8997 (kill-buffer dig)))))
8998
8999(defun gnus-summary-read-document (n)
9000 "Open a new group based on the current article(s).
9001This will allow you to read digests and other similar
9002documents as newsgroups.
9003Obeys the standard process/prefix convention."
9004 (interactive "P")
01c52d31 9005 (let* ((ogroup gnus-newsgroup-name)
eec82323
LMI
9006 (params (append (gnus-info-params (gnus-get-info ogroup))
9007 (list (cons 'to-group ogroup))))
01c52d31
MB
9008 group egroup groups vgroup)
9009 (dolist (article (gnus-summary-work-articles n))
eec82323
LMI
9010 (setq group (format "%s-%d" gnus-newsgroup-name article))
9011 (gnus-summary-remove-process-mark article)
9012 (when (gnus-summary-display-article article)
398a825b 9013 (save-excursion ;;What for?
16409b0b 9014 (with-temp-buffer
eec82323
LMI
9015 (insert-buffer-substring gnus-original-article-buffer)
9016 ;; Remove some headers that may lead nndoc to make
9017 ;; the wrong guess.
9018 (message-narrow-to-head)
9019 (goto-char (point-min))
01c52d31 9020 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
9021 (widen)
9022 (if (setq egroup
9023 (gnus-group-read-ephemeral-group
9024 group `(nndoc ,group (nndoc-address ,(current-buffer))
9025 (nndoc-article-type guess))
9026 t nil t))
9027 (progn
c7a91ce1 9028 ;; Make all postings to this group go to the parent group.
eec82323
LMI
9029 (nconc (gnus-info-params (gnus-get-info egroup))
9030 params)
9031 (push egroup groups))
9032 ;; Couldn't select this doc group.
9033 (gnus-error 3 "Article couldn't be entered"))))))
9034 ;; Now we have selected all the documents.
9035 (cond
9036 ((not groups)
9037 (error "None of the articles could be interpreted as documents"))
9038 ((gnus-group-read-ephemeral-group
9039 (setq vgroup (format
9040 "nnvirtual:%s-%s" gnus-newsgroup-name
9041 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9042 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9043 t
9044 (cons (current-buffer) 'summary)))
9045 (t
9046 (error "Couldn't select virtual nndoc group")))))
9047
9048(defun gnus-summary-isearch-article (&optional regexp-p)
9049 "Do incremental search forward on the current article.
9050If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9051 (interactive "P")
eec82323
LMI
9052 (gnus-summary-select-article)
9053 (gnus-configure-windows 'article)
9054 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
9055 (save-restriction
9056 (widen)
9057 (isearch-forward regexp-p))))
eec82323 9058
01c52d31
MB
9059(defun gnus-summary-repeat-search-article-forward ()
9060 "Repeat the previous search forwards."
9061 (interactive)
9062 (unless gnus-last-search-regexp
9063 (error "No previous search"))
9064 (gnus-summary-search-article-forward gnus-last-search-regexp))
9065
9066(defun gnus-summary-repeat-search-article-backward ()
9067 "Repeat the previous search backwards."
9068 (interactive)
9069 (unless gnus-last-search-regexp
9070 (error "No previous search"))
9071 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9072
eec82323
LMI
9073(defun gnus-summary-search-article-forward (regexp &optional backward)
9074 "Search for an article containing REGEXP forward.
9075If BACKWARD, search backward instead."
9076 (interactive
9077 (list (read-string
9078 (format "Search article %s (regexp%s): "
9079 (if current-prefix-arg "backward" "forward")
9080 (if gnus-last-search-regexp
9081 (concat ", default " gnus-last-search-regexp)
9082 "")))
9083 current-prefix-arg))
eec82323
LMI
9084 (if (string-equal regexp "")
9085 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
9086 (setq gnus-last-search-regexp regexp)
9087 (setq gnus-article-before-search gnus-current-article))
9088 ;; Intentionally set gnus-last-article.
9089 (setq gnus-last-article gnus-article-before-search)
9090 (let ((gnus-last-article gnus-last-article))
9091 (if (gnus-summary-search-article regexp backward)
9092 (gnus-summary-show-thread)
abc40aab 9093 (signal 'search-failed (list regexp)))))
eec82323
LMI
9094
9095(defun gnus-summary-search-article-backward (regexp)
9096 "Search for an article containing REGEXP backward."
9097 (interactive
9098 (list (read-string
9099 (format "Search article backward (regexp%s): "
9100 (if gnus-last-search-regexp
9101 (concat ", default " gnus-last-search-regexp)
9102 "")))))
9103 (gnus-summary-search-article-forward regexp 'backward))
9104
9105(defun gnus-summary-search-article (regexp &optional backward)
9106 "Search for an article containing REGEXP.
9107Optional argument BACKWARD means do search for backward.
9108`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
9109 ;; We have to require this here to make sure that the following
9110 ;; dynamic binding isn't shadowed by autoloading.
9111 (require 'gnus-async)
16409b0b 9112 (require 'gnus-art)
eec82323 9113 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 9114 (gnus-article-prepare-hook nil)
eec82323
LMI
9115 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9116 (gnus-use-article-prefetch nil)
9117 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 9118 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
9119 (gnus-visual nil)
9120 (gnus-keep-backlog nil)
9121 (gnus-break-pages nil)
9122 (gnus-summary-display-arrow nil)
9123 (gnus-updated-mode-lines nil)
9124 (gnus-auto-center-summary nil)
eec82323 9125 (sum (current-buffer))
16409b0b 9126 (gnus-display-mime-function nil)
eec82323
LMI
9127 (found nil)
9128 point)
9129 (gnus-save-hidden-threads
9130 (gnus-summary-select-article)
9131 (set-buffer gnus-article-buffer)
16409b0b 9132 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
9133 (when backward
9134 (forward-line -1))
9135 (while (not found)
9136 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9137 (if (if backward
9138 (re-search-backward regexp nil t)
9139 (re-search-forward regexp nil t))
9140 ;; We found the regexp.
9141 (progn
9142 (setq found 'found)
9143 (beginning-of-line)
9144 (set-window-start
9145 (get-buffer-window (current-buffer))
9146 (point))
9147 (forward-line 1)
16409b0b
GM
9148 (set-window-point
9149 (get-buffer-window (current-buffer))
9150 (point))
eec82323
LMI
9151 (set-buffer sum)
9152 (setq point (point)))
9153 ;; We didn't find it, so we go to the next article.
9154 (set-buffer sum)
9155 (setq found 'not)
9156 (while (eq found 'not)
9157 (if (not (if backward (gnus-summary-find-prev)
9158 (gnus-summary-find-next)))
9159 ;; No more articles.
9160 (setq found t)
9161 ;; Select the next article and adjust point.
9162 (unless (gnus-summary-article-sparse-p
9163 (gnus-summary-article-number))
9164 (setq found nil)
9165 (gnus-summary-select-article)
9166 (set-buffer gnus-article-buffer)
9167 (widen)
9168 (goto-char (if backward (point-max) (point-min))))))))
9169 (gnus-message 7 ""))
9170 ;; Return whether we found the regexp.
9171 (when (eq found 'found)
9172 (goto-char point)
9173 (gnus-summary-show-thread)
9174 (gnus-summary-goto-subject gnus-current-article)
9175 (gnus-summary-position-point)
9176 t)))
9177
23f87bed
MB
9178(defun gnus-find-matching-articles (header regexp)
9179 "Return a list of all articles that match REGEXP on HEADER.
9180This search includes all articles in the current group that Gnus has
9181fetched headers for, whether they are displayed or not."
9182 (let ((articles nil)
c7a91ce1 9183 ;; Can't eta-reduce because it's a macro.
23f87bed
MB
9184 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9185 (case-fold-search t))
9186 (dolist (header gnus-newsgroup-headers)
9187 (when (string-match regexp (funcall func header))
9188 (push (mail-header-number header) articles)))
9189 (nreverse articles)))
9190
eec82323 9191(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 9192 not-case-fold not-matching)
eec82323
LMI
9193 "Return a list of all articles that match REGEXP on HEADER.
9194The search stars on the current article and goes forwards unless
9195BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9196If UNREAD is non-nil, only unread articles will
9197be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 9198in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
9199not match REGEXP on HEADER."
9200 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
9201 articles d func)
9202 (if (consp header)
9203 (if (eq (car header) 'extra)
9204 (setq func
9205 `(lambda (h)
9206 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9207 "")))
9208 (error "%s is an invalid header" header))
9209 (unless (fboundp (intern (concat "mail-header-" header)))
9210 (error "%s is not a valid header" header))
9211 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
9212 (dolist (d (if (eq backward 'all)
9213 gnus-newsgroup-data
9214 (gnus-data-find-list
9215 (gnus-summary-article-number)
9216 (gnus-data-list backward))))
9217 (when (and (or (not unread) ; We want all articles...
9218 (gnus-data-unread-p d)) ; Or just unreads.
9219 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9220 (if not-matching
a1506d29 9221 (not (string-match
47b63dfa
SZ
9222 regexp
9223 (funcall func (gnus-data-header d))))
9224 (string-match regexp
9225 (funcall func (gnus-data-header d)))))
9226 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
9227 (nreverse articles)))
9228
9229(defun gnus-summary-execute-command (header regexp command &optional backward)
9230 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9231If HEADER is an empty string (or nil), the match is done on the entire
9232article. If BACKWARD (the prefix) is non-nil, search backward instead."
9233 (interactive
9234 (list (let ((completion-ignore-case t))
9235 (completing-read
9236 "Header name: "
23f87bed
MB
9237 (mapcar (lambda (header) (list (format "%s" header)))
9238 (append
9239 '("Number" "Subject" "From" "Lines" "Date"
9240 "Message-ID" "Xref" "References" "Body")
9241 gnus-extra-headers))
eec82323
LMI
9242 nil 'require-match))
9243 (read-string "Regexp: ")
9244 (read-key-sequence "Command: ")
9245 current-prefix-arg))
9246 (when (equal header "Body")
9247 (setq header ""))
eec82323
LMI
9248 ;; Hidden thread subtrees must be searched as well.
9249 (gnus-summary-show-all-threads)
9250 ;; We don't want to change current point nor window configuration.
9251 (save-excursion
9252 (save-window-excursion
23f87bed
MB
9253 (let (gnus-visual
9254 gnus-treat-strip-trailing-blank-lines
9255 gnus-treat-strip-leading-blank-lines
9256 gnus-treat-strip-multiple-blank-lines
9257 gnus-treat-hide-boring-headers
9258 gnus-treat-fold-newsgroups
9259 gnus-article-prepare-hook)
9260 (gnus-message 6 "Executing %s..." (key-description command))
9261 ;; We'd like to execute COMMAND interactively so as to give arguments.
9262 (gnus-execute header regexp
9263 `(call-interactively ',(key-binding command))
9264 backward)
9265 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
9266
9267(defun gnus-summary-beginning-of-article ()
9268 "Scroll the article back to the beginning."
9269 (interactive)
eec82323
LMI
9270 (gnus-summary-select-article)
9271 (gnus-configure-windows 'article)
9272 (gnus-eval-in-buffer-window gnus-article-buffer
9273 (widen)
9274 (goto-char (point-min))
23f87bed 9275 (when gnus-break-pages
eec82323
LMI
9276 (gnus-narrow-to-page))))
9277
9278(defun gnus-summary-end-of-article ()
9279 "Scroll to the end of the article."
9280 (interactive)
eec82323
LMI
9281 (gnus-summary-select-article)
9282 (gnus-configure-windows 'article)
9283 (gnus-eval-in-buffer-window gnus-article-buffer
9284 (widen)
9285 (goto-char (point-max))
9286 (recenter -3)
23f87bed 9287 (when gnus-break-pages
eec82323
LMI
9288 (gnus-narrow-to-page))))
9289
23f87bed
MB
9290(defun gnus-summary-print-truncate-and-quote (string &optional len)
9291 "Truncate to LEN and quote all \"(\"'s in STRING."
9292 (gnus-replace-in-string (if (and len (> (length string) len))
9293 (substring string 0 len)
9294 string)
9295 "[()]" "\\\\\\&"))
9296
6748645f 9297(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
9298 "Generate and print a PostScript image of the process-marked (mail) articles.
9299
9300If used interactively, print the current article if none are
9301process-marked. With prefix arg, prompt the user for the name of the
9302file to save in.
6748645f 9303
23f87bed
MB
9304When used from Lisp, accept two optional args FILENAME and N. N means
9305to print the next N articles. If N is negative, print the N previous
9306articles. If N is nil and articles have been marked with the process
9307mark, print these instead.
eec82323 9308
16409b0b 9309If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
9310printer. If FILENAME is a string, save the PostScript image in a file with
9311that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 9312to save in."
676a7cc9 9313 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
9314 (dolist (article (gnus-summary-work-articles n))
9315 (gnus-summary-select-article nil nil 'pseudo article)
9316 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 9317 (gnus-print-buffer))
676a7cc9
SZ
9318 (gnus-summary-remove-process-mark article))
9319 (ps-despool filename))
eec82323 9320
23f87bed
MB
9321(defun gnus-print-buffer ()
9322 (let ((buffer (generate-new-buffer " *print*")))
9323 (unwind-protect
9324 (progn
9325 (copy-to-buffer buffer (point-min) (point-max))
9326 (set-buffer buffer)
9327 (gnus-remove-text-with-property 'gnus-decoration)
9328 (when (gnus-visual-p 'article-highlight 'highlight)
9329 ;; Copy-to-buffer doesn't copy overlay. So redo
9330 ;; highlight.
9331 (let ((gnus-article-buffer buffer))
9332 (gnus-article-highlight-citation t)
9333 (gnus-article-highlight-signature)
9334 (gnus-article-emphasize)
9335 (gnus-article-delete-invisible-text)))
9336 (let ((ps-left-header
9337 (list
9338 (concat "("
9339 (gnus-summary-print-truncate-and-quote
9340 (mail-header-subject gnus-current-headers)
9341 66) ")")
9342 (concat "("
9343 (gnus-summary-print-truncate-and-quote
9344 (mail-header-from gnus-current-headers)
9345 45) ")")))
9346 (ps-right-header
9347 (list
9348 "/pagenumberstring load"
9349 (concat "("
9350 (mail-header-date gnus-current-headers) ")"))))
9351 (gnus-run-hooks 'gnus-ps-print-hook)
9352 (save-excursion
a7b50e1c 9353 (if ps-print-color-p
23f87bed
MB
9354 (ps-spool-buffer-with-faces)
9355 (ps-spool-buffer)))))
9356 (kill-buffer buffer))))
9357
eec82323 9358(defun gnus-summary-show-article (&optional arg)
23f87bed 9359 "Force redisplaying of the current article.
16409b0b
GM
9360If ARG (the prefix) is a number, show the article with the charset
9361defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 9362input.
16409b0b 9363If ARG (the prefix) is non-nil and not a number, show the raw article
23f87bed
MB
9364without any article massaging functions being run. Normally, the key
9365strokes are `C-u g'."
eec82323 9366 (interactive "P")
16409b0b
GM
9367 (cond
9368 ((numberp arg)
23f87bed 9369 (gnus-summary-show-article t)
16409b0b
GM
9370 (let ((gnus-newsgroup-charset
9371 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
9372 (mm-read-coding-system
9373 "View as charset: " ;; actually it is coding system.
01c52d31 9374 (with-current-buffer gnus-article-buffer
23f87bed 9375 (mm-detect-coding-region (point) (point-max))))))
16409b0b 9376 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
9377 (gnus-summary-select-article nil 'force)
9378 (let ((deps gnus-newsgroup-dependencies)
9379 head header lines)
c7a91ce1 9380 (with-current-buffer gnus-original-article-buffer
23f87bed
MB
9381 (save-restriction
9382 (message-narrow-to-head)
9383 (setq head (buffer-string))
9384 (goto-char (point-min))
9385 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9386 (goto-char (point-max))
9387 (widen)
9388 (setq lines (1- (count-lines (point) (point-max))))))
9389 (with-temp-buffer
9390 (insert (format "211 %d Article retrieved.\n"
9391 (cdr gnus-article-current)))
9392 (insert head)
9393 (if lines (insert (format "Lines: %d\n" lines)))
9394 (insert ".\n")
9395 (let ((nntp-server-buffer (current-buffer)))
9396 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9397 (gnus-data-set-header
9398 (gnus-data-find (cdr gnus-article-current))
9399 header)
9400 (gnus-summary-update-article-line
9401 (cdr gnus-article-current) header)
9402 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9403 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
9404 ((not arg)
9405 ;; Select the article the normal way.
9406 (gnus-summary-select-article nil 'force))
9407 (t
9408 ;; We have to require this here to make sure that the following
9409 ;; dynamic binding isn't shadowed by autoloading.
9410 (require 'gnus-async)
9411 (require 'gnus-art)
eec82323
LMI
9412 ;; Bind the article treatment functions to nil.
9413 (let ((gnus-have-all-headers t)
eec82323 9414 gnus-article-prepare-hook
16409b0b
GM
9415 gnus-article-decode-hook
9416 gnus-display-mime-function
9417 gnus-break-pages)
9418 ;; Destroy any MIME parts.
9419 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 9420 (with-current-buffer gnus-article-buffer
16409b0b
GM
9421 (mm-destroy-parts gnus-article-mime-handles)
9422 ;; Set it to nil for safety reason.
9423 (setq gnus-article-mime-handle-alist nil)
9424 (setq gnus-article-mime-handles nil)))
9425 (gnus-summary-select-article nil 'force))))
eec82323
LMI
9426 (gnus-summary-goto-subject gnus-current-article)
9427 (gnus-summary-position-point))
9428
23f87bed
MB
9429(defun gnus-summary-show-raw-article ()
9430 "Show the raw article without any article massaging functions being run."
9431 (interactive)
9432 (gnus-summary-show-article t))
9433
eec82323
LMI
9434(defun gnus-summary-verbose-headers (&optional arg)
9435 "Toggle permanent full header display.
9436If ARG is a positive number, turn header display on.
9437If ARG is a negative number, turn header display off."
9438 (interactive "P")
eec82323
LMI
9439 (setq gnus-show-all-headers
9440 (cond ((or (not (numberp arg))
9441 (zerop arg))
9442 (not gnus-show-all-headers))
9443 ((natnump arg)
9444 t)))
9445 (gnus-summary-show-article))
9446
9447(defun gnus-summary-toggle-header (&optional arg)
9448 "Show the headers if they are hidden, or hide them if they are shown.
9449If ARG is a positive number, show the entire header.
9450If ARG is a negative number, hide the unwanted header lines."
9451 (interactive "P")
23f87bed
MB
9452 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9453 (get-buffer-window gnus-article-buffer t))))
9454 (with-current-buffer gnus-article-buffer
9455 (widen)
9456 (article-narrow-to-head)
c7a91ce1 9457 (let* ((inhibit-read-only t)
16409b0b 9458 (inhibit-point-motion-hooks t)
23f87bed
MB
9459 (hidden (if (numberp arg)
9460 (>= arg 0)
f0096211
MB
9461 (or (not (looking-at "[^ \t\n]+:"))
9462 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
9463 s e)
9464 (delete-region (point-min) (point-max))
667e0ba6
SM
9465 (with-current-buffer gnus-original-article-buffer
9466 (goto-char (setq s (point-min)))
23f87bed
MB
9467 (setq e (if (search-forward "\n\n" nil t)
9468 (1- (point))
9469 (point-max))))
667e0ba6 9470 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
9471 (run-hooks 'gnus-article-decode-hook)
9472 (if hidden
9473 (let ((gnus-treat-hide-headers nil)
9474 (gnus-treat-hide-boring-headers nil))
9475 (gnus-delete-wash-type 'headers)
9476 (gnus-treat-article 'head))
9477 (gnus-treat-article 'head))
9478 (widen)
9479 (if window
9480 (set-window-start window (goto-char (point-min))))
9481 (if gnus-break-pages
9482 (gnus-narrow-to-page)
9483 (when (gnus-visual-p 'page-marker)
c7a91ce1 9484 (let ((inhibit-read-only t))
23f87bed
MB
9485 (gnus-remove-text-with-property 'gnus-prev)
9486 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9487 (gnus-set-mode-line 'article)))))
eec82323
LMI
9488
9489(defun gnus-summary-show-all-headers ()
9490 "Make all header lines visible."
9491 (interactive)
23f87bed 9492 (gnus-summary-toggle-header 1))
eec82323 9493
eec82323
LMI
9494(defun gnus-summary-caesar-message (&optional arg)
9495 "Caesar rotate the current article by 13.
01c52d31
MB
9496With a non-numerical prefix, also rotate headers. A numerical
9497prefix specifies how many places to rotate each letter forward."
eec82323 9498 (interactive "P")
eec82323
LMI
9499 (gnus-summary-select-article)
9500 (let ((mail-header-separator ""))
9501 (gnus-eval-in-buffer-window gnus-article-buffer
9502 (save-restriction
9503 (widen)
9504 (let ((start (window-start))
c7a91ce1 9505 (inhibit-read-only t))
01c52d31
MB
9506 (if (equal arg '(4))
9507 (message-caesar-buffer-body nil t)
9508 (message-caesar-buffer-body arg))
ff4d3926
MB
9509 (set-window-start (get-buffer-window (current-buffer)) start)))))
9510 ;; Create buttons and stuff...
9511 (gnus-treat-article nil))
eec82323 9512
704f1663
GM
9513(declare-function idna-to-unicode "ext:idna" (str))
9514
01c52d31
MB
9515(defun gnus-summary-idna-message (&optional arg)
9516 "Decode IDNA encoded domain names in the current articles.
9517IDNA encoded domain names looks like `xn--bar'. If a string
9518remain unencoded after running this function, it is likely an
9519invalid IDNA string (`xn--bar' is invalid).
9520
9521You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
9522installed for this command to work."
9523 (interactive "P")
9524 (if (not (and (condition-case nil (require 'idna)
9525 (file-error))
9526 (mm-coding-system-p 'utf-8)
9527 (executable-find (symbol-value 'idna-program))))
9528 (gnus-message
9529 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9530 (gnus-summary-select-article)
9531 (let ((mail-header-separator ""))
9532 (gnus-eval-in-buffer-window gnus-article-buffer
9533 (save-restriction
9534 (widen)
9535 (let ((start (window-start))
9536 buffer-read-only)
9537 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9538 (replace-match (idna-to-unicode (match-string 1))))
9539 (set-window-start (get-buffer-window (current-buffer)) start)))))))
23f87bed
MB
9540
9541(defun gnus-summary-morse-message (&optional arg)
9542 "Morse decode the current article."
9543 (interactive "P")
9544 (gnus-summary-select-article)
9545 (let ((mail-header-separator ""))
9546 (gnus-eval-in-buffer-window gnus-article-buffer
9547 (save-excursion
9548 (save-restriction
9549 (widen)
9550 (let ((pos (window-start))
c7a91ce1 9551 (inhibit-read-only t))
23f87bed
MB
9552 (goto-char (point-min))
9553 (when (message-goto-body)
9554 (gnus-narrow-to-body))
9555 (goto-char (point-min))
01c52d31 9556