gnus-sum.el (gnus-summary-widget-forward): Add, and bind to [tab].
[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
f0b7f5a8 28;; For Emacs <22.2 and XEmacs.
d09ae6ca
GM
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
1d297c49 224(defcustom gnus-summary-goto-unread nil
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."
1d297c49 234 :version "24.1"
eec82323
LMI
235 :group 'gnus-summary-marks
236 :link '(custom-manual "(gnus)Setting Marks")
237 :type '(choice (const :tag "off" nil)
238 (const never)
239 (sexp :menu-tag "on" t)))
240
241(defcustom gnus-summary-default-score 0
242 "*Default article score level.
243All scores generated by the score files will be added to this score.
244If this variable is nil, scoring will be disabled."
245 :group 'gnus-score-default
246 :type '(choice (const :tag "disable")
247 integer))
248
23f87bed
MB
249(defcustom gnus-summary-default-high-score 0
250 "*Default threshold for a high scored article.
251An article will be highlighted as high scored if its score is greater
252than this score."
bf247b6e 253 :version "22.1"
23f87bed
MB
254 :group 'gnus-score-default
255 :type 'integer)
256
257(defcustom gnus-summary-default-low-score 0
258 "*Default threshold for a low scored article.
259An article will be highlighted as low scored if its score is smaller
260than this score."
bf247b6e 261 :version "22.1"
23f87bed
MB
262 :group 'gnus-score-default
263 :type 'integer)
264
eec82323
LMI
265(defcustom gnus-summary-zcore-fuzz 0
266 "*Fuzziness factor for the zcore in the summary buffer.
267Articles with scores closer than this to `gnus-summary-default-score'
268will not be marked."
269 :group 'gnus-summary-format
270 :type 'integer)
271
272(defcustom gnus-simplify-subject-fuzzy-regexp nil
273 "*Strings to be removed when doing fuzzy matches.
274This can either be a regular expression or list of regular expressions
275that will be removed from subject strings if fuzzy subject
276simplification is selected."
277 :group 'gnus-thread
278 :type '(repeat regexp))
279
280(defcustom gnus-show-threads t
281 "*If non-nil, display threads in summary mode."
282 :group 'gnus-thread
283 :type 'boolean)
284
285(defcustom gnus-thread-hide-subtree nil
286 "*If non-nil, hide all threads initially.
23f87bed 287This can be a predicate specifier which says which threads to hide.
eec82323 288If threads are hidden, you have to run the command
4a2358e9 289`gnus-summary-show-thread' by hand or select an article."
eec82323 290 :group 'gnus-thread
23f87bed
MB
291 :type '(radio (sexp :format "Non-nil\n"
292 :match (lambda (widget value)
293 (not (or (consp value) (functionp value))))
294 :value t)
295 (const nil)
ad136a7c 296 (sexp :tag "Predicate specifier")))
eec82323
LMI
297
298(defcustom gnus-thread-hide-killed t
299 "*If non-nil, hide killed threads automatically."
300 :group 'gnus-thread
301 :type 'boolean)
302
6748645f
LMI
303(defcustom gnus-thread-ignore-subject t
304 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
305If nil, articles that have different subjects from their parents will
306start separate threads."
eec82323
LMI
307 :group 'gnus-thread
308 :type 'boolean)
309
310(defcustom gnus-thread-operation-ignore-subject t
311 "*If non-nil, subjects will be ignored when doing thread commands.
312This affects commands like `gnus-summary-kill-thread' and
313`gnus-summary-lower-thread'.
314
315If this variable is nil, articles in the same thread with different
316subjects will not be included in the operation in question. If this
317variable is `fuzzy', only articles that have subjects that are fuzzily
318equal will be included."
319 :group 'gnus-thread
320 :type '(choice (const :tag "off" nil)
321 (const fuzzy)
322 (sexp :tag "on" t)))
323
324(defcustom gnus-thread-indent-level 4
325 "*Number that says how much each sub-thread should be indented."
326 :group 'gnus-thread
327 :type 'integer)
328
329(defcustom gnus-auto-extend-newsgroup t
330 "*If non-nil, extend newsgroup forward and backward when requested."
331 :group 'gnus-summary-choose
332 :type 'boolean)
333
334(defcustom gnus-auto-select-first t
651408cb
MB
335 "If non-nil, select an article on group entry.
336An article is selected automatically when entering a group
337e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
338`gnus-summary-catchup-and-goto-next-group'.
339
340Which article is selected is controlled by the variable
341`gnus-auto-select-subject'.
23f87bed
MB
342
343If you want to prevent automatic selection of articles in some
344newsgroups, set the variable to nil in `gnus-select-group-hook'."
651408cb
MB
345 ;; Commands include...
346 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
347 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
348 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
eec82323
LMI
349 :group 'gnus-group-select
350 :type '(choice (const :tag "none" nil)
23f87bed
MB
351 (sexp :menu-tag "first" t)))
352
a1347097 353(defcustom gnus-auto-select-subject 'unseen-or-unread
23f87bed
MB
354 "*Says what subject to place under point when entering a group.
355
356This variable can either be the symbols `first' (place point on the
357first subject), `unread' (place point on the subject line of the first
358unread article), `best' (place point on the subject line of the
359higest-scored article), `unseen' (place point on the subject line of
99b5aab7 360the first unseen article), `unseen-or-unread' (place point on the subject
23f87bed
MB
361line of the first unseen article or, if all article have been seen, on the
362subject line of the first unread article), or a function to be called to
363place point on some subject line."
a1347097 364 :version "24.1"
23f87bed
MB
365 :group 'gnus-group-select
366 :type '(choice (const best)
367 (const unread)
368 (const first)
369 (const unseen)
370 (const unseen-or-unread)))
eec82323
LMI
371
372(defcustom gnus-auto-select-next t
373 "*If non-nil, offer to go to the next group from the end of the previous.
374If the value is t and the next newsgroup is empty, Gnus will exit
23f87bed
MB
375summary mode and go back to group mode. If the value is neither nil
376nor t, Gnus will select the following unread newsgroup. In
eec82323
LMI
377particular, if the value is the symbol `quietly', the next unread
378newsgroup will be selected without any confirmation, and if it is
379`almost-quietly', the next group will be selected without any
380confirmation if you are located on the last article in the group.
23f87bed 381Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
eec82323
LMI
382will go to the next group without confirmation."
383 :group 'gnus-summary-maneuvering
384 :type '(choice (const :tag "off" nil)
385 (const quietly)
386 (const almost-quietly)
387 (const slightly-quietly)
388 (sexp :menu-tag "on" t)))
389
390(defcustom gnus-auto-select-same nil
6748645f
LMI
391 "*If non-nil, select the next article with the same subject.
392If there are no more articles with the same subject, go to
393the first unread article."
eec82323
LMI
394 :group 'gnus-summary-maneuvering
395 :type 'boolean)
396
01c52d31
MB
397(defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
398 "What article should be selected after exiting an ephemeral group.
399Valid values include:
400
401`next'
402 Select the next article.
403`next-unread'
404 Select the next unread article.
405`next-noselect'
406 Move the cursor to the next article. This is the default.
407`next-unread-noselect'
408 Move the cursor to the next unread article.
409
410If it has any other value or there is no next (unread) article, the
411article selected before entering to the ephemeral group will appear."
330f707b 412 :version "23.1" ;; No Gnus
01c52d31
MB
413 :group 'gnus-summary-maneuvering
414 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
415 (const next) (const next-unread)
416 (const next-noselect) (const next-unread-noselect)
417 (sexp :tag "other" :value nil)))
418
23f87bed
MB
419(defcustom gnus-auto-goto-ignores 'unfetched
420 "*Says how to handle unfetched articles when maneuvering.
421
422This variable can either be the symbols nil (maneuver to any
423article), `undownloaded' (maneuvering while unplugged ignores articles
424that have not been fetched), `always-undownloaded' (maneuvering always
425ignores articles that have not been fetched), `unfetched' (maneuvering
426ignores articles whose headers have not been fetched).
427
428NOTE: The list of unfetched articles will always be nil when plugged
429and, when unplugged, a subset of the undownloaded article list."
bf247b6e 430 :version "22.1"
23f87bed
MB
431 :group 'gnus-summary-maneuvering
432 :type '(choice (const :tag "None" nil)
433 (const :tag "Undownloaded when unplugged" undownloaded)
434 (const :tag "Undownloaded" always-undownloaded)
435 (const :tag "Unfetched" unfetched)))
436
eec82323
LMI
437(defcustom gnus-summary-check-current nil
438 "*If non-nil, consider the current article when moving.
439The \"unread\" movement commands will stay on the same line if the
440current article is unread."
441 :group 'gnus-summary-maneuvering
442 :type 'boolean)
443
01c52d31 444(defcustom gnus-auto-center-summary 2
eec82323
LMI
445 "*If non-nil, always center the current summary buffer.
446In particular, if `vertical' do only vertical recentering. If non-nil
447and non-`vertical', do both horizontal and vertical recentering."
448 :group 'gnus-summary-maneuvering
449 :type '(choice (const :tag "none" nil)
450 (const vertical)
16409b0b 451 (integer :tag "height")
eec82323
LMI
452 (sexp :menu-tag "both" t)))
453
2d04f304
G
454(defcustom gnus-auto-center-group t
455 "If non-nil, always center the group buffer."
456 :group 'gnus-summary-maneuvering
457 :type 'boolean)
23f87bed 458
eec82323
LMI
459(defcustom gnus-show-all-headers nil
460 "*If non-nil, don't hide any headers."
461 :group 'gnus-article-hiding
462 :group 'gnus-article-headers
463 :type 'boolean)
464
465(defcustom gnus-summary-ignore-duplicates nil
466 "*If non-nil, ignore articles with identical Message-ID headers."
467 :group 'gnus-summary
468 :type 'boolean)
6748645f 469
1d297c49 470(defcustom gnus-single-article-buffer nil
eec82323
LMI
471 "*If non-nil, display all articles in the same buffer.
472If nil, each group will get its own article buffer."
1d297c49 473 :version "24.1"
eec82323
LMI
474 :group 'gnus-article-various
475 :type 'boolean)
476
71e691a5
G
477(defcustom gnus-widen-article-window nil
478 "If non-nil, selecting the article buffer will display only the article buffer."
479 :version "24.1"
480 :group 'gnus-article-various
481 :type 'boolean)
482
eec82323
LMI
483(defcustom gnus-break-pages t
484 "*If non-nil, do page breaking on articles.
485The page delimiter is specified by the `gnus-page-delimiter'
486variable."
487 :group 'gnus-article-various
488 :type 'boolean)
489
eec82323
LMI
490(defcustom gnus-move-split-methods nil
491 "*Variable used to suggest where articles are to be moved to.
23f87bed
MB
492It uses the same syntax as the `gnus-split-methods' variable.
493However, whereas `gnus-split-methods' specifies file names as targets,
494this variable specifies group names."
eec82323 495 :group 'gnus-summary-mail
6748645f
LMI
496 :type '(repeat (choice (list :value (fun) function)
497 (cons :value ("" "") regexp (repeat string))
498 (sexp :value nil))))
eec82323 499
01c52d31
MB
500(defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
501 "Function used to compute default prefix for article move/copy/etc prompts.
502The function should take one argument, a group name, and return a
503string with the suggested prefix."
504 :group 'gnus-summary-mail
505 :type 'function)
506
e62e7654
MB
507;; FIXME: Although the custom type is `character' for the following variables,
508;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
509
23f87bed 510(defcustom gnus-unread-mark ? ;Whitespace
eec82323
LMI
511 "*Mark used for unread articles."
512 :group 'gnus-summary-marks
513 :type 'character)
514
515(defcustom gnus-ticked-mark ?!
516 "*Mark used for ticked articles."
517 :group 'gnus-summary-marks
518 :type 'character)
519
520(defcustom gnus-dormant-mark ??
521 "*Mark used for dormant articles."
522 :group 'gnus-summary-marks
523 :type 'character)
524
525(defcustom gnus-del-mark ?r
526 "*Mark used for del'd articles."
527 :group 'gnus-summary-marks
528 :type 'character)
529
530(defcustom gnus-read-mark ?R
531 "*Mark used for read articles."
532 :group 'gnus-summary-marks
533 :type 'character)
534
535(defcustom gnus-expirable-mark ?E
536 "*Mark used for expirable articles."
537 :group 'gnus-summary-marks
538 :type 'character)
539
540(defcustom gnus-killed-mark ?K
541 "*Mark used for killed articles."
542 :group 'gnus-summary-marks
543 :type 'character)
544
23f87bed
MB
545(defcustom gnus-spam-mark ?$
546 "*Mark used for spam articles."
bf247b6e 547 :version "22.1"
23f87bed
MB
548 :group 'gnus-summary-marks
549 :type 'character)
550
eec82323
LMI
551(defcustom gnus-kill-file-mark ?X
552 "*Mark used for articles killed by kill files."
553 :group 'gnus-summary-marks
554 :type 'character)
555
556(defcustom gnus-low-score-mark ?Y
557 "*Mark used for articles with a low score."
558 :group 'gnus-summary-marks
559 :type 'character)
560
561(defcustom gnus-catchup-mark ?C
562 "*Mark used for articles that are caught up."
563 :group 'gnus-summary-marks
564 :type 'character)
565
566(defcustom gnus-replied-mark ?A
567 "*Mark used for articles that have been replied to."
568 :group 'gnus-summary-marks
569 :type 'character)
570
23f87bed
MB
571(defcustom gnus-forwarded-mark ?F
572 "*Mark used for articles that have been forwarded."
bf247b6e 573 :version "22.1"
23f87bed
MB
574 :group 'gnus-summary-marks
575 :type 'character)
576
577(defcustom gnus-recent-mark ?N
578 "*Mark used for articles that are recent."
bf247b6e 579 :version "22.1"
23f87bed
MB
580 :group 'gnus-summary-marks
581 :type 'character)
582
eec82323
LMI
583(defcustom gnus-cached-mark ?*
584 "*Mark used for articles that are in the cache."
585 :group 'gnus-summary-marks
586 :type 'character)
587
588(defcustom gnus-saved-mark ?S
23f87bed
MB
589 "*Mark used for articles that have been saved."
590 :group 'gnus-summary-marks
591 :type 'character)
592
593(defcustom gnus-unseen-mark ?.
594 "*Mark used for articles that haven't been seen."
bf247b6e 595 :version "22.1"
23f87bed
MB
596 :group 'gnus-summary-marks
597 :type 'character)
598
599(defcustom gnus-no-mark ? ;Whitespace
600 "*Mark used for articles that have no other secondary mark."
bf247b6e 601 :version "22.1"
eec82323
LMI
602 :group 'gnus-summary-marks
603 :type 'character)
604
605(defcustom gnus-ancient-mark ?O
606 "*Mark used for ancient articles."
607 :group 'gnus-summary-marks
608 :type 'character)
609
610(defcustom gnus-sparse-mark ?Q
611 "*Mark used for sparsely reffed articles."
612 :group 'gnus-summary-marks
613 :type 'character)
614
615(defcustom gnus-canceled-mark ?G
616 "*Mark used for canceled articles."
617 :group 'gnus-summary-marks
618 :type 'character)
619
620(defcustom gnus-duplicate-mark ?M
621 "*Mark used for duplicate articles."
622 :group 'gnus-summary-marks
623 :type 'character)
624
23f87bed 625(defcustom gnus-undownloaded-mark ?-
6748645f 626 "*Mark used for articles that weren't downloaded."
bf247b6e 627 :version "22.1"
6748645f
LMI
628 :group 'gnus-summary-marks
629 :type 'character)
630
23f87bed
MB
631(defcustom gnus-downloaded-mark ?+
632 "*Mark used for articles that were downloaded."
633 :group 'gnus-summary-marks
634 :type 'character)
635
6748645f
LMI
636(defcustom gnus-downloadable-mark ?%
637 "*Mark used for articles that are to be downloaded."
638 :group 'gnus-summary-marks
639 :type 'character)
640
641(defcustom gnus-unsendable-mark ?=
642 "*Mark used for articles that won't be sent."
643 :group 'gnus-summary-marks
644 :type 'character)
645
eec82323
LMI
646(defcustom gnus-score-over-mark ?+
647 "*Score mark used for articles with high scores."
648 :group 'gnus-summary-marks
649 :type 'character)
650
651(defcustom gnus-score-below-mark ?-
652 "*Score mark used for articles with low scores."
653 :group 'gnus-summary-marks
654 :type 'character)
655
23f87bed 656(defcustom gnus-empty-thread-mark ? ;Whitespace
eec82323
LMI
657 "*There is no thread under the article."
658 :group 'gnus-summary-marks
659 :type 'character)
660
661(defcustom gnus-not-empty-thread-mark ?=
662 "*There is a thread under the article."
663 :group 'gnus-summary-marks
664 :type 'character)
665
666(defcustom gnus-view-pseudo-asynchronously nil
667 "*If non-nil, Gnus will view pseudo-articles asynchronously."
668 :group 'gnus-extract-view
669 :type 'boolean)
670
16409b0b
GM
671(defcustom gnus-auto-expirable-marks
672 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
673 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
c4d82de8 674 gnus-duplicate-mark)
16409b0b 675 "*The list of marks converted into expiration if a group is auto-expirable."
b0e30310 676 :version "24.1"
16409b0b
GM
677 :group 'gnus-summary
678 :type '(repeat character))
679
680(defcustom gnus-inhibit-user-auto-expire t
681 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
58e39d05 682 :version "21.1"
16409b0b
GM
683 :group 'gnus-summary
684 :type 'boolean)
685
b0b63450
MB
686(defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
687 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
688If nil, the expirable marks will be unchanged except that the marks
689will be removed when copying or moving articles to a group that has
690not turned auto-expire on. If non-nil, articles that have been read
691will be marked as expirable when being copied or moved to a group in
692which auto-expire is turned on."
693 :version "23.2"
694 :type 'boolean
695 :group 'gnus-summary-marks)
696
eec82323
LMI
697(defcustom gnus-view-pseudos nil
698 "*If `automatic', pseudo-articles will be viewed automatically.
699If `not-confirm', pseudos will be viewed automatically, and the user
700will not be asked to confirm the command."
701 :group 'gnus-extract-view
702 :type '(choice (const :tag "off" nil)
703 (const automatic)
704 (const not-confirm)))
705
706(defcustom gnus-view-pseudos-separately t
707 "*If non-nil, one pseudo-article will be created for each file to be viewed.
708If nil, all files that use the same viewing command will be given as a
709list of parameters to that command."
710 :group 'gnus-extract-view
711 :type 'boolean)
712
713(defcustom gnus-insert-pseudo-articles t
714 "*If non-nil, insert pseudo-articles when decoding articles."
715 :group 'gnus-extract-view
716 :type 'boolean)
717
718(defcustom gnus-summary-dummy-line-format
23f87bed 719 " %(: :%) %S\n"
eec82323
LMI
720 "*The format specification for the dummy roots in the summary buffer.
721It works along the same lines as a normal formatting string,
722with some simple extensions.
723
23f87bed
MB
724%S The subject
725
726General format specifiers can also be used.
727See `(gnus)Formatting Variables'."
728 :link '(custom-manual "(gnus)Formatting Variables")
eec82323
LMI
729 :group 'gnus-threading
730 :type 'string)
731
16409b0b 732(defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
eec82323
LMI
733 "*The format specification for the summary mode line.
734It works along the same lines as a normal formatting string,
735with some simple extensions:
736
737%G Group name
738%p Unprefixed group name
739%A Current article number
6748645f 740%z Current article score
eec82323
LMI
741%V Gnus version
742%U Number of unread articles in the group
743%e Number of unselected articles in the group
744%Z A string with unread/unselected article counts
745%g Shortish group name
746%S Subject of the current article
747%u User-defined spec
748%s Current score file name
749%d Number of dormant articles
750%r Number of articles that have been marked as read in this session
751%E Number of articles expunged by the score files"
752 :group 'gnus-summary-format
753 :type 'string)
754
16409b0b
GM
755(defcustom gnus-list-identifiers nil
756 "Regexp that matches list identifiers to be removed from subject.
757This can also be a list of regexps."
58e39d05 758 :version "21.1"
16409b0b
GM
759 :group 'gnus-summary-format
760 :group 'gnus-article-hiding
761 :type '(choice (const :tag "none" nil)
762 (regexp :value ".*")
763 (repeat :value (".*") regexp)))
764
eec82323
LMI
765(defcustom gnus-summary-mark-below 0
766 "*Mark all articles with a score below this variable as read.
767This variable is local to each summary buffer and usually set by the
768score file."
769 :group 'gnus-score-default
770 :type 'integer)
771
01c52d31
MB
772(defun gnus-widget-reversible-match (widget value)
773 "Ignoring WIDGET, convert VALUE to internal form.
774VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
775 ;; (debug value)
776 (or (symbolp value)
777 (and (listp value)
778 (eq (length value) 2)
779 (eq (nth 0 value) 'not)
780 (symbolp (nth 1 value)))))
781
782(defun gnus-widget-reversible-to-internal (widget value)
783 "Ignoring WIDGET, convert VALUE to internal form.
784VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
785FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
786 ;; (debug value)
787 (if (atom value)
788 (list value nil)
789 (list (nth 1 value) t)))
790
791(defun gnus-widget-reversible-to-external (widget value)
792 "Ignoring WIDGET, convert VALUE to external form.
793VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
794\(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
795 ;; (debug value)
796 (if (nth 1 value)
797 (list 'not (nth 0 value))
798 (nth 0 value)))
799
800(define-widget 'gnus-widget-reversible 'group
801 "A `group' that convert values."
802 :match 'gnus-widget-reversible-match
803 :value-to-internal 'gnus-widget-reversible-to-internal
804 :value-to-external 'gnus-widget-reversible-to-external)
805
eec82323
LMI
806(defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
807 "*List of functions used for sorting articles in the summary buffer.
23f87bed
MB
808
809Each function takes two articles and returns non-nil if the first
810article should be sorted before the other. If you use more than one
811function, the primary sort function should be the last. You should
812probably always include `gnus-article-sort-by-number' in the list of
813sorting functions -- preferably first. Also note that sorting by date
814is often much slower than sorting by number, and the sorting order is
815very similar. (Sorting by date means sorting by the time the message
816was sent, sorting by number means sorting by arrival time.)
817
01c52d31
MB
818Each item can also be a list `(not F)' where F is a function;
819this reverses the sort order.
820
23f87bed
MB
821Ready-made functions include `gnus-article-sort-by-number',
822`gnus-article-sort-by-author', `gnus-article-sort-by-subject',
823`gnus-article-sort-by-date', `gnus-article-sort-by-random'
824and `gnus-article-sort-by-score'.
825
826When threading is turned on, the variable `gnus-thread-sort-functions'
827controls how articles are sorted."
eec82323 828 :group 'gnus-summary-sort
01c52d31
MB
829 :type '(repeat (gnus-widget-reversible
830 (choice (function-item gnus-article-sort-by-number)
831 (function-item gnus-article-sort-by-author)
832 (function-item gnus-article-sort-by-subject)
833 (function-item gnus-article-sort-by-date)
834 (function-item gnus-article-sort-by-score)
835 (function-item gnus-article-sort-by-random)
836 (function :tag "other"))
837 (boolean :tag "Reverse order"))))
838
eec82323
LMI
839
840(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
841 "*List of functions used for sorting threads in the summary buffer.
842By default, threads are sorted by article number.
843
23f87bed
MB
844Each function takes two threads and returns non-nil if the first
845thread should be sorted before the other. If you use more than one
846function, the primary sort function should be the last. You should
847probably always include `gnus-thread-sort-by-number' in the list of
848sorting functions -- preferably first. Also note that sorting by date
849is often much slower than sorting by number, and the sorting order is
850very similar. (Sorting by date means sorting by the time the message
851was sent, sorting by number means sorting by arrival time.)
eec82323 852
01c52d31
MB
853Each list item can also be a list `(not F)' where F is a
854function; this specifies reversed sort order.
855
eec82323 856Ready-made functions include `gnus-thread-sort-by-number',
01c52d31
MB
857`gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
858`gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
859`gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
860`gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
861and `gnus-thread-sort-by-total-score' (see
862`gnus-thread-score-function').
23f87bed
MB
863
864When threading is turned off, the variable
865`gnus-article-sort-functions' controls how articles are sorted."
eec82323 866 :group 'gnus-summary-sort
01c52d31
MB
867 :type '(repeat
868 (gnus-widget-reversible
869 (choice (function-item gnus-thread-sort-by-number)
870 (function-item gnus-thread-sort-by-author)
871 (function-item gnus-thread-sort-by-recipient)
872 (function-item gnus-thread-sort-by-subject)
873 (function-item gnus-thread-sort-by-date)
874 (function-item gnus-thread-sort-by-score)
875 (function-item gnus-thread-sort-by-most-recent-number)
876 (function-item gnus-thread-sort-by-most-recent-date)
877 (function-item gnus-thread-sort-by-random)
878 (function-item gnus-thread-sort-by-total-score)
879 (function :tag "other"))
880 (boolean :tag "Reverse order"))))
eec82323
LMI
881
882(defcustom gnus-thread-score-function '+
883 "*Function used for calculating the total score of a thread.
884
885The function is called with the scores of the article and each
886subthread and should then return the score of the thread.
887
888Some functions you can use are `+', `max', or `min'."
889 :group 'gnus-summary-sort
890 :type 'function)
891
892(defcustom gnus-summary-expunge-below nil
6748645f
LMI
893 "All articles that have a score less than this variable will be expunged.
894This variable is local to the summary buffers."
eec82323
LMI
895 :group 'gnus-score-default
896 :type '(choice (const :tag "off" nil)
897 integer))
898
899(defcustom gnus-thread-expunge-below nil
900 "All threads that have a total score less than this variable will be expunged.
901See `gnus-thread-score-function' for en explanation of what a
6748645f
LMI
902\"thread score\" is.
903
904This variable is local to the summary buffers."
16409b0b 905 :group 'gnus-threading
eec82323
LMI
906 :group 'gnus-score-default
907 :type '(choice (const :tag "off" nil)
908 integer))
909
910(defcustom gnus-summary-mode-hook nil
911 "*A hook for Gnus summary mode.
912This hook is run before any variables are set in the summary buffer."
23f87bed 913 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
eec82323
LMI
914 :group 'gnus-summary-various
915 :type 'hook)
916
23f87bed
MB
917;; Extracted from gnus-xmas-redefine in order to preserve user settings
918(when (featurep 'xemacs)
919 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
920 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
921 (add-hook 'gnus-summary-mode-hook
922 'gnus-xmas-switch-horizontal-scrollbar-off))
923
eec82323
LMI
924(defcustom gnus-summary-menu-hook nil
925 "*Hook run after the creation of the summary mode menu."
926 :group 'gnus-summary-visual
927 :type 'hook)
928
929(defcustom gnus-summary-exit-hook nil
930 "*A hook called on exit from the summary buffer.
931It will be called with point in the group buffer."
932 :group 'gnus-summary-exit
933 :type 'hook)
934
935(defcustom gnus-summary-prepare-hook nil
936 "*A hook called after the summary buffer has been generated.
937If you want to modify the summary buffer, you can use this hook."
938 :group 'gnus-summary-various
939 :type 'hook)
940
6748645f
LMI
941(defcustom gnus-summary-prepared-hook nil
942 "*A hook called as the last thing after the summary buffer has been generated."
943 :group 'gnus-summary-various
944 :type 'hook)
945
eec82323
LMI
946(defcustom gnus-summary-generate-hook nil
947 "*A hook run just before generating the summary buffer.
948This hook is commonly used to customize threading variables and the
949like."
950 :group 'gnus-summary-various
951 :type 'hook)
952
953(defcustom gnus-select-group-hook nil
954 "*A hook called when a newsgroup is selected.
955
956If you'd like to simplify subjects like the
957`gnus-summary-next-same-subject' command does, you can use the
958following hook:
959
23f87bed
MB
960 (add-hook gnus-select-group-hook
961 (lambda ()
962 (mapcar (lambda (header)
963 (mail-header-set-subject
964 header
965 (gnus-simplify-subject
966 (mail-header-subject header) 're-only)))
967 gnus-newsgroup-headers)))"
eec82323
LMI
968 :group 'gnus-group-select
969 :type 'hook)
970
971(defcustom gnus-select-article-hook nil
972 "*A hook called when an article is selected."
973 :group 'gnus-summary-choose
23f87bed 974 :options '(gnus-agent-fetch-selected-article)
eec82323
LMI
975 :type 'hook)
976
977(defcustom gnus-visual-mark-article-hook
978 (list 'gnus-highlight-selected-summary)
979 "*Hook run after selecting an article in the summary buffer.
980It is meant to be used for highlighting the article in some way. It
981is not run if `gnus-visual' is nil."
982 :group 'gnus-summary-visual
983 :type 'hook)
984
16409b0b 985(defcustom gnus-parse-headers-hook nil
eec82323
LMI
986 "*A hook called before parsing the headers."
987 :group 'gnus-various
988 :type 'hook)
989
990(defcustom gnus-exit-group-hook nil
16409b0b
GM
991 "*A hook called when exiting summary mode.
992This hook is not called from the non-updating exit commands like `Q'."
eec82323
LMI
993 :group 'gnus-various
994 :type 'hook)
995
a9ec34f4 996(defcustom gnus-summary-update-hook nil
eec82323
LMI
997 "*A hook called when a summary line is changed.
998The hook will not be called if `gnus-visual' is nil.
999
1000The default function `gnus-summary-highlight-line' will
1001highlight the line according to the `gnus-summary-highlight'
1002variable."
1003 :group 'gnus-summary-visual
1004 :type 'hook)
1005
1006(defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1007 "*A hook called when an article is selected for the first time.
1008The hook is intended to mark an article as read (or unread)
1009automatically when it is selected."
1010 :group 'gnus-summary-choose
1011 :type 'hook)
1012
1013(defcustom gnus-group-no-more-groups-hook nil
1014 "*A hook run when returning to group mode having no more (unread) groups."
1015 :group 'gnus-group-select
1016 :type 'hook)
1017
1018(defcustom gnus-ps-print-hook nil
1019 "*A hook run before ps-printing something from Gnus."
1020 :group 'gnus-summary
1021 :type 'hook)
1022
23f87bed
MB
1023(defcustom gnus-summary-article-move-hook nil
1024 "*A hook called after an article is moved, copied, respooled, or crossposted."
bf247b6e 1025 :version "22.1"
23f87bed
MB
1026 :group 'gnus-summary
1027 :type 'hook)
1028
1029(defcustom gnus-summary-article-delete-hook nil
1030 "*A hook called after an article is deleted."
bf247b6e 1031 :version "22.1"
23f87bed
MB
1032 :group 'gnus-summary
1033 :type 'hook)
1034
1035(defcustom gnus-summary-article-expire-hook nil
1036 "*A hook called after an article is expired."
bf247b6e 1037 :version "22.1"
23f87bed
MB
1038 :group 'gnus-summary
1039 :type 'hook)
1040
1041(defcustom gnus-summary-display-arrow
1042 (and (fboundp 'display-graphic-p)
1043 (display-graphic-p))
1044 "*If non-nil, display an arrow highlighting the current article."
bf247b6e 1045 :version "22.1"
23f87bed
MB
1046 :group 'gnus-summary
1047 :type 'boolean)
1048
0f49874b 1049(defcustom gnus-summary-selected-face 'gnus-summary-selected
eec82323
LMI
1050 "Face used for highlighting the current article in the summary buffer."
1051 :group 'gnus-summary-visual
1052 :type 'face)
1053
23f87bed
MB
1054(defvar gnus-tmp-downloaded nil)
1055
eec82323 1056(defcustom gnus-summary-highlight
23f87bed 1057 '(((eq mark gnus-canceled-mark)
0f49874b 1058 . gnus-summary-cancelled)
23f87bed 1059 ((and uncached (> score default-high))
0f49874b 1060 . gnus-summary-high-undownloaded)
23f87bed 1061 ((and uncached (< score default-low))
0f49874b 1062 . gnus-summary-low-undownloaded)
23f87bed 1063 (uncached
0f49874b 1064 . gnus-summary-normal-undownloaded)
23f87bed
MB
1065 ((and (> score default-high)
1066 (or (eq mark gnus-dormant-mark)
1067 (eq mark gnus-ticked-mark)))
0f49874b 1068 . gnus-summary-high-ticked)
23f87bed
MB
1069 ((and (< score default-low)
1070 (or (eq mark gnus-dormant-mark)
1071 (eq mark gnus-ticked-mark)))
0f49874b 1072 . gnus-summary-low-ticked)
23f87bed
MB
1073 ((or (eq mark gnus-dormant-mark)
1074 (eq mark gnus-ticked-mark))
0f49874b 1075 . gnus-summary-normal-ticked)
23f87bed 1076 ((and (> score default-high) (eq mark gnus-ancient-mark))
0f49874b 1077 . gnus-summary-high-ancient)
23f87bed 1078 ((and (< score default-low) (eq mark gnus-ancient-mark))
0f49874b 1079 . gnus-summary-low-ancient)
23f87bed 1080 ((eq mark gnus-ancient-mark)
0f49874b 1081 . gnus-summary-normal-ancient)
23f87bed 1082 ((and (> score default-high) (eq mark gnus-unread-mark))
0f49874b 1083 . gnus-summary-high-unread)
23f87bed 1084 ((and (< score default-low) (eq mark gnus-unread-mark))
0f49874b 1085 . gnus-summary-low-unread)
23f87bed 1086 ((eq mark gnus-unread-mark)
0f49874b 1087 . gnus-summary-normal-unread)
23f87bed 1088 ((> score default-high)
0f49874b 1089 . gnus-summary-high-read)
23f87bed 1090 ((< score default-low)
0f49874b 1091 . gnus-summary-low-read)
eec82323 1092 (t
0f49874b 1093 . gnus-summary-normal-read))
6748645f 1094 "*Controls the highlighting of summary buffer lines.
eec82323 1095
107cf8ec 1096A list of (FORM . FACE) pairs. When deciding how a particular
23f87bed
MB
1097summary line should be displayed, each form is evaluated. The content
1098of the face field after the first true form is used. You can change
1099how those summary lines are displayed, by editing the face field.
eec82323
LMI
1100
1101You can use the following variables in the FORM field.
1102
107cf8ec 1103score: The article's score.
23f87bed
MB
1104default: The default article score.
1105default-high: The default score for high scored articles.
1106default-low: The default score for low scored articles.
1107below: The score below which articles are automatically marked as read.
1108mark: The article's mark.
1109uncached: Non-nil if the article is uncached."
eec82323
LMI
1110 :group 'gnus-summary-visual
1111 :type '(repeat (cons (sexp :tag "Form" nil)
1112 face)))
c12ecb0a 1113(put 'gnus-summary-highlight 'risky-local-variable t)
eec82323 1114
6748645f
LMI
1115(defcustom gnus-alter-header-function nil
1116 "Function called to allow alteration of article header structures.
1117The function is called with one parameter, the article header vector,
0ab0f2d3
SZ
1118which it may alter in any way."
1119 :type '(choice (const :tag "None" nil)
1120 function)
1121 :group 'gnus-summary)
eec82323 1122
16409b0b 1123(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
343d6628
MB
1124 "Function used to decode a string with encoded words.")
1125
1126(defvar gnus-decode-encoded-address-function
1127 'mail-decode-encoded-address-string
1128 "Function used to decode addresses with encoded words.")
16409b0b 1129
23f87bed 1130(defcustom gnus-extra-headers '(To Newsgroups)
16409b0b 1131 "*Extra headers to parse."
58e39d05 1132 :version "21.1"
16409b0b
GM
1133 :group 'gnus-summary
1134 :type '(repeat symbol))
1135
1136(defcustom gnus-ignored-from-addresses
343d6628 1137 (and user-mail-address
7cd9f860
CY
1138 (not (string= user-mail-address ""))
1139 (regexp-quote user-mail-address))
01c52d31
MB
1140 "*From headers that may be suppressed in favor of To headers.
1141This can be a regexp or a list of regexps."
58e39d05 1142 :version "21.1"
16409b0b 1143 :group 'gnus-summary
01c52d31
MB
1144 :type '(choice regexp
1145 (repeat :tag "Regexp List" regexp)))
1146
1147(defsubst gnus-ignored-from-addresses ()
1148 (gmm-regexp-concat gnus-ignored-from-addresses))
1149
1150(defcustom gnus-summary-to-prefix "-> "
1151 "*String prefixed to the To field in the summary line when
1152using `gnus-ignored-from-addresses'."
1153 :version "22.1"
1154 :group 'gnus-summary
1155 :type 'string)
1156
1157(defcustom gnus-summary-newsgroup-prefix "=> "
1158 "*String prefixed to the Newsgroup field in the summary
1159line when using `gnus-ignored-from-addresses'."
1160 :version "22.1"
1161 :group 'gnus-summary
1162 :type 'string)
16409b0b 1163
16409b0b
GM
1164(defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1165 "List of charsets that should be ignored.
1166When these charsets are used in the \"charset\" parameter, the
1167default charset will be used instead."
58e39d05 1168 :version "21.1"
16409b0b
GM
1169 :type '(repeat symbol)
1170 :group 'gnus-charset)
1171
4b70e299
MB
1172(defcustom gnus-newsgroup-maximum-articles nil
1173 "The maximum number of articles a newsgroup.
1174If this is a number, old articles in a newsgroup exceeding this number
1175are silently ignored. If it is nil, no article is ignored. Note that
1176setting this variable to a number might prevent you from reading very
1177old articles."
1178 :group 'gnus-group-select
1179 :version "22.2"
1180 :type '(choice (const :tag "No limit" nil)
1181 integer))
1182
23f87bed
MB
1183(gnus-define-group-parameter
1184 ignored-charsets
1185 :type list
1186 :function-document
1187 "Return the ignored charsets of GROUP."
1188 :variable gnus-group-ignored-charsets-alist
1189 :variable-default
1190 '(("alt\\.chinese\\.text" iso-8859-1))
1191 :variable-document
1192 "Alist of regexps (to match group names) and charsets that should be ignored.
16409b0b
GM
1193When these charsets are used in the \"charset\" parameter, the
1194default charset will be used instead."
23f87bed
MB
1195 :variable-group gnus-charset
1196 :variable-type '(repeat (cons (regexp :tag "Group")
1197 (repeat symbol)))
1198 :parameter-type '(choice :tag "Ignored charsets"
1199 :value nil
1200 (repeat (symbol)))
1201 :parameter-document "\
1202List of charsets that should be ignored.
1203
1204When these charsets are used in the \"charset\" parameter, the
1205default charset will be used instead.")
16409b0b
GM
1206
1207(defcustom gnus-group-highlight-words-alist nil
1208 "Alist of group regexps and highlight regexps.
1209This variable uses the same syntax as `gnus-emphasis-alist'."
58e39d05 1210 :version "21.1"
16409b0b
GM
1211 :type '(repeat (cons (regexp :tag "Group")
1212 (repeat (list (regexp :tag "Highlight regexp")
1213 (number :tag "Group for entire word" 0)
1214 (number :tag "Group for displayed part" 0)
1215 (symbol :tag "Face"
1216 gnus-emphasis-highlight-words)))))
1217 :group 'gnus-summary-visual)
1218
1219(defcustom gnus-summary-show-article-charset-alist
1220 nil
1221 "Alist of number and charset.
1222The article will be shown with the charset corresponding to the
1223numbered argument.
1224For example: ((1 . cn-gb-2312) (2 . big5))."
58e39d05 1225 :version "21.1"
16409b0b
GM
1226 :type '(repeat (cons (number :tag "Argument" 1)
1227 (symbol :tag "Charset")))
1228 :group 'gnus-charset)
1229
1230(defcustom gnus-preserve-marks t
1231 "Whether marks are preserved when moving, copying and respooling messages."
58e39d05 1232 :version "21.1"
16409b0b
GM
1233 :type 'boolean
1234 :group 'gnus-summary-marks)
1235
3a23a519
MB
1236(defcustom gnus-propagate-marks t
1237 "If non-nil, do not propagate marks to the backends."
f8a29505 1238 :version "23.1" ;; No Gnus
3a23a519
MB
1239 :type 'boolean
1240 :group 'gnus-summary-marks)
1241
16409b0b
GM
1242(defcustom gnus-alter-articles-to-read-function nil
1243 "Function to be called to alter the list of articles to be selected."
8fc7a9a1 1244 :type '(choice (const nil) function)
16409b0b
GM
1245 :group 'gnus-summary)
1246
1247(defcustom gnus-orphan-score nil
1248 "*All orphans get this score added. Set in the score file."
1249 :group 'gnus-score-default
1250 :type '(choice (const nil)
1251 integer))
1252
8b93df01 1253(defcustom gnus-summary-save-parts-default-mime "image/.*"
23f87bed
MB
1254 "*A regexp to match MIME parts when saving multiple parts of a
1255message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1256This regexp will be used by default when prompting the user for which
1257type of files to save."
8b93df01
DL
1258 :group 'gnus-summary
1259 :type 'regexp)
1260
23f87bed
MB
1261(defcustom gnus-read-all-available-headers nil
1262 "Whether Gnus should parse all headers made available to it.
1263This is mostly relevant for slow back ends where the user may
1264wish to widen the summary buffer to include all headers
c4d82de8 1265that were fetched."
bf247b6e 1266 :version "22.1"
23f87bed
MB
1267 :group 'gnus-summary
1268 :type '(choice boolean regexp))
1269
89167438
MB
1270(defcustom gnus-summary-pipe-output-default-command nil
1271 "Command (and optional arguments) used to pipe article to subprocess.
1272This will be used as the default command if it is non-nil. The value
1273will be updated if you modify it when executing the command
1274`gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1275 :version "23.1" ;; No Gnus
1276 :group 'gnus-summary
1277 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1278
23f87bed 1279(defcustom gnus-summary-muttprint-program "muttprint"
89167438
MB
1280 "Command (and optional arguments) used to run Muttprint.
1281The value will be updated if you modify it when executing the command
1282`gnus-summary-muttprint'."
bf247b6e 1283 :version "22.1"
23f87bed
MB
1284 :group 'gnus-summary
1285 :type 'string)
1286
01c52d31 1287(defcustom gnus-article-loose-mime t
23f87bed
MB
1288 "If non-nil, don't require MIME-Version header.
1289Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
a08b59c9 1290supply the MIME-Version header or deliberately strip it from the mail.
01c52d31
MB
1291If non-nil (the default), Gnus will treat some articles as MIME
1292even if the MIME-Version header is missing."
bf247b6e 1293 :version "22.1"
23f87bed
MB
1294 :type 'boolean
1295 :group 'gnus-article-mime)
1296
1297(defcustom gnus-article-emulate-mime t
1298 "If non-nil, use MIME emulation for uuencode and the like.
1299This means that Gnus will search message bodies for text that look
1300like uuencoded bits, yEncoded bits, and so on, and present that using
1301the normal Gnus MIME machinery."
bf247b6e 1302 :version "22.1"
23f87bed
MB
1303 :type 'boolean
1304 :group 'gnus-article-mime)
8b93df01 1305
eec82323
LMI
1306;;; Internal variables
1307
23f87bed 1308(defvar gnus-summary-display-cache nil)
16409b0b
GM
1309(defvar gnus-article-mime-handles nil)
1310(defvar gnus-article-decoded-p nil)
23f87bed
MB
1311(defvar gnus-article-charset nil)
1312(defvar gnus-article-ignored-charsets nil)
67a3b17c 1313(defvar gnus-article-original-subject nil)
eec82323
LMI
1314(defvar gnus-scores-exclude-files nil)
1315(defvar gnus-page-broken nil)
1316
1317(defvar gnus-original-article nil)
1318(defvar gnus-article-internal-prepare-hook nil)
1319(defvar gnus-newsgroup-process-stack nil)
1320
1321(defvar gnus-thread-indent-array nil)
1322(defvar gnus-thread-indent-array-level gnus-thread-indent-level)
16409b0b
GM
1323(defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1324 "Function called to sort the articles within a thread after it has been gathered together.")
eec82323 1325
8b93df01 1326(defvar gnus-summary-save-parts-type-history nil)
23f87bed 1327(defvar gnus-summary-save-parts-last-directory mm-default-directory)
8b93df01 1328
eec82323
LMI
1329;; Avoid highlighting in kill files.
1330(defvar gnus-summary-inhibit-highlight nil)
1331(defvar gnus-newsgroup-selected-overlay nil)
1332(defvar gnus-inhibit-limiting nil)
1333(defvar gnus-newsgroup-adaptive-score-file nil)
1334(defvar gnus-current-score-file nil)
1335(defvar gnus-current-move-group nil)
1336(defvar gnus-current-copy-group nil)
1337(defvar gnus-current-crosspost-group nil)
23f87bed 1338(defvar gnus-newsgroup-display nil)
67a3b17c 1339(defvar gnus-newsgroup-original-name nil)
eec82323
LMI
1340
1341(defvar gnus-newsgroup-dependencies nil)
1342(defvar gnus-newsgroup-adaptive nil)
1343(defvar gnus-summary-display-article-function nil)
1344(defvar gnus-summary-highlight-line-function nil
1345 "Function called after highlighting a summary line.")
1346
1347(defvar gnus-summary-line-format-alist
1348 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1349 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1350 (?s gnus-tmp-subject-or-nil ?s)
1351 (?n gnus-tmp-name ?s)
1352 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1353 ?s)
1354 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1355 gnus-tmp-from) ?s)
1356 (?F gnus-tmp-from ?s)
1357 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1358 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1359 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
6748645f 1360 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
eec82323
LMI
1361 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1362 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1363 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
23f87bed
MB
1364 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1365 (?L gnus-tmp-lines ?s)
1366 (?O gnus-tmp-downloaded ?c)
eec82323
LMI
1367 (?I gnus-tmp-indentation ?s)
1368 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1369 (?R gnus-tmp-replied ?c)
1370 (?\[ gnus-tmp-opening-bracket ?c)
1371 (?\] gnus-tmp-closing-bracket ?c)
1372 (?\> (make-string gnus-tmp-level ? ) ?s)
1373 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1374 (?i gnus-tmp-score ?d)
1375 (?z gnus-tmp-score-char ?c)
eec82323
LMI
1376 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1377 (?U gnus-tmp-unread ?c)
23f87bed
MB
1378 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1379 ?s)
eec82323
LMI
1380 (?t (gnus-summary-number-of-articles-in-thread
1381 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1382 ?d)
1383 (?e (gnus-summary-number-of-articles-in-thread
1384 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1385 ?c)
1386 (?u gnus-tmp-user-defined ?s)
23f87bed
MB
1387 (?P (gnus-pick-line-number) ?d)
1388 (?B gnus-tmp-thread-tree-header-string ?s)
1389 (user-date (gnus-user-date
1390 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
16409b0b
GM
1391 "An alist of format specifications that can appear in summary lines.
1392These are paired with what variables they correspond with, along with
1393the type of the variable (string, integer, character, etc).")
eec82323
LMI
1394
1395(defvar gnus-summary-dummy-line-format-alist
1396 `((?S gnus-tmp-subject ?s)
1397 (?N gnus-tmp-number ?d)
1398 (?u gnus-tmp-user-defined ?s)))
1399
1400(defvar gnus-summary-mode-line-format-alist
1401 `((?G gnus-tmp-group-name ?s)
1402 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1403 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1404 (?A gnus-tmp-article-number ?d)
1405 (?Z gnus-tmp-unread-and-unselected ?s)
1406 (?V gnus-version ?s)
1407 (?U gnus-tmp-unread-and-unticked ?d)
1408 (?S gnus-tmp-subject ?s)
1409 (?e gnus-tmp-unselected ?d)
1410 (?u gnus-tmp-user-defined ?s)
1411 (?d (length gnus-newsgroup-dormant) ?d)
1412 (?t (length gnus-newsgroup-marked) ?d)
23f87bed 1413 (?h (length gnus-newsgroup-spam-marked) ?d)
eec82323 1414 (?r (length gnus-newsgroup-reads) ?d)
6748645f 1415 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
eec82323
LMI
1416 (?E gnus-newsgroup-expunged-tally ?d)
1417 (?s (gnus-current-score-file-nondirectory) ?s)))
1418
c1717fbd
GM
1419;; This is here rather than in gnus-art for compilation reasons.
1420(defvar gnus-article-mode-line-format-alist
1421 (nconc '((?w (gnus-article-wash-status) ?s)
1422 (?m (gnus-article-mime-part-status) ?s))
1423 gnus-summary-mode-line-format-alist))
1424
eec82323
LMI
1425(defvar gnus-last-search-regexp nil
1426 "Default regexp for article search command.")
1427
1428(defvar gnus-last-shell-command nil
1429 "Default shell command on article.")
1430
23f87bed
MB
1431(defvar gnus-newsgroup-agentized nil
1432 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
eec82323
LMI
1433(defvar gnus-newsgroup-begin nil)
1434(defvar gnus-newsgroup-end nil)
1435(defvar gnus-newsgroup-last-rmail nil)
1436(defvar gnus-newsgroup-last-mail nil)
1437(defvar gnus-newsgroup-last-folder nil)
1438(defvar gnus-newsgroup-last-file nil)
26c9afc3 1439(defvar gnus-newsgroup-last-directory nil)
eec82323
LMI
1440(defvar gnus-newsgroup-auto-expire nil)
1441(defvar gnus-newsgroup-active nil)
9f2d52e7 1442(defvar gnus-newsgroup-highest nil)
eec82323
LMI
1443
1444(defvar gnus-newsgroup-data nil)
1445(defvar gnus-newsgroup-data-reverse nil)
1446(defvar gnus-newsgroup-limit nil)
1447(defvar gnus-newsgroup-limits nil)
23f87bed 1448(defvar gnus-summary-use-undownloaded-faces nil)
eec82323
LMI
1449
1450(defvar gnus-newsgroup-unreads nil
23f87bed 1451 "Sorted list of unread articles in the current newsgroup.")
eec82323
LMI
1452
1453(defvar gnus-newsgroup-unselected nil
23f87bed 1454 "Sorted list of unselected unread articles in the current newsgroup.")
eec82323
LMI
1455
1456(defvar gnus-newsgroup-reads nil
1457 "Alist of read articles and article marks in the current newsgroup.")
1458
1459(defvar gnus-newsgroup-expunged-tally nil)
1460
1461(defvar gnus-newsgroup-marked nil
23f87bed
MB
1462 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1463
1464(defvar gnus-newsgroup-spam-marked nil
1465 "List of ranges of articles that have been marked as spam.")
eec82323
LMI
1466
1467(defvar gnus-newsgroup-killed nil
1468 "List of ranges of articles that have been through the scoring process.")
1469
1470(defvar gnus-newsgroup-cached nil
23f87bed 1471 "Sorted list of articles that come from the article cache.")
eec82323
LMI
1472
1473(defvar gnus-newsgroup-saved nil
1474 "List of articles that have been saved.")
1475
1476(defvar gnus-newsgroup-kill-headers nil)
1477
1478(defvar gnus-newsgroup-replied nil
1479 "List of articles that have been replied to in the current newsgroup.")
1480
23f87bed
MB
1481(defvar gnus-newsgroup-forwarded nil
1482 "List of articles that have been forwarded in the current newsgroup.")
1483
1484(defvar gnus-newsgroup-recent nil
1485 "List of articles that have are recent in the current newsgroup.")
1486
eec82323 1487(defvar gnus-newsgroup-expirable nil
23f87bed 1488 "Sorted list of articles in the current newsgroup that can be expired.")
eec82323
LMI
1489
1490(defvar gnus-newsgroup-processable nil
1491 "List of articles in the current newsgroup that can be processed.")
1492
6748645f 1493(defvar gnus-newsgroup-downloadable nil
23f87bed
MB
1494 "Sorted list of articles in the current newsgroup that can be processed.")
1495
1496(defvar gnus-newsgroup-unfetched nil
1497 "Sorted list of articles in the current newsgroup whose headers have
1498not been fetched into the agent.
1499
1500This list will always be a subset of gnus-newsgroup-undownloaded.")
6748645f
LMI
1501
1502(defvar gnus-newsgroup-undownloaded nil
23f87bed 1503 "List of articles in the current newsgroup that haven't been downloaded.")
6748645f
LMI
1504
1505(defvar gnus-newsgroup-unsendable nil
1506 "List of articles in the current newsgroup that won't be sent.")
1507
eec82323
LMI
1508(defvar gnus-newsgroup-bookmarks nil
1509 "List of articles in the current newsgroup that have bookmarks.")
1510
1511(defvar gnus-newsgroup-dormant nil
23f87bed
MB
1512 "Sorted list of dormant articles in the current newsgroup.")
1513
1514(defvar gnus-newsgroup-unseen nil
1515 "List of unseen articles in the current newsgroup.")
1516
1517(defvar gnus-newsgroup-seen nil
1518 "Range of seen articles in the current newsgroup.")
1519
1520(defvar gnus-newsgroup-articles nil
1521 "List of articles in the current newsgroup.")
eec82323
LMI
1522
1523(defvar gnus-newsgroup-scored nil
1524 "List of scored articles in the current newsgroup.")
1525
1526(defvar gnus-newsgroup-headers nil
1527 "List of article headers in the current newsgroup.")
1528
1529(defvar gnus-newsgroup-threads nil)
1530
1531(defvar gnus-newsgroup-prepared nil
1532 "Whether the current group has been prepared properly.")
1533
1534(defvar gnus-newsgroup-ancient nil
1535 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1536
1537(defvar gnus-newsgroup-sparse nil)
1538
1539(defvar gnus-current-article nil)
1540(defvar gnus-article-current nil)
1541(defvar gnus-current-headers nil)
1542(defvar gnus-have-all-headers nil)
1543(defvar gnus-last-article nil)
1544(defvar gnus-newsgroup-history nil)
16409b0b
GM
1545(defvar gnus-newsgroup-charset nil)
1546(defvar gnus-newsgroup-ephemeral-charset nil)
1547(defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
eec82323 1548
23f87bed
MB
1549(defvar gnus-article-before-search nil)
1550
1551(defvar gnus-summary-local-variables
eec82323 1552 '(gnus-newsgroup-name
b1ae92ba
G
1553
1554 ;; Marks lists
1555 gnus-newsgroup-unreads
1556 gnus-newsgroup-unselected
1557 gnus-newsgroup-marked
1558 gnus-newsgroup-spam-marked
1559 gnus-newsgroup-reads
1560 gnus-newsgroup-saved
1561 gnus-newsgroup-replied
1562 gnus-newsgroup-forwarded
1563 gnus-newsgroup-recent
1564 gnus-newsgroup-expirable
1565 gnus-newsgroup-killed
1566 gnus-newsgroup-unseen
1567 gnus-newsgroup-seen
1568 gnus-newsgroup-cached
1569 gnus-newsgroup-downloadable
1570 gnus-newsgroup-undownloaded
1571 gnus-newsgroup-unsendable
1572
eec82323
LMI
1573 gnus-newsgroup-begin gnus-newsgroup-end
1574 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1575 gnus-newsgroup-last-folder gnus-newsgroup-last-file
26c9afc3 1576 gnus-newsgroup-last-directory
b1ae92ba
G
1577 gnus-newsgroup-auto-expire
1578 gnus-newsgroup-processable
23f87bed 1579 gnus-newsgroup-unfetched
b1ae92ba 1580 gnus-newsgroup-articles
eec82323
LMI
1581 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1582 gnus-newsgroup-headers gnus-newsgroup-threads
1583 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1584 gnus-current-article gnus-current-headers gnus-have-all-headers
1585 gnus-last-article gnus-article-internal-prepare-hook
1586 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1587 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1588 gnus-thread-expunge-below
16409b0b
GM
1589 gnus-score-alist gnus-current-score-file
1590 (gnus-summary-expunge-below . global)
eec82323 1591 (gnus-summary-mark-below . global)
16409b0b 1592 (gnus-orphan-score . global)
eec82323 1593 gnus-newsgroup-active gnus-scores-exclude-files
9f2d52e7 1594 gnus-newsgroup-highest
eec82323
LMI
1595 gnus-newsgroup-history gnus-newsgroup-ancient
1596 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1597 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1598 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1599 (gnus-newsgroup-expunged-tally . 0)
b1ae92ba 1600 gnus-cache-removable-articles
eec82323 1601 gnus-newsgroup-data gnus-newsgroup-data-reverse
16409b0b 1602 gnus-newsgroup-limit gnus-newsgroup-limits
23f87bed
MB
1603 gnus-newsgroup-charset gnus-newsgroup-display
1604 gnus-summary-use-undownloaded-faces)
eec82323
LMI
1605 "Variables that are buffer-local to the summary buffers.")
1606
23f87bed
MB
1607(defvar gnus-newsgroup-variables nil
1608 "A list of variables that have separate values in different newsgroups.
1609A list of newsgroup (summary buffer) local variables, or cons of
1610variables and their default expressions to be evalled (when the default
1611values are not nil), that should be made global while the summary buffer
1612is active.
1613
1614Note: The default expressions will be evaluated (using function `eval')
1615before assignment to the local variable rather than just assigned to it.
1616If the default expression is the symbol `global', that symbol will not
1617be evaluated but the global value of the local variable will be used
1618instead.
1619
1620These variables can be used to set variables in the group parameters
1621while still allowing them to affect operations done in other buffers.
1622For example:
1623
1624\(setq gnus-newsgroup-variables
1625 '(message-use-followup-to
1626 (gnus-visible-headers .
1627 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1628")
1629
23f87bed
MB
1630(eval-when-compile
1631 ;; Bind features so that require will believe that gnus-sum has
1632 ;; already been loaded (avoids infinite recursion)
1633 (let ((features (cons 'gnus-sum features)))
23f87bed 1634 (require 'gnus-art)))
eec82323 1635
16409b0b
GM
1636;; MIME stuff.
1637
1638(defvar gnus-decode-encoded-word-methods
1639 '(mail-decode-encoded-word-string)
1640 "List of methods used to decode encoded words.
1641
23f87bed
MB
1642This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1643is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1644\(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
16409b0b
GM
1645whose names match REGEXP.
1646
1647For example:
23f87bed 1648\((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
16409b0b
GM
1649 mail-decode-encoded-word-string
1650 (\"chinese\" . rfc1843-decode-string))")
1651
1652(defvar gnus-decode-encoded-word-methods-cache nil)
1653
1654(defun gnus-multi-decode-encoded-word-string (string)
1655 "Apply the functions from `gnus-encoded-word-methods' that match."
1656 (unless (and gnus-decode-encoded-word-methods-cache
1657 (eq gnus-newsgroup-name
1658 (car gnus-decode-encoded-word-methods-cache)))
1659 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
01c52d31
MB
1660 (dolist (method gnus-decode-encoded-word-methods)
1661 (if (symbolp method)
1662 (nconc gnus-decode-encoded-word-methods-cache (list method))
1663 (if (and gnus-newsgroup-name
1664 (string-match (car method) gnus-newsgroup-name))
1665 (nconc gnus-decode-encoded-word-methods-cache
1666 (list (cdr method)))))))
1667 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1668 (setq string (funcall method string))))
16409b0b 1669
eec82323
LMI
1670;; Subject simplification.
1671
6748645f 1672(defun gnus-simplify-whitespace (str)
16409b0b 1673 "Remove excessive whitespace from STR."
23f87bed
MB
1674 ;; Multiple spaces.
1675 (while (string-match "[ \t][ \t]+" str)
1676 (setq str (concat (substring str 0 (match-beginning 0))
1677 " "
1678 (substring str (match-end 0)))))
1679 ;; Leading spaces.
1680 (when (string-match "^[ \t]+" str)
1681 (setq str (substring str (match-end 0))))
1682 ;; Trailing spaces.
1683 (when (string-match "[ \t]+$" str)
1684 (setq str (substring str 0 (match-beginning 0))))
1685 str)
1686
1687(defun gnus-simplify-all-whitespace (str)
1688 "Remove all whitespace from STR."
1689 (while (string-match "[ \t\n]+" str)
1690 (setq str (replace-match "" nil nil str)))
1691 str)
6748645f 1692
eec82323
LMI
1693(defsubst gnus-simplify-subject-re (subject)
1694 "Remove \"Re:\" from subject lines."
23f87bed 1695 (if (string-match message-subject-re-regexp subject)
eec82323
LMI
1696 (substring subject (match-end 0))
1697 subject))
1698
1699(defun gnus-simplify-subject (subject &optional re-only)
1700 "Remove `Re:' and words in parentheses.
1701If RE-ONLY is non-nil, strip leading `Re:'s only."
1702 (let ((case-fold-search t)) ;Ignore case.
1703 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1704 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1705 (setq subject (substring subject (match-end 0))))
1706 ;; Remove uninteresting prefixes.
1707 (when (and (not re-only)
1708 gnus-simplify-ignored-prefixes
1709 (string-match gnus-simplify-ignored-prefixes subject))
1710 (setq subject (substring subject (match-end 0))))
1711 ;; Remove words in parentheses from end.
1712 (unless re-only
1713 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1714 (setq subject (substring subject 0 (match-beginning 0)))))
1715 ;; Return subject string.
1716 subject))
1717
1718;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1719;; all whitespace.
1720(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1721 (goto-char (point-min))
1722 (while (re-search-forward regexp nil t)
16409b0b 1723 (replace-match (or newtext ""))))
eec82323
LMI
1724
1725(defun gnus-simplify-buffer-fuzzy ()
1726 "Simplify string in the buffer fuzzily.
1727The string in the accessible portion of the current buffer is simplified.
1728It is assumed to be a single-line subject.
1729Whitespace is generally cleaned up, and miscellaneous leading/trailing
1730matter is removed. Additional things can be deleted by setting
16409b0b 1731`gnus-simplify-subject-fuzzy-regexp'."
eec82323
LMI
1732 (let ((case-fold-search t)
1733 (modified-tick))
1734 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1735
1736 (while (not (eq modified-tick (buffer-modified-tick)))
1737 (setq modified-tick (buffer-modified-tick))
1738 (cond
1739 ((listp gnus-simplify-subject-fuzzy-regexp)
01c52d31
MB
1740 (mapc 'gnus-simplify-buffer-fuzzy-step
1741 gnus-simplify-subject-fuzzy-regexp))
eec82323
LMI
1742 (gnus-simplify-subject-fuzzy-regexp
1743 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1744 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1745 (gnus-simplify-buffer-fuzzy-step
1746 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1747 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1748
1749 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1750 (gnus-simplify-buffer-fuzzy-step " +" " ")
1751 (gnus-simplify-buffer-fuzzy-step " $")
1752 (gnus-simplify-buffer-fuzzy-step "^ +")))
1753
1754(defun gnus-simplify-subject-fuzzy (subject)
1755 "Simplify a subject string fuzzily.
6748645f 1756See `gnus-simplify-buffer-fuzzy' for details."
eec82323
LMI
1757 (save-excursion
1758 (gnus-set-work-buffer)
1759 (let ((case-fold-search t))
6748645f
LMI
1760 ;; Remove uninteresting prefixes.
1761 (when (and gnus-simplify-ignored-prefixes
1762 (string-match gnus-simplify-ignored-prefixes subject))
1763 (setq subject (substring subject (match-end 0))))
eec82323
LMI
1764 (insert subject)
1765 (inline (gnus-simplify-buffer-fuzzy))
1766 (buffer-string))))
1767
1768(defsubst gnus-simplify-subject-fully (subject)
23f87bed 1769 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
eec82323 1770 (cond
6748645f
LMI
1771 (gnus-simplify-subject-functions
1772 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1773 ((null gnus-summary-gather-subject-limit)
1774 (gnus-simplify-subject-re subject))
1775 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1776 (gnus-simplify-subject-fuzzy subject))
1777 ((numberp gnus-summary-gather-subject-limit)
01c52d31
MB
1778 (truncate-string-to-width (gnus-simplify-subject-re subject)
1779 gnus-summary-gather-subject-limit))
eec82323
LMI
1780 (t
1781 subject)))
1782
1783(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f 1784 "Check whether two subjects are equal.
23f87bed 1785If optional argument SIMPLE-FIRST is t, first argument is already
6748645f 1786simplified."
eec82323
LMI
1787 (cond
1788 ((null simple-first)
1789 (equal (gnus-simplify-subject-fully s1)
1790 (gnus-simplify-subject-fully s2)))
1791 (t
1792 (equal s1
1793 (gnus-simplify-subject-fully s2)))))
1794
1795(defun gnus-summary-bubble-group ()
1796 "Increase the score of the current group.
1797This is a handy function to add to `gnus-summary-exit-hook' to
1798increase the score of each group you read."
1799 (gnus-group-add-score gnus-newsgroup-name))
1800
1801\f
1802;;;
1803;;; Gnus summary mode
1804;;;
1805
1806(put 'gnus-summary-mode 'mode-class 'special)
1807
1653df0f
SZ
1808(defvar gnus-article-commands-menu)
1809
23f87bed
MB
1810;; Non-orthogonal keys
1811
1812(gnus-define-keys gnus-summary-mode-map
1813 " " gnus-summary-next-page
1814 "\177" gnus-summary-prev-page
1815 [delete] gnus-summary-prev-page
1816 [backspace] gnus-summary-prev-page
1817 "\r" gnus-summary-scroll-up
1818 "\M-\r" gnus-summary-scroll-down
1819 "n" gnus-summary-next-unread-article
1820 "p" gnus-summary-prev-unread-article
1821 "N" gnus-summary-next-article
1822 "P" gnus-summary-prev-article
1823 "\M-\C-n" gnus-summary-next-same-subject
1824 "\M-\C-p" gnus-summary-prev-same-subject
1825 "\M-n" gnus-summary-next-unread-subject
1826 "\M-p" gnus-summary-prev-unread-subject
1827 "." gnus-summary-first-unread-article
1828 "," gnus-summary-best-unread-article
1829 "\M-s" gnus-summary-search-article-forward
1830 "\M-r" gnus-summary-search-article-backward
01c52d31
MB
1831 "\M-S" gnus-summary-repeat-search-article-forward
1832 "\M-R" gnus-summary-repeat-search-article-backward
23f87bed
MB
1833 "<" gnus-summary-beginning-of-article
1834 ">" gnus-summary-end-of-article
1835 "j" gnus-summary-goto-article
1836 "^" gnus-summary-refer-parent-article
1837 "\M-^" gnus-summary-refer-article
1838 "u" gnus-summary-tick-article-forward
1839 "!" gnus-summary-tick-article-forward
1840 "U" gnus-summary-tick-article-backward
1841 "d" gnus-summary-mark-as-read-forward
1842 "D" gnus-summary-mark-as-read-backward
1843 "E" gnus-summary-mark-as-expirable
1844 "\M-u" gnus-summary-clear-mark-forward
1845 "\M-U" gnus-summary-clear-mark-backward
1846 "k" gnus-summary-kill-same-subject-and-select
1847 "\C-k" gnus-summary-kill-same-subject
1848 "\M-\C-k" gnus-summary-kill-thread
1849 "\M-\C-l" gnus-summary-lower-thread
1850 "e" gnus-summary-edit-article
1851 "#" gnus-summary-mark-as-processable
1852 "\M-#" gnus-summary-unmark-as-processable
1853 "\M-\C-t" gnus-summary-toggle-threads
1854 "\M-\C-s" gnus-summary-show-thread
1855 "\M-\C-h" gnus-summary-hide-thread
1856 "\M-\C-f" gnus-summary-next-thread
1857 "\M-\C-b" gnus-summary-prev-thread
1858 [(meta down)] gnus-summary-next-thread
1859 [(meta up)] gnus-summary-prev-thread
1860 "\M-\C-u" gnus-summary-up-thread
1861 "\M-\C-d" gnus-summary-down-thread
1862 "&" gnus-summary-execute-command
1863 "c" gnus-summary-catchup-and-exit
1864 "\C-w" gnus-summary-mark-region-as-read
1865 "\C-t" gnus-summary-toggle-truncation
1866 "?" gnus-summary-mark-as-dormant
1867 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1868 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6ecfe5c2 1869 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
23f87bed
MB
1870 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1871 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1872 "\C-c\C-s\C-a" gnus-summary-sort-by-author
01c52d31 1873 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
23f87bed
MB
1874 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1875 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6ecfe5c2 1876 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
23f87bed
MB
1877 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1878 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1879 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1880 "=" gnus-summary-expand-window
1881 "\C-x\C-s" gnus-summary-reselect-current-group
1882 "\M-g" gnus-summary-rescan-group
23f87bed
MB
1883 "\C-c\C-r" gnus-summary-caesar-message
1884 "f" gnus-summary-followup
1885 "F" gnus-summary-followup-with-original
1886 "C" gnus-summary-cancel-article
1887 "r" gnus-summary-reply
1888 "R" gnus-summary-reply-with-original
1889 "\C-c\C-f" gnus-summary-mail-forward
1890 "o" gnus-summary-save-article
1891 "\C-o" gnus-summary-save-article-mail
1892 "|" gnus-summary-pipe-output
1893 "\M-k" gnus-summary-edit-local-kill
1894 "\M-K" gnus-summary-edit-global-kill
1895 ;; "V" gnus-version
1896 "\C-c\C-d" gnus-summary-describe-group
1897 "q" gnus-summary-exit
1898 "Q" gnus-summary-exit-no-update
1899 "\C-c\C-i" gnus-info-find-node
1900 gnus-mouse-2 gnus-mouse-pick-article
132cf96d 1901 [follow-link] mouse-face
23f87bed
MB
1902 "m" gnus-summary-mail-other-window
1903 "a" gnus-summary-post-news
23f87bed
MB
1904 "x" gnus-summary-limit-to-unread
1905 "s" gnus-summary-isearch-article
d50717f0 1906 [tab] gnus-summary-widget-forward
23f87bed
MB
1907 "t" gnus-summary-toggle-header
1908 "g" gnus-summary-show-article
1909 "l" gnus-summary-goto-last-article
1910 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1911 "\C-d" gnus-summary-enter-digest-group
1912 "\M-\C-d" gnus-summary-read-document
1913 "\M-\C-e" gnus-summary-edit-parameters
1914 "\M-\C-a" gnus-summary-customize-parameters
1915 "\C-c\C-b" gnus-bug
1916 "*" gnus-cache-enter-article
1917 "\M-*" gnus-cache-remove-article
1918 "\M-&" gnus-summary-universal-argument
1919 "\C-l" gnus-recenter
1920 "I" gnus-summary-increase-score
1921 "L" gnus-summary-lower-score
1922 "\M-i" gnus-symbolic-argument
1923 "h" gnus-summary-select-article-buffer
1924
1925 "b" gnus-article-view-part
1926 "\M-t" gnus-summary-toggle-display-buttonized
1927
1928 "V" gnus-summary-score-map
1929 "X" gnus-uu-extract-map
1930 "S" gnus-summary-send-map)
1931
1932;; Sort of orthogonal keymap
1933(gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1934 "t" gnus-summary-tick-article-forward
1935 "!" gnus-summary-tick-article-forward
1936 "d" gnus-summary-mark-as-read-forward
1937 "r" gnus-summary-mark-as-read-forward
1938 "c" gnus-summary-clear-mark-forward
1939 " " gnus-summary-clear-mark-forward
1940 "e" gnus-summary-mark-as-expirable
1941 "x" gnus-summary-mark-as-expirable
1942 "?" gnus-summary-mark-as-dormant
1943 "b" gnus-summary-set-bookmark
1944 "B" gnus-summary-remove-bookmark
1945 "#" gnus-summary-mark-as-processable
1946 "\M-#" gnus-summary-unmark-as-processable
1947 "S" gnus-summary-limit-include-expunged
1948 "C" gnus-summary-catchup
1949 "H" gnus-summary-catchup-to-here
1950 "h" gnus-summary-catchup-from-here
1951 "\C-c" gnus-summary-catchup-all
1952 "k" gnus-summary-kill-same-subject-and-select
1953 "K" gnus-summary-kill-same-subject
1954 "P" gnus-uu-mark-map)
1955
1956(gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1957 "c" gnus-summary-clear-above
1958 "u" gnus-summary-tick-above
1959 "m" gnus-summary-mark-above
1960 "k" gnus-summary-kill-below)
1961
1962(gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1963 "/" gnus-summary-limit-to-subject
1964 "n" gnus-summary-limit-to-articles
01c52d31
MB
1965 "b" gnus-summary-limit-to-bodies
1966 "h" gnus-summary-limit-to-headers
23f87bed
MB
1967 "w" gnus-summary-pop-limit
1968 "s" gnus-summary-limit-to-subject
1969 "a" gnus-summary-limit-to-author
1970 "u" gnus-summary-limit-to-unread
1971 "m" gnus-summary-limit-to-marks
1972 "M" gnus-summary-limit-exclude-marks
1973 "v" gnus-summary-limit-to-score
1974 "*" gnus-summary-limit-include-cached
1975 "D" gnus-summary-limit-include-dormant
1976 "T" gnus-summary-limit-include-thread
1977 "d" gnus-summary-limit-exclude-dormant
1978 "t" gnus-summary-limit-to-age
1979 "." gnus-summary-limit-to-unseen
1980 "x" gnus-summary-limit-to-extra
1981 "p" gnus-summary-limit-to-display-predicate
1982 "E" gnus-summary-limit-include-expunged
1983 "c" gnus-summary-limit-exclude-childless-dormant
1984 "C" gnus-summary-limit-mark-excluded-as-read
1985 "o" gnus-summary-insert-old-articles
01c52d31
MB
1986 "N" gnus-summary-insert-new-articles
1987 "S" gnus-summary-limit-to-singletons
1988 "r" gnus-summary-limit-to-replied
1989 "R" gnus-summary-limit-to-recipient
1990 "A" gnus-summary-limit-to-address)
23f87bed
MB
1991
1992(gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1993 "n" gnus-summary-next-unread-article
1994 "p" gnus-summary-prev-unread-article
1995 "N" gnus-summary-next-article
1996 "P" gnus-summary-prev-article
1997 "\C-n" gnus-summary-next-same-subject
1998 "\C-p" gnus-summary-prev-same-subject
1999 "\M-n" gnus-summary-next-unread-subject
2000 "\M-p" gnus-summary-prev-unread-subject
2001 "f" gnus-summary-first-unread-article
2002 "b" gnus-summary-best-unread-article
2003 "j" gnus-summary-goto-article
2004 "g" gnus-summary-goto-subject
2005 "l" gnus-summary-goto-last-article
2006 "o" gnus-summary-pop-article)
2007
2008(gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2009 "k" gnus-summary-kill-thread
01c52d31 2010 "E" gnus-summary-expire-thread
23f87bed
MB
2011 "l" gnus-summary-lower-thread
2012 "i" gnus-summary-raise-thread
2013 "T" gnus-summary-toggle-threads
2014 "t" gnus-summary-rethread-current
2015 "^" gnus-summary-reparent-thread
01c52d31 2016 "\M-^" gnus-summary-reparent-children
23f87bed
MB
2017 "s" gnus-summary-show-thread
2018 "S" gnus-summary-show-all-threads
2019 "h" gnus-summary-hide-thread
2020 "H" gnus-summary-hide-all-threads
2021 "n" gnus-summary-next-thread
2022 "p" gnus-summary-prev-thread
2023 "u" gnus-summary-up-thread
2024 "o" gnus-summary-top-thread
2025 "d" gnus-summary-down-thread
2026 "#" gnus-uu-mark-thread
2027 "\M-#" gnus-uu-unmark-thread)
2028
2029(gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2030 "g" gnus-summary-prepare
2031 "c" gnus-summary-insert-cached-articles
01c52d31
MB
2032 "d" gnus-summary-insert-dormant-articles
2033 "t" gnus-summary-insert-ticked-articles)
23f87bed
MB
2034
2035(gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2036 "c" gnus-summary-catchup-and-exit
2037 "C" gnus-summary-catchup-all-and-exit
2038 "E" gnus-summary-exit-no-update
2039 "Q" gnus-summary-exit
2040 "Z" gnus-summary-exit
2041 "n" gnus-summary-catchup-and-goto-next-group
01c52d31 2042 "p" gnus-summary-catchup-and-goto-prev-group
23f87bed
MB
2043 "R" gnus-summary-reselect-current-group
2044 "G" gnus-summary-rescan-group
2045 "N" gnus-summary-next-group
2046 "s" gnus-summary-save-newsrc
2047 "P" gnus-summary-prev-group)
2048
2049(gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2050 " " gnus-summary-next-page
2051 "n" gnus-summary-next-page
2052 "\177" gnus-summary-prev-page
2053 [delete] gnus-summary-prev-page
2054 "p" gnus-summary-prev-page
2055 "\r" gnus-summary-scroll-up
2056 "\M-\r" gnus-summary-scroll-down
2057 "<" gnus-summary-beginning-of-article
2058 ">" gnus-summary-end-of-article
2059 "b" gnus-summary-beginning-of-article
2060 "e" gnus-summary-end-of-article
2061 "^" gnus-summary-refer-parent-article
2062 "r" gnus-summary-refer-parent-article
8ccbef23 2063 "C" gnus-summary-show-complete-article
23f87bed
MB
2064 "D" gnus-summary-enter-digest-group
2065 "R" gnus-summary-refer-references
2066 "T" gnus-summary-refer-thread
4ddab346 2067 "W" gnus-warp-to-article
23f87bed
MB
2068 "g" gnus-summary-show-article
2069 "s" gnus-summary-isearch-article
d50717f0 2070 [tab] gnus-summary-widget-forward
23f87bed 2071 "P" gnus-summary-print-article
01c52d31 2072 "S" gnus-sticky-article
23f87bed
MB
2073 "M" gnus-mailing-list-insinuate
2074 "t" gnus-article-babel)
2075
2076(gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2077 "b" gnus-article-add-buttons
2078 "B" gnus-article-add-buttons-to-head
2079 "o" gnus-article-treat-overstrike
2080 "e" gnus-article-emphasize
2081 "w" gnus-article-fill-cited-article
2082 "Q" gnus-article-fill-long-lines
01c52d31 2083 "L" gnus-article-toggle-truncate-lines
23f87bed
MB
2084 "C" gnus-article-capitalize-sentences
2085 "c" gnus-article-remove-cr
2086 "q" gnus-article-de-quoted-unreadable
2087 "6" gnus-article-de-base64-unreadable
2088 "Z" gnus-article-decode-HZ
01c52d31 2089 "A" gnus-article-treat-ansi-sequences
23f87bed
MB
2090 "h" gnus-article-wash-html
2091 "u" gnus-article-unsplit-urls
2092 "s" gnus-summary-force-verify-and-decrypt
2093 "f" gnus-article-display-x-face
2094 "l" gnus-summary-stop-page-breaking
2095 "r" gnus-summary-caesar-message
2096 "m" gnus-summary-morse-message
2097 "t" gnus-summary-toggle-header
2098 "g" gnus-treat-smiley
2099 "v" gnus-summary-verbose-headers
2100 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2101 "p" gnus-article-verify-x-pgp-sig
01c52d31 2102 "d" gnus-article-treat-dumbquotes
be3c11b3 2103 "U" gnus-article-treat-non-ascii
01c52d31 2104 "i" gnus-summary-idna-message)
23f87bed
MB
2105
2106(gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2107 ;; mnemonic: deuglif*Y*
2108 "u" gnus-article-outlook-unwrap-lines
2109 "a" gnus-article-outlook-repair-attribution
2110 "c" gnus-article-outlook-rearrange-citation
2111 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2112
2113(gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2114 "a" gnus-article-hide
2115 "h" gnus-article-hide-headers
2116 "b" gnus-article-hide-boring-headers
2117 "s" gnus-article-hide-signature
2118 "c" gnus-article-hide-citation
2119 "C" gnus-article-hide-citation-in-followups
2120 "l" gnus-article-hide-list-identifiers
2121 "B" gnus-article-strip-banner
2122 "P" gnus-article-hide-pem
2123 "\C-c" gnus-article-hide-citation-maybe)
2124
2125(gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2126 "a" gnus-article-highlight
2127 "h" gnus-article-highlight-headers
2128 "c" gnus-article-highlight-citation
2129 "s" gnus-article-highlight-signature)
2130
2131(gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2132 "f" gnus-article-treat-fold-headers
2133 "u" gnus-article-treat-unfold-headers
2134 "n" gnus-article-treat-fold-newsgroups)
2135
2136(gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2137 "x" gnus-article-display-x-face
2138 "d" gnus-article-display-face
2139 "s" gnus-treat-smiley
2140 "D" gnus-article-remove-images
8b6f6573 2141 "W" gnus-article-show-images
23f87bed
MB
2142 "f" gnus-treat-from-picon
2143 "m" gnus-treat-mail-picon
61b1af82
G
2144 "n" gnus-treat-newsgroups-picon
2145 "g" gnus-treat-from-gravatar
2146 "h" gnus-treat-mail-gravatar)
23f87bed
MB
2147
2148(gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2149 "w" gnus-article-decode-mime-words
2150 "c" gnus-article-decode-charset
2151 "v" gnus-mime-view-all-parts
2152 "b" gnus-article-view-part)
2153
2154(gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2155 "z" gnus-article-date-ut
2156 "u" gnus-article-date-ut
2157 "l" gnus-article-date-local
2158 "p" gnus-article-date-english
2159 "e" gnus-article-date-lapsed
2160 "o" gnus-article-date-original
2161 "i" gnus-article-date-iso8601
2162 "s" gnus-article-date-user)
2163
2164(gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2165 "t" gnus-article-remove-trailing-blank-lines
2166 "l" gnus-article-strip-leading-blank-lines
2167 "m" gnus-article-strip-multiple-blank-lines
2168 "a" gnus-article-strip-blank-lines
2169 "A" gnus-article-strip-all-blank-lines
2170 "s" gnus-article-strip-leading-space
2171 "e" gnus-article-strip-trailing-space
2172 "w" gnus-article-remove-leading-whitespace)
2173
2174(gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2175 "v" gnus-version
23f87bed
MB
2176 "d" gnus-summary-describe-group
2177 "h" gnus-summary-describe-briefly
837ba704 2178 "i" gnus-info-find-node)
23f87bed
MB
2179
2180(gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2181 "e" gnus-summary-expire-articles
2182 "\M-\C-e" gnus-summary-expire-articles-now
2183 "\177" gnus-summary-delete-article
2184 [delete] gnus-summary-delete-article
2185 [backspace] gnus-summary-delete-article
2186 "m" gnus-summary-move-article
2187 "r" gnus-summary-respool-article
2188 "w" gnus-summary-edit-article
2189 "c" gnus-summary-copy-article
2190 "B" gnus-summary-crosspost-article
2191 "q" gnus-summary-respool-query
2192 "t" gnus-summary-respool-trace
2193 "i" gnus-summary-import-article
2194 "I" gnus-summary-create-article
2195 "p" gnus-summary-article-posted-p)
2196
2197(gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2198 "o" gnus-summary-save-article
2199 "m" gnus-summary-save-article-mail
2200 "F" gnus-summary-write-article-file
2201 "r" gnus-summary-save-article-rmail
2202 "f" gnus-summary-save-article-file
2203 "b" gnus-summary-save-article-body-file
26c9afc3 2204 "B" gnus-summary-write-article-body-file
23f87bed
MB
2205 "h" gnus-summary-save-article-folder
2206 "v" gnus-summary-save-article-vm
2207 "p" gnus-summary-pipe-output
c4d82de8 2208 "P" gnus-summary-muttprint)
23f87bed
MB
2209
2210(gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2211 "b" gnus-summary-display-buttonized
2212 "m" gnus-summary-repair-multipart
2213 "v" gnus-article-view-part
2214 "o" gnus-article-save-part
01c52d31
MB
2215 "O" gnus-article-save-part-and-strip
2216 "r" gnus-article-replace-part
2217 "d" gnus-article-delete-part
2218 "t" gnus-article-view-part-as-type
2219 "j" gnus-article-jump-to-part
23f87bed
MB
2220 "c" gnus-article-copy-part
2221 "C" gnus-article-view-part-as-charset
2222 "e" gnus-article-view-part-externally
01c52d31 2223 "H" gnus-article-browse-html-article
23f87bed
MB
2224 "E" gnus-article-encrypt-body
2225 "i" gnus-article-inline-part
2226 "|" gnus-article-pipe-part)
2227
2228(gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2229 "p" gnus-summary-mark-as-processable
2230 "u" gnus-summary-unmark-as-processable
2231 "U" gnus-summary-unmark-all-processable
2232 "v" gnus-uu-mark-over
2233 "s" gnus-uu-mark-series
2234 "r" gnus-uu-mark-region
2235 "g" gnus-uu-unmark-region
2236 "R" gnus-uu-mark-by-regexp
2237 "G" gnus-uu-unmark-by-regexp
2238 "t" gnus-uu-mark-thread
2239 "T" gnus-uu-unmark-thread
2240 "a" gnus-uu-mark-all
2241 "b" gnus-uu-mark-buffer
2242 "S" gnus-uu-mark-sparse
2243 "k" gnus-summary-kill-process-mark
2244 "y" gnus-summary-yank-process-mark
2245 "w" gnus-summary-save-process-mark
2246 "i" gnus-uu-invert-processable)
2247
2248(gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2249 ;;"x" gnus-uu-extract-any
2250 "m" gnus-summary-save-parts
2251 "u" gnus-uu-decode-uu
2252 "U" gnus-uu-decode-uu-and-save
2253 "s" gnus-uu-decode-unshar
2254 "S" gnus-uu-decode-unshar-and-save
2255 "o" gnus-uu-decode-save
2256 "O" gnus-uu-decode-save
2257 "b" gnus-uu-decode-binhex
2258 "B" gnus-uu-decode-binhex
b890d447 2259 "Y" gnus-uu-decode-yenc
23f87bed
MB
2260 "p" gnus-uu-decode-postscript
2261 "P" gnus-uu-decode-postscript-and-save)
2262
2263(gnus-define-keys
2264 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2265 "u" gnus-uu-decode-uu-view
2266 "U" gnus-uu-decode-uu-and-save-view
2267 "s" gnus-uu-decode-unshar-view
2268 "S" gnus-uu-decode-unshar-and-save-view
2269 "o" gnus-uu-decode-save-view
2270 "O" gnus-uu-decode-save-view
2271 "b" gnus-uu-decode-binhex-view
2272 "B" gnus-uu-decode-binhex-view
2273 "p" gnus-uu-decode-postscript-view
2274 "P" gnus-uu-decode-postscript-and-save-view)
2275
2276(defvar gnus-article-post-menu nil)
2277
2278(defconst gnus-summary-menu-maxlen 20)
2279
2280(defun gnus-summary-menu-split (menu)
2281 ;; If we have lots of elements, divide them into groups of 20
2282 ;; and make a pane (or submenu) for each one.
2283 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2284 (let ((menu menu) sublists next
2285 (i 1))
2286 (while menu
2287 ;; Pull off the next gnus-summary-menu-maxlen elements
2288 ;; and make them the next element of sublist.
2289 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2290 (if next
2291 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2292 nil))
2293 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2294 (aref (car (last menu)) 0)) menu)
2295 sublists))
2296 (setq i (1+ i))
2297 (setq menu next))
2298 (nreverse sublists))
2299 ;; Few elements--put them all in one pane.
2300 menu))
eec82323
LMI
2301
2302(defun gnus-summary-make-menu-bar ()
2303 (gnus-turn-off-edit-menu 'summary)
2304
2305 (unless (boundp 'gnus-summary-misc-menu)
2306
2307 (easy-menu-define
23f87bed
MB
2308 gnus-summary-kill-menu gnus-summary-mode-map ""
2309 (cons
2310 "Score"
2311 (nconc
2312 (list
2313 ["Customize" gnus-score-customize t])
2314 (gnus-make-score-map 'increase)
2315 (gnus-make-score-map 'lower)
2316 '(("Mark"
2317 ["Kill below" gnus-summary-kill-below t]
2318 ["Mark above" gnus-summary-mark-above t]
2319 ["Tick above" gnus-summary-tick-above t]
2320 ["Clear above" gnus-summary-clear-above t])
2321 ["Current score" gnus-summary-current-score t]
2322 ["Set score" gnus-summary-set-score t]
2323 ["Switch current score file..." gnus-score-change-score-file t]
2324 ["Set mark below..." gnus-score-set-mark-below t]
2325 ["Set expunge below..." gnus-score-set-expunge-below t]
2326 ["Edit current score file" gnus-score-edit-current-scores t]
59429511 2327 ["Edit score file..." gnus-score-edit-file t]
23f87bed
MB
2328 ["Trace score" gnus-score-find-trace t]
2329 ["Find words" gnus-score-find-favourite-words t]
2330 ["Rescore buffer" gnus-summary-rescore t]
2331 ["Increase score..." gnus-summary-increase-score t]
2332 ["Lower score..." gnus-summary-lower-score t]))))
2333
2334 ;; Define both the Article menu in the summary buffer and the
2335 ;; equivalent Commands menu in the article buffer here for
2336 ;; consistency.
6748645f 2337 (let ((innards
23f87bed
MB
2338 `(("Hide"
2339 ["All" gnus-article-hide t]
2340 ["Headers" gnus-article-hide-headers t]
2341 ["Signature" gnus-article-hide-signature t]
2342 ["Citation" gnus-article-hide-citation t]
16409b0b 2343 ["List identifiers" gnus-article-hide-list-identifiers t]
16409b0b 2344 ["Banner" gnus-article-strip-banner t]
23f87bed
MB
2345 ["Boring headers" gnus-article-hide-boring-headers t])
2346 ("Highlight"
2347 ["All" gnus-article-highlight t]
2348 ["Headers" gnus-article-highlight-headers t]
2349 ["Signature" gnus-article-highlight-signature t]
2350 ["Citation" gnus-article-highlight-citation t])
16409b0b
GM
2351 ("MIME"
2352 ["Words" gnus-article-decode-mime-words t]
2353 ["Charset" gnus-article-decode-charset t]
2354 ["QP" gnus-article-de-quoted-unreadable t]
2355 ["Base64" gnus-article-de-base64-unreadable t]
23f87bed
MB
2356 ["View MIME buttons" gnus-summary-display-buttonized t]
2357 ["View all" gnus-mime-view-all-parts t]
2358 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2359 ["Encrypt body" gnus-article-encrypt-body
2360 :active (not (gnus-group-read-only-p))
2361 ,@(if (featurep 'xemacs) nil
2362 '(:help "Encrypt the message body on disk"))]
2363 ["Extract all parts..." gnus-summary-save-parts t]
2364 ("Multipart"
2365 ["Repair multipart" gnus-summary-repair-multipart t]
2366 ["Pipe part..." gnus-article-pipe-part t]
2367 ["Inline part" gnus-article-inline-part t]
01c52d31 2368 ["View part as type..." gnus-article-view-part-as-type t]
23f87bed
MB
2369 ["Encrypt body" gnus-article-encrypt-body
2370 :active (not (gnus-group-read-only-p))
2371 ,@(if (featurep 'xemacs) nil
2372 '(:help "Encrypt the message body on disk"))]
2373 ["View part externally" gnus-article-view-part-externally t]
01c52d31 2374 ["View HTML parts in browser" gnus-article-browse-html-article t]
23f87bed
MB
2375 ["View part with charset..." gnus-article-view-part-as-charset t]
2376 ["Copy part" gnus-article-copy-part t]
2377 ["Save part..." gnus-article-save-part t]
2378 ["View part" gnus-article-view-part t]))
2379 ("Date"
2380 ["Local" gnus-article-date-local t]
2381 ["ISO8601" gnus-article-date-iso8601 t]
2382 ["UT" gnus-article-date-ut t]
2383 ["Original" gnus-article-date-original t]
2384 ["Lapsed" gnus-article-date-lapsed t]
2385 ["User-defined" gnus-article-date-user t])
2386 ("Display"
2387 ["Remove images" gnus-article-remove-images t]
2388 ["Toggle smiley" gnus-treat-smiley t]
2389 ["Show X-Face" gnus-article-display-x-face t]
2390 ["Show picons in From" gnus-treat-from-picon t]
2391 ["Show picons in mail headers" gnus-treat-mail-picon t]
2392 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
61b1af82
G
2393 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2394 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
23f87bed
MB
2395 ("View as different encoding"
2396 ,@(gnus-summary-menu-split
2397 (mapcar
2398 (lambda (cs)
2399 ;; Since easymenu under Emacs doesn't allow
2400 ;; lambda forms for menu commands, we should
2401 ;; provide intern'ed function symbols.
2402 (let ((command (intern (format "\
2403gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2404 (fset command
2405 `(lambda ()
2406 (interactive)
2407 (let ((gnus-summary-show-article-charset-alist
2408 '((1 . ,cs))))
2409 (gnus-summary-show-article 1))))
2410 `[,(symbol-name cs) ,command t]))
2411 (sort (if (fboundp 'coding-system-list)
2412 (coding-system-list)
2413 (mapcar 'car mm-mime-mule-charset-alist))
2414 'string<)))))
2415 ("Washing"
2416 ("Remove Blanks"
2417 ["Leading" gnus-article-strip-leading-blank-lines t]
2418 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2419 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2420 ["All of the above" gnus-article-strip-blank-lines t]
2421 ["All" gnus-article-strip-all-blank-lines t]
2422 ["Leading space" gnus-article-strip-leading-space t]
2423 ["Trailing space" gnus-article-strip-trailing-space t]
2424 ["Leading space in headers"
2425 gnus-article-remove-leading-whitespace t])
2426 ["Overstrike" gnus-article-treat-overstrike t]
2427 ["Dumb quotes" gnus-article-treat-dumbquotes t]
be3c11b3 2428 ["Non-ASCII" gnus-article-treat-non-ascii t]
23f87bed
MB
2429 ["Emphasis" gnus-article-emphasize t]
2430 ["Word wrap" gnus-article-fill-cited-article t]
16409b0b 2431 ["Fill long lines" gnus-article-fill-long-lines t]
01c52d31 2432 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
16409b0b 2433 ["Capitalize sentences" gnus-article-capitalize-sentences t]
23f87bed
MB
2434 ["Remove CR" gnus-article-remove-cr t]
2435 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2436 ["Base64" gnus-article-de-base64-unreadable t]
2437 ["Rot 13" gnus-summary-caesar-message
2438 ,@(if (featurep 'xemacs) '(t)
2439 '(:help "\"Caesar rotate\" article by 13"))]
01c52d31 2440 ["De-IDNA" gnus-summary-idna-message t]
23f87bed
MB
2441 ["Morse decode" gnus-summary-morse-message t]
2442 ["Unix pipe..." gnus-summary-pipe-message t]
2443 ["Add buttons" gnus-article-add-buttons t]
2444 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2445 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2446 ["Verbose header" gnus-summary-verbose-headers t]
2447 ["Toggle header" gnus-summary-toggle-header t]
2448 ["Unfold headers" gnus-article-treat-unfold-headers t]
2449 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
16409b0b 2450 ["Html" gnus-article-wash-html t]
23f87bed
MB
2451 ["Unsplit URLs" gnus-article-unsplit-urls t]
2452 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2453 ["Decode HZ" gnus-article-decode-HZ t]
01c52d31 2454 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
23f87bed
MB
2455 ("(Outlook) Deuglify"
2456 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2457 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2458 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2459 ["Full (Outlook) deuglify"
2460 gnus-article-outlook-deuglify-article t])
2461 )
2462 ("Output"
2463 ["Save in default format..." gnus-summary-save-article
2464 ,@(if (featurep 'xemacs) '(t)
2465 '(:help "Save article using default method"))]
2466 ["Save in file..." gnus-summary-save-article-file
2467 ,@(if (featurep 'xemacs) '(t)
2468 '(:help "Save article in file"))]
2469 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2470 ["Save in MH folder..." gnus-summary-save-article-folder t]
2471 ["Save in VM folder..." gnus-summary-save-article-vm t]
2472 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2473 ["Save body in file..." gnus-summary-save-article-body-file t]
2474 ["Pipe through a filter..." gnus-summary-pipe-output t]
23f87bed 2475 ["Print with Muttprint..." gnus-summary-muttprint t]
531e5812
MB
2476 ["Print" gnus-summary-print-article
2477 ,@(if (featurep 'xemacs) '(t)
2478 '(:help "Generate and print a PostScript image"))])
2479 ("Copy, move,... (Backend)"
707f2b38 2480 ,@(if (featurep 'xemacs) nil
531e5812 2481 '(:help "Copying, moving, expiring articles..."))
23f87bed
MB
2482 ["Respool article..." gnus-summary-respool-article t]
2483 ["Move article..." gnus-summary-move-article
2484 (gnus-check-backend-function
2485 'request-move-article gnus-newsgroup-name)]
2486 ["Copy article..." gnus-summary-copy-article t]
2487 ["Crosspost article..." gnus-summary-crosspost-article
2488 (gnus-check-backend-function
2489 'request-replace-article gnus-newsgroup-name)]
2490 ["Import file..." gnus-summary-import-article
2491 (gnus-check-backend-function
2492 'request-accept-article gnus-newsgroup-name)]
2493 ["Create article..." gnus-summary-create-article
2494 (gnus-check-backend-function
2495 'request-accept-article gnus-newsgroup-name)]
2496 ["Check if posted" gnus-summary-article-posted-p t]
2497 ["Edit article" gnus-summary-edit-article
2498 (not (gnus-group-read-only-p))]
2499 ["Delete article" gnus-summary-delete-article
2500 (gnus-check-backend-function
2501 'request-expire-articles gnus-newsgroup-name)]
2502 ["Query respool" gnus-summary-respool-query t]
6748645f 2503 ["Trace respool" gnus-summary-respool-trace t]
23f87bed
MB
2504 ["Delete expirable articles" gnus-summary-expire-articles-now
2505 (gnus-check-backend-function
2506 'request-expire-articles gnus-newsgroup-name)])
2507 ("Extract"
2508 ["Uudecode" gnus-uu-decode-uu
2509 ,@(if (featurep 'xemacs) '(t)
2510 '(:help "Decode uuencoded article(s)"))]
2511 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2512 ["Unshar" gnus-uu-decode-unshar t]
2513 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2514 ["Save" gnus-uu-decode-save t]
2515 ["Binhex" gnus-uu-decode-binhex t]
2516 ["Postscript" gnus-uu-decode-postscript t]
2517 ["All MIME parts" gnus-summary-save-parts t])
2518 ("Cache"
2519 ["Enter article" gnus-cache-enter-article t]
2520 ["Remove article" gnus-cache-remove-article t])
16409b0b 2521 ["Translate" gnus-article-babel t]
23f87bed 2522 ["Select article buffer" gnus-summary-select-article-buffer t]
01c52d31 2523 ["Make article buffer sticky" gnus-sticky-article t]
23f87bed
MB
2524 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2525 ["Isearch article..." gnus-summary-isearch-article t]
2526 ["Beginning of the article" gnus-summary-beginning-of-article t]
2527 ["End of the article" gnus-summary-end-of-article t]
2528 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2529 ["Fetch referenced articles" gnus-summary-refer-references t]
2530 ["Fetch current thread" gnus-summary-refer-thread t]
2531 ["Fetch article with id..." gnus-summary-refer-article t]
2532 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2533 ["Redisplay" gnus-summary-show-article t]
2534 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
6748645f 2535 (easy-menu-define
23f87bed
MB
2536 gnus-summary-article-menu gnus-summary-mode-map ""
2537 (cons "Article" innards))
6748645f 2538
1653df0f
SZ
2539 (if (not (keymapp gnus-summary-article-menu))
2540 (easy-menu-define
2541 gnus-article-commands-menu gnus-article-mode-map ""
2542 (cons "Commands" innards))
2543 ;; in Emacs, don't share menu.
a1506d29 2544 (setq gnus-article-commands-menu
1653df0f
SZ
2545 (copy-keymap gnus-summary-article-menu))
2546 (define-key gnus-article-mode-map [menu-bar commands]
2547 (cons "Commands" gnus-article-commands-menu))))
eec82323
LMI
2548
2549 (easy-menu-define
23f87bed
MB
2550 gnus-summary-thread-menu gnus-summary-mode-map ""
2551 '("Threads"
2552 ["Find all messages in thread" gnus-summary-refer-thread t]
2553 ["Toggle threading" gnus-summary-toggle-threads t]
2554 ["Hide threads" gnus-summary-hide-all-threads t]
2555 ["Show threads" gnus-summary-show-all-threads t]
2556 ["Hide thread" gnus-summary-hide-thread t]
2557 ["Show thread" gnus-summary-show-thread t]
2558 ["Go to next thread" gnus-summary-next-thread t]
2559 ["Go to previous thread" gnus-summary-prev-thread t]
2560 ["Go down thread" gnus-summary-down-thread t]
2561 ["Go up thread" gnus-summary-up-thread t]
2562 ["Top of thread" gnus-summary-top-thread t]
2563 ["Mark thread as read" gnus-summary-kill-thread t]
01c52d31 2564 ["Mark thread as expired" gnus-summary-expire-thread t]
23f87bed
MB
2565 ["Lower thread score" gnus-summary-lower-thread t]
2566 ["Raise thread score" gnus-summary-raise-thread t]
2567 ["Rethread current" gnus-summary-rethread-current t]))
eec82323
LMI
2568
2569 (easy-menu-define
23f87bed
MB
2570 gnus-summary-post-menu gnus-summary-mode-map ""
2571 `("Post"
2572 ["Send a message (mail or news)" gnus-summary-post-news
2573 ,@(if (featurep 'xemacs) '(t)
531e5812 2574 '(:help "Compose a new message (mail or news)"))]
23f87bed
MB
2575 ["Followup" gnus-summary-followup
2576 ,@(if (featurep 'xemacs) '(t)
2577 '(:help "Post followup to this article"))]
2578 ["Followup and yank" gnus-summary-followup-with-original
2579 ,@(if (featurep 'xemacs) '(t)
2580 '(:help "Post followup to this article, quoting its contents"))]
2581 ["Supersede article" gnus-summary-supersede-article t]
2582 ["Cancel article" gnus-summary-cancel-article
2583 ,@(if (featurep 'xemacs) '(t)
2584 '(:help "Cancel an article you posted"))]
2585 ["Reply" gnus-summary-reply t]
2586 ["Reply and yank" gnus-summary-reply-with-original t]
2587 ["Wide reply" gnus-summary-wide-reply t]
2588 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2589 ,@(if (featurep 'xemacs) '(t)
2590 '(:help "Mail a reply, quoting this article"))]
2591 ["Very wide reply" gnus-summary-very-wide-reply t]
2592 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2593 ,@(if (featurep 'xemacs) '(t)
2594 '(:help "Mail a very wide reply, quoting this article"))]
2595 ["Mail forward" gnus-summary-mail-forward t]
2596 ["Post forward" gnus-summary-post-forward t]
2597 ["Digest and mail" gnus-uu-digest-mail-forward t]
2598 ["Digest and post" gnus-uu-digest-post-forward t]
2599 ["Resend message" gnus-summary-resend-message t]
2600 ["Resend message edit" gnus-summary-resend-message-edit t]
2601 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2602 ["Send a mail" gnus-summary-mail-other-window t]
2603 ["Create a local message" gnus-summary-news-other-window t]
2604 ["Uuencode and post" gnus-uu-post-news
2605 ,@(if (featurep 'xemacs) '(t)
2606 '(:help "Post a uuencoded article"))]
2607 ["Followup via news" gnus-summary-followup-to-mail t]
2608 ["Followup via news and yank"
2609 gnus-summary-followup-to-mail-with-original t]
9b3ebcb6
MB
2610 ["Strip signature on reply"
2611 (lambda ()
2612 (interactive)
2613 (if (not (memq message-cite-function
2614 '(message-cite-original-without-signature
2615 message-cite-original)))
2616 ;; Stupid workaround for XEmacs not honoring :visible.
2617 (message "Can't toggle this value of `message-cite-function'")
2618 (setq message-cite-function
2619 (if (eq message-cite-function
2620 'message-cite-original-without-signature)
2621 'message-cite-original
2622 'message-cite-original-without-signature))))
2623 ;; XEmacs barfs on :visible.
2624 ,@(if (featurep 'xemacs) nil
2625 '(:visible (memq message-cite-function
2626 '(message-cite-original-without-signature
2627 message-cite-original))))
2628 :style toggle
2629 :selected (eq message-cite-function
2630 'message-cite-original-without-signature)
2631 ,@(if (featurep 'xemacs) nil
2632 '(:help "Strip signature from cited article when replying."))]
23f87bed
MB
2633 ;;("Draft"
2634 ;;["Send" gnus-summary-send-draft t]
2635 ;;["Send bounced" gnus-resend-bounced-mail t])
2636 ))
2637
2638 (cond
2639 ((not (keymapp gnus-summary-post-menu))
2640 (setq gnus-article-post-menu gnus-summary-post-menu))
2641 ((not gnus-article-post-menu)
2642 ;; Don't share post menu.
2643 (setq gnus-article-post-menu
2644 (copy-keymap gnus-summary-post-menu))))
2645 (define-key gnus-article-mode-map [menu-bar post]
2646 (cons "Post" gnus-article-post-menu))
eec82323
LMI
2647
2648 (easy-menu-define
23f87bed
MB
2649 gnus-summary-misc-menu gnus-summary-mode-map ""
2650 `("Gnus"
2651 ("Mark Read"
2652 ["Mark as read" gnus-summary-mark-as-read-forward t]
2653 ["Mark same subject and select"
2654 gnus-summary-kill-same-subject-and-select t]
2655 ["Mark same subject" gnus-summary-kill-same-subject t]
2656 ["Catchup" gnus-summary-catchup
2657 ,@(if (featurep 'xemacs) '(t)
2658 '(:help "Mark unread articles in this group as read"))]
2659 ["Catchup all" gnus-summary-catchup-all t]
2660 ["Catchup to here" gnus-summary-catchup-to-here t]
2661 ["Catchup from here" gnus-summary-catchup-from-here t]
2662 ["Catchup region" gnus-summary-mark-region-as-read
2663 (gnus-mark-active-p)]
2664 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2665 ("Mark Various"
2666 ["Tick" gnus-summary-tick-article-forward t]
2667 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2668 ["Remove marks" gnus-summary-clear-mark-forward t]
2669 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2670 ["Set bookmark" gnus-summary-set-bookmark t]
2671 ["Remove bookmark" gnus-summary-remove-bookmark t])
2672 ("Limit to"
2673 ["Marks..." gnus-summary-limit-to-marks t]
2674 ["Subject..." gnus-summary-limit-to-subject t]
2675 ["Author..." gnus-summary-limit-to-author t]
01c52d31
MB
2676 ["Recipient..." gnus-summary-limit-to-recipient t]
2677 ["Address..." gnus-summary-limit-to-address t]
23f87bed
MB
2678 ["Age..." gnus-summary-limit-to-age t]
2679 ["Extra..." gnus-summary-limit-to-extra t]
2680 ["Score..." gnus-summary-limit-to-score t]
2681 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2682 ["Unread" gnus-summary-limit-to-unread t]
2683 ["Unseen" gnus-summary-limit-to-unseen t]
01c52d31
MB
2684 ["Singletons" gnus-summary-limit-to-singletons t]
2685 ["Replied" gnus-summary-limit-to-replied t]
23f87bed 2686 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
996aa8c1 2687 ["Next or process marked articles" gnus-summary-limit-to-articles t]
23f87bed
MB
2688 ["Pop limit" gnus-summary-pop-limit t]
2689 ["Show dormant" gnus-summary-limit-include-dormant t]
2690 ["Hide childless dormant"
2691 gnus-summary-limit-exclude-childless-dormant t]
2692 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2693 ["Hide marked" gnus-summary-limit-exclude-marks t]
2694 ["Show expunged" gnus-summary-limit-include-expunged t])
2695 ("Process Mark"
2696 ["Set mark" gnus-summary-mark-as-processable t]
2697 ["Remove mark" gnus-summary-unmark-as-processable t]
2698 ["Remove all marks" gnus-summary-unmark-all-processable t]
01c52d31 2699 ["Invert marks" gnus-uu-invert-processable t]
23f87bed
MB
2700 ["Mark above" gnus-uu-mark-over t]
2701 ["Mark series" gnus-uu-mark-series t]
2702 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2703 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2704 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2705 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2706 ["Mark all" gnus-uu-mark-all t]
2707 ["Mark buffer" gnus-uu-mark-buffer t]
2708 ["Mark sparse" gnus-uu-mark-sparse t]
2709 ["Mark thread" gnus-uu-mark-thread t]
2710 ["Unmark thread" gnus-uu-unmark-thread t]
2711 ("Process Mark Sets"
2712 ["Kill" gnus-summary-kill-process-mark t]
2713 ["Yank" gnus-summary-yank-process-mark
2714 gnus-newsgroup-process-stack]
2715 ["Save" gnus-summary-save-process-mark t]
2716 ["Run command on marked..." gnus-summary-universal-argument t]))
ec7995fa 2717 ("Registry Marks")
23f87bed
MB
2718 ("Scroll article"
2719 ["Page forward" gnus-summary-next-page
2720 ,@(if (featurep 'xemacs) '(t)
2721 '(:help "Show next page of article"))]
2722 ["Page backward" gnus-summary-prev-page
2723 ,@(if (featurep 'xemacs) '(t)
2724 '(:help "Show previous page of article"))]
2725 ["Line forward" gnus-summary-scroll-up t])
2726 ("Move"
2727 ["Next unread article" gnus-summary-next-unread-article t]
2728 ["Previous unread article" gnus-summary-prev-unread-article t]
2729 ["Next article" gnus-summary-next-article t]
2730 ["Previous article" gnus-summary-prev-article t]
2731 ["Next unread subject" gnus-summary-next-unread-subject t]
2732 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2733 ["Next article same subject" gnus-summary-next-same-subject t]
2734 ["Previous article same subject" gnus-summary-prev-same-subject t]
2735 ["First unread article" gnus-summary-first-unread-article t]
2736 ["Best unread article" gnus-summary-best-unread-article t]
2737 ["Go to subject number..." gnus-summary-goto-subject t]
2738 ["Go to article number..." gnus-summary-goto-article t]
2739 ["Go to the last article" gnus-summary-goto-last-article t]
2740 ["Pop article off history" gnus-summary-pop-article t])
2741 ("Sort"
2742 ["Sort by number" gnus-summary-sort-by-number t]
6ecfe5c2 2743 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
23f87bed 2744 ["Sort by author" gnus-summary-sort-by-author t]
01c52d31 2745 ["Sort by recipient" gnus-summary-sort-by-recipient t]
23f87bed
MB
2746 ["Sort by subject" gnus-summary-sort-by-subject t]
2747 ["Sort by date" gnus-summary-sort-by-date t]
6ecfe5c2 2748 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
23f87bed
MB
2749 ["Sort by score" gnus-summary-sort-by-score t]
2750 ["Sort by lines" gnus-summary-sort-by-lines t]
2751 ["Sort by characters" gnus-summary-sort-by-chars t]
2752 ["Randomize" gnus-summary-sort-by-random t]
2753 ["Original sort" gnus-summary-sort-by-original t])
2754 ("Help"
23f87bed 2755 ["Describe group" gnus-summary-describe-group t]
23f87bed
MB
2756 ["Read manual" gnus-info-find-node t])
2757 ("Modes"
2758 ["Pick and read" gnus-pick-mode t]
2759 ["Binary" gnus-binary-mode t])
2760 ("Regeneration"
2761 ["Regenerate" gnus-summary-prepare t]
2762 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2763 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
01c52d31 2764 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
23f87bed
MB
2765 ["Toggle threading" gnus-summary-toggle-threads t])
2766 ["See old articles" gnus-summary-insert-old-articles t]
2767 ["See new articles" gnus-summary-insert-new-articles t]
2768 ["Filter articles..." gnus-summary-execute-command t]
2769 ["Run command on articles..." gnus-summary-universal-argument t]
2770 ["Search articles forward..." gnus-summary-search-article-forward t]
2771 ["Search articles backward..." gnus-summary-search-article-backward t]
2772 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2773 ["Expand window" gnus-summary-expand-window t]
2774 ["Expire expirable articles" gnus-summary-expire-articles
2775 (gnus-check-backend-function
2776 'request-expire-articles gnus-newsgroup-name)]
2777 ["Edit local kill file" gnus-summary-edit-local-kill t]
2778 ["Edit main kill file" gnus-summary-edit-global-kill t]
2779 ["Edit group parameters" gnus-summary-edit-parameters t]
2780 ["Customize group parameters" gnus-summary-customize-parameters t]
2781 ["Send a bug report" gnus-bug t]
2782 ("Exit"
2783 ["Catchup and exit" gnus-summary-catchup-and-exit
2784 ,@(if (featurep 'xemacs) '(t)
2785 '(:help "Mark unread articles in this group as read, then exit"))]
2786 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2787 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
01c52d31 2788 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
23f87bed
MB
2789 ["Exit group" gnus-summary-exit
2790 ,@(if (featurep 'xemacs) '(t)
2791 '(:help "Exit current group, return to group selection mode"))]
2792 ["Exit group without updating" gnus-summary-exit-no-update t]
2793 ["Exit and goto next group" gnus-summary-next-group t]
2794 ["Exit and goto prev group" gnus-summary-prev-group t]
2795 ["Reselect group" gnus-summary-reselect-current-group t]
2796 ["Rescan group" gnus-summary-rescan-group t]
2797 ["Update dribble" gnus-summary-save-newsrc t])))
eec82323 2798
6748645f 2799 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323 2800
60bd5589
DL
2801(defvar gnus-summary-tool-bar-map nil)
2802
18c06a99
RS
2803;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2804;; affect _new_ message buffers. We might add a function that walks thru all
2805;; summary-mode buffers and force the update.
2806(defun gnus-summary-tool-bar-update (&optional symbol value)
2807 "Update summary mode toolbar.
2808Setter function for custom variables."
2809 (setq-default gnus-summary-tool-bar-map nil)
2810 (when symbol
2811 ;; When used as ":set" function:
2812 (set-default symbol value))
2813 (when (gnus-buffer-live-p gnus-summary-buffer)
2814 (with-current-buffer gnus-summary-buffer
2815 (gnus-summary-make-tool-bar))))
2816
2817(defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2818 'gnus-summary-tool-bar-gnome
2819 'gnus-summary-tool-bar-retro)
2820 "Specifies the Gnus summary tool bar.
2821
2822It can be either a list or a symbol refering to a list. See
2823`gmm-tool-bar-from-list' for the format of the list. The
2824default key map is `gnus-summary-mode-map'.
2825
2826Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2827`gnus-summary-tool-bar-retro'."
2828 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2829 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2830 (repeat :tag "User defined list" gmm-tool-bar-item)
2831 (symbol))
330f707b 2832 :version "23.1" ;; No Gnus
18c06a99
RS
2833 :initialize 'custom-initialize-default
2834 :set 'gnus-summary-tool-bar-update
2835 :group 'gnus-summary)
2836
2837(defcustom gnus-summary-tool-bar-gnome
2838 '((gnus-summary-post-news "mail/compose" nil)
2839 (gnus-summary-insert-new-articles "mail/inbox" nil
2840 :visible (or (not gnus-agent)
2841 gnus-plugged))
2842 (gnus-summary-reply-with-original "mail/reply")
2843 (gnus-summary-reply "mail/reply" nil :visible nil)
2844 (gnus-summary-followup-with-original "mail/reply-all")
2845 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2846 (gnus-summary-mail-forward "mail/forward")
2847 (gnus-summary-save-article "mail/save")
2848 (gnus-summary-search-article-forward "search" nil :visible nil)
2849 (gnus-summary-print-article "print")
2850 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2851 ;; Some new commands that may need more suitable icons:
2852 (gnus-summary-save-newsrc "save" nil :visible nil)
2853 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2854 (gnus-summary-prev-article "left-arrow")
2855 (gnus-summary-next-article "right-arrow")
2856 (gnus-summary-next-page "next-page")
2857 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2858 ;;
2859 ;; Maybe some sort-by-... could be added:
2860 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2861 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2862 (gnus-summary-mark-as-expirable
2863 "delete" nil
2864 :visible (gnus-check-backend-function 'request-expire-articles
2865 gnus-newsgroup-name))
2866 (gnus-summary-mark-as-spam
2867 "mail/spam" t
2868 :visible (and (fboundp 'spam-group-ham-contents-p)
2869 (spam-group-ham-contents-p gnus-newsgroup-name))
2870 :help "Mark as spam")
2871 (gnus-summary-mark-as-read-forward
2872 "mail/not-spam" nil
2873 :visible (and (fboundp 'spam-group-spam-contents-p)
2874 (spam-group-spam-contents-p gnus-newsgroup-name)))
2875 ;;
2876 (gnus-summary-exit "exit")
2877 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2878 (gnus-info-find-node "help"))
2879 "List of functions for the summary tool bar (GNOME style).
2880
2881See `gmm-tool-bar-from-list' for the format of the list."
2882 :type '(repeat gmm-tool-bar-item)
330f707b 2883 :version "23.1" ;; No Gnus
18c06a99
RS
2884 :initialize 'custom-initialize-default
2885 :set 'gnus-summary-tool-bar-update
2886 :group 'gnus-summary)
2887
2888(defcustom gnus-summary-tool-bar-retro
2889 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2890 (gnus-summary-next-unread-article "gnus/next-ur")
2891 (gnus-summary-post-news "gnus/post")
2892 (gnus-summary-followup-with-original "gnus/fuwo")
2893 (gnus-summary-followup "gnus/followup")
2894 (gnus-summary-reply-with-original "gnus/reply-wo")
2895 (gnus-summary-reply "gnus/reply")
2896 (gnus-summary-caesar-message "gnus/rot13")
2897 (gnus-uu-decode-uu "gnus/uu-decode")
2898 (gnus-summary-save-article-file "gnus/save-aif")
2899 (gnus-summary-save-article "gnus/save-art")
2900 (gnus-uu-post-news "gnus/uu-post")
2901 (gnus-summary-catchup "gnus/catchup")
2902 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2903 (gnus-summary-exit "gnus/exit-summ")
2904 ;; Some new command that may need more suitable icons:
2905 (gnus-summary-print-article "gnus/print" nil :visible nil)
2906 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2907 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2908 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2909 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2910 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2911 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2912 ;;
2913 (gnus-info-find-node "gnus/help" nil :visible nil))
2914 "List of functions for the summary tool bar (retro look).
2915
2916See `gmm-tool-bar-from-list' for the format of the list."
2917 :type '(repeat gmm-tool-bar-item)
330f707b 2918 :version "23.1" ;; No Gnus
18c06a99
RS
2919 :initialize 'custom-initialize-default
2920 :set 'gnus-summary-tool-bar-update
2921 :group 'gnus-summary)
2922
2923(defcustom gnus-summary-tool-bar-zap-list t
2924 "List of icon items from the global tool bar.
2925These items are not displayed in the Gnus summary mode tool bar.
2926
2927See `gmm-tool-bar-from-list' for the format of the list."
2928 :type 'gmm-tool-bar-zap-list
330f707b 2929 :version "23.1" ;; No Gnus
18c06a99
RS
2930 :initialize 'custom-initialize-default
2931 :set 'gnus-summary-tool-bar-update
2932 :group 'gnus-summary)
2933
2934(defvar image-load-path)
f654fa04 2935(defvar tool-bar-map)
18c06a99
RS
2936
2937(defun gnus-summary-make-tool-bar (&optional force)
2938 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2939When FORCE, rebuild the tool bar."
2940 (when (and (not (featurep 'xemacs))
2941 (boundp 'tool-bar-mode)
2942 tool-bar-mode
2943 (or (not gnus-summary-tool-bar-map) force))
2944 (let* ((load-path
2945 (gmm-image-load-path-for-library "gnus"
2946 "mail/save.xpm"
2947 nil t))
2948 (image-load-path (cons (car load-path)
2949 (when (boundp 'image-load-path)
2950 image-load-path)))
2951 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2952 gnus-summary-tool-bar-zap-list
2953 'gnus-summary-mode-map)))
2954 (when map
2955 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2956 ;; uses it's value.
2957 (setq gnus-summary-tool-bar-map map))))
2958 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
60bd5589 2959
eec82323
LMI
2960(defun gnus-score-set-default (var value)
2961 "A version of set that updates the GNU Emacs menu-bar."
2962 (set var value)
2963 ;; It is the message that forces the active status to be updated.
2964 (message ""))
2965
2966(defun gnus-make-score-map (type)
2967 "Make a summary score map of type TYPE."
2968 (if t
2969 nil
2970 (let ((headers '(("author" "from" string)
2971 ("subject" "subject" string)
2972 ("article body" "body" string)
2973 ("article head" "head" string)
2974 ("xref" "xref" string)
16409b0b 2975 ("extra header" "extra" string)
eec82323
LMI
2976 ("lines" "lines" number)
2977 ("followups to author" "followup" string)))
2978 (types '((number ("less than" <)
2979 ("greater than" >)
2980 ("equal" =))
2981 (string ("substring" s)
2982 ("exact string" e)
2983 ("fuzzy string" f)
2984 ("regexp" r))))
2985 (perms '(("temporary" (current-time-string))
2986 ("permanent" nil)
2987 ("immediate" now)))
2988 header)
2989 (list
2990 (apply
2991 'nconc
2992 (list
2993 (if (eq type 'lower)
2994 "Lower score"
2995 "Increase score"))
2996 (let (outh)
2997 (while headers
2998 (setq header (car headers))
2999 (setq outh
3000 (cons
3001 (apply
3002 'nconc
3003 (list (car header))
3004 (let ((ts (cdr (assoc (nth 2 header) types)))
3005 outt)
3006 (while ts
3007 (setq outt
3008 (cons
3009 (apply
3010 'nconc
3011 (list (caar ts))
3012 (let ((ps perms)
3013 outp)
3014 (while ps
3015 (setq outp
3016 (cons
3017 (vector
3018 (caar ps)
3019 (list
3020 'gnus-summary-score-entry
3021 (nth 1 header)
3022 (if (or (string= (nth 1 header)
3023 "head")
3024 (string= (nth 1 header)
3025 "body"))
3026 ""
3027 (list 'gnus-summary-header
3028 (nth 1 header)))
3029 (list 'quote (nth 1 (car ts)))
16409b0b
GM
3030 (list 'gnus-score-delta-default
3031 nil)
eec82323
LMI
3032 (nth 1 (car ps))
3033 t)
3034 t)
3035 outp))
3036 (setq ps (cdr ps)))
3037 (list (nreverse outp))))
3038 outt))
3039 (setq ts (cdr ts)))
3040 (list (nreverse outt))))
3041 outh))
3042 (setq headers (cdr headers)))
3043 (list (nreverse outh))))))))
3044
704f1663
GM
3045
3046(declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
398a825b 3047(defvar bookmark-make-record-function)
eec82323
LMI
3048\f
3049
3050(defun gnus-summary-mode (&optional group)
3051 "Major mode for reading articles.
3052
3053All normal editing commands are switched off.
3054\\<gnus-summary-mode-map>
3055Each line in this buffer represents one article. To read an
3056article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3057and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3058respectively.
3059
3060You can also post articles and send mail from this buffer. To
23f87bed 3061follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
eec82323
LMI
3062of an article, type `\\[gnus-summary-reply]'.
3063
3064There are approx. one gazillion commands you can execute in this
3065buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3066
3067The following commands are available:
3068
3069\\{gnus-summary-mode-map}"
3070 (interactive)
eec82323 3071 (kill-all-local-variables)
01c52d31
MB
3072 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3073 (gnus-summary-make-local-variables))
3074 (gnus-summary-make-local-variables)
3075 (setq gnus-newsgroup-name group)
60bd5589
DL
3076 (when (gnus-visual-p 'summary-menu 'menu)
3077 (gnus-summary-make-menu-bar)
3078 (gnus-summary-make-tool-bar))
eec82323
LMI
3079 (gnus-make-thread-indent-array)
3080 (gnus-simplify-mode-line)
3081 (setq major-mode 'gnus-summary-mode)
3082 (setq mode-name "Summary")
eec82323 3083 (use-local-map gnus-summary-mode-map)
16409b0b 3084 (buffer-disable-undo)
01c52d31
MB
3085 (setq buffer-read-only t ;Disable modification
3086 show-trailing-whitespace nil)
eec82323 3087 (setq truncate-lines t)
9bfd9a76 3088 (add-to-invisibility-spec '(gnus-sum . t))
eec82323
LMI
3089 (gnus-summary-set-display-table)
3090 (gnus-set-default-directory)
eec82323
LMI
3091 (make-local-variable 'gnus-summary-line-format)
3092 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
3093 (make-local-variable 'gnus-summary-dummy-line-format)
3094 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323 3095 (make-local-variable 'gnus-summary-mark-positions)
23f87bed 3096 (gnus-make-local-hook 'pre-command-hook)
6748645f 3097 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
cfcd5c91 3098 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
23f87bed 3099 (turn-on-gnus-mailing-list-mode)
87545352 3100 (mm-enable-multibyte)
45be326a
TV
3101 (set (make-local-variable 'bookmark-make-record-function)
3102 'gnus-summary-bookmark-make-record)
eec82323
LMI
3103 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3104 (gnus-update-summary-mark-positions))
3105
3106(defun gnus-summary-make-local-variables ()
3107 "Make all the local summary buffer variables."
16409b0b
GM
3108 (let (global)
3109 (dolist (local gnus-summary-local-variables)
eec82323
LMI
3110 (if (consp local)
3111 (progn
3112 (if (eq (cdr local) 'global)
3113 ;; Copy the global value of the variable.
3114 (setq global (symbol-value (car local)))
3115 ;; Use the value from the list.
3116 (setq global (eval (cdr local))))
16409b0b 3117 (set (make-local-variable (car local)) global))
eec82323 3118 ;; Simple nil-valued local variable.
16409b0b 3119 (set (make-local-variable local) nil)))))
eec82323 3120
eec82323
LMI
3121;; Summary data functions.
3122
3123(defmacro gnus-data-number (data)
3124 `(car ,data))
3125
3126(defmacro gnus-data-set-number (data number)
3127 `(setcar ,data ,number))
3128
3129(defmacro gnus-data-mark (data)
3130 `(nth 1 ,data))
3131
3132(defmacro gnus-data-set-mark (data mark)
3133 `(setcar (nthcdr 1 ,data) ,mark))
3134
3135(defmacro gnus-data-pos (data)
3136 `(nth 2 ,data))
3137
3138(defmacro gnus-data-set-pos (data pos)
3139 `(setcar (nthcdr 2 ,data) ,pos))
3140
3141(defmacro gnus-data-header (data)
3142 `(nth 3 ,data))
3143
3144(defmacro gnus-data-set-header (data header)
3145 `(setf (nth 3 ,data) ,header))
3146
3147(defmacro gnus-data-level (data)
3148 `(nth 4 ,data))
3149
3150(defmacro gnus-data-unread-p (data)
3151 `(= (nth 1 ,data) gnus-unread-mark))
3152
3153(defmacro gnus-data-read-p (data)
3154 `(/= (nth 1 ,data) gnus-unread-mark))
3155
3156(defmacro gnus-data-pseudo-p (data)
3157 `(consp (nth 3 ,data)))
3158
3159(defmacro gnus-data-find (number)
3160 `(assq ,number gnus-newsgroup-data))
3161
3162(defmacro gnus-data-find-list (number &optional data)
3163 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3164 (memq (assq ,number bdata)
3165 bdata)))
3166
3167(defmacro gnus-data-make (number mark pos header level)
3168 `(list ,number ,mark ,pos ,header ,level))
3169
3170(defun gnus-data-enter (after-article number mark pos header level offset)
3171 (let ((data (gnus-data-find-list after-article)))
3172 (unless data
3173 (error "No such article: %d" after-article))
3174 (setcdr data (cons (gnus-data-make number mark pos header level)
3175 (cdr data)))
3176 (setq gnus-newsgroup-data-reverse nil)
3177 (gnus-data-update-list (cddr data) offset)))
3178
3179(defun gnus-data-enter-list (after-article list &optional offset)
3180 (when list
3181 (let ((data (and after-article (gnus-data-find-list after-article)))
3182 (ilist list))
6748645f
LMI
3183 (if (not (or data
3184 after-article))
3185 (let ((odata gnus-newsgroup-data))
3186 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 3187 (when offset
6748645f 3188 (gnus-data-update-list odata offset)))
01c52d31 3189 ;; Find the last element in the list to be spliced into the main
6748645f 3190 ;; list.
01c52d31 3191 (setq list (last list))
6748645f
LMI
3192 (if (not data)
3193 (progn
3194 (setcdr list gnus-newsgroup-data)
3195 (setq gnus-newsgroup-data ilist)
3196 (when offset
3197 (gnus-data-update-list (cdr list) offset)))
3198 (setcdr list (cdr data))
3199 (setcdr data ilist)
3200 (when offset
3201 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
3202 (setq gnus-newsgroup-data-reverse nil))))
3203
3204(defun gnus-data-remove (article &optional offset)
3205 (let ((data gnus-newsgroup-data))
3206 (if (= (gnus-data-number (car data)) article)
3207 (progn
3208 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3209 gnus-newsgroup-data-reverse nil)
3210 (when offset
3211 (gnus-data-update-list gnus-newsgroup-data offset)))
3212 (while (cdr data)
3213 (when (= (gnus-data-number (cadr data)) article)
3214 (setcdr data (cddr data))
3215 (when offset
3216 (gnus-data-update-list (cdr data) offset))
3217 (setq data nil
3218 gnus-newsgroup-data-reverse nil))
3219 (setq data (cdr data))))))
3220
3221(defmacro gnus-data-list (backward)
3222 `(if ,backward
3223 (or gnus-newsgroup-data-reverse
3224 (setq gnus-newsgroup-data-reverse
3225 (reverse gnus-newsgroup-data)))
3226 gnus-newsgroup-data))
3227
3228(defun gnus-data-update-list (data offset)
3229 "Add OFFSET to the POS of all data entries in DATA."
6748645f 3230 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
3231 (while data
3232 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3233 (setq data (cdr data))))
3234
eec82323
LMI
3235(defun gnus-summary-article-pseudo-p (article)
3236 "Say whether this article is a pseudo article or not."
3237 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3238
3239(defmacro gnus-summary-article-sparse-p (article)
3240 "Say whether this article is a sparse article or not."
a8151ef7 3241 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
3242
3243(defmacro gnus-summary-article-ancient-p (article)
3244 "Say whether this article is a sparse article or not."
3245 `(memq ,article gnus-newsgroup-ancient))
3246
3247(defun gnus-article-parent-p (number)
3248 "Say whether this article is a parent or not."
3249 (let ((data (gnus-data-find-list number)))
23f87bed 3250 (and (cdr data) ; There has to be an article after...
eec82323
LMI
3251 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3252 (gnus-data-level (nth 1 data))))))
3253
3254(defun gnus-article-children (number)
3255 "Return a list of all children to NUMBER."
3256 (let* ((data (gnus-data-find-list number))
3257 (level (gnus-data-level (car data)))
3258 children)
3259 (setq data (cdr data))
3260 (while (and data
3261 (= (gnus-data-level (car data)) (1+ level)))
3262 (push (gnus-data-number (car data)) children)
3263 (setq data (cdr data)))
3264 children))
3265
3266(defmacro gnus-summary-skip-intangible ()
3267 "If the current article is intangible, then jump to a different article."
3268 '(let ((to (get-text-property (point) 'gnus-intangible)))
3269 (and to (gnus-summary-goto-subject to))))
3270
3271(defmacro gnus-summary-article-intangible-p ()
3272 "Say whether this article is intangible or not."
3273 '(get-text-property (point) 'gnus-intangible))
3274
3275(defun gnus-article-read-p (article)
3276 "Say whether ARTICLE is read or not."
3277 (not (or (memq article gnus-newsgroup-marked)
23f87bed 3278 (memq article gnus-newsgroup-spam-marked)
eec82323
LMI
3279 (memq article gnus-newsgroup-unreads)
3280 (memq article gnus-newsgroup-unselected)
3281 (memq article gnus-newsgroup-dormant))))
3282
3283;; Some summary mode macros.
3284
3285(defmacro gnus-summary-article-number ()
3286 "The article number of the article on the current line.
8f688cb0 3287If there isn't an article number here, then we return the current
eec82323
LMI
3288article number."
3289 '(progn
3290 (gnus-summary-skip-intangible)
3291 (or (get-text-property (point) 'gnus-number)
3292 (gnus-summary-last-subject))))
3293
3294(defmacro gnus-summary-article-header (&optional number)
6748645f 3295 "Return the header of article NUMBER."
eec82323
LMI
3296 `(gnus-data-header (gnus-data-find
3297 ,(or number '(gnus-summary-article-number)))))
3298
3299(defmacro gnus-summary-thread-level (&optional number)
6748645f 3300 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
3301 `(if (and (eq gnus-summary-make-false-root 'dummy)
3302 (get-text-property (point) 'gnus-intangible))
3303 0
3304 (gnus-data-level (gnus-data-find
3305 ,(or number '(gnus-summary-article-number))))))
3306
3307(defmacro gnus-summary-article-mark (&optional number)
6748645f 3308 "Return the mark of article NUMBER."
eec82323
LMI
3309 `(gnus-data-mark (gnus-data-find
3310 ,(or number '(gnus-summary-article-number)))))
3311
3312(defmacro gnus-summary-article-pos (&optional number)
6748645f 3313 "Return the position of the line of article NUMBER."
eec82323
LMI
3314 `(gnus-data-pos (gnus-data-find
3315 ,(or number '(gnus-summary-article-number)))))
3316
3317(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3318(defmacro gnus-summary-article-subject (&optional number)
3319 "Return current subject string or nil if nothing."
3320 `(let ((headers
3321 ,(if number
3322 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3323 '(gnus-data-header (assq (gnus-summary-article-number)
3324 gnus-newsgroup-data)))))
3325 (and headers
3326 (vectorp headers)
3327 (mail-header-subject headers))))
3328
3329(defmacro gnus-summary-article-score (&optional number)
3330 "Return current article score."
3331 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3332 gnus-newsgroup-scored))
3333 gnus-summary-default-score 0))
3334
3335(defun gnus-summary-article-children (&optional number)
6748645f 3336 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
3337 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3338 (level (gnus-data-level (car data)))
3339 l children)
3340 (while (and (setq data (cdr data))
3341 (> (setq l (gnus-data-level (car data))) level))
3342 (and (= (1+ level) l)
3343 (push (gnus-data-number (car data))
3344 children)))
3345 (nreverse children)))
3346
3347(defun gnus-summary-article-parent (&optional number)
6748645f 3348 "Return the article number of the parent of article NUMBER."
eec82323
LMI
3349 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3350 (gnus-data-list t)))
3351 (level (gnus-data-level (car data))))
3352 (if (zerop level)
3353 () ; This is a root.
3354 ;; We search until we find an article with a level less than
3355 ;; this one. That function has to be the parent.
3356 (while (and (setq data (cdr data))
3357 (not (< (gnus-data-level (car data)) level))))
3358 (and data (gnus-data-number (car data))))))
3359
3360(defun gnus-unread-mark-p (mark)
3361 "Say whether MARK is the unread mark."
3362 (= mark gnus-unread-mark))
3363
3364(defun gnus-read-mark-p (mark)
3365 "Say whether MARK is one of the marks that mark as read.
3366This is all marks except unread, ticked, dormant, and expirable."
3367 (not (or (= mark gnus-unread-mark)
3368 (= mark gnus-ticked-mark)
23f87bed 3369 (= mark gnus-spam-mark)
eec82323
LMI
3370 (= mark gnus-dormant-mark)
3371 (= mark gnus-expirable-mark))))
3372
3373(defmacro gnus-article-mark (number)
6748645f
LMI
3374 "Return the MARK of article NUMBER.
3375This macro should only be used when computing the mark the \"first\"
3376time; i.e., when generating the summary lines. After that,
3377`gnus-summary-article-mark' should be used to examine the
3378marks of articles."
eec82323 3379 `(cond
6748645f 3380 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
6748645f 3381 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
3382 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3383 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
23f87bed 3384 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
eec82323
LMI
3385 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3386 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3387 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3388 gnus-ancient-mark))))
3389
3390;; Saving hidden threads.
3391
eec82323
LMI
3392(defmacro gnus-save-hidden-threads (&rest forms)
3393 "Save hidden threads, eval FORMS, and restore the hidden threads."
3394 (let ((config (make-symbol "config")))
3395 `(let ((,config (gnus-hidden-threads-configuration)))
3396 (unwind-protect
3397 (save-excursion
3398 ,@forms)
3399 (gnus-restore-hidden-threads-configuration ,config)))))
23f87bed
MB
3400(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3401(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
eec82323 3402
107ecebb
AS
3403(defun gnus-data-compute-positions ()
3404 "Compute the positions of all articles."
3405 (setq gnus-newsgroup-data-reverse nil)
3406 (let ((data gnus-newsgroup-data))
3407 (save-excursion
3408 (gnus-save-hidden-threads
3409 (gnus-summary-show-all-threads)
3410 (goto-char (point-min))
3411 (while data
3412 (while (get-text-property (point) 'gnus-intangible)
3413 (forward-line 1))
3414 (gnus-data-set-pos (car data) (+ (point) 3))
3415 (setq data (cdr data))
3416 (forward-line 1))))))
3417
16409b0b
GM
3418(defun gnus-hidden-threads-configuration ()
3419 "Return the current hidden threads configuration."
3420 (save-excursion
3421 (let (config)
3422 (goto-char (point-min))
62a83cc8
KY
3423 (while (not (eobp))
3424 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3425 (push (save-excursion (forward-line 0) (point)) config))
3426 (forward-line 1))
16409b0b
GM
3427 config)))
3428
3429(defun gnus-restore-hidden-threads-configuration (config)
3430 "Restore hidden threads configuration from CONFIG."
3431 (save-excursion
c7a91ce1 3432 (let (point (inhibit-read-only t))
16409b0b 3433 (while (setq point (pop config))
62a83cc8
KY
3434 (goto-char point)
3435 (gnus-summary-hide-thread)))))
16409b0b 3436
eec82323
LMI
3437;; Various summary mode internalish functions.
3438
3439(defun gnus-mouse-pick-article (e)
3440 (interactive "e")
3441 (mouse-set-point e)
3442 (gnus-summary-next-page nil t))
3443
3444(defun gnus-summary-set-display-table ()
16409b0b
GM
3445 "Change the display table.
3446Odd characters have a tendency to mess
3447up nicely formatted displays - we make all possible glyphs
3448display only a single character."
eec82323
LMI
3449
3450 ;; We start from the standard display table, if any.
3451 (let ((table (or (copy-sequence standard-display-table)
3452 (make-display-table)))
3453 (i 32))
3454 ;; Nix out all the control chars...
3455 (while (>= (setq i (1- i)) 0)
2b968687 3456 (gnus-put-display-table i [??] table))
23f87bed 3457 ;; ... but not newline and cr, of course. (cr is necessary for the
eec82323 3458 ;; selective display).
2b968687
MB
3459 (gnus-put-display-table ?\n nil table)
3460 (gnus-put-display-table ?\r nil table)
6748645f 3461 ;; We keep TAB as well.
2b968687 3462 (gnus-put-display-table ?\t nil table)
719120ef 3463 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
fe62aacc 3464 ;; Emacs 23 (unicode), that are not set already.
719120ef
MB
3465 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3466 160
3467 256)))
eec82323
LMI
3468 (while (>= (setq i (1- i)) 127)
3469 ;; Only modify if the entry is nil.
2b968687
MB
3470 (unless (gnus-get-display-table i table)
3471 (gnus-put-display-table i [??] table))))
eec82323
LMI
3472 (setq buffer-display-table table)))
3473
23f87bed
MB
3474(defun gnus-summary-set-article-display-arrow (pos)
3475 "Update the overlay arrow to point to line at position POS."
e3e955fe
MB
3476 (when gnus-summary-display-arrow
3477 (make-local-variable 'overlay-arrow-position)
3478 (make-local-variable 'overlay-arrow-string)
23f87bed
MB
3479 (save-excursion
3480 (goto-char pos)
3481 (beginning-of-line)
3482 (unless overlay-arrow-position
3483 (setq overlay-arrow-position (make-marker)))
3484 (setq overlay-arrow-string "=>"
3485 overlay-arrow-position (set-marker overlay-arrow-position
3486 (point)
3487 (current-buffer))))))
3488
eec82323
LMI
3489(defun gnus-summary-setup-buffer (group)
3490 "Initialize summary buffer."
23f87bed
MB
3491 (let ((buffer (gnus-summary-buffer-name group))
3492 (dead-name (concat "*Dead Summary "
3493 (gnus-group-decoded-name group) "*")))
3494 ;; If a dead summary buffer exists, we kill it.
3495 (when (gnus-buffer-live-p dead-name)
3496 (gnus-kill-buffer dead-name))
eec82323
LMI
3497 (if (get-buffer buffer)
3498 (progn
3499 (set-buffer buffer)
3500 (setq gnus-summary-buffer (current-buffer))
3501 (not gnus-newsgroup-prepared))
3502 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 3503 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323 3504 (gnus-summary-mode group)
01c52d31
MB
3505 (when (gnus-group-quit-config group)
3506 (set (make-local-variable 'gnus-single-article-buffer) nil))
3507 (make-local-variable 'gnus-article-buffer)
3508 (make-local-variable 'gnus-article-current)
3509 (make-local-variable 'gnus-original-article-buffer)
eec82323 3510 (setq gnus-newsgroup-name group)
23f87bed
MB
3511 ;; Set any local variables in the group parameters.
3512 (gnus-summary-set-local-parameters gnus-newsgroup-name)
eec82323
LMI
3513 t)))
3514
3515(defun gnus-set-global-variables ()
16409b0b
GM
3516 "Set the global equivalents of the buffer-local variables.
3517They are set to the latest values they had. These reflect the summary
3518buffer that was in action when the last article was fetched."
eec82323
LMI
3519 (when (eq major-mode 'gnus-summary-mode)
3520 (setq gnus-summary-buffer (current-buffer))
3521 (let ((name gnus-newsgroup-name)
3522 (marked gnus-newsgroup-marked)
23f87bed 3523 (spam gnus-newsgroup-spam-marked)
eec82323
LMI
3524 (unread gnus-newsgroup-unreads)
3525 (headers gnus-current-headers)
3526 (data gnus-newsgroup-data)
3527 (summary gnus-summary-buffer)
3528 (article-buffer gnus-article-buffer)
3529 (original gnus-original-article-buffer)
3530 (gac gnus-article-current)
3531 (reffed gnus-reffed-article-number)
16409b0b 3532 (score-file gnus-current-score-file)
23f87bed
MB
3533 (default-charset gnus-newsgroup-charset)
3534 vlist)
3535 (let ((locals gnus-newsgroup-variables))
3536 (while locals
3537 (if (consp (car locals))
3538 (push (eval (caar locals)) vlist)
3539 (push (eval (car locals)) vlist))
3540 (setq locals (cdr locals)))
3541 (setq vlist (nreverse vlist)))
01c52d31 3542 (with-current-buffer gnus-group-buffer
6748645f
LMI
3543 (setq gnus-newsgroup-name name
3544 gnus-newsgroup-marked marked
23f87bed 3545 gnus-newsgroup-spam-marked spam
6748645f
LMI
3546 gnus-newsgroup-unreads unread
3547 gnus-current-headers headers
3548 gnus-newsgroup-data data
3549 gnus-article-current gac
3550 gnus-summary-buffer summary
3551 gnus-article-buffer article-buffer
3552 gnus-original-article-buffer original
3553 gnus-reffed-article-number reffed
16409b0b
GM
3554 gnus-current-score-file score-file
3555 gnus-newsgroup-charset default-charset)
23f87bed
MB
3556 (let ((locals gnus-newsgroup-variables))
3557 (while locals
3558 (if (consp (car locals))
3559 (set (caar locals) (pop vlist))
3560 (set (car locals) (pop vlist)))
3561 (setq locals (cdr locals))))
eec82323
LMI
3562 ;; The article buffer also has local variables.
3563 (when (gnus-buffer-live-p gnus-article-buffer)
3564 (set-buffer gnus-article-buffer)
3565 (setq gnus-summary-buffer summary))))))
3566
3567(defun gnus-summary-article-unread-p (article)
3568 "Say whether ARTICLE is unread or not."
3569 (memq article gnus-newsgroup-unreads))
3570
3571(defun gnus-summary-first-article-p (&optional article)
3572 "Return whether ARTICLE is the first article in the buffer."
3573 (if (not (setq article (or article (gnus-summary-article-number))))
3574 nil
3575 (eq article (caar gnus-newsgroup-data))))
3576
3577(defun gnus-summary-last-article-p (&optional article)
3578 "Return whether ARTICLE is the last article in the buffer."
3579 (if (not (setq article (or article (gnus-summary-article-number))))
16409b0b
GM
3580 ;; All non-existent numbers are the last article. :-)
3581 t
eec82323
LMI
3582 (not (cdr (gnus-data-find-list article)))))
3583
4921bbdd
CY
3584(defun gnus-make-thread-indent-array (&optional n)
3585 (when (or n
3586 (progn (setq n 200) nil)
3587 (null gnus-thread-indent-array)
3588 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3589 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3590 gnus-thread-indent-array-level gnus-thread-indent-level)
3591 (while (>= n 0)
3592 (aset gnus-thread-indent-array n
6a30c01d 3593 (make-string (* n gnus-thread-indent-level) ? ))
4921bbdd 3594 (setq n (1- n)))))
eec82323
LMI
3595
3596(defun gnus-update-summary-mark-positions ()
3597 "Compute where the summary marks are to go."
3598 (save-excursion
6748645f 3599 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3600 (set-buffer gnus-summary-buffer))
5153a47a
MB
3601 (let ((spec gnus-summary-line-format-spec)
3602 pos)
eec82323
LMI
3603 (save-excursion
3604 (gnus-set-work-buffer)
5153a47a
MB
3605 (let ((gnus-tmp-unread ?Z)
3606 (gnus-replied-mark ?Z)
3607 (gnus-score-below-mark ?Z)
3608 (gnus-score-over-mark ?Z)
3609 (gnus-undownloaded-mark ?Z)
3610 (gnus-summary-line-format-spec spec)
54506618 3611 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3612 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3613 case-fold-search ignores)
3614 ;; Here, all marks are bound to Z.
3615 (gnus-summary-insert-line header
3616 0 nil t gnus-tmp-unread t nil "" nil 1)
3617 (goto-char (point-min))
3618 ;; Memorize the positions of the same characters as dummy marks.
3619 (while (re-search-forward "[A-D]" nil t)
3620 (push (point) ignores))
54506618 3621 (erase-buffer)
5153a47a
MB
3622 ;; We use A-D as dummy marks in order to know column positions
3623 ;; where marks should be inserted.
3624 (setq gnus-tmp-unread ?A
3625 gnus-replied-mark ?B
3626 gnus-score-below-mark ?C
3627 gnus-score-over-mark ?C
3628 gnus-undownloaded-mark ?D)
3629 (gnus-summary-insert-line header
3630 0 nil t gnus-tmp-unread t nil "" nil 1)
3631 ;; Ignore characters which aren't dummy marks.
3632 (dolist (p ignores)
3633 (delete-region (goto-char (1- p)) p)
3634 (insert ?Z))
eec82323 3635 (goto-char (point-min))
7c3bb5a5 3636 (setq pos (list (cons 'unread
5153a47a 3637 (and (search-forward "A" nil t)
7c3bb5a5 3638 (- (point) (point-min) 1)))))
eec82323 3639 (goto-char (point-min))
5153a47a 3640 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3641 (- (point) (point-min) 1)))
eec82323
LMI
3642 pos)
3643 (goto-char (point-min))
5153a47a 3644 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3645 (- (point) (point-min) 1)))
6748645f
LMI
3646 pos)
3647 (goto-char (point-min))
5153a47a 3648 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3649 (- (point) (point-min) 1)))
eec82323
LMI
3650 pos)))
3651 (setq gnus-summary-mark-positions pos))))
3652
3653(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3654 "Insert a dummy root in the summary buffer."
3655 (beginning-of-line)
3656 (gnus-add-text-properties
3657 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3658 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3659
23f87bed
MB
3660(defun gnus-summary-extract-address-component (from)
3661 (or (car (funcall gnus-extract-address-components from))
3662 from))
3663
3664(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3665 (let ((mail-parse-charset gnus-newsgroup-charset)
01c52d31 3666 (ignored-from-addresses (gnus-ignored-from-addresses))
23f87bed
MB
3667 ; Is it really necessary to do this next part for each summary line?
3668 ; Luckily, doesn't seem to slow things down much.
16409b0b 3669 (mail-parse-ignored-charsets
01c52d31
MB
3670 (with-current-buffer gnus-summary-buffer
3671 gnus-newsgroup-ignored-charsets)))
23f87bed 3672 (or
01c52d31
MB
3673 (and ignored-from-addresses
3674 (string-match ignored-from-addresses gnus-tmp-from)
23f87bed
MB
3675 (let ((extra-headers (mail-header-extra header))
3676 to
3677 newsgroups)
3678 (cond
3679 ((setq to (cdr (assq 'To extra-headers)))
01c52d31 3680 (concat gnus-summary-to-prefix
23f87bed
MB
3681 (inline
3682 (gnus-summary-extract-address-component
343d6628 3683 (funcall gnus-decode-encoded-address-function to)))))
01c52d31
MB
3684 ((setq newsgroups
3685 (or
3686 (cdr (assq 'Newsgroups extra-headers))
3687 (and
3688 (memq 'Newsgroups gnus-extra-headers)
3689 (eq (car (gnus-find-method-for-group
3690 gnus-newsgroup-name)) 'nntp)
3691 (gnus-group-real-name gnus-newsgroup-name))))
3692 (concat gnus-summary-newsgroup-prefix newsgroups)))))
23f87bed 3693 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3694
eec82323
LMI
3695(defun gnus-summary-insert-line (gnus-tmp-header
3696 gnus-tmp-level gnus-tmp-current
23f87bed 3697 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3698 gnus-tmp-expirable gnus-tmp-subject-or-nil
3699 &optional gnus-tmp-dummy gnus-tmp-score
3700 gnus-tmp-process)
4921bbdd
CY
3701 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3702 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3703 gnus-tmp-level)))
eec82323
LMI
3704 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3705 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3706 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3707 (gnus-tmp-score-char
3708 (if (or (null gnus-summary-default-score)
3709 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3710 gnus-summary-zcore-fuzz))
23f87bed 3711 ? ;Whitespace
eec82323
LMI
3712 (if (< gnus-tmp-score gnus-summary-default-score)
3713 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3714 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3715 (gnus-tmp-replied
3716 (cond (gnus-tmp-process gnus-process-mark)
3717 ((memq gnus-tmp-current gnus-newsgroup-cached)
3718 gnus-cached-mark)
3719 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3720 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3721 gnus-forwarded-mark)
eec82323
LMI
3722 ((memq gnus-tmp-current gnus-newsgroup-saved)
3723 gnus-saved-mark)
23f87bed
MB
3724 ((memq gnus-tmp-number gnus-newsgroup-recent)
3725 gnus-recent-mark)
3726 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3727 gnus-unseen-mark)
3728 (t gnus-no-mark)))
3729 (gnus-tmp-downloaded
3730 (cond (undownloaded
3731 gnus-undownloaded-mark)
3732 (gnus-newsgroup-agentized
3733 gnus-downloaded-mark)
3734 (t
3735 gnus-no-mark)))
eec82323
LMI
3736 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3737 (gnus-tmp-name
3738 (cond
3739 ((string-match "<[^>]+> *$" gnus-tmp-from)
3740 (let ((beg (match-beginning 0)))
23f87bed
MB
3741 (or (and (string-match "^\".+\"" gnus-tmp-from)
3742 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3743 (substring gnus-tmp-from 0 beg))))
3744 ((string-match "(.+)" gnus-tmp-from)
3745 (substring gnus-tmp-from
3746 (1+ (match-beginning 0)) (1- (match-end 0))))
3747 (t gnus-tmp-from)))
3748 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3749 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3750 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
c7a91ce1 3751 (inhibit-read-only t))
eec82323
LMI
3752 (when (string= gnus-tmp-name "")
3753 (setq gnus-tmp-name gnus-tmp-from))
3754 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3755 (setq gnus-tmp-lines -1))
3756 (if (= gnus-tmp-lines -1)
3757 (setq gnus-tmp-lines "?")
3758 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
64763fe3
MB
3759 (condition-case ()
3760 (gnus-put-text-property
3761 (point)
3762 (progn (eval gnus-summary-line-format-spec) (point))
3763 'gnus-number gnus-tmp-number)
3764 (error (gnus-message 5 "Error updating the summary line")))
eec82323
LMI
3765 (when (gnus-visual-p 'summary-highlight 'highlight)
3766 (forward-line -1)
a9ec34f4 3767 (gnus-summary-highlight-line)
6748645f 3768 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3769 (forward-line 1))))
3770
3771(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3772 "Update summary line after change."
eec82323
LMI
3773 (when (and gnus-summary-default-score
3774 (not gnus-summary-inhibit-highlight))
3775 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3776 (article (gnus-summary-article-number))
3777 (score (gnus-summary-article-score article)))
3778 (unless dont-update
3779 (if (and gnus-summary-mark-below
3780 (< (gnus-summary-article-score)
3781 gnus-summary-mark-below))
3782 ;; This article has a low score, so we mark it as read.
3783 (when (memq article gnus-newsgroup-unreads)
3784 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3785 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3786 ;; This article was previously marked as read on account
3787 ;; of a low score, but now it has risen, so we mark it as
3788 ;; unread.
3789 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3790 (gnus-summary-update-mark
3791 (if (or (null gnus-summary-default-score)
3792 (<= (abs (- score gnus-summary-default-score))
3793 gnus-summary-zcore-fuzz))
23f87bed 3794 ? ;Whitespace
eec82323
LMI
3795 (if (< score gnus-summary-default-score)
3796 gnus-score-below-mark gnus-score-over-mark))
3797 'score))
3798 ;; Do visual highlighting.
3799 (when (gnus-visual-p 'summary-highlight 'highlight)
a9ec34f4 3800 (gnus-summary-highlight-line)
6748645f 3801 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3802
3803(defvar gnus-tmp-new-adopts nil)
3804
3805(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3806 "Return the number of articles in THREAD.
3807This may be 0 in some cases -- if none of the articles in
3808the thread are to be displayed."
3809 (let* ((number
23f87bed 3810 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3811 (cond
3812 ((not (listp thread))
3813 1)
3814 ((and (consp thread) (cdr thread))
3815 (apply
3816 '+ 1 (mapcar
3817 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3818 ((null thread)
3819 1)
3820 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3821 1)
3822 (t 0))))
3823 (when (and level (zerop level) gnus-tmp-new-adopts)
3824 (incf number
3825 (apply '+ (mapcar
3826 'gnus-summary-number-of-articles-in-thread
3827 gnus-tmp-new-adopts))))
3828 (if char
3829 (if (> number 1) gnus-not-empty-thread-mark
3830 gnus-empty-thread-mark)
3831 number)))
3832
23f87bed
MB
3833(defsubst gnus-summary-line-message-size (head)
3834 "Return pretty-printed version of message size.
3835This function is intended to be used in
3836`gnus-summary-line-format-alist'."
3837 (let ((c (or (mail-header-chars head) -1)))
3838 (cond ((< c 0) "n/a") ; chars not available
3839 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3840 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3841 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3842 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3843
3844
eec82323
LMI
3845(defun gnus-summary-set-local-parameters (group)
3846 "Go through the local params of GROUP and set all variable specs in that list."
dab0271f
G
3847 (let ((vars '(quit-config active))) ; Ignore things that aren't
3848 ; really variables.
01c52d31 3849 (dolist (elem (gnus-group-find-parameter group))
eec82323
LMI
3850 (and (consp elem) ; Has to be a cons.
3851 (consp (cdr elem)) ; The cdr has to be a list.
3852 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3853 (not (memq (car elem) vars))
e3e955fe 3854 (ignore-errors
23f87bed 3855 (push (car elem) vars)
e3e955fe
MB
3856 ;; Variables like `gnus-show-threads' that are globally
3857 ;; bound, if used as group parameters, need to get to be
3858 ;; buffer-local, whereas just parameters like `gcc-self',
3859 ;; `timestamp', etc. should not be bound as variables.
3860 (if (boundp (car elem))
3861 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3862 (eval (nth 1 elem))))))))
eec82323
LMI
3863
3864(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3865 kill-buffer no-display backward
3866 select-articles)
eec82323
LMI
3867 "Start reading news in newsgroup GROUP.
3868If SHOW-ALL is non-nil, already read articles are also listed.
3869If NO-ARTICLE is non-nil, no article is selected initially.
3870If NO-DISPLAY, don't generate a summary buffer."
3871 (let (result)
3872 (while (and group
3873 (null (setq result
3874 (let ((gnus-auto-select-next nil))
6748645f
LMI
3875 (or (gnus-summary-read-group-1
3876 group show-all no-article
3877 kill-buffer no-display
3878 select-articles)
3879 (setq show-all nil
16409b0b 3880 select-articles nil)))))
eec82323
LMI
3881 (eq gnus-auto-select-next 'quietly))
3882 (set-buffer gnus-group-buffer)
6748645f
LMI
3883 ;; The entry function called above goes to the next
3884 ;; group automatically, so we go two groups back
3885 ;; if we are searching for the previous group.
3886 (when backward
3887 (gnus-group-prev-unread-group 2))
eec82323
LMI
3888 (if (not (equal group (gnus-group-group-name)))
3889 (setq group (gnus-group-group-name))
3890 (setq group nil)))
3891 result))
3892
3893(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3894 kill-buffer no-display
3895 &optional select-articles)
eec82323 3896 ;; Killed foreign groups can't be entered.
23f87bed
MB
3897 ;; (when (and (not (gnus-group-native-p group))
3898 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3899 ;; (error "Dead non-native groups can't be entered"))
3900 (gnus-message 5 "Retrieving newsgroup: %s..."
3901 (gnus-group-decoded-name group))
eec82323
LMI
3902 (let* ((new-group (gnus-summary-setup-buffer group))
3903 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3904 (did-select (and new-group (gnus-select-newsgroup
3905 group show-all select-articles))))
eec82323
LMI
3906 (cond
3907 ;; This summary buffer exists already, so we just select it.
3908 ((not new-group)
3909 (gnus-set-global-variables)
3910 (when kill-buffer
3911 (gnus-kill-or-deaden-summary kill-buffer))
3912 (gnus-configure-windows 'summary 'force)
3913 (gnus-set-mode-line 'summary)
3914 (gnus-summary-position-point)
3915 (message "")
3916 t)
3917 ;; We couldn't select this group.
3918 ((null did-select)
3919 (when (and (eq major-mode 'gnus-summary-mode)
3920 (not (equal (current-buffer) kill-buffer)))
3921 (kill-buffer (current-buffer))
3922 (if (not quit-config)
3923 (progn
6748645f
LMI
3924 ;; Update the info -- marks might need to be removed,
3925 ;; for instance.
3926 (gnus-summary-update-info)
eec82323
LMI
3927 (set-buffer gnus-group-buffer)
3928 (gnus-group-jump-to-group group)
3929 (gnus-group-next-unread-group 1))
3930 (gnus-handle-ephemeral-exit quit-config)))
23f87bed
MB
3931 (let ((grpinfo (gnus-get-info group)))
3932 (if (null (gnus-info-read grpinfo))
3933 (gnus-message 3 "Group %s contains no messages"
3934 (gnus-group-decoded-name group))
3935 (gnus-message 3 "Can't select group")))
eec82323
LMI
3936 nil)
3937 ;; The user did a `C-g' while prompting for number of articles,
3938 ;; so we exit this group.
3939 ((eq did-select 'quit)
3940 (and (eq major-mode 'gnus-summary-mode)
3941 (not (equal (current-buffer) kill-buffer))
3942 (kill-buffer (current-buffer)))
3943 (when kill-buffer
3944 (gnus-kill-or-deaden-summary kill-buffer))
3945 (if (not quit-config)
3946 (progn
3947 (set-buffer gnus-group-buffer)
3948 (gnus-group-jump-to-group group)
eec82323
LMI
3949 (gnus-configure-windows 'group 'force))
3950 (gnus-handle-ephemeral-exit quit-config))
3951 ;; Finally signal the quit.
3952 (signal 'quit nil))
3953 ;; The group was successfully selected.
3954 (t
3955 (gnus-set-global-variables)
3956 ;; Save the active value in effect when the group was entered.
3957 (setq gnus-newsgroup-active
3958 (gnus-copy-sequence
3959 (gnus-active gnus-newsgroup-name)))
9f2d52e7 3960 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
eec82323 3961 ;; You can change the summary buffer in some way with this hook.
6748645f 3962 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
3963 (when (memq 'summary (gnus-update-format-specifications
3964 nil 'summary 'summary-mode 'summary-dummy))
3965 ;; The format specification for the summary line was updated,
3966 ;; so we need to update the mark positions as well.
3967 (gnus-update-summary-mark-positions))
eec82323
LMI
3968 ;; Do score processing.
3969 (when gnus-use-scoring
3970 (gnus-possibly-score-headers))
3971 ;; Check whether to fill in the gaps in the threads.
3972 (when gnus-build-sparse-threads
3973 (gnus-build-sparse-threads))
3974 ;; Find the initial limit.
26c9afc3
MB
3975 (if show-all
3976 (let ((gnus-newsgroup-dormant nil))
eec82323 3977 (gnus-summary-initial-limit show-all))
26c9afc3 3978 (gnus-summary-initial-limit show-all))
eec82323
LMI
3979 ;; Generate the summary buffer.
3980 (unless no-display
3981 (gnus-summary-prepare))
3982 (when gnus-use-trees
3983 (gnus-tree-open group)
3984 (setq gnus-summary-highlight-line-function
3985 'gnus-tree-highlight-article))
3986 ;; If the summary buffer is empty, but there are some low-scored
3987 ;; articles or some excluded dormants, we include these in the
3988 ;; buffer.
3989 (when (and (zerop (buffer-size))
3990 (not no-display))
3991 (cond (gnus-newsgroup-dormant
3992 (gnus-summary-limit-include-dormant))
3993 ((and gnus-newsgroup-scored show-all)
3994 (gnus-summary-limit-include-expunged t))))
3995 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 3996 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
3997 (if (and (zerop (buffer-size))
3998 (not no-display))
3999 (progn
4000 ;; This newsgroup is empty.
4001 (gnus-summary-catchup-and-exit nil t)
4002 (gnus-message 6 "No unread news")
4003 (when kill-buffer
4004 (gnus-kill-or-deaden-summary kill-buffer))
4005 ;; Return nil from this function.
4006 nil)
4007 ;; Hide conversation thread subtrees. We cannot do this in
4008 ;; gnus-summary-prepare-hook since kill processing may not
4009 ;; work with hidden articles.
23f87bed 4010 (gnus-summary-maybe-hide-threads)
6748645f
LMI
4011 (when kill-buffer
4012 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 4013 (gnus-summary-auto-select-subject)
eec82323
LMI
4014 ;; Show first unread article if requested.
4015 (if (and (not no-article)
4016 (not no-display)
4017 gnus-newsgroup-unreads
4018 gnus-auto-select-first)
16409b0b
GM
4019 (progn
4020 (gnus-configure-windows 'summary)
23f87bed
MB
4021 (let ((art (gnus-summary-article-number)))
4022 (unless (and (not gnus-plugged)
4023 (or (memq art gnus-newsgroup-undownloaded)
4024 (memq art gnus-newsgroup-downloadable)))
4025 (gnus-summary-goto-article art))))
4026 ;; Don't select any articles.
eec82323 4027 (gnus-summary-position-point)
6748645f
LMI
4028 (gnus-configure-windows 'summary 'force)
4029 (gnus-set-mode-line 'summary))
23f87bed
MB
4030 (when (and gnus-auto-center-group
4031 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
4032 ;; Gotta use windows, because recenter does weird stuff if
4033 ;; the current buffer ain't the displayed window.
4034 (let ((owin (selected-window)))
4035 (select-window (get-buffer-window gnus-group-buffer t))
4036 (when (gnus-group-goto-group group)
4037 (recenter))
4038 (select-window owin)))
4039 ;; Mark this buffer as "prepared".
4040 (setq gnus-newsgroup-prepared t)
6748645f 4041 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
4042 (unless (gnus-ephemeral-group-p group)
4043 (gnus-group-update-group group))
eec82323
LMI
4044 t)))))
4045
23f87bed
MB
4046(defun gnus-summary-auto-select-subject ()
4047 "Select the subject line on initial group entry."
4048 (goto-char (point-min))
4049 (cond
4050 ((eq gnus-auto-select-subject 'best)
4051 (gnus-summary-best-unread-subject))
4052 ((eq gnus-auto-select-subject 'unread)
4053 (gnus-summary-first-unread-subject))
4054 ((eq gnus-auto-select-subject 'unseen)
4055 (gnus-summary-first-unseen-subject))
4056 ((eq gnus-auto-select-subject 'unseen-or-unread)
4057 (gnus-summary-first-unseen-or-unread-subject))
4058 ((eq gnus-auto-select-subject 'first)
4059 ;; Do nothing.
4060 )
4061 ((functionp gnus-auto-select-subject)
4062 (funcall gnus-auto-select-subject))))
4063
eec82323
LMI
4064(defun gnus-summary-prepare ()
4065 "Generate the summary buffer."
4066 (interactive)
c7a91ce1 4067 (let ((inhibit-read-only t))
eec82323
LMI
4068 (erase-buffer)
4069 (setq gnus-newsgroup-data nil
4070 gnus-newsgroup-data-reverse nil)
6748645f 4071 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
4072 ;; Generate the buffer, either with threads or without.
4073 (when gnus-newsgroup-headers
4074 (gnus-summary-prepare-threads
4075 (if gnus-show-threads
4076 (gnus-sort-gathered-threads
4077 (funcall gnus-summary-thread-gathering-function
4078 (gnus-sort-threads
4079 (gnus-cut-threads (gnus-make-threads)))))
4080 ;; Unthreaded display.
4081 (gnus-sort-articles gnus-newsgroup-headers))))
4082 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4083 ;; Call hooks for modifying summary buffer.
4084 (goto-char (point-min))
6748645f 4085 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
4086
4087(defsubst gnus-general-simplify-subject (subject)
23f87bed 4088 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
4089 (setq subject
4090 (cond
4091 ;; Truncate the subject.
6748645f
LMI
4092 (gnus-simplify-subject-functions
4093 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
4094 ((numberp gnus-summary-gather-subject-limit)
4095 (setq subject (gnus-simplify-subject-re subject))
4096 (if (> (length subject) gnus-summary-gather-subject-limit)
4097 (substring subject 0 gnus-summary-gather-subject-limit)
4098 subject))
4099 ;; Fuzzily simplify it.
4100 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4101 (gnus-simplify-subject-fuzzy subject))
4102 ;; Just remove the leading "Re:".
4103 (t
4104 (gnus-simplify-subject-re subject))))
4105
4106 (if (and gnus-summary-gather-exclude-subject
4107 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 4108 nil ; This article shouldn't be gathered
eec82323
LMI
4109 subject))
4110
4111(defun gnus-summary-simplify-subject-query ()
4112 "Query where the respool algorithm would put this article."
4113 (interactive)
eec82323 4114 (gnus-summary-select-article)
274f1353 4115 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
eec82323
LMI
4116
4117(defun gnus-gather-threads-by-subject (threads)
4118 "Gather threads by looking at Subject headers."
4119 (if (not gnus-summary-make-false-root)
4120 threads
4121 (let ((hashtb (gnus-make-hashtable 1024))
4122 (prev threads)
4123 (result threads)
4124 subject hthread whole-subject)
4125 (while threads
4126 (setq subject (gnus-general-simplify-subject
4127 (setq whole-subject (mail-header-subject
4128 (caar threads)))))
4129 (when subject
4130 (if (setq hthread (gnus-gethash subject hashtb))
4131 (progn
4132 ;; We enter a dummy root into the thread, if we
4133 ;; haven't done that already.
4134 (unless (stringp (caar hthread))
4135 (setcar hthread (list whole-subject (car hthread))))
4136 ;; We add this new gathered thread to this gathered
4137 ;; thread.
4138 (setcdr (car hthread)
4139 (nconc (cdar hthread) (list (car threads))))
4140 ;; Remove it from the list of threads.
4141 (setcdr prev (cdr threads))
4142 (setq threads prev))
4143 ;; Enter this thread into the hash table.
23f87bed
MB
4144 (gnus-sethash subject
4145 (if gnus-summary-make-false-root-always
4146 (progn
4147 ;; If you want a dummy root above all
4148 ;; threads...
4149 (setcar threads (list whole-subject
4150 (car threads)))
4151 threads)
4152 threads)
4153 hashtb)))
eec82323
LMI
4154 (setq prev threads)
4155 (setq threads (cdr threads)))
4156 result)))
4157
4158(defun gnus-gather-threads-by-references (threads)
4159 "Gather threads by looking at References headers."
4160 (let ((idhashtb (gnus-make-hashtable 1024))
4161 (thhashtb (gnus-make-hashtable 1024))
4162 (prev threads)
4163 (result threads)
4164 ids references id gthread gid entered ref)
4165 (while threads
4166 (when (setq references (mail-header-references (caar threads)))
4167 (setq id (mail-header-id (caar threads))
23f87bed 4168 ids (inline (gnus-split-references references))
eec82323
LMI
4169 entered nil)
4170 (while (setq ref (pop ids))
4171 (setq ids (delete ref ids))
4172 (if (not (setq gid (gnus-gethash ref idhashtb)))
4173 (progn
4174 (gnus-sethash ref id idhashtb)
4175 (gnus-sethash id threads thhashtb))
4176 (setq gthread (gnus-gethash gid thhashtb))
4177 (unless entered
4178 ;; We enter a dummy root into the thread, if we
4179 ;; haven't done that already.
4180 (unless (stringp (caar gthread))
4181 (setcar gthread (list (mail-header-subject (caar gthread))
4182 (car gthread))))
4183 ;; We add this new gathered thread to this gathered
4184 ;; thread.
4185 (setcdr (car gthread)
4186 (nconc (cdar gthread) (list (car threads)))))
4187 ;; Add it into the thread hash table.
4188 (gnus-sethash id gthread thhashtb)
4189 (setq entered t)
4190 ;; Remove it from the list of threads.
4191 (setcdr prev (cdr threads))
4192 (setq threads prev))))
4193 (setq prev threads)
4194 (setq threads (cdr threads)))
4195 result))
4196
4197(defun gnus-sort-gathered-threads (threads)
16409b0b 4198 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
4199 (let ((result threads))
4200 (while threads
4201 (when (stringp (caar threads))
4202 (setcdr (car threads)
16409b0b 4203 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
4204 (setq threads (cdr threads)))
4205 result))
4206
4207(defun gnus-thread-loop-p (root thread)
4208 "Say whether ROOT is in THREAD."
4209 (let ((stack (list thread))
4210 (infloop 0)
4211 th)
4212 (while (setq thread (pop stack))
4213 (setq th (cdr thread))
4214 (while (and th
4215 (not (eq (caar th) root)))
4216 (pop th))
4217 (if th
4218 ;; We have found a loop.
4219 (let (ref-dep)
4220 (setcdr thread (delq (car th) (cdr thread)))
4221 (if (boundp (setq ref-dep (intern "none"
4222 gnus-newsgroup-dependencies)))
4223 (setcdr (symbol-value ref-dep)
4224 (nconc (cdr (symbol-value ref-dep))
4225 (list (car th))))
4226 (set ref-dep (list nil (car th))))
4227 (setq infloop 1
4228 stack nil))
4229 ;; Push all the subthreads onto the stack.
4230 (push (cdr thread) stack)))
4231 infloop))
4232
4233(defun gnus-make-threads ()
01ccbb85 4234 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
4235 (let (threads)
4236 (while (catch 'infloop
4237 (mapatoms
4238 (lambda (refs)
4239 ;; Deal with self-referencing References loops.
4240 (when (and (car (symbol-value refs))
4241 (not (zerop
4242 (apply
4243 '+
4244 (mapcar
4245 (lambda (thread)
4246 (gnus-thread-loop-p
4247 (car (symbol-value refs)) thread))
4248 (cdr (symbol-value refs)))))))
4249 (setq threads nil)
4250 (throw 'infloop t))
4251 (unless (car (symbol-value refs))
23f87bed
MB
4252 ;; These threads do not refer back to any other
4253 ;; articles, so they're roots.
eec82323
LMI
4254 (setq threads (append (cdr (symbol-value refs)) threads))))
4255 gnus-newsgroup-dependencies)))
4256 threads))
4257
6748645f 4258;; Build the thread tree.
16409b0b 4259(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4260 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4261
4262If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4263if it was already present.
4264
4265If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4266will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4267Message-IDs will be renamed to a unique Message-ID before being
4268entered.
6748645f
LMI
4269
4270Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4271 (let* ((id (mail-header-id header))
4272 (id-dep (and id (intern id dependencies)))
23f87bed 4273 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4274 ;; Enter this `header' in the `dependencies' table.
4275 (cond
4276 ((not id-dep)
4277 (setq header nil))
4278 ;; The first two cases do the normal part: enter a new `header'
4279 ;; in the `dependencies' table.
4280 ((not (boundp id-dep))
4281 (set id-dep (list header)))
4282 ((null (car (symbol-value id-dep)))
4283 (setcar (symbol-value id-dep) header))
4284
4285 ;; From here the `header' was already present in the
4286 ;; `dependencies' table.
4287 (force-new
4288 ;; Overrides an existing entry;
4289 ;; just set the header part of the entry.
23f87bed
MB
4290 (setcar (symbol-value id-dep) header)
4291 (setq replaced t))
6748645f
LMI
4292
4293 ;; Renames the existing `header' to a unique Message-ID.
4294 ((not gnus-summary-ignore-duplicates)
4295 ;; An article with this Message-ID has already been seen.
4296 ;; We rename the Message-ID.
4297 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4298 (list header))
4299 (mail-header-set-id header id))
4300
4301 ;; The last case ignores an existing entry, except it adds any
4302 ;; additional Xrefs (in case the two articles came from different
4303 ;; servers.
4304 ;; Also sets `header' to `nil' meaning that the `dependencies'
4305 ;; table was *not* modified.
4306 (t
4307 (mail-header-set-xref
4308 (car (symbol-value id-dep))
4309 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4310 "")
4311 (or (mail-header-xref header) "")))
4312 (setq header nil)))
4313
23f87bed
MB
4314 (when (and header (not replaced))
4315 ;; First check that we are not creating a References loop.
4316 (setq parent-id (gnus-parent-id (mail-header-references header)))
4317 (setq ref parent-id)
6748645f
LMI
4318 (while (and ref
4319 (setq ref-dep (intern-soft ref dependencies))
4320 (boundp ref-dep)
4321 (setq ref-header (car (symbol-value ref-dep))))
4322 (if (string= id ref)
4323 ;; Yuk! This is a reference loop. Make the article be a
4324 ;; root article.
4325 (progn
4326 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4327 (setq ref nil)
4328 (setq parent-id nil))
6748645f 4329 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4330 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4331 (if (boundp ref-dep)
4332 (setcdr (symbol-value ref-dep)
4333 (nconc (cdr (symbol-value ref-dep))
4334 (list (symbol-value id-dep))))
4335 (set ref-dep (list nil (symbol-value id-dep)))))
4336 header))
4337
23f87bed
MB
4338(defun gnus-extract-message-id-from-in-reply-to (string)
4339 (if (string-match "<[^>]+>" string)
4340 (substring string (match-beginning 0) (match-end 0))
4341 nil))
4342
eec82323
LMI
4343(defun gnus-build-sparse-threads ()
4344 (let ((headers gnus-newsgroup-headers)
16409b0b 4345 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4346 (gnus-summary-ignore-duplicates t)
eec82323 4347 header references generation relations
6748645f 4348 subject child end new-child date)
eec82323
LMI
4349 ;; First we create an alist of generations/relations, where
4350 ;; generations is how much we trust the relation, and the relation
4351 ;; is parent/child.
4352 (gnus-message 7 "Making sparse threads...")
4353 (save-excursion
4354 (nnheader-set-temp-buffer " *gnus sparse threads*")
4355 (while (setq header (pop headers))
4356 (when (and (setq references (mail-header-references header))
4357 (not (string= references "")))
4358 (insert references)
4359 (setq child (mail-header-id header)
6748645f
LMI
4360 subject (mail-header-subject header)
4361 date (mail-header-date header)
4362 generation 0)
eec82323
LMI
4363 (while (search-backward ">" nil t)
4364 (setq end (1+ (point)))
4365 (when (search-backward "<" nil t)
6748645f 4366 (setq new-child (buffer-substring (point) end))
eec82323 4367 (push (list (incf generation)
6748645f
LMI
4368 child (setq child new-child)
4369 subject date)
eec82323 4370 relations)))
6748645f
LMI
4371 (when child
4372 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4373 (erase-buffer)))
4374 (kill-buffer (current-buffer)))
4375 ;; Sort over trustworthiness.
01c52d31
MB
4376 (dolist (relation (sort relations 'car-less-than-car))
4377 (when (gnus-dependencies-add-header
4378 (make-full-mail-header
4379 gnus-reffed-article-number
4380 (nth 3 relation) "" (or (nth 4 relation) "")
4381 (nth 1 relation)
4382 (or (nth 2 relation) "") 0 0 "")
4383 gnus-newsgroup-dependencies nil)
4384 (push gnus-reffed-article-number gnus-newsgroup-limit)
4385 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4386 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4387 gnus-newsgroup-reads)
4388 (decf gnus-reffed-article-number)))
eec82323
LMI
4389 (gnus-message 7 "Making sparse threads...done")))
4390
4391(defun gnus-build-old-threads ()
4392 ;; Look at all the articles that refer back to old articles, and
4393 ;; fetch the headers for the articles that aren't there. This will
4394 ;; build complete threads - if the roots haven't been expired by the
4395 ;; server, that is.
16409b0b
GM
4396 (let ((mail-parse-charset gnus-newsgroup-charset)
4397 id heads)
eec82323
LMI
4398 (mapatoms
4399 (lambda (refs)
4400 (when (not (car (symbol-value refs)))
4401 (setq heads (cdr (symbol-value refs)))
4402 (while heads
4403 (if (memq (mail-header-number (caar heads))
4404 gnus-newsgroup-dormant)
4405 (setq heads (cdr heads))
4406 (setq id (symbol-name refs))
4407 (while (and (setq id (gnus-build-get-header id))
6748645f 4408 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4409 (setq heads nil)))))
4410 gnus-newsgroup-dependencies)))
4411
23f87bed
MB
4412(defsubst gnus-remove-odd-characters (string)
4413 "Translate STRING into something that doesn't contain weird characters."
4414 (mm-subst-char-in-string
4415 ?\r ?\-
01c52d31 4416 (mm-subst-char-in-string ?\n ?\- string t) t))
23f87bed 4417
6748645f
LMI
4418;; This function has to be called with point after the article number
4419;; on the beginning of the line.
4420(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
01c52d31 4421 (let ((eol (point-at-eol))
6748645f 4422 (buffer (current-buffer))
23f87bed 4423 header references in-reply-to)
6748645f
LMI
4424
4425 ;; overview: [num subject from date id refs chars lines misc]
4426 (unwind-protect
23f87bed 4427 (let (x)
6748645f
LMI
4428 (narrow-to-region (point) eol)
4429 (unless (eobp)
4430 (forward-char))
4431
4432 (setq header
4433 (make-full-mail-header
4434 number ; number
23f87bed
MB
4435 (condition-case () ; subject
4436 (gnus-remove-odd-characters
4437 (funcall gnus-decode-encoded-word-function
4438 (setq x (nnheader-nov-field))))
4439 (error x))
4440 (condition-case () ; from
4441 (gnus-remove-odd-characters
343d6628 4442 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4443 (setq x (nnheader-nov-field))))
4444 (error x))
16409b0b 4445 (nnheader-nov-field) ; date
01c52d31 4446 (nnheader-nov-read-message-id number) ; id
23f87bed 4447 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4448 (nnheader-nov-read-integer) ; chars
4449 (nnheader-nov-read-integer) ; lines
4450 (unless (eobp)
8b93df01
DL
4451 (if (looking-at "Xref: ")
4452 (goto-char (match-end 0)))
4453 (nnheader-nov-field)) ; Xref
16409b0b 4454 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4455
4456 (widen))
4457
23f87bed
MB
4458 (when (and (string= references "")
4459 (setq in-reply-to (mail-header-extra header))
4460 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4461 (mail-header-set-references
4462 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4463
6748645f
LMI
4464 (when gnus-alter-header-function
4465 (funcall gnus-alter-header-function header))
4466 (gnus-dependencies-add-header header dependencies force-new)))
4467
eec82323 4468(defun gnus-build-get-header (id)
16409b0b
GM
4469 "Look through the buffer of NOV lines and find the header to ID.
4470Enter this line into the dependencies hash table, and return
4471the id of the parent article (if any)."
eec82323
LMI
4472 (let ((deps gnus-newsgroup-dependencies)
4473 found header)
4474 (prog1
c7a91ce1 4475 (with-current-buffer nntp-server-buffer
eec82323
LMI
4476 (let ((case-fold-search nil))
4477 (goto-char (point-min))
4478 (while (and (not found)
4479 (search-forward id nil t))
4480 (beginning-of-line)
4481 (setq found (looking-at
4482 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4483 (regexp-quote id))))
4484 (or found (beginning-of-line 2)))
4485 (when found
4486 (beginning-of-line)
4487 (and
4488 (setq header (gnus-nov-parse-line
4489 (read (current-buffer)) deps))
4490 (gnus-parent-id (mail-header-references header))))))
4491 (when header
4492 (let ((number (mail-header-number header)))
4493 (push number gnus-newsgroup-limit)
4494 (push header gnus-newsgroup-headers)
4495 (if (memq number gnus-newsgroup-unselected)
4496 (progn
23f87bed
MB
4497 (setq gnus-newsgroup-unreads
4498 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4499 number))
eec82323
LMI
4500 (setq gnus-newsgroup-unselected
4501 (delq number gnus-newsgroup-unselected)))
4502 (push number gnus-newsgroup-ancient)))))))
4503
6748645f
LMI
4504(defun gnus-build-all-threads ()
4505 "Read all the headers."
4506 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4507 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4508 (dependencies gnus-newsgroup-dependencies)
4509 header article)
c7a91ce1 4510 (with-current-buffer nntp-server-buffer
6748645f
LMI
4511 (let ((case-fold-search nil))
4512 (goto-char (point-min))
4513 (while (not (eobp))
4514 (ignore-errors
4515 (setq article (read (current-buffer))
181cb5fb 4516 header (gnus-nov-parse-line article dependencies t)))
6748645f 4517 (when header
01c52d31 4518 (with-current-buffer gnus-summary-buffer
6748645f
LMI
4519 (push header gnus-newsgroup-headers)
4520 (if (memq (setq article (mail-header-number header))
4521 gnus-newsgroup-unselected)
4522 (progn
23f87bed
MB
4523 (setq gnus-newsgroup-unreads
4524 (gnus-add-to-sorted-list
4525 gnus-newsgroup-unreads article))
6748645f
LMI
4526 (setq gnus-newsgroup-unselected
4527 (delq article gnus-newsgroup-unselected)))
4528 (push article gnus-newsgroup-ancient)))
4529 (forward-line 1)))))))
4530
eec82323 4531(defun gnus-summary-update-article-line (article header)
23f87bed 4532 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4533 (let* ((id (mail-header-id header))
4534 (thread (gnus-id-to-thread id)))
4535 (unless thread
4536 (error "Article in no thread"))
4537 ;; Update the thread.
4538 (setcar thread header)
4539 (gnus-summary-goto-subject article)
4540 (let* ((datal (gnus-data-find-list article))
4541 (data (car datal))
c7a91ce1 4542 (inhibit-read-only t)
eec82323
LMI
4543 (level (gnus-summary-thread-level)))
4544 (gnus-delete-line)
23f87bed
MB
4545 (let ((inserted (- (point)
4546 (progn
4547 (gnus-summary-insert-line
4548 header level nil
4549 (memq article gnus-newsgroup-undownloaded)
4550 (gnus-article-mark article)
4551 (memq article gnus-newsgroup-replied)
4552 (memq article gnus-newsgroup-expirable)
4553 ;; Only insert the Subject string when it's different
4554 ;; from the previous Subject string.
4555 (if (and
4556 gnus-show-threads
4557 (gnus-subject-equal
4558 (condition-case ()
4559 (mail-header-subject
4560 (gnus-data-header
4561 (cadr
4562 (gnus-data-find-list
4563 article
4564 (gnus-data-list t)))))
4565 ;; Error on the side of excessive subjects.
4566 (error ""))
4567 (mail-header-subject header)))
4568 ""
4569 (mail-header-subject header))
4570 nil (cdr (assq article gnus-newsgroup-scored))
4571 (memq article gnus-newsgroup-processable))
4572 (point)))))
4573 (when (cdr datal)
4574 (gnus-data-update-list
4575 (cdr datal)
4576 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4577
4578(defun gnus-summary-update-article (article &optional iheader)
4579 "Update ARTICLE in the summary buffer."
4580 (set-buffer gnus-summary-buffer)
6748645f 4581 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4582 (id (mail-header-id header))
4583 (data (gnus-data-find article))
4584 (thread (gnus-id-to-thread id))
4585 (references (mail-header-references header))
4586 (parent
4587 (gnus-id-to-thread
4588 (or (gnus-parent-id
4589 (when (and references
4590 (not (equal "" references)))
4591 references))
4592 "none")))
c7a91ce1 4593 (inhibit-read-only t)
6748645f 4594 (old (car thread)))
eec82323 4595 (when thread
eec82323 4596 (unless iheader
6748645f
LMI
4597 (setcar thread nil)
4598 (when parent
4599 (delq thread parent)))
4600 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4601 ;; Set the (possibly) new article number in the data structure.
4602 (gnus-data-set-number data (gnus-id-to-article id))
4603 (setcar thread old)
4604 nil))))
4605
6748645f
LMI
4606(defun gnus-rebuild-thread (id &optional line)
4607 "Rebuild the thread containing ID.
4608If LINE, insert the rebuilt thread starting on line LINE."
c7a91ce1 4609 (let ((inhibit-read-only t)
eec82323
LMI
4610 old-pos current thread data)
4611 (if (not gnus-show-threads)
4612 (setq thread (list (car (gnus-id-to-thread id))))
4613 ;; Get the thread this article is part of.
4614 (setq thread (gnus-remove-thread id)))
01c52d31 4615 (setq old-pos (point-at-bol))
eec82323 4616 (setq current (save-excursion
94384150 4617 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4618 (gnus-summary-article-number))))
4619 ;; If this is a gathered thread, we have to go some re-gathering.
4620 (when (stringp (car thread))
4621 (let ((subject (car thread))
4622 roots thr)
4623 (setq thread (cdr thread))
4624 (while thread
4625 (unless (memq (setq thr (gnus-id-to-thread
4626 (gnus-root-id
4627 (mail-header-id (caar thread)))))
4628 roots)
4629 (push thr roots))
4630 (setq thread (cdr thread)))
4631 ;; We now have all (unique) roots.
4632 (if (= (length roots) 1)
4633 ;; All the loose roots are now one solid root.
4634 (setq thread (car roots))
4635 (setq thread (cons subject (gnus-sort-threads roots))))))
4636 (let (threads)
4637 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4638 (when line
4639 (goto-char (point-min))
4640 (forward-line (1- line)))
eec82323
LMI
4641 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4642 (if gnus-show-threads
4643 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4644 (gnus-summary-prepare-unthreaded thread))
4645 (setq data (nreverse gnus-newsgroup-data))
4646 (setq threads gnus-newsgroup-threads))
4647 ;; We splice the new data into the data structure.
6748645f
LMI
4648 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4649 ;;!!! then we want to insert at the beginning of the buffer.
4650 ;;!!! That happens to be true with Gnus now, but that may
4651 ;;!!! change in the future. Perhaps.
4652 (gnus-data-enter-list
4653 (if line nil current) data (- (point) old-pos))
4654 (setq gnus-newsgroup-threads
4655 (nconc threads gnus-newsgroup-threads))
4656 (gnus-data-compute-positions))))
eec82323
LMI
4657
4658(defun gnus-number-to-header (number)
4659 "Return the header for article NUMBER."
4660 (let ((headers gnus-newsgroup-headers))
4661 (while (and headers
4662 (not (= number (mail-header-number (car headers)))))
4663 (pop headers))
4664 (when headers
4665 (car headers))))
4666
6748645f 4667(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4668 "Return the headers of the GENERATIONeth parent of HEADERS."
4669 (unless generation
4670 (setq generation 1))
a8151ef7 4671 (let ((parent t)
6748645f 4672 (headers in-headers)
a8151ef7 4673 references)
6748645f
LMI
4674 (while (and parent
4675 (not (zerop generation))
4676 (setq references (mail-header-references headers)))
4677 (setq headers (if (and references
4678 (setq parent (gnus-parent-id references)))
4679 (car (gnus-id-to-thread parent))
4680 nil))
4681 (decf generation))
4682 (and (not (eq headers in-headers))
4683 headers)))
eec82323
LMI
4684
4685(defun gnus-id-to-thread (id)
4686 "Return the (sub-)thread where ID appears."
4687 (gnus-gethash id gnus-newsgroup-dependencies))
4688
4689(defun gnus-id-to-article (id)
4690 "Return the article number of ID."
4691 (let ((thread (gnus-id-to-thread id)))
4692 (when (and thread
4693 (car thread))
4694 (mail-header-number (car thread)))))
4695
4696(defun gnus-id-to-header (id)
4697 "Return the article headers of ID."
4698 (car (gnus-id-to-thread id)))
4699
4700(defun gnus-article-displayed-root-p (article)
4701 "Say whether ARTICLE is a root(ish) article."
4702 (let ((level (gnus-summary-thread-level article))
4703 (refs (mail-header-references (gnus-summary-article-header article)))
4704 particle)
4705 (cond
4706 ((null level) nil)
4707 ((zerop level) t)
4708 ((null refs) t)
4709 ((null (gnus-parent-id refs)) t)
4710 ((and (= 1 level)
4711 (null (setq particle (gnus-id-to-article
4712 (gnus-parent-id refs))))
4713 (null (gnus-summary-thread-level particle)))))))
4714
4715(defun gnus-root-id (id)
4716 "Return the id of the root of the thread where ID appears."
4717 (let (last-id prev)
6748645f 4718 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4719 (setq last-id id
4720 id (gnus-parent-id (mail-header-references prev))))
4721 last-id))
4722
6748645f
LMI
4723(defun gnus-articles-in-thread (thread)
4724 "Return the list of articles in THREAD."
4725 (cons (mail-header-number (car thread))
4726 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4727
eec82323
LMI
4728(defun gnus-remove-thread (id &optional dont-remove)
4729 "Remove the thread that has ID in it."
6748645f 4730 (let (headers thread last-id)
eec82323 4731 ;; First go up in this thread until we find the root.
6748645f
LMI
4732 (setq last-id (gnus-root-id id)
4733 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4734 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4735 ;; been gathered into some loose thread, so we have to search
4736 ;; through the threads to find the thread we wanted.
4737 (let ((threads gnus-newsgroup-threads)
4738 sub)
4739 (while threads
4740 (setq sub (car threads))
4741 (if (stringp (car sub))
4742 ;; This is a gathered thread, so we look at the roots
4743 ;; below it to find whether this article is in this
4744 ;; gathered root.
4745 (progn
4746 (setq sub (cdr sub))
4747 (while sub
4748 (when (member (caar sub) headers)
4749 (setq thread (car threads)
4750 threads nil
4751 sub nil))
4752 (setq sub (cdr sub))))
4753 ;; It's an ordinary thread, so we check it.
4754 (when (eq (car sub) (car headers))
4755 (setq thread sub
4756 threads nil)))
4757 (setq threads (cdr threads)))
4758 ;; If this article is in no thread, then it's a root.
4759 (if thread
4760 (unless dont-remove
4761 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4762 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4763 (when thread
4764 (prog1
4765 thread ; We return this thread.
4766 (unless dont-remove
4767 (if (stringp (car thread))
4768 (progn
4769 ;; If we use dummy roots, then we have to remove the
4770 ;; dummy root as well.
4771 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4772 ;; We go to the dummy root by going to
4773 ;; the first sub-"thread", and then one line up.
4774 (gnus-summary-goto-article
4775 (mail-header-number (caadr thread)))
4776 (forward-line -1)
eec82323
LMI
4777 (gnus-delete-line)
4778 (gnus-data-compute-positions))
4779 (setq thread (cdr thread))
4780 (while thread
4781 (gnus-remove-thread-1 (car thread))
4782 (setq thread (cdr thread))))
4783 (gnus-remove-thread-1 thread))))))))
4784
4785(defun gnus-remove-thread-1 (thread)
4786 "Remove the thread THREAD recursively."
4787 (let ((number (mail-header-number (pop thread)))
4788 d)
4789 (setq thread (reverse thread))
4790 (while thread
4791 (gnus-remove-thread-1 (pop thread)))
4792 (when (setq d (gnus-data-find number))
4793 (goto-char (gnus-data-pos d))
16409b0b 4794 (gnus-summary-show-thread)
eec82323
LMI
4795 (gnus-data-remove
4796 number
01c52d31 4797 (- (point-at-bol)
eec82323 4798 (prog1
01c52d31 4799 (1+ (point-at-eol))
eec82323
LMI
4800 (gnus-delete-line)))))))
4801
4921bbdd 4802(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4803 (sort (mapcar (lambda (thread)
4804 (cons (car thread)
4805 (and (cdr thread)
4921bbdd 4806 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4807 threads) func))
4808
4921bbdd
CY
4809(defun gnus-sort-threads-loop (threads func)
4810 (let* ((superthread (cons nil threads))
4811 (stack (list (cons superthread threads)))
4812 remaining-threads thread)
4813 (while stack
4814 (setq remaining-threads (cdr (car stack)))
4815 (if remaining-threads
4816 (progn (setq thread (car remaining-threads))
4817 (setcdr (car stack) (cdr remaining-threads))
4818 (if (cdr thread)
4819 (push (cons thread (cdr thread)) stack)))
4820 (setq thread (caar stack))
4821 (setcdr thread (sort (cdr thread) func))
4822 (pop stack)))
4823 (cdr superthread)))
4824
eec82323
LMI
4825(defun gnus-sort-threads (threads)
4826 "Sort THREADS."
4827 (if (not gnus-thread-sort-functions)
4828 threads
6748645f 4829 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4830 (prog1
4831 (condition-case nil
4832 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4833 (gnus-sort-threads-recursive
4834 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4835 ;; Even after binding max-lisp-eval-depth, the recursive
4836 ;; sorter might fail for very long threads. In that case,
4837 ;; try using a (less well-tested) non-recursive sorter.
3d6e7a43
KY
4838 (error (gnus-message 9 "Sorting threads with loop...")
4839 (gnus-sort-threads-loop
4921bbdd
CY
4840 threads (gnus-make-sort-function
4841 gnus-thread-sort-functions))))
4842 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4843
4844(defun gnus-sort-articles (articles)
4845 "Sort ARTICLES."
4846 (when gnus-article-sort-functions
4847 (gnus-message 7 "Sorting articles...")
4848 (prog1
4849 (setq gnus-newsgroup-headers
4850 (sort articles (gnus-make-sort-function
4851 gnus-article-sort-functions)))
4852 (gnus-message 7 "Sorting articles...done"))))
4853
4854;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4855(defmacro gnus-thread-header (thread)
16409b0b
GM
4856 "Return header of first article in THREAD.
4857Note that THREAD must never, ever be anything else than a variable -
4858using some other form will lead to serious barfage."
eec82323
LMI
4859 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4860 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4861 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4862 (vector thread) 2))
4863
4864(defsubst gnus-article-sort-by-number (h1 h2)
4865 "Sort articles by article number."
4866 (< (mail-header-number h1)
4867 (mail-header-number h2)))
4868
4869(defun gnus-thread-sort-by-number (h1 h2)
4870 "Sort threads by root article number."
4871 (gnus-article-sort-by-number
4872 (gnus-thread-header h1) (gnus-thread-header h2)))
4873
23f87bed 4874(defsubst gnus-article-sort-by-random (h1 h2)
0b6799c3 4875 "Sort articles randomly."
23f87bed
MB
4876 (zerop (random 2)))
4877
4878(defun gnus-thread-sort-by-random (h1 h2)
0b6799c3 4879 "Sort threads randomly."
23f87bed
MB
4880 (gnus-article-sort-by-random
4881 (gnus-thread-header h1) (gnus-thread-header h2)))
4882
eec82323
LMI
4883(defsubst gnus-article-sort-by-lines (h1 h2)
4884 "Sort articles by article Lines header."
4885 (< (mail-header-lines h1)
4886 (mail-header-lines h2)))
4887
4888(defun gnus-thread-sort-by-lines (h1 h2)
4889 "Sort threads by root article Lines header."
4890 (gnus-article-sort-by-lines
4891 (gnus-thread-header h1) (gnus-thread-header h2)))
4892
16409b0b
GM
4893(defsubst gnus-article-sort-by-chars (h1 h2)
4894 "Sort articles by octet length."
4895 (< (mail-header-chars h1)
4896 (mail-header-chars h2)))
4897
4898(defun gnus-thread-sort-by-chars (h1 h2)
4899 "Sort threads by root article octet length."
4900 (gnus-article-sort-by-chars
4901 (gnus-thread-header h1) (gnus-thread-header h2)))
4902
eec82323
LMI
4903(defsubst gnus-article-sort-by-author (h1 h2)
4904 "Sort articles by root author."
b4fde39f 4905 (gnus-string<
eec82323
LMI
4906 (let ((extract (funcall
4907 gnus-extract-address-components
4908 (mail-header-from h1))))
4909 (or (car extract) (cadr extract) ""))
4910 (let ((extract (funcall
4911 gnus-extract-address-components
4912 (mail-header-from h2))))
4913 (or (car extract) (cadr extract) ""))))
4914
4915(defun gnus-thread-sort-by-author (h1 h2)
4916 "Sort threads by root author."
4917 (gnus-article-sort-by-author
4918 (gnus-thread-header h1) (gnus-thread-header h2)))
4919
01c52d31
MB
4920(defsubst gnus-article-sort-by-recipient (h1 h2)
4921 "Sort articles by recipient."
4922 (gnus-string<
4923 (let ((extract (funcall
4924 gnus-extract-address-components
4925 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4926 (or (car extract) (cadr extract)))
4927 (let ((extract (funcall
4928 gnus-extract-address-components
4929 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4930 (or (car extract) (cadr extract)))))
4931
4932(defun gnus-thread-sort-by-recipient (h1 h2)
4933 "Sort threads by root recipient."
4934 (gnus-article-sort-by-recipient
4935 (gnus-thread-header h1) (gnus-thread-header h2)))
4936
eec82323
LMI
4937(defsubst gnus-article-sort-by-subject (h1 h2)
4938 "Sort articles by root subject."
b4fde39f 4939 (gnus-string<
eec82323
LMI
4940 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4941 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4942
4943(defun gnus-thread-sort-by-subject (h1 h2)
4944 "Sort threads by root subject."
4945 (gnus-article-sort-by-subject
4946 (gnus-thread-header h1) (gnus-thread-header h2)))
4947
4948(defsubst gnus-article-sort-by-date (h1 h2)
4949 "Sort articles by root article date."
16409b0b 4950 (time-less-p
eec82323
LMI
4951 (gnus-date-get-time (mail-header-date h1))
4952 (gnus-date-get-time (mail-header-date h2))))
4953
4954(defun gnus-thread-sort-by-date (h1 h2)
4955 "Sort threads by root article date."
4956 (gnus-article-sort-by-date
4957 (gnus-thread-header h1) (gnus-thread-header h2)))
4958
4959(defsubst gnus-article-sort-by-score (h1 h2)
4960 "Sort articles by root article score.
4961Unscored articles will be counted as having a score of zero."
4962 (> (or (cdr (assq (mail-header-number h1)
4963 gnus-newsgroup-scored))
4964 gnus-summary-default-score 0)
4965 (or (cdr (assq (mail-header-number h2)
4966 gnus-newsgroup-scored))
4967 gnus-summary-default-score 0)))
4968
4969(defun gnus-thread-sort-by-score (h1 h2)
4970 "Sort threads by root article score."
4971 (gnus-article-sort-by-score
4972 (gnus-thread-header h1) (gnus-thread-header h2)))
4973
4974(defun gnus-thread-sort-by-total-score (h1 h2)
4975 "Sort threads by the sum of all scores in the thread.
4976Unscored articles will be counted as having a score of zero."
4977 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4978
4979(defun gnus-thread-total-score (thread)
16409b0b 4980 ;; This function find the total score of THREAD.
23f87bed
MB
4981 (cond
4982 ((null thread)
4983 0)
4984 ((consp thread)
4985 (if (stringp (car thread))
4986 (apply gnus-thread-score-function 0
4987 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4988 (gnus-thread-total-score-1 thread)))
4989 (t
4990 (gnus-thread-total-score-1 (list thread)))))
4991
130e977f
LMI
4992(defun gnus-article-sort-by-most-recent-number (h1 h2)
4993 "Sort articles by number."
4994 (gnus-article-sort-by-number h1 h2))
4995
23f87bed
MB
4996(defun gnus-thread-sort-by-most-recent-number (h1 h2)
4997 "Sort threads such that the thread with the most recently arrived article comes first."
4998 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4999
5000(defun gnus-thread-highest-number (thread)
5001 "Return the highest article number in THREAD."
5002 (apply 'max (mapcar (lambda (header)
5003 (mail-header-number header))
5004 (message-flatten-list thread))))
5005
130e977f
LMI
5006(defun gnus-article-sort-by-most-recent-date (h1 h2)
5007 "Sort articles by number."
5008 (gnus-article-sort-by-date h1 h2))
5009
23f87bed
MB
5010(defun gnus-thread-sort-by-most-recent-date (h1 h2)
5011 "Sort threads such that the thread with the most recently dated article comes first."
5012 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5013
3d6e7a43
KY
5014; Since this is called not only to sort the top-level threads, but
5015; also in recursive sorts to order the articles within a thread, each
5016; article will be processed many times. Thus it speeds things up
5017; quite a bit to use gnus-date-get-time, which caches the time value.
23f87bed
MB
5018(defun gnus-thread-latest-date (thread)
5019 "Return the highest article date in THREAD."
3d6e7a43
KY
5020 (apply 'max
5021 (mapcar (lambda (header) (gnus-float-time
5022 (gnus-date-get-time
5023 (mail-header-date header))))
5024 (message-flatten-list thread))))
eec82323
LMI
5025
5026(defun gnus-thread-total-score-1 (root)
5027 ;; This function find the total score of the thread below ROOT.
5028 (setq root (car root))
5029 (apply gnus-thread-score-function
5030 (or (append
5031 (mapcar 'gnus-thread-total-score
6748645f 5032 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
5033 (when (> (mail-header-number root) 0)
5034 (list (or (cdr (assq (mail-header-number root)
5035 gnus-newsgroup-scored))
5036 gnus-summary-default-score 0))))
5037 (list gnus-summary-default-score)
5038 '(0))))
5039
5040;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5041(defvar gnus-tmp-prev-subject nil)
5042(defvar gnus-tmp-false-parent nil)
5043(defvar gnus-tmp-root-expunged nil)
5044(defvar gnus-tmp-dummy-line nil)
5045
16409b0b
GM
5046(defun gnus-extra-header (type &optional header)
5047 "Return the extra header of TYPE."
5048 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5049 ""))
5050
23f87bed
MB
5051(defvar gnus-tmp-thread-tree-header-string "")
5052
5053(defcustom gnus-sum-thread-tree-root "> "
5054 "With %B spec, used for the root of a thread.
5055If nil, use subject instead."
bf247b6e 5056 :version "22.1"
ad136a7c 5057 :type '(radio (const :format "%v " nil) string)
23f87bed 5058 :group 'gnus-thread)
01c52d31 5059
23f87bed
MB
5060(defcustom gnus-sum-thread-tree-false-root "> "
5061 "With %B spec, used for a false root of a thread.
5062If nil, use subject instead."
bf247b6e 5063 :version "22.1"
ad136a7c 5064 :type '(radio (const :format "%v " nil) string)
23f87bed 5065 :group 'gnus-thread)
01c52d31 5066
23f87bed
MB
5067(defcustom gnus-sum-thread-tree-single-indent ""
5068 "With %B spec, used for a thread with just one message.
5069If nil, use subject instead."
bf247b6e 5070 :version "22.1"
ad136a7c 5071 :type '(radio (const :format "%v " nil) string)
23f87bed 5072 :group 'gnus-thread)
01c52d31 5073
23f87bed
MB
5074(defcustom gnus-sum-thread-tree-vertical "| "
5075 "With %B spec, used for drawing a vertical line."
bf247b6e 5076 :version "22.1"
23f87bed
MB
5077 :type 'string
5078 :group 'gnus-thread)
01c52d31 5079
23f87bed
MB
5080(defcustom gnus-sum-thread-tree-indent " "
5081 "With %B spec, used for indenting."
bf247b6e 5082 :version "22.1"
23f87bed
MB
5083 :type 'string
5084 :group 'gnus-thread)
01c52d31 5085
23f87bed
MB
5086(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5087 "With %B spec, used for a leaf with brothers."
bf247b6e 5088 :version "22.1"
23f87bed
MB
5089 :type 'string
5090 :group 'gnus-thread)
01c52d31 5091
23f87bed
MB
5092(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5093 "With %B spec, used for a leaf without brothers."
bf247b6e 5094 :version "22.1"
23f87bed
MB
5095 :type 'string
5096 :group 'gnus-thread)
5097
1fc34624
GM
5098(defcustom gnus-summary-display-while-building nil
5099 "If non-nil, show and update the summary buffer as it's being built.
5100If the value is t, update the buffer after every line is inserted. If
5101the value is an integer (N), update the display every N lines."
5102 :version "22.1"
5103 :group 'gnus-thread
5104 :type '(choice (const :tag "off" nil)
5105 number
5106 (const :tag "frequently" t)))
5107
eec82323
LMI
5108(defun gnus-summary-prepare-threads (threads)
5109 "Prepare summary buffer from THREADS and indentation LEVEL.
5110THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5111or a straight list of headers."
5112 (gnus-message 7 "Generating summary...")
5113
5114 (setq gnus-newsgroup-threads threads)
5115 (beginning-of-line)
5116
5117 (let ((gnus-tmp-level 0)
5118 (default-score (or gnus-summary-default-score 0))
5119 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
5120 (building-line-count gnus-summary-display-while-building)
5121 (building-count (integerp gnus-summary-display-while-building))
eec82323 5122 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
5123 new-roots gnus-tmp-new-adopts thread-end simp-subject
5124 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
5125 gnus-tmp-replied gnus-tmp-subject-or-nil
5126 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5127 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
5128 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5129 tree-stack)
eec82323 5130
23f87bed
MB
5131 (setq gnus-tmp-prev-subject nil
5132 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
5133
5134 (if (vectorp (car threads))
5135 ;; If this is a straight (sic) list of headers, then a
5136 ;; threaded summary display isn't required, so we just create
5137 ;; an unthreaded one.
5138 (gnus-summary-prepare-unthreaded threads)
5139
5140 ;; Do the threaded display.
5141
23f87bed
MB
5142 (if gnus-summary-display-while-building
5143 (switch-to-buffer (buffer-name)))
eec82323
LMI
5144 (while (or threads stack gnus-tmp-new-adopts new-roots)
5145
5146 (if (and (= gnus-tmp-level 0)
eec82323
LMI
5147 (or (not stack)
5148 (= (caar stack) 0))
5149 (not gnus-tmp-false-parent)
5150 (or gnus-tmp-new-adopts new-roots))
5151 (if gnus-tmp-new-adopts
5152 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5153 thread (list (car gnus-tmp-new-adopts))
5154 gnus-tmp-header (caar thread)
5155 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5156 (when new-roots
5157 (setq thread (list (car new-roots))
5158 gnus-tmp-header (caar thread)
5159 new-roots (cdr new-roots))))
5160
5161 (if threads
5162 ;; If there are some threads, we do them before the
5163 ;; threads on the stack.
5164 (setq thread threads
5165 gnus-tmp-header (caar thread))
5166 ;; There were no current threads, so we pop something off
5167 ;; the stack.
5168 (setq state (car stack)
5169 gnus-tmp-level (car state)
23f87bed
MB
5170 tree-stack (cadr state)
5171 thread (caddr state)
eec82323
LMI
5172 stack (cdr stack)
5173 gnus-tmp-header (caar thread))))
5174
5175 (setq gnus-tmp-false-parent nil)
5176 (setq gnus-tmp-root-expunged nil)
5177 (setq thread-end nil)
5178
5179 (if (stringp gnus-tmp-header)
5180 ;; The header is a dummy root.
5181 (cond
5182 ((eq gnus-summary-make-false-root 'adopt)
5183 ;; We let the first article adopt the rest.
5184 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5185 (cddar thread)))
5186 (setq gnus-tmp-gathered
5187 (nconc (mapcar
5188 (lambda (h) (mail-header-number (car h)))
5189 (cddar thread))
5190 gnus-tmp-gathered))
5191 (setq thread (cons (list (caar thread)
5192 (cadar thread))
5193 (cdr thread)))
5194 (setq gnus-tmp-level -1
5195 gnus-tmp-false-parent t))
5196 ((eq gnus-summary-make-false-root 'empty)
5197 ;; We print adopted articles with empty subject fields.
5198 (setq gnus-tmp-gathered
5199 (nconc (mapcar
5200 (lambda (h) (mail-header-number (car h)))
5201 (cddar thread))
5202 gnus-tmp-gathered))
5203 (setq gnus-tmp-level -1))
5204 ((eq gnus-summary-make-false-root 'dummy)
5205 ;; We remember that we probably want to output a dummy
5206 ;; root.
5207 (setq gnus-tmp-dummy-line gnus-tmp-header)
5208 (setq gnus-tmp-prev-subject gnus-tmp-header))
5209 (t
5210 ;; We do not make a root for the gathered
5211 ;; sub-threads at all.
5212 (setq gnus-tmp-level -1)))
5213
5214 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
5215 subject (mail-header-subject gnus-tmp-header)
5216 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
5217
5218 (cond
5219 ;; If the thread has changed subject, we might want to make
5220 ;; this subthread into a root.
5221 ((and (null gnus-thread-ignore-subject)
5222 (not (zerop gnus-tmp-level))
5223 gnus-tmp-prev-subject
23f87bed 5224 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5225 (setq new-roots (nconc new-roots (list (car thread)))
5226 thread-end t
5227 gnus-tmp-header nil))
5228 ;; If the article lies outside the current limit,
5229 ;; then we do not display it.
5230 ((not (memq number gnus-newsgroup-limit))
5231 (setq gnus-tmp-gathered
5232 (nconc (mapcar
5233 (lambda (h) (mail-header-number (car h)))
5234 (cdar thread))
5235 gnus-tmp-gathered))
5236 (setq gnus-tmp-new-adopts (if (cdar thread)
5237 (append gnus-tmp-new-adopts
5238 (cdar thread))
5239 gnus-tmp-new-adopts)
5240 thread-end t
5241 gnus-tmp-header nil)
5242 (when (zerop gnus-tmp-level)
5243 (setq gnus-tmp-root-expunged t)))
5244 ;; Perhaps this article is to be marked as read?
5245 ((and gnus-summary-mark-below
5246 (< (or (cdr (assq number gnus-newsgroup-scored))
5247 default-score)
5248 gnus-summary-mark-below)
5249 ;; Don't touch sparse articles.
5250 (not (gnus-summary-article-sparse-p number))
5251 (not (gnus-summary-article-ancient-p number)))
5252 (setq gnus-newsgroup-unreads
5253 (delq number gnus-newsgroup-unreads))
5254 (if gnus-newsgroup-auto-expire
23f87bed
MB
5255 (setq gnus-newsgroup-expirable
5256 (gnus-add-to-sorted-list
5257 gnus-newsgroup-expirable number))
eec82323
LMI
5258 (push (cons number gnus-low-score-mark)
5259 gnus-newsgroup-reads))))
5260
5261 (when gnus-tmp-header
5262 ;; We may have an old dummy line to output before this
5263 ;; article.
6748645f
LMI
5264 (when (and gnus-tmp-dummy-line
5265 (gnus-subject-equal
5266 gnus-tmp-dummy-line
5267 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
5268 (gnus-summary-insert-dummy-line
5269 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5270 (setq gnus-tmp-dummy-line nil))
5271
5272 ;; Compute the mark.
5273 (setq gnus-tmp-unread (gnus-article-mark number))
5274
5275 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5276 gnus-tmp-header gnus-tmp-level)
5277 gnus-newsgroup-data)
5278
5279 ;; Actually insert the line.
5280 (setq
5281 gnus-tmp-subject-or-nil
5282 (cond
5283 ((and gnus-thread-ignore-subject
5284 gnus-tmp-prev-subject
23f87bed 5285 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5286 subject)
5287 ((zerop gnus-tmp-level)
5288 (if (and (eq gnus-summary-make-false-root 'empty)
5289 (memq number gnus-tmp-gathered)
5290 gnus-tmp-prev-subject
23f87bed 5291 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5292 gnus-summary-same-subject
5293 subject))
5294 (t gnus-summary-same-subject)))
5295 (if (and (eq gnus-summary-make-false-root 'adopt)
5296 (= gnus-tmp-level 1)
5297 (memq number gnus-tmp-gathered))
5298 (setq gnus-tmp-opening-bracket ?\<
5299 gnus-tmp-closing-bracket ?\>)
5300 (setq gnus-tmp-opening-bracket ?\[
5301 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5302 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5303 (gnus-make-thread-indent-array
5304 (max (* 2 (length gnus-thread-indent-array))
5305 gnus-tmp-level)))
eec82323
LMI
5306 (setq
5307 gnus-tmp-indentation
5308 (aref gnus-thread-indent-array gnus-tmp-level)
5309 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5310 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5311 gnus-summary-default-score 0)
5312 gnus-tmp-score-char
5313 (if (or (null gnus-summary-default-score)
5314 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5315 gnus-summary-zcore-fuzz))
23f87bed 5316 ? ;Whitespace
eec82323
LMI
5317 (if (< gnus-tmp-score gnus-summary-default-score)
5318 gnus-score-below-mark gnus-score-over-mark))
5319 gnus-tmp-replied
5320 (cond ((memq number gnus-newsgroup-processable)
5321 gnus-process-mark)
5322 ((memq number gnus-newsgroup-cached)
5323 gnus-cached-mark)
5324 ((memq number gnus-newsgroup-replied)
5325 gnus-replied-mark)
23f87bed
MB
5326 ((memq number gnus-newsgroup-forwarded)
5327 gnus-forwarded-mark)
eec82323
LMI
5328 ((memq number gnus-newsgroup-saved)
5329 gnus-saved-mark)
23f87bed
MB
5330 ((memq number gnus-newsgroup-recent)
5331 gnus-recent-mark)
5332 ((memq number gnus-newsgroup-unseen)
5333 gnus-unseen-mark)
5334 (t gnus-no-mark))
5335 gnus-tmp-downloaded
5336 (cond ((memq number gnus-newsgroup-undownloaded)
5337 gnus-undownloaded-mark)
5338 (gnus-newsgroup-agentized
5339 gnus-downloaded-mark)
5340 (t
5341 gnus-no-mark))
eec82323
LMI
5342 gnus-tmp-from (mail-header-from gnus-tmp-header)
5343 gnus-tmp-name
5344 (cond
5345 ((string-match "<[^>]+> *$" gnus-tmp-from)
5346 (setq beg-match (match-beginning 0))
23f87bed
MB
5347 (or (and (string-match "^\".+\"" gnus-tmp-from)
5348 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5349 (substring gnus-tmp-from 0 beg-match)))
5350 ((string-match "(.+)" gnus-tmp-from)
5351 (substring gnus-tmp-from
5352 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5353 (t gnus-tmp-from))
5354
5355 ;; Do the %B string
5356 gnus-tmp-thread-tree-header-string
5357 (cond
5358 ((not gnus-show-threads) "")
5359 ((zerop gnus-tmp-level)
5360 (cond ((cdar thread)
5361 (or gnus-sum-thread-tree-root subject))
5362 (gnus-tmp-new-adopts
5363 (or gnus-sum-thread-tree-false-root subject))
5364 (t
5365 (or gnus-sum-thread-tree-single-indent subject))))
5366 (t
5367 (concat (apply 'concat
5368 (mapcar (lambda (item)
5369 (if (= item 1)
5370 gnus-sum-thread-tree-vertical
5371 gnus-sum-thread-tree-indent))
5372 (cdr (reverse tree-stack))))
5373 (if (nth 1 thread)
5374 gnus-sum-thread-tree-leaf-with-other
5375 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5376 (when (string= gnus-tmp-name "")
5377 (setq gnus-tmp-name gnus-tmp-from))
5378 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5379 (setq gnus-tmp-lines -1))
5380 (if (= gnus-tmp-lines -1)
5381 (setq gnus-tmp-lines "?")
5382 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
61b1af82
G
5383 (gnus-put-text-property
5384 (point)
5385 (progn (eval gnus-summary-line-format-spec) (point))
5386 'gnus-number number)
5387 (when gnus-visual-p
5388 (forward-line -1)
5389 (gnus-summary-highlight-line)
5390 (when gnus-summary-update-hook
5391 (gnus-run-hooks 'gnus-summary-update-hook))
5392 (forward-line 1))
5393
5394 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5395
5396 (when (nth 1 thread)
23f87bed
MB
5397 (push (list (max 0 gnus-tmp-level)
5398 (copy-sequence tree-stack)
5399 (nthcdr 1 thread))
5400 stack))
5401 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5402 (incf gnus-tmp-level)
5403 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5404 (if gnus-summary-display-while-building
5405 (if building-count
5406 (progn
5407 ;; use a set frequency
5408 (setq building-line-count (1- building-line-count))
5409 (when (= building-line-count 0)
5410 (sit-for 0)
5411 (setq building-line-count
5412 gnus-summary-display-while-building)))
5413 ;; always
5414 (sit-for 0)))
eec82323
LMI
5415 (unless threads
5416 (setq gnus-tmp-level 0)))))
5417 (gnus-message 7 "Generating summary...done"))
5418
5419(defun gnus-summary-prepare-unthreaded (headers)
5420 "Generate an unthreaded summary buffer based on HEADERS."
5421 (let (header number mark)
5422
5423 (beginning-of-line)
5424
5425 (while headers
5426 ;; We may have to root out some bad articles...
5427 (when (memq (setq number (mail-header-number
5428 (setq header (pop headers))))
5429 gnus-newsgroup-limit)
5430 ;; Mark article as read when it has a low score.
5431 (when (and gnus-summary-mark-below
5432 (< (or (cdr (assq number gnus-newsgroup-scored))
5433 gnus-summary-default-score 0)
5434 gnus-summary-mark-below)
5435 (not (gnus-summary-article-ancient-p number)))
5436 (setq gnus-newsgroup-unreads
5437 (delq number gnus-newsgroup-unreads))
5438 (if gnus-newsgroup-auto-expire
5439 (push number gnus-newsgroup-expirable)
5440 (push (cons number gnus-low-score-mark)
5441 gnus-newsgroup-reads)))
5442
5443 (setq mark (gnus-article-mark number))
5444 (push (gnus-data-make number mark (1+ (point)) header 0)
5445 gnus-newsgroup-data)
5446 (gnus-summary-insert-line
5447 header 0 number
23f87bed 5448 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5449 mark (memq number gnus-newsgroup-replied)
5450 (memq number gnus-newsgroup-expirable)
5451 (mail-header-subject header) nil
5452 (cdr (assq number gnus-newsgroup-scored))
5453 (memq number gnus-newsgroup-processable))))))
5454
16409b0b
GM
5455(defun gnus-summary-remove-list-identifiers ()
5456 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5457 (let ((regexp (if (consp gnus-list-identifiers)
5458 (mapconcat 'identity gnus-list-identifiers " *\\|")
5459 gnus-list-identifiers))
5460 changed subject)
5461 (when regexp
01c52d31 5462 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
23f87bed
MB
5463 (dolist (header gnus-newsgroup-headers)
5464 (setq subject (mail-header-subject header)
5465 changed nil)
01c52d31 5466 (while (string-match regexp subject)
23f87bed 5467 (setq subject
01c52d31 5468 (concat (substring subject 0 (match-beginning 1))
23f87bed
MB
5469 (substring subject (match-end 0)))
5470 changed t))
23f87bed 5471 (when changed
01c52d31
MB
5472 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5473 (setq subject
5474 (concat (substring subject 0 (match-beginning 1))
5475 (substring subject (match-end 1)))))
23f87bed
MB
5476 (mail-header-set-subject header subject))))))
5477
4ddab346 5478(defun gnus-fetch-headers (articles &optional limit force-new dependencies)
23f87bed
MB
5479 "Fetch headers of ARTICLES."
5480 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5481 (gnus-message 5 "Fetching headers for %s..." name)
5482 (prog1
5483 (if (eq 'nov
5484 (setq gnus-headers-retrieved-by
5485 (gnus-retrieve-headers
5486 articles gnus-newsgroup-name
4ddab346
G
5487 (or limit
5488 ;; We might want to fetch old headers, but
5489 ;; not if there is only 1 article.
5490 (and (or (and
5491 (not (eq gnus-fetch-old-headers 'some))
5492 (not (numberp gnus-fetch-old-headers)))
5493 (> (length articles) 1))
5494 gnus-fetch-old-headers)))))
23f87bed 5495 (gnus-get-newsgroup-headers-xover
4ddab346
G
5496 articles force-new dependencies gnus-newsgroup-name t)
5497 (gnus-get-newsgroup-headers dependencies force-new))
23f87bed 5498 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5499
6748645f 5500(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5501 "Select newsgroup GROUP.
6748645f
LMI
5502If READ-ALL is non-nil, all articles in the group are selected.
5503If SELECT-ARTICLES, only select those articles from GROUP."
01c52d31 5504 (let* ((entry (gnus-group-entry group))
eec82323
LMI
5505 ;;!!! Dirty hack; should be removed.
5506 (gnus-summary-ignore-duplicates
23f87bed 5507 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5508 t
5509 gnus-summary-ignore-duplicates))
5510 (info (nth 2 entry))
01c52d31 5511 charset articles fetched-articles cached)
eec82323
LMI
5512
5513 (unless (gnus-check-server
475e0e0c
GM
5514 (set (make-local-variable 'gnus-current-select-method)
5515 (gnus-find-method-for-group group)))
eec82323 5516 (error "Couldn't open server"))
01c52d31 5517 (setq charset (gnus-group-name-charset gnus-current-select-method group))
eec82323
LMI
5518
5519 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5520 (gnus-activate-group group) ; Or we can activate it...
5521 (progn ; Or we bug out.
5522 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5523 (gnus-kill-buffer (current-buffer)))
01c52d31
MB
5524 (error
5525 "Couldn't activate group %s: %s"
5526 (mm-decode-coding-string group charset)
5527 (mm-decode-coding-string (gnus-status-message group) charset))))
eec82323
LMI
5528
5529 (unless (gnus-request-group group t)
20a673b2
KY
5530 (when (equal major-mode 'gnus-summary-mode)
5531 (gnus-kill-buffer (current-buffer)))
5532 (error "Couldn't request group %s: %s"
5533 (mm-decode-coding-string group charset)
5534 (mm-decode-coding-string (gnus-status-message group) charset)))
eec82323 5535
23f87bed 5536 (when gnus-agent
54506618 5537 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5538
23f87bed
MB
5539 (setq gnus-summary-use-undownloaded-faces
5540 (gnus-agent-find-parameter
5541 group
5542 'agent-enable-undownloaded-faces)))
5543
5544 (setq gnus-newsgroup-name group
5545 gnus-newsgroup-unselected nil
5546 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5547
5548 (let ((display (gnus-group-find-parameter group 'display)))
5549 (setq gnus-newsgroup-display
5550 (cond
5551 ((not (zerop (or (car-safe read-all) 0)))
5552 ;; The user entered the group with C-u SPC/RET, let's show
5553 ;; all articles.
5554 'gnus-not-ignore)
5555 ((eq display 'all)
5556 'gnus-not-ignore)
5557 ((arrayp display)
5558 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5559 ((numberp display)
5560 ;; The following is probably the "correct" solution, but
5561 ;; it makes Gnus fetch all headers and then limit the
5562 ;; articles (which is slow), so instead we hack the
5563 ;; select-articles parameter instead. -- Simon Josefsson
5564 ;; <jas@kth.se>
5565 ;;
5566 ;; (gnus-byte-compile
5567 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5568 ;; display)))))
5569 (setq select-articles
5570 (gnus-uncompress-range
5571 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5572 (if (> tmp 0)
5573 tmp
5574 1))
5575 (cdr (gnus-active group)))))
5576 nil)
5577 (t
5578 nil))))
eec82323 5579
23f87bed 5580 (gnus-summary-setup-default-charset)
eec82323
LMI
5581
5582 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5583 (when (gnus-virtual-group-p group)
5584 (setq cached gnus-newsgroup-cached))
5585
5586 (setq gnus-newsgroup-unreads
23f87bed
MB
5587 (gnus-sorted-ndifference
5588 (gnus-sorted-ndifference gnus-newsgroup-unreads
5589 gnus-newsgroup-marked)
eec82323
LMI
5590 gnus-newsgroup-dormant))
5591
5592 (setq gnus-newsgroup-processable nil)
5593
5594 (gnus-update-read-articles group gnus-newsgroup-unreads)
eec82323 5595
23f87bed
MB
5596 ;; Adjust and set lists of article marks.
5597 (when info
5598 (gnus-adjust-marked-articles info))
6748645f
LMI
5599 (if (setq articles select-articles)
5600 (setq gnus-newsgroup-unselected
23f87bed 5601 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5602 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5603
5604 (cond
5605 ((null articles)
5606 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5607 'quit)
5608 ((eq articles 0) nil)
5609 (t
5610 ;; Init the dependencies hash table.
5611 (setq gnus-newsgroup-dependencies
5612 (gnus-make-hashtable (length articles)))
16409b0b 5613 (gnus-set-global-variables)
eec82323 5614 ;; Retrieve the headers and read them in.
23f87bed
MB
5615
5616 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5617
5618 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5619 (when cached
5620 (setq gnus-newsgroup-cached cached))
5621
5622 ;; Suppress duplicates?
5623 (when gnus-suppress-duplicates
5624 (gnus-dup-suppress-articles))
5625
5626 ;; Set the initial limit.
5627 (setq gnus-newsgroup-limit (copy-sequence articles))
5628 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5629 (setq fetched-articles
5630 (mapcar (lambda (headers) (mail-header-number headers))
5631 gnus-newsgroup-headers))
5632 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5633 (setq gnus-newsgroup-unreads
23f87bed
MB
5634 (gnus-sorted-nintersection
5635 gnus-newsgroup-unreads fetched-articles))
5636 (gnus-compute-unseen-list)
5637
eec82323
LMI
5638 ;; Removed marked articles that do not exist.
5639 (gnus-update-missing-marks
23f87bed 5640 (gnus-sorted-difference articles fetched-articles))
eec82323 5641 ;; We might want to build some more threads first.
6748645f
LMI
5642 (when (and gnus-fetch-old-headers
5643 (eq gnus-headers-retrieved-by 'nov))
5644 (if (eq gnus-fetch-old-headers 'invisible)
5645 (gnus-build-all-threads)
5646 (gnus-build-old-threads)))
5647 ;; Let the Gnus agent mark articles as read.
5648 (when gnus-agent
5649 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5650 ;; Remove list identifiers from subject
5651 (when gnus-list-identifiers
5652 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5653 ;; Check whether auto-expire is to be done in this group.
5654 (setq gnus-newsgroup-auto-expire
5655 (gnus-group-auto-expirable-p group))
5656 ;; Set up the article buffer now, if necessary.
01c52d31
MB
5657 (unless (and gnus-single-article-buffer
5658 (equal gnus-article-buffer "*Article*"))
eec82323
LMI
5659 (gnus-article-setup-buffer))
5660 ;; First and last article in this newsgroup.
5661 (when gnus-newsgroup-headers
5662 (setq gnus-newsgroup-begin
5663 (mail-header-number (car gnus-newsgroup-headers))
5664 gnus-newsgroup-end
5665 (mail-header-number
5666 (gnus-last-element gnus-newsgroup-headers))))
5667 ;; GROUP is successfully selected.
5668 (or gnus-newsgroup-headers t)))))
5669
23f87bed
MB
5670(defun gnus-compute-unseen-list ()
5671 ;; The `seen' marks are treated specially.
5672 (if (not gnus-newsgroup-seen)
5673 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5674 (setq gnus-newsgroup-unseen
5675 (gnus-inverse-list-range-intersection
5676 gnus-newsgroup-articles gnus-newsgroup-seen))))
5677
d09ae6ca
GM
5678(declare-function gnus-get-predicate "gnus-agent" (predicate))
5679
23f87bed
MB
5680(defun gnus-summary-display-make-predicate (display)
5681 (require 'gnus-agent)
5682 (when (= (length display) 1)
5683 (setq display (car display)))
5684 (unless gnus-summary-display-cache
5685 (dolist (elem (append '((unread . unread)
5686 (read . read)
5687 (unseen . unseen))
5688 gnus-article-mark-lists))
5689 (push (cons (cdr elem)
3a3cbf0a 5690 (gnus-byte-compile ;Why bother?
23f87bed
MB
5691 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5692 gnus-summary-display-cache)))
5693 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5694 (gnus-category-predicate-cache gnus-summary-display-cache))
5695 (gnus-get-predicate display)))
5696
3a3cbf0a
SM
5697;; Uses the dynamically bound `gnus-number' variable.
5698(defvar gnus-number)
23f87bed 5699(defun gnus-article-marked-p (type &optional article)
3a3cbf0a 5700 (let ((article (or article gnus-number)))
23f87bed
MB
5701 (cond
5702 ((eq type 'tick)
5703 (memq article gnus-newsgroup-marked))
5704 ((eq type 'spam)
5705 (memq article gnus-newsgroup-spam-marked))
5706 ((eq type 'unsend)
5707 (memq article gnus-newsgroup-unsendable))
5708 ((eq type 'undownload)
5709 (memq article gnus-newsgroup-undownloaded))
5710 ((eq type 'download)
5711 (memq article gnus-newsgroup-downloadable))
5712 ((eq type 'unread)
5713 (memq article gnus-newsgroup-unreads))
5714 ((eq type 'read)
5715 (memq article gnus-newsgroup-reads))
5716 ((eq type 'dormant)
5717 (memq article gnus-newsgroup-dormant) )
5718 ((eq type 'expire)
5719 (memq article gnus-newsgroup-expirable))
5720 ((eq type 'reply)
5721 (memq article gnus-newsgroup-replied))
5722 ((eq type 'killed)
5723 (memq article gnus-newsgroup-killed))
5724 ((eq type 'bookmark)
5725 (assq article gnus-newsgroup-bookmarks))
5726 ((eq type 'score)
5727 (assq article gnus-newsgroup-scored))
5728 ((eq type 'save)
5729 (memq article gnus-newsgroup-saved))
5730 ((eq type 'cache)
5731 (memq article gnus-newsgroup-cached))
5732 ((eq type 'forward)
5733 (memq article gnus-newsgroup-forwarded))
5734 ((eq type 'seen)
5735 (not (memq article gnus-newsgroup-unseen)))
5736 ((eq type 'recent)
5737 (memq article gnus-newsgroup-recent))
5738 (t t))))
5739
eec82323 5740(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5741 "Find out what articles the user wants to read."
26c9afc3 5742 (let* ((articles
eec82323
LMI
5743 ;; Select all articles if `read-all' is non-nil, or if there
5744 ;; are no unread articles.
5745 (if (or read-all
5746 (and (zerop (length gnus-newsgroup-marked))
5747 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5748 ;; Fetch all if the predicate is non-nil.
5749 gnus-newsgroup-display)
5750 ;; We want to select the headers for all the articles in
5751 ;; the group, so we select either all the active
5752 ;; articles in the group, or (if that's nil), the
5753 ;; articles in the cache.
16409b0b 5754 (or
4b70e299 5755 (if gnus-newsgroup-maximum-articles
11abff8e
MB
5756 (let ((active (gnus-active group)))
5757 (gnus-uncompress-range
5758 (cons (max (car active)
4b70e299
MB
5759 (- (cdr active)
5760 gnus-newsgroup-maximum-articles
5761 -1))
11abff8e
MB
5762 (cdr active))))
5763 (gnus-uncompress-range (gnus-active group)))
16409b0b 5764 (gnus-cache-articles-in-group group))
23f87bed
MB
5765 ;; Select only the "normal" subset of articles.
5766 (gnus-sorted-nunion
5767 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5768 gnus-newsgroup-unreads)))
eec82323
LMI
5769 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5770 (scored (length scored-list))
5771 (number (length articles))
5772 (marked (+ (length gnus-newsgroup-marked)
5773 (length gnus-newsgroup-dormant)))
5774 (select
5775 (cond
5776 ((numberp read-all)
5777 read-all)
23f87bed
MB
5778 ((numberp gnus-newsgroup-display)
5779 gnus-newsgroup-display)
eec82323
LMI
5780 (t
5781 (condition-case ()
5782 (cond
5783 ((and (or (<= scored marked) (= scored number))
5784 (numberp gnus-large-newsgroup)
5785 (> number gnus-large-newsgroup))
23f87bed
MB
5786 (let* ((cursor-in-echo-area nil)
5787 (initial (gnus-parameter-large-newsgroup-initial
5788 gnus-newsgroup-name))
5789 (input
5790 (read-string
5791 (format
5792 "How many articles from %s (%s %d): "
01c52d31 5793 (gnus-group-decoded-name gnus-newsgroup-name)
23f87bed
MB
5794 (if initial "max" "default")
5795 number)
5796 (if initial
5797 (cons (number-to-string initial)
5798 0)))))
eec82323
LMI
5799 (if (string-match "^[ \t]*$" input) number input)))
5800 ((and (> scored marked) (< scored number)
5801 (> (- scored number) 20))
5802 (let ((input
5803 (read-string
5804 (format "%s %s (%d scored, %d total): "
5805 "How many articles from"
23f87bed
MB
5806 (gnus-group-decoded-name group)
5807 scored number))))
eec82323
LMI
5808 (if (string-match "^[ \t]*$" input)
5809 number input)))
5810 (t number))
d4dfaa19
DL
5811 (quit
5812 (message "Quit getting the articles to read")
5813 nil))))))
eec82323
LMI
5814 (setq select (if (stringp select) (string-to-number select) select))
5815 (if (or (null select) (zerop select))
5816 select
5817 (if (and (not (zerop scored)) (<= (abs select) scored))
5818 (progn
5819 (setq articles (sort scored-list '<))
5820 (setq number (length articles)))
5821 (setq articles (copy-sequence articles)))
5822
5823 (when (< (abs select) number)
5824 (if (< select 0)
5825 ;; Select the N oldest articles.
5826 (setcdr (nthcdr (1- (abs select)) articles) nil)
5827 ;; Select the N most recent articles.
5828 (setq articles (nthcdr (- number select) articles))))
5829 (setq gnus-newsgroup-unselected
23f87bed 5830 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5831 (when gnus-alter-articles-to-read-function
23f87bed 5832 (setq articles
a1506d29 5833 (sort
16409b0b 5834 (funcall gnus-alter-articles-to-read-function
23f87bed 5835 gnus-newsgroup-name articles)
16409b0b 5836 '<)))
eec82323
LMI
5837 articles)))
5838
5839(defun gnus-killed-articles (killed articles)
5840 (let (out)
5841 (while articles
5842 (when (inline (gnus-member-of-range (car articles) killed))
5843 (push (car articles) out))
5844 (setq articles (cdr articles)))
5845 out))
5846
5847(defun gnus-uncompress-marks (marks)
5848 "Uncompress the mark ranges in MARKS."
5849 (let ((uncompressed '(score bookmark))
5850 out)
5851 (while marks
5852 (if (memq (caar marks) uncompressed)
5853 (push (car marks) out)
5854 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5855 (setq marks (cdr marks)))
5856 out))
5857
23f87bed
MB
5858(defun gnus-article-mark-to-type (mark)
5859 "Return the type of MARK."
5860 (or (cadr (assq mark gnus-article-special-mark-lists))
5861 'list))
5862
5863(defun gnus-article-unpropagatable-p (mark)
5864 "Return whether MARK should be propagated to back end."
5865 (memq mark gnus-article-unpropagated-mark-lists))
5866
eec82323 5867(defun gnus-adjust-marked-articles (info)
16409b0b 5868 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5869 (let* ((marked-lists (gnus-info-marks info))
5870 (active (gnus-active (gnus-info-group info)))
5871 (min (car active))
5872 (max (cdr active))
5873 (types gnus-article-mark-lists)
54506618
MB
5874 marks var articles article mark mark-type
5875 bgn end)
0617bb00
LMI
5876 ;; Hack to avoid adjusting marks for imap.
5877 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5878 'nnimap)
5879 (setq min 1))
eec82323 5880
23f87bed
MB
5881 (dolist (marks marked-lists)
5882 (setq mark (car marks)
5883 mark-type (gnus-article-mark-to-type mark)
5884 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5885
23f87bed
MB
5886 ;; We set the variable according to the type of the marks list,
5887 ;; and then adjust the marks to a subset of the active articles.
eec82323 5888 (cond
54506618 5889 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5890 ((eq mark-type 'list)
54506618
MB
5891 ;; Simultaneously uncompress and clip to active range
5892 ;; See gnus-uncompress-range for a description of possible marks
5893 (let (l lh)
5894 (if (not (cadr marks))
5895 (set var nil)
5896 (setq articles (if (numberp (cddr marks))
5897 (list (cdr marks))
5898 (cdr marks))
5899 lh (cons nil nil)
5900 l lh)
5901
5902 (while (setq article (pop articles))
5903 (cond ((consp article)
5904 (setq bgn (max (car article) min)
5905 end (min (cdr article) max))
5906 (while (<= bgn end)
5907 (setq l (setcdr l (cons bgn nil))
5908 bgn (1+ bgn))))
5909 ((and (<= min article)
5910 (>= max article))
5911 (setq l (setcdr l (cons article nil))))))
5912 (set var (cdr lh)))))
eec82323 5913 ;; Adjust assocs.
23f87bed
MB
5914 ((eq mark-type 'tuple)
5915 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5916 (when (not (listp (cdr (symbol-value var))))
5917 (set var (list (symbol-value var))))
5918 (when (not (listp (cdr articles)))
5919 (setq articles (list articles)))
eec82323
LMI
5920 (while articles
5921 (when (or (not (consp (setq article (pop articles))))
5922 (< (car article) min)
5923 (> (car article) max))
23f87bed
MB
5924 (set var (delq article (symbol-value var))))))
5925 ;; Adjust ranges (sloppily).
5926 ((eq mark-type 'range)
5927 (cond
5928 ((eq mark 'seen)
5929 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5930 ;; It should be (seen (NUM1 . NUM2)).
5931 (when (numberp (cddr marks))
5932 (setcdr marks (list (cdr marks))))
5933 (setq articles (cdr marks))
5934 (while (and articles
5935 (or (and (consp (car articles))
5936 (> min (cdar articles)))
5937 (and (numberp (car articles))
5938 (> min (car articles)))))
5939 (pop articles))
5940 (set var articles))))))))
eec82323
LMI
5941
5942(defun gnus-update-missing-marks (missing)
6748645f 5943 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 5944 (when missing
23f87bed 5945 (let (var m)
eec82323 5946 ;; Go through all types.
23f87bed
MB
5947 (dolist (elem gnus-article-mark-lists)
5948 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5949 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5950 (when (symbol-value var)
5951 ;; This list has articles. So we delete all missing
5952 ;; articles from it.
5953 (setq m missing)
5954 (while m
5955 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
5956
5957(defun gnus-update-marks ()
5958 "Enter the various lists of marked articles into the newsgroup info list."
5959 (let ((types gnus-article-mark-lists)
5960 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 5961 type list newmarked symbol delta-marks)
eec82323 5962 (when info
16409b0b 5963 ;; Add all marks lists to the list of marks lists.
eec82323 5964 (while (setq type (pop types))
16409b0b
GM
5965 (setq list (symbol-value
5966 (setq symbol
23f87bed 5967 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 5968
16409b0b 5969 (when list
eec82323
LMI
5970 ;; Get rid of the entries of the articles that have the
5971 ;; default score.
5972 (when (and (eq (cdr type) 'score)
5973 gnus-save-score
5974 list)
5975 (let* ((arts list)
5976 (prev (cons nil list))
5977 (all prev))
5978 (while arts
5979 (if (or (not (consp (car arts)))
5980 (= (cdar arts) gnus-summary-default-score))
5981 (setcdr prev (cdr arts))
5982 (setq prev arts))
5983 (setq arts (cdr arts)))
16409b0b
GM
5984 (setq list (cdr all)))))
5985
23f87bed
MB
5986 (when (eq (cdr type) 'seen)
5987 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5988
5989 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 5990 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 5991
23f87bed
MB
5992 (when (and (gnus-check-backend-function
5993 'request-set-mark gnus-newsgroup-name)
5994 (not (gnus-article-unpropagatable-p (cdr type))))
5995 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5996 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5997 (add (gnus-remove-from-range
5998 (gnus-copy-sequence list) old)))
5999 (when add
6000 (push (list add 'add (list (cdr type))) delta-marks))
6001 (when del
b069e5a6
G
6002 ;; Don't delete marks from outside the active range. This
6003 ;; shouldn't happen, but is a sanity check.
6004 (setq del (gnus-sorted-range-intersection
6005 (gnus-active gnus-newsgroup-name) del))
23f87bed 6006 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 6007
16409b0b
GM
6008 (when list
6009 (push (cons (cdr type) list) newmarked)))
6010
6011 (when delta-marks
6012 (unless (gnus-check-group gnus-newsgroup-name)
6013 (error "Can't open server for %s" gnus-newsgroup-name))
6014 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 6015
eec82323
LMI
6016 ;; Enter these new marks into the info of the group.
6017 (if (nthcdr 3 info)
6018 (setcar (nthcdr 3 info) newmarked)
6019 ;; Add the marks lists to the end of the info.
6020 (when newmarked
6021 (setcdr (nthcdr 2 info) (list newmarked))))
6022
6023 ;; Cut off the end of the info if there's nothing else there.
6024 (let ((i 5))
6025 (while (and (> i 2)
6026 (not (nth i info)))
6027 (when (nthcdr (decf i) info)
6028 (setcdr (nthcdr i info) nil)))))))
6029
6030(defun gnus-set-mode-line (where)
16409b0b 6031 "Set the mode line of the article or summary buffers.
eec82323
LMI
6032If WHERE is `summary', the summary mode line format will be used."
6033 ;; Is this mode line one we keep updated?
16409b0b
GM
6034 (when (and (memq where gnus-updated-mode-lines)
6035 (symbol-value
6036 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323 6037 (let (mode-string)
c7a91ce1
SM
6038 ;; We evaluate this in the summary buffer since these
6039 ;; variables are buffer-local to that buffer.
6040 (with-current-buffer gnus-summary-buffer
6041 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
6042 ;; below.
6043 (let* ((mformat (symbol-value
6044 (intern
6045 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
6046 (gnus-tmp-group-name (gnus-mode-string-quote
6047 (gnus-group-decoded-name
6048 gnus-newsgroup-name)))
eec82323
LMI
6049 (gnus-tmp-article-number (or gnus-current-article 0))
6050 (gnus-tmp-unread gnus-newsgroup-unreads)
6051 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6052 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6053 (gnus-tmp-unread-and-unselected
6054 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6055 (zerop gnus-tmp-unselected))
6056 "")
6057 ((zerop gnus-tmp-unselected)
6058 (format "{%d more}" gnus-tmp-unread-and-unticked))
6059 (t (format "{%d(+%d) more}"
6060 gnus-tmp-unread-and-unticked
6061 gnus-tmp-unselected))))
6062 (gnus-tmp-subject
6063 (if (and gnus-current-headers
6064 (vectorp gnus-current-headers))
6065 (gnus-mode-string-quote
6066 (mail-header-subject gnus-current-headers))
6067 ""))
6068 bufname-length max-len
23f87bed 6069 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
6070 (setq mode-string (eval mformat))
6071 (setq bufname-length (if (string-match "%b" mode-string)
6072 (- (length
6073 (buffer-name
6074 (if (eq where 'summary)
6075 nil
6076 (get-buffer gnus-article-buffer))))
6077 2)
6078 0))
6079 (setq max-len (max 4 (if gnus-mode-non-string-length
6080 (- (window-width)
6081 gnus-mode-non-string-length
6082 bufname-length)
6083 (length mode-string))))
6084 ;; We might have to chop a bit of the string off...
6085 (when (> (length mode-string) max-len)
6086 (setq mode-string
16409b0b 6087 (concat (truncate-string-to-width mode-string (- max-len 3))
29d31b55 6088 "...")))))
eec82323
LMI
6089 ;; Update the mode line.
6090 (setq mode-line-buffer-identification
6091 (gnus-mode-line-buffer-identification (list mode-string)))
6092 (set-buffer-modified-p t))))
6093
6094(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6095 "Go through the HEADERS list and add all Xrefs to a hash table.
6096The resulting hash table is returned, or nil if no Xrefs were found."
6097 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6098 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6099 (xref-hashtb (gnus-make-hashtable))
6100 start group entry number xrefs header)
6101 (while headers
6102 (setq header (pop headers))
6103 (when (and (setq xrefs (mail-header-xref header))
6104 (not (memq (setq number (mail-header-number header))
6105 unreads)))
6106 (setq start 0)
6107 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6108 (setq start (match-end 0))
6109 (setq group (if prefix
6110 (concat prefix (substring xrefs (match-beginning 1)
6111 (match-end 1)))
6112 (substring xrefs (match-beginning 1) (match-end 1))))
6113 (setq number
e9bd5782 6114 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
6115 (match-end 2))))
6116 (if (setq entry (gnus-gethash group xref-hashtb))
6117 (setcdr entry (cons number (cdr entry)))
6118 (gnus-sethash group (cons number nil) xref-hashtb)))))
6119 (and start xref-hashtb)))
6120
6121(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6122 "Look through all the headers and mark the Xrefs as read."
6123 (let ((virtual (gnus-virtual-group-p from-newsgroup))
01c52d31 6124 name info xref-hashtb idlist method nth4)
398a825b 6125 (with-current-buffer gnus-group-buffer
eec82323
LMI
6126 (when (setq xref-hashtb
6127 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6128 (mapatoms
6129 (lambda (group)
6130 (unless (string= from-newsgroup (setq name (symbol-name group)))
6131 (setq idlist (symbol-value group))
6132 ;; Dead groups are not updated.
6133 (and (prog1
01c52d31 6134 (setq info (gnus-get-info name))
eec82323
LMI
6135 (when (stringp (setq nth4 (gnus-info-method info)))
6136 (setq nth4 (gnus-server-to-method nth4))))
6137 ;; Only do the xrefs if the group has the same
6138 ;; select method as the group we have just read.
6139 (or (gnus-methods-equal-p
6140 nth4 (gnus-find-method-for-group from-newsgroup))
6141 virtual
6142 (equal nth4 (setq method (gnus-find-method-for-group
6143 from-newsgroup)))
6144 (and (equal (car nth4) (car method))
6145 (equal (nth 1 nth4) (nth 1 method))))
6146 gnus-use-cross-reference
6147 (or (not (eq gnus-use-cross-reference t))
6148 virtual
6149 ;; Only do cross-references on subscribed
6150 ;; groups, if that is what is wanted.
6151 (<= (gnus-info-level info) gnus-level-subscribed))
6152 (gnus-group-make-articles-read name idlist))))
6153 xref-hashtb)))))
6154
6748645f 6155(defun gnus-compute-read-articles (group articles)
01c52d31 6156 (let* ((entry (gnus-group-entry group))
6748645f
LMI
6157 (info (nth 2 entry))
6158 (active (gnus-active group))
6159 ninfo)
6160 (when entry
16409b0b 6161 ;; First peel off all invalid article numbers.
6748645f
LMI
6162 (when active
6163 (let ((ids articles)
6164 id first)
6165 (while (setq id (pop ids))
6166 (when (and first (> id (cdr active)))
6167 ;; We'll end up in this situation in one particular
6168 ;; obscure situation. If you re-scan a group and get
6169 ;; a new article that is cross-posted to a different
6170 ;; group that has not been re-scanned, you might get
6171 ;; crossposted article that has a higher number than
6172 ;; Gnus believes possible. So we re-activate this
6173 ;; group as well. This might mean doing the
6174 ;; crossposting thingy will *increase* the number
6175 ;; of articles in some groups. Tsk, tsk.
6176 (setq active (or (gnus-activate-group group) active)))
6177 (when (or (> id (cdr active))
6178 (< id (car active)))
6179 (setq articles (delq id articles))))))
6180 ;; If the read list is nil, we init it.
6181 (if (and active
6182 (null (gnus-info-read info))
6183 (> (car active) 1))
6184 (setq ninfo (cons 1 (1- (car active))))
6185 (setq ninfo (gnus-info-read info)))
6186 ;; Then we add the read articles to the range.
6187 (gnus-add-to-range
6188 ninfo (setq articles (sort articles '<))))))
6189
eec82323
LMI
6190(defun gnus-group-make-articles-read (group articles)
6191 "Update the info of GROUP to say that ARTICLES are read."
6192 (let* ((num 0)
01c52d31 6193 (entry (gnus-group-entry group))
eec82323
LMI
6194 (info (nth 2 entry))
6195 (active (gnus-active group))
6196 range)
de635afe
G
6197 (if (not entry)
6198 ;; Group that Gnus doesn't know exists, but still allow the
6199 ;; backend to set marks.
6200 (gnus-request-set-mark
6201 group (list (list (gnus-compress-sequence (sort articles #'<))
6202 'add '(read))))
6203 ;; Normal, subscribed groups.
6748645f 6204 (setq range (gnus-compute-read-articles group articles))
01c52d31 6205 (with-current-buffer gnus-group-buffer
6748645f
LMI
6206 (gnus-undo-register
6207 `(progn
6208 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6209 (gnus-info-set-read ',info ',(gnus-info-read info))
6210 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 6211 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
6212 (gnus-group-update-group ,group t))))
6213 ;; Add the read articles to the range.
6214 (gnus-info-set-read info range)
23f87bed 6215 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
6216 ;; Then we have to re-compute how many unread
6217 ;; articles there are in this group.
6218 (when active
6219 (cond
6220 ((not range)
6221 (setq num (- (1+ (cdr active)) (car active))))
6222 ((not (listp (cdr range)))
6223 (setq num (- (cdr active) (- (1+ (cdr range))
6224 (car range)))))
6225 (t
6226 (while range
6227 (if (numberp (car range))
6228 (setq num (1+ num))
6229 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6230 (setq range (cdr range)))
6231 (setq num (- (cdr active) num))))
6232 ;; Update the number of unread articles.
6233 (setcar entry num)
6234 ;; Update the group buffer.
23f87bed
MB
6235 (unless (gnus-ephemeral-group-p group)
6236 (gnus-group-update-group group t))))))
eec82323 6237
eec82323
LMI
6238(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6239 (let ((cur nntp-server-buffer)
6240 (dependencies
6241 (or dependencies
01c52d31
MB
6242 (with-current-buffer gnus-summary-buffer
6243 gnus-newsgroup-dependencies)))
6244 headers id end ref number
16409b0b
GM
6245 (mail-parse-charset gnus-newsgroup-charset)
6246 (mail-parse-ignored-charsets
c7a91ce1
SM
6247 (save-current-buffer (condition-case nil
6248 (set-buffer gnus-summary-buffer)
6249 (error))
6250 gnus-newsgroup-ignored-charsets)))
6251 (with-current-buffer nntp-server-buffer
eec82323
LMI
6252 ;; Translate all TAB characters into SPACE characters.
6253 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 6254 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 6255 (ietf-drums-unfold-fws)
6748645f 6256 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6257 (let ((case-fold-search t)
6748645f 6258 in-reply-to header p lines chars)
eec82323 6259 (goto-char (point-min))
01ccbb85 6260 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
6261 ;; do not begin with 2 or 3.
6262 (while (re-search-forward "^[23][0-9]+ " nil t)
6263 (setq id nil
6264 ref nil)
6265 ;; This implementation of this function, with nine
6266 ;; search-forwards instead of the one re-search-forward and
6267 ;; a case (which basically was the old function) is actually
01ccbb85 6268 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
6269 ;; can't have everything, I guess. Speed and elegance
6270 ;; doesn't always go hand in hand.
6271 (setq
6272 header
6273 (vector
6274 ;; Number.
6275 (prog1
01c52d31 6276 (setq number (read cur))
eec82323
LMI
6277 (end-of-line)
6278 (setq p (point))
6279 (narrow-to-region (point)
6280 (or (and (search-forward "\n.\n" nil t)
6281 (- (point) 2))
6282 (point))))
6283 ;; Subject.
6284 (progn
6285 (goto-char p)
23f87bed 6286 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
6287 (funcall gnus-decode-encoded-word-function
6288 (nnheader-header-value))
2bd3dcae 6289 "(none)"))
eec82323
LMI
6290 ;; From.
6291 (progn
6292 (goto-char p)
23f87bed 6293 (if (search-forward "\nfrom:" nil t)
343d6628 6294 (funcall gnus-decode-encoded-address-function
16409b0b 6295 (nnheader-header-value))
2bd3dcae 6296 "(nobody)"))
eec82323
LMI
6297 ;; Date.
6298 (progn
6299 (goto-char p)
23f87bed 6300 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6301 (nnheader-header-value) ""))
6302 ;; Message-ID.
6303 (progn
6304 (goto-char p)
6748645f
LMI
6305 (setq id (if (re-search-forward
6306 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6307 ;; We do it this way to make sure the Message-ID
6308 ;; is (somewhat) syntactically valid.
6309 (buffer-substring (match-beginning 1)
6310 (match-end 1))
eec82323
LMI
6311 ;; If there was no message-id, we just fake one
6312 ;; to make subsequent routines simpler.
01c52d31 6313 (nnheader-generate-fake-message-id number))))
eec82323
LMI
6314 ;; References.
6315 (progn
6316 (goto-char p)
23f87bed 6317 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6318 (progn
6319 (setq end (point))
6320 (prog1
6321 (nnheader-header-value)
6322 (setq ref
6323 (buffer-substring
6324 (progn
6325 (end-of-line)
6326 (search-backward ">" end t)
6327 (1+ (point)))
6328 (progn
6329 (search-backward "<" end t)
6330 (point))))))
6331 ;; Get the references from the in-reply-to header if there
6332 ;; were no references and the in-reply-to header looks
6333 ;; promising.
23f87bed 6334 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6335 (setq in-reply-to (nnheader-header-value))
6336 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6337 (let (ref2)
6338 (setq ref (substring in-reply-to (match-beginning 0)
6339 (match-end 0)))
6340 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6341 (setq ref2 (substring in-reply-to (match-beginning 0)
6342 (match-end 0)))
6343 (when (> (length ref2) (length ref))
6344 (setq ref ref2)))
6345 ref)
eec82323
LMI
6346 (setq ref nil))))
6347 ;; Chars.
6748645f
LMI
6348 (progn
6349 (goto-char p)
6350 (if (search-forward "\nchars: " nil t)
6351 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6352 chars -1)
6353 -1))
eec82323
LMI
6354 ;; Lines.
6355 (progn
6356 (goto-char p)
6357 (if (search-forward "\nlines: " nil t)
a8151ef7 6358 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6359 lines -1)
6360 -1))
eec82323
LMI
6361 ;; Xref.
6362 (progn
6363 (goto-char p)
23f87bed 6364 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6365 (nnheader-header-value)))
6366 ;; Extra.
6367 (when gnus-extra-headers
6368 (let ((extra gnus-extra-headers)
6369 out)
6370 (while extra
6371 (goto-char p)
6372 (when (search-forward
23f87bed 6373 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6374 (push (cons (car extra) (nnheader-header-value))
6375 out))
6376 (pop extra))
6377 out))))
eec82323
LMI
6378 (when (equal id ref)
6379 (setq ref nil))
6748645f
LMI
6380
6381 (when gnus-alter-header-function
6382 (funcall gnus-alter-header-function header)
6383 (setq id (mail-header-id header)
6384 ref (gnus-parent-id (mail-header-references header))))
6385
6386 (when (setq header
6387 (gnus-dependencies-add-header
6388 header dependencies force-new))
eec82323
LMI
6389 (push header headers))
6390 (goto-char (point-max))
6391 (widen))
6392 (nreverse headers)))))
6393
eec82323
LMI
6394;; Goes through the xover lines and returns a list of vectors
6395(defun gnus-get-newsgroup-headers-xover (sequence &optional
6396 force-new dependencies
6397 group also-fetch-heads)
16409b0b
GM
6398 "Parse the news overview data in the server buffer.
6399Return a list of headers that match SEQUENCE (see
6400`nntp-retrieve-headers')."
eec82323
LMI
6401 ;; Get the Xref when the users reads the articles since most/some
6402 ;; NNTP servers do not include Xrefs when using XOVER.
6403 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6404 (let ((mail-parse-charset gnus-newsgroup-charset)
6405 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6406 (cur nntp-server-buffer)
eec82323 6407 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6408 (allp (cond
6409 ((eq gnus-read-all-available-headers t)
6410 t)
14e6dc54
MB
6411 ((and (stringp gnus-read-all-available-headers)
6412 group)
23f87bed
MB
6413 (string-match gnus-read-all-available-headers group))
6414 (t
6415 nil)))
eec82323 6416 number headers header)
c7a91ce1 6417 (with-current-buffer nntp-server-buffer
16409b0b 6418 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6419 ;; Allow the user to mangle the headers before parsing them.
6748645f 6420 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6421 (goto-char (point-min))
23f87bed
MB
6422 (gnus-parse-without-error
6423 (while (and (or sequence allp)
6424 (not (eobp)))
6425 (setq number (read cur))
6426 (when (not allp)
6427 (while (and sequence
6428 (< (car sequence) number))
6429 (setq sequence (cdr sequence))))
6430 (when (and (or allp
6431 (and sequence
6432 (eq number (car sequence))))
6433 (progn
6434 (setq sequence (cdr sequence))
6435 (setq header (inline
6436 (gnus-nov-parse-line
6437 number dependencies force-new)))))
6438 (push header headers))
6439 (forward-line 1)))
eec82323
LMI
6440 ;; A common bug in inn is that if you have posted an article and
6441 ;; then retrieves the active file, it will answer correctly --
6442 ;; the new article is included. However, a NOV entry for the
6443 ;; article may not have been generated yet, so this may fail.
6444 ;; We work around this problem by retrieving the last few
6445 ;; headers using HEAD.
6446 (if (or (not also-fetch-heads)
6447 (not sequence))
6448 ;; We (probably) got all the headers.
6449 (nreverse headers)
6450 (let ((gnus-nov-is-evil t))
6451 (nconc
6452 (nreverse headers)
23f87bed 6453 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6454 (gnus-get-newsgroup-headers))))))))
6455
6456(defun gnus-article-get-xrefs ()
6457 "Fill in the Xref value in `gnus-current-headers', if necessary.
6458This is meant to be called in `gnus-article-internal-prepare-hook'."
01c52d31
MB
6459 (let ((headers (with-current-buffer gnus-summary-buffer
6460 gnus-current-headers)))
eec82323
LMI
6461 (or (not gnus-use-cross-reference)
6462 (not headers)
6463 (and (mail-header-xref headers)
6464 (not (string= (mail-header-xref headers) "")))
6465 (let ((case-fold-search t)
6466 xref)
6467 (save-restriction
6468 (nnheader-narrow-to-headers)
6469 (goto-char (point-min))
16409b0b
GM
6470 (when (or (and (not (eobp))
6471 (eq (downcase (char-after)) ?x)
eec82323
LMI
6472 (looking-at "Xref:"))
6473 (search-forward "\nXref:" nil t))
6474 (goto-char (1+ (match-end 0)))
01c52d31 6475 (setq xref (buffer-substring (point) (point-at-eol)))
eec82323
LMI
6476 (mail-header-set-xref headers xref)))))))
6477
6478(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6479 "Find article ID and insert the summary line for that article.
6480OLD-HEADER can either be a header or a line number to insert
6481the subject line on."
6482 (let* ((line (and (numberp old-header) old-header))
6483 (old-header (and (vectorp old-header) old-header))
6484 (header (cond ((and old-header use-old-header)
16409b0b
GM
6485 old-header)
6486 ((and (numberp id)
6487 (gnus-number-to-header id))
6488 (gnus-number-to-header id))
6489 (t
6490 (gnus-read-header id))))
6491 (number (and (numberp id) id))
6492 d)
eec82323
LMI
6493 (when header
6494 ;; Rebuild the thread that this article is part of and go to the
6495 ;; article we have fetched.
6496 (when (and (not gnus-show-threads)
6497 old-header)
6748645f
LMI
6498 (when (and number
6499 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6500 (goto-char (gnus-data-pos d))
6501 (gnus-data-remove
6502 number
01c52d31 6503 (- (point-at-bol)
eec82323 6504 (prog1
01c52d31 6505 (1+ (point-at-eol))
eec82323 6506 (gnus-delete-line))))))
23f87bed
MB
6507 ;; Remove list identifiers from subject.
6508 (when gnus-list-identifiers
6509 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6510 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6511 (when old-header
6512 (mail-header-set-number header (mail-header-number old-header)))
6513 (setq gnus-newsgroup-sparse
6514 (delq (setq number (mail-header-number header))
6515 gnus-newsgroup-sparse))
6516 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6517 (push number gnus-newsgroup-limit)
6518 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6519 (gnus-summary-goto-subject number nil t))
6520 (when (and (numberp number)
6521 (> number 0))
6522 ;; We have to update the boundaries even if we can't fetch the
6523 ;; article if ID is a number -- so that the next `P' or `N'
6524 ;; command will fetch the previous (or next) article even
6525 ;; if the one we tried to fetch this time has been canceled.
6526 (when (> number gnus-newsgroup-end)
6527 (setq gnus-newsgroup-end number))
6528 (when (< number gnus-newsgroup-begin)
6529 (setq gnus-newsgroup-begin number))
6530 (setq gnus-newsgroup-unselected
6531 (delq number gnus-newsgroup-unselected)))
6532 ;; Report back a success?
6533 (and header (mail-header-number header))))
6534
6535;;; Process/prefix in the summary buffer
6536
6537(defun gnus-summary-work-articles (n)
6748645f
LMI
6538 "Return a list of articles to be worked upon.
6539The prefix argument, the list of process marked articles, and the
6540current article will be taken into consideration."
c7a91ce1 6541 (with-current-buffer gnus-summary-buffer
6748645f
LMI
6542 (cond
6543 (n
6544 ;; A numerical prefix has been given.
6545 (setq n (prefix-numeric-value n))
6546 (let ((backward (< n 0))
6547 (n (abs (prefix-numeric-value n)))
6548 articles article)
6549 (save-excursion
6550 (while
6551 (and (> n 0)
6552 (push (setq article (gnus-summary-article-number))
6553 articles)
6554 (if backward
6555 (gnus-summary-find-prev nil article)
6556 (gnus-summary-find-next nil article)))
6557 (decf n)))
6558 (nreverse articles)))
6559 ((and (gnus-region-active-p) (mark))
6560 (message "region active")
6561 ;; Work on the region between point and mark.
6562 (let ((max (max (point) (mark)))
6563 articles article)
6564 (save-excursion
7dafe00b 6565 (goto-char (min (point) (mark)))
6748645f
LMI
6566 (while
6567 (and
6568 (push (setq article (gnus-summary-article-number)) articles)
6569 (gnus-summary-find-next nil article)
6570 (< (point) max)))
6571 (nreverse articles))))
6572 (gnus-newsgroup-processable
6573 ;; There are process-marked articles present.
6574 ;; Save current state.
6575 (gnus-summary-save-process-mark)
6576 ;; Return the list.
6577 (reverse gnus-newsgroup-processable))
6578 (t
6579 ;; Just return the current article.
6580 (list (gnus-summary-article-number))))))
6581
6582(defmacro gnus-summary-iterate (arg &rest forms)
6583 "Iterate over the process/prefixed articles and do FORMS.
6584ARG is the interactive prefix given to the command. FORMS will be
6585executed with point over the summary line of the articles."
6586 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6587 `(let ((,articles (gnus-summary-work-articles ,arg)))
6588 (while ,articles
6589 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6590 ,@forms
6591 (pop ,articles)))))
6748645f
LMI
6592
6593(put 'gnus-summary-iterate 'lisp-indent-function 1)
6594(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6595
6596(defun gnus-summary-save-process-mark ()
6597 "Push the current set of process marked articles on the stack."
6598 (interactive)
6599 (push (copy-sequence gnus-newsgroup-processable)
6600 gnus-newsgroup-process-stack))
6601
6602(defun gnus-summary-kill-process-mark ()
6603 "Push the current set of process marked articles on the stack and unmark."
6604 (interactive)
6605 (gnus-summary-save-process-mark)
6606 (gnus-summary-unmark-all-processable))
6607
6608(defun gnus-summary-yank-process-mark ()
6609 "Pop the last process mark state off the stack and restore it."
6610 (interactive)
6611 (unless gnus-newsgroup-process-stack
6612 (error "Empty mark stack"))
6613 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6614
6615(defun gnus-summary-process-mark-set (set)
6616 "Make SET into the current process marked articles."
6617 (gnus-summary-unmark-all-processable)
01c52d31 6618 (mapc 'gnus-summary-set-process-mark set))
eec82323
LMI
6619
6620;;; Searching and stuff
6621
6622(defun gnus-summary-search-group (&optional backward use-level)
6623 "Search for next unread newsgroup.
6624If optional argument BACKWARD is non-nil, search backward instead."
c7a91ce1 6625 (with-current-buffer gnus-group-buffer
eec82323
LMI
6626 (when (gnus-group-search-forward
6627 backward nil (if use-level (gnus-group-group-level) nil))
6628 (gnus-group-group-name))))
6629
6630(defun gnus-summary-best-group (&optional exclude-group)
6631 "Find the name of the best unread group.
6632If EXCLUDE-GROUP, do not go to this group."
01c52d31 6633 (with-current-buffer gnus-group-buffer
eec82323
LMI
6634 (save-excursion
6635 (gnus-group-best-unread-group exclude-group))))
6636
23f87bed
MB
6637(defun gnus-summary-find-next (&optional unread article backward)
6638 (if backward
6639 (gnus-summary-find-prev unread article)
eec82323
LMI
6640 (let* ((dummy (gnus-summary-article-intangible-p))
6641 (article (or article (gnus-summary-article-number)))
23f87bed 6642 (data (gnus-data-find-list article))
eec82323
LMI
6643 result)
6644 (when (and (not dummy)
6645 (or (not gnus-summary-check-current)
6646 (not unread)
23f87bed
MB
6647 (not (gnus-data-unread-p (car data)))))
6648 (setq data (cdr data)))
eec82323
LMI
6649 (when (setq result
6650 (if unread
6651 (progn
23f87bed
MB
6652 (while data
6653 (unless (memq (gnus-data-number (car data))
6654 (cond
6655 ((eq gnus-auto-goto-ignores
6656 'always-undownloaded)
6657 gnus-newsgroup-undownloaded)
6658 (gnus-plugged
6659 nil)
6660 ((eq gnus-auto-goto-ignores
6661 'unfetched)
6662 gnus-newsgroup-unfetched)
6663 ((eq gnus-auto-goto-ignores
6664 'undownloaded)
6665 gnus-newsgroup-undownloaded)))
6666 (when (gnus-data-unread-p (car data))
6667 (setq result (car data)
6668 data nil)))
6669 (setq data (cdr data)))
eec82323 6670 result)
23f87bed 6671 (car data)))
eec82323
LMI
6672 (goto-char (gnus-data-pos result))
6673 (gnus-data-number result)))))
6674
6675(defun gnus-summary-find-prev (&optional unread article)
6676 (let* ((eobp (eobp))
6677 (article (or article (gnus-summary-article-number)))
23f87bed 6678 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6679 result)
6680 (when (and (not eobp)
6681 (or (not gnus-summary-check-current)
6682 (not unread)
23f87bed
MB
6683 (not (gnus-data-unread-p (car data)))))
6684 (setq data (cdr data)))
eec82323
LMI
6685 (when (setq result
6686 (if unread
6687 (progn
23f87bed
MB
6688 (while data
6689 (unless (memq (gnus-data-number (car data))
6690 (cond
6691 ((eq gnus-auto-goto-ignores
6692 'always-undownloaded)
6693 gnus-newsgroup-undownloaded)
6694 (gnus-plugged
6695 nil)
6696 ((eq gnus-auto-goto-ignores
6697 'unfetched)
6698 gnus-newsgroup-unfetched)
6699 ((eq gnus-auto-goto-ignores
6700 'undownloaded)
6701 gnus-newsgroup-undownloaded)))
6702 (when (gnus-data-unread-p (car data))
6703 (setq result (car data)
6704 data nil)))
6705 (setq data (cdr data)))
eec82323 6706 result)
23f87bed 6707 (car data)))
eec82323
LMI
6708 (goto-char (gnus-data-pos result))
6709 (gnus-data-number result))))
6710
6711(defun gnus-summary-find-subject (subject &optional unread backward article)
6712 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6713 (article (or article (gnus-summary-article-number)))
6714 (articles (gnus-data-list backward))
6715 (arts (gnus-data-find-list article articles))
6716 result)
6717 (when (or (not gnus-summary-check-current)
6718 (not unread)
6719 (not (gnus-data-unread-p (car arts))))
6720 (setq arts (cdr arts)))
6721 (while arts
6722 (and (or (not unread)
6723 (gnus-data-unread-p (car arts)))
6724 (vectorp (gnus-data-header (car arts)))
6725 (gnus-subject-equal
6726 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6727 (setq result (car arts)
6728 arts nil))
6729 (setq arts (cdr arts)))
6730 (and result
6731 (goto-char (gnus-data-pos result))
6732 (gnus-data-number result))))
6733
6734(defun gnus-summary-search-forward (&optional unread subject backward)
6735 "Search forward for an article.
6736If UNREAD, look for unread articles. If SUBJECT, look for
6737articles with that subject. If BACKWARD, search backward instead."
6738 (cond (subject (gnus-summary-find-subject subject unread backward))
6739 (backward (gnus-summary-find-prev unread))
6740 (t (gnus-summary-find-next unread))))
6741
6742(defun gnus-recenter (&optional n)
6743 "Center point in window and redisplay frame.
6744Also do horizontal recentering."
6745 (interactive "P")
6746 (when (and gnus-auto-center-summary
6747 (not (eq gnus-auto-center-summary 'vertical)))
6748 (gnus-horizontal-recenter))
5aa75bd8
JL
6749 (if (fboundp 'recenter-top-bottom)
6750 (recenter-top-bottom n)
6751 (recenter n)))
6752
6753(put 'gnus-recenter 'isearch-scroll t)
eec82323 6754
7b47345b
AS
6755(defun gnus-forward-line-ignore-invisible (n)
6756 "Move N lines forward (backward if N is negative).
6757Like forward-line, but skip over (and don't count) invisible lines."
6758 (let (done)
6759 (while (and (> n 0) (not done))
6760 ;; If the following character is currently invisible,
6761 ;; skip all characters with that same `invisible' property value.
770d9a1f
KY
6762 (while (gnus-invisible-p (point))
6763 (goto-char (gnus-next-char-property-change (point))))
7b47345b
AS
6764 (forward-line 1)
6765 (if (eobp)
6766 (setq done t)
6767 (setq n (1- n))))
6768 (while (and (< n 0) (not done))
6769 (forward-line -1)
6770 (if (bobp) (setq done t)
6771 (setq n (1+ n))
770d9a1f
KY
6772 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6773 (goto-char (gnus-previous-char-property-change (point))))))))
6774
eec82323
LMI
6775(defun gnus-summary-recenter ()
6776 "Center point in the summary window.
6777If `gnus-auto-center-summary' is nil, or the article buffer isn't
6778displayed, no centering will be performed."
6779 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6780 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6781 (interactive)
23f87bed
MB
6782 ;; The user has to want it.
6783 (when gnus-auto-center-summary
6784 (let* ((top (cond ((< (window-height) 4) 0)
6785 ((< (window-height) 7) 1)
6786 (t (if (numberp gnus-auto-center-summary)
6787 gnus-auto-center-summary
01c52d31 6788 (/ (1- (window-height)) 2)))))
23f87bed 6789 (height (1- (window-height)))
7b47345b
AS
6790 (bottom (save-excursion
6791 (goto-char (point-max))
6792 (gnus-forward-line-ignore-invisible (- height))
6793 (point)))
23f87bed 6794 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6795 (when (get-buffer-window gnus-article-buffer)
6796 ;; Only do recentering when the article buffer is displayed,
6797 ;; Set the window start to either `bottom', which is the biggest
6798 ;; possible valid number, or the second line from the top,
6799 ;; whichever is the least.
7b47345b
AS
6800 (let ((top-pos (save-excursion
6801 (gnus-forward-line-ignore-invisible (- top))
6802 (point))))
db7ebd73
MB
6803 (if (> bottom top-pos)
6804 ;; Keep the second line from the top visible
01c52d31 6805 (set-window-start window top-pos)
db7ebd73
MB
6806 ;; Try to keep the bottom line visible; if it's partially
6807 ;; obscured, either scroll one more line to make it fully
6808 ;; visible, or revert to using TOP-POS.
6809 (save-excursion
6810 (goto-char (point-max))
7b47345b 6811 (gnus-forward-line-ignore-invisible -1)
db7ebd73
MB
6812 (let ((last-line-start (point)))
6813 (goto-char bottom)
6814 (set-window-start window (point) t)
6815 (when (not (pos-visible-in-window-p last-line-start window))
7b47345b 6816 (gnus-forward-line-ignore-invisible 1)
db7ebd73 6817 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6818 ;; Do horizontal recentering while we're at it.
6819 (when (and (get-buffer-window (current-buffer) t)
6820 (not (eq gnus-auto-center-summary 'vertical)))
6821 (let ((selected (selected-window)))
6822 (select-window (get-buffer-window (current-buffer) t))
6823 (gnus-summary-position-point)
6824 (gnus-horizontal-recenter)
6825 (select-window selected))))))
6826
6827(defun gnus-summary-jump-to-group (newsgroup)
6828 "Move point to NEWSGROUP in group mode buffer."
6829 ;; Keep update point of group mode buffer if visible.
6830 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6831 (save-window-excursion
6832 ;; Take care of tree window mode.
6833 (when (get-buffer-window gnus-group-buffer)
6834 (pop-to-buffer gnus-group-buffer))
6835 (gnus-group-jump-to-group newsgroup))
6836 (save-excursion
6837 ;; Take care of tree window mode.
c7a91ce1 6838 (if (get-buffer-window gnus-group-buffer 0)
eec82323
LMI
6839 (pop-to-buffer gnus-group-buffer)
6840 (set-buffer gnus-group-buffer))
6841 (gnus-group-jump-to-group newsgroup))))
6842
6843;; This function returns a list of article numbers based on the
6844;; difference between the ranges of read articles in this group and
6845;; the range of active articles.
6846(defun gnus-list-of-unread-articles (group)
6847 (let* ((read (gnus-info-read (gnus-get-info group)))
6848 (active (or (gnus-active group) (gnus-activate-group group)))
01c52d31
MB
6849 (last (or (cdr active)
6850 (error "Group %s couldn't be activated " group)))
4b70e299
MB
6851 (bottom (if gnus-newsgroup-maximum-articles
6852 (max (car active)
6853 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6854 (car active)))
eec82323
LMI
6855 first nlast unread)
6856 ;; If none are read, then all are unread.
6857 (if (not read)
11abff8e 6858 (setq first bottom)
eec82323
LMI
6859 ;; If the range of read articles is a single range, then the
6860 ;; first unread article is the article after the last read
6861 ;; article. Sounds logical, doesn't it?
16409b0b 6862 (if (and (not (listp (cdr read)))
11abff8e 6863 (or (< (car read) bottom)
16409b0b
GM
6864 (progn (setq read (list read))
6865 nil)))
11abff8e 6866 (setq first (max bottom (1+ (cdr read))))
eec82323
LMI
6867 ;; `read' is a list of ranges.
6868 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6869 (caar read)))
6870 1)
11abff8e 6871 (setq first bottom))
eec82323
LMI
6872 (while read
6873 (when first
6874 (while (< first nlast)
54506618
MB
6875 (setq unread (cons first unread)
6876 first (1+ first))))
eec82323
LMI
6877 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6878 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6879 (setq read (cdr read)))))
6880 ;; And add the last unread articles.
6881 (while (<= first last)
54506618
MB
6882 (setq unread (cons first unread)
6883 first (1+ first)))
eec82323 6884 ;; Return the list of unread articles.
6748645f 6885 (delq 0 (nreverse unread))))
eec82323
LMI
6886
6887(defun gnus-list-of-read-articles (group)
6888 "Return a list of unread, unticked and non-dormant articles."
6889 (let* ((info (gnus-get-info group))
6890 (marked (gnus-info-marks info))
6891 (active (gnus-active group)))
6892 (and info active
23f87bed
MB
6893 (gnus-list-range-difference
6894 (gnus-list-range-difference
6895 (gnus-sorted-complement
11abff8e 6896 (gnus-uncompress-range
4b70e299 6897 (if gnus-newsgroup-maximum-articles
11abff8e 6898 (cons (max (car active)
4b70e299
MB
6899 (- (cdr active)
6900 gnus-newsgroup-maximum-articles
6901 -1))
11abff8e
MB
6902 (cdr active))
6903 active))
23f87bed
MB
6904 (gnus-list-of-unread-articles group))
6905 (cdr (assq 'dormant marked)))
6906 (cdr (assq 'tick marked))))))
eec82323 6907
54506618
MB
6908;; This function returns a sequence of article numbers based on the
6909;; difference between the ranges of read articles in this group and
6910;; the range of active articles.
6911(defun gnus-sequence-of-unread-articles (group)
6912 (let* ((read (gnus-info-read (gnus-get-info group)))
6913 (active (or (gnus-active group) (gnus-activate-group group)))
6914 (last (cdr active))
4b70e299
MB
6915 (bottom (if gnus-newsgroup-maximum-articles
6916 (max (car active)
6917 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6918 (car active)))
54506618
MB
6919 first nlast unread)
6920 ;; If none are read, then all are unread.
6921 (if (not read)
11abff8e 6922 (setq first bottom)
54506618
MB
6923 ;; If the range of read articles is a single range, then the
6924 ;; first unread article is the article after the last read
6925 ;; article. Sounds logical, doesn't it?
6926 (if (and (not (listp (cdr read)))
11abff8e 6927 (or (< (car read) bottom)
54506618
MB
6928 (progn (setq read (list read))
6929 nil)))
11abff8e 6930 (setq first (max bottom (1+ (cdr read))))
54506618
MB
6931 ;; `read' is a list of ranges.
6932 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6933 (caar read)))
6934 1)
11abff8e 6935 (setq first bottom))
54506618
MB
6936 (while read
6937 (when first
6938 (push (cons first nlast) unread))
6939 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6940 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6941 (setq read (cdr read)))))
6942 ;; And add the last unread articles.
ba0226dd
MB
6943 (cond ((not (and first last))
6944 nil)
6945 ((< first last)
6946 (push (cons first last) unread))
6947 ((= first last)
6948 (push first unread)))
54506618
MB
6949 ;; Return the sequence of unread articles.
6950 (delq 0 (nreverse unread))))
6951
eec82323
LMI
6952;; Various summary commands
6953
6748645f 6954(defun gnus-summary-select-article-buffer ()
de635afe
G
6955 "Reconfigure windows to show the article buffer.
6956If `gnus-widen-article-buffer' is set, show only the article
6957buffer."
6748645f
LMI
6958 (interactive)
6959 (if (not (gnus-buffer-live-p gnus-article-buffer))
6960 (error "There is no article buffer for this summary buffer")
a41c2e6d
G
6961 (unless (get-buffer-window gnus-article-buffer)
6962 (gnus-summary-show-article))
71e691a5
G
6963 (gnus-configure-windows
6964 (if gnus-widen-article-window
6965 'only-article
6966 'article)
6967 t)
a41c2e6d 6968 (select-window (get-buffer-window gnus-article-buffer))))
6748645f 6969
eec82323
LMI
6970(defun gnus-summary-universal-argument (arg)
6971 "Perform any operation on all articles that are process/prefixed."
6972 (interactive "P")
eec82323
LMI
6973 (let ((articles (gnus-summary-work-articles arg))
6974 func article)
6975 (if (eq
6976 (setq
6977 func
6978 (key-binding
6979 (read-key-sequence
6980 (substitute-command-keys
16409b0b 6981 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
6982 'undefined)
6983 (gnus-error 1 "Undefined key")
6984 (save-excursion
6985 (while articles
6986 (gnus-summary-goto-subject (setq article (pop articles)))
6987 (let (gnus-newsgroup-processable)
6988 (command-execute func))
6989 (gnus-summary-remove-process-mark article)))))
6990 (gnus-summary-position-point))
6991
6992(defun gnus-summary-toggle-truncation (&optional arg)
6993 "Toggle truncation of summary lines.
23f87bed 6994With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
6995 (interactive "P")
6996 (setq truncate-lines
6997 (if (null arg) (not truncate-lines)
6998 (> (prefix-numeric-value arg) 0)))
6999 (redraw-display))
7000
23f87bed
MB
7001(defun gnus-summary-find-for-reselect ()
7002 "Return the number of an article to stay on across a reselect.
7003The current article is considered, then following articles, then previous
7004articles. An article is sought which is not cancelled and isn't a temporary
7005insertion from another group. If there's no such then return a dummy 0."
7006 (let (found)
7007 (dolist (rev '(nil t))
7008 (unless found ; don't demand the reverse list if we don't need it
7009 (let ((data (gnus-data-find-list
7010 (gnus-summary-article-number) (gnus-data-list rev))))
7011 (while (and data (not found))
7012 (if (and (< 0 (gnus-data-number (car data)))
7013 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7014 (setq found (gnus-data-number (car data))))
7015 (setq data (cdr data))))))
7016 (or found 0)))
7017
eec82323
LMI
7018(defun gnus-summary-reselect-current-group (&optional all rescan)
7019 "Exit and then reselect the current newsgroup.
7020The prefix argument ALL means to select all articles."
7021 (interactive "P")
eec82323
LMI
7022 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7023 (error "Ephemeral groups can't be reselected"))
23f87bed 7024 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
7025 (group gnus-newsgroup-name))
7026 (setq gnus-newsgroup-begin nil)
23f87bed 7027 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
7028 ;; We have to adjust the point of group mode buffer because
7029 ;; point was moved to the next unread newsgroup by exiting.
7030 (gnus-summary-jump-to-group group)
7031 (when rescan
7032 (save-excursion
7033 (gnus-group-get-new-news-this-group 1)))
7034 (gnus-group-read-group all t)
7035 (gnus-summary-goto-subject current-subject nil t)))
7036
7037(defun gnus-summary-rescan-group (&optional all)
7038 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7039 (interactive "P")
eb9df2c9
LMI
7040 (let ((config gnus-current-window-configuration))
7041 (gnus-summary-reselect-current-group all t)
7042 (gnus-configure-windows config)
7043 (when (eq config 'article)
7044 (gnus-summary-select-article))))
eec82323
LMI
7045
7046(defun gnus-summary-update-info (&optional non-destructive)
7047 (save-excursion
7048 (let ((group gnus-newsgroup-name))
6748645f
LMI
7049 (when group
7050 (when gnus-newsgroup-kill-headers
7051 (setq gnus-newsgroup-killed
7052 (gnus-compress-sequence
23f87bed
MB
7053 (gnus-sorted-union
7054 (gnus-list-range-intersection
7055 gnus-newsgroup-unselected gnus-newsgroup-killed)
7056 gnus-newsgroup-unreads)
6748645f
LMI
7057 t)))
7058 (unless (listp (cdr gnus-newsgroup-killed))
7059 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7060 (let ((headers gnus-newsgroup-headers))
7061 ;; Set the new ranges of read articles.
01c52d31 7062 (with-current-buffer gnus-group-buffer
6748645f
LMI
7063 (gnus-undo-force-boundary))
7064 (gnus-update-read-articles
23f87bed
MB
7065 group (gnus-sorted-union
7066 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
7067 ;; Set the current article marks.
7068 (let ((gnus-newsgroup-scored
7069 (if (and (not gnus-save-score)
7070 (not non-destructive))
7071 nil
7072 gnus-newsgroup-scored)))
7073 (save-excursion
7074 (gnus-update-marks)))
7075 ;; Do the cross-ref thing.
7076 (when gnus-use-cross-reference
7077 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7078 ;; Do not switch windows but change the buffer to work.
a8151ef7 7079 (set-buffer gnus-group-buffer)
6748645f
LMI
7080 (unless (gnus-ephemeral-group-p group)
7081 (gnus-group-update-group group)))))))
eec82323
LMI
7082
7083(defun gnus-summary-save-newsrc (&optional force)
7084 "Save the current number of read/marked articles in the dribble buffer.
7085The dribble buffer will then be saved.
7086If FORCE (the prefix), also save the .newsrc file(s)."
7087 (interactive "P")
7088 (gnus-summary-update-info t)
7089 (if force
7090 (gnus-save-newsrc-file)
7091 (gnus-dribble-save)))
7092
704f1663
GM
7093(declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7094
23f87bed 7095(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 7096 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 7097`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
7098 (interactive)
7099 (gnus-set-global-variables)
16409b0b 7100 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7101 (with-current-buffer gnus-article-buffer
16409b0b
GM
7102 (mm-destroy-parts gnus-article-mime-handles)
7103 ;; Set it to nil for safety reason.
7104 (setq gnus-article-mime-handle-alist nil)
7105 (setq gnus-article-mime-handles nil)))
eec82323 7106 (gnus-kill-save-kill-buffer)
6748645f 7107 (gnus-async-halt-prefetch)
eec82323
LMI
7108 (let* ((group gnus-newsgroup-name)
7109 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 7110 (gnus-group-is-exiting-p t)
eec82323 7111 (mode major-mode)
23f87bed 7112 (group-point nil)
eec82323 7113 (buf (current-buffer)))
16409b0b
GM
7114 (unless quit-config
7115 ;; Do adaptive scoring, and possibly save score files.
7116 (when gnus-newsgroup-adaptive
7117 (gnus-score-adaptive))
7118 (when gnus-use-scoring
7119 (gnus-score-save)))
6748645f 7120 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
7121 (when gnus-use-cache
7122 (gnus-cache-possibly-remove-articles)
7123 (gnus-cache-save-buffers))
7124 (gnus-async-prefetch-remove-group group)
7125 (when gnus-suppress-duplicates
7126 (gnus-dup-enter-articles))
7127 (when gnus-use-trees
7128 (gnus-tree-close group))
16409b0b
GM
7129 (when gnus-use-cache
7130 (gnus-cache-write-active))
6748645f
LMI
7131 ;; Remove entries for this group.
7132 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
7133 ;; Make all changes in this group permanent.
7134 (unless quit-config
6748645f 7135 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 7136 (gnus-summary-update-info))
eec82323
LMI
7137 (gnus-close-group group)
7138 ;; Make sure where we were, and go to next newsgroup.
7139 (set-buffer gnus-group-buffer)
7140 (unless quit-config
7141 (gnus-group-jump-to-group group))
6748645f
LMI
7142 (gnus-run-hooks 'gnus-summary-exit-hook)
7143 (unless (or quit-config
01c52d31 7144 (not gnus-summary-next-group-on-exit)
6748645f
LMI
7145 ;; If this group has disappeared from the summary
7146 ;; buffer, don't skip forwards.
7147 (not (string= group (gnus-group-group-name))))
eec82323 7148 (gnus-group-next-unread-group 1))
a8151ef7 7149 (setq group-point (point))
eec82323
LMI
7150 (if temporary
7151 nil ;Nothing to do.
eec82323
LMI
7152 (set-buffer buf)
7153 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
7154 (progn
7155 (gnus-deaden-summary)
7156 (setq mode nil))
eec82323
LMI
7157 (when (get-buffer gnus-article-buffer)
7158 (bury-buffer gnus-article-buffer))
eec82323
LMI
7159 ;; Return to group mode buffer.
7160 (when (eq mode 'gnus-summary-mode)
7161 (gnus-kill-buffer buf)))
9f2d52e7
G
7162
7163 ;; If we have several article buffers, we kill them at exit.
7164 (unless gnus-single-article-buffer
7165 (when (gnus-buffer-live-p gnus-article-buffer)
7166 (with-current-buffer gnus-article-buffer
7167 ;; Don't kill sticky article buffers
7168 (unless (eq major-mode 'gnus-sticky-article-mode)
7169 (gnus-kill-buffer gnus-article-buffer)
7170 (setq gnus-article-current nil))))
7171 (gnus-kill-buffer gnus-original-article-buffer))
7172
eec82323 7173 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
7174 (set-buffer gnus-group-buffer)
7175 (if quit-config
7176 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
7177 (goto-char group-point)
7178 ;; If gnus-group-buffer is already displayed, make sure we also move
7179 ;; the cursor in the window that displays it.
7180 (let ((win (get-buffer-window (current-buffer) 0)))
7181 (if win (set-window-point win (point))))
d61c212b 7182 (unless leave-hidden
4e90f2b9 7183 (gnus-configure-windows 'group 'force)))
6748645f 7184 ;; Clear the current group name.
eec82323
LMI
7185 (unless quit-config
7186 (setq gnus-newsgroup-name nil)))))
7187
7188(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7189(defun gnus-summary-exit-no-update (&optional no-questions)
7190 "Quit reading current newsgroup without updating read article info."
7191 (interactive)
eec82323 7192 (let* ((group gnus-newsgroup-name)
23f87bed
MB
7193 (gnus-group-is-exiting-p t)
7194 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
7195 (quit-config (gnus-group-quit-config group)))
7196 (when (or no-questions
7197 gnus-expert-user
7198 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 7199 (gnus-async-halt-prefetch)
23f87bed 7200 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b 7201 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7202 (with-current-buffer gnus-article-buffer
16409b0b
GM
7203 (mm-destroy-parts gnus-article-mime-handles)
7204 ;; Set it to nil for safety reason.
7205 (setq gnus-article-mime-handle-alist nil)
7206 (setq gnus-article-mime-handles nil)))
eec82323
LMI
7207 ;; If we have several article buffers, we kill them at exit.
7208 (unless gnus-single-article-buffer
7209 (gnus-kill-buffer gnus-article-buffer)
7210 (gnus-kill-buffer gnus-original-article-buffer)
7211 (setq gnus-article-current nil))
7212 (if (not gnus-kill-summary-on-exit)
7213 (gnus-deaden-summary)
7214 (gnus-close-group group)
23f87bed 7215 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
7216 (unless gnus-single-article-buffer
7217 (setq gnus-article-current nil))
7218 (when gnus-use-trees
7219 (gnus-tree-close group))
7220 (gnus-async-prefetch-remove-group group)
7221 (when (get-buffer gnus-article-buffer)
7222 (bury-buffer gnus-article-buffer))
7223 ;; Return to the group buffer.
7224 (gnus-configure-windows 'group 'force)
7225 ;; Clear the current group name.
7226 (setq gnus-newsgroup-name nil)
23f87bed
MB
7227 (unless (gnus-ephemeral-group-p group)
7228 (gnus-group-update-group group))
eec82323
LMI
7229 (when (equal (gnus-group-group-name) group)
7230 (gnus-group-next-unread-group 1))
7231 (when quit-config
23f87bed 7232 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
7233
7234(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
7235 "Handle movement when leaving an ephemeral group.
7236The state which existed when entering the ephemeral is reset."
eec82323
LMI
7237 (if (not (buffer-name (car quit-config)))
7238 (gnus-configure-windows 'group 'force)
7239 (set-buffer (car quit-config))
7240 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
7241 (gnus-set-global-variables))
7242 ((eq major-mode 'gnus-article-mode)
c7a91ce1 7243 (save-current-buffer
23f87bed
MB
7244 ;; The `gnus-summary-buffer' variable may point
7245 ;; to the old summary buffer when using a single
7246 ;; article buffer.
7247 (unless (gnus-buffer-live-p gnus-summary-buffer)
7248 (set-buffer gnus-group-buffer))
7249 (set-buffer gnus-summary-buffer)
7250 (gnus-set-global-variables))))
eec82323 7251 (if (or (eq (cdr quit-config) 'article)
23f87bed 7252 (eq (cdr quit-config) 'pick))
01c52d31
MB
7253 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7254 (gnus-configure-windows 'pick 'force)
7255 (gnus-configure-windows (cdr quit-config) 'force))
eec82323
LMI
7256 (gnus-configure-windows (cdr quit-config) 'force))
7257 (when (eq major-mode 'gnus-summary-mode)
01c52d31
MB
7258 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7259 next-unread-noselect))
7260 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7261 'next-noselect)
7262 (gnus-summary-next-subject 1 nil t))
7263 ((eq gnus-auto-select-on-ephemeral-exit
7264 'next-unread-noselect)
7265 (gnus-summary-next-subject 1 t t))))
7266 ;; Hide the article buffer which displays the article different
7267 ;; from the one that the cursor points to in the summary buffer.
7268 (gnus-configure-windows 'summary 'force))
7269 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7270 (gnus-summary-next-subject 1))
7271 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7272 (gnus-summary-next-subject 1 t))))
eec82323
LMI
7273 (gnus-summary-recenter)
7274 (gnus-summary-position-point))))
7275
7276;;; Dead summaries.
7277
bbf52f1e
SM
7278(defvar gnus-dead-summary-mode-map
7279 (let ((map (make-keymap)))
7280 (suppress-keymap map)
7281 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7282 (dolist (key '("\C-d" "\r" "\177" [delete]))
7283 (define-key map key 'gnus-summary-wake-up-the-dead))
7284 (dolist (key '("q" "Q"))
7285 (define-key map key 'bury-buffer))
7286 map))
7287
7288(define-minor-mode gnus-dead-summary-mode
eec82323 7289 "Minor mode for Gnus summary buffers."
bbf52f1e
SM
7290 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7291 (unless (derived-mode-p 'gnus-summary-mode)
7292 (setq gnus-dead-summary-mode nil)))
eec82323
LMI
7293
7294(defun gnus-deaden-summary ()
7295 "Make the current summary buffer into a dead summary buffer."
7296 ;; Kill any previous dead summary buffer.
7297 (when (and gnus-dead-summary
7298 (buffer-name gnus-dead-summary))
01c52d31 7299 (with-current-buffer gnus-dead-summary
eec82323
LMI
7300 (when gnus-dead-summary-mode
7301 (kill-buffer (current-buffer)))))
7302 ;; Make this the current dead summary.
7303 (setq gnus-dead-summary (current-buffer))
7304 (gnus-dead-summary-mode 1)
7305 (let ((name (buffer-name)))
7306 (when (string-match "Summary" name)
7307 (rename-buffer
7308 (concat (substring name 0 (match-beginning 0)) "Dead "
7309 (substring name (match-beginning 0)))
16409b0b
GM
7310 t)
7311 (bury-buffer))))
eec82323
LMI
7312
7313(defun gnus-kill-or-deaden-summary (buffer)
7314 "Kill or deaden the summary BUFFER."
6748645f
LMI
7315 (save-excursion
7316 (when (and (buffer-name buffer)
7317 (not gnus-single-article-buffer))
01c52d31 7318 (with-current-buffer buffer
6748645f
LMI
7319 (gnus-kill-buffer gnus-article-buffer)
7320 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
7321 (cond
7322 ;; Kill the buffer.
7323 (gnus-kill-summary-on-exit
7324 (when (and gnus-use-trees
7325 (gnus-buffer-exists-p buffer))
c7a91ce1 7326 (with-current-buffer buffer
23f87bed
MB
7327 (gnus-tree-close gnus-newsgroup-name)))
7328 (gnus-kill-buffer buffer))
7329 ;; Deaden the buffer.
7330 ((gnus-buffer-exists-p buffer)
c7a91ce1 7331 (with-current-buffer buffer
23f87bed 7332 (gnus-deaden-summary))))))
eec82323
LMI
7333
7334(defun gnus-summary-wake-up-the-dead (&rest args)
7335 "Wake up the dead summary buffer."
7336 (interactive)
7337 (gnus-dead-summary-mode -1)
7338 (let ((name (buffer-name)))
7339 (when (string-match "Dead " name)
7340 (rename-buffer
7341 (concat (substring name 0 (match-beginning 0))
7342 (substring name (match-end 0)))
7343 t)))
7344 (gnus-message 3 "This dead summary is now alive again"))
7345
eec82323
LMI
7346;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7347(defun gnus-summary-describe-group (&optional force)
7348 "Describe the current newsgroup."
7349 (interactive "P")
7350 (gnus-group-describe-group force gnus-newsgroup-name))
7351
7352(defun gnus-summary-describe-briefly ()
7353 "Describe summary mode commands briefly."
7354 (interactive)
bdaa75c7 7355 (gnus-message 6 "%s" (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
7356
7357;; Walking around group mode buffer from summary mode.
7358
7359(defun gnus-summary-next-group (&optional no-article target-group backward)
7360 "Exit current newsgroup and then select next unread newsgroup.
7361If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7362initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7363previous group instead."
7364 (interactive "P")
eec82323
LMI
7365 ;; Stop pre-fetching.
7366 (gnus-async-halt-prefetch)
7367 (let ((current-group gnus-newsgroup-name)
7368 (current-buffer (current-buffer))
7369 entered)
7370 ;; First we semi-exit this group to update Xrefs and all variables.
7371 ;; We can't do a real exit, because the window conf must remain
7372 ;; the same in case the user is prompted for info, and we don't
7373 ;; want the window conf to change before that...
7374 (gnus-summary-exit t)
7375 (while (not entered)
7376 ;; Then we find what group we are supposed to enter.
7377 (set-buffer gnus-group-buffer)
7378 (gnus-group-jump-to-group current-group)
7379 (setq target-group
7380 (or target-group
7381 (if (eq gnus-keep-same-level 'best)
7382 (gnus-summary-best-group gnus-newsgroup-name)
7383 (gnus-summary-search-group backward gnus-keep-same-level))))
7384 (if (not target-group)
7385 ;; There are no further groups, so we return to the group
7386 ;; buffer.
7387 (progn
7388 (gnus-message 5 "Returning to the group buffer")
7389 (setq entered t)
7390 (when (gnus-buffer-live-p current-buffer)
7391 (set-buffer current-buffer)
7392 (gnus-summary-exit))
6748645f 7393 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7394 ;; We try to enter the target group.
7395 (gnus-group-jump-to-group target-group)
7396 (let ((unreads (gnus-group-group-unread)))
7397 (if (and (or (eq t unreads)
7398 (and unreads (not (zerop unreads))))
23f87bed
MB
7399 (gnus-summary-read-group
7400 target-group nil no-article
7401 (and (buffer-name current-buffer) current-buffer)
7402 nil backward))
eec82323
LMI
7403 (setq entered t)
7404 (setq current-group target-group
7405 target-group nil)))))))
7406
7407(defun gnus-summary-prev-group (&optional no-article)
7408 "Exit current newsgroup and then select previous unread newsgroup.
7409If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7410 (interactive "P")
7411 (gnus-summary-next-group no-article nil t))
7412
7413;; Walking around summary lines.
7414
23f87bed
MB
7415(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7416 "Go to the first subject satisfying any non-nil constraint.
7417If UNREAD is non-nil, the article should be unread.
7418If UNDOWNLOADED is non-nil, the article should be undownloaded.
20a673b2 7419If UNSEEN is non-nil, the article should be unseen as well as unread.
23f87bed 7420Returns the article selected or nil if there are no matching articles."
eec82323 7421 (interactive "P")
23f87bed
MB
7422 (cond
7423 ;; Empty summary.
7424 ((null gnus-newsgroup-data)
7425 (gnus-message 3 "No articles in the group")
7426 nil)
7427 ;; Pick the first article.
7428 ((not (or unread undownloaded unseen))
7429 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7430 (gnus-data-number (car gnus-newsgroup-data)))
7431 ;; Find the first unread article.
7432 (t
7433 (let ((data gnus-newsgroup-data))
7434 (while (and data
7435 (let ((num (gnus-data-number (car data))))
7436 (or (memq num gnus-newsgroup-unfetched)
7437 (not (or (and unread
7438 (memq num gnus-newsgroup-unreads))
7439 (and undownloaded
7440 (memq num gnus-newsgroup-undownloaded))
7441 (and unseen
20a673b2
KY
7442 (memq num gnus-newsgroup-unseen)
7443 (memq num gnus-newsgroup-unreads)))))))
23f87bed
MB
7444 (setq data (cdr data)))
7445 (prog1
7446 (if data
7447 (progn
7448 (goto-char (gnus-data-pos (car data)))
7449 (gnus-data-number (car data)))
7450 (gnus-message 3 "No more%s articles"
7451 (let* ((r (when unread " unread"))
7452 (d (when undownloaded " undownloaded"))
7453 (s (when unseen " unseen"))
7454 (l (delq nil (list r d s))))
7455 (cond ((= 3 (length l))
7456 (concat r "," d ", or" s))
7457 ((= 2 (length l))
7458 (concat (car l) ", or" (cadr l)))
7459 ((= 1 (length l))
7460 (car l))
7461 (t
7462 ""))))
7463 nil
7464 )
7465 (gnus-summary-position-point))))))
eec82323
LMI
7466
7467(defun gnus-summary-next-subject (n &optional unread dont-display)
7468 "Go to next N'th summary line.
7469If N is negative, go to the previous N'th subject line.
7470If UNREAD is non-nil, only unread articles are selected.
7471The difference between N and the actual number of steps taken is
7472returned."
7473 (interactive "p")
7474 (let ((backward (< n 0))
7475 (n (abs n)))
7476 (while (and (> n 0)
7477 (if backward
7478 (gnus-summary-find-prev unread)
7479 (gnus-summary-find-next unread)))
16409b0b
GM
7480 (unless (zerop (setq n (1- n)))
7481 (gnus-summary-show-thread)))
eec82323
LMI
7482 (when (/= 0 n)
7483 (gnus-message 7 "No more%s articles"
7484 (if unread " unread" "")))
7485 (unless dont-display
7486 (gnus-summary-recenter)
7487 (gnus-summary-position-point))
7488 n))
7489
7490(defun gnus-summary-next-unread-subject (n)
7491 "Go to next N'th unread summary line."
7492 (interactive "p")
7493 (gnus-summary-next-subject n t))
7494
7495(defun gnus-summary-prev-subject (n &optional unread)
7496 "Go to previous N'th summary line.
7497If optional argument UNREAD is non-nil, only unread article is selected."
7498 (interactive "p")
7499 (gnus-summary-next-subject (- n) unread))
7500
7501(defun gnus-summary-prev-unread-subject (n)
7502 "Go to previous N'th unread summary line."
7503 (interactive "p")
7504 (gnus-summary-next-subject (- n) t))
7505
23f87bed
MB
7506(defun gnus-summary-goto-subjects (articles)
7507 "Insert the subject header for ARTICLES in the current buffer."
7508 (save-excursion
7509 (dolist (article articles)
7510 (gnus-summary-goto-subject article t)))
7511 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7512 (gnus-summary-position-point))
132cf96d 7513
eec82323 7514(defun gnus-summary-goto-subject (article &optional force silent)
d55fe5bb 7515 "Go to the subject line of ARTICLE.
eec82323
LMI
7516If FORCE, also allow jumping to articles not currently shown."
7517 (interactive "nArticle number: ")
23f87bed
MB
7518 (unless (numberp article)
7519 (error "Article %s is not a number" article))
eec82323
LMI
7520 (let ((b (point))
7521 (data (gnus-data-find article)))
7522 ;; We read in the article if we have to.
7523 (and (not data)
7524 force
6748645f
LMI
7525 (gnus-summary-insert-subject
7526 article
7527 (if (or (numberp force) (vectorp force)) force)
7528 t)
eec82323
LMI
7529 (setq data (gnus-data-find article)))
7530 (goto-char b)
7531 (if (not data)
7532 (progn
7533 (unless silent
7534 (gnus-message 3 "Can't find article %d" article))
7535 nil)
23f87bed
MB
7536 (let ((pt (gnus-data-pos data)))
7537 (goto-char pt)
7538 (gnus-summary-set-article-display-arrow pt))
6748645f 7539 (gnus-summary-position-point)
eec82323
LMI
7540 article)))
7541
7542;; Walking around summary lines with displaying articles.
7543
7544(defun gnus-summary-expand-window (&optional arg)
7545 "Make the summary buffer take up the entire Emacs frame.
7546Given a prefix, will force an `article' buffer configuration."
7547 (interactive "P")
eec82323
LMI
7548 (if arg
7549 (gnus-configure-windows 'article 'force)
7550 (gnus-configure-windows 'summary 'force)))
7551
7552(defun gnus-summary-display-article (article &optional all-header)
7553 "Display ARTICLE in article buffer."
01c52d31
MB
7554 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7555 (with-current-buffer gnus-article-buffer
7556 (eq major-mode 'gnus-article-mode)))
7557 (gnus-article-setup-buffer))
eec82323 7558 (gnus-set-global-variables)
01c52d31
MB
7559 (with-current-buffer gnus-article-buffer
7560 (setq gnus-article-charset gnus-newsgroup-charset)
7561 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7562 (mm-enable-multibyte))
eec82323
LMI
7563 (if (null article)
7564 nil
7565 (prog1
7566 (if gnus-summary-display-article-function
7567 (funcall gnus-summary-display-article-function article all-header)
7568 (gnus-article-prepare article all-header))
6748645f 7569 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7570 (when (and gnus-current-article
7571 (not (zerop gnus-current-article)))
7572 (gnus-summary-goto-subject gnus-current-article))
7573 (gnus-summary-recenter)
7574 (when (and gnus-use-trees gnus-show-threads)
7575 (gnus-possibly-generate-tree article)
7576 (gnus-highlight-selected-tree article))
7577 ;; Successfully display article.
7578 (gnus-article-set-window-start
7579 (cdr (assq article gnus-newsgroup-bookmarks))))))
7580
7581(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7582 "Select the current article.
7583If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7584non-nil, the article will be re-fetched even if it already present in
7585the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7586be displayed."
7587 ;; Make sure we are in the summary buffer to work around bbdb bug.
7588 (unless (eq major-mode 'gnus-summary-mode)
7589 (set-buffer gnus-summary-buffer))
7590 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7591 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7592 gnus-summary-display-article-function)
eec82323
LMI
7593 (and (not pseudo)
7594 (gnus-summary-article-pseudo-p article)
a8151ef7 7595 (error "This is a pseudo-article"))
c7a91ce1 7596 (with-current-buffer gnus-summary-buffer
16409b0b
GM
7597 (if (or (and gnus-single-article-buffer
7598 (or (null gnus-current-article)
7599 (null gnus-article-current)
7600 (null (get-buffer gnus-article-buffer))
7601 (not (eq article (cdr gnus-article-current)))
7602 (not (equal (car gnus-article-current)
de635afe 7603 gnus-newsgroup-name))
28090d40 7604 (not (get-buffer gnus-original-article-buffer))))
16409b0b
GM
7605 (and (not gnus-single-article-buffer)
7606 (or (null gnus-current-article)
389b76fa 7607 (not (get-buffer gnus-original-article-buffer))
16409b0b
GM
7608 (not (eq gnus-current-article article))))
7609 force)
7610 ;; The requested article is different from the current article.
7611 (progn
16409b0b
GM
7612 (gnus-summary-display-article article all-headers)
7613 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7614 (with-current-buffer gnus-article-buffer
16409b0b 7615 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7616 (mm-disable-multibyte))))
16409b0b
GM
7617 (gnus-article-set-window-start
7618 (cdr (assq article gnus-newsgroup-bookmarks)))
7619 article)
16409b0b 7620 'old))))
eec82323 7621
23f87bed
MB
7622(defun gnus-summary-force-verify-and-decrypt ()
7623 "Display buttons for signed/encrypted parts and verify/decrypt them."
7624 (interactive)
7625 (let ((mm-verify-option 'known)
7626 (mm-decrypt-option 'known)
7627 (gnus-article-emulate-mime t)
7628 (gnus-buttonized-mime-types (append (list "multipart/signed"
7629 "multipart/encrypted")
7630 gnus-buttonized-mime-types)))
7631 (gnus-summary-select-article nil 'force)))
7632
eec82323
LMI
7633(defun gnus-summary-set-current-mark (&optional current-mark)
7634 "Obsolete function."
7635 nil)
7636
7637(defun gnus-summary-next-article (&optional unread subject backward push)
7638 "Select the next article.
7639If UNREAD, only unread articles are selected.
7640If SUBJECT, only articles with SUBJECT are selected.
7641If BACKWARD, the previous article is selected instead of the next."
7642 (interactive "P")
11e95b02
MB
7643 ;; Make sure we are in the summary buffer.
7644 (unless (eq major-mode 'gnus-summary-mode)
7645 (set-buffer gnus-summary-buffer))
eec82323
LMI
7646 (cond
7647 ;; Is there such an article?
7648 ((and (gnus-summary-search-forward unread subject backward)
7649 (or (gnus-summary-display-article (gnus-summary-article-number))
7650 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7651 (gnus-summary-position-point))
7652 ;; If not, we try the first unread, if that is wanted.
7653 ((and subject
7654 gnus-auto-select-same
7655 (gnus-summary-first-unread-article))
7656 (gnus-summary-position-point)
7657 (gnus-message 6 "Wrapped"))
7658 ;; Try to get next/previous article not displayed in this group.
7659 ((and gnus-auto-extend-newsgroup
7660 (not unread) (not subject))
7661 (gnus-summary-goto-article
7662 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7663 nil (count-lines (point-min) (point))))
eec82323
LMI
7664 ;; Go to next/previous group.
7665 (t
7666 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7667 (gnus-summary-jump-to-group gnus-newsgroup-name))
49e787c9
GM
7668 (let ((cmd (if (featurep 'xemacs)
7669 last-command-char
7670 last-command-event))
eec82323 7671 (point
01c52d31 7672 (with-current-buffer gnus-group-buffer
eec82323
LMI
7673 (point)))
7674 (group
7675 (if (eq gnus-keep-same-level 'best)
7676 (gnus-summary-best-group gnus-newsgroup-name)
7677 (gnus-summary-search-group backward gnus-keep-same-level))))
7678 ;; For some reason, the group window gets selected. We change
7679 ;; it back.
7680 (select-window (get-buffer-window (current-buffer)))
7681 ;; Select next unread newsgroup automagically.
7682 (cond
7683 ((or (not gnus-auto-select-next)
7684 (not cmd))
7685 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7686 ((or (eq gnus-auto-select-next 'quietly)
7687 (and (eq gnus-auto-select-next 'slightly-quietly)
7688 push)
7689 (and (eq gnus-auto-select-next 'almost-quietly)
7690 (gnus-summary-last-article-p)))
7691 ;; Select quietly.
7692 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7693 (gnus-summary-exit)
7694 (gnus-message 7 "No more%s articles (%s)..."
7695 (if unread " unread" "")
7696 (if group (concat "selecting " group)
7697 "exiting"))
7698 (gnus-summary-next-group nil group backward)))
7699 (t
7700 (when (gnus-key-press-event-p last-input-event)
7701 (gnus-summary-walk-group-buffer
7702 gnus-newsgroup-name cmd unread backward point))))))))
7703
7704(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7705 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7706 (?\C-p (gnus-group-prev-unread-group 1))))
7707 (cursor-in-echo-area t)
23f87bed 7708 keve key group ended prompt)
c7a91ce1 7709 (with-current-buffer gnus-group-buffer
eec82323
LMI
7710 (goto-char start)
7711 (setq group
7712 (if (eq gnus-keep-same-level 'best)
7713 (gnus-summary-best-group gnus-newsgroup-name)
7714 (gnus-summary-search-group backward gnus-keep-same-level))))
7715 (while (not ended)
23f87bed
MB
7716 (setq prompt
7717 (format
7718 "No more%s articles%s " (if unread " unread" "")
7719 (if (and group
7720 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7721 (format " (Type %s for %s [%s])"
91472578
MB
7722 (single-key-description cmd)
7723 (gnus-group-decoded-name group)
01c52d31 7724 (gnus-group-unread group))
23f87bed
MB
7725 (format " (Type %s to exit %s)"
7726 (single-key-description cmd)
91472578 7727 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7728 ;; Confirm auto selection.
23f87bed
MB
7729 (setq key (car (setq keve (gnus-read-event-char prompt)))
7730 ended t)
eec82323
LMI
7731 (cond
7732 ((assq key keystrokes)
7733 (let ((obuf (current-buffer)))
7734 (switch-to-buffer gnus-group-buffer)
7735 (when group
7736 (gnus-group-jump-to-group group))
7737 (eval (cadr (assq key keystrokes)))
7738 (setq group (gnus-group-group-name))
7739 (switch-to-buffer obuf))
7740 (setq ended nil))
7741 ((equal key cmd)
7742 (if (or (not group)
7743 (gnus-ephemeral-group-p gnus-newsgroup-name))
7744 (gnus-summary-exit)
7745 (gnus-summary-next-group nil group backward)))
7746 (t
7747 (push (cdr keve) unread-command-events))))))
7748
7749(defun gnus-summary-next-unread-article ()
7750 "Select unread article after current one."
7751 (interactive)
7752 (gnus-summary-next-article
7753 (or (not (eq gnus-summary-goto-unread 'never))
7754 (gnus-summary-last-article-p (gnus-summary-article-number)))
7755 (and gnus-auto-select-same
7756 (gnus-summary-article-subject))))
7757
7758(defun gnus-summary-prev-article (&optional unread subject)
bbbe940b 7759 "Select the article before the current one.
eec82323
LMI
7760If UNREAD is non-nil, only unread articles are selected."
7761 (interactive "P")
7762 (gnus-summary-next-article unread subject t))
7763
7764(defun gnus-summary-prev-unread-article ()
7765 "Select unread article before current one."
7766 (interactive)
7767 (gnus-summary-prev-article
7768 (or (not (eq gnus-summary-goto-unread 'never))
7769 (gnus-summary-first-article-p (gnus-summary-article-number)))
7770 (and gnus-auto-select-same
7771 (gnus-summary-article-subject))))
7772
23f87bed 7773(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7774 "Show next page of the selected article.
7775If at the end of the current article, select the next article.
7776LINES says how many lines should be scrolled up.
7777
7778If CIRCULAR is non-nil, go to the start of the article instead of
7779selecting the next article when reaching the end of the current
23f87bed
MB
7780article.
7781
7782If STOP is non-nil, just stop when reaching the end of the message.
7783
7784Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7785 (interactive "P")
7786 (setq gnus-summary-buffer (current-buffer))
7787 (gnus-set-global-variables)
7788 (let ((article (gnus-summary-article-number))
7789 (article-window (get-buffer-window gnus-article-buffer t))
7790 endp)
6748645f
LMI
7791 ;; If the buffer is empty, we have no article.
7792 (unless article
7793 (error "No article to select"))
eec82323
LMI
7794 (gnus-configure-windows 'article)
7795 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7796 (if (and (eq gnus-summary-goto-unread 'never)
7797 (not (gnus-summary-last-article-p article)))
7798 (gnus-summary-next-article)
7799 (gnus-summary-next-unread-article))
7800 (if (or (null gnus-current-article)
7801 (null gnus-article-current)
7802 (/= article (cdr gnus-article-current))
7803 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7804 ;; Selected subject is different from current article's.
7805 (gnus-summary-display-article article)
7806 (when article-window
7807 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7808 (setq endp (or (gnus-article-next-page lines)
7809 (gnus-article-only-boring-p))))
eec82323 7810 (when endp
b1992461 7811 (cond ((or stop gnus-summary-stop-at-end-of-message)
23f87bed
MB
7812 (gnus-message 3 "End of message"))
7813 (circular
eec82323
LMI
7814 (gnus-summary-beginning-of-article))
7815 (lines
7816 (gnus-message 3 "End of message"))
7817 ((null lines)
7818 (if (and (eq gnus-summary-goto-unread 'never)
7819 (not (gnus-summary-last-article-p article)))
7820 (gnus-summary-next-article)
7821 (gnus-summary-next-unread-article))))))))
7822 (gnus-summary-recenter)
7823 (gnus-summary-position-point)))
7824
7825(defun gnus-summary-prev-page (&optional lines move)
7826 "Show previous page of selected article.
7827Argument LINES specifies lines to be scrolled down.
7828If MOVE, move to the previous unread article if point is at
7829the beginning of the buffer."
7830 (interactive "P")
eec82323
LMI
7831 (let ((article (gnus-summary-article-number))
7832 (article-window (get-buffer-window gnus-article-buffer t))
7833 endp)
7834 (gnus-configure-windows 'article)
7835 (if (or (null gnus-current-article)
7836 (null gnus-article-current)
7837 (/= article (cdr gnus-article-current))
7838 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7839 ;; Selected subject is different from current article's.
7840 (gnus-summary-display-article article)
7841 (gnus-summary-recenter)
7842 (when article-window
7843 (gnus-eval-in-buffer-window gnus-article-buffer
7844 (setq endp (gnus-article-prev-page lines)))
7845 (when (and move endp)
7846 (cond (lines
7847 (gnus-message 3 "Beginning of message"))
7848 ((null lines)
7849 (if (and (eq gnus-summary-goto-unread 'never)
7850 (not (gnus-summary-first-article-p article)))
7851 (gnus-summary-prev-article)
7852 (gnus-summary-prev-unread-article))))))))
7853 (gnus-summary-position-point))
7854
7855(defun gnus-summary-prev-page-or-article (&optional lines)
7856 "Show previous page of selected article.
7857Argument LINES specifies lines to be scrolled down.
7858If at the beginning of the article, go to the next article."
7859 (interactive "P")
7860 (gnus-summary-prev-page lines t))
7861
7862(defun gnus-summary-scroll-up (lines)
7863 "Scroll up (or down) one line current article.
a3f57c41
G
7864Argument LINES specifies lines to be scrolled up (or down if negative).
7865If no article is selected, then the current article will be selected first."
eec82323 7866 (interactive "p")
eec82323
LMI
7867 (gnus-configure-windows 'article)
7868 (gnus-summary-show-thread)
7869 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7870 (gnus-eval-in-buffer-window gnus-article-buffer
7871 (cond ((> lines 0)
7872 (when (gnus-article-next-page lines)
7873 (gnus-message 3 "End of message")))
7874 ((< lines 0)
7875 (gnus-article-prev-page (- lines))))))
7876 (gnus-summary-recenter)
7877 (gnus-summary-position-point))
7878
6748645f
LMI
7879(defun gnus-summary-scroll-down (lines)
7880 "Scroll down (or up) one line current article.
a3f57c41
G
7881Argument LINES specifies lines to be scrolled down (or up if negative).
7882If no article is selected, then the current article will be selected first."
6748645f
LMI
7883 (interactive "p")
7884 (gnus-summary-scroll-up (- lines)))
7885
eec82323
LMI
7886(defun gnus-summary-next-same-subject ()
7887 "Select next article which has the same subject as current one."
7888 (interactive)
eec82323
LMI
7889 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7890
7891(defun gnus-summary-prev-same-subject ()
7892 "Select previous article which has the same subject as current one."
7893 (interactive)
eec82323
LMI
7894 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7895
7896(defun gnus-summary-next-unread-same-subject ()
7897 "Select next unread article which has the same subject as current one."
7898 (interactive)
eec82323
LMI
7899 (gnus-summary-next-article t (gnus-summary-article-subject)))
7900
7901(defun gnus-summary-prev-unread-same-subject ()
7902 "Select previous unread article which has the same subject as current one."
7903 (interactive)
eec82323
LMI
7904 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7905
7906(defun gnus-summary-first-unread-article ()
7907 "Select the first unread article.
7908Return nil if there are no unread articles."
7909 (interactive)
eec82323
LMI
7910 (prog1
7911 (when (gnus-summary-first-subject t)
7912 (gnus-summary-show-thread)
7913 (gnus-summary-first-subject t)
7914 (gnus-summary-display-article (gnus-summary-article-number)))
7915 (gnus-summary-position-point)))
7916
16409b0b
GM
7917(defun gnus-summary-first-unread-subject ()
7918 "Place the point on the subject line of the first unread article.
7919Return nil if there are no unread articles."
7920 (interactive)
7921 (prog1
7922 (when (gnus-summary-first-subject t)
7923 (gnus-summary-show-thread)
7924 (gnus-summary-first-subject t))
7925 (gnus-summary-position-point)))
7926
23f87bed
MB
7927(defun gnus-summary-first-unseen-subject ()
7928 "Place the point on the subject line of the first unseen article.
7929Return nil if there are no unseen articles."
7930 (interactive)
7931 (prog1
7932 (when (gnus-summary-first-subject nil nil t)
7933 (gnus-summary-show-thread)
7934 (gnus-summary-first-subject nil nil t))
7935 (gnus-summary-position-point)))
7936
7937(defun gnus-summary-first-unseen-or-unread-subject ()
20a673b2
KY
7938 "Place the point on the subject line of the first unseen and unread article.
7939If all article have been seen, on the subject line of the first unread
23f87bed
MB
7940article."
7941 (interactive)
7942 (prog1
7943 (unless (when (gnus-summary-first-subject nil nil t)
7944 (gnus-summary-show-thread)
7945 (gnus-summary-first-subject nil nil t))
7946 (when (gnus-summary-first-subject t)
7947 (gnus-summary-show-thread)
7948 (gnus-summary-first-subject t)))
7949 (gnus-summary-position-point)))
7950
eec82323
LMI
7951(defun gnus-summary-first-article ()
7952 "Select the first article.
7953Return nil if there are no articles."
7954 (interactive)
eec82323
LMI
7955 (prog1
7956 (when (gnus-summary-first-subject)
16409b0b
GM
7957 (gnus-summary-show-thread)
7958 (gnus-summary-first-subject)
7959 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
7960 (gnus-summary-position-point)))
7961
23f87bed
MB
7962(defun gnus-summary-best-unread-article (&optional arg)
7963 "Select the unread article with the highest score.
7964If given a prefix argument, select the next unread article that has a
7965score higher than the default score."
7966 (interactive "P")
7967 (let ((article (if arg
7968 (gnus-summary-better-unread-subject)
7969 (gnus-summary-best-unread-subject))))
7970 (if article
7971 (gnus-summary-goto-article article)
7972 (error "No unread articles"))))
7973
7974(defun gnus-summary-best-unread-subject ()
7975 "Select the unread subject with the highest score."
eec82323 7976 (interactive)
eec82323
LMI
7977 (let ((best -1000000)
7978 (data gnus-newsgroup-data)
7979 article score)
7980 (while data
7981 (and (gnus-data-unread-p (car data))
7982 (> (setq score
7983 (gnus-summary-article-score (gnus-data-number (car data))))
7984 best)
7985 (setq best score
7986 article (gnus-data-number (car data))))
7987 (setq data (cdr data)))
23f87bed
MB
7988 (when article
7989 (gnus-summary-goto-subject article))
7990 (gnus-summary-position-point)
7991 article))
7992
7993(defun gnus-summary-better-unread-subject ()
7994 "Select the first unread subject that has a score over the default score."
7995 (interactive)
7996 (let ((data gnus-newsgroup-data)
7997 article score)
7998 (while (and (setq article (gnus-data-number (car data)))
7999 (or (gnus-data-read-p (car data))
8000 (not (> (gnus-summary-article-score article)
8001 gnus-summary-default-score))))
8002 (setq data (cdr data)))
8003 (when article
8004 (gnus-summary-goto-subject article))
8005 (gnus-summary-position-point)
8006 article))
eec82323
LMI
8007
8008(defun gnus-summary-last-subject ()
8009 "Go to the last displayed subject line in the group."
8010 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8011 (when article
8012 (gnus-summary-goto-subject article))))
8013
8014(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
8015 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8016If ALL-HEADERS is non-nil, no header lines are hidden.
8017If FORCE, go to the article even if it isn't displayed. If FORCE
8018is a number, it is the line the article is to be displayed on."
eec82323
LMI
8019 (interactive
8020 (list
229b59da
G
8021 (gnus-completing-read
8022 "Article number or Message-ID"
8023 (mapcar 'int-to-string gnus-newsgroup-limit))
eec82323
LMI
8024 current-prefix-arg
8025 t))
8026 (prog1
6748645f 8027 (if (and (stringp article)
23f87bed 8028 (string-match "@\\|%40" article))
6748645f
LMI
8029 (gnus-summary-refer-article article)
8030 (when (stringp article)
8031 (setq article (string-to-number article)))
8032 (if (gnus-summary-goto-subject article force)
8033 (gnus-summary-display-article article all-headers)
8034 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
8035 (gnus-summary-position-point)))
8036
8037(defun gnus-summary-goto-last-article ()
8038 "Go to the previously read article."
8039 (interactive)
8040 (prog1
8041 (when gnus-last-article
6748645f 8042 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
8043 (gnus-summary-position-point)))
8044
8045(defun gnus-summary-pop-article (number)
8046 "Pop one article off the history and go to the previous.
8047NUMBER articles will be popped off."
8048 (interactive "p")
8049 (let (to)
8050 (setq gnus-newsgroup-history
8051 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8052 (if to
6748645f 8053 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
8054 (error "Article history empty")))
8055 (gnus-summary-position-point))
8056
8057;; Summary commands and functions for limiting the summary buffer.
8058
8059(defun gnus-summary-limit-to-articles (n)
8060 "Limit the summary buffer to the next N articles.
8061If not given a prefix, use the process marked articles instead."
8062 (interactive "P")
eec82323
LMI
8063 (prog1
8064 (let ((articles (gnus-summary-work-articles n)))
8065 (setq gnus-newsgroup-processable nil)
8066 (gnus-summary-limit articles))
8067 (gnus-summary-position-point)))
8068
8069(defun gnus-summary-pop-limit (&optional total)
8070 "Restore the previous limit.
8071If given a prefix, remove all limits."
8072 (interactive "P")
eec82323
LMI
8073 (when total
8074 (setq gnus-newsgroup-limits
8075 (list (mapcar (lambda (h) (mail-header-number h))
8076 gnus-newsgroup-headers))))
8077 (unless gnus-newsgroup-limits
8078 (error "No limit to pop"))
8079 (prog1
8080 (gnus-summary-limit nil 'pop)
8081 (gnus-summary-position-point)))
8082
47b63dfa
SZ
8083(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8084 "Limit the summary buffer to articles that have subjects that match a regexp.
8085If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 8086 (interactive
47b63dfa
SZ
8087 (list (read-string (if current-prefix-arg
8088 "Exclude subject (regexp): "
a1506d29 8089 "Limit to subject (regexp): "))
47b63dfa 8090 nil current-prefix-arg))
eec82323
LMI
8091 (unless header
8092 (setq header "subject"))
8093 (when (not (equal "" subject))
8094 (prog1
8095 (let ((articles (gnus-summary-find-matching
a1506d29 8096 (or header "subject") subject 'all nil nil
47b63dfa 8097 not-matching)))
eec82323
LMI
8098 (unless articles
8099 (error "Found no matches for \"%s\"" subject))
8100 (gnus-summary-limit articles))
8101 (gnus-summary-position-point))))
8102
ef6e0ec7 8103(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
8104 "Limit the summary buffer to articles that have authors that match a regexp.
8105If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 8106 (interactive
47b63dfa
SZ
8107 (list (read-string (if current-prefix-arg
8108 "Exclude author (regexp): "
a1506d29 8109 "Limit to author (regexp): "))
ef6e0ec7
SZ
8110 current-prefix-arg))
8111 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323 8112
01c52d31
MB
8113(defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8114 "Limit the summary buffer to articles with the given RECIPIENT.
8115
8116If NOT-MATCHING, exclude RECIPIENT.
8117
8118To and Cc headers are checked. You need to include them in
8119`nnmail-extra-headers'."
8120 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8121 (interactive
8122 (list (read-string (format "%s recipient (regexp): "
8123 (if current-prefix-arg "Exclude" "Limit to")))
8124 current-prefix-arg))
8125 (when (not (equal "" recipient))
8126 (prog1 (let* ((to
8127 (if (memq 'To nnmail-extra-headers)
8128 (gnus-summary-find-matching
8129 (cons 'extra 'To) recipient 'all nil nil
8130 not-matching)
8131 (gnus-message
8132 1 "`To' isn't present in `nnmail-extra-headers'")
8133 (sit-for 1)
8134 nil))
8135 (cc
8136 (if (memq 'Cc nnmail-extra-headers)
8137 (gnus-summary-find-matching
8138 (cons 'extra 'Cc) recipient 'all nil nil
8139 not-matching)
8140 (gnus-message
8141 1 "`Cc' isn't present in `nnmail-extra-headers'")
8142 (sit-for 1)
8143 nil))
8144 (articles
8145 (if not-matching
8146 ;; We need the numbers that are in both lists:
8147 (mapcar (lambda (a)
8148 (and (memq a to) a))
8149 cc)
8150 (nconc to cc))))
8151 (unless articles
8152 (error "Found no matches for \"%s\"" recipient))
8153 (gnus-summary-limit articles))
8154 (gnus-summary-position-point))))
8155
8156(defun gnus-summary-limit-to-address (address &optional not-matching)
8157 "Limit the summary buffer to articles with the given ADDRESS.
8158
8159If NOT-MATCHING, exclude ADDRESS.
8160
8161To, Cc and From headers are checked. You need to include `To' and `Cc'
8162in `nnmail-extra-headers'."
8163 (interactive
8164 (list (read-string (format "%s address (regexp): "
8165 (if current-prefix-arg "Exclude" "Limit to")))
8166 current-prefix-arg))
8167 (when (not (equal "" address))
8168 (prog1 (let* ((to
8169 (if (memq 'To nnmail-extra-headers)
8170 (gnus-summary-find-matching
8171 (cons 'extra 'To) address 'all nil nil
8172 not-matching)
8173 (gnus-message
8174 1 "`To' isn't present in `nnmail-extra-headers'")
8175 (sit-for 1)
8176 t))
8177 (cc
8178 (if (memq 'Cc nnmail-extra-headers)
8179 (gnus-summary-find-matching
8180 (cons 'extra 'Cc) address 'all nil nil
8181 not-matching)
8182 (gnus-message
8183 1 "`Cc' isn't present in `nnmail-extra-headers'")
8184 (sit-for 1)
8185 t))
8186 (from
8187 (gnus-summary-find-matching "from" address
8188 'all nil nil not-matching))
8189 (articles
8190 (if not-matching
8191 ;; We need the numbers that are in all lists:
8192 (if (eq cc t)
8193 (if (eq to t)
8194 from
8195 (mapcar (lambda (a) (car (memq a from))) to))
8196 (if (eq to t)
8197 (mapcar (lambda (a) (car (memq a from))) cc)
8198 (mapcar (lambda (a) (car (memq a from)))
8199 (mapcar (lambda (a) (car (memq a to)))
8200 cc))))
8201 (nconc (if (eq to t) nil to)
8202 (if (eq cc t) nil cc)
8203 from))))
8204 (unless articles
8205 (error "Found no matches for \"%s\"" address))
8206 (gnus-summary-limit articles))
8207 (gnus-summary-position-point))))
8208
8209(defun gnus-summary-limit-strange-charsets-predicate (header)
765d4319
KY
8210 (when (fboundp 'char-charset)
8211 (let ((string (concat (mail-header-subject header)
8212 (mail-header-from header)))
8213 charset found)
8214 (dotimes (i (1- (length string)))
8215 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8216 (when (string-match "unicode\\|big\\|japanese" charset)
8217 (setq found t)))
8218 found)))
01c52d31
MB
8219
8220(defun gnus-summary-limit-to-predicate (predicate)
8221 "Limit to articles where PREDICATE returns non-nil.
8222PREDICATE will be called with the header structures of the
8223articles."
8224 (let ((articles nil)
8225 (case-fold-search t))
8226 (dolist (header gnus-newsgroup-headers)
8227 (when (funcall predicate header)
8228 (push (mail-header-number header) articles)))
8229 (gnus-summary-limit (nreverse articles))))
8230
eec82323
LMI
8231(defun gnus-summary-limit-to-age (age &optional younger-p)
8232 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8233If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8234articles that are younger than AGE days."
16409b0b
GM
8235 (interactive
8236 (let ((younger current-prefix-arg)
8237 (days-got nil)
8238 days)
8239 (while (not days-got)
8240 (setq days (if younger
23f87bed
MB
8241 (read-string "Limit to articles younger than (in days, older when negative): ")
8242 (read-string
8243 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
8244 (when (> (length days) 0)
8245 (setq days (read days)))
8246 (if (numberp days)
23f87bed
MB
8247 (progn
8248 (setq days-got t)
01c52d31
MB
8249 (when (< days 0)
8250 (setq younger (not younger))
8251 (setq days (* days -1))))
16409b0b
GM
8252 (message "Please enter a number.")
8253 (sleep-for 1)))
8254 (list days younger)))
eec82323
LMI
8255 (prog1
8256 (let ((data gnus-newsgroup-data)
16409b0b 8257 (cutoff (days-to-time age))
eec82323
LMI
8258 articles d date is-younger)
8259 (while (setq d (pop data))
8260 (when (and (vectorp (gnus-data-header d))
8261 (setq date (mail-header-date (gnus-data-header d))))
16409b0b 8262 (setq is-younger (time-less-p
3d6e7a43 8263 (time-since (gnus-date-get-time date))
eec82323 8264 cutoff))
6748645f
LMI
8265 (when (if younger-p
8266 is-younger
8267 (not is-younger))
eec82323
LMI
8268 (push (gnus-data-number d) articles))))
8269 (gnus-summary-limit (nreverse articles)))
8270 (gnus-summary-position-point)))
8271
47b63dfa 8272(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
8273 "Limit the summary buffer to articles that match an 'extra' header."
8274 (interactive
8275 (let ((header
8276 (intern
229b59da 8277 (gnus-completing-read
47b63dfa 8278 (if current-prefix-arg
81df110a
RF
8279 "Exclude extra header"
8280 "Limit extra header")
229b59da
G
8281 (mapcar 'symbol-name gnus-extra-headers)
8282 t nil nil
8283 (symbol-name (car gnus-extra-headers))))))
16409b0b 8284 (list header
a1506d29 8285 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
8286 (if current-prefix-arg "Exclude" "Limit to")
8287 header))
8288 current-prefix-arg)))
16409b0b
GM
8289 (when (not (equal "" regexp))
8290 (prog1
8291 (let ((articles (gnus-summary-find-matching
a1506d29 8292 (cons 'extra header) regexp 'all nil nil
47b63dfa 8293 not-matching)))
16409b0b
GM
8294 (unless articles
8295 (error "Found no matches for \"%s\"" regexp))
8296 (gnus-summary-limit articles))
8297 (gnus-summary-position-point))))
8298
23f87bed
MB
8299(defun gnus-summary-limit-to-display-predicate ()
8300 "Limit the summary buffer to the predicated in the `display' group parameter."
8301 (interactive)
8302 (unless gnus-newsgroup-display
8303 (error "There is no `display' group parameter"))
8304 (let (articles)
3a3cbf0a 8305 (dolist (gnus-number gnus-newsgroup-articles)
23f87bed 8306 (when (funcall gnus-newsgroup-display)
3a3cbf0a 8307 (push gnus-number articles)))
23f87bed
MB
8308 (gnus-summary-limit articles))
8309 (gnus-summary-position-point))
8310
eec82323
LMI
8311(defun gnus-summary-limit-to-unread (&optional all)
8312 "Limit the summary buffer to articles that are not marked as read.
8313If ALL is non-nil, limit strictly to unread articles."
8314 (interactive "P")
8315 (if all
8316 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8317 (gnus-summary-limit-to-marks
8318 ;; Concat all the marks that say that an article is read and have
8319 ;; those removed.
8320 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 8321 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
8322 gnus-low-score-mark gnus-expirable-mark
8323 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
c4d82de8 8324 gnus-duplicate-mark)
eec82323
LMI
8325 'reverse)))
8326
01c52d31
MB
8327(defun gnus-summary-limit-to-headers (match &optional reverse)
8328 "Limit the summary buffer to articles that have headers that match MATCH.
8329If REVERSE (the prefix), limit to articles that don't match."
8330 (interactive "sMatch headers (regexp): \nP")
8331 (gnus-summary-limit-to-bodies match reverse t))
8332
8333(defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8334 "Limit the summary buffer to articles that have bodies that match MATCH.
8335If REVERSE (the prefix), limit to articles that don't match."
8336 (interactive "sMatch body (regexp): \nP")
8337 (let ((articles nil)
8338 (gnus-select-article-hook nil) ;Disable hook.
8339 (gnus-article-prepare-hook nil)
8340 (gnus-use-article-prefetch nil)
8341 (gnus-keep-backlog nil)
8342 (gnus-break-pages nil)
8343 (gnus-summary-display-arrow nil)
8344 (gnus-updated-mode-lines nil)
8345 (gnus-auto-center-summary nil)
8346 (gnus-display-mime-function nil))
8347 (dolist (data gnus-newsgroup-data)
8348 (let (gnus-mark-article-hook)
8349 (gnus-summary-select-article t t nil (gnus-data-number data)))
398a825b 8350 (with-current-buffer gnus-article-buffer
01c52d31
MB
8351 (article-goto-body)
8352 (let* ((case-fold-search t)
8353 (found (if headersp
8354 (re-search-backward match nil t)
8355 (re-search-forward match nil t))))
8356 (when (or (and found
8357 (not reverse))
8358 (and (not found)
8359 reverse))
8360 (push (gnus-data-number data) articles)))))
8361 (if (not articles)
8362 (message "No messages matched")
8363 (gnus-summary-limit articles)))
8364 (gnus-summary-position-point))
8365
8366(defun gnus-summary-limit-to-singletons (&optional threadsp)
8367 "Limit the summary buffer to articles that aren't part on any thread.
8368If THREADSP (the prefix), limit to articles that are in threads."
8369 (interactive "P")
8370 (let ((articles nil)
8371 thread-articles
8372 threads)
8373 (dolist (thread gnus-newsgroup-threads)
8374 (if (stringp (car thread))
8375 (dolist (thread (cdr thread))
8376 (push thread threads))
8377 (push thread threads)))
8378 (dolist (thread threads)
8379 (setq thread-articles (gnus-articles-in-thread thread))
8380 (when (or (and threadsp
8381 (> (length thread-articles) 1))
8382 (and (not threadsp)
8383 (= (length thread-articles) 1)))
8384 (setq articles (nconc thread-articles articles))))
8385 (if (not articles)
8386 (message "No messages matched")
8387 (gnus-summary-limit articles))
8388 (gnus-summary-position-point)))
8389
8390(defun gnus-summary-limit-to-replied (&optional unreplied)
8391 "Limit the summary buffer to replied articles.
8392If UNREPLIED (the prefix), limit to unreplied articles."
8393 (interactive "P")
8394 (if unreplied
8395 (gnus-summary-limit
8396 (gnus-set-difference gnus-newsgroup-articles
8397 gnus-newsgroup-replied))
8398 (gnus-summary-limit gnus-newsgroup-replied))
8399 (gnus-summary-position-point))
8400
eec82323
LMI
8401(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8402 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8403If REVERSE, limit the summary buffer to articles that are marked
8404with MARKS. MARKS can either be a string of marks or a list of marks.
8405Returns how many articles were removed."
8406 (interactive "sMarks: ")
8407 (gnus-summary-limit-to-marks marks t))
8408
8409(defun gnus-summary-limit-to-marks (marks &optional reverse)
8410 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8411If REVERSE (the prefix), limit the summary buffer to articles that are
8412not marked with MARKS. MARKS can either be a string of marks or a
8413list of marks.
8414Returns how many articles were removed."
6748645f 8415 (interactive "sMarks: \nP")
eec82323
LMI
8416 (prog1
8417 (let ((data gnus-newsgroup-data)
8418 (marks (if (listp marks) marks
8419 (append marks nil))) ; Transform to list.
8420 articles)
8421 (while data
8422 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8423 (memq (gnus-data-mark (car data)) marks))
8424 (push (gnus-data-number (car data)) articles))
8425 (setq data (cdr data)))
8426 (gnus-summary-limit articles))
8427 (gnus-summary-position-point)))
8428
23f87bed 8429(defun gnus-summary-limit-to-score (score)
eec82323 8430 "Limit to articles with score at or above SCORE."
23f87bed 8431 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
8432 (let ((data gnus-newsgroup-data)
8433 articles)
8434 (while data
8435 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8436 score)
8437 (push (gnus-data-number (car data)) articles))
8438 (setq data (cdr data)))
8439 (prog1
8440 (gnus-summary-limit articles)
8441 (gnus-summary-position-point))))
8442
23f87bed
MB
8443(defun gnus-summary-limit-to-unseen ()
8444 "Limit to unseen articles."
8445 (interactive)
8446 (prog1
8447 (gnus-summary-limit gnus-newsgroup-unseen)
8448 (gnus-summary-position-point)))
8449
6748645f 8450(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
8451 "Display all the hidden articles that is in the thread with ID in it.
8452When called interactively, ID is the Message-ID of the current
8453article."
6748645f
LMI
8454 (interactive (list (mail-header-id (gnus-summary-article-header))))
8455 (let ((articles (gnus-articles-in-thread
181cb5fb
G
8456 (gnus-id-to-thread (gnus-root-id id))))
8457 ;;we REALLY want the whole thread---this prevents cut-threads
8458 ;;from removing the thread we want to include.
8459 (gnus-fetch-old-headers nil)
8460 (gnus-build-sparse-threads nil))
6748645f
LMI
8461 (prog1
8462 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
8463 (gnus-summary-limit-include-matching-articles
8464 "subject"
8465 (regexp-quote (gnus-simplify-subject-re
8466 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
8467 (gnus-summary-position-point))))
8468
23f87bed
MB
8469(defun gnus-summary-limit-include-matching-articles (header regexp)
8470 "Display all the hidden articles that have HEADERs that match REGEXP."
8471 (interactive (list (read-string "Match on header: ")
8472 (read-string "Regexp: ")))
8473 (let ((articles (gnus-find-matching-articles header regexp)))
8474 (prog1
8475 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8476 (gnus-summary-position-point))))
8477
8478(defun gnus-summary-insert-dormant-articles ()
8479 "Insert all the dormant articles for this group into the current buffer."
8480 (interactive)
8481 (let ((gnus-verbose (max 6 gnus-verbose)))
8482 (if (not gnus-newsgroup-dormant)
db629244 8483 (gnus-message 3 "No dormant articles for this group")
23f87bed
MB
8484 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8485
01c52d31
MB
8486(defun gnus-summary-insert-ticked-articles ()
8487 "Insert ticked articles for this group into the current buffer."
8488 (interactive)
8489 (let ((gnus-verbose (max 6 gnus-verbose)))
8490 (if (not gnus-newsgroup-marked)
8491 (gnus-message 3 "No ticked articles for this group")
8492 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8493
eec82323 8494(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
8495 "Display all the hidden articles that are marked as dormant.
8496Note that this command only works on a subset of the articles currently
8497fetched for this group."
eec82323 8498 (interactive)
eec82323
LMI
8499 (unless gnus-newsgroup-dormant
8500 (error "There are no dormant articles in this group"))
8501 (prog1
8502 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8503 (gnus-summary-position-point)))
8504
144b7b5c
G
8505(defun gnus-summary-include-articles (articles)
8506 "Fetch the headers for ARTICLES and then display the summary lines."
8507 (let ((gnus-inhibit-demon t)
8508 (gnus-agent nil)
8509 (gnus-read-all-available-headers t))
8510 (setq gnus-newsgroup-headers
8511 (gnus-merge
8512 'list gnus-newsgroup-headers
8513 (gnus-fetch-headers articles nil t)
8514 'gnus-article-sort-by-number))
8515 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8516
eec82323
LMI
8517(defun gnus-summary-limit-exclude-dormant ()
8518 "Hide all dormant articles."
8519 (interactive)
eec82323
LMI
8520 (prog1
8521 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8522 (gnus-summary-position-point)))
8523
8524(defun gnus-summary-limit-exclude-childless-dormant ()
8525 "Hide all dormant articles that have no children."
8526 (interactive)
eec82323
LMI
8527 (let ((data (gnus-data-list t))
8528 articles d children)
8529 ;; Find all articles that are either not dormant or have
8530 ;; children.
8531 (while (setq d (pop data))
8532 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8533 (and (setq children
8534 (gnus-article-children (gnus-data-number d)))
8535 (let (found)
8536 (while children
8537 (when (memq (car children) articles)
8538 (setq children nil
8539 found t))
8540 (pop children))
8541 found)))
8542 (push (gnus-data-number d) articles)))
8543 ;; Do the limiting.
8544 (prog1
8545 (gnus-summary-limit articles)
8546 (gnus-summary-position-point))))
8547
8548(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8549 "Mark all unread excluded articles as read.
8550If ALL, mark even excluded ticked and dormants as read."
8551 (interactive "P")
23f87bed
MB
8552 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8553 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8554 (sort
8555 (mapcar (lambda (h) (mail-header-number h))
8556 gnus-newsgroup-headers)
8557 '<)
23f87bed 8558 gnus-newsgroup-limit))
eec82323 8559 article)
6748645f 8560 (setq gnus-newsgroup-unreads
23f87bed
MB
8561 (gnus-sorted-intersection gnus-newsgroup-unreads
8562 gnus-newsgroup-limit))
eec82323
LMI
8563 (if all
8564 (setq gnus-newsgroup-dormant nil
8565 gnus-newsgroup-marked nil
8566 gnus-newsgroup-reads
8567 (nconc
8568 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8569 gnus-newsgroup-reads))
8570 (while (setq article (pop articles))
8571 (unless (or (memq article gnus-newsgroup-dormant)
8572 (memq article gnus-newsgroup-marked))
8573 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8574
8575(defun gnus-summary-limit (articles &optional pop)
8576 (if pop
8577 ;; We pop the previous limit off the stack and use that.
8578 (setq articles (car gnus-newsgroup-limits)
8579 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8580 ;; We use the new limit, so we push the old limit on the stack.
8581 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8582 ;; Set the limit.
8583 (setq gnus-newsgroup-limit articles)
8584 (let ((total (length gnus-newsgroup-data))
8585 (data (gnus-data-find-list (gnus-summary-article-number)))
8586 (gnus-summary-mark-below nil) ; Inhibit this.
8587 found)
8588 ;; This will do all the work of generating the new summary buffer
8589 ;; according to the new limit.
8590 (gnus-summary-prepare)
8591 ;; Hide any threads, possibly.
23f87bed 8592 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8593 ;; Try to return to the article you were at, or one in the
8594 ;; neighborhood.
8595 (when data
8596 ;; We try to find some article after the current one.
8597 (while data
8598 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8599 (setq data nil
8600 found t))
8601 (setq data (cdr data))))
8602 (unless found
8603 ;; If there is no data, that means that we were after the last
8604 ;; article. The same goes when we can't find any articles
8605 ;; after the current one.
8606 (goto-char (point-max))
8607 (gnus-summary-find-prev))
6748645f 8608 (gnus-set-mode-line 'summary)
eec82323
LMI
8609 ;; We return how many articles were removed from the summary
8610 ;; buffer as a result of the new limit.
8611 (- total (length gnus-newsgroup-data))))
8612
8613(defsubst gnus-invisible-cut-children (threads)
8614 (let ((num 0))
8615 (while threads
8616 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8617 (incf num))
8618 (pop threads))
8619 (< num 2)))
8620
8621(defsubst gnus-cut-thread (thread)
8622 "Go forwards in the thread until we find an article that we want to display."
8623 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8624 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8625 (numberp gnus-fetch-old-headers)
eec82323
LMI
8626 (eq gnus-build-sparse-threads 'some)
8627 (eq gnus-build-sparse-threads 'more))
8628 ;; Deal with old-fetched headers and sparse threads.
8629 (while (and
8630 thread
8631 (or
8632 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8633 (gnus-summary-article-ancient-p
8634 (mail-header-number (car thread))))
6748645f
LMI
8635 (if (or (<= (length (cdr thread)) 1)
8636 (eq gnus-fetch-old-headers 'invisible))
8637 (setq gnus-newsgroup-limit
8638 (delq (mail-header-number (car thread))
8639 gnus-newsgroup-limit)
8640 thread (cadr thread))
8641 (when (gnus-invisible-cut-children (cdr thread))
8642 (let ((th (cdr thread)))
8643 (while th
8644 (if (memq (mail-header-number (caar th))
a8151ef7 8645 gnus-newsgroup-limit)
6748645f
LMI
8646 (setq thread (car th)
8647 th nil)
8648 (setq th (cdr th))))))))))
eec82323
LMI
8649 thread)
8650
8651(defun gnus-cut-threads (threads)
23f87bed 8652 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8653 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8654 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8655 (numberp gnus-fetch-old-headers)
eec82323
LMI
8656 (eq gnus-build-sparse-threads 'some)
8657 (eq gnus-build-sparse-threads 'more))
8658 (let ((th threads))
8659 (while th
8660 (setcar th (gnus-cut-thread (car th)))
8661 (setq th (cdr th)))))
8662 ;; Remove nixed out threads.
8663 (delq nil threads))
8664
8665(defun gnus-summary-initial-limit (&optional show-if-empty)
8666 "Figure out what the initial limit is supposed to be on group entry.
8667This entails weeding out unwanted dormants, low-scored articles,
8668fetch-old-headers verbiage, and so on."
8669 ;; Most groups have nothing to remove.
f394fa25
MB
8670 (unless (or gnus-inhibit-limiting
8671 (and (null gnus-newsgroup-dormant)
8672 (eq gnus-newsgroup-display 'gnus-not-ignore)
8673 (not (eq gnus-fetch-old-headers 'some))
8674 (not (numberp gnus-fetch-old-headers))
8675 (not (eq gnus-fetch-old-headers 'invisible))
8676 (null gnus-summary-expunge-below)
8677 (not (eq gnus-build-sparse-threads 'some))
8678 (not (eq gnus-build-sparse-threads 'more))
8ccbef23 8679 (null gnus-thread-expunge-below)))
eec82323
LMI
8680 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8681 (setq gnus-newsgroup-limit nil)
8682 (mapatoms
8683 (lambda (node)
8684 (unless (car (symbol-value node))
8685 ;; These threads have no parents -- they are roots.
8686 (let ((nodes (cdr (symbol-value node)))
8687 thread)
8688 (while nodes
8689 (if (and gnus-thread-expunge-below
8690 (< (gnus-thread-total-score (car nodes))
8691 gnus-thread-expunge-below))
8692 (gnus-expunge-thread (pop nodes))
8693 (setq thread (pop nodes))
8694 (gnus-summary-limit-children thread))))))
8695 gnus-newsgroup-dependencies)
8696 ;; If this limitation resulted in an empty group, we might
8697 ;; pop the previous limit and use it instead.
8698 (when (and (not gnus-newsgroup-limit)
8699 show-if-empty)
8700 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8701 gnus-newsgroup-limit))
8702
8703(defun gnus-summary-limit-children (thread)
8704 "Return 1 if this subthread is visible and 0 if it is not."
8705 ;; First we get the number of visible children to this thread. This
8706 ;; is done by recursing down the thread using this function, so this
8707 ;; will really go down to a leaf article first, before slowly
8708 ;; working its way up towards the root.
8709 (when thread
04b61ae9 8710 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8711 (children
eec82323
LMI
8712 (if (cdr thread)
8713 (apply '+ (mapcar 'gnus-summary-limit-children
8714 (cdr thread)))
8715 0))
3d319c8f
LMI
8716 (number (mail-header-number (car thread)))
8717 score)
eec82323
LMI
8718 (if (and
8719 (not (memq number gnus-newsgroup-marked))
8720 (or
8721 ;; If this article is dormant and has absolutely no visible
8722 ;; children, then this article isn't visible.
8723 (and (memq number gnus-newsgroup-dormant)
8724 (zerop children))
8725 ;; If this is "fetch-old-headered" and there is no
8726 ;; visible children, then we don't want this article.
16409b0b
GM
8727 (and (or (eq gnus-fetch-old-headers 'some)
8728 (numberp gnus-fetch-old-headers))
eec82323
LMI
8729 (gnus-summary-article-ancient-p number)
8730 (zerop children))
6748645f
LMI
8731 ;; If this is "fetch-old-headered" and `invisible', then
8732 ;; we don't want this article.
8733 (and (eq gnus-fetch-old-headers 'invisible)
8734 (gnus-summary-article-ancient-p number))
eec82323
LMI
8735 ;; If this is a sparsely inserted article with no children,
8736 ;; we don't want it.
8737 (and (eq gnus-build-sparse-threads 'some)
8738 (gnus-summary-article-sparse-p number)
8739 (zerop children))
8740 ;; If we use expunging, and this article is really
8741 ;; low-scored, then we don't want this article.
8742 (when (and gnus-summary-expunge-below
8743 (< (setq score
8744 (or (cdr (assq number gnus-newsgroup-scored))
8745 gnus-summary-default-score))
8746 gnus-summary-expunge-below))
8747 ;; We increase the expunge-tally here, but that has
8748 ;; nothing to do with the limits, really.
8749 (incf gnus-newsgroup-expunged-tally)
8750 ;; We also mark as read here, if that's wanted.
8751 (when (and gnus-summary-mark-below
8752 (< score gnus-summary-mark-below))
8753 (setq gnus-newsgroup-unreads
8754 (delq number gnus-newsgroup-unreads))
8755 (if gnus-newsgroup-auto-expire
8756 (push number gnus-newsgroup-expirable)
8757 (push (cons number gnus-low-score-mark)
8758 gnus-newsgroup-reads)))
8759 t)
23f87bed
MB
8760 ;; Do the `display' group parameter.
8761 (and gnus-newsgroup-display
3d319c8f
LMI
8762 (let ((gnus-number number))
8763 (not (funcall gnus-newsgroup-display))))))
eec82323
LMI
8764 ;; Nope, invisible article.
8765 0
8766 ;; Ok, this article is to be visible, so we add it to the limit
8767 ;; and return 1.
8768 (push number gnus-newsgroup-limit)
8769 1))))
8770
8771(defun gnus-expunge-thread (thread)
8772 "Mark all articles in THREAD as read."
8773 (let* ((number (mail-header-number (car thread))))
8774 (incf gnus-newsgroup-expunged-tally)
8775 ;; We also mark as read here, if that's wanted.
8776 (setq gnus-newsgroup-unreads
8777 (delq number gnus-newsgroup-unreads))
8778 (if gnus-newsgroup-auto-expire
8779 (push number gnus-newsgroup-expirable)
8780 (push (cons number gnus-low-score-mark)
8781 gnus-newsgroup-reads)))
8782 ;; Go recursively through all subthreads.
8783 (mapcar 'gnus-expunge-thread (cdr thread)))
8784
8785;; Summary article oriented commands
8786
8787(defun gnus-summary-refer-parent-article (n)
8788 "Refer parent article N times.
8789If N is negative, go to ancestor -N instead.
8790The difference between N and the number of articles fetched is returned."
8791 (interactive "p")
eec82323
LMI
8792 (let ((skip 1)
8793 error header ref)
8794 (when (not (natnump n))
8795 (setq skip (abs n)
8796 n 1))
8797 (while (and (> n 0)
8798 (not error))
8799 (setq header (gnus-summary-article-header))
8800 (if (and (eq (mail-header-number header)
8801 (cdr gnus-article-current))
8802 (equal gnus-newsgroup-name
8803 (car gnus-article-current)))
8804 ;; If we try to find the parent of the currently
8805 ;; displayed article, then we take a look at the actual
8806 ;; References header, since this is slightly more
8807 ;; reliable than the References field we got from the
8808 ;; server.
c7a91ce1 8809 (with-current-buffer gnus-original-article-buffer
eec82323
LMI
8810 (nnheader-narrow-to-headers)
8811 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8812 (when (setq ref (message-fetch-field "in-reply-to"))
8813 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8814 (widen))
8815 (setq ref
8816 ;; It's not the current article, so we take a bet on
8817 ;; the value we got from the server.
8818 (mail-header-references header)))
8819 (if (and ref
8820 (not (equal ref "")))
8821 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8822 (gnus-message 1 "Couldn't find parent"))
8823 (gnus-message 1 "No references in article %d"
8824 (gnus-summary-article-number))
8825 (setq error t))
8826 (decf n))
8827 (gnus-summary-position-point)
8828 n))
8829
8830(defun gnus-summary-refer-references ()
8831 "Fetch all articles mentioned in the References header.
6748645f 8832Return the number of articles fetched."
eec82323 8833 (interactive)
eec82323
LMI
8834 (let ((ref (mail-header-references (gnus-summary-article-header)))
8835 (current (gnus-summary-article-number))
8836 (n 0))
8837 (if (or (not ref)
8838 (equal ref ""))
8839 (error "No References in the current article")
8840 ;; For each Message-ID in the References header...
8841 (while (string-match "<[^>]*>" ref)
8842 (incf n)
8843 ;; ... fetch that article.
8844 (gnus-summary-refer-article
8845 (prog1 (match-string 0 ref)
8846 (setq ref (substring ref (match-end 0))))))
8847 (gnus-summary-goto-subject current)
8848 (gnus-summary-position-point)
8849 n)))
8850
6748645f
LMI
8851(defun gnus-summary-refer-thread (&optional limit)
8852 "Fetch all articles in the current thread.
030158f3
G
8853If no backend-specific 'request-thread function is available
8854fetch LIMIT (the numerical prefix) old headers. If LIMIT is nil
8855fetch what's specified by the `gnus-refer-thread-limit'
8856variable."
6748645f 8857 (interactive "P")
4ddab346 8858 (gnus-warp-to-article)
6748645f 8859 (let ((id (mail-header-id (gnus-summary-article-header)))
181cb5fb 8860 (gnus-inhibit-demon t)
4ddab346
G
8861 (gnus-agent nil)
8862 (gnus-summary-ignore-duplicates t)
181cb5fb 8863 (gnus-read-all-available-headers t)
6748645f
LMI
8864 (limit (if limit (prefix-numeric-value limit)
8865 gnus-refer-thread-limit)))
4ddab346
G
8866 (setq gnus-newsgroup-headers
8867 (gnus-merge
8868 'list gnus-newsgroup-headers
8869 (if (gnus-check-backend-function
8870 'request-thread gnus-newsgroup-name)
8871 (gnus-request-thread id)
8872 (let* ((last (if (numberp limit)
8873 (min (+ (mail-header-number
8874 (gnus-summary-article-header))
8875 limit)
8876 gnus-newsgroup-highest)
8877 gnus-newsgroup-highest))
8878 (subject (gnus-simplify-subject
8879 (mail-header-subject
8880 (gnus-summary-article-header))))
8881 (refs (split-string (or (mail-header-references
8882 (gnus-summary-article-header))
8883 "")))
8884 (gnus-parse-headers-hook
8885 (lambda () (goto-char (point-min))
8886 (keep-lines
8887 (regexp-opt (append refs (list id subject)))))))
8888 (gnus-fetch-headers (list last) (if (numberp limit)
8889 (* 2 limit) limit) t)))
8890 'gnus-article-sort-by-number))
6748645f
LMI
8891 (gnus-summary-limit-include-thread id)))
8892
16409b0b
GM
8893(defun gnus-summary-refer-article (message-id)
8894 "Fetch an article specified by MESSAGE-ID."
8895 (interactive "sMessage-ID: ")
eec82323
LMI
8896 (when (and (stringp message-id)
8897 (not (zerop (length message-id))))
23f87bed 8898 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8899 ;; Construct the correct Message-ID if necessary.
8900 ;; Suggested by tale@pawl.rpi.edu.
8901 (unless (string-match "^<" message-id)
8902 (setq message-id (concat "<" message-id)))
8903 (unless (string-match ">$" message-id)
8904 (setq message-id (concat message-id ">")))
23f87bed
MB
8905 ;; People often post MIDs from URLs, so unhex it:
8906 (unless (string-match "@" message-id)
8907 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8908 (let* ((header (gnus-id-to-header message-id))
8909 (sparse (and header
8910 (gnus-summary-article-sparse-p
a8151ef7
LMI
8911 (mail-header-number header))
8912 (memq (mail-header-number header)
16409b0b
GM
8913 gnus-newsgroup-limit)))
8914 number)
6748645f
LMI
8915 (cond
8916 ;; If the article is present in the buffer we just go to it.
8917 ((and header
8918 (or (not (gnus-summary-article-sparse-p
8919 (mail-header-number header)))
8920 sparse))
8921 (prog1
8922 (gnus-summary-goto-article
8923 (mail-header-number header) nil t)
8924 (when sparse
8925 (gnus-summary-update-article (mail-header-number header)))))
8926 (t
16409b0b
GM
8927 ;; We fetch the article.
8928 (catch 'found
8929 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8930 (when (and (gnus-check-server gnus-override-method)
8931 ;; Fetch the header,
8932 (setq number (gnus-summary-insert-subject message-id)))
8933 ;; and display the article.
eec82323 8934 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8935 (throw 'found t)))
8936 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8937
8938(defun gnus-refer-article-methods ()
8f688cb0 8939 "Return a list of referable methods."
16409b0b
GM
8940 (cond
8941 ;; No method, so we default to current and native.
8942 ((null gnus-refer-article-method)
8943 (list gnus-current-select-method gnus-select-method))
8944 ;; Current.
8945 ((eq 'current gnus-refer-article-method)
8946 (list gnus-current-select-method))
8947 ;; List of select methods.
d4dfaa19
DL
8948 ((not (and (symbolp (car gnus-refer-article-method))
8949 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
8950 (let (out)
8951 (dolist (method gnus-refer-article-method)
8952 (push (if (eq 'current method)
8953 gnus-current-select-method
8954 method)
8955 out))
8956 (nreverse out)))
8957 ;; One single select method.
8958 (t
8959 (list gnus-refer-article-method))))
6748645f
LMI
8960
8961(defun gnus-summary-edit-parameters ()
8962 "Edit the group parameters of the current group."
8963 (interactive)
8964 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 8965
16409b0b
GM
8966(defun gnus-summary-customize-parameters ()
8967 "Customize the group parameters of the current group."
8968 (interactive)
8969 (gnus-group-customize gnus-newsgroup-name))
8970
eec82323
LMI
8971(defun gnus-summary-enter-digest-group (&optional force)
8972 "Enter an nndoc group based on the current article.
8973If FORCE, force a digest interpretation. If not, try
8974to guess what the document format is."
8975 (interactive "P")
eec82323 8976 (let ((conf gnus-current-window-configuration))
23f87bed
MB
8977 (save-window-excursion
8978 (save-excursion
8979 (let (gnus-article-prepare-hook
8980 gnus-display-mime-function
8981 gnus-break-pages)
8982 (gnus-summary-select-article))))
eec82323
LMI
8983 (setq gnus-current-window-configuration conf)
8984 (let* ((name (format "%s-%d"
8985 (gnus-group-prefixed-name
8986 gnus-newsgroup-name (list 'nndoc ""))
01c52d31 8987 (with-current-buffer gnus-summary-buffer
eec82323
LMI
8988 gnus-current-article)))
8989 (ogroup gnus-newsgroup-name)
8990 (params (append (gnus-info-params (gnus-get-info ogroup))
8991 (list (cons 'to-group ogroup))
23f87bed 8992 (list (cons 'parent-group ogroup))
eec82323
LMI
8993 (list (cons 'save-article-group ogroup))))
8994 (case-fold-search t)
8995 (buf (current-buffer))
16409b0b 8996 dig to-address)
c7a91ce1 8997 (with-current-buffer gnus-original-article-buffer
16409b0b
GM
8998 ;; Have the digest group inherit the main mail address of
8999 ;; the parent article.
23f87bed
MB
9000 (when (setq to-address (or (gnus-fetch-field "reply-to")
9001 (gnus-fetch-field "from")))
343d6628
MB
9002 (setq params
9003 (append
9004 (list (cons 'to-address
9005 (funcall gnus-decode-encoded-address-function
9006 to-address))))))
eec82323
LMI
9007 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9008 (insert-buffer-substring gnus-original-article-buffer)
9009 ;; Remove lines that may lead nndoc to misinterpret the
9010 ;; document type.
9011 (narrow-to-region
9012 (goto-char (point-min))
9013 (or (search-forward "\n\n" nil t) (point)))
9014 (goto-char (point-min))
16409b0b 9015 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
9016 (widen))
9017 (unwind-protect
23f87bed 9018 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
9019 (gnus-newsgroup-ephemeral-ignored-charsets
9020 gnus-newsgroup-ignored-charsets))
9021 (gnus-group-read-ephemeral-group
9022 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9023 (nndoc-article-type
23f87bed
MB
9024 ,(if force 'mbox 'guess)))
9025 t nil nil nil
9026 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9027 "ADAPT")))))
16409b0b 9028 ;; Make all postings to this group go to the parent group.
23f87bed
MB
9029 (nconc (gnus-info-params (gnus-get-info name))
9030 params)
9031 ;; Couldn't select this doc group.
9032 (switch-to-buffer buf)
9033 (gnus-set-global-variables)
9034 (gnus-configure-windows 'summary)
9035 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
9036 (kill-buffer dig)))))
9037
9038(defun gnus-summary-read-document (n)
9039 "Open a new group based on the current article(s).
9040This will allow you to read digests and other similar
9041documents as newsgroups.
9042Obeys the standard process/prefix convention."
9043 (interactive "P")
01c52d31 9044 (let* ((ogroup gnus-newsgroup-name)
eec82323
LMI
9045 (params (append (gnus-info-params (gnus-get-info ogroup))
9046 (list (cons 'to-group ogroup))))
01c52d31
MB
9047 group egroup groups vgroup)
9048 (dolist (article (gnus-summary-work-articles n))
eec82323
LMI
9049 (setq group (format "%s-%d" gnus-newsgroup-name article))
9050 (gnus-summary-remove-process-mark article)
9051 (when (gnus-summary-display-article article)
398a825b 9052 (save-excursion ;;What for?
16409b0b 9053 (with-temp-buffer
eec82323
LMI
9054 (insert-buffer-substring gnus-original-article-buffer)
9055 ;; Remove some headers that may lead nndoc to make
9056 ;; the wrong guess.
9057 (message-narrow-to-head)
9058 (goto-char (point-min))
01c52d31 9059 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
9060 (widen)
9061 (if (setq egroup
9062 (gnus-group-read-ephemeral-group
9063 group `(nndoc ,group (nndoc-address ,(current-buffer))
9064 (nndoc-article-type guess))
9065 t nil t))
9066 (progn
c7a91ce1 9067 ;; Make all postings to this group go to the parent group.
eec82323
LMI
9068 (nconc (gnus-info-params (gnus-get-info egroup))
9069 params)
9070 (push egroup groups))
9071 ;; Couldn't select this doc group.
9072 (gnus-error 3 "Article couldn't be entered"))))))
9073 ;; Now we have selected all the documents.
9074 (cond
9075 ((not groups)
9076 (error "None of the articles could be interpreted as documents"))
9077 ((gnus-group-read-ephemeral-group
9078 (setq vgroup (format
9079 "nnvirtual:%s-%s" gnus-newsgroup-name
9080 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9081 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9082 t
9083 (cons (current-buffer) 'summary)))
9084 (t
9085 (error "Couldn't select virtual nndoc group")))))
9086
d50717f0
JD
9087(defun gnus-summary-widget-forward (arg)
9088 "Move point to the next field or button in the article.
9089With optional ARG, move across that many fields."
9090 (interactive "p")
9091 (gnus-summary-select-article)
9092 (gnus-configure-windows 'article)
9093 (select-window (gnus-get-buffer-window gnus-article-buffer))
9094 (widget-forward arg))
9095
eec82323
LMI
9096(defun gnus-summary-isearch-article (&optional regexp-p)
9097 "Do incremental search forward on the current article.
9098If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9099 (interactive "P")
eec82323
LMI
9100 (gnus-summary-select-article)
9101 (gnus-configure-windows 'article)
9102 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
9103 (save-restriction
9104 (widen)
9105 (isearch-forward regexp-p))))
eec82323 9106
01c52d31
MB
9107(defun gnus-summary-repeat-search-article-forward ()
9108 "Repeat the previous search forwards."
9109 (interactive)
9110 (unless gnus-last-search-regexp
9111 (error "No previous search"))
9112 (gnus-summary-search-article-forward gnus-last-search-regexp))
9113
9114(defun gnus-summary-repeat-search-article-backward ()
9115 "Repeat the previous search backwards."
9116 (interactive)
9117 (unless gnus-last-search-regexp
9118 (error "No previous search"))
9119 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9120
eec82323
LMI
9121(defun gnus-summary-search-article-forward (regexp &optional backward)
9122 "Search for an article containing REGEXP forward.
9123If BACKWARD, search backward instead."
9124 (interactive
9125 (list (read-string
9126 (format "Search article %s (regexp%s): "
9127 (if current-prefix-arg "backward" "forward")
9128 (if gnus-last-search-regexp
9129 (concat ", default " gnus-last-search-regexp)
9130 "")))
9131 current-prefix-arg))
eec82323
LMI
9132 (if (string-equal regexp "")
9133 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
9134 (setq gnus-last-search-regexp regexp)
9135 (setq gnus-article-before-search gnus-current-article))
9136 ;; Intentionally set gnus-last-article.
9137 (setq gnus-last-article gnus-article-before-search)
9138 (let ((gnus-last-article gnus-last-article))
9139 (if (gnus-summary-search-article regexp backward)
9140 (gnus-summary-show-thread)
abc40aab 9141 (signal 'search-failed (list regexp)))))
eec82323
LMI
9142
9143(defun gnus-summary-search-article-backward (regexp)
9144 "Search for an article containing REGEXP backward."
9145 (interactive
9146 (list (read-string
9147 (format "Search article backward (regexp%s): "
9148 (if gnus-last-search-regexp
9149 (concat ", default " gnus-last-search-regexp)
9150 "")))))
9151 (gnus-summary-search-article-forward regexp 'backward))
9152
9153(defun gnus-summary-search-article (regexp &optional backward)
9154 "Search for an article containing REGEXP.
9155Optional argument BACKWARD means do search for backward.
9156`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
9157 ;; We have to require this here to make sure that the following
9158 ;; dynamic binding isn't shadowed by autoloading.
9159 (require 'gnus-async)
16409b0b 9160 (require 'gnus-art)
eec82323 9161 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 9162 (gnus-article-prepare-hook nil)
eec82323
LMI
9163 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9164 (gnus-use-article-prefetch nil)
9165 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 9166 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
9167 (gnus-visual nil)
9168 (gnus-keep-backlog nil)
9169 (gnus-break-pages nil)
9170 (gnus-summary-display-arrow nil)
9171 (gnus-updated-mode-lines nil)
9172 (gnus-auto-center-summary nil)
eec82323 9173 (sum (current-buffer))
16409b0b 9174 (gnus-display-mime-function nil)
eec82323
LMI
9175 (found nil)
9176 point)
9177 (gnus-save-hidden-threads
9178 (gnus-summary-select-article)
9179 (set-buffer gnus-article-buffer)
16409b0b 9180 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
9181 (when backward
9182 (forward-line -1))
9183 (while (not found)
9184 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9185 (if (if backward
9186 (re-search-backward regexp nil t)
9187 (re-search-forward regexp nil t))
9188 ;; We found the regexp.
9189 (progn
9190 (setq found 'found)
9191 (beginning-of-line)
9192 (set-window-start
9193 (get-buffer-window (current-buffer))
9194 (point))
9195 (forward-line 1)
16409b0b
GM
9196 (set-window-point
9197 (get-buffer-window (current-buffer))
9198 (point))
eec82323
LMI
9199 (set-buffer sum)
9200 (setq point (point)))
9201 ;; We didn't find it, so we go to the next article.
9202 (set-buffer sum)
9203 (setq found 'not)
9204 (while (eq found 'not)
9205 (if (not (if backward (gnus-summary-find-prev)
9206 (gnus-summary-find-next)))
9207 ;; No more articles.
9208 (setq found t)
9209 ;; Select the next article and adjust point.
9210 (unless (gnus-summary-article-sparse-p
9211 (gnus-summary-article-number))
9212 (setq found nil)
9213 (gnus-summary-select-article)
9214 (set-buffer gnus-article-buffer)
9215 (widen)
9216 (goto-char (if backward (point-max) (point-min))))))))
9217 (gnus-message 7 ""))
9218 ;; Return whether we found the regexp.
9219 (when (eq found 'found)
9220 (goto-char point)
9221 (gnus-summary-show-thread)
9222 (gnus-summary-goto-subject gnus-current-article)
9223 (gnus-summary-position-point)
9224 t)))
9225
23f87bed
MB
9226(defun gnus-find-matching-articles (header regexp)
9227 "Return a list of all articles that match REGEXP on HEADER.
9228This search includes all articles in the current group that Gnus has
9229fetched headers for, whether they are displayed or not."
9230 (let ((articles nil)
c7a91ce1 9231 ;; Can't eta-reduce because it's a macro.
23f87bed
MB
9232 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9233 (case-fold-search t))
9234 (dolist (header gnus-newsgroup-headers)
9235 (when (string-match regexp (funcall func header))
9236 (push (mail-header-number header) articles)))
9237 (nreverse articles)))
9238
eec82323 9239(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 9240 not-case-fold not-matching)
eec82323
LMI
9241 "Return a list of all articles that match REGEXP on HEADER.
9242The search stars on the current article and goes forwards unless
9243BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9244If UNREAD is non-nil, only unread articles will
9245be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 9246in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
9247not match REGEXP on HEADER."
9248 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
9249 articles d func)
9250 (if (consp header)
9251 (if (eq (car header) 'extra)
9252 (setq func
9253 `(lambda (h)
9254 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9255 "")))
9256 (error "%s is an invalid header" header))
9257 (unless (fboundp (intern (concat "mail-header-" header)))
9258 (error "%s is not a valid header" header))
9259 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
9260 (dolist (d (if (eq backward 'all)
9261 gnus-newsgroup-data
9262 (gnus-data-find-list
9263 (gnus-summary-article-number)
9264 (gnus-data-list backward))))
9265 (when (and (or (not unread) ; We want all articles...
9266 (gnus-data-unread-p d)) ; Or just unreads.
9267 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9268 (if not-matching
a1506d29 9269 (not (string-match
47b63dfa
SZ
9270 regexp
9271 (funcall func (gnus-data-header d))))
9272 (string-match regexp
9273 (funcall func (gnus-data-header d)))))
9274 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
9275 (nreverse articles)))
9276
9277(defun gnus-summary-execute-command (header regexp command &optional backward)
9278 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9279If HEADER is an empty string (or nil), the match is done on the entire
9280article. If BACKWARD (the prefix) is non-nil, search backward instead."
9281 (interactive
9282 (list (let ((completion-ignore-case t))
229b59da
G
9283 (gnus-completing-read
9284 "Header name"
9285 (mapcar 'symbol-name
23f87bed 9286 (append
229b59da
G
9287 '(Number Subject From Lines Date
9288 Message-ID Xref References Body)
23f87bed 9289 gnus-extra-headers))
229b59da 9290 'require-match))
eec82323
LMI
9291 (read-string "Regexp: ")
9292 (read-key-sequence "Command: ")
9293 current-prefix-arg))
9294 (when (equal header "Body")
9295 (setq header ""))
eec82323
LMI
9296 ;; Hidden thread subtrees must be searched as well.
9297 (gnus-summary-show-all-threads)
9298 ;; We don't want to change current point nor window configuration.
9299 (save-excursion
9300 (save-window-excursion
23f87bed
MB
9301 (let (gnus-visual
9302 gnus-treat-strip-trailing-blank-lines
9303 gnus-treat-strip-leading-blank-lines
9304 gnus-treat-strip-multiple-blank-lines
9305 gnus-treat-hide-boring-headers
9306 gnus-treat-fold-newsgroups
9307 gnus-article-prepare-hook)
9308 (gnus-message 6 "Executing %s..." (key-description command))
9309 ;; We'd like to execute COMMAND interactively so as to give arguments.
9310 (gnus-execute header regexp
9311 `(call-interactively ',(key-binding command))
9312 backward)
9313 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
9314
9315(defun gnus-summary-beginning-of-article ()
9316 "Scroll the article back to the beginning."
9317 (interactive)
eec82323
LMI
9318 (gnus-summary-select-article)
9319 (gnus-configure-windows 'article)
9320 (gnus-eval-in-buffer-window gnus-article-buffer
9321 (widen)
9322 (goto-char (point-min))
23f87bed 9323 (when gnus-break-pages
eec82323
LMI
9324 (gnus-narrow-to-page))))
9325
9326(defun gnus-summary-end-of-article ()
9327 "Scroll to the end of the article."
9328 (interactive)
eec82323
LMI
9329 (gnus-summary-select-article)
9330 (gnus-configure-windows 'article)
9331 (gnus-eval-in-buffer-window gnus-article-buffer
9332 (widen)
9333 (goto-char (point-max))
9334 (recenter -3)
23f87bed 9335 (when gnus-break-pages
eec82323
LMI
9336 (gnus-narrow-to-page))))
9337
23f87bed
MB
9338(defun gnus-summary-print-truncate-and-quote (string &optional len)
9339 "Truncate to LEN and quote all \"(\"'s in STRING."
9340 (gnus-replace-in-string (if (and len (> (length string) len))
9341 (substring string 0 len)
9342 string)
9343 "[()]" "\\\\\\&"))
9344
6748645f 9345(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
9346 "Generate and print a PostScript image of the process-marked (mail) articles.
9347
9348If used interactively, print the current article if none are
9349process-marked. With prefix arg, prompt the user for the name of the
9350file to save in.
6748645f 9351
23f87bed
MB
9352When used from Lisp, accept two optional args FILENAME and N. N means
9353to print the next N articles. If N is negative, print the N previous
9354articles. If N is nil and articles have been marked with the process
9355mark, print these instead.
eec82323 9356
16409b0b 9357If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
9358printer. If FILENAME is a string, save the PostScript image in a file with
9359that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 9360to save in."
676a7cc9 9361 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
9362 (dolist (article (gnus-summary-work-articles n))
9363 (gnus-summary-select-article nil nil 'pseudo article)
9364 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 9365 (gnus-print-buffer))
676a7cc9
SZ
9366 (gnus-summary-remove-process-mark article))
9367 (ps-despool filename))
eec82323 9368
23f87bed 9369(defun gnus-print-buffer ()
285cf7c8
LMI
9370 (let ((ps-left-header
9371 (list
9372 (concat "("
9373 (gnus-summary-print-truncate-and-quote
9374 (mail-header-subject gnus-current-headers)
9375 66) ")")
9376 (concat "("
9377 (gnus-summary-print-truncate-and-quote
9378 (mail-header-from gnus-current-headers)
9379 45) ")")))
9380 (ps-right-header
9381 (list
9382 "/pagenumberstring load"
9383 (concat "("
9384 (mail-header-date gnus-current-headers) ")"))))
9385 (gnus-run-hooks 'gnus-ps-print-hook)
9386 (save-excursion
9387 (if ps-print-color-p
9388 (ps-spool-buffer-with-faces)
9389 (ps-spool-buffer)))))
23f87bed 9390
8ccbef23
G
9391(defun gnus-summary-show-complete-article ()
9392 "Show a complete version of the current article.
9393This is only useful if you're looking at a partial version of the
9394article currently."
9395 (interactive)
9396 (let ((gnus-keep-backlog nil)
9397 (gnus-use-cache nil)
9398 (gnus-agent nil)
9f2d52e7
G
9399 (variable (intern
9400 (format "%s-fetch-partial-articles"
9401 (car (gnus-find-method-for-group
9402 gnus-newsgroup-name)))
9403 obarray))
9404 old-val)
9405 (unwind-protect
9406 (progn
9407 (setq old-val (symbol-value variable))
9408 (set variable nil)
9409 (gnus-flush-original-article-buffer)
9410 (gnus-summary-show-article))
9411 (set variable old-val))))
8ccbef23 9412
eec82323 9413(defun gnus-summary-show-article (&optional arg)
23f87bed 9414 "Force redisplaying of the current article.
16409b0b
GM
9415If ARG (the prefix) is a number, show the article with the charset
9416defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 9417input.
389b76fa
G
9418If ARG (the prefix) is non-nil and not a number, show the article,
9419but without running any of the article treatment functions
9420article. Normally, the keystroke is `C-u g'. When using `C-u
9421C-u g', show the raw article."
eec82323 9422 (interactive "P")
16409b0b
GM
9423 (cond
9424 ((numberp arg)
23f87bed 9425 (gnus-summary-show-article t)
16409b0b
GM
9426 (let ((gnus-newsgroup-charset
9427 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
9428 (mm-read-coding-system
9429 "View as charset: " ;; actually it is coding system.
01c52d31 9430 (with-current-buffer gnus-article-buffer
23f87bed 9431 (mm-detect-coding-region (point) (point-max))))))
16409b0b 9432 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
9433 (gnus-summary-select-article nil 'force)
9434 (let ((deps gnus-newsgroup-dependencies)
9435 head header lines)
c7a91ce1 9436 (with-current-buffer gnus-original-article-buffer
23f87bed
MB
9437 (save-restriction
9438 (message-narrow-to-head)
9439 (setq head (buffer-string))
9440 (goto-char (point-min))
9441 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9442 (goto-char (point-max))
9443 (widen)
9444 (setq lines (1- (count-lines (point) (point-max))))))
9445 (with-temp-buffer
9446 (insert (format "211 %d Article retrieved.\n"
9447 (cdr gnus-article-current)))
9448 (insert head)
9449 (if lines (insert (format "Lines: %d\n" lines)))
9450 (insert ".\n")
9451 (let ((nntp-server-buffer (current-buffer)))
9452 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9453 (gnus-data-set-header
9454 (gnus-data-find (cdr gnus-article-current))
9455 header)
9456 (gnus-summary-update-article-line
9457 (cdr gnus-article-current) header)
9458 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9459 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
9460 ((not arg)
9461 ;; Select the article the normal way.
9462 (gnus-summary-select-article nil 'force))
181cb5fb
G
9463 ((or (equal arg '(16))
9464 (eq arg t))
389b76fa 9465 ;; C-u C-u g
16409b0b
GM
9466 ;; We have to require this here to make sure that the following
9467 ;; dynamic binding isn't shadowed by autoloading.
9468 (require 'gnus-async)
9469 (require 'gnus-art)
eec82323
LMI
9470 ;; Bind the article treatment functions to nil.
9471 (let ((gnus-have-all-headers t)
eec82323 9472 gnus-article-prepare-hook
16409b0b
GM
9473 gnus-article-decode-hook
9474 gnus-display-mime-function
9475 gnus-break-pages)
9476 ;; Destroy any MIME parts.
9477 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 9478 (with-current-buffer gnus-article-buffer
16409b0b
GM
9479 (mm-destroy-parts gnus-article-mime-handles)
9480 ;; Set it to nil for safety reason.
9481 (setq gnus-article-mime-handle-alist nil)
9482 (setq gnus-article-mime-handles nil)))
389b76fa
G
9483 (gnus-summary-select-article nil 'force)))
9484 (t
9485 (let ((gnus-inhibit-article-treatments t))
16409b0b 9486 (gnus-summary-select-article nil 'force))))
eec82323
LMI
9487 (gnus-summary-goto-subject gnus-current-article)
9488 (gnus-summary-position-point))
9489
23f87bed
MB
9490(defun gnus-summary-show-raw-article ()
9491 "Show the raw article without any article massaging functions being run."
9492 (interactive)
9493 (gnus-summary-show-article t))
9494
eec82323
LMI
9495(defun gnus-summary-verbose-headers (&optional arg)
9496 "Toggle permanent full header display.
9497If ARG is a positive number, turn header display on.
9498If ARG is a negative number, turn header display off."
9499 (interactive "P")
eec82323
LMI
9500 (setq gnus-show-all-headers
9501 (cond ((or (not (numberp arg))
9502 (zerop arg))
9503 (not gnus-show-all-headers))
9504 ((natnump arg)
9505 t)))
9506 (gnus-summary-show-article))
9507
9508(defun gnus-summary-toggle-header (&optional arg)
9509 "Show the headers if they are hidden, or hide them if they are shown.
9510If ARG is a positive number, show the entire header.
9511If ARG is a negative number, hide the unwanted header lines."
9512 (interactive "P")
23f87bed
MB
9513 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9514 (get-buffer-window gnus-article-buffer t))))
9515 (with-current-buffer gnus-article-buffer
9516 (widen)
9517 (article-narrow-to-head)
c7a91ce1 9518 (let* ((inhibit-read-only t)
16409b0b 9519 (inhibit-point-motion-hooks t)
23f87bed
MB
9520 (hidden (if (numberp arg)
9521 (>= arg 0)
f0096211
MB
9522 (or (not (looking-at "[^ \t\n]+:"))
9523 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
9524 s e)
9525 (delete-region (point-min) (point-max))
667e0ba6
SM
9526 (with-current-buffer gnus-original-article-buffer
9527 (goto-char (setq s (point-min)))
23f87bed
MB
9528 (setq e (if (search-forward "\n\n" nil t)
9529 (1- (point))
9530 (point-max))))
667e0ba6 9531 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
9532 (run-hooks 'gnus-article-decode-hook)
9533 (if hidden
9534 (let ((gnus-treat-hide-headers nil)
9535 (gnus-treat-hide-boring-headers nil))
9536 (gnus-delete-wash-type 'headers)
9537 (gnus-treat-article 'head))
9538 (gnus-treat-article 'head))
9539 (widen)
9540 (if window
9541 (set-window-start window (goto-char (point-min))))
9542 (if gnus-break-pages
9543 (gnus-narrow-to-page)
9544 (when (gnus-visual-p 'page-marker)
c7a91ce1 9545 (let ((inhibit-read-only t))
23f87bed
MB
9546 (gnus-remove-text-with-property 'gnus-prev)
9547 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9548 (gnus-set-mode-line 'article)))))
eec82323
LMI
9549
9550(defun gnus-summary-show-all-headers ()
9551 "Make all header lines visible."
9552 (interactive)
23f87bed 9553 (gnus-summary-toggle-header 1))
eec82323 9554
eec82323
LMI
9555(defun gnus-summary-caesar-message (&optional arg)
9556 "Caesar rotate the current article by 13.
01c52d31
MB
9557With a non-numerical prefix, also rotate headers. A numerical
9558prefix specifies how many places to rotate each letter forward."
eec82323 9559 (interactive "P")
eec82323
LMI
9560 (gnus-summary-select-article)
9561 (let ((mail-header-separator ""))
9562 (gnus-eval-in-buffer-window gnus-article-buffer
9563 (save-restriction
9564 (widen)
9565 (let ((start (window-start))
c7a91ce1 9566 (inhibit-read-only t))
01c52d31
MB
9567 (if (equal arg '(4))
9568 (message-caesar-buffer-body nil t)
9569 (message-caesar-buffer-body arg))
ff4d3926
MB
9570 (set-window-start (get-buffer-window (current-buffer)) start)))))
9571 ;; Create buttons and stuff...
9572 (gnus-treat-article nil))
eec82323 9573
704f1663
GM
9574(declare-function idna-to-unicode "ext:idna" (str))
9575
01c52d31
MB
9576(defun gnus-summary-idna-message (&optional arg)
9577 "Decode IDNA encoded domain names in the current articles.
9578IDNA encoded domain names looks like `xn--bar'. If a string
9579remain unencoded after running this function, it is likely an
9580invalid IDNA string (`xn--bar' is invalid).
9581
0b10e437 9582You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
01c52d31
MB
9583installed for this command to work."
9584 (interactive "P")
9585 (if (not (and (condition-case nil (require 'idna)
9586 (file-error))
9587 (mm-coding-system-p 'utf-8)
9588 (executable-find (symbol-value 'idna-program))))
9589 (gnus-message
9590 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9591 (gnus-summary-select-article)
9592 (let ((mail-header-separator ""))
9593 (gnus-eval-in-buffer-window gnus-article-buffer
9594 (save-restriction
9595 (widen)
9596 (let ((start (window-start))
9597 buffer-read-only)
9598 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9599 (replace-match (idna-to-unicode (match-string 1))))
9600 (set-window-start (get-buffer-window (current-buffer)) start)))))))
23f87bed
MB
9601
9602(defun gnus-summary-morse-message (&optional arg)
9603 "Morse decode the current article."
9604 (interactive "P")
9605 (gnus-summary-select-article)
9606 (let ((mail-header-separator ""))
9607 (gnus-eval-in-buffer-window gnus-article-buffer
9608 (save-excursion
9609 (save-restriction
9610 (widen)
9611 (let ((pos (window-start))
c7a91ce1 9612 (inhibit-read-only t))
23f87bed
MB
9613 (goto-char (point-min))
9614 (when (message-goto-body)
9615 (gnus-narrow-to-body))
9616 (goto-char (point-min))
01c52d31 9617