Merge from gnus--rel--5.10
[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,
c4288669 4;; 2005, 2006 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
11;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
13;; the Free Software Foundation; either version 2, or (at your option)
14;; any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs; see the file COPYING. If not, write to the
3a35cf56
LK
23;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24;; Boston, MA 02110-1301, USA.
eec82323
LMI
25
26;;; Commentary:
27
28;;; Code:
29
23f87bed
MB
30(eval-when-compile
31 (require 'cl)
f67d6742 32 (defvar tool-bar-mode))
5ab7173c 33
eec82323
LMI
34(require 'gnus)
35(require 'gnus-group)
36(require 'gnus-spec)
37(require 'gnus-range)
38(require 'gnus-int)
39(require 'gnus-undo)
6748645f 40(require 'gnus-util)
18c06a99 41(require 'gmm-utils)
16409b0b 42(require 'mm-decode)
08c9a385 43(require 'nnoo)
23f87bed 44
6748645f 45(autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
d4dfaa19 46(autoload 'gnus-cache-write-active "gnus-cache")
23f87bed
MB
47(autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
48(autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
531e5812 49(autoload 'gnus-pick-line-number "gnus-salt" nil t)
08c9a385 50(autoload 'mm-uu-dissect "mm-uu")
23f87bed
MB
51(autoload 'gnus-article-outlook-deuglify-article "deuglify"
52 "Deuglify broken Outlook (Express) articles and redisplay."
53 t)
54(autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
55(autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
56(autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
eec82323
LMI
57
58(defcustom gnus-kill-summary-on-exit t
59 "*If non-nil, kill the summary buffer when you exit from it.
60If nil, the summary will become a \"*Dead Summary*\" buffer, and
61it will be killed sometime later."
62 :group 'gnus-summary-exit
63 :type 'boolean)
64
65(defcustom gnus-fetch-old-headers nil
66 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
67If an unread article in the group refers to an older, already read (or
68just marked as read) article, the old article will not normally be
1232b9cb 69displayed in the Summary buffer. If this variable is t, Gnus
eec82323 70will attempt to grab the headers to the old articles, and thereby
6748645f
LMI
71build complete threads. If it has the value `some', only enough
72headers to connect otherwise loose threads will be displayed. This
73variable can also be a number. In that case, no more than that number
74of old headers will be fetched. If it has the value `invisible', all
75old headers will be fetched, but none will be displayed.
eec82323
LMI
76
77The server has to support NOV for any of this to work."
78 :group 'gnus-thread
79 :type '(choice (const :tag "off" nil)
1232b9cb 80 (const :tag "on" t)
eec82323 81 (const some)
1232b9cb 82 (const invisible)
eec82323
LMI
83 number
84 (sexp :menu-tag "other" t)))
85
6748645f
LMI
86(defcustom gnus-refer-thread-limit 200
87 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
88If t, fetch all the available old headers."
89 :group 'gnus-thread
90 :type '(choice number
91 (sexp :menu-tag "other" t)))
92
eec82323
LMI
93(defcustom gnus-summary-make-false-root 'adopt
94 "*nil means that Gnus won't gather loose threads.
95If the root of a thread has expired or been read in a previous
96session, the information necessary to build a complete thread has been
97lost. Instead of having many small sub-threads from this original thread
98scattered all over the summary buffer, Gnus can gather them.
99
100If non-nil, Gnus will try to gather all loose sub-threads from an
101original thread into one large thread.
102
103If this variable is non-nil, it should be one of `none', `adopt',
104`dummy' or `empty'.
105
106If this variable is `none', Gnus will not make a false root, but just
107present the sub-threads after another.
108If this variable is `dummy', Gnus will create a dummy root that will
109have all the sub-threads as children.
110If this variable is `adopt', Gnus will make one of the \"children\"
111the parent and mark all the step-children as such.
112If this variable is `empty', the \"children\" are printed with empty
113subject fields. (Or rather, they will be printed with a string
114given by the `gnus-summary-same-subject' variable.)"
115 :group 'gnus-thread
116 :type '(choice (const :tag "off" nil)
117 (const none)
118 (const dummy)
119 (const adopt)
120 (const empty)))
121
23f87bed
MB
122(defcustom gnus-summary-make-false-root-always nil
123 "Always make a false dummy root."
bf247b6e 124 :version "22.1"
23f87bed
MB
125 :group 'gnus-thread
126 :type 'boolean)
127
eec82323
LMI
128(defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
129 "*A regexp to match subjects to be excluded from loose thread gathering.
130As loose thread gathering is done on subjects only, that means that
131there can be many false gatherings performed. By rooting out certain
132common subjects, gathering might become saner."
133 :group 'gnus-thread
134 :type 'regexp)
135
136(defcustom gnus-summary-gather-subject-limit nil
137 "*Maximum length of subject comparisons when gathering loose threads.
138Use nil to compare full subjects. Setting this variable to a low
139number will help gather threads that have been corrupted by
140newsreaders chopping off subject lines, but it might also mean that
141unrelated articles that have subject that happen to begin with the
142same few characters will be incorrectly gathered.
143
144If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
145comparing subjects."
146 :group 'gnus-thread
147 :type '(choice (const :tag "off" nil)
148 (const fuzzy)
149 (sexp :menu-tag "on" t)))
150
6748645f
LMI
151(defcustom gnus-simplify-subject-functions nil
152 "List of functions taking a string argument that simplify subjects.
153The functions are applied recursively.
154
23f87bed
MB
155Useful functions to put in this list include:
156`gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
157`gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
6748645f
LMI
158 :group 'gnus-thread
159 :type '(repeat function))
160
eec82323 161(defcustom gnus-simplify-ignored-prefixes nil
23f87bed 162 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
eec82323
LMI
163 :group 'gnus-thread
164 :type '(choice (const :tag "off" nil)
165 regexp))
166
167(defcustom gnus-build-sparse-threads nil
168 "*If non-nil, fill in the gaps in threads.
169If `some', only fill in the gaps that are needed to tie loose threads
170together. If `more', fill in all leaf nodes that Gnus can find. If
171non-nil and non-`some', fill in all gaps that Gnus manages to guess."
172 :group 'gnus-thread
173 :type '(choice (const :tag "off" nil)
174 (const some)
175 (const more)
176 (sexp :menu-tag "all" t)))
177
178(defcustom gnus-summary-thread-gathering-function
179 'gnus-gather-threads-by-subject
6748645f 180 "*Function used for gathering loose threads.
eec82323
LMI
181There are two pre-defined functions: `gnus-gather-threads-by-subject',
182which only takes Subjects into consideration; and
183`gnus-gather-threads-by-references', which compared the References
184headers of the articles to find matches."
185 :group 'gnus-thread
22115a9e
RS
186 :type '(radio (function-item gnus-gather-threads-by-subject)
187 (function-item gnus-gather-threads-by-references)
188 (function :tag "other")))
eec82323 189
eec82323
LMI
190(defcustom gnus-summary-same-subject ""
191 "*String indicating that the current article has the same subject as the previous.
192This variable will only be used if the value of
193`gnus-summary-make-false-root' is `empty'."
194 :group 'gnus-summary-format
195 :type 'string)
196
197(defcustom gnus-summary-goto-unread t
16409b0b
GM
198 "*If t, many commands will go to the next unread article.
199This applies to marking commands as well as other commands that
200\"naturally\" select the next article, like, for instance, `SPC' at
201the end of an article.
202
203If nil, the marking commands do NOT go to the next unread article
2642ac8f 204\(they go to the next article instead). If `never', commands that
16409b0b
GM
205usually go to the next unread article, will go to the next article,
206whether it is read or not."
eec82323
LMI
207 :group 'gnus-summary-marks
208 :link '(custom-manual "(gnus)Setting Marks")
209 :type '(choice (const :tag "off" nil)
210 (const never)
211 (sexp :menu-tag "on" t)))
212
213(defcustom gnus-summary-default-score 0
214 "*Default article score level.
215All scores generated by the score files will be added to this score.
216If this variable is nil, scoring will be disabled."
217 :group 'gnus-score-default
218 :type '(choice (const :tag "disable")
219 integer))
220
23f87bed
MB
221(defcustom gnus-summary-default-high-score 0
222 "*Default threshold for a high scored article.
223An article will be highlighted as high scored if its score is greater
224than this score."
bf247b6e 225 :version "22.1"
23f87bed
MB
226 :group 'gnus-score-default
227 :type 'integer)
228
229(defcustom gnus-summary-default-low-score 0
230 "*Default threshold for a low scored article.
231An article will be highlighted as low scored if its score is smaller
232than this score."
bf247b6e 233 :version "22.1"
23f87bed
MB
234 :group 'gnus-score-default
235 :type 'integer)
236
eec82323
LMI
237(defcustom gnus-summary-zcore-fuzz 0
238 "*Fuzziness factor for the zcore in the summary buffer.
239Articles with scores closer than this to `gnus-summary-default-score'
240will not be marked."
241 :group 'gnus-summary-format
242 :type 'integer)
243
244(defcustom gnus-simplify-subject-fuzzy-regexp nil
245 "*Strings to be removed when doing fuzzy matches.
246This can either be a regular expression or list of regular expressions
247that will be removed from subject strings if fuzzy subject
248simplification is selected."
249 :group 'gnus-thread
250 :type '(repeat regexp))
251
252(defcustom gnus-show-threads t
253 "*If non-nil, display threads in summary mode."
254 :group 'gnus-thread
255 :type 'boolean)
256
257(defcustom gnus-thread-hide-subtree nil
258 "*If non-nil, hide all threads initially.
23f87bed 259This can be a predicate specifier which says which threads to hide.
eec82323 260If threads are hidden, you have to run the command
4a2358e9 261`gnus-summary-show-thread' by hand or select an article."
eec82323 262 :group 'gnus-thread
23f87bed
MB
263 :type '(radio (sexp :format "Non-nil\n"
264 :match (lambda (widget value)
265 (not (or (consp value) (functionp value))))
266 :value t)
267 (const nil)
ad136a7c 268 (sexp :tag "Predicate specifier")))
eec82323
LMI
269
270(defcustom gnus-thread-hide-killed t
271 "*If non-nil, hide killed threads automatically."
272 :group 'gnus-thread
273 :type 'boolean)
274
6748645f
LMI
275(defcustom gnus-thread-ignore-subject t
276 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
277If nil, articles that have different subjects from their parents will
278start separate threads."
eec82323
LMI
279 :group 'gnus-thread
280 :type 'boolean)
281
282(defcustom gnus-thread-operation-ignore-subject t
283 "*If non-nil, subjects will be ignored when doing thread commands.
284This affects commands like `gnus-summary-kill-thread' and
285`gnus-summary-lower-thread'.
286
287If this variable is nil, articles in the same thread with different
288subjects will not be included in the operation in question. If this
289variable is `fuzzy', only articles that have subjects that are fuzzily
290equal will be included."
291 :group 'gnus-thread
292 :type '(choice (const :tag "off" nil)
293 (const fuzzy)
294 (sexp :tag "on" t)))
295
296(defcustom gnus-thread-indent-level 4
297 "*Number that says how much each sub-thread should be indented."
298 :group 'gnus-thread
299 :type 'integer)
300
301(defcustom gnus-auto-extend-newsgroup t
302 "*If non-nil, extend newsgroup forward and backward when requested."
303 :group 'gnus-summary-choose
304 :type 'boolean)
305
306(defcustom gnus-auto-select-first t
23f87bed
MB
307 "*If non-nil, select the article under point.
308Which article this is is controlled by the `gnus-auto-select-subject'
309variable.
310
311If you want to prevent automatic selection of articles in some
312newsgroups, set the variable to nil in `gnus-select-group-hook'."
eec82323
LMI
313 :group 'gnus-group-select
314 :type '(choice (const :tag "none" nil)
23f87bed
MB
315 (sexp :menu-tag "first" t)))
316
317(defcustom gnus-auto-select-subject 'unread
318 "*Says what subject to place under point when entering a group.
319
320This variable can either be the symbols `first' (place point on the
321first subject), `unread' (place point on the subject line of the first
322unread article), `best' (place point on the subject line of the
323higest-scored article), `unseen' (place point on the subject line of
99b5aab7 324the first unseen article), `unseen-or-unread' (place point on the subject
23f87bed
MB
325line of the first unseen article or, if all article have been seen, on the
326subject line of the first unread article), or a function to be called to
327place point on some subject line."
bf247b6e 328 :version "22.1"
23f87bed
MB
329 :group 'gnus-group-select
330 :type '(choice (const best)
331 (const unread)
332 (const first)
333 (const unseen)
334 (const unseen-or-unread)))
eec82323
LMI
335
336(defcustom gnus-auto-select-next t
337 "*If non-nil, offer to go to the next group from the end of the previous.
338If the value is t and the next newsgroup is empty, Gnus will exit
23f87bed
MB
339summary mode and go back to group mode. If the value is neither nil
340nor t, Gnus will select the following unread newsgroup. In
eec82323
LMI
341particular, if the value is the symbol `quietly', the next unread
342newsgroup will be selected without any confirmation, and if it is
343`almost-quietly', the next group will be selected without any
344confirmation if you are located on the last article in the group.
23f87bed 345Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
eec82323
LMI
346will go to the next group without confirmation."
347 :group 'gnus-summary-maneuvering
348 :type '(choice (const :tag "off" nil)
349 (const quietly)
350 (const almost-quietly)
351 (const slightly-quietly)
352 (sexp :menu-tag "on" t)))
353
354(defcustom gnus-auto-select-same nil
6748645f
LMI
355 "*If non-nil, select the next article with the same subject.
356If there are no more articles with the same subject, go to
357the first unread article."
eec82323
LMI
358 :group 'gnus-summary-maneuvering
359 :type 'boolean)
360
23f87bed
MB
361(defcustom gnus-auto-goto-ignores 'unfetched
362 "*Says how to handle unfetched articles when maneuvering.
363
364This variable can either be the symbols nil (maneuver to any
365article), `undownloaded' (maneuvering while unplugged ignores articles
366that have not been fetched), `always-undownloaded' (maneuvering always
367ignores articles that have not been fetched), `unfetched' (maneuvering
368ignores articles whose headers have not been fetched).
369
370NOTE: The list of unfetched articles will always be nil when plugged
371and, when unplugged, a subset of the undownloaded article list."
bf247b6e 372 :version "22.1"
23f87bed
MB
373 :group 'gnus-summary-maneuvering
374 :type '(choice (const :tag "None" nil)
375 (const :tag "Undownloaded when unplugged" undownloaded)
376 (const :tag "Undownloaded" always-undownloaded)
377 (const :tag "Unfetched" unfetched)))
378
eec82323
LMI
379(defcustom gnus-summary-check-current nil
380 "*If non-nil, consider the current article when moving.
381The \"unread\" movement commands will stay on the same line if the
382current article is unread."
383 :group 'gnus-summary-maneuvering
384 :type 'boolean)
385
386(defcustom gnus-auto-center-summary t
387 "*If non-nil, always center the current summary buffer.
388In particular, if `vertical' do only vertical recentering. If non-nil
389and non-`vertical', do both horizontal and vertical recentering."
390 :group 'gnus-summary-maneuvering
391 :type '(choice (const :tag "none" nil)
392 (const vertical)
16409b0b 393 (integer :tag "height")
eec82323
LMI
394 (sexp :menu-tag "both" t)))
395
23f87bed
MB
396(defvar gnus-auto-center-group t
397 "*If non-nil, always center the group buffer.")
398
eec82323
LMI
399(defcustom gnus-show-all-headers nil
400 "*If non-nil, don't hide any headers."
401 :group 'gnus-article-hiding
402 :group 'gnus-article-headers
403 :type 'boolean)
404
405(defcustom gnus-summary-ignore-duplicates nil
406 "*If non-nil, ignore articles with identical Message-ID headers."
407 :group 'gnus-summary
408 :type 'boolean)
6748645f 409
eec82323
LMI
410(defcustom gnus-single-article-buffer t
411 "*If non-nil, display all articles in the same buffer.
412If nil, each group will get its own article buffer."
413 :group 'gnus-article-various
414 :type 'boolean)
415
416(defcustom gnus-break-pages t
417 "*If non-nil, do page breaking on articles.
418The page delimiter is specified by the `gnus-page-delimiter'
419variable."
420 :group 'gnus-article-various
421 :type 'boolean)
422
eec82323
LMI
423(defcustom gnus-move-split-methods nil
424 "*Variable used to suggest where articles are to be moved to.
23f87bed
MB
425It uses the same syntax as the `gnus-split-methods' variable.
426However, whereas `gnus-split-methods' specifies file names as targets,
427this variable specifies group names."
eec82323 428 :group 'gnus-summary-mail
6748645f
LMI
429 :type '(repeat (choice (list :value (fun) function)
430 (cons :value ("" "") regexp (repeat string))
431 (sexp :value nil))))
eec82323 432
e62e7654
MB
433;; FIXME: Although the custom type is `character' for the following variables,
434;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
435
23f87bed 436(defcustom gnus-unread-mark ? ;Whitespace
eec82323
LMI
437 "*Mark used for unread articles."
438 :group 'gnus-summary-marks
439 :type 'character)
440
441(defcustom gnus-ticked-mark ?!
442 "*Mark used for ticked articles."
443 :group 'gnus-summary-marks
444 :type 'character)
445
446(defcustom gnus-dormant-mark ??
447 "*Mark used for dormant articles."
448 :group 'gnus-summary-marks
449 :type 'character)
450
451(defcustom gnus-del-mark ?r
452 "*Mark used for del'd articles."
453 :group 'gnus-summary-marks
454 :type 'character)
455
456(defcustom gnus-read-mark ?R
457 "*Mark used for read articles."
458 :group 'gnus-summary-marks
459 :type 'character)
460
461(defcustom gnus-expirable-mark ?E
462 "*Mark used for expirable articles."
463 :group 'gnus-summary-marks
464 :type 'character)
465
466(defcustom gnus-killed-mark ?K
467 "*Mark used for killed articles."
468 :group 'gnus-summary-marks
469 :type 'character)
470
23f87bed
MB
471(defcustom gnus-spam-mark ?$
472 "*Mark used for spam articles."
bf247b6e 473 :version "22.1"
23f87bed
MB
474 :group 'gnus-summary-marks
475 :type 'character)
476
eec82323 477(defcustom gnus-souped-mark ?F
23f87bed 478 "*Mark used for souped articles."
eec82323
LMI
479 :group 'gnus-summary-marks
480 :type 'character)
481
482(defcustom gnus-kill-file-mark ?X
483 "*Mark used for articles killed by kill files."
484 :group 'gnus-summary-marks
485 :type 'character)
486
487(defcustom gnus-low-score-mark ?Y
488 "*Mark used for articles with a low score."
489 :group 'gnus-summary-marks
490 :type 'character)
491
492(defcustom gnus-catchup-mark ?C
493 "*Mark used for articles that are caught up."
494 :group 'gnus-summary-marks
495 :type 'character)
496
497(defcustom gnus-replied-mark ?A
498 "*Mark used for articles that have been replied to."
499 :group 'gnus-summary-marks
500 :type 'character)
501
23f87bed
MB
502(defcustom gnus-forwarded-mark ?F
503 "*Mark used for articles that have been forwarded."
bf247b6e 504 :version "22.1"
23f87bed
MB
505 :group 'gnus-summary-marks
506 :type 'character)
507
508(defcustom gnus-recent-mark ?N
509 "*Mark used for articles that are recent."
bf247b6e 510 :version "22.1"
23f87bed
MB
511 :group 'gnus-summary-marks
512 :type 'character)
513
eec82323
LMI
514(defcustom gnus-cached-mark ?*
515 "*Mark used for articles that are in the cache."
516 :group 'gnus-summary-marks
517 :type 'character)
518
519(defcustom gnus-saved-mark ?S
23f87bed
MB
520 "*Mark used for articles that have been saved."
521 :group 'gnus-summary-marks
522 :type 'character)
523
524(defcustom gnus-unseen-mark ?.
525 "*Mark used for articles that haven't been seen."
bf247b6e 526 :version "22.1"
23f87bed
MB
527 :group 'gnus-summary-marks
528 :type 'character)
529
530(defcustom gnus-no-mark ? ;Whitespace
531 "*Mark used for articles that have no other secondary mark."
bf247b6e 532 :version "22.1"
eec82323
LMI
533 :group 'gnus-summary-marks
534 :type 'character)
535
536(defcustom gnus-ancient-mark ?O
537 "*Mark used for ancient articles."
538 :group 'gnus-summary-marks
539 :type 'character)
540
541(defcustom gnus-sparse-mark ?Q
542 "*Mark used for sparsely reffed articles."
543 :group 'gnus-summary-marks
544 :type 'character)
545
546(defcustom gnus-canceled-mark ?G
547 "*Mark used for canceled articles."
548 :group 'gnus-summary-marks
549 :type 'character)
550
551(defcustom gnus-duplicate-mark ?M
552 "*Mark used for duplicate articles."
553 :group 'gnus-summary-marks
554 :type 'character)
555
23f87bed 556(defcustom gnus-undownloaded-mark ?-
6748645f 557 "*Mark used for articles that weren't downloaded."
bf247b6e 558 :version "22.1"
6748645f
LMI
559 :group 'gnus-summary-marks
560 :type 'character)
561
23f87bed
MB
562(defcustom gnus-downloaded-mark ?+
563 "*Mark used for articles that were downloaded."
564 :group 'gnus-summary-marks
565 :type 'character)
566
6748645f
LMI
567(defcustom gnus-downloadable-mark ?%
568 "*Mark used for articles that are to be downloaded."
569 :group 'gnus-summary-marks
570 :type 'character)
571
572(defcustom gnus-unsendable-mark ?=
573 "*Mark used for articles that won't be sent."
574 :group 'gnus-summary-marks
575 :type 'character)
576
eec82323
LMI
577(defcustom gnus-score-over-mark ?+
578 "*Score mark used for articles with high scores."
579 :group 'gnus-summary-marks
580 :type 'character)
581
582(defcustom gnus-score-below-mark ?-
583 "*Score mark used for articles with low scores."
584 :group 'gnus-summary-marks
585 :type 'character)
586
23f87bed 587(defcustom gnus-empty-thread-mark ? ;Whitespace
eec82323
LMI
588 "*There is no thread under the article."
589 :group 'gnus-summary-marks
590 :type 'character)
591
592(defcustom gnus-not-empty-thread-mark ?=
593 "*There is a thread under the article."
594 :group 'gnus-summary-marks
595 :type 'character)
596
597(defcustom gnus-view-pseudo-asynchronously nil
598 "*If non-nil, Gnus will view pseudo-articles asynchronously."
599 :group 'gnus-extract-view
600 :type 'boolean)
601
16409b0b
GM
602(defcustom gnus-auto-expirable-marks
603 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
604 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
605 gnus-souped-mark gnus-duplicate-mark)
606 "*The list of marks converted into expiration if a group is auto-expirable."
58e39d05 607 :version "21.1"
16409b0b
GM
608 :group 'gnus-summary
609 :type '(repeat character))
610
611(defcustom gnus-inhibit-user-auto-expire t
612 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
58e39d05 613 :version "21.1"
16409b0b
GM
614 :group 'gnus-summary
615 :type 'boolean)
616
eec82323
LMI
617(defcustom gnus-view-pseudos nil
618 "*If `automatic', pseudo-articles will be viewed automatically.
619If `not-confirm', pseudos will be viewed automatically, and the user
620will not be asked to confirm the command."
621 :group 'gnus-extract-view
622 :type '(choice (const :tag "off" nil)
623 (const automatic)
624 (const not-confirm)))
625
626(defcustom gnus-view-pseudos-separately t
627 "*If non-nil, one pseudo-article will be created for each file to be viewed.
628If nil, all files that use the same viewing command will be given as a
629list of parameters to that command."
630 :group 'gnus-extract-view
631 :type 'boolean)
632
633(defcustom gnus-insert-pseudo-articles t
634 "*If non-nil, insert pseudo-articles when decoding articles."
635 :group 'gnus-extract-view
636 :type 'boolean)
637
638(defcustom gnus-summary-dummy-line-format
23f87bed 639 " %(: :%) %S\n"
eec82323
LMI
640 "*The format specification for the dummy roots in the summary buffer.
641It works along the same lines as a normal formatting string,
642with some simple extensions.
643
23f87bed
MB
644%S The subject
645
646General format specifiers can also be used.
647See `(gnus)Formatting Variables'."
648 :link '(custom-manual "(gnus)Formatting Variables")
eec82323
LMI
649 :group 'gnus-threading
650 :type 'string)
651
16409b0b 652(defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
eec82323
LMI
653 "*The format specification for the summary mode line.
654It works along the same lines as a normal formatting string,
655with some simple extensions:
656
657%G Group name
658%p Unprefixed group name
659%A Current article number
6748645f 660%z Current article score
eec82323
LMI
661%V Gnus version
662%U Number of unread articles in the group
663%e Number of unselected articles in the group
664%Z A string with unread/unselected article counts
665%g Shortish group name
666%S Subject of the current article
667%u User-defined spec
668%s Current score file name
669%d Number of dormant articles
670%r Number of articles that have been marked as read in this session
671%E Number of articles expunged by the score files"
672 :group 'gnus-summary-format
673 :type 'string)
674
16409b0b
GM
675(defcustom gnus-list-identifiers nil
676 "Regexp that matches list identifiers to be removed from subject.
677This can also be a list of regexps."
58e39d05 678 :version "21.1"
16409b0b
GM
679 :group 'gnus-summary-format
680 :group 'gnus-article-hiding
681 :type '(choice (const :tag "none" nil)
682 (regexp :value ".*")
683 (repeat :value (".*") regexp)))
684
eec82323
LMI
685(defcustom gnus-summary-mark-below 0
686 "*Mark all articles with a score below this variable as read.
687This variable is local to each summary buffer and usually set by the
688score file."
689 :group 'gnus-score-default
690 :type 'integer)
691
692(defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
693 "*List of functions used for sorting articles in the summary buffer.
23f87bed
MB
694
695Each function takes two articles and returns non-nil if the first
696article should be sorted before the other. If you use more than one
697function, the primary sort function should be the last. You should
698probably always include `gnus-article-sort-by-number' in the list of
699sorting functions -- preferably first. Also note that sorting by date
700is often much slower than sorting by number, and the sorting order is
701very similar. (Sorting by date means sorting by the time the message
702was sent, sorting by number means sorting by arrival time.)
703
704Ready-made functions include `gnus-article-sort-by-number',
705`gnus-article-sort-by-author', `gnus-article-sort-by-subject',
706`gnus-article-sort-by-date', `gnus-article-sort-by-random'
707and `gnus-article-sort-by-score'.
708
709When threading is turned on, the variable `gnus-thread-sort-functions'
710controls how articles are sorted."
eec82323
LMI
711 :group 'gnus-summary-sort
712 :type '(repeat (choice (function-item gnus-article-sort-by-number)
713 (function-item gnus-article-sort-by-author)
714 (function-item gnus-article-sort-by-subject)
715 (function-item gnus-article-sort-by-date)
716 (function-item gnus-article-sort-by-score)
23f87bed 717 (function-item gnus-article-sort-by-random)
eec82323
LMI
718 (function :tag "other"))))
719
720(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
721 "*List of functions used for sorting threads in the summary buffer.
722By default, threads are sorted by article number.
723
23f87bed
MB
724Each function takes two threads and returns non-nil if the first
725thread should be sorted before the other. If you use more than one
726function, the primary sort function should be the last. You should
727probably always include `gnus-thread-sort-by-number' in the list of
728sorting functions -- preferably first. Also note that sorting by date
729is often much slower than sorting by number, and the sorting order is
730very similar. (Sorting by date means sorting by the time the message
731was sent, sorting by number means sorting by arrival time.)
eec82323
LMI
732
733Ready-made functions include `gnus-thread-sort-by-number',
734`gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
23f87bed
MB
735`gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
736`gnus-thread-sort-by-most-recent-number',
737`gnus-thread-sort-by-most-recent-date',
738`gnus-thread-sort-by-random', and
739`gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
740
741When threading is turned off, the variable
742`gnus-article-sort-functions' controls how articles are sorted."
eec82323
LMI
743 :group 'gnus-summary-sort
744 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
745 (function-item gnus-thread-sort-by-author)
746 (function-item gnus-thread-sort-by-subject)
747 (function-item gnus-thread-sort-by-date)
748 (function-item gnus-thread-sort-by-score)
749 (function-item gnus-thread-sort-by-total-score)
23f87bed 750 (function-item gnus-thread-sort-by-random)
eec82323
LMI
751 (function :tag "other"))))
752
753(defcustom gnus-thread-score-function '+
754 "*Function used for calculating the total score of a thread.
755
756The function is called with the scores of the article and each
757subthread and should then return the score of the thread.
758
759Some functions you can use are `+', `max', or `min'."
760 :group 'gnus-summary-sort
761 :type 'function)
762
763(defcustom gnus-summary-expunge-below nil
6748645f
LMI
764 "All articles that have a score less than this variable will be expunged.
765This variable is local to the summary buffers."
eec82323
LMI
766 :group 'gnus-score-default
767 :type '(choice (const :tag "off" nil)
768 integer))
769
770(defcustom gnus-thread-expunge-below nil
771 "All threads that have a total score less than this variable will be expunged.
772See `gnus-thread-score-function' for en explanation of what a
6748645f
LMI
773\"thread score\" is.
774
775This variable is local to the summary buffers."
16409b0b 776 :group 'gnus-threading
eec82323
LMI
777 :group 'gnus-score-default
778 :type '(choice (const :tag "off" nil)
779 integer))
780
781(defcustom gnus-summary-mode-hook nil
782 "*A hook for Gnus summary mode.
783This hook is run before any variables are set in the summary buffer."
23f87bed 784 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
eec82323
LMI
785 :group 'gnus-summary-various
786 :type 'hook)
787
23f87bed
MB
788;; Extracted from gnus-xmas-redefine in order to preserve user settings
789(when (featurep 'xemacs)
790 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
791 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
792 (add-hook 'gnus-summary-mode-hook
793 'gnus-xmas-switch-horizontal-scrollbar-off))
794
eec82323
LMI
795(defcustom gnus-summary-menu-hook nil
796 "*Hook run after the creation of the summary mode menu."
797 :group 'gnus-summary-visual
798 :type 'hook)
799
800(defcustom gnus-summary-exit-hook nil
801 "*A hook called on exit from the summary buffer.
802It will be called with point in the group buffer."
803 :group 'gnus-summary-exit
804 :type 'hook)
805
806(defcustom gnus-summary-prepare-hook nil
807 "*A hook called after the summary buffer has been generated.
808If you want to modify the summary buffer, you can use this hook."
809 :group 'gnus-summary-various
810 :type 'hook)
811
6748645f
LMI
812(defcustom gnus-summary-prepared-hook nil
813 "*A hook called as the last thing after the summary buffer has been generated."
814 :group 'gnus-summary-various
815 :type 'hook)
816
eec82323
LMI
817(defcustom gnus-summary-generate-hook nil
818 "*A hook run just before generating the summary buffer.
819This hook is commonly used to customize threading variables and the
820like."
821 :group 'gnus-summary-various
822 :type 'hook)
823
824(defcustom gnus-select-group-hook nil
825 "*A hook called when a newsgroup is selected.
826
827If you'd like to simplify subjects like the
828`gnus-summary-next-same-subject' command does, you can use the
829following hook:
830
23f87bed
MB
831 (add-hook gnus-select-group-hook
832 (lambda ()
833 (mapcar (lambda (header)
834 (mail-header-set-subject
835 header
836 (gnus-simplify-subject
837 (mail-header-subject header) 're-only)))
838 gnus-newsgroup-headers)))"
eec82323
LMI
839 :group 'gnus-group-select
840 :type 'hook)
841
842(defcustom gnus-select-article-hook nil
843 "*A hook called when an article is selected."
844 :group 'gnus-summary-choose
23f87bed 845 :options '(gnus-agent-fetch-selected-article)
eec82323
LMI
846 :type 'hook)
847
848(defcustom gnus-visual-mark-article-hook
849 (list 'gnus-highlight-selected-summary)
850 "*Hook run after selecting an article in the summary buffer.
851It is meant to be used for highlighting the article in some way. It
852is not run if `gnus-visual' is nil."
853 :group 'gnus-summary-visual
854 :type 'hook)
855
16409b0b 856(defcustom gnus-parse-headers-hook nil
eec82323
LMI
857 "*A hook called before parsing the headers."
858 :group 'gnus-various
859 :type 'hook)
860
861(defcustom gnus-exit-group-hook nil
16409b0b
GM
862 "*A hook called when exiting summary mode.
863This hook is not called from the non-updating exit commands like `Q'."
eec82323
LMI
864 :group 'gnus-various
865 :type 'hook)
866
867(defcustom gnus-summary-update-hook
868 (list 'gnus-summary-highlight-line)
869 "*A hook called when a summary line is changed.
870The hook will not be called if `gnus-visual' is nil.
871
872The default function `gnus-summary-highlight-line' will
873highlight the line according to the `gnus-summary-highlight'
874variable."
875 :group 'gnus-summary-visual
876 :type 'hook)
877
878(defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
879 "*A hook called when an article is selected for the first time.
880The hook is intended to mark an article as read (or unread)
881automatically when it is selected."
882 :group 'gnus-summary-choose
883 :type 'hook)
884
885(defcustom gnus-group-no-more-groups-hook nil
886 "*A hook run when returning to group mode having no more (unread) groups."
887 :group 'gnus-group-select
888 :type 'hook)
889
890(defcustom gnus-ps-print-hook nil
891 "*A hook run before ps-printing something from Gnus."
892 :group 'gnus-summary
893 :type 'hook)
894
23f87bed
MB
895(defcustom gnus-summary-article-move-hook nil
896 "*A hook called after an article is moved, copied, respooled, or crossposted."
bf247b6e 897 :version "22.1"
23f87bed
MB
898 :group 'gnus-summary
899 :type 'hook)
900
901(defcustom gnus-summary-article-delete-hook nil
902 "*A hook called after an article is deleted."
bf247b6e 903 :version "22.1"
23f87bed
MB
904 :group 'gnus-summary
905 :type 'hook)
906
907(defcustom gnus-summary-article-expire-hook nil
908 "*A hook called after an article is expired."
bf247b6e 909 :version "22.1"
23f87bed
MB
910 :group 'gnus-summary
911 :type 'hook)
912
913(defcustom gnus-summary-display-arrow
914 (and (fboundp 'display-graphic-p)
915 (display-graphic-p))
916 "*If non-nil, display an arrow highlighting the current article."
bf247b6e 917 :version "22.1"
23f87bed
MB
918 :group 'gnus-summary
919 :type 'boolean)
920
0f49874b 921(defcustom gnus-summary-selected-face 'gnus-summary-selected
eec82323
LMI
922 "Face used for highlighting the current article in the summary buffer."
923 :group 'gnus-summary-visual
924 :type 'face)
925
23f87bed
MB
926(defvar gnus-tmp-downloaded nil)
927
eec82323 928(defcustom gnus-summary-highlight
23f87bed 929 '(((eq mark gnus-canceled-mark)
0f49874b 930 . gnus-summary-cancelled)
23f87bed 931 ((and uncached (> score default-high))
0f49874b 932 . gnus-summary-high-undownloaded)
23f87bed 933 ((and uncached (< score default-low))
0f49874b 934 . gnus-summary-low-undownloaded)
23f87bed 935 (uncached
0f49874b 936 . gnus-summary-normal-undownloaded)
23f87bed
MB
937 ((and (> score default-high)
938 (or (eq mark gnus-dormant-mark)
939 (eq mark gnus-ticked-mark)))
0f49874b 940 . gnus-summary-high-ticked)
23f87bed
MB
941 ((and (< score default-low)
942 (or (eq mark gnus-dormant-mark)
943 (eq mark gnus-ticked-mark)))
0f49874b 944 . gnus-summary-low-ticked)
23f87bed
MB
945 ((or (eq mark gnus-dormant-mark)
946 (eq mark gnus-ticked-mark))
0f49874b 947 . gnus-summary-normal-ticked)
23f87bed 948 ((and (> score default-high) (eq mark gnus-ancient-mark))
0f49874b 949 . gnus-summary-high-ancient)
23f87bed 950 ((and (< score default-low) (eq mark gnus-ancient-mark))
0f49874b 951 . gnus-summary-low-ancient)
23f87bed 952 ((eq mark gnus-ancient-mark)
0f49874b 953 . gnus-summary-normal-ancient)
23f87bed 954 ((and (> score default-high) (eq mark gnus-unread-mark))
0f49874b 955 . gnus-summary-high-unread)
23f87bed 956 ((and (< score default-low) (eq mark gnus-unread-mark))
0f49874b 957 . gnus-summary-low-unread)
23f87bed 958 ((eq mark gnus-unread-mark)
0f49874b 959 . gnus-summary-normal-unread)
23f87bed 960 ((> score default-high)
0f49874b 961 . gnus-summary-high-read)
23f87bed 962 ((< score default-low)
0f49874b 963 . gnus-summary-low-read)
eec82323 964 (t
0f49874b 965 . gnus-summary-normal-read))
6748645f 966 "*Controls the highlighting of summary buffer lines.
eec82323 967
23f87bed
MB
968A list of (FORM . FACE) pairs. When deciding how a a particular
969summary line should be displayed, each form is evaluated. The content
970of the face field after the first true form is used. You can change
971how those summary lines are displayed, by editing the face field.
eec82323
LMI
972
973You can use the following variables in the FORM field.
974
23f87bed
MB
975score: The article's score
976default: The default article score.
977default-high: The default score for high scored articles.
978default-low: The default score for low scored articles.
979below: The score below which articles are automatically marked as read.
980mark: The article's mark.
981uncached: Non-nil if the article is uncached."
eec82323
LMI
982 :group 'gnus-summary-visual
983 :type '(repeat (cons (sexp :tag "Form" nil)
984 face)))
985
6748645f
LMI
986(defcustom gnus-alter-header-function nil
987 "Function called to allow alteration of article header structures.
988The function is called with one parameter, the article header vector,
0ab0f2d3
SZ
989which it may alter in any way."
990 :type '(choice (const :tag "None" nil)
991 function)
992 :group 'gnus-summary)
eec82323 993
16409b0b 994(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
343d6628
MB
995 "Function used to decode a string with encoded words.")
996
997(defvar gnus-decode-encoded-address-function
998 'mail-decode-encoded-address-string
999 "Function used to decode addresses with encoded words.")
16409b0b 1000
23f87bed 1001(defcustom gnus-extra-headers '(To Newsgroups)
16409b0b 1002 "*Extra headers to parse."
58e39d05 1003 :version "21.1"
16409b0b
GM
1004 :group 'gnus-summary
1005 :type '(repeat symbol))
1006
1007(defcustom gnus-ignored-from-addresses
343d6628 1008 (and user-mail-address
7cd9f860
CY
1009 (not (string= user-mail-address ""))
1010 (regexp-quote user-mail-address))
16409b0b 1011 "*Regexp of From headers that may be suppressed in favor of To headers."
58e39d05 1012 :version "21.1"
16409b0b
GM
1013 :group 'gnus-summary
1014 :type 'regexp)
1015
16409b0b
GM
1016(defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1017 "List of charsets that should be ignored.
1018When these charsets are used in the \"charset\" parameter, the
1019default charset will be used instead."
58e39d05 1020 :version "21.1"
16409b0b
GM
1021 :type '(repeat symbol)
1022 :group 'gnus-charset)
1023
23f87bed
MB
1024(gnus-define-group-parameter
1025 ignored-charsets
1026 :type list
1027 :function-document
1028 "Return the ignored charsets of GROUP."
1029 :variable gnus-group-ignored-charsets-alist
1030 :variable-default
1031 '(("alt\\.chinese\\.text" iso-8859-1))
1032 :variable-document
1033 "Alist of regexps (to match group names) and charsets that should be ignored.
16409b0b
GM
1034When these charsets are used in the \"charset\" parameter, the
1035default charset will be used instead."
23f87bed
MB
1036 :variable-group gnus-charset
1037 :variable-type '(repeat (cons (regexp :tag "Group")
1038 (repeat symbol)))
1039 :parameter-type '(choice :tag "Ignored charsets"
1040 :value nil
1041 (repeat (symbol)))
1042 :parameter-document "\
1043List of charsets that should be ignored.
1044
1045When these charsets are used in the \"charset\" parameter, the
1046default charset will be used instead.")
16409b0b
GM
1047
1048(defcustom gnus-group-highlight-words-alist nil
1049 "Alist of group regexps and highlight regexps.
1050This variable uses the same syntax as `gnus-emphasis-alist'."
58e39d05 1051 :version "21.1"
16409b0b
GM
1052 :type '(repeat (cons (regexp :tag "Group")
1053 (repeat (list (regexp :tag "Highlight regexp")
1054 (number :tag "Group for entire word" 0)
1055 (number :tag "Group for displayed part" 0)
1056 (symbol :tag "Face"
1057 gnus-emphasis-highlight-words)))))
1058 :group 'gnus-summary-visual)
1059
1060(defcustom gnus-summary-show-article-charset-alist
1061 nil
1062 "Alist of number and charset.
1063The article will be shown with the charset corresponding to the
1064numbered argument.
1065For example: ((1 . cn-gb-2312) (2 . big5))."
58e39d05 1066 :version "21.1"
16409b0b
GM
1067 :type '(repeat (cons (number :tag "Argument" 1)
1068 (symbol :tag "Charset")))
1069 :group 'gnus-charset)
1070
1071(defcustom gnus-preserve-marks t
1072 "Whether marks are preserved when moving, copying and respooling messages."
58e39d05 1073 :version "21.1"
16409b0b
GM
1074 :type 'boolean
1075 :group 'gnus-summary-marks)
1076
1077(defcustom gnus-alter-articles-to-read-function nil
1078 "Function to be called to alter the list of articles to be selected."
8fc7a9a1 1079 :type '(choice (const nil) function)
16409b0b
GM
1080 :group 'gnus-summary)
1081
1082(defcustom gnus-orphan-score nil
1083 "*All orphans get this score added. Set in the score file."
1084 :group 'gnus-score-default
1085 :type '(choice (const nil)
1086 integer))
1087
8b93df01 1088(defcustom gnus-summary-save-parts-default-mime "image/.*"
23f87bed
MB
1089 "*A regexp to match MIME parts when saving multiple parts of a
1090message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1091This regexp will be used by default when prompting the user for which
1092type of files to save."
8b93df01
DL
1093 :group 'gnus-summary
1094 :type 'regexp)
1095
23f87bed
MB
1096(defcustom gnus-read-all-available-headers nil
1097 "Whether Gnus should parse all headers made available to it.
1098This is mostly relevant for slow back ends where the user may
1099wish to widen the summary buffer to include all headers
1100that were fetched. Say, for nnultimate groups."
bf247b6e 1101 :version "22.1"
23f87bed
MB
1102 :group 'gnus-summary
1103 :type '(choice boolean regexp))
1104
1105(defcustom gnus-summary-muttprint-program "muttprint"
1106 "Command (and optional arguments) used to run Muttprint."
bf247b6e 1107 :version "22.1"
23f87bed
MB
1108 :group 'gnus-summary
1109 :type 'string)
1110
1111(defcustom gnus-article-loose-mime nil
1112 "If non-nil, don't require MIME-Version header.
1113Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
a08b59c9 1114supply the MIME-Version header or deliberately strip it from the mail.
23f87bed
MB
1115Set it to non-nil, Gnus will treat some articles as MIME even if
1116the MIME-Version header is missed."
bf247b6e 1117 :version "22.1"
23f87bed
MB
1118 :type 'boolean
1119 :group 'gnus-article-mime)
1120
1121(defcustom gnus-article-emulate-mime t
1122 "If non-nil, use MIME emulation for uuencode and the like.
1123This means that Gnus will search message bodies for text that look
1124like uuencoded bits, yEncoded bits, and so on, and present that using
1125the normal Gnus MIME machinery."
bf247b6e 1126 :version "22.1"
23f87bed
MB
1127 :type 'boolean
1128 :group 'gnus-article-mime)
8b93df01 1129
eec82323
LMI
1130;;; Internal variables
1131
23f87bed 1132(defvar gnus-summary-display-cache nil)
16409b0b
GM
1133(defvar gnus-article-mime-handles nil)
1134(defvar gnus-article-decoded-p nil)
23f87bed
MB
1135(defvar gnus-article-charset nil)
1136(defvar gnus-article-ignored-charsets nil)
eec82323
LMI
1137(defvar gnus-scores-exclude-files nil)
1138(defvar gnus-page-broken nil)
1139
1140(defvar gnus-original-article nil)
1141(defvar gnus-article-internal-prepare-hook nil)
1142(defvar gnus-newsgroup-process-stack nil)
1143
1144(defvar gnus-thread-indent-array nil)
1145(defvar gnus-thread-indent-array-level gnus-thread-indent-level)
16409b0b
GM
1146(defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1147 "Function called to sort the articles within a thread after it has been gathered together.")
eec82323 1148
8b93df01 1149(defvar gnus-summary-save-parts-type-history nil)
23f87bed 1150(defvar gnus-summary-save-parts-last-directory mm-default-directory)
8b93df01 1151
eec82323
LMI
1152;; Avoid highlighting in kill files.
1153(defvar gnus-summary-inhibit-highlight nil)
1154(defvar gnus-newsgroup-selected-overlay nil)
1155(defvar gnus-inhibit-limiting nil)
1156(defvar gnus-newsgroup-adaptive-score-file nil)
1157(defvar gnus-current-score-file nil)
1158(defvar gnus-current-move-group nil)
1159(defvar gnus-current-copy-group nil)
1160(defvar gnus-current-crosspost-group nil)
23f87bed 1161(defvar gnus-newsgroup-display nil)
eec82323
LMI
1162
1163(defvar gnus-newsgroup-dependencies nil)
1164(defvar gnus-newsgroup-adaptive nil)
1165(defvar gnus-summary-display-article-function nil)
1166(defvar gnus-summary-highlight-line-function nil
1167 "Function called after highlighting a summary line.")
1168
1169(defvar gnus-summary-line-format-alist
1170 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1171 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1172 (?s gnus-tmp-subject-or-nil ?s)
1173 (?n gnus-tmp-name ?s)
1174 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1175 ?s)
1176 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1177 gnus-tmp-from) ?s)
1178 (?F gnus-tmp-from ?s)
1179 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1180 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1181 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
6748645f 1182 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
eec82323
LMI
1183 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1184 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1185 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
23f87bed
MB
1186 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1187 (?L gnus-tmp-lines ?s)
1188 (?O gnus-tmp-downloaded ?c)
eec82323
LMI
1189 (?I gnus-tmp-indentation ?s)
1190 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1191 (?R gnus-tmp-replied ?c)
1192 (?\[ gnus-tmp-opening-bracket ?c)
1193 (?\] gnus-tmp-closing-bracket ?c)
1194 (?\> (make-string gnus-tmp-level ? ) ?s)
1195 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1196 (?i gnus-tmp-score ?d)
1197 (?z gnus-tmp-score-char ?c)
1198 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1199 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1200 (?U gnus-tmp-unread ?c)
23f87bed
MB
1201 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1202 ?s)
eec82323
LMI
1203 (?t (gnus-summary-number-of-articles-in-thread
1204 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1205 ?d)
1206 (?e (gnus-summary-number-of-articles-in-thread
1207 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1208 ?c)
1209 (?u gnus-tmp-user-defined ?s)
23f87bed
MB
1210 (?P (gnus-pick-line-number) ?d)
1211 (?B gnus-tmp-thread-tree-header-string ?s)
1212 (user-date (gnus-user-date
1213 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
16409b0b
GM
1214 "An alist of format specifications that can appear in summary lines.
1215These are paired with what variables they correspond with, along with
1216the type of the variable (string, integer, character, etc).")
eec82323
LMI
1217
1218(defvar gnus-summary-dummy-line-format-alist
1219 `((?S gnus-tmp-subject ?s)
1220 (?N gnus-tmp-number ?d)
1221 (?u gnus-tmp-user-defined ?s)))
1222
1223(defvar gnus-summary-mode-line-format-alist
1224 `((?G gnus-tmp-group-name ?s)
1225 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1226 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1227 (?A gnus-tmp-article-number ?d)
1228 (?Z gnus-tmp-unread-and-unselected ?s)
1229 (?V gnus-version ?s)
1230 (?U gnus-tmp-unread-and-unticked ?d)
1231 (?S gnus-tmp-subject ?s)
1232 (?e gnus-tmp-unselected ?d)
1233 (?u gnus-tmp-user-defined ?s)
1234 (?d (length gnus-newsgroup-dormant) ?d)
1235 (?t (length gnus-newsgroup-marked) ?d)
23f87bed 1236 (?h (length gnus-newsgroup-spam-marked) ?d)
eec82323 1237 (?r (length gnus-newsgroup-reads) ?d)
6748645f 1238 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
eec82323
LMI
1239 (?E gnus-newsgroup-expunged-tally ?d)
1240 (?s (gnus-current-score-file-nondirectory) ?s)))
1241
1242(defvar gnus-last-search-regexp nil
1243 "Default regexp for article search command.")
1244
1245(defvar gnus-last-shell-command nil
1246 "Default shell command on article.")
1247
23f87bed
MB
1248(defvar gnus-newsgroup-agentized nil
1249 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
eec82323
LMI
1250(defvar gnus-newsgroup-begin nil)
1251(defvar gnus-newsgroup-end nil)
1252(defvar gnus-newsgroup-last-rmail nil)
1253(defvar gnus-newsgroup-last-mail nil)
1254(defvar gnus-newsgroup-last-folder nil)
1255(defvar gnus-newsgroup-last-file nil)
26c9afc3 1256(defvar gnus-newsgroup-last-directory nil)
eec82323
LMI
1257(defvar gnus-newsgroup-auto-expire nil)
1258(defvar gnus-newsgroup-active nil)
1259
1260(defvar gnus-newsgroup-data nil)
1261(defvar gnus-newsgroup-data-reverse nil)
1262(defvar gnus-newsgroup-limit nil)
1263(defvar gnus-newsgroup-limits nil)
23f87bed 1264(defvar gnus-summary-use-undownloaded-faces nil)
eec82323
LMI
1265
1266(defvar gnus-newsgroup-unreads nil
23f87bed 1267 "Sorted list of unread articles in the current newsgroup.")
eec82323
LMI
1268
1269(defvar gnus-newsgroup-unselected nil
23f87bed 1270 "Sorted list of unselected unread articles in the current newsgroup.")
eec82323
LMI
1271
1272(defvar gnus-newsgroup-reads nil
1273 "Alist of read articles and article marks in the current newsgroup.")
1274
1275(defvar gnus-newsgroup-expunged-tally nil)
1276
1277(defvar gnus-newsgroup-marked nil
23f87bed
MB
1278 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1279
1280(defvar gnus-newsgroup-spam-marked nil
1281 "List of ranges of articles that have been marked as spam.")
eec82323
LMI
1282
1283(defvar gnus-newsgroup-killed nil
1284 "List of ranges of articles that have been through the scoring process.")
1285
1286(defvar gnus-newsgroup-cached nil
23f87bed 1287 "Sorted list of articles that come from the article cache.")
eec82323
LMI
1288
1289(defvar gnus-newsgroup-saved nil
1290 "List of articles that have been saved.")
1291
1292(defvar gnus-newsgroup-kill-headers nil)
1293
1294(defvar gnus-newsgroup-replied nil
1295 "List of articles that have been replied to in the current newsgroup.")
1296
23f87bed
MB
1297(defvar gnus-newsgroup-forwarded nil
1298 "List of articles that have been forwarded in the current newsgroup.")
1299
1300(defvar gnus-newsgroup-recent nil
1301 "List of articles that have are recent in the current newsgroup.")
1302
eec82323 1303(defvar gnus-newsgroup-expirable nil
23f87bed 1304 "Sorted list of articles in the current newsgroup that can be expired.")
eec82323
LMI
1305
1306(defvar gnus-newsgroup-processable nil
1307 "List of articles in the current newsgroup that can be processed.")
1308
6748645f 1309(defvar gnus-newsgroup-downloadable nil
23f87bed
MB
1310 "Sorted list of articles in the current newsgroup that can be processed.")
1311
1312(defvar gnus-newsgroup-unfetched nil
1313 "Sorted list of articles in the current newsgroup whose headers have
1314not been fetched into the agent.
1315
1316This list will always be a subset of gnus-newsgroup-undownloaded.")
6748645f
LMI
1317
1318(defvar gnus-newsgroup-undownloaded nil
23f87bed 1319 "List of articles in the current newsgroup that haven't been downloaded.")
6748645f
LMI
1320
1321(defvar gnus-newsgroup-unsendable nil
1322 "List of articles in the current newsgroup that won't be sent.")
1323
eec82323
LMI
1324(defvar gnus-newsgroup-bookmarks nil
1325 "List of articles in the current newsgroup that have bookmarks.")
1326
1327(defvar gnus-newsgroup-dormant nil
23f87bed
MB
1328 "Sorted list of dormant articles in the current newsgroup.")
1329
1330(defvar gnus-newsgroup-unseen nil
1331 "List of unseen articles in the current newsgroup.")
1332
1333(defvar gnus-newsgroup-seen nil
1334 "Range of seen articles in the current newsgroup.")
1335
1336(defvar gnus-newsgroup-articles nil
1337 "List of articles in the current newsgroup.")
eec82323
LMI
1338
1339(defvar gnus-newsgroup-scored nil
1340 "List of scored articles in the current newsgroup.")
1341
1342(defvar gnus-newsgroup-headers nil
1343 "List of article headers in the current newsgroup.")
1344
1345(defvar gnus-newsgroup-threads nil)
1346
1347(defvar gnus-newsgroup-prepared nil
1348 "Whether the current group has been prepared properly.")
1349
1350(defvar gnus-newsgroup-ancient nil
1351 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1352
1353(defvar gnus-newsgroup-sparse nil)
1354
1355(defvar gnus-current-article nil)
1356(defvar gnus-article-current nil)
1357(defvar gnus-current-headers nil)
1358(defvar gnus-have-all-headers nil)
1359(defvar gnus-last-article nil)
1360(defvar gnus-newsgroup-history nil)
16409b0b
GM
1361(defvar gnus-newsgroup-charset nil)
1362(defvar gnus-newsgroup-ephemeral-charset nil)
1363(defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
eec82323 1364
23f87bed
MB
1365(defvar gnus-article-before-search nil)
1366
1367(defvar gnus-summary-local-variables
eec82323
LMI
1368 '(gnus-newsgroup-name
1369 gnus-newsgroup-begin gnus-newsgroup-end
1370 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1371 gnus-newsgroup-last-folder gnus-newsgroup-last-file
26c9afc3 1372 gnus-newsgroup-last-directory
eec82323
LMI
1373 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1374 gnus-newsgroup-unselected gnus-newsgroup-marked
23f87bed 1375 gnus-newsgroup-spam-marked
eec82323 1376 gnus-newsgroup-reads gnus-newsgroup-saved
23f87bed
MB
1377 gnus-newsgroup-replied gnus-newsgroup-forwarded
1378 gnus-newsgroup-recent
1379 gnus-newsgroup-expirable
eec82323 1380 gnus-newsgroup-processable gnus-newsgroup-killed
6748645f 1381 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
23f87bed
MB
1382 gnus-newsgroup-unfetched
1383 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1384 gnus-newsgroup-seen gnus-newsgroup-articles
eec82323
LMI
1385 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1386 gnus-newsgroup-headers gnus-newsgroup-threads
1387 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1388 gnus-current-article gnus-current-headers gnus-have-all-headers
1389 gnus-last-article gnus-article-internal-prepare-hook
1390 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1391 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1392 gnus-thread-expunge-below
16409b0b
GM
1393 gnus-score-alist gnus-current-score-file
1394 (gnus-summary-expunge-below . global)
eec82323 1395 (gnus-summary-mark-below . global)
16409b0b 1396 (gnus-orphan-score . global)
eec82323
LMI
1397 gnus-newsgroup-active gnus-scores-exclude-files
1398 gnus-newsgroup-history gnus-newsgroup-ancient
1399 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1400 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1401 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1402 (gnus-newsgroup-expunged-tally . 0)
1403 gnus-cache-removable-articles gnus-newsgroup-cached
1404 gnus-newsgroup-data gnus-newsgroup-data-reverse
16409b0b 1405 gnus-newsgroup-limit gnus-newsgroup-limits
23f87bed
MB
1406 gnus-newsgroup-charset gnus-newsgroup-display
1407 gnus-summary-use-undownloaded-faces)
eec82323
LMI
1408 "Variables that are buffer-local to the summary buffers.")
1409
23f87bed
MB
1410(defvar gnus-newsgroup-variables nil
1411 "A list of variables that have separate values in different newsgroups.
1412A list of newsgroup (summary buffer) local variables, or cons of
1413variables and their default expressions to be evalled (when the default
1414values are not nil), that should be made global while the summary buffer
1415is active.
1416
1417Note: The default expressions will be evaluated (using function `eval')
1418before assignment to the local variable rather than just assigned to it.
1419If the default expression is the symbol `global', that symbol will not
1420be evaluated but the global value of the local variable will be used
1421instead.
1422
1423These variables can be used to set variables in the group parameters
1424while still allowing them to affect operations done in other buffers.
1425For example:
1426
1427\(setq gnus-newsgroup-variables
1428 '(message-use-followup-to
1429 (gnus-visible-headers .
1430 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1431")
1432
eec82323 1433;; Byte-compiler warning.
23f87bed
MB
1434(eval-when-compile
1435 ;; Bind features so that require will believe that gnus-sum has
1436 ;; already been loaded (avoids infinite recursion)
1437 (let ((features (cons 'gnus-sum features)))
1438 ;; Several of the declarations in gnus-sum are needed to load the
1439 ;; following files. Right now, these definitions have been
1440 ;; compiled but not defined (evaluated). We could either do a
1441 ;; eval-and-compile about all of the declarations or evaluate the
1442 ;; source file.
1443 (if (boundp 'gnus-newsgroup-variables)
1444 nil
1445 (load "gnus-sum.el" t t t))
1446 (require 'gnus)
1447 (require 'gnus-agent)
1448 (require 'gnus-art)))
eec82323 1449
16409b0b
GM
1450;; MIME stuff.
1451
1452(defvar gnus-decode-encoded-word-methods
1453 '(mail-decode-encoded-word-string)
1454 "List of methods used to decode encoded words.
1455
23f87bed
MB
1456This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1457is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1458\(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
16409b0b
GM
1459whose names match REGEXP.
1460
1461For example:
23f87bed 1462\((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
16409b0b
GM
1463 mail-decode-encoded-word-string
1464 (\"chinese\" . rfc1843-decode-string))")
1465
1466(defvar gnus-decode-encoded-word-methods-cache nil)
1467
1468(defun gnus-multi-decode-encoded-word-string (string)
1469 "Apply the functions from `gnus-encoded-word-methods' that match."
1470 (unless (and gnus-decode-encoded-word-methods-cache
1471 (eq gnus-newsgroup-name
1472 (car gnus-decode-encoded-word-methods-cache)))
1473 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1474 (mapcar (lambda (x)
1475 (if (symbolp x)
1476 (nconc gnus-decode-encoded-word-methods-cache (list x))
1477 (if (and gnus-newsgroup-name
1478 (string-match (car x) gnus-newsgroup-name))
1479 (nconc gnus-decode-encoded-word-methods-cache
1480 (list (cdr x))))))
23f87bed 1481 gnus-decode-encoded-word-methods))
16409b0b
GM
1482 (let ((xlist gnus-decode-encoded-word-methods-cache))
1483 (pop xlist)
1484 (while xlist
1485 (setq string (funcall (pop xlist) string))))
1486 string)
1487
eec82323
LMI
1488;; Subject simplification.
1489
6748645f 1490(defun gnus-simplify-whitespace (str)
16409b0b 1491 "Remove excessive whitespace from STR."
23f87bed
MB
1492 ;; Multiple spaces.
1493 (while (string-match "[ \t][ \t]+" str)
1494 (setq str (concat (substring str 0 (match-beginning 0))
1495 " "
1496 (substring str (match-end 0)))))
1497 ;; Leading spaces.
1498 (when (string-match "^[ \t]+" str)
1499 (setq str (substring str (match-end 0))))
1500 ;; Trailing spaces.
1501 (when (string-match "[ \t]+$" str)
1502 (setq str (substring str 0 (match-beginning 0))))
1503 str)
1504
1505(defun gnus-simplify-all-whitespace (str)
1506 "Remove all whitespace from STR."
1507 (while (string-match "[ \t\n]+" str)
1508 (setq str (replace-match "" nil nil str)))
1509 str)
6748645f 1510
eec82323
LMI
1511(defsubst gnus-simplify-subject-re (subject)
1512 "Remove \"Re:\" from subject lines."
23f87bed 1513 (if (string-match message-subject-re-regexp subject)
eec82323
LMI
1514 (substring subject (match-end 0))
1515 subject))
1516
1517(defun gnus-simplify-subject (subject &optional re-only)
1518 "Remove `Re:' and words in parentheses.
1519If RE-ONLY is non-nil, strip leading `Re:'s only."
1520 (let ((case-fold-search t)) ;Ignore case.
1521 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1522 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1523 (setq subject (substring subject (match-end 0))))
1524 ;; Remove uninteresting prefixes.
1525 (when (and (not re-only)
1526 gnus-simplify-ignored-prefixes
1527 (string-match gnus-simplify-ignored-prefixes subject))
1528 (setq subject (substring subject (match-end 0))))
1529 ;; Remove words in parentheses from end.
1530 (unless re-only
1531 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1532 (setq subject (substring subject 0 (match-beginning 0)))))
1533 ;; Return subject string.
1534 subject))
1535
1536;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1537;; all whitespace.
1538(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1539 (goto-char (point-min))
1540 (while (re-search-forward regexp nil t)
16409b0b 1541 (replace-match (or newtext ""))))
eec82323
LMI
1542
1543(defun gnus-simplify-buffer-fuzzy ()
1544 "Simplify string in the buffer fuzzily.
1545The string in the accessible portion of the current buffer is simplified.
1546It is assumed to be a single-line subject.
1547Whitespace is generally cleaned up, and miscellaneous leading/trailing
1548matter is removed. Additional things can be deleted by setting
16409b0b 1549`gnus-simplify-subject-fuzzy-regexp'."
eec82323
LMI
1550 (let ((case-fold-search t)
1551 (modified-tick))
1552 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1553
1554 (while (not (eq modified-tick (buffer-modified-tick)))
1555 (setq modified-tick (buffer-modified-tick))
1556 (cond
1557 ((listp gnus-simplify-subject-fuzzy-regexp)
1558 (mapcar 'gnus-simplify-buffer-fuzzy-step
1559 gnus-simplify-subject-fuzzy-regexp))
1560 (gnus-simplify-subject-fuzzy-regexp
1561 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1562 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1563 (gnus-simplify-buffer-fuzzy-step
1564 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1565 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1566
1567 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1568 (gnus-simplify-buffer-fuzzy-step " +" " ")
1569 (gnus-simplify-buffer-fuzzy-step " $")
1570 (gnus-simplify-buffer-fuzzy-step "^ +")))
1571
1572(defun gnus-simplify-subject-fuzzy (subject)
1573 "Simplify a subject string fuzzily.
6748645f 1574See `gnus-simplify-buffer-fuzzy' for details."
eec82323
LMI
1575 (save-excursion
1576 (gnus-set-work-buffer)
1577 (let ((case-fold-search t))
6748645f
LMI
1578 ;; Remove uninteresting prefixes.
1579 (when (and gnus-simplify-ignored-prefixes
1580 (string-match gnus-simplify-ignored-prefixes subject))
1581 (setq subject (substring subject (match-end 0))))
eec82323
LMI
1582 (insert subject)
1583 (inline (gnus-simplify-buffer-fuzzy))
1584 (buffer-string))))
1585
1586(defsubst gnus-simplify-subject-fully (subject)
23f87bed 1587 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
eec82323 1588 (cond
6748645f
LMI
1589 (gnus-simplify-subject-functions
1590 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1591 ((null gnus-summary-gather-subject-limit)
1592 (gnus-simplify-subject-re subject))
1593 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1594 (gnus-simplify-subject-fuzzy subject))
1595 ((numberp gnus-summary-gather-subject-limit)
1596 (gnus-limit-string (gnus-simplify-subject-re subject)
1597 gnus-summary-gather-subject-limit))
1598 (t
1599 subject)))
1600
1601(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f 1602 "Check whether two subjects are equal.
23f87bed 1603If optional argument SIMPLE-FIRST is t, first argument is already
6748645f 1604simplified."
eec82323
LMI
1605 (cond
1606 ((null simple-first)
1607 (equal (gnus-simplify-subject-fully s1)
1608 (gnus-simplify-subject-fully s2)))
1609 (t
1610 (equal s1
1611 (gnus-simplify-subject-fully s2)))))
1612
1613(defun gnus-summary-bubble-group ()
1614 "Increase the score of the current group.
1615This is a handy function to add to `gnus-summary-exit-hook' to
1616increase the score of each group you read."
1617 (gnus-group-add-score gnus-newsgroup-name))
1618
1619\f
1620;;;
1621;;; Gnus summary mode
1622;;;
1623
1624(put 'gnus-summary-mode 'mode-class 'special)
1625
1653df0f
SZ
1626(defvar gnus-article-commands-menu)
1627
23f87bed
MB
1628;; Non-orthogonal keys
1629
1630(gnus-define-keys gnus-summary-mode-map
1631 " " gnus-summary-next-page
1632 "\177" gnus-summary-prev-page
1633 [delete] gnus-summary-prev-page
1634 [backspace] gnus-summary-prev-page
1635 "\r" gnus-summary-scroll-up
1636 "\M-\r" gnus-summary-scroll-down
1637 "n" gnus-summary-next-unread-article
1638 "p" gnus-summary-prev-unread-article
1639 "N" gnus-summary-next-article
1640 "P" gnus-summary-prev-article
1641 "\M-\C-n" gnus-summary-next-same-subject
1642 "\M-\C-p" gnus-summary-prev-same-subject
1643 "\M-n" gnus-summary-next-unread-subject
1644 "\M-p" gnus-summary-prev-unread-subject
1645 "." gnus-summary-first-unread-article
1646 "," gnus-summary-best-unread-article
1647 "\M-s" gnus-summary-search-article-forward
1648 "\M-r" gnus-summary-search-article-backward
1649 "<" gnus-summary-beginning-of-article
1650 ">" gnus-summary-end-of-article
1651 "j" gnus-summary-goto-article
1652 "^" gnus-summary-refer-parent-article
1653 "\M-^" gnus-summary-refer-article
1654 "u" gnus-summary-tick-article-forward
1655 "!" gnus-summary-tick-article-forward
1656 "U" gnus-summary-tick-article-backward
1657 "d" gnus-summary-mark-as-read-forward
1658 "D" gnus-summary-mark-as-read-backward
1659 "E" gnus-summary-mark-as-expirable
1660 "\M-u" gnus-summary-clear-mark-forward
1661 "\M-U" gnus-summary-clear-mark-backward
1662 "k" gnus-summary-kill-same-subject-and-select
1663 "\C-k" gnus-summary-kill-same-subject
1664 "\M-\C-k" gnus-summary-kill-thread
1665 "\M-\C-l" gnus-summary-lower-thread
1666 "e" gnus-summary-edit-article
1667 "#" gnus-summary-mark-as-processable
1668 "\M-#" gnus-summary-unmark-as-processable
1669 "\M-\C-t" gnus-summary-toggle-threads
1670 "\M-\C-s" gnus-summary-show-thread
1671 "\M-\C-h" gnus-summary-hide-thread
1672 "\M-\C-f" gnus-summary-next-thread
1673 "\M-\C-b" gnus-summary-prev-thread
1674 [(meta down)] gnus-summary-next-thread
1675 [(meta up)] gnus-summary-prev-thread
1676 "\M-\C-u" gnus-summary-up-thread
1677 "\M-\C-d" gnus-summary-down-thread
1678 "&" gnus-summary-execute-command
1679 "c" gnus-summary-catchup-and-exit
1680 "\C-w" gnus-summary-mark-region-as-read
1681 "\C-t" gnus-summary-toggle-truncation
1682 "?" gnus-summary-mark-as-dormant
1683 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1684 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1685 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1686 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1687 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1688 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1689 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1690 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1691 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1692 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1693 "=" gnus-summary-expand-window
1694 "\C-x\C-s" gnus-summary-reselect-current-group
1695 "\M-g" gnus-summary-rescan-group
1696 "w" gnus-summary-stop-page-breaking
1697 "\C-c\C-r" gnus-summary-caesar-message
1698 "f" gnus-summary-followup
1699 "F" gnus-summary-followup-with-original
1700 "C" gnus-summary-cancel-article
1701 "r" gnus-summary-reply
1702 "R" gnus-summary-reply-with-original
1703 "\C-c\C-f" gnus-summary-mail-forward
1704 "o" gnus-summary-save-article
1705 "\C-o" gnus-summary-save-article-mail
1706 "|" gnus-summary-pipe-output
1707 "\M-k" gnus-summary-edit-local-kill
1708 "\M-K" gnus-summary-edit-global-kill
1709 ;; "V" gnus-version
1710 "\C-c\C-d" gnus-summary-describe-group
1711 "q" gnus-summary-exit
1712 "Q" gnus-summary-exit-no-update
1713 "\C-c\C-i" gnus-info-find-node
1714 gnus-mouse-2 gnus-mouse-pick-article
132cf96d 1715 [follow-link] mouse-face
23f87bed
MB
1716 "m" gnus-summary-mail-other-window
1717 "a" gnus-summary-post-news
1718 "i" gnus-summary-news-other-window
1719 "x" gnus-summary-limit-to-unread
1720 "s" gnus-summary-isearch-article
1721 "t" gnus-summary-toggle-header
1722 "g" gnus-summary-show-article
1723 "l" gnus-summary-goto-last-article
1724 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1725 "\C-d" gnus-summary-enter-digest-group
1726 "\M-\C-d" gnus-summary-read-document
1727 "\M-\C-e" gnus-summary-edit-parameters
1728 "\M-\C-a" gnus-summary-customize-parameters
1729 "\C-c\C-b" gnus-bug
1730 "*" gnus-cache-enter-article
1731 "\M-*" gnus-cache-remove-article
1732 "\M-&" gnus-summary-universal-argument
1733 "\C-l" gnus-recenter
1734 "I" gnus-summary-increase-score
1735 "L" gnus-summary-lower-score
1736 "\M-i" gnus-symbolic-argument
1737 "h" gnus-summary-select-article-buffer
1738
1739 "b" gnus-article-view-part
1740 "\M-t" gnus-summary-toggle-display-buttonized
1741
1742 "V" gnus-summary-score-map
1743 "X" gnus-uu-extract-map
1744 "S" gnus-summary-send-map)
1745
1746;; Sort of orthogonal keymap
1747(gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1748 "t" gnus-summary-tick-article-forward
1749 "!" gnus-summary-tick-article-forward
1750 "d" gnus-summary-mark-as-read-forward
1751 "r" gnus-summary-mark-as-read-forward
1752 "c" gnus-summary-clear-mark-forward
1753 " " gnus-summary-clear-mark-forward
1754 "e" gnus-summary-mark-as-expirable
1755 "x" gnus-summary-mark-as-expirable
1756 "?" gnus-summary-mark-as-dormant
1757 "b" gnus-summary-set-bookmark
1758 "B" gnus-summary-remove-bookmark
1759 "#" gnus-summary-mark-as-processable
1760 "\M-#" gnus-summary-unmark-as-processable
1761 "S" gnus-summary-limit-include-expunged
1762 "C" gnus-summary-catchup
1763 "H" gnus-summary-catchup-to-here
1764 "h" gnus-summary-catchup-from-here
1765 "\C-c" gnus-summary-catchup-all
1766 "k" gnus-summary-kill-same-subject-and-select
1767 "K" gnus-summary-kill-same-subject
1768 "P" gnus-uu-mark-map)
1769
1770(gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1771 "c" gnus-summary-clear-above
1772 "u" gnus-summary-tick-above
1773 "m" gnus-summary-mark-above
1774 "k" gnus-summary-kill-below)
1775
1776(gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1777 "/" gnus-summary-limit-to-subject
1778 "n" gnus-summary-limit-to-articles
1779 "w" gnus-summary-pop-limit
1780 "s" gnus-summary-limit-to-subject
1781 "a" gnus-summary-limit-to-author
1782 "u" gnus-summary-limit-to-unread
1783 "m" gnus-summary-limit-to-marks
1784 "M" gnus-summary-limit-exclude-marks
1785 "v" gnus-summary-limit-to-score
1786 "*" gnus-summary-limit-include-cached
1787 "D" gnus-summary-limit-include-dormant
1788 "T" gnus-summary-limit-include-thread
1789 "d" gnus-summary-limit-exclude-dormant
1790 "t" gnus-summary-limit-to-age
1791 "." gnus-summary-limit-to-unseen
1792 "x" gnus-summary-limit-to-extra
1793 "p" gnus-summary-limit-to-display-predicate
1794 "E" gnus-summary-limit-include-expunged
1795 "c" gnus-summary-limit-exclude-childless-dormant
1796 "C" gnus-summary-limit-mark-excluded-as-read
1797 "o" gnus-summary-insert-old-articles
1798 "N" gnus-summary-insert-new-articles)
1799
1800(gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1801 "n" gnus-summary-next-unread-article
1802 "p" gnus-summary-prev-unread-article
1803 "N" gnus-summary-next-article
1804 "P" gnus-summary-prev-article
1805 "\C-n" gnus-summary-next-same-subject
1806 "\C-p" gnus-summary-prev-same-subject
1807 "\M-n" gnus-summary-next-unread-subject
1808 "\M-p" gnus-summary-prev-unread-subject
1809 "f" gnus-summary-first-unread-article
1810 "b" gnus-summary-best-unread-article
1811 "j" gnus-summary-goto-article
1812 "g" gnus-summary-goto-subject
1813 "l" gnus-summary-goto-last-article
1814 "o" gnus-summary-pop-article)
1815
1816(gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1817 "k" gnus-summary-kill-thread
1818 "l" gnus-summary-lower-thread
1819 "i" gnus-summary-raise-thread
1820 "T" gnus-summary-toggle-threads
1821 "t" gnus-summary-rethread-current
1822 "^" gnus-summary-reparent-thread
1823 "s" gnus-summary-show-thread
1824 "S" gnus-summary-show-all-threads
1825 "h" gnus-summary-hide-thread
1826 "H" gnus-summary-hide-all-threads
1827 "n" gnus-summary-next-thread
1828 "p" gnus-summary-prev-thread
1829 "u" gnus-summary-up-thread
1830 "o" gnus-summary-top-thread
1831 "d" gnus-summary-down-thread
1832 "#" gnus-uu-mark-thread
1833 "\M-#" gnus-uu-unmark-thread)
1834
1835(gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1836 "g" gnus-summary-prepare
1837 "c" gnus-summary-insert-cached-articles
1838 "d" gnus-summary-insert-dormant-articles)
1839
1840(gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1841 "c" gnus-summary-catchup-and-exit
1842 "C" gnus-summary-catchup-all-and-exit
1843 "E" gnus-summary-exit-no-update
1844 "Q" gnus-summary-exit
1845 "Z" gnus-summary-exit
1846 "n" gnus-summary-catchup-and-goto-next-group
1847 "R" gnus-summary-reselect-current-group
1848 "G" gnus-summary-rescan-group
1849 "N" gnus-summary-next-group
1850 "s" gnus-summary-save-newsrc
1851 "P" gnus-summary-prev-group)
1852
1853(gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1854 " " gnus-summary-next-page
1855 "n" gnus-summary-next-page
1856 "\177" gnus-summary-prev-page
1857 [delete] gnus-summary-prev-page
1858 "p" gnus-summary-prev-page
1859 "\r" gnus-summary-scroll-up
1860 "\M-\r" gnus-summary-scroll-down
1861 "<" gnus-summary-beginning-of-article
1862 ">" gnus-summary-end-of-article
1863 "b" gnus-summary-beginning-of-article
1864 "e" gnus-summary-end-of-article
1865 "^" gnus-summary-refer-parent-article
1866 "r" gnus-summary-refer-parent-article
1867 "D" gnus-summary-enter-digest-group
1868 "R" gnus-summary-refer-references
1869 "T" gnus-summary-refer-thread
1870 "g" gnus-summary-show-article
1871 "s" gnus-summary-isearch-article
1872 "P" gnus-summary-print-article
1873 "M" gnus-mailing-list-insinuate
1874 "t" gnus-article-babel)
1875
1876(gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1877 "b" gnus-article-add-buttons
1878 "B" gnus-article-add-buttons-to-head
1879 "o" gnus-article-treat-overstrike
1880 "e" gnus-article-emphasize
1881 "w" gnus-article-fill-cited-article
1882 "Q" gnus-article-fill-long-lines
1883 "C" gnus-article-capitalize-sentences
1884 "c" gnus-article-remove-cr
1885 "q" gnus-article-de-quoted-unreadable
1886 "6" gnus-article-de-base64-unreadable
1887 "Z" gnus-article-decode-HZ
1888 "h" gnus-article-wash-html
1889 "u" gnus-article-unsplit-urls
1890 "s" gnus-summary-force-verify-and-decrypt
1891 "f" gnus-article-display-x-face
1892 "l" gnus-summary-stop-page-breaking
1893 "r" gnus-summary-caesar-message
1894 "m" gnus-summary-morse-message
1895 "t" gnus-summary-toggle-header
1896 "g" gnus-treat-smiley
1897 "v" gnus-summary-verbose-headers
1898 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1899 "p" gnus-article-verify-x-pgp-sig
1900 "d" gnus-article-treat-dumbquotes)
1901
1902(gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1903 ;; mnemonic: deuglif*Y*
1904 "u" gnus-article-outlook-unwrap-lines
1905 "a" gnus-article-outlook-repair-attribution
1906 "c" gnus-article-outlook-rearrange-citation
1907 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1908
1909(gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1910 "a" gnus-article-hide
1911 "h" gnus-article-hide-headers
1912 "b" gnus-article-hide-boring-headers
1913 "s" gnus-article-hide-signature
1914 "c" gnus-article-hide-citation
1915 "C" gnus-article-hide-citation-in-followups
1916 "l" gnus-article-hide-list-identifiers
1917 "B" gnus-article-strip-banner
1918 "P" gnus-article-hide-pem
1919 "\C-c" gnus-article-hide-citation-maybe)
1920
1921(gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1922 "a" gnus-article-highlight
1923 "h" gnus-article-highlight-headers
1924 "c" gnus-article-highlight-citation
1925 "s" gnus-article-highlight-signature)
1926
1927(gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1928 "f" gnus-article-treat-fold-headers
1929 "u" gnus-article-treat-unfold-headers
1930 "n" gnus-article-treat-fold-newsgroups)
1931
1932(gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1933 "x" gnus-article-display-x-face
1934 "d" gnus-article-display-face
1935 "s" gnus-treat-smiley
1936 "D" gnus-article-remove-images
1937 "f" gnus-treat-from-picon
1938 "m" gnus-treat-mail-picon
1939 "n" gnus-treat-newsgroups-picon)
1940
1941(gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1942 "w" gnus-article-decode-mime-words
1943 "c" gnus-article-decode-charset
1944 "v" gnus-mime-view-all-parts
1945 "b" gnus-article-view-part)
1946
1947(gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1948 "z" gnus-article-date-ut
1949 "u" gnus-article-date-ut
1950 "l" gnus-article-date-local
1951 "p" gnus-article-date-english
1952 "e" gnus-article-date-lapsed
1953 "o" gnus-article-date-original
1954 "i" gnus-article-date-iso8601
1955 "s" gnus-article-date-user)
1956
1957(gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1958 "t" gnus-article-remove-trailing-blank-lines
1959 "l" gnus-article-strip-leading-blank-lines
1960 "m" gnus-article-strip-multiple-blank-lines
1961 "a" gnus-article-strip-blank-lines
1962 "A" gnus-article-strip-all-blank-lines
1963 "s" gnus-article-strip-leading-space
1964 "e" gnus-article-strip-trailing-space
1965 "w" gnus-article-remove-leading-whitespace)
1966
1967(gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1968 "v" gnus-version
1969 "f" gnus-summary-fetch-faq
1970 "d" gnus-summary-describe-group
1971 "h" gnus-summary-describe-briefly
1972 "i" gnus-info-find-node
1973 "c" gnus-group-fetch-charter
1974 "C" gnus-group-fetch-control)
1975
1976(gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1977 "e" gnus-summary-expire-articles
1978 "\M-\C-e" gnus-summary-expire-articles-now
1979 "\177" gnus-summary-delete-article
1980 [delete] gnus-summary-delete-article
1981 [backspace] gnus-summary-delete-article
1982 "m" gnus-summary-move-article
1983 "r" gnus-summary-respool-article
1984 "w" gnus-summary-edit-article
1985 "c" gnus-summary-copy-article
1986 "B" gnus-summary-crosspost-article
1987 "q" gnus-summary-respool-query
1988 "t" gnus-summary-respool-trace
1989 "i" gnus-summary-import-article
1990 "I" gnus-summary-create-article
1991 "p" gnus-summary-article-posted-p)
1992
1993(gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1994 "o" gnus-summary-save-article
1995 "m" gnus-summary-save-article-mail
1996 "F" gnus-summary-write-article-file
1997 "r" gnus-summary-save-article-rmail
1998 "f" gnus-summary-save-article-file
1999 "b" gnus-summary-save-article-body-file
26c9afc3 2000 "B" gnus-summary-write-article-body-file
23f87bed
MB
2001 "h" gnus-summary-save-article-folder
2002 "v" gnus-summary-save-article-vm
2003 "p" gnus-summary-pipe-output
2004 "P" gnus-summary-muttprint
2005 "s" gnus-soup-add-article)
2006
2007(gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2008 "b" gnus-summary-display-buttonized
2009 "m" gnus-summary-repair-multipart
2010 "v" gnus-article-view-part
2011 "o" gnus-article-save-part
2012 "c" gnus-article-copy-part
2013 "C" gnus-article-view-part-as-charset
2014 "e" gnus-article-view-part-externally
2015 "E" gnus-article-encrypt-body
2016 "i" gnus-article-inline-part
2017 "|" gnus-article-pipe-part)
2018
2019(gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2020 "p" gnus-summary-mark-as-processable
2021 "u" gnus-summary-unmark-as-processable
2022 "U" gnus-summary-unmark-all-processable
2023 "v" gnus-uu-mark-over
2024 "s" gnus-uu-mark-series
2025 "r" gnus-uu-mark-region
2026 "g" gnus-uu-unmark-region
2027 "R" gnus-uu-mark-by-regexp
2028 "G" gnus-uu-unmark-by-regexp
2029 "t" gnus-uu-mark-thread
2030 "T" gnus-uu-unmark-thread
2031 "a" gnus-uu-mark-all
2032 "b" gnus-uu-mark-buffer
2033 "S" gnus-uu-mark-sparse
2034 "k" gnus-summary-kill-process-mark
2035 "y" gnus-summary-yank-process-mark
2036 "w" gnus-summary-save-process-mark
2037 "i" gnus-uu-invert-processable)
2038
2039(gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2040 ;;"x" gnus-uu-extract-any
2041 "m" gnus-summary-save-parts
2042 "u" gnus-uu-decode-uu
2043 "U" gnus-uu-decode-uu-and-save
2044 "s" gnus-uu-decode-unshar
2045 "S" gnus-uu-decode-unshar-and-save
2046 "o" gnus-uu-decode-save
2047 "O" gnus-uu-decode-save
2048 "b" gnus-uu-decode-binhex
2049 "B" gnus-uu-decode-binhex
2050 "p" gnus-uu-decode-postscript
2051 "P" gnus-uu-decode-postscript-and-save)
2052
2053(gnus-define-keys
2054 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2055 "u" gnus-uu-decode-uu-view
2056 "U" gnus-uu-decode-uu-and-save-view
2057 "s" gnus-uu-decode-unshar-view
2058 "S" gnus-uu-decode-unshar-and-save-view
2059 "o" gnus-uu-decode-save-view
2060 "O" gnus-uu-decode-save-view
2061 "b" gnus-uu-decode-binhex-view
2062 "B" gnus-uu-decode-binhex-view
2063 "p" gnus-uu-decode-postscript-view
2064 "P" gnus-uu-decode-postscript-and-save-view)
2065
2066(defvar gnus-article-post-menu nil)
2067
2068(defconst gnus-summary-menu-maxlen 20)
2069
2070(defun gnus-summary-menu-split (menu)
2071 ;; If we have lots of elements, divide them into groups of 20
2072 ;; and make a pane (or submenu) for each one.
2073 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2074 (let ((menu menu) sublists next
2075 (i 1))
2076 (while menu
2077 ;; Pull off the next gnus-summary-menu-maxlen elements
2078 ;; and make them the next element of sublist.
2079 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2080 (if next
2081 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2082 nil))
2083 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2084 (aref (car (last menu)) 0)) menu)
2085 sublists))
2086 (setq i (1+ i))
2087 (setq menu next))
2088 (nreverse sublists))
2089 ;; Few elements--put them all in one pane.
2090 menu))
eec82323
LMI
2091
2092(defun gnus-summary-make-menu-bar ()
2093 (gnus-turn-off-edit-menu 'summary)
2094
2095 (unless (boundp 'gnus-summary-misc-menu)
2096
2097 (easy-menu-define
23f87bed
MB
2098 gnus-summary-kill-menu gnus-summary-mode-map ""
2099 (cons
2100 "Score"
2101 (nconc
2102 (list
2103 ["Customize" gnus-score-customize t])
2104 (gnus-make-score-map 'increase)
2105 (gnus-make-score-map 'lower)
2106 '(("Mark"
2107 ["Kill below" gnus-summary-kill-below t]
2108 ["Mark above" gnus-summary-mark-above t]
2109 ["Tick above" gnus-summary-tick-above t]
2110 ["Clear above" gnus-summary-clear-above t])
2111 ["Current score" gnus-summary-current-score t]
2112 ["Set score" gnus-summary-set-score t]
2113 ["Switch current score file..." gnus-score-change-score-file t]
2114 ["Set mark below..." gnus-score-set-mark-below t]
2115 ["Set expunge below..." gnus-score-set-expunge-below t]
2116 ["Edit current score file" gnus-score-edit-current-scores t]
2117 ["Edit score file" gnus-score-edit-file t]
2118 ["Trace score" gnus-score-find-trace t]
2119 ["Find words" gnus-score-find-favourite-words t]
2120 ["Rescore buffer" gnus-summary-rescore t]
2121 ["Increase score..." gnus-summary-increase-score t]
2122 ["Lower score..." gnus-summary-lower-score t]))))
2123
2124 ;; Define both the Article menu in the summary buffer and the
2125 ;; equivalent Commands menu in the article buffer here for
2126 ;; consistency.
6748645f 2127 (let ((innards
23f87bed
MB
2128 `(("Hide"
2129 ["All" gnus-article-hide t]
2130 ["Headers" gnus-article-hide-headers t]
2131 ["Signature" gnus-article-hide-signature t]
2132 ["Citation" gnus-article-hide-citation t]
16409b0b 2133 ["List identifiers" gnus-article-hide-list-identifiers t]
16409b0b 2134 ["Banner" gnus-article-strip-banner t]
23f87bed
MB
2135 ["Boring headers" gnus-article-hide-boring-headers t])
2136 ("Highlight"
2137 ["All" gnus-article-highlight t]
2138 ["Headers" gnus-article-highlight-headers t]
2139 ["Signature" gnus-article-highlight-signature t]
2140 ["Citation" gnus-article-highlight-citation t])
16409b0b
GM
2141 ("MIME"
2142 ["Words" gnus-article-decode-mime-words t]
2143 ["Charset" gnus-article-decode-charset t]
2144 ["QP" gnus-article-de-quoted-unreadable t]
2145 ["Base64" gnus-article-de-base64-unreadable t]
23f87bed
MB
2146 ["View MIME buttons" gnus-summary-display-buttonized t]
2147 ["View all" gnus-mime-view-all-parts t]
2148 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2149 ["Encrypt body" gnus-article-encrypt-body
2150 :active (not (gnus-group-read-only-p))
2151 ,@(if (featurep 'xemacs) nil
2152 '(:help "Encrypt the message body on disk"))]
2153 ["Extract all parts..." gnus-summary-save-parts t]
2154 ("Multipart"
2155 ["Repair multipart" gnus-summary-repair-multipart t]
2156 ["Pipe part..." gnus-article-pipe-part t]
2157 ["Inline part" gnus-article-inline-part t]
2158 ["Encrypt body" gnus-article-encrypt-body
2159 :active (not (gnus-group-read-only-p))
2160 ,@(if (featurep 'xemacs) nil
2161 '(:help "Encrypt the message body on disk"))]
2162 ["View part externally" gnus-article-view-part-externally t]
2163 ["View part with charset..." gnus-article-view-part-as-charset t]
2164 ["Copy part" gnus-article-copy-part t]
2165 ["Save part..." gnus-article-save-part t]
2166 ["View part" gnus-article-view-part t]))
2167 ("Date"
2168 ["Local" gnus-article-date-local t]
2169 ["ISO8601" gnus-article-date-iso8601 t]
2170 ["UT" gnus-article-date-ut t]
2171 ["Original" gnus-article-date-original t]
2172 ["Lapsed" gnus-article-date-lapsed t]
2173 ["User-defined" gnus-article-date-user t])
2174 ("Display"
2175 ["Remove images" gnus-article-remove-images t]
2176 ["Toggle smiley" gnus-treat-smiley t]
2177 ["Show X-Face" gnus-article-display-x-face t]
2178 ["Show picons in From" gnus-treat-from-picon t]
2179 ["Show picons in mail headers" gnus-treat-mail-picon t]
2180 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2181 ("View as different encoding"
2182 ,@(gnus-summary-menu-split
2183 (mapcar
2184 (lambda (cs)
2185 ;; Since easymenu under Emacs doesn't allow
2186 ;; lambda forms for menu commands, we should
2187 ;; provide intern'ed function symbols.
2188 (let ((command (intern (format "\
2189gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2190 (fset command
2191 `(lambda ()
2192 (interactive)
2193 (let ((gnus-summary-show-article-charset-alist
2194 '((1 . ,cs))))
2195 (gnus-summary-show-article 1))))
2196 `[,(symbol-name cs) ,command t]))
2197 (sort (if (fboundp 'coding-system-list)
2198 (coding-system-list)
2199 (mapcar 'car mm-mime-mule-charset-alist))
2200 'string<)))))
2201 ("Washing"
2202 ("Remove Blanks"
2203 ["Leading" gnus-article-strip-leading-blank-lines t]
2204 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2205 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2206 ["All of the above" gnus-article-strip-blank-lines t]
2207 ["All" gnus-article-strip-all-blank-lines t]
2208 ["Leading space" gnus-article-strip-leading-space t]
2209 ["Trailing space" gnus-article-strip-trailing-space t]
2210 ["Leading space in headers"
2211 gnus-article-remove-leading-whitespace t])
2212 ["Overstrike" gnus-article-treat-overstrike t]
2213 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2214 ["Emphasis" gnus-article-emphasize t]
2215 ["Word wrap" gnus-article-fill-cited-article t]
16409b0b
GM
2216 ["Fill long lines" gnus-article-fill-long-lines t]
2217 ["Capitalize sentences" gnus-article-capitalize-sentences t]
23f87bed
MB
2218 ["Remove CR" gnus-article-remove-cr t]
2219 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2220 ["Base64" gnus-article-de-base64-unreadable t]
2221 ["Rot 13" gnus-summary-caesar-message
2222 ,@(if (featurep 'xemacs) '(t)
2223 '(:help "\"Caesar rotate\" article by 13"))]
2224 ["Morse decode" gnus-summary-morse-message t]
2225 ["Unix pipe..." gnus-summary-pipe-message t]
2226 ["Add buttons" gnus-article-add-buttons t]
2227 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2228 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2229 ["Verbose header" gnus-summary-verbose-headers t]
2230 ["Toggle header" gnus-summary-toggle-header t]
2231 ["Unfold headers" gnus-article-treat-unfold-headers t]
2232 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
16409b0b 2233 ["Html" gnus-article-wash-html t]
23f87bed
MB
2234 ["Unsplit URLs" gnus-article-unsplit-urls t]
2235 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2236 ["Decode HZ" gnus-article-decode-HZ t]
2237 ("(Outlook) Deuglify"
2238 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2239 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2240 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2241 ["Full (Outlook) deuglify"
2242 gnus-article-outlook-deuglify-article t])
2243 )
2244 ("Output"
2245 ["Save in default format..." gnus-summary-save-article
2246 ,@(if (featurep 'xemacs) '(t)
2247 '(:help "Save article using default method"))]
2248 ["Save in file..." gnus-summary-save-article-file
2249 ,@(if (featurep 'xemacs) '(t)
2250 '(:help "Save article in file"))]
2251 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2252 ["Save in MH folder..." gnus-summary-save-article-folder t]
2253 ["Save in VM folder..." gnus-summary-save-article-vm t]
2254 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2255 ["Save body in file..." gnus-summary-save-article-body-file t]
2256 ["Pipe through a filter..." gnus-summary-pipe-output t]
2257 ["Add to SOUP packet" gnus-soup-add-article t]
2258 ["Print with Muttprint..." gnus-summary-muttprint t]
531e5812
MB
2259 ["Print" gnus-summary-print-article
2260 ,@(if (featurep 'xemacs) '(t)
2261 '(:help "Generate and print a PostScript image"))])
2262 ("Copy, move,... (Backend)"
707f2b38 2263 ,@(if (featurep 'xemacs) nil
531e5812 2264 '(:help "Copying, moving, expiring articles..."))
23f87bed
MB
2265 ["Respool article..." gnus-summary-respool-article t]
2266 ["Move article..." gnus-summary-move-article
2267 (gnus-check-backend-function
2268 'request-move-article gnus-newsgroup-name)]
2269 ["Copy article..." gnus-summary-copy-article t]
2270 ["Crosspost article..." gnus-summary-crosspost-article
2271 (gnus-check-backend-function
2272 'request-replace-article gnus-newsgroup-name)]
2273 ["Import file..." gnus-summary-import-article
2274 (gnus-check-backend-function
2275 'request-accept-article gnus-newsgroup-name)]
2276 ["Create article..." gnus-summary-create-article
2277 (gnus-check-backend-function
2278 'request-accept-article gnus-newsgroup-name)]
2279 ["Check if posted" gnus-summary-article-posted-p t]
2280 ["Edit article" gnus-summary-edit-article
2281 (not (gnus-group-read-only-p))]
2282 ["Delete article" gnus-summary-delete-article
2283 (gnus-check-backend-function
2284 'request-expire-articles gnus-newsgroup-name)]
2285 ["Query respool" gnus-summary-respool-query t]
6748645f 2286 ["Trace respool" gnus-summary-respool-trace t]
23f87bed
MB
2287 ["Delete expirable articles" gnus-summary-expire-articles-now
2288 (gnus-check-backend-function
2289 'request-expire-articles gnus-newsgroup-name)])
2290 ("Extract"
2291 ["Uudecode" gnus-uu-decode-uu
2292 ,@(if (featurep 'xemacs) '(t)
2293 '(:help "Decode uuencoded article(s)"))]
2294 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2295 ["Unshar" gnus-uu-decode-unshar t]
2296 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2297 ["Save" gnus-uu-decode-save t]
2298 ["Binhex" gnus-uu-decode-binhex t]
2299 ["Postscript" gnus-uu-decode-postscript t]
2300 ["All MIME parts" gnus-summary-save-parts t])
2301 ("Cache"
2302 ["Enter article" gnus-cache-enter-article t]
2303 ["Remove article" gnus-cache-remove-article t])
16409b0b 2304 ["Translate" gnus-article-babel t]
23f87bed
MB
2305 ["Select article buffer" gnus-summary-select-article-buffer t]
2306 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2307 ["Isearch article..." gnus-summary-isearch-article t]
2308 ["Beginning of the article" gnus-summary-beginning-of-article t]
2309 ["End of the article" gnus-summary-end-of-article t]
2310 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2311 ["Fetch referenced articles" gnus-summary-refer-references t]
2312 ["Fetch current thread" gnus-summary-refer-thread t]
2313 ["Fetch article with id..." gnus-summary-refer-article t]
2314 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2315 ["Redisplay" gnus-summary-show-article t]
2316 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
6748645f 2317 (easy-menu-define
23f87bed
MB
2318 gnus-summary-article-menu gnus-summary-mode-map ""
2319 (cons "Article" innards))
6748645f 2320
1653df0f
SZ
2321 (if (not (keymapp gnus-summary-article-menu))
2322 (easy-menu-define
2323 gnus-article-commands-menu gnus-article-mode-map ""
2324 (cons "Commands" innards))
2325 ;; in Emacs, don't share menu.
a1506d29 2326 (setq gnus-article-commands-menu
1653df0f
SZ
2327 (copy-keymap gnus-summary-article-menu))
2328 (define-key gnus-article-mode-map [menu-bar commands]
2329 (cons "Commands" gnus-article-commands-menu))))
eec82323
LMI
2330
2331 (easy-menu-define
23f87bed
MB
2332 gnus-summary-thread-menu gnus-summary-mode-map ""
2333 '("Threads"
2334 ["Find all messages in thread" gnus-summary-refer-thread t]
2335 ["Toggle threading" gnus-summary-toggle-threads t]
2336 ["Hide threads" gnus-summary-hide-all-threads t]
2337 ["Show threads" gnus-summary-show-all-threads t]
2338 ["Hide thread" gnus-summary-hide-thread t]
2339 ["Show thread" gnus-summary-show-thread t]
2340 ["Go to next thread" gnus-summary-next-thread t]
2341 ["Go to previous thread" gnus-summary-prev-thread t]
2342 ["Go down thread" gnus-summary-down-thread t]
2343 ["Go up thread" gnus-summary-up-thread t]
2344 ["Top of thread" gnus-summary-top-thread t]
2345 ["Mark thread as read" gnus-summary-kill-thread t]
2346 ["Lower thread score" gnus-summary-lower-thread t]
2347 ["Raise thread score" gnus-summary-raise-thread t]
2348 ["Rethread current" gnus-summary-rethread-current t]))
eec82323
LMI
2349
2350 (easy-menu-define
23f87bed
MB
2351 gnus-summary-post-menu gnus-summary-mode-map ""
2352 `("Post"
2353 ["Send a message (mail or news)" gnus-summary-post-news
2354 ,@(if (featurep 'xemacs) '(t)
531e5812 2355 '(:help "Compose a new message (mail or news)"))]
23f87bed
MB
2356 ["Followup" gnus-summary-followup
2357 ,@(if (featurep 'xemacs) '(t)
2358 '(:help "Post followup to this article"))]
2359 ["Followup and yank" gnus-summary-followup-with-original
2360 ,@(if (featurep 'xemacs) '(t)
2361 '(:help "Post followup to this article, quoting its contents"))]
2362 ["Supersede article" gnus-summary-supersede-article t]
2363 ["Cancel article" gnus-summary-cancel-article
2364 ,@(if (featurep 'xemacs) '(t)
2365 '(:help "Cancel an article you posted"))]
2366 ["Reply" gnus-summary-reply t]
2367 ["Reply and yank" gnus-summary-reply-with-original t]
2368 ["Wide reply" gnus-summary-wide-reply t]
2369 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2370 ,@(if (featurep 'xemacs) '(t)
2371 '(:help "Mail a reply, quoting this article"))]
2372 ["Very wide reply" gnus-summary-very-wide-reply t]
2373 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2374 ,@(if (featurep 'xemacs) '(t)
2375 '(:help "Mail a very wide reply, quoting this article"))]
2376 ["Mail forward" gnus-summary-mail-forward t]
2377 ["Post forward" gnus-summary-post-forward t]
2378 ["Digest and mail" gnus-uu-digest-mail-forward t]
2379 ["Digest and post" gnus-uu-digest-post-forward t]
2380 ["Resend message" gnus-summary-resend-message t]
2381 ["Resend message edit" gnus-summary-resend-message-edit t]
2382 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2383 ["Send a mail" gnus-summary-mail-other-window t]
2384 ["Create a local message" gnus-summary-news-other-window t]
2385 ["Uuencode and post" gnus-uu-post-news
2386 ,@(if (featurep 'xemacs) '(t)
2387 '(:help "Post a uuencoded article"))]
2388 ["Followup via news" gnus-summary-followup-to-mail t]
2389 ["Followup via news and yank"
2390 gnus-summary-followup-to-mail-with-original t]
2391 ;;("Draft"
2392 ;;["Send" gnus-summary-send-draft t]
2393 ;;["Send bounced" gnus-resend-bounced-mail t])
2394 ))
2395
2396 (cond
2397 ((not (keymapp gnus-summary-post-menu))
2398 (setq gnus-article-post-menu gnus-summary-post-menu))
2399 ((not gnus-article-post-menu)
2400 ;; Don't share post menu.
2401 (setq gnus-article-post-menu
2402 (copy-keymap gnus-summary-post-menu))))
2403 (define-key gnus-article-mode-map [menu-bar post]
2404 (cons "Post" gnus-article-post-menu))
eec82323
LMI
2405
2406 (easy-menu-define
23f87bed
MB
2407 gnus-summary-misc-menu gnus-summary-mode-map ""
2408 `("Gnus"
2409 ("Mark Read"
2410 ["Mark as read" gnus-summary-mark-as-read-forward t]
2411 ["Mark same subject and select"
2412 gnus-summary-kill-same-subject-and-select t]
2413 ["Mark same subject" gnus-summary-kill-same-subject t]
2414 ["Catchup" gnus-summary-catchup
2415 ,@(if (featurep 'xemacs) '(t)
2416 '(:help "Mark unread articles in this group as read"))]
2417 ["Catchup all" gnus-summary-catchup-all t]
2418 ["Catchup to here" gnus-summary-catchup-to-here t]
2419 ["Catchup from here" gnus-summary-catchup-from-here t]
2420 ["Catchup region" gnus-summary-mark-region-as-read
2421 (gnus-mark-active-p)]
2422 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2423 ("Mark Various"
2424 ["Tick" gnus-summary-tick-article-forward t]
2425 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2426 ["Remove marks" gnus-summary-clear-mark-forward t]
2427 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2428 ["Set bookmark" gnus-summary-set-bookmark t]
2429 ["Remove bookmark" gnus-summary-remove-bookmark t])
2430 ("Limit to"
2431 ["Marks..." gnus-summary-limit-to-marks t]
2432 ["Subject..." gnus-summary-limit-to-subject t]
2433 ["Author..." gnus-summary-limit-to-author t]
2434 ["Age..." gnus-summary-limit-to-age t]
2435 ["Extra..." gnus-summary-limit-to-extra t]
2436 ["Score..." gnus-summary-limit-to-score t]
2437 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2438 ["Unread" gnus-summary-limit-to-unread t]
2439 ["Unseen" gnus-summary-limit-to-unseen t]
2440 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
996aa8c1 2441 ["Next or process marked articles" gnus-summary-limit-to-articles t]
23f87bed
MB
2442 ["Pop limit" gnus-summary-pop-limit t]
2443 ["Show dormant" gnus-summary-limit-include-dormant t]
2444 ["Hide childless dormant"
2445 gnus-summary-limit-exclude-childless-dormant t]
2446 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2447 ["Hide marked" gnus-summary-limit-exclude-marks t]
2448 ["Show expunged" gnus-summary-limit-include-expunged t])
2449 ("Process Mark"
2450 ["Set mark" gnus-summary-mark-as-processable t]
2451 ["Remove mark" gnus-summary-unmark-as-processable t]
2452 ["Remove all marks" gnus-summary-unmark-all-processable t]
2453 ["Mark above" gnus-uu-mark-over t]
2454 ["Mark series" gnus-uu-mark-series t]
2455 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2456 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2457 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2458 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2459 ["Mark all" gnus-uu-mark-all t]
2460 ["Mark buffer" gnus-uu-mark-buffer t]
2461 ["Mark sparse" gnus-uu-mark-sparse t]
2462 ["Mark thread" gnus-uu-mark-thread t]
2463 ["Unmark thread" gnus-uu-unmark-thread t]
2464 ("Process Mark Sets"
2465 ["Kill" gnus-summary-kill-process-mark t]
2466 ["Yank" gnus-summary-yank-process-mark
2467 gnus-newsgroup-process-stack]
2468 ["Save" gnus-summary-save-process-mark t]
2469 ["Run command on marked..." gnus-summary-universal-argument t]))
2470 ("Scroll article"
2471 ["Page forward" gnus-summary-next-page
2472 ,@(if (featurep 'xemacs) '(t)
2473 '(:help "Show next page of article"))]
2474 ["Page backward" gnus-summary-prev-page
2475 ,@(if (featurep 'xemacs) '(t)
2476 '(:help "Show previous page of article"))]
2477 ["Line forward" gnus-summary-scroll-up t])
2478 ("Move"
2479 ["Next unread article" gnus-summary-next-unread-article t]
2480 ["Previous unread article" gnus-summary-prev-unread-article t]
2481 ["Next article" gnus-summary-next-article t]
2482 ["Previous article" gnus-summary-prev-article t]
2483 ["Next unread subject" gnus-summary-next-unread-subject t]
2484 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2485 ["Next article same subject" gnus-summary-next-same-subject t]
2486 ["Previous article same subject" gnus-summary-prev-same-subject t]
2487 ["First unread article" gnus-summary-first-unread-article t]
2488 ["Best unread article" gnus-summary-best-unread-article t]
2489 ["Go to subject number..." gnus-summary-goto-subject t]
2490 ["Go to article number..." gnus-summary-goto-article t]
2491 ["Go to the last article" gnus-summary-goto-last-article t]
2492 ["Pop article off history" gnus-summary-pop-article t])
2493 ("Sort"
2494 ["Sort by number" gnus-summary-sort-by-number t]
2495 ["Sort by author" gnus-summary-sort-by-author t]
2496 ["Sort by subject" gnus-summary-sort-by-subject t]
2497 ["Sort by date" gnus-summary-sort-by-date t]
2498 ["Sort by score" gnus-summary-sort-by-score t]
2499 ["Sort by lines" gnus-summary-sort-by-lines t]
2500 ["Sort by characters" gnus-summary-sort-by-chars t]
2501 ["Randomize" gnus-summary-sort-by-random t]
2502 ["Original sort" gnus-summary-sort-by-original t])
2503 ("Help"
2504 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2505 ["Describe group" gnus-summary-describe-group t]
2506 ["Fetch charter" gnus-group-fetch-charter
2507 ,@(if (featurep 'xemacs) nil
2508 '(:help "Display the charter of the current group"))]
2509 ["Fetch control message" gnus-group-fetch-control
2510 ,@(if (featurep 'xemacs) nil
2511 '(:help "Display the archived control message for the current group"))]
2512 ["Read manual" gnus-info-find-node t])
2513 ("Modes"
2514 ["Pick and read" gnus-pick-mode t]
2515 ["Binary" gnus-binary-mode t])
2516 ("Regeneration"
2517 ["Regenerate" gnus-summary-prepare t]
2518 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2519 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2520 ["Toggle threading" gnus-summary-toggle-threads t])
2521 ["See old articles" gnus-summary-insert-old-articles t]
2522 ["See new articles" gnus-summary-insert-new-articles t]
2523 ["Filter articles..." gnus-summary-execute-command t]
2524 ["Run command on articles..." gnus-summary-universal-argument t]
2525 ["Search articles forward..." gnus-summary-search-article-forward t]
2526 ["Search articles backward..." gnus-summary-search-article-backward t]
2527 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2528 ["Expand window" gnus-summary-expand-window t]
2529 ["Expire expirable articles" gnus-summary-expire-articles
2530 (gnus-check-backend-function
2531 'request-expire-articles gnus-newsgroup-name)]
2532 ["Edit local kill file" gnus-summary-edit-local-kill t]
2533 ["Edit main kill file" gnus-summary-edit-global-kill t]
2534 ["Edit group parameters" gnus-summary-edit-parameters t]
2535 ["Customize group parameters" gnus-summary-customize-parameters t]
2536 ["Send a bug report" gnus-bug t]
2537 ("Exit"
2538 ["Catchup and exit" gnus-summary-catchup-and-exit
2539 ,@(if (featurep 'xemacs) '(t)
2540 '(:help "Mark unread articles in this group as read, then exit"))]
2541 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2542 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2543 ["Exit group" gnus-summary-exit
2544 ,@(if (featurep 'xemacs) '(t)
2545 '(:help "Exit current group, return to group selection mode"))]
2546 ["Exit group without updating" gnus-summary-exit-no-update t]
2547 ["Exit and goto next group" gnus-summary-next-group t]
2548 ["Exit and goto prev group" gnus-summary-prev-group t]
2549 ["Reselect group" gnus-summary-reselect-current-group t]
2550 ["Rescan group" gnus-summary-rescan-group t]
2551 ["Update dribble" gnus-summary-save-newsrc t])))
eec82323 2552
6748645f 2553 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323 2554
60bd5589
DL
2555(defvar gnus-summary-tool-bar-map nil)
2556
18c06a99
RS
2557;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2558;; affect _new_ message buffers. We might add a function that walks thru all
2559;; summary-mode buffers and force the update.
2560(defun gnus-summary-tool-bar-update (&optional symbol value)
2561 "Update summary mode toolbar.
2562Setter function for custom variables."
2563 (setq-default gnus-summary-tool-bar-map nil)
2564 (when symbol
2565 ;; When used as ":set" function:
2566 (set-default symbol value))
2567 (when (gnus-buffer-live-p gnus-summary-buffer)
2568 (with-current-buffer gnus-summary-buffer
2569 (gnus-summary-make-tool-bar))))
2570
2571(defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2572 'gnus-summary-tool-bar-gnome
2573 'gnus-summary-tool-bar-retro)
2574 "Specifies the Gnus summary tool bar.
2575
2576It can be either a list or a symbol refering to a list. See
2577`gmm-tool-bar-from-list' for the format of the list. The
2578default key map is `gnus-summary-mode-map'.
2579
2580Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2581`gnus-summary-tool-bar-retro'."
2582 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2583 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2584 (repeat :tag "User defined list" gmm-tool-bar-item)
2585 (symbol))
25bf7349 2586 :version "22.1" ;; Gnus 5.10.9
18c06a99
RS
2587 :initialize 'custom-initialize-default
2588 :set 'gnus-summary-tool-bar-update
2589 :group 'gnus-summary)
2590
2591(defcustom gnus-summary-tool-bar-gnome
2592 '((gnus-summary-post-news "mail/compose" nil)
2593 (gnus-summary-insert-new-articles "mail/inbox" nil
2594 :visible (or (not gnus-agent)
2595 gnus-plugged))
2596 (gnus-summary-reply-with-original "mail/reply")
2597 (gnus-summary-reply "mail/reply" nil :visible nil)
2598 (gnus-summary-followup-with-original "mail/reply-all")
2599 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2600 (gnus-summary-mail-forward "mail/forward")
2601 (gnus-summary-save-article "mail/save")
2602 (gnus-summary-search-article-forward "search" nil :visible nil)
2603 (gnus-summary-print-article "print")
2604 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2605 ;; Some new commands that may need more suitable icons:
2606 (gnus-summary-save-newsrc "save" nil :visible nil)
2607 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2608 (gnus-summary-prev-article "left-arrow")
2609 (gnus-summary-next-article "right-arrow")
2610 (gnus-summary-next-page "next-page")
2611 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2612 ;;
2613 ;; Maybe some sort-by-... could be added:
2614 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2615 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2616 (gnus-summary-mark-as-expirable
2617 "delete" nil
2618 :visible (gnus-check-backend-function 'request-expire-articles
2619 gnus-newsgroup-name))
2620 (gnus-summary-mark-as-spam
2621 "mail/spam" t
2622 :visible (and (fboundp 'spam-group-ham-contents-p)
2623 (spam-group-ham-contents-p gnus-newsgroup-name))
2624 :help "Mark as spam")
2625 (gnus-summary-mark-as-read-forward
2626 "mail/not-spam" nil
2627 :visible (and (fboundp 'spam-group-spam-contents-p)
2628 (spam-group-spam-contents-p gnus-newsgroup-name)))
2629 ;;
2630 (gnus-summary-exit "exit")
2631 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2632 (gnus-info-find-node "help"))
2633 "List of functions for the summary tool bar (GNOME style).
2634
2635See `gmm-tool-bar-from-list' for the format of the list."
2636 :type '(repeat gmm-tool-bar-item)
25bf7349 2637 :version "22.1" ;; Gnus 5.10.9
18c06a99
RS
2638 :initialize 'custom-initialize-default
2639 :set 'gnus-summary-tool-bar-update
2640 :group 'gnus-summary)
2641
2642(defcustom gnus-summary-tool-bar-retro
2643 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2644 (gnus-summary-next-unread-article "gnus/next-ur")
2645 (gnus-summary-post-news "gnus/post")
2646 (gnus-summary-followup-with-original "gnus/fuwo")
2647 (gnus-summary-followup "gnus/followup")
2648 (gnus-summary-reply-with-original "gnus/reply-wo")
2649 (gnus-summary-reply "gnus/reply")
2650 (gnus-summary-caesar-message "gnus/rot13")
2651 (gnus-uu-decode-uu "gnus/uu-decode")
2652 (gnus-summary-save-article-file "gnus/save-aif")
2653 (gnus-summary-save-article "gnus/save-art")
2654 (gnus-uu-post-news "gnus/uu-post")
2655 (gnus-summary-catchup "gnus/catchup")
2656 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2657 (gnus-summary-exit "gnus/exit-summ")
2658 ;; Some new command that may need more suitable icons:
2659 (gnus-summary-print-article "gnus/print" nil :visible nil)
2660 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2661 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2662 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2663 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2664 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2665 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2666 ;;
2667 (gnus-info-find-node "gnus/help" nil :visible nil))
2668 "List of functions for the summary tool bar (retro look).
2669
2670See `gmm-tool-bar-from-list' for the format of the list."
2671 :type '(repeat gmm-tool-bar-item)
25bf7349 2672 :version "22.1" ;; Gnus 5.10.9
18c06a99
RS
2673 :initialize 'custom-initialize-default
2674 :set 'gnus-summary-tool-bar-update
2675 :group 'gnus-summary)
2676
2677(defcustom gnus-summary-tool-bar-zap-list t
2678 "List of icon items from the global tool bar.
2679These items are not displayed in the Gnus summary mode tool bar.
2680
2681See `gmm-tool-bar-from-list' for the format of the list."
2682 :type 'gmm-tool-bar-zap-list
25bf7349 2683 :version "22.1" ;; Gnus 5.10.9
18c06a99
RS
2684 :initialize 'custom-initialize-default
2685 :set 'gnus-summary-tool-bar-update
2686 :group 'gnus-summary)
2687
2688(defvar image-load-path)
2689
2690(defun gnus-summary-make-tool-bar (&optional force)
2691 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2692When FORCE, rebuild the tool bar."
2693 (when (and (not (featurep 'xemacs))
2694 (boundp 'tool-bar-mode)
2695 tool-bar-mode
2696 (or (not gnus-summary-tool-bar-map) force))
2697 (let* ((load-path
2698 (gmm-image-load-path-for-library "gnus"
2699 "mail/save.xpm"
2700 nil t))
2701 (image-load-path (cons (car load-path)
2702 (when (boundp 'image-load-path)
2703 image-load-path)))
2704 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2705 gnus-summary-tool-bar-zap-list
2706 'gnus-summary-mode-map)))
2707 (when map
2708 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2709 ;; uses it's value.
2710 (setq gnus-summary-tool-bar-map map))))
2711 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
60bd5589 2712
eec82323
LMI
2713(defun gnus-score-set-default (var value)
2714 "A version of set that updates the GNU Emacs menu-bar."
2715 (set var value)
2716 ;; It is the message that forces the active status to be updated.
2717 (message ""))
2718
2719(defun gnus-make-score-map (type)
2720 "Make a summary score map of type TYPE."
2721 (if t
2722 nil
2723 (let ((headers '(("author" "from" string)
2724 ("subject" "subject" string)
2725 ("article body" "body" string)
2726 ("article head" "head" string)
2727 ("xref" "xref" string)
16409b0b 2728 ("extra header" "extra" string)
eec82323
LMI
2729 ("lines" "lines" number)
2730 ("followups to author" "followup" string)))
2731 (types '((number ("less than" <)
2732 ("greater than" >)
2733 ("equal" =))
2734 (string ("substring" s)
2735 ("exact string" e)
2736 ("fuzzy string" f)
2737 ("regexp" r))))
2738 (perms '(("temporary" (current-time-string))
2739 ("permanent" nil)
2740 ("immediate" now)))
2741 header)
2742 (list
2743 (apply
2744 'nconc
2745 (list
2746 (if (eq type 'lower)
2747 "Lower score"
2748 "Increase score"))
2749 (let (outh)
2750 (while headers
2751 (setq header (car headers))
2752 (setq outh
2753 (cons
2754 (apply
2755 'nconc
2756 (list (car header))
2757 (let ((ts (cdr (assoc (nth 2 header) types)))
2758 outt)
2759 (while ts
2760 (setq outt
2761 (cons
2762 (apply
2763 'nconc
2764 (list (caar ts))
2765 (let ((ps perms)
2766 outp)
2767 (while ps
2768 (setq outp
2769 (cons
2770 (vector
2771 (caar ps)
2772 (list
2773 'gnus-summary-score-entry
2774 (nth 1 header)
2775 (if (or (string= (nth 1 header)
2776 "head")
2777 (string= (nth 1 header)
2778 "body"))
2779 ""
2780 (list 'gnus-summary-header
2781 (nth 1 header)))
2782 (list 'quote (nth 1 (car ts)))
16409b0b
GM
2783 (list 'gnus-score-delta-default
2784 nil)
eec82323
LMI
2785 (nth 1 (car ps))
2786 t)
2787 t)
2788 outp))
2789 (setq ps (cdr ps)))
2790 (list (nreverse outp))))
2791 outt))
2792 (setq ts (cdr ts)))
2793 (list (nreverse outt))))
2794 outh))
2795 (setq headers (cdr headers)))
2796 (list (nreverse outh))))))))
2797
2798\f
2799
2800(defun gnus-summary-mode (&optional group)
2801 "Major mode for reading articles.
2802
2803All normal editing commands are switched off.
2804\\<gnus-summary-mode-map>
2805Each line in this buffer represents one article. To read an
2806article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2807and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2808respectively.
2809
2810You can also post articles and send mail from this buffer. To
23f87bed 2811follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
eec82323
LMI
2812of an article, type `\\[gnus-summary-reply]'.
2813
2814There are approx. one gazillion commands you can execute in this
2815buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2816
2817The following commands are available:
2818
2819\\{gnus-summary-mode-map}"
2820 (interactive)
eec82323 2821 (kill-all-local-variables)
60bd5589
DL
2822 (when (gnus-visual-p 'summary-menu 'menu)
2823 (gnus-summary-make-menu-bar)
2824 (gnus-summary-make-tool-bar))
eec82323 2825 (gnus-summary-make-local-variables)
23f87bed
MB
2826 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2827 (gnus-summary-make-local-variables))
eec82323
LMI
2828 (gnus-make-thread-indent-array)
2829 (gnus-simplify-mode-line)
2830 (setq major-mode 'gnus-summary-mode)
2831 (setq mode-name "Summary")
2832 (make-local-variable 'minor-mode-alist)
2833 (use-local-map gnus-summary-mode-map)
16409b0b 2834 (buffer-disable-undo)
eec82323
LMI
2835 (setq buffer-read-only t) ;Disable modification
2836 (setq truncate-lines t)
2837 (setq selective-display t)
2838 (setq selective-display-ellipses t) ;Display `...'
2839 (gnus-summary-set-display-table)
2840 (gnus-set-default-directory)
2841 (setq gnus-newsgroup-name group)
2842 (make-local-variable 'gnus-summary-line-format)
2843 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
2844 (make-local-variable 'gnus-summary-dummy-line-format)
2845 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323 2846 (make-local-variable 'gnus-summary-mark-positions)
23f87bed 2847 (gnus-make-local-hook 'pre-command-hook)
6748645f 2848 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
cfcd5c91 2849 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
23f87bed 2850 (turn-on-gnus-mailing-list-mode)
87545352 2851 (mm-enable-multibyte)
eec82323
LMI
2852 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2853 (gnus-update-summary-mark-positions))
2854
2855(defun gnus-summary-make-local-variables ()
2856 "Make all the local summary buffer variables."
16409b0b
GM
2857 (let (global)
2858 (dolist (local gnus-summary-local-variables)
eec82323
LMI
2859 (if (consp local)
2860 (progn
2861 (if (eq (cdr local) 'global)
2862 ;; Copy the global value of the variable.
2863 (setq global (symbol-value (car local)))
2864 ;; Use the value from the list.
2865 (setq global (eval (cdr local))))
16409b0b 2866 (set (make-local-variable (car local)) global))
eec82323 2867 ;; Simple nil-valued local variable.
16409b0b 2868 (set (make-local-variable local) nil)))))
eec82323
LMI
2869
2870(defun gnus-summary-clear-local-variables ()
2871 (let ((locals gnus-summary-local-variables))
2872 (while locals
2873 (if (consp (car locals))
2874 (and (vectorp (caar locals))
2875 (set (caar locals) nil))
2876 (and (vectorp (car locals))
2877 (set (car locals) nil)))
2878 (setq locals (cdr locals)))))
2879
2880;; Summary data functions.
2881
2882(defmacro gnus-data-number (data)
2883 `(car ,data))
2884
2885(defmacro gnus-data-set-number (data number)
2886 `(setcar ,data ,number))
2887
2888(defmacro gnus-data-mark (data)
2889 `(nth 1 ,data))
2890
2891(defmacro gnus-data-set-mark (data mark)
2892 `(setcar (nthcdr 1 ,data) ,mark))
2893
2894(defmacro gnus-data-pos (data)
2895 `(nth 2 ,data))
2896
2897(defmacro gnus-data-set-pos (data pos)
2898 `(setcar (nthcdr 2 ,data) ,pos))
2899
2900(defmacro gnus-data-header (data)
2901 `(nth 3 ,data))
2902
2903(defmacro gnus-data-set-header (data header)
2904 `(setf (nth 3 ,data) ,header))
2905
2906(defmacro gnus-data-level (data)
2907 `(nth 4 ,data))
2908
2909(defmacro gnus-data-unread-p (data)
2910 `(= (nth 1 ,data) gnus-unread-mark))
2911
2912(defmacro gnus-data-read-p (data)
2913 `(/= (nth 1 ,data) gnus-unread-mark))
2914
2915(defmacro gnus-data-pseudo-p (data)
2916 `(consp (nth 3 ,data)))
2917
2918(defmacro gnus-data-find (number)
2919 `(assq ,number gnus-newsgroup-data))
2920
2921(defmacro gnus-data-find-list (number &optional data)
2922 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2923 (memq (assq ,number bdata)
2924 bdata)))
2925
2926(defmacro gnus-data-make (number mark pos header level)
2927 `(list ,number ,mark ,pos ,header ,level))
2928
2929(defun gnus-data-enter (after-article number mark pos header level offset)
2930 (let ((data (gnus-data-find-list after-article)))
2931 (unless data
2932 (error "No such article: %d" after-article))
2933 (setcdr data (cons (gnus-data-make number mark pos header level)
2934 (cdr data)))
2935 (setq gnus-newsgroup-data-reverse nil)
2936 (gnus-data-update-list (cddr data) offset)))
2937
2938(defun gnus-data-enter-list (after-article list &optional offset)
2939 (when list
2940 (let ((data (and after-article (gnus-data-find-list after-article)))
2941 (ilist list))
6748645f
LMI
2942 (if (not (or data
2943 after-article))
2944 (let ((odata gnus-newsgroup-data))
2945 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 2946 (when offset
6748645f 2947 (gnus-data-update-list odata offset)))
23f87bed 2948 ;; Find the last element in the list to be spliced into the main
6748645f
LMI
2949 ;; list.
2950 (while (cdr list)
2951 (setq list (cdr list)))
2952 (if (not data)
2953 (progn
2954 (setcdr list gnus-newsgroup-data)
2955 (setq gnus-newsgroup-data ilist)
2956 (when offset
2957 (gnus-data-update-list (cdr list) offset)))
2958 (setcdr list (cdr data))
2959 (setcdr data ilist)
2960 (when offset
2961 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
2962 (setq gnus-newsgroup-data-reverse nil))))
2963
2964(defun gnus-data-remove (article &optional offset)
2965 (let ((data gnus-newsgroup-data))
2966 (if (= (gnus-data-number (car data)) article)
2967 (progn
2968 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2969 gnus-newsgroup-data-reverse nil)
2970 (when offset
2971 (gnus-data-update-list gnus-newsgroup-data offset)))
2972 (while (cdr data)
2973 (when (= (gnus-data-number (cadr data)) article)
2974 (setcdr data (cddr data))
2975 (when offset
2976 (gnus-data-update-list (cdr data) offset))
2977 (setq data nil
2978 gnus-newsgroup-data-reverse nil))
2979 (setq data (cdr data))))))
2980
2981(defmacro gnus-data-list (backward)
2982 `(if ,backward
2983 (or gnus-newsgroup-data-reverse
2984 (setq gnus-newsgroup-data-reverse
2985 (reverse gnus-newsgroup-data)))
2986 gnus-newsgroup-data))
2987
2988(defun gnus-data-update-list (data offset)
2989 "Add OFFSET to the POS of all data entries in DATA."
6748645f 2990 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
2991 (while data
2992 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2993 (setq data (cdr data))))
2994
eec82323
LMI
2995(defun gnus-summary-article-pseudo-p (article)
2996 "Say whether this article is a pseudo article or not."
2997 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2998
2999(defmacro gnus-summary-article-sparse-p (article)
3000 "Say whether this article is a sparse article or not."
a8151ef7 3001 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
3002
3003(defmacro gnus-summary-article-ancient-p (article)
3004 "Say whether this article is a sparse article or not."
3005 `(memq ,article gnus-newsgroup-ancient))
3006
3007(defun gnus-article-parent-p (number)
3008 "Say whether this article is a parent or not."
3009 (let ((data (gnus-data-find-list number)))
23f87bed 3010 (and (cdr data) ; There has to be an article after...
eec82323
LMI
3011 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3012 (gnus-data-level (nth 1 data))))))
3013
3014(defun gnus-article-children (number)
3015 "Return a list of all children to NUMBER."
3016 (let* ((data (gnus-data-find-list number))
3017 (level (gnus-data-level (car data)))
3018 children)
3019 (setq data (cdr data))
3020 (while (and data
3021 (= (gnus-data-level (car data)) (1+ level)))
3022 (push (gnus-data-number (car data)) children)
3023 (setq data (cdr data)))
3024 children))
3025
3026(defmacro gnus-summary-skip-intangible ()
3027 "If the current article is intangible, then jump to a different article."
3028 '(let ((to (get-text-property (point) 'gnus-intangible)))
3029 (and to (gnus-summary-goto-subject to))))
3030
3031(defmacro gnus-summary-article-intangible-p ()
3032 "Say whether this article is intangible or not."
3033 '(get-text-property (point) 'gnus-intangible))
3034
3035(defun gnus-article-read-p (article)
3036 "Say whether ARTICLE is read or not."
3037 (not (or (memq article gnus-newsgroup-marked)
23f87bed 3038 (memq article gnus-newsgroup-spam-marked)
eec82323
LMI
3039 (memq article gnus-newsgroup-unreads)
3040 (memq article gnus-newsgroup-unselected)
3041 (memq article gnus-newsgroup-dormant))))
3042
3043;; Some summary mode macros.
3044
3045(defmacro gnus-summary-article-number ()
3046 "The article number of the article on the current line.
8f688cb0 3047If there isn't an article number here, then we return the current
eec82323
LMI
3048article number."
3049 '(progn
3050 (gnus-summary-skip-intangible)
3051 (or (get-text-property (point) 'gnus-number)
3052 (gnus-summary-last-subject))))
3053
3054(defmacro gnus-summary-article-header (&optional number)
6748645f 3055 "Return the header of article NUMBER."
eec82323
LMI
3056 `(gnus-data-header (gnus-data-find
3057 ,(or number '(gnus-summary-article-number)))))
3058
3059(defmacro gnus-summary-thread-level (&optional number)
6748645f 3060 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
3061 `(if (and (eq gnus-summary-make-false-root 'dummy)
3062 (get-text-property (point) 'gnus-intangible))
3063 0
3064 (gnus-data-level (gnus-data-find
3065 ,(or number '(gnus-summary-article-number))))))
3066
3067(defmacro gnus-summary-article-mark (&optional number)
6748645f 3068 "Return the mark of article NUMBER."
eec82323
LMI
3069 `(gnus-data-mark (gnus-data-find
3070 ,(or number '(gnus-summary-article-number)))))
3071
3072(defmacro gnus-summary-article-pos (&optional number)
6748645f 3073 "Return the position of the line of article NUMBER."
eec82323
LMI
3074 `(gnus-data-pos (gnus-data-find
3075 ,(or number '(gnus-summary-article-number)))))
3076
3077(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3078(defmacro gnus-summary-article-subject (&optional number)
3079 "Return current subject string or nil if nothing."
3080 `(let ((headers
3081 ,(if number
3082 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3083 '(gnus-data-header (assq (gnus-summary-article-number)
3084 gnus-newsgroup-data)))))
3085 (and headers
3086 (vectorp headers)
3087 (mail-header-subject headers))))
3088
3089(defmacro gnus-summary-article-score (&optional number)
3090 "Return current article score."
3091 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3092 gnus-newsgroup-scored))
3093 gnus-summary-default-score 0))
3094
3095(defun gnus-summary-article-children (&optional number)
6748645f 3096 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
3097 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3098 (level (gnus-data-level (car data)))
3099 l children)
3100 (while (and (setq data (cdr data))
3101 (> (setq l (gnus-data-level (car data))) level))
3102 (and (= (1+ level) l)
3103 (push (gnus-data-number (car data))
3104 children)))
3105 (nreverse children)))
3106
3107(defun gnus-summary-article-parent (&optional number)
6748645f 3108 "Return the article number of the parent of article NUMBER."
eec82323
LMI
3109 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3110 (gnus-data-list t)))
3111 (level (gnus-data-level (car data))))
3112 (if (zerop level)
3113 () ; This is a root.
3114 ;; We search until we find an article with a level less than
3115 ;; this one. That function has to be the parent.
3116 (while (and (setq data (cdr data))
3117 (not (< (gnus-data-level (car data)) level))))
3118 (and data (gnus-data-number (car data))))))
3119
3120(defun gnus-unread-mark-p (mark)
3121 "Say whether MARK is the unread mark."
3122 (= mark gnus-unread-mark))
3123
3124(defun gnus-read-mark-p (mark)
3125 "Say whether MARK is one of the marks that mark as read.
3126This is all marks except unread, ticked, dormant, and expirable."
3127 (not (or (= mark gnus-unread-mark)
3128 (= mark gnus-ticked-mark)
23f87bed 3129 (= mark gnus-spam-mark)
eec82323
LMI
3130 (= mark gnus-dormant-mark)
3131 (= mark gnus-expirable-mark))))
3132
3133(defmacro gnus-article-mark (number)
6748645f
LMI
3134 "Return the MARK of article NUMBER.
3135This macro should only be used when computing the mark the \"first\"
3136time; i.e., when generating the summary lines. After that,
3137`gnus-summary-article-mark' should be used to examine the
3138marks of articles."
eec82323 3139 `(cond
6748645f 3140 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
6748645f 3141 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
3142 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3143 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
23f87bed 3144 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
eec82323
LMI
3145 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3146 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3147 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3148 gnus-ancient-mark))))
3149
3150;; Saving hidden threads.
3151
eec82323
LMI
3152(defmacro gnus-save-hidden-threads (&rest forms)
3153 "Save hidden threads, eval FORMS, and restore the hidden threads."
3154 (let ((config (make-symbol "config")))
3155 `(let ((,config (gnus-hidden-threads-configuration)))
3156 (unwind-protect
3157 (save-excursion
3158 ,@forms)
3159 (gnus-restore-hidden-threads-configuration ,config)))))
23f87bed
MB
3160(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3161(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
eec82323 3162
107ecebb
AS
3163(defun gnus-data-compute-positions ()
3164 "Compute the positions of all articles."
3165 (setq gnus-newsgroup-data-reverse nil)
3166 (let ((data gnus-newsgroup-data))
3167 (save-excursion
3168 (gnus-save-hidden-threads
3169 (gnus-summary-show-all-threads)
3170 (goto-char (point-min))
3171 (while data
3172 (while (get-text-property (point) 'gnus-intangible)
3173 (forward-line 1))
3174 (gnus-data-set-pos (car data) (+ (point) 3))
3175 (setq data (cdr data))
3176 (forward-line 1))))))
3177
16409b0b
GM
3178(defun gnus-hidden-threads-configuration ()
3179 "Return the current hidden threads configuration."
3180 (save-excursion
3181 (let (config)
3182 (goto-char (point-min))
3183 (while (search-forward "\r" nil t)
3184 (push (1- (point)) config))
3185 config)))
3186
3187(defun gnus-restore-hidden-threads-configuration (config)
3188 "Restore hidden threads configuration from CONFIG."
3189 (save-excursion
3190 (let (point buffer-read-only)
3191 (while (setq point (pop config))
3192 (when (and (< point (point-max))
3193 (goto-char point)
3194 (eq (char-after) ?\n))
3195 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3196
eec82323
LMI
3197;; Various summary mode internalish functions.
3198
3199(defun gnus-mouse-pick-article (e)
3200 (interactive "e")
3201 (mouse-set-point e)
3202 (gnus-summary-next-page nil t))
3203
3204(defun gnus-summary-set-display-table ()
16409b0b
GM
3205 "Change the display table.
3206Odd characters have a tendency to mess
3207up nicely formatted displays - we make all possible glyphs
3208display only a single character."
eec82323
LMI
3209
3210 ;; We start from the standard display table, if any.
3211 (let ((table (or (copy-sequence standard-display-table)
3212 (make-display-table)))
3213 (i 32))
3214 ;; Nix out all the control chars...
3215 (while (>= (setq i (1- i)) 0)
3216 (aset table i [??]))
23f87bed 3217 ;; ... but not newline and cr, of course. (cr is necessary for the
eec82323
LMI
3218 ;; selective display).
3219 (aset table ?\n nil)
3220 (aset table ?\r nil)
6748645f
LMI
3221 ;; We keep TAB as well.
3222 (aset table ?\t nil)
719120ef 3223 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
fe62aacc 3224 ;; Emacs 23 (unicode), that are not set already.
719120ef
MB
3225 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3226 160
3227 256)))
eec82323
LMI
3228 (while (>= (setq i (1- i)) 127)
3229 ;; Only modify if the entry is nil.
3230 (unless (aref table i)
3231 (aset table i [??]))))
3232 (setq buffer-display-table table)))
3233
23f87bed
MB
3234(defun gnus-summary-set-article-display-arrow (pos)
3235 "Update the overlay arrow to point to line at position POS."
3236 (when (and gnus-summary-display-arrow
3237 (boundp 'overlay-arrow-position)
3238 (boundp 'overlay-arrow-string))
3239 (save-excursion
3240 (goto-char pos)
3241 (beginning-of-line)
3242 (unless overlay-arrow-position
3243 (setq overlay-arrow-position (make-marker)))
3244 (setq overlay-arrow-string "=>"
3245 overlay-arrow-position (set-marker overlay-arrow-position
3246 (point)
3247 (current-buffer))))))
3248
eec82323
LMI
3249(defun gnus-summary-setup-buffer (group)
3250 "Initialize summary buffer."
23f87bed
MB
3251 (let ((buffer (gnus-summary-buffer-name group))
3252 (dead-name (concat "*Dead Summary "
3253 (gnus-group-decoded-name group) "*")))
3254 ;; If a dead summary buffer exists, we kill it.
3255 (when (gnus-buffer-live-p dead-name)
3256 (gnus-kill-buffer dead-name))
eec82323
LMI
3257 (if (get-buffer buffer)
3258 (progn
3259 (set-buffer buffer)
3260 (setq gnus-summary-buffer (current-buffer))
3261 (not gnus-newsgroup-prepared))
3262 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 3263 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323
LMI
3264 (gnus-summary-mode group)
3265 (when gnus-carpal
3266 (gnus-carpal-setup-buffer 'summary))
3267 (unless gnus-single-article-buffer
3268 (make-local-variable 'gnus-article-buffer)
3269 (make-local-variable 'gnus-article-current)
3270 (make-local-variable 'gnus-original-article-buffer))
3271 (setq gnus-newsgroup-name group)
23f87bed
MB
3272 ;; Set any local variables in the group parameters.
3273 (gnus-summary-set-local-parameters gnus-newsgroup-name)
eec82323
LMI
3274 t)))
3275
3276(defun gnus-set-global-variables ()
16409b0b
GM
3277 "Set the global equivalents of the buffer-local variables.
3278They are set to the latest values they had. These reflect the summary
3279buffer that was in action when the last article was fetched."
eec82323
LMI
3280 (when (eq major-mode 'gnus-summary-mode)
3281 (setq gnus-summary-buffer (current-buffer))
3282 (let ((name gnus-newsgroup-name)
3283 (marked gnus-newsgroup-marked)
23f87bed 3284 (spam gnus-newsgroup-spam-marked)
eec82323
LMI
3285 (unread gnus-newsgroup-unreads)
3286 (headers gnus-current-headers)
3287 (data gnus-newsgroup-data)
3288 (summary gnus-summary-buffer)
3289 (article-buffer gnus-article-buffer)
3290 (original gnus-original-article-buffer)
3291 (gac gnus-article-current)
3292 (reffed gnus-reffed-article-number)
16409b0b 3293 (score-file gnus-current-score-file)
23f87bed
MB
3294 (default-charset gnus-newsgroup-charset)
3295 vlist)
3296 (let ((locals gnus-newsgroup-variables))
3297 (while locals
3298 (if (consp (car locals))
3299 (push (eval (caar locals)) vlist)
3300 (push (eval (car locals)) vlist))
3301 (setq locals (cdr locals)))
3302 (setq vlist (nreverse vlist)))
eec82323
LMI
3303 (save-excursion
3304 (set-buffer gnus-group-buffer)
6748645f
LMI
3305 (setq gnus-newsgroup-name name
3306 gnus-newsgroup-marked marked
23f87bed 3307 gnus-newsgroup-spam-marked spam
6748645f
LMI
3308 gnus-newsgroup-unreads unread
3309 gnus-current-headers headers
3310 gnus-newsgroup-data data
3311 gnus-article-current gac
3312 gnus-summary-buffer summary
3313 gnus-article-buffer article-buffer
3314 gnus-original-article-buffer original
3315 gnus-reffed-article-number reffed
16409b0b
GM
3316 gnus-current-score-file score-file
3317 gnus-newsgroup-charset default-charset)
23f87bed
MB
3318 (let ((locals gnus-newsgroup-variables))
3319 (while locals
3320 (if (consp (car locals))
3321 (set (caar locals) (pop vlist))
3322 (set (car locals) (pop vlist)))
3323 (setq locals (cdr locals))))
eec82323
LMI
3324 ;; The article buffer also has local variables.
3325 (when (gnus-buffer-live-p gnus-article-buffer)
3326 (set-buffer gnus-article-buffer)
3327 (setq gnus-summary-buffer summary))))))
3328
3329(defun gnus-summary-article-unread-p (article)
3330 "Say whether ARTICLE is unread or not."
3331 (memq article gnus-newsgroup-unreads))
3332
3333(defun gnus-summary-first-article-p (&optional article)
3334 "Return whether ARTICLE is the first article in the buffer."
3335 (if (not (setq article (or article (gnus-summary-article-number))))
3336 nil
3337 (eq article (caar gnus-newsgroup-data))))
3338
3339(defun gnus-summary-last-article-p (&optional article)
3340 "Return whether ARTICLE is the last article in the buffer."
3341 (if (not (setq article (or article (gnus-summary-article-number))))
16409b0b
GM
3342 ;; All non-existent numbers are the last article. :-)
3343 t
eec82323
LMI
3344 (not (cdr (gnus-data-find-list article)))))
3345
3346(defun gnus-make-thread-indent-array ()
3347 (let ((n 200))
3348 (unless (and gnus-thread-indent-array
3349 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3350 (setq gnus-thread-indent-array (make-vector 201 "")
3351 gnus-thread-indent-array-level gnus-thread-indent-level)
3352 (while (>= n 0)
3353 (aset gnus-thread-indent-array n
3354 (make-string (* n gnus-thread-indent-level) ? ))
3355 (setq n (1- n))))))
3356
3357(defun gnus-update-summary-mark-positions ()
3358 "Compute where the summary marks are to go."
3359 (save-excursion
6748645f 3360 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3361 (set-buffer gnus-summary-buffer))
5153a47a
MB
3362 (let ((spec gnus-summary-line-format-spec)
3363 pos)
eec82323
LMI
3364 (save-excursion
3365 (gnus-set-work-buffer)
5153a47a
MB
3366 (let ((gnus-tmp-unread ?Z)
3367 (gnus-replied-mark ?Z)
3368 (gnus-score-below-mark ?Z)
3369 (gnus-score-over-mark ?Z)
3370 (gnus-undownloaded-mark ?Z)
3371 (gnus-summary-line-format-spec spec)
54506618 3372 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3373 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3374 case-fold-search ignores)
3375 ;; Here, all marks are bound to Z.
3376 (gnus-summary-insert-line header
3377 0 nil t gnus-tmp-unread t nil "" nil 1)
3378 (goto-char (point-min))
3379 ;; Memorize the positions of the same characters as dummy marks.
3380 (while (re-search-forward "[A-D]" nil t)
3381 (push (point) ignores))
54506618 3382 (erase-buffer)
5153a47a
MB
3383 ;; We use A-D as dummy marks in order to know column positions
3384 ;; where marks should be inserted.
3385 (setq gnus-tmp-unread ?A
3386 gnus-replied-mark ?B
3387 gnus-score-below-mark ?C
3388 gnus-score-over-mark ?C
3389 gnus-undownloaded-mark ?D)
3390 (gnus-summary-insert-line header
3391 0 nil t gnus-tmp-unread t nil "" nil 1)
3392 ;; Ignore characters which aren't dummy marks.
3393 (dolist (p ignores)
3394 (delete-region (goto-char (1- p)) p)
3395 (insert ?Z))
eec82323 3396 (goto-char (point-min))
7c3bb5a5 3397 (setq pos (list (cons 'unread
5153a47a 3398 (and (search-forward "A" nil t)
7c3bb5a5 3399 (- (point) (point-min) 1)))))
eec82323 3400 (goto-char (point-min))
5153a47a 3401 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3402 (- (point) (point-min) 1)))
eec82323
LMI
3403 pos)
3404 (goto-char (point-min))
5153a47a 3405 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3406 (- (point) (point-min) 1)))
6748645f
LMI
3407 pos)
3408 (goto-char (point-min))
5153a47a 3409 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3410 (- (point) (point-min) 1)))
eec82323
LMI
3411 pos)))
3412 (setq gnus-summary-mark-positions pos))))
3413
3414(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3415 "Insert a dummy root in the summary buffer."
3416 (beginning-of-line)
3417 (gnus-add-text-properties
3418 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3419 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3420
23f87bed
MB
3421(defun gnus-summary-extract-address-component (from)
3422 (or (car (funcall gnus-extract-address-components from))
3423 from))
3424
3425(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3426 (let ((mail-parse-charset gnus-newsgroup-charset)
3427 ; Is it really necessary to do this next part for each summary line?
3428 ; Luckily, doesn't seem to slow things down much.
16409b0b
GM
3429 (mail-parse-ignored-charsets
3430 (save-excursion (set-buffer gnus-summary-buffer)
3431 gnus-newsgroup-ignored-charsets)))
23f87bed
MB
3432 (or
3433 (and gnus-ignored-from-addresses
3434 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3435 (let ((extra-headers (mail-header-extra header))
3436 to
3437 newsgroups)
3438 (cond
3439 ((setq to (cdr (assq 'To extra-headers)))
3440 (concat "-> "
3441 (inline
3442 (gnus-summary-extract-address-component
343d6628 3443 (funcall gnus-decode-encoded-address-function to)))))
23f87bed
MB
3444 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3445 (concat "=> " newsgroups)))))
3446 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3447
eec82323
LMI
3448(defun gnus-summary-insert-line (gnus-tmp-header
3449 gnus-tmp-level gnus-tmp-current
23f87bed 3450 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3451 gnus-tmp-expirable gnus-tmp-subject-or-nil
3452 &optional gnus-tmp-dummy gnus-tmp-score
3453 gnus-tmp-process)
3454 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3455 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3456 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3457 (gnus-tmp-score-char
3458 (if (or (null gnus-summary-default-score)
3459 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3460 gnus-summary-zcore-fuzz))
23f87bed 3461 ? ;Whitespace
eec82323
LMI
3462 (if (< gnus-tmp-score gnus-summary-default-score)
3463 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3464 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3465 (gnus-tmp-replied
3466 (cond (gnus-tmp-process gnus-process-mark)
3467 ((memq gnus-tmp-current gnus-newsgroup-cached)
3468 gnus-cached-mark)
3469 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3470 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3471 gnus-forwarded-mark)
eec82323
LMI
3472 ((memq gnus-tmp-current gnus-newsgroup-saved)
3473 gnus-saved-mark)
23f87bed
MB
3474 ((memq gnus-tmp-number gnus-newsgroup-recent)
3475 gnus-recent-mark)
3476 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3477 gnus-unseen-mark)
3478 (t gnus-no-mark)))
3479 (gnus-tmp-downloaded
3480 (cond (undownloaded
3481 gnus-undownloaded-mark)
3482 (gnus-newsgroup-agentized
3483 gnus-downloaded-mark)
3484 (t
3485 gnus-no-mark)))
eec82323
LMI
3486 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3487 (gnus-tmp-name
3488 (cond
3489 ((string-match "<[^>]+> *$" gnus-tmp-from)
3490 (let ((beg (match-beginning 0)))
23f87bed
MB
3491 (or (and (string-match "^\".+\"" gnus-tmp-from)
3492 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3493 (substring gnus-tmp-from 0 beg))))
3494 ((string-match "(.+)" gnus-tmp-from)
3495 (substring gnus-tmp-from
3496 (1+ (match-beginning 0)) (1- (match-end 0))))
3497 (t gnus-tmp-from)))
3498 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3499 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3500 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3501 (buffer-read-only nil))
3502 (when (string= gnus-tmp-name "")
3503 (setq gnus-tmp-name gnus-tmp-from))
3504 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3505 (setq gnus-tmp-lines -1))
3506 (if (= gnus-tmp-lines -1)
3507 (setq gnus-tmp-lines "?")
3508 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3509 (gnus-put-text-property
eec82323
LMI
3510 (point)
3511 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 3512 'gnus-number gnus-tmp-number)
eec82323
LMI
3513 (when (gnus-visual-p 'summary-highlight 'highlight)
3514 (forward-line -1)
6748645f 3515 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3516 (forward-line 1))))
3517
3518(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3519 "Update summary line after change."
eec82323
LMI
3520 (when (and gnus-summary-default-score
3521 (not gnus-summary-inhibit-highlight))
3522 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3523 (article (gnus-summary-article-number))
3524 (score (gnus-summary-article-score article)))
3525 (unless dont-update
3526 (if (and gnus-summary-mark-below
3527 (< (gnus-summary-article-score)
3528 gnus-summary-mark-below))
3529 ;; This article has a low score, so we mark it as read.
3530 (when (memq article gnus-newsgroup-unreads)
3531 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3532 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3533 ;; This article was previously marked as read on account
3534 ;; of a low score, but now it has risen, so we mark it as
3535 ;; unread.
3536 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3537 (gnus-summary-update-mark
3538 (if (or (null gnus-summary-default-score)
3539 (<= (abs (- score gnus-summary-default-score))
3540 gnus-summary-zcore-fuzz))
23f87bed 3541 ? ;Whitespace
eec82323
LMI
3542 (if (< score gnus-summary-default-score)
3543 gnus-score-below-mark gnus-score-over-mark))
3544 'score))
3545 ;; Do visual highlighting.
3546 (when (gnus-visual-p 'summary-highlight 'highlight)
6748645f 3547 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3548
3549(defvar gnus-tmp-new-adopts nil)
3550
3551(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3552 "Return the number of articles in THREAD.
3553This may be 0 in some cases -- if none of the articles in
3554the thread are to be displayed."
3555 (let* ((number
23f87bed 3556 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3557 (cond
3558 ((not (listp thread))
3559 1)
3560 ((and (consp thread) (cdr thread))
3561 (apply
3562 '+ 1 (mapcar
3563 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3564 ((null thread)
3565 1)
3566 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3567 1)
3568 (t 0))))
3569 (when (and level (zerop level) gnus-tmp-new-adopts)
3570 (incf number
3571 (apply '+ (mapcar
3572 'gnus-summary-number-of-articles-in-thread
3573 gnus-tmp-new-adopts))))
3574 (if char
3575 (if (> number 1) gnus-not-empty-thread-mark
3576 gnus-empty-thread-mark)
3577 number)))
3578
23f87bed
MB
3579(defsubst gnus-summary-line-message-size (head)
3580 "Return pretty-printed version of message size.
3581This function is intended to be used in
3582`gnus-summary-line-format-alist'."
3583 (let ((c (or (mail-header-chars head) -1)))
3584 (cond ((< c 0) "n/a") ; chars not available
3585 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3586 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3587 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3588 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3589
3590
eec82323
LMI
3591(defun gnus-summary-set-local-parameters (group)
3592 "Go through the local params of GROUP and set all variable specs in that list."
3593 (let ((params (gnus-group-find-parameter group))
23f87bed 3594 (vars '(quit-config)) ; Ignore quit-config.
eec82323
LMI
3595 elem)
3596 (while params
3597 (setq elem (car params)
3598 params (cdr params))
3599 (and (consp elem) ; Has to be a cons.
3600 (consp (cdr elem)) ; The cdr has to be a list.
3601 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3602 (not (memq (car elem) vars))
eec82323 3603 (ignore-errors ; So we set it.
23f87bed 3604 (push (car elem) vars)
eec82323
LMI
3605 (make-local-variable (car elem))
3606 (set (car elem) (eval (nth 1 elem))))))))
3607
3608(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3609 kill-buffer no-display backward
3610 select-articles)
eec82323
LMI
3611 "Start reading news in newsgroup GROUP.
3612If SHOW-ALL is non-nil, already read articles are also listed.
3613If NO-ARTICLE is non-nil, no article is selected initially.
3614If NO-DISPLAY, don't generate a summary buffer."
3615 (let (result)
3616 (while (and group
3617 (null (setq result
3618 (let ((gnus-auto-select-next nil))
6748645f
LMI
3619 (or (gnus-summary-read-group-1
3620 group show-all no-article
3621 kill-buffer no-display
3622 select-articles)
3623 (setq show-all nil
16409b0b 3624 select-articles nil)))))
eec82323
LMI
3625 (eq gnus-auto-select-next 'quietly))
3626 (set-buffer gnus-group-buffer)
6748645f
LMI
3627 ;; The entry function called above goes to the next
3628 ;; group automatically, so we go two groups back
3629 ;; if we are searching for the previous group.
3630 (when backward
3631 (gnus-group-prev-unread-group 2))
eec82323
LMI
3632 (if (not (equal group (gnus-group-group-name)))
3633 (setq group (gnus-group-group-name))
3634 (setq group nil)))
3635 result))
3636
3637(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3638 kill-buffer no-display
3639 &optional select-articles)
eec82323 3640 ;; Killed foreign groups can't be entered.
23f87bed
MB
3641 ;; (when (and (not (gnus-group-native-p group))
3642 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3643 ;; (error "Dead non-native groups can't be entered"))
3644 (gnus-message 5 "Retrieving newsgroup: %s..."
3645 (gnus-group-decoded-name group))
eec82323
LMI
3646 (let* ((new-group (gnus-summary-setup-buffer group))
3647 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3648 (did-select (and new-group (gnus-select-newsgroup
3649 group show-all select-articles))))
eec82323
LMI
3650 (cond
3651 ;; This summary buffer exists already, so we just select it.
3652 ((not new-group)
3653 (gnus-set-global-variables)
3654 (when kill-buffer
3655 (gnus-kill-or-deaden-summary kill-buffer))
3656 (gnus-configure-windows 'summary 'force)
3657 (gnus-set-mode-line 'summary)
3658 (gnus-summary-position-point)
3659 (message "")
3660 t)
3661 ;; We couldn't select this group.
3662 ((null did-select)
3663 (when (and (eq major-mode 'gnus-summary-mode)
3664 (not (equal (current-buffer) kill-buffer)))
3665 (kill-buffer (current-buffer))
3666 (if (not quit-config)
3667 (progn
6748645f
LMI
3668 ;; Update the info -- marks might need to be removed,
3669 ;; for instance.
3670 (gnus-summary-update-info)
eec82323
LMI
3671 (set-buffer gnus-group-buffer)
3672 (gnus-group-jump-to-group group)
3673 (gnus-group-next-unread-group 1))
3674 (gnus-handle-ephemeral-exit quit-config)))
23f87bed
MB
3675 (let ((grpinfo (gnus-get-info group)))
3676 (if (null (gnus-info-read grpinfo))
3677 (gnus-message 3 "Group %s contains no messages"
3678 (gnus-group-decoded-name group))
3679 (gnus-message 3 "Can't select group")))
eec82323
LMI
3680 nil)
3681 ;; The user did a `C-g' while prompting for number of articles,
3682 ;; so we exit this group.
3683 ((eq did-select 'quit)
3684 (and (eq major-mode 'gnus-summary-mode)
3685 (not (equal (current-buffer) kill-buffer))
3686 (kill-buffer (current-buffer)))
3687 (when kill-buffer
3688 (gnus-kill-or-deaden-summary kill-buffer))
3689 (if (not quit-config)
3690 (progn
3691 (set-buffer gnus-group-buffer)
3692 (gnus-group-jump-to-group group)
3693 (gnus-group-next-unread-group 1)
3694 (gnus-configure-windows 'group 'force))
3695 (gnus-handle-ephemeral-exit quit-config))
3696 ;; Finally signal the quit.
3697 (signal 'quit nil))
3698 ;; The group was successfully selected.
3699 (t
3700 (gnus-set-global-variables)
3701 ;; Save the active value in effect when the group was entered.
3702 (setq gnus-newsgroup-active
3703 (gnus-copy-sequence
3704 (gnus-active gnus-newsgroup-name)))
3705 ;; You can change the summary buffer in some way with this hook.
6748645f 3706 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
3707 (when (memq 'summary (gnus-update-format-specifications
3708 nil 'summary 'summary-mode 'summary-dummy))
3709 ;; The format specification for the summary line was updated,
3710 ;; so we need to update the mark positions as well.
3711 (gnus-update-summary-mark-positions))
eec82323
LMI
3712 ;; Do score processing.
3713 (when gnus-use-scoring
3714 (gnus-possibly-score-headers))
3715 ;; Check whether to fill in the gaps in the threads.
3716 (when gnus-build-sparse-threads
3717 (gnus-build-sparse-threads))
3718 ;; Find the initial limit.
26c9afc3
MB
3719 (if show-all
3720 (let ((gnus-newsgroup-dormant nil))
eec82323 3721 (gnus-summary-initial-limit show-all))
26c9afc3 3722 (gnus-summary-initial-limit show-all))
eec82323
LMI
3723 ;; Generate the summary buffer.
3724 (unless no-display
3725 (gnus-summary-prepare))
3726 (when gnus-use-trees
3727 (gnus-tree-open group)
3728 (setq gnus-summary-highlight-line-function
3729 'gnus-tree-highlight-article))
3730 ;; If the summary buffer is empty, but there are some low-scored
3731 ;; articles or some excluded dormants, we include these in the
3732 ;; buffer.
3733 (when (and (zerop (buffer-size))
3734 (not no-display))
3735 (cond (gnus-newsgroup-dormant
3736 (gnus-summary-limit-include-dormant))
3737 ((and gnus-newsgroup-scored show-all)
3738 (gnus-summary-limit-include-expunged t))))
3739 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 3740 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
3741 (if (and (zerop (buffer-size))
3742 (not no-display))
3743 (progn
3744 ;; This newsgroup is empty.
3745 (gnus-summary-catchup-and-exit nil t)
3746 (gnus-message 6 "No unread news")
3747 (when kill-buffer
3748 (gnus-kill-or-deaden-summary kill-buffer))
3749 ;; Return nil from this function.
3750 nil)
3751 ;; Hide conversation thread subtrees. We cannot do this in
3752 ;; gnus-summary-prepare-hook since kill processing may not
3753 ;; work with hidden articles.
23f87bed 3754 (gnus-summary-maybe-hide-threads)
6748645f
LMI
3755 (when kill-buffer
3756 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 3757 (gnus-summary-auto-select-subject)
eec82323
LMI
3758 ;; Show first unread article if requested.
3759 (if (and (not no-article)
3760 (not no-display)
3761 gnus-newsgroup-unreads
3762 gnus-auto-select-first)
16409b0b
GM
3763 (progn
3764 (gnus-configure-windows 'summary)
23f87bed
MB
3765 (let ((art (gnus-summary-article-number)))
3766 (unless (and (not gnus-plugged)
3767 (or (memq art gnus-newsgroup-undownloaded)
3768 (memq art gnus-newsgroup-downloadable)))
3769 (gnus-summary-goto-article art))))
3770 ;; Don't select any articles.
eec82323 3771 (gnus-summary-position-point)
6748645f
LMI
3772 (gnus-configure-windows 'summary 'force)
3773 (gnus-set-mode-line 'summary))
23f87bed
MB
3774 (when (and gnus-auto-center-group
3775 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
3776 ;; Gotta use windows, because recenter does weird stuff if
3777 ;; the current buffer ain't the displayed window.
3778 (let ((owin (selected-window)))
3779 (select-window (get-buffer-window gnus-group-buffer t))
3780 (when (gnus-group-goto-group group)
3781 (recenter))
3782 (select-window owin)))
3783 ;; Mark this buffer as "prepared".
3784 (setq gnus-newsgroup-prepared t)
6748645f 3785 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
3786 (unless (gnus-ephemeral-group-p group)
3787 (gnus-group-update-group group))
eec82323
LMI
3788 t)))))
3789
23f87bed
MB
3790(defun gnus-summary-auto-select-subject ()
3791 "Select the subject line on initial group entry."
3792 (goto-char (point-min))
3793 (cond
3794 ((eq gnus-auto-select-subject 'best)
3795 (gnus-summary-best-unread-subject))
3796 ((eq gnus-auto-select-subject 'unread)
3797 (gnus-summary-first-unread-subject))
3798 ((eq gnus-auto-select-subject 'unseen)
3799 (gnus-summary-first-unseen-subject))
3800 ((eq gnus-auto-select-subject 'unseen-or-unread)
3801 (gnus-summary-first-unseen-or-unread-subject))
3802 ((eq gnus-auto-select-subject 'first)
3803 ;; Do nothing.
3804 )
3805 ((functionp gnus-auto-select-subject)
3806 (funcall gnus-auto-select-subject))))
3807
eec82323
LMI
3808(defun gnus-summary-prepare ()
3809 "Generate the summary buffer."
3810 (interactive)
3811 (let ((buffer-read-only nil))
3812 (erase-buffer)
3813 (setq gnus-newsgroup-data nil
3814 gnus-newsgroup-data-reverse nil)
6748645f 3815 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
3816 ;; Generate the buffer, either with threads or without.
3817 (when gnus-newsgroup-headers
3818 (gnus-summary-prepare-threads
3819 (if gnus-show-threads
3820 (gnus-sort-gathered-threads
3821 (funcall gnus-summary-thread-gathering-function
3822 (gnus-sort-threads
3823 (gnus-cut-threads (gnus-make-threads)))))
3824 ;; Unthreaded display.
3825 (gnus-sort-articles gnus-newsgroup-headers))))
3826 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3827 ;; Call hooks for modifying summary buffer.
3828 (goto-char (point-min))
6748645f 3829 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
3830
3831(defsubst gnus-general-simplify-subject (subject)
23f87bed 3832 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
3833 (setq subject
3834 (cond
3835 ;; Truncate the subject.
6748645f
LMI
3836 (gnus-simplify-subject-functions
3837 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
3838 ((numberp gnus-summary-gather-subject-limit)
3839 (setq subject (gnus-simplify-subject-re subject))
3840 (if (> (length subject) gnus-summary-gather-subject-limit)
3841 (substring subject 0 gnus-summary-gather-subject-limit)
3842 subject))
3843 ;; Fuzzily simplify it.
3844 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3845 (gnus-simplify-subject-fuzzy subject))
3846 ;; Just remove the leading "Re:".
3847 (t
3848 (gnus-simplify-subject-re subject))))
3849
3850 (if (and gnus-summary-gather-exclude-subject
3851 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 3852 nil ; This article shouldn't be gathered
eec82323
LMI
3853 subject))
3854
3855(defun gnus-summary-simplify-subject-query ()
3856 "Query where the respool algorithm would put this article."
3857 (interactive)
eec82323
LMI
3858 (gnus-summary-select-article)
3859 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3860
3861(defun gnus-gather-threads-by-subject (threads)
3862 "Gather threads by looking at Subject headers."
3863 (if (not gnus-summary-make-false-root)
3864 threads
3865 (let ((hashtb (gnus-make-hashtable 1024))
3866 (prev threads)
3867 (result threads)
3868 subject hthread whole-subject)
3869 (while threads
3870 (setq subject (gnus-general-simplify-subject
3871 (setq whole-subject (mail-header-subject
3872 (caar threads)))))
3873 (when subject
3874 (if (setq hthread (gnus-gethash subject hashtb))
3875 (progn
3876 ;; We enter a dummy root into the thread, if we
3877 ;; haven't done that already.
3878 (unless (stringp (caar hthread))
3879 (setcar hthread (list whole-subject (car hthread))))
3880 ;; We add this new gathered thread to this gathered
3881 ;; thread.
3882 (setcdr (car hthread)
3883 (nconc (cdar hthread) (list (car threads))))
3884 ;; Remove it from the list of threads.
3885 (setcdr prev (cdr threads))
3886 (setq threads prev))
3887 ;; Enter this thread into the hash table.
23f87bed
MB
3888 (gnus-sethash subject
3889 (if gnus-summary-make-false-root-always
3890 (progn
3891 ;; If you want a dummy root above all
3892 ;; threads...
3893 (setcar threads (list whole-subject
3894 (car threads)))
3895 threads)
3896 threads)
3897 hashtb)))
eec82323
LMI
3898 (setq prev threads)
3899 (setq threads (cdr threads)))
3900 result)))
3901
3902(defun gnus-gather-threads-by-references (threads)
3903 "Gather threads by looking at References headers."
3904 (let ((idhashtb (gnus-make-hashtable 1024))
3905 (thhashtb (gnus-make-hashtable 1024))
3906 (prev threads)
3907 (result threads)
3908 ids references id gthread gid entered ref)
3909 (while threads
3910 (when (setq references (mail-header-references (caar threads)))
3911 (setq id (mail-header-id (caar threads))
23f87bed 3912 ids (inline (gnus-split-references references))
eec82323
LMI
3913 entered nil)
3914 (while (setq ref (pop ids))
3915 (setq ids (delete ref ids))
3916 (if (not (setq gid (gnus-gethash ref idhashtb)))
3917 (progn
3918 (gnus-sethash ref id idhashtb)
3919 (gnus-sethash id threads thhashtb))
3920 (setq gthread (gnus-gethash gid thhashtb))
3921 (unless entered
3922 ;; We enter a dummy root into the thread, if we
3923 ;; haven't done that already.
3924 (unless (stringp (caar gthread))
3925 (setcar gthread (list (mail-header-subject (caar gthread))
3926 (car gthread))))
3927 ;; We add this new gathered thread to this gathered
3928 ;; thread.
3929 (setcdr (car gthread)
3930 (nconc (cdar gthread) (list (car threads)))))
3931 ;; Add it into the thread hash table.
3932 (gnus-sethash id gthread thhashtb)
3933 (setq entered t)
3934 ;; Remove it from the list of threads.
3935 (setcdr prev (cdr threads))
3936 (setq threads prev))))
3937 (setq prev threads)
3938 (setq threads (cdr threads)))
3939 result))
3940
3941(defun gnus-sort-gathered-threads (threads)
16409b0b 3942 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
3943 (let ((result threads))
3944 (while threads
3945 (when (stringp (caar threads))
3946 (setcdr (car threads)
16409b0b 3947 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
3948 (setq threads (cdr threads)))
3949 result))
3950
3951(defun gnus-thread-loop-p (root thread)
3952 "Say whether ROOT is in THREAD."
3953 (let ((stack (list thread))
3954 (infloop 0)
3955 th)
3956 (while (setq thread (pop stack))
3957 (setq th (cdr thread))
3958 (while (and th
3959 (not (eq (caar th) root)))
3960 (pop th))
3961 (if th
3962 ;; We have found a loop.
3963 (let (ref-dep)
3964 (setcdr thread (delq (car th) (cdr thread)))
3965 (if (boundp (setq ref-dep (intern "none"
3966 gnus-newsgroup-dependencies)))
3967 (setcdr (symbol-value ref-dep)
3968 (nconc (cdr (symbol-value ref-dep))
3969 (list (car th))))
3970 (set ref-dep (list nil (car th))))
3971 (setq infloop 1
3972 stack nil))
3973 ;; Push all the subthreads onto the stack.
3974 (push (cdr thread) stack)))
3975 infloop))
3976
3977(defun gnus-make-threads ()
3978 "Go through the dependency hashtb and find the roots. Return all threads."
3979 (let (threads)
3980 (while (catch 'infloop
3981 (mapatoms
3982 (lambda (refs)
3983 ;; Deal with self-referencing References loops.
3984 (when (and (car (symbol-value refs))
3985 (not (zerop
3986 (apply
3987 '+
3988 (mapcar
3989 (lambda (thread)
3990 (gnus-thread-loop-p
3991 (car (symbol-value refs)) thread))
3992 (cdr (symbol-value refs)))))))
3993 (setq threads nil)
3994 (throw 'infloop t))
3995 (unless (car (symbol-value refs))
23f87bed
MB
3996 ;; These threads do not refer back to any other
3997 ;; articles, so they're roots.
eec82323
LMI
3998 (setq threads (append (cdr (symbol-value refs)) threads))))
3999 gnus-newsgroup-dependencies)))
4000 threads))
4001
6748645f 4002;; Build the thread tree.
16409b0b 4003(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4004 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4005
4006If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4007if it was already present.
4008
4009If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4010will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4011Message-IDs will be renamed to a unique Message-ID before being
4012entered.
6748645f
LMI
4013
4014Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4015 (let* ((id (mail-header-id header))
4016 (id-dep (and id (intern id dependencies)))
23f87bed 4017 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4018 ;; Enter this `header' in the `dependencies' table.
4019 (cond
4020 ((not id-dep)
4021 (setq header nil))
4022 ;; The first two cases do the normal part: enter a new `header'
4023 ;; in the `dependencies' table.
4024 ((not (boundp id-dep))
4025 (set id-dep (list header)))
4026 ((null (car (symbol-value id-dep)))
4027 (setcar (symbol-value id-dep) header))
4028
4029 ;; From here the `header' was already present in the
4030 ;; `dependencies' table.
4031 (force-new
4032 ;; Overrides an existing entry;
4033 ;; just set the header part of the entry.
23f87bed
MB
4034 (setcar (symbol-value id-dep) header)
4035 (setq replaced t))
6748645f
LMI
4036
4037 ;; Renames the existing `header' to a unique Message-ID.
4038 ((not gnus-summary-ignore-duplicates)
4039 ;; An article with this Message-ID has already been seen.
4040 ;; We rename the Message-ID.
4041 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4042 (list header))
4043 (mail-header-set-id header id))
4044
4045 ;; The last case ignores an existing entry, except it adds any
4046 ;; additional Xrefs (in case the two articles came from different
4047 ;; servers.
4048 ;; Also sets `header' to `nil' meaning that the `dependencies'
4049 ;; table was *not* modified.
4050 (t
4051 (mail-header-set-xref
4052 (car (symbol-value id-dep))
4053 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4054 "")
4055 (or (mail-header-xref header) "")))
4056 (setq header nil)))
4057
23f87bed
MB
4058 (when (and header (not replaced))
4059 ;; First check that we are not creating a References loop.
4060 (setq parent-id (gnus-parent-id (mail-header-references header)))
4061 (setq ref parent-id)
6748645f
LMI
4062 (while (and ref
4063 (setq ref-dep (intern-soft ref dependencies))
4064 (boundp ref-dep)
4065 (setq ref-header (car (symbol-value ref-dep))))
4066 (if (string= id ref)
4067 ;; Yuk! This is a reference loop. Make the article be a
4068 ;; root article.
4069 (progn
4070 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4071 (setq ref nil)
4072 (setq parent-id nil))
6748645f 4073 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4074 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4075 (if (boundp ref-dep)
4076 (setcdr (symbol-value ref-dep)
4077 (nconc (cdr (symbol-value ref-dep))
4078 (list (symbol-value id-dep))))
4079 (set ref-dep (list nil (symbol-value id-dep)))))
4080 header))
4081
23f87bed
MB
4082(defun gnus-extract-message-id-from-in-reply-to (string)
4083 (if (string-match "<[^>]+>" string)
4084 (substring string (match-beginning 0) (match-end 0))
4085 nil))
4086
eec82323
LMI
4087(defun gnus-build-sparse-threads ()
4088 (let ((headers gnus-newsgroup-headers)
16409b0b 4089 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4090 (gnus-summary-ignore-duplicates t)
eec82323 4091 header references generation relations
6748645f 4092 subject child end new-child date)
eec82323
LMI
4093 ;; First we create an alist of generations/relations, where
4094 ;; generations is how much we trust the relation, and the relation
4095 ;; is parent/child.
4096 (gnus-message 7 "Making sparse threads...")
4097 (save-excursion
4098 (nnheader-set-temp-buffer " *gnus sparse threads*")
4099 (while (setq header (pop headers))
4100 (when (and (setq references (mail-header-references header))
4101 (not (string= references "")))
4102 (insert references)
4103 (setq child (mail-header-id header)
6748645f
LMI
4104 subject (mail-header-subject header)
4105 date (mail-header-date header)
4106 generation 0)
eec82323
LMI
4107 (while (search-backward ">" nil t)
4108 (setq end (1+ (point)))
4109 (when (search-backward "<" nil t)
6748645f 4110 (setq new-child (buffer-substring (point) end))
eec82323 4111 (push (list (incf generation)
6748645f
LMI
4112 child (setq child new-child)
4113 subject date)
eec82323 4114 relations)))
6748645f
LMI
4115 (when child
4116 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4117 (erase-buffer)))
4118 (kill-buffer (current-buffer)))
4119 ;; Sort over trustworthiness.
6748645f
LMI
4120 (mapcar
4121 (lambda (relation)
4122 (when (gnus-dependencies-add-header
4123 (make-full-mail-header
4124 gnus-reffed-article-number
4125 (nth 3 relation) "" (or (nth 4 relation) "")
4126 (nth 1 relation)
4127 (or (nth 2 relation) "") 0 0 "")
4128 gnus-newsgroup-dependencies nil)
4129 (push gnus-reffed-article-number gnus-newsgroup-limit)
4130 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4131 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4132 gnus-newsgroup-reads)
4133 (decf gnus-reffed-article-number)))
4134 (sort relations 'car-less-than-car))
eec82323
LMI
4135 (gnus-message 7 "Making sparse threads...done")))
4136
4137(defun gnus-build-old-threads ()
4138 ;; Look at all the articles that refer back to old articles, and
4139 ;; fetch the headers for the articles that aren't there. This will
4140 ;; build complete threads - if the roots haven't been expired by the
4141 ;; server, that is.
16409b0b
GM
4142 (let ((mail-parse-charset gnus-newsgroup-charset)
4143 id heads)
eec82323
LMI
4144 (mapatoms
4145 (lambda (refs)
4146 (when (not (car (symbol-value refs)))
4147 (setq heads (cdr (symbol-value refs)))
4148 (while heads
4149 (if (memq (mail-header-number (caar heads))
4150 gnus-newsgroup-dormant)
4151 (setq heads (cdr heads))
4152 (setq id (symbol-name refs))
4153 (while (and (setq id (gnus-build-get-header id))
6748645f 4154 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4155 (setq heads nil)))))
4156 gnus-newsgroup-dependencies)))
4157
23f87bed
MB
4158(defsubst gnus-remove-odd-characters (string)
4159 "Translate STRING into something that doesn't contain weird characters."
4160 (mm-subst-char-in-string
4161 ?\r ?\-
4162 (mm-subst-char-in-string
4163 ?\n ?\- string)))
4164
6748645f
LMI
4165;; This function has to be called with point after the article number
4166;; on the beginning of the line.
4167(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4168 (let ((eol (gnus-point-at-eol))
4169 (buffer (current-buffer))
23f87bed 4170 header references in-reply-to)
6748645f
LMI
4171
4172 ;; overview: [num subject from date id refs chars lines misc]
4173 (unwind-protect
23f87bed 4174 (let (x)
6748645f
LMI
4175 (narrow-to-region (point) eol)
4176 (unless (eobp)
4177 (forward-char))
4178
4179 (setq header
4180 (make-full-mail-header
4181 number ; number
23f87bed
MB
4182 (condition-case () ; subject
4183 (gnus-remove-odd-characters
4184 (funcall gnus-decode-encoded-word-function
4185 (setq x (nnheader-nov-field))))
4186 (error x))
4187 (condition-case () ; from
4188 (gnus-remove-odd-characters
343d6628 4189 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4190 (setq x (nnheader-nov-field))))
4191 (error x))
16409b0b
GM
4192 (nnheader-nov-field) ; date
4193 (nnheader-nov-read-message-id) ; id
23f87bed 4194 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4195 (nnheader-nov-read-integer) ; chars
4196 (nnheader-nov-read-integer) ; lines
4197 (unless (eobp)
8b93df01
DL
4198 (if (looking-at "Xref: ")
4199 (goto-char (match-end 0)))
4200 (nnheader-nov-field)) ; Xref
16409b0b 4201 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4202
4203 (widen))
4204
23f87bed
MB
4205 (when (and (string= references "")
4206 (setq in-reply-to (mail-header-extra header))
4207 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4208 (mail-header-set-references
4209 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4210
6748645f
LMI
4211 (when gnus-alter-header-function
4212 (funcall gnus-alter-header-function header))
4213 (gnus-dependencies-add-header header dependencies force-new)))
4214
eec82323 4215(defun gnus-build-get-header (id)
16409b0b
GM
4216 "Look through the buffer of NOV lines and find the header to ID.
4217Enter this line into the dependencies hash table, and return
4218the id of the parent article (if any)."
eec82323
LMI
4219 (let ((deps gnus-newsgroup-dependencies)
4220 found header)
4221 (prog1
4222 (save-excursion
4223 (set-buffer nntp-server-buffer)
4224 (let ((case-fold-search nil))
4225 (goto-char (point-min))
4226 (while (and (not found)
4227 (search-forward id nil t))
4228 (beginning-of-line)
4229 (setq found (looking-at
4230 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4231 (regexp-quote id))))
4232 (or found (beginning-of-line 2)))
4233 (when found
4234 (beginning-of-line)
4235 (and
4236 (setq header (gnus-nov-parse-line
4237 (read (current-buffer)) deps))
4238 (gnus-parent-id (mail-header-references header))))))
4239 (when header
4240 (let ((number (mail-header-number header)))
4241 (push number gnus-newsgroup-limit)
4242 (push header gnus-newsgroup-headers)
4243 (if (memq number gnus-newsgroup-unselected)
4244 (progn
23f87bed
MB
4245 (setq gnus-newsgroup-unreads
4246 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4247 number))
eec82323
LMI
4248 (setq gnus-newsgroup-unselected
4249 (delq number gnus-newsgroup-unselected)))
4250 (push number gnus-newsgroup-ancient)))))))
4251
6748645f
LMI
4252(defun gnus-build-all-threads ()
4253 "Read all the headers."
4254 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4255 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4256 (dependencies gnus-newsgroup-dependencies)
4257 header article)
4258 (save-excursion
4259 (set-buffer nntp-server-buffer)
4260 (let ((case-fold-search nil))
4261 (goto-char (point-min))
4262 (while (not (eobp))
4263 (ignore-errors
4264 (setq article (read (current-buffer))
16409b0b 4265 header (gnus-nov-parse-line article dependencies)))
6748645f
LMI
4266 (when header
4267 (save-excursion
4268 (set-buffer gnus-summary-buffer)
4269 (push header gnus-newsgroup-headers)
4270 (if (memq (setq article (mail-header-number header))
4271 gnus-newsgroup-unselected)
4272 (progn
23f87bed
MB
4273 (setq gnus-newsgroup-unreads
4274 (gnus-add-to-sorted-list
4275 gnus-newsgroup-unreads article))
6748645f
LMI
4276 (setq gnus-newsgroup-unselected
4277 (delq article gnus-newsgroup-unselected)))
4278 (push article gnus-newsgroup-ancient)))
4279 (forward-line 1)))))))
4280
eec82323 4281(defun gnus-summary-update-article-line (article header)
23f87bed 4282 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4283 (let* ((id (mail-header-id header))
4284 (thread (gnus-id-to-thread id)))
4285 (unless thread
4286 (error "Article in no thread"))
4287 ;; Update the thread.
4288 (setcar thread header)
4289 (gnus-summary-goto-subject article)
4290 (let* ((datal (gnus-data-find-list article))
4291 (data (car datal))
eec82323
LMI
4292 (buffer-read-only nil)
4293 (level (gnus-summary-thread-level)))
4294 (gnus-delete-line)
23f87bed
MB
4295 (let ((inserted (- (point)
4296 (progn
4297 (gnus-summary-insert-line
4298 header level nil
4299 (memq article gnus-newsgroup-undownloaded)
4300 (gnus-article-mark article)
4301 (memq article gnus-newsgroup-replied)
4302 (memq article gnus-newsgroup-expirable)
4303 ;; Only insert the Subject string when it's different
4304 ;; from the previous Subject string.
4305 (if (and
4306 gnus-show-threads
4307 (gnus-subject-equal
4308 (condition-case ()
4309 (mail-header-subject
4310 (gnus-data-header
4311 (cadr
4312 (gnus-data-find-list
4313 article
4314 (gnus-data-list t)))))
4315 ;; Error on the side of excessive subjects.
4316 (error ""))
4317 (mail-header-subject header)))
4318 ""
4319 (mail-header-subject header))
4320 nil (cdr (assq article gnus-newsgroup-scored))
4321 (memq article gnus-newsgroup-processable))
4322 (point)))))
4323 (when (cdr datal)
4324 (gnus-data-update-list
4325 (cdr datal)
4326 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4327
4328(defun gnus-summary-update-article (article &optional iheader)
4329 "Update ARTICLE in the summary buffer."
4330 (set-buffer gnus-summary-buffer)
6748645f 4331 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4332 (id (mail-header-id header))
4333 (data (gnus-data-find article))
4334 (thread (gnus-id-to-thread id))
4335 (references (mail-header-references header))
4336 (parent
4337 (gnus-id-to-thread
4338 (or (gnus-parent-id
4339 (when (and references
4340 (not (equal "" references)))
4341 references))
4342 "none")))
4343 (buffer-read-only nil)
6748645f 4344 (old (car thread)))
eec82323 4345 (when thread
eec82323 4346 (unless iheader
6748645f
LMI
4347 (setcar thread nil)
4348 (when parent
4349 (delq thread parent)))
4350 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4351 ;; Set the (possibly) new article number in the data structure.
4352 (gnus-data-set-number data (gnus-id-to-article id))
4353 (setcar thread old)
4354 nil))))
4355
6748645f
LMI
4356(defun gnus-rebuild-thread (id &optional line)
4357 "Rebuild the thread containing ID.
4358If LINE, insert the rebuilt thread starting on line LINE."
eec82323
LMI
4359 (let ((buffer-read-only nil)
4360 old-pos current thread data)
4361 (if (not gnus-show-threads)
4362 (setq thread (list (car (gnus-id-to-thread id))))
4363 ;; Get the thread this article is part of.
4364 (setq thread (gnus-remove-thread id)))
4365 (setq old-pos (gnus-point-at-bol))
4366 (setq current (save-excursion
94384150 4367 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4368 (gnus-summary-article-number))))
4369 ;; If this is a gathered thread, we have to go some re-gathering.
4370 (when (stringp (car thread))
4371 (let ((subject (car thread))
4372 roots thr)
4373 (setq thread (cdr thread))
4374 (while thread
4375 (unless (memq (setq thr (gnus-id-to-thread
4376 (gnus-root-id
4377 (mail-header-id (caar thread)))))
4378 roots)
4379 (push thr roots))
4380 (setq thread (cdr thread)))
4381 ;; We now have all (unique) roots.
4382 (if (= (length roots) 1)
4383 ;; All the loose roots are now one solid root.
4384 (setq thread (car roots))
4385 (setq thread (cons subject (gnus-sort-threads roots))))))
4386 (let (threads)
4387 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4388 (when line
4389 (goto-char (point-min))
4390 (forward-line (1- line)))
eec82323
LMI
4391 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4392 (if gnus-show-threads
4393 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4394 (gnus-summary-prepare-unthreaded thread))
4395 (setq data (nreverse gnus-newsgroup-data))
4396 (setq threads gnus-newsgroup-threads))
4397 ;; We splice the new data into the data structure.
6748645f
LMI
4398 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4399 ;;!!! then we want to insert at the beginning of the buffer.
4400 ;;!!! That happens to be true with Gnus now, but that may
4401 ;;!!! change in the future. Perhaps.
4402 (gnus-data-enter-list
4403 (if line nil current) data (- (point) old-pos))
4404 (setq gnus-newsgroup-threads
4405 (nconc threads gnus-newsgroup-threads))
4406 (gnus-data-compute-positions))))
eec82323
LMI
4407
4408(defun gnus-number-to-header (number)
4409 "Return the header for article NUMBER."
4410 (let ((headers gnus-newsgroup-headers))
4411 (while (and headers
4412 (not (= number (mail-header-number (car headers)))))
4413 (pop headers))
4414 (when headers
4415 (car headers))))
4416
6748645f 4417(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4418 "Return the headers of the GENERATIONeth parent of HEADERS."
4419 (unless generation
4420 (setq generation 1))
a8151ef7 4421 (let ((parent t)
6748645f 4422 (headers in-headers)
a8151ef7 4423 references)
6748645f
LMI
4424 (while (and parent
4425 (not (zerop generation))
4426 (setq references (mail-header-references headers)))
4427 (setq headers (if (and references
4428 (setq parent (gnus-parent-id references)))
4429 (car (gnus-id-to-thread parent))
4430 nil))
4431 (decf generation))
4432 (and (not (eq headers in-headers))
4433 headers)))
eec82323
LMI
4434
4435(defun gnus-id-to-thread (id)
4436 "Return the (sub-)thread where ID appears."
4437 (gnus-gethash id gnus-newsgroup-dependencies))
4438
4439(defun gnus-id-to-article (id)
4440 "Return the article number of ID."
4441 (let ((thread (gnus-id-to-thread id)))
4442 (when (and thread
4443 (car thread))
4444 (mail-header-number (car thread)))))
4445
4446(defun gnus-id-to-header (id)
4447 "Return the article headers of ID."
4448 (car (gnus-id-to-thread id)))
4449
4450(defun gnus-article-displayed-root-p (article)
4451 "Say whether ARTICLE is a root(ish) article."
4452 (let ((level (gnus-summary-thread-level article))
4453 (refs (mail-header-references (gnus-summary-article-header article)))
4454 particle)
4455 (cond
4456 ((null level) nil)
4457 ((zerop level) t)
4458 ((null refs) t)
4459 ((null (gnus-parent-id refs)) t)
4460 ((and (= 1 level)
4461 (null (setq particle (gnus-id-to-article
4462 (gnus-parent-id refs))))
4463 (null (gnus-summary-thread-level particle)))))))
4464
4465(defun gnus-root-id (id)
4466 "Return the id of the root of the thread where ID appears."
4467 (let (last-id prev)
6748645f 4468 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4469 (setq last-id id
4470 id (gnus-parent-id (mail-header-references prev))))
4471 last-id))
4472
6748645f
LMI
4473(defun gnus-articles-in-thread (thread)
4474 "Return the list of articles in THREAD."
4475 (cons (mail-header-number (car thread))
4476 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4477
eec82323
LMI
4478(defun gnus-remove-thread (id &optional dont-remove)
4479 "Remove the thread that has ID in it."
6748645f 4480 (let (headers thread last-id)
eec82323 4481 ;; First go up in this thread until we find the root.
6748645f
LMI
4482 (setq last-id (gnus-root-id id)
4483 headers (message-flatten-list (gnus-id-to-thread last-id)))
eec82323
LMI
4484 ;; We have now found the real root of this thread. It might have
4485 ;; been gathered into some loose thread, so we have to search
4486 ;; through the threads to find the thread we wanted.
4487 (let ((threads gnus-newsgroup-threads)
4488 sub)
4489 (while threads
4490 (setq sub (car threads))
4491 (if (stringp (car sub))
4492 ;; This is a gathered thread, so we look at the roots
4493 ;; below it to find whether this article is in this
4494 ;; gathered root.
4495 (progn
4496 (setq sub (cdr sub))
4497 (while sub
4498 (when (member (caar sub) headers)
4499 (setq thread (car threads)
4500 threads nil
4501 sub nil))
4502 (setq sub (cdr sub))))
4503 ;; It's an ordinary thread, so we check it.
4504 (when (eq (car sub) (car headers))
4505 (setq thread sub
4506 threads nil)))
4507 (setq threads (cdr threads)))
4508 ;; If this article is in no thread, then it's a root.
4509 (if thread
4510 (unless dont-remove
4511 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4512 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4513 (when thread
4514 (prog1
4515 thread ; We return this thread.
4516 (unless dont-remove
4517 (if (stringp (car thread))
4518 (progn
4519 ;; If we use dummy roots, then we have to remove the
4520 ;; dummy root as well.
4521 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4522 ;; We go to the dummy root by going to
4523 ;; the first sub-"thread", and then one line up.
4524 (gnus-summary-goto-article
4525 (mail-header-number (caadr thread)))
4526 (forward-line -1)
eec82323
LMI
4527 (gnus-delete-line)
4528 (gnus-data-compute-positions))
4529 (setq thread (cdr thread))
4530 (while thread
4531 (gnus-remove-thread-1 (car thread))
4532 (setq thread (cdr thread))))
4533 (gnus-remove-thread-1 thread))))))))
4534
4535(defun gnus-remove-thread-1 (thread)
4536 "Remove the thread THREAD recursively."
4537 (let ((number (mail-header-number (pop thread)))
4538 d)
4539 (setq thread (reverse thread))
4540 (while thread
4541 (gnus-remove-thread-1 (pop thread)))
4542 (when (setq d (gnus-data-find number))
4543 (goto-char (gnus-data-pos d))
16409b0b 4544 (gnus-summary-show-thread)
eec82323
LMI
4545 (gnus-data-remove
4546 number
4547 (- (gnus-point-at-bol)
4548 (prog1
4549 (1+ (gnus-point-at-eol))
4550 (gnus-delete-line)))))))
4551
16409b0b
GM
4552(defun gnus-sort-threads-1 (threads func)
4553 (sort (mapcar (lambda (thread)
4554 (cons (car thread)
4555 (and (cdr thread)
4556 (gnus-sort-threads-1 (cdr thread) func))))
4557 threads) func))
4558
eec82323
LMI
4559(defun gnus-sort-threads (threads)
4560 "Sort THREADS."
4561 (if (not gnus-thread-sort-functions)
4562 threads
6748645f 4563 (gnus-message 8 "Sorting threads...")
23f87bed
MB
4564 (let ((max-lisp-eval-depth 5000))
4565 (prog1 (gnus-sort-threads-1
a1506d29 4566 threads
16409b0b 4567 (gnus-make-sort-function gnus-thread-sort-functions))
23f87bed 4568 (gnus-message 8 "Sorting threads...done")))))
eec82323
LMI
4569
4570(defun gnus-sort-articles (articles)
4571 "Sort ARTICLES."
4572 (when gnus-article-sort-functions
4573 (gnus-message 7 "Sorting articles...")
4574 (prog1
4575 (setq gnus-newsgroup-headers
4576 (sort articles (gnus-make-sort-function
4577 gnus-article-sort-functions)))
4578 (gnus-message 7 "Sorting articles...done"))))
4579
4580;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4581(defmacro gnus-thread-header (thread)
16409b0b
GM
4582 "Return header of first article in THREAD.
4583Note that THREAD must never, ever be anything else than a variable -
4584using some other form will lead to serious barfage."
eec82323
LMI
4585 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4586 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4587 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4588 (vector thread) 2))
4589
4590(defsubst gnus-article-sort-by-number (h1 h2)
4591 "Sort articles by article number."
4592 (< (mail-header-number h1)
4593 (mail-header-number h2)))
4594
4595(defun gnus-thread-sort-by-number (h1 h2)
4596 "Sort threads by root article number."
4597 (gnus-article-sort-by-number
4598 (gnus-thread-header h1) (gnus-thread-header h2)))
4599
23f87bed
MB
4600(defsubst gnus-article-sort-by-random (h1 h2)
4601 "Sort articles by article number."
4602 (zerop (random 2)))
4603
4604(defun gnus-thread-sort-by-random (h1 h2)
4605 "Sort threads by root article number."
4606 (gnus-article-sort-by-random
4607 (gnus-thread-header h1) (gnus-thread-header h2)))
4608
eec82323
LMI
4609(defsubst gnus-article-sort-by-lines (h1 h2)
4610 "Sort articles by article Lines header."
4611 (< (mail-header-lines h1)
4612 (mail-header-lines h2)))
4613
4614(defun gnus-thread-sort-by-lines (h1 h2)
4615 "Sort threads by root article Lines header."
4616 (gnus-article-sort-by-lines
4617 (gnus-thread-header h1) (gnus-thread-header h2)))
4618
16409b0b
GM
4619(defsubst gnus-article-sort-by-chars (h1 h2)
4620 "Sort articles by octet length."
4621 (< (mail-header-chars h1)
4622 (mail-header-chars h2)))
4623
4624(defun gnus-thread-sort-by-chars (h1 h2)
4625 "Sort threads by root article octet length."
4626 (gnus-article-sort-by-chars
4627 (gnus-thread-header h1) (gnus-thread-header h2)))
4628
eec82323
LMI
4629(defsubst gnus-article-sort-by-author (h1 h2)
4630 "Sort articles by root author."
4631 (string-lessp
4632 (let ((extract (funcall
4633 gnus-extract-address-components
4634 (mail-header-from h1))))
4635 (or (car extract) (cadr extract) ""))
4636 (let ((extract (funcall
4637 gnus-extract-address-components
4638 (mail-header-from h2))))
4639 (or (car extract) (cadr extract) ""))))
4640
4641(defun gnus-thread-sort-by-author (h1 h2)
4642 "Sort threads by root author."
4643 (gnus-article-sort-by-author
4644 (gnus-thread-header h1) (gnus-thread-header h2)))
4645
4646(defsubst gnus-article-sort-by-subject (h1 h2)
4647 "Sort articles by root subject."
4648 (string-lessp
4649 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4650 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4651
4652(defun gnus-thread-sort-by-subject (h1 h2)
4653 "Sort threads by root subject."
4654 (gnus-article-sort-by-subject
4655 (gnus-thread-header h1) (gnus-thread-header h2)))
4656
4657(defsubst gnus-article-sort-by-date (h1 h2)
4658 "Sort articles by root article date."
16409b0b 4659 (time-less-p
eec82323
LMI
4660 (gnus-date-get-time (mail-header-date h1))
4661 (gnus-date-get-time (mail-header-date h2))))
4662
4663(defun gnus-thread-sort-by-date (h1 h2)
4664 "Sort threads by root article date."
4665 (gnus-article-sort-by-date
4666 (gnus-thread-header h1) (gnus-thread-header h2)))
4667
4668(defsubst gnus-article-sort-by-score (h1 h2)
4669 "Sort articles by root article score.
4670Unscored articles will be counted as having a score of zero."
4671 (> (or (cdr (assq (mail-header-number h1)
4672 gnus-newsgroup-scored))
4673 gnus-summary-default-score 0)
4674 (or (cdr (assq (mail-header-number h2)
4675 gnus-newsgroup-scored))
4676 gnus-summary-default-score 0)))
4677
4678(defun gnus-thread-sort-by-score (h1 h2)
4679 "Sort threads by root article score."
4680 (gnus-article-sort-by-score
4681 (gnus-thread-header h1) (gnus-thread-header h2)))
4682
4683(defun gnus-thread-sort-by-total-score (h1 h2)
4684 "Sort threads by the sum of all scores in the thread.
4685Unscored articles will be counted as having a score of zero."
4686 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4687
4688(defun gnus-thread-total-score (thread)
16409b0b 4689 ;; This function find the total score of THREAD.
23f87bed
MB
4690 (cond
4691 ((null thread)
4692 0)
4693 ((consp thread)
4694 (if (stringp (car thread))
4695 (apply gnus-thread-score-function 0
4696 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4697 (gnus-thread-total-score-1 thread)))
4698 (t
4699 (gnus-thread-total-score-1 (list thread)))))
4700
4701(defun gnus-thread-sort-by-most-recent-number (h1 h2)
4702 "Sort threads such that the thread with the most recently arrived article comes first."
4703 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4704
4705(defun gnus-thread-highest-number (thread)
4706 "Return the highest article number in THREAD."
4707 (apply 'max (mapcar (lambda (header)
4708 (mail-header-number header))
4709 (message-flatten-list thread))))
4710
4711(defun gnus-thread-sort-by-most-recent-date (h1 h2)
4712 "Sort threads such that the thread with the most recently dated article comes first."
4713 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4714
4715(defun gnus-thread-latest-date (thread)
4716 "Return the highest article date in THREAD."
4717 (let ((previous-time 0))
4718 (apply 'max
4719 (mapcar
4720 (lambda (header)
4721 (setq previous-time
4722 (condition-case ()
4723 (time-to-seconds (mail-header-parse-date
4724 (mail-header-date header)))
4725 (error previous-time))))
4726 (sort
4727 (message-flatten-list thread)
4728 (lambda (h1 h2)
4729 (< (mail-header-number h1)
4730 (mail-header-number h2))))))))
eec82323
LMI
4731
4732(defun gnus-thread-total-score-1 (root)
4733 ;; This function find the total score of the thread below ROOT.
4734 (setq root (car root))
4735 (apply gnus-thread-score-function
4736 (or (append
4737 (mapcar 'gnus-thread-total-score
6748645f 4738 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
4739 (when (> (mail-header-number root) 0)
4740 (list (or (cdr (assq (mail-header-number root)
4741 gnus-newsgroup-scored))
4742 gnus-summary-default-score 0))))
4743 (list gnus-summary-default-score)
4744 '(0))))
4745
4746;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4747(defvar gnus-tmp-prev-subject nil)
4748(defvar gnus-tmp-false-parent nil)
4749(defvar gnus-tmp-root-expunged nil)
4750(defvar gnus-tmp-dummy-line nil)
4751
60bd5589 4752(eval-when-compile (defvar gnus-tmp-header))
16409b0b
GM
4753(defun gnus-extra-header (type &optional header)
4754 "Return the extra header of TYPE."
4755 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4756 ""))
4757
23f87bed
MB
4758(defvar gnus-tmp-thread-tree-header-string "")
4759
4760(defcustom gnus-sum-thread-tree-root "> "
4761 "With %B spec, used for the root of a thread.
4762If nil, use subject instead."
bf247b6e 4763 :version "22.1"
ad136a7c 4764 :type '(radio (const :format "%v " nil) string)
23f87bed
MB
4765 :group 'gnus-thread)
4766(defcustom gnus-sum-thread-tree-false-root "> "
4767 "With %B spec, used for a false root of a thread.
4768If nil, use subject instead."
bf247b6e 4769 :version "22.1"
ad136a7c 4770 :type '(radio (const :format "%v " nil) string)
23f87bed
MB
4771 :group 'gnus-thread)
4772(defcustom gnus-sum-thread-tree-single-indent ""
4773 "With %B spec, used for a thread with just one message.
4774If nil, use subject instead."
bf247b6e 4775 :version "22.1"
ad136a7c 4776 :type '(radio (const :format "%v " nil) string)
23f87bed
MB
4777 :group 'gnus-thread)
4778(defcustom gnus-sum-thread-tree-vertical "| "
4779 "With %B spec, used for drawing a vertical line."
bf247b6e 4780 :version "22.1"
23f87bed
MB
4781 :type 'string
4782 :group 'gnus-thread)
4783(defcustom gnus-sum-thread-tree-indent " "
4784 "With %B spec, used for indenting."
bf247b6e 4785 :version "22.1"
23f87bed
MB
4786 :type 'string
4787 :group 'gnus-thread)
4788(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4789 "With %B spec, used for a leaf with brothers."
bf247b6e 4790 :version "22.1"
23f87bed
MB
4791 :type 'string
4792 :group 'gnus-thread)
4793(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4794 "With %B spec, used for a leaf without brothers."
bf247b6e 4795 :version "22.1"
23f87bed
MB
4796 :type 'string
4797 :group 'gnus-thread)
4798
eec82323
LMI
4799(defun gnus-summary-prepare-threads (threads)
4800 "Prepare summary buffer from THREADS and indentation LEVEL.
4801THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4802or a straight list of headers."
4803 (gnus-message 7 "Generating summary...")
4804
4805 (setq gnus-newsgroup-threads threads)
4806 (beginning-of-line)
4807
4808 (let ((gnus-tmp-level 0)
4809 (default-score (or gnus-summary-default-score 0))
4810 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
4811 (building-line-count gnus-summary-display-while-building)
4812 (building-count (integerp gnus-summary-display-while-building))
eec82323 4813 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
4814 new-roots gnus-tmp-new-adopts thread-end simp-subject
4815 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
4816 gnus-tmp-replied gnus-tmp-subject-or-nil
4817 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4818 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
4819 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4820 tree-stack)
eec82323 4821
23f87bed
MB
4822 (setq gnus-tmp-prev-subject nil
4823 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
4824
4825 (if (vectorp (car threads))
4826 ;; If this is a straight (sic) list of headers, then a
4827 ;; threaded summary display isn't required, so we just create
4828 ;; an unthreaded one.
4829 (gnus-summary-prepare-unthreaded threads)
4830
4831 ;; Do the threaded display.
4832
23f87bed
MB
4833 (if gnus-summary-display-while-building
4834 (switch-to-buffer (buffer-name)))
eec82323
LMI
4835 (while (or threads stack gnus-tmp-new-adopts new-roots)
4836
4837 (if (and (= gnus-tmp-level 0)
eec82323
LMI
4838 (or (not stack)
4839 (= (caar stack) 0))
4840 (not gnus-tmp-false-parent)
4841 (or gnus-tmp-new-adopts new-roots))
4842 (if gnus-tmp-new-adopts
4843 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4844 thread (list (car gnus-tmp-new-adopts))
4845 gnus-tmp-header (caar thread)
4846 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4847 (when new-roots
4848 (setq thread (list (car new-roots))
4849 gnus-tmp-header (caar thread)
4850 new-roots (cdr new-roots))))
4851
4852 (if threads
4853 ;; If there are some threads, we do them before the
4854 ;; threads on the stack.
4855 (setq thread threads
4856 gnus-tmp-header (caar thread))
4857 ;; There were no current threads, so we pop something off
4858 ;; the stack.
4859 (setq state (car stack)
4860 gnus-tmp-level (car state)
23f87bed
MB
4861 tree-stack (cadr state)
4862 thread (caddr state)
eec82323
LMI
4863 stack (cdr stack)
4864 gnus-tmp-header (caar thread))))
4865
4866 (setq gnus-tmp-false-parent nil)
4867 (setq gnus-tmp-root-expunged nil)
4868 (setq thread-end nil)
4869
4870 (if (stringp gnus-tmp-header)
4871 ;; The header is a dummy root.
4872 (cond
4873 ((eq gnus-summary-make-false-root 'adopt)
4874 ;; We let the first article adopt the rest.
4875 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4876 (cddar thread)))
4877 (setq gnus-tmp-gathered
4878 (nconc (mapcar
4879 (lambda (h) (mail-header-number (car h)))
4880 (cddar thread))
4881 gnus-tmp-gathered))
4882 (setq thread (cons (list (caar thread)
4883 (cadar thread))
4884 (cdr thread)))
4885 (setq gnus-tmp-level -1
4886 gnus-tmp-false-parent t))
4887 ((eq gnus-summary-make-false-root 'empty)
4888 ;; We print adopted articles with empty subject fields.
4889 (setq gnus-tmp-gathered
4890 (nconc (mapcar
4891 (lambda (h) (mail-header-number (car h)))
4892 (cddar thread))
4893 gnus-tmp-gathered))
4894 (setq gnus-tmp-level -1))
4895 ((eq gnus-summary-make-false-root 'dummy)
4896 ;; We remember that we probably want to output a dummy
4897 ;; root.
4898 (setq gnus-tmp-dummy-line gnus-tmp-header)
4899 (setq gnus-tmp-prev-subject gnus-tmp-header))
4900 (t
4901 ;; We do not make a root for the gathered
4902 ;; sub-threads at all.
4903 (setq gnus-tmp-level -1)))
4904
4905 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
4906 subject (mail-header-subject gnus-tmp-header)
4907 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
4908
4909 (cond
4910 ;; If the thread has changed subject, we might want to make
4911 ;; this subthread into a root.
4912 ((and (null gnus-thread-ignore-subject)
4913 (not (zerop gnus-tmp-level))
4914 gnus-tmp-prev-subject
23f87bed 4915 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
4916 (setq new-roots (nconc new-roots (list (car thread)))
4917 thread-end t
4918 gnus-tmp-header nil))
4919 ;; If the article lies outside the current limit,
4920 ;; then we do not display it.
4921 ((not (memq number gnus-newsgroup-limit))
4922 (setq gnus-tmp-gathered
4923 (nconc (mapcar
4924 (lambda (h) (mail-header-number (car h)))
4925 (cdar thread))
4926 gnus-tmp-gathered))
4927 (setq gnus-tmp-new-adopts (if (cdar thread)
4928 (append gnus-tmp-new-adopts
4929 (cdar thread))
4930 gnus-tmp-new-adopts)
4931 thread-end t
4932 gnus-tmp-header nil)
4933 (when (zerop gnus-tmp-level)
4934 (setq gnus-tmp-root-expunged t)))
4935 ;; Perhaps this article is to be marked as read?
4936 ((and gnus-summary-mark-below
4937 (< (or (cdr (assq number gnus-newsgroup-scored))
4938 default-score)
4939 gnus-summary-mark-below)
4940 ;; Don't touch sparse articles.
4941 (not (gnus-summary-article-sparse-p number))
4942 (not (gnus-summary-article-ancient-p number)))
4943 (setq gnus-newsgroup-unreads
4944 (delq number gnus-newsgroup-unreads))
4945 (if gnus-newsgroup-auto-expire
23f87bed
MB
4946 (setq gnus-newsgroup-expirable
4947 (gnus-add-to-sorted-list
4948 gnus-newsgroup-expirable number))
eec82323
LMI
4949 (push (cons number gnus-low-score-mark)
4950 gnus-newsgroup-reads))))
4951
4952 (when gnus-tmp-header
4953 ;; We may have an old dummy line to output before this
4954 ;; article.
6748645f
LMI
4955 (when (and gnus-tmp-dummy-line
4956 (gnus-subject-equal
4957 gnus-tmp-dummy-line
4958 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
4959 (gnus-summary-insert-dummy-line
4960 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4961 (setq gnus-tmp-dummy-line nil))
4962
4963 ;; Compute the mark.
4964 (setq gnus-tmp-unread (gnus-article-mark number))
4965
4966 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4967 gnus-tmp-header gnus-tmp-level)
4968 gnus-newsgroup-data)
4969
4970 ;; Actually insert the line.
4971 (setq
4972 gnus-tmp-subject-or-nil
4973 (cond
4974 ((and gnus-thread-ignore-subject
4975 gnus-tmp-prev-subject
23f87bed 4976 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
4977 subject)
4978 ((zerop gnus-tmp-level)
4979 (if (and (eq gnus-summary-make-false-root 'empty)
4980 (memq number gnus-tmp-gathered)
4981 gnus-tmp-prev-subject
23f87bed 4982 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
4983 gnus-summary-same-subject
4984 subject))
4985 (t gnus-summary-same-subject)))
4986 (if (and (eq gnus-summary-make-false-root 'adopt)
4987 (= gnus-tmp-level 1)
4988 (memq number gnus-tmp-gathered))
4989 (setq gnus-tmp-opening-bracket ?\<
4990 gnus-tmp-closing-bracket ?\>)
4991 (setq gnus-tmp-opening-bracket ?\[
4992 gnus-tmp-closing-bracket ?\]))
4993 (setq
4994 gnus-tmp-indentation
4995 (aref gnus-thread-indent-array gnus-tmp-level)
4996 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4997 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4998 gnus-summary-default-score 0)
4999 gnus-tmp-score-char
5000 (if (or (null gnus-summary-default-score)
5001 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5002 gnus-summary-zcore-fuzz))
23f87bed 5003 ? ;Whitespace
eec82323
LMI
5004 (if (< gnus-tmp-score gnus-summary-default-score)
5005 gnus-score-below-mark gnus-score-over-mark))
5006 gnus-tmp-replied
5007 (cond ((memq number gnus-newsgroup-processable)
5008 gnus-process-mark)
5009 ((memq number gnus-newsgroup-cached)
5010 gnus-cached-mark)
5011 ((memq number gnus-newsgroup-replied)
5012 gnus-replied-mark)
23f87bed
MB
5013 ((memq number gnus-newsgroup-forwarded)
5014 gnus-forwarded-mark)
eec82323
LMI
5015 ((memq number gnus-newsgroup-saved)
5016 gnus-saved-mark)
23f87bed
MB
5017 ((memq number gnus-newsgroup-recent)
5018 gnus-recent-mark)
5019 ((memq number gnus-newsgroup-unseen)
5020 gnus-unseen-mark)
5021 (t gnus-no-mark))
5022 gnus-tmp-downloaded
5023 (cond ((memq number gnus-newsgroup-undownloaded)
5024 gnus-undownloaded-mark)
5025 (gnus-newsgroup-agentized
5026 gnus-downloaded-mark)
5027 (t
5028 gnus-no-mark))
eec82323
LMI
5029 gnus-tmp-from (mail-header-from gnus-tmp-header)
5030 gnus-tmp-name
5031 (cond
5032 ((string-match "<[^>]+> *$" gnus-tmp-from)
5033 (setq beg-match (match-beginning 0))
23f87bed
MB
5034 (or (and (string-match "^\".+\"" gnus-tmp-from)
5035 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5036 (substring gnus-tmp-from 0 beg-match)))
5037 ((string-match "(.+)" gnus-tmp-from)
5038 (substring gnus-tmp-from
5039 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5040 (t gnus-tmp-from))
5041
5042 ;; Do the %B string
5043 gnus-tmp-thread-tree-header-string
5044 (cond
5045 ((not gnus-show-threads) "")
5046 ((zerop gnus-tmp-level)
5047 (cond ((cdar thread)
5048 (or gnus-sum-thread-tree-root subject))
5049 (gnus-tmp-new-adopts
5050 (or gnus-sum-thread-tree-false-root subject))
5051 (t
5052 (or gnus-sum-thread-tree-single-indent subject))))
5053 (t
5054 (concat (apply 'concat
5055 (mapcar (lambda (item)
5056 (if (= item 1)
5057 gnus-sum-thread-tree-vertical
5058 gnus-sum-thread-tree-indent))
5059 (cdr (reverse tree-stack))))
5060 (if (nth 1 thread)
5061 gnus-sum-thread-tree-leaf-with-other
5062 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5063 (when (string= gnus-tmp-name "")
5064 (setq gnus-tmp-name gnus-tmp-from))
5065 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5066 (setq gnus-tmp-lines -1))
5067 (if (= gnus-tmp-lines -1)
5068 (setq gnus-tmp-lines "?")
5069 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5070 (gnus-put-text-property
eec82323
LMI
5071 (point)
5072 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 5073 'gnus-number number)
eec82323
LMI
5074 (when gnus-visual-p
5075 (forward-line -1)
6748645f 5076 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
5077 (forward-line 1))
5078
23f87bed 5079 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5080
5081 (when (nth 1 thread)
23f87bed
MB
5082 (push (list (max 0 gnus-tmp-level)
5083 (copy-sequence tree-stack)
5084 (nthcdr 1 thread))
5085 stack))
5086 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5087 (incf gnus-tmp-level)
5088 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5089 (if gnus-summary-display-while-building
5090 (if building-count
5091 (progn
5092 ;; use a set frequency
5093 (setq building-line-count (1- building-line-count))
5094 (when (= building-line-count 0)
5095 (sit-for 0)
5096 (setq building-line-count
5097 gnus-summary-display-while-building)))
5098 ;; always
5099 (sit-for 0)))
eec82323
LMI
5100 (unless threads
5101 (setq gnus-tmp-level 0)))))
5102 (gnus-message 7 "Generating summary...done"))
5103
5104(defun gnus-summary-prepare-unthreaded (headers)
5105 "Generate an unthreaded summary buffer based on HEADERS."
5106 (let (header number mark)
5107
5108 (beginning-of-line)
5109
5110 (while headers
5111 ;; We may have to root out some bad articles...
5112 (when (memq (setq number (mail-header-number
5113 (setq header (pop headers))))
5114 gnus-newsgroup-limit)
5115 ;; Mark article as read when it has a low score.
5116 (when (and gnus-summary-mark-below
5117 (< (or (cdr (assq number gnus-newsgroup-scored))
5118 gnus-summary-default-score 0)
5119 gnus-summary-mark-below)
5120 (not (gnus-summary-article-ancient-p number)))
5121 (setq gnus-newsgroup-unreads
5122 (delq number gnus-newsgroup-unreads))
5123 (if gnus-newsgroup-auto-expire
5124 (push number gnus-newsgroup-expirable)
5125 (push (cons number gnus-low-score-mark)
5126 gnus-newsgroup-reads)))
5127
5128 (setq mark (gnus-article-mark number))
5129 (push (gnus-data-make number mark (1+ (point)) header 0)
5130 gnus-newsgroup-data)
5131 (gnus-summary-insert-line
5132 header 0 number
23f87bed 5133 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5134 mark (memq number gnus-newsgroup-replied)
5135 (memq number gnus-newsgroup-expirable)
5136 (mail-header-subject header) nil
5137 (cdr (assq number gnus-newsgroup-scored))
5138 (memq number gnus-newsgroup-processable))))))
5139
16409b0b
GM
5140(defun gnus-summary-remove-list-identifiers ()
5141 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5142 (let ((regexp (if (consp gnus-list-identifiers)
5143 (mapconcat 'identity gnus-list-identifiers " *\\|")
5144 gnus-list-identifiers))
5145 changed subject)
5146 (when regexp
5147 (dolist (header gnus-newsgroup-headers)
5148 (setq subject (mail-header-subject header)
5149 changed nil)
5150 (while (string-match
5151 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
5152 subject)
5153 (setq subject
5154 (concat (substring subject 0 (match-beginning 2))
5155 (substring subject (match-end 0)))
5156 changed t))
5157 (when (and changed
5158 (string-match
5159 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
5160 (setq subject
5161 (concat (substring subject 0 (match-beginning 1))
5162 (substring subject (match-end 1)))))
5163 (when changed
5164 (mail-header-set-subject header subject))))))
5165
5166(defun gnus-fetch-headers (articles)
5167 "Fetch headers of ARTICLES."
5168 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5169 (gnus-message 5 "Fetching headers for %s..." name)
5170 (prog1
5171 (if (eq 'nov
5172 (setq gnus-headers-retrieved-by
5173 (gnus-retrieve-headers
5174 articles gnus-newsgroup-name
5175 ;; We might want to fetch old headers, but
5176 ;; not if there is only 1 article.
5177 (and (or (and
5178 (not (eq gnus-fetch-old-headers 'some))
5179 (not (numberp gnus-fetch-old-headers)))
5180 (> (length articles) 1))
5181 gnus-fetch-old-headers))))
5182 (gnus-get-newsgroup-headers-xover
5183 articles nil nil gnus-newsgroup-name t)
5184 (gnus-get-newsgroup-headers))
5185 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5186
6748645f 5187(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5188 "Select newsgroup GROUP.
6748645f
LMI
5189If READ-ALL is non-nil, all articles in the group are selected.
5190If SELECT-ARTICLES, only select those articles from GROUP."
eec82323
LMI
5191 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5192 ;;!!! Dirty hack; should be removed.
5193 (gnus-summary-ignore-duplicates
23f87bed 5194 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5195 t
5196 gnus-summary-ignore-duplicates))
5197 (info (nth 2 entry))
5198 articles fetched-articles cached)
5199
5200 (unless (gnus-check-server
475e0e0c
GM
5201 (set (make-local-variable 'gnus-current-select-method)
5202 (gnus-find-method-for-group group)))
eec82323
LMI
5203 (error "Couldn't open server"))
5204
5205 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5206 (gnus-activate-group group) ; Or we can activate it...
5207 (progn ; Or we bug out.
5208 (when (equal major-mode 'gnus-summary-mode)
23f87bed
MB
5209 (gnus-kill-buffer (current-buffer)))
5210 (error "Couldn't activate group %s: %s"
c86d4601 5211 (gnus-group-decoded-name group) (gnus-status-message group))))
eec82323
LMI
5212
5213 (unless (gnus-request-group group t)
5214 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5215 (gnus-kill-buffer (current-buffer)))
eec82323 5216 (error "Couldn't request group %s: %s"
c86d4601 5217 (gnus-group-decoded-name group) (gnus-status-message group)))
eec82323 5218
23f87bed 5219 (when gnus-agent
54506618 5220 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5221
23f87bed
MB
5222 (setq gnus-summary-use-undownloaded-faces
5223 (gnus-agent-find-parameter
5224 group
5225 'agent-enable-undownloaded-faces)))
5226
5227 (setq gnus-newsgroup-name group
5228 gnus-newsgroup-unselected nil
5229 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5230
5231 (let ((display (gnus-group-find-parameter group 'display)))
5232 (setq gnus-newsgroup-display
5233 (cond
5234 ((not (zerop (or (car-safe read-all) 0)))
5235 ;; The user entered the group with C-u SPC/RET, let's show
5236 ;; all articles.
5237 'gnus-not-ignore)
5238 ((eq display 'all)
5239 'gnus-not-ignore)
5240 ((arrayp display)
5241 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5242 ((numberp display)
5243 ;; The following is probably the "correct" solution, but
5244 ;; it makes Gnus fetch all headers and then limit the
5245 ;; articles (which is slow), so instead we hack the
5246 ;; select-articles parameter instead. -- Simon Josefsson
5247 ;; <jas@kth.se>
5248 ;;
5249 ;; (gnus-byte-compile
5250 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5251 ;; display)))))
5252 (setq select-articles
5253 (gnus-uncompress-range
5254 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5255 (if (> tmp 0)
5256 tmp
5257 1))
5258 (cdr (gnus-active group)))))
5259 nil)
5260 (t
5261 nil))))
eec82323 5262
23f87bed 5263 (gnus-summary-setup-default-charset)
eec82323
LMI
5264
5265 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5266 (when (gnus-virtual-group-p group)
5267 (setq cached gnus-newsgroup-cached))
5268
5269 (setq gnus-newsgroup-unreads
23f87bed
MB
5270 (gnus-sorted-ndifference
5271 (gnus-sorted-ndifference gnus-newsgroup-unreads
5272 gnus-newsgroup-marked)
eec82323
LMI
5273 gnus-newsgroup-dormant))
5274
5275 (setq gnus-newsgroup-processable nil)
5276
5277 (gnus-update-read-articles group gnus-newsgroup-unreads)
eec82323 5278
23f87bed
MB
5279 ;; Adjust and set lists of article marks.
5280 (when info
5281 (gnus-adjust-marked-articles info))
6748645f
LMI
5282 (if (setq articles select-articles)
5283 (setq gnus-newsgroup-unselected
23f87bed 5284 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5285 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5286
5287 (cond
5288 ((null articles)
5289 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5290 'quit)
5291 ((eq articles 0) nil)
5292 (t
5293 ;; Init the dependencies hash table.
5294 (setq gnus-newsgroup-dependencies
5295 (gnus-make-hashtable (length articles)))
16409b0b 5296 (gnus-set-global-variables)
eec82323 5297 ;; Retrieve the headers and read them in.
23f87bed
MB
5298
5299 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5300
5301 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5302 (when cached
5303 (setq gnus-newsgroup-cached cached))
5304
5305 ;; Suppress duplicates?
5306 (when gnus-suppress-duplicates
5307 (gnus-dup-suppress-articles))
5308
5309 ;; Set the initial limit.
5310 (setq gnus-newsgroup-limit (copy-sequence articles))
5311 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5312 (setq fetched-articles
5313 (mapcar (lambda (headers) (mail-header-number headers))
5314 gnus-newsgroup-headers))
5315 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5316 (setq gnus-newsgroup-unreads
23f87bed
MB
5317 (gnus-sorted-nintersection
5318 gnus-newsgroup-unreads fetched-articles))
5319 (gnus-compute-unseen-list)
5320
eec82323
LMI
5321 ;; Removed marked articles that do not exist.
5322 (gnus-update-missing-marks
23f87bed 5323 (gnus-sorted-difference articles fetched-articles))
eec82323 5324 ;; We might want to build some more threads first.
6748645f
LMI
5325 (when (and gnus-fetch-old-headers
5326 (eq gnus-headers-retrieved-by 'nov))
5327 (if (eq gnus-fetch-old-headers 'invisible)
5328 (gnus-build-all-threads)
5329 (gnus-build-old-threads)))
5330 ;; Let the Gnus agent mark articles as read.
5331 (when gnus-agent
5332 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5333 ;; Remove list identifiers from subject
5334 (when gnus-list-identifiers
5335 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5336 ;; Check whether auto-expire is to be done in this group.
5337 (setq gnus-newsgroup-auto-expire
5338 (gnus-group-auto-expirable-p group))
5339 ;; Set up the article buffer now, if necessary.
5340 (unless gnus-single-article-buffer
5341 (gnus-article-setup-buffer))
5342 ;; First and last article in this newsgroup.
5343 (when gnus-newsgroup-headers
5344 (setq gnus-newsgroup-begin
5345 (mail-header-number (car gnus-newsgroup-headers))
5346 gnus-newsgroup-end
5347 (mail-header-number
5348 (gnus-last-element gnus-newsgroup-headers))))
5349 ;; GROUP is successfully selected.
5350 (or gnus-newsgroup-headers t)))))
5351
23f87bed
MB
5352(defun gnus-compute-unseen-list ()
5353 ;; The `seen' marks are treated specially.
5354 (if (not gnus-newsgroup-seen)
5355 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5356 (setq gnus-newsgroup-unseen
5357 (gnus-inverse-list-range-intersection
5358 gnus-newsgroup-articles gnus-newsgroup-seen))))
5359
5360(defun gnus-summary-display-make-predicate (display)
5361 (require 'gnus-agent)
5362 (when (= (length display) 1)
5363 (setq display (car display)))
5364 (unless gnus-summary-display-cache
5365 (dolist (elem (append '((unread . unread)
5366 (read . read)
5367 (unseen . unseen))
5368 gnus-article-mark-lists))
5369 (push (cons (cdr elem)
5370 (gnus-byte-compile
5371 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5372 gnus-summary-display-cache)))
5373 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5374 (gnus-category-predicate-cache gnus-summary-display-cache))
5375 (gnus-get-predicate display)))
5376
5377;; Uses the dynamically bound `number' variable.
5378(eval-when-compile
5379 (defvar number))
5380(defun gnus-article-marked-p (type &optional article)
5381 (let ((article (or article number)))
5382 (cond
5383 ((eq type 'tick)
5384 (memq article gnus-newsgroup-marked))
5385 ((eq type 'spam)
5386 (memq article gnus-newsgroup-spam-marked))
5387 ((eq type 'unsend)
5388 (memq article gnus-newsgroup-unsendable))
5389 ((eq type 'undownload)
5390 (memq article gnus-newsgroup-undownloaded))
5391 ((eq type 'download)
5392 (memq article gnus-newsgroup-downloadable))
5393 ((eq type 'unread)
5394 (memq article gnus-newsgroup-unreads))
5395 ((eq type 'read)
5396 (memq article gnus-newsgroup-reads))
5397 ((eq type 'dormant)
5398 (memq article gnus-newsgroup-dormant) )
5399 ((eq type 'expire)
5400 (memq article gnus-newsgroup-expirable))
5401 ((eq type 'reply)
5402 (memq article gnus-newsgroup-replied))
5403 ((eq type 'killed)
5404 (memq article gnus-newsgroup-killed))
5405 ((eq type 'bookmark)
5406 (assq article gnus-newsgroup-bookmarks))
5407 ((eq type 'score)
5408 (assq article gnus-newsgroup-scored))
5409 ((eq type 'save)
5410 (memq article gnus-newsgroup-saved))
5411 ((eq type 'cache)
5412 (memq article gnus-newsgroup-cached))
5413 ((eq type 'forward)
5414 (memq article gnus-newsgroup-forwarded))
5415 ((eq type 'seen)
5416 (not (memq article gnus-newsgroup-unseen)))
5417 ((eq type 'recent)
5418 (memq article gnus-newsgroup-recent))
5419 (t t))))
5420
eec82323 5421(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5422 "Find out what articles the user wants to read."
26c9afc3 5423 (let* ((articles
eec82323
LMI
5424 ;; Select all articles if `read-all' is non-nil, or if there
5425 ;; are no unread articles.
5426 (if (or read-all
5427 (and (zerop (length gnus-newsgroup-marked))
5428 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5429 ;; Fetch all if the predicate is non-nil.
5430 gnus-newsgroup-display)
5431 ;; We want to select the headers for all the articles in
5432 ;; the group, so we select either all the active
5433 ;; articles in the group, or (if that's nil), the
5434 ;; articles in the cache.
16409b0b
GM
5435 (or
5436 (gnus-uncompress-range (gnus-active group))
5437 (gnus-cache-articles-in-group group))
23f87bed
MB
5438 ;; Select only the "normal" subset of articles.
5439 (gnus-sorted-nunion
5440 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5441 gnus-newsgroup-unreads)))
eec82323
LMI
5442 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5443 (scored (length scored-list))
5444 (number (length articles))
5445 (marked (+ (length gnus-newsgroup-marked)
5446 (length gnus-newsgroup-dormant)))
5447 (select
5448 (cond
5449 ((numberp read-all)
5450 read-all)
23f87bed
MB
5451 ((numberp gnus-newsgroup-display)
5452 gnus-newsgroup-display)
eec82323
LMI
5453 (t
5454 (condition-case ()
5455 (cond
5456 ((and (or (<= scored marked) (= scored number))
5457 (numberp gnus-large-newsgroup)
5458 (> number gnus-large-newsgroup))
23f87bed
MB
5459 (let* ((cursor-in-echo-area nil)
5460 (initial (gnus-parameter-large-newsgroup-initial
5461 gnus-newsgroup-name))
5462 (input
5463 (read-string
5464 (format
5465 "How many articles from %s (%s %d): "
5466 (gnus-limit-string
5467 (gnus-group-decoded-name gnus-newsgroup-name)
5468 35)
5469 (if initial "max" "default")
5470 number)
5471 (if initial
5472 (cons (number-to-string initial)
5473 0)))))
eec82323
LMI
5474 (if (string-match "^[ \t]*$" input) number input)))
5475 ((and (> scored marked) (< scored number)
5476 (> (- scored number) 20))
5477 (let ((input
5478 (read-string
5479 (format "%s %s (%d scored, %d total): "
5480 "How many articles from"
23f87bed
MB
5481 (gnus-group-decoded-name group)
5482 scored number))))
eec82323
LMI
5483 (if (string-match "^[ \t]*$" input)
5484 number input)))
5485 (t number))
d4dfaa19
DL
5486 (quit
5487 (message "Quit getting the articles to read")
5488 nil))))))
eec82323
LMI
5489 (setq select (if (stringp select) (string-to-number select) select))
5490 (if (or (null select) (zerop select))
5491 select
5492 (if (and (not (zerop scored)) (<= (abs select) scored))
5493 (progn
5494 (setq articles (sort scored-list '<))
5495 (setq number (length articles)))
5496 (setq articles (copy-sequence articles)))
5497
5498 (when (< (abs select) number)
5499 (if (< select 0)
5500 ;; Select the N oldest articles.
5501 (setcdr (nthcdr (1- (abs select)) articles) nil)
5502 ;; Select the N most recent articles.
5503 (setq articles (nthcdr (- number select) articles))))
5504 (setq gnus-newsgroup-unselected
23f87bed 5505 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5506 (when gnus-alter-articles-to-read-function
23f87bed 5507 (setq articles
a1506d29 5508 (sort
16409b0b 5509 (funcall gnus-alter-articles-to-read-function
23f87bed 5510 gnus-newsgroup-name articles)
16409b0b 5511 '<)))
eec82323
LMI
5512 articles)))
5513
5514(defun gnus-killed-articles (killed articles)
5515 (let (out)
5516 (while articles
5517 (when (inline (gnus-member-of-range (car articles) killed))
5518 (push (car articles) out))
5519 (setq articles (cdr articles)))
5520 out))
5521
5522(defun gnus-uncompress-marks (marks)
5523 "Uncompress the mark ranges in MARKS."
5524 (let ((uncompressed '(score bookmark))
5525 out)
5526 (while marks
5527 (if (memq (caar marks) uncompressed)
5528 (push (car marks) out)
5529 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5530 (setq marks (cdr marks)))
5531 out))
5532
23f87bed
MB
5533(defun gnus-article-mark-to-type (mark)
5534 "Return the type of MARK."
5535 (or (cadr (assq mark gnus-article-special-mark-lists))
5536 'list))
5537
5538(defun gnus-article-unpropagatable-p (mark)
5539 "Return whether MARK should be propagated to back end."
5540 (memq mark gnus-article-unpropagated-mark-lists))
5541
eec82323 5542(defun gnus-adjust-marked-articles (info)
16409b0b 5543 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5544 (let* ((marked-lists (gnus-info-marks info))
5545 (active (gnus-active (gnus-info-group info)))
5546 (min (car active))
5547 (max (cdr active))
5548 (types gnus-article-mark-lists)
54506618
MB
5549 marks var articles article mark mark-type
5550 bgn end)
eec82323 5551
23f87bed
MB
5552 (dolist (marks marked-lists)
5553 (setq mark (car marks)
5554 mark-type (gnus-article-mark-to-type mark)
5555 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5556
23f87bed
MB
5557 ;; We set the variable according to the type of the marks list,
5558 ;; and then adjust the marks to a subset of the active articles.
eec82323 5559 (cond
54506618 5560 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5561 ((eq mark-type 'list)
54506618
MB
5562 ;; Simultaneously uncompress and clip to active range
5563 ;; See gnus-uncompress-range for a description of possible marks
5564 (let (l lh)
5565 (if (not (cadr marks))
5566 (set var nil)
5567 (setq articles (if (numberp (cddr marks))
5568 (list (cdr marks))
5569 (cdr marks))
5570 lh (cons nil nil)
5571 l lh)
5572
5573 (while (setq article (pop articles))
5574 (cond ((consp article)
5575 (setq bgn (max (car article) min)
5576 end (min (cdr article) max))
5577 (while (<= bgn end)
5578 (setq l (setcdr l (cons bgn nil))
5579 bgn (1+ bgn))))
5580 ((and (<= min article)
5581 (>= max article))
5582 (setq l (setcdr l (cons article nil))))))
5583 (set var (cdr lh)))))
eec82323 5584 ;; Adjust assocs.
23f87bed
MB
5585 ((eq mark-type 'tuple)
5586 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5587 (when (not (listp (cdr (symbol-value var))))
5588 (set var (list (symbol-value var))))
5589 (when (not (listp (cdr articles)))
5590 (setq articles (list articles)))
eec82323
LMI
5591 (while articles
5592 (when (or (not (consp (setq article (pop articles))))
5593 (< (car article) min)
5594 (> (car article) max))
23f87bed
MB
5595 (set var (delq article (symbol-value var))))))
5596 ;; Adjust ranges (sloppily).
5597 ((eq mark-type 'range)
5598 (cond
5599 ((eq mark 'seen)
5600 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5601 ;; It should be (seen (NUM1 . NUM2)).
5602 (when (numberp (cddr marks))
5603 (setcdr marks (list (cdr marks))))
5604 (setq articles (cdr marks))
5605 (while (and articles
5606 (or (and (consp (car articles))
5607 (> min (cdar articles)))
5608 (and (numberp (car articles))
5609 (> min (car articles)))))
5610 (pop articles))
5611 (set var articles))))))))
eec82323
LMI
5612
5613(defun gnus-update-missing-marks (missing)
6748645f 5614 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 5615 (when missing
23f87bed 5616 (let (var m)
eec82323 5617 ;; Go through all types.
23f87bed
MB
5618 (dolist (elem gnus-article-mark-lists)
5619 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5620 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5621 (when (symbol-value var)
5622 ;; This list has articles. So we delete all missing
5623 ;; articles from it.
5624 (setq m missing)
5625 (while m
5626 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
5627
5628(defun gnus-update-marks ()
5629 "Enter the various lists of marked articles into the newsgroup info list."
5630 (let ((types gnus-article-mark-lists)
5631 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 5632 type list newmarked symbol delta-marks)
eec82323 5633 (when info
16409b0b 5634 ;; Add all marks lists to the list of marks lists.
eec82323 5635 (while (setq type (pop types))
16409b0b
GM
5636 (setq list (symbol-value
5637 (setq symbol
23f87bed 5638 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 5639
16409b0b 5640 (when list
eec82323
LMI
5641 ;; Get rid of the entries of the articles that have the
5642 ;; default score.
5643 (when (and (eq (cdr type) 'score)
5644 gnus-save-score
5645 list)
5646 (let* ((arts list)
5647 (prev (cons nil list))
5648 (all prev))
5649 (while arts
5650 (if (or (not (consp (car arts)))
5651 (= (cdar arts) gnus-summary-default-score))
5652 (setcdr prev (cdr arts))
5653 (setq prev arts))
5654 (setq arts (cdr arts)))
16409b0b
GM
5655 (setq list (cdr all)))))
5656
23f87bed
MB
5657 (when (eq (cdr type) 'seen)
5658 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5659
5660 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 5661 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 5662
23f87bed
MB
5663 (when (and (gnus-check-backend-function
5664 'request-set-mark gnus-newsgroup-name)
5665 (not (gnus-article-unpropagatable-p (cdr type))))
5666 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5667 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5668 (add (gnus-remove-from-range
5669 (gnus-copy-sequence list) old)))
5670 (when add
5671 (push (list add 'add (list (cdr type))) delta-marks))
5672 (when del
5673 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 5674
16409b0b
GM
5675 (when list
5676 (push (cons (cdr type) list) newmarked)))
5677
5678 (when delta-marks
5679 (unless (gnus-check-group gnus-newsgroup-name)
5680 (error "Can't open server for %s" gnus-newsgroup-name))
5681 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 5682
eec82323
LMI
5683 ;; Enter these new marks into the info of the group.
5684 (if (nthcdr 3 info)
5685 (setcar (nthcdr 3 info) newmarked)
5686 ;; Add the marks lists to the end of the info.
5687 (when newmarked
5688 (setcdr (nthcdr 2 info) (list newmarked))))
5689
5690 ;; Cut off the end of the info if there's nothing else there.
5691 (let ((i 5))
5692 (while (and (> i 2)
5693 (not (nth i info)))
5694 (when (nthcdr (decf i) info)
5695 (setcdr (nthcdr i info) nil)))))))
5696
5697(defun gnus-set-mode-line (where)
16409b0b 5698 "Set the mode line of the article or summary buffers.
eec82323
LMI
5699If WHERE is `summary', the summary mode line format will be used."
5700 ;; Is this mode line one we keep updated?
16409b0b
GM
5701 (when (and (memq where gnus-updated-mode-lines)
5702 (symbol-value
5703 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323
LMI
5704 (let (mode-string)
5705 (save-excursion
5706 ;; We evaluate this in the summary buffer since these
5707 ;; variables are buffer-local to that buffer.
5708 (set-buffer gnus-summary-buffer)
23f87bed 5709 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
5710 ;; below.
5711 (let* ((mformat (symbol-value
5712 (intern
5713 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
5714 (gnus-tmp-group-name (gnus-mode-string-quote
5715 (gnus-group-decoded-name
5716 gnus-newsgroup-name)))
eec82323
LMI
5717 (gnus-tmp-article-number (or gnus-current-article 0))
5718 (gnus-tmp-unread gnus-newsgroup-unreads)
5719 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5720 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5721 (gnus-tmp-unread-and-unselected
5722 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5723 (zerop gnus-tmp-unselected))
5724 "")
5725 ((zerop gnus-tmp-unselected)
5726 (format "{%d more}" gnus-tmp-unread-and-unticked))
5727 (t (format "{%d(+%d) more}"
5728 gnus-tmp-unread-and-unticked
5729 gnus-tmp-unselected))))
5730 (gnus-tmp-subject
5731 (if (and gnus-current-headers
5732 (vectorp gnus-current-headers))
5733 (gnus-mode-string-quote
5734 (mail-header-subject gnus-current-headers))
5735 ""))
5736 bufname-length max-len
23f87bed 5737 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
5738 (setq mode-string (eval mformat))
5739 (setq bufname-length (if (string-match "%b" mode-string)
5740 (- (length
5741 (buffer-name
5742 (if (eq where 'summary)
5743 nil
5744 (get-buffer gnus-article-buffer))))
5745 2)
5746 0))
5747 (setq max-len (max 4 (if gnus-mode-non-string-length
5748 (- (window-width)
5749 gnus-mode-non-string-length
5750 bufname-length)
5751 (length mode-string))))
5752 ;; We might have to chop a bit of the string off...
5753 (when (> (length mode-string) max-len)
5754 (setq mode-string
16409b0b 5755 (concat (truncate-string-to-width mode-string (- max-len 3))
eec82323
LMI
5756 "...")))
5757 ;; Pad the mode string a bit.
5758 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5759 ;; Update the mode line.
5760 (setq mode-line-buffer-identification
5761 (gnus-mode-line-buffer-identification (list mode-string)))
5762 (set-buffer-modified-p t))))
5763
5764(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5765 "Go through the HEADERS list and add all Xrefs to a hash table.
5766The resulting hash table is returned, or nil if no Xrefs were found."
5767 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5768 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5769 (xref-hashtb (gnus-make-hashtable))
5770 start group entry number xrefs header)
5771 (while headers
5772 (setq header (pop headers))
5773 (when (and (setq xrefs (mail-header-xref header))
5774 (not (memq (setq number (mail-header-number header))
5775 unreads)))
5776 (setq start 0)
5777 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5778 (setq start (match-end 0))
5779 (setq group (if prefix
5780 (concat prefix (substring xrefs (match-beginning 1)
5781 (match-end 1)))
5782 (substring xrefs (match-beginning 1) (match-end 1))))
5783 (setq number
e9bd5782 5784 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
5785 (match-end 2))))
5786 (if (setq entry (gnus-gethash group xref-hashtb))
5787 (setcdr entry (cons number (cdr entry)))
5788 (gnus-sethash group (cons number nil) xref-hashtb)))))
5789 (and start xref-hashtb)))
5790
5791(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5792 "Look through all the headers and mark the Xrefs as read."
5793 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5794 name entry info xref-hashtb idlist method nth4)
5795 (save-excursion
5796 (set-buffer gnus-group-buffer)
5797 (when (setq xref-hashtb
5798 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5799 (mapatoms
5800 (lambda (group)
5801 (unless (string= from-newsgroup (setq name (symbol-name group)))
5802 (setq idlist (symbol-value group))
5803 ;; Dead groups are not updated.
5804 (and (prog1
5805 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5806 info (nth 2 entry))
5807 (when (stringp (setq nth4 (gnus-info-method info)))
5808 (setq nth4 (gnus-server-to-method nth4))))
5809 ;; Only do the xrefs if the group has the same
5810 ;; select method as the group we have just read.
5811 (or (gnus-methods-equal-p
5812 nth4 (gnus-find-method-for-group from-newsgroup))
5813 virtual
5814 (equal nth4 (setq method (gnus-find-method-for-group
5815 from-newsgroup)))
5816 (and (equal (car nth4) (car method))
5817 (equal (nth 1 nth4) (nth 1 method))))
5818 gnus-use-cross-reference
5819 (or (not (eq gnus-use-cross-reference t))
5820 virtual
5821 ;; Only do cross-references on subscribed
5822 ;; groups, if that is what is wanted.
5823 (<= (gnus-info-level info) gnus-level-subscribed))
5824 (gnus-group-make-articles-read name idlist))))
5825 xref-hashtb)))))
5826
6748645f
LMI
5827(defun gnus-compute-read-articles (group articles)
5828 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5829 (info (nth 2 entry))
5830 (active (gnus-active group))
5831 ninfo)
5832 (when entry
16409b0b 5833 ;; First peel off all invalid article numbers.
6748645f
LMI
5834 (when active
5835 (let ((ids articles)
5836 id first)
5837 (while (setq id (pop ids))
5838 (when (and first (> id (cdr active)))
5839 ;; We'll end up in this situation in one particular
5840 ;; obscure situation. If you re-scan a group and get
5841 ;; a new article that is cross-posted to a different
5842 ;; group that has not been re-scanned, you might get
5843 ;; crossposted article that has a higher number than
5844 ;; Gnus believes possible. So we re-activate this
5845 ;; group as well. This might mean doing the
5846 ;; crossposting thingy will *increase* the number
5847 ;; of articles in some groups. Tsk, tsk.
5848 (setq active (or (gnus-activate-group group) active)))
5849 (when (or (> id (cdr active))
5850 (< id (car active)))
5851 (setq articles (delq id articles))))))
5852 ;; If the read list is nil, we init it.
5853 (if (and active
5854 (null (gnus-info-read info))
5855 (> (car active) 1))
5856 (setq ninfo (cons 1 (1- (car active))))
5857 (setq ninfo (gnus-info-read info)))
5858 ;; Then we add the read articles to the range.
5859 (gnus-add-to-range
5860 ninfo (setq articles (sort articles '<))))))
5861
eec82323
LMI
5862(defun gnus-group-make-articles-read (group articles)
5863 "Update the info of GROUP to say that ARTICLES are read."
5864 (let* ((num 0)
5865 (entry (gnus-gethash group gnus-newsrc-hashtb))
5866 (info (nth 2 entry))
5867 (active (gnus-active group))
5868 range)
6748645f
LMI
5869 (when entry
5870 (setq range (gnus-compute-read-articles group articles))
5871 (save-excursion
5872 (set-buffer gnus-group-buffer)
5873 (gnus-undo-register
5874 `(progn
5875 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5876 (gnus-info-set-read ',info ',(gnus-info-read info))
5877 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 5878 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
5879 (gnus-group-update-group ,group t))))
5880 ;; Add the read articles to the range.
5881 (gnus-info-set-read info range)
23f87bed 5882 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
5883 ;; Then we have to re-compute how many unread
5884 ;; articles there are in this group.
5885 (when active
5886 (cond
5887 ((not range)
5888 (setq num (- (1+ (cdr active)) (car active))))
5889 ((not (listp (cdr range)))
5890 (setq num (- (cdr active) (- (1+ (cdr range))
5891 (car range)))))
5892 (t
5893 (while range
5894 (if (numberp (car range))
5895 (setq num (1+ num))
5896 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5897 (setq range (cdr range)))
5898 (setq num (- (cdr active) num))))
5899 ;; Update the number of unread articles.
5900 (setcar entry num)
5901 ;; Update the group buffer.
23f87bed
MB
5902 (unless (gnus-ephemeral-group-p group)
5903 (gnus-group-update-group group t))))))
eec82323 5904
eec82323
LMI
5905(defvar gnus-newsgroup-none-id 0)
5906
5907(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5908 (let ((cur nntp-server-buffer)
5909 (dependencies
5910 (or dependencies
5911 (save-excursion (set-buffer gnus-summary-buffer)
5912 gnus-newsgroup-dependencies)))
16409b0b
GM
5913 headers id end ref
5914 (mail-parse-charset gnus-newsgroup-charset)
5915 (mail-parse-ignored-charsets
5916 (save-excursion (condition-case nil
5917 (set-buffer gnus-summary-buffer)
5918 (error))
5919 gnus-newsgroup-ignored-charsets)))
eec82323
LMI
5920 (save-excursion
5921 (set-buffer nntp-server-buffer)
5922 ;; Translate all TAB characters into SPACE characters.
5923 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 5924 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 5925 (ietf-drums-unfold-fws)
6748645f 5926 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 5927 (let ((case-fold-search t)
6748645f 5928 in-reply-to header p lines chars)
eec82323
LMI
5929 (goto-char (point-min))
5930 ;; Search to the beginning of the next header. Error messages
5931 ;; do not begin with 2 or 3.
5932 (while (re-search-forward "^[23][0-9]+ " nil t)
5933 (setq id nil
5934 ref nil)
5935 ;; This implementation of this function, with nine
5936 ;; search-forwards instead of the one re-search-forward and
5937 ;; a case (which basically was the old function) is actually
5938 ;; about twice as fast, even though it looks messier. You
5939 ;; can't have everything, I guess. Speed and elegance
5940 ;; doesn't always go hand in hand.
5941 (setq
5942 header
5943 (vector
5944 ;; Number.
5945 (prog1
5946 (read cur)
5947 (end-of-line)
5948 (setq p (point))
5949 (narrow-to-region (point)
5950 (or (and (search-forward "\n.\n" nil t)
5951 (- (point) 2))
5952 (point))))
5953 ;; Subject.
5954 (progn
5955 (goto-char p)
23f87bed 5956 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
5957 (funcall gnus-decode-encoded-word-function
5958 (nnheader-header-value))
2bd3dcae 5959 "(none)"))
eec82323
LMI
5960 ;; From.
5961 (progn
5962 (goto-char p)
23f87bed 5963 (if (search-forward "\nfrom:" nil t)
343d6628 5964 (funcall gnus-decode-encoded-address-function
16409b0b 5965 (nnheader-header-value))
2bd3dcae 5966 "(nobody)"))
eec82323
LMI
5967 ;; Date.
5968 (progn
5969 (goto-char p)
23f87bed 5970 (if (search-forward "\ndate:" nil t)
eec82323
LMI
5971 (nnheader-header-value) ""))
5972 ;; Message-ID.
5973 (progn
5974 (goto-char p)
6748645f
LMI
5975 (setq id (if (re-search-forward
5976 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5977 ;; We do it this way to make sure the Message-ID
5978 ;; is (somewhat) syntactically valid.
5979 (buffer-substring (match-beginning 1)
5980 (match-end 1))
eec82323
LMI
5981 ;; If there was no message-id, we just fake one
5982 ;; to make subsequent routines simpler.
5983 (nnheader-generate-fake-message-id))))
5984 ;; References.
5985 (progn
5986 (goto-char p)
23f87bed 5987 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
5988 (progn
5989 (setq end (point))
5990 (prog1
5991 (nnheader-header-value)
5992 (setq ref
5993 (buffer-substring
5994 (progn
5995 (end-of-line)
5996 (search-backward ">" end t)
5997 (1+ (point)))
5998 (progn
5999 (search-backward "<" end t)
6000 (point))))))
6001 ;; Get the references from the in-reply-to header if there
6002 ;; were no references and the in-reply-to header looks
6003 ;; promising.
23f87bed 6004 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6005 (setq in-reply-to (nnheader-header-value))
6006 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6007 (let (ref2)
6008 (setq ref (substring in-reply-to (match-beginning 0)
6009 (match-end 0)))
6010 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6011 (setq ref2 (substring in-reply-to (match-beginning 0)
6012 (match-end 0)))
6013 (when (> (length ref2) (length ref))
6014 (setq ref ref2)))
6015 ref)
eec82323
LMI
6016 (setq ref nil))))
6017 ;; Chars.
6748645f
LMI
6018 (progn
6019 (goto-char p)
6020 (if (search-forward "\nchars: " nil t)
6021 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6022 chars -1)
6023 -1))
eec82323
LMI
6024 ;; Lines.
6025 (progn
6026 (goto-char p)
6027 (if (search-forward "\nlines: " nil t)
a8151ef7 6028 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6029 lines -1)
6030 -1))
eec82323
LMI
6031 ;; Xref.
6032 (progn
6033 (goto-char p)
23f87bed 6034 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6035 (nnheader-header-value)))
6036 ;; Extra.
6037 (when gnus-extra-headers
6038 (let ((extra gnus-extra-headers)
6039 out)
6040 (while extra
6041 (goto-char p)
6042 (when (search-forward
23f87bed 6043 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6044 (push (cons (car extra) (nnheader-header-value))
6045 out))
6046 (pop extra))
6047 out))))
eec82323
LMI
6048 (when (equal id ref)
6049 (setq ref nil))
6748645f
LMI
6050
6051 (when gnus-alter-header-function
6052 (funcall gnus-alter-header-function header)
6053 (setq id (mail-header-id header)
6054 ref (gnus-parent-id (mail-header-references header))))
6055
6056 (when (setq header
6057 (gnus-dependencies-add-header
6058 header dependencies force-new))
eec82323
LMI
6059 (push header headers))
6060 (goto-char (point-max))
6061 (widen))
6062 (nreverse headers)))))
6063
eec82323
LMI
6064;; Goes through the xover lines and returns a list of vectors
6065(defun gnus-get-newsgroup-headers-xover (sequence &optional
6066 force-new dependencies
6067 group also-fetch-heads)
16409b0b
GM
6068 "Parse the news overview data in the server buffer.
6069Return a list of headers that match SEQUENCE (see
6070`nntp-retrieve-headers')."
eec82323
LMI
6071 ;; Get the Xref when the users reads the articles since most/some
6072 ;; NNTP servers do not include Xrefs when using XOVER.
6073 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6074 (let ((mail-parse-charset gnus-newsgroup-charset)
6075 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6076 (cur nntp-server-buffer)
eec82323 6077 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6078 (allp (cond
6079 ((eq gnus-read-all-available-headers t)
6080 t)
14e6dc54
MB
6081 ((and (stringp gnus-read-all-available-headers)
6082 group)
23f87bed
MB
6083 (string-match gnus-read-all-available-headers group))
6084 (t
6085 nil)))
eec82323
LMI
6086 number headers header)
6087 (save-excursion
6088 (set-buffer nntp-server-buffer)
16409b0b 6089 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6090 ;; Allow the user to mangle the headers before parsing them.
6748645f 6091 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6092 (goto-char (point-min))
23f87bed
MB
6093 (gnus-parse-without-error
6094 (while (and (or sequence allp)
6095 (not (eobp)))
6096 (setq number (read cur))
6097 (when (not allp)
6098 (while (and sequence
6099 (< (car sequence) number))
6100 (setq sequence (cdr sequence))))
6101 (when (and (or allp
6102 (and sequence
6103 (eq number (car sequence))))
6104 (progn
6105 (setq sequence (cdr sequence))
6106 (setq header (inline
6107 (gnus-nov-parse-line
6108 number dependencies force-new)))))
6109 (push header headers))
6110 (forward-line 1)))
eec82323
LMI
6111 ;; A common bug in inn is that if you have posted an article and
6112 ;; then retrieves the active file, it will answer correctly --
6113 ;; the new article is included. However, a NOV entry for the
6114 ;; article may not have been generated yet, so this may fail.
6115 ;; We work around this problem by retrieving the last few
6116 ;; headers using HEAD.
6117 (if (or (not also-fetch-heads)
6118 (not sequence))
6119 ;; We (probably) got all the headers.
6120 (nreverse headers)
6121 (let ((gnus-nov-is-evil t))
6122 (nconc
6123 (nreverse headers)
23f87bed 6124 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6125 (gnus-get-newsgroup-headers))))))))
6126
6127(defun gnus-article-get-xrefs ()
6128 "Fill in the Xref value in `gnus-current-headers', if necessary.
6129This is meant to be called in `gnus-article-internal-prepare-hook'."
6130 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6131 gnus-current-headers)))
6132 (or (not gnus-use-cross-reference)
6133 (not headers)
6134 (and (mail-header-xref headers)
6135 (not (string= (mail-header-xref headers) "")))
6136 (let ((case-fold-search t)
6137 xref)
6138 (save-restriction
6139 (nnheader-narrow-to-headers)
6140 (goto-char (point-min))
16409b0b
GM
6141 (when (or (and (not (eobp))
6142 (eq (downcase (char-after)) ?x)
eec82323
LMI
6143 (looking-at "Xref:"))
6144 (search-forward "\nXref:" nil t))
6145 (goto-char (1+ (match-end 0)))
23f87bed 6146 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
eec82323
LMI
6147 (mail-header-set-xref headers xref)))))))
6148
6149(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6150 "Find article ID and insert the summary line for that article.
6151OLD-HEADER can either be a header or a line number to insert
6152the subject line on."
6153 (let* ((line (and (numberp old-header) old-header))
6154 (old-header (and (vectorp old-header) old-header))
6155 (header (cond ((and old-header use-old-header)
16409b0b
GM
6156 old-header)
6157 ((and (numberp id)
6158 (gnus-number-to-header id))
6159 (gnus-number-to-header id))
6160 (t
6161 (gnus-read-header id))))
6162 (number (and (numberp id) id))
6163 d)
eec82323
LMI
6164 (when header
6165 ;; Rebuild the thread that this article is part of and go to the
6166 ;; article we have fetched.
6167 (when (and (not gnus-show-threads)
6168 old-header)
6748645f
LMI
6169 (when (and number
6170 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6171 (goto-char (gnus-data-pos d))
6172 (gnus-data-remove
6173 number
6174 (- (gnus-point-at-bol)
6175 (prog1
6176 (1+ (gnus-point-at-eol))
6177 (gnus-delete-line))))))
23f87bed
MB
6178 ;; Remove list identifiers from subject.
6179 (when gnus-list-identifiers
6180 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6181 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6182 (when old-header
6183 (mail-header-set-number header (mail-header-number old-header)))
6184 (setq gnus-newsgroup-sparse
6185 (delq (setq number (mail-header-number header))
6186 gnus-newsgroup-sparse))
6187 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6188 (push number gnus-newsgroup-limit)
6189 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6190 (gnus-summary-goto-subject number nil t))
6191 (when (and (numberp number)
6192 (> number 0))
6193 ;; We have to update the boundaries even if we can't fetch the
6194 ;; article if ID is a number -- so that the next `P' or `N'
6195 ;; command will fetch the previous (or next) article even
6196 ;; if the one we tried to fetch this time has been canceled.
6197 (when (> number gnus-newsgroup-end)
6198 (setq gnus-newsgroup-end number))
6199 (when (< number gnus-newsgroup-begin)
6200 (setq gnus-newsgroup-begin number))
6201 (setq gnus-newsgroup-unselected
6202 (delq number gnus-newsgroup-unselected)))
6203 ;; Report back a success?
6204 (and header (mail-header-number header))))
6205
6206;;; Process/prefix in the summary buffer
6207
6208(defun gnus-summary-work-articles (n)
6748645f
LMI
6209 "Return a list of articles to be worked upon.
6210The prefix argument, the list of process marked articles, and the
6211current article will be taken into consideration."
6212 (save-excursion
6213 (set-buffer gnus-summary-buffer)
6214 (cond
6215 (n
6216 ;; A numerical prefix has been given.
6217 (setq n (prefix-numeric-value n))
6218 (let ((backward (< n 0))
6219 (n (abs (prefix-numeric-value n)))
6220 articles article)
6221 (save-excursion
6222 (while
6223 (and (> n 0)
6224 (push (setq article (gnus-summary-article-number))
6225 articles)
6226 (if backward
6227 (gnus-summary-find-prev nil article)
6228 (gnus-summary-find-next nil article)))
6229 (decf n)))
6230 (nreverse articles)))
6231 ((and (gnus-region-active-p) (mark))
6232 (message "region active")
6233 ;; Work on the region between point and mark.
6234 (let ((max (max (point) (mark)))
6235 articles article)
6236 (save-excursion
7dafe00b 6237 (goto-char (min (point) (mark)))
6748645f
LMI
6238 (while
6239 (and
6240 (push (setq article (gnus-summary-article-number)) articles)
6241 (gnus-summary-find-next nil article)
6242 (< (point) max)))
6243 (nreverse articles))))
6244 (gnus-newsgroup-processable
6245 ;; There are process-marked articles present.
6246 ;; Save current state.
6247 (gnus-summary-save-process-mark)
6248 ;; Return the list.
6249 (reverse gnus-newsgroup-processable))
6250 (t
6251 ;; Just return the current article.
6252 (list (gnus-summary-article-number))))))
6253
6254(defmacro gnus-summary-iterate (arg &rest forms)
6255 "Iterate over the process/prefixed articles and do FORMS.
6256ARG is the interactive prefix given to the command. FORMS will be
6257executed with point over the summary line of the articles."
6258 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6259 `(let ((,articles (gnus-summary-work-articles ,arg)))
6260 (while ,articles
6261 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6262 ,@forms
6263 (pop ,articles)))))
6748645f
LMI
6264
6265(put 'gnus-summary-iterate 'lisp-indent-function 1)
6266(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6267
6268(defun gnus-summary-save-process-mark ()
6269 "Push the current set of process marked articles on the stack."
6270 (interactive)
6271 (push (copy-sequence gnus-newsgroup-processable)
6272 gnus-newsgroup-process-stack))
6273
6274(defun gnus-summary-kill-process-mark ()
6275 "Push the current set of process marked articles on the stack and unmark."
6276 (interactive)
6277 (gnus-summary-save-process-mark)
6278 (gnus-summary-unmark-all-processable))
6279
6280(defun gnus-summary-yank-process-mark ()
6281 "Pop the last process mark state off the stack and restore it."
6282 (interactive)
6283 (unless gnus-newsgroup-process-stack
6284 (error "Empty mark stack"))
6285 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6286
6287(defun gnus-summary-process-mark-set (set)
6288 "Make SET into the current process marked articles."
6289 (gnus-summary-unmark-all-processable)
6290 (while set
6291 (gnus-summary-set-process-mark (pop set))))
6292
6293;;; Searching and stuff
6294
6295(defun gnus-summary-search-group (&optional backward use-level)
6296 "Search for next unread newsgroup.
6297If optional argument BACKWARD is non-nil, search backward instead."
6298 (save-excursion
6299 (set-buffer gnus-group-buffer)
6300 (when (gnus-group-search-forward
6301 backward nil (if use-level (gnus-group-group-level) nil))
6302 (gnus-group-group-name))))
6303
6304(defun gnus-summary-best-group (&optional exclude-group)
6305 "Find the name of the best unread group.
6306If EXCLUDE-GROUP, do not go to this group."
6307 (save-excursion
6308 (set-buffer gnus-group-buffer)
6309 (save-excursion
6310 (gnus-group-best-unread-group exclude-group))))
6311
23f87bed
MB
6312(defun gnus-summary-find-next (&optional unread article backward)
6313 (if backward
6314 (gnus-summary-find-prev unread article)
eec82323
LMI
6315 (let* ((dummy (gnus-summary-article-intangible-p))
6316 (article (or article (gnus-summary-article-number)))
23f87bed 6317 (data (gnus-data-find-list article))
eec82323
LMI
6318 result)
6319 (when (and (not dummy)
6320 (or (not gnus-summary-check-current)
6321 (not unread)
23f87bed
MB
6322 (not (gnus-data-unread-p (car data)))))
6323 (setq data (cdr data)))
eec82323
LMI
6324 (when (setq result
6325 (if unread
6326 (progn
23f87bed
MB
6327 (while data
6328 (unless (memq (gnus-data-number (car data))
6329 (cond
6330 ((eq gnus-auto-goto-ignores
6331 'always-undownloaded)
6332 gnus-newsgroup-undownloaded)
6333 (gnus-plugged
6334 nil)
6335 ((eq gnus-auto-goto-ignores
6336 'unfetched)
6337 gnus-newsgroup-unfetched)
6338 ((eq gnus-auto-goto-ignores
6339 'undownloaded)
6340 gnus-newsgroup-undownloaded)))
6341 (when (gnus-data-unread-p (car data))
6342 (setq result (car data)
6343 data nil)))
6344 (setq data (cdr data)))
eec82323 6345 result)
23f87bed 6346 (car data)))
eec82323
LMI
6347 (goto-char (gnus-data-pos result))
6348 (gnus-data-number result)))))
6349
6350(defun gnus-summary-find-prev (&optional unread article)
6351 (let* ((eobp (eobp))
6352 (article (or article (gnus-summary-article-number)))
23f87bed 6353 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6354 result)
6355 (when (and (not eobp)
6356 (or (not gnus-summary-check-current)
6357 (not unread)
23f87bed
MB
6358 (not (gnus-data-unread-p (car data)))))
6359 (setq data (cdr data)))
eec82323
LMI
6360 (when (setq result
6361 (if unread
6362 (progn
23f87bed
MB
6363 (while data
6364 (unless (memq (gnus-data-number (car data))
6365 (cond
6366 ((eq gnus-auto-goto-ignores
6367 'always-undownloaded)
6368 gnus-newsgroup-undownloaded)
6369 (gnus-plugged
6370 nil)
6371 ((eq gnus-auto-goto-ignores
6372 'unfetched)
6373 gnus-newsgroup-unfetched)
6374 ((eq gnus-auto-goto-ignores
6375 'undownloaded)
6376 gnus-newsgroup-undownloaded)))
6377 (when (gnus-data-unread-p (car data))
6378 (setq result (car data)
6379 data nil)))
6380 (setq data (cdr data)))
eec82323 6381 result)
23f87bed 6382 (car data)))
eec82323
LMI
6383 (goto-char (gnus-data-pos result))
6384 (gnus-data-number result))))
6385
6386(defun gnus-summary-find-subject (subject &optional unread backward article)
6387 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6388 (article (or article (gnus-summary-article-number)))
6389 (articles (gnus-data-list backward))
6390 (arts (gnus-data-find-list article articles))
6391 result)
6392 (when (or (not gnus-summary-check-current)
6393 (not unread)
6394 (not (gnus-data-unread-p (car arts))))
6395 (setq arts (cdr arts)))
6396 (while arts
6397 (and (or (not unread)
6398 (gnus-data-unread-p (car arts)))
6399 (vectorp (gnus-data-header (car arts)))
6400 (gnus-subject-equal
6401 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6402 (setq result (car arts)
6403 arts nil))
6404 (setq arts (cdr arts)))
6405 (and result
6406 (goto-char (gnus-data-pos result))
6407 (gnus-data-number result))))
6408
6409(defun gnus-summary-search-forward (&optional unread subject backward)
6410 "Search forward for an article.
6411If UNREAD, look for unread articles. If SUBJECT, look for
6412articles with that subject. If BACKWARD, search backward instead."
6413 (cond (subject (gnus-summary-find-subject subject unread backward))
6414 (backward (gnus-summary-find-prev unread))
6415 (t (gnus-summary-find-next unread))))
6416
6417(defun gnus-recenter (&optional n)
6418 "Center point in window and redisplay frame.
6419Also do horizontal recentering."
6420 (interactive "P")
6421 (when (and gnus-auto-center-summary
6422 (not (eq gnus-auto-center-summary 'vertical)))
6423 (gnus-horizontal-recenter))
6424 (recenter n))
6425
6426(defun gnus-summary-recenter ()
6427 "Center point in the summary window.
6428If `gnus-auto-center-summary' is nil, or the article buffer isn't
6429displayed, no centering will be performed."
6430 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6431 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6432 (interactive)
23f87bed
MB
6433 ;; The user has to want it.
6434 (when gnus-auto-center-summary
6435 (let* ((top (cond ((< (window-height) 4) 0)
6436 ((< (window-height) 7) 1)
6437 (t (if (numberp gnus-auto-center-summary)
6438 gnus-auto-center-summary
6439 2))))
6440 (height (1- (window-height)))
6441 (bottom (save-excursion (goto-char (point-max))
6442 (forward-line (- height))
6443 (point)))
6444 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6445 (when (get-buffer-window gnus-article-buffer)
6446 ;; Only do recentering when the article buffer is displayed,
6447 ;; Set the window start to either `bottom', which is the biggest
6448 ;; possible valid number, or the second line from the top,
6449 ;; whichever is the least.
db7ebd73
MB
6450 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6451 (if (> bottom top-pos)
6452 ;; Keep the second line from the top visible
6453 (set-window-start window top-pos t)
6454 ;; Try to keep the bottom line visible; if it's partially
6455 ;; obscured, either scroll one more line to make it fully
6456 ;; visible, or revert to using TOP-POS.
6457 (save-excursion
6458 (goto-char (point-max))
6459 (forward-line -1)
6460 (let ((last-line-start (point)))
6461 (goto-char bottom)
6462 (set-window-start window (point) t)
6463 (when (not (pos-visible-in-window-p last-line-start window))
6464 (forward-line 1)
6465 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6466 ;; Do horizontal recentering while we're at it.
6467 (when (and (get-buffer-window (current-buffer) t)
6468 (not (eq gnus-auto-center-summary 'vertical)))
6469 (let ((selected (selected-window)))
6470 (select-window (get-buffer-window (current-buffer) t))
6471 (gnus-summary-position-point)
6472 (gnus-horizontal-recenter)
6473 (select-window selected))))))
6474
6475(defun gnus-summary-jump-to-group (newsgroup)
6476 "Move point to NEWSGROUP in group mode buffer."
6477 ;; Keep update point of group mode buffer if visible.
6478 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6479 (save-window-excursion
6480 ;; Take care of tree window mode.
6481 (when (get-buffer-window gnus-group-buffer)
6482 (pop-to-buffer gnus-group-buffer))
6483 (gnus-group-jump-to-group newsgroup))
6484 (save-excursion
6485 ;; Take care of tree window mode.
6486 (if (get-buffer-window gnus-group-buffer)
6487 (pop-to-buffer gnus-group-buffer)
6488 (set-buffer gnus-group-buffer))
6489 (gnus-group-jump-to-group newsgroup))))
6490
6491;; This function returns a list of article numbers based on the
6492;; difference between the ranges of read articles in this group and
6493;; the range of active articles.
6494(defun gnus-list-of-unread-articles (group)
6495 (let* ((read (gnus-info-read (gnus-get-info group)))
6496 (active (or (gnus-active group) (gnus-activate-group group)))
6497 (last (cdr active))
6498 first nlast unread)
6499 ;; If none are read, then all are unread.
6500 (if (not read)
6501 (setq first (car active))
6502 ;; If the range of read articles is a single range, then the
6503 ;; first unread article is the article after the last read
6504 ;; article. Sounds logical, doesn't it?
16409b0b
GM
6505 (if (and (not (listp (cdr read)))
6506 (or (< (car read) (car active))
6507 (progn (setq read (list read))
6508 nil)))
6748645f 6509 (setq first (max (car active) (1+ (cdr read))))
eec82323
LMI
6510 ;; `read' is a list of ranges.
6511 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6512 (caar read)))
6513 1)
6748645f 6514 (setq first (car active)))
eec82323
LMI
6515 (while read
6516 (when first
6517 (while (< first nlast)
54506618
MB
6518 (setq unread (cons first unread)
6519 first (1+ first))))
eec82323
LMI
6520 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6521 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6522 (setq read (cdr read)))))
6523 ;; And add the last unread articles.
6524 (while (<= first last)
54506618
MB
6525 (setq unread (cons first unread)
6526 first (1+ first)))
eec82323 6527 ;; Return the list of unread articles.
6748645f 6528 (delq 0 (nreverse unread))))
eec82323
LMI
6529
6530(defun gnus-list-of-read-articles (group)
6531 "Return a list of unread, unticked and non-dormant articles."
6532 (let* ((info (gnus-get-info group))
6533 (marked (gnus-info-marks info))
6534 (active (gnus-active group)))
6535 (and info active
23f87bed
MB
6536 (gnus-list-range-difference
6537 (gnus-list-range-difference
6538 (gnus-sorted-complement
6539 (gnus-uncompress-range active)
6540 (gnus-list-of-unread-articles group))
6541 (cdr (assq 'dormant marked)))
6542 (cdr (assq 'tick marked))))))
eec82323 6543
54506618
MB
6544;; This function returns a sequence of article numbers based on the
6545;; difference between the ranges of read articles in this group and
6546;; the range of active articles.
6547(defun gnus-sequence-of-unread-articles (group)
6548 (let* ((read (gnus-info-read (gnus-get-info group)))
6549 (active (or (gnus-active group) (gnus-activate-group group)))
6550 (last (cdr active))
6551 first nlast unread)
6552 ;; If none are read, then all are unread.
6553 (if (not read)
6554 (setq first (car active))
6555 ;; If the range of read articles is a single range, then the
6556 ;; first unread article is the article after the last read
6557 ;; article. Sounds logical, doesn't it?
6558 (if (and (not (listp (cdr read)))
6559 (or (< (car read) (car active))
6560 (progn (setq read (list read))
6561 nil)))
6562 (setq first (max (car active) (1+ (cdr read))))
6563 ;; `read' is a list of ranges.
6564 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6565 (caar read)))
6566 1)
6567 (setq first (car active)))
6568 (while read
6569 (when first
6570 (push (cons first nlast) unread))
6571 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6572 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6573 (setq read (cdr read)))))
6574 ;; And add the last unread articles.
ba0226dd
MB
6575 (cond ((not (and first last))
6576 nil)
6577 ((< first last)
6578 (push (cons first last) unread))
6579 ((= first last)
6580 (push first unread)))
54506618
MB
6581 ;; Return the sequence of unread articles.
6582 (delq 0 (nreverse unread))))
6583
eec82323
LMI
6584;; Various summary commands
6585
6748645f
LMI
6586(defun gnus-summary-select-article-buffer ()
6587 "Reconfigure windows to show article buffer."
6588 (interactive)
6589 (if (not (gnus-buffer-live-p gnus-article-buffer))
6590 (error "There is no article buffer for this summary buffer")
6591 (gnus-configure-windows 'article)
6592 (select-window (get-buffer-window gnus-article-buffer))))
6593
eec82323
LMI
6594(defun gnus-summary-universal-argument (arg)
6595 "Perform any operation on all articles that are process/prefixed."
6596 (interactive "P")
eec82323
LMI
6597 (let ((articles (gnus-summary-work-articles arg))
6598 func article)
6599 (if (eq
6600 (setq
6601 func
6602 (key-binding
6603 (read-key-sequence
6604 (substitute-command-keys
16409b0b 6605 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
6606 'undefined)
6607 (gnus-error 1 "Undefined key")
6608 (save-excursion
6609 (while articles
6610 (gnus-summary-goto-subject (setq article (pop articles)))
6611 (let (gnus-newsgroup-processable)
6612 (command-execute func))
6613 (gnus-summary-remove-process-mark article)))))
6614 (gnus-summary-position-point))
6615
6616(defun gnus-summary-toggle-truncation (&optional arg)
6617 "Toggle truncation of summary lines.
23f87bed 6618With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
6619 (interactive "P")
6620 (setq truncate-lines
6621 (if (null arg) (not truncate-lines)
6622 (> (prefix-numeric-value arg) 0)))
6623 (redraw-display))
6624
23f87bed
MB
6625(defun gnus-summary-find-for-reselect ()
6626 "Return the number of an article to stay on across a reselect.
6627The current article is considered, then following articles, then previous
6628articles. An article is sought which is not cancelled and isn't a temporary
6629insertion from another group. If there's no such then return a dummy 0."
6630 (let (found)
6631 (dolist (rev '(nil t))
6632 (unless found ; don't demand the reverse list if we don't need it
6633 (let ((data (gnus-data-find-list
6634 (gnus-summary-article-number) (gnus-data-list rev))))
6635 (while (and data (not found))
6636 (if (and (< 0 (gnus-data-number (car data)))
6637 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6638 (setq found (gnus-data-number (car data))))
6639 (setq data (cdr data))))))
6640 (or found 0)))
6641
eec82323
LMI
6642(defun gnus-summary-reselect-current-group (&optional all rescan)
6643 "Exit and then reselect the current newsgroup.
6644The prefix argument ALL means to select all articles."
6645 (interactive "P")
eec82323
LMI
6646 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6647 (error "Ephemeral groups can't be reselected"))
23f87bed 6648 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
6649 (group gnus-newsgroup-name))
6650 (setq gnus-newsgroup-begin nil)
23f87bed 6651 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
6652 ;; We have to adjust the point of group mode buffer because
6653 ;; point was moved to the next unread newsgroup by exiting.
6654 (gnus-summary-jump-to-group group)
6655 (when rescan
6656 (save-excursion
6657 (gnus-group-get-new-news-this-group 1)))
6658 (gnus-group-read-group all t)
6659 (gnus-summary-goto-subject current-subject nil t)))
6660
6661(defun gnus-summary-rescan-group (&optional all)
6662 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6663 (interactive "P")
6664 (gnus-summary-reselect-current-group all t))
6665
6666(defun gnus-summary-update-info (&optional non-destructive)
6667 (save-excursion
6668 (let ((group gnus-newsgroup-name))
6748645f
LMI
6669 (when group
6670 (when gnus-newsgroup-kill-headers
6671 (setq gnus-newsgroup-killed
6672 (gnus-compress-sequence
23f87bed
MB
6673 (gnus-sorted-union
6674 (gnus-list-range-intersection
6675 gnus-newsgroup-unselected gnus-newsgroup-killed)
6676 gnus-newsgroup-unreads)
6748645f
LMI
6677 t)))
6678 (unless (listp (cdr gnus-newsgroup-killed))
6679 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6680 (let ((headers gnus-newsgroup-headers))
6681 ;; Set the new ranges of read articles.
6682 (save-excursion
6683 (set-buffer gnus-group-buffer)
6684 (gnus-undo-force-boundary))
6685 (gnus-update-read-articles
23f87bed
MB
6686 group (gnus-sorted-union
6687 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
6688 ;; Set the current article marks.
6689 (let ((gnus-newsgroup-scored
6690 (if (and (not gnus-save-score)
6691 (not non-destructive))
6692 nil
6693 gnus-newsgroup-scored)))
6694 (save-excursion
6695 (gnus-update-marks)))
6696 ;; Do the cross-ref thing.
6697 (when gnus-use-cross-reference
6698 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6699 ;; Do not switch windows but change the buffer to work.
a8151ef7 6700 (set-buffer gnus-group-buffer)
6748645f
LMI
6701 (unless (gnus-ephemeral-group-p group)
6702 (gnus-group-update-group group)))))))
eec82323
LMI
6703
6704(defun gnus-summary-save-newsrc (&optional force)
6705 "Save the current number of read/marked articles in the dribble buffer.
6706The dribble buffer will then be saved.
6707If FORCE (the prefix), also save the .newsrc file(s)."
6708 (interactive "P")
6709 (gnus-summary-update-info t)
6710 (if force
6711 (gnus-save-newsrc-file)
6712 (gnus-dribble-save)))
6713
23f87bed 6714(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 6715 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 6716`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
6717 (interactive)
6718 (gnus-set-global-variables)
16409b0b
GM
6719 (when (gnus-buffer-live-p gnus-article-buffer)
6720 (save-excursion
6721 (set-buffer gnus-article-buffer)
6722 (mm-destroy-parts gnus-article-mime-handles)
6723 ;; Set it to nil for safety reason.
6724 (setq gnus-article-mime-handle-alist nil)
6725 (setq gnus-article-mime-handles nil)))
eec82323 6726 (gnus-kill-save-kill-buffer)
6748645f 6727 (gnus-async-halt-prefetch)
eec82323
LMI
6728 (let* ((group gnus-newsgroup-name)
6729 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 6730 (gnus-group-is-exiting-p t)
eec82323 6731 (mode major-mode)
23f87bed 6732 (group-point nil)
eec82323 6733 (buf (current-buffer)))
16409b0b
GM
6734 (unless quit-config
6735 ;; Do adaptive scoring, and possibly save score files.
6736 (when gnus-newsgroup-adaptive
6737 (gnus-score-adaptive))
6738 (when gnus-use-scoring
6739 (gnus-score-save)))
6748645f 6740 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
6741 ;; If we have several article buffers, we kill them at exit.
6742 (unless gnus-single-article-buffer
6743 (gnus-kill-buffer gnus-original-article-buffer)
6744 (setq gnus-article-current nil))
6745 (when gnus-use-cache
6746 (gnus-cache-possibly-remove-articles)
6747 (gnus-cache-save-buffers))
6748 (gnus-async-prefetch-remove-group group)
6749 (when gnus-suppress-duplicates
6750 (gnus-dup-enter-articles))
6751 (when gnus-use-trees
6752 (gnus-tree-close group))
16409b0b
GM
6753 (when gnus-use-cache
6754 (gnus-cache-write-active))
6748645f
LMI
6755 ;; Remove entries for this group.
6756 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
6757 ;; Make all changes in this group permanent.
6758 (unless quit-config
6748645f 6759 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 6760 (gnus-summary-update-info))
eec82323
LMI
6761 (gnus-close-group group)
6762 ;; Make sure where we were, and go to next newsgroup.
6763 (set-buffer gnus-group-buffer)
6764 (unless quit-config
6765 (gnus-group-jump-to-group group))
6748645f
LMI
6766 (gnus-run-hooks 'gnus-summary-exit-hook)
6767 (unless (or quit-config
6768 ;; If this group has disappeared from the summary
6769 ;; buffer, don't skip forwards.
6770 (not (string= group (gnus-group-group-name))))
eec82323 6771 (gnus-group-next-unread-group 1))
a8151ef7 6772 (setq group-point (point))
eec82323
LMI
6773 (if temporary
6774 nil ;Nothing to do.
6775 ;; If we have several article buffers, we kill them at exit.
6776 (unless gnus-single-article-buffer
6777 (gnus-kill-buffer gnus-article-buffer)
6778 (gnus-kill-buffer gnus-original-article-buffer)
6779 (setq gnus-article-current nil))
6780 (set-buffer buf)
6781 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
6782 (progn
6783 (gnus-deaden-summary)
6784 (setq mode nil))
eec82323
LMI
6785 ;; We set all buffer-local variables to nil. It is unclear why
6786 ;; this is needed, but if we don't, buffer-local variables are
6787 ;; not garbage-collected, it seems. This would the lead to en
6788 ;; ever-growing Emacs.
6789 (gnus-summary-clear-local-variables)
23f87bed
MB
6790 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6791 (gnus-summary-clear-local-variables))
eec82323
LMI
6792 (when (get-buffer gnus-article-buffer)
6793 (bury-buffer gnus-article-buffer))
6794 ;; We clear the global counterparts of the buffer-local
6795 ;; variables as well, just to be on the safe side.
6796 (set-buffer gnus-group-buffer)
6797 (gnus-summary-clear-local-variables)
23f87bed
MB
6798 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6799 (gnus-summary-clear-local-variables))
eec82323
LMI
6800 ;; Return to group mode buffer.
6801 (when (eq mode 'gnus-summary-mode)
6802 (gnus-kill-buffer buf)))
6803 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
6804 (set-buffer gnus-group-buffer)
6805 (if quit-config
6806 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
6807 (goto-char group-point)
6808 ;; If gnus-group-buffer is already displayed, make sure we also move
6809 ;; the cursor in the window that displays it.
6810 (let ((win (get-buffer-window (current-buffer) 0)))
6811 (if win (set-window-point win (point))))
d61c212b 6812 (unless leave-hidden
4e90f2b9 6813 (gnus-configure-windows 'group 'force)))
6748645f 6814 ;; Clear the current group name.
eec82323
LMI
6815 (unless quit-config
6816 (setq gnus-newsgroup-name nil)))))
6817
6818(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6819(defun gnus-summary-exit-no-update (&optional no-questions)
6820 "Quit reading current newsgroup without updating read article info."
6821 (interactive)
eec82323 6822 (let* ((group gnus-newsgroup-name)
23f87bed
MB
6823 (gnus-group-is-exiting-p t)
6824 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
6825 (quit-config (gnus-group-quit-config group)))
6826 (when (or no-questions
6827 gnus-expert-user
6828 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 6829 (gnus-async-halt-prefetch)
23f87bed 6830 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b
GM
6831 (when (gnus-buffer-live-p gnus-article-buffer)
6832 (save-excursion
6833 (set-buffer gnus-article-buffer)
6834 (mm-destroy-parts gnus-article-mime-handles)
6835 ;; Set it to nil for safety reason.
6836 (setq gnus-article-mime-handle-alist nil)
6837 (setq gnus-article-mime-handles nil)))
eec82323
LMI
6838 ;; If we have several article buffers, we kill them at exit.
6839 (unless gnus-single-article-buffer
6840 (gnus-kill-buffer gnus-article-buffer)
6841 (gnus-kill-buffer gnus-original-article-buffer)
6842 (setq gnus-article-current nil))
6843 (if (not gnus-kill-summary-on-exit)
6844 (gnus-deaden-summary)
6845 (gnus-close-group group)
6846 (gnus-summary-clear-local-variables)
23f87bed
MB
6847 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6848 (gnus-summary-clear-local-variables))
eec82323
LMI
6849 (set-buffer gnus-group-buffer)
6850 (gnus-summary-clear-local-variables)
23f87bed
MB
6851 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6852 (gnus-summary-clear-local-variables))
6853 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
6854 (unless gnus-single-article-buffer
6855 (setq gnus-article-current nil))
6856 (when gnus-use-trees
6857 (gnus-tree-close group))
6858 (gnus-async-prefetch-remove-group group)
6859 (when (get-buffer gnus-article-buffer)
6860 (bury-buffer gnus-article-buffer))
6861 ;; Return to the group buffer.
6862 (gnus-configure-windows 'group 'force)
6863 ;; Clear the current group name.
6864 (setq gnus-newsgroup-name nil)
23f87bed
MB
6865 (unless (gnus-ephemeral-group-p group)
6866 (gnus-group-update-group group))
eec82323
LMI
6867 (when (equal (gnus-group-group-name) group)
6868 (gnus-group-next-unread-group 1))
6869 (when quit-config
23f87bed 6870 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
6871
6872(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
6873 "Handle movement when leaving an ephemeral group.
6874The state which existed when entering the ephemeral is reset."
eec82323
LMI
6875 (if (not (buffer-name (car quit-config)))
6876 (gnus-configure-windows 'group 'force)
6877 (set-buffer (car quit-config))
6878 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
6879 (gnus-set-global-variables))
6880 ((eq major-mode 'gnus-article-mode)
6881 (save-excursion
6882 ;; The `gnus-summary-buffer' variable may point
6883 ;; to the old summary buffer when using a single
6884 ;; article buffer.
6885 (unless (gnus-buffer-live-p gnus-summary-buffer)
6886 (set-buffer gnus-group-buffer))
6887 (set-buffer gnus-summary-buffer)
6888 (gnus-set-global-variables))))
eec82323 6889 (if (or (eq (cdr quit-config) 'article)
23f87bed
MB
6890 (eq (cdr quit-config) 'pick))
6891 (progn
6892 ;; The current article may be from the ephemeral group
6893 ;; thus it is best that we reload this article
6894 ;;
6895 ;; If we're exiting from a large digest, this can be
6896 ;; extremely slow. So, it's better not to reload it. -- jh.
6897 ;;(gnus-summary-show-article)
6898 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6899 (gnus-configure-windows 'pick 'force)
6900 (gnus-configure-windows (cdr quit-config) 'force)))
eec82323
LMI
6901 (gnus-configure-windows (cdr quit-config) 'force))
6902 (when (eq major-mode 'gnus-summary-mode)
6903 (gnus-summary-next-subject 1 nil t)
6904 (gnus-summary-recenter)
6905 (gnus-summary-position-point))))
6906
6907;;; Dead summaries.
6908
6909(defvar gnus-dead-summary-mode-map nil)
6910
6911(unless gnus-dead-summary-mode-map
6912 (setq gnus-dead-summary-mode-map (make-keymap))
6913 (suppress-keymap gnus-dead-summary-mode-map)
6914 (substitute-key-definition
6915 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
23f87bed
MB
6916 (dolist (key '("\C-d" "\r" "\177" [delete]))
6917 (define-key gnus-dead-summary-mode-map
6918 key 'gnus-summary-wake-up-the-dead))
6919 (dolist (key '("q" "Q"))
6920 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
eec82323
LMI
6921
6922(defvar gnus-dead-summary-mode nil
6923 "Minor mode for Gnus summary buffers.")
6924
6925(defun gnus-dead-summary-mode (&optional arg)
6926 "Minor mode for Gnus summary buffers."
6927 (interactive "P")
6928 (when (eq major-mode 'gnus-summary-mode)
6929 (make-local-variable 'gnus-dead-summary-mode)
6930 (setq gnus-dead-summary-mode
6931 (if (null arg) (not gnus-dead-summary-mode)
6932 (> (prefix-numeric-value arg) 0)))
6933 (when gnus-dead-summary-mode
a8151ef7
LMI
6934 (gnus-add-minor-mode
6935 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
eec82323
LMI
6936
6937(defun gnus-deaden-summary ()
6938 "Make the current summary buffer into a dead summary buffer."
6939 ;; Kill any previous dead summary buffer.
6940 (when (and gnus-dead-summary
6941 (buffer-name gnus-dead-summary))
6942 (save-excursion
6943 (set-buffer gnus-dead-summary)
6944 (when gnus-dead-summary-mode
6945 (kill-buffer (current-buffer)))))
6946 ;; Make this the current dead summary.
6947 (setq gnus-dead-summary (current-buffer))
6948 (gnus-dead-summary-mode 1)
6949 (let ((name (buffer-name)))
6950 (when (string-match "Summary" name)
6951 (rename-buffer
6952 (concat (substring name 0 (match-beginning 0)) "Dead "
6953 (substring name (match-beginning 0)))
16409b0b
GM
6954 t)
6955 (bury-buffer))))
eec82323
LMI
6956
6957(defun gnus-kill-or-deaden-summary (buffer)
6958 "Kill or deaden the summary BUFFER."
6748645f
LMI
6959 (save-excursion
6960 (when (and (buffer-name buffer)
6961 (not gnus-single-article-buffer))
6962 (save-excursion
6963 (set-buffer buffer)
6964 (gnus-kill-buffer gnus-article-buffer)
6965 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
6966 (cond
6967 ;; Kill the buffer.
6968 (gnus-kill-summary-on-exit
6969 (when (and gnus-use-trees
6970 (gnus-buffer-exists-p buffer))
6971 (save-excursion
6972 (set-buffer buffer)
6973 (gnus-tree-close gnus-newsgroup-name)))
6974 (gnus-kill-buffer buffer))
6975 ;; Deaden the buffer.
6976 ((gnus-buffer-exists-p buffer)
6977 (save-excursion
6978 (set-buffer buffer)
6979 (gnus-deaden-summary))))))
eec82323
LMI
6980
6981(defun gnus-summary-wake-up-the-dead (&rest args)
6982 "Wake up the dead summary buffer."
6983 (interactive)
6984 (gnus-dead-summary-mode -1)
6985 (let ((name (buffer-name)))
6986 (when (string-match "Dead " name)
6987 (rename-buffer
6988 (concat (substring name 0 (match-beginning 0))
6989 (substring name (match-end 0)))
6990 t)))
6991 (gnus-message 3 "This dead summary is now alive again"))
6992
6993;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6994(defun gnus-summary-fetch-faq (&optional faq-dir)
6995 "Fetch the FAQ for the current group.
6996If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6997in."
6998 (interactive
6999 (list
7000 (when current-prefix-arg
7001 (completing-read
8f688cb0 7002 "FAQ dir: " (and (listp gnus-group-faq-directory)
a8151ef7
LMI
7003 (mapcar (lambda (file) (list file))
7004 gnus-group-faq-directory))))))
eec82323
LMI
7005 (let (gnus-faq-buffer)
7006 (when (setq gnus-faq-buffer
7007 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7008 (gnus-configure-windows 'summary-faq))))
7009
7010;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7011(defun gnus-summary-describe-group (&optional force)
7012 "Describe the current newsgroup."
7013 (interactive "P")
7014 (gnus-group-describe-group force gnus-newsgroup-name))
7015
7016(defun gnus-summary-describe-briefly ()
7017 "Describe summary mode commands briefly."
7018 (interactive)
16409b0b 7019 (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
7020
7021;; Walking around group mode buffer from summary mode.
7022
7023(defun gnus-summary-next-group (&optional no-article target-group backward)
7024 "Exit current newsgroup and then select next unread newsgroup.
7025If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7026initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7027previous group instead."
7028 (interactive "P")
eec82323
LMI
7029 ;; Stop pre-fetching.
7030 (gnus-async-halt-prefetch)
7031 (let ((current-group gnus-newsgroup-name)
7032 (current-buffer (current-buffer))
7033 entered)
7034 ;; First we semi-exit this group to update Xrefs and all variables.
7035 ;; We can't do a real exit, because the window conf must remain
7036 ;; the same in case the user is prompted for info, and we don't
7037 ;; want the window conf to change before that...
7038 (gnus-summary-exit t)
7039 (while (not entered)
7040 ;; Then we find what group we are supposed to enter.
7041 (set-buffer gnus-group-buffer)
7042 (gnus-group-jump-to-group current-group)
7043 (setq target-group
7044 (or target-group
7045 (if (eq gnus-keep-same-level 'best)
7046 (gnus-summary-best-group gnus-newsgroup-name)
7047 (gnus-summary-search-group backward gnus-keep-same-level))))
7048 (if (not target-group)
7049 ;; There are no further groups, so we return to the group
7050 ;; buffer.
7051 (progn
7052 (gnus-message 5 "Returning to the group buffer")
7053 (setq entered t)
7054 (when (gnus-buffer-live-p current-buffer)
7055 (set-buffer current-buffer)
7056 (gnus-summary-exit))
6748645f 7057 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7058 ;; We try to enter the target group.
7059 (gnus-group-jump-to-group target-group)
7060 (let ((unreads (gnus-group-group-unread)))
7061 (if (and (or (eq t unreads)
7062 (and unreads (not (zerop unreads))))
23f87bed
MB
7063 (gnus-summary-read-group
7064 target-group nil no-article
7065 (and (buffer-name current-buffer) current-buffer)
7066 nil backward))
eec82323
LMI
7067 (setq entered t)
7068 (setq current-group target-group
7069 target-group nil)))))))
7070
7071(defun gnus-summary-prev-group (&optional no-article)
7072 "Exit current newsgroup and then select previous unread newsgroup.
7073If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7074 (interactive "P")
7075 (gnus-summary-next-group no-article nil t))
7076
7077;; Walking around summary lines.
7078
23f87bed
MB
7079(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7080 "Go to the first subject satisfying any non-nil constraint.
7081If UNREAD is non-nil, the article should be unread.
7082If UNDOWNLOADED is non-nil, the article should be undownloaded.
7083If UNSEEN is non-nil, the article should be unseen.
7084Returns the article selected or nil if there are no matching articles."
eec82323 7085 (interactive "P")
23f87bed
MB
7086 (cond
7087 ;; Empty summary.
7088 ((null gnus-newsgroup-data)
7089 (gnus-message 3 "No articles in the group")
7090 nil)
7091 ;; Pick the first article.
7092 ((not (or unread undownloaded unseen))
7093 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7094 (gnus-data-number (car gnus-newsgroup-data)))
7095 ;; Find the first unread article.
7096 (t
7097 (let ((data gnus-newsgroup-data))
7098 (while (and data
7099 (let ((num (gnus-data-number (car data))))
7100 (or (memq num gnus-newsgroup-unfetched)
7101 (not (or (and unread
7102 (memq num gnus-newsgroup-unreads))
7103 (and undownloaded
7104 (memq num gnus-newsgroup-undownloaded))
7105 (and unseen
7106 (memq num gnus-newsgroup-unseen)))))))
7107 (setq data (cdr data)))
7108 (prog1
7109 (if data
7110 (progn
7111 (goto-char (gnus-data-pos (car data)))
7112 (gnus-data-number (car data)))
7113 (gnus-message 3 "No more%s articles"
7114 (let* ((r (when unread " unread"))
7115 (d (when undownloaded " undownloaded"))
7116 (s (when unseen " unseen"))
7117 (l (delq nil (list r d s))))
7118 (cond ((= 3 (length l))
7119 (concat r "," d ", or" s))
7120 ((= 2 (length l))
7121 (concat (car l) ", or" (cadr l)))
7122 ((= 1 (length l))
7123 (car l))
7124 (t
7125 ""))))
7126 nil
7127 )
7128 (gnus-summary-position-point))))))
eec82323
LMI
7129
7130(defun gnus-summary-next-subject (n &optional unread dont-display)
7131 "Go to next N'th summary line.
7132If N is negative, go to the previous N'th subject line.
7133If UNREAD is non-nil, only unread articles are selected.
7134The difference between N and the actual number of steps taken is
7135returned."
7136 (interactive "p")
7137 (let ((backward (< n 0))
7138 (n (abs n)))
7139 (while (and (> n 0)
7140 (if backward
7141 (gnus-summary-find-prev unread)
7142 (gnus-summary-find-next unread)))
16409b0b
GM
7143 (unless (zerop (setq n (1- n)))
7144 (gnus-summary-show-thread)))
eec82323
LMI
7145 (when (/= 0 n)
7146 (gnus-message 7 "No more%s articles"
7147 (if unread " unread" "")))
7148 (unless dont-display
7149 (gnus-summary-recenter)
7150 (gnus-summary-position-point))
7151 n))
7152
7153(defun gnus-summary-next-unread-subject (n)
7154 "Go to next N'th unread summary line."
7155 (interactive "p")
7156 (gnus-summary-next-subject n t))
7157
7158(defun gnus-summary-prev-subject (n &optional unread)
7159 "Go to previous N'th summary line.
7160If optional argument UNREAD is non-nil, only unread article is selected."
7161 (interactive "p")
7162 (gnus-summary-next-subject (- n) unread))
7163
7164(defun gnus-summary-prev-unread-subject (n)
7165 "Go to previous N'th unread summary line."
7166 (interactive "p")
7167 (gnus-summary-next-subject (- n) t))
7168
23f87bed
MB
7169(defun gnus-summary-goto-subjects (articles)
7170 "Insert the subject header for ARTICLES in the current buffer."
7171 (save-excursion
7172 (dolist (article articles)
7173 (gnus-summary-goto-subject article t)))
7174 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7175 (gnus-summary-position-point))
132cf96d 7176
eec82323
LMI
7177(defun gnus-summary-goto-subject (article &optional force silent)
7178 "Go the subject line of ARTICLE.
7179If FORCE, also allow jumping to articles not currently shown."
7180 (interactive "nArticle number: ")
23f87bed
MB
7181 (unless (numberp article)
7182 (error "Article %s is not a number" article))
eec82323
LMI
7183 (let ((b (point))
7184 (data (gnus-data-find article)))
7185 ;; We read in the article if we have to.
7186 (and (not data)
7187 force
6748645f
LMI
7188 (gnus-summary-insert-subject
7189 article
7190 (if (or (numberp force) (vectorp force)) force)
7191 t)
eec82323
LMI
7192 (setq data (gnus-data-find article)))
7193 (goto-char b)
7194 (if (not data)
7195 (progn
7196 (unless silent
7197 (gnus-message 3 "Can't find article %d" article))
7198 nil)
23f87bed
MB
7199 (let ((pt (gnus-data-pos data)))
7200 (goto-char pt)
7201 (gnus-summary-set-article-display-arrow pt))
6748645f 7202 (gnus-summary-position-point)
eec82323
LMI
7203 article)))
7204
7205;; Walking around summary lines with displaying articles.
7206
7207(defun gnus-summary-expand-window (&optional arg)
7208 "Make the summary buffer take up the entire Emacs frame.
7209Given a prefix, will force an `article' buffer configuration."
7210 (interactive "P")
eec82323
LMI
7211 (if arg
7212 (gnus-configure-windows 'article 'force)
7213 (gnus-configure-windows 'summary 'force)))
7214
7215(defun gnus-summary-display-article (article &optional all-header)
7216 "Display ARTICLE in article buffer."
d4dfaa19
DL
7217 (when (gnus-buffer-live-p gnus-article-buffer)
7218 (with-current-buffer gnus-article-buffer
87545352 7219 (mm-enable-multibyte)))
eec82323 7220 (gnus-set-global-variables)
23f87bed
MB
7221 (when (gnus-buffer-live-p gnus-article-buffer)
7222 (with-current-buffer gnus-article-buffer
7223 (setq gnus-article-charset gnus-newsgroup-charset)
7224 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7225 (mm-enable-multibyte)))
eec82323
LMI
7226 (if (null article)
7227 nil
7228 (prog1
7229 (if gnus-summary-display-article-function
7230 (funcall gnus-summary-display-article-function article all-header)
7231 (gnus-article-prepare article all-header))
6748645f 7232 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7233 (when (and gnus-current-article
7234 (not (zerop gnus-current-article)))
7235 (gnus-summary-goto-subject gnus-current-article))
7236 (gnus-summary-recenter)
7237 (when (and gnus-use-trees gnus-show-threads)
7238 (gnus-possibly-generate-tree article)
7239 (gnus-highlight-selected-tree article))
7240 ;; Successfully display article.
7241 (gnus-article-set-window-start
7242 (cdr (assq article gnus-newsgroup-bookmarks))))))
7243
7244(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7245 "Select the current article.
7246If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7247non-nil, the article will be re-fetched even if it already present in
7248the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7249be displayed."
7250 ;; Make sure we are in the summary buffer to work around bbdb bug.
7251 (unless (eq major-mode 'gnus-summary-mode)
7252 (set-buffer gnus-summary-buffer))
7253 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7254 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7255 gnus-summary-display-article-function)
eec82323
LMI
7256 (and (not pseudo)
7257 (gnus-summary-article-pseudo-p article)
a8151ef7 7258 (error "This is a pseudo-article"))
16409b0b
GM
7259 (save-excursion
7260 (set-buffer gnus-summary-buffer)
7261 (if (or (and gnus-single-article-buffer
7262 (or (null gnus-current-article)
7263 (null gnus-article-current)
7264 (null (get-buffer gnus-article-buffer))
7265 (not (eq article (cdr gnus-article-current)))
7266 (not (equal (car gnus-article-current)
7267 gnus-newsgroup-name))))
7268 (and (not gnus-single-article-buffer)
7269 (or (null gnus-current-article)
7270 (not (eq gnus-current-article article))))
7271 force)
7272 ;; The requested article is different from the current article.
7273 (progn
16409b0b
GM
7274 (gnus-summary-display-article article all-headers)
7275 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7276 (with-current-buffer gnus-article-buffer
16409b0b 7277 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7278 (mm-disable-multibyte))))
16409b0b
GM
7279 (gnus-article-set-window-start
7280 (cdr (assq article gnus-newsgroup-bookmarks)))
7281 article)
16409b0b 7282 'old))))
eec82323 7283
23f87bed
MB
7284(defun gnus-summary-force-verify-and-decrypt ()
7285 "Display buttons for signed/encrypted parts and verify/decrypt them."
7286 (interactive)
7287 (let ((mm-verify-option 'known)
7288 (mm-decrypt-option 'known)
7289 (gnus-article-emulate-mime t)
7290 (gnus-buttonized-mime-types (append (list "multipart/signed"
7291 "multipart/encrypted")
7292 gnus-buttonized-mime-types)))
7293 (gnus-summary-select-article nil 'force)))
7294
eec82323
LMI
7295(defun gnus-summary-set-current-mark (&optional current-mark)
7296 "Obsolete function."
7297 nil)
7298
7299(defun gnus-summary-next-article (&optional unread subject backward push)
7300 "Select the next article.
7301If UNREAD, only unread articles are selected.
7302If SUBJECT, only articles with SUBJECT are selected.
7303If BACKWARD, the previous article is selected instead of the next."
7304 (interactive "P")
eec82323
LMI
7305 (cond
7306 ;; Is there such an article?
7307 ((and (gnus-summary-search-forward unread subject backward)
7308 (or (gnus-summary-display-article (gnus-summary-article-number))
7309 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7310 (gnus-summary-position-point))
7311 ;; If not, we try the first unread, if that is wanted.
7312 ((and subject
7313 gnus-auto-select-same
7314 (gnus-summary-first-unread-article))
7315 (gnus-summary-position-point)
7316 (gnus-message 6 "Wrapped"))
7317 ;; Try to get next/previous article not displayed in this group.
7318 ((and gnus-auto-extend-newsgroup
7319 (not unread) (not subject))
7320 (gnus-summary-goto-article
7321 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7322 nil (count-lines (point-min) (point))))
eec82323
LMI
7323 ;; Go to next/previous group.
7324 (t
7325 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7326 (gnus-summary-jump-to-group gnus-newsgroup-name))
7327 (let ((cmd last-command-char)
7328 (point
7329 (save-excursion
7330 (set-buffer gnus-group-buffer)
7331 (point)))
7332 (group
7333 (if (eq gnus-keep-same-level 'best)
7334 (gnus-summary-best-group gnus-newsgroup-name)
7335 (gnus-summary-search-group backward gnus-keep-same-level))))
7336 ;; For some reason, the group window gets selected. We change
7337 ;; it back.
7338 (select-window (get-buffer-window (current-buffer)))
7339 ;; Select next unread newsgroup automagically.
7340 (cond
7341 ((or (not gnus-auto-select-next)
7342 (not cmd))
7343 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7344 ((or (eq gnus-auto-select-next 'quietly)
7345 (and (eq gnus-auto-select-next 'slightly-quietly)
7346 push)
7347 (and (eq gnus-auto-select-next 'almost-quietly)
7348 (gnus-summary-last-article-p)))
7349 ;; Select quietly.
7350 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7351 (gnus-summary-exit)
7352 (gnus-message 7 "No more%s articles (%s)..."
7353 (if unread " unread" "")
7354 (if group (concat "selecting " group)
7355 "exiting"))
7356 (gnus-summary-next-group nil group backward)))
7357 (t
7358 (when (gnus-key-press-event-p last-input-event)
7359 (gnus-summary-walk-group-buffer
7360 gnus-newsgroup-name cmd unread backward point))))))))
7361
7362(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7363 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7364 (?\C-p (gnus-group-prev-unread-group 1))))
7365 (cursor-in-echo-area t)
23f87bed 7366 keve key group ended prompt)
eec82323
LMI
7367 (save-excursion
7368 (set-buffer gnus-group-buffer)
7369 (goto-char start)
7370 (setq group
7371 (if (eq gnus-keep-same-level 'best)
7372 (gnus-summary-best-group gnus-newsgroup-name)
7373 (gnus-summary-search-group backward gnus-keep-same-level))))
7374 (while (not ended)
23f87bed
MB
7375 (setq prompt
7376 (format
7377 "No more%s articles%s " (if unread " unread" "")
7378 (if (and group
7379 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7380 (format " (Type %s for %s [%s])"
91472578
MB
7381 (single-key-description cmd)
7382 (gnus-group-decoded-name group)
23f87bed
MB
7383 (car (gnus-gethash group gnus-newsrc-hashtb)))
7384 (format " (Type %s to exit %s)"
7385 (single-key-description cmd)
91472578 7386 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7387 ;; Confirm auto selection.
23f87bed
MB
7388 (setq key (car (setq keve (gnus-read-event-char prompt)))
7389 ended t)
eec82323
LMI
7390 (cond
7391 ((assq key keystrokes)
7392 (let ((obuf (current-buffer)))
7393 (switch-to-buffer gnus-group-buffer)
7394 (when group
7395 (gnus-group-jump-to-group group))
7396 (eval (cadr (assq key keystrokes)))
7397 (setq group (gnus-group-group-name))
7398 (switch-to-buffer obuf))
7399 (setq ended nil))
7400 ((equal key cmd)
7401 (if (or (not group)
7402 (gnus-ephemeral-group-p gnus-newsgroup-name))
7403 (gnus-summary-exit)
7404 (gnus-summary-next-group nil group backward)))
7405 (t
7406 (push (cdr keve) unread-command-events))))))
7407
7408(defun gnus-summary-next-unread-article ()
7409 "Select unread article after current one."
7410 (interactive)
7411 (gnus-summary-next-article
7412 (or (not (eq gnus-summary-goto-unread 'never))
7413 (gnus-summary-last-article-p (gnus-summary-article-number)))
7414 (and gnus-auto-select-same
7415 (gnus-summary-article-subject))))
7416
7417(defun gnus-summary-prev-article (&optional unread subject)
7418 "Select the article after the current one.
7419If UNREAD is non-nil, only unread articles are selected."
7420 (interactive "P")
7421 (gnus-summary-next-article unread subject t))
7422
7423(defun gnus-summary-prev-unread-article ()
7424 "Select unread article before current one."
7425 (interactive)
7426 (gnus-summary-prev-article
7427 (or (not (eq gnus-summary-goto-unread 'never))
7428 (gnus-summary-first-article-p (gnus-summary-article-number)))
7429 (and gnus-auto-select-same
7430 (gnus-summary-article-subject))))
7431
23f87bed 7432(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7433 "Show next page of the selected article.
7434If at the end of the current article, select the next article.
7435LINES says how many lines should be scrolled up.
7436
7437If CIRCULAR is non-nil, go to the start of the article instead of
7438selecting the next article when reaching the end of the current
23f87bed
MB
7439article.
7440
7441If STOP is non-nil, just stop when reaching the end of the message.
7442
7443Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7444 (interactive "P")
7445 (setq gnus-summary-buffer (current-buffer))
7446 (gnus-set-global-variables)
7447 (let ((article (gnus-summary-article-number))
7448 (article-window (get-buffer-window gnus-article-buffer t))
7449 endp)
6748645f
LMI
7450 ;; If the buffer is empty, we have no article.
7451 (unless article
7452 (error "No article to select"))
eec82323
LMI
7453 (gnus-configure-windows 'article)
7454 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7455 (if (and (eq gnus-summary-goto-unread 'never)
7456 (not (gnus-summary-last-article-p article)))
7457 (gnus-summary-next-article)
7458 (gnus-summary-next-unread-article))
7459 (if (or (null gnus-current-article)
7460 (null gnus-article-current)
7461 (/= article (cdr gnus-article-current))
7462 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7463 ;; Selected subject is different from current article's.
7464 (gnus-summary-display-article article)
7465 (when article-window
7466 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7467 (setq endp (or (gnus-article-next-page lines)
7468 (gnus-article-only-boring-p))))
eec82323 7469 (when endp
23f87bed
MB
7470 (cond (stop
7471 (gnus-message 3 "End of message"))
7472 (circular
eec82323
LMI
7473 (gnus-summary-beginning-of-article))
7474 (lines
7475 (gnus-message 3 "End of message"))
7476 ((null lines)
7477 (if (and (eq gnus-summary-goto-unread 'never)
7478 (not (gnus-summary-last-article-p article)))
7479 (gnus-summary-next-article)
7480 (gnus-summary-next-unread-article))))))))
7481 (gnus-summary-recenter)
7482 (gnus-summary-position-point)))
7483
7484(defun gnus-summary-prev-page (&optional lines move)
7485 "Show previous page of selected article.
7486Argument LINES specifies lines to be scrolled down.
7487If MOVE, move to the previous unread article if point is at
7488the beginning of the buffer."
7489 (interactive "P")
eec82323
LMI
7490 (let ((article (gnus-summary-article-number))
7491 (article-window (get-buffer-window gnus-article-buffer t))
7492 endp)
7493 (gnus-configure-windows 'article)
7494 (if (or (null gnus-current-article)
7495 (null gnus-article-current)
7496 (/= article (cdr gnus-article-current))
7497 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7498 ;; Selected subject is different from current article's.
7499 (gnus-summary-display-article article)
7500 (gnus-summary-recenter)
7501 (when article-window
7502 (gnus-eval-in-buffer-window gnus-article-buffer
7503 (setq endp (gnus-article-prev-page lines)))
7504 (when (and move endp)
7505 (cond (lines
7506 (gnus-message 3 "Beginning of message"))
7507 ((null lines)
7508 (if (and (eq gnus-summary-goto-unread 'never)
7509 (not (gnus-summary-first-article-p article)))
7510 (gnus-summary-prev-article)
7511 (gnus-summary-prev-unread-article))))))))
7512 (gnus-summary-position-point))
7513
7514(defun gnus-summary-prev-page-or-article (&optional lines)
7515 "Show previous page of selected article.
7516Argument LINES specifies lines to be scrolled down.
7517If at the beginning of the article, go to the next article."
7518 (interactive "P")
7519 (gnus-summary-prev-page lines t))
7520
7521(defun gnus-summary-scroll-up (lines)
7522 "Scroll up (or down) one line current article.
7523Argument LINES specifies lines to be scrolled up (or down if negative)."
7524 (interactive "p")
eec82323
LMI
7525 (gnus-configure-windows 'article)
7526 (gnus-summary-show-thread)
7527 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7528 (gnus-eval-in-buffer-window gnus-article-buffer
7529 (cond ((> lines 0)
7530 (when (gnus-article-next-page lines)
7531 (gnus-message 3 "End of message")))
7532 ((< lines 0)
7533 (gnus-article-prev-page (- lines))))))
7534 (gnus-summary-recenter)
7535 (gnus-summary-position-point))
7536
6748645f
LMI
7537(defun gnus-summary-scroll-down (lines)
7538 "Scroll down (or up) one line current article.
7539Argument LINES specifies lines to be scrolled down (or up if negative)."
7540 (interactive "p")
7541 (gnus-summary-scroll-up (- lines)))
7542
eec82323
LMI
7543(defun gnus-summary-next-same-subject ()
7544 "Select next article which has the same subject as current one."
7545 (interactive)
eec82323
LMI
7546 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7547
7548(defun gnus-summary-prev-same-subject ()
7549 "Select previous article which has the same subject as current one."
7550 (interactive)
eec82323
LMI
7551 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7552
7553(defun gnus-summary-next-unread-same-subject ()
7554 "Select next unread article which has the same subject as current one."
7555 (interactive)
eec82323
LMI
7556 (gnus-summary-next-article t (gnus-summary-article-subject)))
7557
7558(defun gnus-summary-prev-unread-same-subject ()
7559 "Select previous unread article which has the same subject as current one."
7560 (interactive)
eec82323
LMI
7561 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7562
7563(defun gnus-summary-first-unread-article ()
7564 "Select the first unread article.
7565Return nil if there are no unread articles."
7566 (interactive)
eec82323
LMI
7567 (prog1
7568 (when (gnus-summary-first-subject t)
7569 (gnus-summary-show-thread)
7570 (gnus-summary-first-subject t)
7571 (gnus-summary-display-article (gnus-summary-article-number)))
7572 (gnus-summary-position-point)))
7573
16409b0b
GM
7574(defun gnus-summary-first-unread-subject ()
7575 "Place the point on the subject line of the first unread article.
7576Return nil if there are no unread articles."
7577 (interactive)
7578 (prog1
7579 (when (gnus-summary-first-subject t)
7580 (gnus-summary-show-thread)
7581 (gnus-summary-first-subject t))
7582 (gnus-summary-position-point)))
7583
23f87bed
MB
7584(defun gnus-summary-first-unseen-subject ()
7585 "Place the point on the subject line of the first unseen article.
7586Return nil if there are no unseen articles."
7587 (interactive)
7588 (prog1
7589 (when (gnus-summary-first-subject nil nil t)
7590 (gnus-summary-show-thread)
7591 (gnus-summary-first-subject nil nil t))
7592 (gnus-summary-position-point)))
7593
7594(defun gnus-summary-first-unseen-or-unread-subject ()
7595 "Place the point on the subject line of the first unseen article or,
7596if all article have been seen, on the subject line of the first unread
7597article."
7598 (interactive)
7599 (prog1
7600 (unless (when (gnus-summary-first-subject nil nil t)
7601 (gnus-summary-show-thread)
7602 (gnus-summary-first-subject nil nil t))
7603 (when (gnus-summary-first-subject t)
7604 (gnus-summary-show-thread)
7605 (gnus-summary-first-subject t)))
7606 (gnus-summary-position-point)))
7607
eec82323
LMI
7608(defun gnus-summary-first-article ()
7609 "Select the first article.
7610Return nil if there are no articles."
7611 (interactive)
eec82323
LMI
7612 (prog1
7613 (when (gnus-summary-first-subject)
16409b0b
GM
7614 (gnus-summary-show-thread)
7615 (gnus-summary-first-subject)
7616 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
7617 (gnus-summary-position-point)))
7618
23f87bed
MB
7619(defun gnus-summary-best-unread-article (&optional arg)
7620 "Select the unread article with the highest score.
7621If given a prefix argument, select the next unread article that has a
7622score higher than the default score."
7623 (interactive "P")
7624 (let ((article (if arg
7625 (gnus-summary-better-unread-subject)
7626 (gnus-summary-best-unread-subject))))
7627 (if article
7628 (gnus-summary-goto-article article)
7629 (error "No unread articles"))))
7630
7631(defun gnus-summary-best-unread-subject ()
7632 "Select the unread subject with the highest score."
eec82323 7633 (interactive)
eec82323
LMI
7634 (let ((best -1000000)
7635 (data gnus-newsgroup-data)
7636 article score)
7637 (while data
7638 (and (gnus-data-unread-p (car data))
7639 (> (setq score
7640 (gnus-summary-article-score (gnus-data-number (car data))))
7641 best)
7642 (setq best score
7643 article (gnus-data-number (car data))))
7644 (setq data (cdr data)))
23f87bed
MB
7645 (when article
7646 (gnus-summary-goto-subject article))
7647 (gnus-summary-position-point)
7648 article))
7649
7650(defun gnus-summary-better-unread-subject ()
7651 "Select the first unread subject that has a score over the default score."
7652 (interactive)
7653 (let ((data gnus-newsgroup-data)
7654 article score)
7655 (while (and (setq article (gnus-data-number (car data)))
7656 (or (gnus-data-read-p (car data))
7657 (not (> (gnus-summary-article-score article)
7658 gnus-summary-default-score))))
7659 (setq data (cdr data)))
7660 (when article
7661 (gnus-summary-goto-subject article))
7662 (gnus-summary-position-point)
7663 article))
eec82323
LMI
7664
7665(defun gnus-summary-last-subject ()
7666 "Go to the last displayed subject line in the group."
7667 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7668 (when article
7669 (gnus-summary-goto-subject article))))
7670
7671(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
7672 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7673If ALL-HEADERS is non-nil, no header lines are hidden.
7674If FORCE, go to the article even if it isn't displayed. If FORCE
7675is a number, it is the line the article is to be displayed on."
eec82323
LMI
7676 (interactive
7677 (list
6748645f
LMI
7678 (completing-read
7679 "Article number or Message-ID: "
7680 (mapcar (lambda (number) (list (int-to-string number)))
7681 gnus-newsgroup-limit))
eec82323
LMI
7682 current-prefix-arg
7683 t))
7684 (prog1
6748645f 7685 (if (and (stringp article)
23f87bed 7686 (string-match "@\\|%40" article))
6748645f
LMI
7687 (gnus-summary-refer-article article)
7688 (when (stringp article)
7689 (setq article (string-to-number article)))
7690 (if (gnus-summary-goto-subject article force)
7691 (gnus-summary-display-article article all-headers)
7692 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
7693 (gnus-summary-position-point)))
7694
7695(defun gnus-summary-goto-last-article ()
7696 "Go to the previously read article."
7697 (interactive)
7698 (prog1
7699 (when gnus-last-article
6748645f 7700 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
7701 (gnus-summary-position-point)))
7702
7703(defun gnus-summary-pop-article (number)
7704 "Pop one article off the history and go to the previous.
7705NUMBER articles will be popped off."
7706 (interactive "p")
7707 (let (to)
7708 (setq gnus-newsgroup-history
7709 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7710 (if to
6748645f 7711 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
7712 (error "Article history empty")))
7713 (gnus-summary-position-point))
7714
7715;; Summary commands and functions for limiting the summary buffer.
7716
7717(defun gnus-summary-limit-to-articles (n)
7718 "Limit the summary buffer to the next N articles.
7719If not given a prefix, use the process marked articles instead."
7720 (interactive "P")
eec82323
LMI
7721 (prog1
7722 (let ((articles (gnus-summary-work-articles n)))
7723 (setq gnus-newsgroup-processable nil)
7724 (gnus-summary-limit articles))
7725 (gnus-summary-position-point)))
7726
7727(defun gnus-summary-pop-limit (&optional total)
7728 "Restore the previous limit.
7729If given a prefix, remove all limits."
7730 (interactive "P")
eec82323
LMI
7731 (when total
7732 (setq gnus-newsgroup-limits
7733 (list (mapcar (lambda (h) (mail-header-number h))
7734 gnus-newsgroup-headers))))
7735 (unless gnus-newsgroup-limits
7736 (error "No limit to pop"))
7737 (prog1
7738 (gnus-summary-limit nil 'pop)
7739 (gnus-summary-position-point)))
7740
47b63dfa
SZ
7741(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7742 "Limit the summary buffer to articles that have subjects that match a regexp.
7743If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 7744 (interactive
47b63dfa
SZ
7745 (list (read-string (if current-prefix-arg
7746 "Exclude subject (regexp): "
a1506d29 7747 "Limit to subject (regexp): "))
47b63dfa 7748 nil current-prefix-arg))
eec82323
LMI
7749 (unless header
7750 (setq header "subject"))
7751 (when (not (equal "" subject))
7752 (prog1
7753 (let ((articles (gnus-summary-find-matching
a1506d29 7754 (or header "subject") subject 'all nil nil
47b63dfa 7755 not-matching)))
eec82323
LMI
7756 (unless articles
7757 (error "Found no matches for \"%s\"" subject))
7758 (gnus-summary-limit articles))
7759 (gnus-summary-position-point))))
7760
ef6e0ec7 7761(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
7762 "Limit the summary buffer to articles that have authors that match a regexp.
7763If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 7764 (interactive
47b63dfa
SZ
7765 (list (read-string (if current-prefix-arg
7766 "Exclude author (regexp): "
a1506d29 7767 "Limit to author (regexp): "))
ef6e0ec7
SZ
7768 current-prefix-arg))
7769 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323
LMI
7770
7771(defun gnus-summary-limit-to-age (age &optional younger-p)
7772 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7773If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7774articles that are younger than AGE days."
16409b0b
GM
7775 (interactive
7776 (let ((younger current-prefix-arg)
7777 (days-got nil)
7778 days)
7779 (while (not days-got)
7780 (setq days (if younger
23f87bed
MB
7781 (read-string "Limit to articles younger than (in days, older when negative): ")
7782 (read-string
7783 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
7784 (when (> (length days) 0)
7785 (setq days (read days)))
7786 (if (numberp days)
23f87bed
MB
7787 (progn
7788 (setq days-got t)
7789 (if (< days 0)
7790 (progn
7791 (setq younger (not younger))
7792 (setq days (* days -1)))))
16409b0b
GM
7793 (message "Please enter a number.")
7794 (sleep-for 1)))
7795 (list days younger)))
eec82323
LMI
7796 (prog1
7797 (let ((data gnus-newsgroup-data)
16409b0b 7798 (cutoff (days-to-time age))
eec82323
LMI
7799 articles d date is-younger)
7800 (while (setq d (pop data))
7801 (when (and (vectorp (gnus-data-header d))
7802 (setq date (mail-header-date (gnus-data-header d))))
16409b0b
GM
7803 (setq is-younger (time-less-p
7804 (time-since (condition-case ()
7805 (date-to-time date)
7806 (error '(0 0))))
eec82323 7807 cutoff))
6748645f
LMI
7808 (when (if younger-p
7809 is-younger
7810 (not is-younger))
eec82323
LMI
7811 (push (gnus-data-number d) articles))))
7812 (gnus-summary-limit (nreverse articles)))
7813 (gnus-summary-position-point)))
7814
47b63dfa 7815(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
7816 "Limit the summary buffer to articles that match an 'extra' header."
7817 (interactive
7818 (let ((header
7819 (intern
23f87bed 7820 (gnus-completing-read-with-default
16409b0b 7821 (symbol-name (car gnus-extra-headers))
47b63dfa 7822 (if current-prefix-arg
81df110a
RF
7823 "Exclude extra header"
7824 "Limit extra header")
16409b0b
GM
7825 (mapcar (lambda (x)
7826 (cons (symbol-name x) x))
7827 gnus-extra-headers)
7828 nil
7829 t))))
7830 (list header
a1506d29 7831 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
7832 (if current-prefix-arg "Exclude" "Limit to")
7833 header))
7834 current-prefix-arg)))
16409b0b
GM
7835 (when (not (equal "" regexp))
7836 (prog1
7837 (let ((articles (gnus-summary-find-matching
a1506d29 7838 (cons 'extra header) regexp 'all nil nil
47b63dfa 7839 not-matching)))
16409b0b
GM
7840 (unless articles
7841 (error "Found no matches for \"%s\"" regexp))
7842 (gnus-summary-limit articles))
7843 (gnus-summary-position-point))))
7844
23f87bed
MB
7845(defun gnus-summary-limit-to-display-predicate ()
7846 "Limit the summary buffer to the predicated in the `display' group parameter."
7847 (interactive)
7848 (unless gnus-newsgroup-display
7849 (error "There is no `display' group parameter"))
7850 (let (articles)
7851 (dolist (number gnus-newsgroup-articles)
7852 (when (funcall gnus-newsgroup-display)
7853 (push number articles)))
7854 (gnus-summary-limit articles))
7855 (gnus-summary-position-point))
7856
eec82323
LMI
7857(defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7858(make-obsolete
7859 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7860
7861(defun gnus-summary-limit-to-unread (&optional all)
7862 "Limit the summary buffer to articles that are not marked as read.
7863If ALL is non-nil, limit strictly to unread articles."
7864 (interactive "P")
7865 (if all
7866 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7867 (gnus-summary-limit-to-marks
7868 ;; Concat all the marks that say that an article is read and have
7869 ;; those removed.
7870 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 7871 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
7872 gnus-low-score-mark gnus-expirable-mark
7873 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7874 gnus-duplicate-mark gnus-souped-mark)
7875 'reverse)))
7876
7877(defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7878(make-obsolete 'gnus-summary-delete-marked-with
81ceefe2 7879 'gnus-summary-limit-exclude-marks)
eec82323
LMI
7880
7881(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7882 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7883If REVERSE, limit the summary buffer to articles that are marked
7884with MARKS. MARKS can either be a string of marks or a list of marks.
7885Returns how many articles were removed."
7886 (interactive "sMarks: ")
7887 (gnus-summary-limit-to-marks marks t))
7888
7889(defun gnus-summary-limit-to-marks (marks &optional reverse)
7890 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7891If REVERSE (the prefix), limit the summary buffer to articles that are
7892not marked with MARKS. MARKS can either be a string of marks or a
7893list of marks.
7894Returns how many articles were removed."
6748645f 7895 (interactive "sMarks: \nP")
eec82323
LMI
7896 (prog1
7897 (let ((data gnus-newsgroup-data)
7898 (marks (if (listp marks) marks
7899 (append marks nil))) ; Transform to list.
7900 articles)
7901 (while data
7902 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7903 (memq (gnus-data-mark (car data)) marks))
7904 (push (gnus-data-number (car data)) articles))
7905 (setq data (cdr data)))
7906 (gnus-summary-limit articles))
7907 (gnus-summary-position-point)))
7908
23f87bed 7909(defun gnus-summary-limit-to-score (score)
eec82323 7910 "Limit to articles with score at or above SCORE."
23f87bed 7911 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
7912 (let ((data gnus-newsgroup-data)
7913 articles)
7914 (while data
7915 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7916 score)
7917 (push (gnus-data-number (car data)) articles))
7918 (setq data (cdr data)))
7919 (prog1
7920 (gnus-summary-limit articles)
7921 (gnus-summary-position-point))))
7922
23f87bed
MB
7923(defun gnus-summary-limit-to-unseen ()
7924 "Limit to unseen articles."
7925 (interactive)
7926 (prog1
7927 (gnus-summary-limit gnus-newsgroup-unseen)
7928 (gnus-summary-position-point)))
7929
6748645f 7930(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
7931 "Display all the hidden articles that is in the thread with ID in it.
7932When called interactively, ID is the Message-ID of the current
7933article."
6748645f
LMI
7934 (interactive (list (mail-header-id (gnus-summary-article-header))))
7935 (let ((articles (gnus-articles-in-thread
7936 (gnus-id-to-thread (gnus-root-id id)))))
7937 (prog1
7938 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
7939 (gnus-summary-limit-include-matching-articles
7940 "subject"
7941 (regexp-quote (gnus-simplify-subject-re
7942 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
7943 (gnus-summary-position-point))))
7944
23f87bed
MB
7945(defun gnus-summary-limit-include-matching-articles (header regexp)
7946 "Display all the hidden articles that have HEADERs that match REGEXP."
7947 (interactive (list (read-string "Match on header: ")
7948 (read-string "Regexp: ")))
7949 (let ((articles (gnus-find-matching-articles header regexp)))
7950 (prog1
7951 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7952 (gnus-summary-position-point))))
7953
7954(defun gnus-summary-insert-dormant-articles ()
7955 "Insert all the dormant articles for this group into the current buffer."
7956 (interactive)
7957 (let ((gnus-verbose (max 6 gnus-verbose)))
7958 (if (not gnus-newsgroup-dormant)
7959 (gnus-message 3 "No cached articles for this group")
7960 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7961
eec82323 7962(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
7963 "Display all the hidden articles that are marked as dormant.
7964Note that this command only works on a subset of the articles currently
7965fetched for this group."
eec82323 7966 (interactive)
eec82323
LMI
7967 (unless gnus-newsgroup-dormant
7968 (error "There are no dormant articles in this group"))
7969 (prog1
7970 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7971 (gnus-summary-position-point)))
7972
7973(defun gnus-summary-limit-exclude-dormant ()
7974 "Hide all dormant articles."
7975 (interactive)
eec82323
LMI
7976 (prog1
7977 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7978 (gnus-summary-position-point)))
7979
7980(defun gnus-summary-limit-exclude-childless-dormant ()
7981 "Hide all dormant articles that have no children."
7982 (interactive)
eec82323
LMI
7983 (let ((data (gnus-data-list t))
7984 articles d children)
7985 ;; Find all articles that are either not dormant or have
7986 ;; children.
7987 (while (setq d (pop data))
7988 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7989 (and (setq children
7990 (gnus-article-children (gnus-data-number d)))
7991 (let (found)
7992 (while children
7993 (when (memq (car children) articles)
7994 (setq children nil
7995 found t))
7996 (pop children))
7997 found)))
7998 (push (gnus-data-number d) articles)))
7999 ;; Do the limiting.
8000 (prog1
8001 (gnus-summary-limit articles)
8002 (gnus-summary-position-point))))
8003
8004(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8005 "Mark all unread excluded articles as read.
8006If ALL, mark even excluded ticked and dormants as read."
8007 (interactive "P")
23f87bed
MB
8008 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8009 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8010 (sort
8011 (mapcar (lambda (h) (mail-header-number h))
8012 gnus-newsgroup-headers)
8013 '<)
23f87bed 8014 gnus-newsgroup-limit))
eec82323 8015 article)
6748645f 8016 (setq gnus-newsgroup-unreads
23f87bed
MB
8017 (gnus-sorted-intersection gnus-newsgroup-unreads
8018 gnus-newsgroup-limit))
eec82323
LMI
8019 (if all
8020 (setq gnus-newsgroup-dormant nil
8021 gnus-newsgroup-marked nil
8022 gnus-newsgroup-reads
8023 (nconc
8024 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8025 gnus-newsgroup-reads))
8026 (while (setq article (pop articles))
8027 (unless (or (memq article gnus-newsgroup-dormant)
8028 (memq article gnus-newsgroup-marked))
8029 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8030
8031(defun gnus-summary-limit (articles &optional pop)
8032 (if pop
8033 ;; We pop the previous limit off the stack and use that.
8034 (setq articles (car gnus-newsgroup-limits)
8035 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8036 ;; We use the new limit, so we push the old limit on the stack.
8037 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8038 ;; Set the limit.
8039 (setq gnus-newsgroup-limit articles)
8040 (let ((total (length gnus-newsgroup-data))
8041 (data (gnus-data-find-list (gnus-summary-article-number)))
8042 (gnus-summary-mark-below nil) ; Inhibit this.
8043 found)
8044 ;; This will do all the work of generating the new summary buffer
8045 ;; according to the new limit.
8046 (gnus-summary-prepare)
8047 ;; Hide any threads, possibly.
23f87bed 8048 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8049 ;; Try to return to the article you were at, or one in the
8050 ;; neighborhood.
8051 (when data
8052 ;; We try to find some article after the current one.
8053 (while data
8054 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8055 (setq data nil
8056 found t))
8057 (setq data (cdr data))))
8058 (unless found
8059 ;; If there is no data, that means that we were after the last
8060 ;; article. The same goes when we can't find any articles
8061 ;; after the current one.
8062 (goto-char (point-max))
8063 (gnus-summary-find-prev))
6748645f 8064 (gnus-set-mode-line 'summary)
eec82323
LMI
8065 ;; We return how many articles were removed from the summary
8066 ;; buffer as a result of the new limit.
8067 (- total (length gnus-newsgroup-data))))
8068
8069(defsubst gnus-invisible-cut-children (threads)
8070 (let ((num 0))
8071 (while threads
8072 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8073 (incf num))
8074 (pop threads))
8075 (< num 2)))
8076
8077(defsubst gnus-cut-thread (thread)
8078 "Go forwards in the thread until we find an article that we want to display."
8079 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8080 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8081 (numberp gnus-fetch-old-headers)
eec82323
LMI
8082 (eq gnus-build-sparse-threads 'some)
8083 (eq gnus-build-sparse-threads 'more))
8084 ;; Deal with old-fetched headers and sparse threads.
8085 (while (and
8086 thread
8087 (or
8088 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8089 (gnus-summary-article-ancient-p
8090 (mail-header-number (car thread))))
6748645f
LMI
8091 (if (or (<= (length (cdr thread)) 1)
8092 (eq gnus-fetch-old-headers 'invisible))
8093 (setq gnus-newsgroup-limit
8094 (delq (mail-header-number (car thread))
8095 gnus-newsgroup-limit)
8096 thread (cadr thread))
8097 (when (gnus-invisible-cut-children (cdr thread))
8098 (let ((th (cdr thread)))
8099 (while th
8100 (if (memq (mail-header-number (caar th))
a8151ef7 8101 gnus-newsgroup-limit)
6748645f
LMI
8102 (setq thread (car th)
8103 th nil)
8104 (setq th (cdr th))))))))))
eec82323
LMI
8105 thread)
8106
8107(defun gnus-cut-threads (threads)
23f87bed 8108 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8109 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8110 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8111 (numberp gnus-fetch-old-headers)
eec82323
LMI
8112 (eq gnus-build-sparse-threads 'some)
8113 (eq gnus-build-sparse-threads 'more))
8114 (let ((th threads))
8115 (while th
8116 (setcar th (gnus-cut-thread (car th)))
8117 (setq th (cdr th)))))
8118 ;; Remove nixed out threads.
8119 (delq nil threads))
8120
8121(defun gnus-summary-initial-limit (&optional show-if-empty)
8122 "Figure out what the initial limit is supposed to be on group entry.
8123This entails weeding out unwanted dormants, low-scored articles,
8124fetch-old-headers verbiage, and so on."
8125 ;; Most groups have nothing to remove.
8126 (if (or gnus-inhibit-limiting
8127 (and (null gnus-newsgroup-dormant)
23f87bed 8128 (eq gnus-newsgroup-display 'gnus-not-ignore)
eec82323 8129 (not (eq gnus-fetch-old-headers 'some))
16409b0b 8130 (not (numberp gnus-fetch-old-headers))
6748645f 8131 (not (eq gnus-fetch-old-headers 'invisible))
eec82323
LMI
8132 (null gnus-summary-expunge-below)
8133 (not (eq gnus-build-sparse-threads 'some))
8134 (not (eq gnus-build-sparse-threads 'more))
8135 (null gnus-thread-expunge-below)
8136 (not gnus-use-nocem)))
8137 () ; Do nothing.
8138 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8139 (setq gnus-newsgroup-limit nil)
8140 (mapatoms
8141 (lambda (node)
8142 (unless (car (symbol-value node))
8143 ;; These threads have no parents -- they are roots.
8144 (let ((nodes (cdr (symbol-value node)))
8145 thread)
8146 (while nodes
8147 (if (and gnus-thread-expunge-below
8148 (< (gnus-thread-total-score (car nodes))
8149 gnus-thread-expunge-below))
8150 (gnus-expunge-thread (pop nodes))
8151 (setq thread (pop nodes))
8152 (gnus-summary-limit-children thread))))))
8153 gnus-newsgroup-dependencies)
8154 ;; If this limitation resulted in an empty group, we might
8155 ;; pop the previous limit and use it instead.
8156 (when (and (not gnus-newsgroup-limit)
8157 show-if-empty)
8158 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8159 gnus-newsgroup-limit))
8160
8161(defun gnus-summary-limit-children (thread)
8162 "Return 1 if this subthread is visible and 0 if it is not."
8163 ;; First we get the number of visible children to this thread. This
8164 ;; is done by recursing down the thread using this function, so this
8165 ;; will really go down to a leaf article first, before slowly
8166 ;; working its way up towards the root.
8167 (when thread
23f87bed
MB
8168 (let* ((max-lisp-eval-depth 5000)
8169 (children
eec82323
LMI
8170 (if (cdr thread)
8171 (apply '+ (mapcar 'gnus-summary-limit-children
8172 (cdr thread)))
8173 0))
8174 (number (mail-header-number (car thread)))
8175 score)
8176 (if (and
8177 (not (memq number gnus-newsgroup-marked))
8178 (or
8179 ;; If this article is dormant and has absolutely no visible
8180 ;; children, then this article isn't visible.
8181 (and (memq number gnus-newsgroup-dormant)
8182 (zerop children))
8183 ;; If this is "fetch-old-headered" and there is no
8184 ;; visible children, then we don't want this article.
16409b0b
GM
8185 (and (or (eq gnus-fetch-old-headers 'some)
8186 (numberp gnus-fetch-old-headers))
eec82323
LMI
8187 (gnus-summary-article-ancient-p number)
8188 (zerop children))
6748645f
LMI
8189 ;; If this is "fetch-old-headered" and `invisible', then
8190 ;; we don't want this article.
8191 (and (eq gnus-fetch-old-headers 'invisible)
8192 (gnus-summary-article-ancient-p number))
eec82323
LMI
8193 ;; If this is a sparsely inserted article with no children,
8194 ;; we don't want it.
8195 (and (eq gnus-build-sparse-threads 'some)
8196 (gnus-summary-article-sparse-p number)
8197 (zerop children))
8198 ;; If we use expunging, and this article is really
8199 ;; low-scored, then we don't want this article.
8200 (when (and gnus-summary-expunge-below
8201 (< (setq score
8202 (or (cdr (assq number gnus-newsgroup-scored))
8203 gnus-summary-default-score))
8204 gnus-summary-expunge-below))
8205 ;; We increase the expunge-tally here, but that has
8206 ;; nothing to do with the limits, really.
8207 (incf gnus-newsgroup-expunged-tally)
8208 ;; We also mark as read here, if that's wanted.
8209 (when (and gnus-summary-mark-below
8210 (< score gnus-summary-mark-below))
8211 (setq gnus-newsgroup-unreads
8212 (delq number gnus-newsgroup-unreads))
8213 (if gnus-newsgroup-auto-expire
8214 (push number gnus-newsgroup-expirable)
8215 (push (cons number gnus-low-score-mark)
8216 gnus-newsgroup-reads)))
8217 t)
23f87bed
MB
8218 ;; Do the `display' group parameter.
8219 (and gnus-newsgroup-display
8220 (not (funcall gnus-newsgroup-display)))
eec82323
LMI
8221 ;; Check NoCeM things.
8222 (if (and gnus-use-nocem
8223 (gnus-nocem-unwanted-article-p
8224 (mail-header-id (car thread))))
8225 (progn
a8151ef7 8226 (setq gnus-newsgroup-unreads
eec82323
LMI
8227 (delq number gnus-newsgroup-unreads))
8228 t))))
8229 ;; Nope, invisible article.
8230 0
8231 ;; Ok, this article is to be visible, so we add it to the limit
8232 ;; and return 1.
8233 (push number gnus-newsgroup-limit)
8234 1))))
8235
8236(defun gnus-expunge-thread (thread)
8237 "Mark all articles in THREAD as read."
8238 (let* ((number (mail-header-number (car thread))))
8239 (incf gnus-newsgroup-expunged-tally)
8240 ;; We also mark as read here, if that's wanted.
8241 (setq gnus-newsgroup-unreads
8242 (delq number gnus-newsgroup-unreads))
8243 (if gnus-newsgroup-auto-expire
8244 (push number gnus-newsgroup-expirable)
8245 (push (cons number gnus-low-score-mark)
8246 gnus-newsgroup-reads)))
8247 ;; Go recursively through all subthreads.
8248 (mapcar 'gnus-expunge-thread (cdr thread)))
8249
8250;; Summary article oriented commands
8251
8252(defun gnus-summary-refer-parent-article (n)
8253 "Refer parent article N times.
8254If N is negative, go to ancestor -N instead.
8255The difference between N and the number of articles fetched is returned."
8256 (interactive "p")
eec82323
LMI
8257 (let ((skip 1)
8258 error header ref)
8259 (when (not (natnump n))
8260 (setq skip (abs n)
8261 n 1))
8262 (while (and (> n 0)
8263 (not error))
8264 (setq header (gnus-summary-article-header))
8265 (if (and (eq (mail-header-number header)
8266 (cdr gnus-article-current))
8267 (equal gnus-newsgroup-name
8268 (car gnus-article-current)))
8269 ;; If we try to find the parent of the currently
8270 ;; displayed article, then we take a look at the actual
8271 ;; References header, since this is slightly more
8272 ;; reliable than the References field we got from the
8273 ;; server.
8274 (save-excursion
8275 (set-buffer gnus-original-article-buffer)
8276 (nnheader-narrow-to-headers)
8277 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8278 (when (setq ref (message-fetch-field "in-reply-to"))
8279 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8280 (widen))
8281 (setq ref
8282 ;; It's not the current article, so we take a bet on
8283 ;; the value we got from the server.
8284 (mail-header-references header)))
8285 (if (and ref
8286 (not (equal ref "")))
8287 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8288 (gnus-message 1 "Couldn't find parent"))
8289 (gnus-message 1 "No references in article %d"
8290 (gnus-summary-article-number))
8291 (setq error t))
8292 (decf n))
8293 (gnus-summary-position-point)
8294 n))
8295
8296(defun gnus-summary-refer-references ()
8297 "Fetch all articles mentioned in the References header.
6748645f 8298Return the number of articles fetched."
eec82323 8299 (interactive)
eec82323
LMI
8300 (let ((ref (mail-header-references (gnus-summary-article-header)))
8301 (current (gnus-summary-article-number))
8302 (n 0))
8303 (if (or (not ref)
8304 (equal ref ""))
8305 (error "No References in the current article")
8306 ;; For each Message-ID in the References header...
8307 (while (string-match "<[^>]*>" ref)
8308 (incf n)
8309 ;; ... fetch that article.
8310 (gnus-summary-refer-article
8311 (prog1 (match-string 0 ref)
8312 (setq ref (substring ref (match-end 0))))))
8313 (gnus-summary-goto-subject current)
8314 (gnus-summary-position-point)
8315 n)))
8316
6748645f
LMI
8317(defun gnus-summary-refer-thread (&optional limit)
8318 "Fetch all articles in the current thread.
8319If LIMIT (the numerical prefix), fetch that many old headers instead
8320of what's specified by the `gnus-refer-thread-limit' variable."
8321 (interactive "P")
8322 (let ((id (mail-header-id (gnus-summary-article-header)))
8323 (limit (if limit (prefix-numeric-value limit)
8324 gnus-refer-thread-limit)))
6748645f
LMI
8325 (unless (eq gnus-fetch-old-headers 'invisible)
8326 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8327 ;; Retrieve the headers and read them in.
23f87bed
MB
8328 (if (eq (if (numberp limit)
8329 (gnus-retrieve-headers
8330 (list (min
8331 (+ (mail-header-number
8332 (gnus-summary-article-header))
8333 limit)
8334 gnus-newsgroup-end))
8335 gnus-newsgroup-name (* limit 2))
8336 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8337 ;; headers.
8338 (gnus-retrieve-headers (list gnus-newsgroup-end)
8339 gnus-newsgroup-name limit))
6748645f
LMI
8340 'nov)
8341 (gnus-build-all-threads)
23f87bed 8342 (error "Can't fetch thread from back ends that don't support NOV"))
6748645f
LMI
8343 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8344 (gnus-summary-limit-include-thread id)))
8345
16409b0b
GM
8346(defun gnus-summary-refer-article (message-id)
8347 "Fetch an article specified by MESSAGE-ID."
8348 (interactive "sMessage-ID: ")
eec82323
LMI
8349 (when (and (stringp message-id)
8350 (not (zerop (length message-id))))
23f87bed 8351 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8352 ;; Construct the correct Message-ID if necessary.
8353 ;; Suggested by tale@pawl.rpi.edu.
8354 (unless (string-match "^<" message-id)
8355 (setq message-id (concat "<" message-id)))
8356 (unless (string-match ">$" message-id)
8357 (setq message-id (concat message-id ">")))
23f87bed
MB
8358 ;; People often post MIDs from URLs, so unhex it:
8359 (unless (string-match "@" message-id)
8360 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8361 (let* ((header (gnus-id-to-header message-id))
8362 (sparse (and header
8363 (gnus-summary-article-sparse-p
a8151ef7
LMI
8364 (mail-header-number header))
8365 (memq (mail-header-number header)
16409b0b
GM
8366 gnus-newsgroup-limit)))
8367 number)
6748645f
LMI
8368 (cond
8369 ;; If the article is present in the buffer we just go to it.
8370 ((and header
8371 (or (not (gnus-summary-article-sparse-p
8372 (mail-header-number header)))
8373 sparse))
8374 (prog1
8375 (gnus-summary-goto-article
8376 (mail-header-number header) nil t)
8377 (when sparse
8378 (gnus-summary-update-article (mail-header-number header)))))
8379 (t
16409b0b
GM
8380 ;; We fetch the article.
8381 (catch 'found
8382 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8383 (when (and (gnus-check-server gnus-override-method)
8384 ;; Fetch the header,
8385 (setq number (gnus-summary-insert-subject message-id)))
8386 ;; and display the article.
eec82323 8387 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8388 (throw 'found t)))
8389 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8390
8391(defun gnus-refer-article-methods ()
8f688cb0 8392 "Return a list of referable methods."
16409b0b
GM
8393 (cond
8394 ;; No method, so we default to current and native.
8395 ((null gnus-refer-article-method)
8396 (list gnus-current-select-method gnus-select-method))
8397 ;; Current.
8398 ((eq 'current gnus-refer-article-method)
8399 (list gnus-current-select-method))
8400 ;; List of select methods.
d4dfaa19
DL
8401 ((not (and (symbolp (car gnus-refer-article-method))
8402 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
8403 (let (out)
8404 (dolist (method gnus-refer-article-method)
8405 (push (if (eq 'current method)
8406 gnus-current-select-method
8407 method)
8408 out))
8409 (nreverse out)))
8410 ;; One single select method.
8411 (t
8412 (list gnus-refer-article-method))))
6748645f
LMI
8413
8414(defun gnus-summary-edit-parameters ()
8415 "Edit the group parameters of the current group."
8416 (interactive)
8417 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 8418
16409b0b
GM
8419(defun gnus-summary-customize-parameters ()
8420 "Customize the group parameters of the current group."
8421 (interactive)
8422 (gnus-group-customize gnus-newsgroup-name))
8423
eec82323
LMI
8424(defun gnus-summary-enter-digest-group (&optional force)
8425 "Enter an nndoc group based on the current article.
8426If FORCE, force a digest interpretation. If not, try
8427to guess what the document format is."
8428 (interactive "P")
eec82323 8429 (let ((conf gnus-current-window-configuration))
23f87bed
MB
8430 (save-window-excursion
8431 (save-excursion
8432 (let (gnus-article-prepare-hook
8433 gnus-display-mime-function
8434 gnus-break-pages)
8435 (gnus-summary-select-article))))
eec82323
LMI
8436 (setq gnus-current-window-configuration conf)
8437 (let* ((name (format "%s-%d"
8438 (gnus-group-prefixed-name
8439 gnus-newsgroup-name (list 'nndoc ""))
8440 (save-excursion
8441 (set-buffer gnus-summary-buffer)
8442 gnus-current-article)))
8443 (ogroup gnus-newsgroup-name)
8444 (params (append (gnus-info-params (gnus-get-info ogroup))
8445 (list (cons 'to-group ogroup))
23f87bed 8446 (list (cons 'parent-group ogroup))
eec82323
LMI
8447 (list (cons 'save-article-group ogroup))))
8448 (case-fold-search t)
8449 (buf (current-buffer))
16409b0b 8450 dig to-address)
eec82323 8451 (save-excursion
16409b0b
GM
8452 (set-buffer gnus-original-article-buffer)
8453 ;; Have the digest group inherit the main mail address of
8454 ;; the parent article.
23f87bed
MB
8455 (when (setq to-address (or (gnus-fetch-field "reply-to")
8456 (gnus-fetch-field "from")))
343d6628
MB
8457 (setq params
8458 (append
8459 (list (cons 'to-address
8460 (funcall gnus-decode-encoded-address-function
8461 to-address))))))
eec82323
LMI
8462 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8463 (insert-buffer-substring gnus-original-article-buffer)
8464 ;; Remove lines that may lead nndoc to misinterpret the
8465 ;; document type.
8466 (narrow-to-region
8467 (goto-char (point-min))
8468 (or (search-forward "\n\n" nil t) (point)))
8469 (goto-char (point-min))
16409b0b 8470 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8471 (widen))
8472 (unwind-protect
23f87bed 8473 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
8474 (gnus-newsgroup-ephemeral-ignored-charsets
8475 gnus-newsgroup-ignored-charsets))
8476 (gnus-group-read-ephemeral-group
8477 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8478 (nndoc-article-type
23f87bed
MB
8479 ,(if force 'mbox 'guess)))
8480 t nil nil nil
8481 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8482 "ADAPT")))))
16409b0b 8483 ;; Make all postings to this group go to the parent group.
23f87bed
MB
8484 (nconc (gnus-info-params (gnus-get-info name))
8485 params)
8486 ;; Couldn't select this doc group.
8487 (switch-to-buffer buf)
8488 (gnus-set-global-variables)
8489 (gnus-configure-windows 'summary)
8490 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
8491 (kill-buffer dig)))))
8492
8493(defun gnus-summary-read-document (n)
8494 "Open a new group based on the current article(s).
8495This will allow you to read digests and other similar
8496documents as newsgroups.
8497Obeys the standard process/prefix convention."
8498 (interactive "P")
8499 (let* ((articles (gnus-summary-work-articles n))
8500 (ogroup gnus-newsgroup-name)
8501 (params (append (gnus-info-params (gnus-get-info ogroup))
8502 (list (cons 'to-group ogroup))))
8503 article group egroup groups vgroup)
8504 (while (setq article (pop articles))
8505 (setq group (format "%s-%d" gnus-newsgroup-name article))
8506 (gnus-summary-remove-process-mark article)
8507 (when (gnus-summary-display-article article)
8508 (save-excursion
16409b0b 8509 (with-temp-buffer
eec82323
LMI
8510 (insert-buffer-substring gnus-original-article-buffer)
8511 ;; Remove some headers that may lead nndoc to make
8512 ;; the wrong guess.
8513 (message-narrow-to-head)
8514 (goto-char (point-min))
8515 (delete-matching-lines "^\\(Path\\):\\|^From ")
8516 (widen)
8517 (if (setq egroup
8518 (gnus-group-read-ephemeral-group
8519 group `(nndoc ,group (nndoc-address ,(current-buffer))
8520 (nndoc-article-type guess))
8521 t nil t))
8522 (progn
23f87bed 8523 ;; Make all postings to this group go to the parent group.
eec82323
LMI
8524 (nconc (gnus-info-params (gnus-get-info egroup))
8525 params)
8526 (push egroup groups))
8527 ;; Couldn't select this doc group.
8528 (gnus-error 3 "Article couldn't be entered"))))))
8529 ;; Now we have selected all the documents.
8530 (cond
8531 ((not groups)
8532 (error "None of the articles could be interpreted as documents"))
8533 ((gnus-group-read-ephemeral-group
8534 (setq vgroup (format
8535 "nnvirtual:%s-%s" gnus-newsgroup-name
8536 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8537 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8538 t
8539 (cons (current-buffer) 'summary)))
8540 (t
8541 (error "Couldn't select virtual nndoc group")))))
8542
8543(defun gnus-summary-isearch-article (&optional regexp-p)
8544 "Do incremental search forward on the current article.
8545If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8546 (interactive "P")
eec82323
LMI
8547 (gnus-summary-select-article)
8548 (gnus-configure-windows 'article)
8549 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
8550 (save-restriction
8551 (widen)
8552 (isearch-forward regexp-p))))
eec82323
LMI
8553
8554(defun gnus-summary-search-article-forward (regexp &optional backward)
8555 "Search for an article containing REGEXP forward.
8556If BACKWARD, search backward instead."
8557 (interactive
8558 (list (read-string
8559 (format "Search article %s (regexp%s): "
8560 (if current-prefix-arg "backward" "forward")
8561 (if gnus-last-search-regexp
8562 (concat ", default " gnus-last-search-regexp)
8563 "")))
8564 current-prefix-arg))
eec82323
LMI
8565 (if (string-equal regexp "")
8566 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
8567 (setq gnus-last-search-regexp regexp)
8568 (setq gnus-article-before-search gnus-current-article))
8569 ;; Intentionally set gnus-last-article.
8570 (setq gnus-last-article gnus-article-before-search)
8571 (let ((gnus-last-article gnus-last-article))
8572 (if (gnus-summary-search-article regexp backward)
8573 (gnus-summary-show-thread)
abc40aab 8574 (signal 'search-failed (list regexp)))))
eec82323
LMI
8575
8576(defun gnus-summary-search-article-backward (regexp)
8577 "Search for an article containing REGEXP backward."
8578 (interactive
8579 (list (read-string
8580 (format "Search article backward (regexp%s): "
8581 (if gnus-last-search-regexp
8582 (concat ", default " gnus-last-search-regexp)
8583 "")))))
8584 (gnus-summary-search-article-forward regexp 'backward))
8585
8586(defun gnus-summary-search-article (regexp &optional backward)
8587 "Search for an article containing REGEXP.
8588Optional argument BACKWARD means do search for backward.
8589`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
8590 ;; We have to require this here to make sure that the following
8591 ;; dynamic binding isn't shadowed by autoloading.
8592 (require 'gnus-async)
16409b0b 8593 (require 'gnus-art)
eec82323 8594 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 8595 (gnus-article-prepare-hook nil)
eec82323
LMI
8596 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8597 (gnus-use-article-prefetch nil)
8598 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 8599 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
8600 (gnus-visual nil)
8601 (gnus-keep-backlog nil)
8602 (gnus-break-pages nil)
8603 (gnus-summary-display-arrow nil)
8604 (gnus-updated-mode-lines nil)
8605 (gnus-auto-center-summary nil)
eec82323 8606 (sum (current-buffer))
16409b0b 8607 (gnus-display-mime-function nil)
eec82323
LMI
8608 (found nil)
8609 point)
8610 (gnus-save-hidden-threads
8611 (gnus-summary-select-article)
8612 (set-buffer gnus-article-buffer)
16409b0b 8613 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
8614 (when backward
8615 (forward-line -1))
8616 (while (not found)
8617 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8618 (if (if backward
8619 (re-search-backward regexp nil t)
8620 (re-search-forward regexp nil t))
8621 ;; We found the regexp.
8622 (progn
8623 (setq found 'found)
8624 (beginning-of-line)
8625 (set-window-start
8626 (get-buffer-window (current-buffer))
8627 (point))
8628 (forward-line 1)
16409b0b
GM
8629 (set-window-point
8630 (get-buffer-window (current-buffer))
8631 (point))
eec82323
LMI
8632 (set-buffer sum)
8633 (setq point (point)))
8634 ;; We didn't find it, so we go to the next article.
8635 (set-buffer sum)
8636 (setq found 'not)
8637 (while (eq found 'not)
8638 (if (not (if backward (gnus-summary-find-prev)
8639 (gnus-summary-find-next)))
8640 ;; No more articles.
8641 (setq found t)
8642 ;; Select the next article and adjust point.
8643 (unless (gnus-summary-article-sparse-p
8644 (gnus-summary-article-number))
8645 (setq found nil)
8646 (gnus-summary-select-article)
8647 (set-buffer gnus-article-buffer)
8648 (widen)
8649 (goto-char (if backward (point-max) (point-min))))))))
8650 (gnus-message 7 ""))
8651 ;; Return whether we found the regexp.
8652 (when (eq found 'found)
8653 (goto-char point)
8654 (gnus-summary-show-thread)
8655 (gnus-summary-goto-subject gnus-current-article)
8656 (gnus-summary-position-point)
8657 t)))
8658
23f87bed
MB
8659(defun gnus-find-matching-articles (header regexp)
8660 "Return a list of all articles that match REGEXP on HEADER.
8661This search includes all articles in the current group that Gnus has
8662fetched headers for, whether they are displayed or not."
8663 (let ((articles nil)
8664 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8665 (case-fold-search t))
8666 (dolist (header gnus-newsgroup-headers)
8667 (when (string-match regexp (funcall func header))
8668 (push (mail-header-number header) articles)))
8669 (nreverse articles)))
8670
eec82323 8671(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 8672 not-case-fold not-matching)
eec82323
LMI
8673 "Return a list of all articles that match REGEXP on HEADER.
8674The search stars on the current article and goes forwards unless
8675BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8676If UNREAD is non-nil, only unread articles will
8677be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 8678in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
8679not match REGEXP on HEADER."
8680 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
8681 articles d func)
8682 (if (consp header)
8683 (if (eq (car header) 'extra)
8684 (setq func
8685 `(lambda (h)
8686 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8687 "")))
8688 (error "%s is an invalid header" header))
8689 (unless (fboundp (intern (concat "mail-header-" header)))
8690 (error "%s is not a valid header" header))
8691 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
8692 (dolist (d (if (eq backward 'all)
8693 gnus-newsgroup-data
8694 (gnus-data-find-list
8695 (gnus-summary-article-number)
8696 (gnus-data-list backward))))
8697 (when (and (or (not unread) ; We want all articles...
8698 (gnus-data-unread-p d)) ; Or just unreads.
8699 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8700 (if not-matching
a1506d29 8701 (not (string-match
47b63dfa
SZ
8702 regexp
8703 (funcall func (gnus-data-header d))))
8704 (string-match regexp
8705 (funcall func (gnus-data-header d)))))
8706 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
8707 (nreverse articles)))
8708
8709(defun gnus-summary-execute-command (header regexp command &optional backward)
8710 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8711If HEADER is an empty string (or nil), the match is done on the entire
8712article. If BACKWARD (the prefix) is non-nil, search backward instead."
8713 (interactive
8714 (list (let ((completion-ignore-case t))
8715 (completing-read
8716 "Header name: "
23f87bed
MB
8717 (mapcar (lambda (header) (list (format "%s" header)))
8718 (append
8719 '("Number" "Subject" "From" "Lines" "Date"
8720 "Message-ID" "Xref" "References" "Body")
8721 gnus-extra-headers))
eec82323
LMI
8722 nil 'require-match))
8723 (read-string "Regexp: ")
8724 (read-key-sequence "Command: ")
8725 current-prefix-arg))
8726 (when (equal header "Body")
8727 (setq header ""))
eec82323
LMI
8728 ;; Hidden thread subtrees must be searched as well.
8729 (gnus-summary-show-all-threads)
8730 ;; We don't want to change current point nor window configuration.
8731 (save-excursion
8732 (save-window-excursion
23f87bed
MB
8733 (let (gnus-visual
8734 gnus-treat-strip-trailing-blank-lines
8735 gnus-treat-strip-leading-blank-lines
8736 gnus-treat-strip-multiple-blank-lines
8737 gnus-treat-hide-boring-headers
8738 gnus-treat-fold-newsgroups
8739 gnus-article-prepare-hook)
8740 (gnus-message 6 "Executing %s..." (key-description command))
8741 ;; We'd like to execute COMMAND interactively so as to give arguments.
8742 (gnus-execute header regexp
8743 `(call-interactively ',(key-binding command))
8744 backward)
8745 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
8746
8747(defun gnus-summary-beginning-of-article ()
8748 "Scroll the article back to the beginning."
8749 (interactive)
eec82323
LMI
8750 (gnus-summary-select-article)
8751 (gnus-configure-windows 'article)
8752 (gnus-eval-in-buffer-window gnus-article-buffer
8753 (widen)
8754 (goto-char (point-min))
23f87bed 8755 (when gnus-break-pages
eec82323
LMI
8756 (gnus-narrow-to-page))))
8757
8758(defun gnus-summary-end-of-article ()
8759 "Scroll to the end of the article."
8760 (interactive)
eec82323
LMI
8761 (gnus-summary-select-article)
8762 (gnus-configure-windows 'article)
8763 (gnus-eval-in-buffer-window gnus-article-buffer
8764 (widen)
8765 (goto-char (point-max))
8766 (recenter -3)
23f87bed
MB
8767 (when gnus-break-pages
8768 (when (re-search-backward page-delimiter nil t)
8769 (narrow-to-region (match-end 0) (point-max)))
eec82323
LMI
8770 (gnus-narrow-to-page))))
8771
23f87bed
MB
8772(defun gnus-summary-print-truncate-and-quote (string &optional len)
8773 "Truncate to LEN and quote all \"(\"'s in STRING."
8774 (gnus-replace-in-string (if (and len (> (length string) len))
8775 (substring string 0 len)
8776 string)
8777 "[()]" "\\\\\\&"))
8778
6748645f 8779(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
8780 "Generate and print a PostScript image of the process-marked (mail) articles.
8781
8782If used interactively, print the current article if none are
8783process-marked. With prefix arg, prompt the user for the name of the
8784file to save in.
6748645f 8785
23f87bed
MB
8786When used from Lisp, accept two optional args FILENAME and N. N means
8787to print the next N articles. If N is negative, print the N previous
8788articles. If N is nil and articles have been marked with the process
8789mark, print these instead.
eec82323 8790
16409b0b 8791If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
8792printer. If FILENAME is a string, save the PostScript image in a file with
8793that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 8794to save in."
676a7cc9 8795 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
8796 (dolist (article (gnus-summary-work-articles n))
8797 (gnus-summary-select-article nil nil 'pseudo article)
8798 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 8799 (gnus-print-buffer))
676a7cc9
SZ
8800 (gnus-summary-remove-process-mark article))
8801 (ps-despool filename))
eec82323 8802
23f87bed
MB
8803(defun gnus-print-buffer ()
8804 (let ((buffer (generate-new-buffer " *print*")))
8805 (unwind-protect
8806 (progn
8807 (copy-to-buffer buffer (point-min) (point-max))
8808 (set-buffer buffer)
8809 (gnus-remove-text-with-property 'gnus-decoration)
8810 (when (gnus-visual-p 'article-highlight 'highlight)
8811 ;; Copy-to-buffer doesn't copy overlay. So redo
8812 ;; highlight.
8813 (let ((gnus-article-buffer buffer))
8814 (gnus-article-highlight-citation t)
8815 (gnus-article-highlight-signature)
8816 (gnus-article-emphasize)
8817 (gnus-article-delete-invisible-text)))
8818 (let ((ps-left-header
8819 (list
8820 (concat "("
8821 (gnus-summary-print-truncate-and-quote
8822 (mail-header-subject gnus-current-headers)
8823 66) ")")
8824 (concat "("
8825 (gnus-summary-print-truncate-and-quote
8826 (mail-header-from gnus-current-headers)
8827 45) ")")))
8828 (ps-right-header
8829 (list
8830 "/pagenumberstring load"
8831 (concat "("
8832 (mail-header-date gnus-current-headers) ")"))))
8833 (gnus-run-hooks 'gnus-ps-print-hook)
8834 (save-excursion
8835 (if window-system
8836 (ps-spool-buffer-with-faces)
8837 (ps-spool-buffer)))))
8838 (kill-buffer buffer))))
8839
eec82323 8840(defun gnus-summary-show-article (&optional arg)
23f87bed 8841 "Force redisplaying of the current article.
16409b0b
GM
8842If ARG (the prefix) is a number, show the article with the charset
8843defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 8844input.
16409b0b 8845If ARG (the prefix) is non-nil and not a number, show the raw article
23f87bed
MB
8846without any article massaging functions being run. Normally, the key
8847strokes are `C-u g'."
eec82323 8848 (interactive "P")
16409b0b
GM
8849 (cond
8850 ((numberp arg)
23f87bed 8851 (gnus-summary-show-article t)
16409b0b
GM
8852 (let ((gnus-newsgroup-charset
8853 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
8854 (mm-read-coding-system
8855 "View as charset: " ;; actually it is coding system.
8856 (save-excursion
8857 (set-buffer gnus-article-buffer)
8858 (mm-detect-coding-region (point) (point-max))))))
16409b0b 8859 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
8860 (gnus-summary-select-article nil 'force)
8861 (let ((deps gnus-newsgroup-dependencies)
8862 head header lines)
8863 (save-excursion
8864 (set-buffer gnus-original-article-buffer)
8865 (save-restriction
8866 (message-narrow-to-head)
8867 (setq head (buffer-string))
8868 (goto-char (point-min))
8869 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8870 (goto-char (point-max))
8871 (widen)
8872 (setq lines (1- (count-lines (point) (point-max))))))
8873 (with-temp-buffer
8874 (insert (format "211 %d Article retrieved.\n"
8875 (cdr gnus-article-current)))
8876 (insert head)
8877 (if lines (insert (format "Lines: %d\n" lines)))
8878 (insert ".\n")
8879 (let ((nntp-server-buffer (current-buffer)))
8880 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8881 (gnus-data-set-header
8882 (gnus-data-find (cdr gnus-article-current))
8883 header)
8884 (gnus-summary-update-article-line
8885 (cdr gnus-article-current) header)
8886 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8887 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
8888 ((not arg)
8889 ;; Select the article the normal way.
8890 (gnus-summary-select-article nil 'force))
8891 (t
8892 ;; We have to require this here to make sure that the following
8893 ;; dynamic binding isn't shadowed by autoloading.
8894 (require 'gnus-async)
8895 (require 'gnus-art)
eec82323
LMI
8896 ;; Bind the article treatment functions to nil.
8897 (let ((gnus-have-all-headers t)
eec82323 8898 gnus-article-prepare-hook
16409b0b
GM
8899 gnus-article-decode-hook
8900 gnus-display-mime-function
8901 gnus-break-pages)
8902 ;; Destroy any MIME parts.
8903 (when (gnus-buffer-live-p gnus-article-buffer)
8904 (save-excursion
8905 (set-buffer gnus-article-buffer)
8906 (mm-destroy-parts gnus-article-mime-handles)
8907 ;; Set it to nil for safety reason.
8908 (setq gnus-article-mime-handle-alist nil)
8909 (setq gnus-article-mime-handles nil)))
8910 (gnus-summary-select-article nil 'force))))
eec82323
LMI
8911 (gnus-summary-goto-subject gnus-current-article)
8912 (gnus-summary-position-point))
8913
23f87bed
MB
8914(defun gnus-summary-show-raw-article ()
8915 "Show the raw article without any article massaging functions being run."
8916 (interactive)
8917 (gnus-summary-show-article t))
8918
eec82323
LMI
8919(defun gnus-summary-verbose-headers (&optional arg)
8920 "Toggle permanent full header display.
8921If ARG is a positive number, turn header display on.
8922If ARG is a negative number, turn header display off."
8923 (interactive "P")
eec82323
LMI
8924 (setq gnus-show-all-headers
8925 (cond ((or (not (numberp arg))
8926 (zerop arg))
8927 (not gnus-show-all-headers))
8928 ((natnump arg)
8929 t)))
8930 (gnus-summary-show-article))
8931
8932(defun gnus-summary-toggle-header (&optional arg)
8933 "Show the headers if they are hidden, or hide them if they are shown.
8934If ARG is a positive number, show the entire header.
8935If ARG is a negative number, hide the unwanted header lines."
8936 (interactive "P")
23f87bed
MB
8937 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8938 (get-buffer-window gnus-article-buffer t))))
8939 (with-current-buffer gnus-article-buffer
8940 (widen)
8941 (article-narrow-to-head)
16409b0b
GM
8942 (let* ((buffer-read-only nil)
8943 (inhibit-point-motion-hooks t)
23f87bed
MB
8944 (hidden (if (numberp arg)
8945 (>= arg 0)
f0096211
MB
8946 (or (not (looking-at "[^ \t\n]+:"))
8947 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
8948 s e)
8949 (delete-region (point-min) (point-max))
667e0ba6
SM
8950 (with-current-buffer gnus-original-article-buffer
8951 (goto-char (setq s (point-min)))
23f87bed
MB
8952 (setq e (if (search-forward "\n\n" nil t)
8953 (1- (point))
8954 (point-max))))
667e0ba6 8955 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
8956 (run-hooks 'gnus-article-decode-hook)
8957 (if hidden
8958 (let ((gnus-treat-hide-headers nil)
8959 (gnus-treat-hide-boring-headers nil))
8960 (gnus-delete-wash-type 'headers)
8961 (gnus-treat-article 'head))
8962 (gnus-treat-article 'head))
8963 (widen)
8964 (if window
8965 (set-window-start window (goto-char (point-min))))
8966 (if gnus-break-pages
8967 (gnus-narrow-to-page)
8968 (when (gnus-visual-p 'page-marker)
8969 (let ((buffer-read-only nil))
8970 (gnus-remove-text-with-property 'gnus-prev)
8971 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 8972 (gnus-set-mode-line 'article)))))
eec82323
LMI
8973
8974(defun gnus-summary-show-all-headers ()
8975 "Make all header lines visible."
8976 (interactive)
23f87bed 8977 (gnus-summary-toggle-header 1))
eec82323 8978
eec82323
LMI
8979(defun gnus-summary-caesar-message (&optional arg)
8980 "Caesar rotate the current article by 13.
8981The numerical prefix specifies how many places to rotate each letter
8982forward."
8983 (interactive "P")
eec82323
LMI
8984 (gnus-summary-select-article)
8985 (let ((mail-header-separator ""))
8986 (gnus-eval-in-buffer-window gnus-article-buffer
8987 (save-restriction
8988 (widen)
8989 (let ((start (window-start))
8990 buffer-read-only)
8991 (message-caesar-buffer-body arg)
ff4d3926
MB
8992 (set-window-start (get-buffer-window (current-buffer)) start)))))
8993 ;; Create buttons and stuff...
8994 (gnus-treat-article nil))
eec82323 8995
23f87bed
MB
8996(autoload 'unmorse-region "morse"
8997 "Convert morse coded text in region to ordinary ASCII text."
8998 t)
8999
9000(defun gnus-summary-morse-message (&optional arg)
9001 "Morse decode the current article."
9002 (interactive "P")
9003 (gnus-summary-select-article)
9004 (let ((mail-header-separator ""))
9005 (gnus-eval-in-buffer-window gnus-article-buffer
9006 (save-excursion
9007 (save-restriction
9008 (widen)
9009 (let ((pos (window-start))
9010 buffer-read-only)
9011 (goto-char (point-min))
9012 (when (message-goto-body)
9013 (gnus-narrow-to-body))
9014 (goto-char (point-min))
9015