(tool-bar-map): Define for compiler.
[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,
e3fe4da0 4;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
eec82323 5
6748645f 6;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
eec82323
LMI
7;; Keywords: news
8
9;; This file is part of GNU Emacs.
10
5e809f55 11;; GNU Emacs is free software: you can redistribute it and/or modify
eec82323 12;; it under the terms of the GNU General Public License as published by
5e809f55
GM
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
eec82323
LMI
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
01ccbb85 18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eec82323
LMI
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
5e809f55 22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
eec82323
LMI
23
24;;; Commentary:
25
26;;; Code:
27
d09ae6ca
GM
28;; For Emacs < 22.2.
29(eval-and-compile
30 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
23f87bed 31(eval-when-compile
9efa445f
DN
32 (require 'cl))
33
34(defvar tool-bar-mode)
35(defvar gnus-tmp-header)
5ab7173c 36
eec82323
LMI
37(require 'gnus)
38(require 'gnus-group)
39(require 'gnus-spec)
40(require 'gnus-range)
41(require 'gnus-int)
42(require 'gnus-undo)
6748645f 43(require 'gnus-util)
18c06a99 44(require 'gmm-utils)
16409b0b 45(require 'mm-decode)
08c9a385 46(require 'nnoo)
23f87bed 47
6748645f 48(autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
d4dfaa19 49(autoload 'gnus-cache-write-active "gnus-cache")
23f87bed
MB
50(autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
51(autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
531e5812 52(autoload 'gnus-pick-line-number "gnus-salt" nil t)
08c9a385 53(autoload 'mm-uu-dissect "mm-uu")
23f87bed
MB
54(autoload 'gnus-article-outlook-deuglify-article "deuglify"
55 "Deuglify broken Outlook (Express) articles and redisplay."
56 t)
57(autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
58(autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
59(autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
eec82323
LMI
60
61(defcustom gnus-kill-summary-on-exit t
62 "*If non-nil, kill the summary buffer when you exit from it.
63If nil, the summary will become a \"*Dead Summary*\" buffer, and
64it will be killed sometime later."
65 :group 'gnus-summary-exit
66 :type 'boolean)
67
01c52d31
MB
68(defcustom gnus-summary-next-group-on-exit t
69 "If non-nil, go to the next unread newsgroup on summary exit.
70See `gnus-group-goto-unread'."
71 :link '(custom-manual "(gnus)Group Maneuvering")
72 :group 'gnus-summary-exit
330f707b 73 :version "23.1" ;; No Gnus
01c52d31
MB
74 :type 'boolean)
75
eec82323
LMI
76(defcustom gnus-fetch-old-headers nil
77 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
01c52d31
MB
78If an unread article in the group refers to an older, already
79read (or just marked as read) article, the old article will not
80normally be displayed in the Summary buffer. If this variable is
81t, Gnus will attempt to grab the headers to the old articles, and
82thereby build complete threads. If it has the value `some', all
83old headers will be fetched but only enough headers to connect
84otherwise loose threads will be displayed. This variable can
85also be a number. In that case, no more than that number of old
86headers will be fetched. If it has the value `invisible', all
6748645f 87old headers will be fetched, but none will be displayed.
eec82323 88
01c52d31
MB
89The server has to support NOV for any of this to work.
90
91This feature can seriously impact performance it ignores all
f394fa25
MB
92locally cached header entries. Setting it to t for groups for a
93server that doesn't expire articles (such as news.gmane.org),
94leads to very slow summary generation."
eec82323
LMI
95 :group 'gnus-thread
96 :type '(choice (const :tag "off" nil)
1232b9cb 97 (const :tag "on" t)
eec82323 98 (const some)
1232b9cb 99 (const invisible)
eec82323
LMI
100 number
101 (sexp :menu-tag "other" t)))
102
01c52d31 103(defcustom gnus-refer-thread-limit 500
6748645f
LMI
104 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
105If t, fetch all the available old headers."
106 :group 'gnus-thread
107 :type '(choice number
108 (sexp :menu-tag "other" t)))
109
eec82323
LMI
110(defcustom gnus-summary-make-false-root 'adopt
111 "*nil means that Gnus won't gather loose threads.
112If the root of a thread has expired or been read in a previous
113session, the information necessary to build a complete thread has been
114lost. Instead of having many small sub-threads from this original thread
115scattered all over the summary buffer, Gnus can gather them.
116
117If non-nil, Gnus will try to gather all loose sub-threads from an
118original thread into one large thread.
119
120If this variable is non-nil, it should be one of `none', `adopt',
121`dummy' or `empty'.
122
123If this variable is `none', Gnus will not make a false root, but just
124present the sub-threads after another.
125If this variable is `dummy', Gnus will create a dummy root that will
126have all the sub-threads as children.
127If this variable is `adopt', Gnus will make one of the \"children\"
128the parent and mark all the step-children as such.
129If this variable is `empty', the \"children\" are printed with empty
01ccbb85 130subject fields. (Or rather, they will be printed with a string
eec82323
LMI
131given by the `gnus-summary-same-subject' variable.)"
132 :group 'gnus-thread
133 :type '(choice (const :tag "off" nil)
134 (const none)
135 (const dummy)
136 (const adopt)
137 (const empty)))
138
23f87bed
MB
139(defcustom gnus-summary-make-false-root-always nil
140 "Always make a false dummy root."
bf247b6e 141 :version "22.1"
23f87bed
MB
142 :group 'gnus-thread
143 :type 'boolean)
144
eec82323
LMI
145(defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
146 "*A regexp to match subjects to be excluded from loose thread gathering.
147As loose thread gathering is done on subjects only, that means that
148there can be many false gatherings performed. By rooting out certain
149common subjects, gathering might become saner."
150 :group 'gnus-thread
151 :type 'regexp)
152
153(defcustom gnus-summary-gather-subject-limit nil
154 "*Maximum length of subject comparisons when gathering loose threads.
155Use nil to compare full subjects. Setting this variable to a low
156number will help gather threads that have been corrupted by
157newsreaders chopping off subject lines, but it might also mean that
158unrelated articles that have subject that happen to begin with the
159same few characters will be incorrectly gathered.
160
161If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
162comparing subjects."
163 :group 'gnus-thread
164 :type '(choice (const :tag "off" nil)
165 (const fuzzy)
166 (sexp :menu-tag "on" t)))
167
6748645f
LMI
168(defcustom gnus-simplify-subject-functions nil
169 "List of functions taking a string argument that simplify subjects.
170The functions are applied recursively.
171
23f87bed
MB
172Useful functions to put in this list include:
173`gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
174`gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
6748645f
LMI
175 :group 'gnus-thread
176 :type '(repeat function))
177
eec82323 178(defcustom gnus-simplify-ignored-prefixes nil
23f87bed 179 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
eec82323
LMI
180 :group 'gnus-thread
181 :type '(choice (const :tag "off" nil)
182 regexp))
183
184(defcustom gnus-build-sparse-threads nil
185 "*If non-nil, fill in the gaps in threads.
186If `some', only fill in the gaps that are needed to tie loose threads
187together. If `more', fill in all leaf nodes that Gnus can find. If
188non-nil and non-`some', fill in all gaps that Gnus manages to guess."
189 :group 'gnus-thread
190 :type '(choice (const :tag "off" nil)
191 (const some)
192 (const more)
193 (sexp :menu-tag "all" t)))
194
195(defcustom gnus-summary-thread-gathering-function
196 'gnus-gather-threads-by-subject
6748645f 197 "*Function used for gathering loose threads.
eec82323
LMI
198There are two pre-defined functions: `gnus-gather-threads-by-subject',
199which only takes Subjects into consideration; and
200`gnus-gather-threads-by-references', which compared the References
201headers of the articles to find matches."
202 :group 'gnus-thread
22115a9e
RS
203 :type '(radio (function-item gnus-gather-threads-by-subject)
204 (function-item gnus-gather-threads-by-references)
205 (function :tag "other")))
eec82323 206
eec82323
LMI
207(defcustom gnus-summary-same-subject ""
208 "*String indicating that the current article has the same subject as the previous.
209This variable will only be used if the value of
210`gnus-summary-make-false-root' is `empty'."
211 :group 'gnus-summary-format
212 :type 'string)
213
214(defcustom gnus-summary-goto-unread t
16409b0b
GM
215 "*If t, many commands will go to the next unread article.
216This applies to marking commands as well as other commands that
217\"naturally\" select the next article, like, for instance, `SPC' at
218the end of an article.
219
220If nil, the marking commands do NOT go to the next unread article
2642ac8f 221\(they go to the next article instead). If `never', commands that
16409b0b
GM
222usually go to the next unread article, will go to the next article,
223whether it is read or not."
eec82323
LMI
224 :group 'gnus-summary-marks
225 :link '(custom-manual "(gnus)Setting Marks")
226 :type '(choice (const :tag "off" nil)
227 (const never)
228 (sexp :menu-tag "on" t)))
229
230(defcustom gnus-summary-default-score 0
231 "*Default article score level.
232All scores generated by the score files will be added to this score.
233If this variable is nil, scoring will be disabled."
234 :group 'gnus-score-default
235 :type '(choice (const :tag "disable")
236 integer))
237
23f87bed
MB
238(defcustom gnus-summary-default-high-score 0
239 "*Default threshold for a high scored article.
240An article will be highlighted as high scored if its score is greater
241than this score."
bf247b6e 242 :version "22.1"
23f87bed
MB
243 :group 'gnus-score-default
244 :type 'integer)
245
246(defcustom gnus-summary-default-low-score 0
247 "*Default threshold for a low scored article.
248An article will be highlighted as low scored if its score is smaller
249than this score."
bf247b6e 250 :version "22.1"
23f87bed
MB
251 :group 'gnus-score-default
252 :type 'integer)
253
eec82323
LMI
254(defcustom gnus-summary-zcore-fuzz 0
255 "*Fuzziness factor for the zcore in the summary buffer.
256Articles with scores closer than this to `gnus-summary-default-score'
257will not be marked."
258 :group 'gnus-summary-format
259 :type 'integer)
260
261(defcustom gnus-simplify-subject-fuzzy-regexp nil
262 "*Strings to be removed when doing fuzzy matches.
263This can either be a regular expression or list of regular expressions
264that will be removed from subject strings if fuzzy subject
265simplification is selected."
266 :group 'gnus-thread
267 :type '(repeat regexp))
268
269(defcustom gnus-show-threads t
270 "*If non-nil, display threads in summary mode."
271 :group 'gnus-thread
272 :type 'boolean)
273
274(defcustom gnus-thread-hide-subtree nil
275 "*If non-nil, hide all threads initially.
23f87bed 276This can be a predicate specifier which says which threads to hide.
eec82323 277If threads are hidden, you have to run the command
4a2358e9 278`gnus-summary-show-thread' by hand or select an article."
eec82323 279 :group 'gnus-thread
23f87bed
MB
280 :type '(radio (sexp :format "Non-nil\n"
281 :match (lambda (widget value)
282 (not (or (consp value) (functionp value))))
283 :value t)
284 (const nil)
ad136a7c 285 (sexp :tag "Predicate specifier")))
eec82323
LMI
286
287(defcustom gnus-thread-hide-killed t
288 "*If non-nil, hide killed threads automatically."
289 :group 'gnus-thread
290 :type 'boolean)
291
6748645f
LMI
292(defcustom gnus-thread-ignore-subject t
293 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
294If nil, articles that have different subjects from their parents will
295start separate threads."
eec82323
LMI
296 :group 'gnus-thread
297 :type 'boolean)
298
299(defcustom gnus-thread-operation-ignore-subject t
300 "*If non-nil, subjects will be ignored when doing thread commands.
301This affects commands like `gnus-summary-kill-thread' and
302`gnus-summary-lower-thread'.
303
304If this variable is nil, articles in the same thread with different
305subjects will not be included in the operation in question. If this
306variable is `fuzzy', only articles that have subjects that are fuzzily
307equal will be included."
308 :group 'gnus-thread
309 :type '(choice (const :tag "off" nil)
310 (const fuzzy)
311 (sexp :tag "on" t)))
312
313(defcustom gnus-thread-indent-level 4
314 "*Number that says how much each sub-thread should be indented."
315 :group 'gnus-thread
316 :type 'integer)
317
318(defcustom gnus-auto-extend-newsgroup t
319 "*If non-nil, extend newsgroup forward and backward when requested."
320 :group 'gnus-summary-choose
321 :type 'boolean)
322
323(defcustom gnus-auto-select-first t
651408cb
MB
324 "If non-nil, select an article on group entry.
325An article is selected automatically when entering a group
326e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
327`gnus-summary-catchup-and-goto-next-group'.
328
329Which article is selected is controlled by the variable
330`gnus-auto-select-subject'.
23f87bed
MB
331
332If you want to prevent automatic selection of articles in some
333newsgroups, set the variable to nil in `gnus-select-group-hook'."
651408cb
MB
334 ;; Commands include...
335 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
336 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
337 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
eec82323
LMI
338 :group 'gnus-group-select
339 :type '(choice (const :tag "none" nil)
23f87bed
MB
340 (sexp :menu-tag "first" t)))
341
342(defcustom gnus-auto-select-subject 'unread
343 "*Says what subject to place under point when entering a group.
344
345This variable can either be the symbols `first' (place point on the
346first subject), `unread' (place point on the subject line of the first
347unread article), `best' (place point on the subject line of the
348higest-scored article), `unseen' (place point on the subject line of
99b5aab7 349the first unseen article), `unseen-or-unread' (place point on the subject
23f87bed
MB
350line of the first unseen article or, if all article have been seen, on the
351subject line of the first unread article), or a function to be called to
352place point on some subject line."
bf247b6e 353 :version "22.1"
23f87bed
MB
354 :group 'gnus-group-select
355 :type '(choice (const best)
356 (const unread)
357 (const first)
358 (const unseen)
359 (const unseen-or-unread)))
eec82323
LMI
360
361(defcustom gnus-auto-select-next t
362 "*If non-nil, offer to go to the next group from the end of the previous.
363If the value is t and the next newsgroup is empty, Gnus will exit
23f87bed
MB
364summary mode and go back to group mode. If the value is neither nil
365nor t, Gnus will select the following unread newsgroup. In
eec82323
LMI
366particular, if the value is the symbol `quietly', the next unread
367newsgroup will be selected without any confirmation, and if it is
368`almost-quietly', the next group will be selected without any
369confirmation if you are located on the last article in the group.
23f87bed 370Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
eec82323
LMI
371will go to the next group without confirmation."
372 :group 'gnus-summary-maneuvering
373 :type '(choice (const :tag "off" nil)
374 (const quietly)
375 (const almost-quietly)
376 (const slightly-quietly)
377 (sexp :menu-tag "on" t)))
378
379(defcustom gnus-auto-select-same nil
6748645f
LMI
380 "*If non-nil, select the next article with the same subject.
381If there are no more articles with the same subject, go to
382the first unread article."
eec82323
LMI
383 :group 'gnus-summary-maneuvering
384 :type 'boolean)
385
01c52d31
MB
386(defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
387 "What article should be selected after exiting an ephemeral group.
388Valid values include:
389
390`next'
391 Select the next article.
392`next-unread'
393 Select the next unread article.
394`next-noselect'
395 Move the cursor to the next article. This is the default.
396`next-unread-noselect'
397 Move the cursor to the next unread article.
398
399If it has any other value or there is no next (unread) article, the
400article selected before entering to the ephemeral group will appear."
330f707b 401 :version "23.1" ;; No Gnus
01c52d31
MB
402 :group 'gnus-summary-maneuvering
403 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
404 (const next) (const next-unread)
405 (const next-noselect) (const next-unread-noselect)
406 (sexp :tag "other" :value nil)))
407
23f87bed
MB
408(defcustom gnus-auto-goto-ignores 'unfetched
409 "*Says how to handle unfetched articles when maneuvering.
410
411This variable can either be the symbols nil (maneuver to any
412article), `undownloaded' (maneuvering while unplugged ignores articles
413that have not been fetched), `always-undownloaded' (maneuvering always
414ignores articles that have not been fetched), `unfetched' (maneuvering
415ignores articles whose headers have not been fetched).
416
417NOTE: The list of unfetched articles will always be nil when plugged
418and, when unplugged, a subset of the undownloaded article list."
bf247b6e 419 :version "22.1"
23f87bed
MB
420 :group 'gnus-summary-maneuvering
421 :type '(choice (const :tag "None" nil)
422 (const :tag "Undownloaded when unplugged" undownloaded)
423 (const :tag "Undownloaded" always-undownloaded)
424 (const :tag "Unfetched" unfetched)))
425
eec82323
LMI
426(defcustom gnus-summary-check-current nil
427 "*If non-nil, consider the current article when moving.
428The \"unread\" movement commands will stay on the same line if the
429current article is unread."
430 :group 'gnus-summary-maneuvering
431 :type 'boolean)
432
01c52d31 433(defcustom gnus-auto-center-summary 2
eec82323
LMI
434 "*If non-nil, always center the current summary buffer.
435In particular, if `vertical' do only vertical recentering. If non-nil
436and non-`vertical', do both horizontal and vertical recentering."
437 :group 'gnus-summary-maneuvering
438 :type '(choice (const :tag "none" nil)
439 (const vertical)
16409b0b 440 (integer :tag "height")
eec82323
LMI
441 (sexp :menu-tag "both" t)))
442
23f87bed
MB
443(defvar gnus-auto-center-group t
444 "*If non-nil, always center the group buffer.")
445
eec82323
LMI
446(defcustom gnus-show-all-headers nil
447 "*If non-nil, don't hide any headers."
448 :group 'gnus-article-hiding
449 :group 'gnus-article-headers
450 :type 'boolean)
451
452(defcustom gnus-summary-ignore-duplicates nil
453 "*If non-nil, ignore articles with identical Message-ID headers."
454 :group 'gnus-summary
455 :type 'boolean)
6748645f 456
eec82323
LMI
457(defcustom gnus-single-article-buffer t
458 "*If non-nil, display all articles in the same buffer.
459If nil, each group will get its own article buffer."
460 :group 'gnus-article-various
461 :type 'boolean)
462
463(defcustom gnus-break-pages t
464 "*If non-nil, do page breaking on articles.
465The page delimiter is specified by the `gnus-page-delimiter'
466variable."
467 :group 'gnus-article-various
468 :type 'boolean)
469
eec82323
LMI
470(defcustom gnus-move-split-methods nil
471 "*Variable used to suggest where articles are to be moved to.
23f87bed
MB
472It uses the same syntax as the `gnus-split-methods' variable.
473However, whereas `gnus-split-methods' specifies file names as targets,
474this variable specifies group names."
eec82323 475 :group 'gnus-summary-mail
6748645f
LMI
476 :type '(repeat (choice (list :value (fun) function)
477 (cons :value ("" "") regexp (repeat string))
478 (sexp :value nil))))
eec82323 479
01c52d31
MB
480(defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
481 "Function used to compute default prefix for article move/copy/etc prompts.
482The function should take one argument, a group name, and return a
483string with the suggested prefix."
484 :group 'gnus-summary-mail
485 :type 'function)
486
e62e7654
MB
487;; FIXME: Although the custom type is `character' for the following variables,
488;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
489
23f87bed 490(defcustom gnus-unread-mark ? ;Whitespace
eec82323
LMI
491 "*Mark used for unread articles."
492 :group 'gnus-summary-marks
493 :type 'character)
494
495(defcustom gnus-ticked-mark ?!
496 "*Mark used for ticked articles."
497 :group 'gnus-summary-marks
498 :type 'character)
499
500(defcustom gnus-dormant-mark ??
501 "*Mark used for dormant articles."
502 :group 'gnus-summary-marks
503 :type 'character)
504
505(defcustom gnus-del-mark ?r
506 "*Mark used for del'd articles."
507 :group 'gnus-summary-marks
508 :type 'character)
509
510(defcustom gnus-read-mark ?R
511 "*Mark used for read articles."
512 :group 'gnus-summary-marks
513 :type 'character)
514
515(defcustom gnus-expirable-mark ?E
516 "*Mark used for expirable articles."
517 :group 'gnus-summary-marks
518 :type 'character)
519
520(defcustom gnus-killed-mark ?K
521 "*Mark used for killed articles."
522 :group 'gnus-summary-marks
523 :type 'character)
524
23f87bed
MB
525(defcustom gnus-spam-mark ?$
526 "*Mark used for spam articles."
bf247b6e 527 :version "22.1"
23f87bed
MB
528 :group 'gnus-summary-marks
529 :type 'character)
530
eec82323 531(defcustom gnus-souped-mark ?F
23f87bed 532 "*Mark used for souped articles."
eec82323
LMI
533 :group 'gnus-summary-marks
534 :type 'character)
535
536(defcustom gnus-kill-file-mark ?X
537 "*Mark used for articles killed by kill files."
538 :group 'gnus-summary-marks
539 :type 'character)
540
541(defcustom gnus-low-score-mark ?Y
542 "*Mark used for articles with a low score."
543 :group 'gnus-summary-marks
544 :type 'character)
545
546(defcustom gnus-catchup-mark ?C
547 "*Mark used for articles that are caught up."
548 :group 'gnus-summary-marks
549 :type 'character)
550
551(defcustom gnus-replied-mark ?A
552 "*Mark used for articles that have been replied to."
553 :group 'gnus-summary-marks
554 :type 'character)
555
23f87bed
MB
556(defcustom gnus-forwarded-mark ?F
557 "*Mark used for articles that have been forwarded."
bf247b6e 558 :version "22.1"
23f87bed
MB
559 :group 'gnus-summary-marks
560 :type 'character)
561
562(defcustom gnus-recent-mark ?N
563 "*Mark used for articles that are recent."
bf247b6e 564 :version "22.1"
23f87bed
MB
565 :group 'gnus-summary-marks
566 :type 'character)
567
eec82323
LMI
568(defcustom gnus-cached-mark ?*
569 "*Mark used for articles that are in the cache."
570 :group 'gnus-summary-marks
571 :type 'character)
572
573(defcustom gnus-saved-mark ?S
23f87bed
MB
574 "*Mark used for articles that have been saved."
575 :group 'gnus-summary-marks
576 :type 'character)
577
578(defcustom gnus-unseen-mark ?.
579 "*Mark used for articles that haven't been seen."
bf247b6e 580 :version "22.1"
23f87bed
MB
581 :group 'gnus-summary-marks
582 :type 'character)
583
584(defcustom gnus-no-mark ? ;Whitespace
585 "*Mark used for articles that have no other secondary mark."
bf247b6e 586 :version "22.1"
eec82323
LMI
587 :group 'gnus-summary-marks
588 :type 'character)
589
590(defcustom gnus-ancient-mark ?O
591 "*Mark used for ancient articles."
592 :group 'gnus-summary-marks
593 :type 'character)
594
595(defcustom gnus-sparse-mark ?Q
596 "*Mark used for sparsely reffed articles."
597 :group 'gnus-summary-marks
598 :type 'character)
599
600(defcustom gnus-canceled-mark ?G
601 "*Mark used for canceled articles."
602 :group 'gnus-summary-marks
603 :type 'character)
604
605(defcustom gnus-duplicate-mark ?M
606 "*Mark used for duplicate articles."
607 :group 'gnus-summary-marks
608 :type 'character)
609
23f87bed 610(defcustom gnus-undownloaded-mark ?-
6748645f 611 "*Mark used for articles that weren't downloaded."
bf247b6e 612 :version "22.1"
6748645f
LMI
613 :group 'gnus-summary-marks
614 :type 'character)
615
23f87bed
MB
616(defcustom gnus-downloaded-mark ?+
617 "*Mark used for articles that were downloaded."
618 :group 'gnus-summary-marks
619 :type 'character)
620
6748645f
LMI
621(defcustom gnus-downloadable-mark ?%
622 "*Mark used for articles that are to be downloaded."
623 :group 'gnus-summary-marks
624 :type 'character)
625
626(defcustom gnus-unsendable-mark ?=
627 "*Mark used for articles that won't be sent."
628 :group 'gnus-summary-marks
629 :type 'character)
630
eec82323
LMI
631(defcustom gnus-score-over-mark ?+
632 "*Score mark used for articles with high scores."
633 :group 'gnus-summary-marks
634 :type 'character)
635
636(defcustom gnus-score-below-mark ?-
637 "*Score mark used for articles with low scores."
638 :group 'gnus-summary-marks
639 :type 'character)
640
23f87bed 641(defcustom gnus-empty-thread-mark ? ;Whitespace
eec82323
LMI
642 "*There is no thread under the article."
643 :group 'gnus-summary-marks
644 :type 'character)
645
646(defcustom gnus-not-empty-thread-mark ?=
647 "*There is a thread under the article."
648 :group 'gnus-summary-marks
649 :type 'character)
650
651(defcustom gnus-view-pseudo-asynchronously nil
652 "*If non-nil, Gnus will view pseudo-articles asynchronously."
653 :group 'gnus-extract-view
654 :type 'boolean)
655
16409b0b
GM
656(defcustom gnus-auto-expirable-marks
657 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
658 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
659 gnus-souped-mark gnus-duplicate-mark)
660 "*The list of marks converted into expiration if a group is auto-expirable."
58e39d05 661 :version "21.1"
16409b0b
GM
662 :group 'gnus-summary
663 :type '(repeat character))
664
665(defcustom gnus-inhibit-user-auto-expire t
666 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
58e39d05 667 :version "21.1"
16409b0b
GM
668 :group 'gnus-summary
669 :type 'boolean)
670
eec82323
LMI
671(defcustom gnus-view-pseudos nil
672 "*If `automatic', pseudo-articles will be viewed automatically.
673If `not-confirm', pseudos will be viewed automatically, and the user
674will not be asked to confirm the command."
675 :group 'gnus-extract-view
676 :type '(choice (const :tag "off" nil)
677 (const automatic)
678 (const not-confirm)))
679
680(defcustom gnus-view-pseudos-separately t
681 "*If non-nil, one pseudo-article will be created for each file to be viewed.
682If nil, all files that use the same viewing command will be given as a
683list of parameters to that command."
684 :group 'gnus-extract-view
685 :type 'boolean)
686
687(defcustom gnus-insert-pseudo-articles t
688 "*If non-nil, insert pseudo-articles when decoding articles."
689 :group 'gnus-extract-view
690 :type 'boolean)
691
692(defcustom gnus-summary-dummy-line-format
23f87bed 693 " %(: :%) %S\n"
eec82323
LMI
694 "*The format specification for the dummy roots in the summary buffer.
695It works along the same lines as a normal formatting string,
696with some simple extensions.
697
23f87bed
MB
698%S The subject
699
700General format specifiers can also be used.
701See `(gnus)Formatting Variables'."
702 :link '(custom-manual "(gnus)Formatting Variables")
eec82323
LMI
703 :group 'gnus-threading
704 :type 'string)
705
16409b0b 706(defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
eec82323
LMI
707 "*The format specification for the summary mode line.
708It works along the same lines as a normal formatting string,
709with some simple extensions:
710
711%G Group name
712%p Unprefixed group name
713%A Current article number
6748645f 714%z Current article score
eec82323
LMI
715%V Gnus version
716%U Number of unread articles in the group
717%e Number of unselected articles in the group
718%Z A string with unread/unselected article counts
719%g Shortish group name
720%S Subject of the current article
721%u User-defined spec
722%s Current score file name
723%d Number of dormant articles
724%r Number of articles that have been marked as read in this session
725%E Number of articles expunged by the score files"
726 :group 'gnus-summary-format
727 :type 'string)
728
16409b0b
GM
729(defcustom gnus-list-identifiers nil
730 "Regexp that matches list identifiers to be removed from subject.
731This can also be a list of regexps."
58e39d05 732 :version "21.1"
16409b0b
GM
733 :group 'gnus-summary-format
734 :group 'gnus-article-hiding
735 :type '(choice (const :tag "none" nil)
736 (regexp :value ".*")
737 (repeat :value (".*") regexp)))
738
eec82323
LMI
739(defcustom gnus-summary-mark-below 0
740 "*Mark all articles with a score below this variable as read.
741This variable is local to each summary buffer and usually set by the
742score file."
743 :group 'gnus-score-default
744 :type 'integer)
745
01c52d31
MB
746(defun gnus-widget-reversible-match (widget value)
747 "Ignoring WIDGET, convert VALUE to internal form.
748VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
749 ;; (debug value)
750 (or (symbolp value)
751 (and (listp value)
752 (eq (length value) 2)
753 (eq (nth 0 value) 'not)
754 (symbolp (nth 1 value)))))
755
756(defun gnus-widget-reversible-to-internal (widget value)
757 "Ignoring WIDGET, convert VALUE to internal form.
758VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
759FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
760 ;; (debug value)
761 (if (atom value)
762 (list value nil)
763 (list (nth 1 value) t)))
764
765(defun gnus-widget-reversible-to-external (widget value)
766 "Ignoring WIDGET, convert VALUE to external form.
767VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
768\(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
769 ;; (debug value)
770 (if (nth 1 value)
771 (list 'not (nth 0 value))
772 (nth 0 value)))
773
774(define-widget 'gnus-widget-reversible 'group
775 "A `group' that convert values."
776 :match 'gnus-widget-reversible-match
777 :value-to-internal 'gnus-widget-reversible-to-internal
778 :value-to-external 'gnus-widget-reversible-to-external)
779
eec82323
LMI
780(defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
781 "*List of functions used for sorting articles in the summary buffer.
23f87bed
MB
782
783Each function takes two articles and returns non-nil if the first
784article should be sorted before the other. If you use more than one
785function, the primary sort function should be the last. You should
786probably always include `gnus-article-sort-by-number' in the list of
787sorting functions -- preferably first. Also note that sorting by date
788is often much slower than sorting by number, and the sorting order is
789very similar. (Sorting by date means sorting by the time the message
790was sent, sorting by number means sorting by arrival time.)
791
01c52d31
MB
792Each item can also be a list `(not F)' where F is a function;
793this reverses the sort order.
794
23f87bed
MB
795Ready-made functions include `gnus-article-sort-by-number',
796`gnus-article-sort-by-author', `gnus-article-sort-by-subject',
797`gnus-article-sort-by-date', `gnus-article-sort-by-random'
798and `gnus-article-sort-by-score'.
799
800When threading is turned on, the variable `gnus-thread-sort-functions'
801controls how articles are sorted."
eec82323 802 :group 'gnus-summary-sort
01c52d31
MB
803 :type '(repeat (gnus-widget-reversible
804 (choice (function-item gnus-article-sort-by-number)
805 (function-item gnus-article-sort-by-author)
806 (function-item gnus-article-sort-by-subject)
807 (function-item gnus-article-sort-by-date)
808 (function-item gnus-article-sort-by-score)
809 (function-item gnus-article-sort-by-random)
810 (function :tag "other"))
811 (boolean :tag "Reverse order"))))
812
eec82323
LMI
813
814(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
815 "*List of functions used for sorting threads in the summary buffer.
816By default, threads are sorted by article number.
817
23f87bed
MB
818Each function takes two threads and returns non-nil if the first
819thread should be sorted before the other. If you use more than one
820function, the primary sort function should be the last. You should
821probably always include `gnus-thread-sort-by-number' in the list of
822sorting functions -- preferably first. Also note that sorting by date
823is often much slower than sorting by number, and the sorting order is
824very similar. (Sorting by date means sorting by the time the message
825was sent, sorting by number means sorting by arrival time.)
eec82323 826
01c52d31
MB
827Each list item can also be a list `(not F)' where F is a
828function; this specifies reversed sort order.
829
eec82323 830Ready-made functions include `gnus-thread-sort-by-number',
01c52d31
MB
831`gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
832`gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
833`gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
834`gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
835and `gnus-thread-sort-by-total-score' (see
836`gnus-thread-score-function').
23f87bed
MB
837
838When threading is turned off, the variable
839`gnus-article-sort-functions' controls how articles are sorted."
eec82323 840 :group 'gnus-summary-sort
01c52d31
MB
841 :type '(repeat
842 (gnus-widget-reversible
843 (choice (function-item gnus-thread-sort-by-number)
844 (function-item gnus-thread-sort-by-author)
845 (function-item gnus-thread-sort-by-recipient)
846 (function-item gnus-thread-sort-by-subject)
847 (function-item gnus-thread-sort-by-date)
848 (function-item gnus-thread-sort-by-score)
849 (function-item gnus-thread-sort-by-most-recent-number)
850 (function-item gnus-thread-sort-by-most-recent-date)
851 (function-item gnus-thread-sort-by-random)
852 (function-item gnus-thread-sort-by-total-score)
853 (function :tag "other"))
854 (boolean :tag "Reverse order"))))
eec82323
LMI
855
856(defcustom gnus-thread-score-function '+
857 "*Function used for calculating the total score of a thread.
858
859The function is called with the scores of the article and each
860subthread and should then return the score of the thread.
861
862Some functions you can use are `+', `max', or `min'."
863 :group 'gnus-summary-sort
864 :type 'function)
865
866(defcustom gnus-summary-expunge-below nil
6748645f
LMI
867 "All articles that have a score less than this variable will be expunged.
868This variable is local to the summary buffers."
eec82323
LMI
869 :group 'gnus-score-default
870 :type '(choice (const :tag "off" nil)
871 integer))
872
873(defcustom gnus-thread-expunge-below nil
874 "All threads that have a total score less than this variable will be expunged.
875See `gnus-thread-score-function' for en explanation of what a
6748645f
LMI
876\"thread score\" is.
877
878This variable is local to the summary buffers."
16409b0b 879 :group 'gnus-threading
eec82323
LMI
880 :group 'gnus-score-default
881 :type '(choice (const :tag "off" nil)
882 integer))
883
884(defcustom gnus-summary-mode-hook nil
885 "*A hook for Gnus summary mode.
886This hook is run before any variables are set in the summary buffer."
23f87bed 887 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
eec82323
LMI
888 :group 'gnus-summary-various
889 :type 'hook)
890
23f87bed
MB
891;; Extracted from gnus-xmas-redefine in order to preserve user settings
892(when (featurep 'xemacs)
893 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
894 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
895 (add-hook 'gnus-summary-mode-hook
896 'gnus-xmas-switch-horizontal-scrollbar-off))
897
eec82323
LMI
898(defcustom gnus-summary-menu-hook nil
899 "*Hook run after the creation of the summary mode menu."
900 :group 'gnus-summary-visual
901 :type 'hook)
902
903(defcustom gnus-summary-exit-hook nil
904 "*A hook called on exit from the summary buffer.
905It will be called with point in the group buffer."
906 :group 'gnus-summary-exit
907 :type 'hook)
908
909(defcustom gnus-summary-prepare-hook nil
910 "*A hook called after the summary buffer has been generated.
911If you want to modify the summary buffer, you can use this hook."
912 :group 'gnus-summary-various
913 :type 'hook)
914
6748645f
LMI
915(defcustom gnus-summary-prepared-hook nil
916 "*A hook called as the last thing after the summary buffer has been generated."
917 :group 'gnus-summary-various
918 :type 'hook)
919
eec82323
LMI
920(defcustom gnus-summary-generate-hook nil
921 "*A hook run just before generating the summary buffer.
922This hook is commonly used to customize threading variables and the
923like."
924 :group 'gnus-summary-various
925 :type 'hook)
926
927(defcustom gnus-select-group-hook nil
928 "*A hook called when a newsgroup is selected.
929
930If you'd like to simplify subjects like the
931`gnus-summary-next-same-subject' command does, you can use the
932following hook:
933
23f87bed
MB
934 (add-hook gnus-select-group-hook
935 (lambda ()
936 (mapcar (lambda (header)
937 (mail-header-set-subject
938 header
939 (gnus-simplify-subject
940 (mail-header-subject header) 're-only)))
941 gnus-newsgroup-headers)))"
eec82323
LMI
942 :group 'gnus-group-select
943 :type 'hook)
944
945(defcustom gnus-select-article-hook nil
946 "*A hook called when an article is selected."
947 :group 'gnus-summary-choose
23f87bed 948 :options '(gnus-agent-fetch-selected-article)
eec82323
LMI
949 :type 'hook)
950
951(defcustom gnus-visual-mark-article-hook
952 (list 'gnus-highlight-selected-summary)
953 "*Hook run after selecting an article in the summary buffer.
954It is meant to be used for highlighting the article in some way. It
955is not run if `gnus-visual' is nil."
956 :group 'gnus-summary-visual
957 :type 'hook)
958
16409b0b 959(defcustom gnus-parse-headers-hook nil
eec82323
LMI
960 "*A hook called before parsing the headers."
961 :group 'gnus-various
962 :type 'hook)
963
964(defcustom gnus-exit-group-hook nil
16409b0b
GM
965 "*A hook called when exiting summary mode.
966This hook is not called from the non-updating exit commands like `Q'."
eec82323
LMI
967 :group 'gnus-various
968 :type 'hook)
969
970(defcustom gnus-summary-update-hook
971 (list 'gnus-summary-highlight-line)
972 "*A hook called when a summary line is changed.
973The hook will not be called if `gnus-visual' is nil.
974
975The default function `gnus-summary-highlight-line' will
976highlight the line according to the `gnus-summary-highlight'
977variable."
978 :group 'gnus-summary-visual
979 :type 'hook)
980
981(defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
982 "*A hook called when an article is selected for the first time.
983The hook is intended to mark an article as read (or unread)
984automatically when it is selected."
985 :group 'gnus-summary-choose
986 :type 'hook)
987
988(defcustom gnus-group-no-more-groups-hook nil
989 "*A hook run when returning to group mode having no more (unread) groups."
990 :group 'gnus-group-select
991 :type 'hook)
992
993(defcustom gnus-ps-print-hook nil
994 "*A hook run before ps-printing something from Gnus."
995 :group 'gnus-summary
996 :type 'hook)
997
23f87bed
MB
998(defcustom gnus-summary-article-move-hook nil
999 "*A hook called after an article is moved, copied, respooled, or crossposted."
bf247b6e 1000 :version "22.1"
23f87bed
MB
1001 :group 'gnus-summary
1002 :type 'hook)
1003
1004(defcustom gnus-summary-article-delete-hook nil
1005 "*A hook called after an article is deleted."
bf247b6e 1006 :version "22.1"
23f87bed
MB
1007 :group 'gnus-summary
1008 :type 'hook)
1009
1010(defcustom gnus-summary-article-expire-hook nil
1011 "*A hook called after an article is expired."
bf247b6e 1012 :version "22.1"
23f87bed
MB
1013 :group 'gnus-summary
1014 :type 'hook)
1015
1016(defcustom gnus-summary-display-arrow
1017 (and (fboundp 'display-graphic-p)
1018 (display-graphic-p))
1019 "*If non-nil, display an arrow highlighting the current article."
bf247b6e 1020 :version "22.1"
23f87bed
MB
1021 :group 'gnus-summary
1022 :type 'boolean)
1023
0f49874b 1024(defcustom gnus-summary-selected-face 'gnus-summary-selected
eec82323
LMI
1025 "Face used for highlighting the current article in the summary buffer."
1026 :group 'gnus-summary-visual
1027 :type 'face)
1028
23f87bed
MB
1029(defvar gnus-tmp-downloaded nil)
1030
eec82323 1031(defcustom gnus-summary-highlight
23f87bed 1032 '(((eq mark gnus-canceled-mark)
0f49874b 1033 . gnus-summary-cancelled)
23f87bed 1034 ((and uncached (> score default-high))
0f49874b 1035 . gnus-summary-high-undownloaded)
23f87bed 1036 ((and uncached (< score default-low))
0f49874b 1037 . gnus-summary-low-undownloaded)
23f87bed 1038 (uncached
0f49874b 1039 . gnus-summary-normal-undownloaded)
23f87bed
MB
1040 ((and (> score default-high)
1041 (or (eq mark gnus-dormant-mark)
1042 (eq mark gnus-ticked-mark)))
0f49874b 1043 . gnus-summary-high-ticked)
23f87bed
MB
1044 ((and (< score default-low)
1045 (or (eq mark gnus-dormant-mark)
1046 (eq mark gnus-ticked-mark)))
0f49874b 1047 . gnus-summary-low-ticked)
23f87bed
MB
1048 ((or (eq mark gnus-dormant-mark)
1049 (eq mark gnus-ticked-mark))
0f49874b 1050 . gnus-summary-normal-ticked)
23f87bed 1051 ((and (> score default-high) (eq mark gnus-ancient-mark))
0f49874b 1052 . gnus-summary-high-ancient)
23f87bed 1053 ((and (< score default-low) (eq mark gnus-ancient-mark))
0f49874b 1054 . gnus-summary-low-ancient)
23f87bed 1055 ((eq mark gnus-ancient-mark)
0f49874b 1056 . gnus-summary-normal-ancient)
23f87bed 1057 ((and (> score default-high) (eq mark gnus-unread-mark))
0f49874b 1058 . gnus-summary-high-unread)
23f87bed 1059 ((and (< score default-low) (eq mark gnus-unread-mark))
0f49874b 1060 . gnus-summary-low-unread)
23f87bed 1061 ((eq mark gnus-unread-mark)
0f49874b 1062 . gnus-summary-normal-unread)
23f87bed 1063 ((> score default-high)
0f49874b 1064 . gnus-summary-high-read)
23f87bed 1065 ((< score default-low)
0f49874b 1066 . gnus-summary-low-read)
eec82323 1067 (t
0f49874b 1068 . gnus-summary-normal-read))
6748645f 1069 "*Controls the highlighting of summary buffer lines.
eec82323 1070
107cf8ec 1071A list of (FORM . FACE) pairs. When deciding how a particular
23f87bed
MB
1072summary line should be displayed, each form is evaluated. The content
1073of the face field after the first true form is used. You can change
1074how those summary lines are displayed, by editing the face field.
eec82323
LMI
1075
1076You can use the following variables in the FORM field.
1077
107cf8ec 1078score: The article's score.
23f87bed
MB
1079default: The default article score.
1080default-high: The default score for high scored articles.
1081default-low: The default score for low scored articles.
1082below: The score below which articles are automatically marked as read.
1083mark: The article's mark.
1084uncached: Non-nil if the article is uncached."
eec82323
LMI
1085 :group 'gnus-summary-visual
1086 :type '(repeat (cons (sexp :tag "Form" nil)
1087 face)))
c12ecb0a 1088(put 'gnus-summary-highlight 'risky-local-variable t)
eec82323 1089
6748645f
LMI
1090(defcustom gnus-alter-header-function nil
1091 "Function called to allow alteration of article header structures.
1092The function is called with one parameter, the article header vector,
0ab0f2d3
SZ
1093which it may alter in any way."
1094 :type '(choice (const :tag "None" nil)
1095 function)
1096 :group 'gnus-summary)
eec82323 1097
16409b0b 1098(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
343d6628
MB
1099 "Function used to decode a string with encoded words.")
1100
1101(defvar gnus-decode-encoded-address-function
1102 'mail-decode-encoded-address-string
1103 "Function used to decode addresses with encoded words.")
16409b0b 1104
23f87bed 1105(defcustom gnus-extra-headers '(To Newsgroups)
16409b0b 1106 "*Extra headers to parse."
58e39d05 1107 :version "21.1"
16409b0b
GM
1108 :group 'gnus-summary
1109 :type '(repeat symbol))
1110
1111(defcustom gnus-ignored-from-addresses
343d6628 1112 (and user-mail-address
7cd9f860
CY
1113 (not (string= user-mail-address ""))
1114 (regexp-quote user-mail-address))
01c52d31
MB
1115 "*From headers that may be suppressed in favor of To headers.
1116This can be a regexp or a list of regexps."
58e39d05 1117 :version "21.1"
16409b0b 1118 :group 'gnus-summary
01c52d31
MB
1119 :type '(choice regexp
1120 (repeat :tag "Regexp List" regexp)))
1121
1122(defsubst gnus-ignored-from-addresses ()
1123 (gmm-regexp-concat gnus-ignored-from-addresses))
1124
1125(defcustom gnus-summary-to-prefix "-> "
1126 "*String prefixed to the To field in the summary line when
1127using `gnus-ignored-from-addresses'."
1128 :version "22.1"
1129 :group 'gnus-summary
1130 :type 'string)
1131
1132(defcustom gnus-summary-newsgroup-prefix "=> "
1133 "*String prefixed to the Newsgroup field in the summary
1134line when using `gnus-ignored-from-addresses'."
1135 :version "22.1"
1136 :group 'gnus-summary
1137 :type 'string)
16409b0b 1138
16409b0b
GM
1139(defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1140 "List of charsets that should be ignored.
1141When these charsets are used in the \"charset\" parameter, the
1142default charset will be used instead."
58e39d05 1143 :version "21.1"
16409b0b
GM
1144 :type '(repeat symbol)
1145 :group 'gnus-charset)
1146
4b70e299
MB
1147(defcustom gnus-newsgroup-maximum-articles nil
1148 "The maximum number of articles a newsgroup.
1149If this is a number, old articles in a newsgroup exceeding this number
1150are silently ignored. If it is nil, no article is ignored. Note that
1151setting this variable to a number might prevent you from reading very
1152old articles."
1153 :group 'gnus-group-select
1154 :version "22.2"
1155 :type '(choice (const :tag "No limit" nil)
1156 integer))
1157
23f87bed
MB
1158(gnus-define-group-parameter
1159 ignored-charsets
1160 :type list
1161 :function-document
1162 "Return the ignored charsets of GROUP."
1163 :variable gnus-group-ignored-charsets-alist
1164 :variable-default
1165 '(("alt\\.chinese\\.text" iso-8859-1))
1166 :variable-document
1167 "Alist of regexps (to match group names) and charsets that should be ignored.
16409b0b
GM
1168When these charsets are used in the \"charset\" parameter, the
1169default charset will be used instead."
23f87bed
MB
1170 :variable-group gnus-charset
1171 :variable-type '(repeat (cons (regexp :tag "Group")
1172 (repeat symbol)))
1173 :parameter-type '(choice :tag "Ignored charsets"
1174 :value nil
1175 (repeat (symbol)))
1176 :parameter-document "\
1177List of charsets that should be ignored.
1178
1179When these charsets are used in the \"charset\" parameter, the
1180default charset will be used instead.")
16409b0b
GM
1181
1182(defcustom gnus-group-highlight-words-alist nil
1183 "Alist of group regexps and highlight regexps.
1184This variable uses the same syntax as `gnus-emphasis-alist'."
58e39d05 1185 :version "21.1"
16409b0b
GM
1186 :type '(repeat (cons (regexp :tag "Group")
1187 (repeat (list (regexp :tag "Highlight regexp")
1188 (number :tag "Group for entire word" 0)
1189 (number :tag "Group for displayed part" 0)
1190 (symbol :tag "Face"
1191 gnus-emphasis-highlight-words)))))
1192 :group 'gnus-summary-visual)
1193
1194(defcustom gnus-summary-show-article-charset-alist
1195 nil
1196 "Alist of number and charset.
1197The article will be shown with the charset corresponding to the
1198numbered argument.
1199For example: ((1 . cn-gb-2312) (2 . big5))."
58e39d05 1200 :version "21.1"
16409b0b
GM
1201 :type '(repeat (cons (number :tag "Argument" 1)
1202 (symbol :tag "Charset")))
1203 :group 'gnus-charset)
1204
1205(defcustom gnus-preserve-marks t
1206 "Whether marks are preserved when moving, copying and respooling messages."
58e39d05 1207 :version "21.1"
16409b0b
GM
1208 :type 'boolean
1209 :group 'gnus-summary-marks)
1210
3a23a519
MB
1211(defcustom gnus-propagate-marks t
1212 "If non-nil, do not propagate marks to the backends."
f8a29505 1213 :version "23.1" ;; No Gnus
3a23a519
MB
1214 :type 'boolean
1215 :group 'gnus-summary-marks)
1216
16409b0b
GM
1217(defcustom gnus-alter-articles-to-read-function nil
1218 "Function to be called to alter the list of articles to be selected."
8fc7a9a1 1219 :type '(choice (const nil) function)
16409b0b
GM
1220 :group 'gnus-summary)
1221
1222(defcustom gnus-orphan-score nil
1223 "*All orphans get this score added. Set in the score file."
1224 :group 'gnus-score-default
1225 :type '(choice (const nil)
1226 integer))
1227
8b93df01 1228(defcustom gnus-summary-save-parts-default-mime "image/.*"
23f87bed
MB
1229 "*A regexp to match MIME parts when saving multiple parts of a
1230message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1231This regexp will be used by default when prompting the user for which
1232type of files to save."
8b93df01
DL
1233 :group 'gnus-summary
1234 :type 'regexp)
1235
23f87bed
MB
1236(defcustom gnus-read-all-available-headers nil
1237 "Whether Gnus should parse all headers made available to it.
1238This is mostly relevant for slow back ends where the user may
1239wish to widen the summary buffer to include all headers
1240that were fetched. Say, for nnultimate groups."
bf247b6e 1241 :version "22.1"
23f87bed
MB
1242 :group 'gnus-summary
1243 :type '(choice boolean regexp))
1244
1245(defcustom gnus-summary-muttprint-program "muttprint"
1246 "Command (and optional arguments) used to run Muttprint."
bf247b6e 1247 :version "22.1"
23f87bed
MB
1248 :group 'gnus-summary
1249 :type 'string)
1250
01c52d31 1251(defcustom gnus-article-loose-mime t
23f87bed
MB
1252 "If non-nil, don't require MIME-Version header.
1253Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
a08b59c9 1254supply the MIME-Version header or deliberately strip it from the mail.
01c52d31
MB
1255If non-nil (the default), Gnus will treat some articles as MIME
1256even if the MIME-Version header is missing."
bf247b6e 1257 :version "22.1"
23f87bed
MB
1258 :type 'boolean
1259 :group 'gnus-article-mime)
1260
1261(defcustom gnus-article-emulate-mime t
1262 "If non-nil, use MIME emulation for uuencode and the like.
1263This means that Gnus will search message bodies for text that look
1264like uuencoded bits, yEncoded bits, and so on, and present that using
1265the normal Gnus MIME machinery."
bf247b6e 1266 :version "22.1"
23f87bed
MB
1267 :type 'boolean
1268 :group 'gnus-article-mime)
8b93df01 1269
eec82323
LMI
1270;;; Internal variables
1271
23f87bed 1272(defvar gnus-summary-display-cache nil)
16409b0b
GM
1273(defvar gnus-article-mime-handles nil)
1274(defvar gnus-article-decoded-p nil)
23f87bed
MB
1275(defvar gnus-article-charset nil)
1276(defvar gnus-article-ignored-charsets nil)
eec82323
LMI
1277(defvar gnus-scores-exclude-files nil)
1278(defvar gnus-page-broken nil)
1279
1280(defvar gnus-original-article nil)
1281(defvar gnus-article-internal-prepare-hook nil)
1282(defvar gnus-newsgroup-process-stack nil)
1283
1284(defvar gnus-thread-indent-array nil)
1285(defvar gnus-thread-indent-array-level gnus-thread-indent-level)
16409b0b
GM
1286(defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1287 "Function called to sort the articles within a thread after it has been gathered together.")
eec82323 1288
8b93df01 1289(defvar gnus-summary-save-parts-type-history nil)
23f87bed 1290(defvar gnus-summary-save-parts-last-directory mm-default-directory)
8b93df01 1291
eec82323
LMI
1292;; Avoid highlighting in kill files.
1293(defvar gnus-summary-inhibit-highlight nil)
1294(defvar gnus-newsgroup-selected-overlay nil)
1295(defvar gnus-inhibit-limiting nil)
1296(defvar gnus-newsgroup-adaptive-score-file nil)
1297(defvar gnus-current-score-file nil)
1298(defvar gnus-current-move-group nil)
1299(defvar gnus-current-copy-group nil)
1300(defvar gnus-current-crosspost-group nil)
23f87bed 1301(defvar gnus-newsgroup-display nil)
eec82323
LMI
1302
1303(defvar gnus-newsgroup-dependencies nil)
1304(defvar gnus-newsgroup-adaptive nil)
1305(defvar gnus-summary-display-article-function nil)
1306(defvar gnus-summary-highlight-line-function nil
1307 "Function called after highlighting a summary line.")
1308
1309(defvar gnus-summary-line-format-alist
1310 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1311 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1312 (?s gnus-tmp-subject-or-nil ?s)
1313 (?n gnus-tmp-name ?s)
1314 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1315 ?s)
1316 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1317 gnus-tmp-from) ?s)
1318 (?F gnus-tmp-from ?s)
1319 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1320 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1321 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
6748645f 1322 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
eec82323
LMI
1323 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1324 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1325 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
23f87bed
MB
1326 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1327 (?L gnus-tmp-lines ?s)
1328 (?O gnus-tmp-downloaded ?c)
eec82323
LMI
1329 (?I gnus-tmp-indentation ?s)
1330 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1331 (?R gnus-tmp-replied ?c)
1332 (?\[ gnus-tmp-opening-bracket ?c)
1333 (?\] gnus-tmp-closing-bracket ?c)
1334 (?\> (make-string gnus-tmp-level ? ) ?s)
1335 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1336 (?i gnus-tmp-score ?d)
1337 (?z gnus-tmp-score-char ?c)
eec82323
LMI
1338 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1339 (?U gnus-tmp-unread ?c)
23f87bed
MB
1340 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1341 ?s)
eec82323
LMI
1342 (?t (gnus-summary-number-of-articles-in-thread
1343 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1344 ?d)
1345 (?e (gnus-summary-number-of-articles-in-thread
1346 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1347 ?c)
1348 (?u gnus-tmp-user-defined ?s)
23f87bed
MB
1349 (?P (gnus-pick-line-number) ?d)
1350 (?B gnus-tmp-thread-tree-header-string ?s)
1351 (user-date (gnus-user-date
1352 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
16409b0b
GM
1353 "An alist of format specifications that can appear in summary lines.
1354These are paired with what variables they correspond with, along with
1355the type of the variable (string, integer, character, etc).")
eec82323
LMI
1356
1357(defvar gnus-summary-dummy-line-format-alist
1358 `((?S gnus-tmp-subject ?s)
1359 (?N gnus-tmp-number ?d)
1360 (?u gnus-tmp-user-defined ?s)))
1361
1362(defvar gnus-summary-mode-line-format-alist
1363 `((?G gnus-tmp-group-name ?s)
1364 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1365 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1366 (?A gnus-tmp-article-number ?d)
1367 (?Z gnus-tmp-unread-and-unselected ?s)
1368 (?V gnus-version ?s)
1369 (?U gnus-tmp-unread-and-unticked ?d)
1370 (?S gnus-tmp-subject ?s)
1371 (?e gnus-tmp-unselected ?d)
1372 (?u gnus-tmp-user-defined ?s)
1373 (?d (length gnus-newsgroup-dormant) ?d)
1374 (?t (length gnus-newsgroup-marked) ?d)
23f87bed 1375 (?h (length gnus-newsgroup-spam-marked) ?d)
eec82323 1376 (?r (length gnus-newsgroup-reads) ?d)
6748645f 1377 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
eec82323
LMI
1378 (?E gnus-newsgroup-expunged-tally ?d)
1379 (?s (gnus-current-score-file-nondirectory) ?s)))
1380
c1717fbd
GM
1381;; This is here rather than in gnus-art for compilation reasons.
1382(defvar gnus-article-mode-line-format-alist
1383 (nconc '((?w (gnus-article-wash-status) ?s)
1384 (?m (gnus-article-mime-part-status) ?s))
1385 gnus-summary-mode-line-format-alist))
1386
eec82323
LMI
1387(defvar gnus-last-search-regexp nil
1388 "Default regexp for article search command.")
1389
1390(defvar gnus-last-shell-command nil
1391 "Default shell command on article.")
1392
23f87bed
MB
1393(defvar gnus-newsgroup-agentized nil
1394 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
eec82323
LMI
1395(defvar gnus-newsgroup-begin nil)
1396(defvar gnus-newsgroup-end nil)
1397(defvar gnus-newsgroup-last-rmail nil)
1398(defvar gnus-newsgroup-last-mail nil)
1399(defvar gnus-newsgroup-last-folder nil)
1400(defvar gnus-newsgroup-last-file nil)
26c9afc3 1401(defvar gnus-newsgroup-last-directory nil)
eec82323
LMI
1402(defvar gnus-newsgroup-auto-expire nil)
1403(defvar gnus-newsgroup-active nil)
1404
1405(defvar gnus-newsgroup-data nil)
1406(defvar gnus-newsgroup-data-reverse nil)
1407(defvar gnus-newsgroup-limit nil)
1408(defvar gnus-newsgroup-limits nil)
23f87bed 1409(defvar gnus-summary-use-undownloaded-faces nil)
eec82323
LMI
1410
1411(defvar gnus-newsgroup-unreads nil
23f87bed 1412 "Sorted list of unread articles in the current newsgroup.")
eec82323
LMI
1413
1414(defvar gnus-newsgroup-unselected nil
23f87bed 1415 "Sorted list of unselected unread articles in the current newsgroup.")
eec82323
LMI
1416
1417(defvar gnus-newsgroup-reads nil
1418 "Alist of read articles and article marks in the current newsgroup.")
1419
1420(defvar gnus-newsgroup-expunged-tally nil)
1421
1422(defvar gnus-newsgroup-marked nil
23f87bed
MB
1423 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1424
1425(defvar gnus-newsgroup-spam-marked nil
1426 "List of ranges of articles that have been marked as spam.")
eec82323
LMI
1427
1428(defvar gnus-newsgroup-killed nil
1429 "List of ranges of articles that have been through the scoring process.")
1430
1431(defvar gnus-newsgroup-cached nil
23f87bed 1432 "Sorted list of articles that come from the article cache.")
eec82323
LMI
1433
1434(defvar gnus-newsgroup-saved nil
1435 "List of articles that have been saved.")
1436
1437(defvar gnus-newsgroup-kill-headers nil)
1438
1439(defvar gnus-newsgroup-replied nil
1440 "List of articles that have been replied to in the current newsgroup.")
1441
23f87bed
MB
1442(defvar gnus-newsgroup-forwarded nil
1443 "List of articles that have been forwarded in the current newsgroup.")
1444
1445(defvar gnus-newsgroup-recent nil
1446 "List of articles that have are recent in the current newsgroup.")
1447
eec82323 1448(defvar gnus-newsgroup-expirable nil
23f87bed 1449 "Sorted list of articles in the current newsgroup that can be expired.")
eec82323
LMI
1450
1451(defvar gnus-newsgroup-processable nil
1452 "List of articles in the current newsgroup that can be processed.")
1453
6748645f 1454(defvar gnus-newsgroup-downloadable nil
23f87bed
MB
1455 "Sorted list of articles in the current newsgroup that can be processed.")
1456
1457(defvar gnus-newsgroup-unfetched nil
1458 "Sorted list of articles in the current newsgroup whose headers have
1459not been fetched into the agent.
1460
1461This list will always be a subset of gnus-newsgroup-undownloaded.")
6748645f
LMI
1462
1463(defvar gnus-newsgroup-undownloaded nil
23f87bed 1464 "List of articles in the current newsgroup that haven't been downloaded.")
6748645f
LMI
1465
1466(defvar gnus-newsgroup-unsendable nil
1467 "List of articles in the current newsgroup that won't be sent.")
1468
eec82323
LMI
1469(defvar gnus-newsgroup-bookmarks nil
1470 "List of articles in the current newsgroup that have bookmarks.")
1471
1472(defvar gnus-newsgroup-dormant nil
23f87bed
MB
1473 "Sorted list of dormant articles in the current newsgroup.")
1474
1475(defvar gnus-newsgroup-unseen nil
1476 "List of unseen articles in the current newsgroup.")
1477
1478(defvar gnus-newsgroup-seen nil
1479 "Range of seen articles in the current newsgroup.")
1480
1481(defvar gnus-newsgroup-articles nil
1482 "List of articles in the current newsgroup.")
eec82323
LMI
1483
1484(defvar gnus-newsgroup-scored nil
1485 "List of scored articles in the current newsgroup.")
1486
1487(defvar gnus-newsgroup-headers nil
1488 "List of article headers in the current newsgroup.")
1489
1490(defvar gnus-newsgroup-threads nil)
1491
1492(defvar gnus-newsgroup-prepared nil
1493 "Whether the current group has been prepared properly.")
1494
1495(defvar gnus-newsgroup-ancient nil
1496 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1497
1498(defvar gnus-newsgroup-sparse nil)
1499
1500(defvar gnus-current-article nil)
1501(defvar gnus-article-current nil)
1502(defvar gnus-current-headers nil)
1503(defvar gnus-have-all-headers nil)
1504(defvar gnus-last-article nil)
1505(defvar gnus-newsgroup-history nil)
16409b0b
GM
1506(defvar gnus-newsgroup-charset nil)
1507(defvar gnus-newsgroup-ephemeral-charset nil)
1508(defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
eec82323 1509
23f87bed
MB
1510(defvar gnus-article-before-search nil)
1511
1512(defvar gnus-summary-local-variables
eec82323
LMI
1513 '(gnus-newsgroup-name
1514 gnus-newsgroup-begin gnus-newsgroup-end
1515 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1516 gnus-newsgroup-last-folder gnus-newsgroup-last-file
26c9afc3 1517 gnus-newsgroup-last-directory
eec82323
LMI
1518 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1519 gnus-newsgroup-unselected gnus-newsgroup-marked
23f87bed 1520 gnus-newsgroup-spam-marked
eec82323 1521 gnus-newsgroup-reads gnus-newsgroup-saved
23f87bed
MB
1522 gnus-newsgroup-replied gnus-newsgroup-forwarded
1523 gnus-newsgroup-recent
1524 gnus-newsgroup-expirable
eec82323 1525 gnus-newsgroup-processable gnus-newsgroup-killed
6748645f 1526 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
23f87bed
MB
1527 gnus-newsgroup-unfetched
1528 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1529 gnus-newsgroup-seen gnus-newsgroup-articles
eec82323
LMI
1530 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1531 gnus-newsgroup-headers gnus-newsgroup-threads
1532 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1533 gnus-current-article gnus-current-headers gnus-have-all-headers
1534 gnus-last-article gnus-article-internal-prepare-hook
1535 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1536 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1537 gnus-thread-expunge-below
16409b0b
GM
1538 gnus-score-alist gnus-current-score-file
1539 (gnus-summary-expunge-below . global)
eec82323 1540 (gnus-summary-mark-below . global)
16409b0b 1541 (gnus-orphan-score . global)
eec82323
LMI
1542 gnus-newsgroup-active gnus-scores-exclude-files
1543 gnus-newsgroup-history gnus-newsgroup-ancient
1544 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1545 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1546 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1547 (gnus-newsgroup-expunged-tally . 0)
1548 gnus-cache-removable-articles gnus-newsgroup-cached
1549 gnus-newsgroup-data gnus-newsgroup-data-reverse
16409b0b 1550 gnus-newsgroup-limit gnus-newsgroup-limits
23f87bed
MB
1551 gnus-newsgroup-charset gnus-newsgroup-display
1552 gnus-summary-use-undownloaded-faces)
eec82323
LMI
1553 "Variables that are buffer-local to the summary buffers.")
1554
23f87bed
MB
1555(defvar gnus-newsgroup-variables nil
1556 "A list of variables that have separate values in different newsgroups.
1557A list of newsgroup (summary buffer) local variables, or cons of
1558variables and their default expressions to be evalled (when the default
1559values are not nil), that should be made global while the summary buffer
1560is active.
1561
1562Note: The default expressions will be evaluated (using function `eval')
1563before assignment to the local variable rather than just assigned to it.
1564If the default expression is the symbol `global', that symbol will not
1565be evaluated but the global value of the local variable will be used
1566instead.
1567
1568These variables can be used to set variables in the group parameters
1569while still allowing them to affect operations done in other buffers.
1570For example:
1571
1572\(setq gnus-newsgroup-variables
1573 '(message-use-followup-to
1574 (gnus-visible-headers .
1575 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1576")
1577
23f87bed
MB
1578(eval-when-compile
1579 ;; Bind features so that require will believe that gnus-sum has
1580 ;; already been loaded (avoids infinite recursion)
1581 (let ((features (cons 'gnus-sum features)))
23f87bed 1582 (require 'gnus-art)))
eec82323 1583
16409b0b
GM
1584;; MIME stuff.
1585
1586(defvar gnus-decode-encoded-word-methods
1587 '(mail-decode-encoded-word-string)
1588 "List of methods used to decode encoded words.
1589
23f87bed
MB
1590This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1591is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1592\(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
16409b0b
GM
1593whose names match REGEXP.
1594
1595For example:
23f87bed 1596\((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
16409b0b
GM
1597 mail-decode-encoded-word-string
1598 (\"chinese\" . rfc1843-decode-string))")
1599
1600(defvar gnus-decode-encoded-word-methods-cache nil)
1601
1602(defun gnus-multi-decode-encoded-word-string (string)
1603 "Apply the functions from `gnus-encoded-word-methods' that match."
1604 (unless (and gnus-decode-encoded-word-methods-cache
1605 (eq gnus-newsgroup-name
1606 (car gnus-decode-encoded-word-methods-cache)))
1607 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
01c52d31
MB
1608 (dolist (method gnus-decode-encoded-word-methods)
1609 (if (symbolp method)
1610 (nconc gnus-decode-encoded-word-methods-cache (list method))
1611 (if (and gnus-newsgroup-name
1612 (string-match (car method) gnus-newsgroup-name))
1613 (nconc gnus-decode-encoded-word-methods-cache
1614 (list (cdr method)))))))
1615 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1616 (setq string (funcall method string))))
16409b0b 1617
eec82323
LMI
1618;; Subject simplification.
1619
6748645f 1620(defun gnus-simplify-whitespace (str)
16409b0b 1621 "Remove excessive whitespace from STR."
23f87bed
MB
1622 ;; Multiple spaces.
1623 (while (string-match "[ \t][ \t]+" str)
1624 (setq str (concat (substring str 0 (match-beginning 0))
1625 " "
1626 (substring str (match-end 0)))))
1627 ;; Leading spaces.
1628 (when (string-match "^[ \t]+" str)
1629 (setq str (substring str (match-end 0))))
1630 ;; Trailing spaces.
1631 (when (string-match "[ \t]+$" str)
1632 (setq str (substring str 0 (match-beginning 0))))
1633 str)
1634
1635(defun gnus-simplify-all-whitespace (str)
1636 "Remove all whitespace from STR."
1637 (while (string-match "[ \t\n]+" str)
1638 (setq str (replace-match "" nil nil str)))
1639 str)
6748645f 1640
eec82323
LMI
1641(defsubst gnus-simplify-subject-re (subject)
1642 "Remove \"Re:\" from subject lines."
23f87bed 1643 (if (string-match message-subject-re-regexp subject)
eec82323
LMI
1644 (substring subject (match-end 0))
1645 subject))
1646
1647(defun gnus-simplify-subject (subject &optional re-only)
1648 "Remove `Re:' and words in parentheses.
1649If RE-ONLY is non-nil, strip leading `Re:'s only."
1650 (let ((case-fold-search t)) ;Ignore case.
1651 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1652 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1653 (setq subject (substring subject (match-end 0))))
1654 ;; Remove uninteresting prefixes.
1655 (when (and (not re-only)
1656 gnus-simplify-ignored-prefixes
1657 (string-match gnus-simplify-ignored-prefixes subject))
1658 (setq subject (substring subject (match-end 0))))
1659 ;; Remove words in parentheses from end.
1660 (unless re-only
1661 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1662 (setq subject (substring subject 0 (match-beginning 0)))))
1663 ;; Return subject string.
1664 subject))
1665
1666;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1667;; all whitespace.
1668(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1669 (goto-char (point-min))
1670 (while (re-search-forward regexp nil t)
16409b0b 1671 (replace-match (or newtext ""))))
eec82323
LMI
1672
1673(defun gnus-simplify-buffer-fuzzy ()
1674 "Simplify string in the buffer fuzzily.
1675The string in the accessible portion of the current buffer is simplified.
1676It is assumed to be a single-line subject.
1677Whitespace is generally cleaned up, and miscellaneous leading/trailing
1678matter is removed. Additional things can be deleted by setting
16409b0b 1679`gnus-simplify-subject-fuzzy-regexp'."
eec82323
LMI
1680 (let ((case-fold-search t)
1681 (modified-tick))
1682 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1683
1684 (while (not (eq modified-tick (buffer-modified-tick)))
1685 (setq modified-tick (buffer-modified-tick))
1686 (cond
1687 ((listp gnus-simplify-subject-fuzzy-regexp)
01c52d31
MB
1688 (mapc 'gnus-simplify-buffer-fuzzy-step
1689 gnus-simplify-subject-fuzzy-regexp))
eec82323
LMI
1690 (gnus-simplify-subject-fuzzy-regexp
1691 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1692 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1693 (gnus-simplify-buffer-fuzzy-step
1694 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1695 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1696
1697 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1698 (gnus-simplify-buffer-fuzzy-step " +" " ")
1699 (gnus-simplify-buffer-fuzzy-step " $")
1700 (gnus-simplify-buffer-fuzzy-step "^ +")))
1701
1702(defun gnus-simplify-subject-fuzzy (subject)
1703 "Simplify a subject string fuzzily.
6748645f 1704See `gnus-simplify-buffer-fuzzy' for details."
eec82323
LMI
1705 (save-excursion
1706 (gnus-set-work-buffer)
1707 (let ((case-fold-search t))
6748645f
LMI
1708 ;; Remove uninteresting prefixes.
1709 (when (and gnus-simplify-ignored-prefixes
1710 (string-match gnus-simplify-ignored-prefixes subject))
1711 (setq subject (substring subject (match-end 0))))
eec82323
LMI
1712 (insert subject)
1713 (inline (gnus-simplify-buffer-fuzzy))
1714 (buffer-string))))
1715
1716(defsubst gnus-simplify-subject-fully (subject)
23f87bed 1717 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
eec82323 1718 (cond
6748645f
LMI
1719 (gnus-simplify-subject-functions
1720 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1721 ((null gnus-summary-gather-subject-limit)
1722 (gnus-simplify-subject-re subject))
1723 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1724 (gnus-simplify-subject-fuzzy subject))
1725 ((numberp gnus-summary-gather-subject-limit)
01c52d31
MB
1726 (truncate-string-to-width (gnus-simplify-subject-re subject)
1727 gnus-summary-gather-subject-limit))
eec82323
LMI
1728 (t
1729 subject)))
1730
1731(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f 1732 "Check whether two subjects are equal.
23f87bed 1733If optional argument SIMPLE-FIRST is t, first argument is already
6748645f 1734simplified."
eec82323
LMI
1735 (cond
1736 ((null simple-first)
1737 (equal (gnus-simplify-subject-fully s1)
1738 (gnus-simplify-subject-fully s2)))
1739 (t
1740 (equal s1
1741 (gnus-simplify-subject-fully s2)))))
1742
1743(defun gnus-summary-bubble-group ()
1744 "Increase the score of the current group.
1745This is a handy function to add to `gnus-summary-exit-hook' to
1746increase the score of each group you read."
1747 (gnus-group-add-score gnus-newsgroup-name))
1748
1749\f
1750;;;
1751;;; Gnus summary mode
1752;;;
1753
1754(put 'gnus-summary-mode 'mode-class 'special)
1755
1653df0f
SZ
1756(defvar gnus-article-commands-menu)
1757
23f87bed
MB
1758;; Non-orthogonal keys
1759
1760(gnus-define-keys gnus-summary-mode-map
1761 " " gnus-summary-next-page
1762 "\177" gnus-summary-prev-page
1763 [delete] gnus-summary-prev-page
1764 [backspace] gnus-summary-prev-page
1765 "\r" gnus-summary-scroll-up
1766 "\M-\r" gnus-summary-scroll-down
1767 "n" gnus-summary-next-unread-article
1768 "p" gnus-summary-prev-unread-article
1769 "N" gnus-summary-next-article
1770 "P" gnus-summary-prev-article
1771 "\M-\C-n" gnus-summary-next-same-subject
1772 "\M-\C-p" gnus-summary-prev-same-subject
1773 "\M-n" gnus-summary-next-unread-subject
1774 "\M-p" gnus-summary-prev-unread-subject
1775 "." gnus-summary-first-unread-article
1776 "," gnus-summary-best-unread-article
1777 "\M-s" gnus-summary-search-article-forward
1778 "\M-r" gnus-summary-search-article-backward
01c52d31
MB
1779 "\M-S" gnus-summary-repeat-search-article-forward
1780 "\M-R" gnus-summary-repeat-search-article-backward
23f87bed
MB
1781 "<" gnus-summary-beginning-of-article
1782 ">" gnus-summary-end-of-article
1783 "j" gnus-summary-goto-article
1784 "^" gnus-summary-refer-parent-article
1785 "\M-^" gnus-summary-refer-article
1786 "u" gnus-summary-tick-article-forward
1787 "!" gnus-summary-tick-article-forward
1788 "U" gnus-summary-tick-article-backward
1789 "d" gnus-summary-mark-as-read-forward
1790 "D" gnus-summary-mark-as-read-backward
1791 "E" gnus-summary-mark-as-expirable
1792 "\M-u" gnus-summary-clear-mark-forward
1793 "\M-U" gnus-summary-clear-mark-backward
1794 "k" gnus-summary-kill-same-subject-and-select
1795 "\C-k" gnus-summary-kill-same-subject
1796 "\M-\C-k" gnus-summary-kill-thread
1797 "\M-\C-l" gnus-summary-lower-thread
1798 "e" gnus-summary-edit-article
1799 "#" gnus-summary-mark-as-processable
1800 "\M-#" gnus-summary-unmark-as-processable
1801 "\M-\C-t" gnus-summary-toggle-threads
1802 "\M-\C-s" gnus-summary-show-thread
1803 "\M-\C-h" gnus-summary-hide-thread
1804 "\M-\C-f" gnus-summary-next-thread
1805 "\M-\C-b" gnus-summary-prev-thread
1806 [(meta down)] gnus-summary-next-thread
1807 [(meta up)] gnus-summary-prev-thread
1808 "\M-\C-u" gnus-summary-up-thread
1809 "\M-\C-d" gnus-summary-down-thread
1810 "&" gnus-summary-execute-command
1811 "c" gnus-summary-catchup-and-exit
1812 "\C-w" gnus-summary-mark-region-as-read
1813 "\C-t" gnus-summary-toggle-truncation
1814 "?" gnus-summary-mark-as-dormant
1815 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1816 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1817 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1818 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1819 "\C-c\C-s\C-a" gnus-summary-sort-by-author
01c52d31 1820 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
23f87bed
MB
1821 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1822 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1823 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1824 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1825 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1826 "=" gnus-summary-expand-window
1827 "\C-x\C-s" gnus-summary-reselect-current-group
1828 "\M-g" gnus-summary-rescan-group
1829 "w" gnus-summary-stop-page-breaking
1830 "\C-c\C-r" gnus-summary-caesar-message
1831 "f" gnus-summary-followup
1832 "F" gnus-summary-followup-with-original
1833 "C" gnus-summary-cancel-article
1834 "r" gnus-summary-reply
1835 "R" gnus-summary-reply-with-original
1836 "\C-c\C-f" gnus-summary-mail-forward
1837 "o" gnus-summary-save-article
1838 "\C-o" gnus-summary-save-article-mail
1839 "|" gnus-summary-pipe-output
1840 "\M-k" gnus-summary-edit-local-kill
1841 "\M-K" gnus-summary-edit-global-kill
1842 ;; "V" gnus-version
1843 "\C-c\C-d" gnus-summary-describe-group
1844 "q" gnus-summary-exit
1845 "Q" gnus-summary-exit-no-update
1846 "\C-c\C-i" gnus-info-find-node
1847 gnus-mouse-2 gnus-mouse-pick-article
132cf96d 1848 [follow-link] mouse-face
23f87bed
MB
1849 "m" gnus-summary-mail-other-window
1850 "a" gnus-summary-post-news
1851 "i" gnus-summary-news-other-window
1852 "x" gnus-summary-limit-to-unread
1853 "s" gnus-summary-isearch-article
1854 "t" gnus-summary-toggle-header
1855 "g" gnus-summary-show-article
1856 "l" gnus-summary-goto-last-article
1857 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1858 "\C-d" gnus-summary-enter-digest-group
1859 "\M-\C-d" gnus-summary-read-document
1860 "\M-\C-e" gnus-summary-edit-parameters
1861 "\M-\C-a" gnus-summary-customize-parameters
1862 "\C-c\C-b" gnus-bug
1863 "*" gnus-cache-enter-article
1864 "\M-*" gnus-cache-remove-article
1865 "\M-&" gnus-summary-universal-argument
1866 "\C-l" gnus-recenter
1867 "I" gnus-summary-increase-score
1868 "L" gnus-summary-lower-score
1869 "\M-i" gnus-symbolic-argument
1870 "h" gnus-summary-select-article-buffer
1871
1872 "b" gnus-article-view-part
1873 "\M-t" gnus-summary-toggle-display-buttonized
1874
1875 "V" gnus-summary-score-map
1876 "X" gnus-uu-extract-map
1877 "S" gnus-summary-send-map)
1878
1879;; Sort of orthogonal keymap
1880(gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1881 "t" gnus-summary-tick-article-forward
1882 "!" gnus-summary-tick-article-forward
1883 "d" gnus-summary-mark-as-read-forward
1884 "r" gnus-summary-mark-as-read-forward
1885 "c" gnus-summary-clear-mark-forward
1886 " " gnus-summary-clear-mark-forward
1887 "e" gnus-summary-mark-as-expirable
1888 "x" gnus-summary-mark-as-expirable
1889 "?" gnus-summary-mark-as-dormant
1890 "b" gnus-summary-set-bookmark
1891 "B" gnus-summary-remove-bookmark
1892 "#" gnus-summary-mark-as-processable
1893 "\M-#" gnus-summary-unmark-as-processable
1894 "S" gnus-summary-limit-include-expunged
1895 "C" gnus-summary-catchup
1896 "H" gnus-summary-catchup-to-here
1897 "h" gnus-summary-catchup-from-here
1898 "\C-c" gnus-summary-catchup-all
1899 "k" gnus-summary-kill-same-subject-and-select
1900 "K" gnus-summary-kill-same-subject
1901 "P" gnus-uu-mark-map)
1902
1903(gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1904 "c" gnus-summary-clear-above
1905 "u" gnus-summary-tick-above
1906 "m" gnus-summary-mark-above
1907 "k" gnus-summary-kill-below)
1908
1909(gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1910 "/" gnus-summary-limit-to-subject
1911 "n" gnus-summary-limit-to-articles
01c52d31
MB
1912 "b" gnus-summary-limit-to-bodies
1913 "h" gnus-summary-limit-to-headers
23f87bed
MB
1914 "w" gnus-summary-pop-limit
1915 "s" gnus-summary-limit-to-subject
1916 "a" gnus-summary-limit-to-author
1917 "u" gnus-summary-limit-to-unread
1918 "m" gnus-summary-limit-to-marks
1919 "M" gnus-summary-limit-exclude-marks
1920 "v" gnus-summary-limit-to-score
1921 "*" gnus-summary-limit-include-cached
1922 "D" gnus-summary-limit-include-dormant
1923 "T" gnus-summary-limit-include-thread
1924 "d" gnus-summary-limit-exclude-dormant
1925 "t" gnus-summary-limit-to-age
1926 "." gnus-summary-limit-to-unseen
1927 "x" gnus-summary-limit-to-extra
1928 "p" gnus-summary-limit-to-display-predicate
1929 "E" gnus-summary-limit-include-expunged
1930 "c" gnus-summary-limit-exclude-childless-dormant
1931 "C" gnus-summary-limit-mark-excluded-as-read
1932 "o" gnus-summary-insert-old-articles
01c52d31
MB
1933 "N" gnus-summary-insert-new-articles
1934 "S" gnus-summary-limit-to-singletons
1935 "r" gnus-summary-limit-to-replied
1936 "R" gnus-summary-limit-to-recipient
1937 "A" gnus-summary-limit-to-address)
23f87bed
MB
1938
1939(gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1940 "n" gnus-summary-next-unread-article
1941 "p" gnus-summary-prev-unread-article
1942 "N" gnus-summary-next-article
1943 "P" gnus-summary-prev-article
1944 "\C-n" gnus-summary-next-same-subject
1945 "\C-p" gnus-summary-prev-same-subject
1946 "\M-n" gnus-summary-next-unread-subject
1947 "\M-p" gnus-summary-prev-unread-subject
1948 "f" gnus-summary-first-unread-article
1949 "b" gnus-summary-best-unread-article
1950 "j" gnus-summary-goto-article
1951 "g" gnus-summary-goto-subject
1952 "l" gnus-summary-goto-last-article
1953 "o" gnus-summary-pop-article)
1954
1955(gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1956 "k" gnus-summary-kill-thread
01c52d31 1957 "E" gnus-summary-expire-thread
23f87bed
MB
1958 "l" gnus-summary-lower-thread
1959 "i" gnus-summary-raise-thread
1960 "T" gnus-summary-toggle-threads
1961 "t" gnus-summary-rethread-current
1962 "^" gnus-summary-reparent-thread
01c52d31 1963 "\M-^" gnus-summary-reparent-children
23f87bed
MB
1964 "s" gnus-summary-show-thread
1965 "S" gnus-summary-show-all-threads
1966 "h" gnus-summary-hide-thread
1967 "H" gnus-summary-hide-all-threads
1968 "n" gnus-summary-next-thread
1969 "p" gnus-summary-prev-thread
1970 "u" gnus-summary-up-thread
1971 "o" gnus-summary-top-thread
1972 "d" gnus-summary-down-thread
1973 "#" gnus-uu-mark-thread
1974 "\M-#" gnus-uu-unmark-thread)
1975
1976(gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1977 "g" gnus-summary-prepare
1978 "c" gnus-summary-insert-cached-articles
01c52d31
MB
1979 "d" gnus-summary-insert-dormant-articles
1980 "t" gnus-summary-insert-ticked-articles)
23f87bed
MB
1981
1982(gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1983 "c" gnus-summary-catchup-and-exit
1984 "C" gnus-summary-catchup-all-and-exit
1985 "E" gnus-summary-exit-no-update
1986 "Q" gnus-summary-exit
1987 "Z" gnus-summary-exit
1988 "n" gnus-summary-catchup-and-goto-next-group
01c52d31 1989 "p" gnus-summary-catchup-and-goto-prev-group
23f87bed
MB
1990 "R" gnus-summary-reselect-current-group
1991 "G" gnus-summary-rescan-group
1992 "N" gnus-summary-next-group
1993 "s" gnus-summary-save-newsrc
1994 "P" gnus-summary-prev-group)
1995
1996(gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1997 " " gnus-summary-next-page
1998 "n" gnus-summary-next-page
1999 "\177" gnus-summary-prev-page
2000 [delete] gnus-summary-prev-page
2001 "p" gnus-summary-prev-page
2002 "\r" gnus-summary-scroll-up
2003 "\M-\r" gnus-summary-scroll-down
2004 "<" gnus-summary-beginning-of-article
2005 ">" gnus-summary-end-of-article
2006 "b" gnus-summary-beginning-of-article
2007 "e" gnus-summary-end-of-article
2008 "^" gnus-summary-refer-parent-article
2009 "r" gnus-summary-refer-parent-article
2010 "D" gnus-summary-enter-digest-group
2011 "R" gnus-summary-refer-references
2012 "T" gnus-summary-refer-thread
2013 "g" gnus-summary-show-article
2014 "s" gnus-summary-isearch-article
2015 "P" gnus-summary-print-article
01c52d31 2016 "S" gnus-sticky-article
23f87bed
MB
2017 "M" gnus-mailing-list-insinuate
2018 "t" gnus-article-babel)
2019
2020(gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2021 "b" gnus-article-add-buttons
2022 "B" gnus-article-add-buttons-to-head
2023 "o" gnus-article-treat-overstrike
2024 "e" gnus-article-emphasize
2025 "w" gnus-article-fill-cited-article
2026 "Q" gnus-article-fill-long-lines
01c52d31 2027 "L" gnus-article-toggle-truncate-lines
23f87bed
MB
2028 "C" gnus-article-capitalize-sentences
2029 "c" gnus-article-remove-cr
2030 "q" gnus-article-de-quoted-unreadable
2031 "6" gnus-article-de-base64-unreadable
2032 "Z" gnus-article-decode-HZ
01c52d31 2033 "A" gnus-article-treat-ansi-sequences
23f87bed
MB
2034 "h" gnus-article-wash-html
2035 "u" gnus-article-unsplit-urls
2036 "s" gnus-summary-force-verify-and-decrypt
2037 "f" gnus-article-display-x-face
2038 "l" gnus-summary-stop-page-breaking
2039 "r" gnus-summary-caesar-message
2040 "m" gnus-summary-morse-message
2041 "t" gnus-summary-toggle-header
2042 "g" gnus-treat-smiley
2043 "v" gnus-summary-verbose-headers
2044 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2045 "p" gnus-article-verify-x-pgp-sig
01c52d31
MB
2046 "d" gnus-article-treat-dumbquotes
2047 "i" gnus-summary-idna-message)
23f87bed
MB
2048
2049(gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2050 ;; mnemonic: deuglif*Y*
2051 "u" gnus-article-outlook-unwrap-lines
2052 "a" gnus-article-outlook-repair-attribution
2053 "c" gnus-article-outlook-rearrange-citation
2054 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2055
2056(gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2057 "a" gnus-article-hide
2058 "h" gnus-article-hide-headers
2059 "b" gnus-article-hide-boring-headers
2060 "s" gnus-article-hide-signature
2061 "c" gnus-article-hide-citation
2062 "C" gnus-article-hide-citation-in-followups
2063 "l" gnus-article-hide-list-identifiers
2064 "B" gnus-article-strip-banner
2065 "P" gnus-article-hide-pem
2066 "\C-c" gnus-article-hide-citation-maybe)
2067
2068(gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2069 "a" gnus-article-highlight
2070 "h" gnus-article-highlight-headers
2071 "c" gnus-article-highlight-citation
2072 "s" gnus-article-highlight-signature)
2073
2074(gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2075 "f" gnus-article-treat-fold-headers
2076 "u" gnus-article-treat-unfold-headers
2077 "n" gnus-article-treat-fold-newsgroups)
2078
2079(gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2080 "x" gnus-article-display-x-face
2081 "d" gnus-article-display-face
2082 "s" gnus-treat-smiley
2083 "D" gnus-article-remove-images
2084 "f" gnus-treat-from-picon
2085 "m" gnus-treat-mail-picon
2086 "n" gnus-treat-newsgroups-picon)
2087
2088(gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2089 "w" gnus-article-decode-mime-words
2090 "c" gnus-article-decode-charset
2091 "v" gnus-mime-view-all-parts
2092 "b" gnus-article-view-part)
2093
2094(gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2095 "z" gnus-article-date-ut
2096 "u" gnus-article-date-ut
2097 "l" gnus-article-date-local
2098 "p" gnus-article-date-english
2099 "e" gnus-article-date-lapsed
2100 "o" gnus-article-date-original
2101 "i" gnus-article-date-iso8601
2102 "s" gnus-article-date-user)
2103
2104(gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2105 "t" gnus-article-remove-trailing-blank-lines
2106 "l" gnus-article-strip-leading-blank-lines
2107 "m" gnus-article-strip-multiple-blank-lines
2108 "a" gnus-article-strip-blank-lines
2109 "A" gnus-article-strip-all-blank-lines
2110 "s" gnus-article-strip-leading-space
2111 "e" gnus-article-strip-trailing-space
2112 "w" gnus-article-remove-leading-whitespace)
2113
2114(gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2115 "v" gnus-version
2116 "f" gnus-summary-fetch-faq
2117 "d" gnus-summary-describe-group
2118 "h" gnus-summary-describe-briefly
2119 "i" gnus-info-find-node
2120 "c" gnus-group-fetch-charter
2121 "C" gnus-group-fetch-control)
2122
2123(gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2124 "e" gnus-summary-expire-articles
2125 "\M-\C-e" gnus-summary-expire-articles-now
2126 "\177" gnus-summary-delete-article
2127 [delete] gnus-summary-delete-article
2128 [backspace] gnus-summary-delete-article
2129 "m" gnus-summary-move-article
2130 "r" gnus-summary-respool-article
2131 "w" gnus-summary-edit-article
2132 "c" gnus-summary-copy-article
2133 "B" gnus-summary-crosspost-article
2134 "q" gnus-summary-respool-query
2135 "t" gnus-summary-respool-trace
2136 "i" gnus-summary-import-article
2137 "I" gnus-summary-create-article
2138 "p" gnus-summary-article-posted-p)
2139
2140(gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2141 "o" gnus-summary-save-article
2142 "m" gnus-summary-save-article-mail
2143 "F" gnus-summary-write-article-file
2144 "r" gnus-summary-save-article-rmail
2145 "f" gnus-summary-save-article-file
2146 "b" gnus-summary-save-article-body-file
26c9afc3 2147 "B" gnus-summary-write-article-body-file
23f87bed
MB
2148 "h" gnus-summary-save-article-folder
2149 "v" gnus-summary-save-article-vm
2150 "p" gnus-summary-pipe-output
2151 "P" gnus-summary-muttprint
2152 "s" gnus-soup-add-article)
2153
2154(gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2155 "b" gnus-summary-display-buttonized
2156 "m" gnus-summary-repair-multipart
2157 "v" gnus-article-view-part
2158 "o" gnus-article-save-part
01c52d31
MB
2159 "O" gnus-article-save-part-and-strip
2160 "r" gnus-article-replace-part
2161 "d" gnus-article-delete-part
2162 "t" gnus-article-view-part-as-type
2163 "j" gnus-article-jump-to-part
23f87bed
MB
2164 "c" gnus-article-copy-part
2165 "C" gnus-article-view-part-as-charset
2166 "e" gnus-article-view-part-externally
01c52d31 2167 "H" gnus-article-browse-html-article
23f87bed
MB
2168 "E" gnus-article-encrypt-body
2169 "i" gnus-article-inline-part
2170 "|" gnus-article-pipe-part)
2171
2172(gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2173 "p" gnus-summary-mark-as-processable
2174 "u" gnus-summary-unmark-as-processable
2175 "U" gnus-summary-unmark-all-processable
2176 "v" gnus-uu-mark-over
2177 "s" gnus-uu-mark-series
2178 "r" gnus-uu-mark-region
2179 "g" gnus-uu-unmark-region
2180 "R" gnus-uu-mark-by-regexp
2181 "G" gnus-uu-unmark-by-regexp
2182 "t" gnus-uu-mark-thread
2183 "T" gnus-uu-unmark-thread
2184 "a" gnus-uu-mark-all
2185 "b" gnus-uu-mark-buffer
2186 "S" gnus-uu-mark-sparse
2187 "k" gnus-summary-kill-process-mark
2188 "y" gnus-summary-yank-process-mark
2189 "w" gnus-summary-save-process-mark
2190 "i" gnus-uu-invert-processable)
2191
2192(gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2193 ;;"x" gnus-uu-extract-any
2194 "m" gnus-summary-save-parts
2195 "u" gnus-uu-decode-uu
2196 "U" gnus-uu-decode-uu-and-save
2197 "s" gnus-uu-decode-unshar
2198 "S" gnus-uu-decode-unshar-and-save
2199 "o" gnus-uu-decode-save
2200 "O" gnus-uu-decode-save
2201 "b" gnus-uu-decode-binhex
2202 "B" gnus-uu-decode-binhex
b890d447 2203 "Y" gnus-uu-decode-yenc
23f87bed
MB
2204 "p" gnus-uu-decode-postscript
2205 "P" gnus-uu-decode-postscript-and-save)
2206
2207(gnus-define-keys
2208 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2209 "u" gnus-uu-decode-uu-view
2210 "U" gnus-uu-decode-uu-and-save-view
2211 "s" gnus-uu-decode-unshar-view
2212 "S" gnus-uu-decode-unshar-and-save-view
2213 "o" gnus-uu-decode-save-view
2214 "O" gnus-uu-decode-save-view
2215 "b" gnus-uu-decode-binhex-view
2216 "B" gnus-uu-decode-binhex-view
2217 "p" gnus-uu-decode-postscript-view
2218 "P" gnus-uu-decode-postscript-and-save-view)
2219
2220(defvar gnus-article-post-menu nil)
2221
2222(defconst gnus-summary-menu-maxlen 20)
2223
2224(defun gnus-summary-menu-split (menu)
2225 ;; If we have lots of elements, divide them into groups of 20
2226 ;; and make a pane (or submenu) for each one.
2227 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2228 (let ((menu menu) sublists next
2229 (i 1))
2230 (while menu
2231 ;; Pull off the next gnus-summary-menu-maxlen elements
2232 ;; and make them the next element of sublist.
2233 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2234 (if next
2235 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2236 nil))
2237 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2238 (aref (car (last menu)) 0)) menu)
2239 sublists))
2240 (setq i (1+ i))
2241 (setq menu next))
2242 (nreverse sublists))
2243 ;; Few elements--put them all in one pane.
2244 menu))
eec82323
LMI
2245
2246(defun gnus-summary-make-menu-bar ()
2247 (gnus-turn-off-edit-menu 'summary)
2248
2249 (unless (boundp 'gnus-summary-misc-menu)
2250
2251 (easy-menu-define
23f87bed
MB
2252 gnus-summary-kill-menu gnus-summary-mode-map ""
2253 (cons
2254 "Score"
2255 (nconc
2256 (list
2257 ["Customize" gnus-score-customize t])
2258 (gnus-make-score-map 'increase)
2259 (gnus-make-score-map 'lower)
2260 '(("Mark"
2261 ["Kill below" gnus-summary-kill-below t]
2262 ["Mark above" gnus-summary-mark-above t]
2263 ["Tick above" gnus-summary-tick-above t]
2264 ["Clear above" gnus-summary-clear-above t])
2265 ["Current score" gnus-summary-current-score t]
2266 ["Set score" gnus-summary-set-score t]
2267 ["Switch current score file..." gnus-score-change-score-file t]
2268 ["Set mark below..." gnus-score-set-mark-below t]
2269 ["Set expunge below..." gnus-score-set-expunge-below t]
2270 ["Edit current score file" gnus-score-edit-current-scores t]
59429511 2271 ["Edit score file..." gnus-score-edit-file t]
23f87bed
MB
2272 ["Trace score" gnus-score-find-trace t]
2273 ["Find words" gnus-score-find-favourite-words t]
2274 ["Rescore buffer" gnus-summary-rescore t]
2275 ["Increase score..." gnus-summary-increase-score t]
2276 ["Lower score..." gnus-summary-lower-score t]))))
2277
2278 ;; Define both the Article menu in the summary buffer and the
2279 ;; equivalent Commands menu in the article buffer here for
2280 ;; consistency.
6748645f 2281 (let ((innards
23f87bed
MB
2282 `(("Hide"
2283 ["All" gnus-article-hide t]
2284 ["Headers" gnus-article-hide-headers t]
2285 ["Signature" gnus-article-hide-signature t]
2286 ["Citation" gnus-article-hide-citation t]
16409b0b 2287 ["List identifiers" gnus-article-hide-list-identifiers t]
16409b0b 2288 ["Banner" gnus-article-strip-banner t]
23f87bed
MB
2289 ["Boring headers" gnus-article-hide-boring-headers t])
2290 ("Highlight"
2291 ["All" gnus-article-highlight t]
2292 ["Headers" gnus-article-highlight-headers t]
2293 ["Signature" gnus-article-highlight-signature t]
2294 ["Citation" gnus-article-highlight-citation t])
16409b0b
GM
2295 ("MIME"
2296 ["Words" gnus-article-decode-mime-words t]
2297 ["Charset" gnus-article-decode-charset t]
2298 ["QP" gnus-article-de-quoted-unreadable t]
2299 ["Base64" gnus-article-de-base64-unreadable t]
23f87bed
MB
2300 ["View MIME buttons" gnus-summary-display-buttonized t]
2301 ["View all" gnus-mime-view-all-parts t]
2302 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2303 ["Encrypt body" gnus-article-encrypt-body
2304 :active (not (gnus-group-read-only-p))
2305 ,@(if (featurep 'xemacs) nil
2306 '(:help "Encrypt the message body on disk"))]
2307 ["Extract all parts..." gnus-summary-save-parts t]
2308 ("Multipart"
2309 ["Repair multipart" gnus-summary-repair-multipart t]
2310 ["Pipe part..." gnus-article-pipe-part t]
2311 ["Inline part" gnus-article-inline-part t]
01c52d31 2312 ["View part as type..." gnus-article-view-part-as-type t]
23f87bed
MB
2313 ["Encrypt body" gnus-article-encrypt-body
2314 :active (not (gnus-group-read-only-p))
2315 ,@(if (featurep 'xemacs) nil
2316 '(:help "Encrypt the message body on disk"))]
2317 ["View part externally" gnus-article-view-part-externally t]
01c52d31 2318 ["View HTML parts in browser" gnus-article-browse-html-article t]
23f87bed
MB
2319 ["View part with charset..." gnus-article-view-part-as-charset t]
2320 ["Copy part" gnus-article-copy-part t]
2321 ["Save part..." gnus-article-save-part t]
2322 ["View part" gnus-article-view-part t]))
2323 ("Date"
2324 ["Local" gnus-article-date-local t]
2325 ["ISO8601" gnus-article-date-iso8601 t]
2326 ["UT" gnus-article-date-ut t]
2327 ["Original" gnus-article-date-original t]
2328 ["Lapsed" gnus-article-date-lapsed t]
2329 ["User-defined" gnus-article-date-user t])
2330 ("Display"
2331 ["Remove images" gnus-article-remove-images t]
2332 ["Toggle smiley" gnus-treat-smiley t]
2333 ["Show X-Face" gnus-article-display-x-face t]
2334 ["Show picons in From" gnus-treat-from-picon t]
2335 ["Show picons in mail headers" gnus-treat-mail-picon t]
2336 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2337 ("View as different encoding"
2338 ,@(gnus-summary-menu-split
2339 (mapcar
2340 (lambda (cs)
2341 ;; Since easymenu under Emacs doesn't allow
2342 ;; lambda forms for menu commands, we should
2343 ;; provide intern'ed function symbols.
2344 (let ((command (intern (format "\
2345gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2346 (fset command
2347 `(lambda ()
2348 (interactive)
2349 (let ((gnus-summary-show-article-charset-alist
2350 '((1 . ,cs))))
2351 (gnus-summary-show-article 1))))
2352 `[,(symbol-name cs) ,command t]))
2353 (sort (if (fboundp 'coding-system-list)
2354 (coding-system-list)
2355 (mapcar 'car mm-mime-mule-charset-alist))
2356 'string<)))))
2357 ("Washing"
2358 ("Remove Blanks"
2359 ["Leading" gnus-article-strip-leading-blank-lines t]
2360 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2361 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2362 ["All of the above" gnus-article-strip-blank-lines t]
2363 ["All" gnus-article-strip-all-blank-lines t]
2364 ["Leading space" gnus-article-strip-leading-space t]
2365 ["Trailing space" gnus-article-strip-trailing-space t]
2366 ["Leading space in headers"
2367 gnus-article-remove-leading-whitespace t])
2368 ["Overstrike" gnus-article-treat-overstrike t]
2369 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2370 ["Emphasis" gnus-article-emphasize t]
2371 ["Word wrap" gnus-article-fill-cited-article t]
16409b0b 2372 ["Fill long lines" gnus-article-fill-long-lines t]
01c52d31 2373 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
16409b0b 2374 ["Capitalize sentences" gnus-article-capitalize-sentences t]
23f87bed
MB
2375 ["Remove CR" gnus-article-remove-cr t]
2376 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2377 ["Base64" gnus-article-de-base64-unreadable t]
2378 ["Rot 13" gnus-summary-caesar-message
2379 ,@(if (featurep 'xemacs) '(t)
2380 '(:help "\"Caesar rotate\" article by 13"))]
01c52d31 2381 ["De-IDNA" gnus-summary-idna-message t]
23f87bed
MB
2382 ["Morse decode" gnus-summary-morse-message t]
2383 ["Unix pipe..." gnus-summary-pipe-message t]
2384 ["Add buttons" gnus-article-add-buttons t]
2385 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2386 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2387 ["Verbose header" gnus-summary-verbose-headers t]
2388 ["Toggle header" gnus-summary-toggle-header t]
2389 ["Unfold headers" gnus-article-treat-unfold-headers t]
2390 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
16409b0b 2391 ["Html" gnus-article-wash-html t]
23f87bed
MB
2392 ["Unsplit URLs" gnus-article-unsplit-urls t]
2393 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2394 ["Decode HZ" gnus-article-decode-HZ t]
01c52d31 2395 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
23f87bed
MB
2396 ("(Outlook) Deuglify"
2397 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2398 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2399 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2400 ["Full (Outlook) deuglify"
2401 gnus-article-outlook-deuglify-article t])
2402 )
2403 ("Output"
2404 ["Save in default format..." gnus-summary-save-article
2405 ,@(if (featurep 'xemacs) '(t)
2406 '(:help "Save article using default method"))]
2407 ["Save in file..." gnus-summary-save-article-file
2408 ,@(if (featurep 'xemacs) '(t)
2409 '(:help "Save article in file"))]
2410 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2411 ["Save in MH folder..." gnus-summary-save-article-folder t]
2412 ["Save in VM folder..." gnus-summary-save-article-vm t]
2413 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2414 ["Save body in file..." gnus-summary-save-article-body-file t]
2415 ["Pipe through a filter..." gnus-summary-pipe-output t]
2416 ["Add to SOUP packet" gnus-soup-add-article t]
2417 ["Print with Muttprint..." gnus-summary-muttprint t]
531e5812
MB
2418 ["Print" gnus-summary-print-article
2419 ,@(if (featurep 'xemacs) '(t)
2420 '(:help "Generate and print a PostScript image"))])
2421 ("Copy, move,... (Backend)"
707f2b38 2422 ,@(if (featurep 'xemacs) nil
531e5812 2423 '(:help "Copying, moving, expiring articles..."))
23f87bed
MB
2424 ["Respool article..." gnus-summary-respool-article t]
2425 ["Move article..." gnus-summary-move-article
2426 (gnus-check-backend-function
2427 'request-move-article gnus-newsgroup-name)]
2428 ["Copy article..." gnus-summary-copy-article t]
2429 ["Crosspost article..." gnus-summary-crosspost-article
2430 (gnus-check-backend-function
2431 'request-replace-article gnus-newsgroup-name)]
2432 ["Import file..." gnus-summary-import-article
2433 (gnus-check-backend-function
2434 'request-accept-article gnus-newsgroup-name)]
2435 ["Create article..." gnus-summary-create-article
2436 (gnus-check-backend-function
2437 'request-accept-article gnus-newsgroup-name)]
2438 ["Check if posted" gnus-summary-article-posted-p t]
2439 ["Edit article" gnus-summary-edit-article
2440 (not (gnus-group-read-only-p))]
2441 ["Delete article" gnus-summary-delete-article
2442 (gnus-check-backend-function
2443 'request-expire-articles gnus-newsgroup-name)]
2444 ["Query respool" gnus-summary-respool-query t]
6748645f 2445 ["Trace respool" gnus-summary-respool-trace t]
23f87bed
MB
2446 ["Delete expirable articles" gnus-summary-expire-articles-now
2447 (gnus-check-backend-function
2448 'request-expire-articles gnus-newsgroup-name)])
2449 ("Extract"
2450 ["Uudecode" gnus-uu-decode-uu
2451 ,@(if (featurep 'xemacs) '(t)
2452 '(:help "Decode uuencoded article(s)"))]
2453 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2454 ["Unshar" gnus-uu-decode-unshar t]
2455 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2456 ["Save" gnus-uu-decode-save t]
2457 ["Binhex" gnus-uu-decode-binhex t]
2458 ["Postscript" gnus-uu-decode-postscript t]
2459 ["All MIME parts" gnus-summary-save-parts t])
2460 ("Cache"
2461 ["Enter article" gnus-cache-enter-article t]
2462 ["Remove article" gnus-cache-remove-article t])
16409b0b 2463 ["Translate" gnus-article-babel t]
23f87bed 2464 ["Select article buffer" gnus-summary-select-article-buffer t]
01c52d31 2465 ["Make article buffer sticky" gnus-sticky-article t]
23f87bed
MB
2466 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2467 ["Isearch article..." gnus-summary-isearch-article t]
2468 ["Beginning of the article" gnus-summary-beginning-of-article t]
2469 ["End of the article" gnus-summary-end-of-article t]
2470 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2471 ["Fetch referenced articles" gnus-summary-refer-references t]
2472 ["Fetch current thread" gnus-summary-refer-thread t]
2473 ["Fetch article with id..." gnus-summary-refer-article t]
2474 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2475 ["Redisplay" gnus-summary-show-article t]
2476 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
6748645f 2477 (easy-menu-define
23f87bed
MB
2478 gnus-summary-article-menu gnus-summary-mode-map ""
2479 (cons "Article" innards))
6748645f 2480
1653df0f
SZ
2481 (if (not (keymapp gnus-summary-article-menu))
2482 (easy-menu-define
2483 gnus-article-commands-menu gnus-article-mode-map ""
2484 (cons "Commands" innards))
2485 ;; in Emacs, don't share menu.
a1506d29 2486 (setq gnus-article-commands-menu
1653df0f
SZ
2487 (copy-keymap gnus-summary-article-menu))
2488 (define-key gnus-article-mode-map [menu-bar commands]
2489 (cons "Commands" gnus-article-commands-menu))))
eec82323
LMI
2490
2491 (easy-menu-define
23f87bed
MB
2492 gnus-summary-thread-menu gnus-summary-mode-map ""
2493 '("Threads"
2494 ["Find all messages in thread" gnus-summary-refer-thread t]
2495 ["Toggle threading" gnus-summary-toggle-threads t]
2496 ["Hide threads" gnus-summary-hide-all-threads t]
2497 ["Show threads" gnus-summary-show-all-threads t]
2498 ["Hide thread" gnus-summary-hide-thread t]
2499 ["Show thread" gnus-summary-show-thread t]
2500 ["Go to next thread" gnus-summary-next-thread t]
2501 ["Go to previous thread" gnus-summary-prev-thread t]
2502 ["Go down thread" gnus-summary-down-thread t]
2503 ["Go up thread" gnus-summary-up-thread t]
2504 ["Top of thread" gnus-summary-top-thread t]
2505 ["Mark thread as read" gnus-summary-kill-thread t]
01c52d31 2506 ["Mark thread as expired" gnus-summary-expire-thread t]
23f87bed
MB
2507 ["Lower thread score" gnus-summary-lower-thread t]
2508 ["Raise thread score" gnus-summary-raise-thread t]
2509 ["Rethread current" gnus-summary-rethread-current t]))
eec82323
LMI
2510
2511 (easy-menu-define
23f87bed
MB
2512 gnus-summary-post-menu gnus-summary-mode-map ""
2513 `("Post"
2514 ["Send a message (mail or news)" gnus-summary-post-news
2515 ,@(if (featurep 'xemacs) '(t)
531e5812 2516 '(:help "Compose a new message (mail or news)"))]
23f87bed
MB
2517 ["Followup" gnus-summary-followup
2518 ,@(if (featurep 'xemacs) '(t)
2519 '(:help "Post followup to this article"))]
2520 ["Followup and yank" gnus-summary-followup-with-original
2521 ,@(if (featurep 'xemacs) '(t)
2522 '(:help "Post followup to this article, quoting its contents"))]
2523 ["Supersede article" gnus-summary-supersede-article t]
2524 ["Cancel article" gnus-summary-cancel-article
2525 ,@(if (featurep 'xemacs) '(t)
2526 '(:help "Cancel an article you posted"))]
2527 ["Reply" gnus-summary-reply t]
2528 ["Reply and yank" gnus-summary-reply-with-original t]
2529 ["Wide reply" gnus-summary-wide-reply t]
2530 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2531 ,@(if (featurep 'xemacs) '(t)
2532 '(:help "Mail a reply, quoting this article"))]
2533 ["Very wide reply" gnus-summary-very-wide-reply t]
2534 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2535 ,@(if (featurep 'xemacs) '(t)
2536 '(:help "Mail a very wide reply, quoting this article"))]
2537 ["Mail forward" gnus-summary-mail-forward t]
2538 ["Post forward" gnus-summary-post-forward t]
2539 ["Digest and mail" gnus-uu-digest-mail-forward t]
2540 ["Digest and post" gnus-uu-digest-post-forward t]
2541 ["Resend message" gnus-summary-resend-message t]
2542 ["Resend message edit" gnus-summary-resend-message-edit t]
2543 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2544 ["Send a mail" gnus-summary-mail-other-window t]
2545 ["Create a local message" gnus-summary-news-other-window t]
2546 ["Uuencode and post" gnus-uu-post-news
2547 ,@(if (featurep 'xemacs) '(t)
2548 '(:help "Post a uuencoded article"))]
2549 ["Followup via news" gnus-summary-followup-to-mail t]
2550 ["Followup via news and yank"
2551 gnus-summary-followup-to-mail-with-original t]
9b3ebcb6
MB
2552 ["Strip signature on reply"
2553 (lambda ()
2554 (interactive)
2555 (if (not (memq message-cite-function
2556 '(message-cite-original-without-signature
2557 message-cite-original)))
2558 ;; Stupid workaround for XEmacs not honoring :visible.
2559 (message "Can't toggle this value of `message-cite-function'")
2560 (setq message-cite-function
2561 (if (eq message-cite-function
2562 'message-cite-original-without-signature)
2563 'message-cite-original
2564 'message-cite-original-without-signature))))
2565 ;; XEmacs barfs on :visible.
2566 ,@(if (featurep 'xemacs) nil
2567 '(:visible (memq message-cite-function
2568 '(message-cite-original-without-signature
2569 message-cite-original))))
2570 :style toggle
2571 :selected (eq message-cite-function
2572 'message-cite-original-without-signature)
2573 ,@(if (featurep 'xemacs) nil
2574 '(:help "Strip signature from cited article when replying."))]
23f87bed
MB
2575 ;;("Draft"
2576 ;;["Send" gnus-summary-send-draft t]
2577 ;;["Send bounced" gnus-resend-bounced-mail t])
2578 ))
2579
2580 (cond
2581 ((not (keymapp gnus-summary-post-menu))
2582 (setq gnus-article-post-menu gnus-summary-post-menu))
2583 ((not gnus-article-post-menu)
2584 ;; Don't share post menu.
2585 (setq gnus-article-post-menu
2586 (copy-keymap gnus-summary-post-menu))))
2587 (define-key gnus-article-mode-map [menu-bar post]
2588 (cons "Post" gnus-article-post-menu))
eec82323
LMI
2589
2590 (easy-menu-define
23f87bed
MB
2591 gnus-summary-misc-menu gnus-summary-mode-map ""
2592 `("Gnus"
2593 ("Mark Read"
2594 ["Mark as read" gnus-summary-mark-as-read-forward t]
2595 ["Mark same subject and select"
2596 gnus-summary-kill-same-subject-and-select t]
2597 ["Mark same subject" gnus-summary-kill-same-subject t]
2598 ["Catchup" gnus-summary-catchup
2599 ,@(if (featurep 'xemacs) '(t)
2600 '(:help "Mark unread articles in this group as read"))]
2601 ["Catchup all" gnus-summary-catchup-all t]
2602 ["Catchup to here" gnus-summary-catchup-to-here t]
2603 ["Catchup from here" gnus-summary-catchup-from-here t]
2604 ["Catchup region" gnus-summary-mark-region-as-read
2605 (gnus-mark-active-p)]
2606 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2607 ("Mark Various"
2608 ["Tick" gnus-summary-tick-article-forward t]
2609 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2610 ["Remove marks" gnus-summary-clear-mark-forward t]
2611 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2612 ["Set bookmark" gnus-summary-set-bookmark t]
2613 ["Remove bookmark" gnus-summary-remove-bookmark t])
8f7abae3
MB
2614 ("Registry Mark"
2615 ["Important" gnus-registry-set-article-Important-mark t]
2616 ["Not Important" gnus-registry-remove-article-Important-mark t]
2617 ["Work" gnus-registry-set-article-Work-mark t]
2618 ["Not Work" gnus-registry-remove-article-Work-mark t]
2619 ["Later" gnus-registry-set-article-Later-mark t]
2620 ["Not Later" gnus-registry-remove-article-Later-mark t]
2621 ["Personal" gnus-registry-set-article-Personal-mark t]
2622 ["Not Personal" gnus-registry-remove-article-Personal-mark t]
2623 ["To Do" gnus-registry-set-article-To-Do-mark t]
2624 ["Not To Do" gnus-registry-remove-article-To-Do-mark t])
23f87bed
MB
2625 ("Limit to"
2626 ["Marks..." gnus-summary-limit-to-marks t]
2627 ["Subject..." gnus-summary-limit-to-subject t]
2628 ["Author..." gnus-summary-limit-to-author t]
01c52d31
MB
2629 ["Recipient..." gnus-summary-limit-to-recipient t]
2630 ["Address..." gnus-summary-limit-to-address t]
23f87bed
MB
2631 ["Age..." gnus-summary-limit-to-age t]
2632 ["Extra..." gnus-summary-limit-to-extra t]
2633 ["Score..." gnus-summary-limit-to-score t]
2634 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2635 ["Unread" gnus-summary-limit-to-unread t]
2636 ["Unseen" gnus-summary-limit-to-unseen t]
01c52d31
MB
2637 ["Singletons" gnus-summary-limit-to-singletons t]
2638 ["Replied" gnus-summary-limit-to-replied t]
23f87bed 2639 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
996aa8c1 2640 ["Next or process marked articles" gnus-summary-limit-to-articles t]
23f87bed
MB
2641 ["Pop limit" gnus-summary-pop-limit t]
2642 ["Show dormant" gnus-summary-limit-include-dormant t]
2643 ["Hide childless dormant"
2644 gnus-summary-limit-exclude-childless-dormant t]
2645 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2646 ["Hide marked" gnus-summary-limit-exclude-marks t]
2647 ["Show expunged" gnus-summary-limit-include-expunged t])
2648 ("Process Mark"
2649 ["Set mark" gnus-summary-mark-as-processable t]
2650 ["Remove mark" gnus-summary-unmark-as-processable t]
2651 ["Remove all marks" gnus-summary-unmark-all-processable t]
01c52d31 2652 ["Invert marks" gnus-uu-invert-processable t]
23f87bed
MB
2653 ["Mark above" gnus-uu-mark-over t]
2654 ["Mark series" gnus-uu-mark-series t]
2655 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2656 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2657 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2658 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2659 ["Mark all" gnus-uu-mark-all t]
2660 ["Mark buffer" gnus-uu-mark-buffer t]
2661 ["Mark sparse" gnus-uu-mark-sparse t]
2662 ["Mark thread" gnus-uu-mark-thread t]
2663 ["Unmark thread" gnus-uu-unmark-thread t]
2664 ("Process Mark Sets"
2665 ["Kill" gnus-summary-kill-process-mark t]
2666 ["Yank" gnus-summary-yank-process-mark
2667 gnus-newsgroup-process-stack]
2668 ["Save" gnus-summary-save-process-mark t]
2669 ["Run command on marked..." gnus-summary-universal-argument t]))
2670 ("Scroll article"
2671 ["Page forward" gnus-summary-next-page
2672 ,@(if (featurep 'xemacs) '(t)
2673 '(:help "Show next page of article"))]
2674 ["Page backward" gnus-summary-prev-page
2675 ,@(if (featurep 'xemacs) '(t)
2676 '(:help "Show previous page of article"))]
2677 ["Line forward" gnus-summary-scroll-up t])
2678 ("Move"
2679 ["Next unread article" gnus-summary-next-unread-article t]
2680 ["Previous unread article" gnus-summary-prev-unread-article t]
2681 ["Next article" gnus-summary-next-article t]
2682 ["Previous article" gnus-summary-prev-article t]
2683 ["Next unread subject" gnus-summary-next-unread-subject t]
2684 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2685 ["Next article same subject" gnus-summary-next-same-subject t]
2686 ["Previous article same subject" gnus-summary-prev-same-subject t]
2687 ["First unread article" gnus-summary-first-unread-article t]
2688 ["Best unread article" gnus-summary-best-unread-article t]
2689 ["Go to subject number..." gnus-summary-goto-subject t]
2690 ["Go to article number..." gnus-summary-goto-article t]
2691 ["Go to the last article" gnus-summary-goto-last-article t]
2692 ["Pop article off history" gnus-summary-pop-article t])
2693 ("Sort"
2694 ["Sort by number" gnus-summary-sort-by-number t]
2695 ["Sort by author" gnus-summary-sort-by-author t]
01c52d31 2696 ["Sort by recipient" gnus-summary-sort-by-recipient t]
23f87bed
MB
2697 ["Sort by subject" gnus-summary-sort-by-subject t]
2698 ["Sort by date" gnus-summary-sort-by-date t]
2699 ["Sort by score" gnus-summary-sort-by-score t]
2700 ["Sort by lines" gnus-summary-sort-by-lines t]
2701 ["Sort by characters" gnus-summary-sort-by-chars t]
2702 ["Randomize" gnus-summary-sort-by-random t]
2703 ["Original sort" gnus-summary-sort-by-original t])
2704 ("Help"
2705 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2706 ["Describe group" gnus-summary-describe-group t]
2707 ["Fetch charter" gnus-group-fetch-charter
2708 ,@(if (featurep 'xemacs) nil
2709 '(:help "Display the charter of the current group"))]
2710 ["Fetch control message" gnus-group-fetch-control
2711 ,@(if (featurep 'xemacs) nil
2712 '(:help "Display the archived control message for the current group"))]
2713 ["Read manual" gnus-info-find-node t])
2714 ("Modes"
2715 ["Pick and read" gnus-pick-mode t]
2716 ["Binary" gnus-binary-mode t])
2717 ("Regeneration"
2718 ["Regenerate" gnus-summary-prepare t]
2719 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2720 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
01c52d31 2721 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
23f87bed
MB
2722 ["Toggle threading" gnus-summary-toggle-threads t])
2723 ["See old articles" gnus-summary-insert-old-articles t]
2724 ["See new articles" gnus-summary-insert-new-articles t]
2725 ["Filter articles..." gnus-summary-execute-command t]
2726 ["Run command on articles..." gnus-summary-universal-argument t]
2727 ["Search articles forward..." gnus-summary-search-article-forward t]
2728 ["Search articles backward..." gnus-summary-search-article-backward t]
2729 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2730 ["Expand window" gnus-summary-expand-window t]
2731 ["Expire expirable articles" gnus-summary-expire-articles
2732 (gnus-check-backend-function
2733 'request-expire-articles gnus-newsgroup-name)]
2734 ["Edit local kill file" gnus-summary-edit-local-kill t]
2735 ["Edit main kill file" gnus-summary-edit-global-kill t]
2736 ["Edit group parameters" gnus-summary-edit-parameters t]
2737 ["Customize group parameters" gnus-summary-customize-parameters t]
2738 ["Send a bug report" gnus-bug t]
2739 ("Exit"
2740 ["Catchup and exit" gnus-summary-catchup-and-exit
2741 ,@(if (featurep 'xemacs) '(t)
2742 '(:help "Mark unread articles in this group as read, then exit"))]
2743 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2744 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
01c52d31 2745 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
23f87bed
MB
2746 ["Exit group" gnus-summary-exit
2747 ,@(if (featurep 'xemacs) '(t)
2748 '(:help "Exit current group, return to group selection mode"))]
2749 ["Exit group without updating" gnus-summary-exit-no-update t]
2750 ["Exit and goto next group" gnus-summary-next-group t]
2751 ["Exit and goto prev group" gnus-summary-prev-group t]
2752 ["Reselect group" gnus-summary-reselect-current-group t]
2753 ["Rescan group" gnus-summary-rescan-group t]
2754 ["Update dribble" gnus-summary-save-newsrc t])))
eec82323 2755
6748645f 2756 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323 2757
60bd5589
DL
2758(defvar gnus-summary-tool-bar-map nil)
2759
18c06a99
RS
2760;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2761;; affect _new_ message buffers. We might add a function that walks thru all
2762;; summary-mode buffers and force the update.
2763(defun gnus-summary-tool-bar-update (&optional symbol value)
2764 "Update summary mode toolbar.
2765Setter function for custom variables."
2766 (setq-default gnus-summary-tool-bar-map nil)
2767 (when symbol
2768 ;; When used as ":set" function:
2769 (set-default symbol value))
2770 (when (gnus-buffer-live-p gnus-summary-buffer)
2771 (with-current-buffer gnus-summary-buffer
2772 (gnus-summary-make-tool-bar))))
2773
2774(defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2775 'gnus-summary-tool-bar-gnome
2776 'gnus-summary-tool-bar-retro)
2777 "Specifies the Gnus summary tool bar.
2778
2779It can be either a list or a symbol refering to a list. See
2780`gmm-tool-bar-from-list' for the format of the list. The
2781default key map is `gnus-summary-mode-map'.
2782
2783Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2784`gnus-summary-tool-bar-retro'."
2785 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2786 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2787 (repeat :tag "User defined list" gmm-tool-bar-item)
2788 (symbol))
330f707b 2789 :version "23.1" ;; No Gnus
18c06a99
RS
2790 :initialize 'custom-initialize-default
2791 :set 'gnus-summary-tool-bar-update
2792 :group 'gnus-summary)
2793
2794(defcustom gnus-summary-tool-bar-gnome
2795 '((gnus-summary-post-news "mail/compose" nil)
2796 (gnus-summary-insert-new-articles "mail/inbox" nil
2797 :visible (or (not gnus-agent)
2798 gnus-plugged))
2799 (gnus-summary-reply-with-original "mail/reply")
2800 (gnus-summary-reply "mail/reply" nil :visible nil)
2801 (gnus-summary-followup-with-original "mail/reply-all")
2802 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2803 (gnus-summary-mail-forward "mail/forward")
2804 (gnus-summary-save-article "mail/save")
2805 (gnus-summary-search-article-forward "search" nil :visible nil)
2806 (gnus-summary-print-article "print")
2807 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2808 ;; Some new commands that may need more suitable icons:
2809 (gnus-summary-save-newsrc "save" nil :visible nil)
2810 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2811 (gnus-summary-prev-article "left-arrow")
2812 (gnus-summary-next-article "right-arrow")
2813 (gnus-summary-next-page "next-page")
2814 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2815 ;;
2816 ;; Maybe some sort-by-... could be added:
2817 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2818 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2819 (gnus-summary-mark-as-expirable
2820 "delete" nil
2821 :visible (gnus-check-backend-function 'request-expire-articles
2822 gnus-newsgroup-name))
2823 (gnus-summary-mark-as-spam
2824 "mail/spam" t
2825 :visible (and (fboundp 'spam-group-ham-contents-p)
2826 (spam-group-ham-contents-p gnus-newsgroup-name))
2827 :help "Mark as spam")
2828 (gnus-summary-mark-as-read-forward
2829 "mail/not-spam" nil
2830 :visible (and (fboundp 'spam-group-spam-contents-p)
2831 (spam-group-spam-contents-p gnus-newsgroup-name)))
2832 ;;
2833 (gnus-summary-exit "exit")
2834 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2835 (gnus-info-find-node "help"))
2836 "List of functions for the summary tool bar (GNOME style).
2837
2838See `gmm-tool-bar-from-list' for the format of the list."
2839 :type '(repeat gmm-tool-bar-item)
330f707b 2840 :version "23.1" ;; No Gnus
18c06a99
RS
2841 :initialize 'custom-initialize-default
2842 :set 'gnus-summary-tool-bar-update
2843 :group 'gnus-summary)
2844
2845(defcustom gnus-summary-tool-bar-retro
2846 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2847 (gnus-summary-next-unread-article "gnus/next-ur")
2848 (gnus-summary-post-news "gnus/post")
2849 (gnus-summary-followup-with-original "gnus/fuwo")
2850 (gnus-summary-followup "gnus/followup")
2851 (gnus-summary-reply-with-original "gnus/reply-wo")
2852 (gnus-summary-reply "gnus/reply")
2853 (gnus-summary-caesar-message "gnus/rot13")
2854 (gnus-uu-decode-uu "gnus/uu-decode")
2855 (gnus-summary-save-article-file "gnus/save-aif")
2856 (gnus-summary-save-article "gnus/save-art")
2857 (gnus-uu-post-news "gnus/uu-post")
2858 (gnus-summary-catchup "gnus/catchup")
2859 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2860 (gnus-summary-exit "gnus/exit-summ")
2861 ;; Some new command that may need more suitable icons:
2862 (gnus-summary-print-article "gnus/print" nil :visible nil)
2863 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2864 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2865 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2866 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2867 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2868 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2869 ;;
2870 (gnus-info-find-node "gnus/help" nil :visible nil))
2871 "List of functions for the summary tool bar (retro look).
2872
2873See `gmm-tool-bar-from-list' for the format of the list."
2874 :type '(repeat gmm-tool-bar-item)
330f707b 2875 :version "23.1" ;; No Gnus
18c06a99
RS
2876 :initialize 'custom-initialize-default
2877 :set 'gnus-summary-tool-bar-update
2878 :group 'gnus-summary)
2879
2880(defcustom gnus-summary-tool-bar-zap-list t
2881 "List of icon items from the global tool bar.
2882These items are not displayed in the Gnus summary mode tool bar.
2883
2884See `gmm-tool-bar-from-list' for the format of the list."
2885 :type 'gmm-tool-bar-zap-list
330f707b 2886 :version "23.1" ;; No Gnus
18c06a99
RS
2887 :initialize 'custom-initialize-default
2888 :set 'gnus-summary-tool-bar-update
2889 :group 'gnus-summary)
2890
2891(defvar image-load-path)
2892
2893(defun gnus-summary-make-tool-bar (&optional force)
2894 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2895When FORCE, rebuild the tool bar."
2896 (when (and (not (featurep 'xemacs))
2897 (boundp 'tool-bar-mode)
2898 tool-bar-mode
2899 (or (not gnus-summary-tool-bar-map) force))
2900 (let* ((load-path
2901 (gmm-image-load-path-for-library "gnus"
2902 "mail/save.xpm"
2903 nil t))
2904 (image-load-path (cons (car load-path)
2905 (when (boundp 'image-load-path)
2906 image-load-path)))
2907 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2908 gnus-summary-tool-bar-zap-list
2909 'gnus-summary-mode-map)))
2910 (when map
2911 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2912 ;; uses it's value.
2913 (setq gnus-summary-tool-bar-map map))))
2914 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
60bd5589 2915
eec82323
LMI
2916(defun gnus-score-set-default (var value)
2917 "A version of set that updates the GNU Emacs menu-bar."
2918 (set var value)
2919 ;; It is the message that forces the active status to be updated.
2920 (message ""))
2921
2922(defun gnus-make-score-map (type)
2923 "Make a summary score map of type TYPE."
2924 (if t
2925 nil
2926 (let ((headers '(("author" "from" string)
2927 ("subject" "subject" string)
2928 ("article body" "body" string)
2929 ("article head" "head" string)
2930 ("xref" "xref" string)
16409b0b 2931 ("extra header" "extra" string)
eec82323
LMI
2932 ("lines" "lines" number)
2933 ("followups to author" "followup" string)))
2934 (types '((number ("less than" <)
2935 ("greater than" >)
2936 ("equal" =))
2937 (string ("substring" s)
2938 ("exact string" e)
2939 ("fuzzy string" f)
2940 ("regexp" r))))
2941 (perms '(("temporary" (current-time-string))
2942 ("permanent" nil)
2943 ("immediate" now)))
2944 header)
2945 (list
2946 (apply
2947 'nconc
2948 (list
2949 (if (eq type 'lower)
2950 "Lower score"
2951 "Increase score"))
2952 (let (outh)
2953 (while headers
2954 (setq header (car headers))
2955 (setq outh
2956 (cons
2957 (apply
2958 'nconc
2959 (list (car header))
2960 (let ((ts (cdr (assoc (nth 2 header) types)))
2961 outt)
2962 (while ts
2963 (setq outt
2964 (cons
2965 (apply
2966 'nconc
2967 (list (caar ts))
2968 (let ((ps perms)
2969 outp)
2970 (while ps
2971 (setq outp
2972 (cons
2973 (vector
2974 (caar ps)
2975 (list
2976 'gnus-summary-score-entry
2977 (nth 1 header)
2978 (if (or (string= (nth 1 header)
2979 "head")
2980 (string= (nth 1 header)
2981 "body"))
2982 ""
2983 (list 'gnus-summary-header
2984 (nth 1 header)))
2985 (list 'quote (nth 1 (car ts)))
16409b0b
GM
2986 (list 'gnus-score-delta-default
2987 nil)
eec82323
LMI
2988 (nth 1 (car ps))
2989 t)
2990 t)
2991 outp))
2992 (setq ps (cdr ps)))
2993 (list (nreverse outp))))
2994 outt))
2995 (setq ts (cdr ts)))
2996 (list (nreverse outt))))
2997 outh))
2998 (setq headers (cdr headers)))
2999 (list (nreverse outh))))))))
3000
704f1663
GM
3001
3002(declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3003
eec82323
LMI
3004\f
3005
3006(defun gnus-summary-mode (&optional group)
3007 "Major mode for reading articles.
3008
3009All normal editing commands are switched off.
3010\\<gnus-summary-mode-map>
3011Each line in this buffer represents one article. To read an
3012article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3013and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3014respectively.
3015
3016You can also post articles and send mail from this buffer. To
23f87bed 3017follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
eec82323
LMI
3018of an article, type `\\[gnus-summary-reply]'.
3019
3020There are approx. one gazillion commands you can execute in this
3021buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3022
3023The following commands are available:
3024
3025\\{gnus-summary-mode-map}"
3026 (interactive)
eec82323 3027 (kill-all-local-variables)
01c52d31
MB
3028 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3029 (gnus-summary-make-local-variables))
3030 (gnus-summary-make-local-variables)
3031 (setq gnus-newsgroup-name group)
60bd5589
DL
3032 (when (gnus-visual-p 'summary-menu 'menu)
3033 (gnus-summary-make-menu-bar)
3034 (gnus-summary-make-tool-bar))
eec82323
LMI
3035 (gnus-make-thread-indent-array)
3036 (gnus-simplify-mode-line)
3037 (setq major-mode 'gnus-summary-mode)
3038 (setq mode-name "Summary")
3039 (make-local-variable 'minor-mode-alist)
3040 (use-local-map gnus-summary-mode-map)
16409b0b 3041 (buffer-disable-undo)
01c52d31
MB
3042 (setq buffer-read-only t ;Disable modification
3043 show-trailing-whitespace nil)
eec82323
LMI
3044 (setq truncate-lines t)
3045 (setq selective-display t)
3046 (setq selective-display-ellipses t) ;Display `...'
3047 (gnus-summary-set-display-table)
3048 (gnus-set-default-directory)
eec82323
LMI
3049 (make-local-variable 'gnus-summary-line-format)
3050 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
3051 (make-local-variable 'gnus-summary-dummy-line-format)
3052 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323 3053 (make-local-variable 'gnus-summary-mark-positions)
23f87bed 3054 (gnus-make-local-hook 'pre-command-hook)
6748645f 3055 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
cfcd5c91 3056 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
23f87bed 3057 (turn-on-gnus-mailing-list-mode)
87545352 3058 (mm-enable-multibyte)
eec82323
LMI
3059 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3060 (gnus-update-summary-mark-positions))
3061
3062(defun gnus-summary-make-local-variables ()
3063 "Make all the local summary buffer variables."
16409b0b
GM
3064 (let (global)
3065 (dolist (local gnus-summary-local-variables)
eec82323
LMI
3066 (if (consp local)
3067 (progn
3068 (if (eq (cdr local) 'global)
3069 ;; Copy the global value of the variable.
3070 (setq global (symbol-value (car local)))
3071 ;; Use the value from the list.
3072 (setq global (eval (cdr local))))
16409b0b 3073 (set (make-local-variable (car local)) global))
eec82323 3074 ;; Simple nil-valued local variable.
16409b0b 3075 (set (make-local-variable local) nil)))))
eec82323
LMI
3076
3077(defun gnus-summary-clear-local-variables ()
3078 (let ((locals gnus-summary-local-variables))
3079 (while locals
3080 (if (consp (car locals))
01c52d31 3081 (and (symbolp (caar locals))
eec82323 3082 (set (caar locals) nil))
01c52d31 3083 (and (symbolp (car locals))
eec82323
LMI
3084 (set (car locals) nil)))
3085 (setq locals (cdr locals)))))
3086
3087;; Summary data functions.
3088
3089(defmacro gnus-data-number (data)
3090 `(car ,data))
3091
3092(defmacro gnus-data-set-number (data number)
3093 `(setcar ,data ,number))
3094
3095(defmacro gnus-data-mark (data)
3096 `(nth 1 ,data))
3097
3098(defmacro gnus-data-set-mark (data mark)
3099 `(setcar (nthcdr 1 ,data) ,mark))
3100
3101(defmacro gnus-data-pos (data)
3102 `(nth 2 ,data))
3103
3104(defmacro gnus-data-set-pos (data pos)
3105 `(setcar (nthcdr 2 ,data) ,pos))
3106
3107(defmacro gnus-data-header (data)
3108 `(nth 3 ,data))
3109
3110(defmacro gnus-data-set-header (data header)
3111 `(setf (nth 3 ,data) ,header))
3112
3113(defmacro gnus-data-level (data)
3114 `(nth 4 ,data))
3115
3116(defmacro gnus-data-unread-p (data)
3117 `(= (nth 1 ,data) gnus-unread-mark))
3118
3119(defmacro gnus-data-read-p (data)
3120 `(/= (nth 1 ,data) gnus-unread-mark))
3121
3122(defmacro gnus-data-pseudo-p (data)
3123 `(consp (nth 3 ,data)))
3124
3125(defmacro gnus-data-find (number)
3126 `(assq ,number gnus-newsgroup-data))
3127
3128(defmacro gnus-data-find-list (number &optional data)
3129 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3130 (memq (assq ,number bdata)
3131 bdata)))
3132
3133(defmacro gnus-data-make (number mark pos header level)
3134 `(list ,number ,mark ,pos ,header ,level))
3135
3136(defun gnus-data-enter (after-article number mark pos header level offset)
3137 (let ((data (gnus-data-find-list after-article)))
3138 (unless data
3139 (error "No such article: %d" after-article))
3140 (setcdr data (cons (gnus-data-make number mark pos header level)
3141 (cdr data)))
3142 (setq gnus-newsgroup-data-reverse nil)
3143 (gnus-data-update-list (cddr data) offset)))
3144
3145(defun gnus-data-enter-list (after-article list &optional offset)
3146 (when list
3147 (let ((data (and after-article (gnus-data-find-list after-article)))
3148 (ilist list))
6748645f
LMI
3149 (if (not (or data
3150 after-article))
3151 (let ((odata gnus-newsgroup-data))
3152 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 3153 (when offset
6748645f 3154 (gnus-data-update-list odata offset)))
01c52d31 3155 ;; Find the last element in the list to be spliced into the main
6748645f 3156 ;; list.
01c52d31 3157 (setq list (last list))
6748645f
LMI
3158 (if (not data)
3159 (progn
3160 (setcdr list gnus-newsgroup-data)
3161 (setq gnus-newsgroup-data ilist)
3162 (when offset
3163 (gnus-data-update-list (cdr list) offset)))
3164 (setcdr list (cdr data))
3165 (setcdr data ilist)
3166 (when offset
3167 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
3168 (setq gnus-newsgroup-data-reverse nil))))
3169
3170(defun gnus-data-remove (article &optional offset)
3171 (let ((data gnus-newsgroup-data))
3172 (if (= (gnus-data-number (car data)) article)
3173 (progn
3174 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3175 gnus-newsgroup-data-reverse nil)
3176 (when offset
3177 (gnus-data-update-list gnus-newsgroup-data offset)))
3178 (while (cdr data)
3179 (when (= (gnus-data-number (cadr data)) article)
3180 (setcdr data (cddr data))
3181 (when offset
3182 (gnus-data-update-list (cdr data) offset))
3183 (setq data nil
3184 gnus-newsgroup-data-reverse nil))
3185 (setq data (cdr data))))))
3186
3187(defmacro gnus-data-list (backward)
3188 `(if ,backward
3189 (or gnus-newsgroup-data-reverse
3190 (setq gnus-newsgroup-data-reverse
3191 (reverse gnus-newsgroup-data)))
3192 gnus-newsgroup-data))
3193
3194(defun gnus-data-update-list (data offset)
3195 "Add OFFSET to the POS of all data entries in DATA."
6748645f 3196 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
3197 (while data
3198 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3199 (setq data (cdr data))))
3200
eec82323
LMI
3201(defun gnus-summary-article-pseudo-p (article)
3202 "Say whether this article is a pseudo article or not."
3203 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3204
3205(defmacro gnus-summary-article-sparse-p (article)
3206 "Say whether this article is a sparse article or not."
a8151ef7 3207 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
3208
3209(defmacro gnus-summary-article-ancient-p (article)
3210 "Say whether this article is a sparse article or not."
3211 `(memq ,article gnus-newsgroup-ancient))
3212
3213(defun gnus-article-parent-p (number)
3214 "Say whether this article is a parent or not."
3215 (let ((data (gnus-data-find-list number)))
23f87bed 3216 (and (cdr data) ; There has to be an article after...
eec82323
LMI
3217 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3218 (gnus-data-level (nth 1 data))))))
3219
3220(defun gnus-article-children (number)
3221 "Return a list of all children to NUMBER."
3222 (let* ((data (gnus-data-find-list number))
3223 (level (gnus-data-level (car data)))
3224 children)
3225 (setq data (cdr data))
3226 (while (and data
3227 (= (gnus-data-level (car data)) (1+ level)))
3228 (push (gnus-data-number (car data)) children)
3229 (setq data (cdr data)))
3230 children))
3231
3232(defmacro gnus-summary-skip-intangible ()
3233 "If the current article is intangible, then jump to a different article."
3234 '(let ((to (get-text-property (point) 'gnus-intangible)))
3235 (and to (gnus-summary-goto-subject to))))
3236
3237(defmacro gnus-summary-article-intangible-p ()
3238 "Say whether this article is intangible or not."
3239 '(get-text-property (point) 'gnus-intangible))
3240
3241(defun gnus-article-read-p (article)
3242 "Say whether ARTICLE is read or not."
3243 (not (or (memq article gnus-newsgroup-marked)
23f87bed 3244 (memq article gnus-newsgroup-spam-marked)
eec82323
LMI
3245 (memq article gnus-newsgroup-unreads)
3246 (memq article gnus-newsgroup-unselected)
3247 (memq article gnus-newsgroup-dormant))))
3248
3249;; Some summary mode macros.
3250
3251(defmacro gnus-summary-article-number ()
3252 "The article number of the article on the current line.
8f688cb0 3253If there isn't an article number here, then we return the current
eec82323
LMI
3254article number."
3255 '(progn
3256 (gnus-summary-skip-intangible)
3257 (or (get-text-property (point) 'gnus-number)
3258 (gnus-summary-last-subject))))
3259
3260(defmacro gnus-summary-article-header (&optional number)
6748645f 3261 "Return the header of article NUMBER."
eec82323
LMI
3262 `(gnus-data-header (gnus-data-find
3263 ,(or number '(gnus-summary-article-number)))))
3264
3265(defmacro gnus-summary-thread-level (&optional number)
6748645f 3266 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
3267 `(if (and (eq gnus-summary-make-false-root 'dummy)
3268 (get-text-property (point) 'gnus-intangible))
3269 0
3270 (gnus-data-level (gnus-data-find
3271 ,(or number '(gnus-summary-article-number))))))
3272
3273(defmacro gnus-summary-article-mark (&optional number)
6748645f 3274 "Return the mark of article NUMBER."
eec82323
LMI
3275 `(gnus-data-mark (gnus-data-find
3276 ,(or number '(gnus-summary-article-number)))))
3277
3278(defmacro gnus-summary-article-pos (&optional number)
6748645f 3279 "Return the position of the line of article NUMBER."
eec82323
LMI
3280 `(gnus-data-pos (gnus-data-find
3281 ,(or number '(gnus-summary-article-number)))))
3282
3283(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3284(defmacro gnus-summary-article-subject (&optional number)
3285 "Return current subject string or nil if nothing."
3286 `(let ((headers
3287 ,(if number
3288 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3289 '(gnus-data-header (assq (gnus-summary-article-number)
3290 gnus-newsgroup-data)))))
3291 (and headers
3292 (vectorp headers)
3293 (mail-header-subject headers))))
3294
3295(defmacro gnus-summary-article-score (&optional number)
3296 "Return current article score."
3297 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3298 gnus-newsgroup-scored))
3299 gnus-summary-default-score 0))
3300
3301(defun gnus-summary-article-children (&optional number)
6748645f 3302 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
3303 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3304 (level (gnus-data-level (car data)))
3305 l children)
3306 (while (and (setq data (cdr data))
3307 (> (setq l (gnus-data-level (car data))) level))
3308 (and (= (1+ level) l)
3309 (push (gnus-data-number (car data))
3310 children)))
3311 (nreverse children)))
3312
3313(defun gnus-summary-article-parent (&optional number)
6748645f 3314 "Return the article number of the parent of article NUMBER."
eec82323
LMI
3315 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3316 (gnus-data-list t)))
3317 (level (gnus-data-level (car data))))
3318 (if (zerop level)
3319 () ; This is a root.
3320 ;; We search until we find an article with a level less than
3321 ;; this one. That function has to be the parent.
3322 (while (and (setq data (cdr data))
3323 (not (< (gnus-data-level (car data)) level))))
3324 (and data (gnus-data-number (car data))))))
3325
3326(defun gnus-unread-mark-p (mark)
3327 "Say whether MARK is the unread mark."
3328 (= mark gnus-unread-mark))
3329
3330(defun gnus-read-mark-p (mark)
3331 "Say whether MARK is one of the marks that mark as read.
3332This is all marks except unread, ticked, dormant, and expirable."
3333 (not (or (= mark gnus-unread-mark)
3334 (= mark gnus-ticked-mark)
23f87bed 3335 (= mark gnus-spam-mark)
eec82323
LMI
3336 (= mark gnus-dormant-mark)
3337 (= mark gnus-expirable-mark))))
3338
3339(defmacro gnus-article-mark (number)
6748645f
LMI
3340 "Return the MARK of article NUMBER.
3341This macro should only be used when computing the mark the \"first\"
3342time; i.e., when generating the summary lines. After that,
3343`gnus-summary-article-mark' should be used to examine the
3344marks of articles."
eec82323 3345 `(cond
6748645f 3346 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
6748645f 3347 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
3348 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3349 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
23f87bed 3350 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
eec82323
LMI
3351 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3352 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3353 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3354 gnus-ancient-mark))))
3355
3356;; Saving hidden threads.
3357
eec82323
LMI
3358(defmacro gnus-save-hidden-threads (&rest forms)
3359 "Save hidden threads, eval FORMS, and restore the hidden threads."
3360 (let ((config (make-symbol "config")))
3361 `(let ((,config (gnus-hidden-threads-configuration)))
3362 (unwind-protect
3363 (save-excursion
3364 ,@forms)
3365 (gnus-restore-hidden-threads-configuration ,config)))))
23f87bed
MB
3366(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3367(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
eec82323 3368
107ecebb
AS
3369(defun gnus-data-compute-positions ()
3370 "Compute the positions of all articles."
3371 (setq gnus-newsgroup-data-reverse nil)
3372 (let ((data gnus-newsgroup-data))
3373 (save-excursion
3374 (gnus-save-hidden-threads
3375 (gnus-summary-show-all-threads)
3376 (goto-char (point-min))
3377 (while data
3378 (while (get-text-property (point) 'gnus-intangible)
3379 (forward-line 1))
3380 (gnus-data-set-pos (car data) (+ (point) 3))
3381 (setq data (cdr data))
3382 (forward-line 1))))))
3383
16409b0b
GM
3384(defun gnus-hidden-threads-configuration ()
3385 "Return the current hidden threads configuration."
3386 (save-excursion
3387 (let (config)
3388 (goto-char (point-min))
3389 (while (search-forward "\r" nil t)
3390 (push (1- (point)) config))
3391 config)))
3392
3393(defun gnus-restore-hidden-threads-configuration (config)
3394 "Restore hidden threads configuration from CONFIG."
3395 (save-excursion
c7a91ce1 3396 (let (point (inhibit-read-only t))
16409b0b
GM
3397 (while (setq point (pop config))
3398 (when (and (< point (point-max))
3399 (goto-char point)
3400 (eq (char-after) ?\n))
3401 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3402
eec82323
LMI
3403;; Various summary mode internalish functions.
3404
3405(defun gnus-mouse-pick-article (e)
3406 (interactive "e")
3407 (mouse-set-point e)
3408 (gnus-summary-next-page nil t))
3409
3410(defun gnus-summary-set-display-table ()
16409b0b
GM
3411 "Change the display table.
3412Odd characters have a tendency to mess
3413up nicely formatted displays - we make all possible glyphs
3414display only a single character."
eec82323
LMI
3415
3416 ;; We start from the standard display table, if any.
3417 (let ((table (or (copy-sequence standard-display-table)
3418 (make-display-table)))
3419 (i 32))
3420 ;; Nix out all the control chars...
3421 (while (>= (setq i (1- i)) 0)
3422 (aset table i [??]))
23f87bed 3423 ;; ... but not newline and cr, of course. (cr is necessary for the
eec82323
LMI
3424 ;; selective display).
3425 (aset table ?\n nil)
3426 (aset table ?\r nil)
6748645f
LMI
3427 ;; We keep TAB as well.
3428 (aset table ?\t nil)
719120ef 3429 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
fe62aacc 3430 ;; Emacs 23 (unicode), that are not set already.
719120ef
MB
3431 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3432 160
3433 256)))
eec82323
LMI
3434 (while (>= (setq i (1- i)) 127)
3435 ;; Only modify if the entry is nil.
3436 (unless (aref table i)
3437 (aset table i [??]))))
3438 (setq buffer-display-table table)))
3439
23f87bed
MB
3440(defun gnus-summary-set-article-display-arrow (pos)
3441 "Update the overlay arrow to point to line at position POS."
3442 (when (and gnus-summary-display-arrow
3443 (boundp 'overlay-arrow-position)
3444 (boundp 'overlay-arrow-string))
3445 (save-excursion
3446 (goto-char pos)
3447 (beginning-of-line)
3448 (unless overlay-arrow-position
3449 (setq overlay-arrow-position (make-marker)))
3450 (setq overlay-arrow-string "=>"
3451 overlay-arrow-position (set-marker overlay-arrow-position
3452 (point)
3453 (current-buffer))))))
3454
eec82323
LMI
3455(defun gnus-summary-setup-buffer (group)
3456 "Initialize summary buffer."
23f87bed
MB
3457 (let ((buffer (gnus-summary-buffer-name group))
3458 (dead-name (concat "*Dead Summary "
3459 (gnus-group-decoded-name group) "*")))
3460 ;; If a dead summary buffer exists, we kill it.
3461 (when (gnus-buffer-live-p dead-name)
3462 (gnus-kill-buffer dead-name))
eec82323
LMI
3463 (if (get-buffer buffer)
3464 (progn
3465 (set-buffer buffer)
3466 (setq gnus-summary-buffer (current-buffer))
3467 (not gnus-newsgroup-prepared))
3468 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 3469 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323
LMI
3470 (gnus-summary-mode group)
3471 (when gnus-carpal
3472 (gnus-carpal-setup-buffer 'summary))
01c52d31
MB
3473 (when (gnus-group-quit-config group)
3474 (set (make-local-variable 'gnus-single-article-buffer) nil))
3475 (make-local-variable 'gnus-article-buffer)
3476 (make-local-variable 'gnus-article-current)
3477 (make-local-variable 'gnus-original-article-buffer)
eec82323 3478 (setq gnus-newsgroup-name group)
23f87bed
MB
3479 ;; Set any local variables in the group parameters.
3480 (gnus-summary-set-local-parameters gnus-newsgroup-name)
eec82323
LMI
3481 t)))
3482
3483(defun gnus-set-global-variables ()
16409b0b
GM
3484 "Set the global equivalents of the buffer-local variables.
3485They are set to the latest values they had. These reflect the summary
3486buffer that was in action when the last article was fetched."
eec82323
LMI
3487 (when (eq major-mode 'gnus-summary-mode)
3488 (setq gnus-summary-buffer (current-buffer))
3489 (let ((name gnus-newsgroup-name)
3490 (marked gnus-newsgroup-marked)
23f87bed 3491 (spam gnus-newsgroup-spam-marked)
eec82323
LMI
3492 (unread gnus-newsgroup-unreads)
3493 (headers gnus-current-headers)
3494 (data gnus-newsgroup-data)
3495 (summary gnus-summary-buffer)
3496 (article-buffer gnus-article-buffer)
3497 (original gnus-original-article-buffer)
3498 (gac gnus-article-current)
3499 (reffed gnus-reffed-article-number)
16409b0b 3500 (score-file gnus-current-score-file)
23f87bed
MB
3501 (default-charset gnus-newsgroup-charset)
3502 vlist)
3503 (let ((locals gnus-newsgroup-variables))
3504 (while locals
3505 (if (consp (car locals))
3506 (push (eval (caar locals)) vlist)
3507 (push (eval (car locals)) vlist))
3508 (setq locals (cdr locals)))
3509 (setq vlist (nreverse vlist)))
01c52d31 3510 (with-current-buffer gnus-group-buffer
6748645f
LMI
3511 (setq gnus-newsgroup-name name
3512 gnus-newsgroup-marked marked
23f87bed 3513 gnus-newsgroup-spam-marked spam
6748645f
LMI
3514 gnus-newsgroup-unreads unread
3515 gnus-current-headers headers
3516 gnus-newsgroup-data data
3517 gnus-article-current gac
3518 gnus-summary-buffer summary
3519 gnus-article-buffer article-buffer
3520 gnus-original-article-buffer original
3521 gnus-reffed-article-number reffed
16409b0b
GM
3522 gnus-current-score-file score-file
3523 gnus-newsgroup-charset default-charset)
23f87bed
MB
3524 (let ((locals gnus-newsgroup-variables))
3525 (while locals
3526 (if (consp (car locals))
3527 (set (caar locals) (pop vlist))
3528 (set (car locals) (pop vlist)))
3529 (setq locals (cdr locals))))
eec82323
LMI
3530 ;; The article buffer also has local variables.
3531 (when (gnus-buffer-live-p gnus-article-buffer)
3532 (set-buffer gnus-article-buffer)
3533 (setq gnus-summary-buffer summary))))))
3534
3535(defun gnus-summary-article-unread-p (article)
3536 "Say whether ARTICLE is unread or not."
3537 (memq article gnus-newsgroup-unreads))
3538
3539(defun gnus-summary-first-article-p (&optional article)
3540 "Return whether ARTICLE is the first article in the buffer."
3541 (if (not (setq article (or article (gnus-summary-article-number))))
3542 nil
3543 (eq article (caar gnus-newsgroup-data))))
3544
3545(defun gnus-summary-last-article-p (&optional article)
3546 "Return whether ARTICLE is the last article in the buffer."
3547 (if (not (setq article (or article (gnus-summary-article-number))))
16409b0b
GM
3548 ;; All non-existent numbers are the last article. :-)
3549 t
eec82323
LMI
3550 (not (cdr (gnus-data-find-list article)))))
3551
4921bbdd
CY
3552(defun gnus-make-thread-indent-array (&optional n)
3553 (when (or n
3554 (progn (setq n 200) nil)
3555 (null gnus-thread-indent-array)
3556 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3557 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3558 gnus-thread-indent-array-level gnus-thread-indent-level)
3559 (while (>= n 0)
3560 (aset gnus-thread-indent-array n
6a30c01d 3561 (make-string (* n gnus-thread-indent-level) ? ))
4921bbdd 3562 (setq n (1- n)))))
eec82323
LMI
3563
3564(defun gnus-update-summary-mark-positions ()
3565 "Compute where the summary marks are to go."
3566 (save-excursion
6748645f 3567 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3568 (set-buffer gnus-summary-buffer))
5153a47a
MB
3569 (let ((spec gnus-summary-line-format-spec)
3570 pos)
eec82323
LMI
3571 (save-excursion
3572 (gnus-set-work-buffer)
5153a47a
MB
3573 (let ((gnus-tmp-unread ?Z)
3574 (gnus-replied-mark ?Z)
3575 (gnus-score-below-mark ?Z)
3576 (gnus-score-over-mark ?Z)
3577 (gnus-undownloaded-mark ?Z)
3578 (gnus-summary-line-format-spec spec)
54506618 3579 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3580 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3581 case-fold-search ignores)
3582 ;; Here, all marks are bound to Z.
3583 (gnus-summary-insert-line header
3584 0 nil t gnus-tmp-unread t nil "" nil 1)
3585 (goto-char (point-min))
3586 ;; Memorize the positions of the same characters as dummy marks.
3587 (while (re-search-forward "[A-D]" nil t)
3588 (push (point) ignores))
54506618 3589 (erase-buffer)
5153a47a
MB
3590 ;; We use A-D as dummy marks in order to know column positions
3591 ;; where marks should be inserted.
3592 (setq gnus-tmp-unread ?A
3593 gnus-replied-mark ?B
3594 gnus-score-below-mark ?C
3595 gnus-score-over-mark ?C
3596 gnus-undownloaded-mark ?D)
3597 (gnus-summary-insert-line header
3598 0 nil t gnus-tmp-unread t nil "" nil 1)
3599 ;; Ignore characters which aren't dummy marks.
3600 (dolist (p ignores)
3601 (delete-region (goto-char (1- p)) p)
3602 (insert ?Z))
eec82323 3603 (goto-char (point-min))
7c3bb5a5 3604 (setq pos (list (cons 'unread
5153a47a 3605 (and (search-forward "A" nil t)
7c3bb5a5 3606 (- (point) (point-min) 1)))))
eec82323 3607 (goto-char (point-min))
5153a47a 3608 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3609 (- (point) (point-min) 1)))
eec82323
LMI
3610 pos)
3611 (goto-char (point-min))
5153a47a 3612 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3613 (- (point) (point-min) 1)))
6748645f
LMI
3614 pos)
3615 (goto-char (point-min))
5153a47a 3616 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3617 (- (point) (point-min) 1)))
eec82323
LMI
3618 pos)))
3619 (setq gnus-summary-mark-positions pos))))
3620
3621(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3622 "Insert a dummy root in the summary buffer."
3623 (beginning-of-line)
3624 (gnus-add-text-properties
3625 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3626 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3627
23f87bed
MB
3628(defun gnus-summary-extract-address-component (from)
3629 (or (car (funcall gnus-extract-address-components from))
3630 from))
3631
3632(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3633 (let ((mail-parse-charset gnus-newsgroup-charset)
01c52d31 3634 (ignored-from-addresses (gnus-ignored-from-addresses))
23f87bed
MB
3635 ; Is it really necessary to do this next part for each summary line?
3636 ; Luckily, doesn't seem to slow things down much.
16409b0b 3637 (mail-parse-ignored-charsets
01c52d31
MB
3638 (with-current-buffer gnus-summary-buffer
3639 gnus-newsgroup-ignored-charsets)))
23f87bed 3640 (or
01c52d31
MB
3641 (and ignored-from-addresses
3642 (string-match ignored-from-addresses gnus-tmp-from)
23f87bed
MB
3643 (let ((extra-headers (mail-header-extra header))
3644 to
3645 newsgroups)
3646 (cond
3647 ((setq to (cdr (assq 'To extra-headers)))
01c52d31 3648 (concat gnus-summary-to-prefix
23f87bed
MB
3649 (inline
3650 (gnus-summary-extract-address-component
343d6628 3651 (funcall gnus-decode-encoded-address-function to)))))
01c52d31
MB
3652 ((setq newsgroups
3653 (or
3654 (cdr (assq 'Newsgroups extra-headers))
3655 (and
3656 (memq 'Newsgroups gnus-extra-headers)
3657 (eq (car (gnus-find-method-for-group
3658 gnus-newsgroup-name)) 'nntp)
3659 (gnus-group-real-name gnus-newsgroup-name))))
3660 (concat gnus-summary-newsgroup-prefix newsgroups)))))
23f87bed 3661 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3662
eec82323
LMI
3663(defun gnus-summary-insert-line (gnus-tmp-header
3664 gnus-tmp-level gnus-tmp-current
23f87bed 3665 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3666 gnus-tmp-expirable gnus-tmp-subject-or-nil
3667 &optional gnus-tmp-dummy gnus-tmp-score
3668 gnus-tmp-process)
4921bbdd
CY
3669 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3670 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3671 gnus-tmp-level)))
eec82323
LMI
3672 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3673 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3674 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3675 (gnus-tmp-score-char
3676 (if (or (null gnus-summary-default-score)
3677 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3678 gnus-summary-zcore-fuzz))
23f87bed 3679 ? ;Whitespace
eec82323
LMI
3680 (if (< gnus-tmp-score gnus-summary-default-score)
3681 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3682 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3683 (gnus-tmp-replied
3684 (cond (gnus-tmp-process gnus-process-mark)
3685 ((memq gnus-tmp-current gnus-newsgroup-cached)
3686 gnus-cached-mark)
3687 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3688 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3689 gnus-forwarded-mark)
eec82323
LMI
3690 ((memq gnus-tmp-current gnus-newsgroup-saved)
3691 gnus-saved-mark)
23f87bed
MB
3692 ((memq gnus-tmp-number gnus-newsgroup-recent)
3693 gnus-recent-mark)
3694 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3695 gnus-unseen-mark)
3696 (t gnus-no-mark)))
3697 (gnus-tmp-downloaded
3698 (cond (undownloaded
3699 gnus-undownloaded-mark)
3700 (gnus-newsgroup-agentized
3701 gnus-downloaded-mark)
3702 (t
3703 gnus-no-mark)))
eec82323
LMI
3704 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3705 (gnus-tmp-name
3706 (cond
3707 ((string-match "<[^>]+> *$" gnus-tmp-from)
3708 (let ((beg (match-beginning 0)))
23f87bed
MB
3709 (or (and (string-match "^\".+\"" gnus-tmp-from)
3710 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3711 (substring gnus-tmp-from 0 beg))))
3712 ((string-match "(.+)" gnus-tmp-from)
3713 (substring gnus-tmp-from
3714 (1+ (match-beginning 0)) (1- (match-end 0))))
3715 (t gnus-tmp-from)))
3716 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3717 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3718 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
c7a91ce1 3719 (inhibit-read-only t))
eec82323
LMI
3720 (when (string= gnus-tmp-name "")
3721 (setq gnus-tmp-name gnus-tmp-from))
3722 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3723 (setq gnus-tmp-lines -1))
3724 (if (= gnus-tmp-lines -1)
3725 (setq gnus-tmp-lines "?")
3726 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3727 (gnus-put-text-property
eec82323
LMI
3728 (point)
3729 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 3730 'gnus-number gnus-tmp-number)
eec82323
LMI
3731 (when (gnus-visual-p 'summary-highlight 'highlight)
3732 (forward-line -1)
6748645f 3733 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3734 (forward-line 1))))
3735
3736(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3737 "Update summary line after change."
eec82323
LMI
3738 (when (and gnus-summary-default-score
3739 (not gnus-summary-inhibit-highlight))
3740 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3741 (article (gnus-summary-article-number))
3742 (score (gnus-summary-article-score article)))
3743 (unless dont-update
3744 (if (and gnus-summary-mark-below
3745 (< (gnus-summary-article-score)
3746 gnus-summary-mark-below))
3747 ;; This article has a low score, so we mark it as read.
3748 (when (memq article gnus-newsgroup-unreads)
3749 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3750 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3751 ;; This article was previously marked as read on account
3752 ;; of a low score, but now it has risen, so we mark it as
3753 ;; unread.
3754 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3755 (gnus-summary-update-mark
3756 (if (or (null gnus-summary-default-score)
3757 (<= (abs (- score gnus-summary-default-score))
3758 gnus-summary-zcore-fuzz))
23f87bed 3759 ? ;Whitespace
eec82323
LMI
3760 (if (< score gnus-summary-default-score)
3761 gnus-score-below-mark gnus-score-over-mark))
3762 'score))
3763 ;; Do visual highlighting.
3764 (when (gnus-visual-p 'summary-highlight 'highlight)
6748645f 3765 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3766
3767(defvar gnus-tmp-new-adopts nil)
3768
3769(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3770 "Return the number of articles in THREAD.
3771This may be 0 in some cases -- if none of the articles in
3772the thread are to be displayed."
3773 (let* ((number
23f87bed 3774 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3775 (cond
3776 ((not (listp thread))
3777 1)
3778 ((and (consp thread) (cdr thread))
3779 (apply
3780 '+ 1 (mapcar
3781 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3782 ((null thread)
3783 1)
3784 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3785 1)
3786 (t 0))))
3787 (when (and level (zerop level) gnus-tmp-new-adopts)
3788 (incf number
3789 (apply '+ (mapcar
3790 'gnus-summary-number-of-articles-in-thread
3791 gnus-tmp-new-adopts))))
3792 (if char
3793 (if (> number 1) gnus-not-empty-thread-mark
3794 gnus-empty-thread-mark)
3795 number)))
3796
23f87bed
MB
3797(defsubst gnus-summary-line-message-size (head)
3798 "Return pretty-printed version of message size.
3799This function is intended to be used in
3800`gnus-summary-line-format-alist'."
3801 (let ((c (or (mail-header-chars head) -1)))
3802 (cond ((< c 0) "n/a") ; chars not available
3803 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3804 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3805 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3806 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3807
3808
eec82323
LMI
3809(defun gnus-summary-set-local-parameters (group)
3810 "Go through the local params of GROUP and set all variable specs in that list."
01c52d31
MB
3811 (let ((vars '(quit-config))) ; Ignore quit-config.
3812 (dolist (elem (gnus-group-find-parameter group))
eec82323
LMI
3813 (and (consp elem) ; Has to be a cons.
3814 (consp (cdr elem)) ; The cdr has to be a list.
3815 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3816 (not (memq (car elem) vars))
eec82323 3817 (ignore-errors ; So we set it.
23f87bed 3818 (push (car elem) vars)
eec82323
LMI
3819 (make-local-variable (car elem))
3820 (set (car elem) (eval (nth 1 elem))))))))
3821
3822(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3823 kill-buffer no-display backward
3824 select-articles)
eec82323
LMI
3825 "Start reading news in newsgroup GROUP.
3826If SHOW-ALL is non-nil, already read articles are also listed.
3827If NO-ARTICLE is non-nil, no article is selected initially.
3828If NO-DISPLAY, don't generate a summary buffer."
3829 (let (result)
3830 (while (and group
3831 (null (setq result
3832 (let ((gnus-auto-select-next nil))
6748645f
LMI
3833 (or (gnus-summary-read-group-1
3834 group show-all no-article
3835 kill-buffer no-display
3836 select-articles)
3837 (setq show-all nil
16409b0b 3838 select-articles nil)))))
eec82323
LMI
3839 (eq gnus-auto-select-next 'quietly))
3840 (set-buffer gnus-group-buffer)
6748645f
LMI
3841 ;; The entry function called above goes to the next
3842 ;; group automatically, so we go two groups back
3843 ;; if we are searching for the previous group.
3844 (when backward
3845 (gnus-group-prev-unread-group 2))
eec82323
LMI
3846 (if (not (equal group (gnus-group-group-name)))
3847 (setq group (gnus-group-group-name))
3848 (setq group nil)))
3849 result))
3850
3851(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3852 kill-buffer no-display
3853 &optional select-articles)
eec82323 3854 ;; Killed foreign groups can't be entered.
23f87bed
MB
3855 ;; (when (and (not (gnus-group-native-p group))
3856 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3857 ;; (error "Dead non-native groups can't be entered"))
3858 (gnus-message 5 "Retrieving newsgroup: %s..."
3859 (gnus-group-decoded-name group))
eec82323
LMI
3860 (let* ((new-group (gnus-summary-setup-buffer group))
3861 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3862 (did-select (and new-group (gnus-select-newsgroup
3863 group show-all select-articles))))
eec82323
LMI
3864 (cond
3865 ;; This summary buffer exists already, so we just select it.
3866 ((not new-group)
3867 (gnus-set-global-variables)
3868 (when kill-buffer
3869 (gnus-kill-or-deaden-summary kill-buffer))
3870 (gnus-configure-windows 'summary 'force)
3871 (gnus-set-mode-line 'summary)
3872 (gnus-summary-position-point)
3873 (message "")
3874 t)
3875 ;; We couldn't select this group.
3876 ((null did-select)
3877 (when (and (eq major-mode 'gnus-summary-mode)
3878 (not (equal (current-buffer) kill-buffer)))
3879 (kill-buffer (current-buffer))
3880 (if (not quit-config)
3881 (progn
6748645f
LMI
3882 ;; Update the info -- marks might need to be removed,
3883 ;; for instance.
3884 (gnus-summary-update-info)
eec82323
LMI
3885 (set-buffer gnus-group-buffer)
3886 (gnus-group-jump-to-group group)
3887 (gnus-group-next-unread-group 1))
3888 (gnus-handle-ephemeral-exit quit-config)))
23f87bed
MB
3889 (let ((grpinfo (gnus-get-info group)))
3890 (if (null (gnus-info-read grpinfo))
3891 (gnus-message 3 "Group %s contains no messages"
3892 (gnus-group-decoded-name group))
3893 (gnus-message 3 "Can't select group")))
eec82323
LMI
3894 nil)
3895 ;; The user did a `C-g' while prompting for number of articles,
3896 ;; so we exit this group.
3897 ((eq did-select 'quit)
3898 (and (eq major-mode 'gnus-summary-mode)
3899 (not (equal (current-buffer) kill-buffer))
3900 (kill-buffer (current-buffer)))
3901 (when kill-buffer
3902 (gnus-kill-or-deaden-summary kill-buffer))
3903 (if (not quit-config)
3904 (progn
3905 (set-buffer gnus-group-buffer)
3906 (gnus-group-jump-to-group group)
3907 (gnus-group-next-unread-group 1)
3908 (gnus-configure-windows 'group 'force))
3909 (gnus-handle-ephemeral-exit quit-config))
3910 ;; Finally signal the quit.
3911 (signal 'quit nil))
3912 ;; The group was successfully selected.
3913 (t
3914 (gnus-set-global-variables)
3915 ;; Save the active value in effect when the group was entered.
3916 (setq gnus-newsgroup-active
3917 (gnus-copy-sequence
3918 (gnus-active gnus-newsgroup-name)))
3919 ;; You can change the summary buffer in some way with this hook.
6748645f 3920 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
3921 (when (memq 'summary (gnus-update-format-specifications
3922 nil 'summary 'summary-mode 'summary-dummy))
3923 ;; The format specification for the summary line was updated,
3924 ;; so we need to update the mark positions as well.
3925 (gnus-update-summary-mark-positions))
eec82323
LMI
3926 ;; Do score processing.
3927 (when gnus-use-scoring
3928 (gnus-possibly-score-headers))
3929 ;; Check whether to fill in the gaps in the threads.
3930 (when gnus-build-sparse-threads
3931 (gnus-build-sparse-threads))
3932 ;; Find the initial limit.
26c9afc3
MB
3933 (if show-all
3934 (let ((gnus-newsgroup-dormant nil))
eec82323 3935 (gnus-summary-initial-limit show-all))
26c9afc3 3936 (gnus-summary-initial-limit show-all))
eec82323
LMI
3937 ;; Generate the summary buffer.
3938 (unless no-display
3939 (gnus-summary-prepare))
3940 (when gnus-use-trees
3941 (gnus-tree-open group)
3942 (setq gnus-summary-highlight-line-function
3943 'gnus-tree-highlight-article))
3944 ;; If the summary buffer is empty, but there are some low-scored
3945 ;; articles or some excluded dormants, we include these in the
3946 ;; buffer.
3947 (when (and (zerop (buffer-size))
3948 (not no-display))
3949 (cond (gnus-newsgroup-dormant
3950 (gnus-summary-limit-include-dormant))
3951 ((and gnus-newsgroup-scored show-all)
3952 (gnus-summary-limit-include-expunged t))))
3953 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 3954 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
3955 (if (and (zerop (buffer-size))
3956 (not no-display))
3957 (progn
3958 ;; This newsgroup is empty.
3959 (gnus-summary-catchup-and-exit nil t)
3960 (gnus-message 6 "No unread news")
3961 (when kill-buffer
3962 (gnus-kill-or-deaden-summary kill-buffer))
3963 ;; Return nil from this function.
3964 nil)
3965 ;; Hide conversation thread subtrees. We cannot do this in
3966 ;; gnus-summary-prepare-hook since kill processing may not
3967 ;; work with hidden articles.
23f87bed 3968 (gnus-summary-maybe-hide-threads)
6748645f
LMI
3969 (when kill-buffer
3970 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 3971 (gnus-summary-auto-select-subject)
eec82323
LMI
3972 ;; Show first unread article if requested.
3973 (if (and (not no-article)
3974 (not no-display)
3975 gnus-newsgroup-unreads
3976 gnus-auto-select-first)
16409b0b
GM
3977 (progn
3978 (gnus-configure-windows 'summary)
23f87bed
MB
3979 (let ((art (gnus-summary-article-number)))
3980 (unless (and (not gnus-plugged)
3981 (or (memq art gnus-newsgroup-undownloaded)
3982 (memq art gnus-newsgroup-downloadable)))
3983 (gnus-summary-goto-article art))))
3984 ;; Don't select any articles.
eec82323 3985 (gnus-summary-position-point)
6748645f
LMI
3986 (gnus-configure-windows 'summary 'force)
3987 (gnus-set-mode-line 'summary))
23f87bed
MB
3988 (when (and gnus-auto-center-group
3989 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
3990 ;; Gotta use windows, because recenter does weird stuff if
3991 ;; the current buffer ain't the displayed window.
3992 (let ((owin (selected-window)))
3993 (select-window (get-buffer-window gnus-group-buffer t))
3994 (when (gnus-group-goto-group group)
3995 (recenter))
3996 (select-window owin)))
3997 ;; Mark this buffer as "prepared".
3998 (setq gnus-newsgroup-prepared t)
6748645f 3999 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
4000 (unless (gnus-ephemeral-group-p group)
4001 (gnus-group-update-group group))
eec82323
LMI
4002 t)))))
4003
23f87bed
MB
4004(defun gnus-summary-auto-select-subject ()
4005 "Select the subject line on initial group entry."
4006 (goto-char (point-min))
4007 (cond
4008 ((eq gnus-auto-select-subject 'best)
4009 (gnus-summary-best-unread-subject))
4010 ((eq gnus-auto-select-subject 'unread)
4011 (gnus-summary-first-unread-subject))
4012 ((eq gnus-auto-select-subject 'unseen)
4013 (gnus-summary-first-unseen-subject))
4014 ((eq gnus-auto-select-subject 'unseen-or-unread)
4015 (gnus-summary-first-unseen-or-unread-subject))
4016 ((eq gnus-auto-select-subject 'first)
4017 ;; Do nothing.
4018 )
4019 ((functionp gnus-auto-select-subject)
4020 (funcall gnus-auto-select-subject))))
4021
eec82323
LMI
4022(defun gnus-summary-prepare ()
4023 "Generate the summary buffer."
4024 (interactive)
c7a91ce1 4025 (let ((inhibit-read-only t))
eec82323
LMI
4026 (erase-buffer)
4027 (setq gnus-newsgroup-data nil
4028 gnus-newsgroup-data-reverse nil)
6748645f 4029 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
4030 ;; Generate the buffer, either with threads or without.
4031 (when gnus-newsgroup-headers
4032 (gnus-summary-prepare-threads
4033 (if gnus-show-threads
4034 (gnus-sort-gathered-threads
4035 (funcall gnus-summary-thread-gathering-function
4036 (gnus-sort-threads
4037 (gnus-cut-threads (gnus-make-threads)))))
4038 ;; Unthreaded display.
4039 (gnus-sort-articles gnus-newsgroup-headers))))
4040 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4041 ;; Call hooks for modifying summary buffer.
4042 (goto-char (point-min))
6748645f 4043 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
4044
4045(defsubst gnus-general-simplify-subject (subject)
23f87bed 4046 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
4047 (setq subject
4048 (cond
4049 ;; Truncate the subject.
6748645f
LMI
4050 (gnus-simplify-subject-functions
4051 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
4052 ((numberp gnus-summary-gather-subject-limit)
4053 (setq subject (gnus-simplify-subject-re subject))
4054 (if (> (length subject) gnus-summary-gather-subject-limit)
4055 (substring subject 0 gnus-summary-gather-subject-limit)
4056 subject))
4057 ;; Fuzzily simplify it.
4058 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4059 (gnus-simplify-subject-fuzzy subject))
4060 ;; Just remove the leading "Re:".
4061 (t
4062 (gnus-simplify-subject-re subject))))
4063
4064 (if (and gnus-summary-gather-exclude-subject
4065 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 4066 nil ; This article shouldn't be gathered
eec82323
LMI
4067 subject))
4068
4069(defun gnus-summary-simplify-subject-query ()
4070 "Query where the respool algorithm would put this article."
4071 (interactive)
eec82323 4072 (gnus-summary-select-article)
274f1353 4073 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
eec82323
LMI
4074
4075(defun gnus-gather-threads-by-subject (threads)
4076 "Gather threads by looking at Subject headers."
4077 (if (not gnus-summary-make-false-root)
4078 threads
4079 (let ((hashtb (gnus-make-hashtable 1024))
4080 (prev threads)
4081 (result threads)
4082 subject hthread whole-subject)
4083 (while threads
4084 (setq subject (gnus-general-simplify-subject
4085 (setq whole-subject (mail-header-subject
4086 (caar threads)))))
4087 (when subject
4088 (if (setq hthread (gnus-gethash subject hashtb))
4089 (progn
4090 ;; We enter a dummy root into the thread, if we
4091 ;; haven't done that already.
4092 (unless (stringp (caar hthread))
4093 (setcar hthread (list whole-subject (car hthread))))
4094 ;; We add this new gathered thread to this gathered
4095 ;; thread.
4096 (setcdr (car hthread)
4097 (nconc (cdar hthread) (list (car threads))))
4098 ;; Remove it from the list of threads.
4099 (setcdr prev (cdr threads))
4100 (setq threads prev))
4101 ;; Enter this thread into the hash table.
23f87bed
MB
4102 (gnus-sethash subject
4103 (if gnus-summary-make-false-root-always
4104 (progn
4105 ;; If you want a dummy root above all
4106 ;; threads...
4107 (setcar threads (list whole-subject
4108 (car threads)))
4109 threads)
4110 threads)
4111 hashtb)))
eec82323
LMI
4112 (setq prev threads)
4113 (setq threads (cdr threads)))
4114 result)))
4115
4116(defun gnus-gather-threads-by-references (threads)
4117 "Gather threads by looking at References headers."
4118 (let ((idhashtb (gnus-make-hashtable 1024))
4119 (thhashtb (gnus-make-hashtable 1024))
4120 (prev threads)
4121 (result threads)
4122 ids references id gthread gid entered ref)
4123 (while threads
4124 (when (setq references (mail-header-references (caar threads)))
4125 (setq id (mail-header-id (caar threads))
23f87bed 4126 ids (inline (gnus-split-references references))
eec82323
LMI
4127 entered nil)
4128 (while (setq ref (pop ids))
4129 (setq ids (delete ref ids))
4130 (if (not (setq gid (gnus-gethash ref idhashtb)))
4131 (progn
4132 (gnus-sethash ref id idhashtb)
4133 (gnus-sethash id threads thhashtb))
4134 (setq gthread (gnus-gethash gid thhashtb))
4135 (unless entered
4136 ;; We enter a dummy root into the thread, if we
4137 ;; haven't done that already.
4138 (unless (stringp (caar gthread))
4139 (setcar gthread (list (mail-header-subject (caar gthread))
4140 (car gthread))))
4141 ;; We add this new gathered thread to this gathered
4142 ;; thread.
4143 (setcdr (car gthread)
4144 (nconc (cdar gthread) (list (car threads)))))
4145 ;; Add it into the thread hash table.
4146 (gnus-sethash id gthread thhashtb)
4147 (setq entered t)
4148 ;; Remove it from the list of threads.
4149 (setcdr prev (cdr threads))
4150 (setq threads prev))))
4151 (setq prev threads)
4152 (setq threads (cdr threads)))
4153 result))
4154
4155(defun gnus-sort-gathered-threads (threads)
16409b0b 4156 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
4157 (let ((result threads))
4158 (while threads
4159 (when (stringp (caar threads))
4160 (setcdr (car threads)
16409b0b 4161 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
4162 (setq threads (cdr threads)))
4163 result))
4164
4165(defun gnus-thread-loop-p (root thread)
4166 "Say whether ROOT is in THREAD."
4167 (let ((stack (list thread))
4168 (infloop 0)
4169 th)
4170 (while (setq thread (pop stack))
4171 (setq th (cdr thread))
4172 (while (and th
4173 (not (eq (caar th) root)))
4174 (pop th))
4175 (if th
4176 ;; We have found a loop.
4177 (let (ref-dep)
4178 (setcdr thread (delq (car th) (cdr thread)))
4179 (if (boundp (setq ref-dep (intern "none"
4180 gnus-newsgroup-dependencies)))
4181 (setcdr (symbol-value ref-dep)
4182 (nconc (cdr (symbol-value ref-dep))
4183 (list (car th))))
4184 (set ref-dep (list nil (car th))))
4185 (setq infloop 1
4186 stack nil))
4187 ;; Push all the subthreads onto the stack.
4188 (push (cdr thread) stack)))
4189 infloop))
4190
4191(defun gnus-make-threads ()
01ccbb85 4192 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
4193 (let (threads)
4194 (while (catch 'infloop
4195 (mapatoms
4196 (lambda (refs)
4197 ;; Deal with self-referencing References loops.
4198 (when (and (car (symbol-value refs))
4199 (not (zerop
4200 (apply
4201 '+
4202 (mapcar
4203 (lambda (thread)
4204 (gnus-thread-loop-p
4205 (car (symbol-value refs)) thread))
4206 (cdr (symbol-value refs)))))))
4207 (setq threads nil)
4208 (throw 'infloop t))
4209 (unless (car (symbol-value refs))
23f87bed
MB
4210 ;; These threads do not refer back to any other
4211 ;; articles, so they're roots.
eec82323
LMI
4212 (setq threads (append (cdr (symbol-value refs)) threads))))
4213 gnus-newsgroup-dependencies)))
4214 threads))
4215
6748645f 4216;; Build the thread tree.
16409b0b 4217(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4218 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4219
4220If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4221if it was already present.
4222
4223If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4224will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4225Message-IDs will be renamed to a unique Message-ID before being
4226entered.
6748645f
LMI
4227
4228Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4229 (let* ((id (mail-header-id header))
4230 (id-dep (and id (intern id dependencies)))
23f87bed 4231 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4232 ;; Enter this `header' in the `dependencies' table.
4233 (cond
4234 ((not id-dep)
4235 (setq header nil))
4236 ;; The first two cases do the normal part: enter a new `header'
4237 ;; in the `dependencies' table.
4238 ((not (boundp id-dep))
4239 (set id-dep (list header)))
4240 ((null (car (symbol-value id-dep)))
4241 (setcar (symbol-value id-dep) header))
4242
4243 ;; From here the `header' was already present in the
4244 ;; `dependencies' table.
4245 (force-new
4246 ;; Overrides an existing entry;
4247 ;; just set the header part of the entry.
23f87bed
MB
4248 (setcar (symbol-value id-dep) header)
4249 (setq replaced t))
6748645f
LMI
4250
4251 ;; Renames the existing `header' to a unique Message-ID.
4252 ((not gnus-summary-ignore-duplicates)
4253 ;; An article with this Message-ID has already been seen.
4254 ;; We rename the Message-ID.
4255 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4256 (list header))
4257 (mail-header-set-id header id))
4258
4259 ;; The last case ignores an existing entry, except it adds any
4260 ;; additional Xrefs (in case the two articles came from different
4261 ;; servers.
4262 ;; Also sets `header' to `nil' meaning that the `dependencies'
4263 ;; table was *not* modified.
4264 (t
4265 (mail-header-set-xref
4266 (car (symbol-value id-dep))
4267 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4268 "")
4269 (or (mail-header-xref header) "")))
4270 (setq header nil)))
4271
23f87bed
MB
4272 (when (and header (not replaced))
4273 ;; First check that we are not creating a References loop.
4274 (setq parent-id (gnus-parent-id (mail-header-references header)))
4275 (setq ref parent-id)
6748645f
LMI
4276 (while (and ref
4277 (setq ref-dep (intern-soft ref dependencies))
4278 (boundp ref-dep)
4279 (setq ref-header (car (symbol-value ref-dep))))
4280 (if (string= id ref)
4281 ;; Yuk! This is a reference loop. Make the article be a
4282 ;; root article.
4283 (progn
4284 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4285 (setq ref nil)
4286 (setq parent-id nil))
6748645f 4287 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4288 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4289 (if (boundp ref-dep)
4290 (setcdr (symbol-value ref-dep)
4291 (nconc (cdr (symbol-value ref-dep))
4292 (list (symbol-value id-dep))))
4293 (set ref-dep (list nil (symbol-value id-dep)))))
4294 header))
4295
23f87bed
MB
4296(defun gnus-extract-message-id-from-in-reply-to (string)
4297 (if (string-match "<[^>]+>" string)
4298 (substring string (match-beginning 0) (match-end 0))
4299 nil))
4300
eec82323
LMI
4301(defun gnus-build-sparse-threads ()
4302 (let ((headers gnus-newsgroup-headers)
16409b0b 4303 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4304 (gnus-summary-ignore-duplicates t)
eec82323 4305 header references generation relations
6748645f 4306 subject child end new-child date)
eec82323
LMI
4307 ;; First we create an alist of generations/relations, where
4308 ;; generations is how much we trust the relation, and the relation
4309 ;; is parent/child.
4310 (gnus-message 7 "Making sparse threads...")
4311 (save-excursion
4312 (nnheader-set-temp-buffer " *gnus sparse threads*")
4313 (while (setq header (pop headers))
4314 (when (and (setq references (mail-header-references header))
4315 (not (string= references "")))
4316 (insert references)
4317 (setq child (mail-header-id header)
6748645f
LMI
4318 subject (mail-header-subject header)
4319 date (mail-header-date header)
4320 generation 0)
eec82323
LMI
4321 (while (search-backward ">" nil t)
4322 (setq end (1+ (point)))
4323 (when (search-backward "<" nil t)
6748645f 4324 (setq new-child (buffer-substring (point) end))
eec82323 4325 (push (list (incf generation)
6748645f
LMI
4326 child (setq child new-child)
4327 subject date)
eec82323 4328 relations)))
6748645f
LMI
4329 (when child
4330 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4331 (erase-buffer)))
4332 (kill-buffer (current-buffer)))
4333 ;; Sort over trustworthiness.
01c52d31
MB
4334 (dolist (relation (sort relations 'car-less-than-car))
4335 (when (gnus-dependencies-add-header
4336 (make-full-mail-header
4337 gnus-reffed-article-number
4338 (nth 3 relation) "" (or (nth 4 relation) "")
4339 (nth 1 relation)
4340 (or (nth 2 relation) "") 0 0 "")
4341 gnus-newsgroup-dependencies nil)
4342 (push gnus-reffed-article-number gnus-newsgroup-limit)
4343 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4344 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4345 gnus-newsgroup-reads)
4346 (decf gnus-reffed-article-number)))
eec82323
LMI
4347 (gnus-message 7 "Making sparse threads...done")))
4348
4349(defun gnus-build-old-threads ()
4350 ;; Look at all the articles that refer back to old articles, and
4351 ;; fetch the headers for the articles that aren't there. This will
4352 ;; build complete threads - if the roots haven't been expired by the
4353 ;; server, that is.
16409b0b
GM
4354 (let ((mail-parse-charset gnus-newsgroup-charset)
4355 id heads)
eec82323
LMI
4356 (mapatoms
4357 (lambda (refs)
4358 (when (not (car (symbol-value refs)))
4359 (setq heads (cdr (symbol-value refs)))
4360 (while heads
4361 (if (memq (mail-header-number (caar heads))
4362 gnus-newsgroup-dormant)
4363 (setq heads (cdr heads))
4364 (setq id (symbol-name refs))
4365 (while (and (setq id (gnus-build-get-header id))
6748645f 4366 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4367 (setq heads nil)))))
4368 gnus-newsgroup-dependencies)))
4369
23f87bed
MB
4370(defsubst gnus-remove-odd-characters (string)
4371 "Translate STRING into something that doesn't contain weird characters."
4372 (mm-subst-char-in-string
4373 ?\r ?\-
01c52d31 4374 (mm-subst-char-in-string ?\n ?\- string t) t))
23f87bed 4375
6748645f
LMI
4376;; This function has to be called with point after the article number
4377;; on the beginning of the line.
4378(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
01c52d31 4379 (let ((eol (point-at-eol))
6748645f 4380 (buffer (current-buffer))
23f87bed 4381 header references in-reply-to)
6748645f
LMI
4382
4383 ;; overview: [num subject from date id refs chars lines misc]
4384 (unwind-protect
23f87bed 4385 (let (x)
6748645f
LMI
4386 (narrow-to-region (point) eol)
4387 (unless (eobp)
4388 (forward-char))
4389
4390 (setq header
4391 (make-full-mail-header
4392 number ; number
23f87bed
MB
4393 (condition-case () ; subject
4394 (gnus-remove-odd-characters
4395 (funcall gnus-decode-encoded-word-function
4396 (setq x (nnheader-nov-field))))
4397 (error x))
4398 (condition-case () ; from
4399 (gnus-remove-odd-characters
343d6628 4400 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4401 (setq x (nnheader-nov-field))))
4402 (error x))
16409b0b 4403 (nnheader-nov-field) ; date
01c52d31 4404 (nnheader-nov-read-message-id number) ; id
23f87bed 4405 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4406 (nnheader-nov-read-integer) ; chars
4407 (nnheader-nov-read-integer) ; lines
4408 (unless (eobp)
8b93df01
DL
4409 (if (looking-at "Xref: ")
4410 (goto-char (match-end 0)))
4411 (nnheader-nov-field)) ; Xref
16409b0b 4412 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4413
4414 (widen))
4415
23f87bed
MB
4416 (when (and (string= references "")
4417 (setq in-reply-to (mail-header-extra header))
4418 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4419 (mail-header-set-references
4420 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4421
6748645f
LMI
4422 (when gnus-alter-header-function
4423 (funcall gnus-alter-header-function header))
4424 (gnus-dependencies-add-header header dependencies force-new)))
4425
eec82323 4426(defun gnus-build-get-header (id)
16409b0b
GM
4427 "Look through the buffer of NOV lines and find the header to ID.
4428Enter this line into the dependencies hash table, and return
4429the id of the parent article (if any)."
eec82323
LMI
4430 (let ((deps gnus-newsgroup-dependencies)
4431 found header)
4432 (prog1
c7a91ce1 4433 (with-current-buffer nntp-server-buffer
eec82323
LMI
4434 (let ((case-fold-search nil))
4435 (goto-char (point-min))
4436 (while (and (not found)
4437 (search-forward id nil t))
4438 (beginning-of-line)
4439 (setq found (looking-at
4440 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4441 (regexp-quote id))))
4442 (or found (beginning-of-line 2)))
4443 (when found
4444 (beginning-of-line)
4445 (and
4446 (setq header (gnus-nov-parse-line
4447 (read (current-buffer)) deps))
4448 (gnus-parent-id (mail-header-references header))))))
4449 (when header
4450 (let ((number (mail-header-number header)))
4451 (push number gnus-newsgroup-limit)
4452 (push header gnus-newsgroup-headers)
4453 (if (memq number gnus-newsgroup-unselected)
4454 (progn
23f87bed
MB
4455 (setq gnus-newsgroup-unreads
4456 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4457 number))
eec82323
LMI
4458 (setq gnus-newsgroup-unselected
4459 (delq number gnus-newsgroup-unselected)))
4460 (push number gnus-newsgroup-ancient)))))))
4461
6748645f
LMI
4462(defun gnus-build-all-threads ()
4463 "Read all the headers."
4464 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4465 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4466 (dependencies gnus-newsgroup-dependencies)
4467 header article)
c7a91ce1 4468 (with-current-buffer nntp-server-buffer
6748645f
LMI
4469 (let ((case-fold-search nil))
4470 (goto-char (point-min))
4471 (while (not (eobp))
4472 (ignore-errors
4473 (setq article (read (current-buffer))
16409b0b 4474 header (gnus-nov-parse-line article dependencies)))
6748645f 4475 (when header
01c52d31 4476 (with-current-buffer gnus-summary-buffer
6748645f
LMI
4477 (push header gnus-newsgroup-headers)
4478 (if (memq (setq article (mail-header-number header))
4479 gnus-newsgroup-unselected)
4480 (progn
23f87bed
MB
4481 (setq gnus-newsgroup-unreads
4482 (gnus-add-to-sorted-list
4483 gnus-newsgroup-unreads article))
6748645f
LMI
4484 (setq gnus-newsgroup-unselected
4485 (delq article gnus-newsgroup-unselected)))
4486 (push article gnus-newsgroup-ancient)))
4487 (forward-line 1)))))))
4488
eec82323 4489(defun gnus-summary-update-article-line (article header)
23f87bed 4490 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4491 (let* ((id (mail-header-id header))
4492 (thread (gnus-id-to-thread id)))
4493 (unless thread
4494 (error "Article in no thread"))
4495 ;; Update the thread.
4496 (setcar thread header)
4497 (gnus-summary-goto-subject article)
4498 (let* ((datal (gnus-data-find-list article))
4499 (data (car datal))
c7a91ce1 4500 (inhibit-read-only t)
eec82323
LMI
4501 (level (gnus-summary-thread-level)))
4502 (gnus-delete-line)
23f87bed
MB
4503 (let ((inserted (- (point)
4504 (progn
4505 (gnus-summary-insert-line
4506 header level nil
4507 (memq article gnus-newsgroup-undownloaded)
4508 (gnus-article-mark article)
4509 (memq article gnus-newsgroup-replied)
4510 (memq article gnus-newsgroup-expirable)
4511 ;; Only insert the Subject string when it's different
4512 ;; from the previous Subject string.
4513 (if (and
4514 gnus-show-threads
4515 (gnus-subject-equal
4516 (condition-case ()
4517 (mail-header-subject
4518 (gnus-data-header
4519 (cadr
4520 (gnus-data-find-list
4521 article
4522 (gnus-data-list t)))))
4523 ;; Error on the side of excessive subjects.
4524 (error ""))
4525 (mail-header-subject header)))
4526 ""
4527 (mail-header-subject header))
4528 nil (cdr (assq article gnus-newsgroup-scored))
4529 (memq article gnus-newsgroup-processable))
4530 (point)))))
4531 (when (cdr datal)
4532 (gnus-data-update-list
4533 (cdr datal)
4534 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4535
4536(defun gnus-summary-update-article (article &optional iheader)
4537 "Update ARTICLE in the summary buffer."
4538 (set-buffer gnus-summary-buffer)
6748645f 4539 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4540 (id (mail-header-id header))
4541 (data (gnus-data-find article))
4542 (thread (gnus-id-to-thread id))
4543 (references (mail-header-references header))
4544 (parent
4545 (gnus-id-to-thread
4546 (or (gnus-parent-id
4547 (when (and references
4548 (not (equal "" references)))
4549 references))
4550 "none")))
c7a91ce1 4551 (inhibit-read-only t)
6748645f 4552 (old (car thread)))
eec82323 4553 (when thread
eec82323 4554 (unless iheader
6748645f
LMI
4555 (setcar thread nil)
4556 (when parent
4557 (delq thread parent)))
4558 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4559 ;; Set the (possibly) new article number in the data structure.
4560 (gnus-data-set-number data (gnus-id-to-article id))
4561 (setcar thread old)
4562 nil))))
4563
6748645f
LMI
4564(defun gnus-rebuild-thread (id &optional line)
4565 "Rebuild the thread containing ID.
4566If LINE, insert the rebuilt thread starting on line LINE."
c7a91ce1 4567 (let ((inhibit-read-only t)
eec82323
LMI
4568 old-pos current thread data)
4569 (if (not gnus-show-threads)
4570 (setq thread (list (car (gnus-id-to-thread id))))
4571 ;; Get the thread this article is part of.
4572 (setq thread (gnus-remove-thread id)))
01c52d31 4573 (setq old-pos (point-at-bol))
eec82323 4574 (setq current (save-excursion
94384150 4575 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4576 (gnus-summary-article-number))))
4577 ;; If this is a gathered thread, we have to go some re-gathering.
4578 (when (stringp (car thread))
4579 (let ((subject (car thread))
4580 roots thr)
4581 (setq thread (cdr thread))
4582 (while thread
4583 (unless (memq (setq thr (gnus-id-to-thread
4584 (gnus-root-id
4585 (mail-header-id (caar thread)))))
4586 roots)
4587 (push thr roots))
4588 (setq thread (cdr thread)))
4589 ;; We now have all (unique) roots.
4590 (if (= (length roots) 1)
4591 ;; All the loose roots are now one solid root.
4592 (setq thread (car roots))
4593 (setq thread (cons subject (gnus-sort-threads roots))))))
4594 (let (threads)
4595 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4596 (when line
4597 (goto-char (point-min))
4598 (forward-line (1- line)))
eec82323
LMI
4599 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4600 (if gnus-show-threads
4601 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4602 (gnus-summary-prepare-unthreaded thread))
4603 (setq data (nreverse gnus-newsgroup-data))
4604 (setq threads gnus-newsgroup-threads))
4605 ;; We splice the new data into the data structure.
6748645f
LMI
4606 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4607 ;;!!! then we want to insert at the beginning of the buffer.
4608 ;;!!! That happens to be true with Gnus now, but that may
4609 ;;!!! change in the future. Perhaps.
4610 (gnus-data-enter-list
4611 (if line nil current) data (- (point) old-pos))
4612 (setq gnus-newsgroup-threads
4613 (nconc threads gnus-newsgroup-threads))
4614 (gnus-data-compute-positions))))
eec82323
LMI
4615
4616(defun gnus-number-to-header (number)
4617 "Return the header for article NUMBER."
4618 (let ((headers gnus-newsgroup-headers))
4619 (while (and headers
4620 (not (= number (mail-header-number (car headers)))))
4621 (pop headers))
4622 (when headers
4623 (car headers))))
4624
6748645f 4625(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4626 "Return the headers of the GENERATIONeth parent of HEADERS."
4627 (unless generation
4628 (setq generation 1))
a8151ef7 4629 (let ((parent t)
6748645f 4630 (headers in-headers)
a8151ef7 4631 references)
6748645f
LMI
4632 (while (and parent
4633 (not (zerop generation))
4634 (setq references (mail-header-references headers)))
4635 (setq headers (if (and references
4636 (setq parent (gnus-parent-id references)))
4637 (car (gnus-id-to-thread parent))
4638 nil))
4639 (decf generation))
4640 (and (not (eq headers in-headers))
4641 headers)))
eec82323
LMI
4642
4643(defun gnus-id-to-thread (id)
4644 "Return the (sub-)thread where ID appears."
4645 (gnus-gethash id gnus-newsgroup-dependencies))
4646
4647(defun gnus-id-to-article (id)
4648 "Return the article number of ID."
4649 (let ((thread (gnus-id-to-thread id)))
4650 (when (and thread
4651 (car thread))
4652 (mail-header-number (car thread)))))
4653
4654(defun gnus-id-to-header (id)
4655 "Return the article headers of ID."
4656 (car (gnus-id-to-thread id)))
4657
4658(defun gnus-article-displayed-root-p (article)
4659 "Say whether ARTICLE is a root(ish) article."
4660 (let ((level (gnus-summary-thread-level article))
4661 (refs (mail-header-references (gnus-summary-article-header article)))
4662 particle)
4663 (cond
4664 ((null level) nil)
4665 ((zerop level) t)
4666 ((null refs) t)
4667 ((null (gnus-parent-id refs)) t)
4668 ((and (= 1 level)
4669 (null (setq particle (gnus-id-to-article
4670 (gnus-parent-id refs))))
4671 (null (gnus-summary-thread-level particle)))))))
4672
4673(defun gnus-root-id (id)
4674 "Return the id of the root of the thread where ID appears."
4675 (let (last-id prev)
6748645f 4676 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4677 (setq last-id id
4678 id (gnus-parent-id (mail-header-references prev))))
4679 last-id))
4680
6748645f
LMI
4681(defun gnus-articles-in-thread (thread)
4682 "Return the list of articles in THREAD."
4683 (cons (mail-header-number (car thread))
4684 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4685
eec82323
LMI
4686(defun gnus-remove-thread (id &optional dont-remove)
4687 "Remove the thread that has ID in it."
6748645f 4688 (let (headers thread last-id)
eec82323 4689 ;; First go up in this thread until we find the root.
6748645f
LMI
4690 (setq last-id (gnus-root-id id)
4691 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4692 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4693 ;; been gathered into some loose thread, so we have to search
4694 ;; through the threads to find the thread we wanted.
4695 (let ((threads gnus-newsgroup-threads)
4696 sub)
4697 (while threads
4698 (setq sub (car threads))
4699 (if (stringp (car sub))
4700 ;; This is a gathered thread, so we look at the roots
4701 ;; below it to find whether this article is in this
4702 ;; gathered root.
4703 (progn
4704 (setq sub (cdr sub))
4705 (while sub
4706 (when (member (caar sub) headers)
4707 (setq thread (car threads)
4708 threads nil
4709 sub nil))
4710 (setq sub (cdr sub))))
4711 ;; It's an ordinary thread, so we check it.
4712 (when (eq (car sub) (car headers))
4713 (setq thread sub
4714 threads nil)))
4715 (setq threads (cdr threads)))
4716 ;; If this article is in no thread, then it's a root.
4717 (if thread
4718 (unless dont-remove
4719 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4720 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4721 (when thread
4722 (prog1
4723 thread ; We return this thread.
4724 (unless dont-remove
4725 (if (stringp (car thread))
4726 (progn
4727 ;; If we use dummy roots, then we have to remove the
4728 ;; dummy root as well.
4729 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4730 ;; We go to the dummy root by going to
4731 ;; the first sub-"thread", and then one line up.
4732 (gnus-summary-goto-article
4733 (mail-header-number (caadr thread)))
4734 (forward-line -1)
eec82323
LMI
4735 (gnus-delete-line)
4736 (gnus-data-compute-positions))
4737 (setq thread (cdr thread))
4738 (while thread
4739 (gnus-remove-thread-1 (car thread))
4740 (setq thread (cdr thread))))
4741 (gnus-remove-thread-1 thread))))))))
4742
4743(defun gnus-remove-thread-1 (thread)
4744 "Remove the thread THREAD recursively."
4745 (let ((number (mail-header-number (pop thread)))
4746 d)
4747 (setq thread (reverse thread))
4748 (while thread
4749 (gnus-remove-thread-1 (pop thread)))
4750 (when (setq d (gnus-data-find number))
4751 (goto-char (gnus-data-pos d))
16409b0b 4752 (gnus-summary-show-thread)
eec82323
LMI
4753 (gnus-data-remove
4754 number
01c52d31 4755 (- (point-at-bol)
eec82323 4756 (prog1
01c52d31 4757 (1+ (point-at-eol))
eec82323
LMI
4758 (gnus-delete-line)))))))
4759
4921bbdd 4760(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4761 (sort (mapcar (lambda (thread)
4762 (cons (car thread)
4763 (and (cdr thread)
4921bbdd 4764 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4765 threads) func))
4766
4921bbdd
CY
4767(defun gnus-sort-threads-loop (threads func)
4768 (let* ((superthread (cons nil threads))
4769 (stack (list (cons superthread threads)))
4770 remaining-threads thread)
4771 (while stack
4772 (setq remaining-threads (cdr (car stack)))
4773 (if remaining-threads
4774 (progn (setq thread (car remaining-threads))
4775 (setcdr (car stack) (cdr remaining-threads))
4776 (if (cdr thread)
4777 (push (cons thread (cdr thread)) stack)))
4778 (setq thread (caar stack))
4779 (setcdr thread (sort (cdr thread) func))
4780 (pop stack)))
4781 (cdr superthread)))
4782
eec82323
LMI
4783(defun gnus-sort-threads (threads)
4784 "Sort THREADS."
4785 (if (not gnus-thread-sort-functions)
4786 threads
6748645f 4787 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4788 (prog1
4789 (condition-case nil
4790 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4791 (gnus-sort-threads-recursive
4792 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4793 ;; Even after binding max-lisp-eval-depth, the recursive
4794 ;; sorter might fail for very long threads. In that case,
4795 ;; try using a (less well-tested) non-recursive sorter.
4796 (error (gnus-sort-threads-loop
4797 threads (gnus-make-sort-function
4798 gnus-thread-sort-functions))))
4799 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4800
4801(defun gnus-sort-articles (articles)
4802 "Sort ARTICLES."
4803 (when gnus-article-sort-functions
4804 (gnus-message 7 "Sorting articles...")
4805 (prog1
4806 (setq gnus-newsgroup-headers
4807 (sort articles (gnus-make-sort-function
4808 gnus-article-sort-functions)))
4809 (gnus-message 7 "Sorting articles...done"))))
4810
4811;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4812(defmacro gnus-thread-header (thread)
16409b0b
GM
4813 "Return header of first article in THREAD.
4814Note that THREAD must never, ever be anything else than a variable -
4815using some other form will lead to serious barfage."
eec82323
LMI
4816 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4817 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4818 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4819 (vector thread) 2))
4820
4821(defsubst gnus-article-sort-by-number (h1 h2)
4822 "Sort articles by article number."
4823 (< (mail-header-number h1)
4824 (mail-header-number h2)))
4825
4826(defun gnus-thread-sort-by-number (h1 h2)
4827 "Sort threads by root article number."
4828 (gnus-article-sort-by-number
4829 (gnus-thread-header h1) (gnus-thread-header h2)))
4830
23f87bed 4831(defsubst gnus-article-sort-by-random (h1 h2)
0b6799c3 4832 "Sort articles randomly."
23f87bed
MB
4833 (zerop (random 2)))
4834
4835(defun gnus-thread-sort-by-random (h1 h2)
0b6799c3 4836 "Sort threads randomly."
23f87bed
MB
4837 (gnus-article-sort-by-random
4838 (gnus-thread-header h1) (gnus-thread-header h2)))
4839
eec82323
LMI
4840(defsubst gnus-article-sort-by-lines (h1 h2)
4841 "Sort articles by article Lines header."
4842 (< (mail-header-lines h1)
4843 (mail-header-lines h2)))
4844
4845(defun gnus-thread-sort-by-lines (h1 h2)
4846 "Sort threads by root article Lines header."
4847 (gnus-article-sort-by-lines
4848 (gnus-thread-header h1) (gnus-thread-header h2)))
4849
16409b0b
GM
4850(defsubst gnus-article-sort-by-chars (h1 h2)
4851 "Sort articles by octet length."
4852 (< (mail-header-chars h1)
4853 (mail-header-chars h2)))
4854
4855(defun gnus-thread-sort-by-chars (h1 h2)
4856 "Sort threads by root article octet length."
4857 (gnus-article-sort-by-chars
4858 (gnus-thread-header h1) (gnus-thread-header h2)))
4859
eec82323
LMI
4860(defsubst gnus-article-sort-by-author (h1 h2)
4861 "Sort articles by root author."
b4fde39f 4862 (gnus-string<
eec82323
LMI
4863 (let ((extract (funcall
4864 gnus-extract-address-components
4865 (mail-header-from h1))))
4866 (or (car extract) (cadr extract) ""))
4867 (let ((extract (funcall
4868 gnus-extract-address-components
4869 (mail-header-from h2))))
4870 (or (car extract) (cadr extract) ""))))
4871
4872(defun gnus-thread-sort-by-author (h1 h2)
4873 "Sort threads by root author."
4874 (gnus-article-sort-by-author
4875 (gnus-thread-header h1) (gnus-thread-header h2)))
4876
01c52d31
MB
4877(defsubst gnus-article-sort-by-recipient (h1 h2)
4878 "Sort articles by recipient."
4879 (gnus-string<
4880 (let ((extract (funcall
4881 gnus-extract-address-components
4882 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4883 (or (car extract) (cadr extract)))
4884 (let ((extract (funcall
4885 gnus-extract-address-components
4886 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4887 (or (car extract) (cadr extract)))))
4888
4889(defun gnus-thread-sort-by-recipient (h1 h2)
4890 "Sort threads by root recipient."
4891 (gnus-article-sort-by-recipient
4892 (gnus-thread-header h1) (gnus-thread-header h2)))
4893
eec82323
LMI
4894(defsubst gnus-article-sort-by-subject (h1 h2)
4895 "Sort articles by root subject."
b4fde39f 4896 (gnus-string<
eec82323
LMI
4897 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4898 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4899
4900(defun gnus-thread-sort-by-subject (h1 h2)
4901 "Sort threads by root subject."
4902 (gnus-article-sort-by-subject
4903 (gnus-thread-header h1) (gnus-thread-header h2)))
4904
4905(defsubst gnus-article-sort-by-date (h1 h2)
4906 "Sort articles by root article date."
16409b0b 4907 (time-less-p
eec82323
LMI
4908 (gnus-date-get-time (mail-header-date h1))
4909 (gnus-date-get-time (mail-header-date h2))))
4910
4911(defun gnus-thread-sort-by-date (h1 h2)
4912 "Sort threads by root article date."
4913 (gnus-article-sort-by-date
4914 (gnus-thread-header h1) (gnus-thread-header h2)))
4915
4916(defsubst gnus-article-sort-by-score (h1 h2)
4917 "Sort articles by root article score.
4918Unscored articles will be counted as having a score of zero."
4919 (> (or (cdr (assq (mail-header-number h1)
4920 gnus-newsgroup-scored))
4921 gnus-summary-default-score 0)
4922 (or (cdr (assq (mail-header-number h2)
4923 gnus-newsgroup-scored))
4924 gnus-summary-default-score 0)))
4925
4926(defun gnus-thread-sort-by-score (h1 h2)
4927 "Sort threads by root article score."
4928 (gnus-article-sort-by-score
4929 (gnus-thread-header h1) (gnus-thread-header h2)))
4930
4931(defun gnus-thread-sort-by-total-score (h1 h2)
4932 "Sort threads by the sum of all scores in the thread.
4933Unscored articles will be counted as having a score of zero."
4934 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4935
4936(defun gnus-thread-total-score (thread)
16409b0b 4937 ;; This function find the total score of THREAD.
23f87bed
MB
4938 (cond
4939 ((null thread)
4940 0)
4941 ((consp thread)
4942 (if (stringp (car thread))
4943 (apply gnus-thread-score-function 0
4944 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4945 (gnus-thread-total-score-1 thread)))
4946 (t
4947 (gnus-thread-total-score-1 (list thread)))))
4948
4949(defun gnus-thread-sort-by-most-recent-number (h1 h2)
4950 "Sort threads such that the thread with the most recently arrived article comes first."
4951 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4952
4953(defun gnus-thread-highest-number (thread)
4954 "Return the highest article number in THREAD."
4955 (apply 'max (mapcar (lambda (header)
4956 (mail-header-number header))
4957 (message-flatten-list thread))))
4958
4959(defun gnus-thread-sort-by-most-recent-date (h1 h2)
4960 "Sort threads such that the thread with the most recently dated article comes first."
4961 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4962
4963(defun gnus-thread-latest-date (thread)
4964 "Return the highest article date in THREAD."
4965 (let ((previous-time 0))
4966 (apply 'max
4967 (mapcar
4968 (lambda (header)
4969 (setq previous-time
4970 (condition-case ()
4971 (time-to-seconds (mail-header-parse-date
4972 (mail-header-date header)))
4973 (error previous-time))))
4974 (sort
4975 (message-flatten-list thread)
4976 (lambda (h1 h2)
4977 (< (mail-header-number h1)
4978 (mail-header-number h2))))))))
eec82323
LMI
4979
4980(defun gnus-thread-total-score-1 (root)
4981 ;; This function find the total score of the thread below ROOT.
4982 (setq root (car root))
4983 (apply gnus-thread-score-function
4984 (or (append
4985 (mapcar 'gnus-thread-total-score
6748645f 4986 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
4987 (when (> (mail-header-number root) 0)
4988 (list (or (cdr (assq (mail-header-number root)
4989 gnus-newsgroup-scored))
4990 gnus-summary-default-score 0))))
4991 (list gnus-summary-default-score)
4992 '(0))))
4993
4994;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4995(defvar gnus-tmp-prev-subject nil)
4996(defvar gnus-tmp-false-parent nil)
4997(defvar gnus-tmp-root-expunged nil)
4998(defvar gnus-tmp-dummy-line nil)
4999
16409b0b
GM
5000(defun gnus-extra-header (type &optional header)
5001 "Return the extra header of TYPE."
5002 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5003 ""))
5004
23f87bed
MB
5005(defvar gnus-tmp-thread-tree-header-string "")
5006
5007(defcustom gnus-sum-thread-tree-root "> "
5008 "With %B spec, used for the root of a thread.
5009If nil, use subject instead."
bf247b6e 5010 :version "22.1"
ad136a7c 5011 :type '(radio (const :format "%v " nil) string)
23f87bed 5012 :group 'gnus-thread)
01c52d31 5013
23f87bed
MB
5014(defcustom gnus-sum-thread-tree-false-root "> "
5015 "With %B spec, used for a false root of a thread.
5016If nil, use subject instead."
bf247b6e 5017 :version "22.1"
ad136a7c 5018 :type '(radio (const :format "%v " nil) string)
23f87bed 5019 :group 'gnus-thread)
01c52d31 5020
23f87bed
MB
5021(defcustom gnus-sum-thread-tree-single-indent ""
5022 "With %B spec, used for a thread with just one message.
5023If nil, use subject instead."
bf247b6e 5024 :version "22.1"
ad136a7c 5025 :type '(radio (const :format "%v " nil) string)
23f87bed 5026 :group 'gnus-thread)
01c52d31 5027
23f87bed
MB
5028(defcustom gnus-sum-thread-tree-vertical "| "
5029 "With %B spec, used for drawing a vertical line."
bf247b6e 5030 :version "22.1"
23f87bed
MB
5031 :type 'string
5032 :group 'gnus-thread)
01c52d31 5033
23f87bed
MB
5034(defcustom gnus-sum-thread-tree-indent " "
5035 "With %B spec, used for indenting."
bf247b6e 5036 :version "22.1"
23f87bed
MB
5037 :type 'string
5038 :group 'gnus-thread)
01c52d31 5039
23f87bed
MB
5040(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5041 "With %B spec, used for a leaf with brothers."
bf247b6e 5042 :version "22.1"
23f87bed
MB
5043 :type 'string
5044 :group 'gnus-thread)
01c52d31 5045
23f87bed
MB
5046(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5047 "With %B spec, used for a leaf without brothers."
bf247b6e 5048 :version "22.1"
23f87bed
MB
5049 :type 'string
5050 :group 'gnus-thread)
5051
1fc34624
GM
5052(defcustom gnus-summary-display-while-building nil
5053 "If non-nil, show and update the summary buffer as it's being built.
5054If the value is t, update the buffer after every line is inserted. If
5055the value is an integer (N), update the display every N lines."
5056 :version "22.1"
5057 :group 'gnus-thread
5058 :type '(choice (const :tag "off" nil)
5059 number
5060 (const :tag "frequently" t)))
5061
eec82323
LMI
5062(defun gnus-summary-prepare-threads (threads)
5063 "Prepare summary buffer from THREADS and indentation LEVEL.
5064THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5065or a straight list of headers."
5066 (gnus-message 7 "Generating summary...")
5067
5068 (setq gnus-newsgroup-threads threads)
5069 (beginning-of-line)
5070
5071 (let ((gnus-tmp-level 0)
5072 (default-score (or gnus-summary-default-score 0))
5073 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
5074 (building-line-count gnus-summary-display-while-building)
5075 (building-count (integerp gnus-summary-display-while-building))
eec82323 5076 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
5077 new-roots gnus-tmp-new-adopts thread-end simp-subject
5078 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
5079 gnus-tmp-replied gnus-tmp-subject-or-nil
5080 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5081 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
5082 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5083 tree-stack)
eec82323 5084
23f87bed
MB
5085 (setq gnus-tmp-prev-subject nil
5086 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
5087
5088 (if (vectorp (car threads))
5089 ;; If this is a straight (sic) list of headers, then a
5090 ;; threaded summary display isn't required, so we just create
5091 ;; an unthreaded one.
5092 (gnus-summary-prepare-unthreaded threads)
5093
5094 ;; Do the threaded display.
5095
23f87bed
MB
5096 (if gnus-summary-display-while-building
5097 (switch-to-buffer (buffer-name)))
eec82323
LMI
5098 (while (or threads stack gnus-tmp-new-adopts new-roots)
5099
5100 (if (and (= gnus-tmp-level 0)
eec82323
LMI
5101 (or (not stack)
5102 (= (caar stack) 0))
5103 (not gnus-tmp-false-parent)
5104 (or gnus-tmp-new-adopts new-roots))
5105 (if gnus-tmp-new-adopts
5106 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5107 thread (list (car gnus-tmp-new-adopts))
5108 gnus-tmp-header (caar thread)
5109 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5110 (when new-roots
5111 (setq thread (list (car new-roots))
5112 gnus-tmp-header (caar thread)
5113 new-roots (cdr new-roots))))
5114
5115 (if threads
5116 ;; If there are some threads, we do them before the
5117 ;; threads on the stack.
5118 (setq thread threads
5119 gnus-tmp-header (caar thread))
5120 ;; There were no current threads, so we pop something off
5121 ;; the stack.
5122 (setq state (car stack)
5123 gnus-tmp-level (car state)
23f87bed
MB
5124 tree-stack (cadr state)
5125 thread (caddr state)
eec82323
LMI
5126 stack (cdr stack)
5127 gnus-tmp-header (caar thread))))
5128
5129 (setq gnus-tmp-false-parent nil)
5130 (setq gnus-tmp-root-expunged nil)
5131 (setq thread-end nil)
5132
5133 (if (stringp gnus-tmp-header)
5134 ;; The header is a dummy root.
5135 (cond
5136 ((eq gnus-summary-make-false-root 'adopt)
5137 ;; We let the first article adopt the rest.
5138 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5139 (cddar thread)))
5140 (setq gnus-tmp-gathered
5141 (nconc (mapcar
5142 (lambda (h) (mail-header-number (car h)))
5143 (cddar thread))
5144 gnus-tmp-gathered))
5145 (setq thread (cons (list (caar thread)
5146 (cadar thread))
5147 (cdr thread)))
5148 (setq gnus-tmp-level -1
5149 gnus-tmp-false-parent t))
5150 ((eq gnus-summary-make-false-root 'empty)
5151 ;; We print adopted articles with empty subject fields.
5152 (setq gnus-tmp-gathered
5153 (nconc (mapcar
5154 (lambda (h) (mail-header-number (car h)))
5155 (cddar thread))
5156 gnus-tmp-gathered))
5157 (setq gnus-tmp-level -1))
5158 ((eq gnus-summary-make-false-root 'dummy)
5159 ;; We remember that we probably want to output a dummy
5160 ;; root.
5161 (setq gnus-tmp-dummy-line gnus-tmp-header)
5162 (setq gnus-tmp-prev-subject gnus-tmp-header))
5163 (t
5164 ;; We do not make a root for the gathered
5165 ;; sub-threads at all.
5166 (setq gnus-tmp-level -1)))
5167
5168 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
5169 subject (mail-header-subject gnus-tmp-header)
5170 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
5171
5172 (cond
5173 ;; If the thread has changed subject, we might want to make
5174 ;; this subthread into a root.
5175 ((and (null gnus-thread-ignore-subject)
5176 (not (zerop gnus-tmp-level))
5177 gnus-tmp-prev-subject
23f87bed 5178 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5179 (setq new-roots (nconc new-roots (list (car thread)))
5180 thread-end t
5181 gnus-tmp-header nil))
5182 ;; If the article lies outside the current limit,
5183 ;; then we do not display it.
5184 ((not (memq number gnus-newsgroup-limit))
5185 (setq gnus-tmp-gathered
5186 (nconc (mapcar
5187 (lambda (h) (mail-header-number (car h)))
5188 (cdar thread))
5189 gnus-tmp-gathered))
5190 (setq gnus-tmp-new-adopts (if (cdar thread)
5191 (append gnus-tmp-new-adopts
5192 (cdar thread))
5193 gnus-tmp-new-adopts)
5194 thread-end t
5195 gnus-tmp-header nil)
5196 (when (zerop gnus-tmp-level)
5197 (setq gnus-tmp-root-expunged t)))
5198 ;; Perhaps this article is to be marked as read?
5199 ((and gnus-summary-mark-below
5200 (< (or (cdr (assq number gnus-newsgroup-scored))
5201 default-score)
5202 gnus-summary-mark-below)
5203 ;; Don't touch sparse articles.
5204 (not (gnus-summary-article-sparse-p number))
5205 (not (gnus-summary-article-ancient-p number)))
5206 (setq gnus-newsgroup-unreads
5207 (delq number gnus-newsgroup-unreads))
5208 (if gnus-newsgroup-auto-expire
23f87bed
MB
5209 (setq gnus-newsgroup-expirable
5210 (gnus-add-to-sorted-list
5211 gnus-newsgroup-expirable number))
eec82323
LMI
5212 (push (cons number gnus-low-score-mark)
5213 gnus-newsgroup-reads))))
5214
5215 (when gnus-tmp-header
5216 ;; We may have an old dummy line to output before this
5217 ;; article.
6748645f
LMI
5218 (when (and gnus-tmp-dummy-line
5219 (gnus-subject-equal
5220 gnus-tmp-dummy-line
5221 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
5222 (gnus-summary-insert-dummy-line
5223 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5224 (setq gnus-tmp-dummy-line nil))
5225
5226 ;; Compute the mark.
5227 (setq gnus-tmp-unread (gnus-article-mark number))
5228
5229 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5230 gnus-tmp-header gnus-tmp-level)
5231 gnus-newsgroup-data)
5232
5233 ;; Actually insert the line.
5234 (setq
5235 gnus-tmp-subject-or-nil
5236 (cond
5237 ((and gnus-thread-ignore-subject
5238 gnus-tmp-prev-subject
23f87bed 5239 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5240 subject)
5241 ((zerop gnus-tmp-level)
5242 (if (and (eq gnus-summary-make-false-root 'empty)
5243 (memq number gnus-tmp-gathered)
5244 gnus-tmp-prev-subject
23f87bed 5245 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5246 gnus-summary-same-subject
5247 subject))
5248 (t gnus-summary-same-subject)))
5249 (if (and (eq gnus-summary-make-false-root 'adopt)
5250 (= gnus-tmp-level 1)
5251 (memq number gnus-tmp-gathered))
5252 (setq gnus-tmp-opening-bracket ?\<
5253 gnus-tmp-closing-bracket ?\>)
5254 (setq gnus-tmp-opening-bracket ?\[
5255 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5256 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5257 (gnus-make-thread-indent-array
5258 (max (* 2 (length gnus-thread-indent-array))
5259 gnus-tmp-level)))
eec82323
LMI
5260 (setq
5261 gnus-tmp-indentation
5262 (aref gnus-thread-indent-array gnus-tmp-level)
5263 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5264 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5265 gnus-summary-default-score 0)
5266 gnus-tmp-score-char
5267 (if (or (null gnus-summary-default-score)
5268 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5269 gnus-summary-zcore-fuzz))
23f87bed 5270 ? ;Whitespace
eec82323
LMI
5271 (if (< gnus-tmp-score gnus-summary-default-score)
5272 gnus-score-below-mark gnus-score-over-mark))
5273 gnus-tmp-replied
5274 (cond ((memq number gnus-newsgroup-processable)
5275 gnus-process-mark)
5276 ((memq number gnus-newsgroup-cached)
5277 gnus-cached-mark)
5278 ((memq number gnus-newsgroup-replied)
5279 gnus-replied-mark)
23f87bed
MB
5280 ((memq number gnus-newsgroup-forwarded)
5281 gnus-forwarded-mark)
eec82323
LMI
5282 ((memq number gnus-newsgroup-saved)
5283 gnus-saved-mark)
23f87bed
MB
5284 ((memq number gnus-newsgroup-recent)
5285 gnus-recent-mark)
5286 ((memq number gnus-newsgroup-unseen)
5287 gnus-unseen-mark)
5288 (t gnus-no-mark))
5289 gnus-tmp-downloaded
5290 (cond ((memq number gnus-newsgroup-undownloaded)
5291 gnus-undownloaded-mark)
5292 (gnus-newsgroup-agentized
5293 gnus-downloaded-mark)
5294 (t
5295 gnus-no-mark))
eec82323
LMI
5296 gnus-tmp-from (mail-header-from gnus-tmp-header)
5297 gnus-tmp-name
5298 (cond
5299 ((string-match "<[^>]+> *$" gnus-tmp-from)
5300 (setq beg-match (match-beginning 0))
23f87bed
MB
5301 (or (and (string-match "^\".+\"" gnus-tmp-from)
5302 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5303 (substring gnus-tmp-from 0 beg-match)))
5304 ((string-match "(.+)" gnus-tmp-from)
5305 (substring gnus-tmp-from
5306 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5307 (t gnus-tmp-from))
5308
5309 ;; Do the %B string
5310 gnus-tmp-thread-tree-header-string
5311 (cond
5312 ((not gnus-show-threads) "")
5313 ((zerop gnus-tmp-level)
5314 (cond ((cdar thread)
5315 (or gnus-sum-thread-tree-root subject))
5316 (gnus-tmp-new-adopts
5317 (or gnus-sum-thread-tree-false-root subject))
5318 (t
5319 (or gnus-sum-thread-tree-single-indent subject))))
5320 (t
5321 (concat (apply 'concat
5322 (mapcar (lambda (item)
5323 (if (= item 1)
5324 gnus-sum-thread-tree-vertical
5325 gnus-sum-thread-tree-indent))
5326 (cdr (reverse tree-stack))))
5327 (if (nth 1 thread)
5328 gnus-sum-thread-tree-leaf-with-other
5329 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5330 (when (string= gnus-tmp-name "")
5331 (setq gnus-tmp-name gnus-tmp-from))
5332 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5333 (setq gnus-tmp-lines -1))
5334 (if (= gnus-tmp-lines -1)
5335 (setq gnus-tmp-lines "?")
5336 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5337 (gnus-put-text-property
eec82323
LMI
5338 (point)
5339 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 5340 'gnus-number number)
eec82323
LMI
5341 (when gnus-visual-p
5342 (forward-line -1)
6748645f 5343 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
5344 (forward-line 1))
5345
23f87bed 5346 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5347
5348 (when (nth 1 thread)
23f87bed
MB
5349 (push (list (max 0 gnus-tmp-level)
5350 (copy-sequence tree-stack)
5351 (nthcdr 1 thread))
5352 stack))
5353 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5354 (incf gnus-tmp-level)
5355 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5356 (if gnus-summary-display-while-building
5357 (if building-count
5358 (progn
5359 ;; use a set frequency
5360 (setq building-line-count (1- building-line-count))
5361 (when (= building-line-count 0)
5362 (sit-for 0)
5363 (setq building-line-count
5364 gnus-summary-display-while-building)))
5365 ;; always
5366 (sit-for 0)))
eec82323
LMI
5367 (unless threads
5368 (setq gnus-tmp-level 0)))))
5369 (gnus-message 7 "Generating summary...done"))
5370
5371(defun gnus-summary-prepare-unthreaded (headers)
5372 "Generate an unthreaded summary buffer based on HEADERS."
5373 (let (header number mark)
5374
5375 (beginning-of-line)
5376
5377 (while headers
5378 ;; We may have to root out some bad articles...
5379 (when (memq (setq number (mail-header-number
5380 (setq header (pop headers))))
5381 gnus-newsgroup-limit)
5382 ;; Mark article as read when it has a low score.
5383 (when (and gnus-summary-mark-below
5384 (< (or (cdr (assq number gnus-newsgroup-scored))
5385 gnus-summary-default-score 0)
5386 gnus-summary-mark-below)
5387 (not (gnus-summary-article-ancient-p number)))
5388 (setq gnus-newsgroup-unreads
5389 (delq number gnus-newsgroup-unreads))
5390 (if gnus-newsgroup-auto-expire
5391 (push number gnus-newsgroup-expirable)
5392 (push (cons number gnus-low-score-mark)
5393 gnus-newsgroup-reads)))
5394
5395 (setq mark (gnus-article-mark number))
5396 (push (gnus-data-make number mark (1+ (point)) header 0)
5397 gnus-newsgroup-data)
5398 (gnus-summary-insert-line
5399 header 0 number
23f87bed 5400 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5401 mark (memq number gnus-newsgroup-replied)
5402 (memq number gnus-newsgroup-expirable)
5403 (mail-header-subject header) nil
5404 (cdr (assq number gnus-newsgroup-scored))
5405 (memq number gnus-newsgroup-processable))))))
5406
16409b0b
GM
5407(defun gnus-summary-remove-list-identifiers ()
5408 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5409 (let ((regexp (if (consp gnus-list-identifiers)
5410 (mapconcat 'identity gnus-list-identifiers " *\\|")
5411 gnus-list-identifiers))
5412 changed subject)
5413 (when regexp
01c52d31 5414 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
23f87bed
MB
5415 (dolist (header gnus-newsgroup-headers)
5416 (setq subject (mail-header-subject header)
5417 changed nil)
01c52d31 5418 (while (string-match regexp subject)
23f87bed 5419 (setq subject
01c52d31 5420 (concat (substring subject 0 (match-beginning 1))
23f87bed
MB
5421 (substring subject (match-end 0)))
5422 changed t))
23f87bed 5423 (when changed
01c52d31
MB
5424 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5425 (setq subject
5426 (concat (substring subject 0 (match-beginning 1))
5427 (substring subject (match-end 1)))))
23f87bed
MB
5428 (mail-header-set-subject header subject))))))
5429
5430(defun gnus-fetch-headers (articles)
5431 "Fetch headers of ARTICLES."
5432 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5433 (gnus-message 5 "Fetching headers for %s..." name)
5434 (prog1
5435 (if (eq 'nov
5436 (setq gnus-headers-retrieved-by
5437 (gnus-retrieve-headers
5438 articles gnus-newsgroup-name
5439 ;; We might want to fetch old headers, but
5440 ;; not if there is only 1 article.
5441 (and (or (and
5442 (not (eq gnus-fetch-old-headers 'some))
5443 (not (numberp gnus-fetch-old-headers)))
5444 (> (length articles) 1))
5445 gnus-fetch-old-headers))))
5446 (gnus-get-newsgroup-headers-xover
5447 articles nil nil gnus-newsgroup-name t)
5448 (gnus-get-newsgroup-headers))
5449 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5450
6748645f 5451(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5452 "Select newsgroup GROUP.
6748645f
LMI
5453If READ-ALL is non-nil, all articles in the group are selected.
5454If SELECT-ARTICLES, only select those articles from GROUP."
01c52d31 5455 (let* ((entry (gnus-group-entry group))
eec82323
LMI
5456 ;;!!! Dirty hack; should be removed.
5457 (gnus-summary-ignore-duplicates
23f87bed 5458 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5459 t
5460 gnus-summary-ignore-duplicates))
5461 (info (nth 2 entry))
01c52d31 5462 charset articles fetched-articles cached)
eec82323
LMI
5463
5464 (unless (gnus-check-server
475e0e0c
GM
5465 (set (make-local-variable 'gnus-current-select-method)
5466 (gnus-find-method-for-group group)))
eec82323 5467 (error "Couldn't open server"))
01c52d31 5468 (setq charset (gnus-group-name-charset gnus-current-select-method group))
eec82323
LMI
5469
5470 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5471 (gnus-activate-group group) ; Or we can activate it...
5472 (progn ; Or we bug out.
5473 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5474 (gnus-kill-buffer (current-buffer)))
01c52d31
MB
5475 (error
5476 "Couldn't activate group %s: %s"
5477 (mm-decode-coding-string group charset)
5478 (mm-decode-coding-string (gnus-status-message group) charset))))
eec82323
LMI
5479
5480 (unless (gnus-request-group group t)
01c52d31
MB
5481 (when (equal major-mode 'gnus-summary-mode)
5482 (gnus-kill-buffer (current-buffer)))
5483 (error "Couldn't request group %s: %s"
5484 (mm-decode-coding-string group charset)
5485 (mm-decode-coding-string (gnus-status-message group) charset)))
eec82323 5486
23f87bed 5487 (when gnus-agent
54506618 5488 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5489
23f87bed
MB
5490 (setq gnus-summary-use-undownloaded-faces
5491 (gnus-agent-find-parameter
5492 group
5493 'agent-enable-undownloaded-faces)))
5494
5495 (setq gnus-newsgroup-name group
5496 gnus-newsgroup-unselected nil
5497 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5498
5499 (let ((display (gnus-group-find-parameter group 'display)))
5500 (setq gnus-newsgroup-display
5501 (cond
5502 ((not (zerop (or (car-safe read-all) 0)))
5503 ;; The user entered the group with C-u SPC/RET, let's show
5504 ;; all articles.
5505 'gnus-not-ignore)
5506 ((eq display 'all)
5507 'gnus-not-ignore)
5508 ((arrayp display)
5509 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5510 ((numberp display)
5511 ;; The following is probably the "correct" solution, but
5512 ;; it makes Gnus fetch all headers and then limit the
5513 ;; articles (which is slow), so instead we hack the
5514 ;; select-articles parameter instead. -- Simon Josefsson
5515 ;; <jas@kth.se>
5516 ;;
5517 ;; (gnus-byte-compile
5518 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5519 ;; display)))))
5520 (setq select-articles
5521 (gnus-uncompress-range
5522 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5523 (if (> tmp 0)
5524 tmp
5525 1))
5526 (cdr (gnus-active group)))))
5527 nil)
5528 (t
5529 nil))))
eec82323 5530
23f87bed 5531 (gnus-summary-setup-default-charset)
eec82323
LMI
5532
5533 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5534 (when (gnus-virtual-group-p group)
5535 (setq cached gnus-newsgroup-cached))
5536
5537 (setq gnus-newsgroup-unreads
23f87bed
MB
5538 (gnus-sorted-ndifference
5539 (gnus-sorted-ndifference gnus-newsgroup-unreads
5540 gnus-newsgroup-marked)
eec82323
LMI
5541 gnus-newsgroup-dormant))
5542
5543 (setq gnus-newsgroup-processable nil)
5544
5545 (gnus-update-read-articles group gnus-newsgroup-unreads)
eec82323 5546
23f87bed
MB
5547 ;; Adjust and set lists of article marks.
5548 (when info
5549 (gnus-adjust-marked-articles info))
6748645f
LMI
5550 (if (setq articles select-articles)
5551 (setq gnus-newsgroup-unselected
23f87bed 5552 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5553 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5554
5555 (cond
5556 ((null articles)
5557 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5558 'quit)
5559 ((eq articles 0) nil)
5560 (t
5561 ;; Init the dependencies hash table.
5562 (setq gnus-newsgroup-dependencies
5563 (gnus-make-hashtable (length articles)))
16409b0b 5564 (gnus-set-global-variables)
eec82323 5565 ;; Retrieve the headers and read them in.
23f87bed
MB
5566
5567 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5568
5569 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5570 (when cached
5571 (setq gnus-newsgroup-cached cached))
5572
5573 ;; Suppress duplicates?
5574 (when gnus-suppress-duplicates
5575 (gnus-dup-suppress-articles))
5576
5577 ;; Set the initial limit.
5578 (setq gnus-newsgroup-limit (copy-sequence articles))
5579 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5580 (setq fetched-articles
5581 (mapcar (lambda (headers) (mail-header-number headers))
5582 gnus-newsgroup-headers))
5583 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5584 (setq gnus-newsgroup-unreads
23f87bed
MB
5585 (gnus-sorted-nintersection
5586 gnus-newsgroup-unreads fetched-articles))
5587 (gnus-compute-unseen-list)
5588
eec82323
LMI
5589 ;; Removed marked articles that do not exist.
5590 (gnus-update-missing-marks
23f87bed 5591 (gnus-sorted-difference articles fetched-articles))
eec82323 5592 ;; We might want to build some more threads first.
6748645f
LMI
5593 (when (and gnus-fetch-old-headers
5594 (eq gnus-headers-retrieved-by 'nov))
5595 (if (eq gnus-fetch-old-headers 'invisible)
5596 (gnus-build-all-threads)
5597 (gnus-build-old-threads)))
5598 ;; Let the Gnus agent mark articles as read.
5599 (when gnus-agent
5600 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5601 ;; Remove list identifiers from subject
5602 (when gnus-list-identifiers
5603 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5604 ;; Check whether auto-expire is to be done in this group.
5605 (setq gnus-newsgroup-auto-expire
5606 (gnus-group-auto-expirable-p group))
5607 ;; Set up the article buffer now, if necessary.
01c52d31
MB
5608 (unless (and gnus-single-article-buffer
5609 (equal gnus-article-buffer "*Article*"))
eec82323
LMI
5610 (gnus-article-setup-buffer))
5611 ;; First and last article in this newsgroup.
5612 (when gnus-newsgroup-headers
5613 (setq gnus-newsgroup-begin
5614 (mail-header-number (car gnus-newsgroup-headers))
5615 gnus-newsgroup-end
5616 (mail-header-number
5617 (gnus-last-element gnus-newsgroup-headers))))
5618 ;; GROUP is successfully selected.
5619 (or gnus-newsgroup-headers t)))))
5620
23f87bed
MB
5621(defun gnus-compute-unseen-list ()
5622 ;; The `seen' marks are treated specially.
5623 (if (not gnus-newsgroup-seen)
5624 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5625 (setq gnus-newsgroup-unseen
5626 (gnus-inverse-list-range-intersection
5627 gnus-newsgroup-articles gnus-newsgroup-seen))))
5628
d09ae6ca
GM
5629(declare-function gnus-get-predicate "gnus-agent" (predicate))
5630
23f87bed
MB
5631(defun gnus-summary-display-make-predicate (display)
5632 (require 'gnus-agent)
5633 (when (= (length display) 1)
5634 (setq display (car display)))
5635 (unless gnus-summary-display-cache
5636 (dolist (elem (append '((unread . unread)
5637 (read . read)
5638 (unseen . unseen))
5639 gnus-article-mark-lists))
5640 (push (cons (cdr elem)
5641 (gnus-byte-compile
5642 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5643 gnus-summary-display-cache)))
5644 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5645 (gnus-category-predicate-cache gnus-summary-display-cache))
5646 (gnus-get-predicate display)))
5647
5648;; Uses the dynamically bound `number' variable.
9efa445f 5649(defvar number)
23f87bed
MB
5650(defun gnus-article-marked-p (type &optional article)
5651 (let ((article (or article number)))
5652 (cond
5653 ((eq type 'tick)
5654 (memq article gnus-newsgroup-marked))
5655 ((eq type 'spam)
5656 (memq article gnus-newsgroup-spam-marked))
5657 ((eq type 'unsend)
5658 (memq article gnus-newsgroup-unsendable))
5659 ((eq type 'undownload)
5660 (memq article gnus-newsgroup-undownloaded))
5661 ((eq type 'download)
5662 (memq article gnus-newsgroup-downloadable))
5663 ((eq type 'unread)
5664 (memq article gnus-newsgroup-unreads))
5665 ((eq type 'read)
5666 (memq article gnus-newsgroup-reads))
5667 ((eq type 'dormant)
5668 (memq article gnus-newsgroup-dormant) )
5669 ((eq type 'expire)
5670 (memq article gnus-newsgroup-expirable))
5671 ((eq type 'reply)
5672 (memq article gnus-newsgroup-replied))
5673 ((eq type 'killed)
5674 (memq article gnus-newsgroup-killed))
5675 ((eq type 'bookmark)
5676 (assq article gnus-newsgroup-bookmarks))
5677 ((eq type 'score)
5678 (assq article gnus-newsgroup-scored))
5679 ((eq type 'save)
5680 (memq article gnus-newsgroup-saved))
5681 ((eq type 'cache)
5682 (memq article gnus-newsgroup-cached))
5683 ((eq type 'forward)
5684 (memq article gnus-newsgroup-forwarded))
5685 ((eq type 'seen)
5686 (not (memq article gnus-newsgroup-unseen)))
5687 ((eq type 'recent)
5688 (memq article gnus-newsgroup-recent))
5689 (t t))))
5690
eec82323 5691(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5692 "Find out what articles the user wants to read."
26c9afc3 5693 (let* ((articles
eec82323
LMI
5694 ;; Select all articles if `read-all' is non-nil, or if there
5695 ;; are no unread articles.
5696 (if (or read-all
5697 (and (zerop (length gnus-newsgroup-marked))
5698 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5699 ;; Fetch all if the predicate is non-nil.
5700 gnus-newsgroup-display)
5701 ;; We want to select the headers for all the articles in
5702 ;; the group, so we select either all the active
5703 ;; articles in the group, or (if that's nil), the
5704 ;; articles in the cache.
16409b0b 5705 (or
4b70e299 5706 (if gnus-newsgroup-maximum-articles
11abff8e
MB
5707 (let ((active (gnus-active group)))
5708 (gnus-uncompress-range
5709 (cons (max (car active)
4b70e299
MB
5710 (- (cdr active)
5711 gnus-newsgroup-maximum-articles
5712 -1))
11abff8e
MB
5713 (cdr active))))
5714 (gnus-uncompress-range (gnus-active group)))
16409b0b 5715 (gnus-cache-articles-in-group group))
23f87bed
MB
5716 ;; Select only the "normal" subset of articles.
5717 (gnus-sorted-nunion
5718 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5719 gnus-newsgroup-unreads)))
eec82323
LMI
5720 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5721 (scored (length scored-list))
5722 (number (length articles))
5723 (marked (+ (length gnus-newsgroup-marked)
5724 (length gnus-newsgroup-dormant)))
5725 (select
5726 (cond
5727 ((numberp read-all)
5728 read-all)
23f87bed
MB
5729 ((numberp gnus-newsgroup-display)
5730 gnus-newsgroup-display)
eec82323
LMI
5731 (t
5732 (condition-case ()
5733 (cond
5734 ((and (or (<= scored marked) (= scored number))
5735 (numberp gnus-large-newsgroup)
5736 (> number gnus-large-newsgroup))
23f87bed
MB
5737 (let* ((cursor-in-echo-area nil)
5738 (initial (gnus-parameter-large-newsgroup-initial
5739 gnus-newsgroup-name))
5740 (input
5741 (read-string
5742 (format
5743 "How many articles from %s (%s %d): "
01c52d31 5744 (gnus-group-decoded-name gnus-newsgroup-name)
23f87bed
MB
5745 (if initial "max" "default")
5746 number)
5747 (if initial
5748 (cons (number-to-string initial)
5749 0)))))
eec82323
LMI
5750 (if (string-match "^[ \t]*$" input) number input)))
5751 ((and (> scored marked) (< scored number)
5752 (> (- scored number) 20))
5753 (let ((input
5754 (read-string
5755 (format "%s %s (%d scored, %d total): "
5756 "How many articles from"
23f87bed
MB
5757 (gnus-group-decoded-name group)
5758 scored number))))
eec82323
LMI
5759 (if (string-match "^[ \t]*$" input)
5760 number input)))
5761 (t number))
d4dfaa19
DL
5762 (quit
5763 (message "Quit getting the articles to read")
5764 nil))))))
eec82323
LMI
5765 (setq select (if (stringp select) (string-to-number select) select))
5766 (if (or (null select) (zerop select))
5767 select
5768 (if (and (not (zerop scored)) (<= (abs select) scored))
5769 (progn
5770 (setq articles (sort scored-list '<))
5771 (setq number (length articles)))
5772 (setq articles (copy-sequence articles)))
5773
5774 (when (< (abs select) number)
5775 (if (< select 0)
5776 ;; Select the N oldest articles.
5777 (setcdr (nthcdr (1- (abs select)) articles) nil)
5778 ;; Select the N most recent articles.
5779 (setq articles (nthcdr (- number select) articles))))
5780 (setq gnus-newsgroup-unselected
23f87bed 5781 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5782 (when gnus-alter-articles-to-read-function
23f87bed 5783 (setq articles
a1506d29 5784 (sort
16409b0b 5785 (funcall gnus-alter-articles-to-read-function
23f87bed 5786 gnus-newsgroup-name articles)
16409b0b 5787 '<)))
eec82323
LMI
5788 articles)))
5789
5790(defun gnus-killed-articles (killed articles)
5791 (let (out)
5792 (while articles
5793 (when (inline (gnus-member-of-range (car articles) killed))
5794 (push (car articles) out))
5795 (setq articles (cdr articles)))
5796 out))
5797
5798(defun gnus-uncompress-marks (marks)
5799 "Uncompress the mark ranges in MARKS."
5800 (let ((uncompressed '(score bookmark))
5801 out)
5802 (while marks
5803 (if (memq (caar marks) uncompressed)
5804 (push (car marks) out)
5805 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5806 (setq marks (cdr marks)))
5807 out))
5808
23f87bed
MB
5809(defun gnus-article-mark-to-type (mark)
5810 "Return the type of MARK."
5811 (or (cadr (assq mark gnus-article-special-mark-lists))
5812 'list))
5813
5814(defun gnus-article-unpropagatable-p (mark)
5815 "Return whether MARK should be propagated to back end."
5816 (memq mark gnus-article-unpropagated-mark-lists))
5817
eec82323 5818(defun gnus-adjust-marked-articles (info)
16409b0b 5819 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5820 (let* ((marked-lists (gnus-info-marks info))
5821 (active (gnus-active (gnus-info-group info)))
5822 (min (car active))
5823 (max (cdr active))
5824 (types gnus-article-mark-lists)
54506618
MB
5825 marks var articles article mark mark-type
5826 bgn end)
eec82323 5827
23f87bed
MB
5828 (dolist (marks marked-lists)
5829 (setq mark (car marks)
5830 mark-type (gnus-article-mark-to-type mark)
5831 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5832
23f87bed
MB
5833 ;; We set the variable according to the type of the marks list,
5834 ;; and then adjust the marks to a subset of the active articles.
eec82323 5835 (cond
54506618 5836 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5837 ((eq mark-type 'list)
54506618
MB
5838 ;; Simultaneously uncompress and clip to active range
5839 ;; See gnus-uncompress-range for a description of possible marks
5840 (let (l lh)
5841 (if (not (cadr marks))
5842 (set var nil)
5843 (setq articles (if (numberp (cddr marks))
5844 (list (cdr marks))
5845 (cdr marks))
5846 lh (cons nil nil)
5847 l lh)
5848
5849 (while (setq article (pop articles))
5850 (cond ((consp article)
5851 (setq bgn (max (car article) min)
5852 end (min (cdr article) max))
5853 (while (<= bgn end)
5854 (setq l (setcdr l (cons bgn nil))
5855 bgn (1+ bgn))))
5856 ((and (<= min article)
5857 (>= max article))
5858 (setq l (setcdr l (cons article nil))))))
5859 (set var (cdr lh)))))
eec82323 5860 ;; Adjust assocs.
23f87bed
MB
5861 ((eq mark-type 'tuple)
5862 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5863 (when (not (listp (cdr (symbol-value var))))
5864 (set var (list (symbol-value var))))
5865 (when (not (listp (cdr articles)))
5866 (setq articles (list articles)))
eec82323
LMI
5867 (while articles
5868 (when (or (not (consp (setq article (pop articles))))
5869 (< (car article) min)
5870 (> (car article) max))
23f87bed
MB
5871 (set var (delq article (symbol-value var))))))
5872 ;; Adjust ranges (sloppily).
5873 ((eq mark-type 'range)
5874 (cond
5875 ((eq mark 'seen)
5876 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5877 ;; It should be (seen (NUM1 . NUM2)).
5878 (when (numberp (cddr marks))
5879 (setcdr marks (list (cdr marks))))
5880 (setq articles (cdr marks))
5881 (while (and articles
5882 (or (and (consp (car articles))
5883 (> min (cdar articles)))
5884 (and (numberp (car articles))
5885 (> min (car articles)))))
5886 (pop articles))
5887 (set var articles))))))))
eec82323
LMI
5888
5889(defun gnus-update-missing-marks (missing)
6748645f 5890 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 5891 (when missing
23f87bed 5892 (let (var m)
eec82323 5893 ;; Go through all types.
23f87bed
MB
5894 (dolist (elem gnus-article-mark-lists)
5895 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5896 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5897 (when (symbol-value var)
5898 ;; This list has articles. So we delete all missing
5899 ;; articles from it.
5900 (setq m missing)
5901 (while m
5902 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
5903
5904(defun gnus-update-marks ()
5905 "Enter the various lists of marked articles into the newsgroup info list."
5906 (let ((types gnus-article-mark-lists)
5907 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 5908 type list newmarked symbol delta-marks)
eec82323 5909 (when info
16409b0b 5910 ;; Add all marks lists to the list of marks lists.
eec82323 5911 (while (setq type (pop types))
16409b0b
GM
5912 (setq list (symbol-value
5913 (setq symbol
23f87bed 5914 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 5915
16409b0b 5916 (when list
eec82323
LMI
5917 ;; Get rid of the entries of the articles that have the
5918 ;; default score.
5919 (when (and (eq (cdr type) 'score)
5920 gnus-save-score
5921 list)
5922 (let* ((arts list)
5923 (prev (cons nil list))
5924 (all prev))
5925 (while arts
5926 (if (or (not (consp (car arts)))
5927 (= (cdar arts) gnus-summary-default-score))
5928 (setcdr prev (cdr arts))
5929 (setq prev arts))
5930 (setq arts (cdr arts)))
16409b0b
GM
5931 (setq list (cdr all)))))
5932
23f87bed
MB
5933 (when (eq (cdr type) 'seen)
5934 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5935
5936 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 5937 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 5938
23f87bed
MB
5939 (when (and (gnus-check-backend-function
5940 'request-set-mark gnus-newsgroup-name)
5941 (not (gnus-article-unpropagatable-p (cdr type))))
5942 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5943 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5944 (add (gnus-remove-from-range
5945 (gnus-copy-sequence list) old)))
5946 (when add
5947 (push (list add 'add (list (cdr type))) delta-marks))
5948 (when del
5949 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 5950
16409b0b
GM
5951 (when list
5952 (push (cons (cdr type) list) newmarked)))
5953
5954 (when delta-marks
5955 (unless (gnus-check-group gnus-newsgroup-name)
5956 (error "Can't open server for %s" gnus-newsgroup-name))
5957 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 5958
eec82323
LMI
5959 ;; Enter these new marks into the info of the group.
5960 (if (nthcdr 3 info)
5961 (setcar (nthcdr 3 info) newmarked)
5962 ;; Add the marks lists to the end of the info.
5963 (when newmarked
5964 (setcdr (nthcdr 2 info) (list newmarked))))
5965
5966 ;; Cut off the end of the info if there's nothing else there.
5967 (let ((i 5))
5968 (while (and (> i 2)
5969 (not (nth i info)))
5970 (when (nthcdr (decf i) info)
5971 (setcdr (nthcdr i info) nil)))))))
5972
5973(defun gnus-set-mode-line (where)
16409b0b 5974 "Set the mode line of the article or summary buffers.
eec82323
LMI
5975If WHERE is `summary', the summary mode line format will be used."
5976 ;; Is this mode line one we keep updated?
16409b0b
GM
5977 (when (and (memq where gnus-updated-mode-lines)
5978 (symbol-value
5979 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323 5980 (let (mode-string)
c7a91ce1
SM
5981 ;; We evaluate this in the summary buffer since these
5982 ;; variables are buffer-local to that buffer.
5983 (with-current-buffer gnus-summary-buffer
5984 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
5985 ;; below.
5986 (let* ((mformat (symbol-value
5987 (intern
5988 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
5989 (gnus-tmp-group-name (gnus-mode-string-quote
5990 (gnus-group-decoded-name
5991 gnus-newsgroup-name)))
eec82323
LMI
5992 (gnus-tmp-article-number (or gnus-current-article 0))
5993 (gnus-tmp-unread gnus-newsgroup-unreads)
5994 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5995 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5996 (gnus-tmp-unread-and-unselected
5997 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5998 (zerop gnus-tmp-unselected))
5999 "")
6000 ((zerop gnus-tmp-unselected)
6001 (format "{%d more}" gnus-tmp-unread-and-unticked))
6002 (t (format "{%d(+%d) more}"
6003 gnus-tmp-unread-and-unticked
6004 gnus-tmp-unselected))))
6005 (gnus-tmp-subject
6006 (if (and gnus-current-headers
6007 (vectorp gnus-current-headers))
6008 (gnus-mode-string-quote
6009 (mail-header-subject gnus-current-headers))
6010 ""))
6011 bufname-length max-len
23f87bed 6012 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
6013 (setq mode-string (eval mformat))
6014 (setq bufname-length (if (string-match "%b" mode-string)
6015 (- (length
6016 (buffer-name
6017 (if (eq where 'summary)
6018 nil
6019 (get-buffer gnus-article-buffer))))
6020 2)
6021 0))
6022 (setq max-len (max 4 (if gnus-mode-non-string-length
6023 (- (window-width)
6024 gnus-mode-non-string-length
6025 bufname-length)
6026 (length mode-string))))
6027 ;; We might have to chop a bit of the string off...
6028 (when (> (length mode-string) max-len)
6029 (setq mode-string
16409b0b 6030 (concat (truncate-string-to-width mode-string (- max-len 3))
eec82323
LMI
6031 "...")))
6032 ;; Pad the mode string a bit.
6033 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
6034 ;; Update the mode line.
6035 (setq mode-line-buffer-identification
6036 (gnus-mode-line-buffer-identification (list mode-string)))
6037 (set-buffer-modified-p t))))
6038
6039(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6040 "Go through the HEADERS list and add all Xrefs to a hash table.
6041The resulting hash table is returned, or nil if no Xrefs were found."
6042 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6043 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6044 (xref-hashtb (gnus-make-hashtable))
6045 start group entry number xrefs header)
6046 (while headers
6047 (setq header (pop headers))
6048 (when (and (setq xrefs (mail-header-xref header))
6049 (not (memq (setq number (mail-header-number header))
6050 unreads)))
6051 (setq start 0)
6052 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6053 (setq start (match-end 0))
6054 (setq group (if prefix
6055 (concat prefix (substring xrefs (match-beginning 1)
6056 (match-end 1)))
6057 (substring xrefs (match-beginning 1) (match-end 1))))
6058 (setq number
e9bd5782 6059 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
6060 (match-end 2))))
6061 (if (setq entry (gnus-gethash group xref-hashtb))
6062 (setcdr entry (cons number (cdr entry)))
6063 (gnus-sethash group (cons number nil) xref-hashtb)))))
6064 (and start xref-hashtb)))
6065
6066(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6067 "Look through all the headers and mark the Xrefs as read."
6068 (let ((virtual (gnus-virtual-group-p from-newsgroup))
01c52d31 6069 name info xref-hashtb idlist method nth4)
eec82323
LMI
6070 (save-excursion
6071 (set-buffer gnus-group-buffer)
6072 (when (setq xref-hashtb
6073 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6074 (mapatoms
6075 (lambda (group)
6076 (unless (string= from-newsgroup (setq name (symbol-name group)))
6077 (setq idlist (symbol-value group))
6078 ;; Dead groups are not updated.
6079 (and (prog1
01c52d31 6080 (setq info (gnus-get-info name))
eec82323
LMI
6081 (when (stringp (setq nth4 (gnus-info-method info)))
6082 (setq nth4 (gnus-server-to-method nth4))))
6083 ;; Only do the xrefs if the group has the same
6084 ;; select method as the group we have just read.
6085 (or (gnus-methods-equal-p
6086 nth4 (gnus-find-method-for-group from-newsgroup))
6087 virtual
6088 (equal nth4 (setq method (gnus-find-method-for-group
6089 from-newsgroup)))
6090 (and (equal (car nth4) (car method))
6091 (equal (nth 1 nth4) (nth 1 method))))
6092 gnus-use-cross-reference
6093 (or (not (eq gnus-use-cross-reference t))
6094 virtual
6095 ;; Only do cross-references on subscribed
6096 ;; groups, if that is what is wanted.
6097 (<= (gnus-info-level info) gnus-level-subscribed))
6098 (gnus-group-make-articles-read name idlist))))
6099 xref-hashtb)))))
6100
6748645f 6101(defun gnus-compute-read-articles (group articles)
01c52d31 6102 (let* ((entry (gnus-group-entry group))
6748645f
LMI
6103 (info (nth 2 entry))
6104 (active (gnus-active group))
6105 ninfo)
6106 (when entry
16409b0b 6107 ;; First peel off all invalid article numbers.
6748645f
LMI
6108 (when active
6109 (let ((ids articles)
6110 id first)
6111 (while (setq id (pop ids))
6112 (when (and first (> id (cdr active)))
6113 ;; We'll end up in this situation in one particular
6114 ;; obscure situation. If you re-scan a group and get
6115 ;; a new article that is cross-posted to a different
6116 ;; group that has not been re-scanned, you might get
6117 ;; crossposted article that has a higher number than
6118 ;; Gnus believes possible. So we re-activate this
6119 ;; group as well. This might mean doing the
6120 ;; crossposting thingy will *increase* the number
6121 ;; of articles in some groups. Tsk, tsk.
6122 (setq active (or (gnus-activate-group group) active)))
6123 (when (or (> id (cdr active))
6124 (< id (car active)))
6125 (setq articles (delq id articles))))))
6126 ;; If the read list is nil, we init it.
6127 (if (and active
6128 (null (gnus-info-read info))
6129 (> (car active) 1))
6130 (setq ninfo (cons 1 (1- (car active))))
6131 (setq ninfo (gnus-info-read info)))
6132 ;; Then we add the read articles to the range.
6133 (gnus-add-to-range
6134 ninfo (setq articles (sort articles '<))))))
6135
eec82323
LMI
6136(defun gnus-group-make-articles-read (group articles)
6137 "Update the info of GROUP to say that ARTICLES are read."
6138 (let* ((num 0)
01c52d31 6139 (entry (gnus-group-entry group))
eec82323
LMI
6140 (info (nth 2 entry))
6141 (active (gnus-active group))
6142 range)
6748645f
LMI
6143 (when entry
6144 (setq range (gnus-compute-read-articles group articles))
01c52d31 6145 (with-current-buffer gnus-group-buffer
6748645f
LMI
6146 (gnus-undo-register
6147 `(progn
6148 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6149 (gnus-info-set-read ',info ',(gnus-info-read info))
6150 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 6151 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
6152 (gnus-group-update-group ,group t))))
6153 ;; Add the read articles to the range.
6154 (gnus-info-set-read info range)
23f87bed 6155 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
6156 ;; Then we have to re-compute how many unread
6157 ;; articles there are in this group.
6158 (when active
6159 (cond
6160 ((not range)
6161 (setq num (- (1+ (cdr active)) (car active))))
6162 ((not (listp (cdr range)))
6163 (setq num (- (cdr active) (- (1+ (cdr range))
6164 (car range)))))
6165 (t
6166 (while range
6167 (if (numberp (car range))
6168 (setq num (1+ num))
6169 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6170 (setq range (cdr range)))
6171 (setq num (- (cdr active) num))))
6172 ;; Update the number of unread articles.
6173 (setcar entry num)
6174 ;; Update the group buffer.
23f87bed
MB
6175 (unless (gnus-ephemeral-group-p group)
6176 (gnus-group-update-group group t))))))
eec82323 6177
eec82323
LMI
6178(defvar gnus-newsgroup-none-id 0)
6179
6180(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6181 (let ((cur nntp-server-buffer)
6182 (dependencies
6183 (or dependencies
01c52d31
MB
6184 (with-current-buffer gnus-summary-buffer
6185 gnus-newsgroup-dependencies)))
6186 headers id end ref number
16409b0b
GM
6187 (mail-parse-charset gnus-newsgroup-charset)
6188 (mail-parse-ignored-charsets
c7a91ce1
SM
6189 (save-current-buffer (condition-case nil
6190 (set-buffer gnus-summary-buffer)
6191 (error))
6192 gnus-newsgroup-ignored-charsets)))
6193 (with-current-buffer nntp-server-buffer
eec82323
LMI
6194 ;; Translate all TAB characters into SPACE characters.
6195 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 6196 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 6197 (ietf-drums-unfold-fws)
6748645f 6198 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6199 (let ((case-fold-search t)
6748645f 6200 in-reply-to header p lines chars)
eec82323 6201 (goto-char (point-min))
01ccbb85 6202 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
6203 ;; do not begin with 2 or 3.
6204 (while (re-search-forward "^[23][0-9]+ " nil t)
6205 (setq id nil
6206 ref nil)
6207 ;; This implementation of this function, with nine
6208 ;; search-forwards instead of the one re-search-forward and
6209 ;; a case (which basically was the old function) is actually
01ccbb85 6210 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
6211 ;; can't have everything, I guess. Speed and elegance
6212 ;; doesn't always go hand in hand.
6213 (setq
6214 header
6215 (vector
6216 ;; Number.
6217 (prog1
01c52d31 6218 (setq number (read cur))
eec82323
LMI
6219 (end-of-line)
6220 (setq p (point))
6221 (narrow-to-region (point)
6222 (or (and (search-forward "\n.\n" nil t)
6223 (- (point) 2))
6224 (point))))
6225 ;; Subject.
6226 (progn
6227 (goto-char p)
23f87bed 6228 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
6229 (funcall gnus-decode-encoded-word-function
6230 (nnheader-header-value))
2bd3dcae 6231 "(none)"))
eec82323
LMI
6232 ;; From.
6233 (progn
6234 (goto-char p)
23f87bed 6235 (if (search-forward "\nfrom:" nil t)
343d6628 6236 (funcall gnus-decode-encoded-address-function
16409b0b 6237 (nnheader-header-value))
2bd3dcae 6238 "(nobody)"))
eec82323
LMI
6239 ;; Date.
6240 (progn
6241 (goto-char p)
23f87bed 6242 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6243 (nnheader-header-value) ""))
6244 ;; Message-ID.
6245 (progn
6246 (goto-char p)
6748645f
LMI
6247 (setq id (if (re-search-forward
6248 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6249 ;; We do it this way to make sure the Message-ID
6250 ;; is (somewhat) syntactically valid.
6251 (buffer-substring (match-beginning 1)
6252 (match-end 1))
eec82323
LMI
6253 ;; If there was no message-id, we just fake one
6254 ;; to make subsequent routines simpler.
01c52d31 6255 (nnheader-generate-fake-message-id number))))
eec82323
LMI
6256 ;; References.
6257 (progn
6258 (goto-char p)
23f87bed 6259 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6260 (progn
6261 (setq end (point))
6262 (prog1
6263 (nnheader-header-value)
6264 (setq ref
6265 (buffer-substring
6266 (progn
6267 (end-of-line)
6268 (search-backward ">" end t)
6269 (1+ (point)))
6270 (progn
6271 (search-backward "<" end t)
6272 (point))))))
6273 ;; Get the references from the in-reply-to header if there
6274 ;; were no references and the in-reply-to header looks
6275 ;; promising.
23f87bed 6276 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6277 (setq in-reply-to (nnheader-header-value))
6278 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6279 (let (ref2)
6280 (setq ref (substring in-reply-to (match-beginning 0)
6281 (match-end 0)))
6282 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6283 (setq ref2 (substring in-reply-to (match-beginning 0)
6284 (match-end 0)))
6285 (when (> (length ref2) (length ref))
6286 (setq ref ref2)))
6287 ref)
eec82323
LMI
6288 (setq ref nil))))
6289 ;; Chars.
6748645f
LMI
6290 (progn
6291 (goto-char p)
6292 (if (search-forward "\nchars: " nil t)
6293 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6294 chars -1)
6295 -1))
eec82323
LMI
6296 ;; Lines.
6297 (progn
6298 (goto-char p)
6299 (if (search-forward "\nlines: " nil t)
a8151ef7 6300 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6301 lines -1)
6302 -1))
eec82323
LMI
6303 ;; Xref.
6304 (progn
6305 (goto-char p)
23f87bed 6306 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6307 (nnheader-header-value)))
6308 ;; Extra.
6309 (when gnus-extra-headers
6310 (let ((extra gnus-extra-headers)
6311 out)
6312 (while extra
6313 (goto-char p)
6314 (when (search-forward
23f87bed 6315 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6316 (push (cons (car extra) (nnheader-header-value))
6317 out))
6318 (pop extra))
6319 out))))
eec82323
LMI
6320 (when (equal id ref)
6321 (setq ref nil))
6748645f
LMI
6322
6323 (when gnus-alter-header-function
6324 (funcall gnus-alter-header-function header)
6325 (setq id (mail-header-id header)
6326 ref (gnus-parent-id (mail-header-references header))))
6327
6328 (when (setq header
6329 (gnus-dependencies-add-header
6330 header dependencies force-new))
eec82323
LMI
6331 (push header headers))
6332 (goto-char (point-max))
6333 (widen))
6334 (nreverse headers)))))
6335
eec82323
LMI
6336;; Goes through the xover lines and returns a list of vectors
6337(defun gnus-get-newsgroup-headers-xover (sequence &optional
6338 force-new dependencies
6339 group also-fetch-heads)
16409b0b
GM
6340 "Parse the news overview data in the server buffer.
6341Return a list of headers that match SEQUENCE (see
6342`nntp-retrieve-headers')."
eec82323
LMI
6343 ;; Get the Xref when the users reads the articles since most/some
6344 ;; NNTP servers do not include Xrefs when using XOVER.
6345 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6346 (let ((mail-parse-charset gnus-newsgroup-charset)
6347 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6348 (cur nntp-server-buffer)
eec82323 6349 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6350 (allp (cond
6351 ((eq gnus-read-all-available-headers t)
6352 t)
14e6dc54
MB
6353 ((and (stringp gnus-read-all-available-headers)
6354 group)
23f87bed
MB
6355 (string-match gnus-read-all-available-headers group))
6356 (t
6357 nil)))
eec82323 6358 number headers header)
c7a91ce1 6359 (with-current-buffer nntp-server-buffer
16409b0b 6360 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6361 ;; Allow the user to mangle the headers before parsing them.
6748645f 6362 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6363 (goto-char (point-min))
23f87bed
MB
6364 (gnus-parse-without-error
6365 (while (and (or sequence allp)
6366 (not (eobp)))
6367 (setq number (read cur))
6368 (when (not allp)
6369 (while (and sequence
6370 (< (car sequence) number))
6371 (setq sequence (cdr sequence))))
6372 (when (and (or allp
6373 (and sequence
6374 (eq number (car sequence))))
6375 (progn
6376 (setq sequence (cdr sequence))
6377 (setq header (inline
6378 (gnus-nov-parse-line
6379 number dependencies force-new)))))
6380 (push header headers))
6381 (forward-line 1)))
eec82323
LMI
6382 ;; A common bug in inn is that if you have posted an article and
6383 ;; then retrieves the active file, it will answer correctly --
6384 ;; the new article is included. However, a NOV entry for the
6385 ;; article may not have been generated yet, so this may fail.
6386 ;; We work around this problem by retrieving the last few
6387 ;; headers using HEAD.
6388 (if (or (not also-fetch-heads)
6389 (not sequence))
6390 ;; We (probably) got all the headers.
6391 (nreverse headers)
6392 (let ((gnus-nov-is-evil t))
6393 (nconc
6394 (nreverse headers)
23f87bed 6395 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6396 (gnus-get-newsgroup-headers))))))))
6397
6398(defun gnus-article-get-xrefs ()
6399 "Fill in the Xref value in `gnus-current-headers', if necessary.
6400This is meant to be called in `gnus-article-internal-prepare-hook'."
01c52d31
MB
6401 (let ((headers (with-current-buffer gnus-summary-buffer
6402 gnus-current-headers)))
eec82323
LMI
6403 (or (not gnus-use-cross-reference)
6404 (not headers)
6405 (and (mail-header-xref headers)
6406 (not (string= (mail-header-xref headers) "")))
6407 (let ((case-fold-search t)
6408 xref)
6409 (save-restriction
6410 (nnheader-narrow-to-headers)
6411 (goto-char (point-min))
16409b0b
GM
6412 (when (or (and (not (eobp))
6413 (eq (downcase (char-after)) ?x)
eec82323
LMI
6414 (looking-at "Xref:"))
6415 (search-forward "\nXref:" nil t))
6416 (goto-char (1+ (match-end 0)))
01c52d31 6417 (setq xref (buffer-substring (point) (point-at-eol)))
eec82323
LMI
6418 (mail-header-set-xref headers xref)))))))
6419
6420(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6421 "Find article ID and insert the summary line for that article.
6422OLD-HEADER can either be a header or a line number to insert
6423the subject line on."
6424 (let* ((line (and (numberp old-header) old-header))
6425 (old-header (and (vectorp old-header) old-header))
6426 (header (cond ((and old-header use-old-header)
16409b0b
GM
6427 old-header)
6428 ((and (numberp id)
6429 (gnus-number-to-header id))
6430 (gnus-number-to-header id))
6431 (t
6432 (gnus-read-header id))))
6433 (number (and (numberp id) id))
6434 d)
eec82323
LMI
6435 (when header
6436 ;; Rebuild the thread that this article is part of and go to the
6437 ;; article we have fetched.
6438 (when (and (not gnus-show-threads)
6439 old-header)
6748645f
LMI
6440 (when (and number
6441 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6442 (goto-char (gnus-data-pos d))
6443 (gnus-data-remove
6444 number
01c52d31 6445 (- (point-at-bol)
eec82323 6446 (prog1
01c52d31 6447 (1+ (point-at-eol))
eec82323 6448 (gnus-delete-line))))))
23f87bed
MB
6449 ;; Remove list identifiers from subject.
6450 (when gnus-list-identifiers
6451 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6452 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6453 (when old-header
6454 (mail-header-set-number header (mail-header-number old-header)))
6455 (setq gnus-newsgroup-sparse
6456 (delq (setq number (mail-header-number header))
6457 gnus-newsgroup-sparse))
6458 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6459 (push number gnus-newsgroup-limit)
6460 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6461 (gnus-summary-goto-subject number nil t))
6462 (when (and (numberp number)
6463 (> number 0))
6464 ;; We have to update the boundaries even if we can't fetch the
6465 ;; article if ID is a number -- so that the next `P' or `N'
6466 ;; command will fetch the previous (or next) article even
6467 ;; if the one we tried to fetch this time has been canceled.
6468 (when (> number gnus-newsgroup-end)
6469 (setq gnus-newsgroup-end number))
6470 (when (< number gnus-newsgroup-begin)
6471 (setq gnus-newsgroup-begin number))
6472 (setq gnus-newsgroup-unselected
6473 (delq number gnus-newsgroup-unselected)))
6474 ;; Report back a success?
6475 (and header (mail-header-number header))))
6476
6477;;; Process/prefix in the summary buffer
6478
6479(defun gnus-summary-work-articles (n)
6748645f
LMI
6480 "Return a list of articles to be worked upon.
6481The prefix argument, the list of process marked articles, and the
6482current article will be taken into consideration."
c7a91ce1 6483 (with-current-buffer gnus-summary-buffer
6748645f
LMI
6484 (cond
6485 (n
6486 ;; A numerical prefix has been given.
6487 (setq n (prefix-numeric-value n))
6488 (let ((backward (< n 0))
6489 (n (abs (prefix-numeric-value n)))
6490 articles article)
6491 (save-excursion
6492 (while
6493 (and (> n 0)
6494 (push (setq article (gnus-summary-article-number))
6495 articles)
6496 (if backward
6497 (gnus-summary-find-prev nil article)
6498 (gnus-summary-find-next nil article)))
6499 (decf n)))
6500 (nreverse articles)))
6501 ((and (gnus-region-active-p) (mark))
6502 (message "region active")
6503 ;; Work on the region between point and mark.
6504 (let ((max (max (point) (mark)))
6505 articles article)
6506 (save-excursion
7dafe00b 6507 (goto-char (min (point) (mark)))
6748645f
LMI
6508 (while
6509 (and
6510 (push (setq article (gnus-summary-article-number)) articles)
6511 (gnus-summary-find-next nil article)
6512 (< (point) max)))
6513 (nreverse articles))))
6514 (gnus-newsgroup-processable
6515 ;; There are process-marked articles present.
6516 ;; Save current state.
6517 (gnus-summary-save-process-mark)
6518 ;; Return the list.
6519 (reverse gnus-newsgroup-processable))
6520 (t
6521 ;; Just return the current article.
6522 (list (gnus-summary-article-number))))))
6523
6524(defmacro gnus-summary-iterate (arg &rest forms)
6525 "Iterate over the process/prefixed articles and do FORMS.
6526ARG is the interactive prefix given to the command. FORMS will be
6527executed with point over the summary line of the articles."
6528 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6529 `(let ((,articles (gnus-summary-work-articles ,arg)))
6530 (while ,articles
6531 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6532 ,@forms
6533 (pop ,articles)))))
6748645f
LMI
6534
6535(put 'gnus-summary-iterate 'lisp-indent-function 1)
6536(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6537
6538(defun gnus-summary-save-process-mark ()
6539 "Push the current set of process marked articles on the stack."
6540 (interactive)
6541 (push (copy-sequence gnus-newsgroup-processable)
6542 gnus-newsgroup-process-stack))
6543
6544(defun gnus-summary-kill-process-mark ()
6545 "Push the current set of process marked articles on the stack and unmark."
6546 (interactive)
6547 (gnus-summary-save-process-mark)
6548 (gnus-summary-unmark-all-processable))
6549
6550(defun gnus-summary-yank-process-mark ()
6551 "Pop the last process mark state off the stack and restore it."
6552 (interactive)
6553 (unless gnus-newsgroup-process-stack
6554 (error "Empty mark stack"))
6555 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6556
6557(defun gnus-summary-process-mark-set (set)
6558 "Make SET into the current process marked articles."
6559 (gnus-summary-unmark-all-processable)
01c52d31 6560 (mapc 'gnus-summary-set-process-mark set))
eec82323
LMI
6561
6562;;; Searching and stuff
6563
6564(defun gnus-summary-search-group (&optional backward use-level)
6565 "Search for next unread newsgroup.
6566If optional argument BACKWARD is non-nil, search backward instead."
c7a91ce1 6567 (with-current-buffer gnus-group-buffer
eec82323
LMI
6568 (when (gnus-group-search-forward
6569 backward nil (if use-level (gnus-group-group-level) nil))
6570 (gnus-group-group-name))))
6571
6572(defun gnus-summary-best-group (&optional exclude-group)
6573 "Find the name of the best unread group.
6574If EXCLUDE-GROUP, do not go to this group."
01c52d31 6575 (with-current-buffer gnus-group-buffer
eec82323
LMI
6576 (save-excursion
6577 (gnus-group-best-unread-group exclude-group))))
6578
23f87bed
MB
6579(defun gnus-summary-find-next (&optional unread article backward)
6580 (if backward
6581 (gnus-summary-find-prev unread article)
eec82323
LMI
6582 (let* ((dummy (gnus-summary-article-intangible-p))
6583 (article (or article (gnus-summary-article-number)))
23f87bed 6584 (data (gnus-data-find-list article))
eec82323
LMI
6585 result)
6586 (when (and (not dummy)
6587 (or (not gnus-summary-check-current)
6588 (not unread)
23f87bed
MB
6589 (not (gnus-data-unread-p (car data)))))
6590 (setq data (cdr data)))
eec82323
LMI
6591 (when (setq result
6592 (if unread
6593 (progn
23f87bed
MB
6594 (while data
6595 (unless (memq (gnus-data-number (car data))
6596 (cond
6597 ((eq gnus-auto-goto-ignores
6598 'always-undownloaded)
6599 gnus-newsgroup-undownloaded)
6600 (gnus-plugged
6601 nil)
6602 ((eq gnus-auto-goto-ignores
6603 'unfetched)
6604 gnus-newsgroup-unfetched)
6605 ((eq gnus-auto-goto-ignores
6606 'undownloaded)
6607 gnus-newsgroup-undownloaded)))
6608 (when (gnus-data-unread-p (car data))
6609 (setq result (car data)
6610 data nil)))
6611 (setq data (cdr data)))
eec82323 6612 result)
23f87bed 6613 (car data)))
eec82323
LMI
6614 (goto-char (gnus-data-pos result))
6615 (gnus-data-number result)))))
6616
6617(defun gnus-summary-find-prev (&optional unread article)
6618 (let* ((eobp (eobp))
6619 (article (or article (gnus-summary-article-number)))
23f87bed 6620 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6621 result)
6622 (when (and (not eobp)
6623 (or (not gnus-summary-check-current)
6624 (not unread)
23f87bed
MB
6625 (not (gnus-data-unread-p (car data)))))
6626 (setq data (cdr data)))
eec82323
LMI
6627 (when (setq result
6628 (if unread
6629 (progn
23f87bed
MB
6630 (while data
6631 (unless (memq (gnus-data-number (car data))
6632 (cond
6633 ((eq gnus-auto-goto-ignores
6634 'always-undownloaded)
6635 gnus-newsgroup-undownloaded)
6636 (gnus-plugged
6637 nil)
6638 ((eq gnus-auto-goto-ignores
6639 'unfetched)
6640 gnus-newsgroup-unfetched)
6641 ((eq gnus-auto-goto-ignores
6642 'undownloaded)
6643 gnus-newsgroup-undownloaded)))
6644 (when (gnus-data-unread-p (car data))
6645 (setq result (car data)
6646 data nil)))
6647 (setq data (cdr data)))
eec82323 6648 result)
23f87bed 6649 (car data)))
eec82323
LMI
6650 (goto-char (gnus-data-pos result))
6651 (gnus-data-number result))))
6652
6653(defun gnus-summary-find-subject (subject &optional unread backward article)
6654 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6655 (article (or article (gnus-summary-article-number)))
6656 (articles (gnus-data-list backward))
6657 (arts (gnus-data-find-list article articles))
6658 result)
6659 (when (or (not gnus-summary-check-current)
6660 (not unread)
6661 (not (gnus-data-unread-p (car arts))))
6662 (setq arts (cdr arts)))
6663 (while arts
6664 (and (or (not unread)
6665 (gnus-data-unread-p (car arts)))
6666 (vectorp (gnus-data-header (car arts)))
6667 (gnus-subject-equal
6668 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6669 (setq result (car arts)
6670 arts nil))
6671 (setq arts (cdr arts)))
6672 (and result
6673 (goto-char (gnus-data-pos result))
6674 (gnus-data-number result))))
6675
6676(defun gnus-summary-search-forward (&optional unread subject backward)
6677 "Search forward for an article.
6678If UNREAD, look for unread articles. If SUBJECT, look for
6679articles with that subject. If BACKWARD, search backward instead."
6680 (cond (subject (gnus-summary-find-subject subject unread backward))
6681 (backward (gnus-summary-find-prev unread))
6682 (t (gnus-summary-find-next unread))))
6683
6684(defun gnus-recenter (&optional n)
6685 "Center point in window and redisplay frame.
6686Also do horizontal recentering."
6687 (interactive "P")
6688 (when (and gnus-auto-center-summary
6689 (not (eq gnus-auto-center-summary 'vertical)))
6690 (gnus-horizontal-recenter))
6691 (recenter n))
6692
6693(defun gnus-summary-recenter ()
6694 "Center point in the summary window.
6695If `gnus-auto-center-summary' is nil, or the article buffer isn't
6696displayed, no centering will be performed."
6697 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6698 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6699 (interactive)
23f87bed
MB
6700 ;; The user has to want it.
6701 (when gnus-auto-center-summary
6702 (let* ((top (cond ((< (window-height) 4) 0)
6703 ((< (window-height) 7) 1)
6704 (t (if (numberp gnus-auto-center-summary)
6705 gnus-auto-center-summary
01c52d31 6706 (/ (1- (window-height)) 2)))))
23f87bed
MB
6707 (height (1- (window-height)))
6708 (bottom (save-excursion (goto-char (point-max))
6709 (forward-line (- height))
6710 (point)))
6711 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6712 (when (get-buffer-window gnus-article-buffer)
6713 ;; Only do recentering when the article buffer is displayed,
6714 ;; Set the window start to either `bottom', which is the biggest
6715 ;; possible valid number, or the second line from the top,
6716 ;; whichever is the least.
db7ebd73
MB
6717 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6718 (if (> bottom top-pos)
6719 ;; Keep the second line from the top visible
01c52d31 6720 (set-window-start window top-pos)
db7ebd73
MB
6721 ;; Try to keep the bottom line visible; if it's partially
6722 ;; obscured, either scroll one more line to make it fully
6723 ;; visible, or revert to using TOP-POS.
6724 (save-excursion
6725 (goto-char (point-max))
6726 (forward-line -1)
6727 (let ((last-line-start (point)))
6728 (goto-char bottom)
6729 (set-window-start window (point) t)
6730 (when (not (pos-visible-in-window-p last-line-start window))
6731 (forward-line 1)
6732 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6733 ;; Do horizontal recentering while we're at it.
6734 (when (and (get-buffer-window (current-buffer) t)
6735 (not (eq gnus-auto-center-summary 'vertical)))
6736 (let ((selected (selected-window)))
6737 (select-window (get-buffer-window (current-buffer) t))
6738 (gnus-summary-position-point)
6739 (gnus-horizontal-recenter)
6740 (select-window selected))))))
6741
6742(defun gnus-summary-jump-to-group (newsgroup)
6743 "Move point to NEWSGROUP in group mode buffer."
6744 ;; Keep update point of group mode buffer if visible.
6745 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6746 (save-window-excursion
6747 ;; Take care of tree window mode.
6748 (when (get-buffer-window gnus-group-buffer)
6749 (pop-to-buffer gnus-group-buffer))
6750 (gnus-group-jump-to-group newsgroup))
6751 (save-excursion
6752 ;; Take care of tree window mode.
c7a91ce1 6753 (if (get-buffer-window gnus-group-buffer 0)
eec82323
LMI
6754 (pop-to-buffer gnus-group-buffer)
6755 (set-buffer gnus-group-buffer))
6756 (gnus-group-jump-to-group newsgroup))))
6757
6758;; This function returns a list of article numbers based on the
6759;; difference between the ranges of read articles in this group and
6760;; the range of active articles.
6761(defun gnus-list-of-unread-articles (group)
6762 (let* ((read (gnus-info-read (gnus-get-info group)))
6763 (active (or (gnus-active group) (gnus-activate-group group)))
01c52d31
MB
6764 (last (or (cdr active)
6765 (error "Group %s couldn't be activated " group)))
4b70e299
MB
6766 (bottom (if gnus-newsgroup-maximum-articles
6767 (max (car active)
6768 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6769 (car active)))
eec82323
LMI
6770 first nlast unread)
6771 ;; If none are read, then all are unread.
6772 (if (not read)
11abff8e 6773 (setq first bottom)
eec82323
LMI
6774 ;; If the range of read articles is a single range, then the
6775 ;; first unread article is the article after the last read
6776 ;; article. Sounds logical, doesn't it?
16409b0b 6777 (if (and (not (listp (cdr read)))
11abff8e 6778 (or (< (car read) bottom)
16409b0b
GM
6779 (progn (setq read (list read))
6780 nil)))
11abff8e 6781 (setq first (max bottom (1+ (cdr read))))
eec82323
LMI
6782 ;; `read' is a list of ranges.
6783 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6784 (caar read)))
6785 1)
11abff8e 6786 (setq first bottom))
eec82323
LMI
6787 (while read
6788 (when first
6789 (while (< first nlast)
54506618
MB
6790 (setq unread (cons first unread)
6791 first (1+ first))))
eec82323
LMI
6792 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6793 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6794 (setq read (cdr read)))))
6795 ;; And add the last unread articles.
6796 (while (<= first last)
54506618
MB
6797 (setq unread (cons first unread)
6798 first (1+ first)))
eec82323 6799 ;; Return the list of unread articles.
6748645f 6800 (delq 0 (nreverse unread))))
eec82323
LMI
6801
6802(defun gnus-list-of-read-articles (group)
6803 "Return a list of unread, unticked and non-dormant articles."
6804 (let* ((info (gnus-get-info group))
6805 (marked (gnus-info-marks info))
6806 (active (gnus-active group)))
6807 (and info active
23f87bed
MB
6808 (gnus-list-range-difference
6809 (gnus-list-range-difference
6810 (gnus-sorted-complement
11abff8e 6811 (gnus-uncompress-range
4b70e299 6812 (if gnus-newsgroup-maximum-articles
11abff8e 6813 (cons (max (car active)
4b70e299
MB
6814 (- (cdr active)
6815 gnus-newsgroup-maximum-articles
6816 -1))
11abff8e
MB
6817 (cdr active))
6818 active))
23f87bed
MB
6819 (gnus-list-of-unread-articles group))
6820 (cdr (assq 'dormant marked)))
6821 (cdr (assq 'tick marked))))))
eec82323 6822
54506618
MB
6823;; This function returns a sequence of article numbers based on the
6824;; difference between the ranges of read articles in this group and
6825;; the range of active articles.
6826(defun gnus-sequence-of-unread-articles (group)
6827 (let* ((read (gnus-info-read (gnus-get-info group)))
6828 (active (or (gnus-active group) (gnus-activate-group group)))
6829 (last (cdr active))
4b70e299
MB
6830 (bottom (if gnus-newsgroup-maximum-articles
6831 (max (car active)
6832 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6833 (car active)))
54506618
MB
6834 first nlast unread)
6835 ;; If none are read, then all are unread.
6836 (if (not read)
11abff8e 6837 (setq first bottom)
54506618
MB
6838 ;; If the range of read articles is a single range, then the
6839 ;; first unread article is the article after the last read
6840 ;; article. Sounds logical, doesn't it?
6841 (if (and (not (listp (cdr read)))
11abff8e 6842 (or (< (car read) bottom)
54506618
MB
6843 (progn (setq read (list read))
6844 nil)))
11abff8e 6845 (setq first (max bottom (1+ (cdr read))))
54506618
MB
6846 ;; `read' is a list of ranges.
6847 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6848 (caar read)))
6849 1)
11abff8e 6850 (setq first bottom))
54506618
MB
6851 (while read
6852 (when first
6853 (push (cons first nlast) unread))
6854 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6855 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6856 (setq read (cdr read)))))
6857 ;; And add the last unread articles.
ba0226dd
MB
6858 (cond ((not (and first last))
6859 nil)
6860 ((< first last)
6861 (push (cons first last) unread))
6862 ((= first last)
6863 (push first unread)))
54506618
MB
6864 ;; Return the sequence of unread articles.
6865 (delq 0 (nreverse unread))))
6866
eec82323
LMI
6867;; Various summary commands
6868
6748645f
LMI
6869(defun gnus-summary-select-article-buffer ()
6870 "Reconfigure windows to show article buffer."
6871 (interactive)
6872 (if (not (gnus-buffer-live-p gnus-article-buffer))
6873 (error "There is no article buffer for this summary buffer")
6874 (gnus-configure-windows 'article)
6875 (select-window (get-buffer-window gnus-article-buffer))))
6876
eec82323
LMI
6877(defun gnus-summary-universal-argument (arg)
6878 "Perform any operation on all articles that are process/prefixed."
6879 (interactive "P")
eec82323
LMI
6880 (let ((articles (gnus-summary-work-articles arg))
6881 func article)
6882 (if (eq
6883 (setq
6884 func
6885 (key-binding
6886 (read-key-sequence
6887 (substitute-command-keys
16409b0b 6888 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
6889 'undefined)
6890 (gnus-error 1 "Undefined key")
6891 (save-excursion
6892 (while articles
6893 (gnus-summary-goto-subject (setq article (pop articles)))
6894 (let (gnus-newsgroup-processable)
6895 (command-execute func))
6896 (gnus-summary-remove-process-mark article)))))
6897 (gnus-summary-position-point))
6898
6899(defun gnus-summary-toggle-truncation (&optional arg)
6900 "Toggle truncation of summary lines.
23f87bed 6901With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
6902 (interactive "P")
6903 (setq truncate-lines
6904 (if (null arg) (not truncate-lines)
6905 (> (prefix-numeric-value arg) 0)))
6906 (redraw-display))
6907
23f87bed
MB
6908(defun gnus-summary-find-for-reselect ()
6909 "Return the number of an article to stay on across a reselect.
6910The current article is considered, then following articles, then previous
6911articles. An article is sought which is not cancelled and isn't a temporary
6912insertion from another group. If there's no such then return a dummy 0."
6913 (let (found)
6914 (dolist (rev '(nil t))
6915 (unless found ; don't demand the reverse list if we don't need it
6916 (let ((data (gnus-data-find-list
6917 (gnus-summary-article-number) (gnus-data-list rev))))
6918 (while (and data (not found))
6919 (if (and (< 0 (gnus-data-number (car data)))
6920 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6921 (setq found (gnus-data-number (car data))))
6922 (setq data (cdr data))))))
6923 (or found 0)))
6924
eec82323
LMI
6925(defun gnus-summary-reselect-current-group (&optional all rescan)
6926 "Exit and then reselect the current newsgroup.
6927The prefix argument ALL means to select all articles."
6928 (interactive "P")
eec82323
LMI
6929 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6930 (error "Ephemeral groups can't be reselected"))
23f87bed 6931 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
6932 (group gnus-newsgroup-name))
6933 (setq gnus-newsgroup-begin nil)
23f87bed 6934 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
6935 ;; We have to adjust the point of group mode buffer because
6936 ;; point was moved to the next unread newsgroup by exiting.
6937 (gnus-summary-jump-to-group group)
6938 (when rescan
6939 (save-excursion
6940 (gnus-group-get-new-news-this-group 1)))
6941 (gnus-group-read-group all t)
6942 (gnus-summary-goto-subject current-subject nil t)))
6943
6944(defun gnus-summary-rescan-group (&optional all)
6945 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6946 (interactive "P")
6947 (gnus-summary-reselect-current-group all t))
6948
6949(defun gnus-summary-update-info (&optional non-destructive)
6950 (save-excursion
6951 (let ((group gnus-newsgroup-name))
6748645f
LMI
6952 (when group
6953 (when gnus-newsgroup-kill-headers
6954 (setq gnus-newsgroup-killed
6955 (gnus-compress-sequence
23f87bed
MB
6956 (gnus-sorted-union
6957 (gnus-list-range-intersection
6958 gnus-newsgroup-unselected gnus-newsgroup-killed)
6959 gnus-newsgroup-unreads)
6748645f
LMI
6960 t)))
6961 (unless (listp (cdr gnus-newsgroup-killed))
6962 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6963 (let ((headers gnus-newsgroup-headers))
6964 ;; Set the new ranges of read articles.
01c52d31 6965 (with-current-buffer gnus-group-buffer
6748645f
LMI
6966 (gnus-undo-force-boundary))
6967 (gnus-update-read-articles
23f87bed
MB
6968 group (gnus-sorted-union
6969 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
6970 ;; Set the current article marks.
6971 (let ((gnus-newsgroup-scored
6972 (if (and (not gnus-save-score)
6973 (not non-destructive))
6974 nil
6975 gnus-newsgroup-scored)))
6976 (save-excursion
6977 (gnus-update-marks)))
6978 ;; Do the cross-ref thing.
6979 (when gnus-use-cross-reference
6980 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6981 ;; Do not switch windows but change the buffer to work.
a8151ef7 6982 (set-buffer gnus-group-buffer)
6748645f
LMI
6983 (unless (gnus-ephemeral-group-p group)
6984 (gnus-group-update-group group)))))))
eec82323
LMI
6985
6986(defun gnus-summary-save-newsrc (&optional force)
6987 "Save the current number of read/marked articles in the dribble buffer.
6988The dribble buffer will then be saved.
6989If FORCE (the prefix), also save the .newsrc file(s)."
6990 (interactive "P")
6991 (gnus-summary-update-info t)
6992 (if force
6993 (gnus-save-newsrc-file)
6994 (gnus-dribble-save)))
6995
704f1663
GM
6996(declare-function gnus-cache-write-active "gnus-cache" (&optional force))
6997
23f87bed 6998(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 6999 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 7000`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
7001 (interactive)
7002 (gnus-set-global-variables)
16409b0b 7003 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7004 (with-current-buffer gnus-article-buffer
16409b0b
GM
7005 (mm-destroy-parts gnus-article-mime-handles)
7006 ;; Set it to nil for safety reason.
7007 (setq gnus-article-mime-handle-alist nil)
7008 (setq gnus-article-mime-handles nil)))
eec82323 7009 (gnus-kill-save-kill-buffer)
6748645f 7010 (gnus-async-halt-prefetch)
eec82323
LMI
7011 (let* ((group gnus-newsgroup-name)
7012 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 7013 (gnus-group-is-exiting-p t)
eec82323 7014 (mode major-mode)
23f87bed 7015 (group-point nil)
eec82323 7016 (buf (current-buffer)))
16409b0b
GM
7017 (unless quit-config
7018 ;; Do adaptive scoring, and possibly save score files.
7019 (when gnus-newsgroup-adaptive
7020 (gnus-score-adaptive))
7021 (when gnus-use-scoring
7022 (gnus-score-save)))
6748645f 7023 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
7024 ;; If we have several article buffers, we kill them at exit.
7025 (unless gnus-single-article-buffer
01c52d31
MB
7026 (when (gnus-buffer-live-p gnus-article-buffer)
7027 (with-current-buffer gnus-article-buffer
7028 ;; Don't kill sticky article buffers
7029 (unless (eq major-mode 'gnus-sticky-article-mode)
7030 (gnus-kill-buffer gnus-article-buffer)
7031 (setq gnus-article-current nil))))
7032 (gnus-kill-buffer gnus-original-article-buffer))
eec82323
LMI
7033 (when gnus-use-cache
7034 (gnus-cache-possibly-remove-articles)
7035 (gnus-cache-save-buffers))
7036 (gnus-async-prefetch-remove-group group)
7037 (when gnus-suppress-duplicates
7038 (gnus-dup-enter-articles))
7039 (when gnus-use-trees
7040 (gnus-tree-close group))
16409b0b
GM
7041 (when gnus-use-cache
7042 (gnus-cache-write-active))
6748645f
LMI
7043 ;; Remove entries for this group.
7044 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
7045 ;; Make all changes in this group permanent.
7046 (unless quit-config
6748645f 7047 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 7048 (gnus-summary-update-info))
eec82323
LMI
7049 (gnus-close-group group)
7050 ;; Make sure where we were, and go to next newsgroup.
7051 (set-buffer gnus-group-buffer)
7052 (unless quit-config
7053 (gnus-group-jump-to-group group))
6748645f
LMI
7054 (gnus-run-hooks 'gnus-summary-exit-hook)
7055 (unless (or quit-config
01c52d31 7056 (not gnus-summary-next-group-on-exit)
6748645f
LMI
7057 ;; If this group has disappeared from the summary
7058 ;; buffer, don't skip forwards.
7059 (not (string= group (gnus-group-group-name))))
eec82323 7060 (gnus-group-next-unread-group 1))
a8151ef7 7061 (setq group-point (point))
eec82323
LMI
7062 (if temporary
7063 nil ;Nothing to do.
eec82323
LMI
7064 (set-buffer buf)
7065 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
7066 (progn
7067 (gnus-deaden-summary)
7068 (setq mode nil))
eec82323
LMI
7069 ;; We set all buffer-local variables to nil. It is unclear why
7070 ;; this is needed, but if we don't, buffer-local variables are
7071 ;; not garbage-collected, it seems. This would the lead to en
7072 ;; ever-growing Emacs.
7073 (gnus-summary-clear-local-variables)
23f87bed
MB
7074 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7075 (gnus-summary-clear-local-variables))
eec82323
LMI
7076 (when (get-buffer gnus-article-buffer)
7077 (bury-buffer gnus-article-buffer))
eec82323
LMI
7078 ;; Return to group mode buffer.
7079 (when (eq mode 'gnus-summary-mode)
7080 (gnus-kill-buffer buf)))
7081 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
7082 (set-buffer gnus-group-buffer)
7083 (if quit-config
7084 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
7085 (goto-char group-point)
7086 ;; If gnus-group-buffer is already displayed, make sure we also move
7087 ;; the cursor in the window that displays it.
7088 (let ((win (get-buffer-window (current-buffer) 0)))
7089 (if win (set-window-point win (point))))
d61c212b 7090 (unless leave-hidden
4e90f2b9 7091 (gnus-configure-windows 'group 'force)))
6748645f 7092 ;; Clear the current group name.
eec82323
LMI
7093 (unless quit-config
7094 (setq gnus-newsgroup-name nil)))))
7095
7096(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7097(defun gnus-summary-exit-no-update (&optional no-questions)
7098 "Quit reading current newsgroup without updating read article info."
7099 (interactive)
eec82323 7100 (let* ((group gnus-newsgroup-name)
23f87bed
MB
7101 (gnus-group-is-exiting-p t)
7102 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
7103 (quit-config (gnus-group-quit-config group)))
7104 (when (or no-questions
7105 gnus-expert-user
7106 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 7107 (gnus-async-halt-prefetch)
23f87bed 7108 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b 7109 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7110 (with-current-buffer gnus-article-buffer
16409b0b
GM
7111 (mm-destroy-parts gnus-article-mime-handles)
7112 ;; Set it to nil for safety reason.
7113 (setq gnus-article-mime-handle-alist nil)
7114 (setq gnus-article-mime-handles nil)))
eec82323
LMI
7115 ;; If we have several article buffers, we kill them at exit.
7116 (unless gnus-single-article-buffer
7117 (gnus-kill-buffer gnus-article-buffer)
7118 (gnus-kill-buffer gnus-original-article-buffer)
7119 (setq gnus-article-current nil))
7120 (if (not gnus-kill-summary-on-exit)
7121 (gnus-deaden-summary)
7122 (gnus-close-group group)
7123 (gnus-summary-clear-local-variables)
23f87bed
MB
7124 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7125 (gnus-summary-clear-local-variables))
7126 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
7127 (unless gnus-single-article-buffer
7128 (setq gnus-article-current nil))
7129 (when gnus-use-trees
7130 (gnus-tree-close group))
7131 (gnus-async-prefetch-remove-group group)
7132 (when (get-buffer gnus-article-buffer)
7133 (bury-buffer gnus-article-buffer))
7134 ;; Return to the group buffer.
7135 (gnus-configure-windows 'group 'force)
7136 ;; Clear the current group name.
7137 (setq gnus-newsgroup-name nil)
23f87bed
MB
7138 (unless (gnus-ephemeral-group-p group)
7139 (gnus-group-update-group group))
eec82323
LMI
7140 (when (equal (gnus-group-group-name) group)
7141 (gnus-group-next-unread-group 1))
7142 (when quit-config
23f87bed 7143 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
7144
7145(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
7146 "Handle movement when leaving an ephemeral group.
7147The state which existed when entering the ephemeral is reset."
eec82323
LMI
7148 (if (not (buffer-name (car quit-config)))
7149 (gnus-configure-windows 'group 'force)
7150 (set-buffer (car quit-config))
7151 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
7152 (gnus-set-global-variables))
7153 ((eq major-mode 'gnus-article-mode)
c7a91ce1 7154 (save-current-buffer
23f87bed
MB
7155 ;; The `gnus-summary-buffer' variable may point
7156 ;; to the old summary buffer when using a single
7157 ;; article buffer.
7158 (unless (gnus-buffer-live-p gnus-summary-buffer)
7159 (set-buffer gnus-group-buffer))
7160 (set-buffer gnus-summary-buffer)
7161 (gnus-set-global-variables))))
eec82323 7162 (if (or (eq (cdr quit-config) 'article)
23f87bed 7163 (eq (cdr quit-config) 'pick))
01c52d31
MB
7164 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7165 (gnus-configure-windows 'pick 'force)
7166 (gnus-configure-windows (cdr quit-config) 'force))
eec82323
LMI
7167 (gnus-configure-windows (cdr quit-config) 'force))
7168 (when (eq major-mode 'gnus-summary-mode)
01c52d31
MB
7169 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7170 next-unread-noselect))
7171 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7172 'next-noselect)
7173 (gnus-summary-next-subject 1 nil t))
7174 ((eq gnus-auto-select-on-ephemeral-exit
7175 'next-unread-noselect)
7176 (gnus-summary-next-subject 1 t t))))
7177 ;; Hide the article buffer which displays the article different
7178 ;; from the one that the cursor points to in the summary buffer.
7179 (gnus-configure-windows 'summary 'force))
7180 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7181 (gnus-summary-next-subject 1))
7182 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7183 (gnus-summary-next-subject 1 t))))
eec82323
LMI
7184 (gnus-summary-recenter)
7185 (gnus-summary-position-point))))
7186
7187;;; Dead summaries.
7188
7189(defvar gnus-dead-summary-mode-map nil)
7190
7191(unless gnus-dead-summary-mode-map
7192 (setq gnus-dead-summary-mode-map (make-keymap))
7193 (suppress-keymap gnus-dead-summary-mode-map)
7194 (substitute-key-definition
7195 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
23f87bed
MB
7196 (dolist (key '("\C-d" "\r" "\177" [delete]))
7197 (define-key gnus-dead-summary-mode-map
7198 key 'gnus-summary-wake-up-the-dead))
7199 (dolist (key '("q" "Q"))
7200 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
eec82323
LMI
7201
7202(defvar gnus-dead-summary-mode nil
7203 "Minor mode for Gnus summary buffers.")
7204
7205(defun gnus-dead-summary-mode (&optional arg)
7206 "Minor mode for Gnus summary buffers."
7207 (interactive "P")
7208 (when (eq major-mode 'gnus-summary-mode)
7209 (make-local-variable 'gnus-dead-summary-mode)
7210 (setq gnus-dead-summary-mode
7211 (if (null arg) (not gnus-dead-summary-mode)
7212 (> (prefix-numeric-value arg) 0)))
7213 (when gnus-dead-summary-mode
01c52d31 7214 (add-minor-mode
a8151ef7 7215 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
eec82323
LMI
7216
7217(defun gnus-deaden-summary ()
7218 "Make the current summary buffer into a dead summary buffer."
7219 ;; Kill any previous dead summary buffer.
7220 (when (and gnus-dead-summary
7221 (buffer-name gnus-dead-summary))
01c52d31 7222 (with-current-buffer gnus-dead-summary
eec82323
LMI
7223 (when gnus-dead-summary-mode
7224 (kill-buffer (current-buffer)))))
7225 ;; Make this the current dead summary.
7226 (setq gnus-dead-summary (current-buffer))
7227 (gnus-dead-summary-mode 1)
7228 (let ((name (buffer-name)))
7229 (when (string-match "Summary" name)
7230 (rename-buffer
7231 (concat (substring name 0 (match-beginning 0)) "Dead "
7232 (substring name (match-beginning 0)))
16409b0b
GM
7233 t)
7234 (bury-buffer))))
eec82323
LMI
7235
7236(defun gnus-kill-or-deaden-summary (buffer)
7237 "Kill or deaden the summary BUFFER."
6748645f
LMI
7238 (save-excursion
7239 (when (and (buffer-name buffer)
7240 (not gnus-single-article-buffer))
01c52d31 7241 (with-current-buffer buffer
6748645f
LMI
7242 (gnus-kill-buffer gnus-article-buffer)
7243 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
7244 (cond
7245 ;; Kill the buffer.
7246 (gnus-kill-summary-on-exit
7247 (when (and gnus-use-trees
7248 (gnus-buffer-exists-p buffer))
c7a91ce1 7249 (with-current-buffer buffer
23f87bed
MB
7250 (gnus-tree-close gnus-newsgroup-name)))
7251 (gnus-kill-buffer buffer))
7252 ;; Deaden the buffer.
7253 ((gnus-buffer-exists-p buffer)
c7a91ce1 7254 (with-current-buffer buffer
23f87bed 7255 (gnus-deaden-summary))))))
eec82323
LMI
7256
7257(defun gnus-summary-wake-up-the-dead (&rest args)
7258 "Wake up the dead summary buffer."
7259 (interactive)
7260 (gnus-dead-summary-mode -1)
7261 (let ((name (buffer-name)))
7262 (when (string-match "Dead " name)
7263 (rename-buffer
7264 (concat (substring name 0 (match-beginning 0))
7265 (substring name (match-end 0)))
7266 t)))
7267 (gnus-message 3 "This dead summary is now alive again"))
7268
7269;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7270(defun gnus-summary-fetch-faq (&optional faq-dir)
7271 "Fetch the FAQ for the current group.
7272If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7273in."
7274 (interactive
7275 (list
7276 (when current-prefix-arg
7277 (completing-read
8f688cb0 7278 "FAQ dir: " (and (listp gnus-group-faq-directory)
01c52d31 7279 (mapcar 'list
a8151ef7 7280 gnus-group-faq-directory))))))
eec82323
LMI
7281 (let (gnus-faq-buffer)
7282 (when (setq gnus-faq-buffer
7283 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7284 (gnus-configure-windows 'summary-faq))))
7285
7286;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7287(defun gnus-summary-describe-group (&optional force)
7288 "Describe the current newsgroup."
7289 (interactive "P")
7290 (gnus-group-describe-group force gnus-newsgroup-name))
7291
7292(defun gnus-summary-describe-briefly ()
7293 "Describe summary mode commands briefly."
7294 (interactive)
16409b0b 7295 (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
7296
7297;; Walking around group mode buffer from summary mode.
7298
7299(defun gnus-summary-next-group (&optional no-article target-group backward)
7300 "Exit current newsgroup and then select next unread newsgroup.
7301If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7302initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7303previous group instead."
7304 (interactive "P")
eec82323
LMI
7305 ;; Stop pre-fetching.
7306 (gnus-async-halt-prefetch)
7307 (let ((current-group gnus-newsgroup-name)
7308 (current-buffer (current-buffer))
7309 entered)
7310 ;; First we semi-exit this group to update Xrefs and all variables.
7311 ;; We can't do a real exit, because the window conf must remain
7312 ;; the same in case the user is prompted for info, and we don't
7313 ;; want the window conf to change before that...
7314 (gnus-summary-exit t)
7315 (while (not entered)
7316 ;; Then we find what group we are supposed to enter.
7317 (set-buffer gnus-group-buffer)
7318 (gnus-group-jump-to-group current-group)
7319 (setq target-group
7320 (or target-group
7321 (if (eq gnus-keep-same-level 'best)
7322 (gnus-summary-best-group gnus-newsgroup-name)
7323 (gnus-summary-search-group backward gnus-keep-same-level))))
7324 (if (not target-group)
7325 ;; There are no further groups, so we return to the group
7326 ;; buffer.
7327 (progn
7328 (gnus-message 5 "Returning to the group buffer")
7329 (setq entered t)
7330 (when (gnus-buffer-live-p current-buffer)
7331 (set-buffer current-buffer)
7332 (gnus-summary-exit))
6748645f 7333 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7334 ;; We try to enter the target group.
7335 (gnus-group-jump-to-group target-group)
7336 (let ((unreads (gnus-group-group-unread)))
7337 (if (and (or (eq t unreads)
7338 (and unreads (not (zerop unreads))))
23f87bed
MB
7339 (gnus-summary-read-group
7340 target-group nil no-article
7341 (and (buffer-name current-buffer) current-buffer)
7342 nil backward))
eec82323
LMI
7343 (setq entered t)
7344 (setq current-group target-group
7345 target-group nil)))))))
7346
7347(defun gnus-summary-prev-group (&optional no-article)
7348 "Exit current newsgroup and then select previous unread newsgroup.
7349If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7350 (interactive "P")
7351 (gnus-summary-next-group no-article nil t))
7352
7353;; Walking around summary lines.
7354
23f87bed
MB
7355(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7356 "Go to the first subject satisfying any non-nil constraint.
7357If UNREAD is non-nil, the article should be unread.
7358If UNDOWNLOADED is non-nil, the article should be undownloaded.
7359If UNSEEN is non-nil, the article should be unseen.
7360Returns the article selected or nil if there are no matching articles."
eec82323 7361 (interactive "P")
23f87bed
MB
7362 (cond
7363 ;; Empty summary.
7364 ((null gnus-newsgroup-data)
7365 (gnus-message 3 "No articles in the group")
7366 nil)
7367 ;; Pick the first article.
7368 ((not (or unread undownloaded unseen))
7369 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7370 (gnus-data-number (car gnus-newsgroup-data)))
7371 ;; Find the first unread article.
7372 (t
7373 (let ((data gnus-newsgroup-data))
7374 (while (and data
7375 (let ((num (gnus-data-number (car data))))
7376 (or (memq num gnus-newsgroup-unfetched)
7377 (not (or (and unread
7378 (memq num gnus-newsgroup-unreads))
7379 (and undownloaded
7380 (memq num gnus-newsgroup-undownloaded))
7381 (and unseen
7382 (memq num gnus-newsgroup-unseen)))))))
7383 (setq data (cdr data)))
7384 (prog1
7385 (if data
7386 (progn
7387 (goto-char (gnus-data-pos (car data)))
7388 (gnus-data-number (car data)))
7389 (gnus-message 3 "No more%s articles"
7390 (let* ((r (when unread " unread"))
7391 (d (when undownloaded " undownloaded"))
7392 (s (when unseen " unseen"))
7393 (l (delq nil (list r d s))))
7394 (cond ((= 3 (length l))
7395 (concat r "," d ", or" s))
7396 ((= 2 (length l))
7397 (concat (car l) ", or" (cadr l)))
7398 ((= 1 (length l))
7399 (car l))
7400 (t
7401 ""))))
7402 nil
7403 )
7404 (gnus-summary-position-point))))))
eec82323
LMI
7405
7406(defun gnus-summary-next-subject (n &optional unread dont-display)
7407 "Go to next N'th summary line.
7408If N is negative, go to the previous N'th subject line.
7409If UNREAD is non-nil, only unread articles are selected.
7410The difference between N and the actual number of steps taken is
7411returned."
7412 (interactive "p")
7413 (let ((backward (< n 0))
7414 (n (abs n)))
7415 (while (and (> n 0)
7416 (if backward
7417 (gnus-summary-find-prev unread)
7418 (gnus-summary-find-next unread)))
16409b0b
GM
7419 (unless (zerop (setq n (1- n)))
7420 (gnus-summary-show-thread)))
eec82323
LMI
7421 (when (/= 0 n)
7422 (gnus-message 7 "No more%s articles"
7423 (if unread " unread" "")))
7424 (unless dont-display
7425 (gnus-summary-recenter)
7426 (gnus-summary-position-point))
7427 n))
7428
7429(defun gnus-summary-next-unread-subject (n)
7430 "Go to next N'th unread summary line."
7431 (interactive "p")
7432 (gnus-summary-next-subject n t))
7433
7434(defun gnus-summary-prev-subject (n &optional unread)
7435 "Go to previous N'th summary line.
7436If optional argument UNREAD is non-nil, only unread article is selected."
7437 (interactive "p")
7438 (gnus-summary-next-subject (- n) unread))
7439
7440(defun gnus-summary-prev-unread-subject (n)
7441 "Go to previous N'th unread summary line."
7442 (interactive "p")
7443 (gnus-summary-next-subject (- n) t))
7444
23f87bed
MB
7445(defun gnus-summary-goto-subjects (articles)
7446 "Insert the subject header for ARTICLES in the current buffer."
7447 (save-excursion
7448 (dolist (article articles)
7449 (gnus-summary-goto-subject article t)))
7450 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7451 (gnus-summary-position-point))
132cf96d 7452
eec82323 7453(defun gnus-summary-goto-subject (article &optional force silent)
d55fe5bb 7454 "Go to the subject line of ARTICLE.
eec82323
LMI
7455If FORCE, also allow jumping to articles not currently shown."
7456 (interactive "nArticle number: ")
23f87bed
MB
7457 (unless (numberp article)
7458 (error "Article %s is not a number" article))
eec82323
LMI
7459 (let ((b (point))
7460 (data (gnus-data-find article)))
7461 ;; We read in the article if we have to.
7462 (and (not data)
7463 force
6748645f
LMI
7464 (gnus-summary-insert-subject
7465 article
7466 (if (or (numberp force) (vectorp force)) force)
7467 t)
eec82323
LMI
7468 (setq data (gnus-data-find article)))
7469 (goto-char b)
7470 (if (not data)
7471 (progn
7472 (unless silent
7473 (gnus-message 3 "Can't find article %d" article))
7474 nil)
23f87bed
MB
7475 (let ((pt (gnus-data-pos data)))
7476 (goto-char pt)
7477 (gnus-summary-set-article-display-arrow pt))
6748645f 7478 (gnus-summary-position-point)
eec82323
LMI
7479 article)))
7480
7481;; Walking around summary lines with displaying articles.
7482
7483(defun gnus-summary-expand-window (&optional arg)
7484 "Make the summary buffer take up the entire Emacs frame.
7485Given a prefix, will force an `article' buffer configuration."
7486 (interactive "P")
eec82323
LMI
7487 (if arg
7488 (gnus-configure-windows 'article 'force)
7489 (gnus-configure-windows 'summary 'force)))
7490
7491(defun gnus-summary-display-article (article &optional all-header)
7492 "Display ARTICLE in article buffer."
01c52d31
MB
7493 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7494 (with-current-buffer gnus-article-buffer
7495 (eq major-mode 'gnus-article-mode)))
7496 (gnus-article-setup-buffer))
eec82323 7497 (gnus-set-global-variables)
01c52d31
MB
7498 (with-current-buffer gnus-article-buffer
7499 (setq gnus-article-charset gnus-newsgroup-charset)
7500 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7501 (mm-enable-multibyte))
eec82323
LMI
7502 (if (null article)
7503 nil
7504 (prog1
7505 (if gnus-summary-display-article-function
7506 (funcall gnus-summary-display-article-function article all-header)
7507 (gnus-article-prepare article all-header))
6748645f 7508 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7509 (when (and gnus-current-article
7510 (not (zerop gnus-current-article)))
7511 (gnus-summary-goto-subject gnus-current-article))
7512 (gnus-summary-recenter)
7513 (when (and gnus-use-trees gnus-show-threads)
7514 (gnus-possibly-generate-tree article)
7515 (gnus-highlight-selected-tree article))
7516 ;; Successfully display article.
7517 (gnus-article-set-window-start
7518 (cdr (assq article gnus-newsgroup-bookmarks))))))
7519
7520(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7521 "Select the current article.
7522If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7523non-nil, the article will be re-fetched even if it already present in
7524the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7525be displayed."
7526 ;; Make sure we are in the summary buffer to work around bbdb bug.
7527 (unless (eq major-mode 'gnus-summary-mode)
7528 (set-buffer gnus-summary-buffer))
7529 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7530 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7531 gnus-summary-display-article-function)
eec82323
LMI
7532 (and (not pseudo)
7533 (gnus-summary-article-pseudo-p article)
a8151ef7 7534 (error "This is a pseudo-article"))
c7a91ce1 7535 (with-current-buffer gnus-summary-buffer
16409b0b
GM
7536 (if (or (and gnus-single-article-buffer
7537 (or (null gnus-current-article)
7538 (null gnus-article-current)
7539 (null (get-buffer gnus-article-buffer))
7540 (not (eq article (cdr gnus-article-current)))
7541 (not (equal (car gnus-article-current)
7542 gnus-newsgroup-name))))
7543 (and (not gnus-single-article-buffer)
7544 (or (null gnus-current-article)
7545 (not (eq gnus-current-article article))))
7546 force)
7547 ;; The requested article is different from the current article.
7548 (progn
16409b0b
GM
7549 (gnus-summary-display-article article all-headers)
7550 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7551 (with-current-buffer gnus-article-buffer
16409b0b 7552 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7553 (mm-disable-multibyte))))
16409b0b
GM
7554 (gnus-article-set-window-start
7555 (cdr (assq article gnus-newsgroup-bookmarks)))
7556 article)
16409b0b 7557 'old))))
eec82323 7558
23f87bed
MB
7559(defun gnus-summary-force-verify-and-decrypt ()
7560 "Display buttons for signed/encrypted parts and verify/decrypt them."
7561 (interactive)
7562 (let ((mm-verify-option 'known)
7563 (mm-decrypt-option 'known)
7564 (gnus-article-emulate-mime t)
7565 (gnus-buttonized-mime-types (append (list "multipart/signed"
7566 "multipart/encrypted")
7567 gnus-buttonized-mime-types)))
7568 (gnus-summary-select-article nil 'force)))
7569
eec82323
LMI
7570(defun gnus-summary-set-current-mark (&optional current-mark)
7571 "Obsolete function."
7572 nil)
7573
7574(defun gnus-summary-next-article (&optional unread subject backward push)
7575 "Select the next article.
7576If UNREAD, only unread articles are selected.
7577If SUBJECT, only articles with SUBJECT are selected.
7578If BACKWARD, the previous article is selected instead of the next."
7579 (interactive "P")
11e95b02
MB
7580 ;; Make sure we are in the summary buffer.
7581 (unless (eq major-mode 'gnus-summary-mode)
7582 (set-buffer gnus-summary-buffer))
eec82323
LMI
7583 (cond
7584 ;; Is there such an article?
7585 ((and (gnus-summary-search-forward unread subject backward)
7586 (or (gnus-summary-display-article (gnus-summary-article-number))
7587 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7588 (gnus-summary-position-point))
7589 ;; If not, we try the first unread, if that is wanted.
7590 ((and subject
7591 gnus-auto-select-same
7592 (gnus-summary-first-unread-article))
7593 (gnus-summary-position-point)
7594 (gnus-message 6 "Wrapped"))
7595 ;; Try to get next/previous article not displayed in this group.
7596 ((and gnus-auto-extend-newsgroup
7597 (not unread) (not subject))
7598 (gnus-summary-goto-article
7599 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7600 nil (count-lines (point-min) (point))))
eec82323
LMI
7601 ;; Go to next/previous group.
7602 (t
7603 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7604 (gnus-summary-jump-to-group gnus-newsgroup-name))
7605 (let ((cmd last-command-char)
7606 (point
01c52d31 7607 (with-current-buffer gnus-group-buffer
eec82323
LMI
7608 (point)))
7609 (group
7610 (if (eq gnus-keep-same-level 'best)
7611 (gnus-summary-best-group gnus-newsgroup-name)
7612 (gnus-summary-search-group backward gnus-keep-same-level))))
7613 ;; For some reason, the group window gets selected. We change
7614 ;; it back.
7615 (select-window (get-buffer-window (current-buffer)))
7616 ;; Select next unread newsgroup automagically.
7617 (cond
7618 ((or (not gnus-auto-select-next)
7619 (not cmd))
7620 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7621 ((or (eq gnus-auto-select-next 'quietly)
7622 (and (eq gnus-auto-select-next 'slightly-quietly)
7623 push)
7624 (and (eq gnus-auto-select-next 'almost-quietly)
7625 (gnus-summary-last-article-p)))
7626 ;; Select quietly.
7627 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7628 (gnus-summary-exit)
7629 (gnus-message 7 "No more%s articles (%s)..."
7630 (if unread " unread" "")
7631 (if group (concat "selecting " group)
7632 "exiting"))
7633 (gnus-summary-next-group nil group backward)))
7634 (t
7635 (when (gnus-key-press-event-p last-input-event)
7636 (gnus-summary-walk-group-buffer
7637 gnus-newsgroup-name cmd unread backward point))))))))
7638
7639(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7640 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7641 (?\C-p (gnus-group-prev-unread-group 1))))
7642 (cursor-in-echo-area t)
23f87bed 7643 keve key group ended prompt)
c7a91ce1 7644 (with-current-buffer gnus-group-buffer
eec82323
LMI
7645 (goto-char start)
7646 (setq group
7647 (if (eq gnus-keep-same-level 'best)
7648 (gnus-summary-best-group gnus-newsgroup-name)
7649 (gnus-summary-search-group backward gnus-keep-same-level))))
7650 (while (not ended)
23f87bed
MB
7651 (setq prompt
7652 (format
7653 "No more%s articles%s " (if unread " unread" "")
7654 (if (and group
7655 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7656 (format " (Type %s for %s [%s])"
91472578
MB
7657 (single-key-description cmd)
7658 (gnus-group-decoded-name group)
01c52d31 7659 (gnus-group-unread group))
23f87bed
MB
7660 (format " (Type %s to exit %s)"
7661 (single-key-description cmd)
91472578 7662 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7663 ;; Confirm auto selection.
23f87bed
MB
7664 (setq key (car (setq keve (gnus-read-event-char prompt)))
7665 ended t)
eec82323
LMI
7666 (cond
7667 ((assq key keystrokes)
7668 (let ((obuf (current-buffer)))
7669 (switch-to-buffer gnus-group-buffer)
7670 (when group
7671 (gnus-group-jump-to-group group))
7672 (eval (cadr (assq key keystrokes)))
7673 (setq group (gnus-group-group-name))
7674 (switch-to-buffer obuf))
7675 (setq ended nil))
7676 ((equal key cmd)
7677 (if (or (not group)
7678 (gnus-ephemeral-group-p gnus-newsgroup-name))
7679 (gnus-summary-exit)
7680 (gnus-summary-next-group nil group backward)))
7681 (t
7682 (push (cdr keve) unread-command-events))))))
7683
7684(defun gnus-summary-next-unread-article ()
7685 "Select unread article after current one."
7686 (interactive)
7687 (gnus-summary-next-article
7688 (or (not (eq gnus-summary-goto-unread 'never))
7689 (gnus-summary-last-article-p (gnus-summary-article-number)))
7690 (and gnus-auto-select-same
7691 (gnus-summary-article-subject))))
7692
7693(defun gnus-summary-prev-article (&optional unread subject)
bbbe940b 7694 "Select the article before the current one.
eec82323
LMI
7695If UNREAD is non-nil, only unread articles are selected."
7696 (interactive "P")
7697 (gnus-summary-next-article unread subject t))
7698
7699(defun gnus-summary-prev-unread-article ()
7700 "Select unread article before current one."
7701 (interactive)
7702 (gnus-summary-prev-article
7703 (or (not (eq gnus-summary-goto-unread 'never))
7704 (gnus-summary-first-article-p (gnus-summary-article-number)))
7705 (and gnus-auto-select-same
7706 (gnus-summary-article-subject))))
7707
23f87bed 7708(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7709 "Show next page of the selected article.
7710If at the end of the current article, select the next article.
7711LINES says how many lines should be scrolled up.
7712
7713If CIRCULAR is non-nil, go to the start of the article instead of
7714selecting the next article when reaching the end of the current
23f87bed
MB
7715article.
7716
7717If STOP is non-nil, just stop when reaching the end of the message.
7718
7719Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7720 (interactive "P")
7721 (setq gnus-summary-buffer (current-buffer))
7722 (gnus-set-global-variables)
7723 (let ((article (gnus-summary-article-number))
7724 (article-window (get-buffer-window gnus-article-buffer t))
7725 endp)
6748645f
LMI
7726 ;; If the buffer is empty, we have no article.
7727 (unless article
7728 (error "No article to select"))
eec82323
LMI
7729 (gnus-configure-windows 'article)
7730 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7731 (if (and (eq gnus-summary-goto-unread 'never)
7732 (not (gnus-summary-last-article-p article)))
7733 (gnus-summary-next-article)
7734 (gnus-summary-next-unread-article))
7735 (if (or (null gnus-current-article)
7736 (null gnus-article-current)
7737 (/= article (cdr gnus-article-current))
7738 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7739 ;; Selected subject is different from current article's.
7740 (gnus-summary-display-article article)
7741 (when article-window
7742 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7743 (setq endp (or (gnus-article-next-page lines)
7744 (gnus-article-only-boring-p))))
eec82323 7745 (when endp
23f87bed
MB
7746 (cond (stop
7747 (gnus-message 3 "End of message"))
7748 (circular
eec82323
LMI
7749 (gnus-summary-beginning-of-article))
7750 (lines
7751 (gnus-message 3 "End of message"))
7752 ((null lines)
7753 (if (and (eq gnus-summary-goto-unread 'never)
7754 (not (gnus-summary-last-article-p article)))
7755 (gnus-summary-next-article)
7756 (gnus-summary-next-unread-article))))))))
7757 (gnus-summary-recenter)
7758 (gnus-summary-position-point)))
7759
7760(defun gnus-summary-prev-page (&optional lines move)
7761 "Show previous page of selected article.
7762Argument LINES specifies lines to be scrolled down.
7763If MOVE, move to the previous unread article if point is at
7764the beginning of the buffer."
7765 (interactive "P")
eec82323
LMI
7766 (let ((article (gnus-summary-article-number))
7767 (article-window (get-buffer-window gnus-article-buffer t))
7768 endp)
7769 (gnus-configure-windows 'article)
7770 (if (or (null gnus-current-article)
7771 (null gnus-article-current)
7772 (/= article (cdr gnus-article-current))
7773 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7774 ;; Selected subject is different from current article's.
7775 (gnus-summary-display-article article)
7776 (gnus-summary-recenter)
7777 (when article-window
7778 (gnus-eval-in-buffer-window gnus-article-buffer
7779 (setq endp (gnus-article-prev-page lines)))
7780 (when (and move endp)
7781 (cond (lines
7782 (gnus-message 3 "Beginning of message"))
7783 ((null lines)
7784 (if (and (eq gnus-summary-goto-unread 'never)
7785 (not (gnus-summary-first-article-p article)))
7786 (gnus-summary-prev-article)
7787 (gnus-summary-prev-unread-article))))))))
7788 (gnus-summary-position-point))
7789
7790(defun gnus-summary-prev-page-or-article (&optional lines)
7791 "Show previous page of selected article.
7792Argument LINES specifies lines to be scrolled down.
7793If at the beginning of the article, go to the next article."
7794 (interactive "P")
7795 (gnus-summary-prev-page lines t))
7796
7797(defun gnus-summary-scroll-up (lines)
7798 "Scroll up (or down) one line current article.
7799Argument LINES specifies lines to be scrolled up (or down if negative)."
7800 (interactive "p")
eec82323
LMI
7801 (gnus-configure-windows 'article)
7802 (gnus-summary-show-thread)
7803 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7804 (gnus-eval-in-buffer-window gnus-article-buffer
7805 (cond ((> lines 0)
7806 (when (gnus-article-next-page lines)
7807 (gnus-message 3 "End of message")))
7808 ((< lines 0)
7809 (gnus-article-prev-page (- lines))))))
7810 (gnus-summary-recenter)
7811 (gnus-summary-position-point))
7812
6748645f
LMI
7813(defun gnus-summary-scroll-down (lines)
7814 "Scroll down (or up) one line current article.
7815Argument LINES specifies lines to be scrolled down (or up if negative)."
7816 (interactive "p")
7817 (gnus-summary-scroll-up (- lines)))
7818
eec82323
LMI
7819(defun gnus-summary-next-same-subject ()
7820 "Select next article which has the same subject as current one."
7821 (interactive)
eec82323
LMI
7822 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7823
7824(defun gnus-summary-prev-same-subject ()
7825 "Select previous article which has the same subject as current one."
7826 (interactive)
eec82323
LMI
7827 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7828
7829(defun gnus-summary-next-unread-same-subject ()
7830 "Select next unread article which has the same subject as current one."
7831 (interactive)
eec82323
LMI
7832 (gnus-summary-next-article t (gnus-summary-article-subject)))
7833
7834(defun gnus-summary-prev-unread-same-subject ()
7835 "Select previous unread article which has the same subject as current one."
7836 (interactive)
eec82323
LMI
7837 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7838
7839(defun gnus-summary-first-unread-article ()
7840 "Select the first unread article.
7841Return nil if there are no unread articles."
7842 (interactive)
eec82323
LMI
7843 (prog1
7844 (when (gnus-summary-first-subject t)
7845 (gnus-summary-show-thread)
7846 (gnus-summary-first-subject t)
7847 (gnus-summary-display-article (gnus-summary-article-number)))
7848 (gnus-summary-position-point)))
7849
16409b0b
GM
7850(defun gnus-summary-first-unread-subject ()
7851 "Place the point on the subject line of the first unread article.
7852Return nil if there are no unread articles."
7853 (interactive)
7854 (prog1
7855 (when (gnus-summary-first-subject t)
7856 (gnus-summary-show-thread)
7857 (gnus-summary-first-subject t))
7858 (gnus-summary-position-point)))
7859
23f87bed
MB
7860(defun gnus-summary-first-unseen-subject ()
7861 "Place the point on the subject line of the first unseen article.
7862Return nil if there are no unseen articles."
7863 (interactive)
7864 (prog1
7865 (when (gnus-summary-first-subject nil nil t)
7866 (gnus-summary-show-thread)
7867 (gnus-summary-first-subject nil nil t))
7868 (gnus-summary-position-point)))
7869
7870(defun gnus-summary-first-unseen-or-unread-subject ()
7871 "Place the point on the subject line of the first unseen article or,
7872if all article have been seen, on the subject line of the first unread
7873article."
7874 (interactive)
7875 (prog1
7876 (unless (when (gnus-summary-first-subject nil nil t)
7877 (gnus-summary-show-thread)
7878 (gnus-summary-first-subject nil nil t))
7879 (when (gnus-summary-first-subject t)
7880 (gnus-summary-show-thread)
7881 (gnus-summary-first-subject t)))
7882 (gnus-summary-position-point)))
7883
eec82323
LMI
7884(defun gnus-summary-first-article ()
7885 "Select the first article.
7886Return nil if there are no articles."
7887 (interactive)
eec82323
LMI
7888 (prog1
7889 (when (gnus-summary-first-subject)
16409b0b
GM
7890 (gnus-summary-show-thread)
7891 (gnus-summary-first-subject)
7892 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
7893 (gnus-summary-position-point)))
7894
23f87bed
MB
7895(defun gnus-summary-best-unread-article (&optional arg)
7896 "Select the unread article with the highest score.
7897If given a prefix argument, select the next unread article that has a
7898score higher than the default score."
7899 (interactive "P")
7900 (let ((article (if arg
7901 (gnus-summary-better-unread-subject)
7902 (gnus-summary-best-unread-subject))))
7903 (if article
7904 (gnus-summary-goto-article article)
7905 (error "No unread articles"))))
7906
7907(defun gnus-summary-best-unread-subject ()
7908 "Select the unread subject with the highest score."
eec82323 7909 (interactive)
eec82323
LMI
7910 (let ((best -1000000)
7911 (data gnus-newsgroup-data)
7912 article score)
7913 (while data
7914 (and (gnus-data-unread-p (car data))
7915 (> (setq score
7916 (gnus-summary-article-score (gnus-data-number (car data))))
7917 best)
7918 (setq best score
7919 article (gnus-data-number (car data))))
7920 (setq data (cdr data)))
23f87bed
MB
7921 (when article
7922 (gnus-summary-goto-subject article))
7923 (gnus-summary-position-point)
7924 article))
7925
7926(defun gnus-summary-better-unread-subject ()
7927 "Select the first unread subject that has a score over the default score."
7928 (interactive)
7929 (let ((data gnus-newsgroup-data)
7930 article score)
7931 (while (and (setq article (gnus-data-number (car data)))
7932 (or (gnus-data-read-p (car data))
7933 (not (> (gnus-summary-article-score article)
7934 gnus-summary-default-score))))
7935 (setq data (cdr data)))
7936 (when article
7937 (gnus-summary-goto-subject article))
7938 (gnus-summary-position-point)
7939 article))
eec82323
LMI
7940
7941(defun gnus-summary-last-subject ()
7942 "Go to the last displayed subject line in the group."
7943 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7944 (when article
7945 (gnus-summary-goto-subject article))))
7946
7947(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
7948 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7949If ALL-HEADERS is non-nil, no header lines are hidden.
7950If FORCE, go to the article even if it isn't displayed. If FORCE
7951is a number, it is the line the article is to be displayed on."
eec82323
LMI
7952 (interactive
7953 (list
6748645f
LMI
7954 (completing-read
7955 "Article number or Message-ID: "
7956 (mapcar (lambda (number) (list (int-to-string number)))
7957 gnus-newsgroup-limit))
eec82323
LMI
7958 current-prefix-arg
7959 t))
7960 (prog1
6748645f 7961 (if (and (stringp article)
23f87bed 7962 (string-match "@\\|%40" article))
6748645f
LMI
7963 (gnus-summary-refer-article article)
7964 (when (stringp article)
7965 (setq article (string-to-number article)))
7966 (if (gnus-summary-goto-subject article force)
7967 (gnus-summary-display-article article all-headers)
7968 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
7969 (gnus-summary-position-point)))
7970
7971(defun gnus-summary-goto-last-article ()
7972 "Go to the previously read article."
7973 (interactive)
7974 (prog1
7975 (when gnus-last-article
6748645f 7976 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
7977 (gnus-summary-position-point)))
7978
7979(defun gnus-summary-pop-article (number)
7980 "Pop one article off the history and go to the previous.
7981NUMBER articles will be popped off."
7982 (interactive "p")
7983 (let (to)
7984 (setq gnus-newsgroup-history
7985 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7986 (if to
6748645f 7987 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
7988 (error "Article history empty")))
7989 (gnus-summary-position-point))
7990
7991;; Summary commands and functions for limiting the summary buffer.
7992
7993(defun gnus-summary-limit-to-articles (n)
7994 "Limit the summary buffer to the next N articles.
7995If not given a prefix, use the process marked articles instead."
7996 (interactive "P")
eec82323
LMI
7997 (prog1
7998 (let ((articles (gnus-summary-work-articles n)))
7999 (setq gnus-newsgroup-processable nil)
8000 (gnus-summary-limit articles))
8001 (gnus-summary-position-point)))
8002
8003(defun gnus-summary-pop-limit (&optional total)
8004 "Restore the previous limit.
8005If given a prefix, remove all limits."
8006 (interactive "P")
eec82323
LMI
8007 (when total
8008 (setq gnus-newsgroup-limits
8009 (list (mapcar (lambda (h) (mail-header-number h))
8010 gnus-newsgroup-headers))))
8011 (unless gnus-newsgroup-limits
8012 (error "No limit to pop"))
8013 (prog1
8014 (gnus-summary-limit nil 'pop)
8015 (gnus-summary-position-point)))
8016
47b63dfa
SZ
8017(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8018 "Limit the summary buffer to articles that have subjects that match a regexp.
8019If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 8020 (interactive
47b63dfa
SZ
8021 (list (read-string (if current-prefix-arg
8022 "Exclude subject (regexp): "
a1506d29 8023 "Limit to subject (regexp): "))
47b63dfa 8024 nil current-prefix-arg))
eec82323
LMI
8025 (unless header
8026 (setq header "subject"))
8027 (when (not (equal "" subject))
8028 (prog1
8029 (let ((articles (gnus-summary-find-matching
a1506d29 8030 (or header "subject") subject 'all nil nil
47b63dfa 8031 not-matching)))
eec82323
LMI
8032 (unless articles
8033 (error "Found no matches for \"%s\"" subject))
8034 (gnus-summary-limit articles))
8035 (gnus-summary-position-point))))
8036
ef6e0ec7 8037(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
8038 "Limit the summary buffer to articles that have authors that match a regexp.
8039If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 8040 (interactive
47b63dfa
SZ
8041 (list (read-string (if current-prefix-arg
8042 "Exclude author (regexp): "
a1506d29 8043 "Limit to author (regexp): "))
ef6e0ec7
SZ
8044 current-prefix-arg))
8045 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323 8046
01c52d31
MB
8047(defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8048 "Limit the summary buffer to articles with the given RECIPIENT.
8049
8050If NOT-MATCHING, exclude RECIPIENT.
8051
8052To and Cc headers are checked. You need to include them in
8053`nnmail-extra-headers'."
8054 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8055 (interactive
8056 (list (read-string (format "%s recipient (regexp): "
8057 (if current-prefix-arg "Exclude" "Limit to")))
8058 current-prefix-arg))
8059 (when (not (equal "" recipient))
8060 (prog1 (let* ((to
8061 (if (memq 'To nnmail-extra-headers)
8062 (gnus-summary-find-matching
8063 (cons 'extra 'To) recipient 'all nil nil
8064 not-matching)
8065 (gnus-message
8066 1 "`To' isn't present in `nnmail-extra-headers'")
8067 (sit-for 1)
8068 nil))
8069 (cc
8070 (if (memq 'Cc nnmail-extra-headers)
8071 (gnus-summary-find-matching
8072 (cons 'extra 'Cc) recipient 'all nil nil
8073 not-matching)
8074 (gnus-message
8075 1 "`Cc' isn't present in `nnmail-extra-headers'")
8076 (sit-for 1)
8077 nil))
8078 (articles
8079 (if not-matching
8080 ;; We need the numbers that are in both lists:
8081 (mapcar (lambda (a)
8082 (and (memq a to) a))
8083 cc)
8084 (nconc to cc))))
8085 (unless articles
8086 (error "Found no matches for \"%s\"" recipient))
8087 (gnus-summary-limit articles))
8088 (gnus-summary-position-point))))
8089
8090(defun gnus-summary-limit-to-address (address &optional not-matching)
8091 "Limit the summary buffer to articles with the given ADDRESS.
8092
8093If NOT-MATCHING, exclude ADDRESS.
8094
8095To, Cc and From headers are checked. You need to include `To' and `Cc'
8096in `nnmail-extra-headers'."
8097 (interactive
8098 (list (read-string (format "%s address (regexp): "
8099 (if current-prefix-arg "Exclude" "Limit to")))
8100 current-prefix-arg))
8101 (when (not (equal "" address))
8102 (prog1 (let* ((to
8103 (if (memq 'To nnmail-extra-headers)
8104 (gnus-summary-find-matching
8105 (cons 'extra 'To) address 'all nil nil
8106 not-matching)
8107 (gnus-message
8108 1 "`To' isn't present in `nnmail-extra-headers'")
8109 (sit-for 1)
8110 t))
8111 (cc
8112 (if (memq 'Cc nnmail-extra-headers)
8113 (gnus-summary-find-matching
8114 (cons 'extra 'Cc) address 'all nil nil
8115 not-matching)
8116 (gnus-message
8117 1 "`Cc' isn't present in `nnmail-extra-headers'")
8118 (sit-for 1)
8119 t))
8120 (from
8121 (gnus-summary-find-matching "from" address
8122 'all nil nil not-matching))
8123 (articles
8124 (if not-matching
8125 ;; We need the numbers that are in all lists:
8126 (if (eq cc t)
8127 (if (eq to t)
8128 from
8129 (mapcar (lambda (a) (car (memq a from))) to))
8130 (if (eq to t)
8131 (mapcar (lambda (a) (car (memq a from))) cc)
8132 (mapcar (lambda (a) (car (memq a from)))
8133 (mapcar (lambda (a) (car (memq a to)))
8134 cc))))
8135 (nconc (if (eq to t) nil to)
8136 (if (eq cc t) nil cc)
8137 from))))
8138 (unless articles
8139 (error "Found no matches for \"%s\"" address))
8140 (gnus-summary-limit articles))
8141 (gnus-summary-position-point))))
8142
8143(defun gnus-summary-limit-strange-charsets-predicate (header)
8144 (let ((string (concat (mail-header-subject header)
8145 (mail-header-from header)))
8146 charset found)
8147 (dotimes (i (1- (length string)))
8148 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8149 (when (string-match "unicode\\|big\\|japanese" charset)
8150 (setq found t)))
8151 found))
8152
8153(defun gnus-summary-limit-to-predicate (predicate)
8154 "Limit to articles where PREDICATE returns non-nil.
8155PREDICATE will be called with the header structures of the
8156articles."
8157 (let ((articles nil)
8158 (case-fold-search t))
8159 (dolist (header gnus-newsgroup-headers)
8160 (when (funcall predicate header)
8161 (push (mail-header-number header) articles)))
8162 (gnus-summary-limit (nreverse articles))))
8163
eec82323
LMI
8164(defun gnus-summary-limit-to-age (age &optional younger-p)
8165 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8166If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8167articles that are younger than AGE days."
16409b0b
GM
8168 (interactive
8169 (let ((younger current-prefix-arg)
8170 (days-got nil)
8171 days)
8172 (while (not days-got)
8173 (setq days (if younger
23f87bed
MB
8174 (read-string "Limit to articles younger than (in days, older when negative): ")
8175 (read-string
8176 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
8177 (when (> (length days) 0)
8178 (setq days (read days)))
8179 (if (numberp days)
23f87bed
MB
8180 (progn
8181 (setq days-got t)
01c52d31
MB
8182 (when (< days 0)
8183 (setq younger (not younger))
8184 (setq days (* days -1))))
16409b0b
GM
8185 (message "Please enter a number.")
8186 (sleep-for 1)))
8187 (list days younger)))
eec82323
LMI
8188 (prog1
8189 (let ((data gnus-newsgroup-data)
16409b0b 8190 (cutoff (days-to-time age))
eec82323
LMI
8191 articles d date is-younger)
8192 (while (setq d (pop data))
8193 (when (and (vectorp (gnus-data-header d))
8194 (setq date (mail-header-date (gnus-data-header d))))
16409b0b
GM
8195 (setq is-younger (time-less-p
8196 (time-since (condition-case ()
8197 (date-to-time date)
8198 (error '(0 0))))
eec82323 8199 cutoff))
6748645f
LMI
8200 (when (if younger-p
8201 is-younger
8202 (not is-younger))
eec82323
LMI
8203 (push (gnus-data-number d) articles))))
8204 (gnus-summary-limit (nreverse articles)))
8205 (gnus-summary-position-point)))
8206
47b63dfa 8207(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
8208 "Limit the summary buffer to articles that match an 'extra' header."
8209 (interactive
8210 (let ((header
8211 (intern
23f87bed 8212 (gnus-completing-read-with-default
16409b0b 8213 (symbol-name (car gnus-extra-headers))
47b63dfa 8214 (if current-prefix-arg
81df110a
RF
8215 "Exclude extra header"
8216 "Limit extra header")
16409b0b
GM
8217 (mapcar (lambda (x)
8218 (cons (symbol-name x) x))
8219 gnus-extra-headers)
8220 nil
8221 t))))
8222 (list header
a1506d29 8223 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
8224 (if current-prefix-arg "Exclude" "Limit to")
8225 header))
8226 current-prefix-arg)))
16409b0b
GM
8227 (when (not (equal "" regexp))
8228 (prog1
8229 (let ((articles (gnus-summary-find-matching
a1506d29 8230 (cons 'extra header) regexp 'all nil nil
47b63dfa 8231 not-matching)))
16409b0b
GM
8232 (unless articles
8233 (error "Found no matches for \"%s\"" regexp))
8234 (gnus-summary-limit articles))
8235 (gnus-summary-position-point))))
8236
23f87bed
MB
8237(defun gnus-summary-limit-to-display-predicate ()
8238 "Limit the summary buffer to the predicated in the `display' group parameter."
8239 (interactive)
8240 (unless gnus-newsgroup-display
8241 (error "There is no `display' group parameter"))
8242 (let (articles)
8243 (dolist (number gnus-newsgroup-articles)
8244 (when (funcall gnus-newsgroup-display)
8245 (push number articles)))
8246 (gnus-summary-limit articles))
8247 (gnus-summary-position-point))
8248
eec82323
LMI
8249(defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8250(make-obsolete
8251 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8252
8253(defun gnus-summary-limit-to-unread (&optional all)
8254 "Limit the summary buffer to articles that are not marked as read.
8255If ALL is non-nil, limit strictly to unread articles."
8256 (interactive "P")
8257 (if all
8258 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8259 (gnus-summary-limit-to-marks
8260 ;; Concat all the marks that say that an article is read and have
8261 ;; those removed.
8262 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 8263 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
8264 gnus-low-score-mark gnus-expirable-mark
8265 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8266 gnus-duplicate-mark gnus-souped-mark)
8267 'reverse)))
8268
01c52d31
MB
8269(defun gnus-summary-limit-to-headers (match &optional reverse)
8270 "Limit the summary buffer to articles that have headers that match MATCH.
8271If REVERSE (the prefix), limit to articles that don't match."
8272 (interactive "sMatch headers (regexp): \nP")
8273 (gnus-summary-limit-to-bodies match reverse t))
8274
8275(defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8276 "Limit the summary buffer to articles that have bodies that match MATCH.
8277If REVERSE (the prefix), limit to articles that don't match."
8278 (interactive "sMatch body (regexp): \nP")
8279 (let ((articles nil)
8280 (gnus-select-article-hook nil) ;Disable hook.
8281 (gnus-article-prepare-hook nil)
8282 (gnus-use-article-prefetch nil)
8283 (gnus-keep-backlog nil)
8284 (gnus-break-pages nil)
8285 (gnus-summary-display-arrow nil)
8286 (gnus-updated-mode-lines nil)
8287 (gnus-auto-center-summary nil)
8288 (gnus-display-mime-function nil))
8289 (dolist (data gnus-newsgroup-data)
8290 (let (gnus-mark-article-hook)
8291 (gnus-summary-select-article t t nil (gnus-data-number data)))
8292 (save-excursion
8293 (set-buffer gnus-article-buffer)
8294 (article-goto-body)
8295 (let* ((case-fold-search t)
8296 (found (if headersp
8297 (re-search-backward match nil t)
8298 (re-search-forward match nil t))))
8299 (when (or (and found
8300 (not reverse))
8301 (and (not found)
8302 reverse))
8303 (push (gnus-data-number data) articles)))))
8304 (if (not articles)
8305 (message "No messages matched")
8306 (gnus-summary-limit articles)))
8307 (gnus-summary-position-point))
8308
8309(defun gnus-summary-limit-to-singletons (&optional threadsp)
8310 "Limit the summary buffer to articles that aren't part on any thread.
8311If THREADSP (the prefix), limit to articles that are in threads."
8312 (interactive "P")
8313 (let ((articles nil)
8314 thread-articles
8315 threads)
8316 (dolist (thread gnus-newsgroup-threads)
8317 (if (stringp (car thread))
8318 (dolist (thread (cdr thread))
8319 (push thread threads))
8320 (push thread threads)))
8321 (dolist (thread threads)
8322 (setq thread-articles (gnus-articles-in-thread thread))
8323 (when (or (and threadsp
8324 (> (length thread-articles) 1))
8325 (and (not threadsp)
8326 (= (length thread-articles) 1)))
8327 (setq articles (nconc thread-articles articles))))
8328 (if (not articles)
8329 (message "No messages matched")
8330 (gnus-summary-limit articles))
8331 (gnus-summary-position-point)))
8332
8333(defun gnus-summary-limit-to-replied (&optional unreplied)
8334 "Limit the summary buffer to replied articles.
8335If UNREPLIED (the prefix), limit to unreplied articles."
8336 (interactive "P")
8337 (if unreplied
8338 (gnus-summary-limit
8339 (gnus-set-difference gnus-newsgroup-articles
8340 gnus-newsgroup-replied))
8341 (gnus-summary-limit gnus-newsgroup-replied))
8342 (gnus-summary-position-point))
8343
eec82323
LMI
8344(defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
8345(make-obsolete 'gnus-summary-delete-marked-with
81ceefe2 8346 'gnus-summary-limit-exclude-marks)
eec82323
LMI
8347
8348(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8349 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8350If REVERSE, limit the summary buffer to articles that are marked
8351with MARKS. MARKS can either be a string of marks or a list of marks.
8352Returns how many articles were removed."
8353 (interactive "sMarks: ")
8354 (gnus-summary-limit-to-marks marks t))
8355
8356(defun gnus-summary-limit-to-marks (marks &optional reverse)
8357 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8358If REVERSE (the prefix), limit the summary buffer to articles that are
8359not marked with MARKS. MARKS can either be a string of marks or a
8360list of marks.
8361Returns how many articles were removed."
6748645f 8362 (interactive "sMarks: \nP")
eec82323
LMI
8363 (prog1
8364 (let ((data gnus-newsgroup-data)
8365 (marks (if (listp marks) marks
8366 (append marks nil))) ; Transform to list.
8367 articles)
8368 (while data
8369 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8370 (memq (gnus-data-mark (car data)) marks))
8371 (push (gnus-data-number (car data)) articles))
8372 (setq data (cdr data)))
8373 (gnus-summary-limit articles))
8374 (gnus-summary-position-point)))
8375
23f87bed 8376(defun gnus-summary-limit-to-score (score)
eec82323 8377 "Limit to articles with score at or above SCORE."
23f87bed 8378 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
8379 (let ((data gnus-newsgroup-data)
8380 articles)
8381 (while data
8382 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8383 score)
8384 (push (gnus-data-number (car data)) articles))
8385 (setq data (cdr data)))
8386 (prog1
8387 (gnus-summary-limit articles)
8388 (gnus-summary-position-point))))
8389
23f87bed
MB
8390(defun gnus-summary-limit-to-unseen ()
8391 "Limit to unseen articles."
8392 (interactive)
8393 (prog1
8394 (gnus-summary-limit gnus-newsgroup-unseen)
8395 (gnus-summary-position-point)))
8396
6748645f 8397(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
8398 "Display all the hidden articles that is in the thread with ID in it.
8399When called interactively, ID is the Message-ID of the current
8400article."
6748645f
LMI
8401 (interactive (list (mail-header-id (gnus-summary-article-header))))
8402 (let ((articles (gnus-articles-in-thread
8403 (gnus-id-to-thread (gnus-root-id id)))))
8404 (prog1
8405 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
8406 (gnus-summary-limit-include-matching-articles
8407 "subject"
8408 (regexp-quote (gnus-simplify-subject-re
8409 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
8410 (gnus-summary-position-point))))
8411
23f87bed
MB
8412(defun gnus-summary-limit-include-matching-articles (header regexp)
8413 "Display all the hidden articles that have HEADERs that match REGEXP."
8414 (interactive (list (read-string "Match on header: ")
8415 (read-string "Regexp: ")))
8416 (let ((articles (gnus-find-matching-articles header regexp)))
8417 (prog1
8418 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8419 (gnus-summary-position-point))))
8420
8421(defun gnus-summary-insert-dormant-articles ()
8422 "Insert all the dormant articles for this group into the current buffer."
8423 (interactive)
8424 (let ((gnus-verbose (max 6 gnus-verbose)))
8425 (if (not gnus-newsgroup-dormant)
db629244 8426 (gnus-message 3 "No dormant articles for this group")
23f87bed
MB
8427 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8428
01c52d31
MB
8429(defun gnus-summary-insert-ticked-articles ()
8430 "Insert ticked articles for this group into the current buffer."
8431 (interactive)
8432 (let ((gnus-verbose (max 6 gnus-verbose)))
8433 (if (not gnus-newsgroup-marked)
8434 (gnus-message 3 "No ticked articles for this group")
8435 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8436
eec82323 8437(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
8438 "Display all the hidden articles that are marked as dormant.
8439Note that this command only works on a subset of the articles currently
8440fetched for this group."
eec82323 8441 (interactive)
eec82323
LMI
8442 (unless gnus-newsgroup-dormant
8443 (error "There are no dormant articles in this group"))
8444 (prog1
8445 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8446 (gnus-summary-position-point)))
8447
8448(defun gnus-summary-limit-exclude-dormant ()
8449 "Hide all dormant articles."
8450 (interactive)
eec82323
LMI
8451 (prog1
8452 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8453 (gnus-summary-position-point)))
8454
8455(defun gnus-summary-limit-exclude-childless-dormant ()
8456 "Hide all dormant articles that have no children."
8457 (interactive)
eec82323
LMI
8458 (let ((data (gnus-data-list t))
8459 articles d children)
8460 ;; Find all articles that are either not dormant or have
8461 ;; children.
8462 (while (setq d (pop data))
8463 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8464 (and (setq children
8465 (gnus-article-children (gnus-data-number d)))
8466 (let (found)
8467 (while children
8468 (when (memq (car children) articles)
8469 (setq children nil
8470 found t))
8471 (pop children))
8472 found)))
8473 (push (gnus-data-number d) articles)))
8474 ;; Do the limiting.
8475 (prog1
8476 (gnus-summary-limit articles)
8477 (gnus-summary-position-point))))
8478
8479(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8480 "Mark all unread excluded articles as read.
8481If ALL, mark even excluded ticked and dormants as read."
8482 (interactive "P")
23f87bed
MB
8483 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8484 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8485 (sort
8486 (mapcar (lambda (h) (mail-header-number h))
8487 gnus-newsgroup-headers)
8488 '<)
23f87bed 8489 gnus-newsgroup-limit))
eec82323 8490 article)
6748645f 8491 (setq gnus-newsgroup-unreads
23f87bed
MB
8492 (gnus-sorted-intersection gnus-newsgroup-unreads
8493 gnus-newsgroup-limit))
eec82323
LMI
8494 (if all
8495 (setq gnus-newsgroup-dormant nil
8496 gnus-newsgroup-marked nil
8497 gnus-newsgroup-reads
8498 (nconc
8499 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8500 gnus-newsgroup-reads))
8501 (while (setq article (pop articles))
8502 (unless (or (memq article gnus-newsgroup-dormant)
8503 (memq article gnus-newsgroup-marked))
8504 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8505
8506(defun gnus-summary-limit (articles &optional pop)
8507 (if pop
8508 ;; We pop the previous limit off the stack and use that.
8509 (setq articles (car gnus-newsgroup-limits)
8510 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8511 ;; We use the new limit, so we push the old limit on the stack.
8512 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8513 ;; Set the limit.
8514 (setq gnus-newsgroup-limit articles)
8515 (let ((total (length gnus-newsgroup-data))
8516 (data (gnus-data-find-list (gnus-summary-article-number)))
8517 (gnus-summary-mark-below nil) ; Inhibit this.
8518 found)
8519 ;; This will do all the work of generating the new summary buffer
8520 ;; according to the new limit.
8521 (gnus-summary-prepare)
8522 ;; Hide any threads, possibly.
23f87bed 8523 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8524 ;; Try to return to the article you were at, or one in the
8525 ;; neighborhood.
8526 (when data
8527 ;; We try to find some article after the current one.
8528 (while data
8529 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8530 (setq data nil
8531 found t))
8532 (setq data (cdr data))))
8533 (unless found
8534 ;; If there is no data, that means that we were after the last
8535 ;; article. The same goes when we can't find any articles
8536 ;; after the current one.
8537 (goto-char (point-max))
8538 (gnus-summary-find-prev))
6748645f 8539 (gnus-set-mode-line 'summary)
eec82323
LMI
8540 ;; We return how many articles were removed from the summary
8541 ;; buffer as a result of the new limit.
8542 (- total (length gnus-newsgroup-data))))
8543
8544(defsubst gnus-invisible-cut-children (threads)
8545 (let ((num 0))
8546 (while threads
8547 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8548 (incf num))
8549 (pop threads))
8550 (< num 2)))
8551
8552(defsubst gnus-cut-thread (thread)
8553 "Go forwards in the thread until we find an article that we want to display."
8554 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8555 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8556 (numberp gnus-fetch-old-headers)
eec82323
LMI
8557 (eq gnus-build-sparse-threads 'some)
8558 (eq gnus-build-sparse-threads 'more))
8559 ;; Deal with old-fetched headers and sparse threads.
8560 (while (and
8561 thread
8562 (or
8563 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8564 (gnus-summary-article-ancient-p
8565 (mail-header-number (car thread))))
6748645f
LMI
8566 (if (or (<= (length (cdr thread)) 1)
8567 (eq gnus-fetch-old-headers 'invisible))
8568 (setq gnus-newsgroup-limit
8569 (delq (mail-header-number (car thread))
8570 gnus-newsgroup-limit)
8571 thread (cadr thread))
8572 (when (gnus-invisible-cut-children (cdr thread))
8573 (let ((th (cdr thread)))
8574 (while th
8575 (if (memq (mail-header-number (caar th))
a8151ef7 8576 gnus-newsgroup-limit)
6748645f
LMI
8577 (setq thread (car th)
8578 th nil)
8579 (setq th (cdr th))))))))))
eec82323
LMI
8580 thread)
8581
8582(defun gnus-cut-threads (threads)
23f87bed 8583 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8584 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8585 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8586 (numberp gnus-fetch-old-headers)
eec82323
LMI
8587 (eq gnus-build-sparse-threads 'some)
8588 (eq gnus-build-sparse-threads 'more))
8589 (let ((th threads))
8590 (while th
8591 (setcar th (gnus-cut-thread (car th)))
8592 (setq th (cdr th)))))
8593 ;; Remove nixed out threads.
8594 (delq nil threads))
8595
8596(defun gnus-summary-initial-limit (&optional show-if-empty)
8597 "Figure out what the initial limit is supposed to be on group entry.
8598This entails weeding out unwanted dormants, low-scored articles,
8599fetch-old-headers verbiage, and so on."
8600 ;; Most groups have nothing to remove.
f394fa25
MB
8601 (unless (or gnus-inhibit-limiting
8602 (and (null gnus-newsgroup-dormant)
8603 (eq gnus-newsgroup-display 'gnus-not-ignore)
8604 (not (eq gnus-fetch-old-headers 'some))
8605 (not (numberp gnus-fetch-old-headers))
8606 (not (eq gnus-fetch-old-headers 'invisible))
8607 (null gnus-summary-expunge-below)
8608 (not (eq gnus-build-sparse-threads 'some))
8609 (not (eq gnus-build-sparse-threads 'more))
8610 (null gnus-thread-expunge-below)
8611 (not gnus-use-nocem)))
eec82323
LMI
8612 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8613 (setq gnus-newsgroup-limit nil)
8614 (mapatoms
8615 (lambda (node)
8616 (unless (car (symbol-value node))
8617 ;; These threads have no parents -- they are roots.
8618 (let ((nodes (cdr (symbol-value node)))
8619 thread)
8620 (while nodes
8621 (if (and gnus-thread-expunge-below
8622 (< (gnus-thread-total-score (car nodes))
8623 gnus-thread-expunge-below))
8624 (gnus-expunge-thread (pop nodes))
8625 (setq thread (pop nodes))
8626 (gnus-summary-limit-children thread))))))
8627 gnus-newsgroup-dependencies)
8628 ;; If this limitation resulted in an empty group, we might
8629 ;; pop the previous limit and use it instead.
8630 (when (and (not gnus-newsgroup-limit)
8631 show-if-empty)
8632 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8633 gnus-newsgroup-limit))
8634
8635(defun gnus-summary-limit-children (thread)
8636 "Return 1 if this subthread is visible and 0 if it is not."
8637 ;; First we get the number of visible children to this thread. This
8638 ;; is done by recursing down the thread using this function, so this
8639 ;; will really go down to a leaf article first, before slowly
8640 ;; working its way up towards the root.
8641 (when thread
04b61ae9 8642 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8643 (children
eec82323
LMI
8644 (if (cdr thread)
8645 (apply '+ (mapcar 'gnus-summary-limit-children
8646 (cdr thread)))
8647 0))
8648 (number (mail-header-number (car thread)))
8649 score)
8650 (if (and
8651 (not (memq number gnus-newsgroup-marked))
8652 (or
8653 ;; If this article is dormant and has absolutely no visible
8654 ;; children, then this article isn't visible.
8655 (and (memq number gnus-newsgroup-dormant)
8656 (zerop children))
8657 ;; If this is "fetch-old-headered" and there is no
8658 ;; visible children, then we don't want this article.
16409b0b
GM
8659 (and (or (eq gnus-fetch-old-headers 'some)
8660 (numberp gnus-fetch-old-headers))
eec82323
LMI
8661 (gnus-summary-article-ancient-p number)
8662 (zerop children))
6748645f
LMI
8663 ;; If this is "fetch-old-headered" and `invisible', then
8664 ;; we don't want this article.
8665 (and (eq gnus-fetch-old-headers 'invisible)
8666 (gnus-summary-article-ancient-p number))
eec82323
LMI
8667 ;; If this is a sparsely inserted article with no children,
8668 ;; we don't want it.
8669 (and (eq gnus-build-sparse-threads 'some)
8670 (gnus-summary-article-sparse-p number)
8671 (zerop children))
8672 ;; If we use expunging, and this article is really
8673 ;; low-scored, then we don't want this article.
8674 (when (and gnus-summary-expunge-below
8675 (< (setq score
8676 (or (cdr (assq number gnus-newsgroup-scored))
8677 gnus-summary-default-score))
8678 gnus-summary-expunge-below))
8679 ;; We increase the expunge-tally here, but that has
8680 ;; nothing to do with the limits, really.
8681 (incf gnus-newsgroup-expunged-tally)
8682 ;; We also mark as read here, if that's wanted.
8683 (when (and gnus-summary-mark-below
8684 (< score gnus-summary-mark-below))
8685 (setq gnus-newsgroup-unreads
8686 (delq number gnus-newsgroup-unreads))
8687 (if gnus-newsgroup-auto-expire
8688 (push number gnus-newsgroup-expirable)
8689 (push (cons number gnus-low-score-mark)
8690 gnus-newsgroup-reads)))
8691 t)
23f87bed
MB
8692 ;; Do the `display' group parameter.
8693 (and gnus-newsgroup-display
8694 (not (funcall gnus-newsgroup-display)))
eec82323 8695 ;; Check NoCeM things.
01c52d31
MB
8696 (when (and gnus-use-nocem
8697 (gnus-nocem-unwanted-article-p
8698 (mail-header-id (car thread))))
8699 (setq gnus-newsgroup-unreads
8700 (delq number gnus-newsgroup-unreads))
8701 t)))
eec82323
LMI
8702 ;; Nope, invisible article.
8703 0
8704 ;; Ok, this article is to be visible, so we add it to the limit
8705 ;; and return 1.
8706 (push number gnus-newsgroup-limit)
8707 1))))
8708
8709(defun gnus-expunge-thread (thread)
8710 "Mark all articles in THREAD as read."
8711 (let* ((number (mail-header-number (car thread))))
8712 (incf gnus-newsgroup-expunged-tally)
8713 ;; We also mark as read here, if that's wanted.
8714 (setq gnus-newsgroup-unreads
8715 (delq number gnus-newsgroup-unreads))
8716 (if gnus-newsgroup-auto-expire
8717 (push number gnus-newsgroup-expirable)
8718 (push (cons number gnus-low-score-mark)
8719 gnus-newsgroup-reads)))
8720 ;; Go recursively through all subthreads.
8721 (mapcar 'gnus-expunge-thread (cdr thread)))
8722
8723;; Summary article oriented commands
8724
8725(defun gnus-summary-refer-parent-article (n)
8726 "Refer parent article N times.
8727If N is negative, go to ancestor -N instead.
8728The difference between N and the number of articles fetched is returned."
8729 (interactive "p")
eec82323
LMI
8730 (let ((skip 1)
8731 error header ref)
8732 (when (not (natnump n))
8733 (setq skip (abs n)
8734 n 1))
8735 (while (and (> n 0)
8736 (not error))
8737 (setq header (gnus-summary-article-header))
8738 (if (and (eq (mail-header-number header)
8739 (cdr gnus-article-current))
8740 (equal gnus-newsgroup-name
8741 (car gnus-article-current)))
8742 ;; If we try to find the parent of the currently
8743 ;; displayed article, then we take a look at the actual
8744 ;; References header, since this is slightly more
8745 ;; reliable than the References field we got from the
8746 ;; server.
c7a91ce1 8747 (with-current-buffer gnus-original-article-buffer
eec82323
LMI
8748 (nnheader-narrow-to-headers)
8749 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8750 (when (setq ref (message-fetch-field "in-reply-to"))
8751 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8752 (widen))
8753 (setq ref
8754 ;; It's not the current article, so we take a bet on
8755 ;; the value we got from the server.
8756 (mail-header-references header)))
8757 (if (and ref
8758 (not (equal ref "")))
8759 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8760 (gnus-message 1 "Couldn't find parent"))
8761 (gnus-message 1 "No references in article %d"
8762 (gnus-summary-article-number))
8763 (setq error t))
8764 (decf n))
8765 (gnus-summary-position-point)
8766 n))
8767
8768(defun gnus-summary-refer-references ()
8769 "Fetch all articles mentioned in the References header.
6748645f 8770Return the number of articles fetched."
eec82323 8771 (interactive)
eec82323
LMI
8772 (let ((ref (mail-header-references (gnus-summary-article-header)))
8773 (current (gnus-summary-article-number))
8774 (n 0))
8775 (if (or (not ref)
8776 (equal ref ""))
8777 (error "No References in the current article")
8778 ;; For each Message-ID in the References header...
8779 (while (string-match "<[^>]*>" ref)
8780 (incf n)
8781 ;; ... fetch that article.
8782 (gnus-summary-refer-article
8783 (prog1 (match-string 0 ref)
8784 (setq ref (substring ref (match-end 0))))))
8785 (gnus-summary-goto-subject current)
8786 (gnus-summary-position-point)
8787 n)))
8788
6748645f
LMI
8789(defun gnus-summary-refer-thread (&optional limit)
8790 "Fetch all articles in the current thread.
8791If LIMIT (the numerical prefix), fetch that many old headers instead
8792of what's specified by the `gnus-refer-thread-limit' variable."
8793 (interactive "P")
8794 (let ((id (mail-header-id (gnus-summary-article-header)))
8795 (limit (if limit (prefix-numeric-value limit)
8796 gnus-refer-thread-limit)))
6748645f
LMI
8797 (unless (eq gnus-fetch-old-headers 'invisible)
8798 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8799 ;; Retrieve the headers and read them in.
23f87bed
MB
8800 (if (eq (if (numberp limit)
8801 (gnus-retrieve-headers
8802 (list (min
8803 (+ (mail-header-number
8804 (gnus-summary-article-header))
8805 limit)
8806 gnus-newsgroup-end))
8807 gnus-newsgroup-name (* limit 2))
8808 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8809 ;; headers.
8810 (gnus-retrieve-headers (list gnus-newsgroup-end)
8811 gnus-newsgroup-name limit))
6748645f
LMI
8812 'nov)
8813 (gnus-build-all-threads)
23f87bed 8814 (error "Can't fetch thread from back ends that don't support NOV"))
6748645f
LMI
8815 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8816 (gnus-summary-limit-include-thread id)))
8817
16409b0b
GM
8818(defun gnus-summary-refer-article (message-id)
8819 "Fetch an article specified by MESSAGE-ID."
8820 (interactive "sMessage-ID: ")
eec82323
LMI
8821 (when (and (stringp message-id)
8822 (not (zerop (length message-id))))
23f87bed 8823 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8824 ;; Construct the correct Message-ID if necessary.
8825 ;; Suggested by tale@pawl.rpi.edu.
8826 (unless (string-match "^<" message-id)
8827 (setq message-id (concat "<" message-id)))
8828 (unless (string-match ">$" message-id)
8829 (setq message-id (concat message-id ">")))
23f87bed
MB
8830 ;; People often post MIDs from URLs, so unhex it:
8831 (unless (string-match "@" message-id)
8832 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8833 (let* ((header (gnus-id-to-header message-id))
8834 (sparse (and header
8835 (gnus-summary-article-sparse-p
a8151ef7
LMI
8836 (mail-header-number header))
8837 (memq (mail-header-number header)
16409b0b
GM
8838 gnus-newsgroup-limit)))
8839 number)
6748645f
LMI
8840 (cond
8841 ;; If the article is present in the buffer we just go to it.
8842 ((and header
8843 (or (not (gnus-summary-article-sparse-p
8844 (mail-header-number header)))
8845 sparse))
8846 (prog1
8847 (gnus-summary-goto-article
8848 (mail-header-number header) nil t)
8849 (when sparse
8850 (gnus-summary-update-article (mail-header-number header)))))
8851 (t
16409b0b
GM
8852 ;; We fetch the article.
8853 (catch 'found
8854 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8855 (when (and (gnus-check-server gnus-override-method)
8856 ;; Fetch the header,
8857 (setq number (gnus-summary-insert-subject message-id)))
8858 ;; and display the article.
eec82323 8859 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8860 (throw 'found t)))
8861 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8862
8863(defun gnus-refer-article-methods ()
8f688cb0 8864 "Return a list of referable methods."
16409b0b
GM
8865 (cond
8866 ;; No method, so we default to current and native.
8867 ((null gnus-refer-article-method)
8868 (list gnus-current-select-method gnus-select-method))
8869 ;; Current.
8870 ((eq 'current gnus-refer-article-method)
8871 (list gnus-current-select-method))
8872 ;; List of select methods.
d4dfaa19
DL
8873 ((not (and (symbolp (car gnus-refer-article-method))
8874 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
8875 (let (out)
8876 (dolist (method gnus-refer-article-method)
8877 (push (if (eq 'current method)
8878 gnus-current-select-method
8879 method)
8880 out))
8881 (nreverse out)))
8882 ;; One single select method.
8883 (t
8884 (list gnus-refer-article-method))))
6748645f
LMI
8885
8886(defun gnus-summary-edit-parameters ()
8887 "Edit the group parameters of the current group."
8888 (interactive)
8889 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 8890
16409b0b
GM
8891(defun gnus-summary-customize-parameters ()
8892 "Customize the group parameters of the current group."
8893 (interactive)
8894 (gnus-group-customize gnus-newsgroup-name))
8895
eec82323
LMI
8896(defun gnus-summary-enter-digest-group (&optional force)
8897 "Enter an nndoc group based on the current article.
8898If FORCE, force a digest interpretation. If not, try
8899to guess what the document format is."
8900 (interactive "P")
eec82323 8901 (let ((conf gnus-current-window-configuration))
23f87bed
MB
8902 (save-window-excursion
8903 (save-excursion
8904 (let (gnus-article-prepare-hook
8905 gnus-display-mime-function
8906 gnus-break-pages)
8907 (gnus-summary-select-article))))
eec82323
LMI
8908 (setq gnus-current-window-configuration conf)
8909 (let* ((name (format "%s-%d"
8910 (gnus-group-prefixed-name
8911 gnus-newsgroup-name (list 'nndoc ""))
01c52d31 8912 (with-current-buffer gnus-summary-buffer
eec82323
LMI
8913 gnus-current-article)))
8914 (ogroup gnus-newsgroup-name)
8915 (params (append (gnus-info-params (gnus-get-info ogroup))
8916 (list (cons 'to-group ogroup))
23f87bed 8917 (list (cons 'parent-group ogroup))
eec82323
LMI
8918 (list (cons 'save-article-group ogroup))))
8919 (case-fold-search t)
8920 (buf (current-buffer))
16409b0b 8921 dig to-address)
c7a91ce1 8922 (with-current-buffer gnus-original-article-buffer
16409b0b
GM
8923 ;; Have the digest group inherit the main mail address of
8924 ;; the parent article.
23f87bed
MB
8925 (when (setq to-address (or (gnus-fetch-field "reply-to")
8926 (gnus-fetch-field "from")))
343d6628
MB
8927 (setq params
8928 (append
8929 (list (cons 'to-address
8930 (funcall gnus-decode-encoded-address-function
8931 to-address))))))
eec82323
LMI
8932 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8933 (insert-buffer-substring gnus-original-article-buffer)
8934 ;; Remove lines that may lead nndoc to misinterpret the
8935 ;; document type.
8936 (narrow-to-region
8937 (goto-char (point-min))
8938 (or (search-forward "\n\n" nil t) (point)))
8939 (goto-char (point-min))
16409b0b 8940 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8941 (widen))
8942 (unwind-protect
23f87bed 8943 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
8944 (gnus-newsgroup-ephemeral-ignored-charsets
8945 gnus-newsgroup-ignored-charsets))
8946 (gnus-group-read-ephemeral-group
8947 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8948 (nndoc-article-type
23f87bed
MB
8949 ,(if force 'mbox 'guess)))
8950 t nil nil nil
8951 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8952 "ADAPT")))))
16409b0b 8953 ;; Make all postings to this group go to the parent group.
23f87bed
MB
8954 (nconc (gnus-info-params (gnus-get-info name))
8955 params)
8956 ;; Couldn't select this doc group.
8957 (switch-to-buffer buf)
8958 (gnus-set-global-variables)
8959 (gnus-configure-windows 'summary)
8960 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
8961 (kill-buffer dig)))))
8962
8963(defun gnus-summary-read-document (n)
8964 "Open a new group based on the current article(s).
8965This will allow you to read digests and other similar
8966documents as newsgroups.
8967Obeys the standard process/prefix convention."
8968 (interactive "P")
01c52d31 8969 (let* ((ogroup gnus-newsgroup-name)
eec82323
LMI
8970 (params (append (gnus-info-params (gnus-get-info ogroup))
8971 (list (cons 'to-group ogroup))))
01c52d31
MB
8972 group egroup groups vgroup)
8973 (dolist (article (gnus-summary-work-articles n))
eec82323
LMI
8974 (setq group (format "%s-%d" gnus-newsgroup-name article))
8975 (gnus-summary-remove-process-mark article)
8976 (when (gnus-summary-display-article article)
8977 (save-excursion
16409b0b 8978 (with-temp-buffer
eec82323
LMI
8979 (insert-buffer-substring gnus-original-article-buffer)
8980 ;; Remove some headers that may lead nndoc to make
8981 ;; the wrong guess.
8982 (message-narrow-to-head)
8983 (goto-char (point-min))
01c52d31 8984 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8985 (widen)
8986 (if (setq egroup
8987 (gnus-group-read-ephemeral-group
8988 group `(nndoc ,group (nndoc-address ,(current-buffer))
8989 (nndoc-article-type guess))
8990 t nil t))
8991 (progn
c7a91ce1 8992 ;; Make all postings to this group go to the parent group.
eec82323
LMI
8993 (nconc (gnus-info-params (gnus-get-info egroup))
8994 params)
8995 (push egroup groups))
8996 ;; Couldn't select this doc group.
8997 (gnus-error 3 "Article couldn't be entered"))))))
8998 ;; Now we have selected all the documents.
8999 (cond
9000 ((not groups)
9001 (error "None of the articles could be interpreted as documents"))
9002 ((gnus-group-read-ephemeral-group
9003 (setq vgroup (format
9004 "nnvirtual:%s-%s" gnus-newsgroup-name
9005 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9006 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9007 t
9008 (cons (current-buffer) 'summary)))
9009 (t
9010 (error "Couldn't select virtual nndoc group")))))
9011
9012(defun gnus-summary-isearch-article (&optional regexp-p)
9013 "Do incremental search forward on the current article.
9014If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9015 (interactive "P")
eec82323
LMI
9016 (gnus-summary-select-article)
9017 (gnus-configure-windows 'article)
9018 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
9019 (save-restriction
9020 (widen)
9021 (isearch-forward regexp-p))))
eec82323 9022
01c52d31
MB
9023(defun gnus-summary-repeat-search-article-forward ()
9024 "Repeat the previous search forwards."
9025 (interactive)
9026 (unless gnus-last-search-regexp
9027 (error "No previous search"))
9028 (gnus-summary-search-article-forward gnus-last-search-regexp))
9029
9030(defun gnus-summary-repeat-search-article-backward ()
9031 "Repeat the previous search backwards."
9032 (interactive)
9033 (unless gnus-last-search-regexp
9034 (error "No previous search"))
9035 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9036
eec82323
LMI
9037(defun gnus-summary-search-article-forward (regexp &optional backward)
9038 "Search for an article containing REGEXP forward.
9039If BACKWARD, search backward instead."
9040 (interactive
9041 (list (read-string
9042 (format "Search article %s (regexp%s): "
9043 (if current-prefix-arg "backward" "forward")
9044 (if gnus-last-search-regexp
9045 (concat ", default " gnus-last-search-regexp)
9046 "")))
9047 current-prefix-arg))
eec82323
LMI
9048 (if (string-equal regexp "")
9049 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
9050 (setq gnus-last-search-regexp regexp)
9051 (setq gnus-article-before-search gnus-current-article))
9052 ;; Intentionally set gnus-last-article.
9053 (setq gnus-last-article gnus-article-before-search)
9054 (let ((gnus-last-article gnus-last-article))
9055 (if (gnus-summary-search-article regexp backward)
9056 (gnus-summary-show-thread)
abc40aab 9057 (signal 'search-failed (list regexp)))))
eec82323
LMI
9058
9059(defun gnus-summary-search-article-backward (regexp)
9060 "Search for an article containing REGEXP backward."
9061 (interactive
9062 (list (read-string
9063 (format "Search article backward (regexp%s): "
9064 (if gnus-last-search-regexp
9065 (concat ", default " gnus-last-search-regexp)
9066 "")))))
9067 (gnus-summary-search-article-forward regexp 'backward))
9068
9069(defun gnus-summary-search-article (regexp &optional backward)
9070 "Search for an article containing REGEXP.
9071Optional argument BACKWARD means do search for backward.
9072`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
9073 ;; We have to require this here to make sure that the following
9074 ;; dynamic binding isn't shadowed by autoloading.
9075 (require 'gnus-async)
16409b0b 9076 (require 'gnus-art)
eec82323 9077 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 9078 (gnus-article-prepare-hook nil)
eec82323
LMI
9079 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9080 (gnus-use-article-prefetch nil)
9081 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 9082 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
9083 (gnus-visual nil)
9084 (gnus-keep-backlog nil)
9085 (gnus-break-pages nil)
9086 (gnus-summary-display-arrow nil)
9087 (gnus-updated-mode-lines nil)
9088 (gnus-auto-center-summary nil)
eec82323 9089 (sum (current-buffer))
16409b0b 9090 (gnus-display-mime-function nil)
eec82323
LMI
9091 (found nil)
9092 point)
9093 (gnus-save-hidden-threads
9094 (gnus-summary-select-article)
9095 (set-buffer gnus-article-buffer)
16409b0b 9096 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
9097 (when backward
9098 (forward-line -1))
9099 (while (not found)
9100 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9101 (if (if backward
9102 (re-search-backward regexp nil t)
9103 (re-search-forward regexp nil t))
9104 ;; We found the regexp.
9105 (progn
9106 (setq found 'found)
9107 (beginning-of-line)
9108 (set-window-start
9109 (get-buffer-window (current-buffer))
9110 (point))
9111 (forward-line 1)
16409b0b
GM
9112 (set-window-point
9113 (get-buffer-window (current-buffer))
9114 (point))
eec82323
LMI
9115 (set-buffer sum)
9116 (setq point (point)))
9117 ;; We didn't find it, so we go to the next article.
9118 (set-buffer sum)
9119 (setq found 'not)
9120 (while (eq found 'not)
9121 (if (not (if backward (gnus-summary-find-prev)
9122 (gnus-summary-find-next)))
9123 ;; No more articles.
9124 (setq found t)
9125 ;; Select the next article and adjust point.
9126 (unless (gnus-summary-article-sparse-p
9127 (gnus-summary-article-number))
9128 (setq found nil)
9129 (gnus-summary-select-article)
9130 (set-buffer gnus-article-buffer)
9131 (widen)
9132 (goto-char (if backward (point-max) (point-min))))))))
9133 (gnus-message 7 ""))
9134 ;; Return whether we found the regexp.
9135 (when (eq found 'found)
9136 (goto-char point)
9137 (gnus-summary-show-thread)
9138 (gnus-summary-goto-subject gnus-current-article)
9139 (gnus-summary-position-point)
9140 t)))
9141
23f87bed
MB
9142(defun gnus-find-matching-articles (header regexp)
9143 "Return a list of all articles that match REGEXP on HEADER.
9144This search includes all articles in the current group that Gnus has
9145fetched headers for, whether they are displayed or not."
9146 (let ((articles nil)
c7a91ce1 9147 ;; Can't eta-reduce because it's a macro.
23f87bed
MB
9148 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9149 (case-fold-search t))
9150 (dolist (header gnus-newsgroup-headers)
9151 (when (string-match regexp (funcall func header))
9152 (push (mail-header-number header) articles)))
9153 (nreverse articles)))
9154
eec82323 9155(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 9156 not-case-fold not-matching)
eec82323
LMI
9157 "Return a list of all articles that match REGEXP on HEADER.
9158The search stars on the current article and goes forwards unless
9159BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9160If UNREAD is non-nil, only unread articles will
9161be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 9162in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
9163not match REGEXP on HEADER."
9164 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
9165 articles d func)
9166 (if (consp header)
9167 (if (eq (car header) 'extra)
9168 (setq func
9169 `(lambda (h)
9170 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9171 "")))
9172 (error "%s is an invalid header" header))
9173 (unless (fboundp (intern (concat "mail-header-" header)))
9174 (error "%s is not a valid header" header))
9175 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
9176 (dolist (d (if (eq backward 'all)
9177 gnus-newsgroup-data
9178 (gnus-data-find-list
9179 (gnus-summary-article-number)
9180 (gnus-data-list backward))))
9181 (when (and (or (not unread) ; We want all articles...
9182 (gnus-data-unread-p d)) ; Or just unreads.
9183 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9184 (if not-matching
a1506d29 9185 (not (string-match
47b63dfa
SZ
9186 regexp
9187 (funcall func (gnus-data-header d))))
9188 (string-match regexp
9189 (funcall func (gnus-data-header d)))))
9190 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
9191 (nreverse articles)))
9192
9193(defun gnus-summary-execute-command (header regexp command &optional backward)
9194 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9195If HEADER is an empty string (or nil), the match is done on the entire
9196article. If BACKWARD (the prefix) is non-nil, search backward instead."
9197 (interactive
9198 (list (let ((completion-ignore-case t))
9199 (completing-read
9200 "Header name: "
23f87bed
MB
9201 (mapcar (lambda (header) (list (format "%s" header)))
9202 (append
9203 '("Number" "Subject" "From" "Lines" "Date"
9204 "Message-ID" "Xref" "References" "Body")
9205 gnus-extra-headers))
eec82323
LMI
9206 nil 'require-match))
9207 (read-string "Regexp: ")
9208 (read-key-sequence "Command: ")
9209 current-prefix-arg))
9210 (when (equal header "Body")
9211 (setq header ""))
eec82323
LMI
9212 ;; Hidden thread subtrees must be searched as well.
9213 (gnus-summary-show-all-threads)
9214 ;; We don't want to change current point nor window configuration.
9215 (save-excursion
9216 (save-window-excursion
23f87bed
MB
9217 (let (gnus-visual
9218 gnus-treat-strip-trailing-blank-lines
9219 gnus-treat-strip-leading-blank-lines
9220 gnus-treat-strip-multiple-blank-lines
9221 gnus-treat-hide-boring-headers
9222 gnus-treat-fold-newsgroups
9223 gnus-article-prepare-hook)
9224 (gnus-message 6 "Executing %s..." (key-description command))
9225 ;; We'd like to execute COMMAND interactively so as to give arguments.
9226 (gnus-execute header regexp
9227 `(call-interactively ',(key-binding command))
9228 backward)
9229 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
9230
9231(defun gnus-summary-beginning-of-article ()
9232 "Scroll the article back to the beginning."
9233 (interactive)
eec82323
LMI
9234 (gnus-summary-select-article)
9235 (gnus-configure-windows 'article)
9236 (gnus-eval-in-buffer-window gnus-article-buffer
9237 (widen)
9238 (goto-char (point-min))
23f87bed 9239 (when gnus-break-pages
eec82323
LMI
9240 (gnus-narrow-to-page))))
9241
9242(defun gnus-summary-end-of-article ()
9243 "Scroll to the end of the article."
9244 (interactive)
eec82323
LMI
9245 (gnus-summary-select-article)
9246 (gnus-configure-windows 'article)
9247 (gnus-eval-in-buffer-window gnus-article-buffer
9248 (widen)
9249 (goto-char (point-max))
9250 (recenter -3)
23f87bed 9251 (when gnus-break-pages
eec82323
LMI
9252 (gnus-narrow-to-page))))
9253
23f87bed
MB
9254(defun gnus-summary-print-truncate-and-quote (string &optional len)
9255 "Truncate to LEN and quote all \"(\"'s in STRING."
9256 (gnus-replace-in-string (if (and len (> (length string) len))
9257 (substring string 0 len)
9258 string)
9259 "[()]" "\\\\\\&"))
9260
6748645f 9261(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
9262 "Generate and print a PostScript image of the process-marked (mail) articles.
9263
9264If used interactively, print the current article if none are
9265process-marked. With prefix arg, prompt the user for the name of the
9266file to save in.
6748645f 9267
23f87bed
MB
9268When used from Lisp, accept two optional args FILENAME and N. N means
9269to print the next N articles. If N is negative, print the N previous
9270articles. If N is nil and articles have been marked with the process
9271mark, print these instead.
eec82323 9272
16409b0b 9273If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
9274printer. If FILENAME is a string, save the PostScript image in a file with
9275that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 9276to save in."
676a7cc9 9277 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
9278 (dolist (article (gnus-summary-work-articles n))
9279 (gnus-summary-select-article nil nil 'pseudo article)
9280 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 9281 (gnus-print-buffer))
676a7cc9
SZ
9282 (gnus-summary-remove-process-mark article))
9283 (ps-despool filename))
eec82323 9284
23f87bed
MB
9285(defun gnus-print-buffer ()
9286 (let ((buffer (generate-new-buffer " *print*")))
9287 (unwind-protect
9288 (progn
9289 (copy-to-buffer buffer (point-min) (point-max))
9290 (set-buffer buffer)
9291 (gnus-remove-text-with-property 'gnus-decoration)
9292 (when (gnus-visual-p 'article-highlight 'highlight)
9293 ;; Copy-to-buffer doesn't copy overlay. So redo
9294 ;; highlight.
9295 (let ((gnus-article-buffer buffer))
9296 (gnus-article-highlight-citation t)
9297 (gnus-article-highlight-signature)
9298 (gnus-article-emphasize)
9299 (gnus-article-delete-invisible-text)))
9300 (let ((ps-left-header
9301 (list
9302 (concat "("
9303 (gnus-summary-print-truncate-and-quote
9304 (mail-header-subject gnus-current-headers)
9305 66) ")")
9306 (concat "("
9307 (gnus-summary-print-truncate-and-quote
9308 (mail-header-from gnus-current-headers)
9309 45) ")")))
9310 (ps-right-header
9311 (list
9312 "/pagenumberstring load"
9313 (concat "("
9314 (mail-header-date gnus-current-headers) ")"))))
9315 (gnus-run-hooks 'gnus-ps-print-hook)
9316 (save-excursion
a7b50e1c 9317 (if ps-print-color-p
23f87bed
MB
9318 (ps-spool-buffer-with-faces)
9319 (ps-spool-buffer)))))
9320 (kill-buffer buffer))))
9321
eec82323 9322(defun gnus-summary-show-article (&optional arg)
23f87bed 9323 "Force redisplaying of the current article.
16409b0b
GM
9324If ARG (the prefix) is a number, show the article with the charset
9325defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 9326input.
16409b0b 9327If ARG (the prefix) is non-nil and not a number, show the raw article
23f87bed
MB
9328without any article massaging functions being run. Normally, the key
9329strokes are `C-u g'."
eec82323 9330 (interactive "P")
16409b0b
GM
9331 (cond
9332 ((numberp arg)
23f87bed 9333 (gnus-summary-show-article t)
16409b0b
GM
9334 (let ((gnus-newsgroup-charset
9335 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
9336 (mm-read-coding-system
9337 "View as charset: " ;; actually it is coding system.
01c52d31 9338 (with-current-buffer gnus-article-buffer
23f87bed 9339 (mm-detect-coding-region (point) (point-max))))))
16409b0b 9340 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
9341 (gnus-summary-select-article nil 'force)
9342 (let ((deps gnus-newsgroup-dependencies)
9343 head header lines)
c7a91ce1 9344 (with-current-buffer gnus-original-article-buffer
23f87bed
MB
9345 (save-restriction
9346 (message-narrow-to-head)
9347 (setq head (buffer-string))
9348 (goto-char (point-min))
9349 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9350 (goto-char (point-max))
9351 (widen)
9352 (setq lines (1- (count-lines (point) (point-max))))))
9353 (with-temp-buffer
9354 (insert (format "211 %d Article retrieved.\n"
9355 (cdr gnus-article-current)))
9356 (insert head)
9357 (if lines (insert (format "Lines: %d\n" lines)))
9358 (insert ".\n")
9359 (let ((nntp-server-buffer (current-buffer)))
9360 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9361 (gnus-data-set-header
9362 (gnus-data-find (cdr gnus-article-current))
9363 header)
9364 (gnus-summary-update-article-line
9365 (cdr gnus-article-current) header)
9366 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9367 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
9368 ((not arg)
9369 ;; Select the article the normal way.
9370 (gnus-summary-select-article nil 'force))
9371 (t
9372 ;; We have to require this here to make sure that the following
9373 ;; dynamic binding isn't shadowed by autoloading.
9374 (require 'gnus-async)
9375 (require 'gnus-art)
eec82323
LMI
9376 ;; Bind the article treatment functions to nil.
9377 (let ((gnus-have-all-headers t)
eec82323 9378 gnus-article-prepare-hook
16409b0b
GM
9379 gnus-article-decode-hook
9380 gnus-display-mime-function
9381 gnus-break-pages)
9382 ;; Destroy any MIME parts.
9383 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 9384 (with-current-buffer gnus-article-buffer
16409b0b
GM
9385 (mm-destroy-parts gnus-article-mime-handles)
9386 ;; Set it to nil for safety reason.
9387 (setq gnus-article-mime-handle-alist nil)
9388 (setq gnus-article-mime-handles nil)))
9389 (gnus-summary-select-article nil 'force))))
eec82323
LMI
9390 (gnus-summary-goto-subject gnus-current-article)
9391 (gnus-summary-position-point))
9392
23f87bed
MB
9393(defun gnus-summary-show-raw-article ()
9394 "Show the raw article without any article massaging functions being run."
9395 (interactive)
9396 (gnus-summary-show-article t))
9397
eec82323
LMI
9398(defun gnus-summary-verbose-headers (&optional arg)
9399 "Toggle permanent full header display.
9400If ARG is a positive number, turn header display on.
9401If ARG is a negative number, turn header display off."
9402 (interactive "P")
eec82323
LMI
9403 (setq gnus-show-all-headers
9404 (cond ((or (not (numberp arg))
9405 (zerop arg))
9406 (not gnus-show-all-headers))
9407 ((natnump arg)
9408 t)))
9409 (gnus-summary-show-article))
9410
9411(defun gnus-summary-toggle-header (&optional arg)
9412 "Show the headers if they are hidden, or hide them if they are shown.
9413If ARG is a positive number, show the entire header.
9414If ARG is a negative number, hide the unwanted header lines."
9415 (interactive "P")
23f87bed
MB
9416 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9417 (get-buffer-window gnus-article-buffer t))))
9418 (with-current-buffer gnus-article-buffer
9419 (widen)
9420 (article-narrow-to-head)
c7a91ce1 9421 (let* ((inhibit-read-only t)
16409b0b 9422 (inhibit-point-motion-hooks t)
23f87bed
MB
9423 (hidden (if (numberp arg)
9424 (>= arg 0)
f0096211
MB
9425 (or (not (looking-at "[^ \t\n]+:"))
9426 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
9427 s e)
9428 (delete-region (point-min) (point-max))
667e0ba6
SM
9429 (with-current-buffer gnus-original-article-buffer
9430 (goto-char (setq s (point-min)))
23f87bed
MB
9431 (setq e (if (search-forward "\n\n" nil t)
9432 (1- (point))
9433 (point-max))))
667e0ba6 9434 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
9435 (run-hooks 'gnus-article-decode-hook)
9436 (if hidden
9437 (let ((gnus-treat-hide-headers nil)
9438 (gnus-treat-hide-boring-headers nil))
9439 (gnus-delete-wash-type 'headers)
9440 (gnus-treat-article 'head))
9441 (gnus-treat-article 'head))
9442 (widen)
9443 (if window
9444 (set-window-start window (goto-char (point-min))))
9445 (if gnus-break-pages
9446 (gnus-narrow-to-page)
9447 (when (gnus-visual-p 'page-marker)
c7a91ce1 9448 (let ((inhibit-read-only t))
23f87bed
MB
9449 (gnus-remove-text-with-property 'gnus-prev)
9450 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9451 (gnus-set-mode-line 'article)))))
eec82323
LMI
9452
9453(defun gnus-summary-show-all-headers ()
9454 "Make all header lines visible."
9455 (interactive)
23f87bed 9456 (gnus-summary-toggle-header 1))
eec82323 9457
eec82323
LMI
9458(defun gnus-summary-caesar-message (&optional arg)
9459 "Caesar rotate the current article by 13.
01c52d31
MB
9460With a non-numerical prefix, also rotate headers. A numerical
9461prefix specifies how many places to rotate each letter forward."
eec82323 9462 (interactive "P")
eec82323
LMI
9463 (gnus-summary-select-article)
9464 (let ((mail-header-separator ""))
9465 (gnus-eval-in-buffer-window gnus-article-buffer
9466 (save-restriction
9467 (widen)
9468 (let ((start (window-start))
c7a91ce1 9469 (inhibit-read-only t))
01c52d31
MB
9470 (if (equal arg '(4))
9471 (message-caesar-buffer-body nil t)
9472 (message-caesar-buffer-body arg))
ff4d3926
MB
9473 (set-window-start (get-buffer-window (current-buffer)) start)))))
9474 ;; Create buttons and stuff...
9475 (gnus-treat-article nil))
eec82323 9476
704f1663
GM
9477(declare-function idna-to-unicode "ext:idna" (str))
9478
01c52d31
MB
9479(defun gnus-summary-idna-message (&optional arg)
9480 "Decode IDNA encoded domain names in the current articles.
9481IDNA encoded domain names looks like `xn--bar'. If a string
9482remain unencoded after running this function, it is likely an
9483invalid IDNA string (`xn--bar' is invalid).
9484
9485You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
9486installed for this command to work."
9487 (interactive "P")
9488 (if (not (and (condition-case nil (require 'idna)
9489 (file-error))
9490 (mm-coding-system-p 'utf-8)
9491 (executable-find (symbol-value 'idna-program))))
9492 (gnus-message
9493 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9494 (gnus-summary-select-article)
9495 (let ((mail-header-separator ""))
9496 (gnus-eval-in-buffer-window gnus-article-buffer
9497 (save-restriction
9498 (widen)
9499 (let ((start (window-start))
9500 buffer-read-only)
9501 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9502 (replace-match (idna-to-unicode (match-string 1))))
9503 (set-window-start (get-buffer-window (current-buffer)) start)))))))
23f87bed
MB
9504
9505(defun gnus-summary-morse-message (&optional arg)
9506 "Morse decode the current article."
9507 (interactive "P")
9508 (gnus-summary-select-article)
9509 (let ((mail-header-separator ""))
9510 (gnus-eval-in-buffer-window gnus-article-buffer
9511 (save-excursion
9512 (save-restriction
9513 (widen)
9514 (let ((pos (window-start))
c7a91ce1 9515 (inhibit-read-only t))
23f87bed
MB
9516 (goto-char (point-min))
9517 (when (message-goto-body)
9518 (gnus-narrow-to-body))
9519 (goto-char (point-min))
01c52d31 9520