gnus-sum.el (gnus-summary-refer-article): Warp to article. This allows article-refer...
[bpt/emacs.git] / lisp / gnus / gnus-sum.el
CommitLineData
eec82323 1;;; gnus-sum.el --- summary mode commands for Gnus
e84b4b86 2
73b0cd50 3;; Copyright (C) 1996-2011 Free Software Foundation, Inc.
eec82323 4
6748645f 5;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
eec82323
LMI
6;; Keywords: news
7
8;; This file is part of GNU Emacs.
9
5e809f55 10;; GNU Emacs is free software: you can redistribute it and/or modify
eec82323 11;; it under the terms of the GNU General Public License as published by
5e809f55
GM
12;; the Free Software Foundation, either version 3 of the License, or
13;; (at your option) any later version.
eec82323
LMI
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
01ccbb85 17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eec82323
LMI
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
5e809f55 21;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
eec82323
LMI
22
23;;; Commentary:
24
25;;; Code:
26
f0b7f5a8 27;; For Emacs <22.2 and XEmacs.
d09ae6ca
GM
28(eval-and-compile
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
23f87bed 30(eval-when-compile
9efa445f 31 (require 'cl))
d029b5d2
KY
32(eval-when-compile
33 (when (featurep 'xemacs)
34 (require 'easy-mmode))) ; for `define-minor-mode'
9efa445f
DN
35
36(defvar tool-bar-mode)
37(defvar gnus-tmp-header)
5ab7173c 38
eec82323
LMI
39(require 'gnus)
40(require 'gnus-group)
41(require 'gnus-spec)
42(require 'gnus-range)
43(require 'gnus-int)
44(require 'gnus-undo)
6748645f 45(require 'gnus-util)
18c06a99 46(require 'gmm-utils)
16409b0b 47(require 'mm-decode)
08c9a385 48(require 'nnoo)
23f87bed 49
6748645f 50(autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
d4dfaa19 51(autoload 'gnus-cache-write-active "gnus-cache")
23f87bed
MB
52(autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
53(autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
531e5812 54(autoload 'gnus-pick-line-number "gnus-salt" nil t)
08c9a385 55(autoload 'mm-uu-dissect "mm-uu")
23f87bed
MB
56(autoload 'gnus-article-outlook-deuglify-article "deuglify"
57 "Deuglify broken Outlook (Express) articles and redisplay."
58 t)
59(autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
60(autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
61(autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
1b811c90
AC
62(autoload 'nnir-article-rsv "nnir" nil nil 'macro)
63(autoload 'nnir-article-group "nnir" nil nil 'macro)
eec82323
LMI
64
65(defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67If nil, the summary will become a \"*Dead Summary*\" buffer, and
68it will be killed sometime later."
69 :group 'gnus-summary-exit
70 :type 'boolean)
71
01c52d31
MB
72(defcustom gnus-summary-next-group-on-exit t
73 "If non-nil, go to the next unread newsgroup on summary exit.
74See `gnus-group-goto-unread'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-exit
330f707b 77 :version "23.1" ;; No Gnus
01c52d31
MB
78 :type 'boolean)
79
b1992461
KY
80(defcustom gnus-summary-stop-at-end-of-message nil
81 "If non-nil, don't select the next message when using `SPC'."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-summary-maneuvering
1a10d421 84 :version "24.1"
b1992461
KY
85 :type 'boolean)
86
eec82323
LMI
87(defcustom gnus-fetch-old-headers nil
88 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
01c52d31
MB
89If an unread article in the group refers to an older, already
90read (or just marked as read) article, the old article will not
91normally be displayed in the Summary buffer. If this variable is
92t, Gnus will attempt to grab the headers to the old articles, and
93thereby build complete threads. If it has the value `some', all
94old headers will be fetched but only enough headers to connect
95otherwise loose threads will be displayed. This variable can
96also be a number. In that case, no more than that number of old
97headers will be fetched. If it has the value `invisible', all
6748645f 98old headers will be fetched, but none will be displayed.
eec82323 99
01c52d31
MB
100The server has to support NOV for any of this to work.
101
102This feature can seriously impact performance it ignores all
f394fa25
MB
103locally cached header entries. Setting it to t for groups for a
104server that doesn't expire articles (such as news.gmane.org),
105leads to very slow summary generation."
eec82323
LMI
106 :group 'gnus-thread
107 :type '(choice (const :tag "off" nil)
1232b9cb 108 (const :tag "on" t)
eec82323 109 (const some)
1232b9cb 110 (const invisible)
eec82323
LMI
111 number
112 (sexp :menu-tag "other" t)))
113
01c52d31 114(defcustom gnus-refer-thread-limit 500
6748645f
LMI
115 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
116If t, fetch all the available old headers."
117 :group 'gnus-thread
118 :type '(choice number
119 (sexp :menu-tag "other" t)))
120
47f0b35e
AC
121(defcustom gnus-refer-thread-use-nnir nil
122 "*Use nnir to search an entire server when referring threads. A
123nil value will only search for thread-related articles in the
124current group."
125 :group 'gnus-thread
126 :type 'boolean)
127
eec82323
LMI
128(defcustom gnus-summary-make-false-root 'adopt
129 "*nil means that Gnus won't gather loose threads.
130If the root of a thread has expired or been read in a previous
131session, the information necessary to build a complete thread has been
132lost. Instead of having many small sub-threads from this original thread
133scattered all over the summary buffer, Gnus can gather them.
134
135If non-nil, Gnus will try to gather all loose sub-threads from an
136original thread into one large thread.
137
138If this variable is non-nil, it should be one of `none', `adopt',
139`dummy' or `empty'.
140
141If this variable is `none', Gnus will not make a false root, but just
142present the sub-threads after another.
143If this variable is `dummy', Gnus will create a dummy root that will
144have all the sub-threads as children.
145If this variable is `adopt', Gnus will make one of the \"children\"
146the parent and mark all the step-children as such.
147If this variable is `empty', the \"children\" are printed with empty
01ccbb85 148subject fields. (Or rather, they will be printed with a string
eec82323
LMI
149given by the `gnus-summary-same-subject' variable.)"
150 :group 'gnus-thread
151 :type '(choice (const :tag "off" nil)
152 (const none)
153 (const dummy)
154 (const adopt)
155 (const empty)))
156
23f87bed
MB
157(defcustom gnus-summary-make-false-root-always nil
158 "Always make a false dummy root."
bf247b6e 159 :version "22.1"
23f87bed
MB
160 :group 'gnus-thread
161 :type 'boolean)
162
eec82323
LMI
163(defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
164 "*A regexp to match subjects to be excluded from loose thread gathering.
165As loose thread gathering is done on subjects only, that means that
166there can be many false gatherings performed. By rooting out certain
167common subjects, gathering might become saner."
168 :group 'gnus-thread
169 :type 'regexp)
170
171(defcustom gnus-summary-gather-subject-limit nil
172 "*Maximum length of subject comparisons when gathering loose threads.
173Use nil to compare full subjects. Setting this variable to a low
174number will help gather threads that have been corrupted by
175newsreaders chopping off subject lines, but it might also mean that
176unrelated articles that have subject that happen to begin with the
177same few characters will be incorrectly gathered.
178
179If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
180comparing subjects."
181 :group 'gnus-thread
182 :type '(choice (const :tag "off" nil)
183 (const fuzzy)
184 (sexp :menu-tag "on" t)))
185
6748645f
LMI
186(defcustom gnus-simplify-subject-functions nil
187 "List of functions taking a string argument that simplify subjects.
188The functions are applied recursively.
189
23f87bed
MB
190Useful functions to put in this list include:
191`gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
192`gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
6748645f
LMI
193 :group 'gnus-thread
194 :type '(repeat function))
195
eec82323 196(defcustom gnus-simplify-ignored-prefixes nil
23f87bed 197 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
eec82323
LMI
198 :group 'gnus-thread
199 :type '(choice (const :tag "off" nil)
200 regexp))
201
202(defcustom gnus-build-sparse-threads nil
203 "*If non-nil, fill in the gaps in threads.
204If `some', only fill in the gaps that are needed to tie loose threads
205together. If `more', fill in all leaf nodes that Gnus can find. If
206non-nil and non-`some', fill in all gaps that Gnus manages to guess."
207 :group 'gnus-thread
208 :type '(choice (const :tag "off" nil)
209 (const some)
210 (const more)
211 (sexp :menu-tag "all" t)))
212
213(defcustom gnus-summary-thread-gathering-function
214 'gnus-gather-threads-by-subject
6748645f 215 "*Function used for gathering loose threads.
eec82323
LMI
216There are two pre-defined functions: `gnus-gather-threads-by-subject',
217which only takes Subjects into consideration; and
218`gnus-gather-threads-by-references', which compared the References
219headers of the articles to find matches."
220 :group 'gnus-thread
22115a9e
RS
221 :type '(radio (function-item gnus-gather-threads-by-subject)
222 (function-item gnus-gather-threads-by-references)
223 (function :tag "other")))
eec82323 224
eec82323
LMI
225(defcustom gnus-summary-same-subject ""
226 "*String indicating that the current article has the same subject as the previous.
227This variable will only be used if the value of
228`gnus-summary-make-false-root' is `empty'."
229 :group 'gnus-summary-format
230 :type 'string)
231
1d297c49 232(defcustom gnus-summary-goto-unread nil
16409b0b
GM
233 "*If t, many commands will go to the next unread article.
234This applies to marking commands as well as other commands that
235\"naturally\" select the next article, like, for instance, `SPC' at
236the end of an article.
237
238If nil, the marking commands do NOT go to the next unread article
2642ac8f 239\(they go to the next article instead). If `never', commands that
16409b0b
GM
240usually go to the next unread article, will go to the next article,
241whether it is read or not."
1d297c49 242 :version "24.1"
eec82323
LMI
243 :group 'gnus-summary-marks
244 :link '(custom-manual "(gnus)Setting Marks")
245 :type '(choice (const :tag "off" nil)
246 (const never)
247 (sexp :menu-tag "on" t)))
248
249(defcustom gnus-summary-default-score 0
250 "*Default article score level.
251All scores generated by the score files will be added to this score.
252If this variable is nil, scoring will be disabled."
253 :group 'gnus-score-default
254 :type '(choice (const :tag "disable")
255 integer))
256
23f87bed
MB
257(defcustom gnus-summary-default-high-score 0
258 "*Default threshold for a high scored article.
259An article will be highlighted as high scored if its score is greater
260than this score."
bf247b6e 261 :version "22.1"
23f87bed
MB
262 :group 'gnus-score-default
263 :type 'integer)
264
265(defcustom gnus-summary-default-low-score 0
266 "*Default threshold for a low scored article.
267An article will be highlighted as low scored if its score is smaller
268than this score."
bf247b6e 269 :version "22.1"
23f87bed
MB
270 :group 'gnus-score-default
271 :type 'integer)
272
eec82323
LMI
273(defcustom gnus-summary-zcore-fuzz 0
274 "*Fuzziness factor for the zcore in the summary buffer.
275Articles with scores closer than this to `gnus-summary-default-score'
276will not be marked."
277 :group 'gnus-summary-format
278 :type 'integer)
279
280(defcustom gnus-simplify-subject-fuzzy-regexp nil
281 "*Strings to be removed when doing fuzzy matches.
282This can either be a regular expression or list of regular expressions
283that will be removed from subject strings if fuzzy subject
284simplification is selected."
285 :group 'gnus-thread
286 :type '(repeat regexp))
287
288(defcustom gnus-show-threads t
289 "*If non-nil, display threads in summary mode."
290 :group 'gnus-thread
291 :type 'boolean)
292
293(defcustom gnus-thread-hide-subtree nil
294 "*If non-nil, hide all threads initially.
23f87bed 295This can be a predicate specifier which says which threads to hide.
eec82323 296If threads are hidden, you have to run the command
4a2358e9 297`gnus-summary-show-thread' by hand or select an article."
eec82323 298 :group 'gnus-thread
23f87bed
MB
299 :type '(radio (sexp :format "Non-nil\n"
300 :match (lambda (widget value)
301 (not (or (consp value) (functionp value))))
302 :value t)
303 (const nil)
ad136a7c 304 (sexp :tag "Predicate specifier")))
eec82323
LMI
305
306(defcustom gnus-thread-hide-killed t
307 "*If non-nil, hide killed threads automatically."
308 :group 'gnus-thread
309 :type 'boolean)
310
6748645f
LMI
311(defcustom gnus-thread-ignore-subject t
312 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
313If nil, articles that have different subjects from their parents will
314start separate threads."
eec82323
LMI
315 :group 'gnus-thread
316 :type 'boolean)
317
318(defcustom gnus-thread-operation-ignore-subject t
319 "*If non-nil, subjects will be ignored when doing thread commands.
320This affects commands like `gnus-summary-kill-thread' and
321`gnus-summary-lower-thread'.
322
323If this variable is nil, articles in the same thread with different
324subjects will not be included in the operation in question. If this
325variable is `fuzzy', only articles that have subjects that are fuzzily
326equal will be included."
327 :group 'gnus-thread
328 :type '(choice (const :tag "off" nil)
329 (const fuzzy)
330 (sexp :tag "on" t)))
331
332(defcustom gnus-thread-indent-level 4
333 "*Number that says how much each sub-thread should be indented."
334 :group 'gnus-thread
335 :type 'integer)
336
337(defcustom gnus-auto-extend-newsgroup t
338 "*If non-nil, extend newsgroup forward and backward when requested."
339 :group 'gnus-summary-choose
340 :type 'boolean)
341
342(defcustom gnus-auto-select-first t
651408cb
MB
343 "If non-nil, select an article on group entry.
344An article is selected automatically when entering a group
345e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
346`gnus-summary-catchup-and-goto-next-group'.
347
348Which article is selected is controlled by the variable
349`gnus-auto-select-subject'.
23f87bed
MB
350
351If you want to prevent automatic selection of articles in some
352newsgroups, set the variable to nil in `gnus-select-group-hook'."
651408cb
MB
353 ;; Commands include...
354 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
355 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
356 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
eec82323
LMI
357 :group 'gnus-group-select
358 :type '(choice (const :tag "none" nil)
23f87bed
MB
359 (sexp :menu-tag "first" t)))
360
a1347097 361(defcustom gnus-auto-select-subject 'unseen-or-unread
23f87bed
MB
362 "*Says what subject to place under point when entering a group.
363
364This variable can either be the symbols `first' (place point on the
365first subject), `unread' (place point on the subject line of the first
366unread article), `best' (place point on the subject line of the
367higest-scored article), `unseen' (place point on the subject line of
99b5aab7 368the first unseen article), `unseen-or-unread' (place point on the subject
647559c2 369line of the first unseen article or, if all articles have been seen, on the
23f87bed
MB
370subject line of the first unread article), or a function to be called to
371place point on some subject line."
a1347097 372 :version "24.1"
23f87bed
MB
373 :group 'gnus-group-select
374 :type '(choice (const best)
375 (const unread)
376 (const first)
377 (const unseen)
378 (const unseen-or-unread)))
eec82323
LMI
379
380(defcustom gnus-auto-select-next t
381 "*If non-nil, offer to go to the next group from the end of the previous.
382If the value is t and the next newsgroup is empty, Gnus will exit
23f87bed
MB
383summary mode and go back to group mode. If the value is neither nil
384nor t, Gnus will select the following unread newsgroup. In
eec82323
LMI
385particular, if the value is the symbol `quietly', the next unread
386newsgroup will be selected without any confirmation, and if it is
387`almost-quietly', the next group will be selected without any
388confirmation if you are located on the last article in the group.
23f87bed 389Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
eec82323
LMI
390will go to the next group without confirmation."
391 :group 'gnus-summary-maneuvering
392 :type '(choice (const :tag "off" nil)
393 (const quietly)
394 (const almost-quietly)
395 (const slightly-quietly)
396 (sexp :menu-tag "on" t)))
397
398(defcustom gnus-auto-select-same nil
6748645f
LMI
399 "*If non-nil, select the next article with the same subject.
400If there are no more articles with the same subject, go to
401the first unread article."
eec82323
LMI
402 :group 'gnus-summary-maneuvering
403 :type 'boolean)
404
01c52d31
MB
405(defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
406 "What article should be selected after exiting an ephemeral group.
407Valid values include:
408
409`next'
410 Select the next article.
411`next-unread'
412 Select the next unread article.
413`next-noselect'
414 Move the cursor to the next article. This is the default.
415`next-unread-noselect'
416 Move the cursor to the next unread article.
417
418If it has any other value or there is no next (unread) article, the
419article selected before entering to the ephemeral group will appear."
330f707b 420 :version "23.1" ;; No Gnus
01c52d31
MB
421 :group 'gnus-summary-maneuvering
422 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
423 (const next) (const next-unread)
424 (const next-noselect) (const next-unread-noselect)
425 (sexp :tag "other" :value nil)))
426
23f87bed
MB
427(defcustom gnus-auto-goto-ignores 'unfetched
428 "*Says how to handle unfetched articles when maneuvering.
429
430This variable can either be the symbols nil (maneuver to any
431article), `undownloaded' (maneuvering while unplugged ignores articles
432that have not been fetched), `always-undownloaded' (maneuvering always
433ignores articles that have not been fetched), `unfetched' (maneuvering
434ignores articles whose headers have not been fetched).
435
436NOTE: The list of unfetched articles will always be nil when plugged
437and, when unplugged, a subset of the undownloaded article list."
bf247b6e 438 :version "22.1"
23f87bed
MB
439 :group 'gnus-summary-maneuvering
440 :type '(choice (const :tag "None" nil)
441 (const :tag "Undownloaded when unplugged" undownloaded)
442 (const :tag "Undownloaded" always-undownloaded)
443 (const :tag "Unfetched" unfetched)))
444
eec82323
LMI
445(defcustom gnus-summary-check-current nil
446 "*If non-nil, consider the current article when moving.
447The \"unread\" movement commands will stay on the same line if the
448current article is unread."
449 :group 'gnus-summary-maneuvering
450 :type 'boolean)
451
01c52d31 452(defcustom gnus-auto-center-summary 2
eec82323
LMI
453 "*If non-nil, always center the current summary buffer.
454In particular, if `vertical' do only vertical recentering. If non-nil
455and non-`vertical', do both horizontal and vertical recentering."
456 :group 'gnus-summary-maneuvering
457 :type '(choice (const :tag "none" nil)
458 (const vertical)
16409b0b 459 (integer :tag "height")
eec82323
LMI
460 (sexp :menu-tag "both" t)))
461
2d04f304
G
462(defcustom gnus-auto-center-group t
463 "If non-nil, always center the group buffer."
464 :group 'gnus-summary-maneuvering
465 :type 'boolean)
23f87bed 466
eec82323
LMI
467(defcustom gnus-show-all-headers nil
468 "*If non-nil, don't hide any headers."
469 :group 'gnus-article-hiding
470 :group 'gnus-article-headers
471 :type 'boolean)
472
473(defcustom gnus-summary-ignore-duplicates nil
474 "*If non-nil, ignore articles with identical Message-ID headers."
475 :group 'gnus-summary
476 :type 'boolean)
6748645f 477
1d297c49 478(defcustom gnus-single-article-buffer nil
eec82323
LMI
479 "*If non-nil, display all articles in the same buffer.
480If nil, each group will get its own article buffer."
1d297c49 481 :version "24.1"
eec82323
LMI
482 :group 'gnus-article-various
483 :type 'boolean)
484
71e691a5
G
485(defcustom gnus-widen-article-window nil
486 "If non-nil, selecting the article buffer will display only the article buffer."
487 :version "24.1"
488 :group 'gnus-article-various
489 :type 'boolean)
490
eec82323
LMI
491(defcustom gnus-break-pages t
492 "*If non-nil, do page breaking on articles.
493The page delimiter is specified by the `gnus-page-delimiter'
494variable."
495 :group 'gnus-article-various
496 :type 'boolean)
497
eec82323
LMI
498(defcustom gnus-move-split-methods nil
499 "*Variable used to suggest where articles are to be moved to.
23f87bed
MB
500It uses the same syntax as the `gnus-split-methods' variable.
501However, whereas `gnus-split-methods' specifies file names as targets,
502this variable specifies group names."
eec82323 503 :group 'gnus-summary-mail
6748645f
LMI
504 :type '(repeat (choice (list :value (fun) function)
505 (cons :value ("" "") regexp (repeat string))
506 (sexp :value nil))))
eec82323 507
01c52d31
MB
508(defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
509 "Function used to compute default prefix for article move/copy/etc prompts.
510The function should take one argument, a group name, and return a
511string with the suggested prefix."
512 :group 'gnus-summary-mail
513 :type 'function)
514
e62e7654
MB
515;; FIXME: Although the custom type is `character' for the following variables,
516;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
517
23f87bed 518(defcustom gnus-unread-mark ? ;Whitespace
eec82323
LMI
519 "*Mark used for unread articles."
520 :group 'gnus-summary-marks
521 :type 'character)
522
523(defcustom gnus-ticked-mark ?!
524 "*Mark used for ticked articles."
525 :group 'gnus-summary-marks
526 :type 'character)
527
528(defcustom gnus-dormant-mark ??
529 "*Mark used for dormant articles."
530 :group 'gnus-summary-marks
531 :type 'character)
532
533(defcustom gnus-del-mark ?r
534 "*Mark used for del'd articles."
535 :group 'gnus-summary-marks
536 :type 'character)
537
538(defcustom gnus-read-mark ?R
539 "*Mark used for read articles."
540 :group 'gnus-summary-marks
541 :type 'character)
542
543(defcustom gnus-expirable-mark ?E
544 "*Mark used for expirable articles."
545 :group 'gnus-summary-marks
546 :type 'character)
547
548(defcustom gnus-killed-mark ?K
549 "*Mark used for killed articles."
550 :group 'gnus-summary-marks
551 :type 'character)
552
23f87bed
MB
553(defcustom gnus-spam-mark ?$
554 "*Mark used for spam articles."
bf247b6e 555 :version "22.1"
23f87bed
MB
556 :group 'gnus-summary-marks
557 :type 'character)
558
eec82323
LMI
559(defcustom gnus-kill-file-mark ?X
560 "*Mark used for articles killed by kill files."
561 :group 'gnus-summary-marks
562 :type 'character)
563
564(defcustom gnus-low-score-mark ?Y
565 "*Mark used for articles with a low score."
566 :group 'gnus-summary-marks
567 :type 'character)
568
569(defcustom gnus-catchup-mark ?C
570 "*Mark used for articles that are caught up."
571 :group 'gnus-summary-marks
572 :type 'character)
573
574(defcustom gnus-replied-mark ?A
575 "*Mark used for articles that have been replied to."
576 :group 'gnus-summary-marks
577 :type 'character)
578
23f87bed
MB
579(defcustom gnus-forwarded-mark ?F
580 "*Mark used for articles that have been forwarded."
bf247b6e 581 :version "22.1"
23f87bed
MB
582 :group 'gnus-summary-marks
583 :type 'character)
584
585(defcustom gnus-recent-mark ?N
586 "*Mark used for articles that are recent."
bf247b6e 587 :version "22.1"
23f87bed
MB
588 :group 'gnus-summary-marks
589 :type 'character)
590
eec82323
LMI
591(defcustom gnus-cached-mark ?*
592 "*Mark used for articles that are in the cache."
593 :group 'gnus-summary-marks
594 :type 'character)
595
596(defcustom gnus-saved-mark ?S
23f87bed
MB
597 "*Mark used for articles that have been saved."
598 :group 'gnus-summary-marks
599 :type 'character)
600
601(defcustom gnus-unseen-mark ?.
602 "*Mark used for articles that haven't been seen."
bf247b6e 603 :version "22.1"
23f87bed
MB
604 :group 'gnus-summary-marks
605 :type 'character)
606
607(defcustom gnus-no-mark ? ;Whitespace
608 "*Mark used for articles that have no other secondary mark."
bf247b6e 609 :version "22.1"
eec82323
LMI
610 :group 'gnus-summary-marks
611 :type 'character)
612
613(defcustom gnus-ancient-mark ?O
614 "*Mark used for ancient articles."
615 :group 'gnus-summary-marks
616 :type 'character)
617
618(defcustom gnus-sparse-mark ?Q
619 "*Mark used for sparsely reffed articles."
620 :group 'gnus-summary-marks
621 :type 'character)
622
623(defcustom gnus-canceled-mark ?G
624 "*Mark used for canceled articles."
625 :group 'gnus-summary-marks
626 :type 'character)
627
628(defcustom gnus-duplicate-mark ?M
629 "*Mark used for duplicate articles."
630 :group 'gnus-summary-marks
631 :type 'character)
632
23f87bed 633(defcustom gnus-undownloaded-mark ?-
6748645f 634 "*Mark used for articles that weren't downloaded."
bf247b6e 635 :version "22.1"
6748645f
LMI
636 :group 'gnus-summary-marks
637 :type 'character)
638
23f87bed
MB
639(defcustom gnus-downloaded-mark ?+
640 "*Mark used for articles that were downloaded."
641 :group 'gnus-summary-marks
642 :type 'character)
643
6748645f
LMI
644(defcustom gnus-downloadable-mark ?%
645 "*Mark used for articles that are to be downloaded."
646 :group 'gnus-summary-marks
647 :type 'character)
648
649(defcustom gnus-unsendable-mark ?=
650 "*Mark used for articles that won't be sent."
651 :group 'gnus-summary-marks
652 :type 'character)
653
eec82323
LMI
654(defcustom gnus-score-over-mark ?+
655 "*Score mark used for articles with high scores."
656 :group 'gnus-summary-marks
657 :type 'character)
658
659(defcustom gnus-score-below-mark ?-
660 "*Score mark used for articles with low scores."
661 :group 'gnus-summary-marks
662 :type 'character)
663
23f87bed 664(defcustom gnus-empty-thread-mark ? ;Whitespace
eec82323
LMI
665 "*There is no thread under the article."
666 :group 'gnus-summary-marks
667 :type 'character)
668
669(defcustom gnus-not-empty-thread-mark ?=
670 "*There is a thread under the article."
671 :group 'gnus-summary-marks
672 :type 'character)
673
674(defcustom gnus-view-pseudo-asynchronously nil
675 "*If non-nil, Gnus will view pseudo-articles asynchronously."
676 :group 'gnus-extract-view
677 :type 'boolean)
678
16409b0b
GM
679(defcustom gnus-auto-expirable-marks
680 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
681 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
c4d82de8 682 gnus-duplicate-mark)
16409b0b 683 "*The list of marks converted into expiration if a group is auto-expirable."
b0e30310 684 :version "24.1"
16409b0b
GM
685 :group 'gnus-summary
686 :type '(repeat character))
687
688(defcustom gnus-inhibit-user-auto-expire t
689 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
58e39d05 690 :version "21.1"
16409b0b
GM
691 :group 'gnus-summary
692 :type 'boolean)
693
b0b63450
MB
694(defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
695 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
696If nil, the expirable marks will be unchanged except that the marks
697will be removed when copying or moving articles to a group that has
698not turned auto-expire on. If non-nil, articles that have been read
699will be marked as expirable when being copied or moved to a group in
700which auto-expire is turned on."
701 :version "23.2"
702 :type 'boolean
703 :group 'gnus-summary-marks)
704
eec82323
LMI
705(defcustom gnus-view-pseudos nil
706 "*If `automatic', pseudo-articles will be viewed automatically.
707If `not-confirm', pseudos will be viewed automatically, and the user
708will not be asked to confirm the command."
709 :group 'gnus-extract-view
710 :type '(choice (const :tag "off" nil)
711 (const automatic)
712 (const not-confirm)))
713
714(defcustom gnus-view-pseudos-separately t
715 "*If non-nil, one pseudo-article will be created for each file to be viewed.
716If nil, all files that use the same viewing command will be given as a
717list of parameters to that command."
718 :group 'gnus-extract-view
719 :type 'boolean)
720
721(defcustom gnus-insert-pseudo-articles t
722 "*If non-nil, insert pseudo-articles when decoding articles."
723 :group 'gnus-extract-view
724 :type 'boolean)
725
726(defcustom gnus-summary-dummy-line-format
23f87bed 727 " %(: :%) %S\n"
eec82323
LMI
728 "*The format specification for the dummy roots in the summary buffer.
729It works along the same lines as a normal formatting string,
730with some simple extensions.
731
23f87bed
MB
732%S The subject
733
734General format specifiers can also be used.
735See `(gnus)Formatting Variables'."
736 :link '(custom-manual "(gnus)Formatting Variables")
eec82323
LMI
737 :group 'gnus-threading
738 :type 'string)
739
16409b0b 740(defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
eec82323
LMI
741 "*The format specification for the summary mode line.
742It works along the same lines as a normal formatting string,
743with some simple extensions:
744
745%G Group name
746%p Unprefixed group name
747%A Current article number
6748645f 748%z Current article score
eec82323
LMI
749%V Gnus version
750%U Number of unread articles in the group
751%e Number of unselected articles in the group
752%Z A string with unread/unselected article counts
753%g Shortish group name
754%S Subject of the current article
755%u User-defined spec
756%s Current score file name
757%d Number of dormant articles
758%r Number of articles that have been marked as read in this session
759%E Number of articles expunged by the score files"
760 :group 'gnus-summary-format
761 :type 'string)
762
16409b0b
GM
763(defcustom gnus-list-identifiers nil
764 "Regexp that matches list identifiers to be removed from subject.
765This can also be a list of regexps."
58e39d05 766 :version "21.1"
16409b0b
GM
767 :group 'gnus-summary-format
768 :group 'gnus-article-hiding
769 :type '(choice (const :tag "none" nil)
770 (regexp :value ".*")
771 (repeat :value (".*") regexp)))
772
eec82323
LMI
773(defcustom gnus-summary-mark-below 0
774 "*Mark all articles with a score below this variable as read.
775This variable is local to each summary buffer and usually set by the
776score file."
777 :group 'gnus-score-default
778 :type 'integer)
779
01c52d31
MB
780(defun gnus-widget-reversible-match (widget value)
781 "Ignoring WIDGET, convert VALUE to internal form.
782VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
783 ;; (debug value)
784 (or (symbolp value)
785 (and (listp value)
786 (eq (length value) 2)
787 (eq (nth 0 value) 'not)
788 (symbolp (nth 1 value)))))
789
790(defun gnus-widget-reversible-to-internal (widget value)
791 "Ignoring WIDGET, convert VALUE to internal form.
792VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
793FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
794 ;; (debug value)
795 (if (atom value)
796 (list value nil)
797 (list (nth 1 value) t)))
798
799(defun gnus-widget-reversible-to-external (widget value)
800 "Ignoring WIDGET, convert VALUE to external form.
801VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
802\(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
803 ;; (debug value)
804 (if (nth 1 value)
805 (list 'not (nth 0 value))
806 (nth 0 value)))
807
808(define-widget 'gnus-widget-reversible 'group
809 "A `group' that convert values."
810 :match 'gnus-widget-reversible-match
811 :value-to-internal 'gnus-widget-reversible-to-internal
812 :value-to-external 'gnus-widget-reversible-to-external)
813
eec82323
LMI
814(defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
815 "*List of functions used for sorting articles in the summary buffer.
23f87bed
MB
816
817Each function takes two articles and returns non-nil if the first
818article should be sorted before the other. If you use more than one
819function, the primary sort function should be the last. You should
820probably always include `gnus-article-sort-by-number' in the list of
821sorting functions -- preferably first. Also note that sorting by date
822is often much slower than sorting by number, and the sorting order is
823very similar. (Sorting by date means sorting by the time the message
824was sent, sorting by number means sorting by arrival time.)
825
01c52d31
MB
826Each item can also be a list `(not F)' where F is a function;
827this reverses the sort order.
828
23f87bed
MB
829Ready-made functions include `gnus-article-sort-by-number',
830`gnus-article-sort-by-author', `gnus-article-sort-by-subject',
831`gnus-article-sort-by-date', `gnus-article-sort-by-random'
832and `gnus-article-sort-by-score'.
833
834When threading is turned on, the variable `gnus-thread-sort-functions'
835controls how articles are sorted."
eec82323 836 :group 'gnus-summary-sort
01c52d31
MB
837 :type '(repeat (gnus-widget-reversible
838 (choice (function-item gnus-article-sort-by-number)
839 (function-item gnus-article-sort-by-author)
840 (function-item gnus-article-sort-by-subject)
841 (function-item gnus-article-sort-by-date)
842 (function-item gnus-article-sort-by-score)
843 (function-item gnus-article-sort-by-random)
844 (function :tag "other"))
845 (boolean :tag "Reverse order"))))
846
eec82323
LMI
847
848(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
849 "*List of functions used for sorting threads in the summary buffer.
850By default, threads are sorted by article number.
851
23f87bed
MB
852Each function takes two threads and returns non-nil if the first
853thread should be sorted before the other. If you use more than one
854function, the primary sort function should be the last. You should
855probably always include `gnus-thread-sort-by-number' in the list of
856sorting functions -- preferably first. Also note that sorting by date
857is often much slower than sorting by number, and the sorting order is
858very similar. (Sorting by date means sorting by the time the message
859was sent, sorting by number means sorting by arrival time.)
eec82323 860
01c52d31
MB
861Each list item can also be a list `(not F)' where F is a
862function; this specifies reversed sort order.
863
eec82323 864Ready-made functions include `gnus-thread-sort-by-number',
01c52d31
MB
865`gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
866`gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
867`gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
868`gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
869and `gnus-thread-sort-by-total-score' (see
870`gnus-thread-score-function').
23f87bed
MB
871
872When threading is turned off, the variable
873`gnus-article-sort-functions' controls how articles are sorted."
eec82323 874 :group 'gnus-summary-sort
01c52d31
MB
875 :type '(repeat
876 (gnus-widget-reversible
877 (choice (function-item gnus-thread-sort-by-number)
878 (function-item gnus-thread-sort-by-author)
879 (function-item gnus-thread-sort-by-recipient)
880 (function-item gnus-thread-sort-by-subject)
881 (function-item gnus-thread-sort-by-date)
882 (function-item gnus-thread-sort-by-score)
883 (function-item gnus-thread-sort-by-most-recent-number)
884 (function-item gnus-thread-sort-by-most-recent-date)
885 (function-item gnus-thread-sort-by-random)
886 (function-item gnus-thread-sort-by-total-score)
887 (function :tag "other"))
888 (boolean :tag "Reverse order"))))
eec82323
LMI
889
890(defcustom gnus-thread-score-function '+
891 "*Function used for calculating the total score of a thread.
892
893The function is called with the scores of the article and each
894subthread and should then return the score of the thread.
895
896Some functions you can use are `+', `max', or `min'."
897 :group 'gnus-summary-sort
898 :type 'function)
899
900(defcustom gnus-summary-expunge-below nil
6748645f
LMI
901 "All articles that have a score less than this variable will be expunged.
902This variable is local to the summary buffers."
eec82323
LMI
903 :group 'gnus-score-default
904 :type '(choice (const :tag "off" nil)
905 integer))
906
907(defcustom gnus-thread-expunge-below nil
908 "All threads that have a total score less than this variable will be expunged.
909See `gnus-thread-score-function' for en explanation of what a
6748645f
LMI
910\"thread score\" is.
911
912This variable is local to the summary buffers."
16409b0b 913 :group 'gnus-threading
eec82323
LMI
914 :group 'gnus-score-default
915 :type '(choice (const :tag "off" nil)
916 integer))
917
918(defcustom gnus-summary-mode-hook nil
919 "*A hook for Gnus summary mode.
920This hook is run before any variables are set in the summary buffer."
23f87bed 921 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
eec82323
LMI
922 :group 'gnus-summary-various
923 :type 'hook)
924
23f87bed
MB
925;; Extracted from gnus-xmas-redefine in order to preserve user settings
926(when (featurep 'xemacs)
927 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
928 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
929 (add-hook 'gnus-summary-mode-hook
930 'gnus-xmas-switch-horizontal-scrollbar-off))
931
eec82323
LMI
932(defcustom gnus-summary-menu-hook nil
933 "*Hook run after the creation of the summary mode menu."
934 :group 'gnus-summary-visual
935 :type 'hook)
936
937(defcustom gnus-summary-exit-hook nil
938 "*A hook called on exit from the summary buffer.
939It will be called with point in the group buffer."
940 :group 'gnus-summary-exit
941 :type 'hook)
942
943(defcustom gnus-summary-prepare-hook nil
944 "*A hook called after the summary buffer has been generated.
945If you want to modify the summary buffer, you can use this hook."
946 :group 'gnus-summary-various
947 :type 'hook)
948
6748645f
LMI
949(defcustom gnus-summary-prepared-hook nil
950 "*A hook called as the last thing after the summary buffer has been generated."
951 :group 'gnus-summary-various
952 :type 'hook)
953
eec82323
LMI
954(defcustom gnus-summary-generate-hook nil
955 "*A hook run just before generating the summary buffer.
956This hook is commonly used to customize threading variables and the
957like."
958 :group 'gnus-summary-various
959 :type 'hook)
960
961(defcustom gnus-select-group-hook nil
962 "*A hook called when a newsgroup is selected.
963
964If you'd like to simplify subjects like the
965`gnus-summary-next-same-subject' command does, you can use the
966following hook:
967
23f87bed
MB
968 (add-hook gnus-select-group-hook
969 (lambda ()
970 (mapcar (lambda (header)
971 (mail-header-set-subject
972 header
973 (gnus-simplify-subject
974 (mail-header-subject header) 're-only)))
975 gnus-newsgroup-headers)))"
eec82323
LMI
976 :group 'gnus-group-select
977 :type 'hook)
978
979(defcustom gnus-select-article-hook nil
980 "*A hook called when an article is selected."
981 :group 'gnus-summary-choose
23f87bed 982 :options '(gnus-agent-fetch-selected-article)
eec82323
LMI
983 :type 'hook)
984
985(defcustom gnus-visual-mark-article-hook
986 (list 'gnus-highlight-selected-summary)
987 "*Hook run after selecting an article in the summary buffer.
988It is meant to be used for highlighting the article in some way. It
989is not run if `gnus-visual' is nil."
990 :group 'gnus-summary-visual
991 :type 'hook)
992
16409b0b 993(defcustom gnus-parse-headers-hook nil
eec82323
LMI
994 "*A hook called before parsing the headers."
995 :group 'gnus-various
996 :type 'hook)
997
998(defcustom gnus-exit-group-hook nil
16409b0b
GM
999 "*A hook called when exiting summary mode.
1000This hook is not called from the non-updating exit commands like `Q'."
eec82323
LMI
1001 :group 'gnus-various
1002 :type 'hook)
1003
a9ec34f4 1004(defcustom gnus-summary-update-hook nil
eec82323
LMI
1005 "*A hook called when a summary line is changed.
1006The hook will not be called if `gnus-visual' is nil.
1007
1008The default function `gnus-summary-highlight-line' will
1009highlight the line according to the `gnus-summary-highlight'
1010variable."
1011 :group 'gnus-summary-visual
1012 :type 'hook)
1013
1014(defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1015 "*A hook called when an article is selected for the first time.
1016The hook is intended to mark an article as read (or unread)
1017automatically when it is selected."
1018 :group 'gnus-summary-choose
1019 :type 'hook)
1020
1021(defcustom gnus-group-no-more-groups-hook nil
1022 "*A hook run when returning to group mode having no more (unread) groups."
1023 :group 'gnus-group-select
1024 :type 'hook)
1025
1026(defcustom gnus-ps-print-hook nil
1027 "*A hook run before ps-printing something from Gnus."
1028 :group 'gnus-summary
1029 :type 'hook)
1030
23f87bed
MB
1031(defcustom gnus-summary-article-move-hook nil
1032 "*A hook called after an article is moved, copied, respooled, or crossposted."
bf247b6e 1033 :version "22.1"
23f87bed
MB
1034 :group 'gnus-summary
1035 :type 'hook)
1036
1037(defcustom gnus-summary-article-delete-hook nil
1038 "*A hook called after an article is deleted."
bf247b6e 1039 :version "22.1"
23f87bed
MB
1040 :group 'gnus-summary
1041 :type 'hook)
1042
1043(defcustom gnus-summary-article-expire-hook nil
1044 "*A hook called after an article is expired."
bf247b6e 1045 :version "22.1"
23f87bed
MB
1046 :group 'gnus-summary
1047 :type 'hook)
1048
1049(defcustom gnus-summary-display-arrow
1050 (and (fboundp 'display-graphic-p)
1051 (display-graphic-p))
1052 "*If non-nil, display an arrow highlighting the current article."
bf247b6e 1053 :version "22.1"
23f87bed
MB
1054 :group 'gnus-summary
1055 :type 'boolean)
1056
0f49874b 1057(defcustom gnus-summary-selected-face 'gnus-summary-selected
eec82323
LMI
1058 "Face used for highlighting the current article in the summary buffer."
1059 :group 'gnus-summary-visual
1060 :type 'face)
1061
23f87bed
MB
1062(defvar gnus-tmp-downloaded nil)
1063
eec82323 1064(defcustom gnus-summary-highlight
23f87bed 1065 '(((eq mark gnus-canceled-mark)
0f49874b 1066 . gnus-summary-cancelled)
23f87bed 1067 ((and uncached (> score default-high))
0f49874b 1068 . gnus-summary-high-undownloaded)
23f87bed 1069 ((and uncached (< score default-low))
0f49874b 1070 . gnus-summary-low-undownloaded)
23f87bed 1071 (uncached
0f49874b 1072 . gnus-summary-normal-undownloaded)
23f87bed
MB
1073 ((and (> score default-high)
1074 (or (eq mark gnus-dormant-mark)
1075 (eq mark gnus-ticked-mark)))
0f49874b 1076 . gnus-summary-high-ticked)
23f87bed
MB
1077 ((and (< score default-low)
1078 (or (eq mark gnus-dormant-mark)
1079 (eq mark gnus-ticked-mark)))
0f49874b 1080 . gnus-summary-low-ticked)
23f87bed
MB
1081 ((or (eq mark gnus-dormant-mark)
1082 (eq mark gnus-ticked-mark))
0f49874b 1083 . gnus-summary-normal-ticked)
23f87bed 1084 ((and (> score default-high) (eq mark gnus-ancient-mark))
0f49874b 1085 . gnus-summary-high-ancient)
23f87bed 1086 ((and (< score default-low) (eq mark gnus-ancient-mark))
0f49874b 1087 . gnus-summary-low-ancient)
23f87bed 1088 ((eq mark gnus-ancient-mark)
0f49874b 1089 . gnus-summary-normal-ancient)
23f87bed 1090 ((and (> score default-high) (eq mark gnus-unread-mark))
0f49874b 1091 . gnus-summary-high-unread)
23f87bed 1092 ((and (< score default-low) (eq mark gnus-unread-mark))
0f49874b 1093 . gnus-summary-low-unread)
23f87bed 1094 ((eq mark gnus-unread-mark)
0f49874b 1095 . gnus-summary-normal-unread)
23f87bed 1096 ((> score default-high)
0f49874b 1097 . gnus-summary-high-read)
23f87bed 1098 ((< score default-low)
0f49874b 1099 . gnus-summary-low-read)
eec82323 1100 (t
0f49874b 1101 . gnus-summary-normal-read))
6748645f 1102 "*Controls the highlighting of summary buffer lines.
eec82323 1103
107cf8ec 1104A list of (FORM . FACE) pairs. When deciding how a particular
23f87bed
MB
1105summary line should be displayed, each form is evaluated. The content
1106of the face field after the first true form is used. You can change
1107how those summary lines are displayed, by editing the face field.
eec82323
LMI
1108
1109You can use the following variables in the FORM field.
1110
107cf8ec 1111score: The article's score.
23f87bed
MB
1112default: The default article score.
1113default-high: The default score for high scored articles.
1114default-low: The default score for low scored articles.
1115below: The score below which articles are automatically marked as read.
1116mark: The article's mark.
1117uncached: Non-nil if the article is uncached."
eec82323
LMI
1118 :group 'gnus-summary-visual
1119 :type '(repeat (cons (sexp :tag "Form" nil)
1120 face)))
c12ecb0a 1121(put 'gnus-summary-highlight 'risky-local-variable t)
eec82323 1122
6748645f
LMI
1123(defcustom gnus-alter-header-function nil
1124 "Function called to allow alteration of article header structures.
1125The function is called with one parameter, the article header vector,
0ab0f2d3
SZ
1126which it may alter in any way."
1127 :type '(choice (const :tag "None" nil)
1128 function)
1129 :group 'gnus-summary)
eec82323 1130
16409b0b 1131(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
343d6628
MB
1132 "Function used to decode a string with encoded words.")
1133
1134(defvar gnus-decode-encoded-address-function
1135 'mail-decode-encoded-address-string
1136 "Function used to decode addresses with encoded words.")
16409b0b 1137
a6e77075 1138(defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups)
16409b0b 1139 "*Extra headers to parse."
81de9236 1140 :version "24.1" ; added Cc Keywords Gcc
16409b0b
GM
1141 :group 'gnus-summary
1142 :type '(repeat symbol))
1143
1144(defcustom gnus-ignored-from-addresses
343d6628 1145 (and user-mail-address
7cd9f860
CY
1146 (not (string= user-mail-address ""))
1147 (regexp-quote user-mail-address))
01c52d31
MB
1148 "*From headers that may be suppressed in favor of To headers.
1149This can be a regexp or a list of regexps."
58e39d05 1150 :version "21.1"
16409b0b 1151 :group 'gnus-summary
01c52d31
MB
1152 :type '(choice regexp
1153 (repeat :tag "Regexp List" regexp)))
1154
1155(defsubst gnus-ignored-from-addresses ()
1156 (gmm-regexp-concat gnus-ignored-from-addresses))
1157
1158(defcustom gnus-summary-to-prefix "-> "
1159 "*String prefixed to the To field in the summary line when
1160using `gnus-ignored-from-addresses'."
1161 :version "22.1"
1162 :group 'gnus-summary
1163 :type 'string)
1164
1165(defcustom gnus-summary-newsgroup-prefix "=> "
1166 "*String prefixed to the Newsgroup field in the summary
1167line when using `gnus-ignored-from-addresses'."
1168 :version "22.1"
1169 :group 'gnus-summary
1170 :type 'string)
16409b0b 1171
16409b0b
GM
1172(defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1173 "List of charsets that should be ignored.
1174When these charsets are used in the \"charset\" parameter, the
1175default charset will be used instead."
58e39d05 1176 :version "21.1"
16409b0b
GM
1177 :type '(repeat symbol)
1178 :group 'gnus-charset)
1179
4b70e299
MB
1180(defcustom gnus-newsgroup-maximum-articles nil
1181 "The maximum number of articles a newsgroup.
1182If this is a number, old articles in a newsgroup exceeding this number
1183are silently ignored. If it is nil, no article is ignored. Note that
1184setting this variable to a number might prevent you from reading very
1185old articles."
1186 :group 'gnus-group-select
1187 :version "22.2"
1188 :type '(choice (const :tag "No limit" nil)
1189 integer))
1190
23f87bed
MB
1191(gnus-define-group-parameter
1192 ignored-charsets
1193 :type list
1194 :function-document
1195 "Return the ignored charsets of GROUP."
1196 :variable gnus-group-ignored-charsets-alist
1197 :variable-default
1198 '(("alt\\.chinese\\.text" iso-8859-1))
1199 :variable-document
1200 "Alist of regexps (to match group names) and charsets that should be ignored.
16409b0b
GM
1201When these charsets are used in the \"charset\" parameter, the
1202default charset will be used instead."
23f87bed
MB
1203 :variable-group gnus-charset
1204 :variable-type '(repeat (cons (regexp :tag "Group")
1205 (repeat symbol)))
1206 :parameter-type '(choice :tag "Ignored charsets"
1207 :value nil
1208 (repeat (symbol)))
1209 :parameter-document "\
1210List of charsets that should be ignored.
1211
1212When these charsets are used in the \"charset\" parameter, the
1213default charset will be used instead.")
16409b0b
GM
1214
1215(defcustom gnus-group-highlight-words-alist nil
1216 "Alist of group regexps and highlight regexps.
1217This variable uses the same syntax as `gnus-emphasis-alist'."
58e39d05 1218 :version "21.1"
16409b0b
GM
1219 :type '(repeat (cons (regexp :tag "Group")
1220 (repeat (list (regexp :tag "Highlight regexp")
1221 (number :tag "Group for entire word" 0)
1222 (number :tag "Group for displayed part" 0)
1223 (symbol :tag "Face"
1224 gnus-emphasis-highlight-words)))))
1225 :group 'gnus-summary-visual)
1226
1227(defcustom gnus-summary-show-article-charset-alist
1228 nil
1229 "Alist of number and charset.
1230The article will be shown with the charset corresponding to the
1231numbered argument.
1232For example: ((1 . cn-gb-2312) (2 . big5))."
58e39d05 1233 :version "21.1"
16409b0b
GM
1234 :type '(repeat (cons (number :tag "Argument" 1)
1235 (symbol :tag "Charset")))
1236 :group 'gnus-charset)
1237
1238(defcustom gnus-preserve-marks t
1239 "Whether marks are preserved when moving, copying and respooling messages."
58e39d05 1240 :version "21.1"
16409b0b
GM
1241 :type 'boolean
1242 :group 'gnus-summary-marks)
1243
706b5974 1244(defcustom gnus-propagate-marks nil
5415d076
G
1245 "If non-nil, Gnus will store and retrieve marks from the backends.
1246This means that marks will be stored both in .newsrc.eld and in
1247the backend, and will slow operation down somewhat."
3a23a519
MB
1248 :type 'boolean
1249 :group 'gnus-summary-marks)
1250
16409b0b
GM
1251(defcustom gnus-alter-articles-to-read-function nil
1252 "Function to be called to alter the list of articles to be selected."
8fc7a9a1 1253 :type '(choice (const nil) function)
16409b0b
GM
1254 :group 'gnus-summary)
1255
1256(defcustom gnus-orphan-score nil
1257 "*All orphans get this score added. Set in the score file."
1258 :group 'gnus-score-default
1259 :type '(choice (const nil)
1260 integer))
1261
8b93df01 1262(defcustom gnus-summary-save-parts-default-mime "image/.*"
23f87bed
MB
1263 "*A regexp to match MIME parts when saving multiple parts of a
1264message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1265This regexp will be used by default when prompting the user for which
1266type of files to save."
8b93df01
DL
1267 :group 'gnus-summary
1268 :type 'regexp)
1269
23f87bed
MB
1270(defcustom gnus-read-all-available-headers nil
1271 "Whether Gnus should parse all headers made available to it.
1272This is mostly relevant for slow back ends where the user may
1273wish to widen the summary buffer to include all headers
c4d82de8 1274that were fetched."
bf247b6e 1275 :version "22.1"
23f87bed
MB
1276 :group 'gnus-summary
1277 :type '(choice boolean regexp))
1278
89167438
MB
1279(defcustom gnus-summary-pipe-output-default-command nil
1280 "Command (and optional arguments) used to pipe article to subprocess.
1281This will be used as the default command if it is non-nil. The value
1282will be updated if you modify it when executing the command
1283`gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1284 :version "23.1" ;; No Gnus
1285 :group 'gnus-summary
1286 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1287
23f87bed 1288(defcustom gnus-summary-muttprint-program "muttprint"
89167438
MB
1289 "Command (and optional arguments) used to run Muttprint.
1290The value will be updated if you modify it when executing the command
1291`gnus-summary-muttprint'."
bf247b6e 1292 :version "22.1"
23f87bed
MB
1293 :group 'gnus-summary
1294 :type 'string)
1295
01c52d31 1296(defcustom gnus-article-loose-mime t
23f87bed
MB
1297 "If non-nil, don't require MIME-Version header.
1298Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
a08b59c9 1299supply the MIME-Version header or deliberately strip it from the mail.
01c52d31
MB
1300If non-nil (the default), Gnus will treat some articles as MIME
1301even if the MIME-Version header is missing."
bf247b6e 1302 :version "22.1"
23f87bed
MB
1303 :type 'boolean
1304 :group 'gnus-article-mime)
1305
1306(defcustom gnus-article-emulate-mime t
1307 "If non-nil, use MIME emulation for uuencode and the like.
1308This means that Gnus will search message bodies for text that look
1309like uuencoded bits, yEncoded bits, and so on, and present that using
1310the normal Gnus MIME machinery."
bf247b6e 1311 :version "22.1"
23f87bed
MB
1312 :type 'boolean
1313 :group 'gnus-article-mime)
8b93df01 1314
eec82323
LMI
1315;;; Internal variables
1316
23f87bed 1317(defvar gnus-summary-display-cache nil)
16409b0b
GM
1318(defvar gnus-article-mime-handles nil)
1319(defvar gnus-article-decoded-p nil)
23f87bed
MB
1320(defvar gnus-article-charset nil)
1321(defvar gnus-article-ignored-charsets nil)
eec82323
LMI
1322(defvar gnus-scores-exclude-files nil)
1323(defvar gnus-page-broken nil)
1324
1325(defvar gnus-original-article nil)
1326(defvar gnus-article-internal-prepare-hook nil)
1327(defvar gnus-newsgroup-process-stack nil)
1328
1329(defvar gnus-thread-indent-array nil)
1330(defvar gnus-thread-indent-array-level gnus-thread-indent-level)
16409b0b
GM
1331(defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1332 "Function called to sort the articles within a thread after it has been gathered together.")
eec82323 1333
8b93df01 1334(defvar gnus-summary-save-parts-type-history nil)
23f87bed 1335(defvar gnus-summary-save-parts-last-directory mm-default-directory)
8b93df01 1336
eec82323
LMI
1337;; Avoid highlighting in kill files.
1338(defvar gnus-summary-inhibit-highlight nil)
1339(defvar gnus-newsgroup-selected-overlay nil)
1340(defvar gnus-inhibit-limiting nil)
1341(defvar gnus-newsgroup-adaptive-score-file nil)
1342(defvar gnus-current-score-file nil)
1343(defvar gnus-current-move-group nil)
1344(defvar gnus-current-copy-group nil)
1345(defvar gnus-current-crosspost-group nil)
23f87bed 1346(defvar gnus-newsgroup-display nil)
eec82323
LMI
1347
1348(defvar gnus-newsgroup-dependencies nil)
1349(defvar gnus-newsgroup-adaptive nil)
1350(defvar gnus-summary-display-article-function nil)
1351(defvar gnus-summary-highlight-line-function nil
1352 "Function called after highlighting a summary line.")
1353
1354(defvar gnus-summary-line-format-alist
1355 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1356 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1357 (?s gnus-tmp-subject-or-nil ?s)
1358 (?n gnus-tmp-name ?s)
1359 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1360 ?s)
1361 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1362 gnus-tmp-from) ?s)
1363 (?F gnus-tmp-from ?s)
1364 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1365 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1366 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
6748645f 1367 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
eec82323
LMI
1368 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1369 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1370 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
23f87bed
MB
1371 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1372 (?L gnus-tmp-lines ?s)
d6f6af81 1373 (?Z (or ,(gnus-macroexpand-all
ed797193
G
1374 '(nnir-article-rsv (mail-header-number gnus-tmp-header)))
1375 0) ?d)
d6f6af81 1376 (?G (or ,(gnus-macroexpand-all
ed797193
G
1377 '(nnir-article-group (mail-header-number gnus-tmp-header)))
1378 "") ?s)
d6f6af81 1379 (?g (or ,(gnus-macroexpand-all
ed797193
G
1380 '(gnus-group-short-name
1381 (nnir-article-group (mail-header-number gnus-tmp-header))))
1382 "") ?s)
23f87bed 1383 (?O gnus-tmp-downloaded ?c)
eec82323
LMI
1384 (?I gnus-tmp-indentation ?s)
1385 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1386 (?R gnus-tmp-replied ?c)
1387 (?\[ gnus-tmp-opening-bracket ?c)
1388 (?\] gnus-tmp-closing-bracket ?c)
1389 (?\> (make-string gnus-tmp-level ? ) ?s)
1390 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1391 (?i gnus-tmp-score ?d)
1392 (?z gnus-tmp-score-char ?c)
eec82323
LMI
1393 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1394 (?U gnus-tmp-unread ?c)
23f87bed
MB
1395 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1396 ?s)
eec82323
LMI
1397 (?t (gnus-summary-number-of-articles-in-thread
1398 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1399 ?d)
1400 (?e (gnus-summary-number-of-articles-in-thread
1401 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1402 ?c)
1403 (?u gnus-tmp-user-defined ?s)
23f87bed
MB
1404 (?P (gnus-pick-line-number) ?d)
1405 (?B gnus-tmp-thread-tree-header-string ?s)
ec72bf63 1406 (user-date (gnus-user-date
23f87bed 1407 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
16409b0b
GM
1408 "An alist of format specifications that can appear in summary lines.
1409These are paired with what variables they correspond with, along with
1410the type of the variable (string, integer, character, etc).")
eec82323
LMI
1411
1412(defvar gnus-summary-dummy-line-format-alist
1413 `((?S gnus-tmp-subject ?s)
1414 (?N gnus-tmp-number ?d)
1415 (?u gnus-tmp-user-defined ?s)))
1416
1417(defvar gnus-summary-mode-line-format-alist
1418 `((?G gnus-tmp-group-name ?s)
1419 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1420 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1421 (?A gnus-tmp-article-number ?d)
1422 (?Z gnus-tmp-unread-and-unselected ?s)
1423 (?V gnus-version ?s)
1424 (?U gnus-tmp-unread-and-unticked ?d)
1425 (?S gnus-tmp-subject ?s)
1426 (?e gnus-tmp-unselected ?d)
1427 (?u gnus-tmp-user-defined ?s)
1428 (?d (length gnus-newsgroup-dormant) ?d)
1429 (?t (length gnus-newsgroup-marked) ?d)
23f87bed 1430 (?h (length gnus-newsgroup-spam-marked) ?d)
eec82323 1431 (?r (length gnus-newsgroup-reads) ?d)
6748645f 1432 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
eec82323
LMI
1433 (?E gnus-newsgroup-expunged-tally ?d)
1434 (?s (gnus-current-score-file-nondirectory) ?s)))
1435
c1717fbd
GM
1436;; This is here rather than in gnus-art for compilation reasons.
1437(defvar gnus-article-mode-line-format-alist
1438 (nconc '((?w (gnus-article-wash-status) ?s)
1439 (?m (gnus-article-mime-part-status) ?s))
1440 gnus-summary-mode-line-format-alist))
1441
eec82323
LMI
1442(defvar gnus-last-search-regexp nil
1443 "Default regexp for article search command.")
1444
1445(defvar gnus-last-shell-command nil
1446 "Default shell command on article.")
1447
23f87bed
MB
1448(defvar gnus-newsgroup-agentized nil
1449 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
eec82323
LMI
1450(defvar gnus-newsgroup-begin nil)
1451(defvar gnus-newsgroup-end nil)
1452(defvar gnus-newsgroup-last-rmail nil)
1453(defvar gnus-newsgroup-last-mail nil)
1454(defvar gnus-newsgroup-last-folder nil)
1455(defvar gnus-newsgroup-last-file nil)
26c9afc3 1456(defvar gnus-newsgroup-last-directory nil)
eec82323
LMI
1457(defvar gnus-newsgroup-auto-expire nil)
1458(defvar gnus-newsgroup-active nil)
9f2d52e7 1459(defvar gnus-newsgroup-highest nil)
eec82323
LMI
1460
1461(defvar gnus-newsgroup-data nil)
1462(defvar gnus-newsgroup-data-reverse nil)
1463(defvar gnus-newsgroup-limit nil)
1464(defvar gnus-newsgroup-limits nil)
23f87bed 1465(defvar gnus-summary-use-undownloaded-faces nil)
eec82323
LMI
1466
1467(defvar gnus-newsgroup-unreads nil
23f87bed 1468 "Sorted list of unread articles in the current newsgroup.")
eec82323
LMI
1469
1470(defvar gnus-newsgroup-unselected nil
23f87bed 1471 "Sorted list of unselected unread articles in the current newsgroup.")
eec82323
LMI
1472
1473(defvar gnus-newsgroup-reads nil
1474 "Alist of read articles and article marks in the current newsgroup.")
1475
1476(defvar gnus-newsgroup-expunged-tally nil)
1477
1478(defvar gnus-newsgroup-marked nil
23f87bed
MB
1479 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1480
1481(defvar gnus-newsgroup-spam-marked nil
1482 "List of ranges of articles that have been marked as spam.")
eec82323
LMI
1483
1484(defvar gnus-newsgroup-killed nil
1485 "List of ranges of articles that have been through the scoring process.")
1486
1487(defvar gnus-newsgroup-cached nil
23f87bed 1488 "Sorted list of articles that come from the article cache.")
eec82323
LMI
1489
1490(defvar gnus-newsgroup-saved nil
1491 "List of articles that have been saved.")
1492
1493(defvar gnus-newsgroup-kill-headers nil)
1494
1495(defvar gnus-newsgroup-replied nil
1496 "List of articles that have been replied to in the current newsgroup.")
1497
23f87bed
MB
1498(defvar gnus-newsgroup-forwarded nil
1499 "List of articles that have been forwarded in the current newsgroup.")
1500
1501(defvar gnus-newsgroup-recent nil
1502 "List of articles that have are recent in the current newsgroup.")
1503
eec82323 1504(defvar gnus-newsgroup-expirable nil
23f87bed 1505 "Sorted list of articles in the current newsgroup that can be expired.")
eec82323
LMI
1506
1507(defvar gnus-newsgroup-processable nil
1508 "List of articles in the current newsgroup that can be processed.")
1509
6748645f 1510(defvar gnus-newsgroup-downloadable nil
23f87bed
MB
1511 "Sorted list of articles in the current newsgroup that can be processed.")
1512
1513(defvar gnus-newsgroup-unfetched nil
1514 "Sorted list of articles in the current newsgroup whose headers have
1515not been fetched into the agent.
1516
1517This list will always be a subset of gnus-newsgroup-undownloaded.")
6748645f
LMI
1518
1519(defvar gnus-newsgroup-undownloaded nil
23f87bed 1520 "List of articles in the current newsgroup that haven't been downloaded.")
6748645f
LMI
1521
1522(defvar gnus-newsgroup-unsendable nil
1523 "List of articles in the current newsgroup that won't be sent.")
1524
eec82323
LMI
1525(defvar gnus-newsgroup-bookmarks nil
1526 "List of articles in the current newsgroup that have bookmarks.")
1527
1528(defvar gnus-newsgroup-dormant nil
23f87bed
MB
1529 "Sorted list of dormant articles in the current newsgroup.")
1530
1531(defvar gnus-newsgroup-unseen nil
1532 "List of unseen articles in the current newsgroup.")
1533
1534(defvar gnus-newsgroup-seen nil
1535 "Range of seen articles in the current newsgroup.")
1536
1537(defvar gnus-newsgroup-articles nil
1538 "List of articles in the current newsgroup.")
eec82323
LMI
1539
1540(defvar gnus-newsgroup-scored nil
1541 "List of scored articles in the current newsgroup.")
1542
1543(defvar gnus-newsgroup-headers nil
1544 "List of article headers in the current newsgroup.")
1545
1546(defvar gnus-newsgroup-threads nil)
1547
1548(defvar gnus-newsgroup-prepared nil
1549 "Whether the current group has been prepared properly.")
1550
1551(defvar gnus-newsgroup-ancient nil
1552 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1553
1554(defvar gnus-newsgroup-sparse nil)
1555
1556(defvar gnus-current-article nil)
1557(defvar gnus-article-current nil)
1558(defvar gnus-current-headers nil)
1559(defvar gnus-have-all-headers nil)
1560(defvar gnus-last-article nil)
1561(defvar gnus-newsgroup-history nil)
16409b0b
GM
1562(defvar gnus-newsgroup-charset nil)
1563(defvar gnus-newsgroup-ephemeral-charset nil)
1564(defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
eec82323 1565
23f87bed
MB
1566(defvar gnus-article-before-search nil)
1567
1568(defvar gnus-summary-local-variables
eec82323 1569 '(gnus-newsgroup-name
b1ae92ba
G
1570
1571 ;; Marks lists
1572 gnus-newsgroup-unreads
1573 gnus-newsgroup-unselected
1574 gnus-newsgroup-marked
1575 gnus-newsgroup-spam-marked
1576 gnus-newsgroup-reads
1577 gnus-newsgroup-saved
1578 gnus-newsgroup-replied
1579 gnus-newsgroup-forwarded
1580 gnus-newsgroup-recent
1581 gnus-newsgroup-expirable
1582 gnus-newsgroup-killed
1583 gnus-newsgroup-unseen
1584 gnus-newsgroup-seen
1585 gnus-newsgroup-cached
1586 gnus-newsgroup-downloadable
1587 gnus-newsgroup-undownloaded
1588 gnus-newsgroup-unsendable
1589
eec82323
LMI
1590 gnus-newsgroup-begin gnus-newsgroup-end
1591 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1592 gnus-newsgroup-last-folder gnus-newsgroup-last-file
26c9afc3 1593 gnus-newsgroup-last-directory
b1ae92ba
G
1594 gnus-newsgroup-auto-expire
1595 gnus-newsgroup-processable
23f87bed 1596 gnus-newsgroup-unfetched
b1ae92ba 1597 gnus-newsgroup-articles
eec82323
LMI
1598 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1599 gnus-newsgroup-headers gnus-newsgroup-threads
1600 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1601 gnus-current-article gnus-current-headers gnus-have-all-headers
1602 gnus-last-article gnus-article-internal-prepare-hook
ed797193
G
1603 (gnus-summary-article-delete-hook . global)
1604 (gnus-summary-article-move-hook . global)
eec82323
LMI
1605 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1606 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1607 gnus-thread-expunge-below
16409b0b
GM
1608 gnus-score-alist gnus-current-score-file
1609 (gnus-summary-expunge-below . global)
eec82323 1610 (gnus-summary-mark-below . global)
16409b0b 1611 (gnus-orphan-score . global)
eec82323 1612 gnus-newsgroup-active gnus-scores-exclude-files
9f2d52e7 1613 gnus-newsgroup-highest
eec82323
LMI
1614 gnus-newsgroup-history gnus-newsgroup-ancient
1615 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1616 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1617 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1618 (gnus-newsgroup-expunged-tally . 0)
b1ae92ba 1619 gnus-cache-removable-articles
eec82323 1620 gnus-newsgroup-data gnus-newsgroup-data-reverse
16409b0b 1621 gnus-newsgroup-limit gnus-newsgroup-limits
23f87bed
MB
1622 gnus-newsgroup-charset gnus-newsgroup-display
1623 gnus-summary-use-undownloaded-faces)
eec82323
LMI
1624 "Variables that are buffer-local to the summary buffers.")
1625
23f87bed
MB
1626(defvar gnus-newsgroup-variables nil
1627 "A list of variables that have separate values in different newsgroups.
1628A list of newsgroup (summary buffer) local variables, or cons of
1629variables and their default expressions to be evalled (when the default
1630values are not nil), that should be made global while the summary buffer
1631is active.
1632
1633Note: The default expressions will be evaluated (using function `eval')
1634before assignment to the local variable rather than just assigned to it.
1635If the default expression is the symbol `global', that symbol will not
1636be evaluated but the global value of the local variable will be used
1637instead.
1638
1639These variables can be used to set variables in the group parameters
1640while still allowing them to affect operations done in other buffers.
1641For example:
1642
1643\(setq gnus-newsgroup-variables
1644 '(message-use-followup-to
1645 (gnus-visible-headers .
1646 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1647")
1648
23f87bed
MB
1649(eval-when-compile
1650 ;; Bind features so that require will believe that gnus-sum has
1651 ;; already been loaded (avoids infinite recursion)
1652 (let ((features (cons 'gnus-sum features)))
23f87bed 1653 (require 'gnus-art)))
eec82323 1654
16409b0b
GM
1655;; MIME stuff.
1656
1657(defvar gnus-decode-encoded-word-methods
1658 '(mail-decode-encoded-word-string)
1659 "List of methods used to decode encoded words.
1660
23f87bed
MB
1661This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1662is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1663\(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
16409b0b
GM
1664whose names match REGEXP.
1665
1666For example:
23f87bed 1667\((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
16409b0b
GM
1668 mail-decode-encoded-word-string
1669 (\"chinese\" . rfc1843-decode-string))")
1670
1671(defvar gnus-decode-encoded-word-methods-cache nil)
1672
1673(defun gnus-multi-decode-encoded-word-string (string)
1674 "Apply the functions from `gnus-encoded-word-methods' that match."
1675 (unless (and gnus-decode-encoded-word-methods-cache
1676 (eq gnus-newsgroup-name
1677 (car gnus-decode-encoded-word-methods-cache)))
1678 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
01c52d31
MB
1679 (dolist (method gnus-decode-encoded-word-methods)
1680 (if (symbolp method)
1681 (nconc gnus-decode-encoded-word-methods-cache (list method))
1682 (if (and gnus-newsgroup-name
1683 (string-match (car method) gnus-newsgroup-name))
1684 (nconc gnus-decode-encoded-word-methods-cache
1685 (list (cdr method)))))))
1686 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1687 (setq string (funcall method string))))
16409b0b 1688
eec82323
LMI
1689;; Subject simplification.
1690
6748645f 1691(defun gnus-simplify-whitespace (str)
16409b0b 1692 "Remove excessive whitespace from STR."
23f87bed
MB
1693 ;; Multiple spaces.
1694 (while (string-match "[ \t][ \t]+" str)
1695 (setq str (concat (substring str 0 (match-beginning 0))
1696 " "
1697 (substring str (match-end 0)))))
1698 ;; Leading spaces.
1699 (when (string-match "^[ \t]+" str)
1700 (setq str (substring str (match-end 0))))
1701 ;; Trailing spaces.
1702 (when (string-match "[ \t]+$" str)
1703 (setq str (substring str 0 (match-beginning 0))))
1704 str)
1705
1706(defun gnus-simplify-all-whitespace (str)
1707 "Remove all whitespace from STR."
1708 (while (string-match "[ \t\n]+" str)
1709 (setq str (replace-match "" nil nil str)))
1710 str)
6748645f 1711
eec82323
LMI
1712(defsubst gnus-simplify-subject-re (subject)
1713 "Remove \"Re:\" from subject lines."
23f87bed 1714 (if (string-match message-subject-re-regexp subject)
eec82323
LMI
1715 (substring subject (match-end 0))
1716 subject))
1717
1718(defun gnus-simplify-subject (subject &optional re-only)
1719 "Remove `Re:' and words in parentheses.
1720If RE-ONLY is non-nil, strip leading `Re:'s only."
1721 (let ((case-fold-search t)) ;Ignore case.
1722 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1723 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1724 (setq subject (substring subject (match-end 0))))
1725 ;; Remove uninteresting prefixes.
1726 (when (and (not re-only)
1727 gnus-simplify-ignored-prefixes
1728 (string-match gnus-simplify-ignored-prefixes subject))
1729 (setq subject (substring subject (match-end 0))))
1730 ;; Remove words in parentheses from end.
1731 (unless re-only
1732 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1733 (setq subject (substring subject 0 (match-beginning 0)))))
1734 ;; Return subject string.
1735 subject))
1736
1737;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1738;; all whitespace.
1739(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1740 (goto-char (point-min))
1741 (while (re-search-forward regexp nil t)
16409b0b 1742 (replace-match (or newtext ""))))
eec82323 1743
a5954fa5 1744(defun gnus-simplify-buffer-fuzzy (regexp)
eec82323
LMI
1745 "Simplify string in the buffer fuzzily.
1746The string in the accessible portion of the current buffer is simplified.
1747It is assumed to be a single-line subject.
1748Whitespace is generally cleaned up, and miscellaneous leading/trailing
1749matter is removed. Additional things can be deleted by setting
16409b0b 1750`gnus-simplify-subject-fuzzy-regexp'."
eec82323
LMI
1751 (let ((case-fold-search t)
1752 (modified-tick))
1753 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1754
1755 (while (not (eq modified-tick (buffer-modified-tick)))
1756 (setq modified-tick (buffer-modified-tick))
1757 (cond
a5954fa5
G
1758 ((listp regexp)
1759 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1760 (regexp
1761 (gnus-simplify-buffer-fuzzy-step regexp)))
eec82323
LMI
1762 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1763 (gnus-simplify-buffer-fuzzy-step
1764 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1765 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1766
1767 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1768 (gnus-simplify-buffer-fuzzy-step " +" " ")
1769 (gnus-simplify-buffer-fuzzy-step " $")
1770 (gnus-simplify-buffer-fuzzy-step "^ +")))
1771
1772(defun gnus-simplify-subject-fuzzy (subject)
1773 "Simplify a subject string fuzzily.
6748645f 1774See `gnus-simplify-buffer-fuzzy' for details."
eec82323 1775 (save-excursion
a5954fa5
G
1776 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1777 (gnus-set-work-buffer)
1778 (let ((case-fold-search t))
1779 ;; Remove uninteresting prefixes.
1780 (when (and gnus-simplify-ignored-prefixes
1781 (string-match gnus-simplify-ignored-prefixes subject))
1782 (setq subject (substring subject (match-end 0))))
1783 (insert subject)
1784 (inline (gnus-simplify-buffer-fuzzy regexp))
1785 (buffer-string)))))
eec82323
LMI
1786
1787(defsubst gnus-simplify-subject-fully (subject)
23f87bed 1788 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
eec82323 1789 (cond
6748645f
LMI
1790 (gnus-simplify-subject-functions
1791 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1792 ((null gnus-summary-gather-subject-limit)
1793 (gnus-simplify-subject-re subject))
1794 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1795 (gnus-simplify-subject-fuzzy subject))
1796 ((numberp gnus-summary-gather-subject-limit)
01c52d31
MB
1797 (truncate-string-to-width (gnus-simplify-subject-re subject)
1798 gnus-summary-gather-subject-limit))
eec82323
LMI
1799 (t
1800 subject)))
1801
1802(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f 1803 "Check whether two subjects are equal.
23f87bed 1804If optional argument SIMPLE-FIRST is t, first argument is already
6748645f 1805simplified."
eec82323
LMI
1806 (cond
1807 ((null simple-first)
1808 (equal (gnus-simplify-subject-fully s1)
1809 (gnus-simplify-subject-fully s2)))
1810 (t
1811 (equal s1
1812 (gnus-simplify-subject-fully s2)))))
1813
1814(defun gnus-summary-bubble-group ()
1815 "Increase the score of the current group.
1816This is a handy function to add to `gnus-summary-exit-hook' to
1817increase the score of each group you read."
1818 (gnus-group-add-score gnus-newsgroup-name))
1819
1820\f
1821;;;
1822;;; Gnus summary mode
1823;;;
1824
1825(put 'gnus-summary-mode 'mode-class 'special)
1826
1653df0f
SZ
1827(defvar gnus-article-commands-menu)
1828
23f87bed
MB
1829;; Non-orthogonal keys
1830
1831(gnus-define-keys gnus-summary-mode-map
1832 " " gnus-summary-next-page
1833 "\177" gnus-summary-prev-page
1834 [delete] gnus-summary-prev-page
1835 [backspace] gnus-summary-prev-page
1836 "\r" gnus-summary-scroll-up
1837 "\M-\r" gnus-summary-scroll-down
1838 "n" gnus-summary-next-unread-article
1839 "p" gnus-summary-prev-unread-article
1840 "N" gnus-summary-next-article
1841 "P" gnus-summary-prev-article
1842 "\M-\C-n" gnus-summary-next-same-subject
1843 "\M-\C-p" gnus-summary-prev-same-subject
1844 "\M-n" gnus-summary-next-unread-subject
1845 "\M-p" gnus-summary-prev-unread-subject
1846 "." gnus-summary-first-unread-article
1847 "," gnus-summary-best-unread-article
1848 "\M-s" gnus-summary-search-article-forward
1849 "\M-r" gnus-summary-search-article-backward
01c52d31
MB
1850 "\M-S" gnus-summary-repeat-search-article-forward
1851 "\M-R" gnus-summary-repeat-search-article-backward
23f87bed
MB
1852 "<" gnus-summary-beginning-of-article
1853 ">" gnus-summary-end-of-article
1854 "j" gnus-summary-goto-article
1855 "^" gnus-summary-refer-parent-article
1856 "\M-^" gnus-summary-refer-article
1857 "u" gnus-summary-tick-article-forward
1858 "!" gnus-summary-tick-article-forward
1859 "U" gnus-summary-tick-article-backward
1860 "d" gnus-summary-mark-as-read-forward
1861 "D" gnus-summary-mark-as-read-backward
1862 "E" gnus-summary-mark-as-expirable
1863 "\M-u" gnus-summary-clear-mark-forward
1864 "\M-U" gnus-summary-clear-mark-backward
1865 "k" gnus-summary-kill-same-subject-and-select
1866 "\C-k" gnus-summary-kill-same-subject
1867 "\M-\C-k" gnus-summary-kill-thread
1868 "\M-\C-l" gnus-summary-lower-thread
1869 "e" gnus-summary-edit-article
1870 "#" gnus-summary-mark-as-processable
1871 "\M-#" gnus-summary-unmark-as-processable
1872 "\M-\C-t" gnus-summary-toggle-threads
1873 "\M-\C-s" gnus-summary-show-thread
1874 "\M-\C-h" gnus-summary-hide-thread
1875 "\M-\C-f" gnus-summary-next-thread
1876 "\M-\C-b" gnus-summary-prev-thread
1877 [(meta down)] gnus-summary-next-thread
1878 [(meta up)] gnus-summary-prev-thread
1879 "\M-\C-u" gnus-summary-up-thread
1880 "\M-\C-d" gnus-summary-down-thread
1881 "&" gnus-summary-execute-command
1882 "c" gnus-summary-catchup-and-exit
1883 "\C-w" gnus-summary-mark-region-as-read
1884 "\C-t" gnus-summary-toggle-truncation
1885 "?" gnus-summary-mark-as-dormant
1886 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1887 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6ecfe5c2 1888 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
23f87bed
MB
1889 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1890 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1891 "\C-c\C-s\C-a" gnus-summary-sort-by-author
01c52d31 1892 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
23f87bed
MB
1893 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1894 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6ecfe5c2 1895 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
23f87bed
MB
1896 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1897 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1898 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1899 "=" gnus-summary-expand-window
1900 "\C-x\C-s" gnus-summary-reselect-current-group
1901 "\M-g" gnus-summary-rescan-group
23f87bed
MB
1902 "\C-c\C-r" gnus-summary-caesar-message
1903 "f" gnus-summary-followup
1904 "F" gnus-summary-followup-with-original
1905 "C" gnus-summary-cancel-article
1906 "r" gnus-summary-reply
1907 "R" gnus-summary-reply-with-original
1908 "\C-c\C-f" gnus-summary-mail-forward
1909 "o" gnus-summary-save-article
1910 "\C-o" gnus-summary-save-article-mail
1911 "|" gnus-summary-pipe-output
1912 "\M-k" gnus-summary-edit-local-kill
1913 "\M-K" gnus-summary-edit-global-kill
1914 ;; "V" gnus-version
1915 "\C-c\C-d" gnus-summary-describe-group
1916 "q" gnus-summary-exit
1917 "Q" gnus-summary-exit-no-update
1918 "\C-c\C-i" gnus-info-find-node
1919 gnus-mouse-2 gnus-mouse-pick-article
132cf96d 1920 [follow-link] mouse-face
23f87bed
MB
1921 "m" gnus-summary-mail-other-window
1922 "a" gnus-summary-post-news
23f87bed
MB
1923 "x" gnus-summary-limit-to-unread
1924 "s" gnus-summary-isearch-article
d50717f0 1925 [tab] gnus-summary-widget-forward
23f87bed
MB
1926 "t" gnus-summary-toggle-header
1927 "g" gnus-summary-show-article
1928 "l" gnus-summary-goto-last-article
1929 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1930 "\C-d" gnus-summary-enter-digest-group
1931 "\M-\C-d" gnus-summary-read-document
1932 "\M-\C-e" gnus-summary-edit-parameters
1933 "\M-\C-a" gnus-summary-customize-parameters
1934 "\C-c\C-b" gnus-bug
1935 "*" gnus-cache-enter-article
1936 "\M-*" gnus-cache-remove-article
1937 "\M-&" gnus-summary-universal-argument
1938 "\C-l" gnus-recenter
1939 "I" gnus-summary-increase-score
1940 "L" gnus-summary-lower-score
1941 "\M-i" gnus-symbolic-argument
1942 "h" gnus-summary-select-article-buffer
1943
1944 "b" gnus-article-view-part
1945 "\M-t" gnus-summary-toggle-display-buttonized
1946
1947 "V" gnus-summary-score-map
1948 "X" gnus-uu-extract-map
1949 "S" gnus-summary-send-map)
1950
1951;; Sort of orthogonal keymap
1952(gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1953 "t" gnus-summary-tick-article-forward
1954 "!" gnus-summary-tick-article-forward
1955 "d" gnus-summary-mark-as-read-forward
1956 "r" gnus-summary-mark-as-read-forward
1957 "c" gnus-summary-clear-mark-forward
1958 " " gnus-summary-clear-mark-forward
1959 "e" gnus-summary-mark-as-expirable
1960 "x" gnus-summary-mark-as-expirable
1961 "?" gnus-summary-mark-as-dormant
1962 "b" gnus-summary-set-bookmark
1963 "B" gnus-summary-remove-bookmark
1964 "#" gnus-summary-mark-as-processable
1965 "\M-#" gnus-summary-unmark-as-processable
1966 "S" gnus-summary-limit-include-expunged
1967 "C" gnus-summary-catchup
1968 "H" gnus-summary-catchup-to-here
1969 "h" gnus-summary-catchup-from-here
1970 "\C-c" gnus-summary-catchup-all
1971 "k" gnus-summary-kill-same-subject-and-select
1972 "K" gnus-summary-kill-same-subject
1973 "P" gnus-uu-mark-map)
1974
1975(gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1976 "c" gnus-summary-clear-above
1977 "u" gnus-summary-tick-above
1978 "m" gnus-summary-mark-above
1979 "k" gnus-summary-kill-below)
1980
1981(gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1982 "/" gnus-summary-limit-to-subject
1983 "n" gnus-summary-limit-to-articles
01c52d31
MB
1984 "b" gnus-summary-limit-to-bodies
1985 "h" gnus-summary-limit-to-headers
23f87bed
MB
1986 "w" gnus-summary-pop-limit
1987 "s" gnus-summary-limit-to-subject
1988 "a" gnus-summary-limit-to-author
1989 "u" gnus-summary-limit-to-unread
1990 "m" gnus-summary-limit-to-marks
1991 "M" gnus-summary-limit-exclude-marks
1992 "v" gnus-summary-limit-to-score
1993 "*" gnus-summary-limit-include-cached
1994 "D" gnus-summary-limit-include-dormant
1995 "T" gnus-summary-limit-include-thread
1996 "d" gnus-summary-limit-exclude-dormant
1997 "t" gnus-summary-limit-to-age
1998 "." gnus-summary-limit-to-unseen
1999 "x" gnus-summary-limit-to-extra
2000 "p" gnus-summary-limit-to-display-predicate
2001 "E" gnus-summary-limit-include-expunged
2002 "c" gnus-summary-limit-exclude-childless-dormant
2003 "C" gnus-summary-limit-mark-excluded-as-read
2004 "o" gnus-summary-insert-old-articles
01c52d31
MB
2005 "N" gnus-summary-insert-new-articles
2006 "S" gnus-summary-limit-to-singletons
2007 "r" gnus-summary-limit-to-replied
2008 "R" gnus-summary-limit-to-recipient
2009 "A" gnus-summary-limit-to-address)
23f87bed
MB
2010
2011(gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2012 "n" gnus-summary-next-unread-article
2013 "p" gnus-summary-prev-unread-article
2014 "N" gnus-summary-next-article
2015 "P" gnus-summary-prev-article
2016 "\C-n" gnus-summary-next-same-subject
2017 "\C-p" gnus-summary-prev-same-subject
2018 "\M-n" gnus-summary-next-unread-subject
2019 "\M-p" gnus-summary-prev-unread-subject
2020 "f" gnus-summary-first-unread-article
2021 "b" gnus-summary-best-unread-article
2022 "j" gnus-summary-goto-article
2023 "g" gnus-summary-goto-subject
2024 "l" gnus-summary-goto-last-article
2025 "o" gnus-summary-pop-article)
2026
2027(gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2028 "k" gnus-summary-kill-thread
01c52d31 2029 "E" gnus-summary-expire-thread
23f87bed
MB
2030 "l" gnus-summary-lower-thread
2031 "i" gnus-summary-raise-thread
2032 "T" gnus-summary-toggle-threads
2033 "t" gnus-summary-rethread-current
2034 "^" gnus-summary-reparent-thread
01c52d31 2035 "\M-^" gnus-summary-reparent-children
23f87bed
MB
2036 "s" gnus-summary-show-thread
2037 "S" gnus-summary-show-all-threads
2038 "h" gnus-summary-hide-thread
2039 "H" gnus-summary-hide-all-threads
2040 "n" gnus-summary-next-thread
2041 "p" gnus-summary-prev-thread
2042 "u" gnus-summary-up-thread
2043 "o" gnus-summary-top-thread
2044 "d" gnus-summary-down-thread
2045 "#" gnus-uu-mark-thread
2046 "\M-#" gnus-uu-unmark-thread)
2047
2048(gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2049 "g" gnus-summary-prepare
2050 "c" gnus-summary-insert-cached-articles
01c52d31
MB
2051 "d" gnus-summary-insert-dormant-articles
2052 "t" gnus-summary-insert-ticked-articles)
23f87bed
MB
2053
2054(gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2055 "c" gnus-summary-catchup-and-exit
2056 "C" gnus-summary-catchup-all-and-exit
2057 "E" gnus-summary-exit-no-update
2058 "Q" gnus-summary-exit
2059 "Z" gnus-summary-exit
2060 "n" gnus-summary-catchup-and-goto-next-group
01c52d31 2061 "p" gnus-summary-catchup-and-goto-prev-group
23f87bed
MB
2062 "R" gnus-summary-reselect-current-group
2063 "G" gnus-summary-rescan-group
2064 "N" gnus-summary-next-group
2065 "s" gnus-summary-save-newsrc
2066 "P" gnus-summary-prev-group)
2067
2068(gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2069 " " gnus-summary-next-page
2070 "n" gnus-summary-next-page
2071 "\177" gnus-summary-prev-page
2072 [delete] gnus-summary-prev-page
2073 "p" gnus-summary-prev-page
2074 "\r" gnus-summary-scroll-up
2075 "\M-\r" gnus-summary-scroll-down
2076 "<" gnus-summary-beginning-of-article
2077 ">" gnus-summary-end-of-article
2078 "b" gnus-summary-beginning-of-article
2079 "e" gnus-summary-end-of-article
2080 "^" gnus-summary-refer-parent-article
2081 "r" gnus-summary-refer-parent-article
8ccbef23 2082 "C" gnus-summary-show-complete-article
23f87bed
MB
2083 "D" gnus-summary-enter-digest-group
2084 "R" gnus-summary-refer-references
2085 "T" gnus-summary-refer-thread
4ddab346 2086 "W" gnus-warp-to-article
23f87bed
MB
2087 "g" gnus-summary-show-article
2088 "s" gnus-summary-isearch-article
d50717f0 2089 [tab] gnus-summary-widget-forward
23f87bed 2090 "P" gnus-summary-print-article
01c52d31 2091 "S" gnus-sticky-article
23f87bed
MB
2092 "M" gnus-mailing-list-insinuate
2093 "t" gnus-article-babel)
2094
2095(gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2096 "b" gnus-article-add-buttons
2097 "B" gnus-article-add-buttons-to-head
2098 "o" gnus-article-treat-overstrike
2099 "e" gnus-article-emphasize
2100 "w" gnus-article-fill-cited-article
2101 "Q" gnus-article-fill-long-lines
01c52d31 2102 "L" gnus-article-toggle-truncate-lines
23f87bed
MB
2103 "C" gnus-article-capitalize-sentences
2104 "c" gnus-article-remove-cr
2105 "q" gnus-article-de-quoted-unreadable
2106 "6" gnus-article-de-base64-unreadable
2107 "Z" gnus-article-decode-HZ
01c52d31 2108 "A" gnus-article-treat-ansi-sequences
23f87bed
MB
2109 "h" gnus-article-wash-html
2110 "u" gnus-article-unsplit-urls
2111 "s" gnus-summary-force-verify-and-decrypt
2112 "f" gnus-article-display-x-face
2113 "l" gnus-summary-stop-page-breaking
2114 "r" gnus-summary-caesar-message
2115 "m" gnus-summary-morse-message
2116 "t" gnus-summary-toggle-header
2117 "g" gnus-treat-smiley
2118 "v" gnus-summary-verbose-headers
2119 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2120 "p" gnus-article-verify-x-pgp-sig
01c52d31 2121 "d" gnus-article-treat-dumbquotes
be3c11b3 2122 "U" gnus-article-treat-non-ascii
01c52d31 2123 "i" gnus-summary-idna-message)
23f87bed
MB
2124
2125(gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2126 ;; mnemonic: deuglif*Y*
2127 "u" gnus-article-outlook-unwrap-lines
2128 "a" gnus-article-outlook-repair-attribution
2129 "c" gnus-article-outlook-rearrange-citation
2130 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2131
2132(gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2133 "a" gnus-article-hide
2134 "h" gnus-article-hide-headers
2135 "b" gnus-article-hide-boring-headers
2136 "s" gnus-article-hide-signature
2137 "c" gnus-article-hide-citation
2138 "C" gnus-article-hide-citation-in-followups
2139 "l" gnus-article-hide-list-identifiers
2140 "B" gnus-article-strip-banner
2141 "P" gnus-article-hide-pem
2142 "\C-c" gnus-article-hide-citation-maybe)
2143
2144(gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2145 "a" gnus-article-highlight
2146 "h" gnus-article-highlight-headers
2147 "c" gnus-article-highlight-citation
2148 "s" gnus-article-highlight-signature)
2149
2150(gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2151 "f" gnus-article-treat-fold-headers
2152 "u" gnus-article-treat-unfold-headers
2153 "n" gnus-article-treat-fold-newsgroups)
2154
2155(gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2156 "x" gnus-article-display-x-face
2157 "d" gnus-article-display-face
2158 "s" gnus-treat-smiley
2159 "D" gnus-article-remove-images
8b6f6573 2160 "W" gnus-article-show-images
23f87bed
MB
2161 "f" gnus-treat-from-picon
2162 "m" gnus-treat-mail-picon
61b1af82
G
2163 "n" gnus-treat-newsgroups-picon
2164 "g" gnus-treat-from-gravatar
2165 "h" gnus-treat-mail-gravatar)
23f87bed
MB
2166
2167(gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2168 "w" gnus-article-decode-mime-words
2169 "c" gnus-article-decode-charset
2170 "v" gnus-mime-view-all-parts
2171 "b" gnus-article-view-part)
2172
2173(gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2174 "z" gnus-article-date-ut
2175 "u" gnus-article-date-ut
2176 "l" gnus-article-date-local
2177 "p" gnus-article-date-english
2178 "e" gnus-article-date-lapsed
2179 "o" gnus-article-date-original
2180 "i" gnus-article-date-iso8601
2181 "s" gnus-article-date-user)
2182
2183(gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2184 "t" gnus-article-remove-trailing-blank-lines
2185 "l" gnus-article-strip-leading-blank-lines
2186 "m" gnus-article-strip-multiple-blank-lines
2187 "a" gnus-article-strip-blank-lines
2188 "A" gnus-article-strip-all-blank-lines
2189 "s" gnus-article-strip-leading-space
2190 "e" gnus-article-strip-trailing-space
2191 "w" gnus-article-remove-leading-whitespace)
2192
2193(gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2194 "v" gnus-version
23f87bed
MB
2195 "d" gnus-summary-describe-group
2196 "h" gnus-summary-describe-briefly
837ba704 2197 "i" gnus-info-find-node)
23f87bed
MB
2198
2199(gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2200 "e" gnus-summary-expire-articles
2201 "\M-\C-e" gnus-summary-expire-articles-now
2202 "\177" gnus-summary-delete-article
2203 [delete] gnus-summary-delete-article
2204 [backspace] gnus-summary-delete-article
2205 "m" gnus-summary-move-article
2206 "r" gnus-summary-respool-article
2207 "w" gnus-summary-edit-article
2208 "c" gnus-summary-copy-article
2209 "B" gnus-summary-crosspost-article
2210 "q" gnus-summary-respool-query
2211 "t" gnus-summary-respool-trace
2212 "i" gnus-summary-import-article
2213 "I" gnus-summary-create-article
2214 "p" gnus-summary-article-posted-p)
2215
2216(gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2217 "o" gnus-summary-save-article
2218 "m" gnus-summary-save-article-mail
2219 "F" gnus-summary-write-article-file
2220 "r" gnus-summary-save-article-rmail
2221 "f" gnus-summary-save-article-file
2222 "b" gnus-summary-save-article-body-file
26c9afc3 2223 "B" gnus-summary-write-article-body-file
23f87bed
MB
2224 "h" gnus-summary-save-article-folder
2225 "v" gnus-summary-save-article-vm
2226 "p" gnus-summary-pipe-output
c4d82de8 2227 "P" gnus-summary-muttprint)
23f87bed
MB
2228
2229(gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2230 "b" gnus-summary-display-buttonized
2231 "m" gnus-summary-repair-multipart
2232 "v" gnus-article-view-part
2233 "o" gnus-article-save-part
01c52d31
MB
2234 "O" gnus-article-save-part-and-strip
2235 "r" gnus-article-replace-part
2236 "d" gnus-article-delete-part
2237 "t" gnus-article-view-part-as-type
2238 "j" gnus-article-jump-to-part
23f87bed
MB
2239 "c" gnus-article-copy-part
2240 "C" gnus-article-view-part-as-charset
2241 "e" gnus-article-view-part-externally
01c52d31 2242 "H" gnus-article-browse-html-article
23f87bed
MB
2243 "E" gnus-article-encrypt-body
2244 "i" gnus-article-inline-part
2245 "|" gnus-article-pipe-part)
2246
2247(gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2248 "p" gnus-summary-mark-as-processable
2249 "u" gnus-summary-unmark-as-processable
2250 "U" gnus-summary-unmark-all-processable
2251 "v" gnus-uu-mark-over
2252 "s" gnus-uu-mark-series
2253 "r" gnus-uu-mark-region
2254 "g" gnus-uu-unmark-region
2255 "R" gnus-uu-mark-by-regexp
2256 "G" gnus-uu-unmark-by-regexp
2257 "t" gnus-uu-mark-thread
2258 "T" gnus-uu-unmark-thread
2259 "a" gnus-uu-mark-all
2260 "b" gnus-uu-mark-buffer
2261 "S" gnus-uu-mark-sparse
2262 "k" gnus-summary-kill-process-mark
2263 "y" gnus-summary-yank-process-mark
2264 "w" gnus-summary-save-process-mark
2265 "i" gnus-uu-invert-processable)
2266
2267(gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2268 ;;"x" gnus-uu-extract-any
2269 "m" gnus-summary-save-parts
2270 "u" gnus-uu-decode-uu
2271 "U" gnus-uu-decode-uu-and-save
2272 "s" gnus-uu-decode-unshar
2273 "S" gnus-uu-decode-unshar-and-save
2274 "o" gnus-uu-decode-save
2275 "O" gnus-uu-decode-save
2276 "b" gnus-uu-decode-binhex
2277 "B" gnus-uu-decode-binhex
b890d447 2278 "Y" gnus-uu-decode-yenc
23f87bed
MB
2279 "p" gnus-uu-decode-postscript
2280 "P" gnus-uu-decode-postscript-and-save)
2281
2282(gnus-define-keys
2283 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2284 "u" gnus-uu-decode-uu-view
2285 "U" gnus-uu-decode-uu-and-save-view
2286 "s" gnus-uu-decode-unshar-view
2287 "S" gnus-uu-decode-unshar-and-save-view
2288 "o" gnus-uu-decode-save-view
2289 "O" gnus-uu-decode-save-view
2290 "b" gnus-uu-decode-binhex-view
2291 "B" gnus-uu-decode-binhex-view
2292 "p" gnus-uu-decode-postscript-view
2293 "P" gnus-uu-decode-postscript-and-save-view)
2294
2295(defvar gnus-article-post-menu nil)
2296
2297(defconst gnus-summary-menu-maxlen 20)
2298
2299(defun gnus-summary-menu-split (menu)
2300 ;; If we have lots of elements, divide them into groups of 20
2301 ;; and make a pane (or submenu) for each one.
2302 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2303 (let ((menu menu) sublists next
2304 (i 1))
2305 (while menu
2306 ;; Pull off the next gnus-summary-menu-maxlen elements
2307 ;; and make them the next element of sublist.
2308 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2309 (if next
2310 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2311 nil))
2312 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2313 (aref (car (last menu)) 0)) menu)
2314 sublists))
2315 (setq i (1+ i))
2316 (setq menu next))
2317 (nreverse sublists))
2318 ;; Few elements--put them all in one pane.
2319 menu))
eec82323
LMI
2320
2321(defun gnus-summary-make-menu-bar ()
2322 (gnus-turn-off-edit-menu 'summary)
2323
2324 (unless (boundp 'gnus-summary-misc-menu)
2325
2326 (easy-menu-define
23f87bed
MB
2327 gnus-summary-kill-menu gnus-summary-mode-map ""
2328 (cons
2329 "Score"
2330 (nconc
2331 (list
2332 ["Customize" gnus-score-customize t])
2333 (gnus-make-score-map 'increase)
2334 (gnus-make-score-map 'lower)
2335 '(("Mark"
2336 ["Kill below" gnus-summary-kill-below t]
2337 ["Mark above" gnus-summary-mark-above t]
2338 ["Tick above" gnus-summary-tick-above t]
2339 ["Clear above" gnus-summary-clear-above t])
2340 ["Current score" gnus-summary-current-score t]
2341 ["Set score" gnus-summary-set-score t]
2342 ["Switch current score file..." gnus-score-change-score-file t]
2343 ["Set mark below..." gnus-score-set-mark-below t]
2344 ["Set expunge below..." gnus-score-set-expunge-below t]
2345 ["Edit current score file" gnus-score-edit-current-scores t]
59429511 2346 ["Edit score file..." gnus-score-edit-file t]
23f87bed
MB
2347 ["Trace score" gnus-score-find-trace t]
2348 ["Find words" gnus-score-find-favourite-words t]
2349 ["Rescore buffer" gnus-summary-rescore t]
2350 ["Increase score..." gnus-summary-increase-score t]
2351 ["Lower score..." gnus-summary-lower-score t]))))
2352
2353 ;; Define both the Article menu in the summary buffer and the
2354 ;; equivalent Commands menu in the article buffer here for
2355 ;; consistency.
6748645f 2356 (let ((innards
23f87bed
MB
2357 `(("Hide"
2358 ["All" gnus-article-hide t]
2359 ["Headers" gnus-article-hide-headers t]
2360 ["Signature" gnus-article-hide-signature t]
2361 ["Citation" gnus-article-hide-citation t]
16409b0b 2362 ["List identifiers" gnus-article-hide-list-identifiers t]
16409b0b 2363 ["Banner" gnus-article-strip-banner t]
23f87bed
MB
2364 ["Boring headers" gnus-article-hide-boring-headers t])
2365 ("Highlight"
2366 ["All" gnus-article-highlight t]
2367 ["Headers" gnus-article-highlight-headers t]
2368 ["Signature" gnus-article-highlight-signature t]
2369 ["Citation" gnus-article-highlight-citation t])
16409b0b
GM
2370 ("MIME"
2371 ["Words" gnus-article-decode-mime-words t]
2372 ["Charset" gnus-article-decode-charset t]
2373 ["QP" gnus-article-de-quoted-unreadable t]
2374 ["Base64" gnus-article-de-base64-unreadable t]
23f87bed
MB
2375 ["View MIME buttons" gnus-summary-display-buttonized t]
2376 ["View all" gnus-mime-view-all-parts t]
2377 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2378 ["Encrypt body" gnus-article-encrypt-body
2379 :active (not (gnus-group-read-only-p))
2380 ,@(if (featurep 'xemacs) nil
2381 '(:help "Encrypt the message body on disk"))]
2382 ["Extract all parts..." gnus-summary-save-parts t]
2383 ("Multipart"
2384 ["Repair multipart" gnus-summary-repair-multipart t]
2385 ["Pipe part..." gnus-article-pipe-part t]
2386 ["Inline part" gnus-article-inline-part t]
01c52d31 2387 ["View part as type..." gnus-article-view-part-as-type t]
23f87bed
MB
2388 ["Encrypt body" gnus-article-encrypt-body
2389 :active (not (gnus-group-read-only-p))
2390 ,@(if (featurep 'xemacs) nil
2391 '(:help "Encrypt the message body on disk"))]
2392 ["View part externally" gnus-article-view-part-externally t]
01c52d31 2393 ["View HTML parts in browser" gnus-article-browse-html-article t]
23f87bed
MB
2394 ["View part with charset..." gnus-article-view-part-as-charset t]
2395 ["Copy part" gnus-article-copy-part t]
2396 ["Save part..." gnus-article-save-part t]
2397 ["View part" gnus-article-view-part t]))
2398 ("Date"
2399 ["Local" gnus-article-date-local t]
2400 ["ISO8601" gnus-article-date-iso8601 t]
2401 ["UT" gnus-article-date-ut t]
2402 ["Original" gnus-article-date-original t]
2403 ["Lapsed" gnus-article-date-lapsed t]
2404 ["User-defined" gnus-article-date-user t])
2405 ("Display"
2406 ["Remove images" gnus-article-remove-images t]
2407 ["Toggle smiley" gnus-treat-smiley t]
2408 ["Show X-Face" gnus-article-display-x-face t]
2409 ["Show picons in From" gnus-treat-from-picon t]
2410 ["Show picons in mail headers" gnus-treat-mail-picon t]
2411 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
61b1af82
G
2412 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2413 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
23f87bed
MB
2414 ("View as different encoding"
2415 ,@(gnus-summary-menu-split
2416 (mapcar
2417 (lambda (cs)
2418 ;; Since easymenu under Emacs doesn't allow
2419 ;; lambda forms for menu commands, we should
2420 ;; provide intern'ed function symbols.
2421 (let ((command (intern (format "\
2422gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2423 (fset command
2424 `(lambda ()
2425 (interactive)
2426 (let ((gnus-summary-show-article-charset-alist
2427 '((1 . ,cs))))
2428 (gnus-summary-show-article 1))))
2429 `[,(symbol-name cs) ,command t]))
2430 (sort (if (fboundp 'coding-system-list)
2431 (coding-system-list)
2432 (mapcar 'car mm-mime-mule-charset-alist))
2433 'string<)))))
2434 ("Washing"
2435 ("Remove Blanks"
2436 ["Leading" gnus-article-strip-leading-blank-lines t]
2437 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2438 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2439 ["All of the above" gnus-article-strip-blank-lines t]
2440 ["All" gnus-article-strip-all-blank-lines t]
2441 ["Leading space" gnus-article-strip-leading-space t]
2442 ["Trailing space" gnus-article-strip-trailing-space t]
2443 ["Leading space in headers"
2444 gnus-article-remove-leading-whitespace t])
2445 ["Overstrike" gnus-article-treat-overstrike t]
2446 ["Dumb quotes" gnus-article-treat-dumbquotes t]
be3c11b3 2447 ["Non-ASCII" gnus-article-treat-non-ascii t]
23f87bed
MB
2448 ["Emphasis" gnus-article-emphasize t]
2449 ["Word wrap" gnus-article-fill-cited-article t]
16409b0b 2450 ["Fill long lines" gnus-article-fill-long-lines t]
01c52d31 2451 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
16409b0b 2452 ["Capitalize sentences" gnus-article-capitalize-sentences t]
23f87bed
MB
2453 ["Remove CR" gnus-article-remove-cr t]
2454 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2455 ["Base64" gnus-article-de-base64-unreadable t]
2456 ["Rot 13" gnus-summary-caesar-message
2457 ,@(if (featurep 'xemacs) '(t)
2458 '(:help "\"Caesar rotate\" article by 13"))]
01c52d31 2459 ["De-IDNA" gnus-summary-idna-message t]
23f87bed
MB
2460 ["Morse decode" gnus-summary-morse-message t]
2461 ["Unix pipe..." gnus-summary-pipe-message t]
2462 ["Add buttons" gnus-article-add-buttons t]
2463 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2464 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2465 ["Verbose header" gnus-summary-verbose-headers t]
2466 ["Toggle header" gnus-summary-toggle-header t]
2467 ["Unfold headers" gnus-article-treat-unfold-headers t]
2468 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
16409b0b 2469 ["Html" gnus-article-wash-html t]
23f87bed
MB
2470 ["Unsplit URLs" gnus-article-unsplit-urls t]
2471 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2472 ["Decode HZ" gnus-article-decode-HZ t]
01c52d31 2473 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
23f87bed
MB
2474 ("(Outlook) Deuglify"
2475 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2476 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2477 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2478 ["Full (Outlook) deuglify"
2479 gnus-article-outlook-deuglify-article t])
2480 )
2481 ("Output"
2482 ["Save in default format..." gnus-summary-save-article
2483 ,@(if (featurep 'xemacs) '(t)
2484 '(:help "Save article using default method"))]
2485 ["Save in file..." gnus-summary-save-article-file
2486 ,@(if (featurep 'xemacs) '(t)
2487 '(:help "Save article in file"))]
2488 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2489 ["Save in MH folder..." gnus-summary-save-article-folder t]
2490 ["Save in VM folder..." gnus-summary-save-article-vm t]
2491 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2492 ["Save body in file..." gnus-summary-save-article-body-file t]
2493 ["Pipe through a filter..." gnus-summary-pipe-output t]
23f87bed 2494 ["Print with Muttprint..." gnus-summary-muttprint t]
531e5812
MB
2495 ["Print" gnus-summary-print-article
2496 ,@(if (featurep 'xemacs) '(t)
2497 '(:help "Generate and print a PostScript image"))])
2498 ("Copy, move,... (Backend)"
707f2b38 2499 ,@(if (featurep 'xemacs) nil
531e5812 2500 '(:help "Copying, moving, expiring articles..."))
23f87bed
MB
2501 ["Respool article..." gnus-summary-respool-article t]
2502 ["Move article..." gnus-summary-move-article
2503 (gnus-check-backend-function
2504 'request-move-article gnus-newsgroup-name)]
2505 ["Copy article..." gnus-summary-copy-article t]
2506 ["Crosspost article..." gnus-summary-crosspost-article
2507 (gnus-check-backend-function
2508 'request-replace-article gnus-newsgroup-name)]
2509 ["Import file..." gnus-summary-import-article
2510 (gnus-check-backend-function
2511 'request-accept-article gnus-newsgroup-name)]
2512 ["Create article..." gnus-summary-create-article
2513 (gnus-check-backend-function
2514 'request-accept-article gnus-newsgroup-name)]
2515 ["Check if posted" gnus-summary-article-posted-p t]
2516 ["Edit article" gnus-summary-edit-article
2517 (not (gnus-group-read-only-p))]
2518 ["Delete article" gnus-summary-delete-article
2519 (gnus-check-backend-function
2520 'request-expire-articles gnus-newsgroup-name)]
2521 ["Query respool" gnus-summary-respool-query t]
6748645f 2522 ["Trace respool" gnus-summary-respool-trace t]
23f87bed
MB
2523 ["Delete expirable articles" gnus-summary-expire-articles-now
2524 (gnus-check-backend-function
2525 'request-expire-articles gnus-newsgroup-name)])
2526 ("Extract"
2527 ["Uudecode" gnus-uu-decode-uu
2528 ,@(if (featurep 'xemacs) '(t)
2529 '(:help "Decode uuencoded article(s)"))]
2530 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2531 ["Unshar" gnus-uu-decode-unshar t]
2532 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2533 ["Save" gnus-uu-decode-save t]
2534 ["Binhex" gnus-uu-decode-binhex t]
2535 ["Postscript" gnus-uu-decode-postscript t]
2536 ["All MIME parts" gnus-summary-save-parts t])
2537 ("Cache"
2538 ["Enter article" gnus-cache-enter-article t]
2539 ["Remove article" gnus-cache-remove-article t])
16409b0b 2540 ["Translate" gnus-article-babel t]
23f87bed 2541 ["Select article buffer" gnus-summary-select-article-buffer t]
01c52d31 2542 ["Make article buffer sticky" gnus-sticky-article t]
23f87bed
MB
2543 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2544 ["Isearch article..." gnus-summary-isearch-article t]
2545 ["Beginning of the article" gnus-summary-beginning-of-article t]
2546 ["End of the article" gnus-summary-end-of-article t]
2547 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2548 ["Fetch referenced articles" gnus-summary-refer-references t]
2549 ["Fetch current thread" gnus-summary-refer-thread t]
2550 ["Fetch article with id..." gnus-summary-refer-article t]
2551 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2552 ["Redisplay" gnus-summary-show-article t]
2553 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
6748645f 2554 (easy-menu-define
23f87bed
MB
2555 gnus-summary-article-menu gnus-summary-mode-map ""
2556 (cons "Article" innards))
6748645f 2557
1653df0f
SZ
2558 (if (not (keymapp gnus-summary-article-menu))
2559 (easy-menu-define
2560 gnus-article-commands-menu gnus-article-mode-map ""
2561 (cons "Commands" innards))
2562 ;; in Emacs, don't share menu.
a1506d29 2563 (setq gnus-article-commands-menu
1653df0f
SZ
2564 (copy-keymap gnus-summary-article-menu))
2565 (define-key gnus-article-mode-map [menu-bar commands]
2566 (cons "Commands" gnus-article-commands-menu))))
eec82323
LMI
2567
2568 (easy-menu-define
23f87bed
MB
2569 gnus-summary-thread-menu gnus-summary-mode-map ""
2570 '("Threads"
2571 ["Find all messages in thread" gnus-summary-refer-thread t]
2572 ["Toggle threading" gnus-summary-toggle-threads t]
2573 ["Hide threads" gnus-summary-hide-all-threads t]
2574 ["Show threads" gnus-summary-show-all-threads t]
2575 ["Hide thread" gnus-summary-hide-thread t]
2576 ["Show thread" gnus-summary-show-thread t]
2577 ["Go to next thread" gnus-summary-next-thread t]
2578 ["Go to previous thread" gnus-summary-prev-thread t]
2579 ["Go down thread" gnus-summary-down-thread t]
2580 ["Go up thread" gnus-summary-up-thread t]
2581 ["Top of thread" gnus-summary-top-thread t]
2582 ["Mark thread as read" gnus-summary-kill-thread t]
01c52d31 2583 ["Mark thread as expired" gnus-summary-expire-thread t]
23f87bed
MB
2584 ["Lower thread score" gnus-summary-lower-thread t]
2585 ["Raise thread score" gnus-summary-raise-thread t]
2586 ["Rethread current" gnus-summary-rethread-current t]))
eec82323
LMI
2587
2588 (easy-menu-define
23f87bed
MB
2589 gnus-summary-post-menu gnus-summary-mode-map ""
2590 `("Post"
2591 ["Send a message (mail or news)" gnus-summary-post-news
2592 ,@(if (featurep 'xemacs) '(t)
531e5812 2593 '(:help "Compose a new message (mail or news)"))]
23f87bed
MB
2594 ["Followup" gnus-summary-followup
2595 ,@(if (featurep 'xemacs) '(t)
2596 '(:help "Post followup to this article"))]
2597 ["Followup and yank" gnus-summary-followup-with-original
2598 ,@(if (featurep 'xemacs) '(t)
2599 '(:help "Post followup to this article, quoting its contents"))]
2600 ["Supersede article" gnus-summary-supersede-article t]
2601 ["Cancel article" gnus-summary-cancel-article
2602 ,@(if (featurep 'xemacs) '(t)
2603 '(:help "Cancel an article you posted"))]
2604 ["Reply" gnus-summary-reply t]
2605 ["Reply and yank" gnus-summary-reply-with-original t]
2606 ["Wide reply" gnus-summary-wide-reply t]
2607 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2608 ,@(if (featurep 'xemacs) '(t)
2609 '(:help "Mail a reply, quoting this article"))]
2610 ["Very wide reply" gnus-summary-very-wide-reply t]
2611 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2612 ,@(if (featurep 'xemacs) '(t)
2613 '(:help "Mail a very wide reply, quoting this article"))]
2614 ["Mail forward" gnus-summary-mail-forward t]
2615 ["Post forward" gnus-summary-post-forward t]
2616 ["Digest and mail" gnus-uu-digest-mail-forward t]
2617 ["Digest and post" gnus-uu-digest-post-forward t]
2618 ["Resend message" gnus-summary-resend-message t]
2619 ["Resend message edit" gnus-summary-resend-message-edit t]
2620 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2621 ["Send a mail" gnus-summary-mail-other-window t]
2622 ["Create a local message" gnus-summary-news-other-window t]
2623 ["Uuencode and post" gnus-uu-post-news
2624 ,@(if (featurep 'xemacs) '(t)
2625 '(:help "Post a uuencoded article"))]
2626 ["Followup via news" gnus-summary-followup-to-mail t]
2627 ["Followup via news and yank"
2628 gnus-summary-followup-to-mail-with-original t]
9b3ebcb6
MB
2629 ["Strip signature on reply"
2630 (lambda ()
2631 (interactive)
2632 (if (not (memq message-cite-function
2633 '(message-cite-original-without-signature
2634 message-cite-original)))
2635 ;; Stupid workaround for XEmacs not honoring :visible.
2636 (message "Can't toggle this value of `message-cite-function'")
2637 (setq message-cite-function
2638 (if (eq message-cite-function
2639 'message-cite-original-without-signature)
2640 'message-cite-original
2641 'message-cite-original-without-signature))))
2642 ;; XEmacs barfs on :visible.
2643 ,@(if (featurep 'xemacs) nil
2644 '(:visible (memq message-cite-function
2645 '(message-cite-original-without-signature
2646 message-cite-original))))
2647 :style toggle
2648 :selected (eq message-cite-function
2649 'message-cite-original-without-signature)
2650 ,@(if (featurep 'xemacs) nil
2651 '(:help "Strip signature from cited article when replying."))]
23f87bed
MB
2652 ;;("Draft"
2653 ;;["Send" gnus-summary-send-draft t]
2654 ;;["Send bounced" gnus-resend-bounced-mail t])
2655 ))
2656
2657 (cond
2658 ((not (keymapp gnus-summary-post-menu))
2659 (setq gnus-article-post-menu gnus-summary-post-menu))
2660 ((not gnus-article-post-menu)
2661 ;; Don't share post menu.
2662 (setq gnus-article-post-menu
2663 (copy-keymap gnus-summary-post-menu))))
2664 (define-key gnus-article-mode-map [menu-bar post]
2665 (cons "Post" gnus-article-post-menu))
eec82323
LMI
2666
2667 (easy-menu-define
23f87bed
MB
2668 gnus-summary-misc-menu gnus-summary-mode-map ""
2669 `("Gnus"
2670 ("Mark Read"
2671 ["Mark as read" gnus-summary-mark-as-read-forward t]
2672 ["Mark same subject and select"
2673 gnus-summary-kill-same-subject-and-select t]
2674 ["Mark same subject" gnus-summary-kill-same-subject t]
2675 ["Catchup" gnus-summary-catchup
2676 ,@(if (featurep 'xemacs) '(t)
2677 '(:help "Mark unread articles in this group as read"))]
2678 ["Catchup all" gnus-summary-catchup-all t]
2679 ["Catchup to here" gnus-summary-catchup-to-here t]
2680 ["Catchup from here" gnus-summary-catchup-from-here t]
2681 ["Catchup region" gnus-summary-mark-region-as-read
2682 (gnus-mark-active-p)]
2683 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2684 ("Mark Various"
2685 ["Tick" gnus-summary-tick-article-forward t]
2686 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2687 ["Remove marks" gnus-summary-clear-mark-forward t]
2688 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2689 ["Set bookmark" gnus-summary-set-bookmark t]
2690 ["Remove bookmark" gnus-summary-remove-bookmark t])
2691 ("Limit to"
2692 ["Marks..." gnus-summary-limit-to-marks t]
2693 ["Subject..." gnus-summary-limit-to-subject t]
2694 ["Author..." gnus-summary-limit-to-author t]
01c52d31
MB
2695 ["Recipient..." gnus-summary-limit-to-recipient t]
2696 ["Address..." gnus-summary-limit-to-address t]
23f87bed
MB
2697 ["Age..." gnus-summary-limit-to-age t]
2698 ["Extra..." gnus-summary-limit-to-extra t]
2699 ["Score..." gnus-summary-limit-to-score t]
2700 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2701 ["Unread" gnus-summary-limit-to-unread t]
2702 ["Unseen" gnus-summary-limit-to-unseen t]
01c52d31
MB
2703 ["Singletons" gnus-summary-limit-to-singletons t]
2704 ["Replied" gnus-summary-limit-to-replied t]
23f87bed 2705 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
996aa8c1 2706 ["Next or process marked articles" gnus-summary-limit-to-articles t]
23f87bed
MB
2707 ["Pop limit" gnus-summary-pop-limit t]
2708 ["Show dormant" gnus-summary-limit-include-dormant t]
2709 ["Hide childless dormant"
2710 gnus-summary-limit-exclude-childless-dormant t]
2711 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2712 ["Hide marked" gnus-summary-limit-exclude-marks t]
2713 ["Show expunged" gnus-summary-limit-include-expunged t])
2714 ("Process Mark"
2715 ["Set mark" gnus-summary-mark-as-processable t]
2716 ["Remove mark" gnus-summary-unmark-as-processable t]
2717 ["Remove all marks" gnus-summary-unmark-all-processable t]
01c52d31 2718 ["Invert marks" gnus-uu-invert-processable t]
23f87bed
MB
2719 ["Mark above" gnus-uu-mark-over t]
2720 ["Mark series" gnus-uu-mark-series t]
2721 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2722 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2723 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2724 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2725 ["Mark all" gnus-uu-mark-all t]
2726 ["Mark buffer" gnus-uu-mark-buffer t]
2727 ["Mark sparse" gnus-uu-mark-sparse t]
2728 ["Mark thread" gnus-uu-mark-thread t]
2729 ["Unmark thread" gnus-uu-unmark-thread t]
2730 ("Process Mark Sets"
2731 ["Kill" gnus-summary-kill-process-mark t]
2732 ["Yank" gnus-summary-yank-process-mark
2733 gnus-newsgroup-process-stack]
2734 ["Save" gnus-summary-save-process-mark t]
2735 ["Run command on marked..." gnus-summary-universal-argument t]))
ec7995fa 2736 ("Registry Marks")
23f87bed
MB
2737 ("Scroll article"
2738 ["Page forward" gnus-summary-next-page
2739 ,@(if (featurep 'xemacs) '(t)
2740 '(:help "Show next page of article"))]
2741 ["Page backward" gnus-summary-prev-page
2742 ,@(if (featurep 'xemacs) '(t)
2743 '(:help "Show previous page of article"))]
2744 ["Line forward" gnus-summary-scroll-up t])
2745 ("Move"
2746 ["Next unread article" gnus-summary-next-unread-article t]
2747 ["Previous unread article" gnus-summary-prev-unread-article t]
2748 ["Next article" gnus-summary-next-article t]
2749 ["Previous article" gnus-summary-prev-article t]
2750 ["Next unread subject" gnus-summary-next-unread-subject t]
2751 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2752 ["Next article same subject" gnus-summary-next-same-subject t]
2753 ["Previous article same subject" gnus-summary-prev-same-subject t]
2754 ["First unread article" gnus-summary-first-unread-article t]
2755 ["Best unread article" gnus-summary-best-unread-article t]
2756 ["Go to subject number..." gnus-summary-goto-subject t]
2757 ["Go to article number..." gnus-summary-goto-article t]
2758 ["Go to the last article" gnus-summary-goto-last-article t]
2759 ["Pop article off history" gnus-summary-pop-article t])
2760 ("Sort"
2761 ["Sort by number" gnus-summary-sort-by-number t]
6ecfe5c2 2762 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
23f87bed 2763 ["Sort by author" gnus-summary-sort-by-author t]
01c52d31 2764 ["Sort by recipient" gnus-summary-sort-by-recipient t]
23f87bed
MB
2765 ["Sort by subject" gnus-summary-sort-by-subject t]
2766 ["Sort by date" gnus-summary-sort-by-date t]
6ecfe5c2 2767 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
23f87bed
MB
2768 ["Sort by score" gnus-summary-sort-by-score t]
2769 ["Sort by lines" gnus-summary-sort-by-lines t]
2770 ["Sort by characters" gnus-summary-sort-by-chars t]
2771 ["Randomize" gnus-summary-sort-by-random t]
2772 ["Original sort" gnus-summary-sort-by-original t])
2773 ("Help"
23f87bed 2774 ["Describe group" gnus-summary-describe-group t]
23f87bed
MB
2775 ["Read manual" gnus-info-find-node t])
2776 ("Modes"
2777 ["Pick and read" gnus-pick-mode t]
2778 ["Binary" gnus-binary-mode t])
2779 ("Regeneration"
2780 ["Regenerate" gnus-summary-prepare t]
2781 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2782 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
01c52d31 2783 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
23f87bed
MB
2784 ["Toggle threading" gnus-summary-toggle-threads t])
2785 ["See old articles" gnus-summary-insert-old-articles t]
2786 ["See new articles" gnus-summary-insert-new-articles t]
2787 ["Filter articles..." gnus-summary-execute-command t]
2788 ["Run command on articles..." gnus-summary-universal-argument t]
2789 ["Search articles forward..." gnus-summary-search-article-forward t]
2790 ["Search articles backward..." gnus-summary-search-article-backward t]
2791 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2792 ["Expand window" gnus-summary-expand-window t]
2793 ["Expire expirable articles" gnus-summary-expire-articles
2794 (gnus-check-backend-function
2795 'request-expire-articles gnus-newsgroup-name)]
2796 ["Edit local kill file" gnus-summary-edit-local-kill t]
2797 ["Edit main kill file" gnus-summary-edit-global-kill t]
2798 ["Edit group parameters" gnus-summary-edit-parameters t]
2799 ["Customize group parameters" gnus-summary-customize-parameters t]
2800 ["Send a bug report" gnus-bug t]
2801 ("Exit"
2802 ["Catchup and exit" gnus-summary-catchup-and-exit
2803 ,@(if (featurep 'xemacs) '(t)
2804 '(:help "Mark unread articles in this group as read, then exit"))]
2805 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2806 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
01c52d31 2807 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
23f87bed
MB
2808 ["Exit group" gnus-summary-exit
2809 ,@(if (featurep 'xemacs) '(t)
2810 '(:help "Exit current group, return to group selection mode"))]
2811 ["Exit group without updating" gnus-summary-exit-no-update t]
2812 ["Exit and goto next group" gnus-summary-next-group t]
2813 ["Exit and goto prev group" gnus-summary-prev-group t]
2814 ["Reselect group" gnus-summary-reselect-current-group t]
2815 ["Rescan group" gnus-summary-rescan-group t]
2816 ["Update dribble" gnus-summary-save-newsrc t])))
eec82323 2817
6748645f 2818 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323 2819
60bd5589
DL
2820(defvar gnus-summary-tool-bar-map nil)
2821
18c06a99
RS
2822;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2823;; affect _new_ message buffers. We might add a function that walks thru all
2824;; summary-mode buffers and force the update.
2825(defun gnus-summary-tool-bar-update (&optional symbol value)
2826 "Update summary mode toolbar.
2827Setter function for custom variables."
2828 (setq-default gnus-summary-tool-bar-map nil)
2829 (when symbol
2830 ;; When used as ":set" function:
2831 (set-default symbol value))
2832 (when (gnus-buffer-live-p gnus-summary-buffer)
2833 (with-current-buffer gnus-summary-buffer
2834 (gnus-summary-make-tool-bar))))
2835
2836(defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2837 'gnus-summary-tool-bar-gnome
2838 'gnus-summary-tool-bar-retro)
2839 "Specifies the Gnus summary tool bar.
2840
2841It can be either a list or a symbol refering to a list. See
2842`gmm-tool-bar-from-list' for the format of the list. The
2843default key map is `gnus-summary-mode-map'.
2844
2845Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2846`gnus-summary-tool-bar-retro'."
2847 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2848 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2849 (repeat :tag "User defined list" gmm-tool-bar-item)
2850 (symbol))
330f707b 2851 :version "23.1" ;; No Gnus
18c06a99
RS
2852 :initialize 'custom-initialize-default
2853 :set 'gnus-summary-tool-bar-update
2854 :group 'gnus-summary)
2855
2856(defcustom gnus-summary-tool-bar-gnome
2857 '((gnus-summary-post-news "mail/compose" nil)
2858 (gnus-summary-insert-new-articles "mail/inbox" nil
2859 :visible (or (not gnus-agent)
2860 gnus-plugged))
2861 (gnus-summary-reply-with-original "mail/reply")
2862 (gnus-summary-reply "mail/reply" nil :visible nil)
2863 (gnus-summary-followup-with-original "mail/reply-all")
2864 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2865 (gnus-summary-mail-forward "mail/forward")
2866 (gnus-summary-save-article "mail/save")
2867 (gnus-summary-search-article-forward "search" nil :visible nil)
2868 (gnus-summary-print-article "print")
2869 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2870 ;; Some new commands that may need more suitable icons:
2871 (gnus-summary-save-newsrc "save" nil :visible nil)
2872 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2873 (gnus-summary-prev-article "left-arrow")
2874 (gnus-summary-next-article "right-arrow")
2875 (gnus-summary-next-page "next-page")
2876 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2877 ;;
2878 ;; Maybe some sort-by-... could be added:
2879 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2880 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2881 (gnus-summary-mark-as-expirable
2882 "delete" nil
2883 :visible (gnus-check-backend-function 'request-expire-articles
2884 gnus-newsgroup-name))
2885 (gnus-summary-mark-as-spam
2886 "mail/spam" t
2887 :visible (and (fboundp 'spam-group-ham-contents-p)
2888 (spam-group-ham-contents-p gnus-newsgroup-name))
2889 :help "Mark as spam")
2890 (gnus-summary-mark-as-read-forward
2891 "mail/not-spam" nil
2892 :visible (and (fboundp 'spam-group-spam-contents-p)
2893 (spam-group-spam-contents-p gnus-newsgroup-name)))
2894 ;;
2895 (gnus-summary-exit "exit")
2896 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2897 (gnus-info-find-node "help"))
2898 "List of functions for the summary tool bar (GNOME style).
2899
2900See `gmm-tool-bar-from-list' for the format of the list."
2901 :type '(repeat gmm-tool-bar-item)
330f707b 2902 :version "23.1" ;; No Gnus
18c06a99
RS
2903 :initialize 'custom-initialize-default
2904 :set 'gnus-summary-tool-bar-update
2905 :group 'gnus-summary)
2906
2907(defcustom gnus-summary-tool-bar-retro
2908 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2909 (gnus-summary-next-unread-article "gnus/next-ur")
2910 (gnus-summary-post-news "gnus/post")
2911 (gnus-summary-followup-with-original "gnus/fuwo")
2912 (gnus-summary-followup "gnus/followup")
2913 (gnus-summary-reply-with-original "gnus/reply-wo")
2914 (gnus-summary-reply "gnus/reply")
2915 (gnus-summary-caesar-message "gnus/rot13")
2916 (gnus-uu-decode-uu "gnus/uu-decode")
2917 (gnus-summary-save-article-file "gnus/save-aif")
2918 (gnus-summary-save-article "gnus/save-art")
2919 (gnus-uu-post-news "gnus/uu-post")
2920 (gnus-summary-catchup "gnus/catchup")
2921 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2922 (gnus-summary-exit "gnus/exit-summ")
2923 ;; Some new command that may need more suitable icons:
2924 (gnus-summary-print-article "gnus/print" nil :visible nil)
2925 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2926 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2927 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2928 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2929 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2930 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2931 ;;
2932 (gnus-info-find-node "gnus/help" nil :visible nil))
2933 "List of functions for the summary tool bar (retro look).
2934
2935See `gmm-tool-bar-from-list' for the format of the list."
2936 :type '(repeat gmm-tool-bar-item)
330f707b 2937 :version "23.1" ;; No Gnus
18c06a99
RS
2938 :initialize 'custom-initialize-default
2939 :set 'gnus-summary-tool-bar-update
2940 :group 'gnus-summary)
2941
2942(defcustom gnus-summary-tool-bar-zap-list t
2943 "List of icon items from the global tool bar.
2944These items are not displayed in the Gnus summary mode tool bar.
2945
2946See `gmm-tool-bar-from-list' for the format of the list."
2947 :type 'gmm-tool-bar-zap-list
330f707b 2948 :version "23.1" ;; No Gnus
18c06a99
RS
2949 :initialize 'custom-initialize-default
2950 :set 'gnus-summary-tool-bar-update
2951 :group 'gnus-summary)
2952
2953(defvar image-load-path)
f654fa04 2954(defvar tool-bar-map)
18c06a99
RS
2955
2956(defun gnus-summary-make-tool-bar (&optional force)
2957 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2958When FORCE, rebuild the tool bar."
2959 (when (and (not (featurep 'xemacs))
2960 (boundp 'tool-bar-mode)
2961 tool-bar-mode
2962 (or (not gnus-summary-tool-bar-map) force))
2963 (let* ((load-path
2964 (gmm-image-load-path-for-library "gnus"
2965 "mail/save.xpm"
2966 nil t))
2967 (image-load-path (cons (car load-path)
2968 (when (boundp 'image-load-path)
2969 image-load-path)))
2970 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2971 gnus-summary-tool-bar-zap-list
2972 'gnus-summary-mode-map)))
2973 (when map
2974 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2975 ;; uses it's value.
2976 (setq gnus-summary-tool-bar-map map))))
2977 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
60bd5589 2978
eec82323
LMI
2979(defun gnus-score-set-default (var value)
2980 "A version of set that updates the GNU Emacs menu-bar."
2981 (set var value)
2982 ;; It is the message that forces the active status to be updated.
2983 (message ""))
2984
2985(defun gnus-make-score-map (type)
2986 "Make a summary score map of type TYPE."
2987 (if t
2988 nil
2989 (let ((headers '(("author" "from" string)
2990 ("subject" "subject" string)
2991 ("article body" "body" string)
2992 ("article head" "head" string)
2993 ("xref" "xref" string)
16409b0b 2994 ("extra header" "extra" string)
eec82323
LMI
2995 ("lines" "lines" number)
2996 ("followups to author" "followup" string)))
2997 (types '((number ("less than" <)
2998 ("greater than" >)
2999 ("equal" =))
3000 (string ("substring" s)
3001 ("exact string" e)
3002 ("fuzzy string" f)
3003 ("regexp" r))))
3004 (perms '(("temporary" (current-time-string))
3005 ("permanent" nil)
3006 ("immediate" now)))
3007 header)
3008 (list
3009 (apply
3010 'nconc
3011 (list
3012 (if (eq type 'lower)
3013 "Lower score"
3014 "Increase score"))
3015 (let (outh)
3016 (while headers
3017 (setq header (car headers))
3018 (setq outh
3019 (cons
3020 (apply
3021 'nconc
3022 (list (car header))
3023 (let ((ts (cdr (assoc (nth 2 header) types)))
3024 outt)
3025 (while ts
3026 (setq outt
3027 (cons
3028 (apply
3029 'nconc
3030 (list (caar ts))
3031 (let ((ps perms)
3032 outp)
3033 (while ps
3034 (setq outp
3035 (cons
3036 (vector
3037 (caar ps)
3038 (list
3039 'gnus-summary-score-entry
3040 (nth 1 header)
3041 (if (or (string= (nth 1 header)
3042 "head")
3043 (string= (nth 1 header)
3044 "body"))
3045 ""
3046 (list 'gnus-summary-header
3047 (nth 1 header)))
3048 (list 'quote (nth 1 (car ts)))
16409b0b
GM
3049 (list 'gnus-score-delta-default
3050 nil)
eec82323
LMI
3051 (nth 1 (car ps))
3052 t)
3053 t)
3054 outp))
3055 (setq ps (cdr ps)))
3056 (list (nreverse outp))))
3057 outt))
3058 (setq ts (cdr ts)))
3059 (list (nreverse outt))))
3060 outh))
3061 (setq headers (cdr headers)))
3062 (list (nreverse outh))))))))
3063
704f1663
GM
3064
3065(declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
398a825b 3066(defvar bookmark-make-record-function)
eec82323
LMI
3067\f
3068
3069(defun gnus-summary-mode (&optional group)
3070 "Major mode for reading articles.
3071
3072All normal editing commands are switched off.
3073\\<gnus-summary-mode-map>
3074Each line in this buffer represents one article. To read an
3075article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3076and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3077respectively.
3078
3079You can also post articles and send mail from this buffer. To
23f87bed 3080follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
eec82323
LMI
3081of an article, type `\\[gnus-summary-reply]'.
3082
3083There are approx. one gazillion commands you can execute in this
3084buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3085
3086The following commands are available:
3087
3088\\{gnus-summary-mode-map}"
3089 (interactive)
eec82323 3090 (kill-all-local-variables)
01c52d31
MB
3091 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3092 (gnus-summary-make-local-variables))
3093 (gnus-summary-make-local-variables)
3094 (setq gnus-newsgroup-name group)
60bd5589
DL
3095 (when (gnus-visual-p 'summary-menu 'menu)
3096 (gnus-summary-make-menu-bar)
3097 (gnus-summary-make-tool-bar))
eec82323
LMI
3098 (gnus-make-thread-indent-array)
3099 (gnus-simplify-mode-line)
3100 (setq major-mode 'gnus-summary-mode)
3101 (setq mode-name "Summary")
eec82323 3102 (use-local-map gnus-summary-mode-map)
16409b0b 3103 (buffer-disable-undo)
01c52d31
MB
3104 (setq buffer-read-only t ;Disable modification
3105 show-trailing-whitespace nil)
eec82323 3106 (setq truncate-lines t)
9bfd9a76 3107 (add-to-invisibility-spec '(gnus-sum . t))
eec82323
LMI
3108 (gnus-summary-set-display-table)
3109 (gnus-set-default-directory)
eec82323
LMI
3110 (make-local-variable 'gnus-summary-line-format)
3111 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
3112 (make-local-variable 'gnus-summary-dummy-line-format)
3113 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323 3114 (make-local-variable 'gnus-summary-mark-positions)
23f87bed 3115 (gnus-make-local-hook 'pre-command-hook)
6748645f 3116 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
cfcd5c91 3117 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
23f87bed 3118 (turn-on-gnus-mailing-list-mode)
87545352 3119 (mm-enable-multibyte)
45be326a
TV
3120 (set (make-local-variable 'bookmark-make-record-function)
3121 'gnus-summary-bookmark-make-record)
eec82323
LMI
3122 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3123 (gnus-update-summary-mark-positions))
3124
3125(defun gnus-summary-make-local-variables ()
3126 "Make all the local summary buffer variables."
16409b0b
GM
3127 (let (global)
3128 (dolist (local gnus-summary-local-variables)
eec82323
LMI
3129 (if (consp local)
3130 (progn
3131 (if (eq (cdr local) 'global)
3132 ;; Copy the global value of the variable.
3133 (setq global (symbol-value (car local)))
3134 ;; Use the value from the list.
3135 (setq global (eval (cdr local))))
16409b0b 3136 (set (make-local-variable (car local)) global))
eec82323 3137 ;; Simple nil-valued local variable.
16409b0b 3138 (set (make-local-variable local) nil)))))
eec82323 3139
eec82323
LMI
3140;; Summary data functions.
3141
3142(defmacro gnus-data-number (data)
3143 `(car ,data))
3144
3145(defmacro gnus-data-set-number (data number)
3146 `(setcar ,data ,number))
3147
3148(defmacro gnus-data-mark (data)
3149 `(nth 1 ,data))
3150
3151(defmacro gnus-data-set-mark (data mark)
3152 `(setcar (nthcdr 1 ,data) ,mark))
3153
3154(defmacro gnus-data-pos (data)
3155 `(nth 2 ,data))
3156
3157(defmacro gnus-data-set-pos (data pos)
3158 `(setcar (nthcdr 2 ,data) ,pos))
3159
3160(defmacro gnus-data-header (data)
3161 `(nth 3 ,data))
3162
3163(defmacro gnus-data-set-header (data header)
3164 `(setf (nth 3 ,data) ,header))
3165
3166(defmacro gnus-data-level (data)
3167 `(nth 4 ,data))
3168
3169(defmacro gnus-data-unread-p (data)
3170 `(= (nth 1 ,data) gnus-unread-mark))
3171
3172(defmacro gnus-data-read-p (data)
3173 `(/= (nth 1 ,data) gnus-unread-mark))
3174
3175(defmacro gnus-data-pseudo-p (data)
3176 `(consp (nth 3 ,data)))
3177
3178(defmacro gnus-data-find (number)
3179 `(assq ,number gnus-newsgroup-data))
3180
3181(defmacro gnus-data-find-list (number &optional data)
3182 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3183 (memq (assq ,number bdata)
3184 bdata)))
3185
3186(defmacro gnus-data-make (number mark pos header level)
3187 `(list ,number ,mark ,pos ,header ,level))
3188
3189(defun gnus-data-enter (after-article number mark pos header level offset)
3190 (let ((data (gnus-data-find-list after-article)))
3191 (unless data
3192 (error "No such article: %d" after-article))
3193 (setcdr data (cons (gnus-data-make number mark pos header level)
3194 (cdr data)))
3195 (setq gnus-newsgroup-data-reverse nil)
3196 (gnus-data-update-list (cddr data) offset)))
3197
3198(defun gnus-data-enter-list (after-article list &optional offset)
3199 (when list
3200 (let ((data (and after-article (gnus-data-find-list after-article)))
3201 (ilist list))
6748645f
LMI
3202 (if (not (or data
3203 after-article))
3204 (let ((odata gnus-newsgroup-data))
3205 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 3206 (when offset
6748645f 3207 (gnus-data-update-list odata offset)))
01c52d31 3208 ;; Find the last element in the list to be spliced into the main
6748645f 3209 ;; list.
01c52d31 3210 (setq list (last list))
6748645f
LMI
3211 (if (not data)
3212 (progn
3213 (setcdr list gnus-newsgroup-data)
3214 (setq gnus-newsgroup-data ilist)
3215 (when offset
3216 (gnus-data-update-list (cdr list) offset)))
3217 (setcdr list (cdr data))
3218 (setcdr data ilist)
3219 (when offset
3220 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
3221 (setq gnus-newsgroup-data-reverse nil))))
3222
3223(defun gnus-data-remove (article &optional offset)
3224 (let ((data gnus-newsgroup-data))
3225 (if (= (gnus-data-number (car data)) article)
3226 (progn
3227 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3228 gnus-newsgroup-data-reverse nil)
3229 (when offset
3230 (gnus-data-update-list gnus-newsgroup-data offset)))
3231 (while (cdr data)
3232 (when (= (gnus-data-number (cadr data)) article)
3233 (setcdr data (cddr data))
3234 (when offset
3235 (gnus-data-update-list (cdr data) offset))
3236 (setq data nil
3237 gnus-newsgroup-data-reverse nil))
3238 (setq data (cdr data))))))
3239
3240(defmacro gnus-data-list (backward)
3241 `(if ,backward
3242 (or gnus-newsgroup-data-reverse
3243 (setq gnus-newsgroup-data-reverse
3244 (reverse gnus-newsgroup-data)))
3245 gnus-newsgroup-data))
3246
3247(defun gnus-data-update-list (data offset)
3248 "Add OFFSET to the POS of all data entries in DATA."
6748645f 3249 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
3250 (while data
3251 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3252 (setq data (cdr data))))
3253
eec82323
LMI
3254(defun gnus-summary-article-pseudo-p (article)
3255 "Say whether this article is a pseudo article or not."
3256 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3257
3258(defmacro gnus-summary-article-sparse-p (article)
3259 "Say whether this article is a sparse article or not."
a8151ef7 3260 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
3261
3262(defmacro gnus-summary-article-ancient-p (article)
3263 "Say whether this article is a sparse article or not."
3264 `(memq ,article gnus-newsgroup-ancient))
3265
3266(defun gnus-article-parent-p (number)
3267 "Say whether this article is a parent or not."
3268 (let ((data (gnus-data-find-list number)))
23f87bed 3269 (and (cdr data) ; There has to be an article after...
eec82323
LMI
3270 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3271 (gnus-data-level (nth 1 data))))))
3272
3273(defun gnus-article-children (number)
3274 "Return a list of all children to NUMBER."
3275 (let* ((data (gnus-data-find-list number))
3276 (level (gnus-data-level (car data)))
3277 children)
3278 (setq data (cdr data))
3279 (while (and data
3280 (= (gnus-data-level (car data)) (1+ level)))
3281 (push (gnus-data-number (car data)) children)
3282 (setq data (cdr data)))
3283 children))
3284
3285(defmacro gnus-summary-skip-intangible ()
3286 "If the current article is intangible, then jump to a different article."
3287 '(let ((to (get-text-property (point) 'gnus-intangible)))
3288 (and to (gnus-summary-goto-subject to))))
3289
3290(defmacro gnus-summary-article-intangible-p ()
3291 "Say whether this article is intangible or not."
3292 '(get-text-property (point) 'gnus-intangible))
3293
3294(defun gnus-article-read-p (article)
3295 "Say whether ARTICLE is read or not."
3296 (not (or (memq article gnus-newsgroup-marked)
23f87bed 3297 (memq article gnus-newsgroup-spam-marked)
eec82323
LMI
3298 (memq article gnus-newsgroup-unreads)
3299 (memq article gnus-newsgroup-unselected)
3300 (memq article gnus-newsgroup-dormant))))
3301
3302;; Some summary mode macros.
3303
3304(defmacro gnus-summary-article-number ()
3305 "The article number of the article on the current line.
8f688cb0 3306If there isn't an article number here, then we return the current
eec82323
LMI
3307article number."
3308 '(progn
3309 (gnus-summary-skip-intangible)
3310 (or (get-text-property (point) 'gnus-number)
3311 (gnus-summary-last-subject))))
3312
3313(defmacro gnus-summary-article-header (&optional number)
6748645f 3314 "Return the header of article NUMBER."
eec82323
LMI
3315 `(gnus-data-header (gnus-data-find
3316 ,(or number '(gnus-summary-article-number)))))
3317
3318(defmacro gnus-summary-thread-level (&optional number)
6748645f 3319 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
3320 `(if (and (eq gnus-summary-make-false-root 'dummy)
3321 (get-text-property (point) 'gnus-intangible))
3322 0
3323 (gnus-data-level (gnus-data-find
3324 ,(or number '(gnus-summary-article-number))))))
3325
3326(defmacro gnus-summary-article-mark (&optional number)
6748645f 3327 "Return the mark of article NUMBER."
eec82323
LMI
3328 `(gnus-data-mark (gnus-data-find
3329 ,(or number '(gnus-summary-article-number)))))
3330
3331(defmacro gnus-summary-article-pos (&optional number)
6748645f 3332 "Return the position of the line of article NUMBER."
eec82323
LMI
3333 `(gnus-data-pos (gnus-data-find
3334 ,(or number '(gnus-summary-article-number)))))
3335
3336(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3337(defmacro gnus-summary-article-subject (&optional number)
3338 "Return current subject string or nil if nothing."
3339 `(let ((headers
3340 ,(if number
3341 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3342 '(gnus-data-header (assq (gnus-summary-article-number)
3343 gnus-newsgroup-data)))))
3344 (and headers
3345 (vectorp headers)
3346 (mail-header-subject headers))))
3347
3348(defmacro gnus-summary-article-score (&optional number)
3349 "Return current article score."
3350 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3351 gnus-newsgroup-scored))
3352 gnus-summary-default-score 0))
3353
3354(defun gnus-summary-article-children (&optional number)
6748645f 3355 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
3356 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3357 (level (gnus-data-level (car data)))
3358 l children)
3359 (while (and (setq data (cdr data))
3360 (> (setq l (gnus-data-level (car data))) level))
3361 (and (= (1+ level) l)
3362 (push (gnus-data-number (car data))
3363 children)))
3364 (nreverse children)))
3365
3366(defun gnus-summary-article-parent (&optional number)
6748645f 3367 "Return the article number of the parent of article NUMBER."
eec82323
LMI
3368 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3369 (gnus-data-list t)))
3370 (level (gnus-data-level (car data))))
3371 (if (zerop level)
3372 () ; This is a root.
3373 ;; We search until we find an article with a level less than
3374 ;; this one. That function has to be the parent.
3375 (while (and (setq data (cdr data))
3376 (not (< (gnus-data-level (car data)) level))))
3377 (and data (gnus-data-number (car data))))))
3378
3379(defun gnus-unread-mark-p (mark)
3380 "Say whether MARK is the unread mark."
3381 (= mark gnus-unread-mark))
3382
3383(defun gnus-read-mark-p (mark)
3384 "Say whether MARK is one of the marks that mark as read.
3385This is all marks except unread, ticked, dormant, and expirable."
3386 (not (or (= mark gnus-unread-mark)
3387 (= mark gnus-ticked-mark)
23f87bed 3388 (= mark gnus-spam-mark)
eec82323
LMI
3389 (= mark gnus-dormant-mark)
3390 (= mark gnus-expirable-mark))))
3391
3392(defmacro gnus-article-mark (number)
6748645f
LMI
3393 "Return the MARK of article NUMBER.
3394This macro should only be used when computing the mark the \"first\"
3395time; i.e., when generating the summary lines. After that,
3396`gnus-summary-article-mark' should be used to examine the
3397marks of articles."
eec82323 3398 `(cond
6748645f 3399 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
6748645f 3400 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
3401 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3402 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
23f87bed 3403 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
eec82323
LMI
3404 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3405 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3406 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3407 gnus-ancient-mark))))
3408
3409;; Saving hidden threads.
3410
eec82323
LMI
3411(defmacro gnus-save-hidden-threads (&rest forms)
3412 "Save hidden threads, eval FORMS, and restore the hidden threads."
3413 (let ((config (make-symbol "config")))
3414 `(let ((,config (gnus-hidden-threads-configuration)))
3415 (unwind-protect
3416 (save-excursion
3417 ,@forms)
3418 (gnus-restore-hidden-threads-configuration ,config)))))
23f87bed
MB
3419(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3420(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
eec82323 3421
107ecebb
AS
3422(defun gnus-data-compute-positions ()
3423 "Compute the positions of all articles."
3424 (setq gnus-newsgroup-data-reverse nil)
3425 (let ((data gnus-newsgroup-data))
3426 (save-excursion
3427 (gnus-save-hidden-threads
3428 (gnus-summary-show-all-threads)
3429 (goto-char (point-min))
3430 (while data
3431 (while (get-text-property (point) 'gnus-intangible)
3432 (forward-line 1))
3433 (gnus-data-set-pos (car data) (+ (point) 3))
3434 (setq data (cdr data))
3435 (forward-line 1))))))
3436
16409b0b
GM
3437(defun gnus-hidden-threads-configuration ()
3438 "Return the current hidden threads configuration."
3439 (save-excursion
3440 (let (config)
3441 (goto-char (point-min))
62a83cc8
KY
3442 (while (not (eobp))
3443 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3444 (push (save-excursion (forward-line 0) (point)) config))
3445 (forward-line 1))
16409b0b
GM
3446 config)))
3447
3448(defun gnus-restore-hidden-threads-configuration (config)
3449 "Restore hidden threads configuration from CONFIG."
3450 (save-excursion
c7a91ce1 3451 (let (point (inhibit-read-only t))
16409b0b 3452 (while (setq point (pop config))
62a83cc8
KY
3453 (goto-char point)
3454 (gnus-summary-hide-thread)))))
16409b0b 3455
eec82323
LMI
3456;; Various summary mode internalish functions.
3457
3458(defun gnus-mouse-pick-article (e)
3459 (interactive "e")
3460 (mouse-set-point e)
3461 (gnus-summary-next-page nil t))
3462
3463(defun gnus-summary-set-display-table ()
16409b0b
GM
3464 "Change the display table.
3465Odd characters have a tendency to mess
3466up nicely formatted displays - we make all possible glyphs
3467display only a single character."
eec82323
LMI
3468
3469 ;; We start from the standard display table, if any.
3470 (let ((table (or (copy-sequence standard-display-table)
3471 (make-display-table)))
3472 (i 32))
3473 ;; Nix out all the control chars...
3474 (while (>= (setq i (1- i)) 0)
2b968687 3475 (gnus-put-display-table i [??] table))
23f87bed 3476 ;; ... but not newline and cr, of course. (cr is necessary for the
eec82323 3477 ;; selective display).
2b968687
MB
3478 (gnus-put-display-table ?\n nil table)
3479 (gnus-put-display-table ?\r nil table)
6748645f 3480 ;; We keep TAB as well.
2b968687 3481 (gnus-put-display-table ?\t nil table)
719120ef 3482 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
fe62aacc 3483 ;; Emacs 23 (unicode), that are not set already.
719120ef
MB
3484 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3485 160
3486 256)))
eec82323
LMI
3487 (while (>= (setq i (1- i)) 127)
3488 ;; Only modify if the entry is nil.
2b968687
MB
3489 (unless (gnus-get-display-table i table)
3490 (gnus-put-display-table i [??] table))))
eec82323
LMI
3491 (setq buffer-display-table table)))
3492
23f87bed
MB
3493(defun gnus-summary-set-article-display-arrow (pos)
3494 "Update the overlay arrow to point to line at position POS."
e3e955fe
MB
3495 (when gnus-summary-display-arrow
3496 (make-local-variable 'overlay-arrow-position)
3497 (make-local-variable 'overlay-arrow-string)
23f87bed
MB
3498 (save-excursion
3499 (goto-char pos)
3500 (beginning-of-line)
3501 (unless overlay-arrow-position
3502 (setq overlay-arrow-position (make-marker)))
3503 (setq overlay-arrow-string "=>"
3504 overlay-arrow-position (set-marker overlay-arrow-position
3505 (point)
3506 (current-buffer))))))
3507
eec82323
LMI
3508(defun gnus-summary-setup-buffer (group)
3509 "Initialize summary buffer."
23f87bed
MB
3510 (let ((buffer (gnus-summary-buffer-name group))
3511 (dead-name (concat "*Dead Summary "
3512 (gnus-group-decoded-name group) "*")))
3513 ;; If a dead summary buffer exists, we kill it.
3514 (when (gnus-buffer-live-p dead-name)
3515 (gnus-kill-buffer dead-name))
eec82323
LMI
3516 (if (get-buffer buffer)
3517 (progn
3518 (set-buffer buffer)
3519 (setq gnus-summary-buffer (current-buffer))
3520 (not gnus-newsgroup-prepared))
3521 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 3522 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323 3523 (gnus-summary-mode group)
01c52d31
MB
3524 (when (gnus-group-quit-config group)
3525 (set (make-local-variable 'gnus-single-article-buffer) nil))
3526 (make-local-variable 'gnus-article-buffer)
3527 (make-local-variable 'gnus-article-current)
3528 (make-local-variable 'gnus-original-article-buffer)
eec82323 3529 (setq gnus-newsgroup-name group)
23f87bed
MB
3530 ;; Set any local variables in the group parameters.
3531 (gnus-summary-set-local-parameters gnus-newsgroup-name)
eec82323
LMI
3532 t)))
3533
3534(defun gnus-set-global-variables ()
16409b0b
GM
3535 "Set the global equivalents of the buffer-local variables.
3536They are set to the latest values they had. These reflect the summary
3537buffer that was in action when the last article was fetched."
eec82323
LMI
3538 (when (eq major-mode 'gnus-summary-mode)
3539 (setq gnus-summary-buffer (current-buffer))
3540 (let ((name gnus-newsgroup-name)
3541 (marked gnus-newsgroup-marked)
23f87bed 3542 (spam gnus-newsgroup-spam-marked)
eec82323
LMI
3543 (unread gnus-newsgroup-unreads)
3544 (headers gnus-current-headers)
3545 (data gnus-newsgroup-data)
3546 (summary gnus-summary-buffer)
3547 (article-buffer gnus-article-buffer)
3548 (original gnus-original-article-buffer)
3549 (gac gnus-article-current)
3550 (reffed gnus-reffed-article-number)
16409b0b 3551 (score-file gnus-current-score-file)
23f87bed
MB
3552 (default-charset gnus-newsgroup-charset)
3553 vlist)
3554 (let ((locals gnus-newsgroup-variables))
3555 (while locals
3556 (if (consp (car locals))
3557 (push (eval (caar locals)) vlist)
3558 (push (eval (car locals)) vlist))
3559 (setq locals (cdr locals)))
3560 (setq vlist (nreverse vlist)))
01c52d31 3561 (with-current-buffer gnus-group-buffer
6748645f
LMI
3562 (setq gnus-newsgroup-name name
3563 gnus-newsgroup-marked marked
23f87bed 3564 gnus-newsgroup-spam-marked spam
6748645f
LMI
3565 gnus-newsgroup-unreads unread
3566 gnus-current-headers headers
3567 gnus-newsgroup-data data
3568 gnus-article-current gac
3569 gnus-summary-buffer summary
3570 gnus-article-buffer article-buffer
3571 gnus-original-article-buffer original
3572 gnus-reffed-article-number reffed
16409b0b
GM
3573 gnus-current-score-file score-file
3574 gnus-newsgroup-charset default-charset)
23f87bed
MB
3575 (let ((locals gnus-newsgroup-variables))
3576 (while locals
3577 (if (consp (car locals))
3578 (set (caar locals) (pop vlist))
3579 (set (car locals) (pop vlist)))
3580 (setq locals (cdr locals))))
eec82323
LMI
3581 ;; The article buffer also has local variables.
3582 (when (gnus-buffer-live-p gnus-article-buffer)
3583 (set-buffer gnus-article-buffer)
3584 (setq gnus-summary-buffer summary))))))
3585
3586(defun gnus-summary-article-unread-p (article)
3587 "Say whether ARTICLE is unread or not."
3588 (memq article gnus-newsgroup-unreads))
3589
3590(defun gnus-summary-first-article-p (&optional article)
3591 "Return whether ARTICLE is the first article in the buffer."
3592 (if (not (setq article (or article (gnus-summary-article-number))))
3593 nil
3594 (eq article (caar gnus-newsgroup-data))))
3595
3596(defun gnus-summary-last-article-p (&optional article)
3597 "Return whether ARTICLE is the last article in the buffer."
3598 (if (not (setq article (or article (gnus-summary-article-number))))
16409b0b
GM
3599 ;; All non-existent numbers are the last article. :-)
3600 t
eec82323
LMI
3601 (not (cdr (gnus-data-find-list article)))))
3602
4921bbdd
CY
3603(defun gnus-make-thread-indent-array (&optional n)
3604 (when (or n
3605 (progn (setq n 200) nil)
3606 (null gnus-thread-indent-array)
3607 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3608 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3609 gnus-thread-indent-array-level gnus-thread-indent-level)
3610 (while (>= n 0)
3611 (aset gnus-thread-indent-array n
6a30c01d 3612 (make-string (* n gnus-thread-indent-level) ? ))
4921bbdd 3613 (setq n (1- n)))))
eec82323
LMI
3614
3615(defun gnus-update-summary-mark-positions ()
3616 "Compute where the summary marks are to go."
3617 (save-excursion
6748645f 3618 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3619 (set-buffer gnus-summary-buffer))
5153a47a
MB
3620 (let ((spec gnus-summary-line-format-spec)
3621 pos)
eec82323
LMI
3622 (save-excursion
3623 (gnus-set-work-buffer)
5153a47a
MB
3624 (let ((gnus-tmp-unread ?Z)
3625 (gnus-replied-mark ?Z)
3626 (gnus-score-below-mark ?Z)
3627 (gnus-score-over-mark ?Z)
3628 (gnus-undownloaded-mark ?Z)
3629 (gnus-summary-line-format-spec spec)
54506618 3630 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3631 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3632 case-fold-search ignores)
3633 ;; Here, all marks are bound to Z.
3634 (gnus-summary-insert-line header
3635 0 nil t gnus-tmp-unread t nil "" nil 1)
3636 (goto-char (point-min))
3637 ;; Memorize the positions of the same characters as dummy marks.
3638 (while (re-search-forward "[A-D]" nil t)
3639 (push (point) ignores))
54506618 3640 (erase-buffer)
5153a47a
MB
3641 ;; We use A-D as dummy marks in order to know column positions
3642 ;; where marks should be inserted.
3643 (setq gnus-tmp-unread ?A
3644 gnus-replied-mark ?B
3645 gnus-score-below-mark ?C
3646 gnus-score-over-mark ?C
3647 gnus-undownloaded-mark ?D)
3648 (gnus-summary-insert-line header
3649 0 nil t gnus-tmp-unread t nil "" nil 1)
3650 ;; Ignore characters which aren't dummy marks.
3651 (dolist (p ignores)
3652 (delete-region (goto-char (1- p)) p)
3653 (insert ?Z))
eec82323 3654 (goto-char (point-min))
7c3bb5a5 3655 (setq pos (list (cons 'unread
5153a47a 3656 (and (search-forward "A" nil t)
7c3bb5a5 3657 (- (point) (point-min) 1)))))
eec82323 3658 (goto-char (point-min))
5153a47a 3659 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3660 (- (point) (point-min) 1)))
eec82323
LMI
3661 pos)
3662 (goto-char (point-min))
5153a47a 3663 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3664 (- (point) (point-min) 1)))
6748645f
LMI
3665 pos)
3666 (goto-char (point-min))
5153a47a 3667 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3668 (- (point) (point-min) 1)))
eec82323
LMI
3669 pos)))
3670 (setq gnus-summary-mark-positions pos))))
3671
3672(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3673 "Insert a dummy root in the summary buffer."
3674 (beginning-of-line)
3675 (gnus-add-text-properties
3676 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3677 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3678
23f87bed
MB
3679(defun gnus-summary-extract-address-component (from)
3680 (or (car (funcall gnus-extract-address-components from))
3681 from))
3682
3683(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3684 (let ((mail-parse-charset gnus-newsgroup-charset)
01c52d31 3685 (ignored-from-addresses (gnus-ignored-from-addresses))
23f87bed
MB
3686 ; Is it really necessary to do this next part for each summary line?
3687 ; Luckily, doesn't seem to slow things down much.
16409b0b 3688 (mail-parse-ignored-charsets
01c52d31
MB
3689 (with-current-buffer gnus-summary-buffer
3690 gnus-newsgroup-ignored-charsets)))
23f87bed 3691 (or
01c52d31
MB
3692 (and ignored-from-addresses
3693 (string-match ignored-from-addresses gnus-tmp-from)
23f87bed
MB
3694 (let ((extra-headers (mail-header-extra header))
3695 to
3696 newsgroups)
3697 (cond
3698 ((setq to (cdr (assq 'To extra-headers)))
01c52d31 3699 (concat gnus-summary-to-prefix
23f87bed
MB
3700 (inline
3701 (gnus-summary-extract-address-component
343d6628 3702 (funcall gnus-decode-encoded-address-function to)))))
01c52d31
MB
3703 ((setq newsgroups
3704 (or
3705 (cdr (assq 'Newsgroups extra-headers))
3706 (and
3707 (memq 'Newsgroups gnus-extra-headers)
3708 (eq (car (gnus-find-method-for-group
3709 gnus-newsgroup-name)) 'nntp)
3710 (gnus-group-real-name gnus-newsgroup-name))))
3711 (concat gnus-summary-newsgroup-prefix newsgroups)))))
23f87bed 3712 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3713
eec82323
LMI
3714(defun gnus-summary-insert-line (gnus-tmp-header
3715 gnus-tmp-level gnus-tmp-current
23f87bed 3716 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3717 gnus-tmp-expirable gnus-tmp-subject-or-nil
3718 &optional gnus-tmp-dummy gnus-tmp-score
3719 gnus-tmp-process)
4921bbdd
CY
3720 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3721 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3722 gnus-tmp-level)))
eec82323
LMI
3723 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3724 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3725 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3726 (gnus-tmp-score-char
3727 (if (or (null gnus-summary-default-score)
3728 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3729 gnus-summary-zcore-fuzz))
23f87bed 3730 ? ;Whitespace
eec82323
LMI
3731 (if (< gnus-tmp-score gnus-summary-default-score)
3732 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3733 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3734 (gnus-tmp-replied
3735 (cond (gnus-tmp-process gnus-process-mark)
3736 ((memq gnus-tmp-current gnus-newsgroup-cached)
3737 gnus-cached-mark)
3738 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3739 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3740 gnus-forwarded-mark)
eec82323
LMI
3741 ((memq gnus-tmp-current gnus-newsgroup-saved)
3742 gnus-saved-mark)
23f87bed
MB
3743 ((memq gnus-tmp-number gnus-newsgroup-recent)
3744 gnus-recent-mark)
3745 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3746 gnus-unseen-mark)
3747 (t gnus-no-mark)))
3748 (gnus-tmp-downloaded
3749 (cond (undownloaded
3750 gnus-undownloaded-mark)
3751 (gnus-newsgroup-agentized
3752 gnus-downloaded-mark)
3753 (t
3754 gnus-no-mark)))
eec82323
LMI
3755 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3756 (gnus-tmp-name
3757 (cond
3758 ((string-match "<[^>]+> *$" gnus-tmp-from)
3759 (let ((beg (match-beginning 0)))
23f87bed
MB
3760 (or (and (string-match "^\".+\"" gnus-tmp-from)
3761 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3762 (substring gnus-tmp-from 0 beg))))
3763 ((string-match "(.+)" gnus-tmp-from)
3764 (substring gnus-tmp-from
3765 (1+ (match-beginning 0)) (1- (match-end 0))))
3766 (t gnus-tmp-from)))
3767 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3768 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3769 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
c7a91ce1 3770 (inhibit-read-only t))
eec82323
LMI
3771 (when (string= gnus-tmp-name "")
3772 (setq gnus-tmp-name gnus-tmp-from))
3773 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3774 (setq gnus-tmp-lines -1))
3775 (if (= gnus-tmp-lines -1)
3776 (setq gnus-tmp-lines "?")
3777 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
64763fe3
MB
3778 (condition-case ()
3779 (gnus-put-text-property
3780 (point)
3781 (progn (eval gnus-summary-line-format-spec) (point))
3782 'gnus-number gnus-tmp-number)
3783 (error (gnus-message 5 "Error updating the summary line")))
eec82323
LMI
3784 (when (gnus-visual-p 'summary-highlight 'highlight)
3785 (forward-line -1)
a9ec34f4 3786 (gnus-summary-highlight-line)
6748645f 3787 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3788 (forward-line 1))))
3789
3790(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3791 "Update summary line after change."
eec82323
LMI
3792 (when (and gnus-summary-default-score
3793 (not gnus-summary-inhibit-highlight))
3794 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3795 (article (gnus-summary-article-number))
3796 (score (gnus-summary-article-score article)))
3797 (unless dont-update
3798 (if (and gnus-summary-mark-below
3799 (< (gnus-summary-article-score)
3800 gnus-summary-mark-below))
3801 ;; This article has a low score, so we mark it as read.
3802 (when (memq article gnus-newsgroup-unreads)
3803 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3804 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3805 ;; This article was previously marked as read on account
3806 ;; of a low score, but now it has risen, so we mark it as
3807 ;; unread.
3808 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3809 (gnus-summary-update-mark
3810 (if (or (null gnus-summary-default-score)
3811 (<= (abs (- score gnus-summary-default-score))
3812 gnus-summary-zcore-fuzz))
23f87bed 3813 ? ;Whitespace
eec82323
LMI
3814 (if (< score gnus-summary-default-score)
3815 gnus-score-below-mark gnus-score-over-mark))
3816 'score))
3817 ;; Do visual highlighting.
3818 (when (gnus-visual-p 'summary-highlight 'highlight)
a9ec34f4 3819 (gnus-summary-highlight-line)
6748645f 3820 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3821
3822(defvar gnus-tmp-new-adopts nil)
3823
3824(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3825 "Return the number of articles in THREAD.
3826This may be 0 in some cases -- if none of the articles in
3827the thread are to be displayed."
3828 (let* ((number
23f87bed 3829 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3830 (cond
3831 ((not (listp thread))
3832 1)
3833 ((and (consp thread) (cdr thread))
3834 (apply
3835 '+ 1 (mapcar
3836 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3837 ((null thread)
3838 1)
3839 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3840 1)
3841 (t 0))))
3842 (when (and level (zerop level) gnus-tmp-new-adopts)
3843 (incf number
3844 (apply '+ (mapcar
3845 'gnus-summary-number-of-articles-in-thread
3846 gnus-tmp-new-adopts))))
3847 (if char
3848 (if (> number 1) gnus-not-empty-thread-mark
3849 gnus-empty-thread-mark)
3850 number)))
3851
23f87bed
MB
3852(defsubst gnus-summary-line-message-size (head)
3853 "Return pretty-printed version of message size.
3854This function is intended to be used in
3855`gnus-summary-line-format-alist'."
3856 (let ((c (or (mail-header-chars head) -1)))
3857 (cond ((< c 0) "n/a") ; chars not available
3858 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3859 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3860 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3861 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3862
4a3988d5 3863(defcustom gnus-user-date-format-alist
0d1c2cc8
G
3864 '(((gnus-seconds-today) . "Today, %H:%M")
3865 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3866 (604800 . "%A %H:%M") ; That's one week
3867 ((gnus-seconds-month) . "%A %d")
3868 ((gnus-seconds-year) . "%B %d")
3869 (t . "%b %d %Y")) ; This one is used when no other
3870 ; does match
3871 "Specifies date format depending on age of article.
3872This is an alist of items (AGE . FORMAT). AGE can be a number (of
3873seconds) or a Lisp expression evaluating to a number. When the age of
3874the article is less than this number, then use `format-time-string'
3875with the corresponding FORMAT for displaying the date of the article.
3876If AGE is not a number or a Lisp expression evaluating to a
3877non-number, then the corresponding FORMAT is used as a default value.
3878
3879Note that the list is processed from the beginning, so it should be
3880sorted by ascending AGE. Also note that items following the first
3881non-number AGE will be ignored.
3882
3883You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3884and `gnus-seconds-year' in the AGE spec. They return the number of
3885seconds passed since the start of today, of this month, of this year,
3886respectively."
3887 :version "24.1"
3888 :group 'gnus-summary-format
3889 :type '(alist :key-type sexp :value-type string))
0d1c2cc8 3890
ec72bf63 3891(defun gnus-user-date (messy-date)
4a3988d5 3892 "Format the messy-date according to `gnus-user-date-format-alist'.
0d1c2cc8
G
3893Returns \" ? \" if there's bad input or if another error occurs.
3894Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3895 (condition-case ()
3896 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3897 (now (gnus-float-time))
3898 ;;If we don't find something suitable we'll use this one
3899 (my-format "%b %d '%y"))
3900 (let* ((difference (- now messy-date))
4a3988d5 3901 (templist gnus-user-date-format-alist)
0d1c2cc8
G
3902 (top (eval (caar templist))))
3903 (while (if (numberp top) (< top difference) (not top))
3904 (progn
3905 (setq templist (cdr templist))
3906 (setq top (eval (caar templist)))))
3907 (if (stringp (cdr (car templist)))
3908 (setq my-format (cdr (car templist)))))
3909 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3910 (error " ? ")))
23f87bed 3911
eec82323
LMI
3912(defun gnus-summary-set-local-parameters (group)
3913 "Go through the local params of GROUP and set all variable specs in that list."
dab0271f
G
3914 (let ((vars '(quit-config active))) ; Ignore things that aren't
3915 ; really variables.
01c52d31 3916 (dolist (elem (gnus-group-find-parameter group))
eec82323
LMI
3917 (and (consp elem) ; Has to be a cons.
3918 (consp (cdr elem)) ; The cdr has to be a list.
3919 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3920 (not (memq (car elem) vars))
e3e955fe 3921 (ignore-errors
23f87bed 3922 (push (car elem) vars)
e3e955fe
MB
3923 ;; Variables like `gnus-show-threads' that are globally
3924 ;; bound, if used as group parameters, need to get to be
3925 ;; buffer-local, whereas just parameters like `gcc-self',
3926 ;; `timestamp', etc. should not be bound as variables.
3927 (if (boundp (car elem))
3928 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3929 (eval (nth 1 elem))))))))
eec82323
LMI
3930
3931(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3932 kill-buffer no-display backward
3933 select-articles)
eec82323
LMI
3934 "Start reading news in newsgroup GROUP.
3935If SHOW-ALL is non-nil, already read articles are also listed.
3936If NO-ARTICLE is non-nil, no article is selected initially.
3937If NO-DISPLAY, don't generate a summary buffer."
3938 (let (result)
3939 (while (and group
3940 (null (setq result
3941 (let ((gnus-auto-select-next nil))
6748645f
LMI
3942 (or (gnus-summary-read-group-1
3943 group show-all no-article
3944 kill-buffer no-display
3945 select-articles)
3946 (setq show-all nil
16409b0b 3947 select-articles nil)))))
eec82323
LMI
3948 (eq gnus-auto-select-next 'quietly))
3949 (set-buffer gnus-group-buffer)
6748645f
LMI
3950 ;; The entry function called above goes to the next
3951 ;; group automatically, so we go two groups back
3952 ;; if we are searching for the previous group.
3953 (when backward
3954 (gnus-group-prev-unread-group 2))
eec82323
LMI
3955 (if (not (equal group (gnus-group-group-name)))
3956 (setq group (gnus-group-group-name))
3957 (setq group nil)))
3958 result))
3959
3960(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3961 kill-buffer no-display
3962 &optional select-articles)
eec82323 3963 ;; Killed foreign groups can't be entered.
23f87bed
MB
3964 ;; (when (and (not (gnus-group-native-p group))
3965 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3966 ;; (error "Dead non-native groups can't be entered"))
3967 (gnus-message 5 "Retrieving newsgroup: %s..."
3968 (gnus-group-decoded-name group))
eec82323
LMI
3969 (let* ((new-group (gnus-summary-setup-buffer group))
3970 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3971 (did-select (and new-group (gnus-select-newsgroup
3972 group show-all select-articles))))
eec82323
LMI
3973 (cond
3974 ;; This summary buffer exists already, so we just select it.
3975 ((not new-group)
3976 (gnus-set-global-variables)
3977 (when kill-buffer
3978 (gnus-kill-or-deaden-summary kill-buffer))
3979 (gnus-configure-windows 'summary 'force)
3980 (gnus-set-mode-line 'summary)
3981 (gnus-summary-position-point)
3982 (message "")
3983 t)
3984 ;; We couldn't select this group.
3985 ((null did-select)
3986 (when (and (eq major-mode 'gnus-summary-mode)
3987 (not (equal (current-buffer) kill-buffer)))
3988 (kill-buffer (current-buffer))
3989 (if (not quit-config)
3990 (progn
6748645f
LMI
3991 ;; Update the info -- marks might need to be removed,
3992 ;; for instance.
3993 (gnus-summary-update-info)
eec82323
LMI
3994 (set-buffer gnus-group-buffer)
3995 (gnus-group-jump-to-group group)
3996 (gnus-group-next-unread-group 1))
3997 (gnus-handle-ephemeral-exit quit-config)))
8937ef6e
LI
3998 (if (null (gnus-list-of-unread-articles group))
3999 (gnus-message 3 "Group %s contains no messages" group)
4000 (gnus-message 3 "Can't select group"))
eec82323
LMI
4001 nil)
4002 ;; The user did a `C-g' while prompting for number of articles,
4003 ;; so we exit this group.
4004 ((eq did-select 'quit)
4005 (and (eq major-mode 'gnus-summary-mode)
4006 (not (equal (current-buffer) kill-buffer))
4007 (kill-buffer (current-buffer)))
4008 (when kill-buffer
4009 (gnus-kill-or-deaden-summary kill-buffer))
4010 (if (not quit-config)
4011 (progn
4012 (set-buffer gnus-group-buffer)
4013 (gnus-group-jump-to-group group)
eec82323
LMI
4014 (gnus-configure-windows 'group 'force))
4015 (gnus-handle-ephemeral-exit quit-config))
4016 ;; Finally signal the quit.
4017 (signal 'quit nil))
4018 ;; The group was successfully selected.
4019 (t
4020 (gnus-set-global-variables)
4021 ;; Save the active value in effect when the group was entered.
4022 (setq gnus-newsgroup-active
4023 (gnus-copy-sequence
4024 (gnus-active gnus-newsgroup-name)))
9f2d52e7 4025 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
eec82323 4026 ;; You can change the summary buffer in some way with this hook.
6748645f 4027 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
4028 (when (memq 'summary (gnus-update-format-specifications
4029 nil 'summary 'summary-mode 'summary-dummy))
4030 ;; The format specification for the summary line was updated,
4031 ;; so we need to update the mark positions as well.
4032 (gnus-update-summary-mark-positions))
eec82323
LMI
4033 ;; Do score processing.
4034 (when gnus-use-scoring
4035 (gnus-possibly-score-headers))
4036 ;; Check whether to fill in the gaps in the threads.
4037 (when gnus-build-sparse-threads
4038 (gnus-build-sparse-threads))
4039 ;; Find the initial limit.
26c9afc3
MB
4040 (if show-all
4041 (let ((gnus-newsgroup-dormant nil))
eec82323 4042 (gnus-summary-initial-limit show-all))
26c9afc3 4043 (gnus-summary-initial-limit show-all))
eec82323
LMI
4044 ;; Generate the summary buffer.
4045 (unless no-display
4046 (gnus-summary-prepare))
4047 (when gnus-use-trees
4048 (gnus-tree-open group)
4049 (setq gnus-summary-highlight-line-function
4050 'gnus-tree-highlight-article))
4051 ;; If the summary buffer is empty, but there are some low-scored
4052 ;; articles or some excluded dormants, we include these in the
4053 ;; buffer.
4054 (when (and (zerop (buffer-size))
4055 (not no-display))
4056 (cond (gnus-newsgroup-dormant
4057 (gnus-summary-limit-include-dormant))
4058 ((and gnus-newsgroup-scored show-all)
4059 (gnus-summary-limit-include-expunged t))))
4060 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 4061 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
4062 (if (and (zerop (buffer-size))
4063 (not no-display))
4064 (progn
4065 ;; This newsgroup is empty.
4066 (gnus-summary-catchup-and-exit nil t)
4067 (gnus-message 6 "No unread news")
4068 (when kill-buffer
4069 (gnus-kill-or-deaden-summary kill-buffer))
4070 ;; Return nil from this function.
4071 nil)
4072 ;; Hide conversation thread subtrees. We cannot do this in
4073 ;; gnus-summary-prepare-hook since kill processing may not
4074 ;; work with hidden articles.
23f87bed 4075 (gnus-summary-maybe-hide-threads)
5415d076 4076 (gnus-configure-windows 'summary)
6748645f
LMI
4077 (when kill-buffer
4078 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 4079 (gnus-summary-auto-select-subject)
eec82323
LMI
4080 ;; Show first unread article if requested.
4081 (if (and (not no-article)
4082 (not no-display)
4083 gnus-newsgroup-unreads
4084 gnus-auto-select-first)
16409b0b 4085 (progn
23f87bed
MB
4086 (let ((art (gnus-summary-article-number)))
4087 (unless (and (not gnus-plugged)
4088 (or (memq art gnus-newsgroup-undownloaded)
4089 (memq art gnus-newsgroup-downloadable)))
4090 (gnus-summary-goto-article art))))
4091 ;; Don't select any articles.
eec82323 4092 (gnus-summary-position-point)
6748645f
LMI
4093 (gnus-configure-windows 'summary 'force)
4094 (gnus-set-mode-line 'summary))
23f87bed
MB
4095 (when (and gnus-auto-center-group
4096 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
4097 ;; Gotta use windows, because recenter does weird stuff if
4098 ;; the current buffer ain't the displayed window.
4099 (let ((owin (selected-window)))
4100 (select-window (get-buffer-window gnus-group-buffer t))
4101 (when (gnus-group-goto-group group)
4102 (recenter))
4103 (select-window owin)))
4104 ;; Mark this buffer as "prepared".
4105 (setq gnus-newsgroup-prepared t)
6748645f 4106 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed 4107 (unless (gnus-ephemeral-group-p group)
b229f37d 4108 (gnus-group-update-group group nil t))
eec82323
LMI
4109 t)))))
4110
23f87bed
MB
4111(defun gnus-summary-auto-select-subject ()
4112 "Select the subject line on initial group entry."
4113 (goto-char (point-min))
4114 (cond
4115 ((eq gnus-auto-select-subject 'best)
4116 (gnus-summary-best-unread-subject))
4117 ((eq gnus-auto-select-subject 'unread)
4118 (gnus-summary-first-unread-subject))
4119 ((eq gnus-auto-select-subject 'unseen)
4120 (gnus-summary-first-unseen-subject))
4121 ((eq gnus-auto-select-subject 'unseen-or-unread)
4122 (gnus-summary-first-unseen-or-unread-subject))
4123 ((eq gnus-auto-select-subject 'first)
4124 ;; Do nothing.
4125 )
4126 ((functionp gnus-auto-select-subject)
4127 (funcall gnus-auto-select-subject))))
4128
eec82323
LMI
4129(defun gnus-summary-prepare ()
4130 "Generate the summary buffer."
4131 (interactive)
c7a91ce1 4132 (let ((inhibit-read-only t))
eec82323
LMI
4133 (erase-buffer)
4134 (setq gnus-newsgroup-data nil
4135 gnus-newsgroup-data-reverse nil)
6748645f 4136 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
4137 ;; Generate the buffer, either with threads or without.
4138 (when gnus-newsgroup-headers
4139 (gnus-summary-prepare-threads
4140 (if gnus-show-threads
4141 (gnus-sort-gathered-threads
4142 (funcall gnus-summary-thread-gathering-function
4143 (gnus-sort-threads
4144 (gnus-cut-threads (gnus-make-threads)))))
4145 ;; Unthreaded display.
4146 (gnus-sort-articles gnus-newsgroup-headers))))
4147 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4148 ;; Call hooks for modifying summary buffer.
4149 (goto-char (point-min))
6748645f 4150 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
4151
4152(defsubst gnus-general-simplify-subject (subject)
23f87bed 4153 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
4154 (setq subject
4155 (cond
4156 ;; Truncate the subject.
6748645f
LMI
4157 (gnus-simplify-subject-functions
4158 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
4159 ((numberp gnus-summary-gather-subject-limit)
4160 (setq subject (gnus-simplify-subject-re subject))
4161 (if (> (length subject) gnus-summary-gather-subject-limit)
4162 (substring subject 0 gnus-summary-gather-subject-limit)
4163 subject))
4164 ;; Fuzzily simplify it.
4165 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4166 (gnus-simplify-subject-fuzzy subject))
4167 ;; Just remove the leading "Re:".
4168 (t
4169 (gnus-simplify-subject-re subject))))
4170
4171 (if (and gnus-summary-gather-exclude-subject
4172 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 4173 nil ; This article shouldn't be gathered
eec82323
LMI
4174 subject))
4175
4176(defun gnus-summary-simplify-subject-query ()
4177 "Query where the respool algorithm would put this article."
4178 (interactive)
eec82323 4179 (gnus-summary-select-article)
274f1353 4180 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
eec82323
LMI
4181
4182(defun gnus-gather-threads-by-subject (threads)
4183 "Gather threads by looking at Subject headers."
4184 (if (not gnus-summary-make-false-root)
4185 threads
4186 (let ((hashtb (gnus-make-hashtable 1024))
4187 (prev threads)
4188 (result threads)
4189 subject hthread whole-subject)
4190 (while threads
4191 (setq subject (gnus-general-simplify-subject
4192 (setq whole-subject (mail-header-subject
4193 (caar threads)))))
4194 (when subject
4195 (if (setq hthread (gnus-gethash subject hashtb))
4196 (progn
4197 ;; We enter a dummy root into the thread, if we
4198 ;; haven't done that already.
4199 (unless (stringp (caar hthread))
4200 (setcar hthread (list whole-subject (car hthread))))
4201 ;; We add this new gathered thread to this gathered
4202 ;; thread.
4203 (setcdr (car hthread)
4204 (nconc (cdar hthread) (list (car threads))))
4205 ;; Remove it from the list of threads.
4206 (setcdr prev (cdr threads))
4207 (setq threads prev))
4208 ;; Enter this thread into the hash table.
23f87bed
MB
4209 (gnus-sethash subject
4210 (if gnus-summary-make-false-root-always
4211 (progn
4212 ;; If you want a dummy root above all
4213 ;; threads...
4214 (setcar threads (list whole-subject
4215 (car threads)))
4216 threads)
4217 threads)
4218 hashtb)))
eec82323
LMI
4219 (setq prev threads)
4220 (setq threads (cdr threads)))
4221 result)))
4222
4223(defun gnus-gather-threads-by-references (threads)
4224 "Gather threads by looking at References headers."
4225 (let ((idhashtb (gnus-make-hashtable 1024))
4226 (thhashtb (gnus-make-hashtable 1024))
4227 (prev threads)
4228 (result threads)
4229 ids references id gthread gid entered ref)
4230 (while threads
4231 (when (setq references (mail-header-references (caar threads)))
4232 (setq id (mail-header-id (caar threads))
23f87bed 4233 ids (inline (gnus-split-references references))
eec82323
LMI
4234 entered nil)
4235 (while (setq ref (pop ids))
4236 (setq ids (delete ref ids))
4237 (if (not (setq gid (gnus-gethash ref idhashtb)))
4238 (progn
4239 (gnus-sethash ref id idhashtb)
4240 (gnus-sethash id threads thhashtb))
4241 (setq gthread (gnus-gethash gid thhashtb))
4242 (unless entered
4243 ;; We enter a dummy root into the thread, if we
4244 ;; haven't done that already.
4245 (unless (stringp (caar gthread))
4246 (setcar gthread (list (mail-header-subject (caar gthread))
4247 (car gthread))))
4248 ;; We add this new gathered thread to this gathered
4249 ;; thread.
4250 (setcdr (car gthread)
4251 (nconc (cdar gthread) (list (car threads)))))
4252 ;; Add it into the thread hash table.
4253 (gnus-sethash id gthread thhashtb)
4254 (setq entered t)
4255 ;; Remove it from the list of threads.
4256 (setcdr prev (cdr threads))
4257 (setq threads prev))))
4258 (setq prev threads)
4259 (setq threads (cdr threads)))
4260 result))
4261
4262(defun gnus-sort-gathered-threads (threads)
16409b0b 4263 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
4264 (let ((result threads))
4265 (while threads
4266 (when (stringp (caar threads))
4267 (setcdr (car threads)
16409b0b 4268 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
4269 (setq threads (cdr threads)))
4270 result))
4271
4272(defun gnus-thread-loop-p (root thread)
4273 "Say whether ROOT is in THREAD."
4274 (let ((stack (list thread))
4275 (infloop 0)
4276 th)
4277 (while (setq thread (pop stack))
4278 (setq th (cdr thread))
4279 (while (and th
4280 (not (eq (caar th) root)))
4281 (pop th))
4282 (if th
4283 ;; We have found a loop.
4284 (let (ref-dep)
4285 (setcdr thread (delq (car th) (cdr thread)))
4286 (if (boundp (setq ref-dep (intern "none"
4287 gnus-newsgroup-dependencies)))
4288 (setcdr (symbol-value ref-dep)
4289 (nconc (cdr (symbol-value ref-dep))
4290 (list (car th))))
4291 (set ref-dep (list nil (car th))))
4292 (setq infloop 1
4293 stack nil))
4294 ;; Push all the subthreads onto the stack.
4295 (push (cdr thread) stack)))
4296 infloop))
4297
4298(defun gnus-make-threads ()
01ccbb85 4299 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
4300 (let (threads)
4301 (while (catch 'infloop
4302 (mapatoms
4303 (lambda (refs)
4304 ;; Deal with self-referencing References loops.
4305 (when (and (car (symbol-value refs))
4306 (not (zerop
4307 (apply
4308 '+
4309 (mapcar
4310 (lambda (thread)
4311 (gnus-thread-loop-p
4312 (car (symbol-value refs)) thread))
4313 (cdr (symbol-value refs)))))))
4314 (setq threads nil)
4315 (throw 'infloop t))
4316 (unless (car (symbol-value refs))
23f87bed
MB
4317 ;; These threads do not refer back to any other
4318 ;; articles, so they're roots.
eec82323
LMI
4319 (setq threads (append (cdr (symbol-value refs)) threads))))
4320 gnus-newsgroup-dependencies)))
4321 threads))
4322
6748645f 4323;; Build the thread tree.
16409b0b 4324(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4325 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4326
4327If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4328if it was already present.
4329
4330If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4331will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4332Message-IDs will be renamed to a unique Message-ID before being
4333entered.
6748645f
LMI
4334
4335Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4336 (let* ((id (mail-header-id header))
4337 (id-dep (and id (intern id dependencies)))
23f87bed 4338 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4339 ;; Enter this `header' in the `dependencies' table.
4340 (cond
4341 ((not id-dep)
4342 (setq header nil))
4343 ;; The first two cases do the normal part: enter a new `header'
4344 ;; in the `dependencies' table.
4345 ((not (boundp id-dep))
4346 (set id-dep (list header)))
4347 ((null (car (symbol-value id-dep)))
4348 (setcar (symbol-value id-dep) header))
4349
4350 ;; From here the `header' was already present in the
4351 ;; `dependencies' table.
4352 (force-new
4353 ;; Overrides an existing entry;
4354 ;; just set the header part of the entry.
23f87bed
MB
4355 (setcar (symbol-value id-dep) header)
4356 (setq replaced t))
6748645f
LMI
4357
4358 ;; Renames the existing `header' to a unique Message-ID.
4359 ((not gnus-summary-ignore-duplicates)
4360 ;; An article with this Message-ID has already been seen.
4361 ;; We rename the Message-ID.
4362 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4363 (list header))
4364 (mail-header-set-id header id))
4365
4366 ;; The last case ignores an existing entry, except it adds any
4367 ;; additional Xrefs (in case the two articles came from different
4368 ;; servers.
4369 ;; Also sets `header' to `nil' meaning that the `dependencies'
4370 ;; table was *not* modified.
4371 (t
4372 (mail-header-set-xref
4373 (car (symbol-value id-dep))
4374 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4375 "")
4376 (or (mail-header-xref header) "")))
4377 (setq header nil)))
4378
23f87bed
MB
4379 (when (and header (not replaced))
4380 ;; First check that we are not creating a References loop.
4381 (setq parent-id (gnus-parent-id (mail-header-references header)))
4382 (setq ref parent-id)
6748645f
LMI
4383 (while (and ref
4384 (setq ref-dep (intern-soft ref dependencies))
4385 (boundp ref-dep)
4386 (setq ref-header (car (symbol-value ref-dep))))
4387 (if (string= id ref)
4388 ;; Yuk! This is a reference loop. Make the article be a
4389 ;; root article.
4390 (progn
4391 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4392 (setq ref nil)
4393 (setq parent-id nil))
6748645f 4394 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4395 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4396 (if (boundp ref-dep)
4397 (setcdr (symbol-value ref-dep)
4398 (nconc (cdr (symbol-value ref-dep))
4399 (list (symbol-value id-dep))))
4400 (set ref-dep (list nil (symbol-value id-dep)))))
4401 header))
4402
23f87bed
MB
4403(defun gnus-extract-message-id-from-in-reply-to (string)
4404 (if (string-match "<[^>]+>" string)
4405 (substring string (match-beginning 0) (match-end 0))
4406 nil))
4407
eec82323
LMI
4408(defun gnus-build-sparse-threads ()
4409 (let ((headers gnus-newsgroup-headers)
16409b0b 4410 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4411 (gnus-summary-ignore-duplicates t)
eec82323 4412 header references generation relations
6748645f 4413 subject child end new-child date)
eec82323
LMI
4414 ;; First we create an alist of generations/relations, where
4415 ;; generations is how much we trust the relation, and the relation
4416 ;; is parent/child.
4417 (gnus-message 7 "Making sparse threads...")
4418 (save-excursion
4419 (nnheader-set-temp-buffer " *gnus sparse threads*")
4420 (while (setq header (pop headers))
4421 (when (and (setq references (mail-header-references header))
4422 (not (string= references "")))
4423 (insert references)
4424 (setq child (mail-header-id header)
6748645f
LMI
4425 subject (mail-header-subject header)
4426 date (mail-header-date header)
4427 generation 0)
eec82323
LMI
4428 (while (search-backward ">" nil t)
4429 (setq end (1+ (point)))
4430 (when (search-backward "<" nil t)
6748645f 4431 (setq new-child (buffer-substring (point) end))
eec82323 4432 (push (list (incf generation)
6748645f
LMI
4433 child (setq child new-child)
4434 subject date)
eec82323 4435 relations)))
6748645f
LMI
4436 (when child
4437 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4438 (erase-buffer)))
4439 (kill-buffer (current-buffer)))
4440 ;; Sort over trustworthiness.
01c52d31
MB
4441 (dolist (relation (sort relations 'car-less-than-car))
4442 (when (gnus-dependencies-add-header
4443 (make-full-mail-header
4444 gnus-reffed-article-number
4445 (nth 3 relation) "" (or (nth 4 relation) "")
4446 (nth 1 relation)
4447 (or (nth 2 relation) "") 0 0 "")
4448 gnus-newsgroup-dependencies nil)
4449 (push gnus-reffed-article-number gnus-newsgroup-limit)
4450 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4451 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4452 gnus-newsgroup-reads)
4453 (decf gnus-reffed-article-number)))
eec82323
LMI
4454 (gnus-message 7 "Making sparse threads...done")))
4455
4456(defun gnus-build-old-threads ()
4457 ;; Look at all the articles that refer back to old articles, and
4458 ;; fetch the headers for the articles that aren't there. This will
4459 ;; build complete threads - if the roots haven't been expired by the
4460 ;; server, that is.
16409b0b
GM
4461 (let ((mail-parse-charset gnus-newsgroup-charset)
4462 id heads)
eec82323
LMI
4463 (mapatoms
4464 (lambda (refs)
4465 (when (not (car (symbol-value refs)))
4466 (setq heads (cdr (symbol-value refs)))
4467 (while heads
4468 (if (memq (mail-header-number (caar heads))
4469 gnus-newsgroup-dormant)
4470 (setq heads (cdr heads))
4471 (setq id (symbol-name refs))
4472 (while (and (setq id (gnus-build-get-header id))
6748645f 4473 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4474 (setq heads nil)))))
4475 gnus-newsgroup-dependencies)))
4476
23f87bed
MB
4477(defsubst gnus-remove-odd-characters (string)
4478 "Translate STRING into something that doesn't contain weird characters."
4479 (mm-subst-char-in-string
4480 ?\r ?\-
01c52d31 4481 (mm-subst-char-in-string ?\n ?\- string t) t))
23f87bed 4482
6748645f
LMI
4483;; This function has to be called with point after the article number
4484;; on the beginning of the line.
4485(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
01c52d31 4486 (let ((eol (point-at-eol))
6748645f 4487 (buffer (current-buffer))
23f87bed 4488 header references in-reply-to)
6748645f
LMI
4489
4490 ;; overview: [num subject from date id refs chars lines misc]
4491 (unwind-protect
23f87bed 4492 (let (x)
6748645f
LMI
4493 (narrow-to-region (point) eol)
4494 (unless (eobp)
4495 (forward-char))
4496
4497 (setq header
4498 (make-full-mail-header
4499 number ; number
23f87bed
MB
4500 (condition-case () ; subject
4501 (gnus-remove-odd-characters
4502 (funcall gnus-decode-encoded-word-function
4503 (setq x (nnheader-nov-field))))
4504 (error x))
4505 (condition-case () ; from
4506 (gnus-remove-odd-characters
343d6628 4507 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4508 (setq x (nnheader-nov-field))))
4509 (error x))
16409b0b 4510 (nnheader-nov-field) ; date
01c52d31 4511 (nnheader-nov-read-message-id number) ; id
23f87bed 4512 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4513 (nnheader-nov-read-integer) ; chars
4514 (nnheader-nov-read-integer) ; lines
4515 (unless (eobp)
8b93df01
DL
4516 (if (looking-at "Xref: ")
4517 (goto-char (match-end 0)))
4518 (nnheader-nov-field)) ; Xref
16409b0b 4519 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4520
4521 (widen))
4522
23f87bed
MB
4523 (when (and (string= references "")
4524 (setq in-reply-to (mail-header-extra header))
4525 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4526 (mail-header-set-references
4527 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4528
6748645f
LMI
4529 (when gnus-alter-header-function
4530 (funcall gnus-alter-header-function header))
4531 (gnus-dependencies-add-header header dependencies force-new)))
4532
eec82323 4533(defun gnus-build-get-header (id)
16409b0b
GM
4534 "Look through the buffer of NOV lines and find the header to ID.
4535Enter this line into the dependencies hash table, and return
4536the id of the parent article (if any)."
eec82323
LMI
4537 (let ((deps gnus-newsgroup-dependencies)
4538 found header)
4539 (prog1
c7a91ce1 4540 (with-current-buffer nntp-server-buffer
eec82323
LMI
4541 (let ((case-fold-search nil))
4542 (goto-char (point-min))
4543 (while (and (not found)
4544 (search-forward id nil t))
4545 (beginning-of-line)
4546 (setq found (looking-at
4547 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4548 (regexp-quote id))))
4549 (or found (beginning-of-line 2)))
4550 (when found
4551 (beginning-of-line)
4552 (and
4553 (setq header (gnus-nov-parse-line
4554 (read (current-buffer)) deps))
4555 (gnus-parent-id (mail-header-references header))))))
4556 (when header
4557 (let ((number (mail-header-number header)))
4558 (push number gnus-newsgroup-limit)
4559 (push header gnus-newsgroup-headers)
4560 (if (memq number gnus-newsgroup-unselected)
4561 (progn
23f87bed
MB
4562 (setq gnus-newsgroup-unreads
4563 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4564 number))
eec82323
LMI
4565 (setq gnus-newsgroup-unselected
4566 (delq number gnus-newsgroup-unselected)))
4567 (push number gnus-newsgroup-ancient)))))))
4568
6748645f
LMI
4569(defun gnus-build-all-threads ()
4570 "Read all the headers."
4571 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4572 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4573 (dependencies gnus-newsgroup-dependencies)
4574 header article)
c7a91ce1 4575 (with-current-buffer nntp-server-buffer
6748645f
LMI
4576 (let ((case-fold-search nil))
4577 (goto-char (point-min))
4578 (while (not (eobp))
4579 (ignore-errors
4580 (setq article (read (current-buffer))
181cb5fb 4581 header (gnus-nov-parse-line article dependencies t)))
6748645f 4582 (when header
01c52d31 4583 (with-current-buffer gnus-summary-buffer
6748645f
LMI
4584 (push header gnus-newsgroup-headers)
4585 (if (memq (setq article (mail-header-number header))
4586 gnus-newsgroup-unselected)
4587 (progn
23f87bed
MB
4588 (setq gnus-newsgroup-unreads
4589 (gnus-add-to-sorted-list
4590 gnus-newsgroup-unreads article))
6748645f
LMI
4591 (setq gnus-newsgroup-unselected
4592 (delq article gnus-newsgroup-unselected)))
4593 (push article gnus-newsgroup-ancient)))
4594 (forward-line 1)))))))
4595
eec82323 4596(defun gnus-summary-update-article-line (article header)
23f87bed 4597 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4598 (let* ((id (mail-header-id header))
4599 (thread (gnus-id-to-thread id)))
4600 (unless thread
4601 (error "Article in no thread"))
4602 ;; Update the thread.
4603 (setcar thread header)
4604 (gnus-summary-goto-subject article)
4605 (let* ((datal (gnus-data-find-list article))
4606 (data (car datal))
c7a91ce1 4607 (inhibit-read-only t)
eec82323
LMI
4608 (level (gnus-summary-thread-level)))
4609 (gnus-delete-line)
23f87bed
MB
4610 (let ((inserted (- (point)
4611 (progn
4612 (gnus-summary-insert-line
4613 header level nil
4614 (memq article gnus-newsgroup-undownloaded)
4615 (gnus-article-mark article)
4616 (memq article gnus-newsgroup-replied)
4617 (memq article gnus-newsgroup-expirable)
4618 ;; Only insert the Subject string when it's different
4619 ;; from the previous Subject string.
4620 (if (and
4621 gnus-show-threads
4622 (gnus-subject-equal
4623 (condition-case ()
4624 (mail-header-subject
4625 (gnus-data-header
4626 (cadr
4627 (gnus-data-find-list
4628 article
4629 (gnus-data-list t)))))
4630 ;; Error on the side of excessive subjects.
4631 (error ""))
4632 (mail-header-subject header)))
4633 ""
4634 (mail-header-subject header))
4635 nil (cdr (assq article gnus-newsgroup-scored))
4636 (memq article gnus-newsgroup-processable))
4637 (point)))))
4638 (when (cdr datal)
4639 (gnus-data-update-list
4640 (cdr datal)
4641 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4642
4643(defun gnus-summary-update-article (article &optional iheader)
4644 "Update ARTICLE in the summary buffer."
4645 (set-buffer gnus-summary-buffer)
6748645f 4646 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4647 (id (mail-header-id header))
4648 (data (gnus-data-find article))
4649 (thread (gnus-id-to-thread id))
4650 (references (mail-header-references header))
4651 (parent
4652 (gnus-id-to-thread
4653 (or (gnus-parent-id
4654 (when (and references
4655 (not (equal "" references)))
4656 references))
4657 "none")))
c7a91ce1 4658 (inhibit-read-only t)
6748645f 4659 (old (car thread)))
eec82323 4660 (when thread
eec82323 4661 (unless iheader
6748645f
LMI
4662 (setcar thread nil)
4663 (when parent
4664 (delq thread parent)))
4665 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4666 ;; Set the (possibly) new article number in the data structure.
4667 (gnus-data-set-number data (gnus-id-to-article id))
4668 (setcar thread old)
4669 nil))))
4670
6748645f
LMI
4671(defun gnus-rebuild-thread (id &optional line)
4672 "Rebuild the thread containing ID.
4673If LINE, insert the rebuilt thread starting on line LINE."
c7a91ce1 4674 (let ((inhibit-read-only t)
eec82323
LMI
4675 old-pos current thread data)
4676 (if (not gnus-show-threads)
4677 (setq thread (list (car (gnus-id-to-thread id))))
4678 ;; Get the thread this article is part of.
4679 (setq thread (gnus-remove-thread id)))
01c52d31 4680 (setq old-pos (point-at-bol))
eec82323 4681 (setq current (save-excursion
94384150 4682 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4683 (gnus-summary-article-number))))
4684 ;; If this is a gathered thread, we have to go some re-gathering.
4685 (when (stringp (car thread))
4686 (let ((subject (car thread))
4687 roots thr)
4688 (setq thread (cdr thread))
4689 (while thread
4690 (unless (memq (setq thr (gnus-id-to-thread
4691 (gnus-root-id
4692 (mail-header-id (caar thread)))))
4693 roots)
4694 (push thr roots))
4695 (setq thread (cdr thread)))
4696 ;; We now have all (unique) roots.
4697 (if (= (length roots) 1)
4698 ;; All the loose roots are now one solid root.
4699 (setq thread (car roots))
4700 (setq thread (cons subject (gnus-sort-threads roots))))))
4701 (let (threads)
4702 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4703 (when line
4704 (goto-char (point-min))
4705 (forward-line (1- line)))
eec82323
LMI
4706 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4707 (if gnus-show-threads
4708 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4709 (gnus-summary-prepare-unthreaded thread))
4710 (setq data (nreverse gnus-newsgroup-data))
4711 (setq threads gnus-newsgroup-threads))
4712 ;; We splice the new data into the data structure.
6748645f
LMI
4713 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4714 ;;!!! then we want to insert at the beginning of the buffer.
4715 ;;!!! That happens to be true with Gnus now, but that may
4716 ;;!!! change in the future. Perhaps.
4717 (gnus-data-enter-list
4718 (if line nil current) data (- (point) old-pos))
4719 (setq gnus-newsgroup-threads
4720 (nconc threads gnus-newsgroup-threads))
4721 (gnus-data-compute-positions))))
eec82323
LMI
4722
4723(defun gnus-number-to-header (number)
4724 "Return the header for article NUMBER."
4725 (let ((headers gnus-newsgroup-headers))
4726 (while (and headers
4727 (not (= number (mail-header-number (car headers)))))
4728 (pop headers))
4729 (when headers
4730 (car headers))))
4731
6748645f 4732(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4733 "Return the headers of the GENERATIONeth parent of HEADERS."
4734 (unless generation
4735 (setq generation 1))
a8151ef7 4736 (let ((parent t)
6748645f 4737 (headers in-headers)
a8151ef7 4738 references)
6748645f
LMI
4739 (while (and parent
4740 (not (zerop generation))
4741 (setq references (mail-header-references headers)))
4742 (setq headers (if (and references
4743 (setq parent (gnus-parent-id references)))
4744 (car (gnus-id-to-thread parent))
4745 nil))
4746 (decf generation))
4747 (and (not (eq headers in-headers))
4748 headers)))
eec82323
LMI
4749
4750(defun gnus-id-to-thread (id)
4751 "Return the (sub-)thread where ID appears."
4752 (gnus-gethash id gnus-newsgroup-dependencies))
4753
4754(defun gnus-id-to-article (id)
4755 "Return the article number of ID."
4756 (let ((thread (gnus-id-to-thread id)))
4757 (when (and thread
4758 (car thread))
4759 (mail-header-number (car thread)))))
4760
4761(defun gnus-id-to-header (id)
4762 "Return the article headers of ID."
4763 (car (gnus-id-to-thread id)))
4764
4765(defun gnus-article-displayed-root-p (article)
4766 "Say whether ARTICLE is a root(ish) article."
4767 (let ((level (gnus-summary-thread-level article))
4768 (refs (mail-header-references (gnus-summary-article-header article)))
4769 particle)
4770 (cond
4771 ((null level) nil)
4772 ((zerop level) t)
4773 ((null refs) t)
4774 ((null (gnus-parent-id refs)) t)
4775 ((and (= 1 level)
4776 (null (setq particle (gnus-id-to-article
4777 (gnus-parent-id refs))))
4778 (null (gnus-summary-thread-level particle)))))))
4779
4780(defun gnus-root-id (id)
4781 "Return the id of the root of the thread where ID appears."
4782 (let (last-id prev)
6748645f 4783 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4784 (setq last-id id
4785 id (gnus-parent-id (mail-header-references prev))))
4786 last-id))
4787
6748645f
LMI
4788(defun gnus-articles-in-thread (thread)
4789 "Return the list of articles in THREAD."
4790 (cons (mail-header-number (car thread))
4791 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4792
eec82323
LMI
4793(defun gnus-remove-thread (id &optional dont-remove)
4794 "Remove the thread that has ID in it."
6748645f 4795 (let (headers thread last-id)
eec82323 4796 ;; First go up in this thread until we find the root.
6748645f
LMI
4797 (setq last-id (gnus-root-id id)
4798 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4799 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4800 ;; been gathered into some loose thread, so we have to search
4801 ;; through the threads to find the thread we wanted.
4802 (let ((threads gnus-newsgroup-threads)
4803 sub)
4804 (while threads
4805 (setq sub (car threads))
4806 (if (stringp (car sub))
4807 ;; This is a gathered thread, so we look at the roots
4808 ;; below it to find whether this article is in this
4809 ;; gathered root.
4810 (progn
4811 (setq sub (cdr sub))
4812 (while sub
4813 (when (member (caar sub) headers)
4814 (setq thread (car threads)
4815 threads nil
4816 sub nil))
4817 (setq sub (cdr sub))))
4818 ;; It's an ordinary thread, so we check it.
4819 (when (eq (car sub) (car headers))
4820 (setq thread sub
4821 threads nil)))
4822 (setq threads (cdr threads)))
4823 ;; If this article is in no thread, then it's a root.
4824 (if thread
4825 (unless dont-remove
4826 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4827 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4828 (when thread
4829 (prog1
4830 thread ; We return this thread.
4831 (unless dont-remove
4832 (if (stringp (car thread))
4833 (progn
4834 ;; If we use dummy roots, then we have to remove the
4835 ;; dummy root as well.
4836 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4837 ;; We go to the dummy root by going to
4838 ;; the first sub-"thread", and then one line up.
4839 (gnus-summary-goto-article
4840 (mail-header-number (caadr thread)))
4841 (forward-line -1)
eec82323
LMI
4842 (gnus-delete-line)
4843 (gnus-data-compute-positions))
4844 (setq thread (cdr thread))
4845 (while thread
4846 (gnus-remove-thread-1 (car thread))
4847 (setq thread (cdr thread))))
4848 (gnus-remove-thread-1 thread))))))))
4849
4850(defun gnus-remove-thread-1 (thread)
4851 "Remove the thread THREAD recursively."
4852 (let ((number (mail-header-number (pop thread)))
4853 d)
4854 (setq thread (reverse thread))
4855 (while thread
4856 (gnus-remove-thread-1 (pop thread)))
4857 (when (setq d (gnus-data-find number))
4858 (goto-char (gnus-data-pos d))
16409b0b 4859 (gnus-summary-show-thread)
eec82323
LMI
4860 (gnus-data-remove
4861 number
01c52d31 4862 (- (point-at-bol)
eec82323 4863 (prog1
01c52d31 4864 (1+ (point-at-eol))
eec82323
LMI
4865 (gnus-delete-line)))))))
4866
4921bbdd 4867(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4868 (sort (mapcar (lambda (thread)
4869 (cons (car thread)
4870 (and (cdr thread)
4921bbdd 4871 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4872 threads) func))
4873
4921bbdd
CY
4874(defun gnus-sort-threads-loop (threads func)
4875 (let* ((superthread (cons nil threads))
4876 (stack (list (cons superthread threads)))
4877 remaining-threads thread)
4878 (while stack
4879 (setq remaining-threads (cdr (car stack)))
4880 (if remaining-threads
4881 (progn (setq thread (car remaining-threads))
4882 (setcdr (car stack) (cdr remaining-threads))
4883 (if (cdr thread)
4884 (push (cons thread (cdr thread)) stack)))
4885 (setq thread (caar stack))
4886 (setcdr thread (sort (cdr thread) func))
4887 (pop stack)))
4888 (cdr superthread)))
4889
eec82323
LMI
4890(defun gnus-sort-threads (threads)
4891 "Sort THREADS."
4892 (if (not gnus-thread-sort-functions)
4893 threads
6748645f 4894 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4895 (prog1
4896 (condition-case nil
4897 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4898 (gnus-sort-threads-recursive
4899 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4900 ;; Even after binding max-lisp-eval-depth, the recursive
4901 ;; sorter might fail for very long threads. In that case,
4902 ;; try using a (less well-tested) non-recursive sorter.
3d6e7a43
KY
4903 (error (gnus-message 9 "Sorting threads with loop...")
4904 (gnus-sort-threads-loop
4921bbdd
CY
4905 threads (gnus-make-sort-function
4906 gnus-thread-sort-functions))))
4907 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4908
4909(defun gnus-sort-articles (articles)
4910 "Sort ARTICLES."
4911 (when gnus-article-sort-functions
4912 (gnus-message 7 "Sorting articles...")
4913 (prog1
4914 (setq gnus-newsgroup-headers
4915 (sort articles (gnus-make-sort-function
4916 gnus-article-sort-functions)))
4917 (gnus-message 7 "Sorting articles...done"))))
4918
4919;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4920(defmacro gnus-thread-header (thread)
16409b0b
GM
4921 "Return header of first article in THREAD.
4922Note that THREAD must never, ever be anything else than a variable -
4923using some other form will lead to serious barfage."
eec82323
LMI
4924 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4925 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4926 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4927 (vector thread) 2))
4928
4929(defsubst gnus-article-sort-by-number (h1 h2)
4930 "Sort articles by article number."
4931 (< (mail-header-number h1)
4932 (mail-header-number h2)))
4933
4934(defun gnus-thread-sort-by-number (h1 h2)
4935 "Sort threads by root article number."
4936 (gnus-article-sort-by-number
4937 (gnus-thread-header h1) (gnus-thread-header h2)))
4938
23f87bed 4939(defsubst gnus-article-sort-by-random (h1 h2)
0b6799c3 4940 "Sort articles randomly."
23f87bed
MB
4941 (zerop (random 2)))
4942
4943(defun gnus-thread-sort-by-random (h1 h2)
0b6799c3 4944 "Sort threads randomly."
23f87bed
MB
4945 (gnus-article-sort-by-random
4946 (gnus-thread-header h1) (gnus-thread-header h2)))
4947
eec82323
LMI
4948(defsubst gnus-article-sort-by-lines (h1 h2)
4949 "Sort articles by article Lines header."
4950 (< (mail-header-lines h1)
4951 (mail-header-lines h2)))
4952
4953(defun gnus-thread-sort-by-lines (h1 h2)
4954 "Sort threads by root article Lines header."
4955 (gnus-article-sort-by-lines
4956 (gnus-thread-header h1) (gnus-thread-header h2)))
4957
16409b0b
GM
4958(defsubst gnus-article-sort-by-chars (h1 h2)
4959 "Sort articles by octet length."
4960 (< (mail-header-chars h1)
4961 (mail-header-chars h2)))
4962
4963(defun gnus-thread-sort-by-chars (h1 h2)
4964 "Sort threads by root article octet length."
4965 (gnus-article-sort-by-chars
4966 (gnus-thread-header h1) (gnus-thread-header h2)))
4967
eec82323
LMI
4968(defsubst gnus-article-sort-by-author (h1 h2)
4969 "Sort articles by root author."
b4fde39f 4970 (gnus-string<
eec82323
LMI
4971 (let ((extract (funcall
4972 gnus-extract-address-components
4973 (mail-header-from h1))))
4974 (or (car extract) (cadr extract) ""))
4975 (let ((extract (funcall
4976 gnus-extract-address-components
4977 (mail-header-from h2))))
4978 (or (car extract) (cadr extract) ""))))
4979
4980(defun gnus-thread-sort-by-author (h1 h2)
4981 "Sort threads by root author."
4982 (gnus-article-sort-by-author
4983 (gnus-thread-header h1) (gnus-thread-header h2)))
4984
01c52d31
MB
4985(defsubst gnus-article-sort-by-recipient (h1 h2)
4986 "Sort articles by recipient."
4987 (gnus-string<
4988 (let ((extract (funcall
4989 gnus-extract-address-components
4990 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4991 (or (car extract) (cadr extract)))
4992 (let ((extract (funcall
4993 gnus-extract-address-components
4994 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4995 (or (car extract) (cadr extract)))))
4996
4997(defun gnus-thread-sort-by-recipient (h1 h2)
4998 "Sort threads by root recipient."
4999 (gnus-article-sort-by-recipient
5000 (gnus-thread-header h1) (gnus-thread-header h2)))
5001
eec82323
LMI
5002(defsubst gnus-article-sort-by-subject (h1 h2)
5003 "Sort articles by root subject."
b4fde39f 5004 (gnus-string<
eec82323
LMI
5005 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5006 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5007
5008(defun gnus-thread-sort-by-subject (h1 h2)
5009 "Sort threads by root subject."
5010 (gnus-article-sort-by-subject
5011 (gnus-thread-header h1) (gnus-thread-header h2)))
5012
5013(defsubst gnus-article-sort-by-date (h1 h2)
5014 "Sort articles by root article date."
16409b0b 5015 (time-less-p
eec82323
LMI
5016 (gnus-date-get-time (mail-header-date h1))
5017 (gnus-date-get-time (mail-header-date h2))))
5018
5019(defun gnus-thread-sort-by-date (h1 h2)
5020 "Sort threads by root article date."
5021 (gnus-article-sort-by-date
5022 (gnus-thread-header h1) (gnus-thread-header h2)))
5023
5024(defsubst gnus-article-sort-by-score (h1 h2)
5025 "Sort articles by root article score.
5026Unscored articles will be counted as having a score of zero."
5027 (> (or (cdr (assq (mail-header-number h1)
5028 gnus-newsgroup-scored))
5029 gnus-summary-default-score 0)
5030 (or (cdr (assq (mail-header-number h2)
5031 gnus-newsgroup-scored))
5032 gnus-summary-default-score 0)))
5033
5034(defun gnus-thread-sort-by-score (h1 h2)
5035 "Sort threads by root article score."
5036 (gnus-article-sort-by-score
5037 (gnus-thread-header h1) (gnus-thread-header h2)))
5038
5039(defun gnus-thread-sort-by-total-score (h1 h2)
5040 "Sort threads by the sum of all scores in the thread.
5041Unscored articles will be counted as having a score of zero."
5042 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5043
5044(defun gnus-thread-total-score (thread)
16409b0b 5045 ;; This function find the total score of THREAD.
23f87bed
MB
5046 (cond
5047 ((null thread)
5048 0)
5049 ((consp thread)
5050 (if (stringp (car thread))
5051 (apply gnus-thread-score-function 0
5052 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5053 (gnus-thread-total-score-1 thread)))
5054 (t
5055 (gnus-thread-total-score-1 (list thread)))))
5056
130e977f
LMI
5057(defun gnus-article-sort-by-most-recent-number (h1 h2)
5058 "Sort articles by number."
5059 (gnus-article-sort-by-number h1 h2))
5060
23f87bed
MB
5061(defun gnus-thread-sort-by-most-recent-number (h1 h2)
5062 "Sort threads such that the thread with the most recently arrived article comes first."
5063 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5064
5065(defun gnus-thread-highest-number (thread)
5066 "Return the highest article number in THREAD."
5067 (apply 'max (mapcar (lambda (header)
5068 (mail-header-number header))
5069 (message-flatten-list thread))))
5070
130e977f
LMI
5071(defun gnus-article-sort-by-most-recent-date (h1 h2)
5072 "Sort articles by number."
5073 (gnus-article-sort-by-date h1 h2))
5074
23f87bed
MB
5075(defun gnus-thread-sort-by-most-recent-date (h1 h2)
5076 "Sort threads such that the thread with the most recently dated article comes first."
5077 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5078
3d6e7a43
KY
5079; Since this is called not only to sort the top-level threads, but
5080; also in recursive sorts to order the articles within a thread, each
5081; article will be processed many times. Thus it speeds things up
5082; quite a bit to use gnus-date-get-time, which caches the time value.
23f87bed
MB
5083(defun gnus-thread-latest-date (thread)
5084 "Return the highest article date in THREAD."
3d6e7a43
KY
5085 (apply 'max
5086 (mapcar (lambda (header) (gnus-float-time
5087 (gnus-date-get-time
5088 (mail-header-date header))))
5089 (message-flatten-list thread))))
eec82323
LMI
5090
5091(defun gnus-thread-total-score-1 (root)
5092 ;; This function find the total score of the thread below ROOT.
5093 (setq root (car root))
5094 (apply gnus-thread-score-function
5095 (or (append
5096 (mapcar 'gnus-thread-total-score
6748645f 5097 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
5098 (when (> (mail-header-number root) 0)
5099 (list (or (cdr (assq (mail-header-number root)
5100 gnus-newsgroup-scored))
5101 gnus-summary-default-score 0))))
5102 (list gnus-summary-default-score)
5103 '(0))))
5104
5105;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5106(defvar gnus-tmp-prev-subject nil)
5107(defvar gnus-tmp-false-parent nil)
5108(defvar gnus-tmp-root-expunged nil)
5109(defvar gnus-tmp-dummy-line nil)
5110
16409b0b
GM
5111(defun gnus-extra-header (type &optional header)
5112 "Return the extra header of TYPE."
5113 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5114 ""))
5115
23f87bed
MB
5116(defvar gnus-tmp-thread-tree-header-string "")
5117
5118(defcustom gnus-sum-thread-tree-root "> "
5119 "With %B spec, used for the root of a thread.
5120If nil, use subject instead."
bf247b6e 5121 :version "22.1"
ad136a7c 5122 :type '(radio (const :format "%v " nil) string)
23f87bed 5123 :group 'gnus-thread)
01c52d31 5124
23f87bed
MB
5125(defcustom gnus-sum-thread-tree-false-root "> "
5126 "With %B spec, used for a false root of a thread.
5127If nil, use subject instead."
bf247b6e 5128 :version "22.1"
ad136a7c 5129 :type '(radio (const :format "%v " nil) string)
23f87bed 5130 :group 'gnus-thread)
01c52d31 5131
23f87bed
MB
5132(defcustom gnus-sum-thread-tree-single-indent ""
5133 "With %B spec, used for a thread with just one message.
5134If nil, use subject instead."
bf247b6e 5135 :version "22.1"
ad136a7c 5136 :type '(radio (const :format "%v " nil) string)
23f87bed 5137 :group 'gnus-thread)
01c52d31 5138
23f87bed
MB
5139(defcustom gnus-sum-thread-tree-vertical "| "
5140 "With %B spec, used for drawing a vertical line."
bf247b6e 5141 :version "22.1"
23f87bed
MB
5142 :type 'string
5143 :group 'gnus-thread)
01c52d31 5144
23f87bed
MB
5145(defcustom gnus-sum-thread-tree-indent " "
5146 "With %B spec, used for indenting."
bf247b6e 5147 :version "22.1"
23f87bed
MB
5148 :type 'string
5149 :group 'gnus-thread)
01c52d31 5150
23f87bed
MB
5151(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5152 "With %B spec, used for a leaf with brothers."
bf247b6e 5153 :version "22.1"
23f87bed
MB
5154 :type 'string
5155 :group 'gnus-thread)
01c52d31 5156
23f87bed
MB
5157(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5158 "With %B spec, used for a leaf without brothers."
bf247b6e 5159 :version "22.1"
23f87bed
MB
5160 :type 'string
5161 :group 'gnus-thread)
5162
1fc34624
GM
5163(defcustom gnus-summary-display-while-building nil
5164 "If non-nil, show and update the summary buffer as it's being built.
5165If the value is t, update the buffer after every line is inserted. If
5166the value is an integer (N), update the display every N lines."
5167 :version "22.1"
5168 :group 'gnus-thread
5169 :type '(choice (const :tag "off" nil)
5170 number
5171 (const :tag "frequently" t)))
5172
eec82323
LMI
5173(defun gnus-summary-prepare-threads (threads)
5174 "Prepare summary buffer from THREADS and indentation LEVEL.
5175THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5176or a straight list of headers."
5177 (gnus-message 7 "Generating summary...")
5178
5179 (setq gnus-newsgroup-threads threads)
5180 (beginning-of-line)
5181
5182 (let ((gnus-tmp-level 0)
5183 (default-score (or gnus-summary-default-score 0))
5184 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
5185 (building-line-count gnus-summary-display-while-building)
5186 (building-count (integerp gnus-summary-display-while-building))
eec82323 5187 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
5188 new-roots gnus-tmp-new-adopts thread-end simp-subject
5189 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
5190 gnus-tmp-replied gnus-tmp-subject-or-nil
5191 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5192 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
5193 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5194 tree-stack)
eec82323 5195
23f87bed
MB
5196 (setq gnus-tmp-prev-subject nil
5197 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
5198
5199 (if (vectorp (car threads))
5200 ;; If this is a straight (sic) list of headers, then a
5201 ;; threaded summary display isn't required, so we just create
5202 ;; an unthreaded one.
5203 (gnus-summary-prepare-unthreaded threads)
5204
5205 ;; Do the threaded display.
5206
23f87bed
MB
5207 (if gnus-summary-display-while-building
5208 (switch-to-buffer (buffer-name)))
eec82323
LMI
5209 (while (or threads stack gnus-tmp-new-adopts new-roots)
5210
5211 (if (and (= gnus-tmp-level 0)
eec82323
LMI
5212 (or (not stack)
5213 (= (caar stack) 0))
5214 (not gnus-tmp-false-parent)
5215 (or gnus-tmp-new-adopts new-roots))
5216 (if gnus-tmp-new-adopts
5217 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5218 thread (list (car gnus-tmp-new-adopts))
5219 gnus-tmp-header (caar thread)
5220 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5221 (when new-roots
5222 (setq thread (list (car new-roots))
5223 gnus-tmp-header (caar thread)
5224 new-roots (cdr new-roots))))
5225
5226 (if threads
5227 ;; If there are some threads, we do them before the
5228 ;; threads on the stack.
5229 (setq thread threads
5230 gnus-tmp-header (caar thread))
5231 ;; There were no current threads, so we pop something off
5232 ;; the stack.
5233 (setq state (car stack)
5234 gnus-tmp-level (car state)
23f87bed
MB
5235 tree-stack (cadr state)
5236 thread (caddr state)
eec82323
LMI
5237 stack (cdr stack)
5238 gnus-tmp-header (caar thread))))
5239
5240 (setq gnus-tmp-false-parent nil)
5241 (setq gnus-tmp-root-expunged nil)
5242 (setq thread-end nil)
5243
5244 (if (stringp gnus-tmp-header)
5245 ;; The header is a dummy root.
5246 (cond
5247 ((eq gnus-summary-make-false-root 'adopt)
5248 ;; We let the first article adopt the rest.
5249 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5250 (cddar thread)))
5251 (setq gnus-tmp-gathered
5252 (nconc (mapcar
5253 (lambda (h) (mail-header-number (car h)))
5254 (cddar thread))
5255 gnus-tmp-gathered))
5256 (setq thread (cons (list (caar thread)
5257 (cadar thread))
5258 (cdr thread)))
5259 (setq gnus-tmp-level -1
5260 gnus-tmp-false-parent t))
5261 ((eq gnus-summary-make-false-root 'empty)
5262 ;; We print adopted articles with empty subject fields.
5263 (setq gnus-tmp-gathered
5264 (nconc (mapcar
5265 (lambda (h) (mail-header-number (car h)))
5266 (cddar thread))
5267 gnus-tmp-gathered))
5268 (setq gnus-tmp-level -1))
5269 ((eq gnus-summary-make-false-root 'dummy)
5270 ;; We remember that we probably want to output a dummy
5271 ;; root.
5272 (setq gnus-tmp-dummy-line gnus-tmp-header)
5273 (setq gnus-tmp-prev-subject gnus-tmp-header))
5274 (t
5275 ;; We do not make a root for the gathered
5276 ;; sub-threads at all.
5277 (setq gnus-tmp-level -1)))
5278
5279 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
5280 subject (mail-header-subject gnus-tmp-header)
5281 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
5282
5283 (cond
5284 ;; If the thread has changed subject, we might want to make
5285 ;; this subthread into a root.
5286 ((and (null gnus-thread-ignore-subject)
5287 (not (zerop gnus-tmp-level))
5288 gnus-tmp-prev-subject
23f87bed 5289 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5290 (setq new-roots (nconc new-roots (list (car thread)))
5291 thread-end t
5292 gnus-tmp-header nil))
5293 ;; If the article lies outside the current limit,
5294 ;; then we do not display it.
5295 ((not (memq number gnus-newsgroup-limit))
5296 (setq gnus-tmp-gathered
5297 (nconc (mapcar
5298 (lambda (h) (mail-header-number (car h)))
5299 (cdar thread))
5300 gnus-tmp-gathered))
5301 (setq gnus-tmp-new-adopts (if (cdar thread)
5302 (append gnus-tmp-new-adopts
5303 (cdar thread))
5304 gnus-tmp-new-adopts)
5305 thread-end t
5306 gnus-tmp-header nil)
5307 (when (zerop gnus-tmp-level)
5308 (setq gnus-tmp-root-expunged t)))
5309 ;; Perhaps this article is to be marked as read?
5310 ((and gnus-summary-mark-below
5311 (< (or (cdr (assq number gnus-newsgroup-scored))
5312 default-score)
5313 gnus-summary-mark-below)
5314 ;; Don't touch sparse articles.
5315 (not (gnus-summary-article-sparse-p number))
5316 (not (gnus-summary-article-ancient-p number)))
5317 (setq gnus-newsgroup-unreads
5318 (delq number gnus-newsgroup-unreads))
5319 (if gnus-newsgroup-auto-expire
23f87bed
MB
5320 (setq gnus-newsgroup-expirable
5321 (gnus-add-to-sorted-list
5322 gnus-newsgroup-expirable number))
eec82323
LMI
5323 (push (cons number gnus-low-score-mark)
5324 gnus-newsgroup-reads))))
5325
5326 (when gnus-tmp-header
5327 ;; We may have an old dummy line to output before this
5328 ;; article.
6748645f
LMI
5329 (when (and gnus-tmp-dummy-line
5330 (gnus-subject-equal
5331 gnus-tmp-dummy-line
5332 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
5333 (gnus-summary-insert-dummy-line
5334 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5335 (setq gnus-tmp-dummy-line nil))
5336
5337 ;; Compute the mark.
5338 (setq gnus-tmp-unread (gnus-article-mark number))
5339
5340 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5341 gnus-tmp-header gnus-tmp-level)
5342 gnus-newsgroup-data)
5343
5344 ;; Actually insert the line.
5345 (setq
5346 gnus-tmp-subject-or-nil
5347 (cond
5348 ((and gnus-thread-ignore-subject
5349 gnus-tmp-prev-subject
23f87bed 5350 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5351 subject)
5352 ((zerop gnus-tmp-level)
5353 (if (and (eq gnus-summary-make-false-root 'empty)
5354 (memq number gnus-tmp-gathered)
5355 gnus-tmp-prev-subject
23f87bed 5356 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5357 gnus-summary-same-subject
5358 subject))
5359 (t gnus-summary-same-subject)))
5360 (if (and (eq gnus-summary-make-false-root 'adopt)
5361 (= gnus-tmp-level 1)
5362 (memq number gnus-tmp-gathered))
5363 (setq gnus-tmp-opening-bracket ?\<
5364 gnus-tmp-closing-bracket ?\>)
5365 (setq gnus-tmp-opening-bracket ?\[
5366 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5367 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5368 (gnus-make-thread-indent-array
5369 (max (* 2 (length gnus-thread-indent-array))
5370 gnus-tmp-level)))
eec82323
LMI
5371 (setq
5372 gnus-tmp-indentation
5373 (aref gnus-thread-indent-array gnus-tmp-level)
5374 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5375 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5376 gnus-summary-default-score 0)
5377 gnus-tmp-score-char
5378 (if (or (null gnus-summary-default-score)
5379 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5380 gnus-summary-zcore-fuzz))
23f87bed 5381 ? ;Whitespace
eec82323
LMI
5382 (if (< gnus-tmp-score gnus-summary-default-score)
5383 gnus-score-below-mark gnus-score-over-mark))
5384 gnus-tmp-replied
5385 (cond ((memq number gnus-newsgroup-processable)
5386 gnus-process-mark)
5387 ((memq number gnus-newsgroup-cached)
5388 gnus-cached-mark)
5389 ((memq number gnus-newsgroup-replied)
5390 gnus-replied-mark)
23f87bed
MB
5391 ((memq number gnus-newsgroup-forwarded)
5392 gnus-forwarded-mark)
eec82323
LMI
5393 ((memq number gnus-newsgroup-saved)
5394 gnus-saved-mark)
23f87bed
MB
5395 ((memq number gnus-newsgroup-recent)
5396 gnus-recent-mark)
5397 ((memq number gnus-newsgroup-unseen)
5398 gnus-unseen-mark)
5399 (t gnus-no-mark))
5400 gnus-tmp-downloaded
5401 (cond ((memq number gnus-newsgroup-undownloaded)
5402 gnus-undownloaded-mark)
5403 (gnus-newsgroup-agentized
5404 gnus-downloaded-mark)
5405 (t
5406 gnus-no-mark))
eec82323
LMI
5407 gnus-tmp-from (mail-header-from gnus-tmp-header)
5408 gnus-tmp-name
5409 (cond
5410 ((string-match "<[^>]+> *$" gnus-tmp-from)
5411 (setq beg-match (match-beginning 0))
23f87bed
MB
5412 (or (and (string-match "^\".+\"" gnus-tmp-from)
5413 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5414 (substring gnus-tmp-from 0 beg-match)))
5415 ((string-match "(.+)" gnus-tmp-from)
5416 (substring gnus-tmp-from
5417 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5418 (t gnus-tmp-from))
5419
5420 ;; Do the %B string
5421 gnus-tmp-thread-tree-header-string
5422 (cond
5423 ((not gnus-show-threads) "")
5424 ((zerop gnus-tmp-level)
5425 (cond ((cdar thread)
5426 (or gnus-sum-thread-tree-root subject))
5427 (gnus-tmp-new-adopts
5428 (or gnus-sum-thread-tree-false-root subject))
5429 (t
5430 (or gnus-sum-thread-tree-single-indent subject))))
5431 (t
5432 (concat (apply 'concat
5433 (mapcar (lambda (item)
5434 (if (= item 1)
5435 gnus-sum-thread-tree-vertical
5436 gnus-sum-thread-tree-indent))
5437 (cdr (reverse tree-stack))))
5438 (if (nth 1 thread)
5439 gnus-sum-thread-tree-leaf-with-other
5440 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5441 (when (string= gnus-tmp-name "")
5442 (setq gnus-tmp-name gnus-tmp-from))
5443 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5444 (setq gnus-tmp-lines -1))
5445 (if (= gnus-tmp-lines -1)
5446 (setq gnus-tmp-lines "?")
5447 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
61b1af82
G
5448 (gnus-put-text-property
5449 (point)
5450 (progn (eval gnus-summary-line-format-spec) (point))
5451 'gnus-number number)
5452 (when gnus-visual-p
5453 (forward-line -1)
5454 (gnus-summary-highlight-line)
5455 (when gnus-summary-update-hook
5456 (gnus-run-hooks 'gnus-summary-update-hook))
5457 (forward-line 1))
5458
5459 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5460
5461 (when (nth 1 thread)
23f87bed
MB
5462 (push (list (max 0 gnus-tmp-level)
5463 (copy-sequence tree-stack)
5464 (nthcdr 1 thread))
5465 stack))
5466 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5467 (incf gnus-tmp-level)
5468 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5469 (if gnus-summary-display-while-building
5470 (if building-count
5471 (progn
5472 ;; use a set frequency
5473 (setq building-line-count (1- building-line-count))
5474 (when (= building-line-count 0)
5475 (sit-for 0)
5476 (setq building-line-count
5477 gnus-summary-display-while-building)))
5478 ;; always
5479 (sit-for 0)))
eec82323
LMI
5480 (unless threads
5481 (setq gnus-tmp-level 0)))))
5482 (gnus-message 7 "Generating summary...done"))
5483
5484(defun gnus-summary-prepare-unthreaded (headers)
5485 "Generate an unthreaded summary buffer based on HEADERS."
5486 (let (header number mark)
5487
5488 (beginning-of-line)
5489
5490 (while headers
5491 ;; We may have to root out some bad articles...
5492 (when (memq (setq number (mail-header-number
5493 (setq header (pop headers))))
5494 gnus-newsgroup-limit)
5495 ;; Mark article as read when it has a low score.
5496 (when (and gnus-summary-mark-below
5497 (< (or (cdr (assq number gnus-newsgroup-scored))
5498 gnus-summary-default-score 0)
5499 gnus-summary-mark-below)
5500 (not (gnus-summary-article-ancient-p number)))
5501 (setq gnus-newsgroup-unreads
5502 (delq number gnus-newsgroup-unreads))
5503 (if gnus-newsgroup-auto-expire
5504 (push number gnus-newsgroup-expirable)
5505 (push (cons number gnus-low-score-mark)
5506 gnus-newsgroup-reads)))
5507
5508 (setq mark (gnus-article-mark number))
5509 (push (gnus-data-make number mark (1+ (point)) header 0)
5510 gnus-newsgroup-data)
5511 (gnus-summary-insert-line
5512 header 0 number
23f87bed 5513 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5514 mark (memq number gnus-newsgroup-replied)
5515 (memq number gnus-newsgroup-expirable)
5516 (mail-header-subject header) nil
5517 (cdr (assq number gnus-newsgroup-scored))
5518 (memq number gnus-newsgroup-processable))))))
5519
d6cd56f1
JD
5520(defun gnus-group-get-list-identifiers (group)
5521 "Get list identifier regexp for GROUP."
5522 (or (gnus-parameter-list-identifier group)
5523 (if (consp gnus-list-identifiers)
5524 (mapconcat 'identity gnus-list-identifiers " *\\|")
5525 gnus-list-identifiers)))
5526
16409b0b
GM
5527(defun gnus-summary-remove-list-identifiers ()
5528 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
d6cd56f1
JD
5529 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5530 changed subject)
23f87bed 5531 (when regexp
01c52d31 5532 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
23f87bed
MB
5533 (dolist (header gnus-newsgroup-headers)
5534 (setq subject (mail-header-subject header)
5535 changed nil)
01c52d31 5536 (while (string-match regexp subject)
23f87bed 5537 (setq subject
01c52d31 5538 (concat (substring subject 0 (match-beginning 1))
23f87bed
MB
5539 (substring subject (match-end 0)))
5540 changed t))
23f87bed 5541 (when changed
01c52d31
MB
5542 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5543 (setq subject
5544 (concat (substring subject 0 (match-beginning 1))
5545 (substring subject (match-end 1)))))
23f87bed
MB
5546 (mail-header-set-subject header subject))))))
5547
4ddab346 5548(defun gnus-fetch-headers (articles &optional limit force-new dependencies)
23f87bed
MB
5549 "Fetch headers of ARTICLES."
5550 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5551 (gnus-message 5 "Fetching headers for %s..." name)
5552 (prog1
5553 (if (eq 'nov
5554 (setq gnus-headers-retrieved-by
5555 (gnus-retrieve-headers
5556 articles gnus-newsgroup-name
4ddab346
G
5557 (or limit
5558 ;; We might want to fetch old headers, but
5559 ;; not if there is only 1 article.
5560 (and (or (and
5561 (not (eq gnus-fetch-old-headers 'some))
5562 (not (numberp gnus-fetch-old-headers)))
5563 (> (length articles) 1))
5564 gnus-fetch-old-headers)))))
23f87bed 5565 (gnus-get-newsgroup-headers-xover
4ddab346
G
5566 articles force-new dependencies gnus-newsgroup-name t)
5567 (gnus-get-newsgroup-headers dependencies force-new))
23f87bed 5568 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5569
6748645f 5570(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5571 "Select newsgroup GROUP.
6748645f
LMI
5572If READ-ALL is non-nil, all articles in the group are selected.
5573If SELECT-ARTICLES, only select those articles from GROUP."
01c52d31 5574 (let* ((entry (gnus-group-entry group))
eec82323
LMI
5575 ;;!!! Dirty hack; should be removed.
5576 (gnus-summary-ignore-duplicates
23f87bed 5577 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5578 t
5579 gnus-summary-ignore-duplicates))
5580 (info (nth 2 entry))
01c52d31 5581 charset articles fetched-articles cached)
eec82323
LMI
5582
5583 (unless (gnus-check-server
475e0e0c
GM
5584 (set (make-local-variable 'gnus-current-select-method)
5585 (gnus-find-method-for-group group)))
eec82323 5586 (error "Couldn't open server"))
01c52d31 5587 (setq charset (gnus-group-name-charset gnus-current-select-method group))
eec82323
LMI
5588
5589 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5590 (gnus-activate-group group) ; Or we can activate it...
5591 (progn ; Or we bug out.
5592 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5593 (gnus-kill-buffer (current-buffer)))
01c52d31
MB
5594 (error
5595 "Couldn't activate group %s: %s"
5596 (mm-decode-coding-string group charset)
5597 (mm-decode-coding-string (gnus-status-message group) charset))))
eec82323
LMI
5598
5599 (unless (gnus-request-group group t)
20a673b2
KY
5600 (when (equal major-mode 'gnus-summary-mode)
5601 (gnus-kill-buffer (current-buffer)))
5602 (error "Couldn't request group %s: %s"
5603 (mm-decode-coding-string group charset)
5604 (mm-decode-coding-string (gnus-status-message group) charset)))
eec82323 5605
54b6f6ed
G
5606 (when (and gnus-agent
5607 (gnus-active group))
54506618 5608 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5609
23f87bed
MB
5610 (setq gnus-summary-use-undownloaded-faces
5611 (gnus-agent-find-parameter
5612 group
5613 'agent-enable-undownloaded-faces)))
5614
5615 (setq gnus-newsgroup-name group
5616 gnus-newsgroup-unselected nil
5617 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5618
5619 (let ((display (gnus-group-find-parameter group 'display)))
5620 (setq gnus-newsgroup-display
5621 (cond
5622 ((not (zerop (or (car-safe read-all) 0)))
5623 ;; The user entered the group with C-u SPC/RET, let's show
5624 ;; all articles.
5625 'gnus-not-ignore)
5626 ((eq display 'all)
5627 'gnus-not-ignore)
5628 ((arrayp display)
5629 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5630 ((numberp display)
5631 ;; The following is probably the "correct" solution, but
5632 ;; it makes Gnus fetch all headers and then limit the
5633 ;; articles (which is slow), so instead we hack the
5634 ;; select-articles parameter instead. -- Simon Josefsson
5635 ;; <jas@kth.se>
5636 ;;
5637 ;; (gnus-byte-compile
5638 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5639 ;; display)))))
5640 (setq select-articles
5641 (gnus-uncompress-range
5642 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5643 (if (> tmp 0)
5644 tmp
5645 1))
5646 (cdr (gnus-active group)))))
5647 nil)
5648 (t
5649 nil))))
eec82323 5650
23f87bed 5651 (gnus-summary-setup-default-charset)
eec82323
LMI
5652
5653 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5654 (when (gnus-virtual-group-p group)
5655 (setq cached gnus-newsgroup-cached))
5656
5657 (setq gnus-newsgroup-unreads
23f87bed
MB
5658 (gnus-sorted-ndifference
5659 (gnus-sorted-ndifference gnus-newsgroup-unreads
5660 gnus-newsgroup-marked)
eec82323
LMI
5661 gnus-newsgroup-dormant))
5662
5663 (setq gnus-newsgroup-processable nil)
5664
bb7f5cbc 5665 (gnus-update-read-articles group gnus-newsgroup-unreads t)
eec82323 5666
23f87bed
MB
5667 ;; Adjust and set lists of article marks.
5668 (when info
5669 (gnus-adjust-marked-articles info))
6748645f
LMI
5670 (if (setq articles select-articles)
5671 (setq gnus-newsgroup-unselected
23f87bed 5672 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5673 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5674
5675 (cond
5676 ((null articles)
5677 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5678 'quit)
5679 ((eq articles 0) nil)
5680 (t
5681 ;; Init the dependencies hash table.
5682 (setq gnus-newsgroup-dependencies
5683 (gnus-make-hashtable (length articles)))
16409b0b 5684 (gnus-set-global-variables)
eec82323 5685 ;; Retrieve the headers and read them in.
23f87bed
MB
5686
5687 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5688
5689 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5690 (when cached
5691 (setq gnus-newsgroup-cached cached))
5692
5693 ;; Suppress duplicates?
5694 (when gnus-suppress-duplicates
5695 (gnus-dup-suppress-articles))
5696
5697 ;; Set the initial limit.
5698 (setq gnus-newsgroup-limit (copy-sequence articles))
5699 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5700 (setq fetched-articles
5701 (mapcar (lambda (headers) (mail-header-number headers))
5702 gnus-newsgroup-headers))
5703 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5704 (setq gnus-newsgroup-unreads
23f87bed
MB
5705 (gnus-sorted-nintersection
5706 gnus-newsgroup-unreads fetched-articles))
5707 (gnus-compute-unseen-list)
5708
eec82323
LMI
5709 ;; Removed marked articles that do not exist.
5710 (gnus-update-missing-marks
23f87bed 5711 (gnus-sorted-difference articles fetched-articles))
eec82323 5712 ;; We might want to build some more threads first.
6748645f
LMI
5713 (when (and gnus-fetch-old-headers
5714 (eq gnus-headers-retrieved-by 'nov))
5715 (if (eq gnus-fetch-old-headers 'invisible)
5716 (gnus-build-all-threads)
5717 (gnus-build-old-threads)))
5718 ;; Let the Gnus agent mark articles as read.
5719 (when gnus-agent
5720 (gnus-agent-get-undownloaded-list))
16409b0b 5721 ;; Remove list identifiers from subject
d6cd56f1 5722 (gnus-summary-remove-list-identifiers)
eec82323
LMI
5723 ;; Check whether auto-expire is to be done in this group.
5724 (setq gnus-newsgroup-auto-expire
b5244046
LMI
5725 (and (gnus-group-auto-expirable-p group)
5726 (not (gnus-group-read-only-p group))))
eec82323 5727 ;; Set up the article buffer now, if necessary.
01c52d31
MB
5728 (unless (and gnus-single-article-buffer
5729 (equal gnus-article-buffer "*Article*"))
eec82323
LMI
5730 (gnus-article-setup-buffer))
5731 ;; First and last article in this newsgroup.
5732 (when gnus-newsgroup-headers
5733 (setq gnus-newsgroup-begin
5734 (mail-header-number (car gnus-newsgroup-headers))
5735 gnus-newsgroup-end
5736 (mail-header-number
5737 (gnus-last-element gnus-newsgroup-headers))))
5738 ;; GROUP is successfully selected.
5739 (or gnus-newsgroup-headers t)))))
5740
23f87bed
MB
5741(defun gnus-compute-unseen-list ()
5742 ;; The `seen' marks are treated specially.
5743 (if (not gnus-newsgroup-seen)
5744 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5745 (setq gnus-newsgroup-unseen
5746 (gnus-inverse-list-range-intersection
5747 gnus-newsgroup-articles gnus-newsgroup-seen))))
5748
d09ae6ca
GM
5749(declare-function gnus-get-predicate "gnus-agent" (predicate))
5750
23f87bed
MB
5751(defun gnus-summary-display-make-predicate (display)
5752 (require 'gnus-agent)
5753 (when (= (length display) 1)
5754 (setq display (car display)))
5755 (unless gnus-summary-display-cache
5756 (dolist (elem (append '((unread . unread)
5757 (read . read)
5758 (unseen . unseen))
5759 gnus-article-mark-lists))
5760 (push (cons (cdr elem)
3a3cbf0a 5761 (gnus-byte-compile ;Why bother?
23f87bed
MB
5762 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5763 gnus-summary-display-cache)))
5764 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5765 (gnus-category-predicate-cache gnus-summary-display-cache))
5766 (gnus-get-predicate display)))
5767
3a3cbf0a
SM
5768;; Uses the dynamically bound `gnus-number' variable.
5769(defvar gnus-number)
23f87bed 5770(defun gnus-article-marked-p (type &optional article)
3a3cbf0a 5771 (let ((article (or article gnus-number)))
23f87bed
MB
5772 (cond
5773 ((eq type 'tick)
5774 (memq article gnus-newsgroup-marked))
5775 ((eq type 'spam)
5776 (memq article gnus-newsgroup-spam-marked))
5777 ((eq type 'unsend)
5778 (memq article gnus-newsgroup-unsendable))
5779 ((eq type 'undownload)
5780 (memq article gnus-newsgroup-undownloaded))
5781 ((eq type 'download)
5782 (memq article gnus-newsgroup-downloadable))
5783 ((eq type 'unread)
5784 (memq article gnus-newsgroup-unreads))
5785 ((eq type 'read)
5786 (memq article gnus-newsgroup-reads))
5787 ((eq type 'dormant)
5788 (memq article gnus-newsgroup-dormant) )
5789 ((eq type 'expire)
5790 (memq article gnus-newsgroup-expirable))
5791 ((eq type 'reply)
5792 (memq article gnus-newsgroup-replied))
5793 ((eq type 'killed)
5794 (memq article gnus-newsgroup-killed))
5795 ((eq type 'bookmark)
5796 (assq article gnus-newsgroup-bookmarks))
5797 ((eq type 'score)
5798 (assq article gnus-newsgroup-scored))
5799 ((eq type 'save)
5800 (memq article gnus-newsgroup-saved))
5801 ((eq type 'cache)
5802 (memq article gnus-newsgroup-cached))
5803 ((eq type 'forward)
5804 (memq article gnus-newsgroup-forwarded))
5805 ((eq type 'seen)
5806 (not (memq article gnus-newsgroup-unseen)))
5807 ((eq type 'recent)
5808 (memq article gnus-newsgroup-recent))
5809 (t t))))
5810
eec82323 5811(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5812 "Find out what articles the user wants to read."
4c7468f6
LMI
5813 (let* ((only-read-p t)
5814 (articles
eec82323
LMI
5815 ;; Select all articles if `read-all' is non-nil, or if there
5816 ;; are no unread articles.
5817 (if (or read-all
5818 (and (zerop (length gnus-newsgroup-marked))
5819 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5820 ;; Fetch all if the predicate is non-nil.
5821 gnus-newsgroup-display)
5822 ;; We want to select the headers for all the articles in
5823 ;; the group, so we select either all the active
5824 ;; articles in the group, or (if that's nil), the
5825 ;; articles in the cache.
16409b0b 5826 (or
4b70e299 5827 (if gnus-newsgroup-maximum-articles
11abff8e
MB
5828 (let ((active (gnus-active group)))
5829 (gnus-uncompress-range
5830 (cons (max (car active)
4b70e299
MB
5831 (- (cdr active)
5832 gnus-newsgroup-maximum-articles
5833 -1))
11abff8e
MB
5834 (cdr active))))
5835 (gnus-uncompress-range (gnus-active group)))
16409b0b 5836 (gnus-cache-articles-in-group group))
23f87bed 5837 ;; Select only the "normal" subset of articles.
4c7468f6 5838 (setq only-read-p nil)
23f87bed
MB
5839 (gnus-sorted-nunion
5840 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5841 gnus-newsgroup-unreads)))
eec82323
LMI
5842 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5843 (scored (length scored-list))
5844 (number (length articles))
5845 (marked (+ (length gnus-newsgroup-marked)
5846 (length gnus-newsgroup-dormant)))
5847 (select
5848 (cond
5849 ((numberp read-all)
5850 read-all)
23f87bed
MB
5851 ((numberp gnus-newsgroup-display)
5852 gnus-newsgroup-display)
eec82323
LMI
5853 (t
5854 (condition-case ()
5855 (cond
5856 ((and (or (<= scored marked) (= scored number))
5857 (numberp gnus-large-newsgroup)
5858 (> number gnus-large-newsgroup))
23f87bed
MB
5859 (let* ((cursor-in-echo-area nil)
5860 (initial (gnus-parameter-large-newsgroup-initial
5861 gnus-newsgroup-name))
4c7468f6
LMI
5862 (default (if only-read-p
5863 (or initial gnus-large-newsgroup)
5864 number))
23f87bed
MB
5865 (input
5866 (read-string
4c7468f6
LMI
5867 (if only-read-p
5868 (format
5869 "How many articles from %s (available %d, default %d): "
5870 (gnus-group-decoded-name
5871 (gnus-group-real-name gnus-newsgroup-name))
5872 number default)
5873 (format
5874 "How many articles from %s (%d available): "
5875 (gnus-group-decoded-name
5876 (gnus-group-real-name gnus-newsgroup-name))
5877 default))
a123622d
G
5878 nil
5879 nil
4c7468f6 5880 (number-to-string default))))
eec82323
LMI
5881 (if (string-match "^[ \t]*$" input) number input)))
5882 ((and (> scored marked) (< scored number)
5883 (> (- scored number) 20))
5884 (let ((input
5885 (read-string
5886 (format "%s %s (%d scored, %d total): "
5887 "How many articles from"
448e0f79
LMI
5888 (gnus-group-decoded-name
5889 (gnus-group-real-name gnus-newsgroup-name))
23f87bed 5890 scored number))))
eec82323
LMI
5891 (if (string-match "^[ \t]*$" input)
5892 number input)))
5893 (t number))
d4dfaa19
DL
5894 (quit
5895 (message "Quit getting the articles to read")
5896 nil))))))
eec82323
LMI
5897 (setq select (if (stringp select) (string-to-number select) select))
5898 (if (or (null select) (zerop select))
5899 select
5900 (if (and (not (zerop scored)) (<= (abs select) scored))
5901 (progn
5902 (setq articles (sort scored-list '<))
5903 (setq number (length articles)))
5904 (setq articles (copy-sequence articles)))
5905
5906 (when (< (abs select) number)
5907 (if (< select 0)
5908 ;; Select the N oldest articles.
5909 (setcdr (nthcdr (1- (abs select)) articles) nil)
5910 ;; Select the N most recent articles.
5911 (setq articles (nthcdr (- number select) articles))))
5912 (setq gnus-newsgroup-unselected
23f87bed 5913 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5914 (when gnus-alter-articles-to-read-function
23f87bed 5915 (setq articles
a1506d29 5916 (sort
16409b0b 5917 (funcall gnus-alter-articles-to-read-function
23f87bed 5918 gnus-newsgroup-name articles)
16409b0b 5919 '<)))
eec82323
LMI
5920 articles)))
5921
5922(defun gnus-killed-articles (killed articles)
5923 (let (out)
5924 (while articles
5925 (when (inline (gnus-member-of-range (car articles) killed))
5926 (push (car articles) out))
5927 (setq articles (cdr articles)))
5928 out))
5929
5930(defun gnus-uncompress-marks (marks)
5931 "Uncompress the mark ranges in MARKS."
5932 (let ((uncompressed '(score bookmark))
5933 out)
5934 (while marks
5935 (if (memq (caar marks) uncompressed)
5936 (push (car marks) out)
5937 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5938 (setq marks (cdr marks)))
5939 out))
5940
23f87bed
MB
5941(defun gnus-article-mark-to-type (mark)
5942 "Return the type of MARK."
5943 (or (cadr (assq mark gnus-article-special-mark-lists))
5944 'list))
5945
5946(defun gnus-article-unpropagatable-p (mark)
5947 "Return whether MARK should be propagated to back end."
5948 (memq mark gnus-article-unpropagated-mark-lists))
5949
eec82323 5950(defun gnus-adjust-marked-articles (info)
16409b0b 5951 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5952 (let* ((marked-lists (gnus-info-marks info))
5953 (active (gnus-active (gnus-info-group info)))
5954 (min (car active))
5955 (max (cdr active))
5956 (types gnus-article-mark-lists)
54506618
MB
5957 marks var articles article mark mark-type
5958 bgn end)
0617bb00
LMI
5959 ;; Hack to avoid adjusting marks for imap.
5960 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5961 'nnimap)
5962 (setq min 1))
eec82323 5963
23f87bed
MB
5964 (dolist (marks marked-lists)
5965 (setq mark (car marks)
5966 mark-type (gnus-article-mark-to-type mark)
5967 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5968
23f87bed
MB
5969 ;; We set the variable according to the type of the marks list,
5970 ;; and then adjust the marks to a subset of the active articles.
eec82323 5971 (cond
54506618 5972 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5973 ((eq mark-type 'list)
54506618
MB
5974 ;; Simultaneously uncompress and clip to active range
5975 ;; See gnus-uncompress-range for a description of possible marks
5976 (let (l lh)
5977 (if (not (cadr marks))
5978 (set var nil)
5979 (setq articles (if (numberp (cddr marks))
5980 (list (cdr marks))
5981 (cdr marks))
5982 lh (cons nil nil)
5983 l lh)
5984
5985 (while (setq article (pop articles))
5986 (cond ((consp article)
5987 (setq bgn (max (car article) min)
5988 end (min (cdr article) max))
5989 (while (<= bgn end)
5990 (setq l (setcdr l (cons bgn nil))
5991 bgn (1+ bgn))))
5992 ((and (<= min article)
5993 (>= max article))
5994 (setq l (setcdr l (cons article nil))))))
5995 (set var (cdr lh)))))
eec82323 5996 ;; Adjust assocs.
23f87bed
MB
5997 ((eq mark-type 'tuple)
5998 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5999 (when (not (listp (cdr (symbol-value var))))
6000 (set var (list (symbol-value var))))
6001 (when (not (listp (cdr articles)))
6002 (setq articles (list articles)))
eec82323
LMI
6003 (while articles
6004 (when (or (not (consp (setq article (pop articles))))
6005 (< (car article) min)
6006 (> (car article) max))
23f87bed
MB
6007 (set var (delq article (symbol-value var))))))
6008 ;; Adjust ranges (sloppily).
6009 ((eq mark-type 'range)
6010 (cond
6011 ((eq mark 'seen)
6012 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6013 ;; It should be (seen (NUM1 . NUM2)).
6014 (when (numberp (cddr marks))
6015 (setcdr marks (list (cdr marks))))
6016 (setq articles (cdr marks))
6017 (while (and articles
6018 (or (and (consp (car articles))
6019 (> min (cdar articles)))
6020 (and (numberp (car articles))
6021 (> min (car articles)))))
6022 (pop articles))
6023 (set var articles))))))))
eec82323
LMI
6024
6025(defun gnus-update-missing-marks (missing)
6748645f 6026 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 6027 (when missing
23f87bed 6028 (let (var m)
eec82323 6029 ;; Go through all types.
23f87bed
MB
6030 (dolist (elem gnus-article-mark-lists)
6031 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6032 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6033 (when (symbol-value var)
6034 ;; This list has articles. So we delete all missing
6035 ;; articles from it.
6036 (setq m missing)
6037 (while m
6038 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
6039
6040(defun gnus-update-marks ()
6041 "Enter the various lists of marked articles into the newsgroup info list."
6042 (let ((types gnus-article-mark-lists)
6043 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 6044 type list newmarked symbol delta-marks)
eec82323 6045 (when info
16409b0b 6046 ;; Add all marks lists to the list of marks lists.
eec82323 6047 (while (setq type (pop types))
16409b0b
GM
6048 (setq list (symbol-value
6049 (setq symbol
23f87bed 6050 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 6051
16409b0b 6052 (when list
eec82323
LMI
6053 ;; Get rid of the entries of the articles that have the
6054 ;; default score.
6055 (when (and (eq (cdr type) 'score)
6056 gnus-save-score
6057 list)
6058 (let* ((arts list)
6059 (prev (cons nil list))
6060 (all prev))
6061 (while arts
6062 (if (or (not (consp (car arts)))
6063 (= (cdar arts) gnus-summary-default-score))
6064 (setcdr prev (cdr arts))
6065 (setq prev arts))
6066 (setq arts (cdr arts)))
16409b0b
GM
6067 (setq list (cdr all)))))
6068
23f87bed
MB
6069 (when (eq (cdr type) 'seen)
6070 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6071
6072 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 6073 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 6074
23f87bed
MB
6075 (when (and (gnus-check-backend-function
6076 'request-set-mark gnus-newsgroup-name)
6077 (not (gnus-article-unpropagatable-p (cdr type))))
6078 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
a5954fa5
G
6079 ;; Don't do anything about marks for articles we
6080 ;; didn't actually get any headers for.
a5954fa5 6081 (del
d451951a
LMI
6082 (gnus-list-range-intersection
6083 gnus-newsgroup-articles
6084 (gnus-remove-from-range (gnus-copy-sequence old) list)))
a5954fa5 6085 (add
d451951a
LMI
6086 (gnus-list-range-intersection
6087 gnus-newsgroup-articles
6088 (gnus-remove-from-range
6089 (gnus-copy-sequence list) old))))
23f87bed
MB
6090 (when add
6091 (push (list add 'add (list (cdr type))) delta-marks))
6092 (when del
a5954fa5
G
6093 ;; Don't delete marks from outside the active range.
6094 ;; This shouldn't happen, but is a sanity check.
b069e5a6
G
6095 (setq del (gnus-sorted-range-intersection
6096 (gnus-active gnus-newsgroup-name) del))
23f87bed 6097 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 6098
16409b0b
GM
6099 (when list
6100 (push (cons (cdr type) list) newmarked)))
6101
6102 (when delta-marks
6103 (unless (gnus-check-group gnus-newsgroup-name)
6104 (error "Can't open server for %s" gnus-newsgroup-name))
6105 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 6106
eec82323
LMI
6107 ;; Enter these new marks into the info of the group.
6108 (if (nthcdr 3 info)
6109 (setcar (nthcdr 3 info) newmarked)
6110 ;; Add the marks lists to the end of the info.
6111 (when newmarked
6112 (setcdr (nthcdr 2 info) (list newmarked))))
6113
6114 ;; Cut off the end of the info if there's nothing else there.
6115 (let ((i 5))
6116 (while (and (> i 2)
6117 (not (nth i info)))
6118 (when (nthcdr (decf i) info)
6119 (setcdr (nthcdr i info) nil)))))))
6120
6121(defun gnus-set-mode-line (where)
16409b0b 6122 "Set the mode line of the article or summary buffers.
eec82323
LMI
6123If WHERE is `summary', the summary mode line format will be used."
6124 ;; Is this mode line one we keep updated?
16409b0b
GM
6125 (when (and (memq where gnus-updated-mode-lines)
6126 (symbol-value
6127 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323 6128 (let (mode-string)
c7a91ce1
SM
6129 ;; We evaluate this in the summary buffer since these
6130 ;; variables are buffer-local to that buffer.
6131 (with-current-buffer gnus-summary-buffer
6132 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
6133 ;; below.
6134 (let* ((mformat (symbol-value
6135 (intern
6136 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
6137 (gnus-tmp-group-name (gnus-mode-string-quote
6138 (gnus-group-decoded-name
6139 gnus-newsgroup-name)))
eec82323
LMI
6140 (gnus-tmp-article-number (or gnus-current-article 0))
6141 (gnus-tmp-unread gnus-newsgroup-unreads)
6142 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6143 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6144 (gnus-tmp-unread-and-unselected
6145 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6146 (zerop gnus-tmp-unselected))
6147 "")
6148 ((zerop gnus-tmp-unselected)
6149 (format "{%d more}" gnus-tmp-unread-and-unticked))
6150 (t (format "{%d(+%d) more}"
6151 gnus-tmp-unread-and-unticked
6152 gnus-tmp-unselected))))
6153 (gnus-tmp-subject
6154 (if (and gnus-current-headers
6155 (vectorp gnus-current-headers))
6156 (gnus-mode-string-quote
6157 (mail-header-subject gnus-current-headers))
6158 ""))
6159 bufname-length max-len
23f87bed 6160 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
6161 (setq mode-string (eval mformat))
6162 (setq bufname-length (if (string-match "%b" mode-string)
6163 (- (length
6164 (buffer-name
6165 (if (eq where 'summary)
6166 nil
6167 (get-buffer gnus-article-buffer))))
6168 2)
6169 0))
6170 (setq max-len (max 4 (if gnus-mode-non-string-length
6171 (- (window-width)
6172 gnus-mode-non-string-length
6173 bufname-length)
6174 (length mode-string))))
6175 ;; We might have to chop a bit of the string off...
6176 (when (> (length mode-string) max-len)
6177 (setq mode-string
16409b0b 6178 (concat (truncate-string-to-width mode-string (- max-len 3))
29d31b55 6179 "...")))))
eec82323
LMI
6180 ;; Update the mode line.
6181 (setq mode-line-buffer-identification
6182 (gnus-mode-line-buffer-identification (list mode-string)))
6183 (set-buffer-modified-p t))))
6184
6185(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6186 "Go through the HEADERS list and add all Xrefs to a hash table.
6187The resulting hash table is returned, or nil if no Xrefs were found."
6188 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6189 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6190 (xref-hashtb (gnus-make-hashtable))
6191 start group entry number xrefs header)
6192 (while headers
6193 (setq header (pop headers))
6194 (when (and (setq xrefs (mail-header-xref header))
6195 (not (memq (setq number (mail-header-number header))
6196 unreads)))
6197 (setq start 0)
6198 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6199 (setq start (match-end 0))
6200 (setq group (if prefix
6201 (concat prefix (substring xrefs (match-beginning 1)
6202 (match-end 1)))
6203 (substring xrefs (match-beginning 1) (match-end 1))))
6204 (setq number
e9bd5782 6205 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
6206 (match-end 2))))
6207 (if (setq entry (gnus-gethash group xref-hashtb))
6208 (setcdr entry (cons number (cdr entry)))
6209 (gnus-sethash group (cons number nil) xref-hashtb)))))
6210 (and start xref-hashtb)))
6211
6212(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6213 "Look through all the headers and mark the Xrefs as read."
6214 (let ((virtual (gnus-virtual-group-p from-newsgroup))
01c52d31 6215 name info xref-hashtb idlist method nth4)
398a825b 6216 (with-current-buffer gnus-group-buffer
eec82323
LMI
6217 (when (setq xref-hashtb
6218 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6219 (mapatoms
6220 (lambda (group)
6221 (unless (string= from-newsgroup (setq name (symbol-name group)))
6222 (setq idlist (symbol-value group))
6223 ;; Dead groups are not updated.
6224 (and (prog1
01c52d31 6225 (setq info (gnus-get-info name))
eec82323
LMI
6226 (when (stringp (setq nth4 (gnus-info-method info)))
6227 (setq nth4 (gnus-server-to-method nth4))))
6228 ;; Only do the xrefs if the group has the same
6229 ;; select method as the group we have just read.
6230 (or (gnus-methods-equal-p
6231 nth4 (gnus-find-method-for-group from-newsgroup))
6232 virtual
6233 (equal nth4 (setq method (gnus-find-method-for-group
6234 from-newsgroup)))
6235 (and (equal (car nth4) (car method))
6236 (equal (nth 1 nth4) (nth 1 method))))
6237 gnus-use-cross-reference
6238 (or (not (eq gnus-use-cross-reference t))
6239 virtual
6240 ;; Only do cross-references on subscribed
6241 ;; groups, if that is what is wanted.
6242 (<= (gnus-info-level info) gnus-level-subscribed))
6243 (gnus-group-make-articles-read name idlist))))
6244 xref-hashtb)))))
6245
6748645f 6246(defun gnus-compute-read-articles (group articles)
01c52d31 6247 (let* ((entry (gnus-group-entry group))
6748645f
LMI
6248 (info (nth 2 entry))
6249 (active (gnus-active group))
6250 ninfo)
6251 (when entry
16409b0b 6252 ;; First peel off all invalid article numbers.
6748645f
LMI
6253 (when active
6254 (let ((ids articles)
6255 id first)
6256 (while (setq id (pop ids))
6257 (when (and first (> id (cdr active)))
6258 ;; We'll end up in this situation in one particular
6259 ;; obscure situation. If you re-scan a group and get
6260 ;; a new article that is cross-posted to a different
6261 ;; group that has not been re-scanned, you might get
6262 ;; crossposted article that has a higher number than
6263 ;; Gnus believes possible. So we re-activate this
6264 ;; group as well. This might mean doing the
6265 ;; crossposting thingy will *increase* the number
6266 ;; of articles in some groups. Tsk, tsk.
6267 (setq active (or (gnus-activate-group group) active)))
6268 (when (or (> id (cdr active))
6269 (< id (car active)))
6270 (setq articles (delq id articles))))))
6271 ;; If the read list is nil, we init it.
6272 (if (and active
6273 (null (gnus-info-read info))
6274 (> (car active) 1))
6275 (setq ninfo (cons 1 (1- (car active))))
6276 (setq ninfo (gnus-info-read info)))
6277 ;; Then we add the read articles to the range.
6278 (gnus-add-to-range
6279 ninfo (setq articles (sort articles '<))))))
6280
eec82323
LMI
6281(defun gnus-group-make-articles-read (group articles)
6282 "Update the info of GROUP to say that ARTICLES are read."
6283 (let* ((num 0)
01c52d31 6284 (entry (gnus-group-entry group))
eec82323
LMI
6285 (info (nth 2 entry))
6286 (active (gnus-active group))
6287 range)
de635afe
G
6288 (if (not entry)
6289 ;; Group that Gnus doesn't know exists, but still allow the
6290 ;; backend to set marks.
6291 (gnus-request-set-mark
6292 group (list (list (gnus-compress-sequence (sort articles #'<))
6293 'add '(read))))
6294 ;; Normal, subscribed groups.
6748645f 6295 (setq range (gnus-compute-read-articles group articles))
01c52d31 6296 (with-current-buffer gnus-group-buffer
6748645f
LMI
6297 (gnus-undo-register
6298 `(progn
6299 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6300 (gnus-info-set-read ',info ',(gnus-info-read info))
6301 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 6302 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
6303 (gnus-group-update-group ,group t))))
6304 ;; Add the read articles to the range.
6305 (gnus-info-set-read info range)
23f87bed 6306 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
6307 ;; Then we have to re-compute how many unread
6308 ;; articles there are in this group.
6309 (when active
6310 (cond
6311 ((not range)
6312 (setq num (- (1+ (cdr active)) (car active))))
6313 ((not (listp (cdr range)))
6314 (setq num (- (cdr active) (- (1+ (cdr range))
6315 (car range)))))
6316 (t
6317 (while range
6318 (if (numberp (car range))
6319 (setq num (1+ num))
6320 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6321 (setq range (cdr range)))
6322 (setq num (- (cdr active) num))))
6323 ;; Update the number of unread articles.
6324 (setcar entry num)
6325 ;; Update the group buffer.
23f87bed
MB
6326 (unless (gnus-ephemeral-group-p group)
6327 (gnus-group-update-group group t))))))
eec82323 6328
eec82323
LMI
6329(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6330 (let ((cur nntp-server-buffer)
6331 (dependencies
6332 (or dependencies
01c52d31
MB
6333 (with-current-buffer gnus-summary-buffer
6334 gnus-newsgroup-dependencies)))
6335 headers id end ref number
16409b0b
GM
6336 (mail-parse-charset gnus-newsgroup-charset)
6337 (mail-parse-ignored-charsets
c7a91ce1
SM
6338 (save-current-buffer (condition-case nil
6339 (set-buffer gnus-summary-buffer)
6340 (error))
6341 gnus-newsgroup-ignored-charsets)))
6342 (with-current-buffer nntp-server-buffer
eec82323
LMI
6343 ;; Translate all TAB characters into SPACE characters.
6344 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 6345 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 6346 (ietf-drums-unfold-fws)
6748645f 6347 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6348 (let ((case-fold-search t)
6748645f 6349 in-reply-to header p lines chars)
eec82323 6350 (goto-char (point-min))
01ccbb85 6351 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
6352 ;; do not begin with 2 or 3.
6353 (while (re-search-forward "^[23][0-9]+ " nil t)
6354 (setq id nil
6355 ref nil)
6356 ;; This implementation of this function, with nine
6357 ;; search-forwards instead of the one re-search-forward and
6358 ;; a case (which basically was the old function) is actually
01ccbb85 6359 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
6360 ;; can't have everything, I guess. Speed and elegance
6361 ;; doesn't always go hand in hand.
6362 (setq
6363 header
6364 (vector
6365 ;; Number.
6366 (prog1
01c52d31 6367 (setq number (read cur))
eec82323
LMI
6368 (end-of-line)
6369 (setq p (point))
6370 (narrow-to-region (point)
6371 (or (and (search-forward "\n.\n" nil t)
6372 (- (point) 2))
6373 (point))))
6374 ;; Subject.
6375 (progn
6376 (goto-char p)
23f87bed 6377 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
6378 (funcall gnus-decode-encoded-word-function
6379 (nnheader-header-value))
2bd3dcae 6380 "(none)"))
eec82323
LMI
6381 ;; From.
6382 (progn
6383 (goto-char p)
23f87bed 6384 (if (search-forward "\nfrom:" nil t)
343d6628 6385 (funcall gnus-decode-encoded-address-function
16409b0b 6386 (nnheader-header-value))
2bd3dcae 6387 "(nobody)"))
eec82323
LMI
6388 ;; Date.
6389 (progn
6390 (goto-char p)
23f87bed 6391 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6392 (nnheader-header-value) ""))
6393 ;; Message-ID.
6394 (progn
6395 (goto-char p)
6748645f
LMI
6396 (setq id (if (re-search-forward
6397 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6398 ;; We do it this way to make sure the Message-ID
6399 ;; is (somewhat) syntactically valid.
6400 (buffer-substring (match-beginning 1)
6401 (match-end 1))
eec82323
LMI
6402 ;; If there was no message-id, we just fake one
6403 ;; to make subsequent routines simpler.
01c52d31 6404 (nnheader-generate-fake-message-id number))))
eec82323
LMI
6405 ;; References.
6406 (progn
6407 (goto-char p)
23f87bed 6408 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6409 (progn
6410 (setq end (point))
6411 (prog1
6412 (nnheader-header-value)
6413 (setq ref
6414 (buffer-substring
6415 (progn
6416 (end-of-line)
6417 (search-backward ">" end t)
6418 (1+ (point)))
6419 (progn
6420 (search-backward "<" end t)
6421 (point))))))
6422 ;; Get the references from the in-reply-to header if there
6423 ;; were no references and the in-reply-to header looks
6424 ;; promising.
23f87bed 6425 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6426 (setq in-reply-to (nnheader-header-value))
6427 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6428 (let (ref2)
6429 (setq ref (substring in-reply-to (match-beginning 0)
6430 (match-end 0)))
6431 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6432 (setq ref2 (substring in-reply-to (match-beginning 0)
6433 (match-end 0)))
6434 (when (> (length ref2) (length ref))
6435 (setq ref ref2)))
6436 ref)
eec82323
LMI
6437 (setq ref nil))))
6438 ;; Chars.
6748645f
LMI
6439 (progn
6440 (goto-char p)
6441 (if (search-forward "\nchars: " nil t)
6442 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6443 chars -1)
6444 -1))
eec82323
LMI
6445 ;; Lines.
6446 (progn
6447 (goto-char p)
6448 (if (search-forward "\nlines: " nil t)
a8151ef7 6449 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6450 lines -1)
6451 -1))
eec82323
LMI
6452 ;; Xref.
6453 (progn
6454 (goto-char p)
23f87bed 6455 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6456 (nnheader-header-value)))
6457 ;; Extra.
6458 (when gnus-extra-headers
6459 (let ((extra gnus-extra-headers)
6460 out)
6461 (while extra
6462 (goto-char p)
6463 (when (search-forward
23f87bed 6464 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6465 (push (cons (car extra) (nnheader-header-value))
6466 out))
6467 (pop extra))
6468 out))))
eec82323
LMI
6469 (when (equal id ref)
6470 (setq ref nil))
6748645f
LMI
6471
6472 (when gnus-alter-header-function
6473 (funcall gnus-alter-header-function header)
6474 (setq id (mail-header-id header)
6475 ref (gnus-parent-id (mail-header-references header))))
6476
6477 (when (setq header
6478 (gnus-dependencies-add-header
6479 header dependencies force-new))
eec82323
LMI
6480 (push header headers))
6481 (goto-char (point-max))
6482 (widen))
6483 (nreverse headers)))))
6484
eec82323
LMI
6485;; Goes through the xover lines and returns a list of vectors
6486(defun gnus-get-newsgroup-headers-xover (sequence &optional
6487 force-new dependencies
6488 group also-fetch-heads)
16409b0b
GM
6489 "Parse the news overview data in the server buffer.
6490Return a list of headers that match SEQUENCE (see
6491`nntp-retrieve-headers')."
eec82323
LMI
6492 ;; Get the Xref when the users reads the articles since most/some
6493 ;; NNTP servers do not include Xrefs when using XOVER.
6494 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6495 (let ((mail-parse-charset gnus-newsgroup-charset)
6496 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6497 (cur nntp-server-buffer)
eec82323 6498 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6499 (allp (cond
6500 ((eq gnus-read-all-available-headers t)
6501 t)
14e6dc54
MB
6502 ((and (stringp gnus-read-all-available-headers)
6503 group)
23f87bed
MB
6504 (string-match gnus-read-all-available-headers group))
6505 (t
6506 nil)))
eec82323 6507 number headers header)
c7a91ce1 6508 (with-current-buffer nntp-server-buffer
16409b0b 6509 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6510 ;; Allow the user to mangle the headers before parsing them.
6748645f 6511 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6512 (goto-char (point-min))
23f87bed
MB
6513 (gnus-parse-without-error
6514 (while (and (or sequence allp)
6515 (not (eobp)))
6516 (setq number (read cur))
6517 (when (not allp)
6518 (while (and sequence
6519 (< (car sequence) number))
6520 (setq sequence (cdr sequence))))
6521 (when (and (or allp
6522 (and sequence
6523 (eq number (car sequence))))
6524 (progn
6525 (setq sequence (cdr sequence))
6526 (setq header (inline
6527 (gnus-nov-parse-line
6528 number dependencies force-new)))))
6529 (push header headers))
6530 (forward-line 1)))
eec82323
LMI
6531 ;; A common bug in inn is that if you have posted an article and
6532 ;; then retrieves the active file, it will answer correctly --
6533 ;; the new article is included. However, a NOV entry for the
6534 ;; article may not have been generated yet, so this may fail.
6535 ;; We work around this problem by retrieving the last few
6536 ;; headers using HEAD.
6537 (if (or (not also-fetch-heads)
6538 (not sequence))
6539 ;; We (probably) got all the headers.
6540 (nreverse headers)
6541 (let ((gnus-nov-is-evil t))
6542 (nconc
6543 (nreverse headers)
23f87bed 6544 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6545 (gnus-get-newsgroup-headers))))))))
6546
6547(defun gnus-article-get-xrefs ()
6548 "Fill in the Xref value in `gnus-current-headers', if necessary.
6549This is meant to be called in `gnus-article-internal-prepare-hook'."
01c52d31
MB
6550 (let ((headers (with-current-buffer gnus-summary-buffer
6551 gnus-current-headers)))
eec82323
LMI
6552 (or (not gnus-use-cross-reference)
6553 (not headers)
6554 (and (mail-header-xref headers)
6555 (not (string= (mail-header-xref headers) "")))
6556 (let ((case-fold-search t)
6557 xref)
6558 (save-restriction
6559 (nnheader-narrow-to-headers)
6560 (goto-char (point-min))
16409b0b
GM
6561 (when (or (and (not (eobp))
6562 (eq (downcase (char-after)) ?x)
eec82323
LMI
6563 (looking-at "Xref:"))
6564 (search-forward "\nXref:" nil t))
6565 (goto-char (1+ (match-end 0)))
01c52d31 6566 (setq xref (buffer-substring (point) (point-at-eol)))
eec82323
LMI
6567 (mail-header-set-xref headers xref)))))))
6568
6569(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6570 "Find article ID and insert the summary line for that article.
6571OLD-HEADER can either be a header or a line number to insert
ae97e645
G
6572the subject line on.
6573If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6574and OLD-HEADER will be used when the summary line is inserted,
6575too, instead of trying to fetch new headers."
6748645f
LMI
6576 (let* ((line (and (numberp old-header) old-header))
6577 (old-header (and (vectorp old-header) old-header))
6578 (header (cond ((and old-header use-old-header)
16409b0b
GM
6579 old-header)
6580 ((and (numberp id)
6581 (gnus-number-to-header id))
6582 (gnus-number-to-header id))
6583 (t
6584 (gnus-read-header id))))
6585 (number (and (numberp id) id))
6586 d)
eec82323
LMI
6587 (when header
6588 ;; Rebuild the thread that this article is part of and go to the
6589 ;; article we have fetched.
6590 (when (and (not gnus-show-threads)
6591 old-header)
6748645f
LMI
6592 (when (and number
6593 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6594 (goto-char (gnus-data-pos d))
6595 (gnus-data-remove
6596 number
01c52d31 6597 (- (point-at-bol)
eec82323 6598 (prog1
01c52d31 6599 (1+ (point-at-eol))
eec82323 6600 (gnus-delete-line))))))
23f87bed 6601 ;; Remove list identifiers from subject.
d6cd56f1
JD
6602 (let ((gnus-newsgroup-headers (list header)))
6603 (gnus-summary-remove-list-identifiers))
eec82323
LMI
6604 (when old-header
6605 (mail-header-set-number header (mail-header-number old-header)))
6606 (setq gnus-newsgroup-sparse
6607 (delq (setq number (mail-header-number header))
6608 gnus-newsgroup-sparse))
6609 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6610 (push number gnus-newsgroup-limit)
6611 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6612 (gnus-summary-goto-subject number nil t))
6613 (when (and (numberp number)
6614 (> number 0))
6615 ;; We have to update the boundaries even if we can't fetch the
6616 ;; article if ID is a number -- so that the next `P' or `N'
6617 ;; command will fetch the previous (or next) article even
6618 ;; if the one we tried to fetch this time has been canceled.
6619 (when (> number gnus-newsgroup-end)
6620 (setq gnus-newsgroup-end number))
6621 (when (< number gnus-newsgroup-begin)
6622 (setq gnus-newsgroup-begin number))
6623 (setq gnus-newsgroup-unselected
6624 (delq number gnus-newsgroup-unselected)))
6625 ;; Report back a success?
6626 (and header (mail-header-number header))))
6627
6628;;; Process/prefix in the summary buffer
6629
6630(defun gnus-summary-work-articles (n)
6748645f
LMI
6631 "Return a list of articles to be worked upon.
6632The prefix argument, the list of process marked articles, and the
6633current article will be taken into consideration."
c7a91ce1 6634 (with-current-buffer gnus-summary-buffer
6748645f
LMI
6635 (cond
6636 (n
6637 ;; A numerical prefix has been given.
6638 (setq n (prefix-numeric-value n))
6639 (let ((backward (< n 0))
6640 (n (abs (prefix-numeric-value n)))
6641 articles article)
6642 (save-excursion
6643 (while
6644 (and (> n 0)
6645 (push (setq article (gnus-summary-article-number))
6646 articles)
6647 (if backward
6648 (gnus-summary-find-prev nil article)
6649 (gnus-summary-find-next nil article)))
6650 (decf n)))
6651 (nreverse articles)))
6652 ((and (gnus-region-active-p) (mark))
6653 (message "region active")
6654 ;; Work on the region between point and mark.
6655 (let ((max (max (point) (mark)))
6656 articles article)
6657 (save-excursion
7dafe00b 6658 (goto-char (min (point) (mark)))
6748645f
LMI
6659 (while
6660 (and
6661 (push (setq article (gnus-summary-article-number)) articles)
6662 (gnus-summary-find-next nil article)
6663 (< (point) max)))
6664 (nreverse articles))))
6665 (gnus-newsgroup-processable
6666 ;; There are process-marked articles present.
6667 ;; Save current state.
6668 (gnus-summary-save-process-mark)
6669 ;; Return the list.
6670 (reverse gnus-newsgroup-processable))
6671 (t
6672 ;; Just return the current article.
6673 (list (gnus-summary-article-number))))))
6674
6675(defmacro gnus-summary-iterate (arg &rest forms)
6676 "Iterate over the process/prefixed articles and do FORMS.
6677ARG is the interactive prefix given to the command. FORMS will be
6678executed with point over the summary line of the articles."
6679 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6680 `(let ((,articles (gnus-summary-work-articles ,arg)))
6681 (while ,articles
6682 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6683 ,@forms
6684 (pop ,articles)))))
6748645f
LMI
6685
6686(put 'gnus-summary-iterate 'lisp-indent-function 1)
6687(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6688
6689(defun gnus-summary-save-process-mark ()
6690 "Push the current set of process marked articles on the stack."
6691 (interactive)
6692 (push (copy-sequence gnus-newsgroup-processable)
6693 gnus-newsgroup-process-stack))
6694
6695(defun gnus-summary-kill-process-mark ()
6696 "Push the current set of process marked articles on the stack and unmark."
6697 (interactive)
6698 (gnus-summary-save-process-mark)
6699 (gnus-summary-unmark-all-processable))
6700
6701(defun gnus-summary-yank-process-mark ()
6702 "Pop the last process mark state off the stack and restore it."
6703 (interactive)
6704 (unless gnus-newsgroup-process-stack
6705 (error "Empty mark stack"))
6706 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6707
6708(defun gnus-summary-process-mark-set (set)
6709 "Make SET into the current process marked articles."
6710 (gnus-summary-unmark-all-processable)
01c52d31 6711 (mapc 'gnus-summary-set-process-mark set))
eec82323
LMI
6712
6713;;; Searching and stuff
6714
6715(defun gnus-summary-search-group (&optional backward use-level)
6716 "Search for next unread newsgroup.
6717If optional argument BACKWARD is non-nil, search backward instead."
c7a91ce1 6718 (with-current-buffer gnus-group-buffer
eec82323
LMI
6719 (when (gnus-group-search-forward
6720 backward nil (if use-level (gnus-group-group-level) nil))
6721 (gnus-group-group-name))))
6722
6723(defun gnus-summary-best-group (&optional exclude-group)
6724 "Find the name of the best unread group.
6725If EXCLUDE-GROUP, do not go to this group."
01c52d31 6726 (with-current-buffer gnus-group-buffer
eec82323
LMI
6727 (save-excursion
6728 (gnus-group-best-unread-group exclude-group))))
6729
23f87bed
MB
6730(defun gnus-summary-find-next (&optional unread article backward)
6731 (if backward
6732 (gnus-summary-find-prev unread article)
eec82323
LMI
6733 (let* ((dummy (gnus-summary-article-intangible-p))
6734 (article (or article (gnus-summary-article-number)))
23f87bed 6735 (data (gnus-data-find-list article))
eec82323
LMI
6736 result)
6737 (when (and (not dummy)
6738 (or (not gnus-summary-check-current)
6739 (not unread)
23f87bed
MB
6740 (not (gnus-data-unread-p (car data)))))
6741 (setq data (cdr data)))
eec82323
LMI
6742 (when (setq result
6743 (if unread
6744 (progn
23f87bed
MB
6745 (while data
6746 (unless (memq (gnus-data-number (car data))
6747 (cond
6748 ((eq gnus-auto-goto-ignores
6749 'always-undownloaded)
6750 gnus-newsgroup-undownloaded)
6751 (gnus-plugged
6752 nil)
6753 ((eq gnus-auto-goto-ignores
6754 'unfetched)
6755 gnus-newsgroup-unfetched)
6756 ((eq gnus-auto-goto-ignores
6757 'undownloaded)
6758 gnus-newsgroup-undownloaded)))
6759 (when (gnus-data-unread-p (car data))
6760 (setq result (car data)
6761 data nil)))
6762 (setq data (cdr data)))
eec82323 6763 result)
23f87bed 6764 (car data)))
eec82323
LMI
6765 (goto-char (gnus-data-pos result))
6766 (gnus-data-number result)))))
6767
6768(defun gnus-summary-find-prev (&optional unread article)
6769 (let* ((eobp (eobp))
6770 (article (or article (gnus-summary-article-number)))
23f87bed 6771 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6772 result)
6773 (when (and (not eobp)
6774 (or (not gnus-summary-check-current)
6775 (not unread)
23f87bed
MB
6776 (not (gnus-data-unread-p (car data)))))
6777 (setq data (cdr data)))
eec82323
LMI
6778 (when (setq result
6779 (if unread
6780 (progn
23f87bed
MB
6781 (while data
6782 (unless (memq (gnus-data-number (car data))
6783 (cond
6784 ((eq gnus-auto-goto-ignores
6785 'always-undownloaded)
6786 gnus-newsgroup-undownloaded)
6787 (gnus-plugged
6788 nil)
6789 ((eq gnus-auto-goto-ignores
6790 'unfetched)
6791 gnus-newsgroup-unfetched)
6792 ((eq gnus-auto-goto-ignores
6793 'undownloaded)
6794 gnus-newsgroup-undownloaded)))
6795 (when (gnus-data-unread-p (car data))
6796 (setq result (car data)
6797 data nil)))
6798 (setq data (cdr data)))
eec82323 6799 result)
23f87bed 6800 (car data)))
eec82323
LMI
6801 (goto-char (gnus-data-pos result))
6802 (gnus-data-number result))))
6803
6804(defun gnus-summary-find-subject (subject &optional unread backward article)
6805 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6806 (article (or article (gnus-summary-article-number)))
6807 (articles (gnus-data-list backward))
6808 (arts (gnus-data-find-list article articles))
6809 result)
6810 (when (or (not gnus-summary-check-current)
6811 (not unread)
6812 (not (gnus-data-unread-p (car arts))))
6813 (setq arts (cdr arts)))
6814 (while arts
6815 (and (or (not unread)
6816 (gnus-data-unread-p (car arts)))
6817 (vectorp (gnus-data-header (car arts)))
6818 (gnus-subject-equal
6819 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6820 (setq result (car arts)
6821 arts nil))
6822 (setq arts (cdr arts)))
6823 (and result
6824 (goto-char (gnus-data-pos result))
6825 (gnus-data-number result))))
6826
6827(defun gnus-summary-search-forward (&optional unread subject backward)
6828 "Search forward for an article.
6829If UNREAD, look for unread articles. If SUBJECT, look for
6830articles with that subject. If BACKWARD, search backward instead."
6831 (cond (subject (gnus-summary-find-subject subject unread backward))
6832 (backward (gnus-summary-find-prev unread))
6833 (t (gnus-summary-find-next unread))))
6834
6835(defun gnus-recenter (&optional n)
6836 "Center point in window and redisplay frame.
6837Also do horizontal recentering."
6838 (interactive "P")
6839 (when (and gnus-auto-center-summary
6840 (not (eq gnus-auto-center-summary 'vertical)))
6841 (gnus-horizontal-recenter))
5aa75bd8
JL
6842 (if (fboundp 'recenter-top-bottom)
6843 (recenter-top-bottom n)
6844 (recenter n)))
6845
6846(put 'gnus-recenter 'isearch-scroll t)
eec82323 6847
7b47345b
AS
6848(defun gnus-forward-line-ignore-invisible (n)
6849 "Move N lines forward (backward if N is negative).
6850Like forward-line, but skip over (and don't count) invisible lines."
6851 (let (done)
6852 (while (and (> n 0) (not done))
6853 ;; If the following character is currently invisible,
6854 ;; skip all characters with that same `invisible' property value.
770d9a1f
KY
6855 (while (gnus-invisible-p (point))
6856 (goto-char (gnus-next-char-property-change (point))))
7b47345b
AS
6857 (forward-line 1)
6858 (if (eobp)
6859 (setq done t)
6860 (setq n (1- n))))
6861 (while (and (< n 0) (not done))
6862 (forward-line -1)
6863 (if (bobp) (setq done t)
6864 (setq n (1+ n))
770d9a1f
KY
6865 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6866 (goto-char (gnus-previous-char-property-change (point))))))))
6867
eec82323
LMI
6868(defun gnus-summary-recenter ()
6869 "Center point in the summary window.
6870If `gnus-auto-center-summary' is nil, or the article buffer isn't
6871displayed, no centering will be performed."
6872 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6873 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6874 (interactive)
23f87bed
MB
6875 ;; The user has to want it.
6876 (when gnus-auto-center-summary
6877 (let* ((top (cond ((< (window-height) 4) 0)
6878 ((< (window-height) 7) 1)
6879 (t (if (numberp gnus-auto-center-summary)
6880 gnus-auto-center-summary
01c52d31 6881 (/ (1- (window-height)) 2)))))
23f87bed 6882 (height (1- (window-height)))
7b47345b
AS
6883 (bottom (save-excursion
6884 (goto-char (point-max))
6885 (gnus-forward-line-ignore-invisible (- height))
6886 (point)))
23f87bed 6887 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6888 (when (get-buffer-window gnus-article-buffer)
6889 ;; Only do recentering when the article buffer is displayed,
6890 ;; Set the window start to either `bottom', which is the biggest
6891 ;; possible valid number, or the second line from the top,
6892 ;; whichever is the least.
7b47345b
AS
6893 (let ((top-pos (save-excursion
6894 (gnus-forward-line-ignore-invisible (- top))
6895 (point))))
db7ebd73
MB
6896 (if (> bottom top-pos)
6897 ;; Keep the second line from the top visible
01c52d31 6898 (set-window-start window top-pos)
db7ebd73
MB
6899 ;; Try to keep the bottom line visible; if it's partially
6900 ;; obscured, either scroll one more line to make it fully
6901 ;; visible, or revert to using TOP-POS.
6902 (save-excursion
6903 (goto-char (point-max))
7b47345b 6904 (gnus-forward-line-ignore-invisible -1)
db7ebd73
MB
6905 (let ((last-line-start (point)))
6906 (goto-char bottom)
6907 (set-window-start window (point) t)
6908 (when (not (pos-visible-in-window-p last-line-start window))
7b47345b 6909 (gnus-forward-line-ignore-invisible 1)
db7ebd73 6910 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6911 ;; Do horizontal recentering while we're at it.
6912 (when (and (get-buffer-window (current-buffer) t)
6913 (not (eq gnus-auto-center-summary 'vertical)))
6914 (let ((selected (selected-window)))
6915 (select-window (get-buffer-window (current-buffer) t))
6916 (gnus-summary-position-point)
6917 (gnus-horizontal-recenter)
6918 (select-window selected))))))
6919
6920(defun gnus-summary-jump-to-group (newsgroup)
6921 "Move point to NEWSGROUP in group mode buffer."
6922 ;; Keep update point of group mode buffer if visible.
6923 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6924 (save-window-excursion
6925 ;; Take care of tree window mode.
6926 (when (get-buffer-window gnus-group-buffer)
6927 (pop-to-buffer gnus-group-buffer))
6928 (gnus-group-jump-to-group newsgroup))
6929 (save-excursion
6930 ;; Take care of tree window mode.
c7a91ce1 6931 (if (get-buffer-window gnus-group-buffer 0)
eec82323
LMI
6932 (pop-to-buffer gnus-group-buffer)
6933 (set-buffer gnus-group-buffer))
6934 (gnus-group-jump-to-group newsgroup))))
6935
6936;; This function returns a list of article numbers based on the
6937;; difference between the ranges of read articles in this group and
6938;; the range of active articles.
6939(defun gnus-list-of-unread-articles (group)
6940 (let* ((read (gnus-info-read (gnus-get-info group)))
6941 (active (or (gnus-active group) (gnus-activate-group group)))
01c52d31
MB
6942 (last (or (cdr active)
6943 (error "Group %s couldn't be activated " group)))
4b70e299
MB
6944 (bottom (if gnus-newsgroup-maximum-articles
6945 (max (car active)
6946 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6947 (car active)))
eec82323
LMI
6948 first nlast unread)
6949 ;; If none are read, then all are unread.
6950 (if (not read)
11abff8e 6951 (setq first bottom)
eec82323
LMI
6952 ;; If the range of read articles is a single range, then the
6953 ;; first unread article is the article after the last read
6954 ;; article. Sounds logical, doesn't it?
16409b0b 6955 (if (and (not (listp (cdr read)))
11abff8e 6956 (or (< (car read) bottom)
16409b0b
GM
6957 (progn (setq read (list read))
6958 nil)))
11abff8e 6959 (setq first (max bottom (1+ (cdr read))))
eec82323
LMI
6960 ;; `read' is a list of ranges.
6961 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6962 (caar read)))
6963 1)
11abff8e 6964 (setq first bottom))
eec82323
LMI
6965 (while read
6966 (when first
6967 (while (< first nlast)
54506618
MB
6968 (setq unread (cons first unread)
6969 first (1+ first))))
eec82323
LMI
6970 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6971 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6972 (setq read (cdr read)))))
6973 ;; And add the last unread articles.
6974 (while (<= first last)
54506618
MB
6975 (setq unread (cons first unread)
6976 first (1+ first)))
eec82323 6977 ;; Return the list of unread articles.
6748645f 6978 (delq 0 (nreverse unread))))
eec82323
LMI
6979
6980(defun gnus-list-of-read-articles (group)
6981 "Return a list of unread, unticked and non-dormant articles."
6982 (let* ((info (gnus-get-info group))
6983 (marked (gnus-info-marks info))
6984 (active (gnus-active group)))
6985 (and info active
23f87bed
MB
6986 (gnus-list-range-difference
6987 (gnus-list-range-difference
6988 (gnus-sorted-complement
11abff8e 6989 (gnus-uncompress-range
4b70e299 6990 (if gnus-newsgroup-maximum-articles
11abff8e 6991 (cons (max (car active)
4b70e299
MB
6992 (- (cdr active)
6993 gnus-newsgroup-maximum-articles
6994 -1))
11abff8e
MB
6995 (cdr active))
6996 active))
23f87bed
MB
6997 (gnus-list-of-unread-articles group))
6998 (cdr (assq 'dormant marked)))
6999 (cdr (assq 'tick marked))))))
eec82323 7000
54506618
MB
7001;; This function returns a sequence of article numbers based on the
7002;; difference between the ranges of read articles in this group and
7003;; the range of active articles.
7004(defun gnus-sequence-of-unread-articles (group)
7005 (let* ((read (gnus-info-read (gnus-get-info group)))
7006 (active (or (gnus-active group) (gnus-activate-group group)))
7007 (last (cdr active))
4b70e299
MB
7008 (bottom (if gnus-newsgroup-maximum-articles
7009 (max (car active)
7010 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 7011 (car active)))
54506618
MB
7012 first nlast unread)
7013 ;; If none are read, then all are unread.
7014 (if (not read)
11abff8e 7015 (setq first bottom)
54506618
MB
7016 ;; If the range of read articles is a single range, then the
7017 ;; first unread article is the article after the last read
7018 ;; article. Sounds logical, doesn't it?
7019 (if (and (not (listp (cdr read)))
11abff8e 7020 (or (< (car read) bottom)
54506618
MB
7021 (progn (setq read (list read))
7022 nil)))
11abff8e 7023 (setq first (max bottom (1+ (cdr read))))
54506618
MB
7024 ;; `read' is a list of ranges.
7025 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7026 (caar read)))
7027 1)
11abff8e 7028 (setq first bottom))
54506618
MB
7029 (while read
7030 (when first
7031 (push (cons first nlast) unread))
7032 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7033 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7034 (setq read (cdr read)))))
7035 ;; And add the last unread articles.
ba0226dd
MB
7036 (cond ((not (and first last))
7037 nil)
7038 ((< first last)
7039 (push (cons first last) unread))
7040 ((= first last)
7041 (push first unread)))
54506618
MB
7042 ;; Return the sequence of unread articles.
7043 (delq 0 (nreverse unread))))
7044
eec82323
LMI
7045;; Various summary commands
7046
6748645f 7047(defun gnus-summary-select-article-buffer ()
de635afe 7048 "Reconfigure windows to show the article buffer.
1e3b6001 7049If `gnus-widen-article-window' is set, show only the article
de635afe 7050buffer."
6748645f
LMI
7051 (interactive)
7052 (if (not (gnus-buffer-live-p gnus-article-buffer))
7053 (error "There is no article buffer for this summary buffer")
a41c2e6d
G
7054 (unless (get-buffer-window gnus-article-buffer)
7055 (gnus-summary-show-article))
71e691a5
G
7056 (gnus-configure-windows
7057 (if gnus-widen-article-window
7058 'only-article
7059 'article)
7060 t)
a41c2e6d 7061 (select-window (get-buffer-window gnus-article-buffer))))
6748645f 7062
eec82323
LMI
7063(defun gnus-summary-universal-argument (arg)
7064 "Perform any operation on all articles that are process/prefixed."
7065 (interactive "P")
eec82323
LMI
7066 (let ((articles (gnus-summary-work-articles arg))
7067 func article)
7068 (if (eq
7069 (setq
7070 func
7071 (key-binding
7072 (read-key-sequence
7073 (substitute-command-keys
16409b0b 7074 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
7075 'undefined)
7076 (gnus-error 1 "Undefined key")
7077 (save-excursion
7078 (while articles
7079 (gnus-summary-goto-subject (setq article (pop articles)))
7080 (let (gnus-newsgroup-processable)
7081 (command-execute func))
7082 (gnus-summary-remove-process-mark article)))))
7083 (gnus-summary-position-point))
7084
7085(defun gnus-summary-toggle-truncation (&optional arg)
7086 "Toggle truncation of summary lines.
23f87bed 7087With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
7088 (interactive "P")
7089 (setq truncate-lines
7090 (if (null arg) (not truncate-lines)
7091 (> (prefix-numeric-value arg) 0)))
7092 (redraw-display))
7093
23f87bed
MB
7094(defun gnus-summary-find-for-reselect ()
7095 "Return the number of an article to stay on across a reselect.
7096The current article is considered, then following articles, then previous
7097articles. An article is sought which is not cancelled and isn't a temporary
7098insertion from another group. If there's no such then return a dummy 0."
7099 (let (found)
7100 (dolist (rev '(nil t))
7101 (unless found ; don't demand the reverse list if we don't need it
7102 (let ((data (gnus-data-find-list
7103 (gnus-summary-article-number) (gnus-data-list rev))))
7104 (while (and data (not found))
7105 (if (and (< 0 (gnus-data-number (car data)))
7106 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7107 (setq found (gnus-data-number (car data))))
7108 (setq data (cdr data))))))
7109 (or found 0)))
7110
eec82323
LMI
7111(defun gnus-summary-reselect-current-group (&optional all rescan)
7112 "Exit and then reselect the current newsgroup.
7113The prefix argument ALL means to select all articles."
7114 (interactive "P")
eec82323
LMI
7115 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7116 (error "Ephemeral groups can't be reselected"))
23f87bed 7117 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
7118 (group gnus-newsgroup-name))
7119 (setq gnus-newsgroup-begin nil)
23f87bed 7120 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
7121 ;; We have to adjust the point of group mode buffer because
7122 ;; point was moved to the next unread newsgroup by exiting.
7123 (gnus-summary-jump-to-group group)
7124 (when rescan
7125 (save-excursion
7126 (gnus-group-get-new-news-this-group 1)))
7127 (gnus-group-read-group all t)
7128 (gnus-summary-goto-subject current-subject nil t)))
7129
7130(defun gnus-summary-rescan-group (&optional all)
7131 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7132 (interactive "P")
eb9df2c9
LMI
7133 (let ((config gnus-current-window-configuration))
7134 (gnus-summary-reselect-current-group all t)
7135 (gnus-configure-windows config)
7136 (when (eq config 'article)
7137 (gnus-summary-select-article))))
eec82323
LMI
7138
7139(defun gnus-summary-update-info (&optional non-destructive)
7140 (save-excursion
7141 (let ((group gnus-newsgroup-name))
6748645f
LMI
7142 (when group
7143 (when gnus-newsgroup-kill-headers
7144 (setq gnus-newsgroup-killed
7145 (gnus-compress-sequence
23f87bed
MB
7146 (gnus-sorted-union
7147 (gnus-list-range-intersection
7148 gnus-newsgroup-unselected gnus-newsgroup-killed)
7149 gnus-newsgroup-unreads)
6748645f
LMI
7150 t)))
7151 (unless (listp (cdr gnus-newsgroup-killed))
7152 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
b229f37d
KY
7153 (let ((headers gnus-newsgroup-headers)
7154 (ephemeral-p (gnus-ephemeral-group-p group))
7155 info)
7156 (unless ephemeral-p
7157 (setq info (copy-sequence (gnus-get-info group))
7158 info (delq (gnus-info-params info) info)))
6748645f 7159 ;; Set the new ranges of read articles.
01c52d31 7160 (with-current-buffer gnus-group-buffer
6748645f
LMI
7161 (gnus-undo-force-boundary))
7162 (gnus-update-read-articles
23f87bed
MB
7163 group (gnus-sorted-union
7164 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
7165 ;; Set the current article marks.
7166 (let ((gnus-newsgroup-scored
7167 (if (and (not gnus-save-score)
7168 (not non-destructive))
7169 nil
7170 gnus-newsgroup-scored)))
7171 (save-excursion
7172 (gnus-update-marks)))
7173 ;; Do the cross-ref thing.
7174 (when gnus-use-cross-reference
7175 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7176 ;; Do not switch windows but change the buffer to work.
a8151ef7 7177 (set-buffer gnus-group-buffer)
b229f37d
KY
7178 (unless ephemeral-p
7179 (gnus-group-update-group
7180 group nil
7181 (equal info
7182 (setq info (copy-sequence (gnus-get-info group))
7183 info (delq (gnus-info-params info) info))))))))))
eec82323
LMI
7184
7185(defun gnus-summary-save-newsrc (&optional force)
7186 "Save the current number of read/marked articles in the dribble buffer.
7187The dribble buffer will then be saved.
7188If FORCE (the prefix), also save the .newsrc file(s)."
7189 (interactive "P")
7190 (gnus-summary-update-info t)
7191 (if force
7192 (gnus-save-newsrc-file)
7193 (gnus-dribble-save)))
7194
704f1663
GM
7195(declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7196
23f87bed 7197(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 7198 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 7199`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
7200 (interactive)
7201 (gnus-set-global-variables)
16409b0b 7202 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7203 (with-current-buffer gnus-article-buffer
16409b0b
GM
7204 (mm-destroy-parts gnus-article-mime-handles)
7205 ;; Set it to nil for safety reason.
7206 (setq gnus-article-mime-handle-alist nil)
7207 (setq gnus-article-mime-handles nil)))
eec82323 7208 (gnus-kill-save-kill-buffer)
6748645f 7209 (gnus-async-halt-prefetch)
eec82323
LMI
7210 (let* ((group gnus-newsgroup-name)
7211 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 7212 (gnus-group-is-exiting-p t)
5415d076 7213 (article-buffer gnus-article-buffer)
eec82323 7214 (mode major-mode)
23f87bed 7215 (group-point nil)
1a3c7209
KY
7216 (buf (current-buffer))
7217 ;; `gnus-single-article-buffer' is nil buffer-locally in
7218 ;; ephemeral group of which summary buffer will be killed,
7219 ;; but the global value may be non-nil.
7220 (single-article-buffer gnus-single-article-buffer))
16409b0b
GM
7221 (unless quit-config
7222 ;; Do adaptive scoring, and possibly save score files.
7223 (when gnus-newsgroup-adaptive
7224 (gnus-score-adaptive))
7225 (when gnus-use-scoring
7226 (gnus-score-save)))
6748645f 7227 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
7228 (when gnus-use-cache
7229 (gnus-cache-possibly-remove-articles)
7230 (gnus-cache-save-buffers))
7231 (gnus-async-prefetch-remove-group group)
7232 (when gnus-suppress-duplicates
7233 (gnus-dup-enter-articles))
7234 (when gnus-use-trees
7235 (gnus-tree-close group))
16409b0b
GM
7236 (when gnus-use-cache
7237 (gnus-cache-write-active))
6748645f
LMI
7238 ;; Remove entries for this group.
7239 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
7240 ;; Make all changes in this group permanent.
7241 (unless quit-config
6748645f 7242 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 7243 (gnus-summary-update-info))
eec82323
LMI
7244 (gnus-close-group group)
7245 ;; Make sure where we were, and go to next newsgroup.
7246 (set-buffer gnus-group-buffer)
7247 (unless quit-config
7248 (gnus-group-jump-to-group group))
6748645f
LMI
7249 (gnus-run-hooks 'gnus-summary-exit-hook)
7250 (unless (or quit-config
01c52d31 7251 (not gnus-summary-next-group-on-exit)
6748645f
LMI
7252 ;; If this group has disappeared from the summary
7253 ;; buffer, don't skip forwards.
7254 (not (string= group (gnus-group-group-name))))
eec82323 7255 (gnus-group-next-unread-group 1))
a8151ef7 7256 (setq group-point (point))
eec82323
LMI
7257 (if temporary
7258 nil ;Nothing to do.
eec82323
LMI
7259 (set-buffer buf)
7260 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
7261 (progn
7262 (gnus-deaden-summary)
7263 (setq mode nil))
eec82323
LMI
7264 (when (get-buffer gnus-article-buffer)
7265 (bury-buffer gnus-article-buffer))
eec82323
LMI
7266 ;; Return to group mode buffer.
7267 (when (eq mode 'gnus-summary-mode)
7268 (gnus-kill-buffer buf)))
9f2d52e7 7269
eec82323 7270 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
7271 (set-buffer gnus-group-buffer)
7272 (if quit-config
7273 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
7274 (goto-char group-point)
7275 ;; If gnus-group-buffer is already displayed, make sure we also move
7276 ;; the cursor in the window that displays it.
7277 (let ((win (get-buffer-window (current-buffer) 0)))
7278 (if win (set-window-point win (point))))
d61c212b 7279 (unless leave-hidden
4e90f2b9 7280 (gnus-configure-windows 'group 'force)))
5415d076
G
7281
7282 ;; If we have several article buffers, we kill them at exit.
1a3c7209 7283 (unless single-article-buffer
5415d076
G
7284 (when (gnus-buffer-live-p article-buffer)
7285 (with-current-buffer article-buffer
7286 ;; Don't kill sticky article buffers
7287 (unless (eq major-mode 'gnus-sticky-article-mode)
7288 (gnus-kill-buffer article-buffer)
7289 (setq gnus-article-current nil))))
7290 (gnus-kill-buffer gnus-original-article-buffer))
7291
6748645f 7292 ;; Clear the current group name.
eec82323
LMI
7293 (unless quit-config
7294 (setq gnus-newsgroup-name nil)))))
7295
7296(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7297(defun gnus-summary-exit-no-update (&optional no-questions)
7298 "Quit reading current newsgroup without updating read article info."
7299 (interactive)
eec82323 7300 (let* ((group gnus-newsgroup-name)
23f87bed
MB
7301 (gnus-group-is-exiting-p t)
7302 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
7303 (quit-config (gnus-group-quit-config group)))
7304 (when (or no-questions
7305 gnus-expert-user
7306 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 7307 (gnus-async-halt-prefetch)
23f87bed 7308 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b 7309 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7310 (with-current-buffer gnus-article-buffer
c146ad85 7311 (gnus-article-stop-animations)
16409b0b
GM
7312 (mm-destroy-parts gnus-article-mime-handles)
7313 ;; Set it to nil for safety reason.
7314 (setq gnus-article-mime-handle-alist nil)
7315 (setq gnus-article-mime-handles nil)))
eec82323
LMI
7316 ;; If we have several article buffers, we kill them at exit.
7317 (unless gnus-single-article-buffer
7318 (gnus-kill-buffer gnus-article-buffer)
7319 (gnus-kill-buffer gnus-original-article-buffer)
7320 (setq gnus-article-current nil))
5415d076
G
7321 ;; Return to the group buffer.
7322 (gnus-configure-windows 'group 'force)
eec82323
LMI
7323 (if (not gnus-kill-summary-on-exit)
7324 (gnus-deaden-summary)
7325 (gnus-close-group group)
23f87bed 7326 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
7327 (unless gnus-single-article-buffer
7328 (setq gnus-article-current nil))
7329 (when gnus-use-trees
7330 (gnus-tree-close group))
7331 (gnus-async-prefetch-remove-group group)
7332 (when (get-buffer gnus-article-buffer)
7333 (bury-buffer gnus-article-buffer))
eec82323
LMI
7334 ;; Clear the current group name.
7335 (setq gnus-newsgroup-name nil)
23f87bed 7336 (unless (gnus-ephemeral-group-p group)
b229f37d 7337 (gnus-group-update-group group nil t))
eec82323
LMI
7338 (when (equal (gnus-group-group-name) group)
7339 (gnus-group-next-unread-group 1))
7340 (when quit-config
23f87bed 7341 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
7342
7343(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
7344 "Handle movement when leaving an ephemeral group.
7345The state which existed when entering the ephemeral is reset."
eec82323
LMI
7346 (if (not (buffer-name (car quit-config)))
7347 (gnus-configure-windows 'group 'force)
7348 (set-buffer (car quit-config))
af92e247
AC
7349 (unless (eq (cdr quit-config) 'group)
7350 (setq gnus-current-select-method
7351 (gnus-find-method-for-group gnus-newsgroup-name)))
eec82323 7352 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
7353 (gnus-set-global-variables))
7354 ((eq major-mode 'gnus-article-mode)
c7a91ce1 7355 (save-current-buffer
23f87bed
MB
7356 ;; The `gnus-summary-buffer' variable may point
7357 ;; to the old summary buffer when using a single
7358 ;; article buffer.
7359 (unless (gnus-buffer-live-p gnus-summary-buffer)
7360 (set-buffer gnus-group-buffer))
7361 (set-buffer gnus-summary-buffer)
7362 (gnus-set-global-variables))))
eec82323 7363 (if (or (eq (cdr quit-config) 'article)
23f87bed 7364 (eq (cdr quit-config) 'pick))
01c52d31
MB
7365 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7366 (gnus-configure-windows 'pick 'force)
7367 (gnus-configure-windows (cdr quit-config) 'force))
eec82323
LMI
7368 (gnus-configure-windows (cdr quit-config) 'force))
7369 (when (eq major-mode 'gnus-summary-mode)
01c52d31
MB
7370 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7371 next-unread-noselect))
7372 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7373 'next-noselect)
7374 (gnus-summary-next-subject 1 nil t))
7375 ((eq gnus-auto-select-on-ephemeral-exit
7376 'next-unread-noselect)
7377 (gnus-summary-next-subject 1 t t))))
7378 ;; Hide the article buffer which displays the article different
7379 ;; from the one that the cursor points to in the summary buffer.
7380 (gnus-configure-windows 'summary 'force))
7381 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7382 (gnus-summary-next-subject 1))
7383 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7384 (gnus-summary-next-subject 1 t))))
eec82323
LMI
7385 (gnus-summary-recenter)
7386 (gnus-summary-position-point))))
7387
7388;;; Dead summaries.
7389
bbf52f1e
SM
7390(defvar gnus-dead-summary-mode-map
7391 (let ((map (make-keymap)))
7392 (suppress-keymap map)
7393 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7394 (dolist (key '("\C-d" "\r" "\177" [delete]))
7395 (define-key map key 'gnus-summary-wake-up-the-dead))
7396 (dolist (key '("q" "Q"))
7397 (define-key map key 'bury-buffer))
7398 map))
7399
7400(define-minor-mode gnus-dead-summary-mode
eec82323 7401 "Minor mode for Gnus summary buffers."
bbf52f1e
SM
7402 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7403 (unless (derived-mode-p 'gnus-summary-mode)
7404 (setq gnus-dead-summary-mode nil)))
eec82323
LMI
7405
7406(defun gnus-deaden-summary ()
7407 "Make the current summary buffer into a dead summary buffer."
7408 ;; Kill any previous dead summary buffer.
7409 (when (and gnus-dead-summary
7410 (buffer-name gnus-dead-summary))
01c52d31 7411 (with-current-buffer gnus-dead-summary
eec82323
LMI
7412 (when gnus-dead-summary-mode
7413 (kill-buffer (current-buffer)))))
7414 ;; Make this the current dead summary.
7415 (setq gnus-dead-summary (current-buffer))
7416 (gnus-dead-summary-mode 1)
7417 (let ((name (buffer-name)))
7418 (when (string-match "Summary" name)
7419 (rename-buffer
7420 (concat (substring name 0 (match-beginning 0)) "Dead "
7421 (substring name (match-beginning 0)))
16409b0b
GM
7422 t)
7423 (bury-buffer))))
eec82323
LMI
7424
7425(defun gnus-kill-or-deaden-summary (buffer)
7426 "Kill or deaden the summary BUFFER."
6748645f
LMI
7427 (save-excursion
7428 (when (and (buffer-name buffer)
7429 (not gnus-single-article-buffer))
01c52d31 7430 (with-current-buffer buffer
6748645f
LMI
7431 (gnus-kill-buffer gnus-article-buffer)
7432 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
7433 (cond
7434 ;; Kill the buffer.
7435 (gnus-kill-summary-on-exit
7436 (when (and gnus-use-trees
7437 (gnus-buffer-exists-p buffer))
c7a91ce1 7438 (with-current-buffer buffer
23f87bed
MB
7439 (gnus-tree-close gnus-newsgroup-name)))
7440 (gnus-kill-buffer buffer))
7441 ;; Deaden the buffer.
7442 ((gnus-buffer-exists-p buffer)
c7a91ce1 7443 (with-current-buffer buffer
23f87bed 7444 (gnus-deaden-summary))))))
eec82323
LMI
7445
7446(defun gnus-summary-wake-up-the-dead (&rest args)
7447 "Wake up the dead summary buffer."
7448 (interactive)
7449 (gnus-dead-summary-mode -1)
7450 (let ((name (buffer-name)))
7451 (when (string-match "Dead " name)
7452 (rename-buffer
7453 (concat (substring name 0 (match-beginning 0))
7454 (substring name (match-end 0)))
7455 t)))
7456 (gnus-message 3 "This dead summary is now alive again"))
7457
eec82323
LMI
7458;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7459(defun gnus-summary-describe-group (&optional force)
7460 "Describe the current newsgroup."
7461 (interactive "P")
7462 (gnus-group-describe-group force gnus-newsgroup-name))
7463
7464(defun gnus-summary-describe-briefly ()
7465 "Describe summary mode commands briefly."
7466 (interactive)
bdaa75c7 7467 (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
7468
7469;; Walking around group mode buffer from summary mode.
7470
7471(defun gnus-summary-next-group (&optional no-article target-group backward)
7472 "Exit current newsgroup and then select next unread newsgroup.
7473If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7474initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7475previous group instead."
7476 (interactive "P")
eec82323
LMI
7477 ;; Stop pre-fetching.
7478 (gnus-async-halt-prefetch)
7479 (let ((current-group gnus-newsgroup-name)
7480 (current-buffer (current-buffer))
7481 entered)
7482 ;; First we semi-exit this group to update Xrefs and all variables.
7483 ;; We can't do a real exit, because the window conf must remain
7484 ;; the same in case the user is prompted for info, and we don't
7485 ;; want the window conf to change before that...
7486 (gnus-summary-exit t)
7487 (while (not entered)
7488 ;; Then we find what group we are supposed to enter.
7489 (set-buffer gnus-group-buffer)
7490 (gnus-group-jump-to-group current-group)
7491 (setq target-group
7492 (or target-group
7493 (if (eq gnus-keep-same-level 'best)
7494 (gnus-summary-best-group gnus-newsgroup-name)
7495 (gnus-summary-search-group backward gnus-keep-same-level))))
7496 (if (not target-group)
7497 ;; There are no further groups, so we return to the group
7498 ;; buffer.
7499 (progn
7500 (gnus-message 5 "Returning to the group buffer")
7501 (setq entered t)
7502 (when (gnus-buffer-live-p current-buffer)
7503 (set-buffer current-buffer)
7504 (gnus-summary-exit))
6748645f 7505 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7506 ;; We try to enter the target group.
7507 (gnus-group-jump-to-group target-group)
7508 (let ((unreads (gnus-group-group-unread)))
7509 (if (and (or (eq t unreads)
7510 (and unreads (not (zerop unreads))))
23f87bed
MB
7511 (gnus-summary-read-group
7512 target-group nil no-article
7513 (and (buffer-name current-buffer) current-buffer)
7514 nil backward))
eec82323
LMI
7515 (setq entered t)
7516 (setq current-group target-group
7517 target-group nil)))))))
7518
7519(defun gnus-summary-prev-group (&optional no-article)
7520 "Exit current newsgroup and then select previous unread newsgroup.
7521If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7522 (interactive "P")
7523 (gnus-summary-next-group no-article nil t))
7524
7525;; Walking around summary lines.
7526
23f87bed
MB
7527(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7528 "Go to the first subject satisfying any non-nil constraint.
7529If UNREAD is non-nil, the article should be unread.
7530If UNDOWNLOADED is non-nil, the article should be undownloaded.
20a673b2 7531If UNSEEN is non-nil, the article should be unseen as well as unread.
23f87bed 7532Returns the article selected or nil if there are no matching articles."
eec82323 7533 (interactive "P")
23f87bed
MB
7534 (cond
7535 ;; Empty summary.
7536 ((null gnus-newsgroup-data)
7537 (gnus-message 3 "No articles in the group")
7538 nil)
7539 ;; Pick the first article.
7540 ((not (or unread undownloaded unseen))
7541 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7542 (gnus-data-number (car gnus-newsgroup-data)))
7543 ;; Find the first unread article.
7544 (t
7545 (let ((data gnus-newsgroup-data))
7546 (while (and data
7547 (let ((num (gnus-data-number (car data))))
7548 (or (memq num gnus-newsgroup-unfetched)
7549 (not (or (and unread
7550 (memq num gnus-newsgroup-unreads))
7551 (and undownloaded
7552 (memq num gnus-newsgroup-undownloaded))
7553 (and unseen
20a673b2
KY
7554 (memq num gnus-newsgroup-unseen)
7555 (memq num gnus-newsgroup-unreads)))))))
23f87bed
MB
7556 (setq data (cdr data)))
7557 (prog1
7558 (if data
7559 (progn
7560 (goto-char (gnus-data-pos (car data)))
7561 (gnus-data-number (car data)))
7562 (gnus-message 3 "No more%s articles"
7563 (let* ((r (when unread " unread"))
7564 (d (when undownloaded " undownloaded"))
7565 (s (when unseen " unseen"))
7566 (l (delq nil (list r d s))))
7567 (cond ((= 3 (length l))
7568 (concat r "," d ", or" s))
7569 ((= 2 (length l))
7570 (concat (car l) ", or" (cadr l)))
7571 ((= 1 (length l))
7572 (car l))
7573 (t
7574 ""))))
7575 nil
7576 )
7577 (gnus-summary-position-point))))))
eec82323
LMI
7578
7579(defun gnus-summary-next-subject (n &optional unread dont-display)
7580 "Go to next N'th summary line.
7581If N is negative, go to the previous N'th subject line.
7582If UNREAD is non-nil, only unread articles are selected.
7583The difference between N and the actual number of steps taken is
7584returned."
7585 (interactive "p")
7586 (let ((backward (< n 0))
7587 (n (abs n)))
7588 (while (and (> n 0)
7589 (if backward
7590 (gnus-summary-find-prev unread)
7591 (gnus-summary-find-next unread)))
16409b0b
GM
7592 (unless (zerop (setq n (1- n)))
7593 (gnus-summary-show-thread)))
eec82323
LMI
7594 (when (/= 0 n)
7595 (gnus-message 7 "No more%s articles"
7596 (if unread " unread" "")))
7597 (unless dont-display
7598 (gnus-summary-recenter)
7599 (gnus-summary-position-point))
7600 n))
7601
7602(defun gnus-summary-next-unread-subject (n)
7603 "Go to next N'th unread summary line."
7604 (interactive "p")
7605 (gnus-summary-next-subject n t))
7606
7607(defun gnus-summary-prev-subject (n &optional unread)
7608 "Go to previous N'th summary line.
7609If optional argument UNREAD is non-nil, only unread article is selected."
7610 (interactive "p")
7611 (gnus-summary-next-subject (- n) unread))
7612
7613(defun gnus-summary-prev-unread-subject (n)
7614 "Go to previous N'th unread summary line."
7615 (interactive "p")
7616 (gnus-summary-next-subject (- n) t))
7617
23f87bed
MB
7618(defun gnus-summary-goto-subjects (articles)
7619 "Insert the subject header for ARTICLES in the current buffer."
7620 (save-excursion
7621 (dolist (article articles)
7622 (gnus-summary-goto-subject article t)))
7623 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7624 (gnus-summary-position-point))
132cf96d 7625
eec82323 7626(defun gnus-summary-goto-subject (article &optional force silent)
d55fe5bb 7627 "Go to the subject line of ARTICLE.
eec82323
LMI
7628If FORCE, also allow jumping to articles not currently shown."
7629 (interactive "nArticle number: ")
23f87bed
MB
7630 (unless (numberp article)
7631 (error "Article %s is not a number" article))
eec82323
LMI
7632 (let ((b (point))
7633 (data (gnus-data-find article)))
7634 ;; We read in the article if we have to.
7635 (and (not data)
7636 force
6748645f
LMI
7637 (gnus-summary-insert-subject
7638 article
7639 (if (or (numberp force) (vectorp force)) force)
7640 t)
eec82323
LMI
7641 (setq data (gnus-data-find article)))
7642 (goto-char b)
7643 (if (not data)
7644 (progn
7645 (unless silent
7646 (gnus-message 3 "Can't find article %d" article))
7647 nil)
23f87bed
MB
7648 (let ((pt (gnus-data-pos data)))
7649 (goto-char pt)
7650 (gnus-summary-set-article-display-arrow pt))
6748645f 7651 (gnus-summary-position-point)
eec82323
LMI
7652 article)))
7653
7654;; Walking around summary lines with displaying articles.
7655
7656(defun gnus-summary-expand-window (&optional arg)
7657 "Make the summary buffer take up the entire Emacs frame.
7658Given a prefix, will force an `article' buffer configuration."
7659 (interactive "P")
eec82323
LMI
7660 (if arg
7661 (gnus-configure-windows 'article 'force)
7662 (gnus-configure-windows 'summary 'force)))
7663
7664(defun gnus-summary-display-article (article &optional all-header)
7665 "Display ARTICLE in article buffer."
01c52d31
MB
7666 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7667 (with-current-buffer gnus-article-buffer
7668 (eq major-mode 'gnus-article-mode)))
7669 (gnus-article-setup-buffer))
eec82323 7670 (gnus-set-global-variables)
01c52d31
MB
7671 (with-current-buffer gnus-article-buffer
7672 (setq gnus-article-charset gnus-newsgroup-charset)
7673 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7674 (mm-enable-multibyte))
eec82323
LMI
7675 (if (null article)
7676 nil
7677 (prog1
7678 (if gnus-summary-display-article-function
7679 (funcall gnus-summary-display-article-function article all-header)
7680 (gnus-article-prepare article all-header))
6748645f 7681 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7682 (when (and gnus-current-article
7683 (not (zerop gnus-current-article)))
7684 (gnus-summary-goto-subject gnus-current-article))
7685 (gnus-summary-recenter)
7686 (when (and gnus-use-trees gnus-show-threads)
7687 (gnus-possibly-generate-tree article)
7688 (gnus-highlight-selected-tree article))
7689 ;; Successfully display article.
7690 (gnus-article-set-window-start
7691 (cdr (assq article gnus-newsgroup-bookmarks))))))
7692
7693(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7694 "Select the current article.
7695If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7696non-nil, the article will be re-fetched even if it already present in
7697the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7698be displayed."
7699 ;; Make sure we are in the summary buffer to work around bbdb bug.
7700 (unless (eq major-mode 'gnus-summary-mode)
7701 (set-buffer gnus-summary-buffer))
7702 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7703 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7704 gnus-summary-display-article-function)
eec82323
LMI
7705 (and (not pseudo)
7706 (gnus-summary-article-pseudo-p article)
a8151ef7 7707 (error "This is a pseudo-article"))
c7a91ce1 7708 (with-current-buffer gnus-summary-buffer
16409b0b
GM
7709 (if (or (and gnus-single-article-buffer
7710 (or (null gnus-current-article)
7711 (null gnus-article-current)
7712 (null (get-buffer gnus-article-buffer))
7713 (not (eq article (cdr gnus-article-current)))
7714 (not (equal (car gnus-article-current)
de635afe 7715 gnus-newsgroup-name))
28090d40 7716 (not (get-buffer gnus-original-article-buffer))))
16409b0b
GM
7717 (and (not gnus-single-article-buffer)
7718 (or (null gnus-current-article)
389b76fa 7719 (not (get-buffer gnus-original-article-buffer))
16409b0b
GM
7720 (not (eq gnus-current-article article))))
7721 force)
7722 ;; The requested article is different from the current article.
7723 (progn
16409b0b
GM
7724 (gnus-summary-display-article article all-headers)
7725 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7726 (with-current-buffer gnus-article-buffer
16409b0b 7727 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7728 (mm-disable-multibyte))))
16409b0b
GM
7729 (gnus-article-set-window-start
7730 (cdr (assq article gnus-newsgroup-bookmarks)))
7731 article)
16409b0b 7732 'old))))
eec82323 7733
23f87bed
MB
7734(defun gnus-summary-force-verify-and-decrypt ()
7735 "Display buttons for signed/encrypted parts and verify/decrypt them."
7736 (interactive)
7737 (let ((mm-verify-option 'known)
7738 (mm-decrypt-option 'known)
7739 (gnus-article-emulate-mime t)
7740 (gnus-buttonized-mime-types (append (list "multipart/signed"
7741 "multipart/encrypted")
7742 gnus-buttonized-mime-types)))
7743 (gnus-summary-select-article nil 'force)))
7744
eec82323
LMI
7745(defun gnus-summary-set-current-mark (&optional current-mark)
7746 "Obsolete function."
7747 nil)
7748
7749(defun gnus-summary-next-article (&optional unread subject backward push)
7750 "Select the next article.
7751If UNREAD, only unread articles are selected.
7752If SUBJECT, only articles with SUBJECT are selected.
7753If BACKWARD, the previous article is selected instead of the next."
7754 (interactive "P")
11e95b02
MB
7755 ;; Make sure we are in the summary buffer.
7756 (unless (eq major-mode 'gnus-summary-mode)
7757 (set-buffer gnus-summary-buffer))
eec82323
LMI
7758 (cond
7759 ;; Is there such an article?
7760 ((and (gnus-summary-search-forward unread subject backward)
7761 (or (gnus-summary-display-article (gnus-summary-article-number))
7762 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7763 (gnus-summary-position-point))
7764 ;; If not, we try the first unread, if that is wanted.
7765 ((and subject
7766 gnus-auto-select-same
7767 (gnus-summary-first-unread-article))
7768 (gnus-summary-position-point)
7769 (gnus-message 6 "Wrapped"))
7770 ;; Try to get next/previous article not displayed in this group.
7771 ((and gnus-auto-extend-newsgroup
7772 (not unread) (not subject))
7773 (gnus-summary-goto-article
7774 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7775 nil (count-lines (point-min) (point))))
eec82323
LMI
7776 ;; Go to next/previous group.
7777 (t
7778 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7779 (gnus-summary-jump-to-group gnus-newsgroup-name))
49e787c9
GM
7780 (let ((cmd (if (featurep 'xemacs)
7781 last-command-char
7782 last-command-event))
eec82323 7783 (point
01c52d31 7784 (with-current-buffer gnus-group-buffer
eec82323 7785 (point)))
06b840e0 7786 (current-summary (current-buffer))
eec82323
LMI
7787 (group
7788 (if (eq gnus-keep-same-level 'best)
7789 (gnus-summary-best-group gnus-newsgroup-name)
7790 (gnus-summary-search-group backward gnus-keep-same-level))))
eec82323
LMI
7791 ;; Select next unread newsgroup automagically.
7792 (cond
7793 ((or (not gnus-auto-select-next)
7794 (not cmd))
7795 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7796 ((or (eq gnus-auto-select-next 'quietly)
7797 (and (eq gnus-auto-select-next 'slightly-quietly)
7798 push)
7799 (and (eq gnus-auto-select-next 'almost-quietly)
7800 (gnus-summary-last-article-p)))
7801 ;; Select quietly.
7802 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7803 (gnus-summary-exit)
7804 (gnus-message 7 "No more%s articles (%s)..."
7805 (if unread " unread" "")
7806 (if group (concat "selecting " group)
7807 "exiting"))
7808 (gnus-summary-next-group nil group backward)))
7809 (t
7810 (when (gnus-key-press-event-p last-input-event)
06b840e0
LI
7811 ;; Somehow or other, we may now have selected a different
7812 ;; window. Make point go back to the summary buffer.
7813 (when (eq current-summary (current-buffer))
b87f32fc
G
7814 ;; FIXME: This burps when get-buffer-window returns nil.
7815 (select-window (get-buffer-window current-summary 0)))
eec82323
LMI
7816 (gnus-summary-walk-group-buffer
7817 gnus-newsgroup-name cmd unread backward point))))))))
7818
7819(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7820 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7821 (?\C-p (gnus-group-prev-unread-group 1))))
7822 (cursor-in-echo-area t)
23f87bed 7823 keve key group ended prompt)
c7a91ce1 7824 (with-current-buffer gnus-group-buffer
eec82323
LMI
7825 (goto-char start)
7826 (setq group
7827 (if (eq gnus-keep-same-level 'best)
7828 (gnus-summary-best-group gnus-newsgroup-name)
7829 (gnus-summary-search-group backward gnus-keep-same-level))))
7830 (while (not ended)
23f87bed
MB
7831 (setq prompt
7832 (format
7833 "No more%s articles%s " (if unread " unread" "")
7834 (if (and group
7835 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7836 (format " (Type %s for %s [%s])"
91472578
MB
7837 (single-key-description cmd)
7838 (gnus-group-decoded-name group)
01c52d31 7839 (gnus-group-unread group))
23f87bed
MB
7840 (format " (Type %s to exit %s)"
7841 (single-key-description cmd)
91472578 7842 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7843 ;; Confirm auto selection.
23f87bed
MB
7844 (setq key (car (setq keve (gnus-read-event-char prompt)))
7845 ended t)
eec82323
LMI
7846 (cond
7847 ((assq key keystrokes)
7848 (let ((obuf (current-buffer)))
7849 (switch-to-buffer gnus-group-buffer)
7850 (when group
7851 (gnus-group-jump-to-group group))
7852 (eval (cadr (assq key keystrokes)))
7853 (setq group (gnus-group-group-name))
7854 (switch-to-buffer obuf))
7855 (setq ended nil))
7856 ((equal key cmd)
7857 (if (or (not group)
7858 (gnus-ephemeral-group-p gnus-newsgroup-name))
7859 (gnus-summary-exit)
7860 (gnus-summary-next-group nil group backward)))
7861 (t
7862 (push (cdr keve) unread-command-events))))))
7863
7864(defun gnus-summary-next-unread-article ()
7865 "Select unread article after current one."
7866 (interactive)
7867 (gnus-summary-next-article
7868 (or (not (eq gnus-summary-goto-unread 'never))
7869 (gnus-summary-last-article-p (gnus-summary-article-number)))
7870 (and gnus-auto-select-same
7871 (gnus-summary-article-subject))))
7872
7873(defun gnus-summary-prev-article (&optional unread subject)
bbbe940b 7874 "Select the article before the current one.
eec82323
LMI
7875If UNREAD is non-nil, only unread articles are selected."
7876 (interactive "P")
7877 (gnus-summary-next-article unread subject t))
7878
7879(defun gnus-summary-prev-unread-article ()
7880 "Select unread article before current one."
7881 (interactive)
7882 (gnus-summary-prev-article
7883 (or (not (eq gnus-summary-goto-unread 'never))
7884 (gnus-summary-first-article-p (gnus-summary-article-number)))
7885 (and gnus-auto-select-same
7886 (gnus-summary-article-subject))))
7887
23f87bed 7888(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7889 "Show next page of the selected article.
7890If at the end of the current article, select the next article.
7891LINES says how many lines should be scrolled up.
7892
7893If CIRCULAR is non-nil, go to the start of the article instead of
7894selecting the next article when reaching the end of the current
23f87bed
MB
7895article.
7896
7897If STOP is non-nil, just stop when reaching the end of the message.
7898
7899Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7900 (interactive "P")
7901 (setq gnus-summary-buffer (current-buffer))
7902 (gnus-set-global-variables)
7903 (let ((article (gnus-summary-article-number))
7904 (article-window (get-buffer-window gnus-article-buffer t))
7905 endp)
6748645f
LMI
7906 ;; If the buffer is empty, we have no article.
7907 (unless article
7908 (error "No article to select"))
eec82323
LMI
7909 (gnus-configure-windows 'article)
7910 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7911 (if (and (eq gnus-summary-goto-unread 'never)
7912 (not (gnus-summary-last-article-p article)))
7913 (gnus-summary-next-article)
7914 (gnus-summary-next-unread-article))
7915 (if (or (null gnus-current-article)
7916 (null gnus-article-current)
7917 (/= article (cdr gnus-article-current))
7918 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7919 ;; Selected subject is different from current article's.
7920 (gnus-summary-display-article article)
7921 (when article-window
7922 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7923 (setq endp (or (gnus-article-next-page lines)
7924 (gnus-article-only-boring-p))))
eec82323 7925 (when endp
b1992461 7926 (cond ((or stop gnus-summary-stop-at-end-of-message)
23f87bed
MB
7927 (gnus-message 3 "End of message"))
7928 (circular
eec82323
LMI
7929 (gnus-summary-beginning-of-article))
7930 (lines
7931 (gnus-message 3 "End of message"))
7932 ((null lines)
7933 (if (and (eq gnus-summary-goto-unread 'never)
7934 (not (gnus-summary-last-article-p article)))
7935 (gnus-summary-next-article)
7936 (gnus-summary-next-unread-article))))))))
7937 (gnus-summary-recenter)
7938 (gnus-summary-position-point)))
7939
7940(defun gnus-summary-prev-page (&optional lines move)
7941 "Show previous page of selected article.
7942Argument LINES specifies lines to be scrolled down.
7943If MOVE, move to the previous unread article if point is at
7944the beginning of the buffer."
7945 (interactive "P")
eec82323
LMI
7946 (let ((article (gnus-summary-article-number))
7947 (article-window (get-buffer-window gnus-article-buffer t))
7948 endp)
7949 (gnus-configure-windows 'article)
7950 (if (or (null gnus-current-article)
7951 (null gnus-article-current)
7952 (/= article (cdr gnus-article-current))
7953 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7954 ;; Selected subject is different from current article's.
7955 (gnus-summary-display-article article)
7956 (gnus-summary-recenter)
7957 (when article-window
7958 (gnus-eval-in-buffer-window gnus-article-buffer
7959 (setq endp (gnus-article-prev-page lines)))
7960 (when (and move endp)
7961 (cond (lines
7962 (gnus-message 3 "Beginning of message"))
7963 ((null lines)
7964 (if (and (eq gnus-summary-goto-unread 'never)
7965 (not (gnus-summary-first-article-p article)))
7966 (gnus-summary-prev-article)
7967 (gnus-summary-prev-unread-article))))))))
7968 (gnus-summary-position-point))
7969
7970(defun gnus-summary-prev-page-or-article (&optional lines)
7971 "Show previous page of selected article.
7972Argument LINES specifies lines to be scrolled down.
7973If at the beginning of the article, go to the next article."
7974 (interactive "P")
7975 (gnus-summary-prev-page lines t))
7976
7977(defun gnus-summary-scroll-up (lines)
7978 "Scroll up (or down) one line current article.
a3f57c41
G
7979Argument LINES specifies lines to be scrolled up (or down if negative).
7980If no article is selected, then the current article will be selected first."
eec82323 7981 (interactive "p")
eec82323
LMI
7982 (gnus-configure-windows 'article)
7983 (gnus-summary-show-thread)
7984 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7985 (gnus-eval-in-buffer-window gnus-article-buffer
7986 (cond ((> lines 0)
7987 (when (gnus-article-next-page lines)
7988 (gnus-message 3 "End of message")))
7989 ((< lines 0)
7990 (gnus-article-prev-page (- lines))))))
7991 (gnus-summary-recenter)
7992 (gnus-summary-position-point))
7993
6748645f
LMI
7994(defun gnus-summary-scroll-down (lines)
7995 "Scroll down (or up) one line current article.
a3f57c41
G
7996Argument LINES specifies lines to be scrolled down (or up if negative).
7997If no article is selected, then the current article will be selected first."
6748645f
LMI
7998 (interactive "p")
7999 (gnus-summary-scroll-up (- lines)))
8000
eec82323
LMI
8001(defun gnus-summary-next-same-subject ()
8002 "Select next article which has the same subject as current one."
8003 (interactive)
eec82323
LMI
8004 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8005
8006(defun gnus-summary-prev-same-subject ()
8007 "Select previous article which has the same subject as current one."
8008 (interactive)
eec82323
LMI
8009 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8010
8011(defun gnus-summary-next-unread-same-subject ()
8012 "Select next unread article which has the same subject as current one."
8013 (interactive)
eec82323
LMI
8014 (gnus-summary-next-article t (gnus-summary-article-subject)))
8015
8016(defun gnus-summary-prev-unread-same-subject ()
8017 "Select previous unread article which has the same subject as current one."
8018 (interactive)
eec82323
LMI
8019 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8020
8021(defun gnus-summary-first-unread-article ()
8022 "Select the first unread article.
8023Return nil if there are no unread articles."
8024 (interactive)
eec82323
LMI
8025 (prog1
8026 (when (gnus-summary-first-subject t)
8027 (gnus-summary-show-thread)
8028 (gnus-summary-first-subject t)
8029 (gnus-summary-display-article (gnus-summary-article-number)))
8030 (gnus-summary-position-point)))
8031
16409b0b
GM
8032(defun gnus-summary-first-unread-subject ()
8033 "Place the point on the subject line of the first unread article.
8034Return nil if there are no unread articles."
8035 (interactive)
8036 (prog1
8037 (when (gnus-summary-first-subject t)
8038 (gnus-summary-show-thread)
8039 (gnus-summary-first-subject t))
8040 (gnus-summary-position-point)))
8041
23f87bed
MB
8042(defun gnus-summary-first-unseen-subject ()
8043 "Place the point on the subject line of the first unseen article.
8044Return nil if there are no unseen articles."
8045 (interactive)
8046 (prog1
8047 (when (gnus-summary-first-subject nil nil t)
8048 (gnus-summary-show-thread)
8049 (gnus-summary-first-subject nil nil t))
8050 (gnus-summary-position-point)))
8051
8052(defun gnus-summary-first-unseen-or-unread-subject ()
20a673b2
KY
8053 "Place the point on the subject line of the first unseen and unread article.
8054If all article have been seen, on the subject line of the first unread
23f87bed
MB
8055article."
8056 (interactive)
8057 (prog1
8058 (unless (when (gnus-summary-first-subject nil nil t)
8059 (gnus-summary-show-thread)
8060 (gnus-summary-first-subject nil nil t))
8061 (when (gnus-summary-first-subject t)
8062 (gnus-summary-show-thread)
8063 (gnus-summary-first-subject t)))
8064 (gnus-summary-position-point)))
8065
eec82323
LMI
8066(defun gnus-summary-first-article ()
8067 "Select the first article.
8068Return nil if there are no articles."
8069 (interactive)
eec82323
LMI
8070 (prog1
8071 (when (gnus-summary-first-subject)
16409b0b
GM
8072 (gnus-summary-show-thread)
8073 (gnus-summary-first-subject)
8074 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
8075 (gnus-summary-position-point)))
8076
23f87bed
MB
8077(defun gnus-summary-best-unread-article (&optional arg)
8078 "Select the unread article with the highest score.
8079If given a prefix argument, select the next unread article that has a
8080score higher than the default score."
8081 (interactive "P")
8082 (let ((article (if arg
8083 (gnus-summary-better-unread-subject)
8084 (gnus-summary-best-unread-subject))))
8085 (if article
8086 (gnus-summary-goto-article article)
8087 (error "No unread articles"))))
8088
8089(defun gnus-summary-best-unread-subject ()
8090 "Select the unread subject with the highest score."
eec82323 8091 (interactive)
eec82323
LMI
8092 (let ((best -1000000)
8093 (data gnus-newsgroup-data)
8094 article score)
8095 (while data
8096 (and (gnus-data-unread-p (car data))
8097 (> (setq score
8098 (gnus-summary-article-score (gnus-data-number (car data))))
8099 best)
8100 (setq best score
8101 article (gnus-data-number (car data))))
8102 (setq data (cdr data)))
23f87bed
MB
8103 (when article
8104 (gnus-summary-goto-subject article))
8105 (gnus-summary-position-point)
8106 article))
8107
8108(defun gnus-summary-better-unread-subject ()
8109 "Select the first unread subject that has a score over the default score."
8110 (interactive)
8111 (let ((data gnus-newsgroup-data)
8112 article score)
8113 (while (and (setq article (gnus-data-number (car data)))
8114 (or (gnus-data-read-p (car data))
8115 (not (> (gnus-summary-article-score article)
8116 gnus-summary-default-score))))
8117 (setq data (cdr data)))
8118 (when article
8119 (gnus-summary-goto-subject article))
8120 (gnus-summary-position-point)
8121 article))
eec82323
LMI
8122
8123(defun gnus-summary-last-subject ()
8124 "Go to the last displayed subject line in the group."
8125 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8126 (when article
8127 (gnus-summary-goto-subject article))))
8128
8129(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
8130 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8131If ALL-HEADERS is non-nil, no header lines are hidden.
8132If FORCE, go to the article even if it isn't displayed. If FORCE
8133is a number, it is the line the article is to be displayed on."
eec82323
LMI
8134 (interactive
8135 (list
229b59da
G
8136 (gnus-completing-read
8137 "Article number or Message-ID"
8138 (mapcar 'int-to-string gnus-newsgroup-limit))
eec82323
LMI
8139 current-prefix-arg
8140 t))
8141 (prog1
6748645f 8142 (if (and (stringp article)
23f87bed 8143 (string-match "@\\|%40" article))
6748645f
LMI
8144 (gnus-summary-refer-article article)
8145 (when (stringp article)
8146 (setq article (string-to-number article)))
8147 (if (gnus-summary-goto-subject article force)
8148 (gnus-summary-display-article article all-headers)
8149 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
8150 (gnus-summary-position-point)))
8151
8152(defun gnus-summary-goto-last-article ()
8153 "Go to the previously read article."
8154 (interactive)
8155 (prog1
8156 (when gnus-last-article
6748645f 8157 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
8158 (gnus-summary-position-point)))
8159
8160(defun gnus-summary-pop-article (number)
8161 "Pop one article off the history and go to the previous.
8162NUMBER articles will be popped off."
8163 (interactive "p")
8164 (let (to)
8165 (setq gnus-newsgroup-history
8166 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8167 (if to
6748645f 8168 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
8169 (error "Article history empty")))
8170 (gnus-summary-position-point))
8171
8172;; Summary commands and functions for limiting the summary buffer.
8173
8174(defun gnus-summary-limit-to-articles (n)
8175 "Limit the summary buffer to the next N articles.
8176If not given a prefix, use the process marked articles instead."
8177 (interactive "P")
eec82323
LMI
8178 (prog1
8179 (let ((articles (gnus-summary-work-articles n)))
8180 (setq gnus-newsgroup-processable nil)
8181 (gnus-summary-limit articles))
8182 (gnus-summary-position-point)))
8183
8184(defun gnus-summary-pop-limit (&optional total)
8185 "Restore the previous limit.
8186If given a prefix, remove all limits."
8187 (interactive "P")
eec82323
LMI
8188 (when total
8189 (setq gnus-newsgroup-limits
8190 (list (mapcar (lambda (h) (mail-header-number h))
8191 gnus-newsgroup-headers))))
8192 (unless gnus-newsgroup-limits
8193 (error "No limit to pop"))
8194 (prog1
8195 (gnus-summary-limit nil 'pop)
8196 (gnus-summary-position-point)))
8197
47b63dfa
SZ
8198(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8199 "Limit the summary buffer to articles that have subjects that match a regexp.
8200If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 8201 (interactive
47b63dfa
SZ
8202 (list (read-string (if current-prefix-arg
8203 "Exclude subject (regexp): "
a1506d29 8204 "Limit to subject (regexp): "))
47b63dfa 8205 nil current-prefix-arg))
eec82323
LMI
8206 (unless header
8207 (setq header "subject"))
8208 (when (not (equal "" subject))
8209 (prog1
8210 (let ((articles (gnus-summary-find-matching
a1506d29 8211 (or header "subject") subject 'all nil nil
47b63dfa 8212 not-matching)))
eec82323
LMI
8213 (unless articles
8214 (error "Found no matches for \"%s\"" subject))
8215 (gnus-summary-limit articles))
8216 (gnus-summary-position-point))))
8217
ef6e0ec7 8218(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
8219 "Limit the summary buffer to articles that have authors that match a regexp.
8220If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 8221 (interactive
47b63dfa
SZ
8222 (list (read-string (if current-prefix-arg
8223 "Exclude author (regexp): "
a1506d29 8224 "Limit to author (regexp): "))
ef6e0ec7
SZ
8225 current-prefix-arg))
8226 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323 8227
01c52d31
MB
8228(defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8229 "Limit the summary buffer to articles with the given RECIPIENT.
8230
8231If NOT-MATCHING, exclude RECIPIENT.
8232
8233To and Cc headers are checked. You need to include them in
8234`nnmail-extra-headers'."
8235 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8236 (interactive
8237 (list (read-string (format "%s recipient (regexp): "
8238 (if current-prefix-arg "Exclude" "Limit to")))
8239 current-prefix-arg))
8240 (when (not (equal "" recipient))
8241 (prog1 (let* ((to
8242 (if (memq 'To nnmail-extra-headers)
8243 (gnus-summary-find-matching
8244 (cons 'extra 'To) recipient 'all nil nil
8245 not-matching)
8246 (gnus-message
8247 1 "`To' isn't present in `nnmail-extra-headers'")
8248 (sit-for 1)
8249 nil))
8250 (cc
8251 (if (memq 'Cc nnmail-extra-headers)
8252 (gnus-summary-find-matching
8253 (cons 'extra 'Cc) recipient 'all nil nil
8254 not-matching)
8255 (gnus-message
8256 1 "`Cc' isn't present in `nnmail-extra-headers'")
8257 (sit-for 1)
8258 nil))
8259 (articles
8260 (if not-matching
8261 ;; We need the numbers that are in both lists:
8262 (mapcar (lambda (a)
8263 (and (memq a to) a))
8264 cc)
8265 (nconc to cc))))
8266 (unless articles
8267 (error "Found no matches for \"%s\"" recipient))
8268 (gnus-summary-limit articles))
8269 (gnus-summary-position-point))))
8270
8271(defun gnus-summary-limit-to-address (address &optional not-matching)
8272 "Limit the summary buffer to articles with the given ADDRESS.
8273
8274If NOT-MATCHING, exclude ADDRESS.
8275
8276To, Cc and From headers are checked. You need to include `To' and `Cc'
8277in `nnmail-extra-headers'."
8278 (interactive
8279 (list (read-string (format "%s address (regexp): "
8280 (if current-prefix-arg "Exclude" "Limit to")))
8281 current-prefix-arg))
8282 (when (not (equal "" address))
8283 (prog1 (let* ((to
8284 (if (memq 'To nnmail-extra-headers)
8285 (gnus-summary-find-matching
8286 (cons 'extra 'To) address 'all nil nil
8287 not-matching)
8288 (gnus-message
8289 1 "`To' isn't present in `nnmail-extra-headers'")
8290 (sit-for 1)
8291 t))
8292 (cc
8293 (if (memq 'Cc nnmail-extra-headers)
8294 (gnus-summary-find-matching
8295 (cons 'extra 'Cc) address 'all nil nil
8296 not-matching)
8297 (gnus-message
8298 1 "`Cc' isn't present in `nnmail-extra-headers'")
8299 (sit-for 1)
8300 t))
8301 (from
8302 (gnus-summary-find-matching "from" address
8303 'all nil nil not-matching))
8304 (articles
8305 (if not-matching
8306 ;; We need the numbers that are in all lists:
8307 (if (eq cc t)
8308 (if (eq to t)
8309 from
8310 (mapcar (lambda (a) (car (memq a from))) to))
8311 (if (eq to t)
8312 (mapcar (lambda (a) (car (memq a from))) cc)
8313 (mapcar (lambda (a) (car (memq a from)))
8314 (mapcar (lambda (a) (car (memq a to)))
8315 cc))))
8316 (nconc (if (eq to t) nil to)
8317 (if (eq cc t) nil cc)
8318 from))))
8319 (unless articles
8320 (error "Found no matches for \"%s\"" address))
8321 (gnus-summary-limit articles))
8322 (gnus-summary-position-point))))
8323
8324(defun gnus-summary-limit-strange-charsets-predicate (header)
765d4319
KY
8325 (when (fboundp 'char-charset)
8326 (let ((string (concat (mail-header-subject header)
8327 (mail-header-from header)))
8328 charset found)
8329 (dotimes (i (1- (length string)))
8330 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8331 (when (string-match "unicode\\|big\\|japanese" charset)
8332 (setq found t)))
8333 found)))
01c52d31
MB
8334
8335(defun gnus-summary-limit-to-predicate (predicate)
8336 "Limit to articles where PREDICATE returns non-nil.
8337PREDICATE will be called with the header structures of the
8338articles."
8339 (let ((articles nil)
8340 (case-fold-search t))
8341 (dolist (header gnus-newsgroup-headers)
8342 (when (funcall predicate header)
8343 (push (mail-header-number header) articles)))
8344 (gnus-summary-limit (nreverse articles))))
8345
eec82323
LMI
8346(defun gnus-summary-limit-to-age (age &optional younger-p)
8347 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8348If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8349articles that are younger than AGE days."
16409b0b
GM
8350 (interactive
8351 (let ((younger current-prefix-arg)
8352 (days-got nil)
8353 days)
8354 (while (not days-got)
8355 (setq days (if younger
23f87bed
MB
8356 (read-string "Limit to articles younger than (in days, older when negative): ")
8357 (read-string
8358 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
8359 (when (> (length days) 0)
8360 (setq days (read days)))
8361 (if (numberp days)
23f87bed
MB
8362 (progn
8363 (setq days-got t)
01c52d31
MB
8364 (when (< days 0)
8365 (setq younger (not younger))
8366 (setq days (* days -1))))
16409b0b
GM
8367 (message "Please enter a number.")
8368 (sleep-for 1)))
8369 (list days younger)))
eec82323
LMI
8370 (prog1
8371 (let ((data gnus-newsgroup-data)
16409b0b 8372 (cutoff (days-to-time age))
eec82323
LMI
8373 articles d date is-younger)
8374 (while (setq d (pop data))
8375 (when (and (vectorp (gnus-data-header d))
8376 (setq date (mail-header-date (gnus-data-header d))))
16409b0b 8377 (setq is-younger (time-less-p
3d6e7a43 8378 (time-since (gnus-date-get-time date))
eec82323 8379 cutoff))
6748645f
LMI
8380 (when (if younger-p
8381 is-younger
8382 (not is-younger))
eec82323
LMI
8383 (push (gnus-data-number d) articles))))
8384 (gnus-summary-limit (nreverse articles)))
8385 (gnus-summary-position-point)))
8386
47b63dfa 8387(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
8388 "Limit the summary buffer to articles that match an 'extra' header."
8389 (interactive
8390 (let ((header
8391 (intern
229b59da 8392 (gnus-completing-read
47b63dfa 8393 (if current-prefix-arg
81df110a
RF
8394 "Exclude extra header"
8395 "Limit extra header")
229b59da
G
8396 (mapcar 'symbol-name gnus-extra-headers)
8397 t nil nil
8398 (symbol-name (car gnus-extra-headers))))))
16409b0b 8399 (list header
a1506d29 8400 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
8401 (if current-prefix-arg "Exclude" "Limit to")
8402 header))
8403 current-prefix-arg)))
16409b0b
GM
8404 (when (not (equal "" regexp))
8405 (prog1
8406 (let ((articles (gnus-summary-find-matching
a1506d29 8407 (cons 'extra header) regexp 'all nil nil
47b63dfa 8408 not-matching)))
16409b0b
GM
8409 (unless articles
8410 (error "Found no matches for \"%s\"" regexp))
8411 (gnus-summary-limit articles))
8412 (gnus-summary-position-point))))
8413
23f87bed
MB
8414(defun gnus-summary-limit-to-display-predicate ()
8415 "Limit the summary buffer to the predicated in the `display' group parameter."
8416 (interactive)
8417 (unless gnus-newsgroup-display
8418 (error "There is no `display' group parameter"))
8419 (let (articles)
3a3cbf0a 8420 (dolist (gnus-number gnus-newsgroup-articles)
23f87bed 8421 (when (funcall gnus-newsgroup-display)
3a3cbf0a 8422 (push gnus-number articles)))
23f87bed
MB
8423 (gnus-summary-limit articles))
8424 (gnus-summary-position-point))
8425
eec82323
LMI
8426(defun gnus-summary-limit-to-unread (&optional all)
8427 "Limit the summary buffer to articles that are not marked as read.
8428If ALL is non-nil, limit strictly to unread articles."
8429 (interactive "P")
8430 (if all
8431 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8432 (gnus-summary-limit-to-marks
8433 ;; Concat all the marks that say that an article is read and have
8434 ;; those removed.
8435 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 8436 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
8437 gnus-low-score-mark gnus-expirable-mark
8438 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
c4d82de8 8439 gnus-duplicate-mark)
eec82323
LMI
8440 'reverse)))
8441
01c52d31
MB
8442(defun gnus-summary-limit-to-headers (match &optional reverse)
8443 "Limit the summary buffer to articles that have headers that match MATCH.
8444If REVERSE (the prefix), limit to articles that don't match."
8445 (interactive "sMatch headers (regexp): \nP")
8446 (gnus-summary-limit-to-bodies match reverse t))
8447
8448(defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8449 "Limit the summary buffer to articles that have bodies that match MATCH.
8450If REVERSE (the prefix), limit to articles that don't match."
8451 (interactive "sMatch body (regexp): \nP")
8452 (let ((articles nil)
8453 (gnus-select-article-hook nil) ;Disable hook.
8454 (gnus-article-prepare-hook nil)
8455 (gnus-use-article-prefetch nil)
8456 (gnus-keep-backlog nil)
8457 (gnus-break-pages nil)
8458 (gnus-summary-display-arrow nil)
8459 (gnus-updated-mode-lines nil)
8460 (gnus-auto-center-summary nil)
8461 (gnus-display-mime-function nil))
8462 (dolist (data gnus-newsgroup-data)
8463 (let (gnus-mark-article-hook)
8464 (gnus-summary-select-article t t nil (gnus-data-number data)))
398a825b 8465 (with-current-buffer gnus-article-buffer
01c52d31
MB
8466 (article-goto-body)
8467 (let* ((case-fold-search t)
8468 (found (if headersp
8469 (re-search-backward match nil t)
8470 (re-search-forward match nil t))))
8471 (when (or (and found
8472 (not reverse))
8473 (and (not found)
8474 reverse))
8475 (push (gnus-data-number data) articles)))))
8476 (if (not articles)
8477 (message "No messages matched")
8478 (gnus-summary-limit articles)))
8479 (gnus-summary-position-point))
8480
8481(defun gnus-summary-limit-to-singletons (&optional threadsp)
8482 "Limit the summary buffer to articles that aren't part on any thread.
8483If THREADSP (the prefix), limit to articles that are in threads."
8484 (interactive "P")
8485 (let ((articles nil)
8486 thread-articles
8487 threads)
8488 (dolist (thread gnus-newsgroup-threads)
8489 (if (stringp (car thread))
8490 (dolist (thread (cdr thread))
8491 (push thread threads))
8492 (push thread threads)))
8493 (dolist (thread threads)
8494 (setq thread-articles (gnus-articles-in-thread thread))
8495 (when (or (and threadsp
8496 (> (length thread-articles) 1))
8497 (and (not threadsp)
8498 (= (length thread-articles) 1)))
8499 (setq articles (nconc thread-articles articles))))
8500 (if (not articles)
8501 (message "No messages matched")
8502 (gnus-summary-limit articles))
8503 (gnus-summary-position-point)))
8504
8505(defun gnus-summary-limit-to-replied (&optional unreplied)
8506 "Limit the summary buffer to replied articles.
8507If UNREPLIED (the prefix), limit to unreplied articles."
8508 (interactive "P")
8509 (if unreplied
8510 (gnus-summary-limit
8511 (gnus-set-difference gnus-newsgroup-articles
8512 gnus-newsgroup-replied))
8513 (gnus-summary-limit gnus-newsgroup-replied))
8514 (gnus-summary-position-point))
8515
eec82323
LMI
8516(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8517 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8518If REVERSE, limit the summary buffer to articles that are marked
8519with MARKS. MARKS can either be a string of marks or a list of marks.
8520Returns how many articles were removed."
8521 (interactive "sMarks: ")
8522 (gnus-summary-limit-to-marks marks t))
8523
8524(defun gnus-summary-limit-to-marks (marks &optional reverse)
8525 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8526If REVERSE (the prefix), limit the summary buffer to articles that are
8527not marked with MARKS. MARKS can either be a string of marks or a
8528list of marks.
8529Returns how many articles were removed."
6748645f 8530 (interactive "sMarks: \nP")
eec82323
LMI
8531 (prog1
8532 (let ((data gnus-newsgroup-data)
8533 (marks (if (listp marks) marks
8534 (append marks nil))) ; Transform to list.
8535 articles)
8536 (while data
8537 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8538 (memq (gnus-data-mark (car data)) marks))
8539 (push (gnus-data-number (car data)) articles))
8540 (setq data (cdr data)))
8541 (gnus-summary-limit articles))
8542 (gnus-summary-position-point)))
8543
23f87bed 8544(defun gnus-summary-limit-to-score (score)
eec82323 8545 "Limit to articles with score at or above SCORE."
23f87bed 8546 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
8547 (let ((data gnus-newsgroup-data)
8548 articles)
8549 (while data
8550 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8551 score)
8552 (push (gnus-data-number (car data)) articles))
8553 (setq data (cdr data)))
8554 (prog1
8555 (gnus-summary-limit articles)
8556 (gnus-summary-position-point))))
8557
23f87bed
MB
8558(defun gnus-summary-limit-to-unseen ()
8559 "Limit to unseen articles."
8560 (interactive)
8561 (prog1
8562 (gnus-summary-limit gnus-newsgroup-unseen)
8563 (gnus-summary-position-point)))
8564
6748645f 8565(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
8566 "Display all the hidden articles that is in the thread with ID in it.
8567When called interactively, ID is the Message-ID of the current
8568article."
6748645f
LMI
8569 (interactive (list (mail-header-id (gnus-summary-article-header))))
8570 (let ((articles (gnus-articles-in-thread
181cb5fb
G
8571 (gnus-id-to-thread (gnus-root-id id))))
8572 ;;we REALLY want the whole thread---this prevents cut-threads
8573 ;;from removing the thread we want to include.
8574 (gnus-fetch-old-headers nil)
8575 (gnus-build-sparse-threads nil))
6748645f
LMI
8576 (prog1
8577 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
8578 (gnus-summary-limit-include-matching-articles
8579 "subject"
8580 (regexp-quote (gnus-simplify-subject-re
8581 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
8582 (gnus-summary-position-point))))
8583
23f87bed
MB
8584(defun gnus-summary-limit-include-matching-articles (header regexp)
8585 "Display all the hidden articles that have HEADERs that match REGEXP."
8586 (interactive (list (read-string "Match on header: ")
8587 (read-string "Regexp: ")))
8588 (let ((articles (gnus-find-matching-articles header regexp)))
8589 (prog1
8590 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8591 (gnus-summary-position-point))))
8592
8593(defun gnus-summary-insert-dormant-articles ()
8594 "Insert all the dormant articles for this group into the current buffer."
8595 (interactive)
8596 (let ((gnus-verbose (max 6 gnus-verbose)))
8597 (if (not gnus-newsgroup-dormant)
db629244 8598 (gnus-message 3 "No dormant articles for this group")
23f87bed
MB
8599 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8600
01c52d31
MB
8601(defun gnus-summary-insert-ticked-articles ()
8602 "Insert ticked articles for this group into the current buffer."
8603 (interactive)
8604 (let ((gnus-verbose (max 6 gnus-verbose)))
8605 (if (not gnus-newsgroup-marked)
8606 (gnus-message 3 "No ticked articles for this group")
8607 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8608
eec82323 8609(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
8610 "Display all the hidden articles that are marked as dormant.
8611Note that this command only works on a subset of the articles currently
8612fetched for this group."
eec82323 8613 (interactive)
eec82323
LMI
8614 (unless gnus-newsgroup-dormant
8615 (error "There are no dormant articles in this group"))
8616 (prog1
8617 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8618 (gnus-summary-position-point)))
8619
144b7b5c
G
8620(defun gnus-summary-include-articles (articles)
8621 "Fetch the headers for ARTICLES and then display the summary lines."
8622 (let ((gnus-inhibit-demon t)
8623 (gnus-agent nil)
8624 (gnus-read-all-available-headers t))
8625 (setq gnus-newsgroup-headers
8626 (gnus-merge
8627 'list gnus-newsgroup-headers
8628 (gnus-fetch-headers articles nil t)
8629 'gnus-article-sort-by-number))
8630 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8631
eec82323
LMI
8632(defun gnus-summary-limit-exclude-dormant ()
8633 "Hide all dormant articles."
8634 (interactive)
eec82323
LMI
8635 (prog1
8636 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8637 (gnus-summary-position-point)))
8638
8639(defun gnus-summary-limit-exclude-childless-dormant ()
8640 "Hide all dormant articles that have no children."
8641 (interactive)
eec82323
LMI
8642 (let ((data (gnus-data-list t))
8643 articles d children)
8644 ;; Find all articles that are either not dormant or have
8645 ;; children.
8646 (while (setq d (pop data))
8647 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8648 (and (setq children
8649 (gnus-article-children (gnus-data-number d)))
8650 (let (found)
8651 (while children
8652 (when (memq (car children) articles)
8653 (setq children nil
8654 found t))
8655 (pop children))
8656 found)))
8657 (push (gnus-data-number d) articles)))
8658 ;; Do the limiting.
8659 (prog1
8660 (gnus-summary-limit articles)
8661 (gnus-summary-position-point))))
8662
8663(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8664 "Mark all unread excluded articles as read.
8665If ALL, mark even excluded ticked and dormants as read."
8666 (interactive "P")
23f87bed
MB
8667 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8668 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8669 (sort
8670 (mapcar (lambda (h) (mail-header-number h))
8671 gnus-newsgroup-headers)
8672 '<)
23f87bed 8673 gnus-newsgroup-limit))
eec82323 8674 article)
6748645f 8675 (setq gnus-newsgroup-unreads
23f87bed
MB
8676 (gnus-sorted-intersection gnus-newsgroup-unreads
8677 gnus-newsgroup-limit))
eec82323
LMI
8678 (if all
8679 (setq gnus-newsgroup-dormant nil
8680 gnus-newsgroup-marked nil
8681 gnus-newsgroup-reads
8682 (nconc
8683 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8684 gnus-newsgroup-reads))
8685 (while (setq article (pop articles))
8686 (unless (or (memq article gnus-newsgroup-dormant)
8687 (memq article gnus-newsgroup-marked))
8688 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8689
8690(defun gnus-summary-limit (articles &optional pop)
8691 (if pop
8692 ;; We pop the previous limit off the stack and use that.
8693 (setq articles (car gnus-newsgroup-limits)
8694 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8695 ;; We use the new limit, so we push the old limit on the stack.
8696 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8697 ;; Set the limit.
8698 (setq gnus-newsgroup-limit articles)
8699 (let ((total (length gnus-newsgroup-data))
8700 (data (gnus-data-find-list (gnus-summary-article-number)))
8701 (gnus-summary-mark-below nil) ; Inhibit this.
8702 found)
8703 ;; This will do all the work of generating the new summary buffer
8704 ;; according to the new limit.
8705 (gnus-summary-prepare)
8706 ;; Hide any threads, possibly.
23f87bed 8707 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8708 ;; Try to return to the article you were at, or one in the
8709 ;; neighborhood.
8710 (when data
8711 ;; We try to find some article after the current one.
8712 (while data
8713 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8714 (setq data nil
8715 found t))
8716 (setq data (cdr data))))
8717 (unless found
8718 ;; If there is no data, that means that we were after the last
8719 ;; article. The same goes when we can't find any articles
8720 ;; after the current one.
8721 (goto-char (point-max))
8722 (gnus-summary-find-prev))
6748645f 8723 (gnus-set-mode-line 'summary)
eec82323
LMI
8724 ;; We return how many articles were removed from the summary
8725 ;; buffer as a result of the new limit.
8726 (- total (length gnus-newsgroup-data))))
8727
8728(defsubst gnus-invisible-cut-children (threads)
8729 (let ((num 0))
8730 (while threads
8731 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8732 (incf num))
8733 (pop threads))
8734 (< num 2)))
8735
8736(defsubst gnus-cut-thread (thread)
8737 "Go forwards in the thread until we find an article that we want to display."
8738 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8739 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8740 (numberp gnus-fetch-old-headers)
eec82323
LMI
8741 (eq gnus-build-sparse-threads 'some)
8742 (eq gnus-build-sparse-threads 'more))
8743 ;; Deal with old-fetched headers and sparse threads.
8744 (while (and
8745 thread
8746 (or
8747 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8748 (gnus-summary-article-ancient-p
8749 (mail-header-number (car thread))))
6748645f
LMI
8750 (if (or (<= (length (cdr thread)) 1)
8751 (eq gnus-fetch-old-headers 'invisible))
8752 (setq gnus-newsgroup-limit
8753 (delq (mail-header-number (car thread))
8754 gnus-newsgroup-limit)
8755 thread (cadr thread))
8756 (when (gnus-invisible-cut-children (cdr thread))
8757 (let ((th (cdr thread)))
8758 (while th
8759 (if (memq (mail-header-number (caar th))
a8151ef7 8760 gnus-newsgroup-limit)
6748645f
LMI
8761 (setq thread (car th)
8762 th nil)
8763 (setq th (cdr th))))))))))
eec82323
LMI
8764 thread)
8765
8766(defun gnus-cut-threads (threads)
23f87bed 8767 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8768 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8769 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8770 (numberp gnus-fetch-old-headers)
eec82323
LMI
8771 (eq gnus-build-sparse-threads 'some)
8772 (eq gnus-build-sparse-threads 'more))
8773 (let ((th threads))
8774 (while th
8775 (setcar th (gnus-cut-thread (car th)))
8776 (setq th (cdr th)))))
8777 ;; Remove nixed out threads.
8778 (delq nil threads))
8779
8780(defun gnus-summary-initial-limit (&optional show-if-empty)
8781 "Figure out what the initial limit is supposed to be on group entry.
8782This entails weeding out unwanted dormants, low-scored articles,
8783fetch-old-headers verbiage, and so on."
8784 ;; Most groups have nothing to remove.
f394fa25
MB
8785 (unless (or gnus-inhibit-limiting
8786 (and (null gnus-newsgroup-dormant)
8787 (eq gnus-newsgroup-display 'gnus-not-ignore)
8788 (not (eq gnus-fetch-old-headers 'some))
8789 (not (numberp gnus-fetch-old-headers))
8790 (not (eq gnus-fetch-old-headers 'invisible))
8791 (null gnus-summary-expunge-below)
8792 (not (eq gnus-build-sparse-threads 'some))
8793 (not (eq gnus-build-sparse-threads 'more))
8ccbef23 8794 (null gnus-thread-expunge-below)))
eec82323
LMI
8795 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8796 (setq gnus-newsgroup-limit nil)
8797 (mapatoms
8798 (lambda (node)
8799 (unless (car (symbol-value node))
8800 ;; These threads have no parents -- they are roots.
8801 (let ((nodes (cdr (symbol-value node)))
8802 thread)
8803 (while nodes
8804 (if (and gnus-thread-expunge-below
8805 (< (gnus-thread-total-score (car nodes))
8806 gnus-thread-expunge-below))
8807 (gnus-expunge-thread (pop nodes))
8808 (setq thread (pop nodes))
8809 (gnus-summary-limit-children thread))))))
8810 gnus-newsgroup-dependencies)
8811 ;; If this limitation resulted in an empty group, we might
8812 ;; pop the previous limit and use it instead.
8813 (when (and (not gnus-newsgroup-limit)
8814 show-if-empty)
8815 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8816 gnus-newsgroup-limit))
8817
8818(defun gnus-summary-limit-children (thread)
8819 "Return 1 if this subthread is visible and 0 if it is not."
8820 ;; First we get the number of visible children to this thread. This
8821 ;; is done by recursing down the thread using this function, so this
8822 ;; will really go down to a leaf article first, before slowly
8823 ;; working its way up towards the root.
8824 (when thread
04b61ae9 8825 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8826 (children
eec82323
LMI
8827 (if (cdr thread)
8828 (apply '+ (mapcar 'gnus-summary-limit-children
8829 (cdr thread)))
8830 0))
3d319c8f
LMI
8831 (number (mail-header-number (car thread)))
8832 score)
eec82323
LMI
8833 (if (and
8834 (not (memq number gnus-newsgroup-marked))
8835 (or
8836 ;; If this article is dormant and has absolutely no visible
8837 ;; children, then this article isn't visible.
8838 (and (memq number gnus-newsgroup-dormant)
8839 (zerop children))
8840 ;; If this is "fetch-old-headered" and there is no
8841 ;; visible children, then we don't want this article.
16409b0b
GM
8842 (and (or (eq gnus-fetch-old-headers 'some)
8843 (numberp gnus-fetch-old-headers))
eec82323
LMI
8844 (gnus-summary-article-ancient-p number)
8845 (zerop children))
6748645f
LMI
8846 ;; If this is "fetch-old-headered" and `invisible', then
8847 ;; we don't want this article.
8848 (and (eq gnus-fetch-old-headers 'invisible)
8849 (gnus-summary-article-ancient-p number))
eec82323
LMI
8850 ;; If this is a sparsely inserted article with no children,
8851 ;; we don't want it.
8852 (and (eq gnus-build-sparse-threads 'some)
8853 (gnus-summary-article-sparse-p number)
8854 (zerop children))
8855 ;; If we use expunging, and this article is really
8856 ;; low-scored, then we don't want this article.
8857 (when (and gnus-summary-expunge-below
8858 (< (setq score
8859 (or (cdr (assq number gnus-newsgroup-scored))
8860 gnus-summary-default-score))
8861 gnus-summary-expunge-below))
8862 ;; We increase the expunge-tally here, but that has
8863 ;; nothing to do with the limits, really.
8864 (incf gnus-newsgroup-expunged-tally)
8865 ;; We also mark as read here, if that's wanted.
8866 (when (and gnus-summary-mark-below
8867 (< score gnus-summary-mark-below))
8868 (setq gnus-newsgroup-unreads
8869 (delq number gnus-newsgroup-unreads))
8870 (if gnus-newsgroup-auto-expire
8871 (push number gnus-newsgroup-expirable)
8872 (push (cons number gnus-low-score-mark)
8873 gnus-newsgroup-reads)))
8874 t)
23f87bed
MB
8875 ;; Do the `display' group parameter.
8876 (and gnus-newsgroup-display
3d319c8f
LMI
8877 (let ((gnus-number number))
8878 (not (funcall gnus-newsgroup-display))))))
eec82323
LMI
8879 ;; Nope, invisible article.
8880 0
8881 ;; Ok, this article is to be visible, so we add it to the limit
8882 ;; and return 1.
8883 (push number gnus-newsgroup-limit)
8884 1))))
8885
8886(defun gnus-expunge-thread (thread)
8887 "Mark all articles in THREAD as read."
8888 (let* ((number (mail-header-number (car thread))))
8889 (incf gnus-newsgroup-expunged-tally)
8890 ;; We also mark as read here, if that's wanted.
8891 (setq gnus-newsgroup-unreads
8892 (delq number gnus-newsgroup-unreads))
8893 (if gnus-newsgroup-auto-expire
8894 (push number gnus-newsgroup-expirable)
8895 (push (cons number gnus-low-score-mark)
8896 gnus-newsgroup-reads)))
8897 ;; Go recursively through all subthreads.
8898 (mapcar 'gnus-expunge-thread (cdr thread)))
8899
8900;; Summary article oriented commands
8901
8902(defun gnus-summary-refer-parent-article (n)
8903 "Refer parent article N times.
8904If N is negative, go to ancestor -N instead.
8905The difference between N and the number of articles fetched is returned."
8906 (interactive "p")
eec82323
LMI
8907 (let ((skip 1)
8908 error header ref)
8909 (when (not (natnump n))
8910 (setq skip (abs n)
8911 n 1))
8912 (while (and (> n 0)
8913 (not error))
8914 (setq header (gnus-summary-article-header))
8915 (if (and (eq (mail-header-number header)
8916 (cdr gnus-article-current))
8917 (equal gnus-newsgroup-name
8918 (car gnus-article-current)))
8919 ;; If we try to find the parent of the currently
8920 ;; displayed article, then we take a look at the actual
8921 ;; References header, since this is slightly more
8922 ;; reliable than the References field we got from the
8923 ;; server.
c7a91ce1 8924 (with-current-buffer gnus-original-article-buffer
eec82323
LMI
8925 (nnheader-narrow-to-headers)
8926 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8927 (when (setq ref (message-fetch-field "in-reply-to"))
8928 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8929 (widen))
8930 (setq ref
8931 ;; It's not the current article, so we take a bet on
8932 ;; the value we got from the server.
8933 (mail-header-references header)))
8934 (if (and ref
8935 (not (equal ref "")))
8936 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8937 (gnus-message 1 "Couldn't find parent"))
8938 (gnus-message 1 "No references in article %d"
8939 (gnus-summary-article-number))
8940 (setq error t))
8941 (decf n))
8942 (gnus-summary-position-point)
8943 n))
8944
8945(defun gnus-summary-refer-references ()
8946 "Fetch all articles mentioned in the References header.
6748645f 8947Return the number of articles fetched."
eec82323 8948 (interactive)
eec82323
LMI
8949 (let ((ref (mail-header-references (gnus-summary-article-header)))
8950 (current (gnus-summary-article-number))
8951 (n 0))
8952 (if (or (not ref)
8953 (equal ref ""))
8954 (error "No References in the current article")
8955 ;; For each Message-ID in the References header...
8956 (while (string-match "<[^>]*>" ref)
8957 (incf n)
8958 ;; ... fetch that article.
8959 (gnus-summary-refer-article
8960 (prog1 (match-string 0 ref)
8961 (setq ref (substring ref (match-end 0))))))
8962 (gnus-summary-goto-subject current)
8963 (gnus-summary-position-point)
8964 n)))
8965
ae97e645
G
8966(defun gnus-delete-duplicate-headers (headers)
8967 ;; First remove leading duplicates.
8968 (while (and (> (length headers) 1)
8969 (= (mail-header-number (car headers))
8970 (mail-header-number (cadr headers))))
8971 (pop headers))
8972 ;; Then the rest.
8973 (let ((result headers))
8974 (while (> (length headers) 1)
8975 (if (= (mail-header-number (car headers))
8976 (mail-header-number (cadr headers)))
8977 (setcdr headers (cddr headers))
8978 (pop headers)))
8979 result))
8980
6748645f 8981(defun gnus-summary-refer-thread (&optional limit)
47f0b35e
AC
8982 "Fetch all articles in the current thread. For backends that
8983know how to search for threads (currently only 'nnimap) a
8984non-numeric prefix arg will use nnir to search the entire
8985server; without a prefix arg only the current group is
8986searched. If the variable `gnus-refer-thread-use-nnir' is
8987non-nil the prefix arg has the reverse meaning. If no
8988backend-specific 'request-thread function is available fetch
8989LIMIT (the numerical prefix) old headers. If LIMIT is
8990non-numeric or nil fetch the number specified by the
8991`gnus-refer-thread-limit' variable."
6748645f 8992 (interactive "P")
4ddab346 8993 (gnus-warp-to-article)
70041e9a
G
8994 (let* ((header (gnus-summary-article-header))
8995 (id (mail-header-id header))
8996 (gnus-inhibit-demon t)
8997 (gnus-summary-ignore-duplicates t)
8998 (gnus-read-all-available-headers t)
47f0b35e
AC
8999 (gnus-refer-thread-use-nnir
9000 (if (and (not (null limit)) (listp limit))
9001 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
ae97e645
G
9002 (new-headers
9003 (if (gnus-check-backend-function
9004 'request-thread gnus-newsgroup-name)
9005 (gnus-request-thread header gnus-newsgroup-name)
47f0b35e
AC
9006 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9007 gnus-refer-thread-limit))
9008 (last (if (numberp limit)
ae97e645
G
9009 (min (+ (mail-header-number header)
9010 limit)
9011 gnus-newsgroup-highest)
9012 gnus-newsgroup-highest))
9013 (subject (gnus-simplify-subject
9014 (mail-header-subject header)))
9015 (refs (split-string (or (mail-header-references header)
9016 "")))
9017 (gnus-parse-headers-hook
93855df9 9018 `(lambda () (goto-char (point-min))
ae97e645 9019 (keep-lines
93855df9 9020 (regexp-opt ',(append refs (list id subject)))))))
ae97e645
G
9021 (gnus-fetch-headers (list last) (if (numberp limit)
9022 (* 2 limit) limit) t)))))
47f0b35e
AC
9023 (when (listp new-headers)
9024 (dolist (header new-headers)
9025 (when (member (mail-header-number header) gnus-newsgroup-unselected)
9026 (push (mail-header-number header) gnus-newsgroup-unreads)
9027 (setq gnus-newsgroup-unselected
9028 (delete (mail-header-number header)
9029 gnus-newsgroup-unselected))))
9030 (setq gnus-newsgroup-headers
9031 (gnus-delete-duplicate-headers
9032 (gnus-merge
9033 'list gnus-newsgroup-headers new-headers
9034 'gnus-article-sort-by-number)))
9035 (gnus-summary-limit-include-thread id))))
6748645f 9036
16409b0b
GM
9037(defun gnus-summary-refer-article (message-id)
9038 "Fetch an article specified by MESSAGE-ID."
9039 (interactive "sMessage-ID: ")
d747b53f 9040 (gnus-warp-to-article)
eec82323
LMI
9041 (when (and (stringp message-id)
9042 (not (zerop (length message-id))))
23f87bed 9043 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
9044 ;; Construct the correct Message-ID if necessary.
9045 ;; Suggested by tale@pawl.rpi.edu.
9046 (unless (string-match "^<" message-id)
9047 (setq message-id (concat "<" message-id)))
9048 (unless (string-match ">$" message-id)
9049 (setq message-id (concat message-id ">")))
23f87bed
MB
9050 ;; People often post MIDs from URLs, so unhex it:
9051 (unless (string-match "@" message-id)
9052 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
9053 (let* ((header (gnus-id-to-header message-id))
9054 (sparse (and header
9055 (gnus-summary-article-sparse-p
a8151ef7
LMI
9056 (mail-header-number header))
9057 (memq (mail-header-number header)
16409b0b
GM
9058 gnus-newsgroup-limit)))
9059 number)
6748645f
LMI
9060 (cond
9061 ;; If the article is present in the buffer we just go to it.
9062 ((and header
9063 (or (not (gnus-summary-article-sparse-p
9064 (mail-header-number header)))
9065 sparse))
9066 (prog1
9067 (gnus-summary-goto-article
9068 (mail-header-number header) nil t)
9069 (when sparse
9070 (gnus-summary-update-article (mail-header-number header)))))
9071 (t
16409b0b
GM
9072 ;; We fetch the article.
9073 (catch 'found
9074 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
9075 (when (and (gnus-check-server gnus-override-method)
9076 ;; Fetch the header,
9077 (setq number (gnus-summary-insert-subject message-id)))
9078 ;; and display the article.
eec82323 9079 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
9080 (throw 'found t)))
9081 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9082
9083(defun gnus-refer-article-methods ()
8f688cb0 9084 "Return a list of referable methods."
16409b0b
GM
9085 (cond
9086 ;; No method, so we default to current and native.
9087 ((null gnus-refer-article-method)
9088 (list gnus-current-select-method gnus-select-method))
9089 ;; Current.
9090 ((eq 'current gnus-refer-article-method)
9091 (list gnus-current-select-method))
9092 ;; List of select methods.
d4dfaa19
DL
9093 ((not (and (symbolp (car gnus-refer-article-method))
9094 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
9095 (let (out)
9096 (dolist (method gnus-refer-article-method)
9097 (push (if (eq 'current method)
9098 gnus-current-select-method
b09c3fe0
G
9099 (if (eq 'nnir (car method))
9100 (list
9101 'nnir
9102 (or (cadr method)
9103 (gnus-method-to-server gnus-current-select-method)))
9104 method))
16409b0b
GM
9105 out))
9106 (nreverse out)))
9107 ;; One single select method.
9108 (t
9109 (list gnus-refer-article-method))))
6748645f
LMI
9110
9111(defun gnus-summary-edit-parameters ()
9112 "Edit the group parameters of the current group."
9113 (interactive)
9114 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 9115
16409b0b
GM
9116(defun gnus-summary-customize-parameters ()
9117 "Customize the group parameters of the current group."
9118 (interactive)
9119 (gnus-group-customize gnus-newsgroup-name))
9120
eec82323
LMI
9121(defun gnus-summary-enter-digest-group (&optional force)
9122 "Enter an nndoc group based on the current article.
07176b2a
LMI
9123If FORCE, force a digest interpretation. If not, try to guess
9124what the document format is.
9125
9126To control what happens when you exit the group, see the
9127`gnus-auto-select-on-ephemeral-exit' variable."
eec82323 9128 (interactive "P")
eec82323 9129 (let ((conf gnus-current-window-configuration))
23f87bed
MB
9130 (save-window-excursion
9131 (save-excursion
9132 (let (gnus-article-prepare-hook
9133 gnus-display-mime-function
9134 gnus-break-pages)
9135 (gnus-summary-select-article))))
eec82323
LMI
9136 (setq gnus-current-window-configuration conf)
9137 (let* ((name (format "%s-%d"
9138 (gnus-group-prefixed-name
9139 gnus-newsgroup-name (list 'nndoc ""))
01c52d31 9140 (with-current-buffer gnus-summary-buffer
eec82323
LMI
9141 gnus-current-article)))
9142 (ogroup gnus-newsgroup-name)
9143 (params (append (gnus-info-params (gnus-get-info ogroup))
9144 (list (cons 'to-group ogroup))
23f87bed 9145 (list (cons 'parent-group ogroup))
eec82323
LMI
9146 (list (cons 'save-article-group ogroup))))
9147 (case-fold-search t)
9148 (buf (current-buffer))
16409b0b 9149 dig to-address)
c7a91ce1 9150 (with-current-buffer gnus-original-article-buffer
16409b0b
GM
9151 ;; Have the digest group inherit the main mail address of
9152 ;; the parent article.
23f87bed
MB
9153 (when (setq to-address (or (gnus-fetch-field "reply-to")
9154 (gnus-fetch-field "from")))
343d6628
MB
9155 (setq params
9156 (append
9157 (list (cons 'to-address
9158 (funcall gnus-decode-encoded-address-function
9159 to-address))))))
eec82323
LMI
9160 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9161 (insert-buffer-substring gnus-original-article-buffer)
9162 ;; Remove lines that may lead nndoc to misinterpret the
9163 ;; document type.
9164 (narrow-to-region
9165 (goto-char (point-min))
9166 (or (search-forward "\n\n" nil t) (point)))
9167 (goto-char (point-min))
16409b0b 9168 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
9169 (widen))
9170 (unwind-protect
23f87bed 9171 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
9172 (gnus-newsgroup-ephemeral-ignored-charsets
9173 gnus-newsgroup-ignored-charsets))
9174 (gnus-group-read-ephemeral-group
9175 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9176 (nndoc-article-type
23f87bed
MB
9177 ,(if force 'mbox 'guess)))
9178 t nil nil nil
9179 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9180 "ADAPT")))))
16409b0b 9181 ;; Make all postings to this group go to the parent group.
23f87bed
MB
9182 (nconc (gnus-info-params (gnus-get-info name))
9183 params)
9184 ;; Couldn't select this doc group.
9185 (switch-to-buffer buf)
9186 (gnus-set-global-variables)
9187 (gnus-configure-windows 'summary)
9188 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
9189 (kill-buffer dig)))))
9190
9191(defun gnus-summary-read-document (n)
9192 "Open a new group based on the current article(s).
9193This will allow you to read digests and other similar
9194documents as newsgroups.
9195Obeys the standard process/prefix convention."
9196 (interactive "P")
01c52d31 9197 (let* ((ogroup gnus-newsgroup-name)
eec82323
LMI
9198 (params (append (gnus-info-params (gnus-get-info ogroup))
9199 (list (cons 'to-group ogroup))))
01c52d31
MB
9200 group egroup groups vgroup)
9201 (dolist (article (gnus-summary-work-articles n))
eec82323
LMI
9202 (setq group (format "%s-%d" gnus-newsgroup-name article))
9203 (gnus-summary-remove-process-mark article)
9204 (when (gnus-summary-display-article article)
398a825b 9205 (save-excursion ;;What for?
16409b0b 9206 (with-temp-buffer
eec82323
LMI
9207 (insert-buffer-substring gnus-original-article-buffer)
9208 ;; Remove some headers that may lead nndoc to make
9209 ;; the wrong guess.
9210 (message-narrow-to-head)
9211 (goto-char (point-min))
01c52d31 9212 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
9213 (widen)
9214 (if (setq egroup
9215 (gnus-group-read-ephemeral-group
9216 group `(nndoc ,group (nndoc-address ,(current-buffer))
9217 (nndoc-article-type guess))
9218 t nil t))
9219 (progn
c7a91ce1 9220 ;; Make all postings to this group go to the parent group.
eec82323
LMI
9221 (nconc (gnus-info-params (gnus-get-info egroup))
9222 params)
9223 (push egroup groups))
9224 ;; Couldn't select this doc group.
9225 (gnus-error 3 "Article couldn't be entered"))))))
9226 ;; Now we have selected all the documents.
9227 (cond
9228 ((not groups)
9229 (error "None of the articles could be interpreted as documents"))
9230 ((gnus-group-read-ephemeral-group
9231 (setq vgroup (format
9232 "nnvirtual:%s-%s" gnus-newsgroup-name
9233 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9234 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9235 t
9236 (cons (current-buffer) 'summary)))
9237 (t
9238 (error "Couldn't select virtual nndoc group")))))
9239
d50717f0
JD
9240(defun gnus-summary-widget-forward (arg)
9241 "Move point to the next field or button in the article.
9242With optional ARG, move across that many fields."
9243 (interactive "p")
9244 (gnus-summary-select-article)
9245 (gnus-configure-windows 'article)
9246 (select-window (gnus-get-buffer-window gnus-article-buffer))
9247 (widget-forward arg))
9248
eec82323
LMI
9249(defun gnus-summary-isearch-article (&optional regexp-p)
9250 "Do incremental search forward on the current article.
9251If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9252 (interactive "P")
eec82323
LMI
9253 (gnus-summary-select-article)
9254 (gnus-configure-windows 'article)
9255 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
9256 (save-restriction
9257 (widen)
9258 (isearch-forward regexp-p))))
eec82323 9259
01c52d31
MB
9260(defun gnus-summary-repeat-search-article-forward ()
9261 "Repeat the previous search forwards."
9262 (interactive)
9263 (unless gnus-last-search-regexp
9264 (error "No previous search"))
9265 (gnus-summary-search-article-forward gnus-last-search-regexp))
9266
9267(defun gnus-summary-repeat-search-article-backward ()
9268 "Repeat the previous search backwards."
9269 (interactive)
9270 (unless gnus-last-search-regexp
9271 (error "No previous search"))
9272 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9273
eec82323
LMI
9274(defun gnus-summary-search-article-forward (regexp &optional backward)
9275 "Search for an article containing REGEXP forward.
9276If BACKWARD, search backward instead."
9277 (interactive
9278 (list (read-string
9279 (format "Search article %s (regexp%s): "
9280 (if current-prefix-arg "backward" "forward")
9281 (if gnus-last-search-regexp
9282 (concat ", default " gnus-last-search-regexp)
9283 "")))
9284 current-prefix-arg))
eec82323
LMI
9285 (if (string-equal regexp "")
9286 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
9287 (setq gnus-last-search-regexp regexp)
9288 (setq gnus-article-before-search gnus-current-article))
9289 ;; Intentionally set gnus-last-article.
9290 (setq gnus-last-article gnus-article-before-search)
9291 (let ((gnus-last-article gnus-last-article))
9292 (if (gnus-summary-search-article regexp backward)
9293 (gnus-summary-show-thread)
abc40aab 9294 (signal 'search-failed (list regexp)))))
eec82323
LMI
9295
9296(defun gnus-summary-search-article-backward (regexp)
9297 "Search for an article containing REGEXP backward."
9298 (interactive
9299 (list (read-string
9300 (format "Search article backward (regexp%s): "
9301 (if gnus-last-search-regexp
9302 (concat ", default " gnus-last-search-regexp)
9303 "")))))
9304 (gnus-summary-search-article-forward regexp 'backward))
9305
9306(defun gnus-summary-search-article (regexp &optional backward)
9307 "Search for an article containing REGEXP.
9308Optional argument BACKWARD means do search for backward.
9309`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
9310 ;; We have to require this here to make sure that the following
9311 ;; dynamic binding isn't shadowed by autoloading.
9312 (require 'gnus-async)
16409b0b 9313 (require 'gnus-art)
eec82323 9314 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 9315 (gnus-article-prepare-hook nil)
eec82323
LMI
9316 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9317 (gnus-use-article-prefetch nil)
9318 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 9319 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
9320 (gnus-visual nil)
9321 (gnus-keep-backlog nil)
9322 (gnus-break-pages nil)
9323 (gnus-summary-display-arrow nil)
9324 (gnus-updated-mode-lines nil)
9325 (gnus-auto-center-summary nil)
eec82323 9326 (sum (current-buffer))
16409b0b 9327 (gnus-display-mime-function nil)
eec82323
LMI
9328 (found nil)
9329 point)
9330 (gnus-save-hidden-threads
9331 (gnus-summary-select-article)
9332 (set-buffer gnus-article-buffer)
16409b0b 9333 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
9334 (when backward
9335 (forward-line -1))
9336 (while (not found)
9337 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9338 (if (if backward
9339 (re-search-backward regexp nil t)
9340 (re-search-forward regexp nil t))
9341 ;; We found the regexp.
9342 (progn
9343 (setq found 'found)
9344 (beginning-of-line)
9345 (set-window-start
9346 (get-buffer-window (current-buffer))
9347 (point))
9348 (forward-line 1)
16409b0b
GM
9349 (set-window-point
9350 (get-buffer-window (current-buffer))
9351 (point))
eec82323
LMI
9352 (set-buffer sum)
9353 (setq point (point)))
9354 ;; We didn't find it, so we go to the next article.
9355 (set-buffer sum)
9356 (setq found 'not)
9357 (while (eq found 'not)
9358 (if (not (if backward (gnus-summary-find-prev)
9359 (gnus-summary-find-next)))
9360 ;; No more articles.
9361 (setq found t)
9362 ;; Select the next article and adjust point.
9363 (unless (gnus-summary-article-sparse-p
9364 (gnus-summary-article-number))
9365 (setq found nil)
9366 (gnus-summary-select-article)
9367 (set-buffer gnus-article-buffer)
9368 (widen)
9369 (goto-char (if backward (point-max) (point-min))))))))
9370 (gnus-message 7 ""))
9371 ;; Return whether we found the regexp.
9372 (when (eq found 'found)
9373 (goto-char point)
9374 (gnus-summary-show-thread)
9375 (gnus-summary-goto-subject gnus-current-article)
9376 (gnus-summary-position-point)
9377 t)))
9378
23f87bed
MB
9379(defun gnus-find-matching-articles (header regexp)
9380 "Return a list of all articles that match REGEXP on HEADER.
9381This search includes all articles in the current group that Gnus has
9382fetched headers for, whether they are displayed or not."
9383 (let ((articles nil)
c7a91ce1 9384 ;; Can't eta-reduce because it's a macro.
23f87bed
MB
9385 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9386 (case-fold-search t))
9387 (dolist (header gnus-newsgroup-headers)
9388 (when (string-match regexp (funcall func header))
9389 (push (mail-header-number header) articles)))
9390 (nreverse articles)))
9391
eec82323 9392(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 9393 not-case-fold not-matching)
eec82323
LMI
9394 "Return a list of all articles that match REGEXP on HEADER.
9395The search stars on the current article and goes forwards unless
9396BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9397If UNREAD is non-nil, only unread articles will
9398be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 9399in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
9400not match REGEXP on HEADER."
9401 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
9402 articles d func)
9403 (if (consp header)
9404 (if (eq (car header) 'extra)
9405 (setq func
9406 `(lambda (h)
9407 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9408 "")))
9409 (error "%s is an invalid header" header))
9410 (unless (fboundp (intern (concat "mail-header-" header)))
9411 (error "%s is not a valid header" header))
9412 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
9413 (dolist (d (if (eq backward 'all)
9414 gnus-newsgroup-data
9415 (gnus-data-find-list
9416 (gnus-summary-article-number)
9417 (gnus-data-list backward))))
9418 (when (and (or (not unread) ; We want all articles...
9419 (gnus-data-unread-p d)) ; Or just unreads.
9420 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9421 (if not-matching
a1506d29 9422 (not (string-match
47b63dfa
SZ
9423 regexp
9424 (funcall func (gnus-data-header d))))
9425 (string-match regexp
9426 (funcall func (gnus-data-header d)))))
9427 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
9428 (nreverse articles)))
9429
9430(defun gnus-summary-execute-command (header regexp command &optional backward)
9431 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9432If HEADER is an empty string (or nil), the match is done on the entire
9433article. If BACKWARD (the prefix) is non-nil, search backward instead."
9434 (interactive
9435 (list (let ((completion-ignore-case t))
229b59da
G
9436 (gnus-completing-read
9437 "Header name"
9438 (mapcar 'symbol-name
23f87bed 9439 (append
229b59da
G
9440 '(Number Subject From Lines Date
9441 Message-ID Xref References Body)
23f87bed 9442 gnus-extra-headers))
229b59da 9443 'require-match))
eec82323
LMI
9444 (read-string "Regexp: ")
9445 (read-key-sequence "Command: ")
9446 current-prefix-arg))
9447 (when (equal header "Body")
9448 (setq header ""))
eec82323
LMI
9449 ;; Hidden thread subtrees must be searched as well.
9450 (gnus-summary-show-all-threads)
9451 ;; We don't want to change current point nor window configuration.
9452 (save-excursion
9453 (save-window-excursion
23f87bed
MB
9454 (let (gnus-visual
9455 gnus-treat-strip-trailing-blank-lines
9456 gnus-treat-strip-leading-blank-lines
9457 gnus-treat-strip-multiple-blank-lines
9458 gnus-treat-hide-boring-headers
9459 gnus-treat-fold-newsgroups
9460 gnus-article-prepare-hook)
9461 (gnus-message 6 "Executing %s..." (key-description command))
9462 ;; We'd like to execute COMMAND interactively so as to give arguments.
9463 (gnus-execute header regexp
9464 `(call-interactively ',(key-binding command))
9465 backward)
9466 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
9467
9468(defun gnus-summary-beginning-of-article ()
9469 "Scroll the article back to the beginning."
9470 (interactive)
eec82323
LMI
9471 (gnus-summary-select-article)
9472 (gnus-configure-windows 'article)
9473 (gnus-eval-in-buffer-window gnus-article-buffer
9474 (widen)
9475 (goto-char (point-min))
23f87bed 9476 (when gnus-break-pages
eec82323
LMI
9477 (gnus-narrow-to-page))))
9478
9479(defun gnus-summary-end-of-article ()
9480 "Scroll to the end of the article."
9481 (interactive)
eec82323
LMI
9482 (gnus-summary-select-article)
9483 (gnus-configure-windows 'article)
9484 (gnus-eval-in-buffer-window gnus-article-buffer
9485 (widen)
9486 (goto-char (point-max))
9487 (recenter -3)
23f87bed 9488 (when gnus-break-pages
eec82323
LMI
9489 (gnus-narrow-to-page))))
9490
23f87bed
MB
9491(defun gnus-summary-print-truncate-and-quote (string &optional len)
9492 "Truncate to LEN and quote all \"(\"'s in STRING."
9493 (gnus-replace-in-string (if (and len (> (length string) len))
9494 (substring string 0 len)
9495 string)
9496 "[()]" "\\\\\\&"))
9497
6748645f 9498(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
9499 "Generate and print a PostScript image of the process-marked (mail) articles.
9500
9501If used interactively, print the current article if none are
9502process-marked. With prefix arg, prompt the user for the name of the
9503file to save in.
6748645f 9504
23f87bed
MB
9505When used from Lisp, accept two optional args FILENAME and N. N means
9506to print the next N articles. If N is negative, print the N previous
9507articles. If N is nil and articles have been marked with the process
9508mark, print these instead.
eec82323 9509
16409b0b 9510If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
9511printer. If FILENAME is a string, save the PostScript image in a file with
9512that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 9513to save in."
676a7cc9 9514 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
9515 (dolist (article (gnus-summary-work-articles n))
9516 (gnus-summary-select-article nil nil 'pseudo article)
9517 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 9518 (gnus-print-buffer))
676a7cc9
SZ
9519 (gnus-summary-remove-process-mark article))
9520 (ps-despool filename))
eec82323 9521
23f87bed 9522(defun gnus-print-buffer ()
285cf7c8
LMI
9523 (let ((ps-left-header
9524 (list
9525 (concat "("
9526 (gnus-summary-print-truncate-and-quote
9527 (mail-header-subject gnus-current-headers)
9528 66) ")")
9529 (concat "("
9530 (gnus-summary-print-truncate-and-quote
9531 (mail-header-from gnus-current-headers)
9532 45) ")")))
9533 (ps-right-header
9534 (list
9535 "/pagenumberstring load"
9536 (concat "("
9537 (mail-header-date gnus-current-headers) ")"))))
9538 (gnus-run-hooks 'gnus-ps-print-hook)
9539 (save-excursion
9540 (if ps-print-color-p
9541 (ps-spool-buffer-with-faces)
9542 (ps-spool-buffer)))))
23f87bed 9543
8ccbef23
G
9544(defun gnus-summary-show-complete-article ()
9545 "Show a complete version of the current article.
9546This is only useful if you're looking at a partial version of the
9547article currently."
9548 (interactive)
9549 (let ((gnus-keep-backlog nil)
9550 (gnus-use-cache nil)
9551 (gnus-agent nil)
9f2d52e7
G
9552 (variable (intern
9553 (format "%s-fetch-partial-articles"
9554 (car (gnus-find-method-for-group
9555 gnus-newsgroup-name)))
9556 obarray))
9557 old-val)
9558 (unwind-protect
9559 (progn
9560 (setq old-val (symbol-value variable))
9561 (set variable nil)
9562 (gnus-flush-original-article-buffer)
9563 (gnus-summary-show-article))
9564 (set variable old-val))))
8ccbef23 9565
eec82323 9566(defun gnus-summary-show-article (&optional arg)
23f87bed 9567 "Force redisplaying of the current article.
16409b0b
GM
9568If ARG (the prefix) is a number, show the article with the charset
9569defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 9570input.
389b76fa
G
9571If ARG (the prefix) is non-nil and not a number, show the article,
9572but without running any of the article treatment functions
9573article. Normally, the keystroke is `C-u g'. When using `C-u
9574C-u g', show the raw article."
eec82323 9575 (interactive "P")
16409b0b
GM
9576 (cond
9577 ((numberp arg)
23f87bed 9578 (gnus-summary-show-article t)
16409b0b
GM
9579 (let ((gnus-newsgroup-charset
9580 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
9581 (mm-read-coding-system
9582 "View as charset: " ;; actually it is coding system.
01c52d31 9583 (with-current-buffer gnus-article-buffer
23f87bed 9584 (mm-detect-coding-region (point) (point-max))))))
16409b0b 9585 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
9586 (gnus-summary-select-article nil 'force)
9587 (let ((deps gnus-newsgroup-dependencies)
9588 head header lines)
c7a91ce1 9589 (with-current-buffer gnus-original-article-buffer
23f87bed
MB
9590 (save-restriction
9591 (message-narrow-to-head)
9592 (setq head (buffer-string))
9593 (goto-char (point-min))
9594 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9595 (goto-char (point-max))
9596 (widen)
9597 (setq lines (1- (count-lines (point) (point-max))))))
9598 (with-temp-buffer
9599 (insert (format "211 %d Article retrieved.\n"
9600 (cdr gnus-article-current)))
9601 (insert head)
9602 (if lines (insert (format "Lines: %d\n" lines)))
9603 (insert ".\n")
9604 (let ((nntp-server-buffer (current-buffer)))
9605 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9606 (gnus-data-set-header
9607 (gnus-data-find (cdr gnus-article-current))
9608 header)
9609 (gnus-summary-update-article-line
9610 (cdr gnus-article-current) header)
9611 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9612 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
9613 ((not arg)
9614 ;; Select the article the normal way.
9615 (gnus-summary-select-article nil 'force))
8e22bee0 9616 ((equal arg '(16))
389b76fa 9617 ;; C-u C-u g
04db63bc
G
9618 (let ((gnus-inhibit-article-treatments t))
9619 (gnus-summary-select-article nil 'force)))
9620 (t
16409b0b
GM
9621 ;; We have to require this here to make sure that the following
9622 ;; dynamic binding isn't shadowed by autoloading.
9623 (require 'gnus-async)
9624 (require 'gnus-art)
eec82323
LMI
9625 ;; Bind the article treatment functions to nil.
9626 (let ((gnus-have-all-headers t)
eec82323 9627 gnus-article-prepare-hook
16409b0b
GM
9628 gnus-article-decode-hook
9629 gnus-display-mime-function
9630 gnus-break-pages)
9631 ;; Destroy any MIME parts.
9632 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 9633 (with-current-buffer gnus-article-buffer
c146ad85 9634 (gnus-article-stop-animations)
16409b0b
GM
9635 (mm-destroy-parts gnus-article-mime-handles)
9636 ;; Set it to nil for safety reason.
9637 (setq gnus-article-mime-handle-alist nil)
9638 (setq gnus-article-mime-handles nil)))
9639 (gnus-summary-select-article nil 'force))))
eec82323
LMI
9640 (gnus-summary-goto-subject gnus-current-article)
9641 (gnus-summary-position-point))
9642
23f87bed
MB
9643(defun gnus-summary-show-raw-article ()
9644 "Show the raw article without any article massaging functions being run."
9645 (interactive)
9646 (gnus-summary-show-article t))
9647
eec82323
LMI
9648(defun gnus-summary-verbose-headers (&optional arg)
9649 "Toggle permanent full header display.
9650If ARG is a positive number, turn header display on.
9651If ARG is a negative number, turn header display off."
9652 (interactive "P")
eec82323
LMI
9653 (setq gnus-show-all-headers
9654 (cond ((or (not (numberp arg))
9655 (zerop arg))
9656 (not gnus-show-all-headers))
9657 ((natnump arg)
9658 t)))
9659 (gnus-summary-show-article))
9660
9661(defun gnus-summary-toggle-header (&optional arg)
9662 "Show the headers if they are hidden, or hide them if they are shown.
9663If ARG is a positive number, show the entire header.
9664If ARG is a negative number, hide the unwanted header lines."
9665 (interactive "P")
23f87bed
MB
9666 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9667 (get-buffer-window gnus-article-buffer t))))
9668 (with-current-buffer gnus-article-buffer
9669 (widen)
9670 (article-narrow-to-head)
c7a91ce1 9671 (let* ((inhibit-read-only t)
16409b0b 9672 (inhibit-point-motion-hooks t)
23f87bed
MB
9673 (hidden (if (numberp arg)
9674 (>= arg 0)
f0096211
MB
9675 (or (not (looking-at "[^ \t\n]+:"))
9676 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
9677 s e)
9678 (delete-region (point-min) (point-max))
667e0ba6
SM
9679 (with-current-buffer gnus-original-article-buffer
9680 (goto-char (setq s (point-min)))
23f87bed
MB
9681 (setq e (if (search-forward "\n\n" nil t)
9682 (1- (point))
9683 (point-max))))
667e0ba6 9684 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
9685 (run-hooks 'gnus-article-decode-hook)
9686 (if hidden
9687 (let ((gnus-treat-hide-headers nil)
9688 (gnus-treat-hide-boring-headers nil))
9689 (gnus-delete-wash-type 'headers)
9690 (gnus-treat-article 'head))
9691 (gnus-treat-article 'head))
9692 (widen)
9693 (if window
9694 (set-window-start window (goto-char (point-min))))
9695 (if gnus-break-pages
9696 (gnus-narrow-to-page)
9697 (when (gnus-visual-p 'page-marker)
c7a91ce1 9698 (let ((inhibit-read-only t))
23f87bed
MB
9699 (gnus-remove-text-with-property 'gnus-prev)
9700 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9701 (gnus-set-mode-line 'article)))))
eec82323
LMI
9702
9703(defun gnus-summary-show-all-headers ()
9704 "Make all header lines visible."
9705 (interactive)
23f87bed 9706 (gnus-summary-toggle-header 1))
eec82323 9707
eec82323
LMI
9708(defun gnus-summary-caesar-message (&optional arg)
9709 "Caesar rotate the current article by 13.
01c52d31
MB
9710With a non-numerical prefix, also rotate headers. A numerical
9711prefix specifies how many places to rotate each letter forward."
eec82323 9712 (interactive "P")
eec82323
LMI
9713 (gnus-summary-select-article)
9714 (let ((mail-header-separator ""))
9715 (gnus-eval-in-buffer-window gnus-article-buffer
9716 (save-restriction
9717 (widen)
9718 (let ((start (window-start))
c7a91ce1 9719 (inhibit-read-only t))
01c52d31
MB
9720 (if (equal arg '(4))
9721 (message-caesar-buffer-body nil t)
9722 (message-caesar-buffer-body arg))
ff4d3926
MB
9723 (set-window-start (get-buffer-window (current-buffer)) start)))))
9724 ;; Create buttons and stuff...
9725 (gnus-treat-article nil))
eec82323 9726
704f1663
GM
9727(declare-function idna-to-unicode "ext:idna" (str))
9728
01c52d31
MB
9729(defun gnus-summary-idna-message (&optional arg)
9730 "Decode IDNA encoded domain names in the current articles.
9731IDNA encoded domain names looks like `xn--bar'. If a string
9732remain unencoded after running this function, it is likely an
9733invalid IDNA string (`xn--bar' is invalid).
9734
0b10e437 9735You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
01c52d31
MB
9736installed for this command to work."
9737 (interactive "P")
9738 (if (not (and (condition-case nil (require 'idna)
9739 (file-error))
9740 (mm-coding-system-p 'utf-8)
9741 (executable-find (symbol-value 'idna-program))))
9742 (gnus-message
9743 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9744 (gnus-summary-select-article)
9745 (let ((mail-header-separator ""))
9746 (gnus-eval-in-buffer-window gnus-article-buffer
9747 (save-restriction
9748 (widen)
9749 (let ((start (window-start))
9750 buffer-read-only)
9751 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9752 (replace-match (idna-to-unicode (match-string 1))))
9753 (set-window-start (get-buffer-window (current-buffer)) start)))))))
23f87bed
MB
9754
9755(defun gnus-summary-morse-message (&optional arg)
9756 "Morse decode the current article."
9757 (interactive "P")
9758 (gnus-summary-select-article)
9759 (let ((mail-header-separator ""))
9760 (gnus-eval-in-buffer-window gnus-article-buffer
9761 (save-excursion
9762 (save-restriction
9763 (widen)
9764 (let ((pos (window-start))
c7a91ce1 9765 (inhibit-read-only t))
23f87bed
MB
9766 (goto-char (point-min))
9767 (when (message-goto-body)
9768 (gnus-narrow-to-body))
9769 (goto-char (point-min))
01c52d31 9770