Set scroll bar mode to right if set by X resources.
[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
01ccbb85 18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eec82323
LMI
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
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
01ccbb85 113subject fields. (Or rather, they will be printed with a string
eec82323
LMI
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
4921bbdd
CY
3346(defun gnus-make-thread-indent-array (&optional n)
3347 (when (or n
3348 (progn (setq n 200) nil)
3349 (null gnus-thread-indent-array)
3350 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3351 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3352 gnus-thread-indent-array-level gnus-thread-indent-level)
3353 (while (>= n 0)
3354 (aset gnus-thread-indent-array n
6a30c01d 3355 (make-string (* n gnus-thread-indent-level) ? ))
4921bbdd 3356 (setq n (1- n)))))
eec82323
LMI
3357
3358(defun gnus-update-summary-mark-positions ()
3359 "Compute where the summary marks are to go."
3360 (save-excursion
6748645f 3361 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3362 (set-buffer gnus-summary-buffer))
5153a47a
MB
3363 (let ((spec gnus-summary-line-format-spec)
3364 pos)
eec82323
LMI
3365 (save-excursion
3366 (gnus-set-work-buffer)
5153a47a
MB
3367 (let ((gnus-tmp-unread ?Z)
3368 (gnus-replied-mark ?Z)
3369 (gnus-score-below-mark ?Z)
3370 (gnus-score-over-mark ?Z)
3371 (gnus-undownloaded-mark ?Z)
3372 (gnus-summary-line-format-spec spec)
54506618 3373 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3374 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3375 case-fold-search ignores)
3376 ;; Here, all marks are bound to Z.
3377 (gnus-summary-insert-line header
3378 0 nil t gnus-tmp-unread t nil "" nil 1)
3379 (goto-char (point-min))
3380 ;; Memorize the positions of the same characters as dummy marks.
3381 (while (re-search-forward "[A-D]" nil t)
3382 (push (point) ignores))
54506618 3383 (erase-buffer)
5153a47a
MB
3384 ;; We use A-D as dummy marks in order to know column positions
3385 ;; where marks should be inserted.
3386 (setq gnus-tmp-unread ?A
3387 gnus-replied-mark ?B
3388 gnus-score-below-mark ?C
3389 gnus-score-over-mark ?C
3390 gnus-undownloaded-mark ?D)
3391 (gnus-summary-insert-line header
3392 0 nil t gnus-tmp-unread t nil "" nil 1)
3393 ;; Ignore characters which aren't dummy marks.
3394 (dolist (p ignores)
3395 (delete-region (goto-char (1- p)) p)
3396 (insert ?Z))
eec82323 3397 (goto-char (point-min))
7c3bb5a5 3398 (setq pos (list (cons 'unread
5153a47a 3399 (and (search-forward "A" nil t)
7c3bb5a5 3400 (- (point) (point-min) 1)))))
eec82323 3401 (goto-char (point-min))
5153a47a 3402 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3403 (- (point) (point-min) 1)))
eec82323
LMI
3404 pos)
3405 (goto-char (point-min))
5153a47a 3406 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3407 (- (point) (point-min) 1)))
6748645f
LMI
3408 pos)
3409 (goto-char (point-min))
5153a47a 3410 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3411 (- (point) (point-min) 1)))
eec82323
LMI
3412 pos)))
3413 (setq gnus-summary-mark-positions pos))))
3414
3415(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3416 "Insert a dummy root in the summary buffer."
3417 (beginning-of-line)
3418 (gnus-add-text-properties
3419 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3420 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3421
23f87bed
MB
3422(defun gnus-summary-extract-address-component (from)
3423 (or (car (funcall gnus-extract-address-components from))
3424 from))
3425
3426(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3427 (let ((mail-parse-charset gnus-newsgroup-charset)
3428 ; Is it really necessary to do this next part for each summary line?
3429 ; Luckily, doesn't seem to slow things down much.
16409b0b
GM
3430 (mail-parse-ignored-charsets
3431 (save-excursion (set-buffer gnus-summary-buffer)
3432 gnus-newsgroup-ignored-charsets)))
23f87bed
MB
3433 (or
3434 (and gnus-ignored-from-addresses
3435 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3436 (let ((extra-headers (mail-header-extra header))
3437 to
3438 newsgroups)
3439 (cond
3440 ((setq to (cdr (assq 'To extra-headers)))
3441 (concat "-> "
3442 (inline
3443 (gnus-summary-extract-address-component
343d6628 3444 (funcall gnus-decode-encoded-address-function to)))))
23f87bed
MB
3445 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3446 (concat "=> " newsgroups)))))
3447 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3448
eec82323
LMI
3449(defun gnus-summary-insert-line (gnus-tmp-header
3450 gnus-tmp-level gnus-tmp-current
23f87bed 3451 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3452 gnus-tmp-expirable gnus-tmp-subject-or-nil
3453 &optional gnus-tmp-dummy gnus-tmp-score
3454 gnus-tmp-process)
4921bbdd
CY
3455 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3456 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3457 gnus-tmp-level)))
eec82323
LMI
3458 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3459 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3460 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3461 (gnus-tmp-score-char
3462 (if (or (null gnus-summary-default-score)
3463 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3464 gnus-summary-zcore-fuzz))
23f87bed 3465 ? ;Whitespace
eec82323
LMI
3466 (if (< gnus-tmp-score gnus-summary-default-score)
3467 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3468 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3469 (gnus-tmp-replied
3470 (cond (gnus-tmp-process gnus-process-mark)
3471 ((memq gnus-tmp-current gnus-newsgroup-cached)
3472 gnus-cached-mark)
3473 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3474 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3475 gnus-forwarded-mark)
eec82323
LMI
3476 ((memq gnus-tmp-current gnus-newsgroup-saved)
3477 gnus-saved-mark)
23f87bed
MB
3478 ((memq gnus-tmp-number gnus-newsgroup-recent)
3479 gnus-recent-mark)
3480 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3481 gnus-unseen-mark)
3482 (t gnus-no-mark)))
3483 (gnus-tmp-downloaded
3484 (cond (undownloaded
3485 gnus-undownloaded-mark)
3486 (gnus-newsgroup-agentized
3487 gnus-downloaded-mark)
3488 (t
3489 gnus-no-mark)))
eec82323
LMI
3490 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3491 (gnus-tmp-name
3492 (cond
3493 ((string-match "<[^>]+> *$" gnus-tmp-from)
3494 (let ((beg (match-beginning 0)))
23f87bed
MB
3495 (or (and (string-match "^\".+\"" gnus-tmp-from)
3496 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3497 (substring gnus-tmp-from 0 beg))))
3498 ((string-match "(.+)" gnus-tmp-from)
3499 (substring gnus-tmp-from
3500 (1+ (match-beginning 0)) (1- (match-end 0))))
3501 (t gnus-tmp-from)))
3502 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3503 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3504 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3505 (buffer-read-only nil))
3506 (when (string= gnus-tmp-name "")
3507 (setq gnus-tmp-name gnus-tmp-from))
3508 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3509 (setq gnus-tmp-lines -1))
3510 (if (= gnus-tmp-lines -1)
3511 (setq gnus-tmp-lines "?")
3512 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3513 (gnus-put-text-property
eec82323
LMI
3514 (point)
3515 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 3516 'gnus-number gnus-tmp-number)
eec82323
LMI
3517 (when (gnus-visual-p 'summary-highlight 'highlight)
3518 (forward-line -1)
6748645f 3519 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3520 (forward-line 1))))
3521
3522(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3523 "Update summary line after change."
eec82323
LMI
3524 (when (and gnus-summary-default-score
3525 (not gnus-summary-inhibit-highlight))
3526 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3527 (article (gnus-summary-article-number))
3528 (score (gnus-summary-article-score article)))
3529 (unless dont-update
3530 (if (and gnus-summary-mark-below
3531 (< (gnus-summary-article-score)
3532 gnus-summary-mark-below))
3533 ;; This article has a low score, so we mark it as read.
3534 (when (memq article gnus-newsgroup-unreads)
3535 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3536 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3537 ;; This article was previously marked as read on account
3538 ;; of a low score, but now it has risen, so we mark it as
3539 ;; unread.
3540 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3541 (gnus-summary-update-mark
3542 (if (or (null gnus-summary-default-score)
3543 (<= (abs (- score gnus-summary-default-score))
3544 gnus-summary-zcore-fuzz))
23f87bed 3545 ? ;Whitespace
eec82323
LMI
3546 (if (< score gnus-summary-default-score)
3547 gnus-score-below-mark gnus-score-over-mark))
3548 'score))
3549 ;; Do visual highlighting.
3550 (when (gnus-visual-p 'summary-highlight 'highlight)
6748645f 3551 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3552
3553(defvar gnus-tmp-new-adopts nil)
3554
3555(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3556 "Return the number of articles in THREAD.
3557This may be 0 in some cases -- if none of the articles in
3558the thread are to be displayed."
3559 (let* ((number
23f87bed 3560 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3561 (cond
3562 ((not (listp thread))
3563 1)
3564 ((and (consp thread) (cdr thread))
3565 (apply
3566 '+ 1 (mapcar
3567 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3568 ((null thread)
3569 1)
3570 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3571 1)
3572 (t 0))))
3573 (when (and level (zerop level) gnus-tmp-new-adopts)
3574 (incf number
3575 (apply '+ (mapcar
3576 'gnus-summary-number-of-articles-in-thread
3577 gnus-tmp-new-adopts))))
3578 (if char
3579 (if (> number 1) gnus-not-empty-thread-mark
3580 gnus-empty-thread-mark)
3581 number)))
3582
23f87bed
MB
3583(defsubst gnus-summary-line-message-size (head)
3584 "Return pretty-printed version of message size.
3585This function is intended to be used in
3586`gnus-summary-line-format-alist'."
3587 (let ((c (or (mail-header-chars head) -1)))
3588 (cond ((< c 0) "n/a") ; chars not available
3589 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3590 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3591 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3592 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3593
3594
eec82323
LMI
3595(defun gnus-summary-set-local-parameters (group)
3596 "Go through the local params of GROUP and set all variable specs in that list."
3597 (let ((params (gnus-group-find-parameter group))
23f87bed 3598 (vars '(quit-config)) ; Ignore quit-config.
eec82323
LMI
3599 elem)
3600 (while params
3601 (setq elem (car params)
3602 params (cdr params))
3603 (and (consp elem) ; Has to be a cons.
3604 (consp (cdr elem)) ; The cdr has to be a list.
3605 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3606 (not (memq (car elem) vars))
eec82323 3607 (ignore-errors ; So we set it.
23f87bed 3608 (push (car elem) vars)
eec82323
LMI
3609 (make-local-variable (car elem))
3610 (set (car elem) (eval (nth 1 elem))))))))
3611
3612(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3613 kill-buffer no-display backward
3614 select-articles)
eec82323
LMI
3615 "Start reading news in newsgroup GROUP.
3616If SHOW-ALL is non-nil, already read articles are also listed.
3617If NO-ARTICLE is non-nil, no article is selected initially.
3618If NO-DISPLAY, don't generate a summary buffer."
3619 (let (result)
3620 (while (and group
3621 (null (setq result
3622 (let ((gnus-auto-select-next nil))
6748645f
LMI
3623 (or (gnus-summary-read-group-1
3624 group show-all no-article
3625 kill-buffer no-display
3626 select-articles)
3627 (setq show-all nil
16409b0b 3628 select-articles nil)))))
eec82323
LMI
3629 (eq gnus-auto-select-next 'quietly))
3630 (set-buffer gnus-group-buffer)
6748645f
LMI
3631 ;; The entry function called above goes to the next
3632 ;; group automatically, so we go two groups back
3633 ;; if we are searching for the previous group.
3634 (when backward
3635 (gnus-group-prev-unread-group 2))
eec82323
LMI
3636 (if (not (equal group (gnus-group-group-name)))
3637 (setq group (gnus-group-group-name))
3638 (setq group nil)))
3639 result))
3640
3641(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3642 kill-buffer no-display
3643 &optional select-articles)
eec82323 3644 ;; Killed foreign groups can't be entered.
23f87bed
MB
3645 ;; (when (and (not (gnus-group-native-p group))
3646 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3647 ;; (error "Dead non-native groups can't be entered"))
3648 (gnus-message 5 "Retrieving newsgroup: %s..."
3649 (gnus-group-decoded-name group))
eec82323
LMI
3650 (let* ((new-group (gnus-summary-setup-buffer group))
3651 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3652 (did-select (and new-group (gnus-select-newsgroup
3653 group show-all select-articles))))
eec82323
LMI
3654 (cond
3655 ;; This summary buffer exists already, so we just select it.
3656 ((not new-group)
3657 (gnus-set-global-variables)
3658 (when kill-buffer
3659 (gnus-kill-or-deaden-summary kill-buffer))
3660 (gnus-configure-windows 'summary 'force)
3661 (gnus-set-mode-line 'summary)
3662 (gnus-summary-position-point)
3663 (message "")
3664 t)
3665 ;; We couldn't select this group.
3666 ((null did-select)
3667 (when (and (eq major-mode 'gnus-summary-mode)
3668 (not (equal (current-buffer) kill-buffer)))
3669 (kill-buffer (current-buffer))
3670 (if (not quit-config)
3671 (progn
6748645f
LMI
3672 ;; Update the info -- marks might need to be removed,
3673 ;; for instance.
3674 (gnus-summary-update-info)
eec82323
LMI
3675 (set-buffer gnus-group-buffer)
3676 (gnus-group-jump-to-group group)
3677 (gnus-group-next-unread-group 1))
3678 (gnus-handle-ephemeral-exit quit-config)))
23f87bed
MB
3679 (let ((grpinfo (gnus-get-info group)))
3680 (if (null (gnus-info-read grpinfo))
3681 (gnus-message 3 "Group %s contains no messages"
3682 (gnus-group-decoded-name group))
3683 (gnus-message 3 "Can't select group")))
eec82323
LMI
3684 nil)
3685 ;; The user did a `C-g' while prompting for number of articles,
3686 ;; so we exit this group.
3687 ((eq did-select 'quit)
3688 (and (eq major-mode 'gnus-summary-mode)
3689 (not (equal (current-buffer) kill-buffer))
3690 (kill-buffer (current-buffer)))
3691 (when kill-buffer
3692 (gnus-kill-or-deaden-summary kill-buffer))
3693 (if (not quit-config)
3694 (progn
3695 (set-buffer gnus-group-buffer)
3696 (gnus-group-jump-to-group group)
3697 (gnus-group-next-unread-group 1)
3698 (gnus-configure-windows 'group 'force))
3699 (gnus-handle-ephemeral-exit quit-config))
3700 ;; Finally signal the quit.
3701 (signal 'quit nil))
3702 ;; The group was successfully selected.
3703 (t
3704 (gnus-set-global-variables)
3705 ;; Save the active value in effect when the group was entered.
3706 (setq gnus-newsgroup-active
3707 (gnus-copy-sequence
3708 (gnus-active gnus-newsgroup-name)))
3709 ;; You can change the summary buffer in some way with this hook.
6748645f 3710 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
3711 (when (memq 'summary (gnus-update-format-specifications
3712 nil 'summary 'summary-mode 'summary-dummy))
3713 ;; The format specification for the summary line was updated,
3714 ;; so we need to update the mark positions as well.
3715 (gnus-update-summary-mark-positions))
eec82323
LMI
3716 ;; Do score processing.
3717 (when gnus-use-scoring
3718 (gnus-possibly-score-headers))
3719 ;; Check whether to fill in the gaps in the threads.
3720 (when gnus-build-sparse-threads
3721 (gnus-build-sparse-threads))
3722 ;; Find the initial limit.
26c9afc3
MB
3723 (if show-all
3724 (let ((gnus-newsgroup-dormant nil))
eec82323 3725 (gnus-summary-initial-limit show-all))
26c9afc3 3726 (gnus-summary-initial-limit show-all))
eec82323
LMI
3727 ;; Generate the summary buffer.
3728 (unless no-display
3729 (gnus-summary-prepare))
3730 (when gnus-use-trees
3731 (gnus-tree-open group)
3732 (setq gnus-summary-highlight-line-function
3733 'gnus-tree-highlight-article))
3734 ;; If the summary buffer is empty, but there are some low-scored
3735 ;; articles or some excluded dormants, we include these in the
3736 ;; buffer.
3737 (when (and (zerop (buffer-size))
3738 (not no-display))
3739 (cond (gnus-newsgroup-dormant
3740 (gnus-summary-limit-include-dormant))
3741 ((and gnus-newsgroup-scored show-all)
3742 (gnus-summary-limit-include-expunged t))))
3743 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 3744 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
3745 (if (and (zerop (buffer-size))
3746 (not no-display))
3747 (progn
3748 ;; This newsgroup is empty.
3749 (gnus-summary-catchup-and-exit nil t)
3750 (gnus-message 6 "No unread news")
3751 (when kill-buffer
3752 (gnus-kill-or-deaden-summary kill-buffer))
3753 ;; Return nil from this function.
3754 nil)
3755 ;; Hide conversation thread subtrees. We cannot do this in
3756 ;; gnus-summary-prepare-hook since kill processing may not
3757 ;; work with hidden articles.
23f87bed 3758 (gnus-summary-maybe-hide-threads)
6748645f
LMI
3759 (when kill-buffer
3760 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 3761 (gnus-summary-auto-select-subject)
eec82323
LMI
3762 ;; Show first unread article if requested.
3763 (if (and (not no-article)
3764 (not no-display)
3765 gnus-newsgroup-unreads
3766 gnus-auto-select-first)
16409b0b
GM
3767 (progn
3768 (gnus-configure-windows 'summary)
23f87bed
MB
3769 (let ((art (gnus-summary-article-number)))
3770 (unless (and (not gnus-plugged)
3771 (or (memq art gnus-newsgroup-undownloaded)
3772 (memq art gnus-newsgroup-downloadable)))
3773 (gnus-summary-goto-article art))))
3774 ;; Don't select any articles.
eec82323 3775 (gnus-summary-position-point)
6748645f
LMI
3776 (gnus-configure-windows 'summary 'force)
3777 (gnus-set-mode-line 'summary))
23f87bed
MB
3778 (when (and gnus-auto-center-group
3779 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
3780 ;; Gotta use windows, because recenter does weird stuff if
3781 ;; the current buffer ain't the displayed window.
3782 (let ((owin (selected-window)))
3783 (select-window (get-buffer-window gnus-group-buffer t))
3784 (when (gnus-group-goto-group group)
3785 (recenter))
3786 (select-window owin)))
3787 ;; Mark this buffer as "prepared".
3788 (setq gnus-newsgroup-prepared t)
6748645f 3789 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
3790 (unless (gnus-ephemeral-group-p group)
3791 (gnus-group-update-group group))
eec82323
LMI
3792 t)))))
3793
23f87bed
MB
3794(defun gnus-summary-auto-select-subject ()
3795 "Select the subject line on initial group entry."
3796 (goto-char (point-min))
3797 (cond
3798 ((eq gnus-auto-select-subject 'best)
3799 (gnus-summary-best-unread-subject))
3800 ((eq gnus-auto-select-subject 'unread)
3801 (gnus-summary-first-unread-subject))
3802 ((eq gnus-auto-select-subject 'unseen)
3803 (gnus-summary-first-unseen-subject))
3804 ((eq gnus-auto-select-subject 'unseen-or-unread)
3805 (gnus-summary-first-unseen-or-unread-subject))
3806 ((eq gnus-auto-select-subject 'first)
3807 ;; Do nothing.
3808 )
3809 ((functionp gnus-auto-select-subject)
3810 (funcall gnus-auto-select-subject))))
3811
eec82323
LMI
3812(defun gnus-summary-prepare ()
3813 "Generate the summary buffer."
3814 (interactive)
3815 (let ((buffer-read-only nil))
3816 (erase-buffer)
3817 (setq gnus-newsgroup-data nil
3818 gnus-newsgroup-data-reverse nil)
6748645f 3819 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
3820 ;; Generate the buffer, either with threads or without.
3821 (when gnus-newsgroup-headers
3822 (gnus-summary-prepare-threads
3823 (if gnus-show-threads
3824 (gnus-sort-gathered-threads
3825 (funcall gnus-summary-thread-gathering-function
3826 (gnus-sort-threads
3827 (gnus-cut-threads (gnus-make-threads)))))
3828 ;; Unthreaded display.
3829 (gnus-sort-articles gnus-newsgroup-headers))))
3830 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3831 ;; Call hooks for modifying summary buffer.
3832 (goto-char (point-min))
6748645f 3833 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
3834
3835(defsubst gnus-general-simplify-subject (subject)
23f87bed 3836 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
3837 (setq subject
3838 (cond
3839 ;; Truncate the subject.
6748645f
LMI
3840 (gnus-simplify-subject-functions
3841 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
3842 ((numberp gnus-summary-gather-subject-limit)
3843 (setq subject (gnus-simplify-subject-re subject))
3844 (if (> (length subject) gnus-summary-gather-subject-limit)
3845 (substring subject 0 gnus-summary-gather-subject-limit)
3846 subject))
3847 ;; Fuzzily simplify it.
3848 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3849 (gnus-simplify-subject-fuzzy subject))
3850 ;; Just remove the leading "Re:".
3851 (t
3852 (gnus-simplify-subject-re subject))))
3853
3854 (if (and gnus-summary-gather-exclude-subject
3855 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 3856 nil ; This article shouldn't be gathered
eec82323
LMI
3857 subject))
3858
3859(defun gnus-summary-simplify-subject-query ()
3860 "Query where the respool algorithm would put this article."
3861 (interactive)
eec82323
LMI
3862 (gnus-summary-select-article)
3863 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3864
3865(defun gnus-gather-threads-by-subject (threads)
3866 "Gather threads by looking at Subject headers."
3867 (if (not gnus-summary-make-false-root)
3868 threads
3869 (let ((hashtb (gnus-make-hashtable 1024))
3870 (prev threads)
3871 (result threads)
3872 subject hthread whole-subject)
3873 (while threads
3874 (setq subject (gnus-general-simplify-subject
3875 (setq whole-subject (mail-header-subject
3876 (caar threads)))))
3877 (when subject
3878 (if (setq hthread (gnus-gethash subject hashtb))
3879 (progn
3880 ;; We enter a dummy root into the thread, if we
3881 ;; haven't done that already.
3882 (unless (stringp (caar hthread))
3883 (setcar hthread (list whole-subject (car hthread))))
3884 ;; We add this new gathered thread to this gathered
3885 ;; thread.
3886 (setcdr (car hthread)
3887 (nconc (cdar hthread) (list (car threads))))
3888 ;; Remove it from the list of threads.
3889 (setcdr prev (cdr threads))
3890 (setq threads prev))
3891 ;; Enter this thread into the hash table.
23f87bed
MB
3892 (gnus-sethash subject
3893 (if gnus-summary-make-false-root-always
3894 (progn
3895 ;; If you want a dummy root above all
3896 ;; threads...
3897 (setcar threads (list whole-subject
3898 (car threads)))
3899 threads)
3900 threads)
3901 hashtb)))
eec82323
LMI
3902 (setq prev threads)
3903 (setq threads (cdr threads)))
3904 result)))
3905
3906(defun gnus-gather-threads-by-references (threads)
3907 "Gather threads by looking at References headers."
3908 (let ((idhashtb (gnus-make-hashtable 1024))
3909 (thhashtb (gnus-make-hashtable 1024))
3910 (prev threads)
3911 (result threads)
3912 ids references id gthread gid entered ref)
3913 (while threads
3914 (when (setq references (mail-header-references (caar threads)))
3915 (setq id (mail-header-id (caar threads))
23f87bed 3916 ids (inline (gnus-split-references references))
eec82323
LMI
3917 entered nil)
3918 (while (setq ref (pop ids))
3919 (setq ids (delete ref ids))
3920 (if (not (setq gid (gnus-gethash ref idhashtb)))
3921 (progn
3922 (gnus-sethash ref id idhashtb)
3923 (gnus-sethash id threads thhashtb))
3924 (setq gthread (gnus-gethash gid thhashtb))
3925 (unless entered
3926 ;; We enter a dummy root into the thread, if we
3927 ;; haven't done that already.
3928 (unless (stringp (caar gthread))
3929 (setcar gthread (list (mail-header-subject (caar gthread))
3930 (car gthread))))
3931 ;; We add this new gathered thread to this gathered
3932 ;; thread.
3933 (setcdr (car gthread)
3934 (nconc (cdar gthread) (list (car threads)))))
3935 ;; Add it into the thread hash table.
3936 (gnus-sethash id gthread thhashtb)
3937 (setq entered t)
3938 ;; Remove it from the list of threads.
3939 (setcdr prev (cdr threads))
3940 (setq threads prev))))
3941 (setq prev threads)
3942 (setq threads (cdr threads)))
3943 result))
3944
3945(defun gnus-sort-gathered-threads (threads)
16409b0b 3946 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
3947 (let ((result threads))
3948 (while threads
3949 (when (stringp (caar threads))
3950 (setcdr (car threads)
16409b0b 3951 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
3952 (setq threads (cdr threads)))
3953 result))
3954
3955(defun gnus-thread-loop-p (root thread)
3956 "Say whether ROOT is in THREAD."
3957 (let ((stack (list thread))
3958 (infloop 0)
3959 th)
3960 (while (setq thread (pop stack))
3961 (setq th (cdr thread))
3962 (while (and th
3963 (not (eq (caar th) root)))
3964 (pop th))
3965 (if th
3966 ;; We have found a loop.
3967 (let (ref-dep)
3968 (setcdr thread (delq (car th) (cdr thread)))
3969 (if (boundp (setq ref-dep (intern "none"
3970 gnus-newsgroup-dependencies)))
3971 (setcdr (symbol-value ref-dep)
3972 (nconc (cdr (symbol-value ref-dep))
3973 (list (car th))))
3974 (set ref-dep (list nil (car th))))
3975 (setq infloop 1
3976 stack nil))
3977 ;; Push all the subthreads onto the stack.
3978 (push (cdr thread) stack)))
3979 infloop))
3980
3981(defun gnus-make-threads ()
01ccbb85 3982 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
3983 (let (threads)
3984 (while (catch 'infloop
3985 (mapatoms
3986 (lambda (refs)
3987 ;; Deal with self-referencing References loops.
3988 (when (and (car (symbol-value refs))
3989 (not (zerop
3990 (apply
3991 '+
3992 (mapcar
3993 (lambda (thread)
3994 (gnus-thread-loop-p
3995 (car (symbol-value refs)) thread))
3996 (cdr (symbol-value refs)))))))
3997 (setq threads nil)
3998 (throw 'infloop t))
3999 (unless (car (symbol-value refs))
23f87bed
MB
4000 ;; These threads do not refer back to any other
4001 ;; articles, so they're roots.
eec82323
LMI
4002 (setq threads (append (cdr (symbol-value refs)) threads))))
4003 gnus-newsgroup-dependencies)))
4004 threads))
4005
6748645f 4006;; Build the thread tree.
16409b0b 4007(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4008 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4009
4010If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4011if it was already present.
4012
4013If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4014will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4015Message-IDs will be renamed to a unique Message-ID before being
4016entered.
6748645f
LMI
4017
4018Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4019 (let* ((id (mail-header-id header))
4020 (id-dep (and id (intern id dependencies)))
23f87bed 4021 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4022 ;; Enter this `header' in the `dependencies' table.
4023 (cond
4024 ((not id-dep)
4025 (setq header nil))
4026 ;; The first two cases do the normal part: enter a new `header'
4027 ;; in the `dependencies' table.
4028 ((not (boundp id-dep))
4029 (set id-dep (list header)))
4030 ((null (car (symbol-value id-dep)))
4031 (setcar (symbol-value id-dep) header))
4032
4033 ;; From here the `header' was already present in the
4034 ;; `dependencies' table.
4035 (force-new
4036 ;; Overrides an existing entry;
4037 ;; just set the header part of the entry.
23f87bed
MB
4038 (setcar (symbol-value id-dep) header)
4039 (setq replaced t))
6748645f
LMI
4040
4041 ;; Renames the existing `header' to a unique Message-ID.
4042 ((not gnus-summary-ignore-duplicates)
4043 ;; An article with this Message-ID has already been seen.
4044 ;; We rename the Message-ID.
4045 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4046 (list header))
4047 (mail-header-set-id header id))
4048
4049 ;; The last case ignores an existing entry, except it adds any
4050 ;; additional Xrefs (in case the two articles came from different
4051 ;; servers.
4052 ;; Also sets `header' to `nil' meaning that the `dependencies'
4053 ;; table was *not* modified.
4054 (t
4055 (mail-header-set-xref
4056 (car (symbol-value id-dep))
4057 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4058 "")
4059 (or (mail-header-xref header) "")))
4060 (setq header nil)))
4061
23f87bed
MB
4062 (when (and header (not replaced))
4063 ;; First check that we are not creating a References loop.
4064 (setq parent-id (gnus-parent-id (mail-header-references header)))
4065 (setq ref parent-id)
6748645f
LMI
4066 (while (and ref
4067 (setq ref-dep (intern-soft ref dependencies))
4068 (boundp ref-dep)
4069 (setq ref-header (car (symbol-value ref-dep))))
4070 (if (string= id ref)
4071 ;; Yuk! This is a reference loop. Make the article be a
4072 ;; root article.
4073 (progn
4074 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4075 (setq ref nil)
4076 (setq parent-id nil))
6748645f 4077 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4078 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4079 (if (boundp ref-dep)
4080 (setcdr (symbol-value ref-dep)
4081 (nconc (cdr (symbol-value ref-dep))
4082 (list (symbol-value id-dep))))
4083 (set ref-dep (list nil (symbol-value id-dep)))))
4084 header))
4085
23f87bed
MB
4086(defun gnus-extract-message-id-from-in-reply-to (string)
4087 (if (string-match "<[^>]+>" string)
4088 (substring string (match-beginning 0) (match-end 0))
4089 nil))
4090
eec82323
LMI
4091(defun gnus-build-sparse-threads ()
4092 (let ((headers gnus-newsgroup-headers)
16409b0b 4093 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4094 (gnus-summary-ignore-duplicates t)
eec82323 4095 header references generation relations
6748645f 4096 subject child end new-child date)
eec82323
LMI
4097 ;; First we create an alist of generations/relations, where
4098 ;; generations is how much we trust the relation, and the relation
4099 ;; is parent/child.
4100 (gnus-message 7 "Making sparse threads...")
4101 (save-excursion
4102 (nnheader-set-temp-buffer " *gnus sparse threads*")
4103 (while (setq header (pop headers))
4104 (when (and (setq references (mail-header-references header))
4105 (not (string= references "")))
4106 (insert references)
4107 (setq child (mail-header-id header)
6748645f
LMI
4108 subject (mail-header-subject header)
4109 date (mail-header-date header)
4110 generation 0)
eec82323
LMI
4111 (while (search-backward ">" nil t)
4112 (setq end (1+ (point)))
4113 (when (search-backward "<" nil t)
6748645f 4114 (setq new-child (buffer-substring (point) end))
eec82323 4115 (push (list (incf generation)
6748645f
LMI
4116 child (setq child new-child)
4117 subject date)
eec82323 4118 relations)))
6748645f
LMI
4119 (when child
4120 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4121 (erase-buffer)))
4122 (kill-buffer (current-buffer)))
4123 ;; Sort over trustworthiness.
6748645f
LMI
4124 (mapcar
4125 (lambda (relation)
4126 (when (gnus-dependencies-add-header
4127 (make-full-mail-header
4128 gnus-reffed-article-number
4129 (nth 3 relation) "" (or (nth 4 relation) "")
4130 (nth 1 relation)
4131 (or (nth 2 relation) "") 0 0 "")
4132 gnus-newsgroup-dependencies nil)
4133 (push gnus-reffed-article-number gnus-newsgroup-limit)
4134 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4135 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4136 gnus-newsgroup-reads)
4137 (decf gnus-reffed-article-number)))
4138 (sort relations 'car-less-than-car))
eec82323
LMI
4139 (gnus-message 7 "Making sparse threads...done")))
4140
4141(defun gnus-build-old-threads ()
4142 ;; Look at all the articles that refer back to old articles, and
4143 ;; fetch the headers for the articles that aren't there. This will
4144 ;; build complete threads - if the roots haven't been expired by the
4145 ;; server, that is.
16409b0b
GM
4146 (let ((mail-parse-charset gnus-newsgroup-charset)
4147 id heads)
eec82323
LMI
4148 (mapatoms
4149 (lambda (refs)
4150 (when (not (car (symbol-value refs)))
4151 (setq heads (cdr (symbol-value refs)))
4152 (while heads
4153 (if (memq (mail-header-number (caar heads))
4154 gnus-newsgroup-dormant)
4155 (setq heads (cdr heads))
4156 (setq id (symbol-name refs))
4157 (while (and (setq id (gnus-build-get-header id))
6748645f 4158 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4159 (setq heads nil)))))
4160 gnus-newsgroup-dependencies)))
4161
23f87bed
MB
4162(defsubst gnus-remove-odd-characters (string)
4163 "Translate STRING into something that doesn't contain weird characters."
4164 (mm-subst-char-in-string
4165 ?\r ?\-
4166 (mm-subst-char-in-string
4167 ?\n ?\- string)))
4168
6748645f
LMI
4169;; This function has to be called with point after the article number
4170;; on the beginning of the line.
4171(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4172 (let ((eol (gnus-point-at-eol))
4173 (buffer (current-buffer))
23f87bed 4174 header references in-reply-to)
6748645f
LMI
4175
4176 ;; overview: [num subject from date id refs chars lines misc]
4177 (unwind-protect
23f87bed 4178 (let (x)
6748645f
LMI
4179 (narrow-to-region (point) eol)
4180 (unless (eobp)
4181 (forward-char))
4182
4183 (setq header
4184 (make-full-mail-header
4185 number ; number
23f87bed
MB
4186 (condition-case () ; subject
4187 (gnus-remove-odd-characters
4188 (funcall gnus-decode-encoded-word-function
4189 (setq x (nnheader-nov-field))))
4190 (error x))
4191 (condition-case () ; from
4192 (gnus-remove-odd-characters
343d6628 4193 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4194 (setq x (nnheader-nov-field))))
4195 (error x))
16409b0b
GM
4196 (nnheader-nov-field) ; date
4197 (nnheader-nov-read-message-id) ; id
23f87bed 4198 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4199 (nnheader-nov-read-integer) ; chars
4200 (nnheader-nov-read-integer) ; lines
4201 (unless (eobp)
8b93df01
DL
4202 (if (looking-at "Xref: ")
4203 (goto-char (match-end 0)))
4204 (nnheader-nov-field)) ; Xref
16409b0b 4205 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4206
4207 (widen))
4208
23f87bed
MB
4209 (when (and (string= references "")
4210 (setq in-reply-to (mail-header-extra header))
4211 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4212 (mail-header-set-references
4213 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4214
6748645f
LMI
4215 (when gnus-alter-header-function
4216 (funcall gnus-alter-header-function header))
4217 (gnus-dependencies-add-header header dependencies force-new)))
4218
eec82323 4219(defun gnus-build-get-header (id)
16409b0b
GM
4220 "Look through the buffer of NOV lines and find the header to ID.
4221Enter this line into the dependencies hash table, and return
4222the id of the parent article (if any)."
eec82323
LMI
4223 (let ((deps gnus-newsgroup-dependencies)
4224 found header)
4225 (prog1
4226 (save-excursion
4227 (set-buffer nntp-server-buffer)
4228 (let ((case-fold-search nil))
4229 (goto-char (point-min))
4230 (while (and (not found)
4231 (search-forward id nil t))
4232 (beginning-of-line)
4233 (setq found (looking-at
4234 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4235 (regexp-quote id))))
4236 (or found (beginning-of-line 2)))
4237 (when found
4238 (beginning-of-line)
4239 (and
4240 (setq header (gnus-nov-parse-line
4241 (read (current-buffer)) deps))
4242 (gnus-parent-id (mail-header-references header))))))
4243 (when header
4244 (let ((number (mail-header-number header)))
4245 (push number gnus-newsgroup-limit)
4246 (push header gnus-newsgroup-headers)
4247 (if (memq number gnus-newsgroup-unselected)
4248 (progn
23f87bed
MB
4249 (setq gnus-newsgroup-unreads
4250 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4251 number))
eec82323
LMI
4252 (setq gnus-newsgroup-unselected
4253 (delq number gnus-newsgroup-unselected)))
4254 (push number gnus-newsgroup-ancient)))))))
4255
6748645f
LMI
4256(defun gnus-build-all-threads ()
4257 "Read all the headers."
4258 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4259 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4260 (dependencies gnus-newsgroup-dependencies)
4261 header article)
4262 (save-excursion
4263 (set-buffer nntp-server-buffer)
4264 (let ((case-fold-search nil))
4265 (goto-char (point-min))
4266 (while (not (eobp))
4267 (ignore-errors
4268 (setq article (read (current-buffer))
16409b0b 4269 header (gnus-nov-parse-line article dependencies)))
6748645f
LMI
4270 (when header
4271 (save-excursion
4272 (set-buffer gnus-summary-buffer)
4273 (push header gnus-newsgroup-headers)
4274 (if (memq (setq article (mail-header-number header))
4275 gnus-newsgroup-unselected)
4276 (progn
23f87bed
MB
4277 (setq gnus-newsgroup-unreads
4278 (gnus-add-to-sorted-list
4279 gnus-newsgroup-unreads article))
6748645f
LMI
4280 (setq gnus-newsgroup-unselected
4281 (delq article gnus-newsgroup-unselected)))
4282 (push article gnus-newsgroup-ancient)))
4283 (forward-line 1)))))))
4284
eec82323 4285(defun gnus-summary-update-article-line (article header)
23f87bed 4286 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4287 (let* ((id (mail-header-id header))
4288 (thread (gnus-id-to-thread id)))
4289 (unless thread
4290 (error "Article in no thread"))
4291 ;; Update the thread.
4292 (setcar thread header)
4293 (gnus-summary-goto-subject article)
4294 (let* ((datal (gnus-data-find-list article))
4295 (data (car datal))
eec82323
LMI
4296 (buffer-read-only nil)
4297 (level (gnus-summary-thread-level)))
4298 (gnus-delete-line)
23f87bed
MB
4299 (let ((inserted (- (point)
4300 (progn
4301 (gnus-summary-insert-line
4302 header level nil
4303 (memq article gnus-newsgroup-undownloaded)
4304 (gnus-article-mark article)
4305 (memq article gnus-newsgroup-replied)
4306 (memq article gnus-newsgroup-expirable)
4307 ;; Only insert the Subject string when it's different
4308 ;; from the previous Subject string.
4309 (if (and
4310 gnus-show-threads
4311 (gnus-subject-equal
4312 (condition-case ()
4313 (mail-header-subject
4314 (gnus-data-header
4315 (cadr
4316 (gnus-data-find-list
4317 article
4318 (gnus-data-list t)))))
4319 ;; Error on the side of excessive subjects.
4320 (error ""))
4321 (mail-header-subject header)))
4322 ""
4323 (mail-header-subject header))
4324 nil (cdr (assq article gnus-newsgroup-scored))
4325 (memq article gnus-newsgroup-processable))
4326 (point)))))
4327 (when (cdr datal)
4328 (gnus-data-update-list
4329 (cdr datal)
4330 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4331
4332(defun gnus-summary-update-article (article &optional iheader)
4333 "Update ARTICLE in the summary buffer."
4334 (set-buffer gnus-summary-buffer)
6748645f 4335 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4336 (id (mail-header-id header))
4337 (data (gnus-data-find article))
4338 (thread (gnus-id-to-thread id))
4339 (references (mail-header-references header))
4340 (parent
4341 (gnus-id-to-thread
4342 (or (gnus-parent-id
4343 (when (and references
4344 (not (equal "" references)))
4345 references))
4346 "none")))
4347 (buffer-read-only nil)
6748645f 4348 (old (car thread)))
eec82323 4349 (when thread
eec82323 4350 (unless iheader
6748645f
LMI
4351 (setcar thread nil)
4352 (when parent
4353 (delq thread parent)))
4354 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4355 ;; Set the (possibly) new article number in the data structure.
4356 (gnus-data-set-number data (gnus-id-to-article id))
4357 (setcar thread old)
4358 nil))))
4359
6748645f
LMI
4360(defun gnus-rebuild-thread (id &optional line)
4361 "Rebuild the thread containing ID.
4362If LINE, insert the rebuilt thread starting on line LINE."
eec82323
LMI
4363 (let ((buffer-read-only nil)
4364 old-pos current thread data)
4365 (if (not gnus-show-threads)
4366 (setq thread (list (car (gnus-id-to-thread id))))
4367 ;; Get the thread this article is part of.
4368 (setq thread (gnus-remove-thread id)))
4369 (setq old-pos (gnus-point-at-bol))
4370 (setq current (save-excursion
94384150 4371 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4372 (gnus-summary-article-number))))
4373 ;; If this is a gathered thread, we have to go some re-gathering.
4374 (when (stringp (car thread))
4375 (let ((subject (car thread))
4376 roots thr)
4377 (setq thread (cdr thread))
4378 (while thread
4379 (unless (memq (setq thr (gnus-id-to-thread
4380 (gnus-root-id
4381 (mail-header-id (caar thread)))))
4382 roots)
4383 (push thr roots))
4384 (setq thread (cdr thread)))
4385 ;; We now have all (unique) roots.
4386 (if (= (length roots) 1)
4387 ;; All the loose roots are now one solid root.
4388 (setq thread (car roots))
4389 (setq thread (cons subject (gnus-sort-threads roots))))))
4390 (let (threads)
4391 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4392 (when line
4393 (goto-char (point-min))
4394 (forward-line (1- line)))
eec82323
LMI
4395 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4396 (if gnus-show-threads
4397 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4398 (gnus-summary-prepare-unthreaded thread))
4399 (setq data (nreverse gnus-newsgroup-data))
4400 (setq threads gnus-newsgroup-threads))
4401 ;; We splice the new data into the data structure.
6748645f
LMI
4402 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4403 ;;!!! then we want to insert at the beginning of the buffer.
4404 ;;!!! That happens to be true with Gnus now, but that may
4405 ;;!!! change in the future. Perhaps.
4406 (gnus-data-enter-list
4407 (if line nil current) data (- (point) old-pos))
4408 (setq gnus-newsgroup-threads
4409 (nconc threads gnus-newsgroup-threads))
4410 (gnus-data-compute-positions))))
eec82323
LMI
4411
4412(defun gnus-number-to-header (number)
4413 "Return the header for article NUMBER."
4414 (let ((headers gnus-newsgroup-headers))
4415 (while (and headers
4416 (not (= number (mail-header-number (car headers)))))
4417 (pop headers))
4418 (when headers
4419 (car headers))))
4420
6748645f 4421(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4422 "Return the headers of the GENERATIONeth parent of HEADERS."
4423 (unless generation
4424 (setq generation 1))
a8151ef7 4425 (let ((parent t)
6748645f 4426 (headers in-headers)
a8151ef7 4427 references)
6748645f
LMI
4428 (while (and parent
4429 (not (zerop generation))
4430 (setq references (mail-header-references headers)))
4431 (setq headers (if (and references
4432 (setq parent (gnus-parent-id references)))
4433 (car (gnus-id-to-thread parent))
4434 nil))
4435 (decf generation))
4436 (and (not (eq headers in-headers))
4437 headers)))
eec82323
LMI
4438
4439(defun gnus-id-to-thread (id)
4440 "Return the (sub-)thread where ID appears."
4441 (gnus-gethash id gnus-newsgroup-dependencies))
4442
4443(defun gnus-id-to-article (id)
4444 "Return the article number of ID."
4445 (let ((thread (gnus-id-to-thread id)))
4446 (when (and thread
4447 (car thread))
4448 (mail-header-number (car thread)))))
4449
4450(defun gnus-id-to-header (id)
4451 "Return the article headers of ID."
4452 (car (gnus-id-to-thread id)))
4453
4454(defun gnus-article-displayed-root-p (article)
4455 "Say whether ARTICLE is a root(ish) article."
4456 (let ((level (gnus-summary-thread-level article))
4457 (refs (mail-header-references (gnus-summary-article-header article)))
4458 particle)
4459 (cond
4460 ((null level) nil)
4461 ((zerop level) t)
4462 ((null refs) t)
4463 ((null (gnus-parent-id refs)) t)
4464 ((and (= 1 level)
4465 (null (setq particle (gnus-id-to-article
4466 (gnus-parent-id refs))))
4467 (null (gnus-summary-thread-level particle)))))))
4468
4469(defun gnus-root-id (id)
4470 "Return the id of the root of the thread where ID appears."
4471 (let (last-id prev)
6748645f 4472 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4473 (setq last-id id
4474 id (gnus-parent-id (mail-header-references prev))))
4475 last-id))
4476
6748645f
LMI
4477(defun gnus-articles-in-thread (thread)
4478 "Return the list of articles in THREAD."
4479 (cons (mail-header-number (car thread))
4480 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4481
eec82323
LMI
4482(defun gnus-remove-thread (id &optional dont-remove)
4483 "Remove the thread that has ID in it."
6748645f 4484 (let (headers thread last-id)
eec82323 4485 ;; First go up in this thread until we find the root.
6748645f
LMI
4486 (setq last-id (gnus-root-id id)
4487 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4488 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4489 ;; been gathered into some loose thread, so we have to search
4490 ;; through the threads to find the thread we wanted.
4491 (let ((threads gnus-newsgroup-threads)
4492 sub)
4493 (while threads
4494 (setq sub (car threads))
4495 (if (stringp (car sub))
4496 ;; This is a gathered thread, so we look at the roots
4497 ;; below it to find whether this article is in this
4498 ;; gathered root.
4499 (progn
4500 (setq sub (cdr sub))
4501 (while sub
4502 (when (member (caar sub) headers)
4503 (setq thread (car threads)
4504 threads nil
4505 sub nil))
4506 (setq sub (cdr sub))))
4507 ;; It's an ordinary thread, so we check it.
4508 (when (eq (car sub) (car headers))
4509 (setq thread sub
4510 threads nil)))
4511 (setq threads (cdr threads)))
4512 ;; If this article is in no thread, then it's a root.
4513 (if thread
4514 (unless dont-remove
4515 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4516 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4517 (when thread
4518 (prog1
4519 thread ; We return this thread.
4520 (unless dont-remove
4521 (if (stringp (car thread))
4522 (progn
4523 ;; If we use dummy roots, then we have to remove the
4524 ;; dummy root as well.
4525 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4526 ;; We go to the dummy root by going to
4527 ;; the first sub-"thread", and then one line up.
4528 (gnus-summary-goto-article
4529 (mail-header-number (caadr thread)))
4530 (forward-line -1)
eec82323
LMI
4531 (gnus-delete-line)
4532 (gnus-data-compute-positions))
4533 (setq thread (cdr thread))
4534 (while thread
4535 (gnus-remove-thread-1 (car thread))
4536 (setq thread (cdr thread))))
4537 (gnus-remove-thread-1 thread))))))))
4538
4539(defun gnus-remove-thread-1 (thread)
4540 "Remove the thread THREAD recursively."
4541 (let ((number (mail-header-number (pop thread)))
4542 d)
4543 (setq thread (reverse thread))
4544 (while thread
4545 (gnus-remove-thread-1 (pop thread)))
4546 (when (setq d (gnus-data-find number))
4547 (goto-char (gnus-data-pos d))
16409b0b 4548 (gnus-summary-show-thread)
eec82323
LMI
4549 (gnus-data-remove
4550 number
4551 (- (gnus-point-at-bol)
4552 (prog1
4553 (1+ (gnus-point-at-eol))
4554 (gnus-delete-line)))))))
4555
4921bbdd 4556(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4557 (sort (mapcar (lambda (thread)
4558 (cons (car thread)
4559 (and (cdr thread)
4921bbdd 4560 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4561 threads) func))
4562
4921bbdd
CY
4563(defun gnus-sort-threads-loop (threads func)
4564 (let* ((superthread (cons nil threads))
4565 (stack (list (cons superthread threads)))
4566 remaining-threads thread)
4567 (while stack
4568 (setq remaining-threads (cdr (car stack)))
4569 (if remaining-threads
4570 (progn (setq thread (car remaining-threads))
4571 (setcdr (car stack) (cdr remaining-threads))
4572 (if (cdr thread)
4573 (push (cons thread (cdr thread)) stack)))
4574 (setq thread (caar stack))
4575 (setcdr thread (sort (cdr thread) func))
4576 (pop stack)))
4577 (cdr superthread)))
4578
eec82323
LMI
4579(defun gnus-sort-threads (threads)
4580 "Sort THREADS."
4581 (if (not gnus-thread-sort-functions)
4582 threads
6748645f 4583 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4584 (prog1
4585 (condition-case nil
4586 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4587 (gnus-sort-threads-recursive
4588 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4589 ;; Even after binding max-lisp-eval-depth, the recursive
4590 ;; sorter might fail for very long threads. In that case,
4591 ;; try using a (less well-tested) non-recursive sorter.
4592 (error (gnus-sort-threads-loop
4593 threads (gnus-make-sort-function
4594 gnus-thread-sort-functions))))
4595 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4596
4597(defun gnus-sort-articles (articles)
4598 "Sort ARTICLES."
4599 (when gnus-article-sort-functions
4600 (gnus-message 7 "Sorting articles...")
4601 (prog1
4602 (setq gnus-newsgroup-headers
4603 (sort articles (gnus-make-sort-function
4604 gnus-article-sort-functions)))
4605 (gnus-message 7 "Sorting articles...done"))))
4606
4607;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4608(defmacro gnus-thread-header (thread)
16409b0b
GM
4609 "Return header of first article in THREAD.
4610Note that THREAD must never, ever be anything else than a variable -
4611using some other form will lead to serious barfage."
eec82323
LMI
4612 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4613 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4614 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4615 (vector thread) 2))
4616
4617(defsubst gnus-article-sort-by-number (h1 h2)
4618 "Sort articles by article number."
4619 (< (mail-header-number h1)
4620 (mail-header-number h2)))
4621
4622(defun gnus-thread-sort-by-number (h1 h2)
4623 "Sort threads by root article number."
4624 (gnus-article-sort-by-number
4625 (gnus-thread-header h1) (gnus-thread-header h2)))
4626
23f87bed
MB
4627(defsubst gnus-article-sort-by-random (h1 h2)
4628 "Sort articles by article number."
4629 (zerop (random 2)))
4630
4631(defun gnus-thread-sort-by-random (h1 h2)
4632 "Sort threads by root article number."
4633 (gnus-article-sort-by-random
4634 (gnus-thread-header h1) (gnus-thread-header h2)))
4635
eec82323
LMI
4636(defsubst gnus-article-sort-by-lines (h1 h2)
4637 "Sort articles by article Lines header."
4638 (< (mail-header-lines h1)
4639 (mail-header-lines h2)))
4640
4641(defun gnus-thread-sort-by-lines (h1 h2)
4642 "Sort threads by root article Lines header."
4643 (gnus-article-sort-by-lines
4644 (gnus-thread-header h1) (gnus-thread-header h2)))
4645
16409b0b
GM
4646(defsubst gnus-article-sort-by-chars (h1 h2)
4647 "Sort articles by octet length."
4648 (< (mail-header-chars h1)
4649 (mail-header-chars h2)))
4650
4651(defun gnus-thread-sort-by-chars (h1 h2)
4652 "Sort threads by root article octet length."
4653 (gnus-article-sort-by-chars
4654 (gnus-thread-header h1) (gnus-thread-header h2)))
4655
eec82323
LMI
4656(defsubst gnus-article-sort-by-author (h1 h2)
4657 "Sort articles by root author."
4658 (string-lessp
4659 (let ((extract (funcall
4660 gnus-extract-address-components
4661 (mail-header-from h1))))
4662 (or (car extract) (cadr extract) ""))
4663 (let ((extract (funcall
4664 gnus-extract-address-components
4665 (mail-header-from h2))))
4666 (or (car extract) (cadr extract) ""))))
4667
4668(defun gnus-thread-sort-by-author (h1 h2)
4669 "Sort threads by root author."
4670 (gnus-article-sort-by-author
4671 (gnus-thread-header h1) (gnus-thread-header h2)))
4672
4673(defsubst gnus-article-sort-by-subject (h1 h2)
4674 "Sort articles by root subject."
4675 (string-lessp
4676 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4677 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4678
4679(defun gnus-thread-sort-by-subject (h1 h2)
4680 "Sort threads by root subject."
4681 (gnus-article-sort-by-subject
4682 (gnus-thread-header h1) (gnus-thread-header h2)))
4683
4684(defsubst gnus-article-sort-by-date (h1 h2)
4685 "Sort articles by root article date."
16409b0b 4686 (time-less-p
eec82323
LMI
4687 (gnus-date-get-time (mail-header-date h1))
4688 (gnus-date-get-time (mail-header-date h2))))
4689
4690(defun gnus-thread-sort-by-date (h1 h2)
4691 "Sort threads by root article date."
4692 (gnus-article-sort-by-date
4693 (gnus-thread-header h1) (gnus-thread-header h2)))
4694
4695(defsubst gnus-article-sort-by-score (h1 h2)
4696 "Sort articles by root article score.
4697Unscored articles will be counted as having a score of zero."
4698 (> (or (cdr (assq (mail-header-number h1)
4699 gnus-newsgroup-scored))
4700 gnus-summary-default-score 0)
4701 (or (cdr (assq (mail-header-number h2)
4702 gnus-newsgroup-scored))
4703 gnus-summary-default-score 0)))
4704
4705(defun gnus-thread-sort-by-score (h1 h2)
4706 "Sort threads by root article score."
4707 (gnus-article-sort-by-score
4708 (gnus-thread-header h1) (gnus-thread-header h2)))
4709
4710(defun gnus-thread-sort-by-total-score (h1 h2)
4711 "Sort threads by the sum of all scores in the thread.
4712Unscored articles will be counted as having a score of zero."
4713 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4714
4715(defun gnus-thread-total-score (thread)
16409b0b 4716 ;; This function find the total score of THREAD.
23f87bed
MB
4717 (cond
4718 ((null thread)
4719 0)
4720 ((consp thread)
4721 (if (stringp (car thread))
4722 (apply gnus-thread-score-function 0
4723 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4724 (gnus-thread-total-score-1 thread)))
4725 (t
4726 (gnus-thread-total-score-1 (list thread)))))
4727
4728(defun gnus-thread-sort-by-most-recent-number (h1 h2)
4729 "Sort threads such that the thread with the most recently arrived article comes first."
4730 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4731
4732(defun gnus-thread-highest-number (thread)
4733 "Return the highest article number in THREAD."
4734 (apply 'max (mapcar (lambda (header)
4735 (mail-header-number header))
4736 (message-flatten-list thread))))
4737
4738(defun gnus-thread-sort-by-most-recent-date (h1 h2)
4739 "Sort threads such that the thread with the most recently dated article comes first."
4740 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4741
4742(defun gnus-thread-latest-date (thread)
4743 "Return the highest article date in THREAD."
4744 (let ((previous-time 0))
4745 (apply 'max
4746 (mapcar
4747 (lambda (header)
4748 (setq previous-time
4749 (condition-case ()
4750 (time-to-seconds (mail-header-parse-date
4751 (mail-header-date header)))
4752 (error previous-time))))
4753 (sort
4754 (message-flatten-list thread)
4755 (lambda (h1 h2)
4756 (< (mail-header-number h1)
4757 (mail-header-number h2))))))))
eec82323
LMI
4758
4759(defun gnus-thread-total-score-1 (root)
4760 ;; This function find the total score of the thread below ROOT.
4761 (setq root (car root))
4762 (apply gnus-thread-score-function
4763 (or (append
4764 (mapcar 'gnus-thread-total-score
6748645f 4765 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
4766 (when (> (mail-header-number root) 0)
4767 (list (or (cdr (assq (mail-header-number root)
4768 gnus-newsgroup-scored))
4769 gnus-summary-default-score 0))))
4770 (list gnus-summary-default-score)
4771 '(0))))
4772
4773;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4774(defvar gnus-tmp-prev-subject nil)
4775(defvar gnus-tmp-false-parent nil)
4776(defvar gnus-tmp-root-expunged nil)
4777(defvar gnus-tmp-dummy-line nil)
4778
60bd5589 4779(eval-when-compile (defvar gnus-tmp-header))
16409b0b
GM
4780(defun gnus-extra-header (type &optional header)
4781 "Return the extra header of TYPE."
4782 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4783 ""))
4784
23f87bed
MB
4785(defvar gnus-tmp-thread-tree-header-string "")
4786
4787(defcustom gnus-sum-thread-tree-root "> "
4788 "With %B spec, used for the root of a thread.
4789If nil, use subject instead."
bf247b6e 4790 :version "22.1"
ad136a7c 4791 :type '(radio (const :format "%v " nil) string)
23f87bed
MB
4792 :group 'gnus-thread)
4793(defcustom gnus-sum-thread-tree-false-root "> "
4794 "With %B spec, used for a false root of a thread.
4795If nil, use subject instead."
bf247b6e 4796 :version "22.1"
ad136a7c 4797 :type '(radio (const :format "%v " nil) string)
23f87bed
MB
4798 :group 'gnus-thread)
4799(defcustom gnus-sum-thread-tree-single-indent ""
4800 "With %B spec, used for a thread with just one message.
4801If nil, use subject instead."
bf247b6e 4802 :version "22.1"
ad136a7c 4803 :type '(radio (const :format "%v " nil) string)
23f87bed
MB
4804 :group 'gnus-thread)
4805(defcustom gnus-sum-thread-tree-vertical "| "
4806 "With %B spec, used for drawing a vertical line."
bf247b6e 4807 :version "22.1"
23f87bed
MB
4808 :type 'string
4809 :group 'gnus-thread)
4810(defcustom gnus-sum-thread-tree-indent " "
4811 "With %B spec, used for indenting."
bf247b6e 4812 :version "22.1"
23f87bed
MB
4813 :type 'string
4814 :group 'gnus-thread)
4815(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4816 "With %B spec, used for a leaf with brothers."
bf247b6e 4817 :version "22.1"
23f87bed
MB
4818 :type 'string
4819 :group 'gnus-thread)
4820(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4821 "With %B spec, used for a leaf without brothers."
bf247b6e 4822 :version "22.1"
23f87bed
MB
4823 :type 'string
4824 :group 'gnus-thread)
4825
eec82323
LMI
4826(defun gnus-summary-prepare-threads (threads)
4827 "Prepare summary buffer from THREADS and indentation LEVEL.
4828THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4829or a straight list of headers."
4830 (gnus-message 7 "Generating summary...")
4831
4832 (setq gnus-newsgroup-threads threads)
4833 (beginning-of-line)
4834
4835 (let ((gnus-tmp-level 0)
4836 (default-score (or gnus-summary-default-score 0))
4837 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
4838 (building-line-count gnus-summary-display-while-building)
4839 (building-count (integerp gnus-summary-display-while-building))
eec82323 4840 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
4841 new-roots gnus-tmp-new-adopts thread-end simp-subject
4842 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
4843 gnus-tmp-replied gnus-tmp-subject-or-nil
4844 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4845 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
4846 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4847 tree-stack)
eec82323 4848
23f87bed
MB
4849 (setq gnus-tmp-prev-subject nil
4850 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
4851
4852 (if (vectorp (car threads))
4853 ;; If this is a straight (sic) list of headers, then a
4854 ;; threaded summary display isn't required, so we just create
4855 ;; an unthreaded one.
4856 (gnus-summary-prepare-unthreaded threads)
4857
4858 ;; Do the threaded display.
4859
23f87bed
MB
4860 (if gnus-summary-display-while-building
4861 (switch-to-buffer (buffer-name)))
eec82323
LMI
4862 (while (or threads stack gnus-tmp-new-adopts new-roots)
4863
4864 (if (and (= gnus-tmp-level 0)
eec82323
LMI
4865 (or (not stack)
4866 (= (caar stack) 0))
4867 (not gnus-tmp-false-parent)
4868 (or gnus-tmp-new-adopts new-roots))
4869 (if gnus-tmp-new-adopts
4870 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4871 thread (list (car gnus-tmp-new-adopts))
4872 gnus-tmp-header (caar thread)
4873 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4874 (when new-roots
4875 (setq thread (list (car new-roots))
4876 gnus-tmp-header (caar thread)
4877 new-roots (cdr new-roots))))
4878
4879 (if threads
4880 ;; If there are some threads, we do them before the
4881 ;; threads on the stack.
4882 (setq thread threads
4883 gnus-tmp-header (caar thread))
4884 ;; There were no current threads, so we pop something off
4885 ;; the stack.
4886 (setq state (car stack)
4887 gnus-tmp-level (car state)
23f87bed
MB
4888 tree-stack (cadr state)
4889 thread (caddr state)
eec82323
LMI
4890 stack (cdr stack)
4891 gnus-tmp-header (caar thread))))
4892
4893 (setq gnus-tmp-false-parent nil)
4894 (setq gnus-tmp-root-expunged nil)
4895 (setq thread-end nil)
4896
4897 (if (stringp gnus-tmp-header)
4898 ;; The header is a dummy root.
4899 (cond
4900 ((eq gnus-summary-make-false-root 'adopt)
4901 ;; We let the first article adopt the rest.
4902 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4903 (cddar thread)))
4904 (setq gnus-tmp-gathered
4905 (nconc (mapcar
4906 (lambda (h) (mail-header-number (car h)))
4907 (cddar thread))
4908 gnus-tmp-gathered))
4909 (setq thread (cons (list (caar thread)
4910 (cadar thread))
4911 (cdr thread)))
4912 (setq gnus-tmp-level -1
4913 gnus-tmp-false-parent t))
4914 ((eq gnus-summary-make-false-root 'empty)
4915 ;; We print adopted articles with empty subject fields.
4916 (setq gnus-tmp-gathered
4917 (nconc (mapcar
4918 (lambda (h) (mail-header-number (car h)))
4919 (cddar thread))
4920 gnus-tmp-gathered))
4921 (setq gnus-tmp-level -1))
4922 ((eq gnus-summary-make-false-root 'dummy)
4923 ;; We remember that we probably want to output a dummy
4924 ;; root.
4925 (setq gnus-tmp-dummy-line gnus-tmp-header)
4926 (setq gnus-tmp-prev-subject gnus-tmp-header))
4927 (t
4928 ;; We do not make a root for the gathered
4929 ;; sub-threads at all.
4930 (setq gnus-tmp-level -1)))
4931
4932 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
4933 subject (mail-header-subject gnus-tmp-header)
4934 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
4935
4936 (cond
4937 ;; If the thread has changed subject, we might want to make
4938 ;; this subthread into a root.
4939 ((and (null gnus-thread-ignore-subject)
4940 (not (zerop gnus-tmp-level))
4941 gnus-tmp-prev-subject
23f87bed 4942 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
4943 (setq new-roots (nconc new-roots (list (car thread)))
4944 thread-end t
4945 gnus-tmp-header nil))
4946 ;; If the article lies outside the current limit,
4947 ;; then we do not display it.
4948 ((not (memq number gnus-newsgroup-limit))
4949 (setq gnus-tmp-gathered
4950 (nconc (mapcar
4951 (lambda (h) (mail-header-number (car h)))
4952 (cdar thread))
4953 gnus-tmp-gathered))
4954 (setq gnus-tmp-new-adopts (if (cdar thread)
4955 (append gnus-tmp-new-adopts
4956 (cdar thread))
4957 gnus-tmp-new-adopts)
4958 thread-end t
4959 gnus-tmp-header nil)
4960 (when (zerop gnus-tmp-level)
4961 (setq gnus-tmp-root-expunged t)))
4962 ;; Perhaps this article is to be marked as read?
4963 ((and gnus-summary-mark-below
4964 (< (or (cdr (assq number gnus-newsgroup-scored))
4965 default-score)
4966 gnus-summary-mark-below)
4967 ;; Don't touch sparse articles.
4968 (not (gnus-summary-article-sparse-p number))
4969 (not (gnus-summary-article-ancient-p number)))
4970 (setq gnus-newsgroup-unreads
4971 (delq number gnus-newsgroup-unreads))
4972 (if gnus-newsgroup-auto-expire
23f87bed
MB
4973 (setq gnus-newsgroup-expirable
4974 (gnus-add-to-sorted-list
4975 gnus-newsgroup-expirable number))
eec82323
LMI
4976 (push (cons number gnus-low-score-mark)
4977 gnus-newsgroup-reads))))
4978
4979 (when gnus-tmp-header
4980 ;; We may have an old dummy line to output before this
4981 ;; article.
6748645f
LMI
4982 (when (and gnus-tmp-dummy-line
4983 (gnus-subject-equal
4984 gnus-tmp-dummy-line
4985 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
4986 (gnus-summary-insert-dummy-line
4987 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4988 (setq gnus-tmp-dummy-line nil))
4989
4990 ;; Compute the mark.
4991 (setq gnus-tmp-unread (gnus-article-mark number))
4992
4993 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4994 gnus-tmp-header gnus-tmp-level)
4995 gnus-newsgroup-data)
4996
4997 ;; Actually insert the line.
4998 (setq
4999 gnus-tmp-subject-or-nil
5000 (cond
5001 ((and gnus-thread-ignore-subject
5002 gnus-tmp-prev-subject
23f87bed 5003 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5004 subject)
5005 ((zerop gnus-tmp-level)
5006 (if (and (eq gnus-summary-make-false-root 'empty)
5007 (memq number gnus-tmp-gathered)
5008 gnus-tmp-prev-subject
23f87bed 5009 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5010 gnus-summary-same-subject
5011 subject))
5012 (t gnus-summary-same-subject)))
5013 (if (and (eq gnus-summary-make-false-root 'adopt)
5014 (= gnus-tmp-level 1)
5015 (memq number gnus-tmp-gathered))
5016 (setq gnus-tmp-opening-bracket ?\<
5017 gnus-tmp-closing-bracket ?\>)
5018 (setq gnus-tmp-opening-bracket ?\[
5019 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5020 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5021 (gnus-make-thread-indent-array
5022 (max (* 2 (length gnus-thread-indent-array))
5023 gnus-tmp-level)))
eec82323
LMI
5024 (setq
5025 gnus-tmp-indentation
5026 (aref gnus-thread-indent-array gnus-tmp-level)
5027 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5028 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5029 gnus-summary-default-score 0)
5030 gnus-tmp-score-char
5031 (if (or (null gnus-summary-default-score)
5032 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5033 gnus-summary-zcore-fuzz))
23f87bed 5034 ? ;Whitespace
eec82323
LMI
5035 (if (< gnus-tmp-score gnus-summary-default-score)
5036 gnus-score-below-mark gnus-score-over-mark))
5037 gnus-tmp-replied
5038 (cond ((memq number gnus-newsgroup-processable)
5039 gnus-process-mark)
5040 ((memq number gnus-newsgroup-cached)
5041 gnus-cached-mark)
5042 ((memq number gnus-newsgroup-replied)
5043 gnus-replied-mark)
23f87bed
MB
5044 ((memq number gnus-newsgroup-forwarded)
5045 gnus-forwarded-mark)
eec82323
LMI
5046 ((memq number gnus-newsgroup-saved)
5047 gnus-saved-mark)
23f87bed
MB
5048 ((memq number gnus-newsgroup-recent)
5049 gnus-recent-mark)
5050 ((memq number gnus-newsgroup-unseen)
5051 gnus-unseen-mark)
5052 (t gnus-no-mark))
5053 gnus-tmp-downloaded
5054 (cond ((memq number gnus-newsgroup-undownloaded)
5055 gnus-undownloaded-mark)
5056 (gnus-newsgroup-agentized
5057 gnus-downloaded-mark)
5058 (t
5059 gnus-no-mark))
eec82323
LMI
5060 gnus-tmp-from (mail-header-from gnus-tmp-header)
5061 gnus-tmp-name
5062 (cond
5063 ((string-match "<[^>]+> *$" gnus-tmp-from)
5064 (setq beg-match (match-beginning 0))
23f87bed
MB
5065 (or (and (string-match "^\".+\"" gnus-tmp-from)
5066 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5067 (substring gnus-tmp-from 0 beg-match)))
5068 ((string-match "(.+)" gnus-tmp-from)
5069 (substring gnus-tmp-from
5070 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5071 (t gnus-tmp-from))
5072
5073 ;; Do the %B string
5074 gnus-tmp-thread-tree-header-string
5075 (cond
5076 ((not gnus-show-threads) "")
5077 ((zerop gnus-tmp-level)
5078 (cond ((cdar thread)
5079 (or gnus-sum-thread-tree-root subject))
5080 (gnus-tmp-new-adopts
5081 (or gnus-sum-thread-tree-false-root subject))
5082 (t
5083 (or gnus-sum-thread-tree-single-indent subject))))
5084 (t
5085 (concat (apply 'concat
5086 (mapcar (lambda (item)
5087 (if (= item 1)
5088 gnus-sum-thread-tree-vertical
5089 gnus-sum-thread-tree-indent))
5090 (cdr (reverse tree-stack))))
5091 (if (nth 1 thread)
5092 gnus-sum-thread-tree-leaf-with-other
5093 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5094 (when (string= gnus-tmp-name "")
5095 (setq gnus-tmp-name gnus-tmp-from))
5096 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5097 (setq gnus-tmp-lines -1))
5098 (if (= gnus-tmp-lines -1)
5099 (setq gnus-tmp-lines "?")
5100 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5101 (gnus-put-text-property
eec82323
LMI
5102 (point)
5103 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 5104 'gnus-number number)
eec82323
LMI
5105 (when gnus-visual-p
5106 (forward-line -1)
6748645f 5107 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
5108 (forward-line 1))
5109
23f87bed 5110 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5111
5112 (when (nth 1 thread)
23f87bed
MB
5113 (push (list (max 0 gnus-tmp-level)
5114 (copy-sequence tree-stack)
5115 (nthcdr 1 thread))
5116 stack))
5117 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5118 (incf gnus-tmp-level)
5119 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5120 (if gnus-summary-display-while-building
5121 (if building-count
5122 (progn
5123 ;; use a set frequency
5124 (setq building-line-count (1- building-line-count))
5125 (when (= building-line-count 0)
5126 (sit-for 0)
5127 (setq building-line-count
5128 gnus-summary-display-while-building)))
5129 ;; always
5130 (sit-for 0)))
eec82323
LMI
5131 (unless threads
5132 (setq gnus-tmp-level 0)))))
5133 (gnus-message 7 "Generating summary...done"))
5134
5135(defun gnus-summary-prepare-unthreaded (headers)
5136 "Generate an unthreaded summary buffer based on HEADERS."
5137 (let (header number mark)
5138
5139 (beginning-of-line)
5140
5141 (while headers
5142 ;; We may have to root out some bad articles...
5143 (when (memq (setq number (mail-header-number
5144 (setq header (pop headers))))
5145 gnus-newsgroup-limit)
5146 ;; Mark article as read when it has a low score.
5147 (when (and gnus-summary-mark-below
5148 (< (or (cdr (assq number gnus-newsgroup-scored))
5149 gnus-summary-default-score 0)
5150 gnus-summary-mark-below)
5151 (not (gnus-summary-article-ancient-p number)))
5152 (setq gnus-newsgroup-unreads
5153 (delq number gnus-newsgroup-unreads))
5154 (if gnus-newsgroup-auto-expire
5155 (push number gnus-newsgroup-expirable)
5156 (push (cons number gnus-low-score-mark)
5157 gnus-newsgroup-reads)))
5158
5159 (setq mark (gnus-article-mark number))
5160 (push (gnus-data-make number mark (1+ (point)) header 0)
5161 gnus-newsgroup-data)
5162 (gnus-summary-insert-line
5163 header 0 number
23f87bed 5164 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5165 mark (memq number gnus-newsgroup-replied)
5166 (memq number gnus-newsgroup-expirable)
5167 (mail-header-subject header) nil
5168 (cdr (assq number gnus-newsgroup-scored))
5169 (memq number gnus-newsgroup-processable))))))
5170
16409b0b
GM
5171(defun gnus-summary-remove-list-identifiers ()
5172 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5173 (let ((regexp (if (consp gnus-list-identifiers)
5174 (mapconcat 'identity gnus-list-identifiers " *\\|")
5175 gnus-list-identifiers))
5176 changed subject)
5177 (when regexp
5178 (dolist (header gnus-newsgroup-headers)
5179 (setq subject (mail-header-subject header)
5180 changed nil)
5181 (while (string-match
5182 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
5183 subject)
5184 (setq subject
5185 (concat (substring subject 0 (match-beginning 2))
5186 (substring subject (match-end 0)))
5187 changed t))
5188 (when (and changed
5189 (string-match
5190 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
5191 (setq subject
5192 (concat (substring subject 0 (match-beginning 1))
5193 (substring subject (match-end 1)))))
5194 (when changed
5195 (mail-header-set-subject header subject))))))
5196
5197(defun gnus-fetch-headers (articles)
5198 "Fetch headers of ARTICLES."
5199 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5200 (gnus-message 5 "Fetching headers for %s..." name)
5201 (prog1
5202 (if (eq 'nov
5203 (setq gnus-headers-retrieved-by
5204 (gnus-retrieve-headers
5205 articles gnus-newsgroup-name
5206 ;; We might want to fetch old headers, but
5207 ;; not if there is only 1 article.
5208 (and (or (and
5209 (not (eq gnus-fetch-old-headers 'some))
5210 (not (numberp gnus-fetch-old-headers)))
5211 (> (length articles) 1))
5212 gnus-fetch-old-headers))))
5213 (gnus-get-newsgroup-headers-xover
5214 articles nil nil gnus-newsgroup-name t)
5215 (gnus-get-newsgroup-headers))
5216 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5217
6748645f 5218(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5219 "Select newsgroup GROUP.
6748645f
LMI
5220If READ-ALL is non-nil, all articles in the group are selected.
5221If SELECT-ARTICLES, only select those articles from GROUP."
eec82323
LMI
5222 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5223 ;;!!! Dirty hack; should be removed.
5224 (gnus-summary-ignore-duplicates
23f87bed 5225 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5226 t
5227 gnus-summary-ignore-duplicates))
5228 (info (nth 2 entry))
5229 articles fetched-articles cached)
5230
5231 (unless (gnus-check-server
475e0e0c
GM
5232 (set (make-local-variable 'gnus-current-select-method)
5233 (gnus-find-method-for-group group)))
eec82323
LMI
5234 (error "Couldn't open server"))
5235
5236 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5237 (gnus-activate-group group) ; Or we can activate it...
5238 (progn ; Or we bug out.
5239 (when (equal major-mode 'gnus-summary-mode)
23f87bed
MB
5240 (gnus-kill-buffer (current-buffer)))
5241 (error "Couldn't activate group %s: %s"
c86d4601 5242 (gnus-group-decoded-name group) (gnus-status-message group))))
eec82323
LMI
5243
5244 (unless (gnus-request-group group t)
5245 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5246 (gnus-kill-buffer (current-buffer)))
eec82323 5247 (error "Couldn't request group %s: %s"
c86d4601 5248 (gnus-group-decoded-name group) (gnus-status-message group)))
eec82323 5249
23f87bed 5250 (when gnus-agent
54506618 5251 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5252
23f87bed
MB
5253 (setq gnus-summary-use-undownloaded-faces
5254 (gnus-agent-find-parameter
5255 group
5256 'agent-enable-undownloaded-faces)))
5257
5258 (setq gnus-newsgroup-name group
5259 gnus-newsgroup-unselected nil
5260 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5261
5262 (let ((display (gnus-group-find-parameter group 'display)))
5263 (setq gnus-newsgroup-display
5264 (cond
5265 ((not (zerop (or (car-safe read-all) 0)))
5266 ;; The user entered the group with C-u SPC/RET, let's show
5267 ;; all articles.
5268 'gnus-not-ignore)
5269 ((eq display 'all)
5270 'gnus-not-ignore)
5271 ((arrayp display)
5272 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5273 ((numberp display)
5274 ;; The following is probably the "correct" solution, but
5275 ;; it makes Gnus fetch all headers and then limit the
5276 ;; articles (which is slow), so instead we hack the
5277 ;; select-articles parameter instead. -- Simon Josefsson
5278 ;; <jas@kth.se>
5279 ;;
5280 ;; (gnus-byte-compile
5281 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5282 ;; display)))))
5283 (setq select-articles
5284 (gnus-uncompress-range
5285 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5286 (if (> tmp 0)
5287 tmp
5288 1))
5289 (cdr (gnus-active group)))))
5290 nil)
5291 (t
5292 nil))))
eec82323 5293
23f87bed 5294 (gnus-summary-setup-default-charset)
eec82323
LMI
5295
5296 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5297 (when (gnus-virtual-group-p group)
5298 (setq cached gnus-newsgroup-cached))
5299
5300 (setq gnus-newsgroup-unreads
23f87bed
MB
5301 (gnus-sorted-ndifference
5302 (gnus-sorted-ndifference gnus-newsgroup-unreads
5303 gnus-newsgroup-marked)
eec82323
LMI
5304 gnus-newsgroup-dormant))
5305
5306 (setq gnus-newsgroup-processable nil)
5307
5308 (gnus-update-read-articles group gnus-newsgroup-unreads)
eec82323 5309
23f87bed
MB
5310 ;; Adjust and set lists of article marks.
5311 (when info
5312 (gnus-adjust-marked-articles info))
6748645f
LMI
5313 (if (setq articles select-articles)
5314 (setq gnus-newsgroup-unselected
23f87bed 5315 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5316 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5317
5318 (cond
5319 ((null articles)
5320 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5321 'quit)
5322 ((eq articles 0) nil)
5323 (t
5324 ;; Init the dependencies hash table.
5325 (setq gnus-newsgroup-dependencies
5326 (gnus-make-hashtable (length articles)))
16409b0b 5327 (gnus-set-global-variables)
eec82323 5328 ;; Retrieve the headers and read them in.
23f87bed
MB
5329
5330 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5331
5332 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5333 (when cached
5334 (setq gnus-newsgroup-cached cached))
5335
5336 ;; Suppress duplicates?
5337 (when gnus-suppress-duplicates
5338 (gnus-dup-suppress-articles))
5339
5340 ;; Set the initial limit.
5341 (setq gnus-newsgroup-limit (copy-sequence articles))
5342 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5343 (setq fetched-articles
5344 (mapcar (lambda (headers) (mail-header-number headers))
5345 gnus-newsgroup-headers))
5346 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5347 (setq gnus-newsgroup-unreads
23f87bed
MB
5348 (gnus-sorted-nintersection
5349 gnus-newsgroup-unreads fetched-articles))
5350 (gnus-compute-unseen-list)
5351
eec82323
LMI
5352 ;; Removed marked articles that do not exist.
5353 (gnus-update-missing-marks
23f87bed 5354 (gnus-sorted-difference articles fetched-articles))
eec82323 5355 ;; We might want to build some more threads first.
6748645f
LMI
5356 (when (and gnus-fetch-old-headers
5357 (eq gnus-headers-retrieved-by 'nov))
5358 (if (eq gnus-fetch-old-headers 'invisible)
5359 (gnus-build-all-threads)
5360 (gnus-build-old-threads)))
5361 ;; Let the Gnus agent mark articles as read.
5362 (when gnus-agent
5363 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5364 ;; Remove list identifiers from subject
5365 (when gnus-list-identifiers
5366 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5367 ;; Check whether auto-expire is to be done in this group.
5368 (setq gnus-newsgroup-auto-expire
5369 (gnus-group-auto-expirable-p group))
5370 ;; Set up the article buffer now, if necessary.
5371 (unless gnus-single-article-buffer
5372 (gnus-article-setup-buffer))
5373 ;; First and last article in this newsgroup.
5374 (when gnus-newsgroup-headers
5375 (setq gnus-newsgroup-begin
5376 (mail-header-number (car gnus-newsgroup-headers))
5377 gnus-newsgroup-end
5378 (mail-header-number
5379 (gnus-last-element gnus-newsgroup-headers))))
5380 ;; GROUP is successfully selected.
5381 (or gnus-newsgroup-headers t)))))
5382
23f87bed
MB
5383(defun gnus-compute-unseen-list ()
5384 ;; The `seen' marks are treated specially.
5385 (if (not gnus-newsgroup-seen)
5386 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5387 (setq gnus-newsgroup-unseen
5388 (gnus-inverse-list-range-intersection
5389 gnus-newsgroup-articles gnus-newsgroup-seen))))
5390
5391(defun gnus-summary-display-make-predicate (display)
5392 (require 'gnus-agent)
5393 (when (= (length display) 1)
5394 (setq display (car display)))
5395 (unless gnus-summary-display-cache
5396 (dolist (elem (append '((unread . unread)
5397 (read . read)
5398 (unseen . unseen))
5399 gnus-article-mark-lists))
5400 (push (cons (cdr elem)
5401 (gnus-byte-compile
5402 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5403 gnus-summary-display-cache)))
5404 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5405 (gnus-category-predicate-cache gnus-summary-display-cache))
5406 (gnus-get-predicate display)))
5407
5408;; Uses the dynamically bound `number' variable.
5409(eval-when-compile
5410 (defvar number))
5411(defun gnus-article-marked-p (type &optional article)
5412 (let ((article (or article number)))
5413 (cond
5414 ((eq type 'tick)
5415 (memq article gnus-newsgroup-marked))
5416 ((eq type 'spam)
5417 (memq article gnus-newsgroup-spam-marked))
5418 ((eq type 'unsend)
5419 (memq article gnus-newsgroup-unsendable))
5420 ((eq type 'undownload)
5421 (memq article gnus-newsgroup-undownloaded))
5422 ((eq type 'download)
5423 (memq article gnus-newsgroup-downloadable))
5424 ((eq type 'unread)
5425 (memq article gnus-newsgroup-unreads))
5426 ((eq type 'read)
5427 (memq article gnus-newsgroup-reads))
5428 ((eq type 'dormant)
5429 (memq article gnus-newsgroup-dormant) )
5430 ((eq type 'expire)
5431 (memq article gnus-newsgroup-expirable))
5432 ((eq type 'reply)
5433 (memq article gnus-newsgroup-replied))
5434 ((eq type 'killed)
5435 (memq article gnus-newsgroup-killed))
5436 ((eq type 'bookmark)
5437 (assq article gnus-newsgroup-bookmarks))
5438 ((eq type 'score)
5439 (assq article gnus-newsgroup-scored))
5440 ((eq type 'save)
5441 (memq article gnus-newsgroup-saved))
5442 ((eq type 'cache)
5443 (memq article gnus-newsgroup-cached))
5444 ((eq type 'forward)
5445 (memq article gnus-newsgroup-forwarded))
5446 ((eq type 'seen)
5447 (not (memq article gnus-newsgroup-unseen)))
5448 ((eq type 'recent)
5449 (memq article gnus-newsgroup-recent))
5450 (t t))))
5451
eec82323 5452(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5453 "Find out what articles the user wants to read."
26c9afc3 5454 (let* ((articles
eec82323
LMI
5455 ;; Select all articles if `read-all' is non-nil, or if there
5456 ;; are no unread articles.
5457 (if (or read-all
5458 (and (zerop (length gnus-newsgroup-marked))
5459 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5460 ;; Fetch all if the predicate is non-nil.
5461 gnus-newsgroup-display)
5462 ;; We want to select the headers for all the articles in
5463 ;; the group, so we select either all the active
5464 ;; articles in the group, or (if that's nil), the
5465 ;; articles in the cache.
16409b0b
GM
5466 (or
5467 (gnus-uncompress-range (gnus-active group))
5468 (gnus-cache-articles-in-group group))
23f87bed
MB
5469 ;; Select only the "normal" subset of articles.
5470 (gnus-sorted-nunion
5471 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5472 gnus-newsgroup-unreads)))
eec82323
LMI
5473 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5474 (scored (length scored-list))
5475 (number (length articles))
5476 (marked (+ (length gnus-newsgroup-marked)
5477 (length gnus-newsgroup-dormant)))
5478 (select
5479 (cond
5480 ((numberp read-all)
5481 read-all)
23f87bed
MB
5482 ((numberp gnus-newsgroup-display)
5483 gnus-newsgroup-display)
eec82323
LMI
5484 (t
5485 (condition-case ()
5486 (cond
5487 ((and (or (<= scored marked) (= scored number))
5488 (numberp gnus-large-newsgroup)
5489 (> number gnus-large-newsgroup))
23f87bed
MB
5490 (let* ((cursor-in-echo-area nil)
5491 (initial (gnus-parameter-large-newsgroup-initial
5492 gnus-newsgroup-name))
5493 (input
5494 (read-string
5495 (format
5496 "How many articles from %s (%s %d): "
5497 (gnus-limit-string
5498 (gnus-group-decoded-name gnus-newsgroup-name)
5499 35)
5500 (if initial "max" "default")
5501 number)
5502 (if initial
5503 (cons (number-to-string initial)
5504 0)))))
eec82323
LMI
5505 (if (string-match "^[ \t]*$" input) number input)))
5506 ((and (> scored marked) (< scored number)
5507 (> (- scored number) 20))
5508 (let ((input
5509 (read-string
5510 (format "%s %s (%d scored, %d total): "
5511 "How many articles from"
23f87bed
MB
5512 (gnus-group-decoded-name group)
5513 scored number))))
eec82323
LMI
5514 (if (string-match "^[ \t]*$" input)
5515 number input)))
5516 (t number))
d4dfaa19
DL
5517 (quit
5518 (message "Quit getting the articles to read")
5519 nil))))))
eec82323
LMI
5520 (setq select (if (stringp select) (string-to-number select) select))
5521 (if (or (null select) (zerop select))
5522 select
5523 (if (and (not (zerop scored)) (<= (abs select) scored))
5524 (progn
5525 (setq articles (sort scored-list '<))
5526 (setq number (length articles)))
5527 (setq articles (copy-sequence articles)))
5528
5529 (when (< (abs select) number)
5530 (if (< select 0)
5531 ;; Select the N oldest articles.
5532 (setcdr (nthcdr (1- (abs select)) articles) nil)
5533 ;; Select the N most recent articles.
5534 (setq articles (nthcdr (- number select) articles))))
5535 (setq gnus-newsgroup-unselected
23f87bed 5536 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5537 (when gnus-alter-articles-to-read-function
23f87bed 5538 (setq articles
a1506d29 5539 (sort
16409b0b 5540 (funcall gnus-alter-articles-to-read-function
23f87bed 5541 gnus-newsgroup-name articles)
16409b0b 5542 '<)))
eec82323
LMI
5543 articles)))
5544
5545(defun gnus-killed-articles (killed articles)
5546 (let (out)
5547 (while articles
5548 (when (inline (gnus-member-of-range (car articles) killed))
5549 (push (car articles) out))
5550 (setq articles (cdr articles)))
5551 out))
5552
5553(defun gnus-uncompress-marks (marks)
5554 "Uncompress the mark ranges in MARKS."
5555 (let ((uncompressed '(score bookmark))
5556 out)
5557 (while marks
5558 (if (memq (caar marks) uncompressed)
5559 (push (car marks) out)
5560 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5561 (setq marks (cdr marks)))
5562 out))
5563
23f87bed
MB
5564(defun gnus-article-mark-to-type (mark)
5565 "Return the type of MARK."
5566 (or (cadr (assq mark gnus-article-special-mark-lists))
5567 'list))
5568
5569(defun gnus-article-unpropagatable-p (mark)
5570 "Return whether MARK should be propagated to back end."
5571 (memq mark gnus-article-unpropagated-mark-lists))
5572
eec82323 5573(defun gnus-adjust-marked-articles (info)
16409b0b 5574 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5575 (let* ((marked-lists (gnus-info-marks info))
5576 (active (gnus-active (gnus-info-group info)))
5577 (min (car active))
5578 (max (cdr active))
5579 (types gnus-article-mark-lists)
54506618
MB
5580 marks var articles article mark mark-type
5581 bgn end)
eec82323 5582
23f87bed
MB
5583 (dolist (marks marked-lists)
5584 (setq mark (car marks)
5585 mark-type (gnus-article-mark-to-type mark)
5586 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5587
23f87bed
MB
5588 ;; We set the variable according to the type of the marks list,
5589 ;; and then adjust the marks to a subset of the active articles.
eec82323 5590 (cond
54506618 5591 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5592 ((eq mark-type 'list)
54506618
MB
5593 ;; Simultaneously uncompress and clip to active range
5594 ;; See gnus-uncompress-range for a description of possible marks
5595 (let (l lh)
5596 (if (not (cadr marks))
5597 (set var nil)
5598 (setq articles (if (numberp (cddr marks))
5599 (list (cdr marks))
5600 (cdr marks))
5601 lh (cons nil nil)
5602 l lh)
5603
5604 (while (setq article (pop articles))
5605 (cond ((consp article)
5606 (setq bgn (max (car article) min)
5607 end (min (cdr article) max))
5608 (while (<= bgn end)
5609 (setq l (setcdr l (cons bgn nil))
5610 bgn (1+ bgn))))
5611 ((and (<= min article)
5612 (>= max article))
5613 (setq l (setcdr l (cons article nil))))))
5614 (set var (cdr lh)))))
eec82323 5615 ;; Adjust assocs.
23f87bed
MB
5616 ((eq mark-type 'tuple)
5617 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5618 (when (not (listp (cdr (symbol-value var))))
5619 (set var (list (symbol-value var))))
5620 (when (not (listp (cdr articles)))
5621 (setq articles (list articles)))
eec82323
LMI
5622 (while articles
5623 (when (or (not (consp (setq article (pop articles))))
5624 (< (car article) min)
5625 (> (car article) max))
23f87bed
MB
5626 (set var (delq article (symbol-value var))))))
5627 ;; Adjust ranges (sloppily).
5628 ((eq mark-type 'range)
5629 (cond
5630 ((eq mark 'seen)
5631 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5632 ;; It should be (seen (NUM1 . NUM2)).
5633 (when (numberp (cddr marks))
5634 (setcdr marks (list (cdr marks))))
5635 (setq articles (cdr marks))
5636 (while (and articles
5637 (or (and (consp (car articles))
5638 (> min (cdar articles)))
5639 (and (numberp (car articles))
5640 (> min (car articles)))))
5641 (pop articles))
5642 (set var articles))))))))
eec82323
LMI
5643
5644(defun gnus-update-missing-marks (missing)
6748645f 5645 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 5646 (when missing
23f87bed 5647 (let (var m)
eec82323 5648 ;; Go through all types.
23f87bed
MB
5649 (dolist (elem gnus-article-mark-lists)
5650 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5651 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5652 (when (symbol-value var)
5653 ;; This list has articles. So we delete all missing
5654 ;; articles from it.
5655 (setq m missing)
5656 (while m
5657 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
5658
5659(defun gnus-update-marks ()
5660 "Enter the various lists of marked articles into the newsgroup info list."
5661 (let ((types gnus-article-mark-lists)
5662 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 5663 type list newmarked symbol delta-marks)
eec82323 5664 (when info
16409b0b 5665 ;; Add all marks lists to the list of marks lists.
eec82323 5666 (while (setq type (pop types))
16409b0b
GM
5667 (setq list (symbol-value
5668 (setq symbol
23f87bed 5669 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 5670
16409b0b 5671 (when list
eec82323
LMI
5672 ;; Get rid of the entries of the articles that have the
5673 ;; default score.
5674 (when (and (eq (cdr type) 'score)
5675 gnus-save-score
5676 list)
5677 (let* ((arts list)
5678 (prev (cons nil list))
5679 (all prev))
5680 (while arts
5681 (if (or (not (consp (car arts)))
5682 (= (cdar arts) gnus-summary-default-score))
5683 (setcdr prev (cdr arts))
5684 (setq prev arts))
5685 (setq arts (cdr arts)))
16409b0b
GM
5686 (setq list (cdr all)))))
5687
23f87bed
MB
5688 (when (eq (cdr type) 'seen)
5689 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5690
5691 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 5692 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 5693
23f87bed
MB
5694 (when (and (gnus-check-backend-function
5695 'request-set-mark gnus-newsgroup-name)
5696 (not (gnus-article-unpropagatable-p (cdr type))))
5697 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5698 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5699 (add (gnus-remove-from-range
5700 (gnus-copy-sequence list) old)))
5701 (when add
5702 (push (list add 'add (list (cdr type))) delta-marks))
5703 (when del
5704 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 5705
16409b0b
GM
5706 (when list
5707 (push (cons (cdr type) list) newmarked)))
5708
5709 (when delta-marks
5710 (unless (gnus-check-group gnus-newsgroup-name)
5711 (error "Can't open server for %s" gnus-newsgroup-name))
5712 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 5713
eec82323
LMI
5714 ;; Enter these new marks into the info of the group.
5715 (if (nthcdr 3 info)
5716 (setcar (nthcdr 3 info) newmarked)
5717 ;; Add the marks lists to the end of the info.
5718 (when newmarked
5719 (setcdr (nthcdr 2 info) (list newmarked))))
5720
5721 ;; Cut off the end of the info if there's nothing else there.
5722 (let ((i 5))
5723 (while (and (> i 2)
5724 (not (nth i info)))
5725 (when (nthcdr (decf i) info)
5726 (setcdr (nthcdr i info) nil)))))))
5727
5728(defun gnus-set-mode-line (where)
16409b0b 5729 "Set the mode line of the article or summary buffers.
eec82323
LMI
5730If WHERE is `summary', the summary mode line format will be used."
5731 ;; Is this mode line one we keep updated?
16409b0b
GM
5732 (when (and (memq where gnus-updated-mode-lines)
5733 (symbol-value
5734 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323
LMI
5735 (let (mode-string)
5736 (save-excursion
5737 ;; We evaluate this in the summary buffer since these
5738 ;; variables are buffer-local to that buffer.
5739 (set-buffer gnus-summary-buffer)
23f87bed 5740 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
5741 ;; below.
5742 (let* ((mformat (symbol-value
5743 (intern
5744 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
5745 (gnus-tmp-group-name (gnus-mode-string-quote
5746 (gnus-group-decoded-name
5747 gnus-newsgroup-name)))
eec82323
LMI
5748 (gnus-tmp-article-number (or gnus-current-article 0))
5749 (gnus-tmp-unread gnus-newsgroup-unreads)
5750 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5751 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5752 (gnus-tmp-unread-and-unselected
5753 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5754 (zerop gnus-tmp-unselected))
5755 "")
5756 ((zerop gnus-tmp-unselected)
5757 (format "{%d more}" gnus-tmp-unread-and-unticked))
5758 (t (format "{%d(+%d) more}"
5759 gnus-tmp-unread-and-unticked
5760 gnus-tmp-unselected))))
5761 (gnus-tmp-subject
5762 (if (and gnus-current-headers
5763 (vectorp gnus-current-headers))
5764 (gnus-mode-string-quote
5765 (mail-header-subject gnus-current-headers))
5766 ""))
5767 bufname-length max-len
23f87bed 5768 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
5769 (setq mode-string (eval mformat))
5770 (setq bufname-length (if (string-match "%b" mode-string)
5771 (- (length
5772 (buffer-name
5773 (if (eq where 'summary)
5774 nil
5775 (get-buffer gnus-article-buffer))))
5776 2)
5777 0))
5778 (setq max-len (max 4 (if gnus-mode-non-string-length
5779 (- (window-width)
5780 gnus-mode-non-string-length
5781 bufname-length)
5782 (length mode-string))))
5783 ;; We might have to chop a bit of the string off...
5784 (when (> (length mode-string) max-len)
5785 (setq mode-string
16409b0b 5786 (concat (truncate-string-to-width mode-string (- max-len 3))
eec82323
LMI
5787 "...")))
5788 ;; Pad the mode string a bit.
5789 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5790 ;; Update the mode line.
5791 (setq mode-line-buffer-identification
5792 (gnus-mode-line-buffer-identification (list mode-string)))
5793 (set-buffer-modified-p t))))
5794
5795(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5796 "Go through the HEADERS list and add all Xrefs to a hash table.
5797The resulting hash table is returned, or nil if no Xrefs were found."
5798 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5799 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5800 (xref-hashtb (gnus-make-hashtable))
5801 start group entry number xrefs header)
5802 (while headers
5803 (setq header (pop headers))
5804 (when (and (setq xrefs (mail-header-xref header))
5805 (not (memq (setq number (mail-header-number header))
5806 unreads)))
5807 (setq start 0)
5808 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5809 (setq start (match-end 0))
5810 (setq group (if prefix
5811 (concat prefix (substring xrefs (match-beginning 1)
5812 (match-end 1)))
5813 (substring xrefs (match-beginning 1) (match-end 1))))
5814 (setq number
e9bd5782 5815 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
5816 (match-end 2))))
5817 (if (setq entry (gnus-gethash group xref-hashtb))
5818 (setcdr entry (cons number (cdr entry)))
5819 (gnus-sethash group (cons number nil) xref-hashtb)))))
5820 (and start xref-hashtb)))
5821
5822(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5823 "Look through all the headers and mark the Xrefs as read."
5824 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5825 name entry info xref-hashtb idlist method nth4)
5826 (save-excursion
5827 (set-buffer gnus-group-buffer)
5828 (when (setq xref-hashtb
5829 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5830 (mapatoms
5831 (lambda (group)
5832 (unless (string= from-newsgroup (setq name (symbol-name group)))
5833 (setq idlist (symbol-value group))
5834 ;; Dead groups are not updated.
5835 (and (prog1
5836 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5837 info (nth 2 entry))
5838 (when (stringp (setq nth4 (gnus-info-method info)))
5839 (setq nth4 (gnus-server-to-method nth4))))
5840 ;; Only do the xrefs if the group has the same
5841 ;; select method as the group we have just read.
5842 (or (gnus-methods-equal-p
5843 nth4 (gnus-find-method-for-group from-newsgroup))
5844 virtual
5845 (equal nth4 (setq method (gnus-find-method-for-group
5846 from-newsgroup)))
5847 (and (equal (car nth4) (car method))
5848 (equal (nth 1 nth4) (nth 1 method))))
5849 gnus-use-cross-reference
5850 (or (not (eq gnus-use-cross-reference t))
5851 virtual
5852 ;; Only do cross-references on subscribed
5853 ;; groups, if that is what is wanted.
5854 (<= (gnus-info-level info) gnus-level-subscribed))
5855 (gnus-group-make-articles-read name idlist))))
5856 xref-hashtb)))))
5857
6748645f
LMI
5858(defun gnus-compute-read-articles (group articles)
5859 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5860 (info (nth 2 entry))
5861 (active (gnus-active group))
5862 ninfo)
5863 (when entry
16409b0b 5864 ;; First peel off all invalid article numbers.
6748645f
LMI
5865 (when active
5866 (let ((ids articles)
5867 id first)
5868 (while (setq id (pop ids))
5869 (when (and first (> id (cdr active)))
5870 ;; We'll end up in this situation in one particular
5871 ;; obscure situation. If you re-scan a group and get
5872 ;; a new article that is cross-posted to a different
5873 ;; group that has not been re-scanned, you might get
5874 ;; crossposted article that has a higher number than
5875 ;; Gnus believes possible. So we re-activate this
5876 ;; group as well. This might mean doing the
5877 ;; crossposting thingy will *increase* the number
5878 ;; of articles in some groups. Tsk, tsk.
5879 (setq active (or (gnus-activate-group group) active)))
5880 (when (or (> id (cdr active))
5881 (< id (car active)))
5882 (setq articles (delq id articles))))))
5883 ;; If the read list is nil, we init it.
5884 (if (and active
5885 (null (gnus-info-read info))
5886 (> (car active) 1))
5887 (setq ninfo (cons 1 (1- (car active))))
5888 (setq ninfo (gnus-info-read info)))
5889 ;; Then we add the read articles to the range.
5890 (gnus-add-to-range
5891 ninfo (setq articles (sort articles '<))))))
5892
eec82323
LMI
5893(defun gnus-group-make-articles-read (group articles)
5894 "Update the info of GROUP to say that ARTICLES are read."
5895 (let* ((num 0)
5896 (entry (gnus-gethash group gnus-newsrc-hashtb))
5897 (info (nth 2 entry))
5898 (active (gnus-active group))
5899 range)
6748645f
LMI
5900 (when entry
5901 (setq range (gnus-compute-read-articles group articles))
5902 (save-excursion
5903 (set-buffer gnus-group-buffer)
5904 (gnus-undo-register
5905 `(progn
5906 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5907 (gnus-info-set-read ',info ',(gnus-info-read info))
5908 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 5909 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
5910 (gnus-group-update-group ,group t))))
5911 ;; Add the read articles to the range.
5912 (gnus-info-set-read info range)
23f87bed 5913 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
5914 ;; Then we have to re-compute how many unread
5915 ;; articles there are in this group.
5916 (when active
5917 (cond
5918 ((not range)
5919 (setq num (- (1+ (cdr active)) (car active))))
5920 ((not (listp (cdr range)))
5921 (setq num (- (cdr active) (- (1+ (cdr range))
5922 (car range)))))
5923 (t
5924 (while range
5925 (if (numberp (car range))
5926 (setq num (1+ num))
5927 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5928 (setq range (cdr range)))
5929 (setq num (- (cdr active) num))))
5930 ;; Update the number of unread articles.
5931 (setcar entry num)
5932 ;; Update the group buffer.
23f87bed
MB
5933 (unless (gnus-ephemeral-group-p group)
5934 (gnus-group-update-group group t))))))
eec82323 5935
eec82323
LMI
5936(defvar gnus-newsgroup-none-id 0)
5937
5938(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5939 (let ((cur nntp-server-buffer)
5940 (dependencies
5941 (or dependencies
5942 (save-excursion (set-buffer gnus-summary-buffer)
5943 gnus-newsgroup-dependencies)))
16409b0b
GM
5944 headers id end ref
5945 (mail-parse-charset gnus-newsgroup-charset)
5946 (mail-parse-ignored-charsets
5947 (save-excursion (condition-case nil
5948 (set-buffer gnus-summary-buffer)
5949 (error))
5950 gnus-newsgroup-ignored-charsets)))
eec82323
LMI
5951 (save-excursion
5952 (set-buffer nntp-server-buffer)
5953 ;; Translate all TAB characters into SPACE characters.
5954 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 5955 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 5956 (ietf-drums-unfold-fws)
6748645f 5957 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 5958 (let ((case-fold-search t)
6748645f 5959 in-reply-to header p lines chars)
eec82323 5960 (goto-char (point-min))
01ccbb85 5961 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
5962 ;; do not begin with 2 or 3.
5963 (while (re-search-forward "^[23][0-9]+ " nil t)
5964 (setq id nil
5965 ref nil)
5966 ;; This implementation of this function, with nine
5967 ;; search-forwards instead of the one re-search-forward and
5968 ;; a case (which basically was the old function) is actually
01ccbb85 5969 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
5970 ;; can't have everything, I guess. Speed and elegance
5971 ;; doesn't always go hand in hand.
5972 (setq
5973 header
5974 (vector
5975 ;; Number.
5976 (prog1
5977 (read cur)
5978 (end-of-line)
5979 (setq p (point))
5980 (narrow-to-region (point)
5981 (or (and (search-forward "\n.\n" nil t)
5982 (- (point) 2))
5983 (point))))
5984 ;; Subject.
5985 (progn
5986 (goto-char p)
23f87bed 5987 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
5988 (funcall gnus-decode-encoded-word-function
5989 (nnheader-header-value))
2bd3dcae 5990 "(none)"))
eec82323
LMI
5991 ;; From.
5992 (progn
5993 (goto-char p)
23f87bed 5994 (if (search-forward "\nfrom:" nil t)
343d6628 5995 (funcall gnus-decode-encoded-address-function
16409b0b 5996 (nnheader-header-value))
2bd3dcae 5997 "(nobody)"))
eec82323
LMI
5998 ;; Date.
5999 (progn
6000 (goto-char p)
23f87bed 6001 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6002 (nnheader-header-value) ""))
6003 ;; Message-ID.
6004 (progn
6005 (goto-char p)
6748645f
LMI
6006 (setq id (if (re-search-forward
6007 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6008 ;; We do it this way to make sure the Message-ID
6009 ;; is (somewhat) syntactically valid.
6010 (buffer-substring (match-beginning 1)
6011 (match-end 1))
eec82323
LMI
6012 ;; If there was no message-id, we just fake one
6013 ;; to make subsequent routines simpler.
6014 (nnheader-generate-fake-message-id))))
6015 ;; References.
6016 (progn
6017 (goto-char p)
23f87bed 6018 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6019 (progn
6020 (setq end (point))
6021 (prog1
6022 (nnheader-header-value)
6023 (setq ref
6024 (buffer-substring
6025 (progn
6026 (end-of-line)
6027 (search-backward ">" end t)
6028 (1+ (point)))
6029 (progn
6030 (search-backward "<" end t)
6031 (point))))))
6032 ;; Get the references from the in-reply-to header if there
6033 ;; were no references and the in-reply-to header looks
6034 ;; promising.
23f87bed 6035 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6036 (setq in-reply-to (nnheader-header-value))
6037 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6038 (let (ref2)
6039 (setq ref (substring in-reply-to (match-beginning 0)
6040 (match-end 0)))
6041 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6042 (setq ref2 (substring in-reply-to (match-beginning 0)
6043 (match-end 0)))
6044 (when (> (length ref2) (length ref))
6045 (setq ref ref2)))
6046 ref)
eec82323
LMI
6047 (setq ref nil))))
6048 ;; Chars.
6748645f
LMI
6049 (progn
6050 (goto-char p)
6051 (if (search-forward "\nchars: " nil t)
6052 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6053 chars -1)
6054 -1))
eec82323
LMI
6055 ;; Lines.
6056 (progn
6057 (goto-char p)
6058 (if (search-forward "\nlines: " nil t)
a8151ef7 6059 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6060 lines -1)
6061 -1))
eec82323
LMI
6062 ;; Xref.
6063 (progn
6064 (goto-char p)
23f87bed 6065 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6066 (nnheader-header-value)))
6067 ;; Extra.
6068 (when gnus-extra-headers
6069 (let ((extra gnus-extra-headers)
6070 out)
6071 (while extra
6072 (goto-char p)
6073 (when (search-forward
23f87bed 6074 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6075 (push (cons (car extra) (nnheader-header-value))
6076 out))
6077 (pop extra))
6078 out))))
eec82323
LMI
6079 (when (equal id ref)
6080 (setq ref nil))
6748645f
LMI
6081
6082 (when gnus-alter-header-function
6083 (funcall gnus-alter-header-function header)
6084 (setq id (mail-header-id header)
6085 ref (gnus-parent-id (mail-header-references header))))
6086
6087 (when (setq header
6088 (gnus-dependencies-add-header
6089 header dependencies force-new))
eec82323
LMI
6090 (push header headers))
6091 (goto-char (point-max))
6092 (widen))
6093 (nreverse headers)))))
6094
eec82323
LMI
6095;; Goes through the xover lines and returns a list of vectors
6096(defun gnus-get-newsgroup-headers-xover (sequence &optional
6097 force-new dependencies
6098 group also-fetch-heads)
16409b0b
GM
6099 "Parse the news overview data in the server buffer.
6100Return a list of headers that match SEQUENCE (see
6101`nntp-retrieve-headers')."
eec82323
LMI
6102 ;; Get the Xref when the users reads the articles since most/some
6103 ;; NNTP servers do not include Xrefs when using XOVER.
6104 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6105 (let ((mail-parse-charset gnus-newsgroup-charset)
6106 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6107 (cur nntp-server-buffer)
eec82323 6108 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6109 (allp (cond
6110 ((eq gnus-read-all-available-headers t)
6111 t)
14e6dc54
MB
6112 ((and (stringp gnus-read-all-available-headers)
6113 group)
23f87bed
MB
6114 (string-match gnus-read-all-available-headers group))
6115 (t
6116 nil)))
eec82323
LMI
6117 number headers header)
6118 (save-excursion
6119 (set-buffer nntp-server-buffer)
16409b0b 6120 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6121 ;; Allow the user to mangle the headers before parsing them.
6748645f 6122 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6123 (goto-char (point-min))
23f87bed
MB
6124 (gnus-parse-without-error
6125 (while (and (or sequence allp)
6126 (not (eobp)))
6127 (setq number (read cur))
6128 (when (not allp)
6129 (while (and sequence
6130 (< (car sequence) number))
6131 (setq sequence (cdr sequence))))
6132 (when (and (or allp
6133 (and sequence
6134 (eq number (car sequence))))
6135 (progn
6136 (setq sequence (cdr sequence))
6137 (setq header (inline
6138 (gnus-nov-parse-line
6139 number dependencies force-new)))))
6140 (push header headers))
6141 (forward-line 1)))
eec82323
LMI
6142 ;; A common bug in inn is that if you have posted an article and
6143 ;; then retrieves the active file, it will answer correctly --
6144 ;; the new article is included. However, a NOV entry for the
6145 ;; article may not have been generated yet, so this may fail.
6146 ;; We work around this problem by retrieving the last few
6147 ;; headers using HEAD.
6148 (if (or (not also-fetch-heads)
6149 (not sequence))
6150 ;; We (probably) got all the headers.
6151 (nreverse headers)
6152 (let ((gnus-nov-is-evil t))
6153 (nconc
6154 (nreverse headers)
23f87bed 6155 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6156 (gnus-get-newsgroup-headers))))))))
6157
6158(defun gnus-article-get-xrefs ()
6159 "Fill in the Xref value in `gnus-current-headers', if necessary.
6160This is meant to be called in `gnus-article-internal-prepare-hook'."
6161 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6162 gnus-current-headers)))
6163 (or (not gnus-use-cross-reference)
6164 (not headers)
6165 (and (mail-header-xref headers)
6166 (not (string= (mail-header-xref headers) "")))
6167 (let ((case-fold-search t)
6168 xref)
6169 (save-restriction
6170 (nnheader-narrow-to-headers)
6171 (goto-char (point-min))
16409b0b
GM
6172 (when (or (and (not (eobp))
6173 (eq (downcase (char-after)) ?x)
eec82323
LMI
6174 (looking-at "Xref:"))
6175 (search-forward "\nXref:" nil t))
6176 (goto-char (1+ (match-end 0)))
23f87bed 6177 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
eec82323
LMI
6178 (mail-header-set-xref headers xref)))))))
6179
6180(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6181 "Find article ID and insert the summary line for that article.
6182OLD-HEADER can either be a header or a line number to insert
6183the subject line on."
6184 (let* ((line (and (numberp old-header) old-header))
6185 (old-header (and (vectorp old-header) old-header))
6186 (header (cond ((and old-header use-old-header)
16409b0b
GM
6187 old-header)
6188 ((and (numberp id)
6189 (gnus-number-to-header id))
6190 (gnus-number-to-header id))
6191 (t
6192 (gnus-read-header id))))
6193 (number (and (numberp id) id))
6194 d)
eec82323
LMI
6195 (when header
6196 ;; Rebuild the thread that this article is part of and go to the
6197 ;; article we have fetched.
6198 (when (and (not gnus-show-threads)
6199 old-header)
6748645f
LMI
6200 (when (and number
6201 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6202 (goto-char (gnus-data-pos d))
6203 (gnus-data-remove
6204 number
6205 (- (gnus-point-at-bol)
6206 (prog1
6207 (1+ (gnus-point-at-eol))
6208 (gnus-delete-line))))))
23f87bed
MB
6209 ;; Remove list identifiers from subject.
6210 (when gnus-list-identifiers
6211 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6212 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6213 (when old-header
6214 (mail-header-set-number header (mail-header-number old-header)))
6215 (setq gnus-newsgroup-sparse
6216 (delq (setq number (mail-header-number header))
6217 gnus-newsgroup-sparse))
6218 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6219 (push number gnus-newsgroup-limit)
6220 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6221 (gnus-summary-goto-subject number nil t))
6222 (when (and (numberp number)
6223 (> number 0))
6224 ;; We have to update the boundaries even if we can't fetch the
6225 ;; article if ID is a number -- so that the next `P' or `N'
6226 ;; command will fetch the previous (or next) article even
6227 ;; if the one we tried to fetch this time has been canceled.
6228 (when (> number gnus-newsgroup-end)
6229 (setq gnus-newsgroup-end number))
6230 (when (< number gnus-newsgroup-begin)
6231 (setq gnus-newsgroup-begin number))
6232 (setq gnus-newsgroup-unselected
6233 (delq number gnus-newsgroup-unselected)))
6234 ;; Report back a success?
6235 (and header (mail-header-number header))))
6236
6237;;; Process/prefix in the summary buffer
6238
6239(defun gnus-summary-work-articles (n)
6748645f
LMI
6240 "Return a list of articles to be worked upon.
6241The prefix argument, the list of process marked articles, and the
6242current article will be taken into consideration."
6243 (save-excursion
6244 (set-buffer gnus-summary-buffer)
6245 (cond
6246 (n
6247 ;; A numerical prefix has been given.
6248 (setq n (prefix-numeric-value n))
6249 (let ((backward (< n 0))
6250 (n (abs (prefix-numeric-value n)))
6251 articles article)
6252 (save-excursion
6253 (while
6254 (and (> n 0)
6255 (push (setq article (gnus-summary-article-number))
6256 articles)
6257 (if backward
6258 (gnus-summary-find-prev nil article)
6259 (gnus-summary-find-next nil article)))
6260 (decf n)))
6261 (nreverse articles)))
6262 ((and (gnus-region-active-p) (mark))
6263 (message "region active")
6264 ;; Work on the region between point and mark.
6265 (let ((max (max (point) (mark)))
6266 articles article)
6267 (save-excursion
7dafe00b 6268 (goto-char (min (point) (mark)))
6748645f
LMI
6269 (while
6270 (and
6271 (push (setq article (gnus-summary-article-number)) articles)
6272 (gnus-summary-find-next nil article)
6273 (< (point) max)))
6274 (nreverse articles))))
6275 (gnus-newsgroup-processable
6276 ;; There are process-marked articles present.
6277 ;; Save current state.
6278 (gnus-summary-save-process-mark)
6279 ;; Return the list.
6280 (reverse gnus-newsgroup-processable))
6281 (t
6282 ;; Just return the current article.
6283 (list (gnus-summary-article-number))))))
6284
6285(defmacro gnus-summary-iterate (arg &rest forms)
6286 "Iterate over the process/prefixed articles and do FORMS.
6287ARG is the interactive prefix given to the command. FORMS will be
6288executed with point over the summary line of the articles."
6289 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6290 `(let ((,articles (gnus-summary-work-articles ,arg)))
6291 (while ,articles
6292 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6293 ,@forms
6294 (pop ,articles)))))
6748645f
LMI
6295
6296(put 'gnus-summary-iterate 'lisp-indent-function 1)
6297(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6298
6299(defun gnus-summary-save-process-mark ()
6300 "Push the current set of process marked articles on the stack."
6301 (interactive)
6302 (push (copy-sequence gnus-newsgroup-processable)
6303 gnus-newsgroup-process-stack))
6304
6305(defun gnus-summary-kill-process-mark ()
6306 "Push the current set of process marked articles on the stack and unmark."
6307 (interactive)
6308 (gnus-summary-save-process-mark)
6309 (gnus-summary-unmark-all-processable))
6310
6311(defun gnus-summary-yank-process-mark ()
6312 "Pop the last process mark state off the stack and restore it."
6313 (interactive)
6314 (unless gnus-newsgroup-process-stack
6315 (error "Empty mark stack"))
6316 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6317
6318(defun gnus-summary-process-mark-set (set)
6319 "Make SET into the current process marked articles."
6320 (gnus-summary-unmark-all-processable)
6321 (while set
6322 (gnus-summary-set-process-mark (pop set))))
6323
6324;;; Searching and stuff
6325
6326(defun gnus-summary-search-group (&optional backward use-level)
6327 "Search for next unread newsgroup.
6328If optional argument BACKWARD is non-nil, search backward instead."
6329 (save-excursion
6330 (set-buffer gnus-group-buffer)
6331 (when (gnus-group-search-forward
6332 backward nil (if use-level (gnus-group-group-level) nil))
6333 (gnus-group-group-name))))
6334
6335(defun gnus-summary-best-group (&optional exclude-group)
6336 "Find the name of the best unread group.
6337If EXCLUDE-GROUP, do not go to this group."
6338 (save-excursion
6339 (set-buffer gnus-group-buffer)
6340 (save-excursion
6341 (gnus-group-best-unread-group exclude-group))))
6342
23f87bed
MB
6343(defun gnus-summary-find-next (&optional unread article backward)
6344 (if backward
6345 (gnus-summary-find-prev unread article)
eec82323
LMI
6346 (let* ((dummy (gnus-summary-article-intangible-p))
6347 (article (or article (gnus-summary-article-number)))
23f87bed 6348 (data (gnus-data-find-list article))
eec82323
LMI
6349 result)
6350 (when (and (not dummy)
6351 (or (not gnus-summary-check-current)
6352 (not unread)
23f87bed
MB
6353 (not (gnus-data-unread-p (car data)))))
6354 (setq data (cdr data)))
eec82323
LMI
6355 (when (setq result
6356 (if unread
6357 (progn
23f87bed
MB
6358 (while data
6359 (unless (memq (gnus-data-number (car data))
6360 (cond
6361 ((eq gnus-auto-goto-ignores
6362 'always-undownloaded)
6363 gnus-newsgroup-undownloaded)
6364 (gnus-plugged
6365 nil)
6366 ((eq gnus-auto-goto-ignores
6367 'unfetched)
6368 gnus-newsgroup-unfetched)
6369 ((eq gnus-auto-goto-ignores
6370 'undownloaded)
6371 gnus-newsgroup-undownloaded)))
6372 (when (gnus-data-unread-p (car data))
6373 (setq result (car data)
6374 data nil)))
6375 (setq data (cdr data)))
eec82323 6376 result)
23f87bed 6377 (car data)))
eec82323
LMI
6378 (goto-char (gnus-data-pos result))
6379 (gnus-data-number result)))))
6380
6381(defun gnus-summary-find-prev (&optional unread article)
6382 (let* ((eobp (eobp))
6383 (article (or article (gnus-summary-article-number)))
23f87bed 6384 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6385 result)
6386 (when (and (not eobp)
6387 (or (not gnus-summary-check-current)
6388 (not unread)
23f87bed
MB
6389 (not (gnus-data-unread-p (car data)))))
6390 (setq data (cdr data)))
eec82323
LMI
6391 (when (setq result
6392 (if unread
6393 (progn
23f87bed
MB
6394 (while data
6395 (unless (memq (gnus-data-number (car data))
6396 (cond
6397 ((eq gnus-auto-goto-ignores
6398 'always-undownloaded)
6399 gnus-newsgroup-undownloaded)
6400 (gnus-plugged
6401 nil)
6402 ((eq gnus-auto-goto-ignores
6403 'unfetched)
6404 gnus-newsgroup-unfetched)
6405 ((eq gnus-auto-goto-ignores
6406 'undownloaded)
6407 gnus-newsgroup-undownloaded)))
6408 (when (gnus-data-unread-p (car data))
6409 (setq result (car data)
6410 data nil)))
6411 (setq data (cdr data)))
eec82323 6412 result)
23f87bed 6413 (car data)))
eec82323
LMI
6414 (goto-char (gnus-data-pos result))
6415 (gnus-data-number result))))
6416
6417(defun gnus-summary-find-subject (subject &optional unread backward article)
6418 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6419 (article (or article (gnus-summary-article-number)))
6420 (articles (gnus-data-list backward))
6421 (arts (gnus-data-find-list article articles))
6422 result)
6423 (when (or (not gnus-summary-check-current)
6424 (not unread)
6425 (not (gnus-data-unread-p (car arts))))
6426 (setq arts (cdr arts)))
6427 (while arts
6428 (and (or (not unread)
6429 (gnus-data-unread-p (car arts)))
6430 (vectorp (gnus-data-header (car arts)))
6431 (gnus-subject-equal
6432 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6433 (setq result (car arts)
6434 arts nil))
6435 (setq arts (cdr arts)))
6436 (and result
6437 (goto-char (gnus-data-pos result))
6438 (gnus-data-number result))))
6439
6440(defun gnus-summary-search-forward (&optional unread subject backward)
6441 "Search forward for an article.
6442If UNREAD, look for unread articles. If SUBJECT, look for
6443articles with that subject. If BACKWARD, search backward instead."
6444 (cond (subject (gnus-summary-find-subject subject unread backward))
6445 (backward (gnus-summary-find-prev unread))
6446 (t (gnus-summary-find-next unread))))
6447
6448(defun gnus-recenter (&optional n)
6449 "Center point in window and redisplay frame.
6450Also do horizontal recentering."
6451 (interactive "P")
6452 (when (and gnus-auto-center-summary
6453 (not (eq gnus-auto-center-summary 'vertical)))
6454 (gnus-horizontal-recenter))
6455 (recenter n))
6456
6457(defun gnus-summary-recenter ()
6458 "Center point in the summary window.
6459If `gnus-auto-center-summary' is nil, or the article buffer isn't
6460displayed, no centering will be performed."
6461 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6462 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6463 (interactive)
23f87bed
MB
6464 ;; The user has to want it.
6465 (when gnus-auto-center-summary
6466 (let* ((top (cond ((< (window-height) 4) 0)
6467 ((< (window-height) 7) 1)
6468 (t (if (numberp gnus-auto-center-summary)
6469 gnus-auto-center-summary
6470 2))))
6471 (height (1- (window-height)))
6472 (bottom (save-excursion (goto-char (point-max))
6473 (forward-line (- height))
6474 (point)))
6475 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6476 (when (get-buffer-window gnus-article-buffer)
6477 ;; Only do recentering when the article buffer is displayed,
6478 ;; Set the window start to either `bottom', which is the biggest
6479 ;; possible valid number, or the second line from the top,
6480 ;; whichever is the least.
db7ebd73
MB
6481 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6482 (if (> bottom top-pos)
6483 ;; Keep the second line from the top visible
6484 (set-window-start window top-pos t)
6485 ;; Try to keep the bottom line visible; if it's partially
6486 ;; obscured, either scroll one more line to make it fully
6487 ;; visible, or revert to using TOP-POS.
6488 (save-excursion
6489 (goto-char (point-max))
6490 (forward-line -1)
6491 (let ((last-line-start (point)))
6492 (goto-char bottom)
6493 (set-window-start window (point) t)
6494 (when (not (pos-visible-in-window-p last-line-start window))
6495 (forward-line 1)
6496 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6497 ;; Do horizontal recentering while we're at it.
6498 (when (and (get-buffer-window (current-buffer) t)
6499 (not (eq gnus-auto-center-summary 'vertical)))
6500 (let ((selected (selected-window)))
6501 (select-window (get-buffer-window (current-buffer) t))
6502 (gnus-summary-position-point)
6503 (gnus-horizontal-recenter)
6504 (select-window selected))))))
6505
6506(defun gnus-summary-jump-to-group (newsgroup)
6507 "Move point to NEWSGROUP in group mode buffer."
6508 ;; Keep update point of group mode buffer if visible.
6509 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6510 (save-window-excursion
6511 ;; Take care of tree window mode.
6512 (when (get-buffer-window gnus-group-buffer)
6513 (pop-to-buffer gnus-group-buffer))
6514 (gnus-group-jump-to-group newsgroup))
6515 (save-excursion
6516 ;; Take care of tree window mode.
6517 (if (get-buffer-window gnus-group-buffer)
6518 (pop-to-buffer gnus-group-buffer)
6519 (set-buffer gnus-group-buffer))
6520 (gnus-group-jump-to-group newsgroup))))
6521
6522;; This function returns a list of article numbers based on the
6523;; difference between the ranges of read articles in this group and
6524;; the range of active articles.
6525(defun gnus-list-of-unread-articles (group)
6526 (let* ((read (gnus-info-read (gnus-get-info group)))
6527 (active (or (gnus-active group) (gnus-activate-group group)))
6528 (last (cdr active))
6529 first nlast unread)
6530 ;; If none are read, then all are unread.
6531 (if (not read)
6532 (setq first (car active))
6533 ;; If the range of read articles is a single range, then the
6534 ;; first unread article is the article after the last read
6535 ;; article. Sounds logical, doesn't it?
16409b0b
GM
6536 (if (and (not (listp (cdr read)))
6537 (or (< (car read) (car active))
6538 (progn (setq read (list read))
6539 nil)))
6748645f 6540 (setq first (max (car active) (1+ (cdr read))))
eec82323
LMI
6541 ;; `read' is a list of ranges.
6542 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6543 (caar read)))
6544 1)
6748645f 6545 (setq first (car active)))
eec82323
LMI
6546 (while read
6547 (when first
6548 (while (< first nlast)
54506618
MB
6549 (setq unread (cons first unread)
6550 first (1+ first))))
eec82323
LMI
6551 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6552 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6553 (setq read (cdr read)))))
6554 ;; And add the last unread articles.
6555 (while (<= first last)
54506618
MB
6556 (setq unread (cons first unread)
6557 first (1+ first)))
eec82323 6558 ;; Return the list of unread articles.
6748645f 6559 (delq 0 (nreverse unread))))
eec82323
LMI
6560
6561(defun gnus-list-of-read-articles (group)
6562 "Return a list of unread, unticked and non-dormant articles."
6563 (let* ((info (gnus-get-info group))
6564 (marked (gnus-info-marks info))
6565 (active (gnus-active group)))
6566 (and info active
23f87bed
MB
6567 (gnus-list-range-difference
6568 (gnus-list-range-difference
6569 (gnus-sorted-complement
6570 (gnus-uncompress-range active)
6571 (gnus-list-of-unread-articles group))
6572 (cdr (assq 'dormant marked)))
6573 (cdr (assq 'tick marked))))))
eec82323 6574
54506618
MB
6575;; This function returns a sequence of article numbers based on the
6576;; difference between the ranges of read articles in this group and
6577;; the range of active articles.
6578(defun gnus-sequence-of-unread-articles (group)
6579 (let* ((read (gnus-info-read (gnus-get-info group)))
6580 (active (or (gnus-active group) (gnus-activate-group group)))
6581 (last (cdr active))
6582 first nlast unread)
6583 ;; If none are read, then all are unread.
6584 (if (not read)
6585 (setq first (car active))
6586 ;; If the range of read articles is a single range, then the
6587 ;; first unread article is the article after the last read
6588 ;; article. Sounds logical, doesn't it?
6589 (if (and (not (listp (cdr read)))
6590 (or (< (car read) (car active))
6591 (progn (setq read (list read))
6592 nil)))
6593 (setq first (max (car active) (1+ (cdr read))))
6594 ;; `read' is a list of ranges.
6595 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6596 (caar read)))
6597 1)
6598 (setq first (car active)))
6599 (while read
6600 (when first
6601 (push (cons first nlast) unread))
6602 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6603 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6604 (setq read (cdr read)))))
6605 ;; And add the last unread articles.
ba0226dd
MB
6606 (cond ((not (and first last))
6607 nil)
6608 ((< first last)
6609 (push (cons first last) unread))
6610 ((= first last)
6611 (push first unread)))
54506618
MB
6612 ;; Return the sequence of unread articles.
6613 (delq 0 (nreverse unread))))
6614
eec82323
LMI
6615;; Various summary commands
6616
6748645f
LMI
6617(defun gnus-summary-select-article-buffer ()
6618 "Reconfigure windows to show article buffer."
6619 (interactive)
6620 (if (not (gnus-buffer-live-p gnus-article-buffer))
6621 (error "There is no article buffer for this summary buffer")
6622 (gnus-configure-windows 'article)
6623 (select-window (get-buffer-window gnus-article-buffer))))
6624
eec82323
LMI
6625(defun gnus-summary-universal-argument (arg)
6626 "Perform any operation on all articles that are process/prefixed."
6627 (interactive "P")
eec82323
LMI
6628 (let ((articles (gnus-summary-work-articles arg))
6629 func article)
6630 (if (eq
6631 (setq
6632 func
6633 (key-binding
6634 (read-key-sequence
6635 (substitute-command-keys
16409b0b 6636 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
6637 'undefined)
6638 (gnus-error 1 "Undefined key")
6639 (save-excursion
6640 (while articles
6641 (gnus-summary-goto-subject (setq article (pop articles)))
6642 (let (gnus-newsgroup-processable)
6643 (command-execute func))
6644 (gnus-summary-remove-process-mark article)))))
6645 (gnus-summary-position-point))
6646
6647(defun gnus-summary-toggle-truncation (&optional arg)
6648 "Toggle truncation of summary lines.
23f87bed 6649With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
6650 (interactive "P")
6651 (setq truncate-lines
6652 (if (null arg) (not truncate-lines)
6653 (> (prefix-numeric-value arg) 0)))
6654 (redraw-display))
6655
23f87bed
MB
6656(defun gnus-summary-find-for-reselect ()
6657 "Return the number of an article to stay on across a reselect.
6658The current article is considered, then following articles, then previous
6659articles. An article is sought which is not cancelled and isn't a temporary
6660insertion from another group. If there's no such then return a dummy 0."
6661 (let (found)
6662 (dolist (rev '(nil t))
6663 (unless found ; don't demand the reverse list if we don't need it
6664 (let ((data (gnus-data-find-list
6665 (gnus-summary-article-number) (gnus-data-list rev))))
6666 (while (and data (not found))
6667 (if (and (< 0 (gnus-data-number (car data)))
6668 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6669 (setq found (gnus-data-number (car data))))
6670 (setq data (cdr data))))))
6671 (or found 0)))
6672
eec82323
LMI
6673(defun gnus-summary-reselect-current-group (&optional all rescan)
6674 "Exit and then reselect the current newsgroup.
6675The prefix argument ALL means to select all articles."
6676 (interactive "P")
eec82323
LMI
6677 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6678 (error "Ephemeral groups can't be reselected"))
23f87bed 6679 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
6680 (group gnus-newsgroup-name))
6681 (setq gnus-newsgroup-begin nil)
23f87bed 6682 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
6683 ;; We have to adjust the point of group mode buffer because
6684 ;; point was moved to the next unread newsgroup by exiting.
6685 (gnus-summary-jump-to-group group)
6686 (when rescan
6687 (save-excursion
6688 (gnus-group-get-new-news-this-group 1)))
6689 (gnus-group-read-group all t)
6690 (gnus-summary-goto-subject current-subject nil t)))
6691
6692(defun gnus-summary-rescan-group (&optional all)
6693 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6694 (interactive "P")
6695 (gnus-summary-reselect-current-group all t))
6696
6697(defun gnus-summary-update-info (&optional non-destructive)
6698 (save-excursion
6699 (let ((group gnus-newsgroup-name))
6748645f
LMI
6700 (when group
6701 (when gnus-newsgroup-kill-headers
6702 (setq gnus-newsgroup-killed
6703 (gnus-compress-sequence
23f87bed
MB
6704 (gnus-sorted-union
6705 (gnus-list-range-intersection
6706 gnus-newsgroup-unselected gnus-newsgroup-killed)
6707 gnus-newsgroup-unreads)
6748645f
LMI
6708 t)))
6709 (unless (listp (cdr gnus-newsgroup-killed))
6710 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6711 (let ((headers gnus-newsgroup-headers))
6712 ;; Set the new ranges of read articles.
6713 (save-excursion
6714 (set-buffer gnus-group-buffer)
6715 (gnus-undo-force-boundary))
6716 (gnus-update-read-articles
23f87bed
MB
6717 group (gnus-sorted-union
6718 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
6719 ;; Set the current article marks.
6720 (let ((gnus-newsgroup-scored
6721 (if (and (not gnus-save-score)
6722 (not non-destructive))
6723 nil
6724 gnus-newsgroup-scored)))
6725 (save-excursion
6726 (gnus-update-marks)))
6727 ;; Do the cross-ref thing.
6728 (when gnus-use-cross-reference
6729 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6730 ;; Do not switch windows but change the buffer to work.
a8151ef7 6731 (set-buffer gnus-group-buffer)
6748645f
LMI
6732 (unless (gnus-ephemeral-group-p group)
6733 (gnus-group-update-group group)))))))
eec82323
LMI
6734
6735(defun gnus-summary-save-newsrc (&optional force)
6736 "Save the current number of read/marked articles in the dribble buffer.
6737The dribble buffer will then be saved.
6738If FORCE (the prefix), also save the .newsrc file(s)."
6739 (interactive "P")
6740 (gnus-summary-update-info t)
6741 (if force
6742 (gnus-save-newsrc-file)
6743 (gnus-dribble-save)))
6744
23f87bed 6745(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 6746 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 6747`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
6748 (interactive)
6749 (gnus-set-global-variables)
16409b0b
GM
6750 (when (gnus-buffer-live-p gnus-article-buffer)
6751 (save-excursion
6752 (set-buffer gnus-article-buffer)
6753 (mm-destroy-parts gnus-article-mime-handles)
6754 ;; Set it to nil for safety reason.
6755 (setq gnus-article-mime-handle-alist nil)
6756 (setq gnus-article-mime-handles nil)))
eec82323 6757 (gnus-kill-save-kill-buffer)
6748645f 6758 (gnus-async-halt-prefetch)
eec82323
LMI
6759 (let* ((group gnus-newsgroup-name)
6760 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 6761 (gnus-group-is-exiting-p t)
eec82323 6762 (mode major-mode)
23f87bed 6763 (group-point nil)
eec82323 6764 (buf (current-buffer)))
16409b0b
GM
6765 (unless quit-config
6766 ;; Do adaptive scoring, and possibly save score files.
6767 (when gnus-newsgroup-adaptive
6768 (gnus-score-adaptive))
6769 (when gnus-use-scoring
6770 (gnus-score-save)))
6748645f 6771 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
6772 ;; If we have several article buffers, we kill them at exit.
6773 (unless gnus-single-article-buffer
6774 (gnus-kill-buffer gnus-original-article-buffer)
6775 (setq gnus-article-current nil))
6776 (when gnus-use-cache
6777 (gnus-cache-possibly-remove-articles)
6778 (gnus-cache-save-buffers))
6779 (gnus-async-prefetch-remove-group group)
6780 (when gnus-suppress-duplicates
6781 (gnus-dup-enter-articles))
6782 (when gnus-use-trees
6783 (gnus-tree-close group))
16409b0b
GM
6784 (when gnus-use-cache
6785 (gnus-cache-write-active))
6748645f
LMI
6786 ;; Remove entries for this group.
6787 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
6788 ;; Make all changes in this group permanent.
6789 (unless quit-config
6748645f 6790 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 6791 (gnus-summary-update-info))
eec82323
LMI
6792 (gnus-close-group group)
6793 ;; Make sure where we were, and go to next newsgroup.
6794 (set-buffer gnus-group-buffer)
6795 (unless quit-config
6796 (gnus-group-jump-to-group group))
6748645f
LMI
6797 (gnus-run-hooks 'gnus-summary-exit-hook)
6798 (unless (or quit-config
6799 ;; If this group has disappeared from the summary
6800 ;; buffer, don't skip forwards.
6801 (not (string= group (gnus-group-group-name))))
eec82323 6802 (gnus-group-next-unread-group 1))
a8151ef7 6803 (setq group-point (point))
eec82323
LMI
6804 (if temporary
6805 nil ;Nothing to do.
6806 ;; If we have several article buffers, we kill them at exit.
6807 (unless gnus-single-article-buffer
6808 (gnus-kill-buffer gnus-article-buffer)
6809 (gnus-kill-buffer gnus-original-article-buffer)
6810 (setq gnus-article-current nil))
6811 (set-buffer buf)
6812 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
6813 (progn
6814 (gnus-deaden-summary)
6815 (setq mode nil))
eec82323
LMI
6816 ;; We set all buffer-local variables to nil. It is unclear why
6817 ;; this is needed, but if we don't, buffer-local variables are
6818 ;; not garbage-collected, it seems. This would the lead to en
6819 ;; ever-growing Emacs.
6820 (gnus-summary-clear-local-variables)
23f87bed
MB
6821 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6822 (gnus-summary-clear-local-variables))
eec82323
LMI
6823 (when (get-buffer gnus-article-buffer)
6824 (bury-buffer gnus-article-buffer))
6825 ;; We clear the global counterparts of the buffer-local
6826 ;; variables as well, just to be on the safe side.
6827 (set-buffer gnus-group-buffer)
6828 (gnus-summary-clear-local-variables)
23f87bed
MB
6829 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6830 (gnus-summary-clear-local-variables))
eec82323
LMI
6831 ;; Return to group mode buffer.
6832 (when (eq mode 'gnus-summary-mode)
6833 (gnus-kill-buffer buf)))
6834 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
6835 (set-buffer gnus-group-buffer)
6836 (if quit-config
6837 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
6838 (goto-char group-point)
6839 ;; If gnus-group-buffer is already displayed, make sure we also move
6840 ;; the cursor in the window that displays it.
6841 (let ((win (get-buffer-window (current-buffer) 0)))
6842 (if win (set-window-point win (point))))
d61c212b 6843 (unless leave-hidden
4e90f2b9 6844 (gnus-configure-windows 'group 'force)))
6748645f 6845 ;; Clear the current group name.
eec82323
LMI
6846 (unless quit-config
6847 (setq gnus-newsgroup-name nil)))))
6848
6849(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6850(defun gnus-summary-exit-no-update (&optional no-questions)
6851 "Quit reading current newsgroup without updating read article info."
6852 (interactive)
eec82323 6853 (let* ((group gnus-newsgroup-name)
23f87bed
MB
6854 (gnus-group-is-exiting-p t)
6855 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
6856 (quit-config (gnus-group-quit-config group)))
6857 (when (or no-questions
6858 gnus-expert-user
6859 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 6860 (gnus-async-halt-prefetch)
23f87bed 6861 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b
GM
6862 (when (gnus-buffer-live-p gnus-article-buffer)
6863 (save-excursion
6864 (set-buffer gnus-article-buffer)
6865 (mm-destroy-parts gnus-article-mime-handles)
6866 ;; Set it to nil for safety reason.
6867 (setq gnus-article-mime-handle-alist nil)
6868 (setq gnus-article-mime-handles nil)))
eec82323
LMI
6869 ;; If we have several article buffers, we kill them at exit.
6870 (unless gnus-single-article-buffer
6871 (gnus-kill-buffer gnus-article-buffer)
6872 (gnus-kill-buffer gnus-original-article-buffer)
6873 (setq gnus-article-current nil))
6874 (if (not gnus-kill-summary-on-exit)
6875 (gnus-deaden-summary)
6876 (gnus-close-group group)
6877 (gnus-summary-clear-local-variables)
23f87bed
MB
6878 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6879 (gnus-summary-clear-local-variables))
eec82323
LMI
6880 (set-buffer gnus-group-buffer)
6881 (gnus-summary-clear-local-variables)
23f87bed
MB
6882 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6883 (gnus-summary-clear-local-variables))
6884 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
6885 (unless gnus-single-article-buffer
6886 (setq gnus-article-current nil))
6887 (when gnus-use-trees
6888 (gnus-tree-close group))
6889 (gnus-async-prefetch-remove-group group)
6890 (when (get-buffer gnus-article-buffer)
6891 (bury-buffer gnus-article-buffer))
6892 ;; Return to the group buffer.
6893 (gnus-configure-windows 'group 'force)
6894 ;; Clear the current group name.
6895 (setq gnus-newsgroup-name nil)
23f87bed
MB
6896 (unless (gnus-ephemeral-group-p group)
6897 (gnus-group-update-group group))
eec82323
LMI
6898 (when (equal (gnus-group-group-name) group)
6899 (gnus-group-next-unread-group 1))
6900 (when quit-config
23f87bed 6901 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
6902
6903(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
6904 "Handle movement when leaving an ephemeral group.
6905The state which existed when entering the ephemeral is reset."
eec82323
LMI
6906 (if (not (buffer-name (car quit-config)))
6907 (gnus-configure-windows 'group 'force)
6908 (set-buffer (car quit-config))
6909 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
6910 (gnus-set-global-variables))
6911 ((eq major-mode 'gnus-article-mode)
6912 (save-excursion
6913 ;; The `gnus-summary-buffer' variable may point
6914 ;; to the old summary buffer when using a single
6915 ;; article buffer.
6916 (unless (gnus-buffer-live-p gnus-summary-buffer)
6917 (set-buffer gnus-group-buffer))
6918 (set-buffer gnus-summary-buffer)
6919 (gnus-set-global-variables))))
eec82323 6920 (if (or (eq (cdr quit-config) 'article)
23f87bed
MB
6921 (eq (cdr quit-config) 'pick))
6922 (progn
6923 ;; The current article may be from the ephemeral group
6924 ;; thus it is best that we reload this article
6925 ;;
6926 ;; If we're exiting from a large digest, this can be
6927 ;; extremely slow. So, it's better not to reload it. -- jh.
6928 ;;(gnus-summary-show-article)
6929 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6930 (gnus-configure-windows 'pick 'force)
6931 (gnus-configure-windows (cdr quit-config) 'force)))
eec82323
LMI
6932 (gnus-configure-windows (cdr quit-config) 'force))
6933 (when (eq major-mode 'gnus-summary-mode)
6934 (gnus-summary-next-subject 1 nil t)
6935 (gnus-summary-recenter)
6936 (gnus-summary-position-point))))
6937
6938;;; Dead summaries.
6939
6940(defvar gnus-dead-summary-mode-map nil)
6941
6942(unless gnus-dead-summary-mode-map
6943 (setq gnus-dead-summary-mode-map (make-keymap))
6944 (suppress-keymap gnus-dead-summary-mode-map)
6945 (substitute-key-definition
6946 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
23f87bed
MB
6947 (dolist (key '("\C-d" "\r" "\177" [delete]))
6948 (define-key gnus-dead-summary-mode-map
6949 key 'gnus-summary-wake-up-the-dead))
6950 (dolist (key '("q" "Q"))
6951 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
eec82323
LMI
6952
6953(defvar gnus-dead-summary-mode nil
6954 "Minor mode for Gnus summary buffers.")
6955
6956(defun gnus-dead-summary-mode (&optional arg)
6957 "Minor mode for Gnus summary buffers."
6958 (interactive "P")
6959 (when (eq major-mode 'gnus-summary-mode)
6960 (make-local-variable 'gnus-dead-summary-mode)
6961 (setq gnus-dead-summary-mode
6962 (if (null arg) (not gnus-dead-summary-mode)
6963 (> (prefix-numeric-value arg) 0)))
6964 (when gnus-dead-summary-mode
a8151ef7
LMI
6965 (gnus-add-minor-mode
6966 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
eec82323
LMI
6967
6968(defun gnus-deaden-summary ()
6969 "Make the current summary buffer into a dead summary buffer."
6970 ;; Kill any previous dead summary buffer.
6971 (when (and gnus-dead-summary
6972 (buffer-name gnus-dead-summary))
6973 (save-excursion
6974 (set-buffer gnus-dead-summary)
6975 (when gnus-dead-summary-mode
6976 (kill-buffer (current-buffer)))))
6977 ;; Make this the current dead summary.
6978 (setq gnus-dead-summary (current-buffer))
6979 (gnus-dead-summary-mode 1)
6980 (let ((name (buffer-name)))
6981 (when (string-match "Summary" name)
6982 (rename-buffer
6983 (concat (substring name 0 (match-beginning 0)) "Dead "
6984 (substring name (match-beginning 0)))
16409b0b
GM
6985 t)
6986 (bury-buffer))))
eec82323
LMI
6987
6988(defun gnus-kill-or-deaden-summary (buffer)
6989 "Kill or deaden the summary BUFFER."
6748645f
LMI
6990 (save-excursion
6991 (when (and (buffer-name buffer)
6992 (not gnus-single-article-buffer))
6993 (save-excursion
6994 (set-buffer buffer)
6995 (gnus-kill-buffer gnus-article-buffer)
6996 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
6997 (cond
6998 ;; Kill the buffer.
6999 (gnus-kill-summary-on-exit
7000 (when (and gnus-use-trees
7001 (gnus-buffer-exists-p buffer))
7002 (save-excursion
7003 (set-buffer buffer)
7004 (gnus-tree-close gnus-newsgroup-name)))
7005 (gnus-kill-buffer buffer))
7006 ;; Deaden the buffer.
7007 ((gnus-buffer-exists-p buffer)
7008 (save-excursion
7009 (set-buffer buffer)
7010 (gnus-deaden-summary))))))
eec82323
LMI
7011
7012(defun gnus-summary-wake-up-the-dead (&rest args)
7013 "Wake up the dead summary buffer."
7014 (interactive)
7015 (gnus-dead-summary-mode -1)
7016 (let ((name (buffer-name)))
7017 (when (string-match "Dead " name)
7018 (rename-buffer
7019 (concat (substring name 0 (match-beginning 0))
7020 (substring name (match-end 0)))
7021 t)))
7022 (gnus-message 3 "This dead summary is now alive again"))
7023
7024;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7025(defun gnus-summary-fetch-faq (&optional faq-dir)
7026 "Fetch the FAQ for the current group.
7027If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7028in."
7029 (interactive
7030 (list
7031 (when current-prefix-arg
7032 (completing-read
8f688cb0 7033 "FAQ dir: " (and (listp gnus-group-faq-directory)
a8151ef7
LMI
7034 (mapcar (lambda (file) (list file))
7035 gnus-group-faq-directory))))))
eec82323
LMI
7036 (let (gnus-faq-buffer)
7037 (when (setq gnus-faq-buffer
7038 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7039 (gnus-configure-windows 'summary-faq))))
7040
7041;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7042(defun gnus-summary-describe-group (&optional force)
7043 "Describe the current newsgroup."
7044 (interactive "P")
7045 (gnus-group-describe-group force gnus-newsgroup-name))
7046
7047(defun gnus-summary-describe-briefly ()
7048 "Describe summary mode commands briefly."
7049 (interactive)
16409b0b 7050 (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
7051
7052;; Walking around group mode buffer from summary mode.
7053
7054(defun gnus-summary-next-group (&optional no-article target-group backward)
7055 "Exit current newsgroup and then select next unread newsgroup.
7056If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7057initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7058previous group instead."
7059 (interactive "P")
eec82323
LMI
7060 ;; Stop pre-fetching.
7061 (gnus-async-halt-prefetch)
7062 (let ((current-group gnus-newsgroup-name)
7063 (current-buffer (current-buffer))
7064 entered)
7065 ;; First we semi-exit this group to update Xrefs and all variables.
7066 ;; We can't do a real exit, because the window conf must remain
7067 ;; the same in case the user is prompted for info, and we don't
7068 ;; want the window conf to change before that...
7069 (gnus-summary-exit t)
7070 (while (not entered)
7071 ;; Then we find what group we are supposed to enter.
7072 (set-buffer gnus-group-buffer)
7073 (gnus-group-jump-to-group current-group)
7074 (setq target-group
7075 (or target-group
7076 (if (eq gnus-keep-same-level 'best)
7077 (gnus-summary-best-group gnus-newsgroup-name)
7078 (gnus-summary-search-group backward gnus-keep-same-level))))
7079 (if (not target-group)
7080 ;; There are no further groups, so we return to the group
7081 ;; buffer.
7082 (progn
7083 (gnus-message 5 "Returning to the group buffer")
7084 (setq entered t)
7085 (when (gnus-buffer-live-p current-buffer)
7086 (set-buffer current-buffer)
7087 (gnus-summary-exit))
6748645f 7088 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7089 ;; We try to enter the target group.
7090 (gnus-group-jump-to-group target-group)
7091 (let ((unreads (gnus-group-group-unread)))
7092 (if (and (or (eq t unreads)
7093 (and unreads (not (zerop unreads))))
23f87bed
MB
7094 (gnus-summary-read-group
7095 target-group nil no-article
7096 (and (buffer-name current-buffer) current-buffer)
7097 nil backward))
eec82323
LMI
7098 (setq entered t)
7099 (setq current-group target-group
7100 target-group nil)))))))
7101
7102(defun gnus-summary-prev-group (&optional no-article)
7103 "Exit current newsgroup and then select previous unread newsgroup.
7104If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7105 (interactive "P")
7106 (gnus-summary-next-group no-article nil t))
7107
7108;; Walking around summary lines.
7109
23f87bed
MB
7110(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7111 "Go to the first subject satisfying any non-nil constraint.
7112If UNREAD is non-nil, the article should be unread.
7113If UNDOWNLOADED is non-nil, the article should be undownloaded.
7114If UNSEEN is non-nil, the article should be unseen.
7115Returns the article selected or nil if there are no matching articles."
eec82323 7116 (interactive "P")
23f87bed
MB
7117 (cond
7118 ;; Empty summary.
7119 ((null gnus-newsgroup-data)
7120 (gnus-message 3 "No articles in the group")
7121 nil)
7122 ;; Pick the first article.
7123 ((not (or unread undownloaded unseen))
7124 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7125 (gnus-data-number (car gnus-newsgroup-data)))
7126 ;; Find the first unread article.
7127 (t
7128 (let ((data gnus-newsgroup-data))
7129 (while (and data
7130 (let ((num (gnus-data-number (car data))))
7131 (or (memq num gnus-newsgroup-unfetched)
7132 (not (or (and unread
7133 (memq num gnus-newsgroup-unreads))
7134 (and undownloaded
7135 (memq num gnus-newsgroup-undownloaded))
7136 (and unseen
7137 (memq num gnus-newsgroup-unseen)))))))
7138 (setq data (cdr data)))
7139 (prog1
7140 (if data
7141 (progn
7142 (goto-char (gnus-data-pos (car data)))
7143 (gnus-data-number (car data)))
7144 (gnus-message 3 "No more%s articles"
7145 (let* ((r (when unread " unread"))
7146 (d (when undownloaded " undownloaded"))
7147 (s (when unseen " unseen"))
7148 (l (delq nil (list r d s))))
7149 (cond ((= 3 (length l))
7150 (concat r "," d ", or" s))
7151 ((= 2 (length l))
7152 (concat (car l) ", or" (cadr l)))
7153 ((= 1 (length l))
7154 (car l))
7155 (t
7156 ""))))
7157 nil
7158 )
7159 (gnus-summary-position-point))))))
eec82323
LMI
7160
7161(defun gnus-summary-next-subject (n &optional unread dont-display)
7162 "Go to next N'th summary line.
7163If N is negative, go to the previous N'th subject line.
7164If UNREAD is non-nil, only unread articles are selected.
7165The difference between N and the actual number of steps taken is
7166returned."
7167 (interactive "p")
7168 (let ((backward (< n 0))
7169 (n (abs n)))
7170 (while (and (> n 0)
7171 (if backward
7172 (gnus-summary-find-prev unread)
7173 (gnus-summary-find-next unread)))
16409b0b
GM
7174 (unless (zerop (setq n (1- n)))
7175 (gnus-summary-show-thread)))
eec82323
LMI
7176 (when (/= 0 n)
7177 (gnus-message 7 "No more%s articles"
7178 (if unread " unread" "")))
7179 (unless dont-display
7180 (gnus-summary-recenter)
7181 (gnus-summary-position-point))
7182 n))
7183
7184(defun gnus-summary-next-unread-subject (n)
7185 "Go to next N'th unread summary line."
7186 (interactive "p")
7187 (gnus-summary-next-subject n t))
7188
7189(defun gnus-summary-prev-subject (n &optional unread)
7190 "Go to previous N'th summary line.
7191If optional argument UNREAD is non-nil, only unread article is selected."
7192 (interactive "p")
7193 (gnus-summary-next-subject (- n) unread))
7194
7195(defun gnus-summary-prev-unread-subject (n)
7196 "Go to previous N'th unread summary line."
7197 (interactive "p")
7198 (gnus-summary-next-subject (- n) t))
7199
23f87bed
MB
7200(defun gnus-summary-goto-subjects (articles)
7201 "Insert the subject header for ARTICLES in the current buffer."
7202 (save-excursion
7203 (dolist (article articles)
7204 (gnus-summary-goto-subject article t)))
7205 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7206 (gnus-summary-position-point))
132cf96d 7207
eec82323
LMI
7208(defun gnus-summary-goto-subject (article &optional force silent)
7209 "Go the subject line of ARTICLE.
7210If FORCE, also allow jumping to articles not currently shown."
7211 (interactive "nArticle number: ")
23f87bed
MB
7212 (unless (numberp article)
7213 (error "Article %s is not a number" article))
eec82323
LMI
7214 (let ((b (point))
7215 (data (gnus-data-find article)))
7216 ;; We read in the article if we have to.
7217 (and (not data)
7218 force
6748645f
LMI
7219 (gnus-summary-insert-subject
7220 article
7221 (if (or (numberp force) (vectorp force)) force)
7222 t)
eec82323
LMI
7223 (setq data (gnus-data-find article)))
7224 (goto-char b)
7225 (if (not data)
7226 (progn
7227 (unless silent
7228 (gnus-message 3 "Can't find article %d" article))
7229 nil)
23f87bed
MB
7230 (let ((pt (gnus-data-pos data)))
7231 (goto-char pt)
7232 (gnus-summary-set-article-display-arrow pt))
6748645f 7233 (gnus-summary-position-point)
eec82323
LMI
7234 article)))
7235
7236;; Walking around summary lines with displaying articles.
7237
7238(defun gnus-summary-expand-window (&optional arg)
7239 "Make the summary buffer take up the entire Emacs frame.
7240Given a prefix, will force an `article' buffer configuration."
7241 (interactive "P")
eec82323
LMI
7242 (if arg
7243 (gnus-configure-windows 'article 'force)
7244 (gnus-configure-windows 'summary 'force)))
7245
7246(defun gnus-summary-display-article (article &optional all-header)
7247 "Display ARTICLE in article buffer."
d4dfaa19
DL
7248 (when (gnus-buffer-live-p gnus-article-buffer)
7249 (with-current-buffer gnus-article-buffer
87545352 7250 (mm-enable-multibyte)))
eec82323 7251 (gnus-set-global-variables)
23f87bed
MB
7252 (when (gnus-buffer-live-p gnus-article-buffer)
7253 (with-current-buffer gnus-article-buffer
7254 (setq gnus-article-charset gnus-newsgroup-charset)
7255 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7256 (mm-enable-multibyte)))
eec82323
LMI
7257 (if (null article)
7258 nil
7259 (prog1
7260 (if gnus-summary-display-article-function
7261 (funcall gnus-summary-display-article-function article all-header)
7262 (gnus-article-prepare article all-header))
6748645f 7263 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7264 (when (and gnus-current-article
7265 (not (zerop gnus-current-article)))
7266 (gnus-summary-goto-subject gnus-current-article))
7267 (gnus-summary-recenter)
7268 (when (and gnus-use-trees gnus-show-threads)
7269 (gnus-possibly-generate-tree article)
7270 (gnus-highlight-selected-tree article))
7271 ;; Successfully display article.
7272 (gnus-article-set-window-start
7273 (cdr (assq article gnus-newsgroup-bookmarks))))))
7274
7275(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7276 "Select the current article.
7277If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7278non-nil, the article will be re-fetched even if it already present in
7279the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7280be displayed."
7281 ;; Make sure we are in the summary buffer to work around bbdb bug.
7282 (unless (eq major-mode 'gnus-summary-mode)
7283 (set-buffer gnus-summary-buffer))
7284 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7285 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7286 gnus-summary-display-article-function)
eec82323
LMI
7287 (and (not pseudo)
7288 (gnus-summary-article-pseudo-p article)
a8151ef7 7289 (error "This is a pseudo-article"))
16409b0b
GM
7290 (save-excursion
7291 (set-buffer gnus-summary-buffer)
7292 (if (or (and gnus-single-article-buffer
7293 (or (null gnus-current-article)
7294 (null gnus-article-current)
7295 (null (get-buffer gnus-article-buffer))
7296 (not (eq article (cdr gnus-article-current)))
7297 (not (equal (car gnus-article-current)
7298 gnus-newsgroup-name))))
7299 (and (not gnus-single-article-buffer)
7300 (or (null gnus-current-article)
7301 (not (eq gnus-current-article article))))
7302 force)
7303 ;; The requested article is different from the current article.
7304 (progn
16409b0b
GM
7305 (gnus-summary-display-article article all-headers)
7306 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7307 (with-current-buffer gnus-article-buffer
16409b0b 7308 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7309 (mm-disable-multibyte))))
16409b0b
GM
7310 (gnus-article-set-window-start
7311 (cdr (assq article gnus-newsgroup-bookmarks)))
7312 article)
16409b0b 7313 'old))))
eec82323 7314
23f87bed
MB
7315(defun gnus-summary-force-verify-and-decrypt ()
7316 "Display buttons for signed/encrypted parts and verify/decrypt them."
7317 (interactive)
7318 (let ((mm-verify-option 'known)
7319 (mm-decrypt-option 'known)
7320 (gnus-article-emulate-mime t)
7321 (gnus-buttonized-mime-types (append (list "multipart/signed"
7322 "multipart/encrypted")
7323 gnus-buttonized-mime-types)))
7324 (gnus-summary-select-article nil 'force)))
7325
eec82323
LMI
7326(defun gnus-summary-set-current-mark (&optional current-mark)
7327 "Obsolete function."
7328 nil)
7329
7330(defun gnus-summary-next-article (&optional unread subject backward push)
7331 "Select the next article.
7332If UNREAD, only unread articles are selected.
7333If SUBJECT, only articles with SUBJECT are selected.
7334If BACKWARD, the previous article is selected instead of the next."
7335 (interactive "P")
eec82323
LMI
7336 (cond
7337 ;; Is there such an article?
7338 ((and (gnus-summary-search-forward unread subject backward)
7339 (or (gnus-summary-display-article (gnus-summary-article-number))
7340 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7341 (gnus-summary-position-point))
7342 ;; If not, we try the first unread, if that is wanted.
7343 ((and subject
7344 gnus-auto-select-same
7345 (gnus-summary-first-unread-article))
7346 (gnus-summary-position-point)
7347 (gnus-message 6 "Wrapped"))
7348 ;; Try to get next/previous article not displayed in this group.
7349 ((and gnus-auto-extend-newsgroup
7350 (not unread) (not subject))
7351 (gnus-summary-goto-article
7352 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7353 nil (count-lines (point-min) (point))))
eec82323
LMI
7354 ;; Go to next/previous group.
7355 (t
7356 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7357 (gnus-summary-jump-to-group gnus-newsgroup-name))
7358 (let ((cmd last-command-char)
7359 (point
7360 (save-excursion
7361 (set-buffer gnus-group-buffer)
7362 (point)))
7363 (group
7364 (if (eq gnus-keep-same-level 'best)
7365 (gnus-summary-best-group gnus-newsgroup-name)
7366 (gnus-summary-search-group backward gnus-keep-same-level))))
7367 ;; For some reason, the group window gets selected. We change
7368 ;; it back.
7369 (select-window (get-buffer-window (current-buffer)))
7370 ;; Select next unread newsgroup automagically.
7371 (cond
7372 ((or (not gnus-auto-select-next)
7373 (not cmd))
7374 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7375 ((or (eq gnus-auto-select-next 'quietly)
7376 (and (eq gnus-auto-select-next 'slightly-quietly)
7377 push)
7378 (and (eq gnus-auto-select-next 'almost-quietly)
7379 (gnus-summary-last-article-p)))
7380 ;; Select quietly.
7381 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7382 (gnus-summary-exit)
7383 (gnus-message 7 "No more%s articles (%s)..."
7384 (if unread " unread" "")
7385 (if group (concat "selecting " group)
7386 "exiting"))
7387 (gnus-summary-next-group nil group backward)))
7388 (t
7389 (when (gnus-key-press-event-p last-input-event)
7390 (gnus-summary-walk-group-buffer
7391 gnus-newsgroup-name cmd unread backward point))))))))
7392
7393(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7394 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7395 (?\C-p (gnus-group-prev-unread-group 1))))
7396 (cursor-in-echo-area t)
23f87bed 7397 keve key group ended prompt)
eec82323
LMI
7398 (save-excursion
7399 (set-buffer gnus-group-buffer)
7400 (goto-char start)
7401 (setq group
7402 (if (eq gnus-keep-same-level 'best)
7403 (gnus-summary-best-group gnus-newsgroup-name)
7404 (gnus-summary-search-group backward gnus-keep-same-level))))
7405 (while (not ended)
23f87bed
MB
7406 (setq prompt
7407 (format
7408 "No more%s articles%s " (if unread " unread" "")
7409 (if (and group
7410 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7411 (format " (Type %s for %s [%s])"
91472578
MB
7412 (single-key-description cmd)
7413 (gnus-group-decoded-name group)
23f87bed
MB
7414 (car (gnus-gethash group gnus-newsrc-hashtb)))
7415 (format " (Type %s to exit %s)"
7416 (single-key-description cmd)
91472578 7417 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7418 ;; Confirm auto selection.
23f87bed
MB
7419 (setq key (car (setq keve (gnus-read-event-char prompt)))
7420 ended t)
eec82323
LMI
7421 (cond
7422 ((assq key keystrokes)
7423 (let ((obuf (current-buffer)))
7424 (switch-to-buffer gnus-group-buffer)
7425 (when group
7426 (gnus-group-jump-to-group group))
7427 (eval (cadr (assq key keystrokes)))
7428 (setq group (gnus-group-group-name))
7429 (switch-to-buffer obuf))
7430 (setq ended nil))
7431 ((equal key cmd)
7432 (if (or (not group)
7433 (gnus-ephemeral-group-p gnus-newsgroup-name))
7434 (gnus-summary-exit)
7435 (gnus-summary-next-group nil group backward)))
7436 (t
7437 (push (cdr keve) unread-command-events))))))
7438
7439(defun gnus-summary-next-unread-article ()
7440 "Select unread article after current one."
7441 (interactive)
7442 (gnus-summary-next-article
7443 (or (not (eq gnus-summary-goto-unread 'never))
7444 (gnus-summary-last-article-p (gnus-summary-article-number)))
7445 (and gnus-auto-select-same
7446 (gnus-summary-article-subject))))
7447
7448(defun gnus-summary-prev-article (&optional unread subject)
7449 "Select the article after the current one.
7450If UNREAD is non-nil, only unread articles are selected."
7451 (interactive "P")
7452 (gnus-summary-next-article unread subject t))
7453
7454(defun gnus-summary-prev-unread-article ()
7455 "Select unread article before current one."
7456 (interactive)
7457 (gnus-summary-prev-article
7458 (or (not (eq gnus-summary-goto-unread 'never))
7459 (gnus-summary-first-article-p (gnus-summary-article-number)))
7460 (and gnus-auto-select-same
7461 (gnus-summary-article-subject))))
7462
23f87bed 7463(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7464 "Show next page of the selected article.
7465If at the end of the current article, select the next article.
7466LINES says how many lines should be scrolled up.
7467
7468If CIRCULAR is non-nil, go to the start of the article instead of
7469selecting the next article when reaching the end of the current
23f87bed
MB
7470article.
7471
7472If STOP is non-nil, just stop when reaching the end of the message.
7473
7474Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7475 (interactive "P")
7476 (setq gnus-summary-buffer (current-buffer))
7477 (gnus-set-global-variables)
7478 (let ((article (gnus-summary-article-number))
7479 (article-window (get-buffer-window gnus-article-buffer t))
7480 endp)
6748645f
LMI
7481 ;; If the buffer is empty, we have no article.
7482 (unless article
7483 (error "No article to select"))
eec82323
LMI
7484 (gnus-configure-windows 'article)
7485 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7486 (if (and (eq gnus-summary-goto-unread 'never)
7487 (not (gnus-summary-last-article-p article)))
7488 (gnus-summary-next-article)
7489 (gnus-summary-next-unread-article))
7490 (if (or (null gnus-current-article)
7491 (null gnus-article-current)
7492 (/= article (cdr gnus-article-current))
7493 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7494 ;; Selected subject is different from current article's.
7495 (gnus-summary-display-article article)
7496 (when article-window
7497 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7498 (setq endp (or (gnus-article-next-page lines)
7499 (gnus-article-only-boring-p))))
eec82323 7500 (when endp
23f87bed
MB
7501 (cond (stop
7502 (gnus-message 3 "End of message"))
7503 (circular
eec82323
LMI
7504 (gnus-summary-beginning-of-article))
7505 (lines
7506 (gnus-message 3 "End of message"))
7507 ((null lines)
7508 (if (and (eq gnus-summary-goto-unread 'never)
7509 (not (gnus-summary-last-article-p article)))
7510 (gnus-summary-next-article)
7511 (gnus-summary-next-unread-article))))))))
7512 (gnus-summary-recenter)
7513 (gnus-summary-position-point)))
7514
7515(defun gnus-summary-prev-page (&optional lines move)
7516 "Show previous page of selected article.
7517Argument LINES specifies lines to be scrolled down.
7518If MOVE, move to the previous unread article if point is at
7519the beginning of the buffer."
7520 (interactive "P")
eec82323
LMI
7521 (let ((article (gnus-summary-article-number))
7522 (article-window (get-buffer-window gnus-article-buffer t))
7523 endp)
7524 (gnus-configure-windows 'article)
7525 (if (or (null gnus-current-article)
7526 (null gnus-article-current)
7527 (/= article (cdr gnus-article-current))
7528 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7529 ;; Selected subject is different from current article's.
7530 (gnus-summary-display-article article)
7531 (gnus-summary-recenter)
7532 (when article-window
7533 (gnus-eval-in-buffer-window gnus-article-buffer
7534 (setq endp (gnus-article-prev-page lines)))
7535 (when (and move endp)
7536 (cond (lines
7537 (gnus-message 3 "Beginning of message"))
7538 ((null lines)
7539 (if (and (eq gnus-summary-goto-unread 'never)
7540 (not (gnus-summary-first-article-p article)))
7541 (gnus-summary-prev-article)
7542 (gnus-summary-prev-unread-article))))))))
7543 (gnus-summary-position-point))
7544
7545(defun gnus-summary-prev-page-or-article (&optional lines)
7546 "Show previous page of selected article.
7547Argument LINES specifies lines to be scrolled down.
7548If at the beginning of the article, go to the next article."
7549 (interactive "P")
7550 (gnus-summary-prev-page lines t))
7551
7552(defun gnus-summary-scroll-up (lines)
7553 "Scroll up (or down) one line current article.
7554Argument LINES specifies lines to be scrolled up (or down if negative)."
7555 (interactive "p")
eec82323
LMI
7556 (gnus-configure-windows 'article)
7557 (gnus-summary-show-thread)
7558 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7559 (gnus-eval-in-buffer-window gnus-article-buffer
7560 (cond ((> lines 0)
7561 (when (gnus-article-next-page lines)
7562 (gnus-message 3 "End of message")))
7563 ((< lines 0)
7564 (gnus-article-prev-page (- lines))))))
7565 (gnus-summary-recenter)
7566 (gnus-summary-position-point))
7567
6748645f
LMI
7568(defun gnus-summary-scroll-down (lines)
7569 "Scroll down (or up) one line current article.
7570Argument LINES specifies lines to be scrolled down (or up if negative)."
7571 (interactive "p")
7572 (gnus-summary-scroll-up (- lines)))
7573
eec82323
LMI
7574(defun gnus-summary-next-same-subject ()
7575 "Select next article which has the same subject as current one."
7576 (interactive)
eec82323
LMI
7577 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7578
7579(defun gnus-summary-prev-same-subject ()
7580 "Select previous article which has the same subject as current one."
7581 (interactive)
eec82323
LMI
7582 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7583
7584(defun gnus-summary-next-unread-same-subject ()
7585 "Select next unread article which has the same subject as current one."
7586 (interactive)
eec82323
LMI
7587 (gnus-summary-next-article t (gnus-summary-article-subject)))
7588
7589(defun gnus-summary-prev-unread-same-subject ()
7590 "Select previous unread article which has the same subject as current one."
7591 (interactive)
eec82323
LMI
7592 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7593
7594(defun gnus-summary-first-unread-article ()
7595 "Select the first unread article.
7596Return nil if there are no unread articles."
7597 (interactive)
eec82323
LMI
7598 (prog1
7599 (when (gnus-summary-first-subject t)
7600 (gnus-summary-show-thread)
7601 (gnus-summary-first-subject t)
7602 (gnus-summary-display-article (gnus-summary-article-number)))
7603 (gnus-summary-position-point)))
7604
16409b0b
GM
7605(defun gnus-summary-first-unread-subject ()
7606 "Place the point on the subject line of the first unread article.
7607Return nil if there are no unread articles."
7608 (interactive)
7609 (prog1
7610 (when (gnus-summary-first-subject t)
7611 (gnus-summary-show-thread)
7612 (gnus-summary-first-subject t))
7613 (gnus-summary-position-point)))
7614
23f87bed
MB
7615(defun gnus-summary-first-unseen-subject ()
7616 "Place the point on the subject line of the first unseen article.
7617Return nil if there are no unseen articles."
7618 (interactive)
7619 (prog1
7620 (when (gnus-summary-first-subject nil nil t)
7621 (gnus-summary-show-thread)
7622 (gnus-summary-first-subject nil nil t))
7623 (gnus-summary-position-point)))
7624
7625(defun gnus-summary-first-unseen-or-unread-subject ()
7626 "Place the point on the subject line of the first unseen article or,
7627if all article have been seen, on the subject line of the first unread
7628article."
7629 (interactive)
7630 (prog1
7631 (unless (when (gnus-summary-first-subject nil nil t)
7632 (gnus-summary-show-thread)
7633 (gnus-summary-first-subject nil nil t))
7634 (when (gnus-summary-first-subject t)
7635 (gnus-summary-show-thread)
7636 (gnus-summary-first-subject t)))
7637 (gnus-summary-position-point)))
7638
eec82323
LMI
7639(defun gnus-summary-first-article ()
7640 "Select the first article.
7641Return nil if there are no articles."
7642 (interactive)
eec82323
LMI
7643 (prog1
7644 (when (gnus-summary-first-subject)
16409b0b
GM
7645 (gnus-summary-show-thread)
7646 (gnus-summary-first-subject)
7647 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
7648 (gnus-summary-position-point)))
7649
23f87bed
MB
7650(defun gnus-summary-best-unread-article (&optional arg)
7651 "Select the unread article with the highest score.
7652If given a prefix argument, select the next unread article that has a
7653score higher than the default score."
7654 (interactive "P")
7655 (let ((article (if arg
7656 (gnus-summary-better-unread-subject)
7657 (gnus-summary-best-unread-subject))))
7658 (if article
7659 (gnus-summary-goto-article article)
7660 (error "No unread articles"))))
7661
7662(defun gnus-summary-best-unread-subject ()
7663 "Select the unread subject with the highest score."
eec82323 7664 (interactive)
eec82323
LMI
7665 (let ((best -1000000)
7666 (data gnus-newsgroup-data)
7667 article score)
7668 (while data
7669 (and (gnus-data-unread-p (car data))
7670 (> (setq score
7671 (gnus-summary-article-score (gnus-data-number (car data))))
7672 best)
7673 (setq best score
7674 article (gnus-data-number (car data))))
7675 (setq data (cdr data)))
23f87bed
MB
7676 (when article
7677 (gnus-summary-goto-subject article))
7678 (gnus-summary-position-point)
7679 article))
7680
7681(defun gnus-summary-better-unread-subject ()
7682 "Select the first unread subject that has a score over the default score."
7683 (interactive)
7684 (let ((data gnus-newsgroup-data)
7685 article score)
7686 (while (and (setq article (gnus-data-number (car data)))
7687 (or (gnus-data-read-p (car data))
7688 (not (> (gnus-summary-article-score article)
7689 gnus-summary-default-score))))
7690 (setq data (cdr data)))
7691 (when article
7692 (gnus-summary-goto-subject article))
7693 (gnus-summary-position-point)
7694 article))
eec82323
LMI
7695
7696(defun gnus-summary-last-subject ()
7697 "Go to the last displayed subject line in the group."
7698 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7699 (when article
7700 (gnus-summary-goto-subject article))))
7701
7702(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
7703 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7704If ALL-HEADERS is non-nil, no header lines are hidden.
7705If FORCE, go to the article even if it isn't displayed. If FORCE
7706is a number, it is the line the article is to be displayed on."
eec82323
LMI
7707 (interactive
7708 (list
6748645f
LMI
7709 (completing-read
7710 "Article number or Message-ID: "
7711 (mapcar (lambda (number) (list (int-to-string number)))
7712 gnus-newsgroup-limit))
eec82323
LMI
7713 current-prefix-arg
7714 t))
7715 (prog1
6748645f 7716 (if (and (stringp article)
23f87bed 7717 (string-match "@\\|%40" article))
6748645f
LMI
7718 (gnus-summary-refer-article article)
7719 (when (stringp article)
7720 (setq article (string-to-number article)))
7721 (if (gnus-summary-goto-subject article force)
7722 (gnus-summary-display-article article all-headers)
7723 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
7724 (gnus-summary-position-point)))
7725
7726(defun gnus-summary-goto-last-article ()
7727 "Go to the previously read article."
7728 (interactive)
7729 (prog1
7730 (when gnus-last-article
6748645f 7731 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
7732 (gnus-summary-position-point)))
7733
7734(defun gnus-summary-pop-article (number)
7735 "Pop one article off the history and go to the previous.
7736NUMBER articles will be popped off."
7737 (interactive "p")
7738 (let (to)
7739 (setq gnus-newsgroup-history
7740 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7741 (if to
6748645f 7742 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
7743 (error "Article history empty")))
7744 (gnus-summary-position-point))
7745
7746;; Summary commands and functions for limiting the summary buffer.
7747
7748(defun gnus-summary-limit-to-articles (n)
7749 "Limit the summary buffer to the next N articles.
7750If not given a prefix, use the process marked articles instead."
7751 (interactive "P")
eec82323
LMI
7752 (prog1
7753 (let ((articles (gnus-summary-work-articles n)))
7754 (setq gnus-newsgroup-processable nil)
7755 (gnus-summary-limit articles))
7756 (gnus-summary-position-point)))
7757
7758(defun gnus-summary-pop-limit (&optional total)
7759 "Restore the previous limit.
7760If given a prefix, remove all limits."
7761 (interactive "P")
eec82323
LMI
7762 (when total
7763 (setq gnus-newsgroup-limits
7764 (list (mapcar (lambda (h) (mail-header-number h))
7765 gnus-newsgroup-headers))))
7766 (unless gnus-newsgroup-limits
7767 (error "No limit to pop"))
7768 (prog1
7769 (gnus-summary-limit nil 'pop)
7770 (gnus-summary-position-point)))
7771
47b63dfa
SZ
7772(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7773 "Limit the summary buffer to articles that have subjects that match a regexp.
7774If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 7775 (interactive
47b63dfa
SZ
7776 (list (read-string (if current-prefix-arg
7777 "Exclude subject (regexp): "
a1506d29 7778 "Limit to subject (regexp): "))
47b63dfa 7779 nil current-prefix-arg))
eec82323
LMI
7780 (unless header
7781 (setq header "subject"))
7782 (when (not (equal "" subject))
7783 (prog1
7784 (let ((articles (gnus-summary-find-matching
a1506d29 7785 (or header "subject") subject 'all nil nil
47b63dfa 7786 not-matching)))
eec82323
LMI
7787 (unless articles
7788 (error "Found no matches for \"%s\"" subject))
7789 (gnus-summary-limit articles))
7790 (gnus-summary-position-point))))
7791
ef6e0ec7 7792(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
7793 "Limit the summary buffer to articles that have authors that match a regexp.
7794If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 7795 (interactive
47b63dfa
SZ
7796 (list (read-string (if current-prefix-arg
7797 "Exclude author (regexp): "
a1506d29 7798 "Limit to author (regexp): "))
ef6e0ec7
SZ
7799 current-prefix-arg))
7800 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323
LMI
7801
7802(defun gnus-summary-limit-to-age (age &optional younger-p)
7803 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7804If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7805articles that are younger than AGE days."
16409b0b
GM
7806 (interactive
7807 (let ((younger current-prefix-arg)
7808 (days-got nil)
7809 days)
7810 (while (not days-got)
7811 (setq days (if younger
23f87bed
MB
7812 (read-string "Limit to articles younger than (in days, older when negative): ")
7813 (read-string
7814 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
7815 (when (> (length days) 0)
7816 (setq days (read days)))
7817 (if (numberp days)
23f87bed
MB
7818 (progn
7819 (setq days-got t)
7820 (if (< days 0)
7821 (progn
7822 (setq younger (not younger))
7823 (setq days (* days -1)))))
16409b0b
GM
7824 (message "Please enter a number.")
7825 (sleep-for 1)))
7826 (list days younger)))
eec82323
LMI
7827 (prog1
7828 (let ((data gnus-newsgroup-data)
16409b0b 7829 (cutoff (days-to-time age))
eec82323
LMI
7830 articles d date is-younger)
7831 (while (setq d (pop data))
7832 (when (and (vectorp (gnus-data-header d))
7833 (setq date (mail-header-date (gnus-data-header d))))
16409b0b
GM
7834 (setq is-younger (time-less-p
7835 (time-since (condition-case ()
7836 (date-to-time date)
7837 (error '(0 0))))
eec82323 7838 cutoff))
6748645f
LMI
7839 (when (if younger-p
7840 is-younger
7841 (not is-younger))
eec82323
LMI
7842 (push (gnus-data-number d) articles))))
7843 (gnus-summary-limit (nreverse articles)))
7844 (gnus-summary-position-point)))
7845
47b63dfa 7846(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
7847 "Limit the summary buffer to articles that match an 'extra' header."
7848 (interactive
7849 (let ((header
7850 (intern
23f87bed 7851 (gnus-completing-read-with-default
16409b0b 7852 (symbol-name (car gnus-extra-headers))
47b63dfa 7853 (if current-prefix-arg
81df110a
RF
7854 "Exclude extra header"
7855 "Limit extra header")
16409b0b
GM
7856 (mapcar (lambda (x)
7857 (cons (symbol-name x) x))
7858 gnus-extra-headers)
7859 nil
7860 t))))
7861 (list header
a1506d29 7862 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
7863 (if current-prefix-arg "Exclude" "Limit to")
7864 header))
7865 current-prefix-arg)))
16409b0b
GM
7866 (when (not (equal "" regexp))
7867 (prog1
7868 (let ((articles (gnus-summary-find-matching
a1506d29 7869 (cons 'extra header) regexp 'all nil nil
47b63dfa 7870 not-matching)))
16409b0b
GM
7871 (unless articles
7872 (error "Found no matches for \"%s\"" regexp))
7873 (gnus-summary-limit articles))
7874 (gnus-summary-position-point))))
7875
23f87bed
MB
7876(defun gnus-summary-limit-to-display-predicate ()
7877 "Limit the summary buffer to the predicated in the `display' group parameter."
7878 (interactive)
7879 (unless gnus-newsgroup-display
7880 (error "There is no `display' group parameter"))
7881 (let (articles)
7882 (dolist (number gnus-newsgroup-articles)
7883 (when (funcall gnus-newsgroup-display)
7884 (push number articles)))
7885 (gnus-summary-limit articles))
7886 (gnus-summary-position-point))
7887
eec82323
LMI
7888(defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7889(make-obsolete
7890 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7891
7892(defun gnus-summary-limit-to-unread (&optional all)
7893 "Limit the summary buffer to articles that are not marked as read.
7894If ALL is non-nil, limit strictly to unread articles."
7895 (interactive "P")
7896 (if all
7897 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7898 (gnus-summary-limit-to-marks
7899 ;; Concat all the marks that say that an article is read and have
7900 ;; those removed.
7901 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 7902 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
7903 gnus-low-score-mark gnus-expirable-mark
7904 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7905 gnus-duplicate-mark gnus-souped-mark)
7906 'reverse)))
7907
7908(defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7909(make-obsolete 'gnus-summary-delete-marked-with
81ceefe2 7910 'gnus-summary-limit-exclude-marks)
eec82323
LMI
7911
7912(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7913 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7914If REVERSE, limit the summary buffer to articles that are marked
7915with MARKS. MARKS can either be a string of marks or a list of marks.
7916Returns how many articles were removed."
7917 (interactive "sMarks: ")
7918 (gnus-summary-limit-to-marks marks t))
7919
7920(defun gnus-summary-limit-to-marks (marks &optional reverse)
7921 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7922If REVERSE (the prefix), limit the summary buffer to articles that are
7923not marked with MARKS. MARKS can either be a string of marks or a
7924list of marks.
7925Returns how many articles were removed."
6748645f 7926 (interactive "sMarks: \nP")
eec82323
LMI
7927 (prog1
7928 (let ((data gnus-newsgroup-data)
7929 (marks (if (listp marks) marks
7930 (append marks nil))) ; Transform to list.
7931 articles)
7932 (while data
7933 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7934 (memq (gnus-data-mark (car data)) marks))
7935 (push (gnus-data-number (car data)) articles))
7936 (setq data (cdr data)))
7937 (gnus-summary-limit articles))
7938 (gnus-summary-position-point)))
7939
23f87bed 7940(defun gnus-summary-limit-to-score (score)
eec82323 7941 "Limit to articles with score at or above SCORE."
23f87bed 7942 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
7943 (let ((data gnus-newsgroup-data)
7944 articles)
7945 (while data
7946 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7947 score)
7948 (push (gnus-data-number (car data)) articles))
7949 (setq data (cdr data)))
7950 (prog1
7951 (gnus-summary-limit articles)
7952 (gnus-summary-position-point))))
7953
23f87bed
MB
7954(defun gnus-summary-limit-to-unseen ()
7955 "Limit to unseen articles."
7956 (interactive)
7957 (prog1
7958 (gnus-summary-limit gnus-newsgroup-unseen)
7959 (gnus-summary-position-point)))
7960
6748645f 7961(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
7962 "Display all the hidden articles that is in the thread with ID in it.
7963When called interactively, ID is the Message-ID of the current
7964article."
6748645f
LMI
7965 (interactive (list (mail-header-id (gnus-summary-article-header))))
7966 (let ((articles (gnus-articles-in-thread
7967 (gnus-id-to-thread (gnus-root-id id)))))
7968 (prog1
7969 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
7970 (gnus-summary-limit-include-matching-articles
7971 "subject"
7972 (regexp-quote (gnus-simplify-subject-re
7973 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
7974 (gnus-summary-position-point))))
7975
23f87bed
MB
7976(defun gnus-summary-limit-include-matching-articles (header regexp)
7977 "Display all the hidden articles that have HEADERs that match REGEXP."
7978 (interactive (list (read-string "Match on header: ")
7979 (read-string "Regexp: ")))
7980 (let ((articles (gnus-find-matching-articles header regexp)))
7981 (prog1
7982 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7983 (gnus-summary-position-point))))
7984
7985(defun gnus-summary-insert-dormant-articles ()
7986 "Insert all the dormant articles for this group into the current buffer."
7987 (interactive)
7988 (let ((gnus-verbose (max 6 gnus-verbose)))
7989 (if (not gnus-newsgroup-dormant)
7990 (gnus-message 3 "No cached articles for this group")
7991 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7992
eec82323 7993(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
7994 "Display all the hidden articles that are marked as dormant.
7995Note that this command only works on a subset of the articles currently
7996fetched for this group."
eec82323 7997 (interactive)
eec82323
LMI
7998 (unless gnus-newsgroup-dormant
7999 (error "There are no dormant articles in this group"))
8000 (prog1
8001 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8002 (gnus-summary-position-point)))
8003
8004(defun gnus-summary-limit-exclude-dormant ()
8005 "Hide all dormant articles."
8006 (interactive)
eec82323
LMI
8007 (prog1
8008 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8009 (gnus-summary-position-point)))
8010
8011(defun gnus-summary-limit-exclude-childless-dormant ()
8012 "Hide all dormant articles that have no children."
8013 (interactive)
eec82323
LMI
8014 (let ((data (gnus-data-list t))
8015 articles d children)
8016 ;; Find all articles that are either not dormant or have
8017 ;; children.
8018 (while (setq d (pop data))
8019 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8020 (and (setq children
8021 (gnus-article-children (gnus-data-number d)))
8022 (let (found)
8023 (while children
8024 (when (memq (car children) articles)
8025 (setq children nil
8026 found t))
8027 (pop children))
8028 found)))
8029 (push (gnus-data-number d) articles)))
8030 ;; Do the limiting.
8031 (prog1
8032 (gnus-summary-limit articles)
8033 (gnus-summary-position-point))))
8034
8035(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8036 "Mark all unread excluded articles as read.
8037If ALL, mark even excluded ticked and dormants as read."
8038 (interactive "P")
23f87bed
MB
8039 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8040 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8041 (sort
8042 (mapcar (lambda (h) (mail-header-number h))
8043 gnus-newsgroup-headers)
8044 '<)
23f87bed 8045 gnus-newsgroup-limit))
eec82323 8046 article)
6748645f 8047 (setq gnus-newsgroup-unreads
23f87bed
MB
8048 (gnus-sorted-intersection gnus-newsgroup-unreads
8049 gnus-newsgroup-limit))
eec82323
LMI
8050 (if all
8051 (setq gnus-newsgroup-dormant nil
8052 gnus-newsgroup-marked nil
8053 gnus-newsgroup-reads
8054 (nconc
8055 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8056 gnus-newsgroup-reads))
8057 (while (setq article (pop articles))
8058 (unless (or (memq article gnus-newsgroup-dormant)
8059 (memq article gnus-newsgroup-marked))
8060 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8061
8062(defun gnus-summary-limit (articles &optional pop)
8063 (if pop
8064 ;; We pop the previous limit off the stack and use that.
8065 (setq articles (car gnus-newsgroup-limits)
8066 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8067 ;; We use the new limit, so we push the old limit on the stack.
8068 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8069 ;; Set the limit.
8070 (setq gnus-newsgroup-limit articles)
8071 (let ((total (length gnus-newsgroup-data))
8072 (data (gnus-data-find-list (gnus-summary-article-number)))
8073 (gnus-summary-mark-below nil) ; Inhibit this.
8074 found)
8075 ;; This will do all the work of generating the new summary buffer
8076 ;; according to the new limit.
8077 (gnus-summary-prepare)
8078 ;; Hide any threads, possibly.
23f87bed 8079 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8080 ;; Try to return to the article you were at, or one in the
8081 ;; neighborhood.
8082 (when data
8083 ;; We try to find some article after the current one.
8084 (while data
8085 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8086 (setq data nil
8087 found t))
8088 (setq data (cdr data))))
8089 (unless found
8090 ;; If there is no data, that means that we were after the last
8091 ;; article. The same goes when we can't find any articles
8092 ;; after the current one.
8093 (goto-char (point-max))
8094 (gnus-summary-find-prev))
6748645f 8095 (gnus-set-mode-line 'summary)
eec82323
LMI
8096 ;; We return how many articles were removed from the summary
8097 ;; buffer as a result of the new limit.
8098 (- total (length gnus-newsgroup-data))))
8099
8100(defsubst gnus-invisible-cut-children (threads)
8101 (let ((num 0))
8102 (while threads
8103 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8104 (incf num))
8105 (pop threads))
8106 (< num 2)))
8107
8108(defsubst gnus-cut-thread (thread)
8109 "Go forwards in the thread until we find an article that we want to display."
8110 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8111 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8112 (numberp gnus-fetch-old-headers)
eec82323
LMI
8113 (eq gnus-build-sparse-threads 'some)
8114 (eq gnus-build-sparse-threads 'more))
8115 ;; Deal with old-fetched headers and sparse threads.
8116 (while (and
8117 thread
8118 (or
8119 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8120 (gnus-summary-article-ancient-p
8121 (mail-header-number (car thread))))
6748645f
LMI
8122 (if (or (<= (length (cdr thread)) 1)
8123 (eq gnus-fetch-old-headers 'invisible))
8124 (setq gnus-newsgroup-limit
8125 (delq (mail-header-number (car thread))
8126 gnus-newsgroup-limit)
8127 thread (cadr thread))
8128 (when (gnus-invisible-cut-children (cdr thread))
8129 (let ((th (cdr thread)))
8130 (while th
8131 (if (memq (mail-header-number (caar th))
a8151ef7 8132 gnus-newsgroup-limit)
6748645f
LMI
8133 (setq thread (car th)
8134 th nil)
8135 (setq th (cdr th))))))))))
eec82323
LMI
8136 thread)
8137
8138(defun gnus-cut-threads (threads)
23f87bed 8139 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8140 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8141 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8142 (numberp gnus-fetch-old-headers)
eec82323
LMI
8143 (eq gnus-build-sparse-threads 'some)
8144 (eq gnus-build-sparse-threads 'more))
8145 (let ((th threads))
8146 (while th
8147 (setcar th (gnus-cut-thread (car th)))
8148 (setq th (cdr th)))))
8149 ;; Remove nixed out threads.
8150 (delq nil threads))
8151
8152(defun gnus-summary-initial-limit (&optional show-if-empty)
8153 "Figure out what the initial limit is supposed to be on group entry.
8154This entails weeding out unwanted dormants, low-scored articles,
8155fetch-old-headers verbiage, and so on."
8156 ;; Most groups have nothing to remove.
8157 (if (or gnus-inhibit-limiting
8158 (and (null gnus-newsgroup-dormant)
23f87bed 8159 (eq gnus-newsgroup-display 'gnus-not-ignore)
eec82323 8160 (not (eq gnus-fetch-old-headers 'some))
16409b0b 8161 (not (numberp gnus-fetch-old-headers))
6748645f 8162 (not (eq gnus-fetch-old-headers 'invisible))
eec82323
LMI
8163 (null gnus-summary-expunge-below)
8164 (not (eq gnus-build-sparse-threads 'some))
8165 (not (eq gnus-build-sparse-threads 'more))
8166 (null gnus-thread-expunge-below)
8167 (not gnus-use-nocem)))
8168 () ; Do nothing.
8169 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8170 (setq gnus-newsgroup-limit nil)
8171 (mapatoms
8172 (lambda (node)
8173 (unless (car (symbol-value node))
8174 ;; These threads have no parents -- they are roots.
8175 (let ((nodes (cdr (symbol-value node)))
8176 thread)
8177 (while nodes
8178 (if (and gnus-thread-expunge-below
8179 (< (gnus-thread-total-score (car nodes))
8180 gnus-thread-expunge-below))
8181 (gnus-expunge-thread (pop nodes))
8182 (setq thread (pop nodes))
8183 (gnus-summary-limit-children thread))))))
8184 gnus-newsgroup-dependencies)
8185 ;; If this limitation resulted in an empty group, we might
8186 ;; pop the previous limit and use it instead.
8187 (when (and (not gnus-newsgroup-limit)
8188 show-if-empty)
8189 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8190 gnus-newsgroup-limit))
8191
8192(defun gnus-summary-limit-children (thread)
8193 "Return 1 if this subthread is visible and 0 if it is not."
8194 ;; First we get the number of visible children to this thread. This
8195 ;; is done by recursing down the thread using this function, so this
8196 ;; will really go down to a leaf article first, before slowly
8197 ;; working its way up towards the root.
8198 (when thread
04b61ae9 8199 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8200 (children
eec82323
LMI
8201 (if (cdr thread)
8202 (apply '+ (mapcar 'gnus-summary-limit-children
8203 (cdr thread)))
8204 0))
8205 (number (mail-header-number (car thread)))
8206 score)
8207 (if (and
8208 (not (memq number gnus-newsgroup-marked))
8209 (or
8210 ;; If this article is dormant and has absolutely no visible
8211 ;; children, then this article isn't visible.
8212 (and (memq number gnus-newsgroup-dormant)
8213 (zerop children))
8214 ;; If this is "fetch-old-headered" and there is no
8215 ;; visible children, then we don't want this article.
16409b0b
GM
8216 (and (or (eq gnus-fetch-old-headers 'some)
8217 (numberp gnus-fetch-old-headers))
eec82323
LMI
8218 (gnus-summary-article-ancient-p number)
8219 (zerop children))
6748645f
LMI
8220 ;; If this is "fetch-old-headered" and `invisible', then
8221 ;; we don't want this article.
8222 (and (eq gnus-fetch-old-headers 'invisible)
8223 (gnus-summary-article-ancient-p number))
eec82323
LMI
8224 ;; If this is a sparsely inserted article with no children,
8225 ;; we don't want it.
8226 (and (eq gnus-build-sparse-threads 'some)
8227 (gnus-summary-article-sparse-p number)
8228 (zerop children))
8229 ;; If we use expunging, and this article is really
8230 ;; low-scored, then we don't want this article.
8231 (when (and gnus-summary-expunge-below
8232 (< (setq score
8233 (or (cdr (assq number gnus-newsgroup-scored))
8234 gnus-summary-default-score))
8235 gnus-summary-expunge-below))
8236 ;; We increase the expunge-tally here, but that has
8237 ;; nothing to do with the limits, really.
8238 (incf gnus-newsgroup-expunged-tally)
8239 ;; We also mark as read here, if that's wanted.
8240 (when (and gnus-summary-mark-below
8241 (< score gnus-summary-mark-below))
8242 (setq gnus-newsgroup-unreads
8243 (delq number gnus-newsgroup-unreads))
8244 (if gnus-newsgroup-auto-expire
8245 (push number gnus-newsgroup-expirable)
8246 (push (cons number gnus-low-score-mark)
8247 gnus-newsgroup-reads)))
8248 t)
23f87bed
MB
8249 ;; Do the `display' group parameter.
8250 (and gnus-newsgroup-display
8251 (not (funcall gnus-newsgroup-display)))
eec82323
LMI
8252 ;; Check NoCeM things.
8253 (if (and gnus-use-nocem
8254 (gnus-nocem-unwanted-article-p
8255 (mail-header-id (car thread))))
8256 (progn
a8151ef7 8257 (setq gnus-newsgroup-unreads
eec82323
LMI
8258 (delq number gnus-newsgroup-unreads))
8259 t))))
8260 ;; Nope, invisible article.
8261 0
8262 ;; Ok, this article is to be visible, so we add it to the limit
8263 ;; and return 1.
8264 (push number gnus-newsgroup-limit)
8265 1))))
8266
8267(defun gnus-expunge-thread (thread)
8268 "Mark all articles in THREAD as read."
8269 (let* ((number (mail-header-number (car thread))))
8270 (incf gnus-newsgroup-expunged-tally)
8271 ;; We also mark as read here, if that's wanted.
8272 (setq gnus-newsgroup-unreads
8273 (delq number gnus-newsgroup-unreads))
8274 (if gnus-newsgroup-auto-expire
8275 (push number gnus-newsgroup-expirable)
8276 (push (cons number gnus-low-score-mark)
8277 gnus-newsgroup-reads)))
8278 ;; Go recursively through all subthreads.
8279 (mapcar 'gnus-expunge-thread (cdr thread)))
8280
8281;; Summary article oriented commands
8282
8283(defun gnus-summary-refer-parent-article (n)
8284 "Refer parent article N times.
8285If N is negative, go to ancestor -N instead.
8286The difference between N and the number of articles fetched is returned."
8287 (interactive "p")
eec82323
LMI
8288 (let ((skip 1)
8289 error header ref)
8290 (when (not (natnump n))
8291 (setq skip (abs n)
8292 n 1))
8293 (while (and (> n 0)
8294 (not error))
8295 (setq header (gnus-summary-article-header))
8296 (if (and (eq (mail-header-number header)
8297 (cdr gnus-article-current))
8298 (equal gnus-newsgroup-name
8299 (car gnus-article-current)))
8300 ;; If we try to find the parent of the currently
8301 ;; displayed article, then we take a look at the actual
8302 ;; References header, since this is slightly more
8303 ;; reliable than the References field we got from the
8304 ;; server.
8305 (save-excursion
8306 (set-buffer gnus-original-article-buffer)
8307 (nnheader-narrow-to-headers)
8308 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8309 (when (setq ref (message-fetch-field "in-reply-to"))
8310 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8311 (widen))
8312 (setq ref
8313 ;; It's not the current article, so we take a bet on
8314 ;; the value we got from the server.
8315 (mail-header-references header)))
8316 (if (and ref
8317 (not (equal ref "")))
8318 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8319 (gnus-message 1 "Couldn't find parent"))
8320 (gnus-message 1 "No references in article %d"
8321 (gnus-summary-article-number))
8322 (setq error t))
8323 (decf n))
8324 (gnus-summary-position-point)
8325 n))
8326
8327(defun gnus-summary-refer-references ()
8328 "Fetch all articles mentioned in the References header.
6748645f 8329Return the number of articles fetched."
eec82323 8330 (interactive)
eec82323
LMI
8331 (let ((ref (mail-header-references (gnus-summary-article-header)))
8332 (current (gnus-summary-article-number))
8333 (n 0))
8334 (if (or (not ref)
8335 (equal ref ""))
8336 (error "No References in the current article")
8337 ;; For each Message-ID in the References header...
8338 (while (string-match "<[^>]*>" ref)
8339 (incf n)
8340 ;; ... fetch that article.
8341 (gnus-summary-refer-article
8342 (prog1 (match-string 0 ref)
8343 (setq ref (substring ref (match-end 0))))))
8344 (gnus-summary-goto-subject current)
8345 (gnus-summary-position-point)
8346 n)))
8347
6748645f
LMI
8348(defun gnus-summary-refer-thread (&optional limit)
8349 "Fetch all articles in the current thread.
8350If LIMIT (the numerical prefix), fetch that many old headers instead
8351of what's specified by the `gnus-refer-thread-limit' variable."
8352 (interactive "P")
8353 (let ((id (mail-header-id (gnus-summary-article-header)))
8354 (limit (if limit (prefix-numeric-value limit)
8355 gnus-refer-thread-limit)))
6748645f
LMI
8356 (unless (eq gnus-fetch-old-headers 'invisible)
8357 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8358 ;; Retrieve the headers and read them in.
23f87bed
MB
8359 (if (eq (if (numberp limit)
8360 (gnus-retrieve-headers
8361 (list (min
8362 (+ (mail-header-number
8363 (gnus-summary-article-header))
8364 limit)
8365 gnus-newsgroup-end))
8366 gnus-newsgroup-name (* limit 2))
8367 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8368 ;; headers.
8369 (gnus-retrieve-headers (list gnus-newsgroup-end)
8370 gnus-newsgroup-name limit))
6748645f
LMI
8371 'nov)
8372 (gnus-build-all-threads)
23f87bed 8373 (error "Can't fetch thread from back ends that don't support NOV"))
6748645f
LMI
8374 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8375 (gnus-summary-limit-include-thread id)))
8376
16409b0b
GM
8377(defun gnus-summary-refer-article (message-id)
8378 "Fetch an article specified by MESSAGE-ID."
8379 (interactive "sMessage-ID: ")
eec82323
LMI
8380 (when (and (stringp message-id)
8381 (not (zerop (length message-id))))
23f87bed 8382 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8383 ;; Construct the correct Message-ID if necessary.
8384 ;; Suggested by tale@pawl.rpi.edu.
8385 (unless (string-match "^<" message-id)
8386 (setq message-id (concat "<" message-id)))
8387 (unless (string-match ">$" message-id)
8388 (setq message-id (concat message-id ">")))
23f87bed
MB
8389 ;; People often post MIDs from URLs, so unhex it:
8390 (unless (string-match "@" message-id)
8391 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8392 (let* ((header (gnus-id-to-header message-id))
8393 (sparse (and header
8394 (gnus-summary-article-sparse-p
a8151ef7
LMI
8395 (mail-header-number header))
8396 (memq (mail-header-number header)
16409b0b
GM
8397 gnus-newsgroup-limit)))
8398 number)
6748645f
LMI
8399 (cond
8400 ;; If the article is present in the buffer we just go to it.
8401 ((and header
8402 (or (not (gnus-summary-article-sparse-p
8403 (mail-header-number header)))
8404 sparse))
8405 (prog1
8406 (gnus-summary-goto-article
8407 (mail-header-number header) nil t)
8408 (when sparse
8409 (gnus-summary-update-article (mail-header-number header)))))
8410 (t
16409b0b
GM
8411 ;; We fetch the article.
8412 (catch 'found
8413 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8414 (when (and (gnus-check-server gnus-override-method)
8415 ;; Fetch the header,
8416 (setq number (gnus-summary-insert-subject message-id)))
8417 ;; and display the article.
eec82323 8418 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8419 (throw 'found t)))
8420 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8421
8422(defun gnus-refer-article-methods ()
8f688cb0 8423 "Return a list of referable methods."
16409b0b
GM
8424 (cond
8425 ;; No method, so we default to current and native.
8426 ((null gnus-refer-article-method)
8427 (list gnus-current-select-method gnus-select-method))
8428 ;; Current.
8429 ((eq 'current gnus-refer-article-method)
8430 (list gnus-current-select-method))
8431 ;; List of select methods.
d4dfaa19
DL
8432 ((not (and (symbolp (car gnus-refer-article-method))
8433 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
8434 (let (out)
8435 (dolist (method gnus-refer-article-method)
8436 (push (if (eq 'current method)
8437 gnus-current-select-method
8438 method)
8439 out))
8440 (nreverse out)))
8441 ;; One single select method.
8442 (t
8443 (list gnus-refer-article-method))))
6748645f
LMI
8444
8445(defun gnus-summary-edit-parameters ()
8446 "Edit the group parameters of the current group."
8447 (interactive)
8448 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 8449
16409b0b
GM
8450(defun gnus-summary-customize-parameters ()
8451 "Customize the group parameters of the current group."
8452 (interactive)
8453 (gnus-group-customize gnus-newsgroup-name))
8454
eec82323
LMI
8455(defun gnus-summary-enter-digest-group (&optional force)
8456 "Enter an nndoc group based on the current article.
8457If FORCE, force a digest interpretation. If not, try
8458to guess what the document format is."
8459 (interactive "P")
eec82323 8460 (let ((conf gnus-current-window-configuration))
23f87bed
MB
8461 (save-window-excursion
8462 (save-excursion
8463 (let (gnus-article-prepare-hook
8464 gnus-display-mime-function
8465 gnus-break-pages)
8466 (gnus-summary-select-article))))
eec82323
LMI
8467 (setq gnus-current-window-configuration conf)
8468 (let* ((name (format "%s-%d"
8469 (gnus-group-prefixed-name
8470 gnus-newsgroup-name (list 'nndoc ""))
8471 (save-excursion
8472 (set-buffer gnus-summary-buffer)
8473 gnus-current-article)))
8474 (ogroup gnus-newsgroup-name)
8475 (params (append (gnus-info-params (gnus-get-info ogroup))
8476 (list (cons 'to-group ogroup))
23f87bed 8477 (list (cons 'parent-group ogroup))
eec82323
LMI
8478 (list (cons 'save-article-group ogroup))))
8479 (case-fold-search t)
8480 (buf (current-buffer))
16409b0b 8481 dig to-address)
eec82323 8482 (save-excursion
16409b0b
GM
8483 (set-buffer gnus-original-article-buffer)
8484 ;; Have the digest group inherit the main mail address of
8485 ;; the parent article.
23f87bed
MB
8486 (when (setq to-address (or (gnus-fetch-field "reply-to")
8487 (gnus-fetch-field "from")))
343d6628
MB
8488 (setq params
8489 (append
8490 (list (cons 'to-address
8491 (funcall gnus-decode-encoded-address-function
8492 to-address))))))
eec82323
LMI
8493 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8494 (insert-buffer-substring gnus-original-article-buffer)
8495 ;; Remove lines that may lead nndoc to misinterpret the
8496 ;; document type.
8497 (narrow-to-region
8498 (goto-char (point-min))
8499 (or (search-forward "\n\n" nil t) (point)))
8500 (goto-char (point-min))
16409b0b 8501 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8502 (widen))
8503 (unwind-protect
23f87bed 8504 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
8505 (gnus-newsgroup-ephemeral-ignored-charsets
8506 gnus-newsgroup-ignored-charsets))
8507 (gnus-group-read-ephemeral-group
8508 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8509 (nndoc-article-type
23f87bed
MB
8510 ,(if force 'mbox 'guess)))
8511 t nil nil nil
8512 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8513 "ADAPT")))))
16409b0b 8514 ;; Make all postings to this group go to the parent group.
23f87bed
MB
8515 (nconc (gnus-info-params (gnus-get-info name))
8516 params)
8517 ;; Couldn't select this doc group.
8518 (switch-to-buffer buf)
8519 (gnus-set-global-variables)
8520 (gnus-configure-windows 'summary)
8521 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
8522 (kill-buffer dig)))))
8523
8524(defun gnus-summary-read-document (n)
8525 "Open a new group based on the current article(s).
8526This will allow you to read digests and other similar
8527documents as newsgroups.
8528Obeys the standard process/prefix convention."
8529 (interactive "P")
8530 (let* ((articles (gnus-summary-work-articles n))
8531 (ogroup gnus-newsgroup-name)
8532 (params (append (gnus-info-params (gnus-get-info ogroup))
8533 (list (cons 'to-group ogroup))))
8534 article group egroup groups vgroup)
8535 (while (setq article (pop articles))
8536 (setq group (format "%s-%d" gnus-newsgroup-name article))
8537 (gnus-summary-remove-process-mark article)
8538 (when (gnus-summary-display-article article)
8539 (save-excursion
16409b0b 8540 (with-temp-buffer
eec82323
LMI
8541 (insert-buffer-substring gnus-original-article-buffer)
8542 ;; Remove some headers that may lead nndoc to make
8543 ;; the wrong guess.
8544 (message-narrow-to-head)
8545 (goto-char (point-min))
8546 (delete-matching-lines "^\\(Path\\):\\|^From ")
8547 (widen)
8548 (if (setq egroup
8549 (gnus-group-read-ephemeral-group
8550 group `(nndoc ,group (nndoc-address ,(current-buffer))
8551 (nndoc-article-type guess))
8552 t nil t))
8553 (progn
23f87bed 8554 ;; Make all postings to this group go to the parent group.
eec82323
LMI
8555 (nconc (gnus-info-params (gnus-get-info egroup))
8556 params)
8557 (push egroup groups))
8558 ;; Couldn't select this doc group.
8559 (gnus-error 3 "Article couldn't be entered"))))))
8560 ;; Now we have selected all the documents.
8561 (cond
8562 ((not groups)
8563 (error "None of the articles could be interpreted as documents"))
8564 ((gnus-group-read-ephemeral-group
8565 (setq vgroup (format
8566 "nnvirtual:%s-%s" gnus-newsgroup-name
8567 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8568 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8569 t
8570 (cons (current-buffer) 'summary)))
8571 (t
8572 (error "Couldn't select virtual nndoc group")))))
8573
8574(defun gnus-summary-isearch-article (&optional regexp-p)
8575 "Do incremental search forward on the current article.
8576If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8577 (interactive "P")
eec82323
LMI
8578 (gnus-summary-select-article)
8579 (gnus-configure-windows 'article)
8580 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
8581 (save-restriction
8582 (widen)
8583 (isearch-forward regexp-p))))
eec82323
LMI
8584
8585(defun gnus-summary-search-article-forward (regexp &optional backward)
8586 "Search for an article containing REGEXP forward.
8587If BACKWARD, search backward instead."
8588 (interactive
8589 (list (read-string
8590 (format "Search article %s (regexp%s): "
8591 (if current-prefix-arg "backward" "forward")
8592 (if gnus-last-search-regexp
8593 (concat ", default " gnus-last-search-regexp)
8594 "")))
8595 current-prefix-arg))
eec82323
LMI
8596 (if (string-equal regexp "")
8597 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
8598 (setq gnus-last-search-regexp regexp)
8599 (setq gnus-article-before-search gnus-current-article))
8600 ;; Intentionally set gnus-last-article.
8601 (setq gnus-last-article gnus-article-before-search)
8602 (let ((gnus-last-article gnus-last-article))
8603 (if (gnus-summary-search-article regexp backward)
8604 (gnus-summary-show-thread)
abc40aab 8605 (signal 'search-failed (list regexp)))))
eec82323
LMI
8606
8607(defun gnus-summary-search-article-backward (regexp)
8608 "Search for an article containing REGEXP backward."
8609 (interactive
8610 (list (read-string
8611 (format "Search article backward (regexp%s): "
8612 (if gnus-last-search-regexp
8613 (concat ", default " gnus-last-search-regexp)
8614 "")))))
8615 (gnus-summary-search-article-forward regexp 'backward))
8616
8617(defun gnus-summary-search-article (regexp &optional backward)
8618 "Search for an article containing REGEXP.
8619Optional argument BACKWARD means do search for backward.
8620`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
8621 ;; We have to require this here to make sure that the following
8622 ;; dynamic binding isn't shadowed by autoloading.
8623 (require 'gnus-async)
16409b0b 8624 (require 'gnus-art)
eec82323 8625 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 8626 (gnus-article-prepare-hook nil)
eec82323
LMI
8627 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8628 (gnus-use-article-prefetch nil)
8629 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 8630 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
8631 (gnus-visual nil)
8632 (gnus-keep-backlog nil)
8633 (gnus-break-pages nil)
8634 (gnus-summary-display-arrow nil)
8635 (gnus-updated-mode-lines nil)
8636 (gnus-auto-center-summary nil)
eec82323 8637 (sum (current-buffer))
16409b0b 8638 (gnus-display-mime-function nil)
eec82323
LMI
8639 (found nil)
8640 point)
8641 (gnus-save-hidden-threads
8642 (gnus-summary-select-article)
8643 (set-buffer gnus-article-buffer)
16409b0b 8644 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
8645 (when backward
8646 (forward-line -1))
8647 (while (not found)
8648 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8649 (if (if backward
8650 (re-search-backward regexp nil t)
8651 (re-search-forward regexp nil t))
8652 ;; We found the regexp.
8653 (progn
8654 (setq found 'found)
8655 (beginning-of-line)
8656 (set-window-start
8657 (get-buffer-window (current-buffer))
8658 (point))
8659 (forward-line 1)
16409b0b
GM
8660 (set-window-point
8661 (get-buffer-window (current-buffer))
8662 (point))
eec82323
LMI
8663 (set-buffer sum)
8664 (setq point (point)))
8665 ;; We didn't find it, so we go to the next article.
8666 (set-buffer sum)
8667 (setq found 'not)
8668 (while (eq found 'not)
8669 (if (not (if backward (gnus-summary-find-prev)
8670 (gnus-summary-find-next)))
8671 ;; No more articles.
8672 (setq found t)
8673 ;; Select the next article and adjust point.
8674 (unless (gnus-summary-article-sparse-p
8675 (gnus-summary-article-number))
8676 (setq found nil)
8677 (gnus-summary-select-article)
8678 (set-buffer gnus-article-buffer)
8679 (widen)
8680 (goto-char (if backward (point-max) (point-min))))))))
8681 (gnus-message 7 ""))
8682 ;; Return whether we found the regexp.
8683 (when (eq found 'found)
8684 (goto-char point)
8685 (gnus-summary-show-thread)
8686 (gnus-summary-goto-subject gnus-current-article)
8687 (gnus-summary-position-point)
8688 t)))
8689
23f87bed
MB
8690(defun gnus-find-matching-articles (header regexp)
8691 "Return a list of all articles that match REGEXP on HEADER.
8692This search includes all articles in the current group that Gnus has
8693fetched headers for, whether they are displayed or not."
8694 (let ((articles nil)
8695 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8696 (case-fold-search t))
8697 (dolist (header gnus-newsgroup-headers)
8698 (when (string-match regexp (funcall func header))
8699 (push (mail-header-number header) articles)))
8700 (nreverse articles)))
8701
eec82323 8702(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 8703 not-case-fold not-matching)
eec82323
LMI
8704 "Return a list of all articles that match REGEXP on HEADER.
8705The search stars on the current article and goes forwards unless
8706BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8707If UNREAD is non-nil, only unread articles will
8708be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 8709in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
8710not match REGEXP on HEADER."
8711 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
8712 articles d func)
8713 (if (consp header)
8714 (if (eq (car header) 'extra)
8715 (setq func
8716 `(lambda (h)
8717 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8718 "")))
8719 (error "%s is an invalid header" header))
8720 (unless (fboundp (intern (concat "mail-header-" header)))
8721 (error "%s is not a valid header" header))
8722 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
8723 (dolist (d (if (eq backward 'all)
8724 gnus-newsgroup-data
8725 (gnus-data-find-list
8726 (gnus-summary-article-number)
8727 (gnus-data-list backward))))
8728 (when (and (or (not unread) ; We want all articles...
8729 (gnus-data-unread-p d)) ; Or just unreads.
8730 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8731 (if not-matching
a1506d29 8732 (not (string-match
47b63dfa
SZ
8733 regexp
8734 (funcall func (gnus-data-header d))))
8735 (string-match regexp
8736 (funcall func (gnus-data-header d)))))
8737 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
8738 (nreverse articles)))
8739
8740(defun gnus-summary-execute-command (header regexp command &optional backward)
8741 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8742If HEADER is an empty string (or nil), the match is done on the entire
8743article. If BACKWARD (the prefix) is non-nil, search backward instead."
8744 (interactive
8745 (list (let ((completion-ignore-case t))
8746 (completing-read
8747 "Header name: "
23f87bed
MB
8748 (mapcar (lambda (header) (list (format "%s" header)))
8749 (append
8750 '("Number" "Subject" "From" "Lines" "Date"
8751 "Message-ID" "Xref" "References" "Body")
8752 gnus-extra-headers))
eec82323
LMI
8753 nil 'require-match))
8754 (read-string "Regexp: ")
8755 (read-key-sequence "Command: ")
8756 current-prefix-arg))
8757 (when (equal header "Body")
8758 (setq header ""))
eec82323
LMI
8759 ;; Hidden thread subtrees must be searched as well.
8760 (gnus-summary-show-all-threads)
8761 ;; We don't want to change current point nor window configuration.
8762 (save-excursion
8763 (save-window-excursion
23f87bed
MB
8764 (let (gnus-visual
8765 gnus-treat-strip-trailing-blank-lines
8766 gnus-treat-strip-leading-blank-lines
8767 gnus-treat-strip-multiple-blank-lines
8768 gnus-treat-hide-boring-headers
8769 gnus-treat-fold-newsgroups
8770 gnus-article-prepare-hook)
8771 (gnus-message 6 "Executing %s..." (key-description command))
8772 ;; We'd like to execute COMMAND interactively so as to give arguments.
8773 (gnus-execute header regexp
8774 `(call-interactively ',(key-binding command))
8775 backward)
8776 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
8777
8778(defun gnus-summary-beginning-of-article ()
8779 "Scroll the article back to the beginning."
8780 (interactive)
eec82323
LMI
8781 (gnus-summary-select-article)
8782 (gnus-configure-windows 'article)
8783 (gnus-eval-in-buffer-window gnus-article-buffer
8784 (widen)
8785 (goto-char (point-min))
23f87bed 8786 (when gnus-break-pages
eec82323
LMI
8787 (gnus-narrow-to-page))))
8788
8789(defun gnus-summary-end-of-article ()
8790 "Scroll to the end of the article."
8791 (interactive)
eec82323
LMI
8792 (gnus-summary-select-article)
8793 (gnus-configure-windows 'article)
8794 (gnus-eval-in-buffer-window gnus-article-buffer
8795 (widen)
8796 (goto-char (point-max))
8797 (recenter -3)
23f87bed
MB
8798 (when gnus-break-pages
8799 (when (re-search-backward page-delimiter nil t)
8800 (narrow-to-region (match-end 0) (point-max)))
eec82323
LMI
8801 (gnus-narrow-to-page))))
8802
23f87bed
MB
8803(defun gnus-summary-print-truncate-and-quote (string &optional len)
8804 "Truncate to LEN and quote all \"(\"'s in STRING."
8805 (gnus-replace-in-string (if (and len (> (length string) len))
8806 (substring string 0 len)
8807 string)
8808 "[()]" "\\\\\\&"))
8809
6748645f 8810(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
8811 "Generate and print a PostScript image of the process-marked (mail) articles.
8812
8813If used interactively, print the current article if none are
8814process-marked. With prefix arg, prompt the user for the name of the
8815file to save in.
6748645f 8816
23f87bed
MB
8817When used from Lisp, accept two optional args FILENAME and N. N means
8818to print the next N articles. If N is negative, print the N previous
8819articles. If N is nil and articles have been marked with the process
8820mark, print these instead.
eec82323 8821
16409b0b 8822If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
8823printer. If FILENAME is a string, save the PostScript image in a file with
8824that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 8825to save in."
676a7cc9 8826 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
8827 (dolist (article (gnus-summary-work-articles n))
8828 (gnus-summary-select-article nil nil 'pseudo article)
8829 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 8830 (gnus-print-buffer))
676a7cc9
SZ
8831 (gnus-summary-remove-process-mark article))
8832 (ps-despool filename))
eec82323 8833
23f87bed
MB
8834(defun gnus-print-buffer ()
8835 (let ((buffer (generate-new-buffer " *print*")))
8836 (unwind-protect
8837 (progn
8838 (copy-to-buffer buffer (point-min) (point-max))
8839 (set-buffer buffer)
8840 (gnus-remove-text-with-property 'gnus-decoration)
8841 (when (gnus-visual-p 'article-highlight 'highlight)
8842 ;; Copy-to-buffer doesn't copy overlay. So redo
8843 ;; highlight.
8844 (let ((gnus-article-buffer buffer))
8845 (gnus-article-highlight-citation t)
8846 (gnus-article-highlight-signature)
8847 (gnus-article-emphasize)
8848 (gnus-article-delete-invisible-text)))
8849 (let ((ps-left-header
8850 (list
8851 (concat "("
8852 (gnus-summary-print-truncate-and-quote
8853 (mail-header-subject gnus-current-headers)
8854 66) ")")
8855 (concat "("
8856 (gnus-summary-print-truncate-and-quote
8857 (mail-header-from gnus-current-headers)
8858 45) ")")))
8859 (ps-right-header
8860 (list
8861 "/pagenumberstring load"
8862 (concat "("
8863 (mail-header-date gnus-current-headers) ")"))))
8864 (gnus-run-hooks 'gnus-ps-print-hook)
8865 (save-excursion
8866 (if window-system
8867 (ps-spool-buffer-with-faces)
8868 (ps-spool-buffer)))))
8869 (kill-buffer buffer))))
8870
eec82323 8871(defun gnus-summary-show-article (&optional arg)
23f87bed 8872 "Force redisplaying of the current article.
16409b0b
GM
8873If ARG (the prefix) is a number, show the article with the charset
8874defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 8875input.
16409b0b 8876If ARG (the prefix) is non-nil and not a number, show the raw article
23f87bed
MB
8877without any article massaging functions being run. Normally, the key
8878strokes are `C-u g'."
eec82323 8879 (interactive "P")
16409b0b
GM
8880 (cond
8881 ((numberp arg)
23f87bed 8882 (gnus-summary-show-article t)
16409b0b
GM
8883 (let ((gnus-newsgroup-charset
8884 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
8885 (mm-read-coding-system
8886 "View as charset: " ;; actually it is coding system.
8887 (save-excursion
8888 (set-buffer gnus-article-buffer)
8889 (mm-detect-coding-region (point) (point-max))))))
16409b0b 8890 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
8891 (gnus-summary-select-article nil 'force)
8892 (let ((deps gnus-newsgroup-dependencies)
8893 head header lines)
8894 (save-excursion
8895 (set-buffer gnus-original-article-buffer)
8896 (save-restriction
8897 (message-narrow-to-head)
8898 (setq head (buffer-string))
8899 (goto-char (point-min))
8900 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8901 (goto-char (point-max))
8902 (widen)
8903 (setq lines (1- (count-lines (point) (point-max))))))
8904 (with-temp-buffer
8905 (insert (format "211 %d Article retrieved.\n"
8906 (cdr gnus-article-current)))
8907 (insert head)
8908 (if lines (insert (format "Lines: %d\n" lines)))
8909 (insert ".\n")
8910 (let ((nntp-server-buffer (current-buffer)))
8911 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8912 (gnus-data-set-header
8913 (gnus-data-find (cdr gnus-article-current))
8914 header)
8915 (gnus-summary-update-article-line
8916 (cdr gnus-article-current) header)
8917 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8918 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
8919 ((not arg)
8920 ;; Select the article the normal way.
8921 (gnus-summary-select-article nil 'force))
8922 (t
8923 ;; We have to require this here to make sure that the following
8924 ;; dynamic binding isn't shadowed by autoloading.
8925 (require 'gnus-async)
8926 (require 'gnus-art)
eec82323
LMI
8927 ;; Bind the article treatment functions to nil.
8928 (let ((gnus-have-all-headers t)
eec82323 8929 gnus-article-prepare-hook
16409b0b
GM
8930 gnus-article-decode-hook
8931 gnus-display-mime-function
8932 gnus-break-pages)
8933 ;; Destroy any MIME parts.
8934 (when (gnus-buffer-live-p gnus-article-buffer)
8935 (save-excursion
8936 (set-buffer gnus-article-buffer)
8937 (mm-destroy-parts gnus-article-mime-handles)
8938 ;; Set it to nil for safety reason.
8939 (setq gnus-article-mime-handle-alist nil)
8940 (setq gnus-article-mime-handles nil)))
8941 (gnus-summary-select-article nil 'force))))
eec82323
LMI
8942 (gnus-summary-goto-subject gnus-current-article)
8943 (gnus-summary-position-point))
8944
23f87bed
MB
8945(defun gnus-summary-show-raw-article ()
8946 "Show the raw article without any article massaging functions being run."
8947 (interactive)
8948 (gnus-summary-show-article t))
8949
eec82323
LMI
8950(defun gnus-summary-verbose-headers (&optional arg)
8951 "Toggle permanent full header display.
8952If ARG is a positive number, turn header display on.
8953If ARG is a negative number, turn header display off."
8954 (interactive "P")
eec82323
LMI
8955 (setq gnus-show-all-headers
8956 (cond ((or (not (numberp arg))
8957 (zerop arg))
8958 (not gnus-show-all-headers))
8959 ((natnump arg)
8960 t)))
8961 (gnus-summary-show-article))
8962
8963(defun gnus-summary-toggle-header (&optional arg)
8964 "Show the headers if they are hidden, or hide them if they are shown.
8965If ARG is a positive number, show the entire header.
8966If ARG is a negative number, hide the unwanted header lines."
8967 (interactive "P")
23f87bed
MB
8968 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8969 (get-buffer-window gnus-article-buffer t))))
8970 (with-current-buffer gnus-article-buffer
8971 (widen)
8972 (article-narrow-to-head)
16409b0b
GM
8973 (let* ((buffer-read-only nil)
8974 (inhibit-point-motion-hooks t)
23f87bed
MB
8975 (hidden (if (numberp arg)
8976 (>= arg 0)
f0096211
MB
8977 (or (not (looking-at "[^ \t\n]+:"))
8978 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
8979 s e)
8980 (delete-region (point-min) (point-max))
667e0ba6
SM
8981 (with-current-buffer gnus-original-article-buffer
8982 (goto-char (setq s (point-min)))
23f87bed
MB
8983 (setq e (if (search-forward "\n\n" nil t)
8984 (1- (point))
8985 (point-max))))
667e0ba6 8986 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
8987 (run-hooks 'gnus-article-decode-hook)
8988 (if hidden
8989 (let ((gnus-treat-hide-headers nil)
8990 (gnus-treat-hide-boring-headers nil))
8991 (gnus-delete-wash-type 'headers)
8992 (gnus-treat-article 'head))
8993 (gnus-treat-article 'head))
8994 (widen)
8995 (if window
8996 (set-window-start window (goto-char (point-min))))
8997 (if gnus-break-pages
8998 (gnus-narrow-to-page)
8999 (when (gnus-visual-p 'page-marker)
9000 (let ((buffer-read-only nil))
9001 (gnus-remove-text-with-property 'gnus-prev)
9002 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9003 (gnus-set-mode-line 'article)))))
eec82323
LMI
9004
9005(defun gnus-summary-show-all-headers ()
9006 "Make all header lines visible."
9007 (interactive)
23f87bed 9008 (gnus-summary-toggle-header 1))
eec82323 9009
eec82323
LMI
9010(defun gnus-summary-caesar-message (&optional arg)
9011 "Caesar rotate the current article by 13.
9012The numerical prefix specifies how many places to rotate each letter
9013forward."
9014 (interactive "P")
eec82323
LMI
9015 (gnus-summary-select-article)
9016 (let ((mail-header-separator ""))
9017 (gnus-eval-in-buffer-window gnus-article-buffer
9018 (save-restriction
9019 (widen)
9020 (let ((start (window-start))
9021 buffer-read-only)
9022 (message-caesar-buffer-body arg)
ff4d3926
MB
9023 (set-window-start (get-buffer-window (current-buffer)) start)))))
9024 ;; Create buttons and stuff...
9025 (gnus-treat-article nil))
eec82323 9026
23f87bed
MB
9027(autoload 'unmorse-region "morse"
9028 "Convert morse coded text in region to ordinary ASCII text."
9029 t)
9030
9031(defun gnus-summary-morse-message (&optional arg)
9032 "Morse decode the current article."
9033 (interactive "P")
9034 (gnus-summary-select-article)
9035 (let ((mail-header-separator ""))
9036 (gnus-eval-in-buffer-window gnus-article-buffer
9037 (save-excursion
9038 (save-restriction
9039 (widen)
9040 (let ((pos (window-start))
9041 buffer-read-only)
9042 (goto-char (point-min))
9043 (when (message-goto-body)
9044 (gnus-narrow-to-body))
9045 (goto-char (point-min))
9046