gnus-html-curl-sentinel: Replace process-get with gnus-process-get.
[bpt/emacs.git] / lisp / gnus / gnus-sum.el
CommitLineData
eec82323 1;;; gnus-sum.el --- summary mode commands for Gnus
e84b4b86
TTN
2
3;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
114f9c96 4;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
eec82323 5
6748645f 6;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
eec82323
LMI
7;; Keywords: news
8
9;; This file is part of GNU Emacs.
10
5e809f55 11;; GNU Emacs is free software: you can redistribute it and/or modify
eec82323 12;; it under the terms of the GNU General Public License as published by
5e809f55
GM
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
eec82323
LMI
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
01ccbb85 18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eec82323
LMI
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
5e809f55 22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
eec82323
LMI
23
24;;; Commentary:
25
26;;; Code:
27
d09ae6ca
GM
28;; For Emacs < 22.2.
29(eval-and-compile
30 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
23f87bed 31(eval-when-compile
9efa445f 32 (require 'cl))
d029b5d2
KY
33(eval-when-compile
34 (when (featurep 'xemacs)
35 (require 'easy-mmode))) ; for `define-minor-mode'
9efa445f
DN
36
37(defvar tool-bar-mode)
38(defvar gnus-tmp-header)
5ab7173c 39
eec82323
LMI
40(require 'gnus)
41(require 'gnus-group)
42(require 'gnus-spec)
43(require 'gnus-range)
44(require 'gnus-int)
45(require 'gnus-undo)
6748645f 46(require 'gnus-util)
18c06a99 47(require 'gmm-utils)
16409b0b 48(require 'mm-decode)
08c9a385 49(require 'nnoo)
23f87bed 50
6748645f 51(autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
d4dfaa19 52(autoload 'gnus-cache-write-active "gnus-cache")
23f87bed
MB
53(autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
54(autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
531e5812 55(autoload 'gnus-pick-line-number "gnus-salt" nil t)
08c9a385 56(autoload 'mm-uu-dissect "mm-uu")
23f87bed
MB
57(autoload 'gnus-article-outlook-deuglify-article "deuglify"
58 "Deuglify broken Outlook (Express) articles and redisplay."
59 t)
60(autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
61(autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
62(autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
eec82323
LMI
63
64(defcustom gnus-kill-summary-on-exit t
65 "*If non-nil, kill the summary buffer when you exit from it.
66If nil, the summary will become a \"*Dead Summary*\" buffer, and
67it will be killed sometime later."
68 :group 'gnus-summary-exit
69 :type 'boolean)
70
01c52d31
MB
71(defcustom gnus-summary-next-group-on-exit t
72 "If non-nil, go to the next unread newsgroup on summary exit.
73See `gnus-group-goto-unread'."
74 :link '(custom-manual "(gnus)Group Maneuvering")
75 :group 'gnus-summary-exit
330f707b 76 :version "23.1" ;; No Gnus
01c52d31
MB
77 :type 'boolean)
78
b1992461
KY
79(defcustom gnus-summary-stop-at-end-of-message nil
80 "If non-nil, don't select the next message when using `SPC'."
81 :link '(custom-manual "(gnus)Group Maneuvering")
82 :group 'gnus-summary-maneuvering
1a10d421 83 :version "24.1"
b1992461
KY
84 :type 'boolean)
85
eec82323
LMI
86(defcustom gnus-fetch-old-headers nil
87 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
01c52d31
MB
88If an unread article in the group refers to an older, already
89read (or just marked as read) article, the old article will not
90normally be displayed in the Summary buffer. If this variable is
91t, Gnus will attempt to grab the headers to the old articles, and
92thereby build complete threads. If it has the value `some', all
93old headers will be fetched but only enough headers to connect
94otherwise loose threads will be displayed. This variable can
95also be a number. In that case, no more than that number of old
96headers will be fetched. If it has the value `invisible', all
6748645f 97old headers will be fetched, but none will be displayed.
eec82323 98
01c52d31
MB
99The server has to support NOV for any of this to work.
100
101This feature can seriously impact performance it ignores all
f394fa25
MB
102locally cached header entries. Setting it to t for groups for a
103server that doesn't expire articles (such as news.gmane.org),
104leads to very slow summary generation."
eec82323
LMI
105 :group 'gnus-thread
106 :type '(choice (const :tag "off" nil)
1232b9cb 107 (const :tag "on" t)
eec82323 108 (const some)
1232b9cb 109 (const invisible)
eec82323
LMI
110 number
111 (sexp :menu-tag "other" t)))
112
01c52d31 113(defcustom gnus-refer-thread-limit 500
6748645f
LMI
114 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
115If t, fetch all the available old headers."
116 :group 'gnus-thread
117 :type '(choice number
118 (sexp :menu-tag "other" t)))
119
eec82323
LMI
120(defcustom gnus-summary-make-false-root 'adopt
121 "*nil means that Gnus won't gather loose threads.
122If the root of a thread has expired or been read in a previous
123session, the information necessary to build a complete thread has been
124lost. Instead of having many small sub-threads from this original thread
125scattered all over the summary buffer, Gnus can gather them.
126
127If non-nil, Gnus will try to gather all loose sub-threads from an
128original thread into one large thread.
129
130If this variable is non-nil, it should be one of `none', `adopt',
131`dummy' or `empty'.
132
133If this variable is `none', Gnus will not make a false root, but just
134present the sub-threads after another.
135If this variable is `dummy', Gnus will create a dummy root that will
136have all the sub-threads as children.
137If this variable is `adopt', Gnus will make one of the \"children\"
138the parent and mark all the step-children as such.
139If this variable is `empty', the \"children\" are printed with empty
01ccbb85 140subject fields. (Or rather, they will be printed with a string
eec82323
LMI
141given by the `gnus-summary-same-subject' variable.)"
142 :group 'gnus-thread
143 :type '(choice (const :tag "off" nil)
144 (const none)
145 (const dummy)
146 (const adopt)
147 (const empty)))
148
23f87bed
MB
149(defcustom gnus-summary-make-false-root-always nil
150 "Always make a false dummy root."
bf247b6e 151 :version "22.1"
23f87bed
MB
152 :group 'gnus-thread
153 :type 'boolean)
154
eec82323
LMI
155(defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
156 "*A regexp to match subjects to be excluded from loose thread gathering.
157As loose thread gathering is done on subjects only, that means that
158there can be many false gatherings performed. By rooting out certain
159common subjects, gathering might become saner."
160 :group 'gnus-thread
161 :type 'regexp)
162
163(defcustom gnus-summary-gather-subject-limit nil
164 "*Maximum length of subject comparisons when gathering loose threads.
165Use nil to compare full subjects. Setting this variable to a low
166number will help gather threads that have been corrupted by
167newsreaders chopping off subject lines, but it might also mean that
168unrelated articles that have subject that happen to begin with the
169same few characters will be incorrectly gathered.
170
171If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
172comparing subjects."
173 :group 'gnus-thread
174 :type '(choice (const :tag "off" nil)
175 (const fuzzy)
176 (sexp :menu-tag "on" t)))
177
6748645f
LMI
178(defcustom gnus-simplify-subject-functions nil
179 "List of functions taking a string argument that simplify subjects.
180The functions are applied recursively.
181
23f87bed
MB
182Useful functions to put in this list include:
183`gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
184`gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
6748645f
LMI
185 :group 'gnus-thread
186 :type '(repeat function))
187
eec82323 188(defcustom gnus-simplify-ignored-prefixes nil
23f87bed 189 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
eec82323
LMI
190 :group 'gnus-thread
191 :type '(choice (const :tag "off" nil)
192 regexp))
193
194(defcustom gnus-build-sparse-threads nil
195 "*If non-nil, fill in the gaps in threads.
196If `some', only fill in the gaps that are needed to tie loose threads
197together. If `more', fill in all leaf nodes that Gnus can find. If
198non-nil and non-`some', fill in all gaps that Gnus manages to guess."
199 :group 'gnus-thread
200 :type '(choice (const :tag "off" nil)
201 (const some)
202 (const more)
203 (sexp :menu-tag "all" t)))
204
205(defcustom gnus-summary-thread-gathering-function
206 'gnus-gather-threads-by-subject
6748645f 207 "*Function used for gathering loose threads.
eec82323
LMI
208There are two pre-defined functions: `gnus-gather-threads-by-subject',
209which only takes Subjects into consideration; and
210`gnus-gather-threads-by-references', which compared the References
211headers of the articles to find matches."
212 :group 'gnus-thread
22115a9e
RS
213 :type '(radio (function-item gnus-gather-threads-by-subject)
214 (function-item gnus-gather-threads-by-references)
215 (function :tag "other")))
eec82323 216
eec82323
LMI
217(defcustom gnus-summary-same-subject ""
218 "*String indicating that the current article has the same subject as the previous.
219This variable will only be used if the value of
220`gnus-summary-make-false-root' is `empty'."
221 :group 'gnus-summary-format
222 :type 'string)
223
224(defcustom gnus-summary-goto-unread t
16409b0b
GM
225 "*If t, many commands will go to the next unread article.
226This applies to marking commands as well as other commands that
227\"naturally\" select the next article, like, for instance, `SPC' at
228the end of an article.
229
230If nil, the marking commands do NOT go to the next unread article
2642ac8f 231\(they go to the next article instead). If `never', commands that
16409b0b
GM
232usually go to the next unread article, will go to the next article,
233whether it is read or not."
eec82323
LMI
234 :group 'gnus-summary-marks
235 :link '(custom-manual "(gnus)Setting Marks")
236 :type '(choice (const :tag "off" nil)
237 (const never)
238 (sexp :menu-tag "on" t)))
239
240(defcustom gnus-summary-default-score 0
241 "*Default article score level.
242All scores generated by the score files will be added to this score.
243If this variable is nil, scoring will be disabled."
244 :group 'gnus-score-default
245 :type '(choice (const :tag "disable")
246 integer))
247
23f87bed
MB
248(defcustom gnus-summary-default-high-score 0
249 "*Default threshold for a high scored article.
250An article will be highlighted as high scored if its score is greater
251than this score."
bf247b6e 252 :version "22.1"
23f87bed
MB
253 :group 'gnus-score-default
254 :type 'integer)
255
256(defcustom gnus-summary-default-low-score 0
257 "*Default threshold for a low scored article.
258An article will be highlighted as low scored if its score is smaller
259than this score."
bf247b6e 260 :version "22.1"
23f87bed
MB
261 :group 'gnus-score-default
262 :type 'integer)
263
eec82323
LMI
264(defcustom gnus-summary-zcore-fuzz 0
265 "*Fuzziness factor for the zcore in the summary buffer.
266Articles with scores closer than this to `gnus-summary-default-score'
267will not be marked."
268 :group 'gnus-summary-format
269 :type 'integer)
270
271(defcustom gnus-simplify-subject-fuzzy-regexp nil
272 "*Strings to be removed when doing fuzzy matches.
273This can either be a regular expression or list of regular expressions
274that will be removed from subject strings if fuzzy subject
275simplification is selected."
276 :group 'gnus-thread
277 :type '(repeat regexp))
278
279(defcustom gnus-show-threads t
280 "*If non-nil, display threads in summary mode."
281 :group 'gnus-thread
282 :type 'boolean)
283
284(defcustom gnus-thread-hide-subtree nil
285 "*If non-nil, hide all threads initially.
23f87bed 286This can be a predicate specifier which says which threads to hide.
eec82323 287If threads are hidden, you have to run the command
4a2358e9 288`gnus-summary-show-thread' by hand or select an article."
eec82323 289 :group 'gnus-thread
23f87bed
MB
290 :type '(radio (sexp :format "Non-nil\n"
291 :match (lambda (widget value)
292 (not (or (consp value) (functionp value))))
293 :value t)
294 (const nil)
ad136a7c 295 (sexp :tag "Predicate specifier")))
eec82323
LMI
296
297(defcustom gnus-thread-hide-killed t
298 "*If non-nil, hide killed threads automatically."
299 :group 'gnus-thread
300 :type 'boolean)
301
6748645f
LMI
302(defcustom gnus-thread-ignore-subject t
303 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
304If nil, articles that have different subjects from their parents will
305start separate threads."
eec82323
LMI
306 :group 'gnus-thread
307 :type 'boolean)
308
309(defcustom gnus-thread-operation-ignore-subject t
310 "*If non-nil, subjects will be ignored when doing thread commands.
311This affects commands like `gnus-summary-kill-thread' and
312`gnus-summary-lower-thread'.
313
314If this variable is nil, articles in the same thread with different
315subjects will not be included in the operation in question. If this
316variable is `fuzzy', only articles that have subjects that are fuzzily
317equal will be included."
318 :group 'gnus-thread
319 :type '(choice (const :tag "off" nil)
320 (const fuzzy)
321 (sexp :tag "on" t)))
322
323(defcustom gnus-thread-indent-level 4
324 "*Number that says how much each sub-thread should be indented."
325 :group 'gnus-thread
326 :type 'integer)
327
328(defcustom gnus-auto-extend-newsgroup t
329 "*If non-nil, extend newsgroup forward and backward when requested."
330 :group 'gnus-summary-choose
331 :type 'boolean)
332
333(defcustom gnus-auto-select-first t
651408cb
MB
334 "If non-nil, select an article on group entry.
335An article is selected automatically when entering a group
336e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
337`gnus-summary-catchup-and-goto-next-group'.
338
339Which article is selected is controlled by the variable
340`gnus-auto-select-subject'.
23f87bed
MB
341
342If you want to prevent automatic selection of articles in some
343newsgroups, set the variable to nil in `gnus-select-group-hook'."
651408cb
MB
344 ;; Commands include...
345 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
346 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
347 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
eec82323
LMI
348 :group 'gnus-group-select
349 :type '(choice (const :tag "none" nil)
23f87bed
MB
350 (sexp :menu-tag "first" t)))
351
352(defcustom gnus-auto-select-subject 'unread
353 "*Says what subject to place under point when entering a group.
354
355This variable can either be the symbols `first' (place point on the
356first subject), `unread' (place point on the subject line of the first
357unread article), `best' (place point on the subject line of the
358higest-scored article), `unseen' (place point on the subject line of
99b5aab7 359the first unseen article), `unseen-or-unread' (place point on the subject
23f87bed
MB
360line of the first unseen article or, if all article have been seen, on the
361subject line of the first unread article), or a function to be called to
362place point on some subject line."
bf247b6e 363 :version "22.1"
23f87bed
MB
364 :group 'gnus-group-select
365 :type '(choice (const best)
366 (const unread)
367 (const first)
368 (const unseen)
369 (const unseen-or-unread)))
eec82323
LMI
370
371(defcustom gnus-auto-select-next t
372 "*If non-nil, offer to go to the next group from the end of the previous.
373If the value is t and the next newsgroup is empty, Gnus will exit
23f87bed
MB
374summary mode and go back to group mode. If the value is neither nil
375nor t, Gnus will select the following unread newsgroup. In
eec82323
LMI
376particular, if the value is the symbol `quietly', the next unread
377newsgroup will be selected without any confirmation, and if it is
378`almost-quietly', the next group will be selected without any
379confirmation if you are located on the last article in the group.
23f87bed 380Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
eec82323
LMI
381will go to the next group without confirmation."
382 :group 'gnus-summary-maneuvering
383 :type '(choice (const :tag "off" nil)
384 (const quietly)
385 (const almost-quietly)
386 (const slightly-quietly)
387 (sexp :menu-tag "on" t)))
388
389(defcustom gnus-auto-select-same nil
6748645f
LMI
390 "*If non-nil, select the next article with the same subject.
391If there are no more articles with the same subject, go to
392the first unread article."
eec82323
LMI
393 :group 'gnus-summary-maneuvering
394 :type 'boolean)
395
01c52d31
MB
396(defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
397 "What article should be selected after exiting an ephemeral group.
398Valid values include:
399
400`next'
401 Select the next article.
402`next-unread'
403 Select the next unread article.
404`next-noselect'
405 Move the cursor to the next article. This is the default.
406`next-unread-noselect'
407 Move the cursor to the next unread article.
408
409If it has any other value or there is no next (unread) article, the
410article selected before entering to the ephemeral group will appear."
330f707b 411 :version "23.1" ;; No Gnus
01c52d31
MB
412 :group 'gnus-summary-maneuvering
413 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
414 (const next) (const next-unread)
415 (const next-noselect) (const next-unread-noselect)
416 (sexp :tag "other" :value nil)))
417
23f87bed
MB
418(defcustom gnus-auto-goto-ignores 'unfetched
419 "*Says how to handle unfetched articles when maneuvering.
420
421This variable can either be the symbols nil (maneuver to any
422article), `undownloaded' (maneuvering while unplugged ignores articles
423that have not been fetched), `always-undownloaded' (maneuvering always
424ignores articles that have not been fetched), `unfetched' (maneuvering
425ignores articles whose headers have not been fetched).
426
427NOTE: The list of unfetched articles will always be nil when plugged
428and, when unplugged, a subset of the undownloaded article list."
bf247b6e 429 :version "22.1"
23f87bed
MB
430 :group 'gnus-summary-maneuvering
431 :type '(choice (const :tag "None" nil)
432 (const :tag "Undownloaded when unplugged" undownloaded)
433 (const :tag "Undownloaded" always-undownloaded)
434 (const :tag "Unfetched" unfetched)))
435
eec82323
LMI
436(defcustom gnus-summary-check-current nil
437 "*If non-nil, consider the current article when moving.
438The \"unread\" movement commands will stay on the same line if the
439current article is unread."
440 :group 'gnus-summary-maneuvering
441 :type 'boolean)
442
01c52d31 443(defcustom gnus-auto-center-summary 2
eec82323
LMI
444 "*If non-nil, always center the current summary buffer.
445In particular, if `vertical' do only vertical recentering. If non-nil
446and non-`vertical', do both horizontal and vertical recentering."
447 :group 'gnus-summary-maneuvering
448 :type '(choice (const :tag "none" nil)
449 (const vertical)
16409b0b 450 (integer :tag "height")
eec82323
LMI
451 (sexp :menu-tag "both" t)))
452
23f87bed
MB
453(defvar gnus-auto-center-group t
454 "*If non-nil, always center the group buffer.")
455
eec82323
LMI
456(defcustom gnus-show-all-headers nil
457 "*If non-nil, don't hide any headers."
458 :group 'gnus-article-hiding
459 :group 'gnus-article-headers
460 :type 'boolean)
461
462(defcustom gnus-summary-ignore-duplicates nil
463 "*If non-nil, ignore articles with identical Message-ID headers."
464 :group 'gnus-summary
465 :type 'boolean)
6748645f 466
eec82323
LMI
467(defcustom gnus-single-article-buffer t
468 "*If non-nil, display all articles in the same buffer.
469If nil, each group will get its own article buffer."
470 :group 'gnus-article-various
471 :type 'boolean)
472
473(defcustom gnus-break-pages t
474 "*If non-nil, do page breaking on articles.
475The page delimiter is specified by the `gnus-page-delimiter'
476variable."
477 :group 'gnus-article-various
478 :type 'boolean)
479
eec82323
LMI
480(defcustom gnus-move-split-methods nil
481 "*Variable used to suggest where articles are to be moved to.
23f87bed
MB
482It uses the same syntax as the `gnus-split-methods' variable.
483However, whereas `gnus-split-methods' specifies file names as targets,
484this variable specifies group names."
eec82323 485 :group 'gnus-summary-mail
6748645f
LMI
486 :type '(repeat (choice (list :value (fun) function)
487 (cons :value ("" "") regexp (repeat string))
488 (sexp :value nil))))
eec82323 489
01c52d31
MB
490(defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
491 "Function used to compute default prefix for article move/copy/etc prompts.
492The function should take one argument, a group name, and return a
493string with the suggested prefix."
494 :group 'gnus-summary-mail
495 :type 'function)
496
e62e7654
MB
497;; FIXME: Although the custom type is `character' for the following variables,
498;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
499
23f87bed 500(defcustom gnus-unread-mark ? ;Whitespace
eec82323
LMI
501 "*Mark used for unread articles."
502 :group 'gnus-summary-marks
503 :type 'character)
504
505(defcustom gnus-ticked-mark ?!
506 "*Mark used for ticked articles."
507 :group 'gnus-summary-marks
508 :type 'character)
509
510(defcustom gnus-dormant-mark ??
511 "*Mark used for dormant articles."
512 :group 'gnus-summary-marks
513 :type 'character)
514
515(defcustom gnus-del-mark ?r
516 "*Mark used for del'd articles."
517 :group 'gnus-summary-marks
518 :type 'character)
519
520(defcustom gnus-read-mark ?R
521 "*Mark used for read articles."
522 :group 'gnus-summary-marks
523 :type 'character)
524
525(defcustom gnus-expirable-mark ?E
526 "*Mark used for expirable articles."
527 :group 'gnus-summary-marks
528 :type 'character)
529
530(defcustom gnus-killed-mark ?K
531 "*Mark used for killed articles."
532 :group 'gnus-summary-marks
533 :type 'character)
534
23f87bed
MB
535(defcustom gnus-spam-mark ?$
536 "*Mark used for spam articles."
bf247b6e 537 :version "22.1"
23f87bed
MB
538 :group 'gnus-summary-marks
539 :type 'character)
540
eec82323
LMI
541(defcustom gnus-kill-file-mark ?X
542 "*Mark used for articles killed by kill files."
543 :group 'gnus-summary-marks
544 :type 'character)
545
546(defcustom gnus-low-score-mark ?Y
547 "*Mark used for articles with a low score."
548 :group 'gnus-summary-marks
549 :type 'character)
550
551(defcustom gnus-catchup-mark ?C
552 "*Mark used for articles that are caught up."
553 :group 'gnus-summary-marks
554 :type 'character)
555
556(defcustom gnus-replied-mark ?A
557 "*Mark used for articles that have been replied to."
558 :group 'gnus-summary-marks
559 :type 'character)
560
23f87bed
MB
561(defcustom gnus-forwarded-mark ?F
562 "*Mark used for articles that have been forwarded."
bf247b6e 563 :version "22.1"
23f87bed
MB
564 :group 'gnus-summary-marks
565 :type 'character)
566
567(defcustom gnus-recent-mark ?N
568 "*Mark used for articles that are recent."
bf247b6e 569 :version "22.1"
23f87bed
MB
570 :group 'gnus-summary-marks
571 :type 'character)
572
eec82323
LMI
573(defcustom gnus-cached-mark ?*
574 "*Mark used for articles that are in the cache."
575 :group 'gnus-summary-marks
576 :type 'character)
577
578(defcustom gnus-saved-mark ?S
23f87bed
MB
579 "*Mark used for articles that have been saved."
580 :group 'gnus-summary-marks
581 :type 'character)
582
583(defcustom gnus-unseen-mark ?.
584 "*Mark used for articles that haven't been seen."
bf247b6e 585 :version "22.1"
23f87bed
MB
586 :group 'gnus-summary-marks
587 :type 'character)
588
589(defcustom gnus-no-mark ? ;Whitespace
590 "*Mark used for articles that have no other secondary mark."
bf247b6e 591 :version "22.1"
eec82323
LMI
592 :group 'gnus-summary-marks
593 :type 'character)
594
595(defcustom gnus-ancient-mark ?O
596 "*Mark used for ancient articles."
597 :group 'gnus-summary-marks
598 :type 'character)
599
600(defcustom gnus-sparse-mark ?Q
601 "*Mark used for sparsely reffed articles."
602 :group 'gnus-summary-marks
603 :type 'character)
604
605(defcustom gnus-canceled-mark ?G
606 "*Mark used for canceled articles."
607 :group 'gnus-summary-marks
608 :type 'character)
609
610(defcustom gnus-duplicate-mark ?M
611 "*Mark used for duplicate articles."
612 :group 'gnus-summary-marks
613 :type 'character)
614
23f87bed 615(defcustom gnus-undownloaded-mark ?-
6748645f 616 "*Mark used for articles that weren't downloaded."
bf247b6e 617 :version "22.1"
6748645f
LMI
618 :group 'gnus-summary-marks
619 :type 'character)
620
23f87bed
MB
621(defcustom gnus-downloaded-mark ?+
622 "*Mark used for articles that were downloaded."
623 :group 'gnus-summary-marks
624 :type 'character)
625
6748645f
LMI
626(defcustom gnus-downloadable-mark ?%
627 "*Mark used for articles that are to be downloaded."
628 :group 'gnus-summary-marks
629 :type 'character)
630
631(defcustom gnus-unsendable-mark ?=
632 "*Mark used for articles that won't be sent."
633 :group 'gnus-summary-marks
634 :type 'character)
635
eec82323
LMI
636(defcustom gnus-score-over-mark ?+
637 "*Score mark used for articles with high scores."
638 :group 'gnus-summary-marks
639 :type 'character)
640
641(defcustom gnus-score-below-mark ?-
642 "*Score mark used for articles with low scores."
643 :group 'gnus-summary-marks
644 :type 'character)
645
23f87bed 646(defcustom gnus-empty-thread-mark ? ;Whitespace
eec82323
LMI
647 "*There is no thread under the article."
648 :group 'gnus-summary-marks
649 :type 'character)
650
651(defcustom gnus-not-empty-thread-mark ?=
652 "*There is a thread under the article."
653 :group 'gnus-summary-marks
654 :type 'character)
655
656(defcustom gnus-view-pseudo-asynchronously nil
657 "*If non-nil, Gnus will view pseudo-articles asynchronously."
658 :group 'gnus-extract-view
659 :type 'boolean)
660
16409b0b
GM
661(defcustom gnus-auto-expirable-marks
662 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
663 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
c4d82de8 664 gnus-duplicate-mark)
16409b0b 665 "*The list of marks converted into expiration if a group is auto-expirable."
58e39d05 666 :version "21.1"
16409b0b
GM
667 :group 'gnus-summary
668 :type '(repeat character))
669
670(defcustom gnus-inhibit-user-auto-expire t
671 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
58e39d05 672 :version "21.1"
16409b0b
GM
673 :group 'gnus-summary
674 :type 'boolean)
675
b0b63450
MB
676(defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
677 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
678If nil, the expirable marks will be unchanged except that the marks
679will be removed when copying or moving articles to a group that has
680not turned auto-expire on. If non-nil, articles that have been read
681will be marked as expirable when being copied or moved to a group in
682which auto-expire is turned on."
683 :version "23.2"
684 :type 'boolean
685 :group 'gnus-summary-marks)
686
eec82323
LMI
687(defcustom gnus-view-pseudos nil
688 "*If `automatic', pseudo-articles will be viewed automatically.
689If `not-confirm', pseudos will be viewed automatically, and the user
690will not be asked to confirm the command."
691 :group 'gnus-extract-view
692 :type '(choice (const :tag "off" nil)
693 (const automatic)
694 (const not-confirm)))
695
696(defcustom gnus-view-pseudos-separately t
697 "*If non-nil, one pseudo-article will be created for each file to be viewed.
698If nil, all files that use the same viewing command will be given as a
699list of parameters to that command."
700 :group 'gnus-extract-view
701 :type 'boolean)
702
703(defcustom gnus-insert-pseudo-articles t
704 "*If non-nil, insert pseudo-articles when decoding articles."
705 :group 'gnus-extract-view
706 :type 'boolean)
707
708(defcustom gnus-summary-dummy-line-format
23f87bed 709 " %(: :%) %S\n"
eec82323
LMI
710 "*The format specification for the dummy roots in the summary buffer.
711It works along the same lines as a normal formatting string,
712with some simple extensions.
713
23f87bed
MB
714%S The subject
715
716General format specifiers can also be used.
717See `(gnus)Formatting Variables'."
718 :link '(custom-manual "(gnus)Formatting Variables")
eec82323
LMI
719 :group 'gnus-threading
720 :type 'string)
721
16409b0b 722(defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
eec82323
LMI
723 "*The format specification for the summary mode line.
724It works along the same lines as a normal formatting string,
725with some simple extensions:
726
727%G Group name
728%p Unprefixed group name
729%A Current article number
6748645f 730%z Current article score
eec82323
LMI
731%V Gnus version
732%U Number of unread articles in the group
733%e Number of unselected articles in the group
734%Z A string with unread/unselected article counts
735%g Shortish group name
736%S Subject of the current article
737%u User-defined spec
738%s Current score file name
739%d Number of dormant articles
740%r Number of articles that have been marked as read in this session
741%E Number of articles expunged by the score files"
742 :group 'gnus-summary-format
743 :type 'string)
744
16409b0b
GM
745(defcustom gnus-list-identifiers nil
746 "Regexp that matches list identifiers to be removed from subject.
747This can also be a list of regexps."
58e39d05 748 :version "21.1"
16409b0b
GM
749 :group 'gnus-summary-format
750 :group 'gnus-article-hiding
751 :type '(choice (const :tag "none" nil)
752 (regexp :value ".*")
753 (repeat :value (".*") regexp)))
754
eec82323
LMI
755(defcustom gnus-summary-mark-below 0
756 "*Mark all articles with a score below this variable as read.
757This variable is local to each summary buffer and usually set by the
758score file."
759 :group 'gnus-score-default
760 :type 'integer)
761
01c52d31
MB
762(defun gnus-widget-reversible-match (widget value)
763 "Ignoring WIDGET, convert VALUE to internal form.
764VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
765 ;; (debug value)
766 (or (symbolp value)
767 (and (listp value)
768 (eq (length value) 2)
769 (eq (nth 0 value) 'not)
770 (symbolp (nth 1 value)))))
771
772(defun gnus-widget-reversible-to-internal (widget value)
773 "Ignoring WIDGET, convert VALUE to internal form.
774VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
775FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
776 ;; (debug value)
777 (if (atom value)
778 (list value nil)
779 (list (nth 1 value) t)))
780
781(defun gnus-widget-reversible-to-external (widget value)
782 "Ignoring WIDGET, convert VALUE to external form.
783VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
784\(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
785 ;; (debug value)
786 (if (nth 1 value)
787 (list 'not (nth 0 value))
788 (nth 0 value)))
789
790(define-widget 'gnus-widget-reversible 'group
791 "A `group' that convert values."
792 :match 'gnus-widget-reversible-match
793 :value-to-internal 'gnus-widget-reversible-to-internal
794 :value-to-external 'gnus-widget-reversible-to-external)
795
eec82323
LMI
796(defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
797 "*List of functions used for sorting articles in the summary buffer.
23f87bed
MB
798
799Each function takes two articles and returns non-nil if the first
800article should be sorted before the other. If you use more than one
801function, the primary sort function should be the last. You should
802probably always include `gnus-article-sort-by-number' in the list of
803sorting functions -- preferably first. Also note that sorting by date
804is often much slower than sorting by number, and the sorting order is
805very similar. (Sorting by date means sorting by the time the message
806was sent, sorting by number means sorting by arrival time.)
807
01c52d31
MB
808Each item can also be a list `(not F)' where F is a function;
809this reverses the sort order.
810
23f87bed
MB
811Ready-made functions include `gnus-article-sort-by-number',
812`gnus-article-sort-by-author', `gnus-article-sort-by-subject',
813`gnus-article-sort-by-date', `gnus-article-sort-by-random'
814and `gnus-article-sort-by-score'.
815
816When threading is turned on, the variable `gnus-thread-sort-functions'
817controls how articles are sorted."
eec82323 818 :group 'gnus-summary-sort
01c52d31
MB
819 :type '(repeat (gnus-widget-reversible
820 (choice (function-item gnus-article-sort-by-number)
821 (function-item gnus-article-sort-by-author)
822 (function-item gnus-article-sort-by-subject)
823 (function-item gnus-article-sort-by-date)
824 (function-item gnus-article-sort-by-score)
825 (function-item gnus-article-sort-by-random)
826 (function :tag "other"))
827 (boolean :tag "Reverse order"))))
828
eec82323
LMI
829
830(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
831 "*List of functions used for sorting threads in the summary buffer.
832By default, threads are sorted by article number.
833
23f87bed
MB
834Each function takes two threads and returns non-nil if the first
835thread should be sorted before the other. If you use more than one
836function, the primary sort function should be the last. You should
837probably always include `gnus-thread-sort-by-number' in the list of
838sorting functions -- preferably first. Also note that sorting by date
839is often much slower than sorting by number, and the sorting order is
840very similar. (Sorting by date means sorting by the time the message
841was sent, sorting by number means sorting by arrival time.)
eec82323 842
01c52d31
MB
843Each list item can also be a list `(not F)' where F is a
844function; this specifies reversed sort order.
845
eec82323 846Ready-made functions include `gnus-thread-sort-by-number',
01c52d31
MB
847`gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
848`gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
849`gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
850`gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
851and `gnus-thread-sort-by-total-score' (see
852`gnus-thread-score-function').
23f87bed
MB
853
854When threading is turned off, the variable
855`gnus-article-sort-functions' controls how articles are sorted."
eec82323 856 :group 'gnus-summary-sort
01c52d31
MB
857 :type '(repeat
858 (gnus-widget-reversible
859 (choice (function-item gnus-thread-sort-by-number)
860 (function-item gnus-thread-sort-by-author)
861 (function-item gnus-thread-sort-by-recipient)
862 (function-item gnus-thread-sort-by-subject)
863 (function-item gnus-thread-sort-by-date)
864 (function-item gnus-thread-sort-by-score)
865 (function-item gnus-thread-sort-by-most-recent-number)
866 (function-item gnus-thread-sort-by-most-recent-date)
867 (function-item gnus-thread-sort-by-random)
868 (function-item gnus-thread-sort-by-total-score)
869 (function :tag "other"))
870 (boolean :tag "Reverse order"))))
eec82323
LMI
871
872(defcustom gnus-thread-score-function '+
873 "*Function used for calculating the total score of a thread.
874
875The function is called with the scores of the article and each
876subthread and should then return the score of the thread.
877
878Some functions you can use are `+', `max', or `min'."
879 :group 'gnus-summary-sort
880 :type 'function)
881
882(defcustom gnus-summary-expunge-below nil
6748645f
LMI
883 "All articles that have a score less than this variable will be expunged.
884This variable is local to the summary buffers."
eec82323
LMI
885 :group 'gnus-score-default
886 :type '(choice (const :tag "off" nil)
887 integer))
888
889(defcustom gnus-thread-expunge-below nil
890 "All threads that have a total score less than this variable will be expunged.
891See `gnus-thread-score-function' for en explanation of what a
6748645f
LMI
892\"thread score\" is.
893
894This variable is local to the summary buffers."
16409b0b 895 :group 'gnus-threading
eec82323
LMI
896 :group 'gnus-score-default
897 :type '(choice (const :tag "off" nil)
898 integer))
899
900(defcustom gnus-summary-mode-hook nil
901 "*A hook for Gnus summary mode.
902This hook is run before any variables are set in the summary buffer."
23f87bed 903 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
eec82323
LMI
904 :group 'gnus-summary-various
905 :type 'hook)
906
23f87bed
MB
907;; Extracted from gnus-xmas-redefine in order to preserve user settings
908(when (featurep 'xemacs)
909 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
910 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
911 (add-hook 'gnus-summary-mode-hook
912 'gnus-xmas-switch-horizontal-scrollbar-off))
913
eec82323
LMI
914(defcustom gnus-summary-menu-hook nil
915 "*Hook run after the creation of the summary mode menu."
916 :group 'gnus-summary-visual
917 :type 'hook)
918
919(defcustom gnus-summary-exit-hook nil
920 "*A hook called on exit from the summary buffer.
921It will be called with point in the group buffer."
922 :group 'gnus-summary-exit
923 :type 'hook)
924
925(defcustom gnus-summary-prepare-hook nil
926 "*A hook called after the summary buffer has been generated.
927If you want to modify the summary buffer, you can use this hook."
928 :group 'gnus-summary-various
929 :type 'hook)
930
6748645f
LMI
931(defcustom gnus-summary-prepared-hook nil
932 "*A hook called as the last thing after the summary buffer has been generated."
933 :group 'gnus-summary-various
934 :type 'hook)
935
eec82323
LMI
936(defcustom gnus-summary-generate-hook nil
937 "*A hook run just before generating the summary buffer.
938This hook is commonly used to customize threading variables and the
939like."
940 :group 'gnus-summary-various
941 :type 'hook)
942
943(defcustom gnus-select-group-hook nil
944 "*A hook called when a newsgroup is selected.
945
946If you'd like to simplify subjects like the
947`gnus-summary-next-same-subject' command does, you can use the
948following hook:
949
23f87bed
MB
950 (add-hook gnus-select-group-hook
951 (lambda ()
952 (mapcar (lambda (header)
953 (mail-header-set-subject
954 header
955 (gnus-simplify-subject
956 (mail-header-subject header) 're-only)))
957 gnus-newsgroup-headers)))"
eec82323
LMI
958 :group 'gnus-group-select
959 :type 'hook)
960
961(defcustom gnus-select-article-hook nil
962 "*A hook called when an article is selected."
963 :group 'gnus-summary-choose
23f87bed 964 :options '(gnus-agent-fetch-selected-article)
eec82323
LMI
965 :type 'hook)
966
967(defcustom gnus-visual-mark-article-hook
968 (list 'gnus-highlight-selected-summary)
969 "*Hook run after selecting an article in the summary buffer.
970It is meant to be used for highlighting the article in some way. It
971is not run if `gnus-visual' is nil."
972 :group 'gnus-summary-visual
973 :type 'hook)
974
16409b0b 975(defcustom gnus-parse-headers-hook nil
eec82323
LMI
976 "*A hook called before parsing the headers."
977 :group 'gnus-various
978 :type 'hook)
979
980(defcustom gnus-exit-group-hook nil
16409b0b
GM
981 "*A hook called when exiting summary mode.
982This hook is not called from the non-updating exit commands like `Q'."
eec82323
LMI
983 :group 'gnus-various
984 :type 'hook)
985
986(defcustom gnus-summary-update-hook
987 (list 'gnus-summary-highlight-line)
988 "*A hook called when a summary line is changed.
989The hook will not be called if `gnus-visual' is nil.
990
991The default function `gnus-summary-highlight-line' will
992highlight the line according to the `gnus-summary-highlight'
993variable."
994 :group 'gnus-summary-visual
995 :type 'hook)
996
997(defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
998 "*A hook called when an article is selected for the first time.
999The hook is intended to mark an article as read (or unread)
1000automatically when it is selected."
1001 :group 'gnus-summary-choose
1002 :type 'hook)
1003
1004(defcustom gnus-group-no-more-groups-hook nil
1005 "*A hook run when returning to group mode having no more (unread) groups."
1006 :group 'gnus-group-select
1007 :type 'hook)
1008
1009(defcustom gnus-ps-print-hook nil
1010 "*A hook run before ps-printing something from Gnus."
1011 :group 'gnus-summary
1012 :type 'hook)
1013
23f87bed
MB
1014(defcustom gnus-summary-article-move-hook nil
1015 "*A hook called after an article is moved, copied, respooled, or crossposted."
bf247b6e 1016 :version "22.1"
23f87bed
MB
1017 :group 'gnus-summary
1018 :type 'hook)
1019
1020(defcustom gnus-summary-article-delete-hook nil
1021 "*A hook called after an article is deleted."
bf247b6e 1022 :version "22.1"
23f87bed
MB
1023 :group 'gnus-summary
1024 :type 'hook)
1025
1026(defcustom gnus-summary-article-expire-hook nil
1027 "*A hook called after an article is expired."
bf247b6e 1028 :version "22.1"
23f87bed
MB
1029 :group 'gnus-summary
1030 :type 'hook)
1031
1032(defcustom gnus-summary-display-arrow
1033 (and (fboundp 'display-graphic-p)
1034 (display-graphic-p))
1035 "*If non-nil, display an arrow highlighting the current article."
bf247b6e 1036 :version "22.1"
23f87bed
MB
1037 :group 'gnus-summary
1038 :type 'boolean)
1039
0f49874b 1040(defcustom gnus-summary-selected-face 'gnus-summary-selected
eec82323
LMI
1041 "Face used for highlighting the current article in the summary buffer."
1042 :group 'gnus-summary-visual
1043 :type 'face)
1044
23f87bed
MB
1045(defvar gnus-tmp-downloaded nil)
1046
eec82323 1047(defcustom gnus-summary-highlight
23f87bed 1048 '(((eq mark gnus-canceled-mark)
0f49874b 1049 . gnus-summary-cancelled)
23f87bed 1050 ((and uncached (> score default-high))
0f49874b 1051 . gnus-summary-high-undownloaded)
23f87bed 1052 ((and uncached (< score default-low))
0f49874b 1053 . gnus-summary-low-undownloaded)
23f87bed 1054 (uncached
0f49874b 1055 . gnus-summary-normal-undownloaded)
23f87bed
MB
1056 ((and (> score default-high)
1057 (or (eq mark gnus-dormant-mark)
1058 (eq mark gnus-ticked-mark)))
0f49874b 1059 . gnus-summary-high-ticked)
23f87bed
MB
1060 ((and (< score default-low)
1061 (or (eq mark gnus-dormant-mark)
1062 (eq mark gnus-ticked-mark)))
0f49874b 1063 . gnus-summary-low-ticked)
23f87bed
MB
1064 ((or (eq mark gnus-dormant-mark)
1065 (eq mark gnus-ticked-mark))
0f49874b 1066 . gnus-summary-normal-ticked)
23f87bed 1067 ((and (> score default-high) (eq mark gnus-ancient-mark))
0f49874b 1068 . gnus-summary-high-ancient)
23f87bed 1069 ((and (< score default-low) (eq mark gnus-ancient-mark))
0f49874b 1070 . gnus-summary-low-ancient)
23f87bed 1071 ((eq mark gnus-ancient-mark)
0f49874b 1072 . gnus-summary-normal-ancient)
23f87bed 1073 ((and (> score default-high) (eq mark gnus-unread-mark))
0f49874b 1074 . gnus-summary-high-unread)
23f87bed 1075 ((and (< score default-low) (eq mark gnus-unread-mark))
0f49874b 1076 . gnus-summary-low-unread)
23f87bed 1077 ((eq mark gnus-unread-mark)
0f49874b 1078 . gnus-summary-normal-unread)
23f87bed 1079 ((> score default-high)
0f49874b 1080 . gnus-summary-high-read)
23f87bed 1081 ((< score default-low)
0f49874b 1082 . gnus-summary-low-read)
eec82323 1083 (t
0f49874b 1084 . gnus-summary-normal-read))
6748645f 1085 "*Controls the highlighting of summary buffer lines.
eec82323 1086
107cf8ec 1087A list of (FORM . FACE) pairs. When deciding how a particular
23f87bed
MB
1088summary line should be displayed, each form is evaluated. The content
1089of the face field after the first true form is used. You can change
1090how those summary lines are displayed, by editing the face field.
eec82323
LMI
1091
1092You can use the following variables in the FORM field.
1093
107cf8ec 1094score: The article's score.
23f87bed
MB
1095default: The default article score.
1096default-high: The default score for high scored articles.
1097default-low: The default score for low scored articles.
1098below: The score below which articles are automatically marked as read.
1099mark: The article's mark.
1100uncached: Non-nil if the article is uncached."
eec82323
LMI
1101 :group 'gnus-summary-visual
1102 :type '(repeat (cons (sexp :tag "Form" nil)
1103 face)))
c12ecb0a 1104(put 'gnus-summary-highlight 'risky-local-variable t)
eec82323 1105
6748645f
LMI
1106(defcustom gnus-alter-header-function nil
1107 "Function called to allow alteration of article header structures.
1108The function is called with one parameter, the article header vector,
0ab0f2d3
SZ
1109which it may alter in any way."
1110 :type '(choice (const :tag "None" nil)
1111 function)
1112 :group 'gnus-summary)
eec82323 1113
16409b0b 1114(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
343d6628
MB
1115 "Function used to decode a string with encoded words.")
1116
1117(defvar gnus-decode-encoded-address-function
1118 'mail-decode-encoded-address-string
1119 "Function used to decode addresses with encoded words.")
16409b0b 1120
23f87bed 1121(defcustom gnus-extra-headers '(To Newsgroups)
16409b0b 1122 "*Extra headers to parse."
58e39d05 1123 :version "21.1"
16409b0b
GM
1124 :group 'gnus-summary
1125 :type '(repeat symbol))
1126
1127(defcustom gnus-ignored-from-addresses
343d6628 1128 (and user-mail-address
7cd9f860
CY
1129 (not (string= user-mail-address ""))
1130 (regexp-quote user-mail-address))
01c52d31
MB
1131 "*From headers that may be suppressed in favor of To headers.
1132This can be a regexp or a list of regexps."
58e39d05 1133 :version "21.1"
16409b0b 1134 :group 'gnus-summary
01c52d31
MB
1135 :type '(choice regexp
1136 (repeat :tag "Regexp List" regexp)))
1137
1138(defsubst gnus-ignored-from-addresses ()
1139 (gmm-regexp-concat gnus-ignored-from-addresses))
1140
1141(defcustom gnus-summary-to-prefix "-> "
1142 "*String prefixed to the To field in the summary line when
1143using `gnus-ignored-from-addresses'."
1144 :version "22.1"
1145 :group 'gnus-summary
1146 :type 'string)
1147
1148(defcustom gnus-summary-newsgroup-prefix "=> "
1149 "*String prefixed to the Newsgroup field in the summary
1150line when using `gnus-ignored-from-addresses'."
1151 :version "22.1"
1152 :group 'gnus-summary
1153 :type 'string)
16409b0b 1154
16409b0b
GM
1155(defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1156 "List of charsets that should be ignored.
1157When these charsets are used in the \"charset\" parameter, the
1158default charset will be used instead."
58e39d05 1159 :version "21.1"
16409b0b
GM
1160 :type '(repeat symbol)
1161 :group 'gnus-charset)
1162
4b70e299
MB
1163(defcustom gnus-newsgroup-maximum-articles nil
1164 "The maximum number of articles a newsgroup.
1165If this is a number, old articles in a newsgroup exceeding this number
1166are silently ignored. If it is nil, no article is ignored. Note that
1167setting this variable to a number might prevent you from reading very
1168old articles."
1169 :group 'gnus-group-select
1170 :version "22.2"
1171 :type '(choice (const :tag "No limit" nil)
1172 integer))
1173
23f87bed
MB
1174(gnus-define-group-parameter
1175 ignored-charsets
1176 :type list
1177 :function-document
1178 "Return the ignored charsets of GROUP."
1179 :variable gnus-group-ignored-charsets-alist
1180 :variable-default
1181 '(("alt\\.chinese\\.text" iso-8859-1))
1182 :variable-document
1183 "Alist of regexps (to match group names) and charsets that should be ignored.
16409b0b
GM
1184When these charsets are used in the \"charset\" parameter, the
1185default charset will be used instead."
23f87bed
MB
1186 :variable-group gnus-charset
1187 :variable-type '(repeat (cons (regexp :tag "Group")
1188 (repeat symbol)))
1189 :parameter-type '(choice :tag "Ignored charsets"
1190 :value nil
1191 (repeat (symbol)))
1192 :parameter-document "\
1193List of charsets that should be ignored.
1194
1195When these charsets are used in the \"charset\" parameter, the
1196default charset will be used instead.")
16409b0b
GM
1197
1198(defcustom gnus-group-highlight-words-alist nil
1199 "Alist of group regexps and highlight regexps.
1200This variable uses the same syntax as `gnus-emphasis-alist'."
58e39d05 1201 :version "21.1"
16409b0b
GM
1202 :type '(repeat (cons (regexp :tag "Group")
1203 (repeat (list (regexp :tag "Highlight regexp")
1204 (number :tag "Group for entire word" 0)
1205 (number :tag "Group for displayed part" 0)
1206 (symbol :tag "Face"
1207 gnus-emphasis-highlight-words)))))
1208 :group 'gnus-summary-visual)
1209
1210(defcustom gnus-summary-show-article-charset-alist
1211 nil
1212 "Alist of number and charset.
1213The article will be shown with the charset corresponding to the
1214numbered argument.
1215For example: ((1 . cn-gb-2312) (2 . big5))."
58e39d05 1216 :version "21.1"
16409b0b
GM
1217 :type '(repeat (cons (number :tag "Argument" 1)
1218 (symbol :tag "Charset")))
1219 :group 'gnus-charset)
1220
1221(defcustom gnus-preserve-marks t
1222 "Whether marks are preserved when moving, copying and respooling messages."
58e39d05 1223 :version "21.1"
16409b0b
GM
1224 :type 'boolean
1225 :group 'gnus-summary-marks)
1226
3a23a519
MB
1227(defcustom gnus-propagate-marks t
1228 "If non-nil, do not propagate marks to the backends."
f8a29505 1229 :version "23.1" ;; No Gnus
3a23a519
MB
1230 :type 'boolean
1231 :group 'gnus-summary-marks)
1232
16409b0b
GM
1233(defcustom gnus-alter-articles-to-read-function nil
1234 "Function to be called to alter the list of articles to be selected."
8fc7a9a1 1235 :type '(choice (const nil) function)
16409b0b
GM
1236 :group 'gnus-summary)
1237
1238(defcustom gnus-orphan-score nil
1239 "*All orphans get this score added. Set in the score file."
1240 :group 'gnus-score-default
1241 :type '(choice (const nil)
1242 integer))
1243
8b93df01 1244(defcustom gnus-summary-save-parts-default-mime "image/.*"
23f87bed
MB
1245 "*A regexp to match MIME parts when saving multiple parts of a
1246message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1247This regexp will be used by default when prompting the user for which
1248type of files to save."
8b93df01
DL
1249 :group 'gnus-summary
1250 :type 'regexp)
1251
23f87bed
MB
1252(defcustom gnus-read-all-available-headers nil
1253 "Whether Gnus should parse all headers made available to it.
1254This is mostly relevant for slow back ends where the user may
1255wish to widen the summary buffer to include all headers
c4d82de8 1256that were fetched."
bf247b6e 1257 :version "22.1"
23f87bed
MB
1258 :group 'gnus-summary
1259 :type '(choice boolean regexp))
1260
89167438
MB
1261(defcustom gnus-summary-pipe-output-default-command nil
1262 "Command (and optional arguments) used to pipe article to subprocess.
1263This will be used as the default command if it is non-nil. The value
1264will be updated if you modify it when executing the command
1265`gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1266 :version "23.1" ;; No Gnus
1267 :group 'gnus-summary
1268 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1269
23f87bed 1270(defcustom gnus-summary-muttprint-program "muttprint"
89167438
MB
1271 "Command (and optional arguments) used to run Muttprint.
1272The value will be updated if you modify it when executing the command
1273`gnus-summary-muttprint'."
bf247b6e 1274 :version "22.1"
23f87bed
MB
1275 :group 'gnus-summary
1276 :type 'string)
1277
01c52d31 1278(defcustom gnus-article-loose-mime t
23f87bed
MB
1279 "If non-nil, don't require MIME-Version header.
1280Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
a08b59c9 1281supply the MIME-Version header or deliberately strip it from the mail.
01c52d31
MB
1282If non-nil (the default), Gnus will treat some articles as MIME
1283even if the MIME-Version header is missing."
bf247b6e 1284 :version "22.1"
23f87bed
MB
1285 :type 'boolean
1286 :group 'gnus-article-mime)
1287
1288(defcustom gnus-article-emulate-mime t
1289 "If non-nil, use MIME emulation for uuencode and the like.
1290This means that Gnus will search message bodies for text that look
1291like uuencoded bits, yEncoded bits, and so on, and present that using
1292the normal Gnus MIME machinery."
bf247b6e 1293 :version "22.1"
23f87bed
MB
1294 :type 'boolean
1295 :group 'gnus-article-mime)
8b93df01 1296
eec82323
LMI
1297;;; Internal variables
1298
23f87bed 1299(defvar gnus-summary-display-cache nil)
16409b0b
GM
1300(defvar gnus-article-mime-handles nil)
1301(defvar gnus-article-decoded-p nil)
23f87bed
MB
1302(defvar gnus-article-charset nil)
1303(defvar gnus-article-ignored-charsets nil)
eec82323
LMI
1304(defvar gnus-scores-exclude-files nil)
1305(defvar gnus-page-broken nil)
1306
1307(defvar gnus-original-article nil)
1308(defvar gnus-article-internal-prepare-hook nil)
1309(defvar gnus-newsgroup-process-stack nil)
1310
1311(defvar gnus-thread-indent-array nil)
1312(defvar gnus-thread-indent-array-level gnus-thread-indent-level)
16409b0b
GM
1313(defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1314 "Function called to sort the articles within a thread after it has been gathered together.")
eec82323 1315
8b93df01 1316(defvar gnus-summary-save-parts-type-history nil)
23f87bed 1317(defvar gnus-summary-save-parts-last-directory mm-default-directory)
8b93df01 1318
eec82323
LMI
1319;; Avoid highlighting in kill files.
1320(defvar gnus-summary-inhibit-highlight nil)
1321(defvar gnus-newsgroup-selected-overlay nil)
1322(defvar gnus-inhibit-limiting nil)
1323(defvar gnus-newsgroup-adaptive-score-file nil)
1324(defvar gnus-current-score-file nil)
1325(defvar gnus-current-move-group nil)
1326(defvar gnus-current-copy-group nil)
1327(defvar gnus-current-crosspost-group nil)
23f87bed 1328(defvar gnus-newsgroup-display nil)
eec82323
LMI
1329
1330(defvar gnus-newsgroup-dependencies nil)
1331(defvar gnus-newsgroup-adaptive nil)
1332(defvar gnus-summary-display-article-function nil)
1333(defvar gnus-summary-highlight-line-function nil
1334 "Function called after highlighting a summary line.")
1335
1336(defvar gnus-summary-line-format-alist
1337 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1338 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1339 (?s gnus-tmp-subject-or-nil ?s)
1340 (?n gnus-tmp-name ?s)
1341 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1342 ?s)
1343 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1344 gnus-tmp-from) ?s)
1345 (?F gnus-tmp-from ?s)
1346 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1347 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1348 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
6748645f 1349 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
eec82323
LMI
1350 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1351 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1352 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
23f87bed
MB
1353 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1354 (?L gnus-tmp-lines ?s)
1355 (?O gnus-tmp-downloaded ?c)
eec82323
LMI
1356 (?I gnus-tmp-indentation ?s)
1357 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1358 (?R gnus-tmp-replied ?c)
1359 (?\[ gnus-tmp-opening-bracket ?c)
1360 (?\] gnus-tmp-closing-bracket ?c)
1361 (?\> (make-string gnus-tmp-level ? ) ?s)
1362 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1363 (?i gnus-tmp-score ?d)
1364 (?z gnus-tmp-score-char ?c)
eec82323
LMI
1365 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1366 (?U gnus-tmp-unread ?c)
23f87bed
MB
1367 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1368 ?s)
eec82323
LMI
1369 (?t (gnus-summary-number-of-articles-in-thread
1370 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1371 ?d)
1372 (?e (gnus-summary-number-of-articles-in-thread
1373 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1374 ?c)
1375 (?u gnus-tmp-user-defined ?s)
23f87bed
MB
1376 (?P (gnus-pick-line-number) ?d)
1377 (?B gnus-tmp-thread-tree-header-string ?s)
1378 (user-date (gnus-user-date
1379 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
16409b0b
GM
1380 "An alist of format specifications that can appear in summary lines.
1381These are paired with what variables they correspond with, along with
1382the type of the variable (string, integer, character, etc).")
eec82323
LMI
1383
1384(defvar gnus-summary-dummy-line-format-alist
1385 `((?S gnus-tmp-subject ?s)
1386 (?N gnus-tmp-number ?d)
1387 (?u gnus-tmp-user-defined ?s)))
1388
1389(defvar gnus-summary-mode-line-format-alist
1390 `((?G gnus-tmp-group-name ?s)
1391 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1392 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1393 (?A gnus-tmp-article-number ?d)
1394 (?Z gnus-tmp-unread-and-unselected ?s)
1395 (?V gnus-version ?s)
1396 (?U gnus-tmp-unread-and-unticked ?d)
1397 (?S gnus-tmp-subject ?s)
1398 (?e gnus-tmp-unselected ?d)
1399 (?u gnus-tmp-user-defined ?s)
1400 (?d (length gnus-newsgroup-dormant) ?d)
1401 (?t (length gnus-newsgroup-marked) ?d)
23f87bed 1402 (?h (length gnus-newsgroup-spam-marked) ?d)
eec82323 1403 (?r (length gnus-newsgroup-reads) ?d)
6748645f 1404 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
eec82323
LMI
1405 (?E gnus-newsgroup-expunged-tally ?d)
1406 (?s (gnus-current-score-file-nondirectory) ?s)))
1407
c1717fbd
GM
1408;; This is here rather than in gnus-art for compilation reasons.
1409(defvar gnus-article-mode-line-format-alist
1410 (nconc '((?w (gnus-article-wash-status) ?s)
1411 (?m (gnus-article-mime-part-status) ?s))
1412 gnus-summary-mode-line-format-alist))
1413
eec82323
LMI
1414(defvar gnus-last-search-regexp nil
1415 "Default regexp for article search command.")
1416
1417(defvar gnus-last-shell-command nil
1418 "Default shell command on article.")
1419
23f87bed
MB
1420(defvar gnus-newsgroup-agentized nil
1421 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
eec82323
LMI
1422(defvar gnus-newsgroup-begin nil)
1423(defvar gnus-newsgroup-end nil)
1424(defvar gnus-newsgroup-last-rmail nil)
1425(defvar gnus-newsgroup-last-mail nil)
1426(defvar gnus-newsgroup-last-folder nil)
1427(defvar gnus-newsgroup-last-file nil)
26c9afc3 1428(defvar gnus-newsgroup-last-directory nil)
eec82323
LMI
1429(defvar gnus-newsgroup-auto-expire nil)
1430(defvar gnus-newsgroup-active nil)
1431
1432(defvar gnus-newsgroup-data nil)
1433(defvar gnus-newsgroup-data-reverse nil)
1434(defvar gnus-newsgroup-limit nil)
1435(defvar gnus-newsgroup-limits nil)
23f87bed 1436(defvar gnus-summary-use-undownloaded-faces nil)
eec82323
LMI
1437
1438(defvar gnus-newsgroup-unreads nil
23f87bed 1439 "Sorted list of unread articles in the current newsgroup.")
eec82323
LMI
1440
1441(defvar gnus-newsgroup-unselected nil
23f87bed 1442 "Sorted list of unselected unread articles in the current newsgroup.")
eec82323
LMI
1443
1444(defvar gnus-newsgroup-reads nil
1445 "Alist of read articles and article marks in the current newsgroup.")
1446
1447(defvar gnus-newsgroup-expunged-tally nil)
1448
1449(defvar gnus-newsgroup-marked nil
23f87bed
MB
1450 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1451
1452(defvar gnus-newsgroup-spam-marked nil
1453 "List of ranges of articles that have been marked as spam.")
eec82323
LMI
1454
1455(defvar gnus-newsgroup-killed nil
1456 "List of ranges of articles that have been through the scoring process.")
1457
1458(defvar gnus-newsgroup-cached nil
23f87bed 1459 "Sorted list of articles that come from the article cache.")
eec82323
LMI
1460
1461(defvar gnus-newsgroup-saved nil
1462 "List of articles that have been saved.")
1463
1464(defvar gnus-newsgroup-kill-headers nil)
1465
1466(defvar gnus-newsgroup-replied nil
1467 "List of articles that have been replied to in the current newsgroup.")
1468
23f87bed
MB
1469(defvar gnus-newsgroup-forwarded nil
1470 "List of articles that have been forwarded in the current newsgroup.")
1471
1472(defvar gnus-newsgroup-recent nil
1473 "List of articles that have are recent in the current newsgroup.")
1474
eec82323 1475(defvar gnus-newsgroup-expirable nil
23f87bed 1476 "Sorted list of articles in the current newsgroup that can be expired.")
eec82323
LMI
1477
1478(defvar gnus-newsgroup-processable nil
1479 "List of articles in the current newsgroup that can be processed.")
1480
6748645f 1481(defvar gnus-newsgroup-downloadable nil
23f87bed
MB
1482 "Sorted list of articles in the current newsgroup that can be processed.")
1483
1484(defvar gnus-newsgroup-unfetched nil
1485 "Sorted list of articles in the current newsgroup whose headers have
1486not been fetched into the agent.
1487
1488This list will always be a subset of gnus-newsgroup-undownloaded.")
6748645f
LMI
1489
1490(defvar gnus-newsgroup-undownloaded nil
23f87bed 1491 "List of articles in the current newsgroup that haven't been downloaded.")
6748645f
LMI
1492
1493(defvar gnus-newsgroup-unsendable nil
1494 "List of articles in the current newsgroup that won't be sent.")
1495
eec82323
LMI
1496(defvar gnus-newsgroup-bookmarks nil
1497 "List of articles in the current newsgroup that have bookmarks.")
1498
1499(defvar gnus-newsgroup-dormant nil
23f87bed
MB
1500 "Sorted list of dormant articles in the current newsgroup.")
1501
1502(defvar gnus-newsgroup-unseen nil
1503 "List of unseen articles in the current newsgroup.")
1504
1505(defvar gnus-newsgroup-seen nil
1506 "Range of seen articles in the current newsgroup.")
1507
1508(defvar gnus-newsgroup-articles nil
1509 "List of articles in the current newsgroup.")
eec82323
LMI
1510
1511(defvar gnus-newsgroup-scored nil
1512 "List of scored articles in the current newsgroup.")
1513
1514(defvar gnus-newsgroup-headers nil
1515 "List of article headers in the current newsgroup.")
1516
1517(defvar gnus-newsgroup-threads nil)
1518
1519(defvar gnus-newsgroup-prepared nil
1520 "Whether the current group has been prepared properly.")
1521
1522(defvar gnus-newsgroup-ancient nil
1523 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1524
1525(defvar gnus-newsgroup-sparse nil)
1526
1527(defvar gnus-current-article nil)
1528(defvar gnus-article-current nil)
1529(defvar gnus-current-headers nil)
1530(defvar gnus-have-all-headers nil)
1531(defvar gnus-last-article nil)
1532(defvar gnus-newsgroup-history nil)
16409b0b
GM
1533(defvar gnus-newsgroup-charset nil)
1534(defvar gnus-newsgroup-ephemeral-charset nil)
1535(defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
eec82323 1536
23f87bed
MB
1537(defvar gnus-article-before-search nil)
1538
1539(defvar gnus-summary-local-variables
eec82323
LMI
1540 '(gnus-newsgroup-name
1541 gnus-newsgroup-begin gnus-newsgroup-end
1542 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1543 gnus-newsgroup-last-folder gnus-newsgroup-last-file
26c9afc3 1544 gnus-newsgroup-last-directory
eec82323
LMI
1545 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1546 gnus-newsgroup-unselected gnus-newsgroup-marked
23f87bed 1547 gnus-newsgroup-spam-marked
eec82323 1548 gnus-newsgroup-reads gnus-newsgroup-saved
23f87bed
MB
1549 gnus-newsgroup-replied gnus-newsgroup-forwarded
1550 gnus-newsgroup-recent
1551 gnus-newsgroup-expirable
eec82323 1552 gnus-newsgroup-processable gnus-newsgroup-killed
6748645f 1553 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
23f87bed
MB
1554 gnus-newsgroup-unfetched
1555 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1556 gnus-newsgroup-seen gnus-newsgroup-articles
eec82323
LMI
1557 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1558 gnus-newsgroup-headers gnus-newsgroup-threads
1559 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1560 gnus-current-article gnus-current-headers gnus-have-all-headers
1561 gnus-last-article gnus-article-internal-prepare-hook
1562 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1563 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1564 gnus-thread-expunge-below
16409b0b
GM
1565 gnus-score-alist gnus-current-score-file
1566 (gnus-summary-expunge-below . global)
eec82323 1567 (gnus-summary-mark-below . global)
16409b0b 1568 (gnus-orphan-score . global)
eec82323
LMI
1569 gnus-newsgroup-active gnus-scores-exclude-files
1570 gnus-newsgroup-history gnus-newsgroup-ancient
1571 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1572 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1573 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1574 (gnus-newsgroup-expunged-tally . 0)
1575 gnus-cache-removable-articles gnus-newsgroup-cached
1576 gnus-newsgroup-data gnus-newsgroup-data-reverse
16409b0b 1577 gnus-newsgroup-limit gnus-newsgroup-limits
23f87bed
MB
1578 gnus-newsgroup-charset gnus-newsgroup-display
1579 gnus-summary-use-undownloaded-faces)
eec82323
LMI
1580 "Variables that are buffer-local to the summary buffers.")
1581
23f87bed
MB
1582(defvar gnus-newsgroup-variables nil
1583 "A list of variables that have separate values in different newsgroups.
1584A list of newsgroup (summary buffer) local variables, or cons of
1585variables and their default expressions to be evalled (when the default
1586values are not nil), that should be made global while the summary buffer
1587is active.
1588
1589Note: The default expressions will be evaluated (using function `eval')
1590before assignment to the local variable rather than just assigned to it.
1591If the default expression is the symbol `global', that symbol will not
1592be evaluated but the global value of the local variable will be used
1593instead.
1594
1595These variables can be used to set variables in the group parameters
1596while still allowing them to affect operations done in other buffers.
1597For example:
1598
1599\(setq gnus-newsgroup-variables
1600 '(message-use-followup-to
1601 (gnus-visible-headers .
1602 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1603")
1604
23f87bed
MB
1605(eval-when-compile
1606 ;; Bind features so that require will believe that gnus-sum has
1607 ;; already been loaded (avoids infinite recursion)
1608 (let ((features (cons 'gnus-sum features)))
23f87bed 1609 (require 'gnus-art)))
eec82323 1610
16409b0b
GM
1611;; MIME stuff.
1612
1613(defvar gnus-decode-encoded-word-methods
1614 '(mail-decode-encoded-word-string)
1615 "List of methods used to decode encoded words.
1616
23f87bed
MB
1617This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1618is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1619\(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
16409b0b
GM
1620whose names match REGEXP.
1621
1622For example:
23f87bed 1623\((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
16409b0b
GM
1624 mail-decode-encoded-word-string
1625 (\"chinese\" . rfc1843-decode-string))")
1626
1627(defvar gnus-decode-encoded-word-methods-cache nil)
1628
1629(defun gnus-multi-decode-encoded-word-string (string)
1630 "Apply the functions from `gnus-encoded-word-methods' that match."
1631 (unless (and gnus-decode-encoded-word-methods-cache
1632 (eq gnus-newsgroup-name
1633 (car gnus-decode-encoded-word-methods-cache)))
1634 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
01c52d31
MB
1635 (dolist (method gnus-decode-encoded-word-methods)
1636 (if (symbolp method)
1637 (nconc gnus-decode-encoded-word-methods-cache (list method))
1638 (if (and gnus-newsgroup-name
1639 (string-match (car method) gnus-newsgroup-name))
1640 (nconc gnus-decode-encoded-word-methods-cache
1641 (list (cdr method)))))))
1642 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1643 (setq string (funcall method string))))
16409b0b 1644
eec82323
LMI
1645;; Subject simplification.
1646
6748645f 1647(defun gnus-simplify-whitespace (str)
16409b0b 1648 "Remove excessive whitespace from STR."
23f87bed
MB
1649 ;; Multiple spaces.
1650 (while (string-match "[ \t][ \t]+" str)
1651 (setq str (concat (substring str 0 (match-beginning 0))
1652 " "
1653 (substring str (match-end 0)))))
1654 ;; Leading spaces.
1655 (when (string-match "^[ \t]+" str)
1656 (setq str (substring str (match-end 0))))
1657 ;; Trailing spaces.
1658 (when (string-match "[ \t]+$" str)
1659 (setq str (substring str 0 (match-beginning 0))))
1660 str)
1661
1662(defun gnus-simplify-all-whitespace (str)
1663 "Remove all whitespace from STR."
1664 (while (string-match "[ \t\n]+" str)
1665 (setq str (replace-match "" nil nil str)))
1666 str)
6748645f 1667
eec82323
LMI
1668(defsubst gnus-simplify-subject-re (subject)
1669 "Remove \"Re:\" from subject lines."
23f87bed 1670 (if (string-match message-subject-re-regexp subject)
eec82323
LMI
1671 (substring subject (match-end 0))
1672 subject))
1673
1674(defun gnus-simplify-subject (subject &optional re-only)
1675 "Remove `Re:' and words in parentheses.
1676If RE-ONLY is non-nil, strip leading `Re:'s only."
1677 (let ((case-fold-search t)) ;Ignore case.
1678 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1679 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1680 (setq subject (substring subject (match-end 0))))
1681 ;; Remove uninteresting prefixes.
1682 (when (and (not re-only)
1683 gnus-simplify-ignored-prefixes
1684 (string-match gnus-simplify-ignored-prefixes subject))
1685 (setq subject (substring subject (match-end 0))))
1686 ;; Remove words in parentheses from end.
1687 (unless re-only
1688 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1689 (setq subject (substring subject 0 (match-beginning 0)))))
1690 ;; Return subject string.
1691 subject))
1692
1693;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1694;; all whitespace.
1695(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1696 (goto-char (point-min))
1697 (while (re-search-forward regexp nil t)
16409b0b 1698 (replace-match (or newtext ""))))
eec82323
LMI
1699
1700(defun gnus-simplify-buffer-fuzzy ()
1701 "Simplify string in the buffer fuzzily.
1702The string in the accessible portion of the current buffer is simplified.
1703It is assumed to be a single-line subject.
1704Whitespace is generally cleaned up, and miscellaneous leading/trailing
1705matter is removed. Additional things can be deleted by setting
16409b0b 1706`gnus-simplify-subject-fuzzy-regexp'."
eec82323
LMI
1707 (let ((case-fold-search t)
1708 (modified-tick))
1709 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1710
1711 (while (not (eq modified-tick (buffer-modified-tick)))
1712 (setq modified-tick (buffer-modified-tick))
1713 (cond
1714 ((listp gnus-simplify-subject-fuzzy-regexp)
01c52d31
MB
1715 (mapc 'gnus-simplify-buffer-fuzzy-step
1716 gnus-simplify-subject-fuzzy-regexp))
eec82323
LMI
1717 (gnus-simplify-subject-fuzzy-regexp
1718 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1719 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1720 (gnus-simplify-buffer-fuzzy-step
1721 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1722 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1723
1724 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1725 (gnus-simplify-buffer-fuzzy-step " +" " ")
1726 (gnus-simplify-buffer-fuzzy-step " $")
1727 (gnus-simplify-buffer-fuzzy-step "^ +")))
1728
1729(defun gnus-simplify-subject-fuzzy (subject)
1730 "Simplify a subject string fuzzily.
6748645f 1731See `gnus-simplify-buffer-fuzzy' for details."
eec82323
LMI
1732 (save-excursion
1733 (gnus-set-work-buffer)
1734 (let ((case-fold-search t))
6748645f
LMI
1735 ;; Remove uninteresting prefixes.
1736 (when (and gnus-simplify-ignored-prefixes
1737 (string-match gnus-simplify-ignored-prefixes subject))
1738 (setq subject (substring subject (match-end 0))))
eec82323
LMI
1739 (insert subject)
1740 (inline (gnus-simplify-buffer-fuzzy))
1741 (buffer-string))))
1742
1743(defsubst gnus-simplify-subject-fully (subject)
23f87bed 1744 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
eec82323 1745 (cond
6748645f
LMI
1746 (gnus-simplify-subject-functions
1747 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1748 ((null gnus-summary-gather-subject-limit)
1749 (gnus-simplify-subject-re subject))
1750 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1751 (gnus-simplify-subject-fuzzy subject))
1752 ((numberp gnus-summary-gather-subject-limit)
01c52d31
MB
1753 (truncate-string-to-width (gnus-simplify-subject-re subject)
1754 gnus-summary-gather-subject-limit))
eec82323
LMI
1755 (t
1756 subject)))
1757
1758(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f 1759 "Check whether two subjects are equal.
23f87bed 1760If optional argument SIMPLE-FIRST is t, first argument is already
6748645f 1761simplified."
eec82323
LMI
1762 (cond
1763 ((null simple-first)
1764 (equal (gnus-simplify-subject-fully s1)
1765 (gnus-simplify-subject-fully s2)))
1766 (t
1767 (equal s1
1768 (gnus-simplify-subject-fully s2)))))
1769
1770(defun gnus-summary-bubble-group ()
1771 "Increase the score of the current group.
1772This is a handy function to add to `gnus-summary-exit-hook' to
1773increase the score of each group you read."
1774 (gnus-group-add-score gnus-newsgroup-name))
1775
1776\f
1777;;;
1778;;; Gnus summary mode
1779;;;
1780
1781(put 'gnus-summary-mode 'mode-class 'special)
1782
1653df0f
SZ
1783(defvar gnus-article-commands-menu)
1784
23f87bed
MB
1785;; Non-orthogonal keys
1786
1787(gnus-define-keys gnus-summary-mode-map
1788 " " gnus-summary-next-page
1789 "\177" gnus-summary-prev-page
1790 [delete] gnus-summary-prev-page
1791 [backspace] gnus-summary-prev-page
1792 "\r" gnus-summary-scroll-up
1793 "\M-\r" gnus-summary-scroll-down
1794 "n" gnus-summary-next-unread-article
1795 "p" gnus-summary-prev-unread-article
1796 "N" gnus-summary-next-article
1797 "P" gnus-summary-prev-article
1798 "\M-\C-n" gnus-summary-next-same-subject
1799 "\M-\C-p" gnus-summary-prev-same-subject
1800 "\M-n" gnus-summary-next-unread-subject
1801 "\M-p" gnus-summary-prev-unread-subject
1802 "." gnus-summary-first-unread-article
1803 "," gnus-summary-best-unread-article
1804 "\M-s" gnus-summary-search-article-forward
1805 "\M-r" gnus-summary-search-article-backward
01c52d31
MB
1806 "\M-S" gnus-summary-repeat-search-article-forward
1807 "\M-R" gnus-summary-repeat-search-article-backward
23f87bed
MB
1808 "<" gnus-summary-beginning-of-article
1809 ">" gnus-summary-end-of-article
1810 "j" gnus-summary-goto-article
1811 "^" gnus-summary-refer-parent-article
1812 "\M-^" gnus-summary-refer-article
1813 "u" gnus-summary-tick-article-forward
1814 "!" gnus-summary-tick-article-forward
1815 "U" gnus-summary-tick-article-backward
1816 "d" gnus-summary-mark-as-read-forward
1817 "D" gnus-summary-mark-as-read-backward
1818 "E" gnus-summary-mark-as-expirable
1819 "\M-u" gnus-summary-clear-mark-forward
1820 "\M-U" gnus-summary-clear-mark-backward
1821 "k" gnus-summary-kill-same-subject-and-select
1822 "\C-k" gnus-summary-kill-same-subject
1823 "\M-\C-k" gnus-summary-kill-thread
1824 "\M-\C-l" gnus-summary-lower-thread
1825 "e" gnus-summary-edit-article
1826 "#" gnus-summary-mark-as-processable
1827 "\M-#" gnus-summary-unmark-as-processable
1828 "\M-\C-t" gnus-summary-toggle-threads
1829 "\M-\C-s" gnus-summary-show-thread
1830 "\M-\C-h" gnus-summary-hide-thread
1831 "\M-\C-f" gnus-summary-next-thread
1832 "\M-\C-b" gnus-summary-prev-thread
1833 [(meta down)] gnus-summary-next-thread
1834 [(meta up)] gnus-summary-prev-thread
1835 "\M-\C-u" gnus-summary-up-thread
1836 "\M-\C-d" gnus-summary-down-thread
1837 "&" gnus-summary-execute-command
1838 "c" gnus-summary-catchup-and-exit
1839 "\C-w" gnus-summary-mark-region-as-read
1840 "\C-t" gnus-summary-toggle-truncation
1841 "?" gnus-summary-mark-as-dormant
1842 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1843 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6ecfe5c2 1844 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
23f87bed
MB
1845 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1846 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1847 "\C-c\C-s\C-a" gnus-summary-sort-by-author
01c52d31 1848 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
23f87bed
MB
1849 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1850 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6ecfe5c2 1851 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
23f87bed
MB
1852 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1853 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1854 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1855 "=" gnus-summary-expand-window
1856 "\C-x\C-s" gnus-summary-reselect-current-group
1857 "\M-g" gnus-summary-rescan-group
23f87bed
MB
1858 "\C-c\C-r" gnus-summary-caesar-message
1859 "f" gnus-summary-followup
1860 "F" gnus-summary-followup-with-original
1861 "C" gnus-summary-cancel-article
1862 "r" gnus-summary-reply
1863 "R" gnus-summary-reply-with-original
1864 "\C-c\C-f" gnus-summary-mail-forward
1865 "o" gnus-summary-save-article
1866 "\C-o" gnus-summary-save-article-mail
1867 "|" gnus-summary-pipe-output
1868 "\M-k" gnus-summary-edit-local-kill
1869 "\M-K" gnus-summary-edit-global-kill
1870 ;; "V" gnus-version
1871 "\C-c\C-d" gnus-summary-describe-group
1872 "q" gnus-summary-exit
1873 "Q" gnus-summary-exit-no-update
1874 "\C-c\C-i" gnus-info-find-node
1875 gnus-mouse-2 gnus-mouse-pick-article
132cf96d 1876 [follow-link] mouse-face
23f87bed
MB
1877 "m" gnus-summary-mail-other-window
1878 "a" gnus-summary-post-news
23f87bed
MB
1879 "x" gnus-summary-limit-to-unread
1880 "s" gnus-summary-isearch-article
1881 "t" gnus-summary-toggle-header
1882 "g" gnus-summary-show-article
1883 "l" gnus-summary-goto-last-article
1884 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1885 "\C-d" gnus-summary-enter-digest-group
1886 "\M-\C-d" gnus-summary-read-document
1887 "\M-\C-e" gnus-summary-edit-parameters
1888 "\M-\C-a" gnus-summary-customize-parameters
1889 "\C-c\C-b" gnus-bug
1890 "*" gnus-cache-enter-article
1891 "\M-*" gnus-cache-remove-article
1892 "\M-&" gnus-summary-universal-argument
1893 "\C-l" gnus-recenter
1894 "I" gnus-summary-increase-score
1895 "L" gnus-summary-lower-score
1896 "\M-i" gnus-symbolic-argument
1897 "h" gnus-summary-select-article-buffer
1898
1899 "b" gnus-article-view-part
1900 "\M-t" gnus-summary-toggle-display-buttonized
1901
1902 "V" gnus-summary-score-map
1903 "X" gnus-uu-extract-map
1904 "S" gnus-summary-send-map)
1905
1906;; Sort of orthogonal keymap
1907(gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1908 "t" gnus-summary-tick-article-forward
1909 "!" gnus-summary-tick-article-forward
1910 "d" gnus-summary-mark-as-read-forward
1911 "r" gnus-summary-mark-as-read-forward
1912 "c" gnus-summary-clear-mark-forward
1913 " " gnus-summary-clear-mark-forward
1914 "e" gnus-summary-mark-as-expirable
1915 "x" gnus-summary-mark-as-expirable
1916 "?" gnus-summary-mark-as-dormant
1917 "b" gnus-summary-set-bookmark
1918 "B" gnus-summary-remove-bookmark
1919 "#" gnus-summary-mark-as-processable
1920 "\M-#" gnus-summary-unmark-as-processable
1921 "S" gnus-summary-limit-include-expunged
1922 "C" gnus-summary-catchup
1923 "H" gnus-summary-catchup-to-here
1924 "h" gnus-summary-catchup-from-here
1925 "\C-c" gnus-summary-catchup-all
1926 "k" gnus-summary-kill-same-subject-and-select
1927 "K" gnus-summary-kill-same-subject
1928 "P" gnus-uu-mark-map)
1929
1930(gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1931 "c" gnus-summary-clear-above
1932 "u" gnus-summary-tick-above
1933 "m" gnus-summary-mark-above
1934 "k" gnus-summary-kill-below)
1935
1936(gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1937 "/" gnus-summary-limit-to-subject
1938 "n" gnus-summary-limit-to-articles
01c52d31
MB
1939 "b" gnus-summary-limit-to-bodies
1940 "h" gnus-summary-limit-to-headers
23f87bed
MB
1941 "w" gnus-summary-pop-limit
1942 "s" gnus-summary-limit-to-subject
1943 "a" gnus-summary-limit-to-author
1944 "u" gnus-summary-limit-to-unread
1945 "m" gnus-summary-limit-to-marks
1946 "M" gnus-summary-limit-exclude-marks
1947 "v" gnus-summary-limit-to-score
1948 "*" gnus-summary-limit-include-cached
1949 "D" gnus-summary-limit-include-dormant
1950 "T" gnus-summary-limit-include-thread
1951 "d" gnus-summary-limit-exclude-dormant
1952 "t" gnus-summary-limit-to-age
1953 "." gnus-summary-limit-to-unseen
1954 "x" gnus-summary-limit-to-extra
1955 "p" gnus-summary-limit-to-display-predicate
1956 "E" gnus-summary-limit-include-expunged
1957 "c" gnus-summary-limit-exclude-childless-dormant
1958 "C" gnus-summary-limit-mark-excluded-as-read
1959 "o" gnus-summary-insert-old-articles
01c52d31
MB
1960 "N" gnus-summary-insert-new-articles
1961 "S" gnus-summary-limit-to-singletons
1962 "r" gnus-summary-limit-to-replied
1963 "R" gnus-summary-limit-to-recipient
1964 "A" gnus-summary-limit-to-address)
23f87bed
MB
1965
1966(gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1967 "n" gnus-summary-next-unread-article
1968 "p" gnus-summary-prev-unread-article
1969 "N" gnus-summary-next-article
1970 "P" gnus-summary-prev-article
1971 "\C-n" gnus-summary-next-same-subject
1972 "\C-p" gnus-summary-prev-same-subject
1973 "\M-n" gnus-summary-next-unread-subject
1974 "\M-p" gnus-summary-prev-unread-subject
1975 "f" gnus-summary-first-unread-article
1976 "b" gnus-summary-best-unread-article
1977 "j" gnus-summary-goto-article
1978 "g" gnus-summary-goto-subject
1979 "l" gnus-summary-goto-last-article
1980 "o" gnus-summary-pop-article)
1981
1982(gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1983 "k" gnus-summary-kill-thread
01c52d31 1984 "E" gnus-summary-expire-thread
23f87bed
MB
1985 "l" gnus-summary-lower-thread
1986 "i" gnus-summary-raise-thread
1987 "T" gnus-summary-toggle-threads
1988 "t" gnus-summary-rethread-current
1989 "^" gnus-summary-reparent-thread
01c52d31 1990 "\M-^" gnus-summary-reparent-children
23f87bed
MB
1991 "s" gnus-summary-show-thread
1992 "S" gnus-summary-show-all-threads
1993 "h" gnus-summary-hide-thread
1994 "H" gnus-summary-hide-all-threads
1995 "n" gnus-summary-next-thread
1996 "p" gnus-summary-prev-thread
1997 "u" gnus-summary-up-thread
1998 "o" gnus-summary-top-thread
1999 "d" gnus-summary-down-thread
2000 "#" gnus-uu-mark-thread
2001 "\M-#" gnus-uu-unmark-thread)
2002
2003(gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2004 "g" gnus-summary-prepare
2005 "c" gnus-summary-insert-cached-articles
01c52d31
MB
2006 "d" gnus-summary-insert-dormant-articles
2007 "t" gnus-summary-insert-ticked-articles)
23f87bed
MB
2008
2009(gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2010 "c" gnus-summary-catchup-and-exit
2011 "C" gnus-summary-catchup-all-and-exit
2012 "E" gnus-summary-exit-no-update
2013 "Q" gnus-summary-exit
2014 "Z" gnus-summary-exit
2015 "n" gnus-summary-catchup-and-goto-next-group
01c52d31 2016 "p" gnus-summary-catchup-and-goto-prev-group
23f87bed
MB
2017 "R" gnus-summary-reselect-current-group
2018 "G" gnus-summary-rescan-group
2019 "N" gnus-summary-next-group
2020 "s" gnus-summary-save-newsrc
2021 "P" gnus-summary-prev-group)
2022
2023(gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2024 " " gnus-summary-next-page
2025 "n" gnus-summary-next-page
2026 "\177" gnus-summary-prev-page
2027 [delete] gnus-summary-prev-page
2028 "p" gnus-summary-prev-page
2029 "\r" gnus-summary-scroll-up
2030 "\M-\r" gnus-summary-scroll-down
2031 "<" gnus-summary-beginning-of-article
2032 ">" gnus-summary-end-of-article
2033 "b" gnus-summary-beginning-of-article
2034 "e" gnus-summary-end-of-article
2035 "^" gnus-summary-refer-parent-article
2036 "r" gnus-summary-refer-parent-article
2037 "D" gnus-summary-enter-digest-group
2038 "R" gnus-summary-refer-references
2039 "T" gnus-summary-refer-thread
2040 "g" gnus-summary-show-article
2041 "s" gnus-summary-isearch-article
2042 "P" gnus-summary-print-article
01c52d31 2043 "S" gnus-sticky-article
23f87bed
MB
2044 "M" gnus-mailing-list-insinuate
2045 "t" gnus-article-babel)
2046
2047(gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2048 "b" gnus-article-add-buttons
2049 "B" gnus-article-add-buttons-to-head
2050 "o" gnus-article-treat-overstrike
2051 "e" gnus-article-emphasize
2052 "w" gnus-article-fill-cited-article
2053 "Q" gnus-article-fill-long-lines
01c52d31 2054 "L" gnus-article-toggle-truncate-lines
23f87bed
MB
2055 "C" gnus-article-capitalize-sentences
2056 "c" gnus-article-remove-cr
2057 "q" gnus-article-de-quoted-unreadable
2058 "6" gnus-article-de-base64-unreadable
2059 "Z" gnus-article-decode-HZ
01c52d31 2060 "A" gnus-article-treat-ansi-sequences
23f87bed
MB
2061 "h" gnus-article-wash-html
2062 "u" gnus-article-unsplit-urls
2063 "s" gnus-summary-force-verify-and-decrypt
2064 "f" gnus-article-display-x-face
2065 "l" gnus-summary-stop-page-breaking
2066 "r" gnus-summary-caesar-message
2067 "m" gnus-summary-morse-message
2068 "t" gnus-summary-toggle-header
2069 "g" gnus-treat-smiley
2070 "v" gnus-summary-verbose-headers
2071 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2072 "p" gnus-article-verify-x-pgp-sig
01c52d31
MB
2073 "d" gnus-article-treat-dumbquotes
2074 "i" gnus-summary-idna-message)
23f87bed
MB
2075
2076(gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2077 ;; mnemonic: deuglif*Y*
2078 "u" gnus-article-outlook-unwrap-lines
2079 "a" gnus-article-outlook-repair-attribution
2080 "c" gnus-article-outlook-rearrange-citation
2081 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2082
2083(gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2084 "a" gnus-article-hide
2085 "h" gnus-article-hide-headers
2086 "b" gnus-article-hide-boring-headers
2087 "s" gnus-article-hide-signature
2088 "c" gnus-article-hide-citation
2089 "C" gnus-article-hide-citation-in-followups
2090 "l" gnus-article-hide-list-identifiers
2091 "B" gnus-article-strip-banner
2092 "P" gnus-article-hide-pem
2093 "\C-c" gnus-article-hide-citation-maybe)
2094
2095(gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2096 "a" gnus-article-highlight
2097 "h" gnus-article-highlight-headers
2098 "c" gnus-article-highlight-citation
2099 "s" gnus-article-highlight-signature)
2100
2101(gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2102 "f" gnus-article-treat-fold-headers
2103 "u" gnus-article-treat-unfold-headers
2104 "n" gnus-article-treat-fold-newsgroups)
2105
2106(gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2107 "x" gnus-article-display-x-face
2108 "d" gnus-article-display-face
2109 "s" gnus-treat-smiley
2110 "D" gnus-article-remove-images
2111 "f" gnus-treat-from-picon
2112 "m" gnus-treat-mail-picon
2113 "n" gnus-treat-newsgroups-picon)
2114
2115(gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2116 "w" gnus-article-decode-mime-words
2117 "c" gnus-article-decode-charset
2118 "v" gnus-mime-view-all-parts
2119 "b" gnus-article-view-part)
2120
2121(gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2122 "z" gnus-article-date-ut
2123 "u" gnus-article-date-ut
2124 "l" gnus-article-date-local
2125 "p" gnus-article-date-english
2126 "e" gnus-article-date-lapsed
2127 "o" gnus-article-date-original
2128 "i" gnus-article-date-iso8601
2129 "s" gnus-article-date-user)
2130
2131(gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2132 "t" gnus-article-remove-trailing-blank-lines
2133 "l" gnus-article-strip-leading-blank-lines
2134 "m" gnus-article-strip-multiple-blank-lines
2135 "a" gnus-article-strip-blank-lines
2136 "A" gnus-article-strip-all-blank-lines
2137 "s" gnus-article-strip-leading-space
2138 "e" gnus-article-strip-trailing-space
2139 "w" gnus-article-remove-leading-whitespace)
2140
2141(gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2142 "v" gnus-version
2143 "f" gnus-summary-fetch-faq
2144 "d" gnus-summary-describe-group
2145 "h" gnus-summary-describe-briefly
2146 "i" gnus-info-find-node
2147 "c" gnus-group-fetch-charter
2148 "C" gnus-group-fetch-control)
2149
2150(gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2151 "e" gnus-summary-expire-articles
2152 "\M-\C-e" gnus-summary-expire-articles-now
2153 "\177" gnus-summary-delete-article
2154 [delete] gnus-summary-delete-article
2155 [backspace] gnus-summary-delete-article
2156 "m" gnus-summary-move-article
2157 "r" gnus-summary-respool-article
2158 "w" gnus-summary-edit-article
2159 "c" gnus-summary-copy-article
2160 "B" gnus-summary-crosspost-article
2161 "q" gnus-summary-respool-query
2162 "t" gnus-summary-respool-trace
2163 "i" gnus-summary-import-article
2164 "I" gnus-summary-create-article
2165 "p" gnus-summary-article-posted-p)
2166
2167(gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2168 "o" gnus-summary-save-article
2169 "m" gnus-summary-save-article-mail
2170 "F" gnus-summary-write-article-file
2171 "r" gnus-summary-save-article-rmail
2172 "f" gnus-summary-save-article-file
2173 "b" gnus-summary-save-article-body-file
26c9afc3 2174 "B" gnus-summary-write-article-body-file
23f87bed
MB
2175 "h" gnus-summary-save-article-folder
2176 "v" gnus-summary-save-article-vm
2177 "p" gnus-summary-pipe-output
c4d82de8 2178 "P" gnus-summary-muttprint)
23f87bed
MB
2179
2180(gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2181 "b" gnus-summary-display-buttonized
2182 "m" gnus-summary-repair-multipart
2183 "v" gnus-article-view-part
2184 "o" gnus-article-save-part
01c52d31
MB
2185 "O" gnus-article-save-part-and-strip
2186 "r" gnus-article-replace-part
2187 "d" gnus-article-delete-part
2188 "t" gnus-article-view-part-as-type
2189 "j" gnus-article-jump-to-part
23f87bed
MB
2190 "c" gnus-article-copy-part
2191 "C" gnus-article-view-part-as-charset
2192 "e" gnus-article-view-part-externally
01c52d31 2193 "H" gnus-article-browse-html-article
23f87bed
MB
2194 "E" gnus-article-encrypt-body
2195 "i" gnus-article-inline-part
2196 "|" gnus-article-pipe-part)
2197
2198(gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2199 "p" gnus-summary-mark-as-processable
2200 "u" gnus-summary-unmark-as-processable
2201 "U" gnus-summary-unmark-all-processable
2202 "v" gnus-uu-mark-over
2203 "s" gnus-uu-mark-series
2204 "r" gnus-uu-mark-region
2205 "g" gnus-uu-unmark-region
2206 "R" gnus-uu-mark-by-regexp
2207 "G" gnus-uu-unmark-by-regexp
2208 "t" gnus-uu-mark-thread
2209 "T" gnus-uu-unmark-thread
2210 "a" gnus-uu-mark-all
2211 "b" gnus-uu-mark-buffer
2212 "S" gnus-uu-mark-sparse
2213 "k" gnus-summary-kill-process-mark
2214 "y" gnus-summary-yank-process-mark
2215 "w" gnus-summary-save-process-mark
2216 "i" gnus-uu-invert-processable)
2217
2218(gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2219 ;;"x" gnus-uu-extract-any
2220 "m" gnus-summary-save-parts
2221 "u" gnus-uu-decode-uu
2222 "U" gnus-uu-decode-uu-and-save
2223 "s" gnus-uu-decode-unshar
2224 "S" gnus-uu-decode-unshar-and-save
2225 "o" gnus-uu-decode-save
2226 "O" gnus-uu-decode-save
2227 "b" gnus-uu-decode-binhex
2228 "B" gnus-uu-decode-binhex
b890d447 2229 "Y" gnus-uu-decode-yenc
23f87bed
MB
2230 "p" gnus-uu-decode-postscript
2231 "P" gnus-uu-decode-postscript-and-save)
2232
2233(gnus-define-keys
2234 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2235 "u" gnus-uu-decode-uu-view
2236 "U" gnus-uu-decode-uu-and-save-view
2237 "s" gnus-uu-decode-unshar-view
2238 "S" gnus-uu-decode-unshar-and-save-view
2239 "o" gnus-uu-decode-save-view
2240 "O" gnus-uu-decode-save-view
2241 "b" gnus-uu-decode-binhex-view
2242 "B" gnus-uu-decode-binhex-view
2243 "p" gnus-uu-decode-postscript-view
2244 "P" gnus-uu-decode-postscript-and-save-view)
2245
2246(defvar gnus-article-post-menu nil)
2247
2248(defconst gnus-summary-menu-maxlen 20)
2249
2250(defun gnus-summary-menu-split (menu)
2251 ;; If we have lots of elements, divide them into groups of 20
2252 ;; and make a pane (or submenu) for each one.
2253 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2254 (let ((menu menu) sublists next
2255 (i 1))
2256 (while menu
2257 ;; Pull off the next gnus-summary-menu-maxlen elements
2258 ;; and make them the next element of sublist.
2259 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2260 (if next
2261 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2262 nil))
2263 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2264 (aref (car (last menu)) 0)) menu)
2265 sublists))
2266 (setq i (1+ i))
2267 (setq menu next))
2268 (nreverse sublists))
2269 ;; Few elements--put them all in one pane.
2270 menu))
eec82323
LMI
2271
2272(defun gnus-summary-make-menu-bar ()
2273 (gnus-turn-off-edit-menu 'summary)
2274
2275 (unless (boundp 'gnus-summary-misc-menu)
2276
2277 (easy-menu-define
23f87bed
MB
2278 gnus-summary-kill-menu gnus-summary-mode-map ""
2279 (cons
2280 "Score"
2281 (nconc
2282 (list
2283 ["Customize" gnus-score-customize t])
2284 (gnus-make-score-map 'increase)
2285 (gnus-make-score-map 'lower)
2286 '(("Mark"
2287 ["Kill below" gnus-summary-kill-below t]
2288 ["Mark above" gnus-summary-mark-above t]
2289 ["Tick above" gnus-summary-tick-above t]
2290 ["Clear above" gnus-summary-clear-above t])
2291 ["Current score" gnus-summary-current-score t]
2292 ["Set score" gnus-summary-set-score t]
2293 ["Switch current score file..." gnus-score-change-score-file t]
2294 ["Set mark below..." gnus-score-set-mark-below t]
2295 ["Set expunge below..." gnus-score-set-expunge-below t]
2296 ["Edit current score file" gnus-score-edit-current-scores t]
59429511 2297 ["Edit score file..." gnus-score-edit-file t]
23f87bed
MB
2298 ["Trace score" gnus-score-find-trace t]
2299 ["Find words" gnus-score-find-favourite-words t]
2300 ["Rescore buffer" gnus-summary-rescore t]
2301 ["Increase score..." gnus-summary-increase-score t]
2302 ["Lower score..." gnus-summary-lower-score t]))))
2303
2304 ;; Define both the Article menu in the summary buffer and the
2305 ;; equivalent Commands menu in the article buffer here for
2306 ;; consistency.
6748645f 2307 (let ((innards
23f87bed
MB
2308 `(("Hide"
2309 ["All" gnus-article-hide t]
2310 ["Headers" gnus-article-hide-headers t]
2311 ["Signature" gnus-article-hide-signature t]
2312 ["Citation" gnus-article-hide-citation t]
16409b0b 2313 ["List identifiers" gnus-article-hide-list-identifiers t]
16409b0b 2314 ["Banner" gnus-article-strip-banner t]
23f87bed
MB
2315 ["Boring headers" gnus-article-hide-boring-headers t])
2316 ("Highlight"
2317 ["All" gnus-article-highlight t]
2318 ["Headers" gnus-article-highlight-headers t]
2319 ["Signature" gnus-article-highlight-signature t]
2320 ["Citation" gnus-article-highlight-citation t])
16409b0b
GM
2321 ("MIME"
2322 ["Words" gnus-article-decode-mime-words t]
2323 ["Charset" gnus-article-decode-charset t]
2324 ["QP" gnus-article-de-quoted-unreadable t]
2325 ["Base64" gnus-article-de-base64-unreadable t]
23f87bed
MB
2326 ["View MIME buttons" gnus-summary-display-buttonized t]
2327 ["View all" gnus-mime-view-all-parts t]
2328 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2329 ["Encrypt body" gnus-article-encrypt-body
2330 :active (not (gnus-group-read-only-p))
2331 ,@(if (featurep 'xemacs) nil
2332 '(:help "Encrypt the message body on disk"))]
2333 ["Extract all parts..." gnus-summary-save-parts t]
2334 ("Multipart"
2335 ["Repair multipart" gnus-summary-repair-multipart t]
2336 ["Pipe part..." gnus-article-pipe-part t]
2337 ["Inline part" gnus-article-inline-part t]
01c52d31 2338 ["View part as type..." gnus-article-view-part-as-type t]
23f87bed
MB
2339 ["Encrypt body" gnus-article-encrypt-body
2340 :active (not (gnus-group-read-only-p))
2341 ,@(if (featurep 'xemacs) nil
2342 '(:help "Encrypt the message body on disk"))]
2343 ["View part externally" gnus-article-view-part-externally t]
01c52d31 2344 ["View HTML parts in browser" gnus-article-browse-html-article t]
23f87bed
MB
2345 ["View part with charset..." gnus-article-view-part-as-charset t]
2346 ["Copy part" gnus-article-copy-part t]
2347 ["Save part..." gnus-article-save-part t]
2348 ["View part" gnus-article-view-part t]))
2349 ("Date"
2350 ["Local" gnus-article-date-local t]
2351 ["ISO8601" gnus-article-date-iso8601 t]
2352 ["UT" gnus-article-date-ut t]
2353 ["Original" gnus-article-date-original t]
2354 ["Lapsed" gnus-article-date-lapsed t]
2355 ["User-defined" gnus-article-date-user t])
2356 ("Display"
2357 ["Remove images" gnus-article-remove-images t]
2358 ["Toggle smiley" gnus-treat-smiley t]
2359 ["Show X-Face" gnus-article-display-x-face t]
2360 ["Show picons in From" gnus-treat-from-picon t]
2361 ["Show picons in mail headers" gnus-treat-mail-picon t]
2362 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2363 ("View as different encoding"
2364 ,@(gnus-summary-menu-split
2365 (mapcar
2366 (lambda (cs)
2367 ;; Since easymenu under Emacs doesn't allow
2368 ;; lambda forms for menu commands, we should
2369 ;; provide intern'ed function symbols.
2370 (let ((command (intern (format "\
2371gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2372 (fset command
2373 `(lambda ()
2374 (interactive)
2375 (let ((gnus-summary-show-article-charset-alist
2376 '((1 . ,cs))))
2377 (gnus-summary-show-article 1))))
2378 `[,(symbol-name cs) ,command t]))
2379 (sort (if (fboundp 'coding-system-list)
2380 (coding-system-list)
2381 (mapcar 'car mm-mime-mule-charset-alist))
2382 'string<)))))
2383 ("Washing"
2384 ("Remove Blanks"
2385 ["Leading" gnus-article-strip-leading-blank-lines t]
2386 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2387 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2388 ["All of the above" gnus-article-strip-blank-lines t]
2389 ["All" gnus-article-strip-all-blank-lines t]
2390 ["Leading space" gnus-article-strip-leading-space t]
2391 ["Trailing space" gnus-article-strip-trailing-space t]
2392 ["Leading space in headers"
2393 gnus-article-remove-leading-whitespace t])
2394 ["Overstrike" gnus-article-treat-overstrike t]
2395 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2396 ["Emphasis" gnus-article-emphasize t]
2397 ["Word wrap" gnus-article-fill-cited-article t]
16409b0b 2398 ["Fill long lines" gnus-article-fill-long-lines t]
01c52d31 2399 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
16409b0b 2400 ["Capitalize sentences" gnus-article-capitalize-sentences t]
23f87bed
MB
2401 ["Remove CR" gnus-article-remove-cr t]
2402 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2403 ["Base64" gnus-article-de-base64-unreadable t]
2404 ["Rot 13" gnus-summary-caesar-message
2405 ,@(if (featurep 'xemacs) '(t)
2406 '(:help "\"Caesar rotate\" article by 13"))]
01c52d31 2407 ["De-IDNA" gnus-summary-idna-message t]
23f87bed
MB
2408 ["Morse decode" gnus-summary-morse-message t]
2409 ["Unix pipe..." gnus-summary-pipe-message t]
2410 ["Add buttons" gnus-article-add-buttons t]
2411 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2412 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2413 ["Verbose header" gnus-summary-verbose-headers t]
2414 ["Toggle header" gnus-summary-toggle-header t]
2415 ["Unfold headers" gnus-article-treat-unfold-headers t]
2416 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
16409b0b 2417 ["Html" gnus-article-wash-html t]
23f87bed
MB
2418 ["Unsplit URLs" gnus-article-unsplit-urls t]
2419 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2420 ["Decode HZ" gnus-article-decode-HZ t]
01c52d31 2421 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
23f87bed
MB
2422 ("(Outlook) Deuglify"
2423 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2424 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2425 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2426 ["Full (Outlook) deuglify"
2427 gnus-article-outlook-deuglify-article t])
2428 )
2429 ("Output"
2430 ["Save in default format..." gnus-summary-save-article
2431 ,@(if (featurep 'xemacs) '(t)
2432 '(:help "Save article using default method"))]
2433 ["Save in file..." gnus-summary-save-article-file
2434 ,@(if (featurep 'xemacs) '(t)
2435 '(:help "Save article in file"))]
2436 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2437 ["Save in MH folder..." gnus-summary-save-article-folder t]
2438 ["Save in VM folder..." gnus-summary-save-article-vm t]
2439 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2440 ["Save body in file..." gnus-summary-save-article-body-file t]
2441 ["Pipe through a filter..." gnus-summary-pipe-output t]
23f87bed 2442 ["Print with Muttprint..." gnus-summary-muttprint t]
531e5812
MB
2443 ["Print" gnus-summary-print-article
2444 ,@(if (featurep 'xemacs) '(t)
2445 '(:help "Generate and print a PostScript image"))])
2446 ("Copy, move,... (Backend)"
707f2b38 2447 ,@(if (featurep 'xemacs) nil
531e5812 2448 '(:help "Copying, moving, expiring articles..."))
23f87bed
MB
2449 ["Respool article..." gnus-summary-respool-article t]
2450 ["Move article..." gnus-summary-move-article
2451 (gnus-check-backend-function
2452 'request-move-article gnus-newsgroup-name)]
2453 ["Copy article..." gnus-summary-copy-article t]
2454 ["Crosspost article..." gnus-summary-crosspost-article
2455 (gnus-check-backend-function
2456 'request-replace-article gnus-newsgroup-name)]
2457 ["Import file..." gnus-summary-import-article
2458 (gnus-check-backend-function
2459 'request-accept-article gnus-newsgroup-name)]
2460 ["Create article..." gnus-summary-create-article
2461 (gnus-check-backend-function
2462 'request-accept-article gnus-newsgroup-name)]
2463 ["Check if posted" gnus-summary-article-posted-p t]
2464 ["Edit article" gnus-summary-edit-article
2465 (not (gnus-group-read-only-p))]
2466 ["Delete article" gnus-summary-delete-article
2467 (gnus-check-backend-function
2468 'request-expire-articles gnus-newsgroup-name)]
2469 ["Query respool" gnus-summary-respool-query t]
6748645f 2470 ["Trace respool" gnus-summary-respool-trace t]
23f87bed
MB
2471 ["Delete expirable articles" gnus-summary-expire-articles-now
2472 (gnus-check-backend-function
2473 'request-expire-articles gnus-newsgroup-name)])
2474 ("Extract"
2475 ["Uudecode" gnus-uu-decode-uu
2476 ,@(if (featurep 'xemacs) '(t)
2477 '(:help "Decode uuencoded article(s)"))]
2478 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2479 ["Unshar" gnus-uu-decode-unshar t]
2480 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2481 ["Save" gnus-uu-decode-save t]
2482 ["Binhex" gnus-uu-decode-binhex t]
2483 ["Postscript" gnus-uu-decode-postscript t]
2484 ["All MIME parts" gnus-summary-save-parts t])
2485 ("Cache"
2486 ["Enter article" gnus-cache-enter-article t]
2487 ["Remove article" gnus-cache-remove-article t])
16409b0b 2488 ["Translate" gnus-article-babel t]
23f87bed 2489 ["Select article buffer" gnus-summary-select-article-buffer t]
01c52d31 2490 ["Make article buffer sticky" gnus-sticky-article t]
23f87bed
MB
2491 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2492 ["Isearch article..." gnus-summary-isearch-article t]
2493 ["Beginning of the article" gnus-summary-beginning-of-article t]
2494 ["End of the article" gnus-summary-end-of-article t]
2495 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2496 ["Fetch referenced articles" gnus-summary-refer-references t]
2497 ["Fetch current thread" gnus-summary-refer-thread t]
2498 ["Fetch article with id..." gnus-summary-refer-article t]
2499 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2500 ["Redisplay" gnus-summary-show-article t]
2501 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
6748645f 2502 (easy-menu-define
23f87bed
MB
2503 gnus-summary-article-menu gnus-summary-mode-map ""
2504 (cons "Article" innards))
6748645f 2505
1653df0f
SZ
2506 (if (not (keymapp gnus-summary-article-menu))
2507 (easy-menu-define
2508 gnus-article-commands-menu gnus-article-mode-map ""
2509 (cons "Commands" innards))
2510 ;; in Emacs, don't share menu.
a1506d29 2511 (setq gnus-article-commands-menu
1653df0f
SZ
2512 (copy-keymap gnus-summary-article-menu))
2513 (define-key gnus-article-mode-map [menu-bar commands]
2514 (cons "Commands" gnus-article-commands-menu))))
eec82323
LMI
2515
2516 (easy-menu-define
23f87bed
MB
2517 gnus-summary-thread-menu gnus-summary-mode-map ""
2518 '("Threads"
2519 ["Find all messages in thread" gnus-summary-refer-thread t]
2520 ["Toggle threading" gnus-summary-toggle-threads t]
2521 ["Hide threads" gnus-summary-hide-all-threads t]
2522 ["Show threads" gnus-summary-show-all-threads t]
2523 ["Hide thread" gnus-summary-hide-thread t]
2524 ["Show thread" gnus-summary-show-thread t]
2525 ["Go to next thread" gnus-summary-next-thread t]
2526 ["Go to previous thread" gnus-summary-prev-thread t]
2527 ["Go down thread" gnus-summary-down-thread t]
2528 ["Go up thread" gnus-summary-up-thread t]
2529 ["Top of thread" gnus-summary-top-thread t]
2530 ["Mark thread as read" gnus-summary-kill-thread t]
01c52d31 2531 ["Mark thread as expired" gnus-summary-expire-thread t]
23f87bed
MB
2532 ["Lower thread score" gnus-summary-lower-thread t]
2533 ["Raise thread score" gnus-summary-raise-thread t]
2534 ["Rethread current" gnus-summary-rethread-current t]))
eec82323
LMI
2535
2536 (easy-menu-define
23f87bed
MB
2537 gnus-summary-post-menu gnus-summary-mode-map ""
2538 `("Post"
2539 ["Send a message (mail or news)" gnus-summary-post-news
2540 ,@(if (featurep 'xemacs) '(t)
531e5812 2541 '(:help "Compose a new message (mail or news)"))]
23f87bed
MB
2542 ["Followup" gnus-summary-followup
2543 ,@(if (featurep 'xemacs) '(t)
2544 '(:help "Post followup to this article"))]
2545 ["Followup and yank" gnus-summary-followup-with-original
2546 ,@(if (featurep 'xemacs) '(t)
2547 '(:help "Post followup to this article, quoting its contents"))]
2548 ["Supersede article" gnus-summary-supersede-article t]
2549 ["Cancel article" gnus-summary-cancel-article
2550 ,@(if (featurep 'xemacs) '(t)
2551 '(:help "Cancel an article you posted"))]
2552 ["Reply" gnus-summary-reply t]
2553 ["Reply and yank" gnus-summary-reply-with-original t]
2554 ["Wide reply" gnus-summary-wide-reply t]
2555 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2556 ,@(if (featurep 'xemacs) '(t)
2557 '(:help "Mail a reply, quoting this article"))]
2558 ["Very wide reply" gnus-summary-very-wide-reply t]
2559 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2560 ,@(if (featurep 'xemacs) '(t)
2561 '(:help "Mail a very wide reply, quoting this article"))]
2562 ["Mail forward" gnus-summary-mail-forward t]
2563 ["Post forward" gnus-summary-post-forward t]
2564 ["Digest and mail" gnus-uu-digest-mail-forward t]
2565 ["Digest and post" gnus-uu-digest-post-forward t]
2566 ["Resend message" gnus-summary-resend-message t]
2567 ["Resend message edit" gnus-summary-resend-message-edit t]
2568 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2569 ["Send a mail" gnus-summary-mail-other-window t]
2570 ["Create a local message" gnus-summary-news-other-window t]
2571 ["Uuencode and post" gnus-uu-post-news
2572 ,@(if (featurep 'xemacs) '(t)
2573 '(:help "Post a uuencoded article"))]
2574 ["Followup via news" gnus-summary-followup-to-mail t]
2575 ["Followup via news and yank"
2576 gnus-summary-followup-to-mail-with-original t]
9b3ebcb6
MB
2577 ["Strip signature on reply"
2578 (lambda ()
2579 (interactive)
2580 (if (not (memq message-cite-function
2581 '(message-cite-original-without-signature
2582 message-cite-original)))
2583 ;; Stupid workaround for XEmacs not honoring :visible.
2584 (message "Can't toggle this value of `message-cite-function'")
2585 (setq message-cite-function
2586 (if (eq message-cite-function
2587 'message-cite-original-without-signature)
2588 'message-cite-original
2589 'message-cite-original-without-signature))))
2590 ;; XEmacs barfs on :visible.
2591 ,@(if (featurep 'xemacs) nil
2592 '(:visible (memq message-cite-function
2593 '(message-cite-original-without-signature
2594 message-cite-original))))
2595 :style toggle
2596 :selected (eq message-cite-function
2597 'message-cite-original-without-signature)
2598 ,@(if (featurep 'xemacs) nil
2599 '(:help "Strip signature from cited article when replying."))]
23f87bed
MB
2600 ;;("Draft"
2601 ;;["Send" gnus-summary-send-draft t]
2602 ;;["Send bounced" gnus-resend-bounced-mail t])
2603 ))
2604
2605 (cond
2606 ((not (keymapp gnus-summary-post-menu))
2607 (setq gnus-article-post-menu gnus-summary-post-menu))
2608 ((not gnus-article-post-menu)
2609 ;; Don't share post menu.
2610 (setq gnus-article-post-menu
2611 (copy-keymap gnus-summary-post-menu))))
2612 (define-key gnus-article-mode-map [menu-bar post]
2613 (cons "Post" gnus-article-post-menu))
eec82323
LMI
2614
2615 (easy-menu-define
23f87bed
MB
2616 gnus-summary-misc-menu gnus-summary-mode-map ""
2617 `("Gnus"
2618 ("Mark Read"
2619 ["Mark as read" gnus-summary-mark-as-read-forward t]
2620 ["Mark same subject and select"
2621 gnus-summary-kill-same-subject-and-select t]
2622 ["Mark same subject" gnus-summary-kill-same-subject t]
2623 ["Catchup" gnus-summary-catchup
2624 ,@(if (featurep 'xemacs) '(t)
2625 '(:help "Mark unread articles in this group as read"))]
2626 ["Catchup all" gnus-summary-catchup-all t]
2627 ["Catchup to here" gnus-summary-catchup-to-here t]
2628 ["Catchup from here" gnus-summary-catchup-from-here t]
2629 ["Catchup region" gnus-summary-mark-region-as-read
2630 (gnus-mark-active-p)]
2631 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2632 ("Mark Various"
2633 ["Tick" gnus-summary-tick-article-forward t]
2634 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2635 ["Remove marks" gnus-summary-clear-mark-forward t]
2636 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2637 ["Set bookmark" gnus-summary-set-bookmark t]
2638 ["Remove bookmark" gnus-summary-remove-bookmark t])
2639 ("Limit to"
2640 ["Marks..." gnus-summary-limit-to-marks t]
2641 ["Subject..." gnus-summary-limit-to-subject t]
2642 ["Author..." gnus-summary-limit-to-author t]
01c52d31
MB
2643 ["Recipient..." gnus-summary-limit-to-recipient t]
2644 ["Address..." gnus-summary-limit-to-address t]
23f87bed
MB
2645 ["Age..." gnus-summary-limit-to-age t]
2646 ["Extra..." gnus-summary-limit-to-extra t]
2647 ["Score..." gnus-summary-limit-to-score t]
2648 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2649 ["Unread" gnus-summary-limit-to-unread t]
2650 ["Unseen" gnus-summary-limit-to-unseen t]
01c52d31
MB
2651 ["Singletons" gnus-summary-limit-to-singletons t]
2652 ["Replied" gnus-summary-limit-to-replied t]
23f87bed 2653 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
996aa8c1 2654 ["Next or process marked articles" gnus-summary-limit-to-articles t]
23f87bed
MB
2655 ["Pop limit" gnus-summary-pop-limit t]
2656 ["Show dormant" gnus-summary-limit-include-dormant t]
2657 ["Hide childless dormant"
2658 gnus-summary-limit-exclude-childless-dormant t]
2659 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2660 ["Hide marked" gnus-summary-limit-exclude-marks t]
2661 ["Show expunged" gnus-summary-limit-include-expunged t])
2662 ("Process Mark"
2663 ["Set mark" gnus-summary-mark-as-processable t]
2664 ["Remove mark" gnus-summary-unmark-as-processable t]
2665 ["Remove all marks" gnus-summary-unmark-all-processable t]
01c52d31 2666 ["Invert marks" gnus-uu-invert-processable t]
23f87bed
MB
2667 ["Mark above" gnus-uu-mark-over t]
2668 ["Mark series" gnus-uu-mark-series t]
2669 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2670 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2671 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2672 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2673 ["Mark all" gnus-uu-mark-all t]
2674 ["Mark buffer" gnus-uu-mark-buffer t]
2675 ["Mark sparse" gnus-uu-mark-sparse t]
2676 ["Mark thread" gnus-uu-mark-thread t]
2677 ["Unmark thread" gnus-uu-unmark-thread t]
2678 ("Process Mark Sets"
2679 ["Kill" gnus-summary-kill-process-mark t]
2680 ["Yank" gnus-summary-yank-process-mark
2681 gnus-newsgroup-process-stack]
2682 ["Save" gnus-summary-save-process-mark t]
2683 ["Run command on marked..." gnus-summary-universal-argument t]))
ec7995fa 2684 ("Registry Marks")
23f87bed
MB
2685 ("Scroll article"
2686 ["Page forward" gnus-summary-next-page
2687 ,@(if (featurep 'xemacs) '(t)
2688 '(:help "Show next page of article"))]
2689 ["Page backward" gnus-summary-prev-page
2690 ,@(if (featurep 'xemacs) '(t)
2691 '(:help "Show previous page of article"))]
2692 ["Line forward" gnus-summary-scroll-up t])
2693 ("Move"
2694 ["Next unread article" gnus-summary-next-unread-article t]
2695 ["Previous unread article" gnus-summary-prev-unread-article t]
2696 ["Next article" gnus-summary-next-article t]
2697 ["Previous article" gnus-summary-prev-article t]
2698 ["Next unread subject" gnus-summary-next-unread-subject t]
2699 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2700 ["Next article same subject" gnus-summary-next-same-subject t]
2701 ["Previous article same subject" gnus-summary-prev-same-subject t]
2702 ["First unread article" gnus-summary-first-unread-article t]
2703 ["Best unread article" gnus-summary-best-unread-article t]
2704 ["Go to subject number..." gnus-summary-goto-subject t]
2705 ["Go to article number..." gnus-summary-goto-article t]
2706 ["Go to the last article" gnus-summary-goto-last-article t]
2707 ["Pop article off history" gnus-summary-pop-article t])
2708 ("Sort"
2709 ["Sort by number" gnus-summary-sort-by-number t]
6ecfe5c2 2710 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
23f87bed 2711 ["Sort by author" gnus-summary-sort-by-author t]
01c52d31 2712 ["Sort by recipient" gnus-summary-sort-by-recipient t]
23f87bed
MB
2713 ["Sort by subject" gnus-summary-sort-by-subject t]
2714 ["Sort by date" gnus-summary-sort-by-date t]
6ecfe5c2 2715 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
23f87bed
MB
2716 ["Sort by score" gnus-summary-sort-by-score t]
2717 ["Sort by lines" gnus-summary-sort-by-lines t]
2718 ["Sort by characters" gnus-summary-sort-by-chars t]
2719 ["Randomize" gnus-summary-sort-by-random t]
2720 ["Original sort" gnus-summary-sort-by-original t])
2721 ("Help"
2722 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2723 ["Describe group" gnus-summary-describe-group t]
2724 ["Fetch charter" gnus-group-fetch-charter
2725 ,@(if (featurep 'xemacs) nil
2726 '(:help "Display the charter of the current group"))]
2727 ["Fetch control message" gnus-group-fetch-control
2728 ,@(if (featurep 'xemacs) nil
2729 '(:help "Display the archived control message for the current group"))]
2730 ["Read manual" gnus-info-find-node t])
2731 ("Modes"
2732 ["Pick and read" gnus-pick-mode t]
2733 ["Binary" gnus-binary-mode t])
2734 ("Regeneration"
2735 ["Regenerate" gnus-summary-prepare t]
2736 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2737 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
01c52d31 2738 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
23f87bed
MB
2739 ["Toggle threading" gnus-summary-toggle-threads t])
2740 ["See old articles" gnus-summary-insert-old-articles t]
2741 ["See new articles" gnus-summary-insert-new-articles t]
2742 ["Filter articles..." gnus-summary-execute-command t]
2743 ["Run command on articles..." gnus-summary-universal-argument t]
2744 ["Search articles forward..." gnus-summary-search-article-forward t]
2745 ["Search articles backward..." gnus-summary-search-article-backward t]
2746 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2747 ["Expand window" gnus-summary-expand-window t]
2748 ["Expire expirable articles" gnus-summary-expire-articles
2749 (gnus-check-backend-function
2750 'request-expire-articles gnus-newsgroup-name)]
2751 ["Edit local kill file" gnus-summary-edit-local-kill t]
2752 ["Edit main kill file" gnus-summary-edit-global-kill t]
2753 ["Edit group parameters" gnus-summary-edit-parameters t]
2754 ["Customize group parameters" gnus-summary-customize-parameters t]
2755 ["Send a bug report" gnus-bug t]
2756 ("Exit"
2757 ["Catchup and exit" gnus-summary-catchup-and-exit
2758 ,@(if (featurep 'xemacs) '(t)
2759 '(:help "Mark unread articles in this group as read, then exit"))]
2760 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2761 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
01c52d31 2762 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
23f87bed
MB
2763 ["Exit group" gnus-summary-exit
2764 ,@(if (featurep 'xemacs) '(t)
2765 '(:help "Exit current group, return to group selection mode"))]
2766 ["Exit group without updating" gnus-summary-exit-no-update t]
2767 ["Exit and goto next group" gnus-summary-next-group t]
2768 ["Exit and goto prev group" gnus-summary-prev-group t]
2769 ["Reselect group" gnus-summary-reselect-current-group t]
2770 ["Rescan group" gnus-summary-rescan-group t]
2771 ["Update dribble" gnus-summary-save-newsrc t])))
eec82323 2772
6748645f 2773 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323 2774
60bd5589
DL
2775(defvar gnus-summary-tool-bar-map nil)
2776
18c06a99
RS
2777;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2778;; affect _new_ message buffers. We might add a function that walks thru all
2779;; summary-mode buffers and force the update.
2780(defun gnus-summary-tool-bar-update (&optional symbol value)
2781 "Update summary mode toolbar.
2782Setter function for custom variables."
2783 (setq-default gnus-summary-tool-bar-map nil)
2784 (when symbol
2785 ;; When used as ":set" function:
2786 (set-default symbol value))
2787 (when (gnus-buffer-live-p gnus-summary-buffer)
2788 (with-current-buffer gnus-summary-buffer
2789 (gnus-summary-make-tool-bar))))
2790
2791(defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2792 'gnus-summary-tool-bar-gnome
2793 'gnus-summary-tool-bar-retro)
2794 "Specifies the Gnus summary tool bar.
2795
2796It can be either a list or a symbol refering to a list. See
2797`gmm-tool-bar-from-list' for the format of the list. The
2798default key map is `gnus-summary-mode-map'.
2799
2800Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2801`gnus-summary-tool-bar-retro'."
2802 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2803 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2804 (repeat :tag "User defined list" gmm-tool-bar-item)
2805 (symbol))
330f707b 2806 :version "23.1" ;; No Gnus
18c06a99
RS
2807 :initialize 'custom-initialize-default
2808 :set 'gnus-summary-tool-bar-update
2809 :group 'gnus-summary)
2810
2811(defcustom gnus-summary-tool-bar-gnome
2812 '((gnus-summary-post-news "mail/compose" nil)
2813 (gnus-summary-insert-new-articles "mail/inbox" nil
2814 :visible (or (not gnus-agent)
2815 gnus-plugged))
2816 (gnus-summary-reply-with-original "mail/reply")
2817 (gnus-summary-reply "mail/reply" nil :visible nil)
2818 (gnus-summary-followup-with-original "mail/reply-all")
2819 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2820 (gnus-summary-mail-forward "mail/forward")
2821 (gnus-summary-save-article "mail/save")
2822 (gnus-summary-search-article-forward "search" nil :visible nil)
2823 (gnus-summary-print-article "print")
2824 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2825 ;; Some new commands that may need more suitable icons:
2826 (gnus-summary-save-newsrc "save" nil :visible nil)
2827 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2828 (gnus-summary-prev-article "left-arrow")
2829 (gnus-summary-next-article "right-arrow")
2830 (gnus-summary-next-page "next-page")
2831 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2832 ;;
2833 ;; Maybe some sort-by-... could be added:
2834 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2835 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2836 (gnus-summary-mark-as-expirable
2837 "delete" nil
2838 :visible (gnus-check-backend-function 'request-expire-articles
2839 gnus-newsgroup-name))
2840 (gnus-summary-mark-as-spam
2841 "mail/spam" t
2842 :visible (and (fboundp 'spam-group-ham-contents-p)
2843 (spam-group-ham-contents-p gnus-newsgroup-name))
2844 :help "Mark as spam")
2845 (gnus-summary-mark-as-read-forward
2846 "mail/not-spam" nil
2847 :visible (and (fboundp 'spam-group-spam-contents-p)
2848 (spam-group-spam-contents-p gnus-newsgroup-name)))
2849 ;;
2850 (gnus-summary-exit "exit")
2851 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2852 (gnus-info-find-node "help"))
2853 "List of functions for the summary tool bar (GNOME style).
2854
2855See `gmm-tool-bar-from-list' for the format of the list."
2856 :type '(repeat gmm-tool-bar-item)
330f707b 2857 :version "23.1" ;; No Gnus
18c06a99
RS
2858 :initialize 'custom-initialize-default
2859 :set 'gnus-summary-tool-bar-update
2860 :group 'gnus-summary)
2861
2862(defcustom gnus-summary-tool-bar-retro
2863 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2864 (gnus-summary-next-unread-article "gnus/next-ur")
2865 (gnus-summary-post-news "gnus/post")
2866 (gnus-summary-followup-with-original "gnus/fuwo")
2867 (gnus-summary-followup "gnus/followup")
2868 (gnus-summary-reply-with-original "gnus/reply-wo")
2869 (gnus-summary-reply "gnus/reply")
2870 (gnus-summary-caesar-message "gnus/rot13")
2871 (gnus-uu-decode-uu "gnus/uu-decode")
2872 (gnus-summary-save-article-file "gnus/save-aif")
2873 (gnus-summary-save-article "gnus/save-art")
2874 (gnus-uu-post-news "gnus/uu-post")
2875 (gnus-summary-catchup "gnus/catchup")
2876 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2877 (gnus-summary-exit "gnus/exit-summ")
2878 ;; Some new command that may need more suitable icons:
2879 (gnus-summary-print-article "gnus/print" nil :visible nil)
2880 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2881 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2882 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2883 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2884 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2885 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2886 ;;
2887 (gnus-info-find-node "gnus/help" nil :visible nil))
2888 "List of functions for the summary tool bar (retro look).
2889
2890See `gmm-tool-bar-from-list' for the format of the list."
2891 :type '(repeat gmm-tool-bar-item)
330f707b 2892 :version "23.1" ;; No Gnus
18c06a99
RS
2893 :initialize 'custom-initialize-default
2894 :set 'gnus-summary-tool-bar-update
2895 :group 'gnus-summary)
2896
2897(defcustom gnus-summary-tool-bar-zap-list t
2898 "List of icon items from the global tool bar.
2899These items are not displayed in the Gnus summary mode tool bar.
2900
2901See `gmm-tool-bar-from-list' for the format of the list."
2902 :type 'gmm-tool-bar-zap-list
330f707b 2903 :version "23.1" ;; No Gnus
18c06a99
RS
2904 :initialize 'custom-initialize-default
2905 :set 'gnus-summary-tool-bar-update
2906 :group 'gnus-summary)
2907
2908(defvar image-load-path)
f654fa04 2909(defvar tool-bar-map)
18c06a99
RS
2910
2911(defun gnus-summary-make-tool-bar (&optional force)
2912 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2913When FORCE, rebuild the tool bar."
2914 (when (and (not (featurep 'xemacs))
2915 (boundp 'tool-bar-mode)
2916 tool-bar-mode
2917 (or (not gnus-summary-tool-bar-map) force))
2918 (let* ((load-path
2919 (gmm-image-load-path-for-library "gnus"
2920 "mail/save.xpm"
2921 nil t))
2922 (image-load-path (cons (car load-path)
2923 (when (boundp 'image-load-path)
2924 image-load-path)))
2925 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2926 gnus-summary-tool-bar-zap-list
2927 'gnus-summary-mode-map)))
2928 (when map
2929 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2930 ;; uses it's value.
2931 (setq gnus-summary-tool-bar-map map))))
2932 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
60bd5589 2933
eec82323
LMI
2934(defun gnus-score-set-default (var value)
2935 "A version of set that updates the GNU Emacs menu-bar."
2936 (set var value)
2937 ;; It is the message that forces the active status to be updated.
2938 (message ""))
2939
2940(defun gnus-make-score-map (type)
2941 "Make a summary score map of type TYPE."
2942 (if t
2943 nil
2944 (let ((headers '(("author" "from" string)
2945 ("subject" "subject" string)
2946 ("article body" "body" string)
2947 ("article head" "head" string)
2948 ("xref" "xref" string)
16409b0b 2949 ("extra header" "extra" string)
eec82323
LMI
2950 ("lines" "lines" number)
2951 ("followups to author" "followup" string)))
2952 (types '((number ("less than" <)
2953 ("greater than" >)
2954 ("equal" =))
2955 (string ("substring" s)
2956 ("exact string" e)
2957 ("fuzzy string" f)
2958 ("regexp" r))))
2959 (perms '(("temporary" (current-time-string))
2960 ("permanent" nil)
2961 ("immediate" now)))
2962 header)
2963 (list
2964 (apply
2965 'nconc
2966 (list
2967 (if (eq type 'lower)
2968 "Lower score"
2969 "Increase score"))
2970 (let (outh)
2971 (while headers
2972 (setq header (car headers))
2973 (setq outh
2974 (cons
2975 (apply
2976 'nconc
2977 (list (car header))
2978 (let ((ts (cdr (assoc (nth 2 header) types)))
2979 outt)
2980 (while ts
2981 (setq outt
2982 (cons
2983 (apply
2984 'nconc
2985 (list (caar ts))
2986 (let ((ps perms)
2987 outp)
2988 (while ps
2989 (setq outp
2990 (cons
2991 (vector
2992 (caar ps)
2993 (list
2994 'gnus-summary-score-entry
2995 (nth 1 header)
2996 (if (or (string= (nth 1 header)
2997 "head")
2998 (string= (nth 1 header)
2999 "body"))
3000 ""
3001 (list 'gnus-summary-header
3002 (nth 1 header)))
3003 (list 'quote (nth 1 (car ts)))
16409b0b
GM
3004 (list 'gnus-score-delta-default
3005 nil)
eec82323
LMI
3006 (nth 1 (car ps))
3007 t)
3008 t)
3009 outp))
3010 (setq ps (cdr ps)))
3011 (list (nreverse outp))))
3012 outt))
3013 (setq ts (cdr ts)))
3014 (list (nreverse outt))))
3015 outh))
3016 (setq headers (cdr headers)))
3017 (list (nreverse outh))))))))
3018
704f1663
GM
3019
3020(declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
398a825b 3021(defvar bookmark-make-record-function)
eec82323
LMI
3022\f
3023
3024(defun gnus-summary-mode (&optional group)
3025 "Major mode for reading articles.
3026
3027All normal editing commands are switched off.
3028\\<gnus-summary-mode-map>
3029Each line in this buffer represents one article. To read an
3030article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3031and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3032respectively.
3033
3034You can also post articles and send mail from this buffer. To
23f87bed 3035follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
eec82323
LMI
3036of an article, type `\\[gnus-summary-reply]'.
3037
3038There are approx. one gazillion commands you can execute in this
3039buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3040
3041The following commands are available:
3042
3043\\{gnus-summary-mode-map}"
3044 (interactive)
eec82323 3045 (kill-all-local-variables)
01c52d31
MB
3046 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3047 (gnus-summary-make-local-variables))
3048 (gnus-summary-make-local-variables)
3049 (setq gnus-newsgroup-name group)
60bd5589
DL
3050 (when (gnus-visual-p 'summary-menu 'menu)
3051 (gnus-summary-make-menu-bar)
3052 (gnus-summary-make-tool-bar))
eec82323
LMI
3053 (gnus-make-thread-indent-array)
3054 (gnus-simplify-mode-line)
3055 (setq major-mode 'gnus-summary-mode)
3056 (setq mode-name "Summary")
eec82323 3057 (use-local-map gnus-summary-mode-map)
16409b0b 3058 (buffer-disable-undo)
01c52d31
MB
3059 (setq buffer-read-only t ;Disable modification
3060 show-trailing-whitespace nil)
eec82323 3061 (setq truncate-lines t)
9bfd9a76 3062 (add-to-invisibility-spec '(gnus-sum . t))
eec82323
LMI
3063 (gnus-summary-set-display-table)
3064 (gnus-set-default-directory)
eec82323
LMI
3065 (make-local-variable 'gnus-summary-line-format)
3066 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
3067 (make-local-variable 'gnus-summary-dummy-line-format)
3068 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323 3069 (make-local-variable 'gnus-summary-mark-positions)
23f87bed 3070 (gnus-make-local-hook 'pre-command-hook)
6748645f 3071 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
cfcd5c91 3072 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
23f87bed 3073 (turn-on-gnus-mailing-list-mode)
87545352 3074 (mm-enable-multibyte)
45be326a
TV
3075 (set (make-local-variable 'bookmark-make-record-function)
3076 'gnus-summary-bookmark-make-record)
eec82323
LMI
3077 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3078 (gnus-update-summary-mark-positions))
3079
3080(defun gnus-summary-make-local-variables ()
3081 "Make all the local summary buffer variables."
16409b0b
GM
3082 (let (global)
3083 (dolist (local gnus-summary-local-variables)
eec82323
LMI
3084 (if (consp local)
3085 (progn
3086 (if (eq (cdr local) 'global)
3087 ;; Copy the global value of the variable.
3088 (setq global (symbol-value (car local)))
3089 ;; Use the value from the list.
3090 (setq global (eval (cdr local))))
16409b0b 3091 (set (make-local-variable (car local)) global))
eec82323 3092 ;; Simple nil-valued local variable.
16409b0b 3093 (set (make-local-variable local) nil)))))
eec82323
LMI
3094
3095(defun gnus-summary-clear-local-variables ()
3096 (let ((locals gnus-summary-local-variables))
3097 (while locals
3098 (if (consp (car locals))
01c52d31 3099 (and (symbolp (caar locals))
eec82323 3100 (set (caar locals) nil))
01c52d31 3101 (and (symbolp (car locals))
eec82323
LMI
3102 (set (car locals) nil)))
3103 (setq locals (cdr locals)))))
3104
3105;; Summary data functions.
3106
3107(defmacro gnus-data-number (data)
3108 `(car ,data))
3109
3110(defmacro gnus-data-set-number (data number)
3111 `(setcar ,data ,number))
3112
3113(defmacro gnus-data-mark (data)
3114 `(nth 1 ,data))
3115
3116(defmacro gnus-data-set-mark (data mark)
3117 `(setcar (nthcdr 1 ,data) ,mark))
3118
3119(defmacro gnus-data-pos (data)
3120 `(nth 2 ,data))
3121
3122(defmacro gnus-data-set-pos (data pos)
3123 `(setcar (nthcdr 2 ,data) ,pos))
3124
3125(defmacro gnus-data-header (data)
3126 `(nth 3 ,data))
3127
3128(defmacro gnus-data-set-header (data header)
3129 `(setf (nth 3 ,data) ,header))
3130
3131(defmacro gnus-data-level (data)
3132 `(nth 4 ,data))
3133
3134(defmacro gnus-data-unread-p (data)
3135 `(= (nth 1 ,data) gnus-unread-mark))
3136
3137(defmacro gnus-data-read-p (data)
3138 `(/= (nth 1 ,data) gnus-unread-mark))
3139
3140(defmacro gnus-data-pseudo-p (data)
3141 `(consp (nth 3 ,data)))
3142
3143(defmacro gnus-data-find (number)
3144 `(assq ,number gnus-newsgroup-data))
3145
3146(defmacro gnus-data-find-list (number &optional data)
3147 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3148 (memq (assq ,number bdata)
3149 bdata)))
3150
3151(defmacro gnus-data-make (number mark pos header level)
3152 `(list ,number ,mark ,pos ,header ,level))
3153
3154(defun gnus-data-enter (after-article number mark pos header level offset)
3155 (let ((data (gnus-data-find-list after-article)))
3156 (unless data
3157 (error "No such article: %d" after-article))
3158 (setcdr data (cons (gnus-data-make number mark pos header level)
3159 (cdr data)))
3160 (setq gnus-newsgroup-data-reverse nil)
3161 (gnus-data-update-list (cddr data) offset)))
3162
3163(defun gnus-data-enter-list (after-article list &optional offset)
3164 (when list
3165 (let ((data (and after-article (gnus-data-find-list after-article)))
3166 (ilist list))
6748645f
LMI
3167 (if (not (or data
3168 after-article))
3169 (let ((odata gnus-newsgroup-data))
3170 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 3171 (when offset
6748645f 3172 (gnus-data-update-list odata offset)))
01c52d31 3173 ;; Find the last element in the list to be spliced into the main
6748645f 3174 ;; list.
01c52d31 3175 (setq list (last list))
6748645f
LMI
3176 (if (not data)
3177 (progn
3178 (setcdr list gnus-newsgroup-data)
3179 (setq gnus-newsgroup-data ilist)
3180 (when offset
3181 (gnus-data-update-list (cdr list) offset)))
3182 (setcdr list (cdr data))
3183 (setcdr data ilist)
3184 (when offset
3185 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
3186 (setq gnus-newsgroup-data-reverse nil))))
3187
3188(defun gnus-data-remove (article &optional offset)
3189 (let ((data gnus-newsgroup-data))
3190 (if (= (gnus-data-number (car data)) article)
3191 (progn
3192 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3193 gnus-newsgroup-data-reverse nil)
3194 (when offset
3195 (gnus-data-update-list gnus-newsgroup-data offset)))
3196 (while (cdr data)
3197 (when (= (gnus-data-number (cadr data)) article)
3198 (setcdr data (cddr data))
3199 (when offset
3200 (gnus-data-update-list (cdr data) offset))
3201 (setq data nil
3202 gnus-newsgroup-data-reverse nil))
3203 (setq data (cdr data))))))
3204
3205(defmacro gnus-data-list (backward)
3206 `(if ,backward
3207 (or gnus-newsgroup-data-reverse
3208 (setq gnus-newsgroup-data-reverse
3209 (reverse gnus-newsgroup-data)))
3210 gnus-newsgroup-data))
3211
3212(defun gnus-data-update-list (data offset)
3213 "Add OFFSET to the POS of all data entries in DATA."
6748645f 3214 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
3215 (while data
3216 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3217 (setq data (cdr data))))
3218
eec82323
LMI
3219(defun gnus-summary-article-pseudo-p (article)
3220 "Say whether this article is a pseudo article or not."
3221 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3222
3223(defmacro gnus-summary-article-sparse-p (article)
3224 "Say whether this article is a sparse article or not."
a8151ef7 3225 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
3226
3227(defmacro gnus-summary-article-ancient-p (article)
3228 "Say whether this article is a sparse article or not."
3229 `(memq ,article gnus-newsgroup-ancient))
3230
3231(defun gnus-article-parent-p (number)
3232 "Say whether this article is a parent or not."
3233 (let ((data (gnus-data-find-list number)))
23f87bed 3234 (and (cdr data) ; There has to be an article after...
eec82323
LMI
3235 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3236 (gnus-data-level (nth 1 data))))))
3237
3238(defun gnus-article-children (number)
3239 "Return a list of all children to NUMBER."
3240 (let* ((data (gnus-data-find-list number))
3241 (level (gnus-data-level (car data)))
3242 children)
3243 (setq data (cdr data))
3244 (while (and data
3245 (= (gnus-data-level (car data)) (1+ level)))
3246 (push (gnus-data-number (car data)) children)
3247 (setq data (cdr data)))
3248 children))
3249
3250(defmacro gnus-summary-skip-intangible ()
3251 "If the current article is intangible, then jump to a different article."
3252 '(let ((to (get-text-property (point) 'gnus-intangible)))
3253 (and to (gnus-summary-goto-subject to))))
3254
3255(defmacro gnus-summary-article-intangible-p ()
3256 "Say whether this article is intangible or not."
3257 '(get-text-property (point) 'gnus-intangible))
3258
3259(defun gnus-article-read-p (article)
3260 "Say whether ARTICLE is read or not."
3261 (not (or (memq article gnus-newsgroup-marked)
23f87bed 3262 (memq article gnus-newsgroup-spam-marked)
eec82323
LMI
3263 (memq article gnus-newsgroup-unreads)
3264 (memq article gnus-newsgroup-unselected)
3265 (memq article gnus-newsgroup-dormant))))
3266
3267;; Some summary mode macros.
3268
3269(defmacro gnus-summary-article-number ()
3270 "The article number of the article on the current line.
8f688cb0 3271If there isn't an article number here, then we return the current
eec82323
LMI
3272article number."
3273 '(progn
3274 (gnus-summary-skip-intangible)
3275 (or (get-text-property (point) 'gnus-number)
3276 (gnus-summary-last-subject))))
3277
3278(defmacro gnus-summary-article-header (&optional number)
6748645f 3279 "Return the header of article NUMBER."
eec82323
LMI
3280 `(gnus-data-header (gnus-data-find
3281 ,(or number '(gnus-summary-article-number)))))
3282
3283(defmacro gnus-summary-thread-level (&optional number)
6748645f 3284 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
3285 `(if (and (eq gnus-summary-make-false-root 'dummy)
3286 (get-text-property (point) 'gnus-intangible))
3287 0
3288 (gnus-data-level (gnus-data-find
3289 ,(or number '(gnus-summary-article-number))))))
3290
3291(defmacro gnus-summary-article-mark (&optional number)
6748645f 3292 "Return the mark of article NUMBER."
eec82323
LMI
3293 `(gnus-data-mark (gnus-data-find
3294 ,(or number '(gnus-summary-article-number)))))
3295
3296(defmacro gnus-summary-article-pos (&optional number)
6748645f 3297 "Return the position of the line of article NUMBER."
eec82323
LMI
3298 `(gnus-data-pos (gnus-data-find
3299 ,(or number '(gnus-summary-article-number)))))
3300
3301(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3302(defmacro gnus-summary-article-subject (&optional number)
3303 "Return current subject string or nil if nothing."
3304 `(let ((headers
3305 ,(if number
3306 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3307 '(gnus-data-header (assq (gnus-summary-article-number)
3308 gnus-newsgroup-data)))))
3309 (and headers
3310 (vectorp headers)
3311 (mail-header-subject headers))))
3312
3313(defmacro gnus-summary-article-score (&optional number)
3314 "Return current article score."
3315 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3316 gnus-newsgroup-scored))
3317 gnus-summary-default-score 0))
3318
3319(defun gnus-summary-article-children (&optional number)
6748645f 3320 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
3321 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3322 (level (gnus-data-level (car data)))
3323 l children)
3324 (while (and (setq data (cdr data))
3325 (> (setq l (gnus-data-level (car data))) level))
3326 (and (= (1+ level) l)
3327 (push (gnus-data-number (car data))
3328 children)))
3329 (nreverse children)))
3330
3331(defun gnus-summary-article-parent (&optional number)
6748645f 3332 "Return the article number of the parent of article NUMBER."
eec82323
LMI
3333 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3334 (gnus-data-list t)))
3335 (level (gnus-data-level (car data))))
3336 (if (zerop level)
3337 () ; This is a root.
3338 ;; We search until we find an article with a level less than
3339 ;; this one. That function has to be the parent.
3340 (while (and (setq data (cdr data))
3341 (not (< (gnus-data-level (car data)) level))))
3342 (and data (gnus-data-number (car data))))))
3343
3344(defun gnus-unread-mark-p (mark)
3345 "Say whether MARK is the unread mark."
3346 (= mark gnus-unread-mark))
3347
3348(defun gnus-read-mark-p (mark)
3349 "Say whether MARK is one of the marks that mark as read.
3350This is all marks except unread, ticked, dormant, and expirable."
3351 (not (or (= mark gnus-unread-mark)
3352 (= mark gnus-ticked-mark)
23f87bed 3353 (= mark gnus-spam-mark)
eec82323
LMI
3354 (= mark gnus-dormant-mark)
3355 (= mark gnus-expirable-mark))))
3356
3357(defmacro gnus-article-mark (number)
6748645f
LMI
3358 "Return the MARK of article NUMBER.
3359This macro should only be used when computing the mark the \"first\"
3360time; i.e., when generating the summary lines. After that,
3361`gnus-summary-article-mark' should be used to examine the
3362marks of articles."
eec82323 3363 `(cond
6748645f 3364 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
6748645f 3365 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
3366 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3367 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
23f87bed 3368 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
eec82323
LMI
3369 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3370 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3371 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3372 gnus-ancient-mark))))
3373
3374;; Saving hidden threads.
3375
eec82323
LMI
3376(defmacro gnus-save-hidden-threads (&rest forms)
3377 "Save hidden threads, eval FORMS, and restore the hidden threads."
3378 (let ((config (make-symbol "config")))
3379 `(let ((,config (gnus-hidden-threads-configuration)))
3380 (unwind-protect
3381 (save-excursion
3382 ,@forms)
3383 (gnus-restore-hidden-threads-configuration ,config)))))
23f87bed
MB
3384(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3385(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
eec82323 3386
107ecebb
AS
3387(defun gnus-data-compute-positions ()
3388 "Compute the positions of all articles."
3389 (setq gnus-newsgroup-data-reverse nil)
3390 (let ((data gnus-newsgroup-data))
3391 (save-excursion
3392 (gnus-save-hidden-threads
3393 (gnus-summary-show-all-threads)
3394 (goto-char (point-min))
3395 (while data
3396 (while (get-text-property (point) 'gnus-intangible)
3397 (forward-line 1))
3398 (gnus-data-set-pos (car data) (+ (point) 3))
3399 (setq data (cdr data))
3400 (forward-line 1))))))
3401
16409b0b
GM
3402(defun gnus-hidden-threads-configuration ()
3403 "Return the current hidden threads configuration."
3404 (save-excursion
3405 (let (config)
3406 (goto-char (point-min))
62a83cc8
KY
3407 (while (not (eobp))
3408 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3409 (push (save-excursion (forward-line 0) (point)) config))
3410 (forward-line 1))
16409b0b
GM
3411 config)))
3412
3413(defun gnus-restore-hidden-threads-configuration (config)
3414 "Restore hidden threads configuration from CONFIG."
3415 (save-excursion
c7a91ce1 3416 (let (point (inhibit-read-only t))
16409b0b 3417 (while (setq point (pop config))
62a83cc8
KY
3418 (goto-char point)
3419 (gnus-summary-hide-thread)))))
16409b0b 3420
eec82323
LMI
3421;; Various summary mode internalish functions.
3422
3423(defun gnus-mouse-pick-article (e)
3424 (interactive "e")
3425 (mouse-set-point e)
3426 (gnus-summary-next-page nil t))
3427
3428(defun gnus-summary-set-display-table ()
16409b0b
GM
3429 "Change the display table.
3430Odd characters have a tendency to mess
3431up nicely formatted displays - we make all possible glyphs
3432display only a single character."
eec82323
LMI
3433
3434 ;; We start from the standard display table, if any.
3435 (let ((table (or (copy-sequence standard-display-table)
3436 (make-display-table)))
3437 (i 32))
3438 ;; Nix out all the control chars...
3439 (while (>= (setq i (1- i)) 0)
2b968687 3440 (gnus-put-display-table i [??] table))
23f87bed 3441 ;; ... but not newline and cr, of course. (cr is necessary for the
eec82323 3442 ;; selective display).
2b968687
MB
3443 (gnus-put-display-table ?\n nil table)
3444 (gnus-put-display-table ?\r nil table)
6748645f 3445 ;; We keep TAB as well.
2b968687 3446 (gnus-put-display-table ?\t nil table)
719120ef 3447 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
fe62aacc 3448 ;; Emacs 23 (unicode), that are not set already.
719120ef
MB
3449 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3450 160
3451 256)))
eec82323
LMI
3452 (while (>= (setq i (1- i)) 127)
3453 ;; Only modify if the entry is nil.
2b968687
MB
3454 (unless (gnus-get-display-table i table)
3455 (gnus-put-display-table i [??] table))))
eec82323
LMI
3456 (setq buffer-display-table table)))
3457
23f87bed
MB
3458(defun gnus-summary-set-article-display-arrow (pos)
3459 "Update the overlay arrow to point to line at position POS."
e3e955fe
MB
3460 (when gnus-summary-display-arrow
3461 (make-local-variable 'overlay-arrow-position)
3462 (make-local-variable 'overlay-arrow-string)
23f87bed
MB
3463 (save-excursion
3464 (goto-char pos)
3465 (beginning-of-line)
3466 (unless overlay-arrow-position
3467 (setq overlay-arrow-position (make-marker)))
3468 (setq overlay-arrow-string "=>"
3469 overlay-arrow-position (set-marker overlay-arrow-position
3470 (point)
3471 (current-buffer))))))
3472
eec82323
LMI
3473(defun gnus-summary-setup-buffer (group)
3474 "Initialize summary buffer."
23f87bed
MB
3475 (let ((buffer (gnus-summary-buffer-name group))
3476 (dead-name (concat "*Dead Summary "
3477 (gnus-group-decoded-name group) "*")))
3478 ;; If a dead summary buffer exists, we kill it.
3479 (when (gnus-buffer-live-p dead-name)
3480 (gnus-kill-buffer dead-name))
eec82323
LMI
3481 (if (get-buffer buffer)
3482 (progn
3483 (set-buffer buffer)
3484 (setq gnus-summary-buffer (current-buffer))
3485 (not gnus-newsgroup-prepared))
3486 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 3487 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323
LMI
3488 (gnus-summary-mode group)
3489 (when gnus-carpal
3490 (gnus-carpal-setup-buffer 'summary))
01c52d31
MB
3491 (when (gnus-group-quit-config group)
3492 (set (make-local-variable 'gnus-single-article-buffer) nil))
3493 (make-local-variable 'gnus-article-buffer)
3494 (make-local-variable 'gnus-article-current)
3495 (make-local-variable 'gnus-original-article-buffer)
eec82323 3496 (setq gnus-newsgroup-name group)
23f87bed
MB
3497 ;; Set any local variables in the group parameters.
3498 (gnus-summary-set-local-parameters gnus-newsgroup-name)
eec82323
LMI
3499 t)))
3500
3501(defun gnus-set-global-variables ()
16409b0b
GM
3502 "Set the global equivalents of the buffer-local variables.
3503They are set to the latest values they had. These reflect the summary
3504buffer that was in action when the last article was fetched."
eec82323
LMI
3505 (when (eq major-mode 'gnus-summary-mode)
3506 (setq gnus-summary-buffer (current-buffer))
3507 (let ((name gnus-newsgroup-name)
3508 (marked gnus-newsgroup-marked)
23f87bed 3509 (spam gnus-newsgroup-spam-marked)
eec82323
LMI
3510 (unread gnus-newsgroup-unreads)
3511 (headers gnus-current-headers)
3512 (data gnus-newsgroup-data)
3513 (summary gnus-summary-buffer)
3514 (article-buffer gnus-article-buffer)
3515 (original gnus-original-article-buffer)
3516 (gac gnus-article-current)
3517 (reffed gnus-reffed-article-number)
16409b0b 3518 (score-file gnus-current-score-file)
23f87bed
MB
3519 (default-charset gnus-newsgroup-charset)
3520 vlist)
3521 (let ((locals gnus-newsgroup-variables))
3522 (while locals
3523 (if (consp (car locals))
3524 (push (eval (caar locals)) vlist)
3525 (push (eval (car locals)) vlist))
3526 (setq locals (cdr locals)))
3527 (setq vlist (nreverse vlist)))
01c52d31 3528 (with-current-buffer gnus-group-buffer
6748645f
LMI
3529 (setq gnus-newsgroup-name name
3530 gnus-newsgroup-marked marked
23f87bed 3531 gnus-newsgroup-spam-marked spam
6748645f
LMI
3532 gnus-newsgroup-unreads unread
3533 gnus-current-headers headers
3534 gnus-newsgroup-data data
3535 gnus-article-current gac
3536 gnus-summary-buffer summary
3537 gnus-article-buffer article-buffer
3538 gnus-original-article-buffer original
3539 gnus-reffed-article-number reffed
16409b0b
GM
3540 gnus-current-score-file score-file
3541 gnus-newsgroup-charset default-charset)
23f87bed
MB
3542 (let ((locals gnus-newsgroup-variables))
3543 (while locals
3544 (if (consp (car locals))
3545 (set (caar locals) (pop vlist))
3546 (set (car locals) (pop vlist)))
3547 (setq locals (cdr locals))))
eec82323
LMI
3548 ;; The article buffer also has local variables.
3549 (when (gnus-buffer-live-p gnus-article-buffer)
3550 (set-buffer gnus-article-buffer)
3551 (setq gnus-summary-buffer summary))))))
3552
3553(defun gnus-summary-article-unread-p (article)
3554 "Say whether ARTICLE is unread or not."
3555 (memq article gnus-newsgroup-unreads))
3556
3557(defun gnus-summary-first-article-p (&optional article)
3558 "Return whether ARTICLE is the first article in the buffer."
3559 (if (not (setq article (or article (gnus-summary-article-number))))
3560 nil
3561 (eq article (caar gnus-newsgroup-data))))
3562
3563(defun gnus-summary-last-article-p (&optional article)
3564 "Return whether ARTICLE is the last article in the buffer."
3565 (if (not (setq article (or article (gnus-summary-article-number))))
16409b0b
GM
3566 ;; All non-existent numbers are the last article. :-)
3567 t
eec82323
LMI
3568 (not (cdr (gnus-data-find-list article)))))
3569
4921bbdd
CY
3570(defun gnus-make-thread-indent-array (&optional n)
3571 (when (or n
3572 (progn (setq n 200) nil)
3573 (null gnus-thread-indent-array)
3574 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3575 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3576 gnus-thread-indent-array-level gnus-thread-indent-level)
3577 (while (>= n 0)
3578 (aset gnus-thread-indent-array n
6a30c01d 3579 (make-string (* n gnus-thread-indent-level) ? ))
4921bbdd 3580 (setq n (1- n)))))
eec82323
LMI
3581
3582(defun gnus-update-summary-mark-positions ()
3583 "Compute where the summary marks are to go."
3584 (save-excursion
6748645f 3585 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3586 (set-buffer gnus-summary-buffer))
5153a47a
MB
3587 (let ((spec gnus-summary-line-format-spec)
3588 pos)
eec82323
LMI
3589 (save-excursion
3590 (gnus-set-work-buffer)
5153a47a
MB
3591 (let ((gnus-tmp-unread ?Z)
3592 (gnus-replied-mark ?Z)
3593 (gnus-score-below-mark ?Z)
3594 (gnus-score-over-mark ?Z)
3595 (gnus-undownloaded-mark ?Z)
3596 (gnus-summary-line-format-spec spec)
54506618 3597 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3598 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3599 case-fold-search ignores)
3600 ;; Here, all marks are bound to Z.
3601 (gnus-summary-insert-line header
3602 0 nil t gnus-tmp-unread t nil "" nil 1)
3603 (goto-char (point-min))
3604 ;; Memorize the positions of the same characters as dummy marks.
3605 (while (re-search-forward "[A-D]" nil t)
3606 (push (point) ignores))
54506618 3607 (erase-buffer)
5153a47a
MB
3608 ;; We use A-D as dummy marks in order to know column positions
3609 ;; where marks should be inserted.
3610 (setq gnus-tmp-unread ?A
3611 gnus-replied-mark ?B
3612 gnus-score-below-mark ?C
3613 gnus-score-over-mark ?C
3614 gnus-undownloaded-mark ?D)
3615 (gnus-summary-insert-line header
3616 0 nil t gnus-tmp-unread t nil "" nil 1)
3617 ;; Ignore characters which aren't dummy marks.
3618 (dolist (p ignores)
3619 (delete-region (goto-char (1- p)) p)
3620 (insert ?Z))
eec82323 3621 (goto-char (point-min))
7c3bb5a5 3622 (setq pos (list (cons 'unread
5153a47a 3623 (and (search-forward "A" nil t)
7c3bb5a5 3624 (- (point) (point-min) 1)))))
eec82323 3625 (goto-char (point-min))
5153a47a 3626 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3627 (- (point) (point-min) 1)))
eec82323
LMI
3628 pos)
3629 (goto-char (point-min))
5153a47a 3630 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3631 (- (point) (point-min) 1)))
6748645f
LMI
3632 pos)
3633 (goto-char (point-min))
5153a47a 3634 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3635 (- (point) (point-min) 1)))
eec82323
LMI
3636 pos)))
3637 (setq gnus-summary-mark-positions pos))))
3638
3639(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3640 "Insert a dummy root in the summary buffer."
3641 (beginning-of-line)
3642 (gnus-add-text-properties
3643 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3644 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3645
23f87bed
MB
3646(defun gnus-summary-extract-address-component (from)
3647 (or (car (funcall gnus-extract-address-components from))
3648 from))
3649
3650(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3651 (let ((mail-parse-charset gnus-newsgroup-charset)
01c52d31 3652 (ignored-from-addresses (gnus-ignored-from-addresses))
23f87bed
MB
3653 ; Is it really necessary to do this next part for each summary line?
3654 ; Luckily, doesn't seem to slow things down much.
16409b0b 3655 (mail-parse-ignored-charsets
01c52d31
MB
3656 (with-current-buffer gnus-summary-buffer
3657 gnus-newsgroup-ignored-charsets)))
23f87bed 3658 (or
01c52d31
MB
3659 (and ignored-from-addresses
3660 (string-match ignored-from-addresses gnus-tmp-from)
23f87bed
MB
3661 (let ((extra-headers (mail-header-extra header))
3662 to
3663 newsgroups)
3664 (cond
3665 ((setq to (cdr (assq 'To extra-headers)))
01c52d31 3666 (concat gnus-summary-to-prefix
23f87bed
MB
3667 (inline
3668 (gnus-summary-extract-address-component
343d6628 3669 (funcall gnus-decode-encoded-address-function to)))))
01c52d31
MB
3670 ((setq newsgroups
3671 (or
3672 (cdr (assq 'Newsgroups extra-headers))
3673 (and
3674 (memq 'Newsgroups gnus-extra-headers)
3675 (eq (car (gnus-find-method-for-group
3676 gnus-newsgroup-name)) 'nntp)
3677 (gnus-group-real-name gnus-newsgroup-name))))
3678 (concat gnus-summary-newsgroup-prefix newsgroups)))))
23f87bed 3679 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3680
eec82323
LMI
3681(defun gnus-summary-insert-line (gnus-tmp-header
3682 gnus-tmp-level gnus-tmp-current
23f87bed 3683 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3684 gnus-tmp-expirable gnus-tmp-subject-or-nil
3685 &optional gnus-tmp-dummy gnus-tmp-score
3686 gnus-tmp-process)
4921bbdd
CY
3687 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3688 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3689 gnus-tmp-level)))
eec82323
LMI
3690 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3691 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3692 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3693 (gnus-tmp-score-char
3694 (if (or (null gnus-summary-default-score)
3695 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3696 gnus-summary-zcore-fuzz))
23f87bed 3697 ? ;Whitespace
eec82323
LMI
3698 (if (< gnus-tmp-score gnus-summary-default-score)
3699 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3700 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3701 (gnus-tmp-replied
3702 (cond (gnus-tmp-process gnus-process-mark)
3703 ((memq gnus-tmp-current gnus-newsgroup-cached)
3704 gnus-cached-mark)
3705 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3706 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3707 gnus-forwarded-mark)
eec82323
LMI
3708 ((memq gnus-tmp-current gnus-newsgroup-saved)
3709 gnus-saved-mark)
23f87bed
MB
3710 ((memq gnus-tmp-number gnus-newsgroup-recent)
3711 gnus-recent-mark)
3712 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3713 gnus-unseen-mark)
3714 (t gnus-no-mark)))
3715 (gnus-tmp-downloaded
3716 (cond (undownloaded
3717 gnus-undownloaded-mark)
3718 (gnus-newsgroup-agentized
3719 gnus-downloaded-mark)
3720 (t
3721 gnus-no-mark)))
eec82323
LMI
3722 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3723 (gnus-tmp-name
3724 (cond
3725 ((string-match "<[^>]+> *$" gnus-tmp-from)
3726 (let ((beg (match-beginning 0)))
23f87bed
MB
3727 (or (and (string-match "^\".+\"" gnus-tmp-from)
3728 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3729 (substring gnus-tmp-from 0 beg))))
3730 ((string-match "(.+)" gnus-tmp-from)
3731 (substring gnus-tmp-from
3732 (1+ (match-beginning 0)) (1- (match-end 0))))
3733 (t gnus-tmp-from)))
3734 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3735 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3736 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
c7a91ce1 3737 (inhibit-read-only t))
eec82323
LMI
3738 (when (string= gnus-tmp-name "")
3739 (setq gnus-tmp-name gnus-tmp-from))
3740 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3741 (setq gnus-tmp-lines -1))
3742 (if (= gnus-tmp-lines -1)
3743 (setq gnus-tmp-lines "?")
3744 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
64763fe3
MB
3745 (condition-case ()
3746 (gnus-put-text-property
3747 (point)
3748 (progn (eval gnus-summary-line-format-spec) (point))
3749 'gnus-number gnus-tmp-number)
3750 (error (gnus-message 5 "Error updating the summary line")))
eec82323
LMI
3751 (when (gnus-visual-p 'summary-highlight 'highlight)
3752 (forward-line -1)
6748645f 3753 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3754 (forward-line 1))))
3755
3756(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3757 "Update summary line after change."
eec82323
LMI
3758 (when (and gnus-summary-default-score
3759 (not gnus-summary-inhibit-highlight))
3760 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3761 (article (gnus-summary-article-number))
3762 (score (gnus-summary-article-score article)))
3763 (unless dont-update
3764 (if (and gnus-summary-mark-below
3765 (< (gnus-summary-article-score)
3766 gnus-summary-mark-below))
3767 ;; This article has a low score, so we mark it as read.
3768 (when (memq article gnus-newsgroup-unreads)
3769 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3770 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3771 ;; This article was previously marked as read on account
3772 ;; of a low score, but now it has risen, so we mark it as
3773 ;; unread.
3774 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3775 (gnus-summary-update-mark
3776 (if (or (null gnus-summary-default-score)
3777 (<= (abs (- score gnus-summary-default-score))
3778 gnus-summary-zcore-fuzz))
23f87bed 3779 ? ;Whitespace
eec82323
LMI
3780 (if (< score gnus-summary-default-score)
3781 gnus-score-below-mark gnus-score-over-mark))
3782 'score))
3783 ;; Do visual highlighting.
3784 (when (gnus-visual-p 'summary-highlight 'highlight)
6748645f 3785 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3786
3787(defvar gnus-tmp-new-adopts nil)
3788
3789(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3790 "Return the number of articles in THREAD.
3791This may be 0 in some cases -- if none of the articles in
3792the thread are to be displayed."
3793 (let* ((number
23f87bed 3794 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3795 (cond
3796 ((not (listp thread))
3797 1)
3798 ((and (consp thread) (cdr thread))
3799 (apply
3800 '+ 1 (mapcar
3801 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3802 ((null thread)
3803 1)
3804 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3805 1)
3806 (t 0))))
3807 (when (and level (zerop level) gnus-tmp-new-adopts)
3808 (incf number
3809 (apply '+ (mapcar
3810 'gnus-summary-number-of-articles-in-thread
3811 gnus-tmp-new-adopts))))
3812 (if char
3813 (if (> number 1) gnus-not-empty-thread-mark
3814 gnus-empty-thread-mark)
3815 number)))
3816
23f87bed
MB
3817(defsubst gnus-summary-line-message-size (head)
3818 "Return pretty-printed version of message size.
3819This function is intended to be used in
3820`gnus-summary-line-format-alist'."
3821 (let ((c (or (mail-header-chars head) -1)))
3822 (cond ((< c 0) "n/a") ; chars not available
3823 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3824 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3825 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3826 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3827
3828
eec82323
LMI
3829(defun gnus-summary-set-local-parameters (group)
3830 "Go through the local params of GROUP and set all variable specs in that list."
01c52d31
MB
3831 (let ((vars '(quit-config))) ; Ignore quit-config.
3832 (dolist (elem (gnus-group-find-parameter group))
eec82323
LMI
3833 (and (consp elem) ; Has to be a cons.
3834 (consp (cdr elem)) ; The cdr has to be a list.
3835 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3836 (not (memq (car elem) vars))
e3e955fe 3837 (ignore-errors
23f87bed 3838 (push (car elem) vars)
e3e955fe
MB
3839 ;; Variables like `gnus-show-threads' that are globally
3840 ;; bound, if used as group parameters, need to get to be
3841 ;; buffer-local, whereas just parameters like `gcc-self',
3842 ;; `timestamp', etc. should not be bound as variables.
3843 (if (boundp (car elem))
3844 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3845 (eval (nth 1 elem))))))))
eec82323
LMI
3846
3847(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3848 kill-buffer no-display backward
3849 select-articles)
eec82323
LMI
3850 "Start reading news in newsgroup GROUP.
3851If SHOW-ALL is non-nil, already read articles are also listed.
3852If NO-ARTICLE is non-nil, no article is selected initially.
3853If NO-DISPLAY, don't generate a summary buffer."
3854 (let (result)
3855 (while (and group
3856 (null (setq result
3857 (let ((gnus-auto-select-next nil))
6748645f
LMI
3858 (or (gnus-summary-read-group-1
3859 group show-all no-article
3860 kill-buffer no-display
3861 select-articles)
3862 (setq show-all nil
16409b0b 3863 select-articles nil)))))
eec82323
LMI
3864 (eq gnus-auto-select-next 'quietly))
3865 (set-buffer gnus-group-buffer)
6748645f
LMI
3866 ;; The entry function called above goes to the next
3867 ;; group automatically, so we go two groups back
3868 ;; if we are searching for the previous group.
3869 (when backward
3870 (gnus-group-prev-unread-group 2))
eec82323
LMI
3871 (if (not (equal group (gnus-group-group-name)))
3872 (setq group (gnus-group-group-name))
3873 (setq group nil)))
3874 result))
3875
3876(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3877 kill-buffer no-display
3878 &optional select-articles)
eec82323 3879 ;; Killed foreign groups can't be entered.
23f87bed
MB
3880 ;; (when (and (not (gnus-group-native-p group))
3881 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3882 ;; (error "Dead non-native groups can't be entered"))
3883 (gnus-message 5 "Retrieving newsgroup: %s..."
3884 (gnus-group-decoded-name group))
eec82323
LMI
3885 (let* ((new-group (gnus-summary-setup-buffer group))
3886 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3887 (did-select (and new-group (gnus-select-newsgroup
3888 group show-all select-articles))))
eec82323
LMI
3889 (cond
3890 ;; This summary buffer exists already, so we just select it.
3891 ((not new-group)
3892 (gnus-set-global-variables)
3893 (when kill-buffer
3894 (gnus-kill-or-deaden-summary kill-buffer))
3895 (gnus-configure-windows 'summary 'force)
3896 (gnus-set-mode-line 'summary)
3897 (gnus-summary-position-point)
3898 (message "")
3899 t)
3900 ;; We couldn't select this group.
3901 ((null did-select)
3902 (when (and (eq major-mode 'gnus-summary-mode)
3903 (not (equal (current-buffer) kill-buffer)))
3904 (kill-buffer (current-buffer))
3905 (if (not quit-config)
3906 (progn
6748645f
LMI
3907 ;; Update the info -- marks might need to be removed,
3908 ;; for instance.
3909 (gnus-summary-update-info)
eec82323
LMI
3910 (set-buffer gnus-group-buffer)
3911 (gnus-group-jump-to-group group)
3912 (gnus-group-next-unread-group 1))
3913 (gnus-handle-ephemeral-exit quit-config)))
23f87bed
MB
3914 (let ((grpinfo (gnus-get-info group)))
3915 (if (null (gnus-info-read grpinfo))
3916 (gnus-message 3 "Group %s contains no messages"
3917 (gnus-group-decoded-name group))
3918 (gnus-message 3 "Can't select group")))
eec82323
LMI
3919 nil)
3920 ;; The user did a `C-g' while prompting for number of articles,
3921 ;; so we exit this group.
3922 ((eq did-select 'quit)
3923 (and (eq major-mode 'gnus-summary-mode)
3924 (not (equal (current-buffer) kill-buffer))
3925 (kill-buffer (current-buffer)))
3926 (when kill-buffer
3927 (gnus-kill-or-deaden-summary kill-buffer))
3928 (if (not quit-config)
3929 (progn
3930 (set-buffer gnus-group-buffer)
3931 (gnus-group-jump-to-group group)
eec82323
LMI
3932 (gnus-configure-windows 'group 'force))
3933 (gnus-handle-ephemeral-exit quit-config))
3934 ;; Finally signal the quit.
3935 (signal 'quit nil))
3936 ;; The group was successfully selected.
3937 (t
3938 (gnus-set-global-variables)
3939 ;; Save the active value in effect when the group was entered.
3940 (setq gnus-newsgroup-active
3941 (gnus-copy-sequence
3942 (gnus-active gnus-newsgroup-name)))
3943 ;; You can change the summary buffer in some way with this hook.
6748645f 3944 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
3945 (when (memq 'summary (gnus-update-format-specifications
3946 nil 'summary 'summary-mode 'summary-dummy))
3947 ;; The format specification for the summary line was updated,
3948 ;; so we need to update the mark positions as well.
3949 (gnus-update-summary-mark-positions))
eec82323
LMI
3950 ;; Do score processing.
3951 (when gnus-use-scoring
3952 (gnus-possibly-score-headers))
3953 ;; Check whether to fill in the gaps in the threads.
3954 (when gnus-build-sparse-threads
3955 (gnus-build-sparse-threads))
3956 ;; Find the initial limit.
26c9afc3
MB
3957 (if show-all
3958 (let ((gnus-newsgroup-dormant nil))
eec82323 3959 (gnus-summary-initial-limit show-all))
26c9afc3 3960 (gnus-summary-initial-limit show-all))
eec82323
LMI
3961 ;; Generate the summary buffer.
3962 (unless no-display
3963 (gnus-summary-prepare))
3964 (when gnus-use-trees
3965 (gnus-tree-open group)
3966 (setq gnus-summary-highlight-line-function
3967 'gnus-tree-highlight-article))
3968 ;; If the summary buffer is empty, but there are some low-scored
3969 ;; articles or some excluded dormants, we include these in the
3970 ;; buffer.
3971 (when (and (zerop (buffer-size))
3972 (not no-display))
3973 (cond (gnus-newsgroup-dormant
3974 (gnus-summary-limit-include-dormant))
3975 ((and gnus-newsgroup-scored show-all)
3976 (gnus-summary-limit-include-expunged t))))
3977 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 3978 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
3979 (if (and (zerop (buffer-size))
3980 (not no-display))
3981 (progn
3982 ;; This newsgroup is empty.
3983 (gnus-summary-catchup-and-exit nil t)
3984 (gnus-message 6 "No unread news")
3985 (when kill-buffer
3986 (gnus-kill-or-deaden-summary kill-buffer))
3987 ;; Return nil from this function.
3988 nil)
3989 ;; Hide conversation thread subtrees. We cannot do this in
3990 ;; gnus-summary-prepare-hook since kill processing may not
3991 ;; work with hidden articles.
23f87bed 3992 (gnus-summary-maybe-hide-threads)
6748645f
LMI
3993 (when kill-buffer
3994 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 3995 (gnus-summary-auto-select-subject)
eec82323
LMI
3996 ;; Show first unread article if requested.
3997 (if (and (not no-article)
3998 (not no-display)
3999 gnus-newsgroup-unreads
4000 gnus-auto-select-first)
16409b0b
GM
4001 (progn
4002 (gnus-configure-windows 'summary)
23f87bed
MB
4003 (let ((art (gnus-summary-article-number)))
4004 (unless (and (not gnus-plugged)
4005 (or (memq art gnus-newsgroup-undownloaded)
4006 (memq art gnus-newsgroup-downloadable)))
4007 (gnus-summary-goto-article art))))
4008 ;; Don't select any articles.
eec82323 4009 (gnus-summary-position-point)
6748645f
LMI
4010 (gnus-configure-windows 'summary 'force)
4011 (gnus-set-mode-line 'summary))
23f87bed
MB
4012 (when (and gnus-auto-center-group
4013 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
4014 ;; Gotta use windows, because recenter does weird stuff if
4015 ;; the current buffer ain't the displayed window.
4016 (let ((owin (selected-window)))
4017 (select-window (get-buffer-window gnus-group-buffer t))
4018 (when (gnus-group-goto-group group)
4019 (recenter))
4020 (select-window owin)))
4021 ;; Mark this buffer as "prepared".
4022 (setq gnus-newsgroup-prepared t)
6748645f 4023 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
4024 (unless (gnus-ephemeral-group-p group)
4025 (gnus-group-update-group group))
eec82323
LMI
4026 t)))))
4027
23f87bed
MB
4028(defun gnus-summary-auto-select-subject ()
4029 "Select the subject line on initial group entry."
4030 (goto-char (point-min))
4031 (cond
4032 ((eq gnus-auto-select-subject 'best)
4033 (gnus-summary-best-unread-subject))
4034 ((eq gnus-auto-select-subject 'unread)
4035 (gnus-summary-first-unread-subject))
4036 ((eq gnus-auto-select-subject 'unseen)
4037 (gnus-summary-first-unseen-subject))
4038 ((eq gnus-auto-select-subject 'unseen-or-unread)
4039 (gnus-summary-first-unseen-or-unread-subject))
4040 ((eq gnus-auto-select-subject 'first)
4041 ;; Do nothing.
4042 )
4043 ((functionp gnus-auto-select-subject)
4044 (funcall gnus-auto-select-subject))))
4045
eec82323
LMI
4046(defun gnus-summary-prepare ()
4047 "Generate the summary buffer."
4048 (interactive)
c7a91ce1 4049 (let ((inhibit-read-only t))
eec82323
LMI
4050 (erase-buffer)
4051 (setq gnus-newsgroup-data nil
4052 gnus-newsgroup-data-reverse nil)
6748645f 4053 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
4054 ;; Generate the buffer, either with threads or without.
4055 (when gnus-newsgroup-headers
4056 (gnus-summary-prepare-threads
4057 (if gnus-show-threads
4058 (gnus-sort-gathered-threads
4059 (funcall gnus-summary-thread-gathering-function
4060 (gnus-sort-threads
4061 (gnus-cut-threads (gnus-make-threads)))))
4062 ;; Unthreaded display.
4063 (gnus-sort-articles gnus-newsgroup-headers))))
4064 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4065 ;; Call hooks for modifying summary buffer.
4066 (goto-char (point-min))
6748645f 4067 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
4068
4069(defsubst gnus-general-simplify-subject (subject)
23f87bed 4070 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
4071 (setq subject
4072 (cond
4073 ;; Truncate the subject.
6748645f
LMI
4074 (gnus-simplify-subject-functions
4075 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
4076 ((numberp gnus-summary-gather-subject-limit)
4077 (setq subject (gnus-simplify-subject-re subject))
4078 (if (> (length subject) gnus-summary-gather-subject-limit)
4079 (substring subject 0 gnus-summary-gather-subject-limit)
4080 subject))
4081 ;; Fuzzily simplify it.
4082 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4083 (gnus-simplify-subject-fuzzy subject))
4084 ;; Just remove the leading "Re:".
4085 (t
4086 (gnus-simplify-subject-re subject))))
4087
4088 (if (and gnus-summary-gather-exclude-subject
4089 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 4090 nil ; This article shouldn't be gathered
eec82323
LMI
4091 subject))
4092
4093(defun gnus-summary-simplify-subject-query ()
4094 "Query where the respool algorithm would put this article."
4095 (interactive)
eec82323 4096 (gnus-summary-select-article)
274f1353 4097 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
eec82323
LMI
4098
4099(defun gnus-gather-threads-by-subject (threads)
4100 "Gather threads by looking at Subject headers."
4101 (if (not gnus-summary-make-false-root)
4102 threads
4103 (let ((hashtb (gnus-make-hashtable 1024))
4104 (prev threads)
4105 (result threads)
4106 subject hthread whole-subject)
4107 (while threads
4108 (setq subject (gnus-general-simplify-subject
4109 (setq whole-subject (mail-header-subject
4110 (caar threads)))))
4111 (when subject
4112 (if (setq hthread (gnus-gethash subject hashtb))
4113 (progn
4114 ;; We enter a dummy root into the thread, if we
4115 ;; haven't done that already.
4116 (unless (stringp (caar hthread))
4117 (setcar hthread (list whole-subject (car hthread))))
4118 ;; We add this new gathered thread to this gathered
4119 ;; thread.
4120 (setcdr (car hthread)
4121 (nconc (cdar hthread) (list (car threads))))
4122 ;; Remove it from the list of threads.
4123 (setcdr prev (cdr threads))
4124 (setq threads prev))
4125 ;; Enter this thread into the hash table.
23f87bed
MB
4126 (gnus-sethash subject
4127 (if gnus-summary-make-false-root-always
4128 (progn
4129 ;; If you want a dummy root above all
4130 ;; threads...
4131 (setcar threads (list whole-subject
4132 (car threads)))
4133 threads)
4134 threads)
4135 hashtb)))
eec82323
LMI
4136 (setq prev threads)
4137 (setq threads (cdr threads)))
4138 result)))
4139
4140(defun gnus-gather-threads-by-references (threads)
4141 "Gather threads by looking at References headers."
4142 (let ((idhashtb (gnus-make-hashtable 1024))
4143 (thhashtb (gnus-make-hashtable 1024))
4144 (prev threads)
4145 (result threads)
4146 ids references id gthread gid entered ref)
4147 (while threads
4148 (when (setq references (mail-header-references (caar threads)))
4149 (setq id (mail-header-id (caar threads))
23f87bed 4150 ids (inline (gnus-split-references references))
eec82323
LMI
4151 entered nil)
4152 (while (setq ref (pop ids))
4153 (setq ids (delete ref ids))
4154 (if (not (setq gid (gnus-gethash ref idhashtb)))
4155 (progn
4156 (gnus-sethash ref id idhashtb)
4157 (gnus-sethash id threads thhashtb))
4158 (setq gthread (gnus-gethash gid thhashtb))
4159 (unless entered
4160 ;; We enter a dummy root into the thread, if we
4161 ;; haven't done that already.
4162 (unless (stringp (caar gthread))
4163 (setcar gthread (list (mail-header-subject (caar gthread))
4164 (car gthread))))
4165 ;; We add this new gathered thread to this gathered
4166 ;; thread.
4167 (setcdr (car gthread)
4168 (nconc (cdar gthread) (list (car threads)))))
4169 ;; Add it into the thread hash table.
4170 (gnus-sethash id gthread thhashtb)
4171 (setq entered t)
4172 ;; Remove it from the list of threads.
4173 (setcdr prev (cdr threads))
4174 (setq threads prev))))
4175 (setq prev threads)
4176 (setq threads (cdr threads)))
4177 result))
4178
4179(defun gnus-sort-gathered-threads (threads)
16409b0b 4180 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
4181 (let ((result threads))
4182 (while threads
4183 (when (stringp (caar threads))
4184 (setcdr (car threads)
16409b0b 4185 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
4186 (setq threads (cdr threads)))
4187 result))
4188
4189(defun gnus-thread-loop-p (root thread)
4190 "Say whether ROOT is in THREAD."
4191 (let ((stack (list thread))
4192 (infloop 0)
4193 th)
4194 (while (setq thread (pop stack))
4195 (setq th (cdr thread))
4196 (while (and th
4197 (not (eq (caar th) root)))
4198 (pop th))
4199 (if th
4200 ;; We have found a loop.
4201 (let (ref-dep)
4202 (setcdr thread (delq (car th) (cdr thread)))
4203 (if (boundp (setq ref-dep (intern "none"
4204 gnus-newsgroup-dependencies)))
4205 (setcdr (symbol-value ref-dep)
4206 (nconc (cdr (symbol-value ref-dep))
4207 (list (car th))))
4208 (set ref-dep (list nil (car th))))
4209 (setq infloop 1
4210 stack nil))
4211 ;; Push all the subthreads onto the stack.
4212 (push (cdr thread) stack)))
4213 infloop))
4214
4215(defun gnus-make-threads ()
01ccbb85 4216 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
4217 (let (threads)
4218 (while (catch 'infloop
4219 (mapatoms
4220 (lambda (refs)
4221 ;; Deal with self-referencing References loops.
4222 (when (and (car (symbol-value refs))
4223 (not (zerop
4224 (apply
4225 '+
4226 (mapcar
4227 (lambda (thread)
4228 (gnus-thread-loop-p
4229 (car (symbol-value refs)) thread))
4230 (cdr (symbol-value refs)))))))
4231 (setq threads nil)
4232 (throw 'infloop t))
4233 (unless (car (symbol-value refs))
23f87bed
MB
4234 ;; These threads do not refer back to any other
4235 ;; articles, so they're roots.
eec82323
LMI
4236 (setq threads (append (cdr (symbol-value refs)) threads))))
4237 gnus-newsgroup-dependencies)))
4238 threads))
4239
6748645f 4240;; Build the thread tree.
16409b0b 4241(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4242 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4243
4244If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4245if it was already present.
4246
4247If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4248will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4249Message-IDs will be renamed to a unique Message-ID before being
4250entered.
6748645f
LMI
4251
4252Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4253 (let* ((id (mail-header-id header))
4254 (id-dep (and id (intern id dependencies)))
23f87bed 4255 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4256 ;; Enter this `header' in the `dependencies' table.
4257 (cond
4258 ((not id-dep)
4259 (setq header nil))
4260 ;; The first two cases do the normal part: enter a new `header'
4261 ;; in the `dependencies' table.
4262 ((not (boundp id-dep))
4263 (set id-dep (list header)))
4264 ((null (car (symbol-value id-dep)))
4265 (setcar (symbol-value id-dep) header))
4266
4267 ;; From here the `header' was already present in the
4268 ;; `dependencies' table.
4269 (force-new
4270 ;; Overrides an existing entry;
4271 ;; just set the header part of the entry.
23f87bed
MB
4272 (setcar (symbol-value id-dep) header)
4273 (setq replaced t))
6748645f
LMI
4274
4275 ;; Renames the existing `header' to a unique Message-ID.
4276 ((not gnus-summary-ignore-duplicates)
4277 ;; An article with this Message-ID has already been seen.
4278 ;; We rename the Message-ID.
4279 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4280 (list header))
4281 (mail-header-set-id header id))
4282
4283 ;; The last case ignores an existing entry, except it adds any
4284 ;; additional Xrefs (in case the two articles came from different
4285 ;; servers.
4286 ;; Also sets `header' to `nil' meaning that the `dependencies'
4287 ;; table was *not* modified.
4288 (t
4289 (mail-header-set-xref
4290 (car (symbol-value id-dep))
4291 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4292 "")
4293 (or (mail-header-xref header) "")))
4294 (setq header nil)))
4295
23f87bed
MB
4296 (when (and header (not replaced))
4297 ;; First check that we are not creating a References loop.
4298 (setq parent-id (gnus-parent-id (mail-header-references header)))
4299 (setq ref parent-id)
6748645f
LMI
4300 (while (and ref
4301 (setq ref-dep (intern-soft ref dependencies))
4302 (boundp ref-dep)
4303 (setq ref-header (car (symbol-value ref-dep))))
4304 (if (string= id ref)
4305 ;; Yuk! This is a reference loop. Make the article be a
4306 ;; root article.
4307 (progn
4308 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4309 (setq ref nil)
4310 (setq parent-id nil))
6748645f 4311 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4312 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4313 (if (boundp ref-dep)
4314 (setcdr (symbol-value ref-dep)
4315 (nconc (cdr (symbol-value ref-dep))
4316 (list (symbol-value id-dep))))
4317 (set ref-dep (list nil (symbol-value id-dep)))))
4318 header))
4319
23f87bed
MB
4320(defun gnus-extract-message-id-from-in-reply-to (string)
4321 (if (string-match "<[^>]+>" string)
4322 (substring string (match-beginning 0) (match-end 0))
4323 nil))
4324
eec82323
LMI
4325(defun gnus-build-sparse-threads ()
4326 (let ((headers gnus-newsgroup-headers)
16409b0b 4327 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4328 (gnus-summary-ignore-duplicates t)
eec82323 4329 header references generation relations
6748645f 4330 subject child end new-child date)
eec82323
LMI
4331 ;; First we create an alist of generations/relations, where
4332 ;; generations is how much we trust the relation, and the relation
4333 ;; is parent/child.
4334 (gnus-message 7 "Making sparse threads...")
4335 (save-excursion
4336 (nnheader-set-temp-buffer " *gnus sparse threads*")
4337 (while (setq header (pop headers))
4338 (when (and (setq references (mail-header-references header))
4339 (not (string= references "")))
4340 (insert references)
4341 (setq child (mail-header-id header)
6748645f
LMI
4342 subject (mail-header-subject header)
4343 date (mail-header-date header)
4344 generation 0)
eec82323
LMI
4345 (while (search-backward ">" nil t)
4346 (setq end (1+ (point)))
4347 (when (search-backward "<" nil t)
6748645f 4348 (setq new-child (buffer-substring (point) end))
eec82323 4349 (push (list (incf generation)
6748645f
LMI
4350 child (setq child new-child)
4351 subject date)
eec82323 4352 relations)))
6748645f
LMI
4353 (when child
4354 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4355 (erase-buffer)))
4356 (kill-buffer (current-buffer)))
4357 ;; Sort over trustworthiness.
01c52d31
MB
4358 (dolist (relation (sort relations 'car-less-than-car))
4359 (when (gnus-dependencies-add-header
4360 (make-full-mail-header
4361 gnus-reffed-article-number
4362 (nth 3 relation) "" (or (nth 4 relation) "")
4363 (nth 1 relation)
4364 (or (nth 2 relation) "") 0 0 "")
4365 gnus-newsgroup-dependencies nil)
4366 (push gnus-reffed-article-number gnus-newsgroup-limit)
4367 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4368 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4369 gnus-newsgroup-reads)
4370 (decf gnus-reffed-article-number)))
eec82323
LMI
4371 (gnus-message 7 "Making sparse threads...done")))
4372
4373(defun gnus-build-old-threads ()
4374 ;; Look at all the articles that refer back to old articles, and
4375 ;; fetch the headers for the articles that aren't there. This will
4376 ;; build complete threads - if the roots haven't been expired by the
4377 ;; server, that is.
16409b0b
GM
4378 (let ((mail-parse-charset gnus-newsgroup-charset)
4379 id heads)
eec82323
LMI
4380 (mapatoms
4381 (lambda (refs)
4382 (when (not (car (symbol-value refs)))
4383 (setq heads (cdr (symbol-value refs)))
4384 (while heads
4385 (if (memq (mail-header-number (caar heads))
4386 gnus-newsgroup-dormant)
4387 (setq heads (cdr heads))
4388 (setq id (symbol-name refs))
4389 (while (and (setq id (gnus-build-get-header id))
6748645f 4390 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4391 (setq heads nil)))))
4392 gnus-newsgroup-dependencies)))
4393
23f87bed
MB
4394(defsubst gnus-remove-odd-characters (string)
4395 "Translate STRING into something that doesn't contain weird characters."
4396 (mm-subst-char-in-string
4397 ?\r ?\-
01c52d31 4398 (mm-subst-char-in-string ?\n ?\- string t) t))
23f87bed 4399
6748645f
LMI
4400;; This function has to be called with point after the article number
4401;; on the beginning of the line.
4402(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
01c52d31 4403 (let ((eol (point-at-eol))
6748645f 4404 (buffer (current-buffer))
23f87bed 4405 header references in-reply-to)
6748645f
LMI
4406
4407 ;; overview: [num subject from date id refs chars lines misc]
4408 (unwind-protect
23f87bed 4409 (let (x)
6748645f
LMI
4410 (narrow-to-region (point) eol)
4411 (unless (eobp)
4412 (forward-char))
4413
4414 (setq header
4415 (make-full-mail-header
4416 number ; number
23f87bed
MB
4417 (condition-case () ; subject
4418 (gnus-remove-odd-characters
4419 (funcall gnus-decode-encoded-word-function
4420 (setq x (nnheader-nov-field))))
4421 (error x))
4422 (condition-case () ; from
4423 (gnus-remove-odd-characters
343d6628 4424 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4425 (setq x (nnheader-nov-field))))
4426 (error x))
16409b0b 4427 (nnheader-nov-field) ; date
01c52d31 4428 (nnheader-nov-read-message-id number) ; id
23f87bed 4429 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4430 (nnheader-nov-read-integer) ; chars
4431 (nnheader-nov-read-integer) ; lines
4432 (unless (eobp)
8b93df01
DL
4433 (if (looking-at "Xref: ")
4434 (goto-char (match-end 0)))
4435 (nnheader-nov-field)) ; Xref
16409b0b 4436 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4437
4438 (widen))
4439
23f87bed
MB
4440 (when (and (string= references "")
4441 (setq in-reply-to (mail-header-extra header))
4442 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4443 (mail-header-set-references
4444 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4445
6748645f
LMI
4446 (when gnus-alter-header-function
4447 (funcall gnus-alter-header-function header))
4448 (gnus-dependencies-add-header header dependencies force-new)))
4449
eec82323 4450(defun gnus-build-get-header (id)
16409b0b
GM
4451 "Look through the buffer of NOV lines and find the header to ID.
4452Enter this line into the dependencies hash table, and return
4453the id of the parent article (if any)."
eec82323
LMI
4454 (let ((deps gnus-newsgroup-dependencies)
4455 found header)
4456 (prog1
c7a91ce1 4457 (with-current-buffer nntp-server-buffer
eec82323
LMI
4458 (let ((case-fold-search nil))
4459 (goto-char (point-min))
4460 (while (and (not found)
4461 (search-forward id nil t))
4462 (beginning-of-line)
4463 (setq found (looking-at
4464 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4465 (regexp-quote id))))
4466 (or found (beginning-of-line 2)))
4467 (when found
4468 (beginning-of-line)
4469 (and
4470 (setq header (gnus-nov-parse-line
4471 (read (current-buffer)) deps))
4472 (gnus-parent-id (mail-header-references header))))))
4473 (when header
4474 (let ((number (mail-header-number header)))
4475 (push number gnus-newsgroup-limit)
4476 (push header gnus-newsgroup-headers)
4477 (if (memq number gnus-newsgroup-unselected)
4478 (progn
23f87bed
MB
4479 (setq gnus-newsgroup-unreads
4480 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4481 number))
eec82323
LMI
4482 (setq gnus-newsgroup-unselected
4483 (delq number gnus-newsgroup-unselected)))
4484 (push number gnus-newsgroup-ancient)))))))
4485
6748645f
LMI
4486(defun gnus-build-all-threads ()
4487 "Read all the headers."
4488 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4489 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4490 (dependencies gnus-newsgroup-dependencies)
4491 header article)
c7a91ce1 4492 (with-current-buffer nntp-server-buffer
6748645f
LMI
4493 (let ((case-fold-search nil))
4494 (goto-char (point-min))
4495 (while (not (eobp))
4496 (ignore-errors
4497 (setq article (read (current-buffer))
16409b0b 4498 header (gnus-nov-parse-line article dependencies)))
6748645f 4499 (when header
01c52d31 4500 (with-current-buffer gnus-summary-buffer
6748645f
LMI
4501 (push header gnus-newsgroup-headers)
4502 (if (memq (setq article (mail-header-number header))
4503 gnus-newsgroup-unselected)
4504 (progn
23f87bed
MB
4505 (setq gnus-newsgroup-unreads
4506 (gnus-add-to-sorted-list
4507 gnus-newsgroup-unreads article))
6748645f
LMI
4508 (setq gnus-newsgroup-unselected
4509 (delq article gnus-newsgroup-unselected)))
4510 (push article gnus-newsgroup-ancient)))
4511 (forward-line 1)))))))
4512
eec82323 4513(defun gnus-summary-update-article-line (article header)
23f87bed 4514 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4515 (let* ((id (mail-header-id header))
4516 (thread (gnus-id-to-thread id)))
4517 (unless thread
4518 (error "Article in no thread"))
4519 ;; Update the thread.
4520 (setcar thread header)
4521 (gnus-summary-goto-subject article)
4522 (let* ((datal (gnus-data-find-list article))
4523 (data (car datal))
c7a91ce1 4524 (inhibit-read-only t)
eec82323
LMI
4525 (level (gnus-summary-thread-level)))
4526 (gnus-delete-line)
23f87bed
MB
4527 (let ((inserted (- (point)
4528 (progn
4529 (gnus-summary-insert-line
4530 header level nil
4531 (memq article gnus-newsgroup-undownloaded)
4532 (gnus-article-mark article)
4533 (memq article gnus-newsgroup-replied)
4534 (memq article gnus-newsgroup-expirable)
4535 ;; Only insert the Subject string when it's different
4536 ;; from the previous Subject string.
4537 (if (and
4538 gnus-show-threads
4539 (gnus-subject-equal
4540 (condition-case ()
4541 (mail-header-subject
4542 (gnus-data-header
4543 (cadr
4544 (gnus-data-find-list
4545 article
4546 (gnus-data-list t)))))
4547 ;; Error on the side of excessive subjects.
4548 (error ""))
4549 (mail-header-subject header)))
4550 ""
4551 (mail-header-subject header))
4552 nil (cdr (assq article gnus-newsgroup-scored))
4553 (memq article gnus-newsgroup-processable))
4554 (point)))))
4555 (when (cdr datal)
4556 (gnus-data-update-list
4557 (cdr datal)
4558 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4559
4560(defun gnus-summary-update-article (article &optional iheader)
4561 "Update ARTICLE in the summary buffer."
4562 (set-buffer gnus-summary-buffer)
6748645f 4563 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4564 (id (mail-header-id header))
4565 (data (gnus-data-find article))
4566 (thread (gnus-id-to-thread id))
4567 (references (mail-header-references header))
4568 (parent
4569 (gnus-id-to-thread
4570 (or (gnus-parent-id
4571 (when (and references
4572 (not (equal "" references)))
4573 references))
4574 "none")))
c7a91ce1 4575 (inhibit-read-only t)
6748645f 4576 (old (car thread)))
eec82323 4577 (when thread
eec82323 4578 (unless iheader
6748645f
LMI
4579 (setcar thread nil)
4580 (when parent
4581 (delq thread parent)))
4582 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4583 ;; Set the (possibly) new article number in the data structure.
4584 (gnus-data-set-number data (gnus-id-to-article id))
4585 (setcar thread old)
4586 nil))))
4587
6748645f
LMI
4588(defun gnus-rebuild-thread (id &optional line)
4589 "Rebuild the thread containing ID.
4590If LINE, insert the rebuilt thread starting on line LINE."
c7a91ce1 4591 (let ((inhibit-read-only t)
eec82323
LMI
4592 old-pos current thread data)
4593 (if (not gnus-show-threads)
4594 (setq thread (list (car (gnus-id-to-thread id))))
4595 ;; Get the thread this article is part of.
4596 (setq thread (gnus-remove-thread id)))
01c52d31 4597 (setq old-pos (point-at-bol))
eec82323 4598 (setq current (save-excursion
94384150 4599 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4600 (gnus-summary-article-number))))
4601 ;; If this is a gathered thread, we have to go some re-gathering.
4602 (when (stringp (car thread))
4603 (let ((subject (car thread))
4604 roots thr)
4605 (setq thread (cdr thread))
4606 (while thread
4607 (unless (memq (setq thr (gnus-id-to-thread
4608 (gnus-root-id
4609 (mail-header-id (caar thread)))))
4610 roots)
4611 (push thr roots))
4612 (setq thread (cdr thread)))
4613 ;; We now have all (unique) roots.
4614 (if (= (length roots) 1)
4615 ;; All the loose roots are now one solid root.
4616 (setq thread (car roots))
4617 (setq thread (cons subject (gnus-sort-threads roots))))))
4618 (let (threads)
4619 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4620 (when line
4621 (goto-char (point-min))
4622 (forward-line (1- line)))
eec82323
LMI
4623 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4624 (if gnus-show-threads
4625 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4626 (gnus-summary-prepare-unthreaded thread))
4627 (setq data (nreverse gnus-newsgroup-data))
4628 (setq threads gnus-newsgroup-threads))
4629 ;; We splice the new data into the data structure.
6748645f
LMI
4630 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4631 ;;!!! then we want to insert at the beginning of the buffer.
4632 ;;!!! That happens to be true with Gnus now, but that may
4633 ;;!!! change in the future. Perhaps.
4634 (gnus-data-enter-list
4635 (if line nil current) data (- (point) old-pos))
4636 (setq gnus-newsgroup-threads
4637 (nconc threads gnus-newsgroup-threads))
4638 (gnus-data-compute-positions))))
eec82323
LMI
4639
4640(defun gnus-number-to-header (number)
4641 "Return the header for article NUMBER."
4642 (let ((headers gnus-newsgroup-headers))
4643 (while (and headers
4644 (not (= number (mail-header-number (car headers)))))
4645 (pop headers))
4646 (when headers
4647 (car headers))))
4648
6748645f 4649(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4650 "Return the headers of the GENERATIONeth parent of HEADERS."
4651 (unless generation
4652 (setq generation 1))
a8151ef7 4653 (let ((parent t)
6748645f 4654 (headers in-headers)
a8151ef7 4655 references)
6748645f
LMI
4656 (while (and parent
4657 (not (zerop generation))
4658 (setq references (mail-header-references headers)))
4659 (setq headers (if (and references
4660 (setq parent (gnus-parent-id references)))
4661 (car (gnus-id-to-thread parent))
4662 nil))
4663 (decf generation))
4664 (and (not (eq headers in-headers))
4665 headers)))
eec82323
LMI
4666
4667(defun gnus-id-to-thread (id)
4668 "Return the (sub-)thread where ID appears."
4669 (gnus-gethash id gnus-newsgroup-dependencies))
4670
4671(defun gnus-id-to-article (id)
4672 "Return the article number of ID."
4673 (let ((thread (gnus-id-to-thread id)))
4674 (when (and thread
4675 (car thread))
4676 (mail-header-number (car thread)))))
4677
4678(defun gnus-id-to-header (id)
4679 "Return the article headers of ID."
4680 (car (gnus-id-to-thread id)))
4681
4682(defun gnus-article-displayed-root-p (article)
4683 "Say whether ARTICLE is a root(ish) article."
4684 (let ((level (gnus-summary-thread-level article))
4685 (refs (mail-header-references (gnus-summary-article-header article)))
4686 particle)
4687 (cond
4688 ((null level) nil)
4689 ((zerop level) t)
4690 ((null refs) t)
4691 ((null (gnus-parent-id refs)) t)
4692 ((and (= 1 level)
4693 (null (setq particle (gnus-id-to-article
4694 (gnus-parent-id refs))))
4695 (null (gnus-summary-thread-level particle)))))))
4696
4697(defun gnus-root-id (id)
4698 "Return the id of the root of the thread where ID appears."
4699 (let (last-id prev)
6748645f 4700 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4701 (setq last-id id
4702 id (gnus-parent-id (mail-header-references prev))))
4703 last-id))
4704
6748645f
LMI
4705(defun gnus-articles-in-thread (thread)
4706 "Return the list of articles in THREAD."
4707 (cons (mail-header-number (car thread))
4708 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4709
eec82323
LMI
4710(defun gnus-remove-thread (id &optional dont-remove)
4711 "Remove the thread that has ID in it."
6748645f 4712 (let (headers thread last-id)
eec82323 4713 ;; First go up in this thread until we find the root.
6748645f
LMI
4714 (setq last-id (gnus-root-id id)
4715 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4716 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4717 ;; been gathered into some loose thread, so we have to search
4718 ;; through the threads to find the thread we wanted.
4719 (let ((threads gnus-newsgroup-threads)
4720 sub)
4721 (while threads
4722 (setq sub (car threads))
4723 (if (stringp (car sub))
4724 ;; This is a gathered thread, so we look at the roots
4725 ;; below it to find whether this article is in this
4726 ;; gathered root.
4727 (progn
4728 (setq sub (cdr sub))
4729 (while sub
4730 (when (member (caar sub) headers)
4731 (setq thread (car threads)
4732 threads nil
4733 sub nil))
4734 (setq sub (cdr sub))))
4735 ;; It's an ordinary thread, so we check it.
4736 (when (eq (car sub) (car headers))
4737 (setq thread sub
4738 threads nil)))
4739 (setq threads (cdr threads)))
4740 ;; If this article is in no thread, then it's a root.
4741 (if thread
4742 (unless dont-remove
4743 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4744 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4745 (when thread
4746 (prog1
4747 thread ; We return this thread.
4748 (unless dont-remove
4749 (if (stringp (car thread))
4750 (progn
4751 ;; If we use dummy roots, then we have to remove the
4752 ;; dummy root as well.
4753 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4754 ;; We go to the dummy root by going to
4755 ;; the first sub-"thread", and then one line up.
4756 (gnus-summary-goto-article
4757 (mail-header-number (caadr thread)))
4758 (forward-line -1)
eec82323
LMI
4759 (gnus-delete-line)
4760 (gnus-data-compute-positions))
4761 (setq thread (cdr thread))
4762 (while thread
4763 (gnus-remove-thread-1 (car thread))
4764 (setq thread (cdr thread))))
4765 (gnus-remove-thread-1 thread))))))))
4766
4767(defun gnus-remove-thread-1 (thread)
4768 "Remove the thread THREAD recursively."
4769 (let ((number (mail-header-number (pop thread)))
4770 d)
4771 (setq thread (reverse thread))
4772 (while thread
4773 (gnus-remove-thread-1 (pop thread)))
4774 (when (setq d (gnus-data-find number))
4775 (goto-char (gnus-data-pos d))
16409b0b 4776 (gnus-summary-show-thread)
eec82323
LMI
4777 (gnus-data-remove
4778 number
01c52d31 4779 (- (point-at-bol)
eec82323 4780 (prog1
01c52d31 4781 (1+ (point-at-eol))
eec82323
LMI
4782 (gnus-delete-line)))))))
4783
4921bbdd 4784(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4785 (sort (mapcar (lambda (thread)
4786 (cons (car thread)
4787 (and (cdr thread)
4921bbdd 4788 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4789 threads) func))
4790
4921bbdd
CY
4791(defun gnus-sort-threads-loop (threads func)
4792 (let* ((superthread (cons nil threads))
4793 (stack (list (cons superthread threads)))
4794 remaining-threads thread)
4795 (while stack
4796 (setq remaining-threads (cdr (car stack)))
4797 (if remaining-threads
4798 (progn (setq thread (car remaining-threads))
4799 (setcdr (car stack) (cdr remaining-threads))
4800 (if (cdr thread)
4801 (push (cons thread (cdr thread)) stack)))
4802 (setq thread (caar stack))
4803 (setcdr thread (sort (cdr thread) func))
4804 (pop stack)))
4805 (cdr superthread)))
4806
eec82323
LMI
4807(defun gnus-sort-threads (threads)
4808 "Sort THREADS."
4809 (if (not gnus-thread-sort-functions)
4810 threads
6748645f 4811 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4812 (prog1
4813 (condition-case nil
4814 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4815 (gnus-sort-threads-recursive
4816 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4817 ;; Even after binding max-lisp-eval-depth, the recursive
4818 ;; sorter might fail for very long threads. In that case,
4819 ;; try using a (less well-tested) non-recursive sorter.
3d6e7a43
KY
4820 (error (gnus-message 9 "Sorting threads with loop...")
4821 (gnus-sort-threads-loop
4921bbdd
CY
4822 threads (gnus-make-sort-function
4823 gnus-thread-sort-functions))))
4824 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4825
4826(defun gnus-sort-articles (articles)
4827 "Sort ARTICLES."
4828 (when gnus-article-sort-functions
4829 (gnus-message 7 "Sorting articles...")
4830 (prog1
4831 (setq gnus-newsgroup-headers
4832 (sort articles (gnus-make-sort-function
4833 gnus-article-sort-functions)))
4834 (gnus-message 7 "Sorting articles...done"))))
4835
4836;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4837(defmacro gnus-thread-header (thread)
16409b0b
GM
4838 "Return header of first article in THREAD.
4839Note that THREAD must never, ever be anything else than a variable -
4840using some other form will lead to serious barfage."
eec82323
LMI
4841 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4842 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4843 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4844 (vector thread) 2))
4845
4846(defsubst gnus-article-sort-by-number (h1 h2)
4847 "Sort articles by article number."
4848 (< (mail-header-number h1)
4849 (mail-header-number h2)))
4850
4851(defun gnus-thread-sort-by-number (h1 h2)
4852 "Sort threads by root article number."
4853 (gnus-article-sort-by-number
4854 (gnus-thread-header h1) (gnus-thread-header h2)))
4855
23f87bed 4856(defsubst gnus-article-sort-by-random (h1 h2)
0b6799c3 4857 "Sort articles randomly."
23f87bed
MB
4858 (zerop (random 2)))
4859
4860(defun gnus-thread-sort-by-random (h1 h2)
0b6799c3 4861 "Sort threads randomly."
23f87bed
MB
4862 (gnus-article-sort-by-random
4863 (gnus-thread-header h1) (gnus-thread-header h2)))
4864
eec82323
LMI
4865(defsubst gnus-article-sort-by-lines (h1 h2)
4866 "Sort articles by article Lines header."
4867 (< (mail-header-lines h1)
4868 (mail-header-lines h2)))
4869
4870(defun gnus-thread-sort-by-lines (h1 h2)
4871 "Sort threads by root article Lines header."
4872 (gnus-article-sort-by-lines
4873 (gnus-thread-header h1) (gnus-thread-header h2)))
4874
16409b0b
GM
4875(defsubst gnus-article-sort-by-chars (h1 h2)
4876 "Sort articles by octet length."
4877 (< (mail-header-chars h1)
4878 (mail-header-chars h2)))
4879
4880(defun gnus-thread-sort-by-chars (h1 h2)
4881 "Sort threads by root article octet length."
4882 (gnus-article-sort-by-chars
4883 (gnus-thread-header h1) (gnus-thread-header h2)))
4884
eec82323
LMI
4885(defsubst gnus-article-sort-by-author (h1 h2)
4886 "Sort articles by root author."
b4fde39f 4887 (gnus-string<
eec82323
LMI
4888 (let ((extract (funcall
4889 gnus-extract-address-components
4890 (mail-header-from h1))))
4891 (or (car extract) (cadr extract) ""))
4892 (let ((extract (funcall
4893 gnus-extract-address-components
4894 (mail-header-from h2))))
4895 (or (car extract) (cadr extract) ""))))
4896
4897(defun gnus-thread-sort-by-author (h1 h2)
4898 "Sort threads by root author."
4899 (gnus-article-sort-by-author
4900 (gnus-thread-header h1) (gnus-thread-header h2)))
4901
01c52d31
MB
4902(defsubst gnus-article-sort-by-recipient (h1 h2)
4903 "Sort articles by recipient."
4904 (gnus-string<
4905 (let ((extract (funcall
4906 gnus-extract-address-components
4907 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4908 (or (car extract) (cadr extract)))
4909 (let ((extract (funcall
4910 gnus-extract-address-components
4911 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4912 (or (car extract) (cadr extract)))))
4913
4914(defun gnus-thread-sort-by-recipient (h1 h2)
4915 "Sort threads by root recipient."
4916 (gnus-article-sort-by-recipient
4917 (gnus-thread-header h1) (gnus-thread-header h2)))
4918
eec82323
LMI
4919(defsubst gnus-article-sort-by-subject (h1 h2)
4920 "Sort articles by root subject."
b4fde39f 4921 (gnus-string<
eec82323
LMI
4922 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4923 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4924
4925(defun gnus-thread-sort-by-subject (h1 h2)
4926 "Sort threads by root subject."
4927 (gnus-article-sort-by-subject
4928 (gnus-thread-header h1) (gnus-thread-header h2)))
4929
4930(defsubst gnus-article-sort-by-date (h1 h2)
4931 "Sort articles by root article date."
16409b0b 4932 (time-less-p
eec82323
LMI
4933 (gnus-date-get-time (mail-header-date h1))
4934 (gnus-date-get-time (mail-header-date h2))))
4935
4936(defun gnus-thread-sort-by-date (h1 h2)
4937 "Sort threads by root article date."
4938 (gnus-article-sort-by-date
4939 (gnus-thread-header h1) (gnus-thread-header h2)))
4940
4941(defsubst gnus-article-sort-by-score (h1 h2)
4942 "Sort articles by root article score.
4943Unscored articles will be counted as having a score of zero."
4944 (> (or (cdr (assq (mail-header-number h1)
4945 gnus-newsgroup-scored))
4946 gnus-summary-default-score 0)
4947 (or (cdr (assq (mail-header-number h2)
4948 gnus-newsgroup-scored))
4949 gnus-summary-default-score 0)))
4950
4951(defun gnus-thread-sort-by-score (h1 h2)
4952 "Sort threads by root article score."
4953 (gnus-article-sort-by-score
4954 (gnus-thread-header h1) (gnus-thread-header h2)))
4955
4956(defun gnus-thread-sort-by-total-score (h1 h2)
4957 "Sort threads by the sum of all scores in the thread.
4958Unscored articles will be counted as having a score of zero."
4959 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4960
4961(defun gnus-thread-total-score (thread)
16409b0b 4962 ;; This function find the total score of THREAD.
23f87bed
MB
4963 (cond
4964 ((null thread)
4965 0)
4966 ((consp thread)
4967 (if (stringp (car thread))
4968 (apply gnus-thread-score-function 0
4969 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4970 (gnus-thread-total-score-1 thread)))
4971 (t
4972 (gnus-thread-total-score-1 (list thread)))))
4973
4974(defun gnus-thread-sort-by-most-recent-number (h1 h2)
4975 "Sort threads such that the thread with the most recently arrived article comes first."
4976 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4977
4978(defun gnus-thread-highest-number (thread)
4979 "Return the highest article number in THREAD."
4980 (apply 'max (mapcar (lambda (header)
4981 (mail-header-number header))
4982 (message-flatten-list thread))))
4983
4984(defun gnus-thread-sort-by-most-recent-date (h1 h2)
4985 "Sort threads such that the thread with the most recently dated article comes first."
4986 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4987
3d6e7a43
KY
4988; Since this is called not only to sort the top-level threads, but
4989; also in recursive sorts to order the articles within a thread, each
4990; article will be processed many times. Thus it speeds things up
4991; quite a bit to use gnus-date-get-time, which caches the time value.
23f87bed
MB
4992(defun gnus-thread-latest-date (thread)
4993 "Return the highest article date in THREAD."
3d6e7a43
KY
4994 (apply 'max
4995 (mapcar (lambda (header) (gnus-float-time
4996 (gnus-date-get-time
4997 (mail-header-date header))))
4998 (message-flatten-list thread))))
eec82323
LMI
4999
5000(defun gnus-thread-total-score-1 (root)
5001 ;; This function find the total score of the thread below ROOT.
5002 (setq root (car root))
5003 (apply gnus-thread-score-function
5004 (or (append
5005 (mapcar 'gnus-thread-total-score
6748645f 5006 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
5007 (when (> (mail-header-number root) 0)
5008 (list (or (cdr (assq (mail-header-number root)
5009 gnus-newsgroup-scored))
5010 gnus-summary-default-score 0))))
5011 (list gnus-summary-default-score)
5012 '(0))))
5013
5014;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5015(defvar gnus-tmp-prev-subject nil)
5016(defvar gnus-tmp-false-parent nil)
5017(defvar gnus-tmp-root-expunged nil)
5018(defvar gnus-tmp-dummy-line nil)
5019
16409b0b
GM
5020(defun gnus-extra-header (type &optional header)
5021 "Return the extra header of TYPE."
5022 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5023 ""))
5024
23f87bed
MB
5025(defvar gnus-tmp-thread-tree-header-string "")
5026
5027(defcustom gnus-sum-thread-tree-root "> "
5028 "With %B spec, used for the root of a thread.
5029If nil, use subject instead."
bf247b6e 5030 :version "22.1"
ad136a7c 5031 :type '(radio (const :format "%v " nil) string)
23f87bed 5032 :group 'gnus-thread)
01c52d31 5033
23f87bed
MB
5034(defcustom gnus-sum-thread-tree-false-root "> "
5035 "With %B spec, used for a false root of a thread.
5036If nil, use subject instead."
bf247b6e 5037 :version "22.1"
ad136a7c 5038 :type '(radio (const :format "%v " nil) string)
23f87bed 5039 :group 'gnus-thread)
01c52d31 5040
23f87bed
MB
5041(defcustom gnus-sum-thread-tree-single-indent ""
5042 "With %B spec, used for a thread with just one message.
5043If nil, use subject instead."
bf247b6e 5044 :version "22.1"
ad136a7c 5045 :type '(radio (const :format "%v " nil) string)
23f87bed 5046 :group 'gnus-thread)
01c52d31 5047
23f87bed
MB
5048(defcustom gnus-sum-thread-tree-vertical "| "
5049 "With %B spec, used for drawing a vertical line."
bf247b6e 5050 :version "22.1"
23f87bed
MB
5051 :type 'string
5052 :group 'gnus-thread)
01c52d31 5053
23f87bed
MB
5054(defcustom gnus-sum-thread-tree-indent " "
5055 "With %B spec, used for indenting."
bf247b6e 5056 :version "22.1"
23f87bed
MB
5057 :type 'string
5058 :group 'gnus-thread)
01c52d31 5059
23f87bed
MB
5060(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5061 "With %B spec, used for a leaf with brothers."
bf247b6e 5062 :version "22.1"
23f87bed
MB
5063 :type 'string
5064 :group 'gnus-thread)
01c52d31 5065
23f87bed
MB
5066(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5067 "With %B spec, used for a leaf without brothers."
bf247b6e 5068 :version "22.1"
23f87bed
MB
5069 :type 'string
5070 :group 'gnus-thread)
5071
1fc34624
GM
5072(defcustom gnus-summary-display-while-building nil
5073 "If non-nil, show and update the summary buffer as it's being built.
5074If the value is t, update the buffer after every line is inserted. If
5075the value is an integer (N), update the display every N lines."
5076 :version "22.1"
5077 :group 'gnus-thread
5078 :type '(choice (const :tag "off" nil)
5079 number
5080 (const :tag "frequently" t)))
5081
eec82323
LMI
5082(defun gnus-summary-prepare-threads (threads)
5083 "Prepare summary buffer from THREADS and indentation LEVEL.
5084THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5085or a straight list of headers."
5086 (gnus-message 7 "Generating summary...")
5087
5088 (setq gnus-newsgroup-threads threads)
5089 (beginning-of-line)
5090
5091 (let ((gnus-tmp-level 0)
5092 (default-score (or gnus-summary-default-score 0))
5093 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
5094 (building-line-count gnus-summary-display-while-building)
5095 (building-count (integerp gnus-summary-display-while-building))
eec82323 5096 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
5097 new-roots gnus-tmp-new-adopts thread-end simp-subject
5098 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
5099 gnus-tmp-replied gnus-tmp-subject-or-nil
5100 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5101 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
5102 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5103 tree-stack)
eec82323 5104
23f87bed
MB
5105 (setq gnus-tmp-prev-subject nil
5106 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
5107
5108 (if (vectorp (car threads))
5109 ;; If this is a straight (sic) list of headers, then a
5110 ;; threaded summary display isn't required, so we just create
5111 ;; an unthreaded one.
5112 (gnus-summary-prepare-unthreaded threads)
5113
5114 ;; Do the threaded display.
5115
23f87bed
MB
5116 (if gnus-summary-display-while-building
5117 (switch-to-buffer (buffer-name)))
eec82323
LMI
5118 (while (or threads stack gnus-tmp-new-adopts new-roots)
5119
5120 (if (and (= gnus-tmp-level 0)
eec82323
LMI
5121 (or (not stack)
5122 (= (caar stack) 0))
5123 (not gnus-tmp-false-parent)
5124 (or gnus-tmp-new-adopts new-roots))
5125 (if gnus-tmp-new-adopts
5126 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5127 thread (list (car gnus-tmp-new-adopts))
5128 gnus-tmp-header (caar thread)
5129 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5130 (when new-roots
5131 (setq thread (list (car new-roots))
5132 gnus-tmp-header (caar thread)
5133 new-roots (cdr new-roots))))
5134
5135 (if threads
5136 ;; If there are some threads, we do them before the
5137 ;; threads on the stack.
5138 (setq thread threads
5139 gnus-tmp-header (caar thread))
5140 ;; There were no current threads, so we pop something off
5141 ;; the stack.
5142 (setq state (car stack)
5143 gnus-tmp-level (car state)
23f87bed
MB
5144 tree-stack (cadr state)
5145 thread (caddr state)
eec82323
LMI
5146 stack (cdr stack)
5147 gnus-tmp-header (caar thread))))
5148
5149 (setq gnus-tmp-false-parent nil)
5150 (setq gnus-tmp-root-expunged nil)
5151 (setq thread-end nil)
5152
5153 (if (stringp gnus-tmp-header)
5154 ;; The header is a dummy root.
5155 (cond
5156 ((eq gnus-summary-make-false-root 'adopt)
5157 ;; We let the first article adopt the rest.
5158 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5159 (cddar thread)))
5160 (setq gnus-tmp-gathered
5161 (nconc (mapcar
5162 (lambda (h) (mail-header-number (car h)))
5163 (cddar thread))
5164 gnus-tmp-gathered))
5165 (setq thread (cons (list (caar thread)
5166 (cadar thread))
5167 (cdr thread)))
5168 (setq gnus-tmp-level -1
5169 gnus-tmp-false-parent t))
5170 ((eq gnus-summary-make-false-root 'empty)
5171 ;; We print adopted articles with empty subject fields.
5172 (setq gnus-tmp-gathered
5173 (nconc (mapcar
5174 (lambda (h) (mail-header-number (car h)))
5175 (cddar thread))
5176 gnus-tmp-gathered))
5177 (setq gnus-tmp-level -1))
5178 ((eq gnus-summary-make-false-root 'dummy)
5179 ;; We remember that we probably want to output a dummy
5180 ;; root.
5181 (setq gnus-tmp-dummy-line gnus-tmp-header)
5182 (setq gnus-tmp-prev-subject gnus-tmp-header))
5183 (t
5184 ;; We do not make a root for the gathered
5185 ;; sub-threads at all.
5186 (setq gnus-tmp-level -1)))
5187
5188 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
5189 subject (mail-header-subject gnus-tmp-header)
5190 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
5191
5192 (cond
5193 ;; If the thread has changed subject, we might want to make
5194 ;; this subthread into a root.
5195 ((and (null gnus-thread-ignore-subject)
5196 (not (zerop gnus-tmp-level))
5197 gnus-tmp-prev-subject
23f87bed 5198 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5199 (setq new-roots (nconc new-roots (list (car thread)))
5200 thread-end t
5201 gnus-tmp-header nil))
5202 ;; If the article lies outside the current limit,
5203 ;; then we do not display it.
5204 ((not (memq number gnus-newsgroup-limit))
5205 (setq gnus-tmp-gathered
5206 (nconc (mapcar
5207 (lambda (h) (mail-header-number (car h)))
5208 (cdar thread))
5209 gnus-tmp-gathered))
5210 (setq gnus-tmp-new-adopts (if (cdar thread)
5211 (append gnus-tmp-new-adopts
5212 (cdar thread))
5213 gnus-tmp-new-adopts)
5214 thread-end t
5215 gnus-tmp-header nil)
5216 (when (zerop gnus-tmp-level)
5217 (setq gnus-tmp-root-expunged t)))
5218 ;; Perhaps this article is to be marked as read?
5219 ((and gnus-summary-mark-below
5220 (< (or (cdr (assq number gnus-newsgroup-scored))
5221 default-score)
5222 gnus-summary-mark-below)
5223 ;; Don't touch sparse articles.
5224 (not (gnus-summary-article-sparse-p number))
5225 (not (gnus-summary-article-ancient-p number)))
5226 (setq gnus-newsgroup-unreads
5227 (delq number gnus-newsgroup-unreads))
5228 (if gnus-newsgroup-auto-expire
23f87bed
MB
5229 (setq gnus-newsgroup-expirable
5230 (gnus-add-to-sorted-list
5231 gnus-newsgroup-expirable number))
eec82323
LMI
5232 (push (cons number gnus-low-score-mark)
5233 gnus-newsgroup-reads))))
5234
5235 (when gnus-tmp-header
5236 ;; We may have an old dummy line to output before this
5237 ;; article.
6748645f
LMI
5238 (when (and gnus-tmp-dummy-line
5239 (gnus-subject-equal
5240 gnus-tmp-dummy-line
5241 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
5242 (gnus-summary-insert-dummy-line
5243 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5244 (setq gnus-tmp-dummy-line nil))
5245
5246 ;; Compute the mark.
5247 (setq gnus-tmp-unread (gnus-article-mark number))
5248
5249 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5250 gnus-tmp-header gnus-tmp-level)
5251 gnus-newsgroup-data)
5252
5253 ;; Actually insert the line.
5254 (setq
5255 gnus-tmp-subject-or-nil
5256 (cond
5257 ((and gnus-thread-ignore-subject
5258 gnus-tmp-prev-subject
23f87bed 5259 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5260 subject)
5261 ((zerop gnus-tmp-level)
5262 (if (and (eq gnus-summary-make-false-root 'empty)
5263 (memq number gnus-tmp-gathered)
5264 gnus-tmp-prev-subject
23f87bed 5265 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5266 gnus-summary-same-subject
5267 subject))
5268 (t gnus-summary-same-subject)))
5269 (if (and (eq gnus-summary-make-false-root 'adopt)
5270 (= gnus-tmp-level 1)
5271 (memq number gnus-tmp-gathered))
5272 (setq gnus-tmp-opening-bracket ?\<
5273 gnus-tmp-closing-bracket ?\>)
5274 (setq gnus-tmp-opening-bracket ?\[
5275 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5276 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5277 (gnus-make-thread-indent-array
5278 (max (* 2 (length gnus-thread-indent-array))
5279 gnus-tmp-level)))
eec82323
LMI
5280 (setq
5281 gnus-tmp-indentation
5282 (aref gnus-thread-indent-array gnus-tmp-level)
5283 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5284 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5285 gnus-summary-default-score 0)
5286 gnus-tmp-score-char
5287 (if (or (null gnus-summary-default-score)
5288 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5289 gnus-summary-zcore-fuzz))
23f87bed 5290 ? ;Whitespace
eec82323
LMI
5291 (if (< gnus-tmp-score gnus-summary-default-score)
5292 gnus-score-below-mark gnus-score-over-mark))
5293 gnus-tmp-replied
5294 (cond ((memq number gnus-newsgroup-processable)
5295 gnus-process-mark)
5296 ((memq number gnus-newsgroup-cached)
5297 gnus-cached-mark)
5298 ((memq number gnus-newsgroup-replied)
5299 gnus-replied-mark)
23f87bed
MB
5300 ((memq number gnus-newsgroup-forwarded)
5301 gnus-forwarded-mark)
eec82323
LMI
5302 ((memq number gnus-newsgroup-saved)
5303 gnus-saved-mark)
23f87bed
MB
5304 ((memq number gnus-newsgroup-recent)
5305 gnus-recent-mark)
5306 ((memq number gnus-newsgroup-unseen)
5307 gnus-unseen-mark)
5308 (t gnus-no-mark))
5309 gnus-tmp-downloaded
5310 (cond ((memq number gnus-newsgroup-undownloaded)
5311 gnus-undownloaded-mark)
5312 (gnus-newsgroup-agentized
5313 gnus-downloaded-mark)
5314 (t
5315 gnus-no-mark))
eec82323
LMI
5316 gnus-tmp-from (mail-header-from gnus-tmp-header)
5317 gnus-tmp-name
5318 (cond
5319 ((string-match "<[^>]+> *$" gnus-tmp-from)
5320 (setq beg-match (match-beginning 0))
23f87bed
MB
5321 (or (and (string-match "^\".+\"" gnus-tmp-from)
5322 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5323 (substring gnus-tmp-from 0 beg-match)))
5324 ((string-match "(.+)" gnus-tmp-from)
5325 (substring gnus-tmp-from
5326 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5327 (t gnus-tmp-from))
5328
5329 ;; Do the %B string
5330 gnus-tmp-thread-tree-header-string
5331 (cond
5332 ((not gnus-show-threads) "")
5333 ((zerop gnus-tmp-level)
5334 (cond ((cdar thread)
5335 (or gnus-sum-thread-tree-root subject))
5336 (gnus-tmp-new-adopts
5337 (or gnus-sum-thread-tree-false-root subject))
5338 (t
5339 (or gnus-sum-thread-tree-single-indent subject))))
5340 (t
5341 (concat (apply 'concat
5342 (mapcar (lambda (item)
5343 (if (= item 1)
5344 gnus-sum-thread-tree-vertical
5345 gnus-sum-thread-tree-indent))
5346 (cdr (reverse tree-stack))))
5347 (if (nth 1 thread)
5348 gnus-sum-thread-tree-leaf-with-other
5349 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5350 (when (string= gnus-tmp-name "")
5351 (setq gnus-tmp-name gnus-tmp-from))
5352 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5353 (setq gnus-tmp-lines -1))
5354 (if (= gnus-tmp-lines -1)
5355 (setq gnus-tmp-lines "?")
5356 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5357 (gnus-put-text-property
64763fe3
MB
5358 (point)
5359 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 5360 'gnus-number number)
64763fe3
MB
5361 (when gnus-visual-p
5362 (forward-line -1)
5363 (gnus-run-hooks 'gnus-summary-update-hook)
5364 (forward-line 1))
eec82323 5365
64763fe3 5366 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5367
5368 (when (nth 1 thread)
23f87bed
MB
5369 (push (list (max 0 gnus-tmp-level)
5370 (copy-sequence tree-stack)
5371 (nthcdr 1 thread))
5372 stack))
5373 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5374 (incf gnus-tmp-level)
5375 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5376 (if gnus-summary-display-while-building
5377 (if building-count
5378 (progn
5379 ;; use a set frequency
5380 (setq building-line-count (1- building-line-count))
5381 (when (= building-line-count 0)
5382 (sit-for 0)
5383 (setq building-line-count
5384 gnus-summary-display-while-building)))
5385 ;; always
5386 (sit-for 0)))
eec82323
LMI
5387 (unless threads
5388 (setq gnus-tmp-level 0)))))
5389 (gnus-message 7 "Generating summary...done"))
5390
5391(defun gnus-summary-prepare-unthreaded (headers)
5392 "Generate an unthreaded summary buffer based on HEADERS."
5393 (let (header number mark)
5394
5395 (beginning-of-line)
5396
5397 (while headers
5398 ;; We may have to root out some bad articles...
5399 (when (memq (setq number (mail-header-number
5400 (setq header (pop headers))))
5401 gnus-newsgroup-limit)
5402 ;; Mark article as read when it has a low score.
5403 (when (and gnus-summary-mark-below
5404 (< (or (cdr (assq number gnus-newsgroup-scored))
5405 gnus-summary-default-score 0)
5406 gnus-summary-mark-below)
5407 (not (gnus-summary-article-ancient-p number)))
5408 (setq gnus-newsgroup-unreads
5409 (delq number gnus-newsgroup-unreads))
5410 (if gnus-newsgroup-auto-expire
5411 (push number gnus-newsgroup-expirable)
5412 (push (cons number gnus-low-score-mark)
5413 gnus-newsgroup-reads)))
5414
5415 (setq mark (gnus-article-mark number))
5416 (push (gnus-data-make number mark (1+ (point)) header 0)
5417 gnus-newsgroup-data)
5418 (gnus-summary-insert-line
5419 header 0 number
23f87bed 5420 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5421 mark (memq number gnus-newsgroup-replied)
5422 (memq number gnus-newsgroup-expirable)
5423 (mail-header-subject header) nil
5424 (cdr (assq number gnus-newsgroup-scored))
5425 (memq number gnus-newsgroup-processable))))))
5426
16409b0b
GM
5427(defun gnus-summary-remove-list-identifiers ()
5428 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5429 (let ((regexp (if (consp gnus-list-identifiers)
5430 (mapconcat 'identity gnus-list-identifiers " *\\|")
5431 gnus-list-identifiers))
5432 changed subject)
5433 (when regexp
01c52d31 5434 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
23f87bed
MB
5435 (dolist (header gnus-newsgroup-headers)
5436 (setq subject (mail-header-subject header)
5437 changed nil)
01c52d31 5438 (while (string-match regexp subject)
23f87bed 5439 (setq subject
01c52d31 5440 (concat (substring subject 0 (match-beginning 1))
23f87bed
MB
5441 (substring subject (match-end 0)))
5442 changed t))
23f87bed 5443 (when changed
01c52d31
MB
5444 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5445 (setq subject
5446 (concat (substring subject 0 (match-beginning 1))
5447 (substring subject (match-end 1)))))
23f87bed
MB
5448 (mail-header-set-subject header subject))))))
5449
5450(defun gnus-fetch-headers (articles)
5451 "Fetch headers of ARTICLES."
5452 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5453 (gnus-message 5 "Fetching headers for %s..." name)
5454 (prog1
5455 (if (eq 'nov
5456 (setq gnus-headers-retrieved-by
5457 (gnus-retrieve-headers
5458 articles gnus-newsgroup-name
5459 ;; We might want to fetch old headers, but
5460 ;; not if there is only 1 article.
5461 (and (or (and
5462 (not (eq gnus-fetch-old-headers 'some))
5463 (not (numberp gnus-fetch-old-headers)))
5464 (> (length articles) 1))
5465 gnus-fetch-old-headers))))
5466 (gnus-get-newsgroup-headers-xover
5467 articles nil nil gnus-newsgroup-name t)
5468 (gnus-get-newsgroup-headers))
5469 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5470
6748645f 5471(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5472 "Select newsgroup GROUP.
6748645f
LMI
5473If READ-ALL is non-nil, all articles in the group are selected.
5474If SELECT-ARTICLES, only select those articles from GROUP."
01c52d31 5475 (let* ((entry (gnus-group-entry group))
eec82323
LMI
5476 ;;!!! Dirty hack; should be removed.
5477 (gnus-summary-ignore-duplicates
23f87bed 5478 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5479 t
5480 gnus-summary-ignore-duplicates))
5481 (info (nth 2 entry))
01c52d31 5482 charset articles fetched-articles cached)
eec82323
LMI
5483
5484 (unless (gnus-check-server
475e0e0c
GM
5485 (set (make-local-variable 'gnus-current-select-method)
5486 (gnus-find-method-for-group group)))
eec82323 5487 (error "Couldn't open server"))
01c52d31 5488 (setq charset (gnus-group-name-charset gnus-current-select-method group))
eec82323
LMI
5489
5490 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5491 (gnus-activate-group group) ; Or we can activate it...
5492 (progn ; Or we bug out.
5493 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5494 (gnus-kill-buffer (current-buffer)))
01c52d31
MB
5495 (error
5496 "Couldn't activate group %s: %s"
5497 (mm-decode-coding-string group charset)
5498 (mm-decode-coding-string (gnus-status-message group) charset))))
eec82323
LMI
5499
5500 (unless (gnus-request-group group t)
01c52d31
MB
5501 (when (equal major-mode 'gnus-summary-mode)
5502 (gnus-kill-buffer (current-buffer)))
5503 (error "Couldn't request group %s: %s"
5504 (mm-decode-coding-string group charset)
5505 (mm-decode-coding-string (gnus-status-message group) charset)))
eec82323 5506
23f87bed 5507 (when gnus-agent
54506618 5508 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5509
23f87bed
MB
5510 (setq gnus-summary-use-undownloaded-faces
5511 (gnus-agent-find-parameter
5512 group
5513 'agent-enable-undownloaded-faces)))
5514
5515 (setq gnus-newsgroup-name group
5516 gnus-newsgroup-unselected nil
5517 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5518
5519 (let ((display (gnus-group-find-parameter group 'display)))
5520 (setq gnus-newsgroup-display
5521 (cond
5522 ((not (zerop (or (car-safe read-all) 0)))
5523 ;; The user entered the group with C-u SPC/RET, let's show
5524 ;; all articles.
5525 'gnus-not-ignore)
5526 ((eq display 'all)
5527 'gnus-not-ignore)
5528 ((arrayp display)
5529 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5530 ((numberp display)
5531 ;; The following is probably the "correct" solution, but
5532 ;; it makes Gnus fetch all headers and then limit the
5533 ;; articles (which is slow), so instead we hack the
5534 ;; select-articles parameter instead. -- Simon Josefsson
5535 ;; <jas@kth.se>
5536 ;;
5537 ;; (gnus-byte-compile
5538 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5539 ;; display)))))
5540 (setq select-articles
5541 (gnus-uncompress-range
5542 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5543 (if (> tmp 0)
5544 tmp
5545 1))
5546 (cdr (gnus-active group)))))
5547 nil)
5548 (t
5549 nil))))
eec82323 5550
23f87bed 5551 (gnus-summary-setup-default-charset)
eec82323
LMI
5552
5553 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5554 (when (gnus-virtual-group-p group)
5555 (setq cached gnus-newsgroup-cached))
5556
5557 (setq gnus-newsgroup-unreads
23f87bed
MB
5558 (gnus-sorted-ndifference
5559 (gnus-sorted-ndifference gnus-newsgroup-unreads
5560 gnus-newsgroup-marked)
eec82323
LMI
5561 gnus-newsgroup-dormant))
5562
5563 (setq gnus-newsgroup-processable nil)
5564
5565 (gnus-update-read-articles group gnus-newsgroup-unreads)
eec82323 5566
23f87bed
MB
5567 ;; Adjust and set lists of article marks.
5568 (when info
5569 (gnus-adjust-marked-articles info))
6748645f
LMI
5570 (if (setq articles select-articles)
5571 (setq gnus-newsgroup-unselected
23f87bed 5572 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5573 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5574
5575 (cond
5576 ((null articles)
5577 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5578 'quit)
5579 ((eq articles 0) nil)
5580 (t
5581 ;; Init the dependencies hash table.
5582 (setq gnus-newsgroup-dependencies
5583 (gnus-make-hashtable (length articles)))
16409b0b 5584 (gnus-set-global-variables)
eec82323 5585 ;; Retrieve the headers and read them in.
23f87bed
MB
5586
5587 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5588
5589 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5590 (when cached
5591 (setq gnus-newsgroup-cached cached))
5592
5593 ;; Suppress duplicates?
5594 (when gnus-suppress-duplicates
5595 (gnus-dup-suppress-articles))
5596
5597 ;; Set the initial limit.
5598 (setq gnus-newsgroup-limit (copy-sequence articles))
5599 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5600 (setq fetched-articles
5601 (mapcar (lambda (headers) (mail-header-number headers))
5602 gnus-newsgroup-headers))
5603 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5604 (setq gnus-newsgroup-unreads
23f87bed
MB
5605 (gnus-sorted-nintersection
5606 gnus-newsgroup-unreads fetched-articles))
5607 (gnus-compute-unseen-list)
5608
eec82323
LMI
5609 ;; Removed marked articles that do not exist.
5610 (gnus-update-missing-marks
23f87bed 5611 (gnus-sorted-difference articles fetched-articles))
eec82323 5612 ;; We might want to build some more threads first.
6748645f
LMI
5613 (when (and gnus-fetch-old-headers
5614 (eq gnus-headers-retrieved-by 'nov))
5615 (if (eq gnus-fetch-old-headers 'invisible)
5616 (gnus-build-all-threads)
5617 (gnus-build-old-threads)))
5618 ;; Let the Gnus agent mark articles as read.
5619 (when gnus-agent
5620 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5621 ;; Remove list identifiers from subject
5622 (when gnus-list-identifiers
5623 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5624 ;; Check whether auto-expire is to be done in this group.
5625 (setq gnus-newsgroup-auto-expire
5626 (gnus-group-auto-expirable-p group))
5627 ;; Set up the article buffer now, if necessary.
01c52d31
MB
5628 (unless (and gnus-single-article-buffer
5629 (equal gnus-article-buffer "*Article*"))
eec82323
LMI
5630 (gnus-article-setup-buffer))
5631 ;; First and last article in this newsgroup.
5632 (when gnus-newsgroup-headers
5633 (setq gnus-newsgroup-begin
5634 (mail-header-number (car gnus-newsgroup-headers))
5635 gnus-newsgroup-end
5636 (mail-header-number
5637 (gnus-last-element gnus-newsgroup-headers))))
5638 ;; GROUP is successfully selected.
5639 (or gnus-newsgroup-headers t)))))
5640
23f87bed
MB
5641(defun gnus-compute-unseen-list ()
5642 ;; The `seen' marks are treated specially.
5643 (if (not gnus-newsgroup-seen)
5644 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5645 (setq gnus-newsgroup-unseen
5646 (gnus-inverse-list-range-intersection
5647 gnus-newsgroup-articles gnus-newsgroup-seen))))
5648
d09ae6ca
GM
5649(declare-function gnus-get-predicate "gnus-agent" (predicate))
5650
23f87bed
MB
5651(defun gnus-summary-display-make-predicate (display)
5652 (require 'gnus-agent)
5653 (when (= (length display) 1)
5654 (setq display (car display)))
5655 (unless gnus-summary-display-cache
5656 (dolist (elem (append '((unread . unread)
5657 (read . read)
5658 (unseen . unseen))
5659 gnus-article-mark-lists))
5660 (push (cons (cdr elem)
5661 (gnus-byte-compile
5662 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5663 gnus-summary-display-cache)))
5664 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5665 (gnus-category-predicate-cache gnus-summary-display-cache))
5666 (gnus-get-predicate display)))
5667
5668;; Uses the dynamically bound `number' variable.
9efa445f 5669(defvar number)
23f87bed
MB
5670(defun gnus-article-marked-p (type &optional article)
5671 (let ((article (or article number)))
5672 (cond
5673 ((eq type 'tick)
5674 (memq article gnus-newsgroup-marked))
5675 ((eq type 'spam)
5676 (memq article gnus-newsgroup-spam-marked))
5677 ((eq type 'unsend)
5678 (memq article gnus-newsgroup-unsendable))
5679 ((eq type 'undownload)
5680 (memq article gnus-newsgroup-undownloaded))
5681 ((eq type 'download)
5682 (memq article gnus-newsgroup-downloadable))
5683 ((eq type 'unread)
5684 (memq article gnus-newsgroup-unreads))
5685 ((eq type 'read)
5686 (memq article gnus-newsgroup-reads))
5687 ((eq type 'dormant)
5688 (memq article gnus-newsgroup-dormant) )
5689 ((eq type 'expire)
5690 (memq article gnus-newsgroup-expirable))
5691 ((eq type 'reply)
5692 (memq article gnus-newsgroup-replied))
5693 ((eq type 'killed)
5694 (memq article gnus-newsgroup-killed))
5695 ((eq type 'bookmark)
5696 (assq article gnus-newsgroup-bookmarks))
5697 ((eq type 'score)
5698 (assq article gnus-newsgroup-scored))
5699 ((eq type 'save)
5700 (memq article gnus-newsgroup-saved))
5701 ((eq type 'cache)
5702 (memq article gnus-newsgroup-cached))
5703 ((eq type 'forward)
5704 (memq article gnus-newsgroup-forwarded))
5705 ((eq type 'seen)
5706 (not (memq article gnus-newsgroup-unseen)))
5707 ((eq type 'recent)
5708 (memq article gnus-newsgroup-recent))
5709 (t t))))
5710
eec82323 5711(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5712 "Find out what articles the user wants to read."
26c9afc3 5713 (let* ((articles
eec82323
LMI
5714 ;; Select all articles if `read-all' is non-nil, or if there
5715 ;; are no unread articles.
5716 (if (or read-all
5717 (and (zerop (length gnus-newsgroup-marked))
5718 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5719 ;; Fetch all if the predicate is non-nil.
5720 gnus-newsgroup-display)
5721 ;; We want to select the headers for all the articles in
5722 ;; the group, so we select either all the active
5723 ;; articles in the group, or (if that's nil), the
5724 ;; articles in the cache.
16409b0b 5725 (or
4b70e299 5726 (if gnus-newsgroup-maximum-articles
11abff8e
MB
5727 (let ((active (gnus-active group)))
5728 (gnus-uncompress-range
5729 (cons (max (car active)
4b70e299
MB
5730 (- (cdr active)
5731 gnus-newsgroup-maximum-articles
5732 -1))
11abff8e
MB
5733 (cdr active))))
5734 (gnus-uncompress-range (gnus-active group)))
16409b0b 5735 (gnus-cache-articles-in-group group))
23f87bed
MB
5736 ;; Select only the "normal" subset of articles.
5737 (gnus-sorted-nunion
5738 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5739 gnus-newsgroup-unreads)))
eec82323
LMI
5740 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5741 (scored (length scored-list))
5742 (number (length articles))
5743 (marked (+ (length gnus-newsgroup-marked)
5744 (length gnus-newsgroup-dormant)))
5745 (select
5746 (cond
5747 ((numberp read-all)
5748 read-all)
23f87bed
MB
5749 ((numberp gnus-newsgroup-display)
5750 gnus-newsgroup-display)
eec82323
LMI
5751 (t
5752 (condition-case ()
5753 (cond
5754 ((and (or (<= scored marked) (= scored number))
5755 (numberp gnus-large-newsgroup)
5756 (> number gnus-large-newsgroup))
23f87bed
MB
5757 (let* ((cursor-in-echo-area nil)
5758 (initial (gnus-parameter-large-newsgroup-initial
5759 gnus-newsgroup-name))
5760 (input
5761 (read-string
5762 (format
5763 "How many articles from %s (%s %d): "
01c52d31 5764 (gnus-group-decoded-name gnus-newsgroup-name)
23f87bed
MB
5765 (if initial "max" "default")
5766 number)
5767 (if initial
5768 (cons (number-to-string initial)
5769 0)))))
eec82323
LMI
5770 (if (string-match "^[ \t]*$" input) number input)))
5771 ((and (> scored marked) (< scored number)
5772 (> (- scored number) 20))
5773 (let ((input
5774 (read-string
5775 (format "%s %s (%d scored, %d total): "
5776 "How many articles from"
23f87bed
MB
5777 (gnus-group-decoded-name group)
5778 scored number))))
eec82323
LMI
5779 (if (string-match "^[ \t]*$" input)
5780 number input)))
5781 (t number))
d4dfaa19
DL
5782 (quit
5783 (message "Quit getting the articles to read")
5784 nil))))))
eec82323
LMI
5785 (setq select (if (stringp select) (string-to-number select) select))
5786 (if (or (null select) (zerop select))
5787 select
5788 (if (and (not (zerop scored)) (<= (abs select) scored))
5789 (progn
5790 (setq articles (sort scored-list '<))
5791 (setq number (length articles)))
5792 (setq articles (copy-sequence articles)))
5793
5794 (when (< (abs select) number)
5795 (if (< select 0)
5796 ;; Select the N oldest articles.
5797 (setcdr (nthcdr (1- (abs select)) articles) nil)
5798 ;; Select the N most recent articles.
5799 (setq articles (nthcdr (- number select) articles))))
5800 (setq gnus-newsgroup-unselected
23f87bed 5801 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5802 (when gnus-alter-articles-to-read-function
23f87bed 5803 (setq articles
a1506d29 5804 (sort
16409b0b 5805 (funcall gnus-alter-articles-to-read-function
23f87bed 5806 gnus-newsgroup-name articles)
16409b0b 5807 '<)))
eec82323
LMI
5808 articles)))
5809
5810(defun gnus-killed-articles (killed articles)
5811 (let (out)
5812 (while articles
5813 (when (inline (gnus-member-of-range (car articles) killed))
5814 (push (car articles) out))
5815 (setq articles (cdr articles)))
5816 out))
5817
5818(defun gnus-uncompress-marks (marks)
5819 "Uncompress the mark ranges in MARKS."
5820 (let ((uncompressed '(score bookmark))
5821 out)
5822 (while marks
5823 (if (memq (caar marks) uncompressed)
5824 (push (car marks) out)
5825 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5826 (setq marks (cdr marks)))
5827 out))
5828
23f87bed
MB
5829(defun gnus-article-mark-to-type (mark)
5830 "Return the type of MARK."
5831 (or (cadr (assq mark gnus-article-special-mark-lists))
5832 'list))
5833
5834(defun gnus-article-unpropagatable-p (mark)
5835 "Return whether MARK should be propagated to back end."
5836 (memq mark gnus-article-unpropagated-mark-lists))
5837
eec82323 5838(defun gnus-adjust-marked-articles (info)
16409b0b 5839 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5840 (let* ((marked-lists (gnus-info-marks info))
5841 (active (gnus-active (gnus-info-group info)))
5842 (min (car active))
5843 (max (cdr active))
5844 (types gnus-article-mark-lists)
54506618
MB
5845 marks var articles article mark mark-type
5846 bgn end)
eec82323 5847
23f87bed
MB
5848 (dolist (marks marked-lists)
5849 (setq mark (car marks)
5850 mark-type (gnus-article-mark-to-type mark)
5851 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5852
23f87bed
MB
5853 ;; We set the variable according to the type of the marks list,
5854 ;; and then adjust the marks to a subset of the active articles.
eec82323 5855 (cond
54506618 5856 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5857 ((eq mark-type 'list)
54506618
MB
5858 ;; Simultaneously uncompress and clip to active range
5859 ;; See gnus-uncompress-range for a description of possible marks
5860 (let (l lh)
5861 (if (not (cadr marks))
5862 (set var nil)
5863 (setq articles (if (numberp (cddr marks))
5864 (list (cdr marks))
5865 (cdr marks))
5866 lh (cons nil nil)
5867 l lh)
5868
5869 (while (setq article (pop articles))
5870 (cond ((consp article)
5871 (setq bgn (max (car article) min)
5872 end (min (cdr article) max))
5873 (while (<= bgn end)
5874 (setq l (setcdr l (cons bgn nil))
5875 bgn (1+ bgn))))
5876 ((and (<= min article)
5877 (>= max article))
5878 (setq l (setcdr l (cons article nil))))))
5879 (set var (cdr lh)))))
eec82323 5880 ;; Adjust assocs.
23f87bed
MB
5881 ((eq mark-type 'tuple)
5882 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5883 (when (not (listp (cdr (symbol-value var))))
5884 (set var (list (symbol-value var))))
5885 (when (not (listp (cdr articles)))
5886 (setq articles (list articles)))
eec82323
LMI
5887 (while articles
5888 (when (or (not (consp (setq article (pop articles))))
5889 (< (car article) min)
5890 (> (car article) max))
23f87bed
MB
5891 (set var (delq article (symbol-value var))))))
5892 ;; Adjust ranges (sloppily).
5893 ((eq mark-type 'range)
5894 (cond
5895 ((eq mark 'seen)
5896 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5897 ;; It should be (seen (NUM1 . NUM2)).
5898 (when (numberp (cddr marks))
5899 (setcdr marks (list (cdr marks))))
5900 (setq articles (cdr marks))
5901 (while (and articles
5902 (or (and (consp (car articles))
5903 (> min (cdar articles)))
5904 (and (numberp (car articles))
5905 (> min (car articles)))))
5906 (pop articles))
5907 (set var articles))))))))
eec82323
LMI
5908
5909(defun gnus-update-missing-marks (missing)
6748645f 5910 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 5911 (when missing
23f87bed 5912 (let (var m)
eec82323 5913 ;; Go through all types.
23f87bed
MB
5914 (dolist (elem gnus-article-mark-lists)
5915 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5916 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5917 (when (symbol-value var)
5918 ;; This list has articles. So we delete all missing
5919 ;; articles from it.
5920 (setq m missing)
5921 (while m
5922 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
5923
5924(defun gnus-update-marks ()
5925 "Enter the various lists of marked articles into the newsgroup info list."
5926 (let ((types gnus-article-mark-lists)
5927 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 5928 type list newmarked symbol delta-marks)
eec82323 5929 (when info
16409b0b 5930 ;; Add all marks lists to the list of marks lists.
eec82323 5931 (while (setq type (pop types))
16409b0b
GM
5932 (setq list (symbol-value
5933 (setq symbol
23f87bed 5934 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 5935
16409b0b 5936 (when list
eec82323
LMI
5937 ;; Get rid of the entries of the articles that have the
5938 ;; default score.
5939 (when (and (eq (cdr type) 'score)
5940 gnus-save-score
5941 list)
5942 (let* ((arts list)
5943 (prev (cons nil list))
5944 (all prev))
5945 (while arts
5946 (if (or (not (consp (car arts)))
5947 (= (cdar arts) gnus-summary-default-score))
5948 (setcdr prev (cdr arts))
5949 (setq prev arts))
5950 (setq arts (cdr arts)))
16409b0b
GM
5951 (setq list (cdr all)))))
5952
23f87bed
MB
5953 (when (eq (cdr type) 'seen)
5954 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5955
5956 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 5957 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 5958
23f87bed
MB
5959 (when (and (gnus-check-backend-function
5960 'request-set-mark gnus-newsgroup-name)
5961 (not (gnus-article-unpropagatable-p (cdr type))))
5962 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5963 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5964 (add (gnus-remove-from-range
5965 (gnus-copy-sequence list) old)))
5966 (when add
5967 (push (list add 'add (list (cdr type))) delta-marks))
5968 (when del
5969 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 5970
16409b0b
GM
5971 (when list
5972 (push (cons (cdr type) list) newmarked)))
5973
5974 (when delta-marks
5975 (unless (gnus-check-group gnus-newsgroup-name)
5976 (error "Can't open server for %s" gnus-newsgroup-name))
5977 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 5978
eec82323
LMI
5979 ;; Enter these new marks into the info of the group.
5980 (if (nthcdr 3 info)
5981 (setcar (nthcdr 3 info) newmarked)
5982 ;; Add the marks lists to the end of the info.
5983 (when newmarked
5984 (setcdr (nthcdr 2 info) (list newmarked))))
5985
5986 ;; Cut off the end of the info if there's nothing else there.
5987 (let ((i 5))
5988 (while (and (> i 2)
5989 (not (nth i info)))
5990 (when (nthcdr (decf i) info)
5991 (setcdr (nthcdr i info) nil)))))))
5992
5993(defun gnus-set-mode-line (where)
16409b0b 5994 "Set the mode line of the article or summary buffers.
eec82323
LMI
5995If WHERE is `summary', the summary mode line format will be used."
5996 ;; Is this mode line one we keep updated?
16409b0b
GM
5997 (when (and (memq where gnus-updated-mode-lines)
5998 (symbol-value
5999 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323 6000 (let (mode-string)
c7a91ce1
SM
6001 ;; We evaluate this in the summary buffer since these
6002 ;; variables are buffer-local to that buffer.
6003 (with-current-buffer gnus-summary-buffer
6004 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
6005 ;; below.
6006 (let* ((mformat (symbol-value
6007 (intern
6008 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
6009 (gnus-tmp-group-name (gnus-mode-string-quote
6010 (gnus-group-decoded-name
6011 gnus-newsgroup-name)))
eec82323
LMI
6012 (gnus-tmp-article-number (or gnus-current-article 0))
6013 (gnus-tmp-unread gnus-newsgroup-unreads)
6014 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6015 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6016 (gnus-tmp-unread-and-unselected
6017 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6018 (zerop gnus-tmp-unselected))
6019 "")
6020 ((zerop gnus-tmp-unselected)
6021 (format "{%d more}" gnus-tmp-unread-and-unticked))
6022 (t (format "{%d(+%d) more}"
6023 gnus-tmp-unread-and-unticked
6024 gnus-tmp-unselected))))
6025 (gnus-tmp-subject
6026 (if (and gnus-current-headers
6027 (vectorp gnus-current-headers))
6028 (gnus-mode-string-quote
6029 (mail-header-subject gnus-current-headers))
6030 ""))
6031 bufname-length max-len
23f87bed 6032 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
6033 (setq mode-string (eval mformat))
6034 (setq bufname-length (if (string-match "%b" mode-string)
6035 (- (length
6036 (buffer-name
6037 (if (eq where 'summary)
6038 nil
6039 (get-buffer gnus-article-buffer))))
6040 2)
6041 0))
6042 (setq max-len (max 4 (if gnus-mode-non-string-length
6043 (- (window-width)
6044 gnus-mode-non-string-length
6045 bufname-length)
6046 (length mode-string))))
6047 ;; We might have to chop a bit of the string off...
6048 (when (> (length mode-string) max-len)
6049 (setq mode-string
16409b0b 6050 (concat (truncate-string-to-width mode-string (- max-len 3))
eec82323
LMI
6051 "...")))
6052 ;; Pad the mode string a bit.
6053 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
6054 ;; Update the mode line.
6055 (setq mode-line-buffer-identification
6056 (gnus-mode-line-buffer-identification (list mode-string)))
6057 (set-buffer-modified-p t))))
6058
6059(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6060 "Go through the HEADERS list and add all Xrefs to a hash table.
6061The resulting hash table is returned, or nil if no Xrefs were found."
6062 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6063 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6064 (xref-hashtb (gnus-make-hashtable))
6065 start group entry number xrefs header)
6066 (while headers
6067 (setq header (pop headers))
6068 (when (and (setq xrefs (mail-header-xref header))
6069 (not (memq (setq number (mail-header-number header))
6070 unreads)))
6071 (setq start 0)
6072 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6073 (setq start (match-end 0))
6074 (setq group (if prefix
6075 (concat prefix (substring xrefs (match-beginning 1)
6076 (match-end 1)))
6077 (substring xrefs (match-beginning 1) (match-end 1))))
6078 (setq number
e9bd5782 6079 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
6080 (match-end 2))))
6081 (if (setq entry (gnus-gethash group xref-hashtb))
6082 (setcdr entry (cons number (cdr entry)))
6083 (gnus-sethash group (cons number nil) xref-hashtb)))))
6084 (and start xref-hashtb)))
6085
6086(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6087 "Look through all the headers and mark the Xrefs as read."
6088 (let ((virtual (gnus-virtual-group-p from-newsgroup))
01c52d31 6089 name info xref-hashtb idlist method nth4)
398a825b 6090 (with-current-buffer gnus-group-buffer
eec82323
LMI
6091 (when (setq xref-hashtb
6092 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6093 (mapatoms
6094 (lambda (group)
6095 (unless (string= from-newsgroup (setq name (symbol-name group)))
6096 (setq idlist (symbol-value group))
6097 ;; Dead groups are not updated.
6098 (and (prog1
01c52d31 6099 (setq info (gnus-get-info name))
eec82323
LMI
6100 (when (stringp (setq nth4 (gnus-info-method info)))
6101 (setq nth4 (gnus-server-to-method nth4))))
6102 ;; Only do the xrefs if the group has the same
6103 ;; select method as the group we have just read.
6104 (or (gnus-methods-equal-p
6105 nth4 (gnus-find-method-for-group from-newsgroup))
6106 virtual
6107 (equal nth4 (setq method (gnus-find-method-for-group
6108 from-newsgroup)))
6109 (and (equal (car nth4) (car method))
6110 (equal (nth 1 nth4) (nth 1 method))))
6111 gnus-use-cross-reference
6112 (or (not (eq gnus-use-cross-reference t))
6113 virtual
6114 ;; Only do cross-references on subscribed
6115 ;; groups, if that is what is wanted.
6116 (<= (gnus-info-level info) gnus-level-subscribed))
6117 (gnus-group-make-articles-read name idlist))))
6118 xref-hashtb)))))
6119
6748645f 6120(defun gnus-compute-read-articles (group articles)
01c52d31 6121 (let* ((entry (gnus-group-entry group))
6748645f
LMI
6122 (info (nth 2 entry))
6123 (active (gnus-active group))
6124 ninfo)
6125 (when entry
16409b0b 6126 ;; First peel off all invalid article numbers.
6748645f
LMI
6127 (when active
6128 (let ((ids articles)
6129 id first)
6130 (while (setq id (pop ids))
6131 (when (and first (> id (cdr active)))
6132 ;; We'll end up in this situation in one particular
6133 ;; obscure situation. If you re-scan a group and get
6134 ;; a new article that is cross-posted to a different
6135 ;; group that has not been re-scanned, you might get
6136 ;; crossposted article that has a higher number than
6137 ;; Gnus believes possible. So we re-activate this
6138 ;; group as well. This might mean doing the
6139 ;; crossposting thingy will *increase* the number
6140 ;; of articles in some groups. Tsk, tsk.
6141 (setq active (or (gnus-activate-group group) active)))
6142 (when (or (> id (cdr active))
6143 (< id (car active)))
6144 (setq articles (delq id articles))))))
6145 ;; If the read list is nil, we init it.
6146 (if (and active
6147 (null (gnus-info-read info))
6148 (> (car active) 1))
6149 (setq ninfo (cons 1 (1- (car active))))
6150 (setq ninfo (gnus-info-read info)))
6151 ;; Then we add the read articles to the range.
6152 (gnus-add-to-range
6153 ninfo (setq articles (sort articles '<))))))
6154
eec82323
LMI
6155(defun gnus-group-make-articles-read (group articles)
6156 "Update the info of GROUP to say that ARTICLES are read."
6157 (let* ((num 0)
01c52d31 6158 (entry (gnus-group-entry group))
eec82323
LMI
6159 (info (nth 2 entry))
6160 (active (gnus-active group))
6161 range)
6748645f
LMI
6162 (when entry
6163 (setq range (gnus-compute-read-articles group articles))
01c52d31 6164 (with-current-buffer gnus-group-buffer
6748645f
LMI
6165 (gnus-undo-register
6166 `(progn
6167 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6168 (gnus-info-set-read ',info ',(gnus-info-read info))
6169 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 6170 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
6171 (gnus-group-update-group ,group t))))
6172 ;; Add the read articles to the range.
6173 (gnus-info-set-read info range)
23f87bed 6174 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
6175 ;; Then we have to re-compute how many unread
6176 ;; articles there are in this group.
6177 (when active
6178 (cond
6179 ((not range)
6180 (setq num (- (1+ (cdr active)) (car active))))
6181 ((not (listp (cdr range)))
6182 (setq num (- (cdr active) (- (1+ (cdr range))
6183 (car range)))))
6184 (t
6185 (while range
6186 (if (numberp (car range))
6187 (setq num (1+ num))
6188 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6189 (setq range (cdr range)))
6190 (setq num (- (cdr active) num))))
6191 ;; Update the number of unread articles.
6192 (setcar entry num)
6193 ;; Update the group buffer.
23f87bed
MB
6194 (unless (gnus-ephemeral-group-p group)
6195 (gnus-group-update-group group t))))))
eec82323 6196
eec82323
LMI
6197(defvar gnus-newsgroup-none-id 0)
6198
6199(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6200 (let ((cur nntp-server-buffer)
6201 (dependencies
6202 (or dependencies
01c52d31
MB
6203 (with-current-buffer gnus-summary-buffer
6204 gnus-newsgroup-dependencies)))
6205 headers id end ref number
16409b0b
GM
6206 (mail-parse-charset gnus-newsgroup-charset)
6207 (mail-parse-ignored-charsets
c7a91ce1
SM
6208 (save-current-buffer (condition-case nil
6209 (set-buffer gnus-summary-buffer)
6210 (error))
6211 gnus-newsgroup-ignored-charsets)))
6212 (with-current-buffer nntp-server-buffer
eec82323
LMI
6213 ;; Translate all TAB characters into SPACE characters.
6214 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 6215 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 6216 (ietf-drums-unfold-fws)
6748645f 6217 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6218 (let ((case-fold-search t)
6748645f 6219 in-reply-to header p lines chars)
eec82323 6220 (goto-char (point-min))
01ccbb85 6221 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
6222 ;; do not begin with 2 or 3.
6223 (while (re-search-forward "^[23][0-9]+ " nil t)
6224 (setq id nil
6225 ref nil)
6226 ;; This implementation of this function, with nine
6227 ;; search-forwards instead of the one re-search-forward and
6228 ;; a case (which basically was the old function) is actually
01ccbb85 6229 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
6230 ;; can't have everything, I guess. Speed and elegance
6231 ;; doesn't always go hand in hand.
6232 (setq
6233 header
6234 (vector
6235 ;; Number.
6236 (prog1
01c52d31 6237 (setq number (read cur))
eec82323
LMI
6238 (end-of-line)
6239 (setq p (point))
6240 (narrow-to-region (point)
6241 (or (and (search-forward "\n.\n" nil t)
6242 (- (point) 2))
6243 (point))))
6244 ;; Subject.
6245 (progn
6246 (goto-char p)
23f87bed 6247 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
6248 (funcall gnus-decode-encoded-word-function
6249 (nnheader-header-value))
2bd3dcae 6250 "(none)"))
eec82323
LMI
6251 ;; From.
6252 (progn
6253 (goto-char p)
23f87bed 6254 (if (search-forward "\nfrom:" nil t)
343d6628 6255 (funcall gnus-decode-encoded-address-function
16409b0b 6256 (nnheader-header-value))
2bd3dcae 6257 "(nobody)"))
eec82323
LMI
6258 ;; Date.
6259 (progn
6260 (goto-char p)
23f87bed 6261 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6262 (nnheader-header-value) ""))
6263 ;; Message-ID.
6264 (progn
6265 (goto-char p)
6748645f
LMI
6266 (setq id (if (re-search-forward
6267 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6268 ;; We do it this way to make sure the Message-ID
6269 ;; is (somewhat) syntactically valid.
6270 (buffer-substring (match-beginning 1)
6271 (match-end 1))
eec82323
LMI
6272 ;; If there was no message-id, we just fake one
6273 ;; to make subsequent routines simpler.
01c52d31 6274 (nnheader-generate-fake-message-id number))))
eec82323
LMI
6275 ;; References.
6276 (progn
6277 (goto-char p)
23f87bed 6278 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6279 (progn
6280 (setq end (point))
6281 (prog1
6282 (nnheader-header-value)
6283 (setq ref
6284 (buffer-substring
6285 (progn
6286 (end-of-line)
6287 (search-backward ">" end t)
6288 (1+ (point)))
6289 (progn
6290 (search-backward "<" end t)
6291 (point))))))
6292 ;; Get the references from the in-reply-to header if there
6293 ;; were no references and the in-reply-to header looks
6294 ;; promising.
23f87bed 6295 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6296 (setq in-reply-to (nnheader-header-value))
6297 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6298 (let (ref2)
6299 (setq ref (substring in-reply-to (match-beginning 0)
6300 (match-end 0)))
6301 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6302 (setq ref2 (substring in-reply-to (match-beginning 0)
6303 (match-end 0)))
6304 (when (> (length ref2) (length ref))
6305 (setq ref ref2)))
6306 ref)
eec82323
LMI
6307 (setq ref nil))))
6308 ;; Chars.
6748645f
LMI
6309 (progn
6310 (goto-char p)
6311 (if (search-forward "\nchars: " nil t)
6312 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6313 chars -1)
6314 -1))
eec82323
LMI
6315 ;; Lines.
6316 (progn
6317 (goto-char p)
6318 (if (search-forward "\nlines: " nil t)
a8151ef7 6319 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6320 lines -1)
6321 -1))
eec82323
LMI
6322 ;; Xref.
6323 (progn
6324 (goto-char p)
23f87bed 6325 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6326 (nnheader-header-value)))
6327 ;; Extra.
6328 (when gnus-extra-headers
6329 (let ((extra gnus-extra-headers)
6330 out)
6331 (while extra
6332 (goto-char p)
6333 (when (search-forward
23f87bed 6334 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6335 (push (cons (car extra) (nnheader-header-value))
6336 out))
6337 (pop extra))
6338 out))))
eec82323
LMI
6339 (when (equal id ref)
6340 (setq ref nil))
6748645f
LMI
6341
6342 (when gnus-alter-header-function
6343 (funcall gnus-alter-header-function header)
6344 (setq id (mail-header-id header)
6345 ref (gnus-parent-id (mail-header-references header))))
6346
6347 (when (setq header
6348 (gnus-dependencies-add-header
6349 header dependencies force-new))
eec82323
LMI
6350 (push header headers))
6351 (goto-char (point-max))
6352 (widen))
6353 (nreverse headers)))))
6354
eec82323
LMI
6355;; Goes through the xover lines and returns a list of vectors
6356(defun gnus-get-newsgroup-headers-xover (sequence &optional
6357 force-new dependencies
6358 group also-fetch-heads)
16409b0b
GM
6359 "Parse the news overview data in the server buffer.
6360Return a list of headers that match SEQUENCE (see
6361`nntp-retrieve-headers')."
eec82323
LMI
6362 ;; Get the Xref when the users reads the articles since most/some
6363 ;; NNTP servers do not include Xrefs when using XOVER.
6364 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6365 (let ((mail-parse-charset gnus-newsgroup-charset)
6366 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6367 (cur nntp-server-buffer)
eec82323 6368 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6369 (allp (cond
6370 ((eq gnus-read-all-available-headers t)
6371 t)
14e6dc54
MB
6372 ((and (stringp gnus-read-all-available-headers)
6373 group)
23f87bed
MB
6374 (string-match gnus-read-all-available-headers group))
6375 (t
6376 nil)))
eec82323 6377 number headers header)
c7a91ce1 6378 (with-current-buffer nntp-server-buffer
16409b0b 6379 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6380 ;; Allow the user to mangle the headers before parsing them.
6748645f 6381 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6382 (goto-char (point-min))
23f87bed
MB
6383 (gnus-parse-without-error
6384 (while (and (or sequence allp)
6385 (not (eobp)))
6386 (setq number (read cur))
6387 (when (not allp)
6388 (while (and sequence
6389 (< (car sequence) number))
6390 (setq sequence (cdr sequence))))
6391 (when (and (or allp
6392 (and sequence
6393 (eq number (car sequence))))
6394 (progn
6395 (setq sequence (cdr sequence))
6396 (setq header (inline
6397 (gnus-nov-parse-line
6398 number dependencies force-new)))))
6399 (push header headers))
6400 (forward-line 1)))
eec82323
LMI
6401 ;; A common bug in inn is that if you have posted an article and
6402 ;; then retrieves the active file, it will answer correctly --
6403 ;; the new article is included. However, a NOV entry for the
6404 ;; article may not have been generated yet, so this may fail.
6405 ;; We work around this problem by retrieving the last few
6406 ;; headers using HEAD.
6407 (if (or (not also-fetch-heads)
6408 (not sequence))
6409 ;; We (probably) got all the headers.
6410 (nreverse headers)
6411 (let ((gnus-nov-is-evil t))
6412 (nconc
6413 (nreverse headers)
23f87bed 6414 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6415 (gnus-get-newsgroup-headers))))))))
6416
6417(defun gnus-article-get-xrefs ()
6418 "Fill in the Xref value in `gnus-current-headers', if necessary.
6419This is meant to be called in `gnus-article-internal-prepare-hook'."
01c52d31
MB
6420 (let ((headers (with-current-buffer gnus-summary-buffer
6421 gnus-current-headers)))
eec82323
LMI
6422 (or (not gnus-use-cross-reference)
6423 (not headers)
6424 (and (mail-header-xref headers)
6425 (not (string= (mail-header-xref headers) "")))
6426 (let ((case-fold-search t)
6427 xref)
6428 (save-restriction
6429 (nnheader-narrow-to-headers)
6430 (goto-char (point-min))
16409b0b
GM
6431 (when (or (and (not (eobp))
6432 (eq (downcase (char-after)) ?x)
eec82323
LMI
6433 (looking-at "Xref:"))
6434 (search-forward "\nXref:" nil t))
6435 (goto-char (1+ (match-end 0)))
01c52d31 6436 (setq xref (buffer-substring (point) (point-at-eol)))
eec82323
LMI
6437 (mail-header-set-xref headers xref)))))))
6438
6439(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6440 "Find article ID and insert the summary line for that article.
6441OLD-HEADER can either be a header or a line number to insert
6442the subject line on."
6443 (let* ((line (and (numberp old-header) old-header))
6444 (old-header (and (vectorp old-header) old-header))
6445 (header (cond ((and old-header use-old-header)
16409b0b
GM
6446 old-header)
6447 ((and (numberp id)
6448 (gnus-number-to-header id))
6449 (gnus-number-to-header id))
6450 (t
6451 (gnus-read-header id))))
6452 (number (and (numberp id) id))
6453 d)
eec82323
LMI
6454 (when header
6455 ;; Rebuild the thread that this article is part of and go to the
6456 ;; article we have fetched.
6457 (when (and (not gnus-show-threads)
6458 old-header)
6748645f
LMI
6459 (when (and number
6460 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6461 (goto-char (gnus-data-pos d))
6462 (gnus-data-remove
6463 number
01c52d31 6464 (- (point-at-bol)
eec82323 6465 (prog1
01c52d31 6466 (1+ (point-at-eol))
eec82323 6467 (gnus-delete-line))))))
23f87bed
MB
6468 ;; Remove list identifiers from subject.
6469 (when gnus-list-identifiers
6470 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6471 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6472 (when old-header
6473 (mail-header-set-number header (mail-header-number old-header)))
6474 (setq gnus-newsgroup-sparse
6475 (delq (setq number (mail-header-number header))
6476 gnus-newsgroup-sparse))
6477 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6478 (push number gnus-newsgroup-limit)
6479 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6480 (gnus-summary-goto-subject number nil t))
6481 (when (and (numberp number)
6482 (> number 0))
6483 ;; We have to update the boundaries even if we can't fetch the
6484 ;; article if ID is a number -- so that the next `P' or `N'
6485 ;; command will fetch the previous (or next) article even
6486 ;; if the one we tried to fetch this time has been canceled.
6487 (when (> number gnus-newsgroup-end)
6488 (setq gnus-newsgroup-end number))
6489 (when (< number gnus-newsgroup-begin)
6490 (setq gnus-newsgroup-begin number))
6491 (setq gnus-newsgroup-unselected
6492 (delq number gnus-newsgroup-unselected)))
6493 ;; Report back a success?
6494 (and header (mail-header-number header))))
6495
6496;;; Process/prefix in the summary buffer
6497
6498(defun gnus-summary-work-articles (n)
6748645f
LMI
6499 "Return a list of articles to be worked upon.
6500The prefix argument, the list of process marked articles, and the
6501current article will be taken into consideration."
c7a91ce1 6502 (with-current-buffer gnus-summary-buffer
6748645f
LMI
6503 (cond
6504 (n
6505 ;; A numerical prefix has been given.
6506 (setq n (prefix-numeric-value n))
6507 (let ((backward (< n 0))
6508 (n (abs (prefix-numeric-value n)))
6509 articles article)
6510 (save-excursion
6511 (while
6512 (and (> n 0)
6513 (push (setq article (gnus-summary-article-number))
6514 articles)
6515 (if backward
6516 (gnus-summary-find-prev nil article)
6517 (gnus-summary-find-next nil article)))
6518 (decf n)))
6519 (nreverse articles)))
6520 ((and (gnus-region-active-p) (mark))
6521 (message "region active")
6522 ;; Work on the region between point and mark.
6523 (let ((max (max (point) (mark)))
6524 articles article)
6525 (save-excursion
7dafe00b 6526 (goto-char (min (point) (mark)))
6748645f
LMI
6527 (while
6528 (and
6529 (push (setq article (gnus-summary-article-number)) articles)
6530 (gnus-summary-find-next nil article)
6531 (< (point) max)))
6532 (nreverse articles))))
6533 (gnus-newsgroup-processable
6534 ;; There are process-marked articles present.
6535 ;; Save current state.
6536 (gnus-summary-save-process-mark)
6537 ;; Return the list.
6538 (reverse gnus-newsgroup-processable))
6539 (t
6540 ;; Just return the current article.
6541 (list (gnus-summary-article-number))))))
6542
6543(defmacro gnus-summary-iterate (arg &rest forms)
6544 "Iterate over the process/prefixed articles and do FORMS.
6545ARG is the interactive prefix given to the command. FORMS will be
6546executed with point over the summary line of the articles."
6547 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6548 `(let ((,articles (gnus-summary-work-articles ,arg)))
6549 (while ,articles
6550 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6551 ,@forms
6552 (pop ,articles)))))
6748645f
LMI
6553
6554(put 'gnus-summary-iterate 'lisp-indent-function 1)
6555(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6556
6557(defun gnus-summary-save-process-mark ()
6558 "Push the current set of process marked articles on the stack."
6559 (interactive)
6560 (push (copy-sequence gnus-newsgroup-processable)
6561 gnus-newsgroup-process-stack))
6562
6563(defun gnus-summary-kill-process-mark ()
6564 "Push the current set of process marked articles on the stack and unmark."
6565 (interactive)
6566 (gnus-summary-save-process-mark)
6567 (gnus-summary-unmark-all-processable))
6568
6569(defun gnus-summary-yank-process-mark ()
6570 "Pop the last process mark state off the stack and restore it."
6571 (interactive)
6572 (unless gnus-newsgroup-process-stack
6573 (error "Empty mark stack"))
6574 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6575
6576(defun gnus-summary-process-mark-set (set)
6577 "Make SET into the current process marked articles."
6578 (gnus-summary-unmark-all-processable)
01c52d31 6579 (mapc 'gnus-summary-set-process-mark set))
eec82323
LMI
6580
6581;;; Searching and stuff
6582
6583(defun gnus-summary-search-group (&optional backward use-level)
6584 "Search for next unread newsgroup.
6585If optional argument BACKWARD is non-nil, search backward instead."
c7a91ce1 6586 (with-current-buffer gnus-group-buffer
eec82323
LMI
6587 (when (gnus-group-search-forward
6588 backward nil (if use-level (gnus-group-group-level) nil))
6589 (gnus-group-group-name))))
6590
6591(defun gnus-summary-best-group (&optional exclude-group)
6592 "Find the name of the best unread group.
6593If EXCLUDE-GROUP, do not go to this group."
01c52d31 6594 (with-current-buffer gnus-group-buffer
eec82323
LMI
6595 (save-excursion
6596 (gnus-group-best-unread-group exclude-group))))
6597
23f87bed
MB
6598(defun gnus-summary-find-next (&optional unread article backward)
6599 (if backward
6600 (gnus-summary-find-prev unread article)
eec82323
LMI
6601 (let* ((dummy (gnus-summary-article-intangible-p))
6602 (article (or article (gnus-summary-article-number)))
23f87bed 6603 (data (gnus-data-find-list article))
eec82323
LMI
6604 result)
6605 (when (and (not dummy)
6606 (or (not gnus-summary-check-current)
6607 (not unread)
23f87bed
MB
6608 (not (gnus-data-unread-p (car data)))))
6609 (setq data (cdr data)))
eec82323
LMI
6610 (when (setq result
6611 (if unread
6612 (progn
23f87bed
MB
6613 (while data
6614 (unless (memq (gnus-data-number (car data))
6615 (cond
6616 ((eq gnus-auto-goto-ignores
6617 'always-undownloaded)
6618 gnus-newsgroup-undownloaded)
6619 (gnus-plugged
6620 nil)
6621 ((eq gnus-auto-goto-ignores
6622 'unfetched)
6623 gnus-newsgroup-unfetched)
6624 ((eq gnus-auto-goto-ignores
6625 'undownloaded)
6626 gnus-newsgroup-undownloaded)))
6627 (when (gnus-data-unread-p (car data))
6628 (setq result (car data)
6629 data nil)))
6630 (setq data (cdr data)))
eec82323 6631 result)
23f87bed 6632 (car data)))
eec82323
LMI
6633 (goto-char (gnus-data-pos result))
6634 (gnus-data-number result)))))
6635
6636(defun gnus-summary-find-prev (&optional unread article)
6637 (let* ((eobp (eobp))
6638 (article (or article (gnus-summary-article-number)))
23f87bed 6639 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6640 result)
6641 (when (and (not eobp)
6642 (or (not gnus-summary-check-current)
6643 (not unread)
23f87bed
MB
6644 (not (gnus-data-unread-p (car data)))))
6645 (setq data (cdr data)))
eec82323
LMI
6646 (when (setq result
6647 (if unread
6648 (progn
23f87bed
MB
6649 (while data
6650 (unless (memq (gnus-data-number (car data))
6651 (cond
6652 ((eq gnus-auto-goto-ignores
6653 'always-undownloaded)
6654 gnus-newsgroup-undownloaded)
6655 (gnus-plugged
6656 nil)
6657 ((eq gnus-auto-goto-ignores
6658 'unfetched)
6659 gnus-newsgroup-unfetched)
6660 ((eq gnus-auto-goto-ignores
6661 'undownloaded)
6662 gnus-newsgroup-undownloaded)))
6663 (when (gnus-data-unread-p (car data))
6664 (setq result (car data)
6665 data nil)))
6666 (setq data (cdr data)))
eec82323 6667 result)
23f87bed 6668 (car data)))
eec82323
LMI
6669 (goto-char (gnus-data-pos result))
6670 (gnus-data-number result))))
6671
6672(defun gnus-summary-find-subject (subject &optional unread backward article)
6673 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6674 (article (or article (gnus-summary-article-number)))
6675 (articles (gnus-data-list backward))
6676 (arts (gnus-data-find-list article articles))
6677 result)
6678 (when (or (not gnus-summary-check-current)
6679 (not unread)
6680 (not (gnus-data-unread-p (car arts))))
6681 (setq arts (cdr arts)))
6682 (while arts
6683 (and (or (not unread)
6684 (gnus-data-unread-p (car arts)))
6685 (vectorp (gnus-data-header (car arts)))
6686 (gnus-subject-equal
6687 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6688 (setq result (car arts)
6689 arts nil))
6690 (setq arts (cdr arts)))
6691 (and result
6692 (goto-char (gnus-data-pos result))
6693 (gnus-data-number result))))
6694
6695(defun gnus-summary-search-forward (&optional unread subject backward)
6696 "Search forward for an article.
6697If UNREAD, look for unread articles. If SUBJECT, look for
6698articles with that subject. If BACKWARD, search backward instead."
6699 (cond (subject (gnus-summary-find-subject subject unread backward))
6700 (backward (gnus-summary-find-prev unread))
6701 (t (gnus-summary-find-next unread))))
6702
6703(defun gnus-recenter (&optional n)
6704 "Center point in window and redisplay frame.
6705Also do horizontal recentering."
6706 (interactive "P")
6707 (when (and gnus-auto-center-summary
6708 (not (eq gnus-auto-center-summary 'vertical)))
6709 (gnus-horizontal-recenter))
5aa75bd8
JL
6710 (if (fboundp 'recenter-top-bottom)
6711 (recenter-top-bottom n)
6712 (recenter n)))
6713
6714(put 'gnus-recenter 'isearch-scroll t)
eec82323 6715
7b47345b
AS
6716(defun gnus-forward-line-ignore-invisible (n)
6717 "Move N lines forward (backward if N is negative).
6718Like forward-line, but skip over (and don't count) invisible lines."
6719 (let (done)
6720 (while (and (> n 0) (not done))
6721 ;; If the following character is currently invisible,
6722 ;; skip all characters with that same `invisible' property value.
770d9a1f
KY
6723 (while (gnus-invisible-p (point))
6724 (goto-char (gnus-next-char-property-change (point))))
7b47345b
AS
6725 (forward-line 1)
6726 (if (eobp)
6727 (setq done t)
6728 (setq n (1- n))))
6729 (while (and (< n 0) (not done))
6730 (forward-line -1)
6731 (if (bobp) (setq done t)
6732 (setq n (1+ n))
770d9a1f
KY
6733 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6734 (goto-char (gnus-previous-char-property-change (point))))))))
6735
eec82323
LMI
6736(defun gnus-summary-recenter ()
6737 "Center point in the summary window.
6738If `gnus-auto-center-summary' is nil, or the article buffer isn't
6739displayed, no centering will be performed."
6740 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6741 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6742 (interactive)
23f87bed
MB
6743 ;; The user has to want it.
6744 (when gnus-auto-center-summary
6745 (let* ((top (cond ((< (window-height) 4) 0)
6746 ((< (window-height) 7) 1)
6747 (t (if (numberp gnus-auto-center-summary)
6748 gnus-auto-center-summary
01c52d31 6749 (/ (1- (window-height)) 2)))))
23f87bed 6750 (height (1- (window-height)))
7b47345b
AS
6751 (bottom (save-excursion
6752 (goto-char (point-max))
6753 (gnus-forward-line-ignore-invisible (- height))
6754 (point)))
23f87bed 6755 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6756 (when (get-buffer-window gnus-article-buffer)
6757 ;; Only do recentering when the article buffer is displayed,
6758 ;; Set the window start to either `bottom', which is the biggest
6759 ;; possible valid number, or the second line from the top,
6760 ;; whichever is the least.
7b47345b
AS
6761 (let ((top-pos (save-excursion
6762 (gnus-forward-line-ignore-invisible (- top))
6763 (point))))
db7ebd73
MB
6764 (if (> bottom top-pos)
6765 ;; Keep the second line from the top visible
01c52d31 6766 (set-window-start window top-pos)
db7ebd73
MB
6767 ;; Try to keep the bottom line visible; if it's partially
6768 ;; obscured, either scroll one more line to make it fully
6769 ;; visible, or revert to using TOP-POS.
6770 (save-excursion
6771 (goto-char (point-max))
7b47345b 6772 (gnus-forward-line-ignore-invisible -1)
db7ebd73
MB
6773 (let ((last-line-start (point)))
6774 (goto-char bottom)
6775 (set-window-start window (point) t)
6776 (when (not (pos-visible-in-window-p last-line-start window))
7b47345b 6777 (gnus-forward-line-ignore-invisible 1)
db7ebd73 6778 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6779 ;; Do horizontal recentering while we're at it.
6780 (when (and (get-buffer-window (current-buffer) t)
6781 (not (eq gnus-auto-center-summary 'vertical)))
6782 (let ((selected (selected-window)))
6783 (select-window (get-buffer-window (current-buffer) t))
6784 (gnus-summary-position-point)
6785 (gnus-horizontal-recenter)
6786 (select-window selected))))))
6787
6788(defun gnus-summary-jump-to-group (newsgroup)
6789 "Move point to NEWSGROUP in group mode buffer."
6790 ;; Keep update point of group mode buffer if visible.
6791 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6792 (save-window-excursion
6793 ;; Take care of tree window mode.
6794 (when (get-buffer-window gnus-group-buffer)
6795 (pop-to-buffer gnus-group-buffer))
6796 (gnus-group-jump-to-group newsgroup))
6797 (save-excursion
6798 ;; Take care of tree window mode.
c7a91ce1 6799 (if (get-buffer-window gnus-group-buffer 0)
eec82323
LMI
6800 (pop-to-buffer gnus-group-buffer)
6801 (set-buffer gnus-group-buffer))
6802 (gnus-group-jump-to-group newsgroup))))
6803
6804;; This function returns a list of article numbers based on the
6805;; difference between the ranges of read articles in this group and
6806;; the range of active articles.
6807(defun gnus-list-of-unread-articles (group)
6808 (let* ((read (gnus-info-read (gnus-get-info group)))
6809 (active (or (gnus-active group) (gnus-activate-group group)))
01c52d31
MB
6810 (last (or (cdr active)
6811 (error "Group %s couldn't be activated " group)))
4b70e299
MB
6812 (bottom (if gnus-newsgroup-maximum-articles
6813 (max (car active)
6814 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6815 (car active)))
eec82323
LMI
6816 first nlast unread)
6817 ;; If none are read, then all are unread.
6818 (if (not read)
11abff8e 6819 (setq first bottom)
eec82323
LMI
6820 ;; If the range of read articles is a single range, then the
6821 ;; first unread article is the article after the last read
6822 ;; article. Sounds logical, doesn't it?
16409b0b 6823 (if (and (not (listp (cdr read)))
11abff8e 6824 (or (< (car read) bottom)
16409b0b
GM
6825 (progn (setq read (list read))
6826 nil)))
11abff8e 6827 (setq first (max bottom (1+ (cdr read))))
eec82323
LMI
6828 ;; `read' is a list of ranges.
6829 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6830 (caar read)))
6831 1)
11abff8e 6832 (setq first bottom))
eec82323
LMI
6833 (while read
6834 (when first
6835 (while (< first nlast)
54506618
MB
6836 (setq unread (cons first unread)
6837 first (1+ first))))
eec82323
LMI
6838 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6839 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6840 (setq read (cdr read)))))
6841 ;; And add the last unread articles.
6842 (while (<= first last)
54506618
MB
6843 (setq unread (cons first unread)
6844 first (1+ first)))
eec82323 6845 ;; Return the list of unread articles.
6748645f 6846 (delq 0 (nreverse unread))))
eec82323
LMI
6847
6848(defun gnus-list-of-read-articles (group)
6849 "Return a list of unread, unticked and non-dormant articles."
6850 (let* ((info (gnus-get-info group))
6851 (marked (gnus-info-marks info))
6852 (active (gnus-active group)))
6853 (and info active
23f87bed
MB
6854 (gnus-list-range-difference
6855 (gnus-list-range-difference
6856 (gnus-sorted-complement
11abff8e 6857 (gnus-uncompress-range
4b70e299 6858 (if gnus-newsgroup-maximum-articles
11abff8e 6859 (cons (max (car active)
4b70e299
MB
6860 (- (cdr active)
6861 gnus-newsgroup-maximum-articles
6862 -1))
11abff8e
MB
6863 (cdr active))
6864 active))
23f87bed
MB
6865 (gnus-list-of-unread-articles group))
6866 (cdr (assq 'dormant marked)))
6867 (cdr (assq 'tick marked))))))
eec82323 6868
54506618
MB
6869;; This function returns a sequence of article numbers based on the
6870;; difference between the ranges of read articles in this group and
6871;; the range of active articles.
6872(defun gnus-sequence-of-unread-articles (group)
6873 (let* ((read (gnus-info-read (gnus-get-info group)))
6874 (active (or (gnus-active group) (gnus-activate-group group)))
6875 (last (cdr active))
4b70e299
MB
6876 (bottom (if gnus-newsgroup-maximum-articles
6877 (max (car active)
6878 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6879 (car active)))
54506618
MB
6880 first nlast unread)
6881 ;; If none are read, then all are unread.
6882 (if (not read)
11abff8e 6883 (setq first bottom)
54506618
MB
6884 ;; If the range of read articles is a single range, then the
6885 ;; first unread article is the article after the last read
6886 ;; article. Sounds logical, doesn't it?
6887 (if (and (not (listp (cdr read)))
11abff8e 6888 (or (< (car read) bottom)
54506618
MB
6889 (progn (setq read (list read))
6890 nil)))
11abff8e 6891 (setq first (max bottom (1+ (cdr read))))
54506618
MB
6892 ;; `read' is a list of ranges.
6893 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6894 (caar read)))
6895 1)
11abff8e 6896 (setq first bottom))
54506618
MB
6897 (while read
6898 (when first
6899 (push (cons first nlast) unread))
6900 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6901 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6902 (setq read (cdr read)))))
6903 ;; And add the last unread articles.
ba0226dd
MB
6904 (cond ((not (and first last))
6905 nil)
6906 ((< first last)
6907 (push (cons first last) unread))
6908 ((= first last)
6909 (push first unread)))
54506618
MB
6910 ;; Return the sequence of unread articles.
6911 (delq 0 (nreverse unread))))
6912
eec82323
LMI
6913;; Various summary commands
6914
6748645f
LMI
6915(defun gnus-summary-select-article-buffer ()
6916 "Reconfigure windows to show article buffer."
6917 (interactive)
6918 (if (not (gnus-buffer-live-p gnus-article-buffer))
6919 (error "There is no article buffer for this summary buffer")
6920 (gnus-configure-windows 'article)
6921 (select-window (get-buffer-window gnus-article-buffer))))
6922
eec82323
LMI
6923(defun gnus-summary-universal-argument (arg)
6924 "Perform any operation on all articles that are process/prefixed."
6925 (interactive "P")
eec82323
LMI
6926 (let ((articles (gnus-summary-work-articles arg))
6927 func article)
6928 (if (eq
6929 (setq
6930 func
6931 (key-binding
6932 (read-key-sequence
6933 (substitute-command-keys
16409b0b 6934 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
6935 'undefined)
6936 (gnus-error 1 "Undefined key")
6937 (save-excursion
6938 (while articles
6939 (gnus-summary-goto-subject (setq article (pop articles)))
6940 (let (gnus-newsgroup-processable)
6941 (command-execute func))
6942 (gnus-summary-remove-process-mark article)))))
6943 (gnus-summary-position-point))
6944
6945(defun gnus-summary-toggle-truncation (&optional arg)
6946 "Toggle truncation of summary lines.
23f87bed 6947With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
6948 (interactive "P")
6949 (setq truncate-lines
6950 (if (null arg) (not truncate-lines)
6951 (> (prefix-numeric-value arg) 0)))
6952 (redraw-display))
6953
23f87bed
MB
6954(defun gnus-summary-find-for-reselect ()
6955 "Return the number of an article to stay on across a reselect.
6956The current article is considered, then following articles, then previous
6957articles. An article is sought which is not cancelled and isn't a temporary
6958insertion from another group. If there's no such then return a dummy 0."
6959 (let (found)
6960 (dolist (rev '(nil t))
6961 (unless found ; don't demand the reverse list if we don't need it
6962 (let ((data (gnus-data-find-list
6963 (gnus-summary-article-number) (gnus-data-list rev))))
6964 (while (and data (not found))
6965 (if (and (< 0 (gnus-data-number (car data)))
6966 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6967 (setq found (gnus-data-number (car data))))
6968 (setq data (cdr data))))))
6969 (or found 0)))
6970
eec82323
LMI
6971(defun gnus-summary-reselect-current-group (&optional all rescan)
6972 "Exit and then reselect the current newsgroup.
6973The prefix argument ALL means to select all articles."
6974 (interactive "P")
eec82323
LMI
6975 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6976 (error "Ephemeral groups can't be reselected"))
23f87bed 6977 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
6978 (group gnus-newsgroup-name))
6979 (setq gnus-newsgroup-begin nil)
23f87bed 6980 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
6981 ;; We have to adjust the point of group mode buffer because
6982 ;; point was moved to the next unread newsgroup by exiting.
6983 (gnus-summary-jump-to-group group)
6984 (when rescan
6985 (save-excursion
6986 (gnus-group-get-new-news-this-group 1)))
6987 (gnus-group-read-group all t)
6988 (gnus-summary-goto-subject current-subject nil t)))
6989
6990(defun gnus-summary-rescan-group (&optional all)
6991 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6992 (interactive "P")
6993 (gnus-summary-reselect-current-group all t))
6994
6995(defun gnus-summary-update-info (&optional non-destructive)
6996 (save-excursion
6997 (let ((group gnus-newsgroup-name))
6748645f
LMI
6998 (when group
6999 (when gnus-newsgroup-kill-headers
7000 (setq gnus-newsgroup-killed
7001 (gnus-compress-sequence
23f87bed
MB
7002 (gnus-sorted-union
7003 (gnus-list-range-intersection
7004 gnus-newsgroup-unselected gnus-newsgroup-killed)
7005 gnus-newsgroup-unreads)
6748645f
LMI
7006 t)))
7007 (unless (listp (cdr gnus-newsgroup-killed))
7008 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7009 (let ((headers gnus-newsgroup-headers))
7010 ;; Set the new ranges of read articles.
01c52d31 7011 (with-current-buffer gnus-group-buffer
6748645f
LMI
7012 (gnus-undo-force-boundary))
7013 (gnus-update-read-articles
23f87bed
MB
7014 group (gnus-sorted-union
7015 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
7016 ;; Set the current article marks.
7017 (let ((gnus-newsgroup-scored
7018 (if (and (not gnus-save-score)
7019 (not non-destructive))
7020 nil
7021 gnus-newsgroup-scored)))
7022 (save-excursion
7023 (gnus-update-marks)))
7024 ;; Do the cross-ref thing.
7025 (when gnus-use-cross-reference
7026 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7027 ;; Do not switch windows but change the buffer to work.
a8151ef7 7028 (set-buffer gnus-group-buffer)
6748645f
LMI
7029 (unless (gnus-ephemeral-group-p group)
7030 (gnus-group-update-group group)))))))
eec82323
LMI
7031
7032(defun gnus-summary-save-newsrc (&optional force)
7033 "Save the current number of read/marked articles in the dribble buffer.
7034The dribble buffer will then be saved.
7035If FORCE (the prefix), also save the .newsrc file(s)."
7036 (interactive "P")
7037 (gnus-summary-update-info t)
7038 (if force
7039 (gnus-save-newsrc-file)
7040 (gnus-dribble-save)))
7041
704f1663
GM
7042(declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7043
23f87bed 7044(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 7045 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 7046`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
7047 (interactive)
7048 (gnus-set-global-variables)
16409b0b 7049 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7050 (with-current-buffer gnus-article-buffer
16409b0b
GM
7051 (mm-destroy-parts gnus-article-mime-handles)
7052 ;; Set it to nil for safety reason.
7053 (setq gnus-article-mime-handle-alist nil)
7054 (setq gnus-article-mime-handles nil)))
eec82323 7055 (gnus-kill-save-kill-buffer)
6748645f 7056 (gnus-async-halt-prefetch)
eec82323
LMI
7057 (let* ((group gnus-newsgroup-name)
7058 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 7059 (gnus-group-is-exiting-p t)
eec82323 7060 (mode major-mode)
23f87bed 7061 (group-point nil)
eec82323 7062 (buf (current-buffer)))
16409b0b
GM
7063 (unless quit-config
7064 ;; Do adaptive scoring, and possibly save score files.
7065 (when gnus-newsgroup-adaptive
7066 (gnus-score-adaptive))
7067 (when gnus-use-scoring
7068 (gnus-score-save)))
6748645f 7069 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
7070 ;; If we have several article buffers, we kill them at exit.
7071 (unless gnus-single-article-buffer
01c52d31
MB
7072 (when (gnus-buffer-live-p gnus-article-buffer)
7073 (with-current-buffer gnus-article-buffer
7074 ;; Don't kill sticky article buffers
7075 (unless (eq major-mode 'gnus-sticky-article-mode)
7076 (gnus-kill-buffer gnus-article-buffer)
7077 (setq gnus-article-current nil))))
7078 (gnus-kill-buffer gnus-original-article-buffer))
eec82323
LMI
7079 (when gnus-use-cache
7080 (gnus-cache-possibly-remove-articles)
7081 (gnus-cache-save-buffers))
7082 (gnus-async-prefetch-remove-group group)
7083 (when gnus-suppress-duplicates
7084 (gnus-dup-enter-articles))
7085 (when gnus-use-trees
7086 (gnus-tree-close group))
16409b0b
GM
7087 (when gnus-use-cache
7088 (gnus-cache-write-active))
6748645f
LMI
7089 ;; Remove entries for this group.
7090 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
7091 ;; Make all changes in this group permanent.
7092 (unless quit-config
6748645f 7093 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 7094 (gnus-summary-update-info))
eec82323
LMI
7095 (gnus-close-group group)
7096 ;; Make sure where we were, and go to next newsgroup.
7097 (set-buffer gnus-group-buffer)
7098 (unless quit-config
7099 (gnus-group-jump-to-group group))
6748645f
LMI
7100 (gnus-run-hooks 'gnus-summary-exit-hook)
7101 (unless (or quit-config
01c52d31 7102 (not gnus-summary-next-group-on-exit)
6748645f
LMI
7103 ;; If this group has disappeared from the summary
7104 ;; buffer, don't skip forwards.
7105 (not (string= group (gnus-group-group-name))))
eec82323 7106 (gnus-group-next-unread-group 1))
a8151ef7 7107 (setq group-point (point))
eec82323
LMI
7108 (if temporary
7109 nil ;Nothing to do.
eec82323
LMI
7110 (set-buffer buf)
7111 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
7112 (progn
7113 (gnus-deaden-summary)
7114 (setq mode nil))
eec82323
LMI
7115 ;; We set all buffer-local variables to nil. It is unclear why
7116 ;; this is needed, but if we don't, buffer-local variables are
7117 ;; not garbage-collected, it seems. This would the lead to en
7118 ;; ever-growing Emacs.
7119 (gnus-summary-clear-local-variables)
23f87bed
MB
7120 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7121 (gnus-summary-clear-local-variables))
eec82323
LMI
7122 (when (get-buffer gnus-article-buffer)
7123 (bury-buffer gnus-article-buffer))
eec82323
LMI
7124 ;; Return to group mode buffer.
7125 (when (eq mode 'gnus-summary-mode)
7126 (gnus-kill-buffer buf)))
7127 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
7128 (set-buffer gnus-group-buffer)
7129 (if quit-config
7130 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
7131 (goto-char group-point)
7132 ;; If gnus-group-buffer is already displayed, make sure we also move
7133 ;; the cursor in the window that displays it.
7134 (let ((win (get-buffer-window (current-buffer) 0)))
7135 (if win (set-window-point win (point))))
d61c212b 7136 (unless leave-hidden
4e90f2b9 7137 (gnus-configure-windows 'group 'force)))
6748645f 7138 ;; Clear the current group name.
eec82323
LMI
7139 (unless quit-config
7140 (setq gnus-newsgroup-name nil)))))
7141
7142(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7143(defun gnus-summary-exit-no-update (&optional no-questions)
7144 "Quit reading current newsgroup without updating read article info."
7145 (interactive)
eec82323 7146 (let* ((group gnus-newsgroup-name)
23f87bed
MB
7147 (gnus-group-is-exiting-p t)
7148 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
7149 (quit-config (gnus-group-quit-config group)))
7150 (when (or no-questions
7151 gnus-expert-user
7152 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 7153 (gnus-async-halt-prefetch)
23f87bed 7154 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b 7155 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7156 (with-current-buffer gnus-article-buffer
16409b0b
GM
7157 (mm-destroy-parts gnus-article-mime-handles)
7158 ;; Set it to nil for safety reason.
7159 (setq gnus-article-mime-handle-alist nil)
7160 (setq gnus-article-mime-handles nil)))
eec82323
LMI
7161 ;; If we have several article buffers, we kill them at exit.
7162 (unless gnus-single-article-buffer
7163 (gnus-kill-buffer gnus-article-buffer)
7164 (gnus-kill-buffer gnus-original-article-buffer)
7165 (setq gnus-article-current nil))
7166 (if (not gnus-kill-summary-on-exit)
7167 (gnus-deaden-summary)
7168 (gnus-close-group group)
7169 (gnus-summary-clear-local-variables)
23f87bed
MB
7170 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7171 (gnus-summary-clear-local-variables))
7172 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
7173 (unless gnus-single-article-buffer
7174 (setq gnus-article-current nil))
7175 (when gnus-use-trees
7176 (gnus-tree-close group))
7177 (gnus-async-prefetch-remove-group group)
7178 (when (get-buffer gnus-article-buffer)
7179 (bury-buffer gnus-article-buffer))
7180 ;; Return to the group buffer.
7181 (gnus-configure-windows 'group 'force)
7182 ;; Clear the current group name.
7183 (setq gnus-newsgroup-name nil)
23f87bed
MB
7184 (unless (gnus-ephemeral-group-p group)
7185 (gnus-group-update-group group))
eec82323
LMI
7186 (when (equal (gnus-group-group-name) group)
7187 (gnus-group-next-unread-group 1))
7188 (when quit-config
23f87bed 7189 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
7190
7191(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
7192 "Handle movement when leaving an ephemeral group.
7193The state which existed when entering the ephemeral is reset."
eec82323
LMI
7194 (if (not (buffer-name (car quit-config)))
7195 (gnus-configure-windows 'group 'force)
7196 (set-buffer (car quit-config))
7197 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
7198 (gnus-set-global-variables))
7199 ((eq major-mode 'gnus-article-mode)
c7a91ce1 7200 (save-current-buffer
23f87bed
MB
7201 ;; The `gnus-summary-buffer' variable may point
7202 ;; to the old summary buffer when using a single
7203 ;; article buffer.
7204 (unless (gnus-buffer-live-p gnus-summary-buffer)
7205 (set-buffer gnus-group-buffer))
7206 (set-buffer gnus-summary-buffer)
7207 (gnus-set-global-variables))))
eec82323 7208 (if (or (eq (cdr quit-config) 'article)
23f87bed 7209 (eq (cdr quit-config) 'pick))
01c52d31
MB
7210 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7211 (gnus-configure-windows 'pick 'force)
7212 (gnus-configure-windows (cdr quit-config) 'force))
eec82323
LMI
7213 (gnus-configure-windows (cdr quit-config) 'force))
7214 (when (eq major-mode 'gnus-summary-mode)
01c52d31
MB
7215 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7216 next-unread-noselect))
7217 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7218 'next-noselect)
7219 (gnus-summary-next-subject 1 nil t))
7220 ((eq gnus-auto-select-on-ephemeral-exit
7221 'next-unread-noselect)
7222 (gnus-summary-next-subject 1 t t))))
7223 ;; Hide the article buffer which displays the article different
7224 ;; from the one that the cursor points to in the summary buffer.
7225 (gnus-configure-windows 'summary 'force))
7226 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7227 (gnus-summary-next-subject 1))
7228 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7229 (gnus-summary-next-subject 1 t))))
eec82323
LMI
7230 (gnus-summary-recenter)
7231 (gnus-summary-position-point))))
7232
7233;;; Dead summaries.
7234
bbf52f1e
SM
7235(defvar gnus-dead-summary-mode-map
7236 (let ((map (make-keymap)))
7237 (suppress-keymap map)
7238 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7239 (dolist (key '("\C-d" "\r" "\177" [delete]))
7240 (define-key map key 'gnus-summary-wake-up-the-dead))
7241 (dolist (key '("q" "Q"))
7242 (define-key map key 'bury-buffer))
7243 map))
7244
7245(define-minor-mode gnus-dead-summary-mode
eec82323 7246 "Minor mode for Gnus summary buffers."
bbf52f1e
SM
7247 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7248 (unless (derived-mode-p 'gnus-summary-mode)
7249 (setq gnus-dead-summary-mode nil)))
eec82323
LMI
7250
7251(defun gnus-deaden-summary ()
7252 "Make the current summary buffer into a dead summary buffer."
7253 ;; Kill any previous dead summary buffer.
7254 (when (and gnus-dead-summary
7255 (buffer-name gnus-dead-summary))
01c52d31 7256 (with-current-buffer gnus-dead-summary
eec82323
LMI
7257 (when gnus-dead-summary-mode
7258 (kill-buffer (current-buffer)))))
7259 ;; Make this the current dead summary.
7260 (setq gnus-dead-summary (current-buffer))
7261 (gnus-dead-summary-mode 1)
7262 (let ((name (buffer-name)))
7263 (when (string-match "Summary" name)
7264 (rename-buffer
7265 (concat (substring name 0 (match-beginning 0)) "Dead "
7266 (substring name (match-beginning 0)))
16409b0b
GM
7267 t)
7268 (bury-buffer))))
eec82323
LMI
7269
7270(defun gnus-kill-or-deaden-summary (buffer)
7271 "Kill or deaden the summary BUFFER."
6748645f
LMI
7272 (save-excursion
7273 (when (and (buffer-name buffer)
7274 (not gnus-single-article-buffer))
01c52d31 7275 (with-current-buffer buffer
6748645f
LMI
7276 (gnus-kill-buffer gnus-article-buffer)
7277 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
7278 (cond
7279 ;; Kill the buffer.
7280 (gnus-kill-summary-on-exit
7281 (when (and gnus-use-trees
7282 (gnus-buffer-exists-p buffer))
c7a91ce1 7283 (with-current-buffer buffer
23f87bed
MB
7284 (gnus-tree-close gnus-newsgroup-name)))
7285 (gnus-kill-buffer buffer))
7286 ;; Deaden the buffer.
7287 ((gnus-buffer-exists-p buffer)
c7a91ce1 7288 (with-current-buffer buffer
23f87bed 7289 (gnus-deaden-summary))))))
eec82323
LMI
7290
7291(defun gnus-summary-wake-up-the-dead (&rest args)
7292 "Wake up the dead summary buffer."
7293 (interactive)
7294 (gnus-dead-summary-mode -1)
7295 (let ((name (buffer-name)))
7296 (when (string-match "Dead " name)
7297 (rename-buffer
7298 (concat (substring name 0 (match-beginning 0))
7299 (substring name (match-end 0)))
7300 t)))
7301 (gnus-message 3 "This dead summary is now alive again"))
7302
7303;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7304(defun gnus-summary-fetch-faq (&optional faq-dir)
7305 "Fetch the FAQ for the current group.
7306If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7307in."
7308 (interactive
7309 (list
7310 (when current-prefix-arg
7311 (completing-read
8f688cb0 7312 "FAQ dir: " (and (listp gnus-group-faq-directory)
01c52d31 7313 (mapcar 'list
a8151ef7 7314 gnus-group-faq-directory))))))
eec82323
LMI
7315 (let (gnus-faq-buffer)
7316 (when (setq gnus-faq-buffer
7317 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7318 (gnus-configure-windows 'summary-faq))))
7319
7320;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7321(defun gnus-summary-describe-group (&optional force)
7322 "Describe the current newsgroup."
7323 (interactive "P")
7324 (gnus-group-describe-group force gnus-newsgroup-name))
7325
7326(defun gnus-summary-describe-briefly ()
7327 "Describe summary mode commands briefly."
7328 (interactive)
16409b0b 7329 (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
7330
7331;; Walking around group mode buffer from summary mode.
7332
7333(defun gnus-summary-next-group (&optional no-article target-group backward)
7334 "Exit current newsgroup and then select next unread newsgroup.
7335If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7336initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7337previous group instead."
7338 (interactive "P")
eec82323
LMI
7339 ;; Stop pre-fetching.
7340 (gnus-async-halt-prefetch)
7341 (let ((current-group gnus-newsgroup-name)
7342 (current-buffer (current-buffer))
7343 entered)
7344 ;; First we semi-exit this group to update Xrefs and all variables.
7345 ;; We can't do a real exit, because the window conf must remain
7346 ;; the same in case the user is prompted for info, and we don't
7347 ;; want the window conf to change before that...
7348 (gnus-summary-exit t)
7349 (while (not entered)
7350 ;; Then we find what group we are supposed to enter.
7351 (set-buffer gnus-group-buffer)
7352 (gnus-group-jump-to-group current-group)
7353 (setq target-group
7354 (or target-group
7355 (if (eq gnus-keep-same-level 'best)
7356 (gnus-summary-best-group gnus-newsgroup-name)
7357 (gnus-summary-search-group backward gnus-keep-same-level))))
7358 (if (not target-group)
7359 ;; There are no further groups, so we return to the group
7360 ;; buffer.
7361 (progn
7362 (gnus-message 5 "Returning to the group buffer")
7363 (setq entered t)
7364 (when (gnus-buffer-live-p current-buffer)
7365 (set-buffer current-buffer)
7366 (gnus-summary-exit))
6748645f 7367 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7368 ;; We try to enter the target group.
7369 (gnus-group-jump-to-group target-group)
7370 (let ((unreads (gnus-group-group-unread)))
7371 (if (and (or (eq t unreads)
7372 (and unreads (not (zerop unreads))))
23f87bed
MB
7373 (gnus-summary-read-group
7374 target-group nil no-article
7375 (and (buffer-name current-buffer) current-buffer)
7376 nil backward))
eec82323
LMI
7377 (setq entered t)
7378 (setq current-group target-group
7379 target-group nil)))))))
7380
7381(defun gnus-summary-prev-group (&optional no-article)
7382 "Exit current newsgroup and then select previous unread newsgroup.
7383If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7384 (interactive "P")
7385 (gnus-summary-next-group no-article nil t))
7386
7387;; Walking around summary lines.
7388
23f87bed
MB
7389(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7390 "Go to the first subject satisfying any non-nil constraint.
7391If UNREAD is non-nil, the article should be unread.
7392If UNDOWNLOADED is non-nil, the article should be undownloaded.
7393If UNSEEN is non-nil, the article should be unseen.
7394Returns the article selected or nil if there are no matching articles."
eec82323 7395 (interactive "P")
23f87bed
MB
7396 (cond
7397 ;; Empty summary.
7398 ((null gnus-newsgroup-data)
7399 (gnus-message 3 "No articles in the group")
7400 nil)
7401 ;; Pick the first article.
7402 ((not (or unread undownloaded unseen))
7403 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7404 (gnus-data-number (car gnus-newsgroup-data)))
7405 ;; Find the first unread article.
7406 (t
7407 (let ((data gnus-newsgroup-data))
7408 (while (and data
7409 (let ((num (gnus-data-number (car data))))
7410 (or (memq num gnus-newsgroup-unfetched)
7411 (not (or (and unread
7412 (memq num gnus-newsgroup-unreads))
7413 (and undownloaded
7414 (memq num gnus-newsgroup-undownloaded))
7415 (and unseen
7416 (memq num gnus-newsgroup-unseen)))))))
7417 (setq data (cdr data)))
7418 (prog1
7419 (if data
7420 (progn
7421 (goto-char (gnus-data-pos (car data)))
7422 (gnus-data-number (car data)))
7423 (gnus-message 3 "No more%s articles"
7424 (let* ((r (when unread " unread"))
7425 (d (when undownloaded " undownloaded"))
7426 (s (when unseen " unseen"))
7427 (l (delq nil (list r d s))))
7428 (cond ((= 3 (length l))
7429 (concat r "," d ", or" s))
7430 ((= 2 (length l))
7431 (concat (car l) ", or" (cadr l)))
7432 ((= 1 (length l))
7433 (car l))
7434 (t
7435 ""))))
7436 nil
7437 )
7438 (gnus-summary-position-point))))))
eec82323
LMI
7439
7440(defun gnus-summary-next-subject (n &optional unread dont-display)
7441 "Go to next N'th summary line.
7442If N is negative, go to the previous N'th subject line.
7443If UNREAD is non-nil, only unread articles are selected.
7444The difference between N and the actual number of steps taken is
7445returned."
7446 (interactive "p")
7447 (let ((backward (< n 0))
7448 (n (abs n)))
7449 (while (and (> n 0)
7450 (if backward
7451 (gnus-summary-find-prev unread)
7452 (gnus-summary-find-next unread)))
16409b0b
GM
7453 (unless (zerop (setq n (1- n)))
7454 (gnus-summary-show-thread)))
eec82323
LMI
7455 (when (/= 0 n)
7456 (gnus-message 7 "No more%s articles"
7457 (if unread " unread" "")))
7458 (unless dont-display
7459 (gnus-summary-recenter)
7460 (gnus-summary-position-point))
7461 n))
7462
7463(defun gnus-summary-next-unread-subject (n)
7464 "Go to next N'th unread summary line."
7465 (interactive "p")
7466 (gnus-summary-next-subject n t))
7467
7468(defun gnus-summary-prev-subject (n &optional unread)
7469 "Go to previous N'th summary line.
7470If optional argument UNREAD is non-nil, only unread article is selected."
7471 (interactive "p")
7472 (gnus-summary-next-subject (- n) unread))
7473
7474(defun gnus-summary-prev-unread-subject (n)
7475 "Go to previous N'th unread summary line."
7476 (interactive "p")
7477 (gnus-summary-next-subject (- n) t))
7478
23f87bed
MB
7479(defun gnus-summary-goto-subjects (articles)
7480 "Insert the subject header for ARTICLES in the current buffer."
7481 (save-excursion
7482 (dolist (article articles)
7483 (gnus-summary-goto-subject article t)))
7484 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7485 (gnus-summary-position-point))
132cf96d 7486
eec82323 7487(defun gnus-summary-goto-subject (article &optional force silent)
d55fe5bb 7488 "Go to the subject line of ARTICLE.
eec82323
LMI
7489If FORCE, also allow jumping to articles not currently shown."
7490 (interactive "nArticle number: ")
23f87bed
MB
7491 (unless (numberp article)
7492 (error "Article %s is not a number" article))
eec82323
LMI
7493 (let ((b (point))
7494 (data (gnus-data-find article)))
7495 ;; We read in the article if we have to.
7496 (and (not data)
7497 force
6748645f
LMI
7498 (gnus-summary-insert-subject
7499 article
7500 (if (or (numberp force) (vectorp force)) force)
7501 t)
eec82323
LMI
7502 (setq data (gnus-data-find article)))
7503 (goto-char b)
7504 (if (not data)
7505 (progn
7506 (unless silent
7507 (gnus-message 3 "Can't find article %d" article))
7508 nil)
23f87bed
MB
7509 (let ((pt (gnus-data-pos data)))
7510 (goto-char pt)
7511 (gnus-summary-set-article-display-arrow pt))
6748645f 7512 (gnus-summary-position-point)
eec82323
LMI
7513 article)))
7514
7515;; Walking around summary lines with displaying articles.
7516
7517(defun gnus-summary-expand-window (&optional arg)
7518 "Make the summary buffer take up the entire Emacs frame.
7519Given a prefix, will force an `article' buffer configuration."
7520 (interactive "P")
eec82323
LMI
7521 (if arg
7522 (gnus-configure-windows 'article 'force)
7523 (gnus-configure-windows 'summary 'force)))
7524
7525(defun gnus-summary-display-article (article &optional all-header)
7526 "Display ARTICLE in article buffer."
01c52d31
MB
7527 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7528 (with-current-buffer gnus-article-buffer
7529 (eq major-mode 'gnus-article-mode)))
7530 (gnus-article-setup-buffer))
eec82323 7531 (gnus-set-global-variables)
01c52d31
MB
7532 (with-current-buffer gnus-article-buffer
7533 (setq gnus-article-charset gnus-newsgroup-charset)
7534 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7535 (mm-enable-multibyte))
eec82323
LMI
7536 (if (null article)
7537 nil
7538 (prog1
7539 (if gnus-summary-display-article-function
7540 (funcall gnus-summary-display-article-function article all-header)
7541 (gnus-article-prepare article all-header))
6748645f 7542 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7543 (when (and gnus-current-article
7544 (not (zerop gnus-current-article)))
7545 (gnus-summary-goto-subject gnus-current-article))
7546 (gnus-summary-recenter)
7547 (when (and gnus-use-trees gnus-show-threads)
7548 (gnus-possibly-generate-tree article)
7549 (gnus-highlight-selected-tree article))
7550 ;; Successfully display article.
7551 (gnus-article-set-window-start
7552 (cdr (assq article gnus-newsgroup-bookmarks))))))
7553
7554(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7555 "Select the current article.
7556If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7557non-nil, the article will be re-fetched even if it already present in
7558the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7559be displayed."
7560 ;; Make sure we are in the summary buffer to work around bbdb bug.
7561 (unless (eq major-mode 'gnus-summary-mode)
7562 (set-buffer gnus-summary-buffer))
7563 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7564 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7565 gnus-summary-display-article-function)
eec82323
LMI
7566 (and (not pseudo)
7567 (gnus-summary-article-pseudo-p article)
a8151ef7 7568 (error "This is a pseudo-article"))
c7a91ce1 7569 (with-current-buffer gnus-summary-buffer
16409b0b
GM
7570 (if (or (and gnus-single-article-buffer
7571 (or (null gnus-current-article)
7572 (null gnus-article-current)
7573 (null (get-buffer gnus-article-buffer))
7574 (not (eq article (cdr gnus-article-current)))
7575 (not (equal (car gnus-article-current)
7576 gnus-newsgroup-name))))
7577 (and (not gnus-single-article-buffer)
7578 (or (null gnus-current-article)
7579 (not (eq gnus-current-article article))))
7580 force)
7581 ;; The requested article is different from the current article.
7582 (progn
16409b0b
GM
7583 (gnus-summary-display-article article all-headers)
7584 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7585 (with-current-buffer gnus-article-buffer
16409b0b 7586 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7587 (mm-disable-multibyte))))
16409b0b
GM
7588 (gnus-article-set-window-start
7589 (cdr (assq article gnus-newsgroup-bookmarks)))
7590 article)
16409b0b 7591 'old))))
eec82323 7592
23f87bed
MB
7593(defun gnus-summary-force-verify-and-decrypt ()
7594 "Display buttons for signed/encrypted parts and verify/decrypt them."
7595 (interactive)
7596 (let ((mm-verify-option 'known)
7597 (mm-decrypt-option 'known)
7598 (gnus-article-emulate-mime t)
7599 (gnus-buttonized-mime-types (append (list "multipart/signed"
7600 "multipart/encrypted")
7601 gnus-buttonized-mime-types)))
7602 (gnus-summary-select-article nil 'force)))
7603
eec82323
LMI
7604(defun gnus-summary-set-current-mark (&optional current-mark)
7605 "Obsolete function."
7606 nil)
7607
7608(defun gnus-summary-next-article (&optional unread subject backward push)
7609 "Select the next article.
7610If UNREAD, only unread articles are selected.
7611If SUBJECT, only articles with SUBJECT are selected.
7612If BACKWARD, the previous article is selected instead of the next."
7613 (interactive "P")
11e95b02
MB
7614 ;; Make sure we are in the summary buffer.
7615 (unless (eq major-mode 'gnus-summary-mode)
7616 (set-buffer gnus-summary-buffer))
eec82323
LMI
7617 (cond
7618 ;; Is there such an article?
7619 ((and (gnus-summary-search-forward unread subject backward)
7620 (or (gnus-summary-display-article (gnus-summary-article-number))
7621 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7622 (gnus-summary-position-point))
7623 ;; If not, we try the first unread, if that is wanted.
7624 ((and subject
7625 gnus-auto-select-same
7626 (gnus-summary-first-unread-article))
7627 (gnus-summary-position-point)
7628 (gnus-message 6 "Wrapped"))
7629 ;; Try to get next/previous article not displayed in this group.
7630 ((and gnus-auto-extend-newsgroup
7631 (not unread) (not subject))
7632 (gnus-summary-goto-article
7633 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7634 nil (count-lines (point-min) (point))))
eec82323
LMI
7635 ;; Go to next/previous group.
7636 (t
7637 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7638 (gnus-summary-jump-to-group gnus-newsgroup-name))
49e787c9
GM
7639 (let ((cmd (if (featurep 'xemacs)
7640 last-command-char
7641 last-command-event))
eec82323 7642 (point
01c52d31 7643 (with-current-buffer gnus-group-buffer
eec82323
LMI
7644 (point)))
7645 (group
7646 (if (eq gnus-keep-same-level 'best)
7647 (gnus-summary-best-group gnus-newsgroup-name)
7648 (gnus-summary-search-group backward gnus-keep-same-level))))
7649 ;; For some reason, the group window gets selected. We change
7650 ;; it back.
7651 (select-window (get-buffer-window (current-buffer)))
7652 ;; Select next unread newsgroup automagically.
7653 (cond
7654 ((or (not gnus-auto-select-next)
7655 (not cmd))
7656 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7657 ((or (eq gnus-auto-select-next 'quietly)
7658 (and (eq gnus-auto-select-next 'slightly-quietly)
7659 push)
7660 (and (eq gnus-auto-select-next 'almost-quietly)
7661 (gnus-summary-last-article-p)))
7662 ;; Select quietly.
7663 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7664 (gnus-summary-exit)
7665 (gnus-message 7 "No more%s articles (%s)..."
7666 (if unread " unread" "")
7667 (if group (concat "selecting " group)
7668 "exiting"))
7669 (gnus-summary-next-group nil group backward)))
7670 (t
7671 (when (gnus-key-press-event-p last-input-event)
7672 (gnus-summary-walk-group-buffer
7673 gnus-newsgroup-name cmd unread backward point))))))))
7674
7675(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7676 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7677 (?\C-p (gnus-group-prev-unread-group 1))))
7678 (cursor-in-echo-area t)
23f87bed 7679 keve key group ended prompt)
c7a91ce1 7680 (with-current-buffer gnus-group-buffer
eec82323
LMI
7681 (goto-char start)
7682 (setq group
7683 (if (eq gnus-keep-same-level 'best)
7684 (gnus-summary-best-group gnus-newsgroup-name)
7685 (gnus-summary-search-group backward gnus-keep-same-level))))
7686 (while (not ended)
23f87bed
MB
7687 (setq prompt
7688 (format
7689 "No more%s articles%s " (if unread " unread" "")
7690 (if (and group
7691 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7692 (format " (Type %s for %s [%s])"
91472578
MB
7693 (single-key-description cmd)
7694 (gnus-group-decoded-name group)
01c52d31 7695 (gnus-group-unread group))
23f87bed
MB
7696 (format " (Type %s to exit %s)"
7697 (single-key-description cmd)
91472578 7698 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7699 ;; Confirm auto selection.
23f87bed
MB
7700 (setq key (car (setq keve (gnus-read-event-char prompt)))
7701 ended t)
eec82323
LMI
7702 (cond
7703 ((assq key keystrokes)
7704 (let ((obuf (current-buffer)))
7705 (switch-to-buffer gnus-group-buffer)
7706 (when group
7707 (gnus-group-jump-to-group group))
7708 (eval (cadr (assq key keystrokes)))
7709 (setq group (gnus-group-group-name))
7710 (switch-to-buffer obuf))
7711 (setq ended nil))
7712 ((equal key cmd)
7713 (if (or (not group)
7714 (gnus-ephemeral-group-p gnus-newsgroup-name))
7715 (gnus-summary-exit)
7716 (gnus-summary-next-group nil group backward)))
7717 (t
7718 (push (cdr keve) unread-command-events))))))
7719
7720(defun gnus-summary-next-unread-article ()
7721 "Select unread article after current one."
7722 (interactive)
7723 (gnus-summary-next-article
7724 (or (not (eq gnus-summary-goto-unread 'never))
7725 (gnus-summary-last-article-p (gnus-summary-article-number)))
7726 (and gnus-auto-select-same
7727 (gnus-summary-article-subject))))
7728
7729(defun gnus-summary-prev-article (&optional unread subject)
bbbe940b 7730 "Select the article before the current one.
eec82323
LMI
7731If UNREAD is non-nil, only unread articles are selected."
7732 (interactive "P")
7733 (gnus-summary-next-article unread subject t))
7734
7735(defun gnus-summary-prev-unread-article ()
7736 "Select unread article before current one."
7737 (interactive)
7738 (gnus-summary-prev-article
7739 (or (not (eq gnus-summary-goto-unread 'never))
7740 (gnus-summary-first-article-p (gnus-summary-article-number)))
7741 (and gnus-auto-select-same
7742 (gnus-summary-article-subject))))
7743
23f87bed 7744(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7745 "Show next page of the selected article.
7746If at the end of the current article, select the next article.
7747LINES says how many lines should be scrolled up.
7748
7749If CIRCULAR is non-nil, go to the start of the article instead of
7750selecting the next article when reaching the end of the current
23f87bed
MB
7751article.
7752
7753If STOP is non-nil, just stop when reaching the end of the message.
7754
7755Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7756 (interactive "P")
7757 (setq gnus-summary-buffer (current-buffer))
7758 (gnus-set-global-variables)
7759 (let ((article (gnus-summary-article-number))
7760 (article-window (get-buffer-window gnus-article-buffer t))
7761 endp)
6748645f
LMI
7762 ;; If the buffer is empty, we have no article.
7763 (unless article
7764 (error "No article to select"))
eec82323
LMI
7765 (gnus-configure-windows 'article)
7766 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7767 (if (and (eq gnus-summary-goto-unread 'never)
7768 (not (gnus-summary-last-article-p article)))
7769 (gnus-summary-next-article)
7770 (gnus-summary-next-unread-article))
7771 (if (or (null gnus-current-article)
7772 (null gnus-article-current)
7773 (/= article (cdr gnus-article-current))
7774 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7775 ;; Selected subject is different from current article's.
7776 (gnus-summary-display-article article)
7777 (when article-window
7778 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7779 (setq endp (or (gnus-article-next-page lines)
7780 (gnus-article-only-boring-p))))
eec82323 7781 (when endp
b1992461 7782 (cond ((or stop gnus-summary-stop-at-end-of-message)
23f87bed
MB
7783 (gnus-message 3 "End of message"))
7784 (circular
eec82323
LMI
7785 (gnus-summary-beginning-of-article))
7786 (lines
7787 (gnus-message 3 "End of message"))
7788 ((null lines)
7789 (if (and (eq gnus-summary-goto-unread 'never)
7790 (not (gnus-summary-last-article-p article)))
7791 (gnus-summary-next-article)
7792 (gnus-summary-next-unread-article))))))))
7793 (gnus-summary-recenter)
7794 (gnus-summary-position-point)))
7795
7796(defun gnus-summary-prev-page (&optional lines move)
7797 "Show previous page of selected article.
7798Argument LINES specifies lines to be scrolled down.
7799If MOVE, move to the previous unread article if point is at
7800the beginning of the buffer."
7801 (interactive "P")
eec82323
LMI
7802 (let ((article (gnus-summary-article-number))
7803 (article-window (get-buffer-window gnus-article-buffer t))
7804 endp)
7805 (gnus-configure-windows 'article)
7806 (if (or (null gnus-current-article)
7807 (null gnus-article-current)
7808 (/= article (cdr gnus-article-current))
7809 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7810 ;; Selected subject is different from current article's.
7811 (gnus-summary-display-article article)
7812 (gnus-summary-recenter)
7813 (when article-window
7814 (gnus-eval-in-buffer-window gnus-article-buffer
7815 (setq endp (gnus-article-prev-page lines)))
7816 (when (and move endp)
7817 (cond (lines
7818 (gnus-message 3 "Beginning of message"))
7819 ((null lines)
7820 (if (and (eq gnus-summary-goto-unread 'never)
7821 (not (gnus-summary-first-article-p article)))
7822 (gnus-summary-prev-article)
7823 (gnus-summary-prev-unread-article))))))))
7824 (gnus-summary-position-point))
7825
7826(defun gnus-summary-prev-page-or-article (&optional lines)
7827 "Show previous page of selected article.
7828Argument LINES specifies lines to be scrolled down.
7829If at the beginning of the article, go to the next article."
7830 (interactive "P")
7831 (gnus-summary-prev-page lines t))
7832
7833(defun gnus-summary-scroll-up (lines)
7834 "Scroll up (or down) one line current article.
7835Argument LINES specifies lines to be scrolled up (or down if negative)."
7836 (interactive "p")
eec82323
LMI
7837 (gnus-configure-windows 'article)
7838 (gnus-summary-show-thread)
7839 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7840 (gnus-eval-in-buffer-window gnus-article-buffer
7841 (cond ((> lines 0)
7842 (when (gnus-article-next-page lines)
7843 (gnus-message 3 "End of message")))
7844 ((< lines 0)
7845 (gnus-article-prev-page (- lines))))))
7846 (gnus-summary-recenter)
7847 (gnus-summary-position-point))
7848
6748645f
LMI
7849(defun gnus-summary-scroll-down (lines)
7850 "Scroll down (or up) one line current article.
7851Argument LINES specifies lines to be scrolled down (or up if negative)."
7852 (interactive "p")
7853 (gnus-summary-scroll-up (- lines)))
7854
eec82323
LMI
7855(defun gnus-summary-next-same-subject ()
7856 "Select next article which has the same subject as current one."
7857 (interactive)
eec82323
LMI
7858 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7859
7860(defun gnus-summary-prev-same-subject ()
7861 "Select previous article which has the same subject as current one."
7862 (interactive)
eec82323
LMI
7863 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7864
7865(defun gnus-summary-next-unread-same-subject ()
7866 "Select next unread article which has the same subject as current one."
7867 (interactive)
eec82323
LMI
7868 (gnus-summary-next-article t (gnus-summary-article-subject)))
7869
7870(defun gnus-summary-prev-unread-same-subject ()
7871 "Select previous unread article which has the same subject as current one."
7872 (interactive)
eec82323
LMI
7873 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7874
7875(defun gnus-summary-first-unread-article ()
7876 "Select the first unread article.
7877Return nil if there are no unread articles."
7878 (interactive)
eec82323
LMI
7879 (prog1
7880 (when (gnus-summary-first-subject t)
7881 (gnus-summary-show-thread)
7882 (gnus-summary-first-subject t)
7883 (gnus-summary-display-article (gnus-summary-article-number)))
7884 (gnus-summary-position-point)))
7885
16409b0b
GM
7886(defun gnus-summary-first-unread-subject ()
7887 "Place the point on the subject line of the first unread article.
7888Return nil if there are no unread articles."
7889 (interactive)
7890 (prog1
7891 (when (gnus-summary-first-subject t)
7892 (gnus-summary-show-thread)
7893 (gnus-summary-first-subject t))
7894 (gnus-summary-position-point)))
7895
23f87bed
MB
7896(defun gnus-summary-first-unseen-subject ()
7897 "Place the point on the subject line of the first unseen article.
7898Return nil if there are no unseen articles."
7899 (interactive)
7900 (prog1
7901 (when (gnus-summary-first-subject nil nil t)
7902 (gnus-summary-show-thread)
7903 (gnus-summary-first-subject nil nil t))
7904 (gnus-summary-position-point)))
7905
7906(defun gnus-summary-first-unseen-or-unread-subject ()
7907 "Place the point on the subject line of the first unseen article or,
7908if all article have been seen, on the subject line of the first unread
7909article."
7910 (interactive)
7911 (prog1
7912 (unless (when (gnus-summary-first-subject nil nil t)
7913 (gnus-summary-show-thread)
7914 (gnus-summary-first-subject nil nil t))
7915 (when (gnus-summary-first-subject t)
7916 (gnus-summary-show-thread)
7917 (gnus-summary-first-subject t)))
7918 (gnus-summary-position-point)))
7919
eec82323
LMI
7920(defun gnus-summary-first-article ()
7921 "Select the first article.
7922Return nil if there are no articles."
7923 (interactive)
eec82323
LMI
7924 (prog1
7925 (when (gnus-summary-first-subject)
16409b0b
GM
7926 (gnus-summary-show-thread)
7927 (gnus-summary-first-subject)
7928 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
7929 (gnus-summary-position-point)))
7930
23f87bed
MB
7931(defun gnus-summary-best-unread-article (&optional arg)
7932 "Select the unread article with the highest score.
7933If given a prefix argument, select the next unread article that has a
7934score higher than the default score."
7935 (interactive "P")
7936 (let ((article (if arg
7937 (gnus-summary-better-unread-subject)
7938 (gnus-summary-best-unread-subject))))
7939 (if article
7940 (gnus-summary-goto-article article)
7941 (error "No unread articles"))))
7942
7943(defun gnus-summary-best-unread-subject ()
7944 "Select the unread subject with the highest score."
eec82323 7945 (interactive)
eec82323
LMI
7946 (let ((best -1000000)
7947 (data gnus-newsgroup-data)
7948 article score)
7949 (while data
7950 (and (gnus-data-unread-p (car data))
7951 (> (setq score
7952 (gnus-summary-article-score (gnus-data-number (car data))))
7953 best)
7954 (setq best score
7955 article (gnus-data-number (car data))))
7956 (setq data (cdr data)))
23f87bed
MB
7957 (when article
7958 (gnus-summary-goto-subject article))
7959 (gnus-summary-position-point)
7960 article))
7961
7962(defun gnus-summary-better-unread-subject ()
7963 "Select the first unread subject that has a score over the default score."
7964 (interactive)
7965 (let ((data gnus-newsgroup-data)
7966 article score)
7967 (while (and (setq article (gnus-data-number (car data)))
7968 (or (gnus-data-read-p (car data))
7969 (not (> (gnus-summary-article-score article)
7970 gnus-summary-default-score))))
7971 (setq data (cdr data)))
7972 (when article
7973 (gnus-summary-goto-subject article))
7974 (gnus-summary-position-point)
7975 article))
eec82323
LMI
7976
7977(defun gnus-summary-last-subject ()
7978 "Go to the last displayed subject line in the group."
7979 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7980 (when article
7981 (gnus-summary-goto-subject article))))
7982
7983(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
7984 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7985If ALL-HEADERS is non-nil, no header lines are hidden.
7986If FORCE, go to the article even if it isn't displayed. If FORCE
7987is a number, it is the line the article is to be displayed on."
eec82323
LMI
7988 (interactive
7989 (list
6748645f
LMI
7990 (completing-read
7991 "Article number or Message-ID: "
7992 (mapcar (lambda (number) (list (int-to-string number)))
7993 gnus-newsgroup-limit))
eec82323
LMI
7994 current-prefix-arg
7995 t))
7996 (prog1
6748645f 7997 (if (and (stringp article)
23f87bed 7998 (string-match "@\\|%40" article))
6748645f
LMI
7999 (gnus-summary-refer-article article)
8000 (when (stringp article)
8001 (setq article (string-to-number article)))
8002 (if (gnus-summary-goto-subject article force)
8003 (gnus-summary-display-article article all-headers)
8004 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
8005 (gnus-summary-position-point)))
8006
8007(defun gnus-summary-goto-last-article ()
8008 "Go to the previously read article."
8009 (interactive)
8010 (prog1
8011 (when gnus-last-article
6748645f 8012 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
8013 (gnus-summary-position-point)))
8014
8015(defun gnus-summary-pop-article (number)
8016 "Pop one article off the history and go to the previous.
8017NUMBER articles will be popped off."
8018 (interactive "p")
8019 (let (to)
8020 (setq gnus-newsgroup-history
8021 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8022 (if to
6748645f 8023 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
8024 (error "Article history empty")))
8025 (gnus-summary-position-point))
8026
8027;; Summary commands and functions for limiting the summary buffer.
8028
8029(defun gnus-summary-limit-to-articles (n)
8030 "Limit the summary buffer to the next N articles.
8031If not given a prefix, use the process marked articles instead."
8032 (interactive "P")
eec82323
LMI
8033 (prog1
8034 (let ((articles (gnus-summary-work-articles n)))
8035 (setq gnus-newsgroup-processable nil)
8036 (gnus-summary-limit articles))
8037 (gnus-summary-position-point)))
8038
8039(defun gnus-summary-pop-limit (&optional total)
8040 "Restore the previous limit.
8041If given a prefix, remove all limits."
8042 (interactive "P")
eec82323
LMI
8043 (when total
8044 (setq gnus-newsgroup-limits
8045 (list (mapcar (lambda (h) (mail-header-number h))
8046 gnus-newsgroup-headers))))
8047 (unless gnus-newsgroup-limits
8048 (error "No limit to pop"))
8049 (prog1
8050 (gnus-summary-limit nil 'pop)
8051 (gnus-summary-position-point)))
8052
47b63dfa
SZ
8053(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8054 "Limit the summary buffer to articles that have subjects that match a regexp.
8055If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 8056 (interactive
47b63dfa
SZ
8057 (list (read-string (if current-prefix-arg
8058 "Exclude subject (regexp): "
a1506d29 8059 "Limit to subject (regexp): "))
47b63dfa 8060 nil current-prefix-arg))
eec82323
LMI
8061 (unless header
8062 (setq header "subject"))
8063 (when (not (equal "" subject))
8064 (prog1
8065 (let ((articles (gnus-summary-find-matching
a1506d29 8066 (or header "subject") subject 'all nil nil
47b63dfa 8067 not-matching)))
eec82323
LMI
8068 (unless articles
8069 (error "Found no matches for \"%s\"" subject))
8070 (gnus-summary-limit articles))
8071 (gnus-summary-position-point))))
8072
ef6e0ec7 8073(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
8074 "Limit the summary buffer to articles that have authors that match a regexp.
8075If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 8076 (interactive
47b63dfa
SZ
8077 (list (read-string (if current-prefix-arg
8078 "Exclude author (regexp): "
a1506d29 8079 "Limit to author (regexp): "))
ef6e0ec7
SZ
8080 current-prefix-arg))
8081 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323 8082
01c52d31
MB
8083(defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8084 "Limit the summary buffer to articles with the given RECIPIENT.
8085
8086If NOT-MATCHING, exclude RECIPIENT.
8087
8088To and Cc headers are checked. You need to include them in
8089`nnmail-extra-headers'."
8090 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8091 (interactive
8092 (list (read-string (format "%s recipient (regexp): "
8093 (if current-prefix-arg "Exclude" "Limit to")))
8094 current-prefix-arg))
8095 (when (not (equal "" recipient))
8096 (prog1 (let* ((to
8097 (if (memq 'To nnmail-extra-headers)
8098 (gnus-summary-find-matching
8099 (cons 'extra 'To) recipient 'all nil nil
8100 not-matching)
8101 (gnus-message
8102 1 "`To' isn't present in `nnmail-extra-headers'")
8103 (sit-for 1)
8104 nil))
8105 (cc
8106 (if (memq 'Cc nnmail-extra-headers)
8107 (gnus-summary-find-matching
8108 (cons 'extra 'Cc) recipient 'all nil nil
8109 not-matching)
8110 (gnus-message
8111 1 "`Cc' isn't present in `nnmail-extra-headers'")
8112 (sit-for 1)
8113 nil))
8114 (articles
8115 (if not-matching
8116 ;; We need the numbers that are in both lists:
8117 (mapcar (lambda (a)
8118 (and (memq a to) a))
8119 cc)
8120 (nconc to cc))))
8121 (unless articles
8122 (error "Found no matches for \"%s\"" recipient))
8123 (gnus-summary-limit articles))
8124 (gnus-summary-position-point))))
8125
8126(defun gnus-summary-limit-to-address (address &optional not-matching)
8127 "Limit the summary buffer to articles with the given ADDRESS.
8128
8129If NOT-MATCHING, exclude ADDRESS.
8130
8131To, Cc and From headers are checked. You need to include `To' and `Cc'
8132in `nnmail-extra-headers'."
8133 (interactive
8134 (list (read-string (format "%s address (regexp): "
8135 (if current-prefix-arg "Exclude" "Limit to")))
8136 current-prefix-arg))
8137 (when (not (equal "" address))
8138 (prog1 (let* ((to
8139 (if (memq 'To nnmail-extra-headers)
8140 (gnus-summary-find-matching
8141 (cons 'extra 'To) address 'all nil nil
8142 not-matching)
8143 (gnus-message
8144 1 "`To' isn't present in `nnmail-extra-headers'")
8145 (sit-for 1)
8146 t))
8147 (cc
8148 (if (memq 'Cc nnmail-extra-headers)
8149 (gnus-summary-find-matching
8150 (cons 'extra 'Cc) address 'all nil nil
8151 not-matching)
8152 (gnus-message
8153 1 "`Cc' isn't present in `nnmail-extra-headers'")
8154 (sit-for 1)
8155 t))
8156 (from
8157 (gnus-summary-find-matching "from" address
8158 'all nil nil not-matching))
8159 (articles
8160 (if not-matching
8161 ;; We need the numbers that are in all lists:
8162 (if (eq cc t)
8163 (if (eq to t)
8164 from
8165 (mapcar (lambda (a) (car (memq a from))) to))
8166 (if (eq to t)
8167 (mapcar (lambda (a) (car (memq a from))) cc)
8168 (mapcar (lambda (a) (car (memq a from)))
8169 (mapcar (lambda (a) (car (memq a to)))
8170 cc))))
8171 (nconc (if (eq to t) nil to)
8172 (if (eq cc t) nil cc)
8173 from))))
8174 (unless articles
8175 (error "Found no matches for \"%s\"" address))
8176 (gnus-summary-limit articles))
8177 (gnus-summary-position-point))))
8178
8179(defun gnus-summary-limit-strange-charsets-predicate (header)
765d4319
KY
8180 (when (fboundp 'char-charset)
8181 (let ((string (concat (mail-header-subject header)
8182 (mail-header-from header)))
8183 charset found)
8184 (dotimes (i (1- (length string)))
8185 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8186 (when (string-match "unicode\\|big\\|japanese" charset)
8187 (setq found t)))
8188 found)))
01c52d31
MB
8189
8190(defun gnus-summary-limit-to-predicate (predicate)
8191 "Limit to articles where PREDICATE returns non-nil.
8192PREDICATE will be called with the header structures of the
8193articles."
8194 (let ((articles nil)
8195 (case-fold-search t))
8196 (dolist (header gnus-newsgroup-headers)
8197 (when (funcall predicate header)
8198 (push (mail-header-number header) articles)))
8199 (gnus-summary-limit (nreverse articles))))
8200
eec82323
LMI
8201(defun gnus-summary-limit-to-age (age &optional younger-p)
8202 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8203If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8204articles that are younger than AGE days."
16409b0b
GM
8205 (interactive
8206 (let ((younger current-prefix-arg)
8207 (days-got nil)
8208 days)
8209 (while (not days-got)
8210 (setq days (if younger
23f87bed
MB
8211 (read-string "Limit to articles younger than (in days, older when negative): ")
8212 (read-string
8213 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
8214 (when (> (length days) 0)
8215 (setq days (read days)))
8216 (if (numberp days)
23f87bed
MB
8217 (progn
8218 (setq days-got t)
01c52d31
MB
8219 (when (< days 0)
8220 (setq younger (not younger))
8221 (setq days (* days -1))))
16409b0b
GM
8222 (message "Please enter a number.")
8223 (sleep-for 1)))
8224 (list days younger)))
eec82323
LMI
8225 (prog1
8226 (let ((data gnus-newsgroup-data)
16409b0b 8227 (cutoff (days-to-time age))
eec82323
LMI
8228 articles d date is-younger)
8229 (while (setq d (pop data))
8230 (when (and (vectorp (gnus-data-header d))
8231 (setq date (mail-header-date (gnus-data-header d))))
16409b0b 8232 (setq is-younger (time-less-p
3d6e7a43 8233 (time-since (gnus-date-get-time date))
eec82323 8234 cutoff))
6748645f
LMI
8235 (when (if younger-p
8236 is-younger
8237 (not is-younger))
eec82323
LMI
8238 (push (gnus-data-number d) articles))))
8239 (gnus-summary-limit (nreverse articles)))
8240 (gnus-summary-position-point)))
8241
47b63dfa 8242(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
8243 "Limit the summary buffer to articles that match an 'extra' header."
8244 (interactive
8245 (let ((header
8246 (intern
23f87bed 8247 (gnus-completing-read-with-default
16409b0b 8248 (symbol-name (car gnus-extra-headers))
47b63dfa 8249 (if current-prefix-arg
81df110a
RF
8250 "Exclude extra header"
8251 "Limit extra header")
16409b0b
GM
8252 (mapcar (lambda (x)
8253 (cons (symbol-name x) x))
8254 gnus-extra-headers)
8255 nil
8256 t))))
8257 (list header
a1506d29 8258 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
8259 (if current-prefix-arg "Exclude" "Limit to")
8260 header))
8261 current-prefix-arg)))
16409b0b
GM
8262 (when (not (equal "" regexp))
8263 (prog1
8264 (let ((articles (gnus-summary-find-matching
a1506d29 8265 (cons 'extra header) regexp 'all nil nil
47b63dfa 8266 not-matching)))
16409b0b
GM
8267 (unless articles
8268 (error "Found no matches for \"%s\"" regexp))
8269 (gnus-summary-limit articles))
8270 (gnus-summary-position-point))))
8271
23f87bed
MB
8272(defun gnus-summary-limit-to-display-predicate ()
8273 "Limit the summary buffer to the predicated in the `display' group parameter."
8274 (interactive)
8275 (unless gnus-newsgroup-display
8276 (error "There is no `display' group parameter"))
8277 (let (articles)
8278 (dolist (number gnus-newsgroup-articles)
8279 (when (funcall gnus-newsgroup-display)
8280 (push number articles)))
8281 (gnus-summary-limit articles))
8282 (gnus-summary-position-point))
8283
eec82323
LMI
8284(defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8285(make-obsolete
265ac10b 8286 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread "Emacs 20.4")
eec82323
LMI
8287
8288(defun gnus-summary-limit-to-unread (&optional all)
8289 "Limit the summary buffer to articles that are not marked as read.
8290If ALL is non-nil, limit strictly to unread articles."
8291 (interactive "P")
8292 (if all
8293 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8294 (gnus-summary-limit-to-marks
8295 ;; Concat all the marks that say that an article is read and have
8296 ;; those removed.
8297 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 8298 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
8299 gnus-low-score-mark gnus-expirable-mark
8300 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
c4d82de8 8301 gnus-duplicate-mark)
eec82323
LMI
8302 'reverse)))
8303
01c52d31
MB
8304(defun gnus-summary-limit-to-headers (match &optional reverse)
8305 "Limit the summary buffer to articles that have headers that match MATCH.
8306If REVERSE (the prefix), limit to articles that don't match."
8307 (interactive "sMatch headers (regexp): \nP")
8308 (gnus-summary-limit-to-bodies match reverse t))
8309
8310(defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8311 "Limit the summary buffer to articles that have bodies that match MATCH.
8312If REVERSE (the prefix), limit to articles that don't match."
8313 (interactive "sMatch body (regexp): \nP")
8314 (let ((articles nil)
8315 (gnus-select-article-hook nil) ;Disable hook.
8316 (gnus-article-prepare-hook nil)
8317 (gnus-use-article-prefetch nil)
8318 (gnus-keep-backlog nil)
8319 (gnus-break-pages nil)
8320 (gnus-summary-display-arrow nil)
8321 (gnus-updated-mode-lines nil)
8322 (gnus-auto-center-summary nil)
8323 (gnus-display-mime-function nil))
8324 (dolist (data gnus-newsgroup-data)
8325 (let (gnus-mark-article-hook)
8326 (gnus-summary-select-article t t nil (gnus-data-number data)))
398a825b 8327 (with-current-buffer gnus-article-buffer
01c52d31
MB
8328 (article-goto-body)
8329 (let* ((case-fold-search t)
8330 (found (if headersp
8331 (re-search-backward match nil t)
8332 (re-search-forward match nil t))))
8333 (when (or (and found
8334 (not reverse))
8335 (and (not found)
8336 reverse))
8337 (push (gnus-data-number data) articles)))))
8338 (if (not articles)
8339 (message "No messages matched")
8340 (gnus-summary-limit articles)))
8341 (gnus-summary-position-point))
8342
8343(defun gnus-summary-limit-to-singletons (&optional threadsp)
8344 "Limit the summary buffer to articles that aren't part on any thread.
8345If THREADSP (the prefix), limit to articles that are in threads."
8346 (interactive "P")
8347 (let ((articles nil)
8348 thread-articles
8349 threads)
8350 (dolist (thread gnus-newsgroup-threads)
8351 (if (stringp (car thread))
8352 (dolist (thread (cdr thread))
8353 (push thread threads))
8354 (push thread threads)))
8355 (dolist (thread threads)
8356 (setq thread-articles (gnus-articles-in-thread thread))
8357 (when (or (and threadsp
8358 (> (length thread-articles) 1))
8359 (and (not threadsp)
8360 (= (length thread-articles) 1)))
8361 (setq articles (nconc thread-articles articles))))
8362 (if (not articles)
8363 (message "No messages matched")
8364 (gnus-summary-limit articles))
8365 (gnus-summary-position-point)))
8366
8367(defun gnus-summary-limit-to-replied (&optional unreplied)
8368 "Limit the summary buffer to replied articles.
8369If UNREPLIED (the prefix), limit to unreplied articles."
8370 (interactive "P")
8371 (if unreplied
8372 (gnus-summary-limit
8373 (gnus-set-difference gnus-newsgroup-articles
8374 gnus-newsgroup-replied))
8375 (gnus-summary-limit gnus-newsgroup-replied))
8376 (gnus-summary-position-point))
8377
eec82323
LMI
8378(defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
8379(make-obsolete 'gnus-summary-delete-marked-with
265ac10b 8380 'gnus-summary-limit-exclude-marks "Emacs 20.4")
eec82323
LMI
8381
8382(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8383 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8384If REVERSE, limit the summary buffer to articles that are marked
8385with MARKS. MARKS can either be a string of marks or a list of marks.
8386Returns how many articles were removed."
8387 (interactive "sMarks: ")
8388 (gnus-summary-limit-to-marks marks t))
8389
8390(defun gnus-summary-limit-to-marks (marks &optional reverse)
8391 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8392If REVERSE (the prefix), limit the summary buffer to articles that are
8393not marked with MARKS. MARKS can either be a string of marks or a
8394list of marks.
8395Returns how many articles were removed."
6748645f 8396 (interactive "sMarks: \nP")
eec82323
LMI
8397 (prog1
8398 (let ((data gnus-newsgroup-data)
8399 (marks (if (listp marks) marks
8400 (append marks nil))) ; Transform to list.
8401 articles)
8402 (while data
8403 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8404 (memq (gnus-data-mark (car data)) marks))
8405 (push (gnus-data-number (car data)) articles))
8406 (setq data (cdr data)))
8407 (gnus-summary-limit articles))
8408 (gnus-summary-position-point)))
8409
23f87bed 8410(defun gnus-summary-limit-to-score (score)
eec82323 8411 "Limit to articles with score at or above SCORE."
23f87bed 8412 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
8413 (let ((data gnus-newsgroup-data)
8414 articles)
8415 (while data
8416 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8417 score)
8418 (push (gnus-data-number (car data)) articles))
8419 (setq data (cdr data)))
8420 (prog1
8421 (gnus-summary-limit articles)
8422 (gnus-summary-position-point))))
8423
23f87bed
MB
8424(defun gnus-summary-limit-to-unseen ()
8425 "Limit to unseen articles."
8426 (interactive)
8427 (prog1
8428 (gnus-summary-limit gnus-newsgroup-unseen)
8429 (gnus-summary-position-point)))
8430
6748645f 8431(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
8432 "Display all the hidden articles that is in the thread with ID in it.
8433When called interactively, ID is the Message-ID of the current
8434article."
6748645f
LMI
8435 (interactive (list (mail-header-id (gnus-summary-article-header))))
8436 (let ((articles (gnus-articles-in-thread
8437 (gnus-id-to-thread (gnus-root-id id)))))
8438 (prog1
8439 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
8440 (gnus-summary-limit-include-matching-articles
8441 "subject"
8442 (regexp-quote (gnus-simplify-subject-re
8443 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
8444 (gnus-summary-position-point))))
8445
23f87bed
MB
8446(defun gnus-summary-limit-include-matching-articles (header regexp)
8447 "Display all the hidden articles that have HEADERs that match REGEXP."
8448 (interactive (list (read-string "Match on header: ")
8449 (read-string "Regexp: ")))
8450 (let ((articles (gnus-find-matching-articles header regexp)))
8451 (prog1
8452 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8453 (gnus-summary-position-point))))
8454
8455(defun gnus-summary-insert-dormant-articles ()
8456 "Insert all the dormant articles for this group into the current buffer."
8457 (interactive)
8458 (let ((gnus-verbose (max 6 gnus-verbose)))
8459 (if (not gnus-newsgroup-dormant)
db629244 8460 (gnus-message 3 "No dormant articles for this group")
23f87bed
MB
8461 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8462
01c52d31
MB
8463(defun gnus-summary-insert-ticked-articles ()
8464 "Insert ticked articles for this group into the current buffer."
8465 (interactive)
8466 (let ((gnus-verbose (max 6 gnus-verbose)))
8467 (if (not gnus-newsgroup-marked)
8468 (gnus-message 3 "No ticked articles for this group")
8469 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8470
eec82323 8471(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
8472 "Display all the hidden articles that are marked as dormant.
8473Note that this command only works on a subset of the articles currently
8474fetched for this group."
eec82323 8475 (interactive)
eec82323
LMI
8476 (unless gnus-newsgroup-dormant
8477 (error "There are no dormant articles in this group"))
8478 (prog1
8479 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8480 (gnus-summary-position-point)))
8481
8482(defun gnus-summary-limit-exclude-dormant ()
8483 "Hide all dormant articles."
8484 (interactive)
eec82323
LMI
8485 (prog1
8486 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8487 (gnus-summary-position-point)))
8488
8489(defun gnus-summary-limit-exclude-childless-dormant ()
8490 "Hide all dormant articles that have no children."
8491 (interactive)
eec82323
LMI
8492 (let ((data (gnus-data-list t))
8493 articles d children)
8494 ;; Find all articles that are either not dormant or have
8495 ;; children.
8496 (while (setq d (pop data))
8497 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8498 (and (setq children
8499 (gnus-article-children (gnus-data-number d)))
8500 (let (found)
8501 (while children
8502 (when (memq (car children) articles)
8503 (setq children nil
8504 found t))
8505 (pop children))
8506 found)))
8507 (push (gnus-data-number d) articles)))
8508 ;; Do the limiting.
8509 (prog1
8510 (gnus-summary-limit articles)
8511 (gnus-summary-position-point))))
8512
8513(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8514 "Mark all unread excluded articles as read.
8515If ALL, mark even excluded ticked and dormants as read."
8516 (interactive "P")
23f87bed
MB
8517 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8518 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8519 (sort
8520 (mapcar (lambda (h) (mail-header-number h))
8521 gnus-newsgroup-headers)
8522 '<)
23f87bed 8523 gnus-newsgroup-limit))
eec82323 8524 article)
6748645f 8525 (setq gnus-newsgroup-unreads
23f87bed
MB
8526 (gnus-sorted-intersection gnus-newsgroup-unreads
8527 gnus-newsgroup-limit))
eec82323
LMI
8528 (if all
8529 (setq gnus-newsgroup-dormant nil
8530 gnus-newsgroup-marked nil
8531 gnus-newsgroup-reads
8532 (nconc
8533 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8534 gnus-newsgroup-reads))
8535 (while (setq article (pop articles))
8536 (unless (or (memq article gnus-newsgroup-dormant)
8537 (memq article gnus-newsgroup-marked))
8538 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8539
8540(defun gnus-summary-limit (articles &optional pop)
8541 (if pop
8542 ;; We pop the previous limit off the stack and use that.
8543 (setq articles (car gnus-newsgroup-limits)
8544 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8545 ;; We use the new limit, so we push the old limit on the stack.
8546 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8547 ;; Set the limit.
8548 (setq gnus-newsgroup-limit articles)
8549 (let ((total (length gnus-newsgroup-data))
8550 (data (gnus-data-find-list (gnus-summary-article-number)))
8551 (gnus-summary-mark-below nil) ; Inhibit this.
8552 found)
8553 ;; This will do all the work of generating the new summary buffer
8554 ;; according to the new limit.
8555 (gnus-summary-prepare)
8556 ;; Hide any threads, possibly.
23f87bed 8557 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8558 ;; Try to return to the article you were at, or one in the
8559 ;; neighborhood.
8560 (when data
8561 ;; We try to find some article after the current one.
8562 (while data
8563 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8564 (setq data nil
8565 found t))
8566 (setq data (cdr data))))
8567 (unless found
8568 ;; If there is no data, that means that we were after the last
8569 ;; article. The same goes when we can't find any articles
8570 ;; after the current one.
8571 (goto-char (point-max))
8572 (gnus-summary-find-prev))
6748645f 8573 (gnus-set-mode-line 'summary)
eec82323
LMI
8574 ;; We return how many articles were removed from the summary
8575 ;; buffer as a result of the new limit.
8576 (- total (length gnus-newsgroup-data))))
8577
8578(defsubst gnus-invisible-cut-children (threads)
8579 (let ((num 0))
8580 (while threads
8581 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8582 (incf num))
8583 (pop threads))
8584 (< num 2)))
8585
8586(defsubst gnus-cut-thread (thread)
8587 "Go forwards in the thread until we find an article that we want to display."
8588 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8589 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8590 (numberp gnus-fetch-old-headers)
eec82323
LMI
8591 (eq gnus-build-sparse-threads 'some)
8592 (eq gnus-build-sparse-threads 'more))
8593 ;; Deal with old-fetched headers and sparse threads.
8594 (while (and
8595 thread
8596 (or
8597 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8598 (gnus-summary-article-ancient-p
8599 (mail-header-number (car thread))))
6748645f
LMI
8600 (if (or (<= (length (cdr thread)) 1)
8601 (eq gnus-fetch-old-headers 'invisible))
8602 (setq gnus-newsgroup-limit
8603 (delq (mail-header-number (car thread))
8604 gnus-newsgroup-limit)
8605 thread (cadr thread))
8606 (when (gnus-invisible-cut-children (cdr thread))
8607 (let ((th (cdr thread)))
8608 (while th
8609 (if (memq (mail-header-number (caar th))
a8151ef7 8610 gnus-newsgroup-limit)
6748645f
LMI
8611 (setq thread (car th)
8612 th nil)
8613 (setq th (cdr th))))))))))
eec82323
LMI
8614 thread)
8615
8616(defun gnus-cut-threads (threads)
23f87bed 8617 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8618 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8619 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8620 (numberp gnus-fetch-old-headers)
eec82323
LMI
8621 (eq gnus-build-sparse-threads 'some)
8622 (eq gnus-build-sparse-threads 'more))
8623 (let ((th threads))
8624 (while th
8625 (setcar th (gnus-cut-thread (car th)))
8626 (setq th (cdr th)))))
8627 ;; Remove nixed out threads.
8628 (delq nil threads))
8629
8630(defun gnus-summary-initial-limit (&optional show-if-empty)
8631 "Figure out what the initial limit is supposed to be on group entry.
8632This entails weeding out unwanted dormants, low-scored articles,
8633fetch-old-headers verbiage, and so on."
8634 ;; Most groups have nothing to remove.
f394fa25
MB
8635 (unless (or gnus-inhibit-limiting
8636 (and (null gnus-newsgroup-dormant)
8637 (eq gnus-newsgroup-display 'gnus-not-ignore)
8638 (not (eq gnus-fetch-old-headers 'some))
8639 (not (numberp gnus-fetch-old-headers))
8640 (not (eq gnus-fetch-old-headers 'invisible))
8641 (null gnus-summary-expunge-below)
8642 (not (eq gnus-build-sparse-threads 'some))
8643 (not (eq gnus-build-sparse-threads 'more))
8644 (null gnus-thread-expunge-below)
8645 (not gnus-use-nocem)))
eec82323
LMI
8646 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8647 (setq gnus-newsgroup-limit nil)
8648 (mapatoms
8649 (lambda (node)
8650 (unless (car (symbol-value node))
8651 ;; These threads have no parents -- they are roots.
8652 (let ((nodes (cdr (symbol-value node)))
8653 thread)
8654 (while nodes
8655 (if (and gnus-thread-expunge-below
8656 (< (gnus-thread-total-score (car nodes))
8657 gnus-thread-expunge-below))
8658 (gnus-expunge-thread (pop nodes))
8659 (setq thread (pop nodes))
8660 (gnus-summary-limit-children thread))))))
8661 gnus-newsgroup-dependencies)
8662 ;; If this limitation resulted in an empty group, we might
8663 ;; pop the previous limit and use it instead.
8664 (when (and (not gnus-newsgroup-limit)
8665 show-if-empty)
8666 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8667 gnus-newsgroup-limit))
8668
8669(defun gnus-summary-limit-children (thread)
8670 "Return 1 if this subthread is visible and 0 if it is not."
8671 ;; First we get the number of visible children to this thread. This
8672 ;; is done by recursing down the thread using this function, so this
8673 ;; will really go down to a leaf article first, before slowly
8674 ;; working its way up towards the root.
8675 (when thread
04b61ae9 8676 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8677 (children
eec82323
LMI
8678 (if (cdr thread)
8679 (apply '+ (mapcar 'gnus-summary-limit-children
8680 (cdr thread)))
8681 0))
8682 (number (mail-header-number (car thread)))
8683 score)
8684 (if (and
8685 (not (memq number gnus-newsgroup-marked))
8686 (or
8687 ;; If this article is dormant and has absolutely no visible
8688 ;; children, then this article isn't visible.
8689 (and (memq number gnus-newsgroup-dormant)
8690 (zerop children))
8691 ;; If this is "fetch-old-headered" and there is no
8692 ;; visible children, then we don't want this article.
16409b0b
GM
8693 (and (or (eq gnus-fetch-old-headers 'some)
8694 (numberp gnus-fetch-old-headers))
eec82323
LMI
8695 (gnus-summary-article-ancient-p number)
8696 (zerop children))
6748645f
LMI
8697 ;; If this is "fetch-old-headered" and `invisible', then
8698 ;; we don't want this article.
8699 (and (eq gnus-fetch-old-headers 'invisible)
8700 (gnus-summary-article-ancient-p number))
eec82323
LMI
8701 ;; If this is a sparsely inserted article with no children,
8702 ;; we don't want it.
8703 (and (eq gnus-build-sparse-threads 'some)
8704 (gnus-summary-article-sparse-p number)
8705 (zerop children))
8706 ;; If we use expunging, and this article is really
8707 ;; low-scored, then we don't want this article.
8708 (when (and gnus-summary-expunge-below
8709 (< (setq score
8710 (or (cdr (assq number gnus-newsgroup-scored))
8711 gnus-summary-default-score))
8712 gnus-summary-expunge-below))
8713 ;; We increase the expunge-tally here, but that has
8714 ;; nothing to do with the limits, really.
8715 (incf gnus-newsgroup-expunged-tally)
8716 ;; We also mark as read here, if that's wanted.
8717 (when (and gnus-summary-mark-below
8718 (< score gnus-summary-mark-below))
8719 (setq gnus-newsgroup-unreads
8720 (delq number gnus-newsgroup-unreads))
8721 (if gnus-newsgroup-auto-expire
8722 (push number gnus-newsgroup-expirable)
8723 (push (cons number gnus-low-score-mark)
8724 gnus-newsgroup-reads)))
8725 t)
23f87bed
MB
8726 ;; Do the `display' group parameter.
8727 (and gnus-newsgroup-display
8728 (not (funcall gnus-newsgroup-display)))
eec82323 8729 ;; Check NoCeM things.
01c52d31
MB
8730 (when (and gnus-use-nocem
8731 (gnus-nocem-unwanted-article-p
8732 (mail-header-id (car thread))))
8733 (setq gnus-newsgroup-unreads
8734 (delq number gnus-newsgroup-unreads))
8735 t)))
eec82323
LMI
8736 ;; Nope, invisible article.
8737 0
8738 ;; Ok, this article is to be visible, so we add it to the limit
8739 ;; and return 1.
8740 (push number gnus-newsgroup-limit)
8741 1))))
8742
8743(defun gnus-expunge-thread (thread)
8744 "Mark all articles in THREAD as read."
8745 (let* ((number (mail-header-number (car thread))))
8746 (incf gnus-newsgroup-expunged-tally)
8747 ;; We also mark as read here, if that's wanted.
8748 (setq gnus-newsgroup-unreads
8749 (delq number gnus-newsgroup-unreads))
8750 (if gnus-newsgroup-auto-expire
8751 (push number gnus-newsgroup-expirable)
8752 (push (cons number gnus-low-score-mark)
8753 gnus-newsgroup-reads)))
8754 ;; Go recursively through all subthreads.
8755 (mapcar 'gnus-expunge-thread (cdr thread)))
8756
8757;; Summary article oriented commands
8758
8759(defun gnus-summary-refer-parent-article (n)
8760 "Refer parent article N times.
8761If N is negative, go to ancestor -N instead.
8762The difference between N and the number of articles fetched is returned."
8763 (interactive "p")
eec82323
LMI
8764 (let ((skip 1)
8765 error header ref)
8766 (when (not (natnump n))
8767 (setq skip (abs n)
8768 n 1))
8769 (while (and (> n 0)
8770 (not error))
8771 (setq header (gnus-summary-article-header))
8772 (if (and (eq (mail-header-number header)
8773 (cdr gnus-article-current))
8774 (equal gnus-newsgroup-name
8775 (car gnus-article-current)))
8776 ;; If we try to find the parent of the currently
8777 ;; displayed article, then we take a look at the actual
8778 ;; References header, since this is slightly more
8779 ;; reliable than the References field we got from the
8780 ;; server.
c7a91ce1 8781 (with-current-buffer gnus-original-article-buffer
eec82323
LMI
8782 (nnheader-narrow-to-headers)
8783 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8784 (when (setq ref (message-fetch-field "in-reply-to"))
8785 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8786 (widen))
8787 (setq ref
8788 ;; It's not the current article, so we take a bet on
8789 ;; the value we got from the server.
8790 (mail-header-references header)))
8791 (if (and ref
8792 (not (equal ref "")))
8793 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8794 (gnus-message 1 "Couldn't find parent"))
8795 (gnus-message 1 "No references in article %d"
8796 (gnus-summary-article-number))
8797 (setq error t))
8798 (decf n))
8799 (gnus-summary-position-point)
8800 n))
8801
8802(defun gnus-summary-refer-references ()
8803 "Fetch all articles mentioned in the References header.
6748645f 8804Return the number of articles fetched."
eec82323 8805 (interactive)
eec82323
LMI
8806 (let ((ref (mail-header-references (gnus-summary-article-header)))
8807 (current (gnus-summary-article-number))
8808 (n 0))
8809 (if (or (not ref)
8810 (equal ref ""))
8811 (error "No References in the current article")
8812 ;; For each Message-ID in the References header...
8813 (while (string-match "<[^>]*>" ref)
8814 (incf n)
8815 ;; ... fetch that article.
8816 (gnus-summary-refer-article
8817 (prog1 (match-string 0 ref)
8818 (setq ref (substring ref (match-end 0))))))
8819 (gnus-summary-goto-subject current)
8820 (gnus-summary-position-point)
8821 n)))
8822
6748645f
LMI
8823(defun gnus-summary-refer-thread (&optional limit)
8824 "Fetch all articles in the current thread.
8825If LIMIT (the numerical prefix), fetch that many old headers instead
8826of what's specified by the `gnus-refer-thread-limit' variable."
8827 (interactive "P")
8828 (let ((id (mail-header-id (gnus-summary-article-header)))
8829 (limit (if limit (prefix-numeric-value limit)
8830 gnus-refer-thread-limit)))
6748645f
LMI
8831 (unless (eq gnus-fetch-old-headers 'invisible)
8832 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8833 ;; Retrieve the headers and read them in.
23f87bed
MB
8834 (if (eq (if (numberp limit)
8835 (gnus-retrieve-headers
8836 (list (min
8837 (+ (mail-header-number
8838 (gnus-summary-article-header))
8839 limit)
8840 gnus-newsgroup-end))
8841 gnus-newsgroup-name (* limit 2))
8842 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8843 ;; headers.
8844 (gnus-retrieve-headers (list gnus-newsgroup-end)
8845 gnus-newsgroup-name limit))
6748645f
LMI
8846 'nov)
8847 (gnus-build-all-threads)
23f87bed 8848 (error "Can't fetch thread from back ends that don't support NOV"))
6748645f
LMI
8849 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8850 (gnus-summary-limit-include-thread id)))
8851
16409b0b
GM
8852(defun gnus-summary-refer-article (message-id)
8853 "Fetch an article specified by MESSAGE-ID."
8854 (interactive "sMessage-ID: ")
eec82323
LMI
8855 (when (and (stringp message-id)
8856 (not (zerop (length message-id))))
23f87bed 8857 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8858 ;; Construct the correct Message-ID if necessary.
8859 ;; Suggested by tale@pawl.rpi.edu.
8860 (unless (string-match "^<" message-id)
8861 (setq message-id (concat "<" message-id)))
8862 (unless (string-match ">$" message-id)
8863 (setq message-id (concat message-id ">")))
23f87bed
MB
8864 ;; People often post MIDs from URLs, so unhex it:
8865 (unless (string-match "@" message-id)
8866 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8867 (let* ((header (gnus-id-to-header message-id))
8868 (sparse (and header
8869 (gnus-summary-article-sparse-p
a8151ef7
LMI
8870 (mail-header-number header))
8871 (memq (mail-header-number header)
16409b0b
GM
8872 gnus-newsgroup-limit)))
8873 number)
6748645f
LMI
8874 (cond
8875 ;; If the article is present in the buffer we just go to it.
8876 ((and header
8877 (or (not (gnus-summary-article-sparse-p
8878 (mail-header-number header)))
8879 sparse))
8880 (prog1
8881 (gnus-summary-goto-article
8882 (mail-header-number header) nil t)
8883 (when sparse
8884 (gnus-summary-update-article (mail-header-number header)))))
8885 (t
16409b0b
GM
8886 ;; We fetch the article.
8887 (catch 'found
8888 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8889 (when (and (gnus-check-server gnus-override-method)
8890 ;; Fetch the header,
8891 (setq number (gnus-summary-insert-subject message-id)))
8892 ;; and display the article.
eec82323 8893 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8894 (throw 'found t)))
8895 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8896
8897(defun gnus-refer-article-methods ()
8f688cb0 8898 "Return a list of referable methods."
16409b0b
GM
8899 (cond
8900 ;; No method, so we default to current and native.
8901 ((null gnus-refer-article-method)
8902 (list gnus-current-select-method gnus-select-method))
8903 ;; Current.
8904 ((eq 'current gnus-refer-article-method)
8905 (list gnus-current-select-method))
8906 ;; List of select methods.
d4dfaa19
DL
8907 ((not (and (symbolp (car gnus-refer-article-method))
8908 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
8909 (let (out)
8910 (dolist (method gnus-refer-article-method)
8911 (push (if (eq 'current method)
8912 gnus-current-select-method
8913 method)
8914 out))
8915 (nreverse out)))
8916 ;; One single select method.
8917 (t
8918 (list gnus-refer-article-method))))
6748645f
LMI
8919
8920(defun gnus-summary-edit-parameters ()
8921 "Edit the group parameters of the current group."
8922 (interactive)
8923 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 8924
16409b0b
GM
8925(defun gnus-summary-customize-parameters ()
8926 "Customize the group parameters of the current group."
8927 (interactive)
8928 (gnus-group-customize gnus-newsgroup-name))
8929
eec82323
LMI
8930(defun gnus-summary-enter-digest-group (&optional force)
8931 "Enter an nndoc group based on the current article.
8932If FORCE, force a digest interpretation. If not, try
8933to guess what the document format is."
8934 (interactive "P")
eec82323 8935 (let ((conf gnus-current-window-configuration))
23f87bed
MB
8936 (save-window-excursion
8937 (save-excursion
8938 (let (gnus-article-prepare-hook
8939 gnus-display-mime-function
8940 gnus-break-pages)
8941 (gnus-summary-select-article))))
eec82323
LMI
8942 (setq gnus-current-window-configuration conf)
8943 (let* ((name (format "%s-%d"
8944 (gnus-group-prefixed-name
8945 gnus-newsgroup-name (list 'nndoc ""))
01c52d31 8946 (with-current-buffer gnus-summary-buffer
eec82323
LMI
8947 gnus-current-article)))
8948 (ogroup gnus-newsgroup-name)
8949 (params (append (gnus-info-params (gnus-get-info ogroup))
8950 (list (cons 'to-group ogroup))
23f87bed 8951 (list (cons 'parent-group ogroup))
eec82323
LMI
8952 (list (cons 'save-article-group ogroup))))
8953 (case-fold-search t)
8954 (buf (current-buffer))
16409b0b 8955 dig to-address)
c7a91ce1 8956 (with-current-buffer gnus-original-article-buffer
16409b0b
GM
8957 ;; Have the digest group inherit the main mail address of
8958 ;; the parent article.
23f87bed
MB
8959 (when (setq to-address (or (gnus-fetch-field "reply-to")
8960 (gnus-fetch-field "from")))
343d6628
MB
8961 (setq params
8962 (append
8963 (list (cons 'to-address
8964 (funcall gnus-decode-encoded-address-function
8965 to-address))))))
eec82323
LMI
8966 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8967 (insert-buffer-substring gnus-original-article-buffer)
8968 ;; Remove lines that may lead nndoc to misinterpret the
8969 ;; document type.
8970 (narrow-to-region
8971 (goto-char (point-min))
8972 (or (search-forward "\n\n" nil t) (point)))
8973 (goto-char (point-min))
16409b0b 8974 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8975 (widen))
8976 (unwind-protect
23f87bed 8977 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
8978 (gnus-newsgroup-ephemeral-ignored-charsets
8979 gnus-newsgroup-ignored-charsets))
8980 (gnus-group-read-ephemeral-group
8981 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8982 (nndoc-article-type
23f87bed
MB
8983 ,(if force 'mbox 'guess)))
8984 t nil nil nil
8985 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8986 "ADAPT")))))
16409b0b 8987 ;; Make all postings to this group go to the parent group.
23f87bed
MB
8988 (nconc (gnus-info-params (gnus-get-info name))
8989 params)
8990 ;; Couldn't select this doc group.
8991 (switch-to-buffer buf)
8992 (gnus-set-global-variables)
8993 (gnus-configure-windows 'summary)
8994 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
8995 (kill-buffer dig)))))
8996
8997(defun gnus-summary-read-document (n)
8998 "Open a new group based on the current article(s).
8999This will allow you to read digests and other similar
9000documents as newsgroups.
9001Obeys the standard process/prefix convention."
9002 (interactive "P")
01c52d31 9003 (let* ((ogroup gnus-newsgroup-name)
eec82323
LMI
9004 (params (append (gnus-info-params (gnus-get-info ogroup))
9005 (list (cons 'to-group ogroup))))
01c52d31
MB
9006 group egroup groups vgroup)
9007 (dolist (article (gnus-summary-work-articles n))
eec82323
LMI
9008 (setq group (format "%s-%d" gnus-newsgroup-name article))
9009 (gnus-summary-remove-process-mark article)
9010 (when (gnus-summary-display-article article)
398a825b 9011 (save-excursion ;;What for?
16409b0b 9012 (with-temp-buffer
eec82323
LMI
9013 (insert-buffer-substring gnus-original-article-buffer)
9014 ;; Remove some headers that may lead nndoc to make
9015 ;; the wrong guess.
9016 (message-narrow-to-head)
9017 (goto-char (point-min))
01c52d31 9018 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
9019 (widen)
9020 (if (setq egroup
9021 (gnus-group-read-ephemeral-group
9022 group `(nndoc ,group (nndoc-address ,(current-buffer))
9023 (nndoc-article-type guess))
9024 t nil t))
9025 (progn
c7a91ce1 9026 ;; Make all postings to this group go to the parent group.
eec82323
LMI
9027 (nconc (gnus-info-params (gnus-get-info egroup))
9028 params)
9029 (push egroup groups))
9030 ;; Couldn't select this doc group.
9031 (gnus-error 3 "Article couldn't be entered"))))))
9032 ;; Now we have selected all the documents.
9033 (cond
9034 ((not groups)
9035 (error "None of the articles could be interpreted as documents"))
9036 ((gnus-group-read-ephemeral-group
9037 (setq vgroup (format
9038 "nnvirtual:%s-%s" gnus-newsgroup-name
9039 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9040 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9041 t
9042 (cons (current-buffer) 'summary)))
9043 (t
9044 (error "Couldn't select virtual nndoc group")))))
9045
9046(defun gnus-summary-isearch-article (&optional regexp-p)
9047 "Do incremental search forward on the current article.
9048If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9049 (interactive "P")
eec82323
LMI
9050 (gnus-summary-select-article)
9051 (gnus-configure-windows 'article)
9052 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
9053 (save-restriction
9054 (widen)
9055 (isearch-forward regexp-p))))
eec82323 9056
01c52d31
MB
9057(defun gnus-summary-repeat-search-article-forward ()
9058 "Repeat the previous search forwards."
9059 (interactive)
9060 (unless gnus-last-search-regexp
9061 (error "No previous search"))
9062 (gnus-summary-search-article-forward gnus-last-search-regexp))
9063
9064(defun gnus-summary-repeat-search-article-backward ()
9065 "Repeat the previous search backwards."
9066 (interactive)
9067 (unless gnus-last-search-regexp
9068 (error "No previous search"))
9069 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9070
eec82323
LMI
9071(defun gnus-summary-search-article-forward (regexp &optional backward)
9072 "Search for an article containing REGEXP forward.
9073If BACKWARD, search backward instead."
9074 (interactive
9075 (list (read-string
9076 (format "Search article %s (regexp%s): "
9077 (if current-prefix-arg "backward" "forward")
9078 (if gnus-last-search-regexp
9079 (concat ", default " gnus-last-search-regexp)
9080 "")))
9081 current-prefix-arg))
eec82323
LMI
9082 (if (string-equal regexp "")
9083 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
9084 (setq gnus-last-search-regexp regexp)
9085 (setq gnus-article-before-search gnus-current-article))
9086 ;; Intentionally set gnus-last-article.
9087 (setq gnus-last-article gnus-article-before-search)
9088 (let ((gnus-last-article gnus-last-article))
9089 (if (gnus-summary-search-article regexp backward)
9090 (gnus-summary-show-thread)
abc40aab 9091 (signal 'search-failed (list regexp)))))
eec82323
LMI
9092
9093(defun gnus-summary-search-article-backward (regexp)
9094 "Search for an article containing REGEXP backward."
9095 (interactive
9096 (list (read-string
9097 (format "Search article backward (regexp%s): "
9098 (if gnus-last-search-regexp
9099 (concat ", default " gnus-last-search-regexp)
9100 "")))))
9101 (gnus-summary-search-article-forward regexp 'backward))
9102
9103(defun gnus-summary-search-article (regexp &optional backward)
9104 "Search for an article containing REGEXP.
9105Optional argument BACKWARD means do search for backward.
9106`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
9107 ;; We have to require this here to make sure that the following
9108 ;; dynamic binding isn't shadowed by autoloading.
9109 (require 'gnus-async)
16409b0b 9110 (require 'gnus-art)
eec82323 9111 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 9112 (gnus-article-prepare-hook nil)
eec82323
LMI
9113 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9114 (gnus-use-article-prefetch nil)
9115 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 9116 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
9117 (gnus-visual nil)
9118 (gnus-keep-backlog nil)
9119 (gnus-break-pages nil)
9120 (gnus-summary-display-arrow nil)
9121 (gnus-updated-mode-lines nil)
9122 (gnus-auto-center-summary nil)
eec82323 9123 (sum (current-buffer))
16409b0b 9124 (gnus-display-mime-function nil)
eec82323
LMI
9125 (found nil)
9126 point)
9127 (gnus-save-hidden-threads
9128 (gnus-summary-select-article)
9129 (set-buffer gnus-article-buffer)
16409b0b 9130 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
9131 (when backward
9132 (forward-line -1))
9133 (while (not found)
9134 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9135 (if (if backward
9136 (re-search-backward regexp nil t)
9137 (re-search-forward regexp nil t))
9138 ;; We found the regexp.
9139 (progn
9140 (setq found 'found)
9141 (beginning-of-line)
9142 (set-window-start
9143 (get-buffer-window (current-buffer))
9144 (point))
9145 (forward-line 1)
16409b0b
GM
9146 (set-window-point
9147 (get-buffer-window (current-buffer))
9148 (point))
eec82323
LMI
9149 (set-buffer sum)
9150 (setq point (point)))
9151 ;; We didn't find it, so we go to the next article.
9152 (set-buffer sum)
9153 (setq found 'not)
9154 (while (eq found 'not)
9155 (if (not (if backward (gnus-summary-find-prev)
9156 (gnus-summary-find-next)))
9157 ;; No more articles.
9158 (setq found t)
9159 ;; Select the next article and adjust point.
9160 (unless (gnus-summary-article-sparse-p
9161 (gnus-summary-article-number))
9162 (setq found nil)
9163 (gnus-summary-select-article)
9164 (set-buffer gnus-article-buffer)
9165 (widen)
9166 (goto-char (if backward (point-max) (point-min))))))))
9167 (gnus-message 7 ""))
9168 ;; Return whether we found the regexp.
9169 (when (eq found 'found)
9170 (goto-char point)
9171 (gnus-summary-show-thread)
9172 (gnus-summary-goto-subject gnus-current-article)
9173 (gnus-summary-position-point)
9174 t)))
9175
23f87bed
MB
9176(defun gnus-find-matching-articles (header regexp)
9177 "Return a list of all articles that match REGEXP on HEADER.
9178This search includes all articles in the current group that Gnus has
9179fetched headers for, whether they are displayed or not."
9180 (let ((articles nil)
c7a91ce1 9181 ;; Can't eta-reduce because it's a macro.
23f87bed
MB
9182 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9183 (case-fold-search t))
9184 (dolist (header gnus-newsgroup-headers)
9185 (when (string-match regexp (funcall func header))
9186 (push (mail-header-number header) articles)))
9187 (nreverse articles)))
9188
eec82323 9189(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 9190 not-case-fold not-matching)
eec82323
LMI
9191 "Return a list of all articles that match REGEXP on HEADER.
9192The search stars on the current article and goes forwards unless
9193BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9194If UNREAD is non-nil, only unread articles will
9195be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 9196in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
9197not match REGEXP on HEADER."
9198 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
9199 articles d func)
9200 (if (consp header)
9201 (if (eq (car header) 'extra)
9202 (setq func
9203 `(lambda (h)
9204 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9205 "")))
9206 (error "%s is an invalid header" header))
9207 (unless (fboundp (intern (concat "mail-header-" header)))
9208 (error "%s is not a valid header" header))
9209 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
9210 (dolist (d (if (eq backward 'all)
9211 gnus-newsgroup-data
9212 (gnus-data-find-list
9213 (gnus-summary-article-number)
9214 (gnus-data-list backward))))
9215 (when (and (or (not unread) ; We want all articles...
9216 (gnus-data-unread-p d)) ; Or just unreads.
9217 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9218 (if not-matching
a1506d29 9219 (not (string-match
47b63dfa
SZ
9220 regexp
9221 (funcall func (gnus-data-header d))))
9222 (string-match regexp
9223 (funcall func (gnus-data-header d)))))
9224 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
9225 (nreverse articles)))
9226
9227(defun gnus-summary-execute-command (header regexp command &optional backward)
9228 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9229If HEADER is an empty string (or nil), the match is done on the entire
9230article. If BACKWARD (the prefix) is non-nil, search backward instead."
9231 (interactive
9232 (list (let ((completion-ignore-case t))
9233 (completing-read
9234 "Header name: "
23f87bed
MB
9235 (mapcar (lambda (header) (list (format "%s" header)))
9236 (append
9237 '("Number" "Subject" "From" "Lines" "Date"
9238 "Message-ID" "Xref" "References" "Body")
9239 gnus-extra-headers))
eec82323
LMI
9240 nil 'require-match))
9241 (read-string "Regexp: ")
9242 (read-key-sequence "Command: ")
9243 current-prefix-arg))
9244 (when (equal header "Body")
9245 (setq header ""))
eec82323
LMI
9246 ;; Hidden thread subtrees must be searched as well.
9247 (gnus-summary-show-all-threads)
9248 ;; We don't want to change current point nor window configuration.
9249 (save-excursion
9250 (save-window-excursion
23f87bed
MB
9251 (let (gnus-visual
9252 gnus-treat-strip-trailing-blank-lines
9253 gnus-treat-strip-leading-blank-lines
9254 gnus-treat-strip-multiple-blank-lines
9255 gnus-treat-hide-boring-headers
9256 gnus-treat-fold-newsgroups
9257 gnus-article-prepare-hook)
9258 (gnus-message 6 "Executing %s..." (key-description command))
9259 ;; We'd like to execute COMMAND interactively so as to give arguments.
9260 (gnus-execute header regexp
9261 `(call-interactively ',(key-binding command))
9262 backward)
9263 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
9264
9265(defun gnus-summary-beginning-of-article ()
9266 "Scroll the article back to the beginning."
9267 (interactive)
eec82323
LMI
9268 (gnus-summary-select-article)
9269 (gnus-configure-windows 'article)
9270 (gnus-eval-in-buffer-window gnus-article-buffer
9271 (widen)
9272 (goto-char (point-min))
23f87bed 9273 (when gnus-break-pages
eec82323
LMI
9274 (gnus-narrow-to-page))))
9275
9276(defun gnus-summary-end-of-article ()
9277 "Scroll to the end of the article."
9278 (interactive)
eec82323
LMI
9279 (gnus-summary-select-article)
9280 (gnus-configure-windows 'article)
9281 (gnus-eval-in-buffer-window gnus-article-buffer
9282 (widen)
9283 (goto-char (point-max))
9284 (recenter -3)
23f87bed 9285 (when gnus-break-pages
eec82323
LMI
9286 (gnus-narrow-to-page))))
9287
23f87bed
MB
9288(defun gnus-summary-print-truncate-and-quote (string &optional len)
9289 "Truncate to LEN and quote all \"(\"'s in STRING."
9290 (gnus-replace-in-string (if (and len (> (length string) len))
9291 (substring string 0 len)
9292 string)
9293 "[()]" "\\\\\\&"))
9294
6748645f 9295(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
9296 "Generate and print a PostScript image of the process-marked (mail) articles.
9297
9298If used interactively, print the current article if none are
9299process-marked. With prefix arg, prompt the user for the name of the
9300file to save in.
6748645f 9301
23f87bed
MB
9302When used from Lisp, accept two optional args FILENAME and N. N means
9303to print the next N articles. If N is negative, print the N previous
9304articles. If N is nil and articles have been marked with the process
9305mark, print these instead.
eec82323 9306
16409b0b 9307If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
9308printer. If FILENAME is a string, save the PostScript image in a file with
9309that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 9310to save in."
676a7cc9 9311 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
9312 (dolist (article (gnus-summary-work-articles n))
9313 (gnus-summary-select-article nil nil 'pseudo article)
9314 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 9315 (gnus-print-buffer))
676a7cc9
SZ
9316 (gnus-summary-remove-process-mark article))
9317 (ps-despool filename))
eec82323 9318
23f87bed
MB
9319(defun gnus-print-buffer ()
9320 (let ((buffer (generate-new-buffer " *print*")))
9321 (unwind-protect
9322 (progn
9323 (copy-to-buffer buffer (point-min) (point-max))
9324 (set-buffer buffer)
9325 (gnus-remove-text-with-property 'gnus-decoration)
9326 (when (gnus-visual-p 'article-highlight 'highlight)
9327 ;; Copy-to-buffer doesn't copy overlay. So redo
9328 ;; highlight.
9329 (let ((gnus-article-buffer buffer))
9330 (gnus-article-highlight-citation t)
9331 (gnus-article-highlight-signature)
9332 (gnus-article-emphasize)
9333 (gnus-article-delete-invisible-text)))
9334 (let ((ps-left-header
9335 (list
9336 (concat "("
9337 (gnus-summary-print-truncate-and-quote
9338 (mail-header-subject gnus-current-headers)
9339 66) ")")
9340 (concat "("
9341 (gnus-summary-print-truncate-and-quote
9342 (mail-header-from gnus-current-headers)
9343 45) ")")))
9344 (ps-right-header
9345 (list
9346 "/pagenumberstring load"
9347 (concat "("
9348 (mail-header-date gnus-current-headers) ")"))))
9349 (gnus-run-hooks 'gnus-ps-print-hook)
9350 (save-excursion
a7b50e1c 9351 (if ps-print-color-p
23f87bed
MB
9352 (ps-spool-buffer-with-faces)
9353 (ps-spool-buffer)))))
9354 (kill-buffer buffer))))
9355
eec82323 9356(defun gnus-summary-show-article (&optional arg)
23f87bed 9357 "Force redisplaying of the current article.
16409b0b
GM
9358If ARG (the prefix) is a number, show the article with the charset
9359defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 9360input.
16409b0b 9361If ARG (the prefix) is non-nil and not a number, show the raw article
23f87bed
MB
9362without any article massaging functions being run. Normally, the key
9363strokes are `C-u g'."
eec82323 9364 (interactive "P")
16409b0b
GM
9365 (cond
9366 ((numberp arg)
23f87bed 9367 (gnus-summary-show-article t)
16409b0b
GM
9368 (let ((gnus-newsgroup-charset
9369 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
9370 (mm-read-coding-system
9371 "View as charset: " ;; actually it is coding system.
01c52d31 9372 (with-current-buffer gnus-article-buffer
23f87bed 9373 (mm-detect-coding-region (point) (point-max))))))
16409b0b 9374 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
9375 (gnus-summary-select-article nil 'force)
9376 (let ((deps gnus-newsgroup-dependencies)
9377 head header lines)
c7a91ce1 9378 (with-current-buffer gnus-original-article-buffer
23f87bed
MB
9379 (save-restriction
9380 (message-narrow-to-head)
9381 (setq head (buffer-string))
9382 (goto-char (point-min))
9383 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9384 (goto-char (point-max))
9385 (widen)
9386 (setq lines (1- (count-lines (point) (point-max))))))
9387 (with-temp-buffer
9388 (insert (format "211 %d Article retrieved.\n"
9389 (cdr gnus-article-current)))
9390 (insert head)
9391 (if lines (insert (format "Lines: %d\n" lines)))
9392 (insert ".\n")
9393 (let ((nntp-server-buffer (current-buffer)))
9394 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9395 (gnus-data-set-header
9396 (gnus-data-find (cdr gnus-article-current))
9397 header)
9398 (gnus-summary-update-article-line
9399 (cdr gnus-article-current) header)
9400 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9401 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
9402 ((not arg)
9403 ;; Select the article the normal way.
9404 (gnus-summary-select-article nil 'force))
9405 (t
9406 ;; We have to require this here to make sure that the following
9407 ;; dynamic binding isn't shadowed by autoloading.
9408 (require 'gnus-async)
9409 (require 'gnus-art)
eec82323
LMI
9410 ;; Bind the article treatment functions to nil.
9411 (let ((gnus-have-all-headers t)
eec82323 9412 gnus-article-prepare-hook
16409b0b
GM
9413 gnus-article-decode-hook
9414 gnus-display-mime-function
9415 gnus-break-pages)
9416 ;; Destroy any MIME parts.
9417 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 9418 (with-current-buffer gnus-article-buffer
16409b0b
GM
9419 (mm-destroy-parts gnus-article-mime-handles)
9420 ;; Set it to nil for safety reason.
9421 (setq gnus-article-mime-handle-alist nil)
9422 (setq gnus-article-mime-handles nil)))
9423 (gnus-summary-select-article nil 'force))))
eec82323
LMI
9424 (gnus-summary-goto-subject gnus-current-article)
9425 (gnus-summary-position-point))
9426
23f87bed
MB
9427(defun gnus-summary-show-raw-article ()
9428 "Show the raw article without any article massaging functions being run."
9429 (interactive)
9430 (gnus-summary-show-article t))
9431
eec82323
LMI
9432(defun gnus-summary-verbose-headers (&optional arg)
9433 "Toggle permanent full header display.
9434If ARG is a positive number, turn header display on.
9435If ARG is a negative number, turn header display off."
9436 (interactive "P")
eec82323
LMI
9437 (setq gnus-show-all-headers
9438 (cond ((or (not (numberp arg))
9439 (zerop arg))
9440 (not gnus-show-all-headers))
9441 ((natnump arg)
9442 t)))
9443 (gnus-summary-show-article))
9444
9445(defun gnus-summary-toggle-header (&optional arg)
9446 "Show the headers if they are hidden, or hide them if they are shown.
9447If ARG is a positive number, show the entire header.
9448If ARG is a negative number, hide the unwanted header lines."
9449 (interactive "P")
23f87bed
MB
9450 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9451 (get-buffer-window gnus-article-buffer t))))
9452 (with-current-buffer gnus-article-buffer
9453 (widen)
9454 (article-narrow-to-head)
c7a91ce1 9455 (let* ((inhibit-read-only t)
16409b0b 9456 (inhibit-point-motion-hooks t)
23f87bed
MB
9457 (hidden (if (numberp arg)
9458 (>= arg 0)
f0096211
MB
9459 (or (not (looking-at "[^ \t\n]+:"))
9460 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
9461 s e)
9462 (delete-region (point-min) (point-max))
667e0ba6
SM
9463 (with-current-buffer gnus-original-article-buffer
9464 (goto-char (setq s (point-min)))
23f87bed
MB
9465 (setq e (if (search-forward "\n\n" nil t)
9466 (1- (point))
9467 (point-max))))
667e0ba6 9468 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
9469 (run-hooks 'gnus-article-decode-hook)
9470 (if hidden
9471 (let ((gnus-treat-hide-headers nil)
9472 (gnus-treat-hide-boring-headers nil))
9473 (gnus-delete-wash-type 'headers)
9474 (gnus-treat-article 'head))
9475 (gnus-treat-article 'head))
9476 (widen)
9477 (if window
9478 (set-window-start window (goto-char (point-min))))
9479 (if gnus-break-pages
9480 (gnus-narrow-to-page)
9481 (when (gnus-visual-p 'page-marker)
c7a91ce1 9482 (let ((inhibit-read-only t))
23f87bed
MB
9483 (gnus-remove-text-with-property 'gnus-prev)
9484 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9485 (gnus-set-mode-line 'article)))))
eec82323
LMI
9486
9487(defun gnus-summary-show-all-headers ()
9488 "Make all header lines visible."
9489 (interactive)
23f87bed 9490 (gnus-summary-toggle-header 1))
eec82323 9491
eec82323
LMI
9492(defun gnus-summary-caesar-message (&optional arg)
9493 "Caesar rotate the current article by 13.
01c52d31
MB
9494With a non-numerical prefix, also rotate headers. A numerical
9495prefix specifies how many places to rotate each letter forward."
eec82323 9496 (interactive "P")
eec82323
LMI
9497 (gnus-summary-select-article)
9498 (let ((mail-header-separator ""))
9499 (gnus-eval-in-buffer-window gnus-article-buffer
9500 (save-restriction
9501 (widen)
9502 (let ((start (window-start))
c7a91ce1 9503 (inhibit-read-only t))
01c52d31
MB
9504 (if (equal arg '(4))
9505 (message-caesar-buffer-body nil t)
9506 (message-caesar-buffer-body arg))
ff4d3926
MB
9507 (set-window-start (get-buffer-window (current-buffer)) start)))))
9508 ;; Create buttons and stuff...
9509 (gnus-treat-article nil))
eec82323 9510
704f1663
GM
9511(declare-function idna-to-unicode "ext:idna" (str))
9512
01c52d31
MB
9513(defun gnus-summary-idna-message (&optional arg)
9514 "Decode IDNA encoded domain names in the current articles.
9515IDNA encoded domain names looks like `xn--bar'. If a string
9516remain unencoded after running this function, it is likely an
9517invalid IDNA string (`xn--bar' is invalid).
9518
0b10e437 9519You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
01c52d31
MB
9520installed for this command to work."
9521 (interactive "P")
9522 (if (not (and (condition-case nil (require 'idna)
9523 (file-error))
9524 (mm-coding-system-p 'utf-8)
9525 (executable-find (symbol-value 'idna-program))))
9526 (gnus-message
9527 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9528 (gnus-summary-select-article)
9529 (let ((mail-header-separator ""))
9530 (gnus-eval-in-buffer-window gnus-article-buffer
9531 (save-restriction
9532 (widen)
9533 (let ((start (window-start))
9534 buffer-read-only)
9535 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9536 (replace-match (idna-to-unicode (match-string 1))))
9537 (set-window-start (get-buffer-window (current-buffer)) start)))))))
23f87bed
MB
9538
9539(defun gnus-summary-morse-message (&optional arg)
9540 "Morse decode the current article."
9541 (interactive "P")
9542 (gnus-summary-select-article)
9543 (let ((mail-header-separator ""))
9544 (gnus-eval-in-buffer-window gnus-article-buffer
9545 (save-excursion
9546 (save-restriction
9547 (widen)
9548 (let ((pos (window-start))
c7a91ce1 9549 (inhibit-read-only t))
23f87bed
MB
9550 (goto-char (point-min))
9551 (when (message-goto-body)
9552 (gnus-narrow-to-body))
9553 (goto-char (point-min))
01c52d31 9554