(vac-dec-vms): Remove, not supported anymore.
[bpt/emacs.git] / lisp / gnus / gnus-sum.el
CommitLineData
eec82323 1;;; gnus-sum.el --- summary mode commands for Gnus
e84b4b86
TTN
2
3;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
ae940284 4;; 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
eec82323 5
6748645f 6;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
eec82323
LMI
7;; Keywords: news
8
9;; This file is part of GNU Emacs.
10
5e809f55 11;; GNU Emacs is free software: you can redistribute it and/or modify
eec82323 12;; it under the terms of the GNU General Public License as published by
5e809f55
GM
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
eec82323
LMI
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
01ccbb85 18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
eec82323
LMI
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
5e809f55 22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
eec82323
LMI
23
24;;; Commentary:
25
26;;; Code:
27
d09ae6ca
GM
28;; For Emacs < 22.2.
29(eval-and-compile
30 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
23f87bed 31(eval-when-compile
9efa445f
DN
32 (require 'cl))
33
34(defvar tool-bar-mode)
35(defvar gnus-tmp-header)
5ab7173c 36
eec82323
LMI
37(require 'gnus)
38(require 'gnus-group)
39(require 'gnus-spec)
40(require 'gnus-range)
41(require 'gnus-int)
42(require 'gnus-undo)
6748645f 43(require 'gnus-util)
18c06a99 44(require 'gmm-utils)
16409b0b 45(require 'mm-decode)
08c9a385 46(require 'nnoo)
23f87bed 47
6748645f 48(autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
d4dfaa19 49(autoload 'gnus-cache-write-active "gnus-cache")
23f87bed
MB
50(autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
51(autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
531e5812 52(autoload 'gnus-pick-line-number "gnus-salt" nil t)
08c9a385 53(autoload 'mm-uu-dissect "mm-uu")
23f87bed
MB
54(autoload 'gnus-article-outlook-deuglify-article "deuglify"
55 "Deuglify broken Outlook (Express) articles and redisplay."
56 t)
57(autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
58(autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
59(autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
eec82323
LMI
60
61(defcustom gnus-kill-summary-on-exit t
62 "*If non-nil, kill the summary buffer when you exit from it.
63If nil, the summary will become a \"*Dead Summary*\" buffer, and
64it will be killed sometime later."
65 :group 'gnus-summary-exit
66 :type 'boolean)
67
01c52d31
MB
68(defcustom gnus-summary-next-group-on-exit t
69 "If non-nil, go to the next unread newsgroup on summary exit.
70See `gnus-group-goto-unread'."
71 :link '(custom-manual "(gnus)Group Maneuvering")
72 :group 'gnus-summary-exit
330f707b 73 :version "23.1" ;; No Gnus
01c52d31
MB
74 :type 'boolean)
75
eec82323
LMI
76(defcustom gnus-fetch-old-headers nil
77 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
01c52d31
MB
78If an unread article in the group refers to an older, already
79read (or just marked as read) article, the old article will not
80normally be displayed in the Summary buffer. If this variable is
81t, Gnus will attempt to grab the headers to the old articles, and
82thereby build complete threads. If it has the value `some', all
83old headers will be fetched but only enough headers to connect
84otherwise loose threads will be displayed. This variable can
85also be a number. In that case, no more than that number of old
86headers will be fetched. If it has the value `invisible', all
6748645f 87old headers will be fetched, but none will be displayed.
eec82323 88
01c52d31
MB
89The server has to support NOV for any of this to work.
90
91This feature can seriously impact performance it ignores all
f394fa25
MB
92locally cached header entries. Setting it to t for groups for a
93server that doesn't expire articles (such as news.gmane.org),
94leads to very slow summary generation."
eec82323
LMI
95 :group 'gnus-thread
96 :type '(choice (const :tag "off" nil)
1232b9cb 97 (const :tag "on" t)
eec82323 98 (const some)
1232b9cb 99 (const invisible)
eec82323
LMI
100 number
101 (sexp :menu-tag "other" t)))
102
01c52d31 103(defcustom gnus-refer-thread-limit 500
6748645f
LMI
104 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
105If t, fetch all the available old headers."
106 :group 'gnus-thread
107 :type '(choice number
108 (sexp :menu-tag "other" t)))
109
eec82323
LMI
110(defcustom gnus-summary-make-false-root 'adopt
111 "*nil means that Gnus won't gather loose threads.
112If the root of a thread has expired or been read in a previous
113session, the information necessary to build a complete thread has been
114lost. Instead of having many small sub-threads from this original thread
115scattered all over the summary buffer, Gnus can gather them.
116
117If non-nil, Gnus will try to gather all loose sub-threads from an
118original thread into one large thread.
119
120If this variable is non-nil, it should be one of `none', `adopt',
121`dummy' or `empty'.
122
123If this variable is `none', Gnus will not make a false root, but just
124present the sub-threads after another.
125If this variable is `dummy', Gnus will create a dummy root that will
126have all the sub-threads as children.
127If this variable is `adopt', Gnus will make one of the \"children\"
128the parent and mark all the step-children as such.
129If this variable is `empty', the \"children\" are printed with empty
01ccbb85 130subject fields. (Or rather, they will be printed with a string
eec82323
LMI
131given by the `gnus-summary-same-subject' variable.)"
132 :group 'gnus-thread
133 :type '(choice (const :tag "off" nil)
134 (const none)
135 (const dummy)
136 (const adopt)
137 (const empty)))
138
23f87bed
MB
139(defcustom gnus-summary-make-false-root-always nil
140 "Always make a false dummy root."
bf247b6e 141 :version "22.1"
23f87bed
MB
142 :group 'gnus-thread
143 :type 'boolean)
144
eec82323
LMI
145(defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
146 "*A regexp to match subjects to be excluded from loose thread gathering.
147As loose thread gathering is done on subjects only, that means that
148there can be many false gatherings performed. By rooting out certain
149common subjects, gathering might become saner."
150 :group 'gnus-thread
151 :type 'regexp)
152
153(defcustom gnus-summary-gather-subject-limit nil
154 "*Maximum length of subject comparisons when gathering loose threads.
155Use nil to compare full subjects. Setting this variable to a low
156number will help gather threads that have been corrupted by
157newsreaders chopping off subject lines, but it might also mean that
158unrelated articles that have subject that happen to begin with the
159same few characters will be incorrectly gathered.
160
161If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
162comparing subjects."
163 :group 'gnus-thread
164 :type '(choice (const :tag "off" nil)
165 (const fuzzy)
166 (sexp :menu-tag "on" t)))
167
6748645f
LMI
168(defcustom gnus-simplify-subject-functions nil
169 "List of functions taking a string argument that simplify subjects.
170The functions are applied recursively.
171
23f87bed
MB
172Useful functions to put in this list include:
173`gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
174`gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
6748645f
LMI
175 :group 'gnus-thread
176 :type '(repeat function))
177
eec82323 178(defcustom gnus-simplify-ignored-prefixes nil
23f87bed 179 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
eec82323
LMI
180 :group 'gnus-thread
181 :type '(choice (const :tag "off" nil)
182 regexp))
183
184(defcustom gnus-build-sparse-threads nil
185 "*If non-nil, fill in the gaps in threads.
186If `some', only fill in the gaps that are needed to tie loose threads
187together. If `more', fill in all leaf nodes that Gnus can find. If
188non-nil and non-`some', fill in all gaps that Gnus manages to guess."
189 :group 'gnus-thread
190 :type '(choice (const :tag "off" nil)
191 (const some)
192 (const more)
193 (sexp :menu-tag "all" t)))
194
195(defcustom gnus-summary-thread-gathering-function
196 'gnus-gather-threads-by-subject
6748645f 197 "*Function used for gathering loose threads.
eec82323
LMI
198There are two pre-defined functions: `gnus-gather-threads-by-subject',
199which only takes Subjects into consideration; and
200`gnus-gather-threads-by-references', which compared the References
201headers of the articles to find matches."
202 :group 'gnus-thread
22115a9e
RS
203 :type '(radio (function-item gnus-gather-threads-by-subject)
204 (function-item gnus-gather-threads-by-references)
205 (function :tag "other")))
eec82323 206
eec82323
LMI
207(defcustom gnus-summary-same-subject ""
208 "*String indicating that the current article has the same subject as the previous.
209This variable will only be used if the value of
210`gnus-summary-make-false-root' is `empty'."
211 :group 'gnus-summary-format
212 :type 'string)
213
214(defcustom gnus-summary-goto-unread t
16409b0b
GM
215 "*If t, many commands will go to the next unread article.
216This applies to marking commands as well as other commands that
217\"naturally\" select the next article, like, for instance, `SPC' at
218the end of an article.
219
220If nil, the marking commands do NOT go to the next unread article
2642ac8f 221\(they go to the next article instead). If `never', commands that
16409b0b
GM
222usually go to the next unread article, will go to the next article,
223whether it is read or not."
eec82323
LMI
224 :group 'gnus-summary-marks
225 :link '(custom-manual "(gnus)Setting Marks")
226 :type '(choice (const :tag "off" nil)
227 (const never)
228 (sexp :menu-tag "on" t)))
229
230(defcustom gnus-summary-default-score 0
231 "*Default article score level.
232All scores generated by the score files will be added to this score.
233If this variable is nil, scoring will be disabled."
234 :group 'gnus-score-default
235 :type '(choice (const :tag "disable")
236 integer))
237
23f87bed
MB
238(defcustom gnus-summary-default-high-score 0
239 "*Default threshold for a high scored article.
240An article will be highlighted as high scored if its score is greater
241than this score."
bf247b6e 242 :version "22.1"
23f87bed
MB
243 :group 'gnus-score-default
244 :type 'integer)
245
246(defcustom gnus-summary-default-low-score 0
247 "*Default threshold for a low scored article.
248An article will be highlighted as low scored if its score is smaller
249than this score."
bf247b6e 250 :version "22.1"
23f87bed
MB
251 :group 'gnus-score-default
252 :type 'integer)
253
eec82323
LMI
254(defcustom gnus-summary-zcore-fuzz 0
255 "*Fuzziness factor for the zcore in the summary buffer.
256Articles with scores closer than this to `gnus-summary-default-score'
257will not be marked."
258 :group 'gnus-summary-format
259 :type 'integer)
260
261(defcustom gnus-simplify-subject-fuzzy-regexp nil
262 "*Strings to be removed when doing fuzzy matches.
263This can either be a regular expression or list of regular expressions
264that will be removed from subject strings if fuzzy subject
265simplification is selected."
266 :group 'gnus-thread
267 :type '(repeat regexp))
268
269(defcustom gnus-show-threads t
270 "*If non-nil, display threads in summary mode."
271 :group 'gnus-thread
272 :type 'boolean)
273
274(defcustom gnus-thread-hide-subtree nil
275 "*If non-nil, hide all threads initially.
23f87bed 276This can be a predicate specifier which says which threads to hide.
eec82323 277If threads are hidden, you have to run the command
4a2358e9 278`gnus-summary-show-thread' by hand or select an article."
eec82323 279 :group 'gnus-thread
23f87bed
MB
280 :type '(radio (sexp :format "Non-nil\n"
281 :match (lambda (widget value)
282 (not (or (consp value) (functionp value))))
283 :value t)
284 (const nil)
ad136a7c 285 (sexp :tag "Predicate specifier")))
eec82323
LMI
286
287(defcustom gnus-thread-hide-killed t
288 "*If non-nil, hide killed threads automatically."
289 :group 'gnus-thread
290 :type 'boolean)
291
6748645f
LMI
292(defcustom gnus-thread-ignore-subject t
293 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
294If nil, articles that have different subjects from their parents will
295start separate threads."
eec82323
LMI
296 :group 'gnus-thread
297 :type 'boolean)
298
299(defcustom gnus-thread-operation-ignore-subject t
300 "*If non-nil, subjects will be ignored when doing thread commands.
301This affects commands like `gnus-summary-kill-thread' and
302`gnus-summary-lower-thread'.
303
304If this variable is nil, articles in the same thread with different
305subjects will not be included in the operation in question. If this
306variable is `fuzzy', only articles that have subjects that are fuzzily
307equal will be included."
308 :group 'gnus-thread
309 :type '(choice (const :tag "off" nil)
310 (const fuzzy)
311 (sexp :tag "on" t)))
312
313(defcustom gnus-thread-indent-level 4
314 "*Number that says how much each sub-thread should be indented."
315 :group 'gnus-thread
316 :type 'integer)
317
318(defcustom gnus-auto-extend-newsgroup t
319 "*If non-nil, extend newsgroup forward and backward when requested."
320 :group 'gnus-summary-choose
321 :type 'boolean)
322
323(defcustom gnus-auto-select-first t
651408cb
MB
324 "If non-nil, select an article on group entry.
325An article is selected automatically when entering a group
326e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
327`gnus-summary-catchup-and-goto-next-group'.
328
329Which article is selected is controlled by the variable
330`gnus-auto-select-subject'.
23f87bed
MB
331
332If you want to prevent automatic selection of articles in some
333newsgroups, set the variable to nil in `gnus-select-group-hook'."
651408cb
MB
334 ;; Commands include...
335 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
336 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
337 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
eec82323
LMI
338 :group 'gnus-group-select
339 :type '(choice (const :tag "none" nil)
23f87bed
MB
340 (sexp :menu-tag "first" t)))
341
342(defcustom gnus-auto-select-subject 'unread
343 "*Says what subject to place under point when entering a group.
344
345This variable can either be the symbols `first' (place point on the
346first subject), `unread' (place point on the subject line of the first
347unread article), `best' (place point on the subject line of the
348higest-scored article), `unseen' (place point on the subject line of
99b5aab7 349the first unseen article), `unseen-or-unread' (place point on the subject
23f87bed
MB
350line of the first unseen article or, if all article have been seen, on the
351subject line of the first unread article), or a function to be called to
352place point on some subject line."
bf247b6e 353 :version "22.1"
23f87bed
MB
354 :group 'gnus-group-select
355 :type '(choice (const best)
356 (const unread)
357 (const first)
358 (const unseen)
359 (const unseen-or-unread)))
eec82323
LMI
360
361(defcustom gnus-auto-select-next t
362 "*If non-nil, offer to go to the next group from the end of the previous.
363If the value is t and the next newsgroup is empty, Gnus will exit
23f87bed
MB
364summary mode and go back to group mode. If the value is neither nil
365nor t, Gnus will select the following unread newsgroup. In
eec82323
LMI
366particular, if the value is the symbol `quietly', the next unread
367newsgroup will be selected without any confirmation, and if it is
368`almost-quietly', the next group will be selected without any
369confirmation if you are located on the last article in the group.
23f87bed 370Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
eec82323
LMI
371will go to the next group without confirmation."
372 :group 'gnus-summary-maneuvering
373 :type '(choice (const :tag "off" nil)
374 (const quietly)
375 (const almost-quietly)
376 (const slightly-quietly)
377 (sexp :menu-tag "on" t)))
378
379(defcustom gnus-auto-select-same nil
6748645f
LMI
380 "*If non-nil, select the next article with the same subject.
381If there are no more articles with the same subject, go to
382the first unread article."
eec82323
LMI
383 :group 'gnus-summary-maneuvering
384 :type 'boolean)
385
01c52d31
MB
386(defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
387 "What article should be selected after exiting an ephemeral group.
388Valid values include:
389
390`next'
391 Select the next article.
392`next-unread'
393 Select the next unread article.
394`next-noselect'
395 Move the cursor to the next article. This is the default.
396`next-unread-noselect'
397 Move the cursor to the next unread article.
398
399If it has any other value or there is no next (unread) article, the
400article selected before entering to the ephemeral group will appear."
330f707b 401 :version "23.1" ;; No Gnus
01c52d31
MB
402 :group 'gnus-summary-maneuvering
403 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
404 (const next) (const next-unread)
405 (const next-noselect) (const next-unread-noselect)
406 (sexp :tag "other" :value nil)))
407
23f87bed
MB
408(defcustom gnus-auto-goto-ignores 'unfetched
409 "*Says how to handle unfetched articles when maneuvering.
410
411This variable can either be the symbols nil (maneuver to any
412article), `undownloaded' (maneuvering while unplugged ignores articles
413that have not been fetched), `always-undownloaded' (maneuvering always
414ignores articles that have not been fetched), `unfetched' (maneuvering
415ignores articles whose headers have not been fetched).
416
417NOTE: The list of unfetched articles will always be nil when plugged
418and, when unplugged, a subset of the undownloaded article list."
bf247b6e 419 :version "22.1"
23f87bed
MB
420 :group 'gnus-summary-maneuvering
421 :type '(choice (const :tag "None" nil)
422 (const :tag "Undownloaded when unplugged" undownloaded)
423 (const :tag "Undownloaded" always-undownloaded)
424 (const :tag "Unfetched" unfetched)))
425
eec82323
LMI
426(defcustom gnus-summary-check-current nil
427 "*If non-nil, consider the current article when moving.
428The \"unread\" movement commands will stay on the same line if the
429current article is unread."
430 :group 'gnus-summary-maneuvering
431 :type 'boolean)
432
01c52d31 433(defcustom gnus-auto-center-summary 2
eec82323
LMI
434 "*If non-nil, always center the current summary buffer.
435In particular, if `vertical' do only vertical recentering. If non-nil
436and non-`vertical', do both horizontal and vertical recentering."
437 :group 'gnus-summary-maneuvering
438 :type '(choice (const :tag "none" nil)
439 (const vertical)
16409b0b 440 (integer :tag "height")
eec82323
LMI
441 (sexp :menu-tag "both" t)))
442
23f87bed
MB
443(defvar gnus-auto-center-group t
444 "*If non-nil, always center the group buffer.")
445
eec82323
LMI
446(defcustom gnus-show-all-headers nil
447 "*If non-nil, don't hide any headers."
448 :group 'gnus-article-hiding
449 :group 'gnus-article-headers
450 :type 'boolean)
451
452(defcustom gnus-summary-ignore-duplicates nil
453 "*If non-nil, ignore articles with identical Message-ID headers."
454 :group 'gnus-summary
455 :type 'boolean)
6748645f 456
eec82323
LMI
457(defcustom gnus-single-article-buffer t
458 "*If non-nil, display all articles in the same buffer.
459If nil, each group will get its own article buffer."
460 :group 'gnus-article-various
461 :type 'boolean)
462
463(defcustom gnus-break-pages t
464 "*If non-nil, do page breaking on articles.
465The page delimiter is specified by the `gnus-page-delimiter'
466variable."
467 :group 'gnus-article-various
468 :type 'boolean)
469
eec82323
LMI
470(defcustom gnus-move-split-methods nil
471 "*Variable used to suggest where articles are to be moved to.
23f87bed
MB
472It uses the same syntax as the `gnus-split-methods' variable.
473However, whereas `gnus-split-methods' specifies file names as targets,
474this variable specifies group names."
eec82323 475 :group 'gnus-summary-mail
6748645f
LMI
476 :type '(repeat (choice (list :value (fun) function)
477 (cons :value ("" "") regexp (repeat string))
478 (sexp :value nil))))
eec82323 479
01c52d31
MB
480(defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
481 "Function used to compute default prefix for article move/copy/etc prompts.
482The function should take one argument, a group name, and return a
483string with the suggested prefix."
484 :group 'gnus-summary-mail
485 :type 'function)
486
e62e7654
MB
487;; FIXME: Although the custom type is `character' for the following variables,
488;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
489
23f87bed 490(defcustom gnus-unread-mark ? ;Whitespace
eec82323
LMI
491 "*Mark used for unread articles."
492 :group 'gnus-summary-marks
493 :type 'character)
494
495(defcustom gnus-ticked-mark ?!
496 "*Mark used for ticked articles."
497 :group 'gnus-summary-marks
498 :type 'character)
499
500(defcustom gnus-dormant-mark ??
501 "*Mark used for dormant articles."
502 :group 'gnus-summary-marks
503 :type 'character)
504
505(defcustom gnus-del-mark ?r
506 "*Mark used for del'd articles."
507 :group 'gnus-summary-marks
508 :type 'character)
509
510(defcustom gnus-read-mark ?R
511 "*Mark used for read articles."
512 :group 'gnus-summary-marks
513 :type 'character)
514
515(defcustom gnus-expirable-mark ?E
516 "*Mark used for expirable articles."
517 :group 'gnus-summary-marks
518 :type 'character)
519
520(defcustom gnus-killed-mark ?K
521 "*Mark used for killed articles."
522 :group 'gnus-summary-marks
523 :type 'character)
524
23f87bed
MB
525(defcustom gnus-spam-mark ?$
526 "*Mark used for spam articles."
bf247b6e 527 :version "22.1"
23f87bed
MB
528 :group 'gnus-summary-marks
529 :type 'character)
530
eec82323 531(defcustom gnus-souped-mark ?F
23f87bed 532 "*Mark used for souped articles."
eec82323
LMI
533 :group 'gnus-summary-marks
534 :type 'character)
535
536(defcustom gnus-kill-file-mark ?X
537 "*Mark used for articles killed by kill files."
538 :group 'gnus-summary-marks
539 :type 'character)
540
541(defcustom gnus-low-score-mark ?Y
542 "*Mark used for articles with a low score."
543 :group 'gnus-summary-marks
544 :type 'character)
545
546(defcustom gnus-catchup-mark ?C
547 "*Mark used for articles that are caught up."
548 :group 'gnus-summary-marks
549 :type 'character)
550
551(defcustom gnus-replied-mark ?A
552 "*Mark used for articles that have been replied to."
553 :group 'gnus-summary-marks
554 :type 'character)
555
23f87bed
MB
556(defcustom gnus-forwarded-mark ?F
557 "*Mark used for articles that have been forwarded."
bf247b6e 558 :version "22.1"
23f87bed
MB
559 :group 'gnus-summary-marks
560 :type 'character)
561
562(defcustom gnus-recent-mark ?N
563 "*Mark used for articles that are recent."
bf247b6e 564 :version "22.1"
23f87bed
MB
565 :group 'gnus-summary-marks
566 :type 'character)
567
eec82323
LMI
568(defcustom gnus-cached-mark ?*
569 "*Mark used for articles that are in the cache."
570 :group 'gnus-summary-marks
571 :type 'character)
572
573(defcustom gnus-saved-mark ?S
23f87bed
MB
574 "*Mark used for articles that have been saved."
575 :group 'gnus-summary-marks
576 :type 'character)
577
578(defcustom gnus-unseen-mark ?.
579 "*Mark used for articles that haven't been seen."
bf247b6e 580 :version "22.1"
23f87bed
MB
581 :group 'gnus-summary-marks
582 :type 'character)
583
584(defcustom gnus-no-mark ? ;Whitespace
585 "*Mark used for articles that have no other secondary mark."
bf247b6e 586 :version "22.1"
eec82323
LMI
587 :group 'gnus-summary-marks
588 :type 'character)
589
590(defcustom gnus-ancient-mark ?O
591 "*Mark used for ancient articles."
592 :group 'gnus-summary-marks
593 :type 'character)
594
595(defcustom gnus-sparse-mark ?Q
596 "*Mark used for sparsely reffed articles."
597 :group 'gnus-summary-marks
598 :type 'character)
599
600(defcustom gnus-canceled-mark ?G
601 "*Mark used for canceled articles."
602 :group 'gnus-summary-marks
603 :type 'character)
604
605(defcustom gnus-duplicate-mark ?M
606 "*Mark used for duplicate articles."
607 :group 'gnus-summary-marks
608 :type 'character)
609
23f87bed 610(defcustom gnus-undownloaded-mark ?-
6748645f 611 "*Mark used for articles that weren't downloaded."
bf247b6e 612 :version "22.1"
6748645f
LMI
613 :group 'gnus-summary-marks
614 :type 'character)
615
23f87bed
MB
616(defcustom gnus-downloaded-mark ?+
617 "*Mark used for articles that were downloaded."
618 :group 'gnus-summary-marks
619 :type 'character)
620
6748645f
LMI
621(defcustom gnus-downloadable-mark ?%
622 "*Mark used for articles that are to be downloaded."
623 :group 'gnus-summary-marks
624 :type 'character)
625
626(defcustom gnus-unsendable-mark ?=
627 "*Mark used for articles that won't be sent."
628 :group 'gnus-summary-marks
629 :type 'character)
630
eec82323
LMI
631(defcustom gnus-score-over-mark ?+
632 "*Score mark used for articles with high scores."
633 :group 'gnus-summary-marks
634 :type 'character)
635
636(defcustom gnus-score-below-mark ?-
637 "*Score mark used for articles with low scores."
638 :group 'gnus-summary-marks
639 :type 'character)
640
23f87bed 641(defcustom gnus-empty-thread-mark ? ;Whitespace
eec82323
LMI
642 "*There is no thread under the article."
643 :group 'gnus-summary-marks
644 :type 'character)
645
646(defcustom gnus-not-empty-thread-mark ?=
647 "*There is a thread under the article."
648 :group 'gnus-summary-marks
649 :type 'character)
650
651(defcustom gnus-view-pseudo-asynchronously nil
652 "*If non-nil, Gnus will view pseudo-articles asynchronously."
653 :group 'gnus-extract-view
654 :type 'boolean)
655
16409b0b
GM
656(defcustom gnus-auto-expirable-marks
657 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
658 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
659 gnus-souped-mark gnus-duplicate-mark)
660 "*The list of marks converted into expiration if a group is auto-expirable."
58e39d05 661 :version "21.1"
16409b0b
GM
662 :group 'gnus-summary
663 :type '(repeat character))
664
665(defcustom gnus-inhibit-user-auto-expire t
666 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
58e39d05 667 :version "21.1"
16409b0b
GM
668 :group 'gnus-summary
669 :type 'boolean)
670
b0b63450
MB
671(defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
672 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
673If nil, the expirable marks will be unchanged except that the marks
674will be removed when copying or moving articles to a group that has
675not turned auto-expire on. If non-nil, articles that have been read
676will be marked as expirable when being copied or moved to a group in
677which auto-expire is turned on."
678 :version "23.2"
679 :type 'boolean
680 :group 'gnus-summary-marks)
681
eec82323
LMI
682(defcustom gnus-view-pseudos nil
683 "*If `automatic', pseudo-articles will be viewed automatically.
684If `not-confirm', pseudos will be viewed automatically, and the user
685will not be asked to confirm the command."
686 :group 'gnus-extract-view
687 :type '(choice (const :tag "off" nil)
688 (const automatic)
689 (const not-confirm)))
690
691(defcustom gnus-view-pseudos-separately t
692 "*If non-nil, one pseudo-article will be created for each file to be viewed.
693If nil, all files that use the same viewing command will be given as a
694list of parameters to that command."
695 :group 'gnus-extract-view
696 :type 'boolean)
697
698(defcustom gnus-insert-pseudo-articles t
699 "*If non-nil, insert pseudo-articles when decoding articles."
700 :group 'gnus-extract-view
701 :type 'boolean)
702
703(defcustom gnus-summary-dummy-line-format
23f87bed 704 " %(: :%) %S\n"
eec82323
LMI
705 "*The format specification for the dummy roots in the summary buffer.
706It works along the same lines as a normal formatting string,
707with some simple extensions.
708
23f87bed
MB
709%S The subject
710
711General format specifiers can also be used.
712See `(gnus)Formatting Variables'."
713 :link '(custom-manual "(gnus)Formatting Variables")
eec82323
LMI
714 :group 'gnus-threading
715 :type 'string)
716
16409b0b 717(defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
eec82323
LMI
718 "*The format specification for the summary mode line.
719It works along the same lines as a normal formatting string,
720with some simple extensions:
721
722%G Group name
723%p Unprefixed group name
724%A Current article number
6748645f 725%z Current article score
eec82323
LMI
726%V Gnus version
727%U Number of unread articles in the group
728%e Number of unselected articles in the group
729%Z A string with unread/unselected article counts
730%g Shortish group name
731%S Subject of the current article
732%u User-defined spec
733%s Current score file name
734%d Number of dormant articles
735%r Number of articles that have been marked as read in this session
736%E Number of articles expunged by the score files"
737 :group 'gnus-summary-format
738 :type 'string)
739
16409b0b
GM
740(defcustom gnus-list-identifiers nil
741 "Regexp that matches list identifiers to be removed from subject.
742This can also be a list of regexps."
58e39d05 743 :version "21.1"
16409b0b
GM
744 :group 'gnus-summary-format
745 :group 'gnus-article-hiding
746 :type '(choice (const :tag "none" nil)
747 (regexp :value ".*")
748 (repeat :value (".*") regexp)))
749
eec82323
LMI
750(defcustom gnus-summary-mark-below 0
751 "*Mark all articles with a score below this variable as read.
752This variable is local to each summary buffer and usually set by the
753score file."
754 :group 'gnus-score-default
755 :type 'integer)
756
01c52d31
MB
757(defun gnus-widget-reversible-match (widget value)
758 "Ignoring WIDGET, convert VALUE to internal form.
759VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
760 ;; (debug value)
761 (or (symbolp value)
762 (and (listp value)
763 (eq (length value) 2)
764 (eq (nth 0 value) 'not)
765 (symbolp (nth 1 value)))))
766
767(defun gnus-widget-reversible-to-internal (widget value)
768 "Ignoring WIDGET, convert VALUE to internal form.
769VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
770FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
771 ;; (debug value)
772 (if (atom value)
773 (list value nil)
774 (list (nth 1 value) t)))
775
776(defun gnus-widget-reversible-to-external (widget value)
777 "Ignoring WIDGET, convert VALUE to external form.
778VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
779\(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
780 ;; (debug value)
781 (if (nth 1 value)
782 (list 'not (nth 0 value))
783 (nth 0 value)))
784
785(define-widget 'gnus-widget-reversible 'group
786 "A `group' that convert values."
787 :match 'gnus-widget-reversible-match
788 :value-to-internal 'gnus-widget-reversible-to-internal
789 :value-to-external 'gnus-widget-reversible-to-external)
790
eec82323
LMI
791(defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
792 "*List of functions used for sorting articles in the summary buffer.
23f87bed
MB
793
794Each function takes two articles and returns non-nil if the first
795article should be sorted before the other. If you use more than one
796function, the primary sort function should be the last. You should
797probably always include `gnus-article-sort-by-number' in the list of
798sorting functions -- preferably first. Also note that sorting by date
799is often much slower than sorting by number, and the sorting order is
800very similar. (Sorting by date means sorting by the time the message
801was sent, sorting by number means sorting by arrival time.)
802
01c52d31
MB
803Each item can also be a list `(not F)' where F is a function;
804this reverses the sort order.
805
23f87bed
MB
806Ready-made functions include `gnus-article-sort-by-number',
807`gnus-article-sort-by-author', `gnus-article-sort-by-subject',
808`gnus-article-sort-by-date', `gnus-article-sort-by-random'
809and `gnus-article-sort-by-score'.
810
811When threading is turned on, the variable `gnus-thread-sort-functions'
812controls how articles are sorted."
eec82323 813 :group 'gnus-summary-sort
01c52d31
MB
814 :type '(repeat (gnus-widget-reversible
815 (choice (function-item gnus-article-sort-by-number)
816 (function-item gnus-article-sort-by-author)
817 (function-item gnus-article-sort-by-subject)
818 (function-item gnus-article-sort-by-date)
819 (function-item gnus-article-sort-by-score)
820 (function-item gnus-article-sort-by-random)
821 (function :tag "other"))
822 (boolean :tag "Reverse order"))))
823
eec82323
LMI
824
825(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
826 "*List of functions used for sorting threads in the summary buffer.
827By default, threads are sorted by article number.
828
23f87bed
MB
829Each function takes two threads and returns non-nil if the first
830thread should be sorted before the other. If you use more than one
831function, the primary sort function should be the last. You should
832probably always include `gnus-thread-sort-by-number' in the list of
833sorting functions -- preferably first. Also note that sorting by date
834is often much slower than sorting by number, and the sorting order is
835very similar. (Sorting by date means sorting by the time the message
836was sent, sorting by number means sorting by arrival time.)
eec82323 837
01c52d31
MB
838Each list item can also be a list `(not F)' where F is a
839function; this specifies reversed sort order.
840
eec82323 841Ready-made functions include `gnus-thread-sort-by-number',
01c52d31
MB
842`gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
843`gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
844`gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
845`gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
846and `gnus-thread-sort-by-total-score' (see
847`gnus-thread-score-function').
23f87bed
MB
848
849When threading is turned off, the variable
850`gnus-article-sort-functions' controls how articles are sorted."
eec82323 851 :group 'gnus-summary-sort
01c52d31
MB
852 :type '(repeat
853 (gnus-widget-reversible
854 (choice (function-item gnus-thread-sort-by-number)
855 (function-item gnus-thread-sort-by-author)
856 (function-item gnus-thread-sort-by-recipient)
857 (function-item gnus-thread-sort-by-subject)
858 (function-item gnus-thread-sort-by-date)
859 (function-item gnus-thread-sort-by-score)
860 (function-item gnus-thread-sort-by-most-recent-number)
861 (function-item gnus-thread-sort-by-most-recent-date)
862 (function-item gnus-thread-sort-by-random)
863 (function-item gnus-thread-sort-by-total-score)
864 (function :tag "other"))
865 (boolean :tag "Reverse order"))))
eec82323
LMI
866
867(defcustom gnus-thread-score-function '+
868 "*Function used for calculating the total score of a thread.
869
870The function is called with the scores of the article and each
871subthread and should then return the score of the thread.
872
873Some functions you can use are `+', `max', or `min'."
874 :group 'gnus-summary-sort
875 :type 'function)
876
877(defcustom gnus-summary-expunge-below nil
6748645f
LMI
878 "All articles that have a score less than this variable will be expunged.
879This variable is local to the summary buffers."
eec82323
LMI
880 :group 'gnus-score-default
881 :type '(choice (const :tag "off" nil)
882 integer))
883
884(defcustom gnus-thread-expunge-below nil
885 "All threads that have a total score less than this variable will be expunged.
886See `gnus-thread-score-function' for en explanation of what a
6748645f
LMI
887\"thread score\" is.
888
889This variable is local to the summary buffers."
16409b0b 890 :group 'gnus-threading
eec82323
LMI
891 :group 'gnus-score-default
892 :type '(choice (const :tag "off" nil)
893 integer))
894
895(defcustom gnus-summary-mode-hook nil
896 "*A hook for Gnus summary mode.
897This hook is run before any variables are set in the summary buffer."
23f87bed 898 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
eec82323
LMI
899 :group 'gnus-summary-various
900 :type 'hook)
901
23f87bed
MB
902;; Extracted from gnus-xmas-redefine in order to preserve user settings
903(when (featurep 'xemacs)
904 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
905 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
906 (add-hook 'gnus-summary-mode-hook
907 'gnus-xmas-switch-horizontal-scrollbar-off))
908
eec82323
LMI
909(defcustom gnus-summary-menu-hook nil
910 "*Hook run after the creation of the summary mode menu."
911 :group 'gnus-summary-visual
912 :type 'hook)
913
914(defcustom gnus-summary-exit-hook nil
915 "*A hook called on exit from the summary buffer.
916It will be called with point in the group buffer."
917 :group 'gnus-summary-exit
918 :type 'hook)
919
920(defcustom gnus-summary-prepare-hook nil
921 "*A hook called after the summary buffer has been generated.
922If you want to modify the summary buffer, you can use this hook."
923 :group 'gnus-summary-various
924 :type 'hook)
925
6748645f
LMI
926(defcustom gnus-summary-prepared-hook nil
927 "*A hook called as the last thing after the summary buffer has been generated."
928 :group 'gnus-summary-various
929 :type 'hook)
930
eec82323
LMI
931(defcustom gnus-summary-generate-hook nil
932 "*A hook run just before generating the summary buffer.
933This hook is commonly used to customize threading variables and the
934like."
935 :group 'gnus-summary-various
936 :type 'hook)
937
938(defcustom gnus-select-group-hook nil
939 "*A hook called when a newsgroup is selected.
940
941If you'd like to simplify subjects like the
942`gnus-summary-next-same-subject' command does, you can use the
943following hook:
944
23f87bed
MB
945 (add-hook gnus-select-group-hook
946 (lambda ()
947 (mapcar (lambda (header)
948 (mail-header-set-subject
949 header
950 (gnus-simplify-subject
951 (mail-header-subject header) 're-only)))
952 gnus-newsgroup-headers)))"
eec82323
LMI
953 :group 'gnus-group-select
954 :type 'hook)
955
956(defcustom gnus-select-article-hook nil
957 "*A hook called when an article is selected."
958 :group 'gnus-summary-choose
23f87bed 959 :options '(gnus-agent-fetch-selected-article)
eec82323
LMI
960 :type 'hook)
961
962(defcustom gnus-visual-mark-article-hook
963 (list 'gnus-highlight-selected-summary)
964 "*Hook run after selecting an article in the summary buffer.
965It is meant to be used for highlighting the article in some way. It
966is not run if `gnus-visual' is nil."
967 :group 'gnus-summary-visual
968 :type 'hook)
969
16409b0b 970(defcustom gnus-parse-headers-hook nil
eec82323
LMI
971 "*A hook called before parsing the headers."
972 :group 'gnus-various
973 :type 'hook)
974
975(defcustom gnus-exit-group-hook nil
16409b0b
GM
976 "*A hook called when exiting summary mode.
977This hook is not called from the non-updating exit commands like `Q'."
eec82323
LMI
978 :group 'gnus-various
979 :type 'hook)
980
981(defcustom gnus-summary-update-hook
982 (list 'gnus-summary-highlight-line)
983 "*A hook called when a summary line is changed.
984The hook will not be called if `gnus-visual' is nil.
985
986The default function `gnus-summary-highlight-line' will
987highlight the line according to the `gnus-summary-highlight'
988variable."
989 :group 'gnus-summary-visual
990 :type 'hook)
991
992(defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
993 "*A hook called when an article is selected for the first time.
994The hook is intended to mark an article as read (or unread)
995automatically when it is selected."
996 :group 'gnus-summary-choose
997 :type 'hook)
998
999(defcustom gnus-group-no-more-groups-hook nil
1000 "*A hook run when returning to group mode having no more (unread) groups."
1001 :group 'gnus-group-select
1002 :type 'hook)
1003
1004(defcustom gnus-ps-print-hook nil
1005 "*A hook run before ps-printing something from Gnus."
1006 :group 'gnus-summary
1007 :type 'hook)
1008
23f87bed
MB
1009(defcustom gnus-summary-article-move-hook nil
1010 "*A hook called after an article is moved, copied, respooled, or crossposted."
bf247b6e 1011 :version "22.1"
23f87bed
MB
1012 :group 'gnus-summary
1013 :type 'hook)
1014
1015(defcustom gnus-summary-article-delete-hook nil
1016 "*A hook called after an article is deleted."
bf247b6e 1017 :version "22.1"
23f87bed
MB
1018 :group 'gnus-summary
1019 :type 'hook)
1020
1021(defcustom gnus-summary-article-expire-hook nil
1022 "*A hook called after an article is expired."
bf247b6e 1023 :version "22.1"
23f87bed
MB
1024 :group 'gnus-summary
1025 :type 'hook)
1026
1027(defcustom gnus-summary-display-arrow
1028 (and (fboundp 'display-graphic-p)
1029 (display-graphic-p))
1030 "*If non-nil, display an arrow highlighting the current article."
bf247b6e 1031 :version "22.1"
23f87bed
MB
1032 :group 'gnus-summary
1033 :type 'boolean)
1034
0f49874b 1035(defcustom gnus-summary-selected-face 'gnus-summary-selected
eec82323
LMI
1036 "Face used for highlighting the current article in the summary buffer."
1037 :group 'gnus-summary-visual
1038 :type 'face)
1039
23f87bed
MB
1040(defvar gnus-tmp-downloaded nil)
1041
eec82323 1042(defcustom gnus-summary-highlight
23f87bed 1043 '(((eq mark gnus-canceled-mark)
0f49874b 1044 . gnus-summary-cancelled)
23f87bed 1045 ((and uncached (> score default-high))
0f49874b 1046 . gnus-summary-high-undownloaded)
23f87bed 1047 ((and uncached (< score default-low))
0f49874b 1048 . gnus-summary-low-undownloaded)
23f87bed 1049 (uncached
0f49874b 1050 . gnus-summary-normal-undownloaded)
23f87bed
MB
1051 ((and (> score default-high)
1052 (or (eq mark gnus-dormant-mark)
1053 (eq mark gnus-ticked-mark)))
0f49874b 1054 . gnus-summary-high-ticked)
23f87bed
MB
1055 ((and (< score default-low)
1056 (or (eq mark gnus-dormant-mark)
1057 (eq mark gnus-ticked-mark)))
0f49874b 1058 . gnus-summary-low-ticked)
23f87bed
MB
1059 ((or (eq mark gnus-dormant-mark)
1060 (eq mark gnus-ticked-mark))
0f49874b 1061 . gnus-summary-normal-ticked)
23f87bed 1062 ((and (> score default-high) (eq mark gnus-ancient-mark))
0f49874b 1063 . gnus-summary-high-ancient)
23f87bed 1064 ((and (< score default-low) (eq mark gnus-ancient-mark))
0f49874b 1065 . gnus-summary-low-ancient)
23f87bed 1066 ((eq mark gnus-ancient-mark)
0f49874b 1067 . gnus-summary-normal-ancient)
23f87bed 1068 ((and (> score default-high) (eq mark gnus-unread-mark))
0f49874b 1069 . gnus-summary-high-unread)
23f87bed 1070 ((and (< score default-low) (eq mark gnus-unread-mark))
0f49874b 1071 . gnus-summary-low-unread)
23f87bed 1072 ((eq mark gnus-unread-mark)
0f49874b 1073 . gnus-summary-normal-unread)
23f87bed 1074 ((> score default-high)
0f49874b 1075 . gnus-summary-high-read)
23f87bed 1076 ((< score default-low)
0f49874b 1077 . gnus-summary-low-read)
eec82323 1078 (t
0f49874b 1079 . gnus-summary-normal-read))
6748645f 1080 "*Controls the highlighting of summary buffer lines.
eec82323 1081
107cf8ec 1082A list of (FORM . FACE) pairs. When deciding how a particular
23f87bed
MB
1083summary line should be displayed, each form is evaluated. The content
1084of the face field after the first true form is used. You can change
1085how those summary lines are displayed, by editing the face field.
eec82323
LMI
1086
1087You can use the following variables in the FORM field.
1088
107cf8ec 1089score: The article's score.
23f87bed
MB
1090default: The default article score.
1091default-high: The default score for high scored articles.
1092default-low: The default score for low scored articles.
1093below: The score below which articles are automatically marked as read.
1094mark: The article's mark.
1095uncached: Non-nil if the article is uncached."
eec82323
LMI
1096 :group 'gnus-summary-visual
1097 :type '(repeat (cons (sexp :tag "Form" nil)
1098 face)))
c12ecb0a 1099(put 'gnus-summary-highlight 'risky-local-variable t)
eec82323 1100
6748645f
LMI
1101(defcustom gnus-alter-header-function nil
1102 "Function called to allow alteration of article header structures.
1103The function is called with one parameter, the article header vector,
0ab0f2d3
SZ
1104which it may alter in any way."
1105 :type '(choice (const :tag "None" nil)
1106 function)
1107 :group 'gnus-summary)
eec82323 1108
16409b0b 1109(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
343d6628
MB
1110 "Function used to decode a string with encoded words.")
1111
1112(defvar gnus-decode-encoded-address-function
1113 'mail-decode-encoded-address-string
1114 "Function used to decode addresses with encoded words.")
16409b0b 1115
23f87bed 1116(defcustom gnus-extra-headers '(To Newsgroups)
16409b0b 1117 "*Extra headers to parse."
58e39d05 1118 :version "21.1"
16409b0b
GM
1119 :group 'gnus-summary
1120 :type '(repeat symbol))
1121
1122(defcustom gnus-ignored-from-addresses
343d6628 1123 (and user-mail-address
7cd9f860
CY
1124 (not (string= user-mail-address ""))
1125 (regexp-quote user-mail-address))
01c52d31
MB
1126 "*From headers that may be suppressed in favor of To headers.
1127This can be a regexp or a list of regexps."
58e39d05 1128 :version "21.1"
16409b0b 1129 :group 'gnus-summary
01c52d31
MB
1130 :type '(choice regexp
1131 (repeat :tag "Regexp List" regexp)))
1132
1133(defsubst gnus-ignored-from-addresses ()
1134 (gmm-regexp-concat gnus-ignored-from-addresses))
1135
1136(defcustom gnus-summary-to-prefix "-> "
1137 "*String prefixed to the To field in the summary line when
1138using `gnus-ignored-from-addresses'."
1139 :version "22.1"
1140 :group 'gnus-summary
1141 :type 'string)
1142
1143(defcustom gnus-summary-newsgroup-prefix "=> "
1144 "*String prefixed to the Newsgroup field in the summary
1145line when using `gnus-ignored-from-addresses'."
1146 :version "22.1"
1147 :group 'gnus-summary
1148 :type 'string)
16409b0b 1149
16409b0b
GM
1150(defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1151 "List of charsets that should be ignored.
1152When these charsets are used in the \"charset\" parameter, the
1153default charset will be used instead."
58e39d05 1154 :version "21.1"
16409b0b
GM
1155 :type '(repeat symbol)
1156 :group 'gnus-charset)
1157
4b70e299
MB
1158(defcustom gnus-newsgroup-maximum-articles nil
1159 "The maximum number of articles a newsgroup.
1160If this is a number, old articles in a newsgroup exceeding this number
1161are silently ignored. If it is nil, no article is ignored. Note that
1162setting this variable to a number might prevent you from reading very
1163old articles."
1164 :group 'gnus-group-select
1165 :version "22.2"
1166 :type '(choice (const :tag "No limit" nil)
1167 integer))
1168
23f87bed
MB
1169(gnus-define-group-parameter
1170 ignored-charsets
1171 :type list
1172 :function-document
1173 "Return the ignored charsets of GROUP."
1174 :variable gnus-group-ignored-charsets-alist
1175 :variable-default
1176 '(("alt\\.chinese\\.text" iso-8859-1))
1177 :variable-document
1178 "Alist of regexps (to match group names) and charsets that should be ignored.
16409b0b
GM
1179When these charsets are used in the \"charset\" parameter, the
1180default charset will be used instead."
23f87bed
MB
1181 :variable-group gnus-charset
1182 :variable-type '(repeat (cons (regexp :tag "Group")
1183 (repeat symbol)))
1184 :parameter-type '(choice :tag "Ignored charsets"
1185 :value nil
1186 (repeat (symbol)))
1187 :parameter-document "\
1188List of charsets that should be ignored.
1189
1190When these charsets are used in the \"charset\" parameter, the
1191default charset will be used instead.")
16409b0b
GM
1192
1193(defcustom gnus-group-highlight-words-alist nil
1194 "Alist of group regexps and highlight regexps.
1195This variable uses the same syntax as `gnus-emphasis-alist'."
58e39d05 1196 :version "21.1"
16409b0b
GM
1197 :type '(repeat (cons (regexp :tag "Group")
1198 (repeat (list (regexp :tag "Highlight regexp")
1199 (number :tag "Group for entire word" 0)
1200 (number :tag "Group for displayed part" 0)
1201 (symbol :tag "Face"
1202 gnus-emphasis-highlight-words)))))
1203 :group 'gnus-summary-visual)
1204
1205(defcustom gnus-summary-show-article-charset-alist
1206 nil
1207 "Alist of number and charset.
1208The article will be shown with the charset corresponding to the
1209numbered argument.
1210For example: ((1 . cn-gb-2312) (2 . big5))."
58e39d05 1211 :version "21.1"
16409b0b
GM
1212 :type '(repeat (cons (number :tag "Argument" 1)
1213 (symbol :tag "Charset")))
1214 :group 'gnus-charset)
1215
1216(defcustom gnus-preserve-marks t
1217 "Whether marks are preserved when moving, copying and respooling messages."
58e39d05 1218 :version "21.1"
16409b0b
GM
1219 :type 'boolean
1220 :group 'gnus-summary-marks)
1221
3a23a519
MB
1222(defcustom gnus-propagate-marks t
1223 "If non-nil, do not propagate marks to the backends."
f8a29505 1224 :version "23.1" ;; No Gnus
3a23a519
MB
1225 :type 'boolean
1226 :group 'gnus-summary-marks)
1227
16409b0b
GM
1228(defcustom gnus-alter-articles-to-read-function nil
1229 "Function to be called to alter the list of articles to be selected."
8fc7a9a1 1230 :type '(choice (const nil) function)
16409b0b
GM
1231 :group 'gnus-summary)
1232
1233(defcustom gnus-orphan-score nil
1234 "*All orphans get this score added. Set in the score file."
1235 :group 'gnus-score-default
1236 :type '(choice (const nil)
1237 integer))
1238
8b93df01 1239(defcustom gnus-summary-save-parts-default-mime "image/.*"
23f87bed
MB
1240 "*A regexp to match MIME parts when saving multiple parts of a
1241message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1242This regexp will be used by default when prompting the user for which
1243type of files to save."
8b93df01
DL
1244 :group 'gnus-summary
1245 :type 'regexp)
1246
23f87bed
MB
1247(defcustom gnus-read-all-available-headers nil
1248 "Whether Gnus should parse all headers made available to it.
1249This is mostly relevant for slow back ends where the user may
1250wish to widen the summary buffer to include all headers
1251that were fetched. Say, for nnultimate groups."
bf247b6e 1252 :version "22.1"
23f87bed
MB
1253 :group 'gnus-summary
1254 :type '(choice boolean regexp))
1255
89167438
MB
1256(defcustom gnus-summary-pipe-output-default-command nil
1257 "Command (and optional arguments) used to pipe article to subprocess.
1258This will be used as the default command if it is non-nil. The value
1259will be updated if you modify it when executing the command
1260`gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1261 :version "23.1" ;; No Gnus
1262 :group 'gnus-summary
1263 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1264
23f87bed 1265(defcustom gnus-summary-muttprint-program "muttprint"
89167438
MB
1266 "Command (and optional arguments) used to run Muttprint.
1267The value will be updated if you modify it when executing the command
1268`gnus-summary-muttprint'."
bf247b6e 1269 :version "22.1"
23f87bed
MB
1270 :group 'gnus-summary
1271 :type 'string)
1272
01c52d31 1273(defcustom gnus-article-loose-mime t
23f87bed
MB
1274 "If non-nil, don't require MIME-Version header.
1275Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
a08b59c9 1276supply the MIME-Version header or deliberately strip it from the mail.
01c52d31
MB
1277If non-nil (the default), Gnus will treat some articles as MIME
1278even if the MIME-Version header is missing."
bf247b6e 1279 :version "22.1"
23f87bed
MB
1280 :type 'boolean
1281 :group 'gnus-article-mime)
1282
1283(defcustom gnus-article-emulate-mime t
1284 "If non-nil, use MIME emulation for uuencode and the like.
1285This means that Gnus will search message bodies for text that look
1286like uuencoded bits, yEncoded bits, and so on, and present that using
1287the normal Gnus MIME machinery."
bf247b6e 1288 :version "22.1"
23f87bed
MB
1289 :type 'boolean
1290 :group 'gnus-article-mime)
8b93df01 1291
eec82323
LMI
1292;;; Internal variables
1293
23f87bed 1294(defvar gnus-summary-display-cache nil)
16409b0b
GM
1295(defvar gnus-article-mime-handles nil)
1296(defvar gnus-article-decoded-p nil)
23f87bed
MB
1297(defvar gnus-article-charset nil)
1298(defvar gnus-article-ignored-charsets nil)
eec82323
LMI
1299(defvar gnus-scores-exclude-files nil)
1300(defvar gnus-page-broken nil)
1301
1302(defvar gnus-original-article nil)
1303(defvar gnus-article-internal-prepare-hook nil)
1304(defvar gnus-newsgroup-process-stack nil)
1305
1306(defvar gnus-thread-indent-array nil)
1307(defvar gnus-thread-indent-array-level gnus-thread-indent-level)
16409b0b
GM
1308(defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1309 "Function called to sort the articles within a thread after it has been gathered together.")
eec82323 1310
8b93df01 1311(defvar gnus-summary-save-parts-type-history nil)
23f87bed 1312(defvar gnus-summary-save-parts-last-directory mm-default-directory)
8b93df01 1313
eec82323
LMI
1314;; Avoid highlighting in kill files.
1315(defvar gnus-summary-inhibit-highlight nil)
1316(defvar gnus-newsgroup-selected-overlay nil)
1317(defvar gnus-inhibit-limiting nil)
1318(defvar gnus-newsgroup-adaptive-score-file nil)
1319(defvar gnus-current-score-file nil)
1320(defvar gnus-current-move-group nil)
1321(defvar gnus-current-copy-group nil)
1322(defvar gnus-current-crosspost-group nil)
23f87bed 1323(defvar gnus-newsgroup-display nil)
eec82323
LMI
1324
1325(defvar gnus-newsgroup-dependencies nil)
1326(defvar gnus-newsgroup-adaptive nil)
1327(defvar gnus-summary-display-article-function nil)
1328(defvar gnus-summary-highlight-line-function nil
1329 "Function called after highlighting a summary line.")
1330
1331(defvar gnus-summary-line-format-alist
1332 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1333 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1334 (?s gnus-tmp-subject-or-nil ?s)
1335 (?n gnus-tmp-name ?s)
1336 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1337 ?s)
1338 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1339 gnus-tmp-from) ?s)
1340 (?F gnus-tmp-from ?s)
1341 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1342 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1343 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
6748645f 1344 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
eec82323
LMI
1345 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1346 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1347 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
23f87bed
MB
1348 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1349 (?L gnus-tmp-lines ?s)
1350 (?O gnus-tmp-downloaded ?c)
eec82323
LMI
1351 (?I gnus-tmp-indentation ?s)
1352 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1353 (?R gnus-tmp-replied ?c)
1354 (?\[ gnus-tmp-opening-bracket ?c)
1355 (?\] gnus-tmp-closing-bracket ?c)
1356 (?\> (make-string gnus-tmp-level ? ) ?s)
1357 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1358 (?i gnus-tmp-score ?d)
1359 (?z gnus-tmp-score-char ?c)
eec82323
LMI
1360 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1361 (?U gnus-tmp-unread ?c)
23f87bed
MB
1362 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1363 ?s)
eec82323
LMI
1364 (?t (gnus-summary-number-of-articles-in-thread
1365 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1366 ?d)
1367 (?e (gnus-summary-number-of-articles-in-thread
1368 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1369 ?c)
1370 (?u gnus-tmp-user-defined ?s)
23f87bed
MB
1371 (?P (gnus-pick-line-number) ?d)
1372 (?B gnus-tmp-thread-tree-header-string ?s)
1373 (user-date (gnus-user-date
1374 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
16409b0b
GM
1375 "An alist of format specifications that can appear in summary lines.
1376These are paired with what variables they correspond with, along with
1377the type of the variable (string, integer, character, etc).")
eec82323
LMI
1378
1379(defvar gnus-summary-dummy-line-format-alist
1380 `((?S gnus-tmp-subject ?s)
1381 (?N gnus-tmp-number ?d)
1382 (?u gnus-tmp-user-defined ?s)))
1383
1384(defvar gnus-summary-mode-line-format-alist
1385 `((?G gnus-tmp-group-name ?s)
1386 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1387 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1388 (?A gnus-tmp-article-number ?d)
1389 (?Z gnus-tmp-unread-and-unselected ?s)
1390 (?V gnus-version ?s)
1391 (?U gnus-tmp-unread-and-unticked ?d)
1392 (?S gnus-tmp-subject ?s)
1393 (?e gnus-tmp-unselected ?d)
1394 (?u gnus-tmp-user-defined ?s)
1395 (?d (length gnus-newsgroup-dormant) ?d)
1396 (?t (length gnus-newsgroup-marked) ?d)
23f87bed 1397 (?h (length gnus-newsgroup-spam-marked) ?d)
eec82323 1398 (?r (length gnus-newsgroup-reads) ?d)
6748645f 1399 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
eec82323
LMI
1400 (?E gnus-newsgroup-expunged-tally ?d)
1401 (?s (gnus-current-score-file-nondirectory) ?s)))
1402
c1717fbd
GM
1403;; This is here rather than in gnus-art for compilation reasons.
1404(defvar gnus-article-mode-line-format-alist
1405 (nconc '((?w (gnus-article-wash-status) ?s)
1406 (?m (gnus-article-mime-part-status) ?s))
1407 gnus-summary-mode-line-format-alist))
1408
eec82323
LMI
1409(defvar gnus-last-search-regexp nil
1410 "Default regexp for article search command.")
1411
1412(defvar gnus-last-shell-command nil
1413 "Default shell command on article.")
1414
23f87bed
MB
1415(defvar gnus-newsgroup-agentized nil
1416 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
eec82323
LMI
1417(defvar gnus-newsgroup-begin nil)
1418(defvar gnus-newsgroup-end nil)
1419(defvar gnus-newsgroup-last-rmail nil)
1420(defvar gnus-newsgroup-last-mail nil)
1421(defvar gnus-newsgroup-last-folder nil)
1422(defvar gnus-newsgroup-last-file nil)
26c9afc3 1423(defvar gnus-newsgroup-last-directory nil)
eec82323
LMI
1424(defvar gnus-newsgroup-auto-expire nil)
1425(defvar gnus-newsgroup-active nil)
1426
1427(defvar gnus-newsgroup-data nil)
1428(defvar gnus-newsgroup-data-reverse nil)
1429(defvar gnus-newsgroup-limit nil)
1430(defvar gnus-newsgroup-limits nil)
23f87bed 1431(defvar gnus-summary-use-undownloaded-faces nil)
eec82323
LMI
1432
1433(defvar gnus-newsgroup-unreads nil
23f87bed 1434 "Sorted list of unread articles in the current newsgroup.")
eec82323
LMI
1435
1436(defvar gnus-newsgroup-unselected nil
23f87bed 1437 "Sorted list of unselected unread articles in the current newsgroup.")
eec82323
LMI
1438
1439(defvar gnus-newsgroup-reads nil
1440 "Alist of read articles and article marks in the current newsgroup.")
1441
1442(defvar gnus-newsgroup-expunged-tally nil)
1443
1444(defvar gnus-newsgroup-marked nil
23f87bed
MB
1445 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1446
1447(defvar gnus-newsgroup-spam-marked nil
1448 "List of ranges of articles that have been marked as spam.")
eec82323
LMI
1449
1450(defvar gnus-newsgroup-killed nil
1451 "List of ranges of articles that have been through the scoring process.")
1452
1453(defvar gnus-newsgroup-cached nil
23f87bed 1454 "Sorted list of articles that come from the article cache.")
eec82323
LMI
1455
1456(defvar gnus-newsgroup-saved nil
1457 "List of articles that have been saved.")
1458
1459(defvar gnus-newsgroup-kill-headers nil)
1460
1461(defvar gnus-newsgroup-replied nil
1462 "List of articles that have been replied to in the current newsgroup.")
1463
23f87bed
MB
1464(defvar gnus-newsgroup-forwarded nil
1465 "List of articles that have been forwarded in the current newsgroup.")
1466
1467(defvar gnus-newsgroup-recent nil
1468 "List of articles that have are recent in the current newsgroup.")
1469
eec82323 1470(defvar gnus-newsgroup-expirable nil
23f87bed 1471 "Sorted list of articles in the current newsgroup that can be expired.")
eec82323
LMI
1472
1473(defvar gnus-newsgroup-processable nil
1474 "List of articles in the current newsgroup that can be processed.")
1475
6748645f 1476(defvar gnus-newsgroup-downloadable nil
23f87bed
MB
1477 "Sorted list of articles in the current newsgroup that can be processed.")
1478
1479(defvar gnus-newsgroup-unfetched nil
1480 "Sorted list of articles in the current newsgroup whose headers have
1481not been fetched into the agent.
1482
1483This list will always be a subset of gnus-newsgroup-undownloaded.")
6748645f
LMI
1484
1485(defvar gnus-newsgroup-undownloaded nil
23f87bed 1486 "List of articles in the current newsgroup that haven't been downloaded.")
6748645f
LMI
1487
1488(defvar gnus-newsgroup-unsendable nil
1489 "List of articles in the current newsgroup that won't be sent.")
1490
eec82323
LMI
1491(defvar gnus-newsgroup-bookmarks nil
1492 "List of articles in the current newsgroup that have bookmarks.")
1493
1494(defvar gnus-newsgroup-dormant nil
23f87bed
MB
1495 "Sorted list of dormant articles in the current newsgroup.")
1496
1497(defvar gnus-newsgroup-unseen nil
1498 "List of unseen articles in the current newsgroup.")
1499
1500(defvar gnus-newsgroup-seen nil
1501 "Range of seen articles in the current newsgroup.")
1502
1503(defvar gnus-newsgroup-articles nil
1504 "List of articles in the current newsgroup.")
eec82323
LMI
1505
1506(defvar gnus-newsgroup-scored nil
1507 "List of scored articles in the current newsgroup.")
1508
1509(defvar gnus-newsgroup-headers nil
1510 "List of article headers in the current newsgroup.")
1511
1512(defvar gnus-newsgroup-threads nil)
1513
1514(defvar gnus-newsgroup-prepared nil
1515 "Whether the current group has been prepared properly.")
1516
1517(defvar gnus-newsgroup-ancient nil
1518 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1519
1520(defvar gnus-newsgroup-sparse nil)
1521
1522(defvar gnus-current-article nil)
1523(defvar gnus-article-current nil)
1524(defvar gnus-current-headers nil)
1525(defvar gnus-have-all-headers nil)
1526(defvar gnus-last-article nil)
1527(defvar gnus-newsgroup-history nil)
16409b0b
GM
1528(defvar gnus-newsgroup-charset nil)
1529(defvar gnus-newsgroup-ephemeral-charset nil)
1530(defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
eec82323 1531
23f87bed
MB
1532(defvar gnus-article-before-search nil)
1533
1534(defvar gnus-summary-local-variables
eec82323
LMI
1535 '(gnus-newsgroup-name
1536 gnus-newsgroup-begin gnus-newsgroup-end
1537 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1538 gnus-newsgroup-last-folder gnus-newsgroup-last-file
26c9afc3 1539 gnus-newsgroup-last-directory
eec82323
LMI
1540 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1541 gnus-newsgroup-unselected gnus-newsgroup-marked
23f87bed 1542 gnus-newsgroup-spam-marked
eec82323 1543 gnus-newsgroup-reads gnus-newsgroup-saved
23f87bed
MB
1544 gnus-newsgroup-replied gnus-newsgroup-forwarded
1545 gnus-newsgroup-recent
1546 gnus-newsgroup-expirable
eec82323 1547 gnus-newsgroup-processable gnus-newsgroup-killed
6748645f 1548 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
23f87bed
MB
1549 gnus-newsgroup-unfetched
1550 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1551 gnus-newsgroup-seen gnus-newsgroup-articles
eec82323
LMI
1552 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1553 gnus-newsgroup-headers gnus-newsgroup-threads
1554 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1555 gnus-current-article gnus-current-headers gnus-have-all-headers
1556 gnus-last-article gnus-article-internal-prepare-hook
1557 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1558 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1559 gnus-thread-expunge-below
16409b0b
GM
1560 gnus-score-alist gnus-current-score-file
1561 (gnus-summary-expunge-below . global)
eec82323 1562 (gnus-summary-mark-below . global)
16409b0b 1563 (gnus-orphan-score . global)
eec82323
LMI
1564 gnus-newsgroup-active gnus-scores-exclude-files
1565 gnus-newsgroup-history gnus-newsgroup-ancient
1566 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1567 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1568 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1569 (gnus-newsgroup-expunged-tally . 0)
1570 gnus-cache-removable-articles gnus-newsgroup-cached
1571 gnus-newsgroup-data gnus-newsgroup-data-reverse
16409b0b 1572 gnus-newsgroup-limit gnus-newsgroup-limits
23f87bed
MB
1573 gnus-newsgroup-charset gnus-newsgroup-display
1574 gnus-summary-use-undownloaded-faces)
eec82323
LMI
1575 "Variables that are buffer-local to the summary buffers.")
1576
23f87bed
MB
1577(defvar gnus-newsgroup-variables nil
1578 "A list of variables that have separate values in different newsgroups.
1579A list of newsgroup (summary buffer) local variables, or cons of
1580variables and their default expressions to be evalled (when the default
1581values are not nil), that should be made global while the summary buffer
1582is active.
1583
1584Note: The default expressions will be evaluated (using function `eval')
1585before assignment to the local variable rather than just assigned to it.
1586If the default expression is the symbol `global', that symbol will not
1587be evaluated but the global value of the local variable will be used
1588instead.
1589
1590These variables can be used to set variables in the group parameters
1591while still allowing them to affect operations done in other buffers.
1592For example:
1593
1594\(setq gnus-newsgroup-variables
1595 '(message-use-followup-to
1596 (gnus-visible-headers .
1597 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1598")
1599
23f87bed
MB
1600(eval-when-compile
1601 ;; Bind features so that require will believe that gnus-sum has
1602 ;; already been loaded (avoids infinite recursion)
1603 (let ((features (cons 'gnus-sum features)))
23f87bed 1604 (require 'gnus-art)))
eec82323 1605
16409b0b
GM
1606;; MIME stuff.
1607
1608(defvar gnus-decode-encoded-word-methods
1609 '(mail-decode-encoded-word-string)
1610 "List of methods used to decode encoded words.
1611
23f87bed
MB
1612This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1613is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1614\(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
16409b0b
GM
1615whose names match REGEXP.
1616
1617For example:
23f87bed 1618\((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
16409b0b
GM
1619 mail-decode-encoded-word-string
1620 (\"chinese\" . rfc1843-decode-string))")
1621
1622(defvar gnus-decode-encoded-word-methods-cache nil)
1623
1624(defun gnus-multi-decode-encoded-word-string (string)
1625 "Apply the functions from `gnus-encoded-word-methods' that match."
1626 (unless (and gnus-decode-encoded-word-methods-cache
1627 (eq gnus-newsgroup-name
1628 (car gnus-decode-encoded-word-methods-cache)))
1629 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
01c52d31
MB
1630 (dolist (method gnus-decode-encoded-word-methods)
1631 (if (symbolp method)
1632 (nconc gnus-decode-encoded-word-methods-cache (list method))
1633 (if (and gnus-newsgroup-name
1634 (string-match (car method) gnus-newsgroup-name))
1635 (nconc gnus-decode-encoded-word-methods-cache
1636 (list (cdr method)))))))
1637 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1638 (setq string (funcall method string))))
16409b0b 1639
eec82323
LMI
1640;; Subject simplification.
1641
6748645f 1642(defun gnus-simplify-whitespace (str)
16409b0b 1643 "Remove excessive whitespace from STR."
23f87bed
MB
1644 ;; Multiple spaces.
1645 (while (string-match "[ \t][ \t]+" str)
1646 (setq str (concat (substring str 0 (match-beginning 0))
1647 " "
1648 (substring str (match-end 0)))))
1649 ;; Leading spaces.
1650 (when (string-match "^[ \t]+" str)
1651 (setq str (substring str (match-end 0))))
1652 ;; Trailing spaces.
1653 (when (string-match "[ \t]+$" str)
1654 (setq str (substring str 0 (match-beginning 0))))
1655 str)
1656
1657(defun gnus-simplify-all-whitespace (str)
1658 "Remove all whitespace from STR."
1659 (while (string-match "[ \t\n]+" str)
1660 (setq str (replace-match "" nil nil str)))
1661 str)
6748645f 1662
eec82323
LMI
1663(defsubst gnus-simplify-subject-re (subject)
1664 "Remove \"Re:\" from subject lines."
23f87bed 1665 (if (string-match message-subject-re-regexp subject)
eec82323
LMI
1666 (substring subject (match-end 0))
1667 subject))
1668
1669(defun gnus-simplify-subject (subject &optional re-only)
1670 "Remove `Re:' and words in parentheses.
1671If RE-ONLY is non-nil, strip leading `Re:'s only."
1672 (let ((case-fold-search t)) ;Ignore case.
1673 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1674 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1675 (setq subject (substring subject (match-end 0))))
1676 ;; Remove uninteresting prefixes.
1677 (when (and (not re-only)
1678 gnus-simplify-ignored-prefixes
1679 (string-match gnus-simplify-ignored-prefixes subject))
1680 (setq subject (substring subject (match-end 0))))
1681 ;; Remove words in parentheses from end.
1682 (unless re-only
1683 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1684 (setq subject (substring subject 0 (match-beginning 0)))))
1685 ;; Return subject string.
1686 subject))
1687
1688;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1689;; all whitespace.
1690(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1691 (goto-char (point-min))
1692 (while (re-search-forward regexp nil t)
16409b0b 1693 (replace-match (or newtext ""))))
eec82323
LMI
1694
1695(defun gnus-simplify-buffer-fuzzy ()
1696 "Simplify string in the buffer fuzzily.
1697The string in the accessible portion of the current buffer is simplified.
1698It is assumed to be a single-line subject.
1699Whitespace is generally cleaned up, and miscellaneous leading/trailing
1700matter is removed. Additional things can be deleted by setting
16409b0b 1701`gnus-simplify-subject-fuzzy-regexp'."
eec82323
LMI
1702 (let ((case-fold-search t)
1703 (modified-tick))
1704 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1705
1706 (while (not (eq modified-tick (buffer-modified-tick)))
1707 (setq modified-tick (buffer-modified-tick))
1708 (cond
1709 ((listp gnus-simplify-subject-fuzzy-regexp)
01c52d31
MB
1710 (mapc 'gnus-simplify-buffer-fuzzy-step
1711 gnus-simplify-subject-fuzzy-regexp))
eec82323
LMI
1712 (gnus-simplify-subject-fuzzy-regexp
1713 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1714 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1715 (gnus-simplify-buffer-fuzzy-step
1716 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1717 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1718
1719 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1720 (gnus-simplify-buffer-fuzzy-step " +" " ")
1721 (gnus-simplify-buffer-fuzzy-step " $")
1722 (gnus-simplify-buffer-fuzzy-step "^ +")))
1723
1724(defun gnus-simplify-subject-fuzzy (subject)
1725 "Simplify a subject string fuzzily.
6748645f 1726See `gnus-simplify-buffer-fuzzy' for details."
eec82323
LMI
1727 (save-excursion
1728 (gnus-set-work-buffer)
1729 (let ((case-fold-search t))
6748645f
LMI
1730 ;; Remove uninteresting prefixes.
1731 (when (and gnus-simplify-ignored-prefixes
1732 (string-match gnus-simplify-ignored-prefixes subject))
1733 (setq subject (substring subject (match-end 0))))
eec82323
LMI
1734 (insert subject)
1735 (inline (gnus-simplify-buffer-fuzzy))
1736 (buffer-string))))
1737
1738(defsubst gnus-simplify-subject-fully (subject)
23f87bed 1739 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
eec82323 1740 (cond
6748645f
LMI
1741 (gnus-simplify-subject-functions
1742 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1743 ((null gnus-summary-gather-subject-limit)
1744 (gnus-simplify-subject-re subject))
1745 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1746 (gnus-simplify-subject-fuzzy subject))
1747 ((numberp gnus-summary-gather-subject-limit)
01c52d31
MB
1748 (truncate-string-to-width (gnus-simplify-subject-re subject)
1749 gnus-summary-gather-subject-limit))
eec82323
LMI
1750 (t
1751 subject)))
1752
1753(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f 1754 "Check whether two subjects are equal.
23f87bed 1755If optional argument SIMPLE-FIRST is t, first argument is already
6748645f 1756simplified."
eec82323
LMI
1757 (cond
1758 ((null simple-first)
1759 (equal (gnus-simplify-subject-fully s1)
1760 (gnus-simplify-subject-fully s2)))
1761 (t
1762 (equal s1
1763 (gnus-simplify-subject-fully s2)))))
1764
1765(defun gnus-summary-bubble-group ()
1766 "Increase the score of the current group.
1767This is a handy function to add to `gnus-summary-exit-hook' to
1768increase the score of each group you read."
1769 (gnus-group-add-score gnus-newsgroup-name))
1770
1771\f
1772;;;
1773;;; Gnus summary mode
1774;;;
1775
1776(put 'gnus-summary-mode 'mode-class 'special)
1777
1653df0f
SZ
1778(defvar gnus-article-commands-menu)
1779
23f87bed
MB
1780;; Non-orthogonal keys
1781
1782(gnus-define-keys gnus-summary-mode-map
1783 " " gnus-summary-next-page
1784 "\177" gnus-summary-prev-page
1785 [delete] gnus-summary-prev-page
1786 [backspace] gnus-summary-prev-page
1787 "\r" gnus-summary-scroll-up
1788 "\M-\r" gnus-summary-scroll-down
1789 "n" gnus-summary-next-unread-article
1790 "p" gnus-summary-prev-unread-article
1791 "N" gnus-summary-next-article
1792 "P" gnus-summary-prev-article
1793 "\M-\C-n" gnus-summary-next-same-subject
1794 "\M-\C-p" gnus-summary-prev-same-subject
1795 "\M-n" gnus-summary-next-unread-subject
1796 "\M-p" gnus-summary-prev-unread-subject
1797 "." gnus-summary-first-unread-article
1798 "," gnus-summary-best-unread-article
1799 "\M-s" gnus-summary-search-article-forward
1800 "\M-r" gnus-summary-search-article-backward
01c52d31
MB
1801 "\M-S" gnus-summary-repeat-search-article-forward
1802 "\M-R" gnus-summary-repeat-search-article-backward
23f87bed
MB
1803 "<" gnus-summary-beginning-of-article
1804 ">" gnus-summary-end-of-article
1805 "j" gnus-summary-goto-article
1806 "^" gnus-summary-refer-parent-article
1807 "\M-^" gnus-summary-refer-article
1808 "u" gnus-summary-tick-article-forward
1809 "!" gnus-summary-tick-article-forward
1810 "U" gnus-summary-tick-article-backward
1811 "d" gnus-summary-mark-as-read-forward
1812 "D" gnus-summary-mark-as-read-backward
1813 "E" gnus-summary-mark-as-expirable
1814 "\M-u" gnus-summary-clear-mark-forward
1815 "\M-U" gnus-summary-clear-mark-backward
1816 "k" gnus-summary-kill-same-subject-and-select
1817 "\C-k" gnus-summary-kill-same-subject
1818 "\M-\C-k" gnus-summary-kill-thread
1819 "\M-\C-l" gnus-summary-lower-thread
1820 "e" gnus-summary-edit-article
1821 "#" gnus-summary-mark-as-processable
1822 "\M-#" gnus-summary-unmark-as-processable
1823 "\M-\C-t" gnus-summary-toggle-threads
1824 "\M-\C-s" gnus-summary-show-thread
1825 "\M-\C-h" gnus-summary-hide-thread
1826 "\M-\C-f" gnus-summary-next-thread
1827 "\M-\C-b" gnus-summary-prev-thread
1828 [(meta down)] gnus-summary-next-thread
1829 [(meta up)] gnus-summary-prev-thread
1830 "\M-\C-u" gnus-summary-up-thread
1831 "\M-\C-d" gnus-summary-down-thread
1832 "&" gnus-summary-execute-command
1833 "c" gnus-summary-catchup-and-exit
1834 "\C-w" gnus-summary-mark-region-as-read
1835 "\C-t" gnus-summary-toggle-truncation
1836 "?" gnus-summary-mark-as-dormant
1837 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1838 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6ecfe5c2 1839 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
23f87bed
MB
1840 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1841 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1842 "\C-c\C-s\C-a" gnus-summary-sort-by-author
01c52d31 1843 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
23f87bed
MB
1844 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1845 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6ecfe5c2 1846 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
23f87bed
MB
1847 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1848 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1849 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1850 "=" gnus-summary-expand-window
1851 "\C-x\C-s" gnus-summary-reselect-current-group
1852 "\M-g" gnus-summary-rescan-group
1853 "w" gnus-summary-stop-page-breaking
1854 "\C-c\C-r" gnus-summary-caesar-message
1855 "f" gnus-summary-followup
1856 "F" gnus-summary-followup-with-original
1857 "C" gnus-summary-cancel-article
1858 "r" gnus-summary-reply
1859 "R" gnus-summary-reply-with-original
1860 "\C-c\C-f" gnus-summary-mail-forward
1861 "o" gnus-summary-save-article
1862 "\C-o" gnus-summary-save-article-mail
1863 "|" gnus-summary-pipe-output
1864 "\M-k" gnus-summary-edit-local-kill
1865 "\M-K" gnus-summary-edit-global-kill
1866 ;; "V" gnus-version
1867 "\C-c\C-d" gnus-summary-describe-group
1868 "q" gnus-summary-exit
1869 "Q" gnus-summary-exit-no-update
1870 "\C-c\C-i" gnus-info-find-node
1871 gnus-mouse-2 gnus-mouse-pick-article
132cf96d 1872 [follow-link] mouse-face
23f87bed
MB
1873 "m" gnus-summary-mail-other-window
1874 "a" gnus-summary-post-news
1875 "i" gnus-summary-news-other-window
1876 "x" gnus-summary-limit-to-unread
1877 "s" gnus-summary-isearch-article
1878 "t" gnus-summary-toggle-header
1879 "g" gnus-summary-show-article
1880 "l" gnus-summary-goto-last-article
1881 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1882 "\C-d" gnus-summary-enter-digest-group
1883 "\M-\C-d" gnus-summary-read-document
1884 "\M-\C-e" gnus-summary-edit-parameters
1885 "\M-\C-a" gnus-summary-customize-parameters
1886 "\C-c\C-b" gnus-bug
1887 "*" gnus-cache-enter-article
1888 "\M-*" gnus-cache-remove-article
1889 "\M-&" gnus-summary-universal-argument
1890 "\C-l" gnus-recenter
1891 "I" gnus-summary-increase-score
1892 "L" gnus-summary-lower-score
1893 "\M-i" gnus-symbolic-argument
1894 "h" gnus-summary-select-article-buffer
1895
1896 "b" gnus-article-view-part
1897 "\M-t" gnus-summary-toggle-display-buttonized
1898
1899 "V" gnus-summary-score-map
1900 "X" gnus-uu-extract-map
1901 "S" gnus-summary-send-map)
1902
1903;; Sort of orthogonal keymap
1904(gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1905 "t" gnus-summary-tick-article-forward
1906 "!" gnus-summary-tick-article-forward
1907 "d" gnus-summary-mark-as-read-forward
1908 "r" gnus-summary-mark-as-read-forward
1909 "c" gnus-summary-clear-mark-forward
1910 " " gnus-summary-clear-mark-forward
1911 "e" gnus-summary-mark-as-expirable
1912 "x" gnus-summary-mark-as-expirable
1913 "?" gnus-summary-mark-as-dormant
1914 "b" gnus-summary-set-bookmark
1915 "B" gnus-summary-remove-bookmark
1916 "#" gnus-summary-mark-as-processable
1917 "\M-#" gnus-summary-unmark-as-processable
1918 "S" gnus-summary-limit-include-expunged
1919 "C" gnus-summary-catchup
1920 "H" gnus-summary-catchup-to-here
1921 "h" gnus-summary-catchup-from-here
1922 "\C-c" gnus-summary-catchup-all
1923 "k" gnus-summary-kill-same-subject-and-select
1924 "K" gnus-summary-kill-same-subject
1925 "P" gnus-uu-mark-map)
1926
1927(gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1928 "c" gnus-summary-clear-above
1929 "u" gnus-summary-tick-above
1930 "m" gnus-summary-mark-above
1931 "k" gnus-summary-kill-below)
1932
1933(gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1934 "/" gnus-summary-limit-to-subject
1935 "n" gnus-summary-limit-to-articles
01c52d31
MB
1936 "b" gnus-summary-limit-to-bodies
1937 "h" gnus-summary-limit-to-headers
23f87bed
MB
1938 "w" gnus-summary-pop-limit
1939 "s" gnus-summary-limit-to-subject
1940 "a" gnus-summary-limit-to-author
1941 "u" gnus-summary-limit-to-unread
1942 "m" gnus-summary-limit-to-marks
1943 "M" gnus-summary-limit-exclude-marks
1944 "v" gnus-summary-limit-to-score
1945 "*" gnus-summary-limit-include-cached
1946 "D" gnus-summary-limit-include-dormant
1947 "T" gnus-summary-limit-include-thread
1948 "d" gnus-summary-limit-exclude-dormant
1949 "t" gnus-summary-limit-to-age
1950 "." gnus-summary-limit-to-unseen
1951 "x" gnus-summary-limit-to-extra
1952 "p" gnus-summary-limit-to-display-predicate
1953 "E" gnus-summary-limit-include-expunged
1954 "c" gnus-summary-limit-exclude-childless-dormant
1955 "C" gnus-summary-limit-mark-excluded-as-read
1956 "o" gnus-summary-insert-old-articles
01c52d31
MB
1957 "N" gnus-summary-insert-new-articles
1958 "S" gnus-summary-limit-to-singletons
1959 "r" gnus-summary-limit-to-replied
1960 "R" gnus-summary-limit-to-recipient
1961 "A" gnus-summary-limit-to-address)
23f87bed
MB
1962
1963(gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1964 "n" gnus-summary-next-unread-article
1965 "p" gnus-summary-prev-unread-article
1966 "N" gnus-summary-next-article
1967 "P" gnus-summary-prev-article
1968 "\C-n" gnus-summary-next-same-subject
1969 "\C-p" gnus-summary-prev-same-subject
1970 "\M-n" gnus-summary-next-unread-subject
1971 "\M-p" gnus-summary-prev-unread-subject
1972 "f" gnus-summary-first-unread-article
1973 "b" gnus-summary-best-unread-article
1974 "j" gnus-summary-goto-article
1975 "g" gnus-summary-goto-subject
1976 "l" gnus-summary-goto-last-article
1977 "o" gnus-summary-pop-article)
1978
1979(gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1980 "k" gnus-summary-kill-thread
01c52d31 1981 "E" gnus-summary-expire-thread
23f87bed
MB
1982 "l" gnus-summary-lower-thread
1983 "i" gnus-summary-raise-thread
1984 "T" gnus-summary-toggle-threads
1985 "t" gnus-summary-rethread-current
1986 "^" gnus-summary-reparent-thread
01c52d31 1987 "\M-^" gnus-summary-reparent-children
23f87bed
MB
1988 "s" gnus-summary-show-thread
1989 "S" gnus-summary-show-all-threads
1990 "h" gnus-summary-hide-thread
1991 "H" gnus-summary-hide-all-threads
1992 "n" gnus-summary-next-thread
1993 "p" gnus-summary-prev-thread
1994 "u" gnus-summary-up-thread
1995 "o" gnus-summary-top-thread
1996 "d" gnus-summary-down-thread
1997 "#" gnus-uu-mark-thread
1998 "\M-#" gnus-uu-unmark-thread)
1999
2000(gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2001 "g" gnus-summary-prepare
2002 "c" gnus-summary-insert-cached-articles
01c52d31
MB
2003 "d" gnus-summary-insert-dormant-articles
2004 "t" gnus-summary-insert-ticked-articles)
23f87bed
MB
2005
2006(gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2007 "c" gnus-summary-catchup-and-exit
2008 "C" gnus-summary-catchup-all-and-exit
2009 "E" gnus-summary-exit-no-update
2010 "Q" gnus-summary-exit
2011 "Z" gnus-summary-exit
2012 "n" gnus-summary-catchup-and-goto-next-group
01c52d31 2013 "p" gnus-summary-catchup-and-goto-prev-group
23f87bed
MB
2014 "R" gnus-summary-reselect-current-group
2015 "G" gnus-summary-rescan-group
2016 "N" gnus-summary-next-group
2017 "s" gnus-summary-save-newsrc
2018 "P" gnus-summary-prev-group)
2019
2020(gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2021 " " gnus-summary-next-page
2022 "n" gnus-summary-next-page
2023 "\177" gnus-summary-prev-page
2024 [delete] gnus-summary-prev-page
2025 "p" gnus-summary-prev-page
2026 "\r" gnus-summary-scroll-up
2027 "\M-\r" gnus-summary-scroll-down
2028 "<" gnus-summary-beginning-of-article
2029 ">" gnus-summary-end-of-article
2030 "b" gnus-summary-beginning-of-article
2031 "e" gnus-summary-end-of-article
2032 "^" gnus-summary-refer-parent-article
2033 "r" gnus-summary-refer-parent-article
2034 "D" gnus-summary-enter-digest-group
2035 "R" gnus-summary-refer-references
2036 "T" gnus-summary-refer-thread
2037 "g" gnus-summary-show-article
2038 "s" gnus-summary-isearch-article
2039 "P" gnus-summary-print-article
01c52d31 2040 "S" gnus-sticky-article
23f87bed
MB
2041 "M" gnus-mailing-list-insinuate
2042 "t" gnus-article-babel)
2043
2044(gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2045 "b" gnus-article-add-buttons
2046 "B" gnus-article-add-buttons-to-head
2047 "o" gnus-article-treat-overstrike
2048 "e" gnus-article-emphasize
2049 "w" gnus-article-fill-cited-article
2050 "Q" gnus-article-fill-long-lines
01c52d31 2051 "L" gnus-article-toggle-truncate-lines
23f87bed
MB
2052 "C" gnus-article-capitalize-sentences
2053 "c" gnus-article-remove-cr
2054 "q" gnus-article-de-quoted-unreadable
2055 "6" gnus-article-de-base64-unreadable
2056 "Z" gnus-article-decode-HZ
01c52d31 2057 "A" gnus-article-treat-ansi-sequences
23f87bed
MB
2058 "h" gnus-article-wash-html
2059 "u" gnus-article-unsplit-urls
2060 "s" gnus-summary-force-verify-and-decrypt
2061 "f" gnus-article-display-x-face
2062 "l" gnus-summary-stop-page-breaking
2063 "r" gnus-summary-caesar-message
2064 "m" gnus-summary-morse-message
2065 "t" gnus-summary-toggle-header
2066 "g" gnus-treat-smiley
2067 "v" gnus-summary-verbose-headers
2068 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2069 "p" gnus-article-verify-x-pgp-sig
01c52d31
MB
2070 "d" gnus-article-treat-dumbquotes
2071 "i" gnus-summary-idna-message)
23f87bed
MB
2072
2073(gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2074 ;; mnemonic: deuglif*Y*
2075 "u" gnus-article-outlook-unwrap-lines
2076 "a" gnus-article-outlook-repair-attribution
2077 "c" gnus-article-outlook-rearrange-citation
2078 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2079
2080(gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2081 "a" gnus-article-hide
2082 "h" gnus-article-hide-headers
2083 "b" gnus-article-hide-boring-headers
2084 "s" gnus-article-hide-signature
2085 "c" gnus-article-hide-citation
2086 "C" gnus-article-hide-citation-in-followups
2087 "l" gnus-article-hide-list-identifiers
2088 "B" gnus-article-strip-banner
2089 "P" gnus-article-hide-pem
2090 "\C-c" gnus-article-hide-citation-maybe)
2091
2092(gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2093 "a" gnus-article-highlight
2094 "h" gnus-article-highlight-headers
2095 "c" gnus-article-highlight-citation
2096 "s" gnus-article-highlight-signature)
2097
2098(gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2099 "f" gnus-article-treat-fold-headers
2100 "u" gnus-article-treat-unfold-headers
2101 "n" gnus-article-treat-fold-newsgroups)
2102
2103(gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2104 "x" gnus-article-display-x-face
2105 "d" gnus-article-display-face
2106 "s" gnus-treat-smiley
2107 "D" gnus-article-remove-images
2108 "f" gnus-treat-from-picon
2109 "m" gnus-treat-mail-picon
2110 "n" gnus-treat-newsgroups-picon)
2111
2112(gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2113 "w" gnus-article-decode-mime-words
2114 "c" gnus-article-decode-charset
2115 "v" gnus-mime-view-all-parts
2116 "b" gnus-article-view-part)
2117
2118(gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2119 "z" gnus-article-date-ut
2120 "u" gnus-article-date-ut
2121 "l" gnus-article-date-local
2122 "p" gnus-article-date-english
2123 "e" gnus-article-date-lapsed
2124 "o" gnus-article-date-original
2125 "i" gnus-article-date-iso8601
2126 "s" gnus-article-date-user)
2127
2128(gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2129 "t" gnus-article-remove-trailing-blank-lines
2130 "l" gnus-article-strip-leading-blank-lines
2131 "m" gnus-article-strip-multiple-blank-lines
2132 "a" gnus-article-strip-blank-lines
2133 "A" gnus-article-strip-all-blank-lines
2134 "s" gnus-article-strip-leading-space
2135 "e" gnus-article-strip-trailing-space
2136 "w" gnus-article-remove-leading-whitespace)
2137
2138(gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2139 "v" gnus-version
2140 "f" gnus-summary-fetch-faq
2141 "d" gnus-summary-describe-group
2142 "h" gnus-summary-describe-briefly
2143 "i" gnus-info-find-node
2144 "c" gnus-group-fetch-charter
2145 "C" gnus-group-fetch-control)
2146
2147(gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2148 "e" gnus-summary-expire-articles
2149 "\M-\C-e" gnus-summary-expire-articles-now
2150 "\177" gnus-summary-delete-article
2151 [delete] gnus-summary-delete-article
2152 [backspace] gnus-summary-delete-article
2153 "m" gnus-summary-move-article
2154 "r" gnus-summary-respool-article
2155 "w" gnus-summary-edit-article
2156 "c" gnus-summary-copy-article
2157 "B" gnus-summary-crosspost-article
2158 "q" gnus-summary-respool-query
2159 "t" gnus-summary-respool-trace
2160 "i" gnus-summary-import-article
2161 "I" gnus-summary-create-article
2162 "p" gnus-summary-article-posted-p)
2163
2164(gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2165 "o" gnus-summary-save-article
2166 "m" gnus-summary-save-article-mail
2167 "F" gnus-summary-write-article-file
2168 "r" gnus-summary-save-article-rmail
2169 "f" gnus-summary-save-article-file
2170 "b" gnus-summary-save-article-body-file
26c9afc3 2171 "B" gnus-summary-write-article-body-file
23f87bed
MB
2172 "h" gnus-summary-save-article-folder
2173 "v" gnus-summary-save-article-vm
2174 "p" gnus-summary-pipe-output
2175 "P" gnus-summary-muttprint
2176 "s" gnus-soup-add-article)
2177
2178(gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2179 "b" gnus-summary-display-buttonized
2180 "m" gnus-summary-repair-multipart
2181 "v" gnus-article-view-part
2182 "o" gnus-article-save-part
01c52d31
MB
2183 "O" gnus-article-save-part-and-strip
2184 "r" gnus-article-replace-part
2185 "d" gnus-article-delete-part
2186 "t" gnus-article-view-part-as-type
2187 "j" gnus-article-jump-to-part
23f87bed
MB
2188 "c" gnus-article-copy-part
2189 "C" gnus-article-view-part-as-charset
2190 "e" gnus-article-view-part-externally
01c52d31 2191 "H" gnus-article-browse-html-article
23f87bed
MB
2192 "E" gnus-article-encrypt-body
2193 "i" gnus-article-inline-part
2194 "|" gnus-article-pipe-part)
2195
2196(gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2197 "p" gnus-summary-mark-as-processable
2198 "u" gnus-summary-unmark-as-processable
2199 "U" gnus-summary-unmark-all-processable
2200 "v" gnus-uu-mark-over
2201 "s" gnus-uu-mark-series
2202 "r" gnus-uu-mark-region
2203 "g" gnus-uu-unmark-region
2204 "R" gnus-uu-mark-by-regexp
2205 "G" gnus-uu-unmark-by-regexp
2206 "t" gnus-uu-mark-thread
2207 "T" gnus-uu-unmark-thread
2208 "a" gnus-uu-mark-all
2209 "b" gnus-uu-mark-buffer
2210 "S" gnus-uu-mark-sparse
2211 "k" gnus-summary-kill-process-mark
2212 "y" gnus-summary-yank-process-mark
2213 "w" gnus-summary-save-process-mark
2214 "i" gnus-uu-invert-processable)
2215
2216(gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2217 ;;"x" gnus-uu-extract-any
2218 "m" gnus-summary-save-parts
2219 "u" gnus-uu-decode-uu
2220 "U" gnus-uu-decode-uu-and-save
2221 "s" gnus-uu-decode-unshar
2222 "S" gnus-uu-decode-unshar-and-save
2223 "o" gnus-uu-decode-save
2224 "O" gnus-uu-decode-save
2225 "b" gnus-uu-decode-binhex
2226 "B" gnus-uu-decode-binhex
b890d447 2227 "Y" gnus-uu-decode-yenc
23f87bed
MB
2228 "p" gnus-uu-decode-postscript
2229 "P" gnus-uu-decode-postscript-and-save)
2230
2231(gnus-define-keys
2232 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2233 "u" gnus-uu-decode-uu-view
2234 "U" gnus-uu-decode-uu-and-save-view
2235 "s" gnus-uu-decode-unshar-view
2236 "S" gnus-uu-decode-unshar-and-save-view
2237 "o" gnus-uu-decode-save-view
2238 "O" gnus-uu-decode-save-view
2239 "b" gnus-uu-decode-binhex-view
2240 "B" gnus-uu-decode-binhex-view
2241 "p" gnus-uu-decode-postscript-view
2242 "P" gnus-uu-decode-postscript-and-save-view)
2243
2244(defvar gnus-article-post-menu nil)
2245
2246(defconst gnus-summary-menu-maxlen 20)
2247
2248(defun gnus-summary-menu-split (menu)
2249 ;; If we have lots of elements, divide them into groups of 20
2250 ;; and make a pane (or submenu) for each one.
2251 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2252 (let ((menu menu) sublists next
2253 (i 1))
2254 (while menu
2255 ;; Pull off the next gnus-summary-menu-maxlen elements
2256 ;; and make them the next element of sublist.
2257 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2258 (if next
2259 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2260 nil))
2261 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2262 (aref (car (last menu)) 0)) menu)
2263 sublists))
2264 (setq i (1+ i))
2265 (setq menu next))
2266 (nreverse sublists))
2267 ;; Few elements--put them all in one pane.
2268 menu))
eec82323
LMI
2269
2270(defun gnus-summary-make-menu-bar ()
2271 (gnus-turn-off-edit-menu 'summary)
2272
2273 (unless (boundp 'gnus-summary-misc-menu)
2274
2275 (easy-menu-define
23f87bed
MB
2276 gnus-summary-kill-menu gnus-summary-mode-map ""
2277 (cons
2278 "Score"
2279 (nconc
2280 (list
2281 ["Customize" gnus-score-customize t])
2282 (gnus-make-score-map 'increase)
2283 (gnus-make-score-map 'lower)
2284 '(("Mark"
2285 ["Kill below" gnus-summary-kill-below t]
2286 ["Mark above" gnus-summary-mark-above t]
2287 ["Tick above" gnus-summary-tick-above t]
2288 ["Clear above" gnus-summary-clear-above t])
2289 ["Current score" gnus-summary-current-score t]
2290 ["Set score" gnus-summary-set-score t]
2291 ["Switch current score file..." gnus-score-change-score-file t]
2292 ["Set mark below..." gnus-score-set-mark-below t]
2293 ["Set expunge below..." gnus-score-set-expunge-below t]
2294 ["Edit current score file" gnus-score-edit-current-scores t]
59429511 2295 ["Edit score file..." gnus-score-edit-file t]
23f87bed
MB
2296 ["Trace score" gnus-score-find-trace t]
2297 ["Find words" gnus-score-find-favourite-words t]
2298 ["Rescore buffer" gnus-summary-rescore t]
2299 ["Increase score..." gnus-summary-increase-score t]
2300 ["Lower score..." gnus-summary-lower-score t]))))
2301
2302 ;; Define both the Article menu in the summary buffer and the
2303 ;; equivalent Commands menu in the article buffer here for
2304 ;; consistency.
6748645f 2305 (let ((innards
23f87bed
MB
2306 `(("Hide"
2307 ["All" gnus-article-hide t]
2308 ["Headers" gnus-article-hide-headers t]
2309 ["Signature" gnus-article-hide-signature t]
2310 ["Citation" gnus-article-hide-citation t]
16409b0b 2311 ["List identifiers" gnus-article-hide-list-identifiers t]
16409b0b 2312 ["Banner" gnus-article-strip-banner t]
23f87bed
MB
2313 ["Boring headers" gnus-article-hide-boring-headers t])
2314 ("Highlight"
2315 ["All" gnus-article-highlight t]
2316 ["Headers" gnus-article-highlight-headers t]
2317 ["Signature" gnus-article-highlight-signature t]
2318 ["Citation" gnus-article-highlight-citation t])
16409b0b
GM
2319 ("MIME"
2320 ["Words" gnus-article-decode-mime-words t]
2321 ["Charset" gnus-article-decode-charset t]
2322 ["QP" gnus-article-de-quoted-unreadable t]
2323 ["Base64" gnus-article-de-base64-unreadable t]
23f87bed
MB
2324 ["View MIME buttons" gnus-summary-display-buttonized t]
2325 ["View all" gnus-mime-view-all-parts t]
2326 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2327 ["Encrypt body" gnus-article-encrypt-body
2328 :active (not (gnus-group-read-only-p))
2329 ,@(if (featurep 'xemacs) nil
2330 '(:help "Encrypt the message body on disk"))]
2331 ["Extract all parts..." gnus-summary-save-parts t]
2332 ("Multipart"
2333 ["Repair multipart" gnus-summary-repair-multipart t]
2334 ["Pipe part..." gnus-article-pipe-part t]
2335 ["Inline part" gnus-article-inline-part t]
01c52d31 2336 ["View part as type..." gnus-article-view-part-as-type t]
23f87bed
MB
2337 ["Encrypt body" gnus-article-encrypt-body
2338 :active (not (gnus-group-read-only-p))
2339 ,@(if (featurep 'xemacs) nil
2340 '(:help "Encrypt the message body on disk"))]
2341 ["View part externally" gnus-article-view-part-externally t]
01c52d31 2342 ["View HTML parts in browser" gnus-article-browse-html-article t]
23f87bed
MB
2343 ["View part with charset..." gnus-article-view-part-as-charset t]
2344 ["Copy part" gnus-article-copy-part t]
2345 ["Save part..." gnus-article-save-part t]
2346 ["View part" gnus-article-view-part t]))
2347 ("Date"
2348 ["Local" gnus-article-date-local t]
2349 ["ISO8601" gnus-article-date-iso8601 t]
2350 ["UT" gnus-article-date-ut t]
2351 ["Original" gnus-article-date-original t]
2352 ["Lapsed" gnus-article-date-lapsed t]
2353 ["User-defined" gnus-article-date-user t])
2354 ("Display"
2355 ["Remove images" gnus-article-remove-images t]
2356 ["Toggle smiley" gnus-treat-smiley t]
2357 ["Show X-Face" gnus-article-display-x-face t]
2358 ["Show picons in From" gnus-treat-from-picon t]
2359 ["Show picons in mail headers" gnus-treat-mail-picon t]
2360 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2361 ("View as different encoding"
2362 ,@(gnus-summary-menu-split
2363 (mapcar
2364 (lambda (cs)
2365 ;; Since easymenu under Emacs doesn't allow
2366 ;; lambda forms for menu commands, we should
2367 ;; provide intern'ed function symbols.
2368 (let ((command (intern (format "\
2369gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2370 (fset command
2371 `(lambda ()
2372 (interactive)
2373 (let ((gnus-summary-show-article-charset-alist
2374 '((1 . ,cs))))
2375 (gnus-summary-show-article 1))))
2376 `[,(symbol-name cs) ,command t]))
2377 (sort (if (fboundp 'coding-system-list)
2378 (coding-system-list)
2379 (mapcar 'car mm-mime-mule-charset-alist))
2380 'string<)))))
2381 ("Washing"
2382 ("Remove Blanks"
2383 ["Leading" gnus-article-strip-leading-blank-lines t]
2384 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2385 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2386 ["All of the above" gnus-article-strip-blank-lines t]
2387 ["All" gnus-article-strip-all-blank-lines t]
2388 ["Leading space" gnus-article-strip-leading-space t]
2389 ["Trailing space" gnus-article-strip-trailing-space t]
2390 ["Leading space in headers"
2391 gnus-article-remove-leading-whitespace t])
2392 ["Overstrike" gnus-article-treat-overstrike t]
2393 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2394 ["Emphasis" gnus-article-emphasize t]
2395 ["Word wrap" gnus-article-fill-cited-article t]
16409b0b 2396 ["Fill long lines" gnus-article-fill-long-lines t]
01c52d31 2397 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
16409b0b 2398 ["Capitalize sentences" gnus-article-capitalize-sentences t]
23f87bed
MB
2399 ["Remove CR" gnus-article-remove-cr t]
2400 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2401 ["Base64" gnus-article-de-base64-unreadable t]
2402 ["Rot 13" gnus-summary-caesar-message
2403 ,@(if (featurep 'xemacs) '(t)
2404 '(:help "\"Caesar rotate\" article by 13"))]
01c52d31 2405 ["De-IDNA" gnus-summary-idna-message t]
23f87bed
MB
2406 ["Morse decode" gnus-summary-morse-message t]
2407 ["Unix pipe..." gnus-summary-pipe-message t]
2408 ["Add buttons" gnus-article-add-buttons t]
2409 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2410 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2411 ["Verbose header" gnus-summary-verbose-headers t]
2412 ["Toggle header" gnus-summary-toggle-header t]
2413 ["Unfold headers" gnus-article-treat-unfold-headers t]
2414 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
16409b0b 2415 ["Html" gnus-article-wash-html t]
23f87bed
MB
2416 ["Unsplit URLs" gnus-article-unsplit-urls t]
2417 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2418 ["Decode HZ" gnus-article-decode-HZ t]
01c52d31 2419 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
23f87bed
MB
2420 ("(Outlook) Deuglify"
2421 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2422 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2423 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2424 ["Full (Outlook) deuglify"
2425 gnus-article-outlook-deuglify-article t])
2426 )
2427 ("Output"
2428 ["Save in default format..." gnus-summary-save-article
2429 ,@(if (featurep 'xemacs) '(t)
2430 '(:help "Save article using default method"))]
2431 ["Save in file..." gnus-summary-save-article-file
2432 ,@(if (featurep 'xemacs) '(t)
2433 '(:help "Save article in file"))]
2434 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2435 ["Save in MH folder..." gnus-summary-save-article-folder t]
2436 ["Save in VM folder..." gnus-summary-save-article-vm t]
2437 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2438 ["Save body in file..." gnus-summary-save-article-body-file t]
2439 ["Pipe through a filter..." gnus-summary-pipe-output t]
2440 ["Add to SOUP packet" gnus-soup-add-article t]
2441 ["Print with Muttprint..." gnus-summary-muttprint t]
531e5812
MB
2442 ["Print" gnus-summary-print-article
2443 ,@(if (featurep 'xemacs) '(t)
2444 '(:help "Generate and print a PostScript image"))])
2445 ("Copy, move,... (Backend)"
707f2b38 2446 ,@(if (featurep 'xemacs) nil
531e5812 2447 '(:help "Copying, moving, expiring articles..."))
23f87bed
MB
2448 ["Respool article..." gnus-summary-respool-article t]
2449 ["Move article..." gnus-summary-move-article
2450 (gnus-check-backend-function
2451 'request-move-article gnus-newsgroup-name)]
2452 ["Copy article..." gnus-summary-copy-article t]
2453 ["Crosspost article..." gnus-summary-crosspost-article
2454 (gnus-check-backend-function
2455 'request-replace-article gnus-newsgroup-name)]
2456 ["Import file..." gnus-summary-import-article
2457 (gnus-check-backend-function
2458 'request-accept-article gnus-newsgroup-name)]
2459 ["Create article..." gnus-summary-create-article
2460 (gnus-check-backend-function
2461 'request-accept-article gnus-newsgroup-name)]
2462 ["Check if posted" gnus-summary-article-posted-p t]
2463 ["Edit article" gnus-summary-edit-article
2464 (not (gnus-group-read-only-p))]
2465 ["Delete article" gnus-summary-delete-article
2466 (gnus-check-backend-function
2467 'request-expire-articles gnus-newsgroup-name)]
2468 ["Query respool" gnus-summary-respool-query t]
6748645f 2469 ["Trace respool" gnus-summary-respool-trace t]
23f87bed
MB
2470 ["Delete expirable articles" gnus-summary-expire-articles-now
2471 (gnus-check-backend-function
2472 'request-expire-articles gnus-newsgroup-name)])
2473 ("Extract"
2474 ["Uudecode" gnus-uu-decode-uu
2475 ,@(if (featurep 'xemacs) '(t)
2476 '(:help "Decode uuencoded article(s)"))]
2477 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2478 ["Unshar" gnus-uu-decode-unshar t]
2479 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2480 ["Save" gnus-uu-decode-save t]
2481 ["Binhex" gnus-uu-decode-binhex t]
2482 ["Postscript" gnus-uu-decode-postscript t]
2483 ["All MIME parts" gnus-summary-save-parts t])
2484 ("Cache"
2485 ["Enter article" gnus-cache-enter-article t]
2486 ["Remove article" gnus-cache-remove-article t])
16409b0b 2487 ["Translate" gnus-article-babel t]
23f87bed 2488 ["Select article buffer" gnus-summary-select-article-buffer t]
01c52d31 2489 ["Make article buffer sticky" gnus-sticky-article t]
23f87bed
MB
2490 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2491 ["Isearch article..." gnus-summary-isearch-article t]
2492 ["Beginning of the article" gnus-summary-beginning-of-article t]
2493 ["End of the article" gnus-summary-end-of-article t]
2494 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2495 ["Fetch referenced articles" gnus-summary-refer-references t]
2496 ["Fetch current thread" gnus-summary-refer-thread t]
2497 ["Fetch article with id..." gnus-summary-refer-article t]
2498 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2499 ["Redisplay" gnus-summary-show-article t]
2500 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
6748645f 2501 (easy-menu-define
23f87bed
MB
2502 gnus-summary-article-menu gnus-summary-mode-map ""
2503 (cons "Article" innards))
6748645f 2504
1653df0f
SZ
2505 (if (not (keymapp gnus-summary-article-menu))
2506 (easy-menu-define
2507 gnus-article-commands-menu gnus-article-mode-map ""
2508 (cons "Commands" innards))
2509 ;; in Emacs, don't share menu.
a1506d29 2510 (setq gnus-article-commands-menu
1653df0f
SZ
2511 (copy-keymap gnus-summary-article-menu))
2512 (define-key gnus-article-mode-map [menu-bar commands]
2513 (cons "Commands" gnus-article-commands-menu))))
eec82323
LMI
2514
2515 (easy-menu-define
23f87bed
MB
2516 gnus-summary-thread-menu gnus-summary-mode-map ""
2517 '("Threads"
2518 ["Find all messages in thread" gnus-summary-refer-thread t]
2519 ["Toggle threading" gnus-summary-toggle-threads t]
2520 ["Hide threads" gnus-summary-hide-all-threads t]
2521 ["Show threads" gnus-summary-show-all-threads t]
2522 ["Hide thread" gnus-summary-hide-thread t]
2523 ["Show thread" gnus-summary-show-thread t]
2524 ["Go to next thread" gnus-summary-next-thread t]
2525 ["Go to previous thread" gnus-summary-prev-thread t]
2526 ["Go down thread" gnus-summary-down-thread t]
2527 ["Go up thread" gnus-summary-up-thread t]
2528 ["Top of thread" gnus-summary-top-thread t]
2529 ["Mark thread as read" gnus-summary-kill-thread t]
01c52d31 2530 ["Mark thread as expired" gnus-summary-expire-thread t]
23f87bed
MB
2531 ["Lower thread score" gnus-summary-lower-thread t]
2532 ["Raise thread score" gnus-summary-raise-thread t]
2533 ["Rethread current" gnus-summary-rethread-current t]))
eec82323
LMI
2534
2535 (easy-menu-define
23f87bed
MB
2536 gnus-summary-post-menu gnus-summary-mode-map ""
2537 `("Post"
2538 ["Send a message (mail or news)" gnus-summary-post-news
2539 ,@(if (featurep 'xemacs) '(t)
531e5812 2540 '(:help "Compose a new message (mail or news)"))]
23f87bed
MB
2541 ["Followup" gnus-summary-followup
2542 ,@(if (featurep 'xemacs) '(t)
2543 '(:help "Post followup to this article"))]
2544 ["Followup and yank" gnus-summary-followup-with-original
2545 ,@(if (featurep 'xemacs) '(t)
2546 '(:help "Post followup to this article, quoting its contents"))]
2547 ["Supersede article" gnus-summary-supersede-article t]
2548 ["Cancel article" gnus-summary-cancel-article
2549 ,@(if (featurep 'xemacs) '(t)
2550 '(:help "Cancel an article you posted"))]
2551 ["Reply" gnus-summary-reply t]
2552 ["Reply and yank" gnus-summary-reply-with-original t]
2553 ["Wide reply" gnus-summary-wide-reply t]
2554 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2555 ,@(if (featurep 'xemacs) '(t)
2556 '(:help "Mail a reply, quoting this article"))]
2557 ["Very wide reply" gnus-summary-very-wide-reply t]
2558 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2559 ,@(if (featurep 'xemacs) '(t)
2560 '(:help "Mail a very wide reply, quoting this article"))]
2561 ["Mail forward" gnus-summary-mail-forward t]
2562 ["Post forward" gnus-summary-post-forward t]
2563 ["Digest and mail" gnus-uu-digest-mail-forward t]
2564 ["Digest and post" gnus-uu-digest-post-forward t]
2565 ["Resend message" gnus-summary-resend-message t]
2566 ["Resend message edit" gnus-summary-resend-message-edit t]
2567 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2568 ["Send a mail" gnus-summary-mail-other-window t]
2569 ["Create a local message" gnus-summary-news-other-window t]
2570 ["Uuencode and post" gnus-uu-post-news
2571 ,@(if (featurep 'xemacs) '(t)
2572 '(:help "Post a uuencoded article"))]
2573 ["Followup via news" gnus-summary-followup-to-mail t]
2574 ["Followup via news and yank"
2575 gnus-summary-followup-to-mail-with-original t]
9b3ebcb6
MB
2576 ["Strip signature on reply"
2577 (lambda ()
2578 (interactive)
2579 (if (not (memq message-cite-function
2580 '(message-cite-original-without-signature
2581 message-cite-original)))
2582 ;; Stupid workaround for XEmacs not honoring :visible.
2583 (message "Can't toggle this value of `message-cite-function'")
2584 (setq message-cite-function
2585 (if (eq message-cite-function
2586 'message-cite-original-without-signature)
2587 'message-cite-original
2588 'message-cite-original-without-signature))))
2589 ;; XEmacs barfs on :visible.
2590 ,@(if (featurep 'xemacs) nil
2591 '(:visible (memq message-cite-function
2592 '(message-cite-original-without-signature
2593 message-cite-original))))
2594 :style toggle
2595 :selected (eq message-cite-function
2596 'message-cite-original-without-signature)
2597 ,@(if (featurep 'xemacs) nil
2598 '(:help "Strip signature from cited article when replying."))]
23f87bed
MB
2599 ;;("Draft"
2600 ;;["Send" gnus-summary-send-draft t]
2601 ;;["Send bounced" gnus-resend-bounced-mail t])
2602 ))
2603
2604 (cond
2605 ((not (keymapp gnus-summary-post-menu))
2606 (setq gnus-article-post-menu gnus-summary-post-menu))
2607 ((not gnus-article-post-menu)
2608 ;; Don't share post menu.
2609 (setq gnus-article-post-menu
2610 (copy-keymap gnus-summary-post-menu))))
2611 (define-key gnus-article-mode-map [menu-bar post]
2612 (cons "Post" gnus-article-post-menu))
eec82323
LMI
2613
2614 (easy-menu-define
23f87bed
MB
2615 gnus-summary-misc-menu gnus-summary-mode-map ""
2616 `("Gnus"
2617 ("Mark Read"
2618 ["Mark as read" gnus-summary-mark-as-read-forward t]
2619 ["Mark same subject and select"
2620 gnus-summary-kill-same-subject-and-select t]
2621 ["Mark same subject" gnus-summary-kill-same-subject t]
2622 ["Catchup" gnus-summary-catchup
2623 ,@(if (featurep 'xemacs) '(t)
2624 '(:help "Mark unread articles in this group as read"))]
2625 ["Catchup all" gnus-summary-catchup-all t]
2626 ["Catchup to here" gnus-summary-catchup-to-here t]
2627 ["Catchup from here" gnus-summary-catchup-from-here t]
2628 ["Catchup region" gnus-summary-mark-region-as-read
2629 (gnus-mark-active-p)]
2630 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2631 ("Mark Various"
2632 ["Tick" gnus-summary-tick-article-forward t]
2633 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2634 ["Remove marks" gnus-summary-clear-mark-forward t]
2635 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2636 ["Set bookmark" gnus-summary-set-bookmark t]
2637 ["Remove bookmark" gnus-summary-remove-bookmark t])
8f7abae3
MB
2638 ("Registry Mark"
2639 ["Important" gnus-registry-set-article-Important-mark t]
2640 ["Not Important" gnus-registry-remove-article-Important-mark t]
2641 ["Work" gnus-registry-set-article-Work-mark t]
2642 ["Not Work" gnus-registry-remove-article-Work-mark t]
2643 ["Later" gnus-registry-set-article-Later-mark t]
2644 ["Not Later" gnus-registry-remove-article-Later-mark t]
2645 ["Personal" gnus-registry-set-article-Personal-mark t]
2646 ["Not Personal" gnus-registry-remove-article-Personal-mark t]
2647 ["To Do" gnus-registry-set-article-To-Do-mark t]
2648 ["Not To Do" gnus-registry-remove-article-To-Do-mark t])
23f87bed
MB
2649 ("Limit to"
2650 ["Marks..." gnus-summary-limit-to-marks t]
2651 ["Subject..." gnus-summary-limit-to-subject t]
2652 ["Author..." gnus-summary-limit-to-author t]
01c52d31
MB
2653 ["Recipient..." gnus-summary-limit-to-recipient t]
2654 ["Address..." gnus-summary-limit-to-address t]
23f87bed
MB
2655 ["Age..." gnus-summary-limit-to-age t]
2656 ["Extra..." gnus-summary-limit-to-extra t]
2657 ["Score..." gnus-summary-limit-to-score t]
2658 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2659 ["Unread" gnus-summary-limit-to-unread t]
2660 ["Unseen" gnus-summary-limit-to-unseen t]
01c52d31
MB
2661 ["Singletons" gnus-summary-limit-to-singletons t]
2662 ["Replied" gnus-summary-limit-to-replied t]
23f87bed 2663 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
996aa8c1 2664 ["Next or process marked articles" gnus-summary-limit-to-articles t]
23f87bed
MB
2665 ["Pop limit" gnus-summary-pop-limit t]
2666 ["Show dormant" gnus-summary-limit-include-dormant t]
2667 ["Hide childless dormant"
2668 gnus-summary-limit-exclude-childless-dormant t]
2669 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2670 ["Hide marked" gnus-summary-limit-exclude-marks t]
2671 ["Show expunged" gnus-summary-limit-include-expunged t])
2672 ("Process Mark"
2673 ["Set mark" gnus-summary-mark-as-processable t]
2674 ["Remove mark" gnus-summary-unmark-as-processable t]
2675 ["Remove all marks" gnus-summary-unmark-all-processable t]
01c52d31 2676 ["Invert marks" gnus-uu-invert-processable t]
23f87bed
MB
2677 ["Mark above" gnus-uu-mark-over t]
2678 ["Mark series" gnus-uu-mark-series t]
2679 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2680 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2681 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2682 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2683 ["Mark all" gnus-uu-mark-all t]
2684 ["Mark buffer" gnus-uu-mark-buffer t]
2685 ["Mark sparse" gnus-uu-mark-sparse t]
2686 ["Mark thread" gnus-uu-mark-thread t]
2687 ["Unmark thread" gnus-uu-unmark-thread t]
2688 ("Process Mark Sets"
2689 ["Kill" gnus-summary-kill-process-mark t]
2690 ["Yank" gnus-summary-yank-process-mark
2691 gnus-newsgroup-process-stack]
2692 ["Save" gnus-summary-save-process-mark t]
2693 ["Run command on marked..." gnus-summary-universal-argument t]))
2694 ("Scroll article"
2695 ["Page forward" gnus-summary-next-page
2696 ,@(if (featurep 'xemacs) '(t)
2697 '(:help "Show next page of article"))]
2698 ["Page backward" gnus-summary-prev-page
2699 ,@(if (featurep 'xemacs) '(t)
2700 '(:help "Show previous page of article"))]
2701 ["Line forward" gnus-summary-scroll-up t])
2702 ("Move"
2703 ["Next unread article" gnus-summary-next-unread-article t]
2704 ["Previous unread article" gnus-summary-prev-unread-article t]
2705 ["Next article" gnus-summary-next-article t]
2706 ["Previous article" gnus-summary-prev-article t]
2707 ["Next unread subject" gnus-summary-next-unread-subject t]
2708 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2709 ["Next article same subject" gnus-summary-next-same-subject t]
2710 ["Previous article same subject" gnus-summary-prev-same-subject t]
2711 ["First unread article" gnus-summary-first-unread-article t]
2712 ["Best unread article" gnus-summary-best-unread-article t]
2713 ["Go to subject number..." gnus-summary-goto-subject t]
2714 ["Go to article number..." gnus-summary-goto-article t]
2715 ["Go to the last article" gnus-summary-goto-last-article t]
2716 ["Pop article off history" gnus-summary-pop-article t])
2717 ("Sort"
2718 ["Sort by number" gnus-summary-sort-by-number t]
6ecfe5c2 2719 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
23f87bed 2720 ["Sort by author" gnus-summary-sort-by-author t]
01c52d31 2721 ["Sort by recipient" gnus-summary-sort-by-recipient t]
23f87bed
MB
2722 ["Sort by subject" gnus-summary-sort-by-subject t]
2723 ["Sort by date" gnus-summary-sort-by-date t]
6ecfe5c2 2724 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
23f87bed
MB
2725 ["Sort by score" gnus-summary-sort-by-score t]
2726 ["Sort by lines" gnus-summary-sort-by-lines t]
2727 ["Sort by characters" gnus-summary-sort-by-chars t]
2728 ["Randomize" gnus-summary-sort-by-random t]
2729 ["Original sort" gnus-summary-sort-by-original t])
2730 ("Help"
2731 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2732 ["Describe group" gnus-summary-describe-group t]
2733 ["Fetch charter" gnus-group-fetch-charter
2734 ,@(if (featurep 'xemacs) nil
2735 '(:help "Display the charter of the current group"))]
2736 ["Fetch control message" gnus-group-fetch-control
2737 ,@(if (featurep 'xemacs) nil
2738 '(:help "Display the archived control message for the current group"))]
2739 ["Read manual" gnus-info-find-node t])
2740 ("Modes"
2741 ["Pick and read" gnus-pick-mode t]
2742 ["Binary" gnus-binary-mode t])
2743 ("Regeneration"
2744 ["Regenerate" gnus-summary-prepare t]
2745 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2746 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
01c52d31 2747 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
23f87bed
MB
2748 ["Toggle threading" gnus-summary-toggle-threads t])
2749 ["See old articles" gnus-summary-insert-old-articles t]
2750 ["See new articles" gnus-summary-insert-new-articles t]
2751 ["Filter articles..." gnus-summary-execute-command t]
2752 ["Run command on articles..." gnus-summary-universal-argument t]
2753 ["Search articles forward..." gnus-summary-search-article-forward t]
2754 ["Search articles backward..." gnus-summary-search-article-backward t]
2755 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2756 ["Expand window" gnus-summary-expand-window t]
2757 ["Expire expirable articles" gnus-summary-expire-articles
2758 (gnus-check-backend-function
2759 'request-expire-articles gnus-newsgroup-name)]
2760 ["Edit local kill file" gnus-summary-edit-local-kill t]
2761 ["Edit main kill file" gnus-summary-edit-global-kill t]
2762 ["Edit group parameters" gnus-summary-edit-parameters t]
2763 ["Customize group parameters" gnus-summary-customize-parameters t]
2764 ["Send a bug report" gnus-bug t]
2765 ("Exit"
2766 ["Catchup and exit" gnus-summary-catchup-and-exit
2767 ,@(if (featurep 'xemacs) '(t)
2768 '(:help "Mark unread articles in this group as read, then exit"))]
2769 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2770 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
01c52d31 2771 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
23f87bed
MB
2772 ["Exit group" gnus-summary-exit
2773 ,@(if (featurep 'xemacs) '(t)
2774 '(:help "Exit current group, return to group selection mode"))]
2775 ["Exit group without updating" gnus-summary-exit-no-update t]
2776 ["Exit and goto next group" gnus-summary-next-group t]
2777 ["Exit and goto prev group" gnus-summary-prev-group t]
2778 ["Reselect group" gnus-summary-reselect-current-group t]
2779 ["Rescan group" gnus-summary-rescan-group t]
2780 ["Update dribble" gnus-summary-save-newsrc t])))
eec82323 2781
6748645f 2782 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323 2783
60bd5589
DL
2784(defvar gnus-summary-tool-bar-map nil)
2785
18c06a99
RS
2786;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2787;; affect _new_ message buffers. We might add a function that walks thru all
2788;; summary-mode buffers and force the update.
2789(defun gnus-summary-tool-bar-update (&optional symbol value)
2790 "Update summary mode toolbar.
2791Setter function for custom variables."
2792 (setq-default gnus-summary-tool-bar-map nil)
2793 (when symbol
2794 ;; When used as ":set" function:
2795 (set-default symbol value))
2796 (when (gnus-buffer-live-p gnus-summary-buffer)
2797 (with-current-buffer gnus-summary-buffer
2798 (gnus-summary-make-tool-bar))))
2799
2800(defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2801 'gnus-summary-tool-bar-gnome
2802 'gnus-summary-tool-bar-retro)
2803 "Specifies the Gnus summary tool bar.
2804
2805It can be either a list or a symbol refering to a list. See
2806`gmm-tool-bar-from-list' for the format of the list. The
2807default key map is `gnus-summary-mode-map'.
2808
2809Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2810`gnus-summary-tool-bar-retro'."
2811 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2812 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2813 (repeat :tag "User defined list" gmm-tool-bar-item)
2814 (symbol))
330f707b 2815 :version "23.1" ;; No Gnus
18c06a99
RS
2816 :initialize 'custom-initialize-default
2817 :set 'gnus-summary-tool-bar-update
2818 :group 'gnus-summary)
2819
2820(defcustom gnus-summary-tool-bar-gnome
2821 '((gnus-summary-post-news "mail/compose" nil)
2822 (gnus-summary-insert-new-articles "mail/inbox" nil
2823 :visible (or (not gnus-agent)
2824 gnus-plugged))
2825 (gnus-summary-reply-with-original "mail/reply")
2826 (gnus-summary-reply "mail/reply" nil :visible nil)
2827 (gnus-summary-followup-with-original "mail/reply-all")
2828 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2829 (gnus-summary-mail-forward "mail/forward")
2830 (gnus-summary-save-article "mail/save")
2831 (gnus-summary-search-article-forward "search" nil :visible nil)
2832 (gnus-summary-print-article "print")
2833 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2834 ;; Some new commands that may need more suitable icons:
2835 (gnus-summary-save-newsrc "save" nil :visible nil)
2836 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2837 (gnus-summary-prev-article "left-arrow")
2838 (gnus-summary-next-article "right-arrow")
2839 (gnus-summary-next-page "next-page")
2840 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2841 ;;
2842 ;; Maybe some sort-by-... could be added:
2843 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2844 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2845 (gnus-summary-mark-as-expirable
2846 "delete" nil
2847 :visible (gnus-check-backend-function 'request-expire-articles
2848 gnus-newsgroup-name))
2849 (gnus-summary-mark-as-spam
2850 "mail/spam" t
2851 :visible (and (fboundp 'spam-group-ham-contents-p)
2852 (spam-group-ham-contents-p gnus-newsgroup-name))
2853 :help "Mark as spam")
2854 (gnus-summary-mark-as-read-forward
2855 "mail/not-spam" nil
2856 :visible (and (fboundp 'spam-group-spam-contents-p)
2857 (spam-group-spam-contents-p gnus-newsgroup-name)))
2858 ;;
2859 (gnus-summary-exit "exit")
2860 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2861 (gnus-info-find-node "help"))
2862 "List of functions for the summary tool bar (GNOME style).
2863
2864See `gmm-tool-bar-from-list' for the format of the list."
2865 :type '(repeat gmm-tool-bar-item)
330f707b 2866 :version "23.1" ;; No Gnus
18c06a99
RS
2867 :initialize 'custom-initialize-default
2868 :set 'gnus-summary-tool-bar-update
2869 :group 'gnus-summary)
2870
2871(defcustom gnus-summary-tool-bar-retro
2872 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2873 (gnus-summary-next-unread-article "gnus/next-ur")
2874 (gnus-summary-post-news "gnus/post")
2875 (gnus-summary-followup-with-original "gnus/fuwo")
2876 (gnus-summary-followup "gnus/followup")
2877 (gnus-summary-reply-with-original "gnus/reply-wo")
2878 (gnus-summary-reply "gnus/reply")
2879 (gnus-summary-caesar-message "gnus/rot13")
2880 (gnus-uu-decode-uu "gnus/uu-decode")
2881 (gnus-summary-save-article-file "gnus/save-aif")
2882 (gnus-summary-save-article "gnus/save-art")
2883 (gnus-uu-post-news "gnus/uu-post")
2884 (gnus-summary-catchup "gnus/catchup")
2885 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2886 (gnus-summary-exit "gnus/exit-summ")
2887 ;; Some new command that may need more suitable icons:
2888 (gnus-summary-print-article "gnus/print" nil :visible nil)
2889 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2890 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2891 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2892 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2893 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2894 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2895 ;;
2896 (gnus-info-find-node "gnus/help" nil :visible nil))
2897 "List of functions for the summary tool bar (retro look).
2898
2899See `gmm-tool-bar-from-list' for the format of the list."
2900 :type '(repeat gmm-tool-bar-item)
330f707b 2901 :version "23.1" ;; No Gnus
18c06a99
RS
2902 :initialize 'custom-initialize-default
2903 :set 'gnus-summary-tool-bar-update
2904 :group 'gnus-summary)
2905
2906(defcustom gnus-summary-tool-bar-zap-list t
2907 "List of icon items from the global tool bar.
2908These items are not displayed in the Gnus summary mode tool bar.
2909
2910See `gmm-tool-bar-from-list' for the format of the list."
2911 :type 'gmm-tool-bar-zap-list
330f707b 2912 :version "23.1" ;; No Gnus
18c06a99
RS
2913 :initialize 'custom-initialize-default
2914 :set 'gnus-summary-tool-bar-update
2915 :group 'gnus-summary)
2916
2917(defvar image-load-path)
f654fa04 2918(defvar tool-bar-map)
18c06a99
RS
2919
2920(defun gnus-summary-make-tool-bar (&optional force)
2921 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2922When FORCE, rebuild the tool bar."
2923 (when (and (not (featurep 'xemacs))
2924 (boundp 'tool-bar-mode)
2925 tool-bar-mode
2926 (or (not gnus-summary-tool-bar-map) force))
2927 (let* ((load-path
2928 (gmm-image-load-path-for-library "gnus"
2929 "mail/save.xpm"
2930 nil t))
2931 (image-load-path (cons (car load-path)
2932 (when (boundp 'image-load-path)
2933 image-load-path)))
2934 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2935 gnus-summary-tool-bar-zap-list
2936 'gnus-summary-mode-map)))
2937 (when map
2938 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2939 ;; uses it's value.
2940 (setq gnus-summary-tool-bar-map map))))
2941 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
60bd5589 2942
eec82323
LMI
2943(defun gnus-score-set-default (var value)
2944 "A version of set that updates the GNU Emacs menu-bar."
2945 (set var value)
2946 ;; It is the message that forces the active status to be updated.
2947 (message ""))
2948
2949(defun gnus-make-score-map (type)
2950 "Make a summary score map of type TYPE."
2951 (if t
2952 nil
2953 (let ((headers '(("author" "from" string)
2954 ("subject" "subject" string)
2955 ("article body" "body" string)
2956 ("article head" "head" string)
2957 ("xref" "xref" string)
16409b0b 2958 ("extra header" "extra" string)
eec82323
LMI
2959 ("lines" "lines" number)
2960 ("followups to author" "followup" string)))
2961 (types '((number ("less than" <)
2962 ("greater than" >)
2963 ("equal" =))
2964 (string ("substring" s)
2965 ("exact string" e)
2966 ("fuzzy string" f)
2967 ("regexp" r))))
2968 (perms '(("temporary" (current-time-string))
2969 ("permanent" nil)
2970 ("immediate" now)))
2971 header)
2972 (list
2973 (apply
2974 'nconc
2975 (list
2976 (if (eq type 'lower)
2977 "Lower score"
2978 "Increase score"))
2979 (let (outh)
2980 (while headers
2981 (setq header (car headers))
2982 (setq outh
2983 (cons
2984 (apply
2985 'nconc
2986 (list (car header))
2987 (let ((ts (cdr (assoc (nth 2 header) types)))
2988 outt)
2989 (while ts
2990 (setq outt
2991 (cons
2992 (apply
2993 'nconc
2994 (list (caar ts))
2995 (let ((ps perms)
2996 outp)
2997 (while ps
2998 (setq outp
2999 (cons
3000 (vector
3001 (caar ps)
3002 (list
3003 'gnus-summary-score-entry
3004 (nth 1 header)
3005 (if (or (string= (nth 1 header)
3006 "head")
3007 (string= (nth 1 header)
3008 "body"))
3009 ""
3010 (list 'gnus-summary-header
3011 (nth 1 header)))
3012 (list 'quote (nth 1 (car ts)))
16409b0b
GM
3013 (list 'gnus-score-delta-default
3014 nil)
eec82323
LMI
3015 (nth 1 (car ps))
3016 t)
3017 t)
3018 outp))
3019 (setq ps (cdr ps)))
3020 (list (nreverse outp))))
3021 outt))
3022 (setq ts (cdr ts)))
3023 (list (nreverse outt))))
3024 outh))
3025 (setq headers (cdr headers)))
3026 (list (nreverse outh))))))))
3027
704f1663
GM
3028
3029(declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3030
eec82323
LMI
3031\f
3032
3033(defun gnus-summary-mode (&optional group)
3034 "Major mode for reading articles.
3035
3036All normal editing commands are switched off.
3037\\<gnus-summary-mode-map>
3038Each line in this buffer represents one article. To read an
3039article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3040and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3041respectively.
3042
3043You can also post articles and send mail from this buffer. To
23f87bed 3044follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
eec82323
LMI
3045of an article, type `\\[gnus-summary-reply]'.
3046
3047There are approx. one gazillion commands you can execute in this
3048buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3049
3050The following commands are available:
3051
3052\\{gnus-summary-mode-map}"
3053 (interactive)
eec82323 3054 (kill-all-local-variables)
01c52d31
MB
3055 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3056 (gnus-summary-make-local-variables))
3057 (gnus-summary-make-local-variables)
3058 (setq gnus-newsgroup-name group)
60bd5589
DL
3059 (when (gnus-visual-p 'summary-menu 'menu)
3060 (gnus-summary-make-menu-bar)
3061 (gnus-summary-make-tool-bar))
eec82323
LMI
3062 (gnus-make-thread-indent-array)
3063 (gnus-simplify-mode-line)
3064 (setq major-mode 'gnus-summary-mode)
3065 (setq mode-name "Summary")
3066 (make-local-variable 'minor-mode-alist)
3067 (use-local-map gnus-summary-mode-map)
16409b0b 3068 (buffer-disable-undo)
01c52d31
MB
3069 (setq buffer-read-only t ;Disable modification
3070 show-trailing-whitespace nil)
eec82323
LMI
3071 (setq truncate-lines t)
3072 (setq selective-display t)
3073 (setq selective-display-ellipses t) ;Display `...'
3074 (gnus-summary-set-display-table)
3075 (gnus-set-default-directory)
eec82323
LMI
3076 (make-local-variable 'gnus-summary-line-format)
3077 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
3078 (make-local-variable 'gnus-summary-dummy-line-format)
3079 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323 3080 (make-local-variable 'gnus-summary-mark-positions)
23f87bed 3081 (gnus-make-local-hook 'pre-command-hook)
6748645f 3082 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
cfcd5c91 3083 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
23f87bed 3084 (turn-on-gnus-mailing-list-mode)
87545352 3085 (mm-enable-multibyte)
eec82323
LMI
3086 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3087 (gnus-update-summary-mark-positions))
3088
3089(defun gnus-summary-make-local-variables ()
3090 "Make all the local summary buffer variables."
16409b0b
GM
3091 (let (global)
3092 (dolist (local gnus-summary-local-variables)
eec82323
LMI
3093 (if (consp local)
3094 (progn
3095 (if (eq (cdr local) 'global)
3096 ;; Copy the global value of the variable.
3097 (setq global (symbol-value (car local)))
3098 ;; Use the value from the list.
3099 (setq global (eval (cdr local))))
16409b0b 3100 (set (make-local-variable (car local)) global))
eec82323 3101 ;; Simple nil-valued local variable.
16409b0b 3102 (set (make-local-variable local) nil)))))
eec82323
LMI
3103
3104(defun gnus-summary-clear-local-variables ()
3105 (let ((locals gnus-summary-local-variables))
3106 (while locals
3107 (if (consp (car locals))
01c52d31 3108 (and (symbolp (caar locals))
eec82323 3109 (set (caar locals) nil))
01c52d31 3110 (and (symbolp (car locals))
eec82323
LMI
3111 (set (car locals) nil)))
3112 (setq locals (cdr locals)))))
3113
3114;; Summary data functions.
3115
3116(defmacro gnus-data-number (data)
3117 `(car ,data))
3118
3119(defmacro gnus-data-set-number (data number)
3120 `(setcar ,data ,number))
3121
3122(defmacro gnus-data-mark (data)
3123 `(nth 1 ,data))
3124
3125(defmacro gnus-data-set-mark (data mark)
3126 `(setcar (nthcdr 1 ,data) ,mark))
3127
3128(defmacro gnus-data-pos (data)
3129 `(nth 2 ,data))
3130
3131(defmacro gnus-data-set-pos (data pos)
3132 `(setcar (nthcdr 2 ,data) ,pos))
3133
3134(defmacro gnus-data-header (data)
3135 `(nth 3 ,data))
3136
3137(defmacro gnus-data-set-header (data header)
3138 `(setf (nth 3 ,data) ,header))
3139
3140(defmacro gnus-data-level (data)
3141 `(nth 4 ,data))
3142
3143(defmacro gnus-data-unread-p (data)
3144 `(= (nth 1 ,data) gnus-unread-mark))
3145
3146(defmacro gnus-data-read-p (data)
3147 `(/= (nth 1 ,data) gnus-unread-mark))
3148
3149(defmacro gnus-data-pseudo-p (data)
3150 `(consp (nth 3 ,data)))
3151
3152(defmacro gnus-data-find (number)
3153 `(assq ,number gnus-newsgroup-data))
3154
3155(defmacro gnus-data-find-list (number &optional data)
3156 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3157 (memq (assq ,number bdata)
3158 bdata)))
3159
3160(defmacro gnus-data-make (number mark pos header level)
3161 `(list ,number ,mark ,pos ,header ,level))
3162
3163(defun gnus-data-enter (after-article number mark pos header level offset)
3164 (let ((data (gnus-data-find-list after-article)))
3165 (unless data
3166 (error "No such article: %d" after-article))
3167 (setcdr data (cons (gnus-data-make number mark pos header level)
3168 (cdr data)))
3169 (setq gnus-newsgroup-data-reverse nil)
3170 (gnus-data-update-list (cddr data) offset)))
3171
3172(defun gnus-data-enter-list (after-article list &optional offset)
3173 (when list
3174 (let ((data (and after-article (gnus-data-find-list after-article)))
3175 (ilist list))
6748645f
LMI
3176 (if (not (or data
3177 after-article))
3178 (let ((odata gnus-newsgroup-data))
3179 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 3180 (when offset
6748645f 3181 (gnus-data-update-list odata offset)))
01c52d31 3182 ;; Find the last element in the list to be spliced into the main
6748645f 3183 ;; list.
01c52d31 3184 (setq list (last list))
6748645f
LMI
3185 (if (not data)
3186 (progn
3187 (setcdr list gnus-newsgroup-data)
3188 (setq gnus-newsgroup-data ilist)
3189 (when offset
3190 (gnus-data-update-list (cdr list) offset)))
3191 (setcdr list (cdr data))
3192 (setcdr data ilist)
3193 (when offset
3194 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
3195 (setq gnus-newsgroup-data-reverse nil))))
3196
3197(defun gnus-data-remove (article &optional offset)
3198 (let ((data gnus-newsgroup-data))
3199 (if (= (gnus-data-number (car data)) article)
3200 (progn
3201 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3202 gnus-newsgroup-data-reverse nil)
3203 (when offset
3204 (gnus-data-update-list gnus-newsgroup-data offset)))
3205 (while (cdr data)
3206 (when (= (gnus-data-number (cadr data)) article)
3207 (setcdr data (cddr data))
3208 (when offset
3209 (gnus-data-update-list (cdr data) offset))
3210 (setq data nil
3211 gnus-newsgroup-data-reverse nil))
3212 (setq data (cdr data))))))
3213
3214(defmacro gnus-data-list (backward)
3215 `(if ,backward
3216 (or gnus-newsgroup-data-reverse
3217 (setq gnus-newsgroup-data-reverse
3218 (reverse gnus-newsgroup-data)))
3219 gnus-newsgroup-data))
3220
3221(defun gnus-data-update-list (data offset)
3222 "Add OFFSET to the POS of all data entries in DATA."
6748645f 3223 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
3224 (while data
3225 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3226 (setq data (cdr data))))
3227
eec82323
LMI
3228(defun gnus-summary-article-pseudo-p (article)
3229 "Say whether this article is a pseudo article or not."
3230 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3231
3232(defmacro gnus-summary-article-sparse-p (article)
3233 "Say whether this article is a sparse article or not."
a8151ef7 3234 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
3235
3236(defmacro gnus-summary-article-ancient-p (article)
3237 "Say whether this article is a sparse article or not."
3238 `(memq ,article gnus-newsgroup-ancient))
3239
3240(defun gnus-article-parent-p (number)
3241 "Say whether this article is a parent or not."
3242 (let ((data (gnus-data-find-list number)))
23f87bed 3243 (and (cdr data) ; There has to be an article after...
eec82323
LMI
3244 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3245 (gnus-data-level (nth 1 data))))))
3246
3247(defun gnus-article-children (number)
3248 "Return a list of all children to NUMBER."
3249 (let* ((data (gnus-data-find-list number))
3250 (level (gnus-data-level (car data)))
3251 children)
3252 (setq data (cdr data))
3253 (while (and data
3254 (= (gnus-data-level (car data)) (1+ level)))
3255 (push (gnus-data-number (car data)) children)
3256 (setq data (cdr data)))
3257 children))
3258
3259(defmacro gnus-summary-skip-intangible ()
3260 "If the current article is intangible, then jump to a different article."
3261 '(let ((to (get-text-property (point) 'gnus-intangible)))
3262 (and to (gnus-summary-goto-subject to))))
3263
3264(defmacro gnus-summary-article-intangible-p ()
3265 "Say whether this article is intangible or not."
3266 '(get-text-property (point) 'gnus-intangible))
3267
3268(defun gnus-article-read-p (article)
3269 "Say whether ARTICLE is read or not."
3270 (not (or (memq article gnus-newsgroup-marked)
23f87bed 3271 (memq article gnus-newsgroup-spam-marked)
eec82323
LMI
3272 (memq article gnus-newsgroup-unreads)
3273 (memq article gnus-newsgroup-unselected)
3274 (memq article gnus-newsgroup-dormant))))
3275
3276;; Some summary mode macros.
3277
3278(defmacro gnus-summary-article-number ()
3279 "The article number of the article on the current line.
8f688cb0 3280If there isn't an article number here, then we return the current
eec82323
LMI
3281article number."
3282 '(progn
3283 (gnus-summary-skip-intangible)
3284 (or (get-text-property (point) 'gnus-number)
3285 (gnus-summary-last-subject))))
3286
3287(defmacro gnus-summary-article-header (&optional number)
6748645f 3288 "Return the header of article NUMBER."
eec82323
LMI
3289 `(gnus-data-header (gnus-data-find
3290 ,(or number '(gnus-summary-article-number)))))
3291
3292(defmacro gnus-summary-thread-level (&optional number)
6748645f 3293 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
3294 `(if (and (eq gnus-summary-make-false-root 'dummy)
3295 (get-text-property (point) 'gnus-intangible))
3296 0
3297 (gnus-data-level (gnus-data-find
3298 ,(or number '(gnus-summary-article-number))))))
3299
3300(defmacro gnus-summary-article-mark (&optional number)
6748645f 3301 "Return the mark of article NUMBER."
eec82323
LMI
3302 `(gnus-data-mark (gnus-data-find
3303 ,(or number '(gnus-summary-article-number)))))
3304
3305(defmacro gnus-summary-article-pos (&optional number)
6748645f 3306 "Return the position of the line of article NUMBER."
eec82323
LMI
3307 `(gnus-data-pos (gnus-data-find
3308 ,(or number '(gnus-summary-article-number)))))
3309
3310(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3311(defmacro gnus-summary-article-subject (&optional number)
3312 "Return current subject string or nil if nothing."
3313 `(let ((headers
3314 ,(if number
3315 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3316 '(gnus-data-header (assq (gnus-summary-article-number)
3317 gnus-newsgroup-data)))))
3318 (and headers
3319 (vectorp headers)
3320 (mail-header-subject headers))))
3321
3322(defmacro gnus-summary-article-score (&optional number)
3323 "Return current article score."
3324 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3325 gnus-newsgroup-scored))
3326 gnus-summary-default-score 0))
3327
3328(defun gnus-summary-article-children (&optional number)
6748645f 3329 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
3330 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3331 (level (gnus-data-level (car data)))
3332 l children)
3333 (while (and (setq data (cdr data))
3334 (> (setq l (gnus-data-level (car data))) level))
3335 (and (= (1+ level) l)
3336 (push (gnus-data-number (car data))
3337 children)))
3338 (nreverse children)))
3339
3340(defun gnus-summary-article-parent (&optional number)
6748645f 3341 "Return the article number of the parent of article NUMBER."
eec82323
LMI
3342 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3343 (gnus-data-list t)))
3344 (level (gnus-data-level (car data))))
3345 (if (zerop level)
3346 () ; This is a root.
3347 ;; We search until we find an article with a level less than
3348 ;; this one. That function has to be the parent.
3349 (while (and (setq data (cdr data))
3350 (not (< (gnus-data-level (car data)) level))))
3351 (and data (gnus-data-number (car data))))))
3352
3353(defun gnus-unread-mark-p (mark)
3354 "Say whether MARK is the unread mark."
3355 (= mark gnus-unread-mark))
3356
3357(defun gnus-read-mark-p (mark)
3358 "Say whether MARK is one of the marks that mark as read.
3359This is all marks except unread, ticked, dormant, and expirable."
3360 (not (or (= mark gnus-unread-mark)
3361 (= mark gnus-ticked-mark)
23f87bed 3362 (= mark gnus-spam-mark)
eec82323
LMI
3363 (= mark gnus-dormant-mark)
3364 (= mark gnus-expirable-mark))))
3365
3366(defmacro gnus-article-mark (number)
6748645f
LMI
3367 "Return the MARK of article NUMBER.
3368This macro should only be used when computing the mark the \"first\"
3369time; i.e., when generating the summary lines. After that,
3370`gnus-summary-article-mark' should be used to examine the
3371marks of articles."
eec82323 3372 `(cond
6748645f 3373 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
6748645f 3374 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
3375 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3376 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
23f87bed 3377 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
eec82323
LMI
3378 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3379 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3380 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3381 gnus-ancient-mark))))
3382
3383;; Saving hidden threads.
3384
eec82323
LMI
3385(defmacro gnus-save-hidden-threads (&rest forms)
3386 "Save hidden threads, eval FORMS, and restore the hidden threads."
3387 (let ((config (make-symbol "config")))
3388 `(let ((,config (gnus-hidden-threads-configuration)))
3389 (unwind-protect
3390 (save-excursion
3391 ,@forms)
3392 (gnus-restore-hidden-threads-configuration ,config)))))
23f87bed
MB
3393(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3394(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
eec82323 3395
107ecebb
AS
3396(defun gnus-data-compute-positions ()
3397 "Compute the positions of all articles."
3398 (setq gnus-newsgroup-data-reverse nil)
3399 (let ((data gnus-newsgroup-data))
3400 (save-excursion
3401 (gnus-save-hidden-threads
3402 (gnus-summary-show-all-threads)
3403 (goto-char (point-min))
3404 (while data
3405 (while (get-text-property (point) 'gnus-intangible)
3406 (forward-line 1))
3407 (gnus-data-set-pos (car data) (+ (point) 3))
3408 (setq data (cdr data))
3409 (forward-line 1))))))
3410
16409b0b
GM
3411(defun gnus-hidden-threads-configuration ()
3412 "Return the current hidden threads configuration."
3413 (save-excursion
3414 (let (config)
3415 (goto-char (point-min))
3416 (while (search-forward "\r" nil t)
3417 (push (1- (point)) config))
3418 config)))
3419
3420(defun gnus-restore-hidden-threads-configuration (config)
3421 "Restore hidden threads configuration from CONFIG."
3422 (save-excursion
c7a91ce1 3423 (let (point (inhibit-read-only t))
16409b0b
GM
3424 (while (setq point (pop config))
3425 (when (and (< point (point-max))
3426 (goto-char point)
3427 (eq (char-after) ?\n))
3428 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3429
eec82323
LMI
3430;; Various summary mode internalish functions.
3431
3432(defun gnus-mouse-pick-article (e)
3433 (interactive "e")
3434 (mouse-set-point e)
3435 (gnus-summary-next-page nil t))
3436
3437(defun gnus-summary-set-display-table ()
16409b0b
GM
3438 "Change the display table.
3439Odd characters have a tendency to mess
3440up nicely formatted displays - we make all possible glyphs
3441display only a single character."
eec82323
LMI
3442
3443 ;; We start from the standard display table, if any.
3444 (let ((table (or (copy-sequence standard-display-table)
3445 (make-display-table)))
3446 (i 32))
3447 ;; Nix out all the control chars...
3448 (while (>= (setq i (1- i)) 0)
2b968687 3449 (gnus-put-display-table i [??] table))
23f87bed 3450 ;; ... but not newline and cr, of course. (cr is necessary for the
eec82323 3451 ;; selective display).
2b968687
MB
3452 (gnus-put-display-table ?\n nil table)
3453 (gnus-put-display-table ?\r nil table)
6748645f 3454 ;; We keep TAB as well.
2b968687 3455 (gnus-put-display-table ?\t nil table)
719120ef 3456 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
fe62aacc 3457 ;; Emacs 23 (unicode), that are not set already.
719120ef
MB
3458 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3459 160
3460 256)))
eec82323
LMI
3461 (while (>= (setq i (1- i)) 127)
3462 ;; Only modify if the entry is nil.
2b968687
MB
3463 (unless (gnus-get-display-table i table)
3464 (gnus-put-display-table i [??] table))))
eec82323
LMI
3465 (setq buffer-display-table table)))
3466
23f87bed
MB
3467(defun gnus-summary-set-article-display-arrow (pos)
3468 "Update the overlay arrow to point to line at position POS."
e3e955fe
MB
3469 (when gnus-summary-display-arrow
3470 (make-local-variable 'overlay-arrow-position)
3471 (make-local-variable 'overlay-arrow-string)
23f87bed
MB
3472 (save-excursion
3473 (goto-char pos)
3474 (beginning-of-line)
3475 (unless overlay-arrow-position
3476 (setq overlay-arrow-position (make-marker)))
3477 (setq overlay-arrow-string "=>"
3478 overlay-arrow-position (set-marker overlay-arrow-position
3479 (point)
3480 (current-buffer))))))
3481
eec82323
LMI
3482(defun gnus-summary-setup-buffer (group)
3483 "Initialize summary buffer."
23f87bed
MB
3484 (let ((buffer (gnus-summary-buffer-name group))
3485 (dead-name (concat "*Dead Summary "
3486 (gnus-group-decoded-name group) "*")))
3487 ;; If a dead summary buffer exists, we kill it.
3488 (when (gnus-buffer-live-p dead-name)
3489 (gnus-kill-buffer dead-name))
eec82323
LMI
3490 (if (get-buffer buffer)
3491 (progn
3492 (set-buffer buffer)
3493 (setq gnus-summary-buffer (current-buffer))
3494 (not gnus-newsgroup-prepared))
3495 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 3496 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323
LMI
3497 (gnus-summary-mode group)
3498 (when gnus-carpal
3499 (gnus-carpal-setup-buffer 'summary))
01c52d31
MB
3500 (when (gnus-group-quit-config group)
3501 (set (make-local-variable 'gnus-single-article-buffer) nil))
3502 (make-local-variable 'gnus-article-buffer)
3503 (make-local-variable 'gnus-article-current)
3504 (make-local-variable 'gnus-original-article-buffer)
eec82323 3505 (setq gnus-newsgroup-name group)
23f87bed
MB
3506 ;; Set any local variables in the group parameters.
3507 (gnus-summary-set-local-parameters gnus-newsgroup-name)
eec82323
LMI
3508 t)))
3509
3510(defun gnus-set-global-variables ()
16409b0b
GM
3511 "Set the global equivalents of the buffer-local variables.
3512They are set to the latest values they had. These reflect the summary
3513buffer that was in action when the last article was fetched."
eec82323
LMI
3514 (when (eq major-mode 'gnus-summary-mode)
3515 (setq gnus-summary-buffer (current-buffer))
3516 (let ((name gnus-newsgroup-name)
3517 (marked gnus-newsgroup-marked)
23f87bed 3518 (spam gnus-newsgroup-spam-marked)
eec82323
LMI
3519 (unread gnus-newsgroup-unreads)
3520 (headers gnus-current-headers)
3521 (data gnus-newsgroup-data)
3522 (summary gnus-summary-buffer)
3523 (article-buffer gnus-article-buffer)
3524 (original gnus-original-article-buffer)
3525 (gac gnus-article-current)
3526 (reffed gnus-reffed-article-number)
16409b0b 3527 (score-file gnus-current-score-file)
23f87bed
MB
3528 (default-charset gnus-newsgroup-charset)
3529 vlist)
3530 (let ((locals gnus-newsgroup-variables))
3531 (while locals
3532 (if (consp (car locals))
3533 (push (eval (caar locals)) vlist)
3534 (push (eval (car locals)) vlist))
3535 (setq locals (cdr locals)))
3536 (setq vlist (nreverse vlist)))
01c52d31 3537 (with-current-buffer gnus-group-buffer
6748645f
LMI
3538 (setq gnus-newsgroup-name name
3539 gnus-newsgroup-marked marked
23f87bed 3540 gnus-newsgroup-spam-marked spam
6748645f
LMI
3541 gnus-newsgroup-unreads unread
3542 gnus-current-headers headers
3543 gnus-newsgroup-data data
3544 gnus-article-current gac
3545 gnus-summary-buffer summary
3546 gnus-article-buffer article-buffer
3547 gnus-original-article-buffer original
3548 gnus-reffed-article-number reffed
16409b0b
GM
3549 gnus-current-score-file score-file
3550 gnus-newsgroup-charset default-charset)
23f87bed
MB
3551 (let ((locals gnus-newsgroup-variables))
3552 (while locals
3553 (if (consp (car locals))
3554 (set (caar locals) (pop vlist))
3555 (set (car locals) (pop vlist)))
3556 (setq locals (cdr locals))))
eec82323
LMI
3557 ;; The article buffer also has local variables.
3558 (when (gnus-buffer-live-p gnus-article-buffer)
3559 (set-buffer gnus-article-buffer)
3560 (setq gnus-summary-buffer summary))))))
3561
3562(defun gnus-summary-article-unread-p (article)
3563 "Say whether ARTICLE is unread or not."
3564 (memq article gnus-newsgroup-unreads))
3565
3566(defun gnus-summary-first-article-p (&optional article)
3567 "Return whether ARTICLE is the first article in the buffer."
3568 (if (not (setq article (or article (gnus-summary-article-number))))
3569 nil
3570 (eq article (caar gnus-newsgroup-data))))
3571
3572(defun gnus-summary-last-article-p (&optional article)
3573 "Return whether ARTICLE is the last article in the buffer."
3574 (if (not (setq article (or article (gnus-summary-article-number))))
16409b0b
GM
3575 ;; All non-existent numbers are the last article. :-)
3576 t
eec82323
LMI
3577 (not (cdr (gnus-data-find-list article)))))
3578
4921bbdd
CY
3579(defun gnus-make-thread-indent-array (&optional n)
3580 (when (or n
3581 (progn (setq n 200) nil)
3582 (null gnus-thread-indent-array)
3583 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3584 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3585 gnus-thread-indent-array-level gnus-thread-indent-level)
3586 (while (>= n 0)
3587 (aset gnus-thread-indent-array n
6a30c01d 3588 (make-string (* n gnus-thread-indent-level) ? ))
4921bbdd 3589 (setq n (1- n)))))
eec82323
LMI
3590
3591(defun gnus-update-summary-mark-positions ()
3592 "Compute where the summary marks are to go."
3593 (save-excursion
6748645f 3594 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3595 (set-buffer gnus-summary-buffer))
5153a47a
MB
3596 (let ((spec gnus-summary-line-format-spec)
3597 pos)
eec82323
LMI
3598 (save-excursion
3599 (gnus-set-work-buffer)
5153a47a
MB
3600 (let ((gnus-tmp-unread ?Z)
3601 (gnus-replied-mark ?Z)
3602 (gnus-score-below-mark ?Z)
3603 (gnus-score-over-mark ?Z)
3604 (gnus-undownloaded-mark ?Z)
3605 (gnus-summary-line-format-spec spec)
54506618 3606 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3607 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3608 case-fold-search ignores)
3609 ;; Here, all marks are bound to Z.
3610 (gnus-summary-insert-line header
3611 0 nil t gnus-tmp-unread t nil "" nil 1)
3612 (goto-char (point-min))
3613 ;; Memorize the positions of the same characters as dummy marks.
3614 (while (re-search-forward "[A-D]" nil t)
3615 (push (point) ignores))
54506618 3616 (erase-buffer)
5153a47a
MB
3617 ;; We use A-D as dummy marks in order to know column positions
3618 ;; where marks should be inserted.
3619 (setq gnus-tmp-unread ?A
3620 gnus-replied-mark ?B
3621 gnus-score-below-mark ?C
3622 gnus-score-over-mark ?C
3623 gnus-undownloaded-mark ?D)
3624 (gnus-summary-insert-line header
3625 0 nil t gnus-tmp-unread t nil "" nil 1)
3626 ;; Ignore characters which aren't dummy marks.
3627 (dolist (p ignores)
3628 (delete-region (goto-char (1- p)) p)
3629 (insert ?Z))
eec82323 3630 (goto-char (point-min))
7c3bb5a5 3631 (setq pos (list (cons 'unread
5153a47a 3632 (and (search-forward "A" nil t)
7c3bb5a5 3633 (- (point) (point-min) 1)))))
eec82323 3634 (goto-char (point-min))
5153a47a 3635 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3636 (- (point) (point-min) 1)))
eec82323
LMI
3637 pos)
3638 (goto-char (point-min))
5153a47a 3639 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3640 (- (point) (point-min) 1)))
6748645f
LMI
3641 pos)
3642 (goto-char (point-min))
5153a47a 3643 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3644 (- (point) (point-min) 1)))
eec82323
LMI
3645 pos)))
3646 (setq gnus-summary-mark-positions pos))))
3647
3648(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3649 "Insert a dummy root in the summary buffer."
3650 (beginning-of-line)
3651 (gnus-add-text-properties
3652 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3653 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3654
23f87bed
MB
3655(defun gnus-summary-extract-address-component (from)
3656 (or (car (funcall gnus-extract-address-components from))
3657 from))
3658
3659(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3660 (let ((mail-parse-charset gnus-newsgroup-charset)
01c52d31 3661 (ignored-from-addresses (gnus-ignored-from-addresses))
23f87bed
MB
3662 ; Is it really necessary to do this next part for each summary line?
3663 ; Luckily, doesn't seem to slow things down much.
16409b0b 3664 (mail-parse-ignored-charsets
01c52d31
MB
3665 (with-current-buffer gnus-summary-buffer
3666 gnus-newsgroup-ignored-charsets)))
23f87bed 3667 (or
01c52d31
MB
3668 (and ignored-from-addresses
3669 (string-match ignored-from-addresses gnus-tmp-from)
23f87bed
MB
3670 (let ((extra-headers (mail-header-extra header))
3671 to
3672 newsgroups)
3673 (cond
3674 ((setq to (cdr (assq 'To extra-headers)))
01c52d31 3675 (concat gnus-summary-to-prefix
23f87bed
MB
3676 (inline
3677 (gnus-summary-extract-address-component
343d6628 3678 (funcall gnus-decode-encoded-address-function to)))))
01c52d31
MB
3679 ((setq newsgroups
3680 (or
3681 (cdr (assq 'Newsgroups extra-headers))
3682 (and
3683 (memq 'Newsgroups gnus-extra-headers)
3684 (eq (car (gnus-find-method-for-group
3685 gnus-newsgroup-name)) 'nntp)
3686 (gnus-group-real-name gnus-newsgroup-name))))
3687 (concat gnus-summary-newsgroup-prefix newsgroups)))))
23f87bed 3688 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3689
eec82323
LMI
3690(defun gnus-summary-insert-line (gnus-tmp-header
3691 gnus-tmp-level gnus-tmp-current
23f87bed 3692 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3693 gnus-tmp-expirable gnus-tmp-subject-or-nil
3694 &optional gnus-tmp-dummy gnus-tmp-score
3695 gnus-tmp-process)
4921bbdd
CY
3696 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3697 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3698 gnus-tmp-level)))
eec82323
LMI
3699 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3700 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3701 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3702 (gnus-tmp-score-char
3703 (if (or (null gnus-summary-default-score)
3704 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3705 gnus-summary-zcore-fuzz))
23f87bed 3706 ? ;Whitespace
eec82323
LMI
3707 (if (< gnus-tmp-score gnus-summary-default-score)
3708 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3709 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3710 (gnus-tmp-replied
3711 (cond (gnus-tmp-process gnus-process-mark)
3712 ((memq gnus-tmp-current gnus-newsgroup-cached)
3713 gnus-cached-mark)
3714 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3715 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3716 gnus-forwarded-mark)
eec82323
LMI
3717 ((memq gnus-tmp-current gnus-newsgroup-saved)
3718 gnus-saved-mark)
23f87bed
MB
3719 ((memq gnus-tmp-number gnus-newsgroup-recent)
3720 gnus-recent-mark)
3721 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3722 gnus-unseen-mark)
3723 (t gnus-no-mark)))
3724 (gnus-tmp-downloaded
3725 (cond (undownloaded
3726 gnus-undownloaded-mark)
3727 (gnus-newsgroup-agentized
3728 gnus-downloaded-mark)
3729 (t
3730 gnus-no-mark)))
eec82323
LMI
3731 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3732 (gnus-tmp-name
3733 (cond
3734 ((string-match "<[^>]+> *$" gnus-tmp-from)
3735 (let ((beg (match-beginning 0)))
23f87bed
MB
3736 (or (and (string-match "^\".+\"" gnus-tmp-from)
3737 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3738 (substring gnus-tmp-from 0 beg))))
3739 ((string-match "(.+)" gnus-tmp-from)
3740 (substring gnus-tmp-from
3741 (1+ (match-beginning 0)) (1- (match-end 0))))
3742 (t gnus-tmp-from)))
3743 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3744 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3745 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
c7a91ce1 3746 (inhibit-read-only t))
eec82323
LMI
3747 (when (string= gnus-tmp-name "")
3748 (setq gnus-tmp-name gnus-tmp-from))
3749 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3750 (setq gnus-tmp-lines -1))
3751 (if (= gnus-tmp-lines -1)
3752 (setq gnus-tmp-lines "?")
3753 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
64763fe3
MB
3754 (condition-case ()
3755 (gnus-put-text-property
3756 (point)
3757 (progn (eval gnus-summary-line-format-spec) (point))
3758 'gnus-number gnus-tmp-number)
3759 (error (gnus-message 5 "Error updating the summary line")))
eec82323
LMI
3760 (when (gnus-visual-p 'summary-highlight 'highlight)
3761 (forward-line -1)
6748645f 3762 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3763 (forward-line 1))))
3764
3765(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3766 "Update summary line after change."
eec82323
LMI
3767 (when (and gnus-summary-default-score
3768 (not gnus-summary-inhibit-highlight))
3769 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3770 (article (gnus-summary-article-number))
3771 (score (gnus-summary-article-score article)))
3772 (unless dont-update
3773 (if (and gnus-summary-mark-below
3774 (< (gnus-summary-article-score)
3775 gnus-summary-mark-below))
3776 ;; This article has a low score, so we mark it as read.
3777 (when (memq article gnus-newsgroup-unreads)
3778 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3779 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3780 ;; This article was previously marked as read on account
3781 ;; of a low score, but now it has risen, so we mark it as
3782 ;; unread.
3783 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3784 (gnus-summary-update-mark
3785 (if (or (null gnus-summary-default-score)
3786 (<= (abs (- score gnus-summary-default-score))
3787 gnus-summary-zcore-fuzz))
23f87bed 3788 ? ;Whitespace
eec82323
LMI
3789 (if (< score gnus-summary-default-score)
3790 gnus-score-below-mark gnus-score-over-mark))
3791 'score))
3792 ;; Do visual highlighting.
3793 (when (gnus-visual-p 'summary-highlight 'highlight)
6748645f 3794 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3795
3796(defvar gnus-tmp-new-adopts nil)
3797
3798(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3799 "Return the number of articles in THREAD.
3800This may be 0 in some cases -- if none of the articles in
3801the thread are to be displayed."
3802 (let* ((number
23f87bed 3803 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3804 (cond
3805 ((not (listp thread))
3806 1)
3807 ((and (consp thread) (cdr thread))
3808 (apply
3809 '+ 1 (mapcar
3810 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3811 ((null thread)
3812 1)
3813 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3814 1)
3815 (t 0))))
3816 (when (and level (zerop level) gnus-tmp-new-adopts)
3817 (incf number
3818 (apply '+ (mapcar
3819 'gnus-summary-number-of-articles-in-thread
3820 gnus-tmp-new-adopts))))
3821 (if char
3822 (if (> number 1) gnus-not-empty-thread-mark
3823 gnus-empty-thread-mark)
3824 number)))
3825
23f87bed
MB
3826(defsubst gnus-summary-line-message-size (head)
3827 "Return pretty-printed version of message size.
3828This function is intended to be used in
3829`gnus-summary-line-format-alist'."
3830 (let ((c (or (mail-header-chars head) -1)))
3831 (cond ((< c 0) "n/a") ; chars not available
3832 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3833 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3834 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3835 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3836
3837
eec82323
LMI
3838(defun gnus-summary-set-local-parameters (group)
3839 "Go through the local params of GROUP and set all variable specs in that list."
01c52d31
MB
3840 (let ((vars '(quit-config))) ; Ignore quit-config.
3841 (dolist (elem (gnus-group-find-parameter group))
eec82323
LMI
3842 (and (consp elem) ; Has to be a cons.
3843 (consp (cdr elem)) ; The cdr has to be a list.
3844 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3845 (not (memq (car elem) vars))
e3e955fe 3846 (ignore-errors
23f87bed 3847 (push (car elem) vars)
e3e955fe
MB
3848 ;; Variables like `gnus-show-threads' that are globally
3849 ;; bound, if used as group parameters, need to get to be
3850 ;; buffer-local, whereas just parameters like `gcc-self',
3851 ;; `timestamp', etc. should not be bound as variables.
3852 (if (boundp (car elem))
3853 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3854 (eval (nth 1 elem))))))))
eec82323
LMI
3855
3856(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3857 kill-buffer no-display backward
3858 select-articles)
eec82323
LMI
3859 "Start reading news in newsgroup GROUP.
3860If SHOW-ALL is non-nil, already read articles are also listed.
3861If NO-ARTICLE is non-nil, no article is selected initially.
3862If NO-DISPLAY, don't generate a summary buffer."
3863 (let (result)
3864 (while (and group
3865 (null (setq result
3866 (let ((gnus-auto-select-next nil))
6748645f
LMI
3867 (or (gnus-summary-read-group-1
3868 group show-all no-article
3869 kill-buffer no-display
3870 select-articles)
3871 (setq show-all nil
16409b0b 3872 select-articles nil)))))
eec82323
LMI
3873 (eq gnus-auto-select-next 'quietly))
3874 (set-buffer gnus-group-buffer)
6748645f
LMI
3875 ;; The entry function called above goes to the next
3876 ;; group automatically, so we go two groups back
3877 ;; if we are searching for the previous group.
3878 (when backward
3879 (gnus-group-prev-unread-group 2))
eec82323
LMI
3880 (if (not (equal group (gnus-group-group-name)))
3881 (setq group (gnus-group-group-name))
3882 (setq group nil)))
3883 result))
3884
3885(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3886 kill-buffer no-display
3887 &optional select-articles)
eec82323 3888 ;; Killed foreign groups can't be entered.
23f87bed
MB
3889 ;; (when (and (not (gnus-group-native-p group))
3890 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3891 ;; (error "Dead non-native groups can't be entered"))
3892 (gnus-message 5 "Retrieving newsgroup: %s..."
3893 (gnus-group-decoded-name group))
eec82323
LMI
3894 (let* ((new-group (gnus-summary-setup-buffer group))
3895 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3896 (did-select (and new-group (gnus-select-newsgroup
3897 group show-all select-articles))))
eec82323
LMI
3898 (cond
3899 ;; This summary buffer exists already, so we just select it.
3900 ((not new-group)
3901 (gnus-set-global-variables)
3902 (when kill-buffer
3903 (gnus-kill-or-deaden-summary kill-buffer))
3904 (gnus-configure-windows 'summary 'force)
3905 (gnus-set-mode-line 'summary)
3906 (gnus-summary-position-point)
3907 (message "")
3908 t)
3909 ;; We couldn't select this group.
3910 ((null did-select)
3911 (when (and (eq major-mode 'gnus-summary-mode)
3912 (not (equal (current-buffer) kill-buffer)))
3913 (kill-buffer (current-buffer))
3914 (if (not quit-config)
3915 (progn
6748645f
LMI
3916 ;; Update the info -- marks might need to be removed,
3917 ;; for instance.
3918 (gnus-summary-update-info)
eec82323
LMI
3919 (set-buffer gnus-group-buffer)
3920 (gnus-group-jump-to-group group)
3921 (gnus-group-next-unread-group 1))
3922 (gnus-handle-ephemeral-exit quit-config)))
23f87bed
MB
3923 (let ((grpinfo (gnus-get-info group)))
3924 (if (null (gnus-info-read grpinfo))
3925 (gnus-message 3 "Group %s contains no messages"
3926 (gnus-group-decoded-name group))
3927 (gnus-message 3 "Can't select group")))
eec82323
LMI
3928 nil)
3929 ;; The user did a `C-g' while prompting for number of articles,
3930 ;; so we exit this group.
3931 ((eq did-select 'quit)
3932 (and (eq major-mode 'gnus-summary-mode)
3933 (not (equal (current-buffer) kill-buffer))
3934 (kill-buffer (current-buffer)))
3935 (when kill-buffer
3936 (gnus-kill-or-deaden-summary kill-buffer))
3937 (if (not quit-config)
3938 (progn
3939 (set-buffer gnus-group-buffer)
3940 (gnus-group-jump-to-group group)
3941 (gnus-group-next-unread-group 1)
3942 (gnus-configure-windows 'group 'force))
3943 (gnus-handle-ephemeral-exit quit-config))
3944 ;; Finally signal the quit.
3945 (signal 'quit nil))
3946 ;; The group was successfully selected.
3947 (t
3948 (gnus-set-global-variables)
3949 ;; Save the active value in effect when the group was entered.
3950 (setq gnus-newsgroup-active
3951 (gnus-copy-sequence
3952 (gnus-active gnus-newsgroup-name)))
3953 ;; You can change the summary buffer in some way with this hook.
6748645f 3954 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
3955 (when (memq 'summary (gnus-update-format-specifications
3956 nil 'summary 'summary-mode 'summary-dummy))
3957 ;; The format specification for the summary line was updated,
3958 ;; so we need to update the mark positions as well.
3959 (gnus-update-summary-mark-positions))
eec82323
LMI
3960 ;; Do score processing.
3961 (when gnus-use-scoring
3962 (gnus-possibly-score-headers))
3963 ;; Check whether to fill in the gaps in the threads.
3964 (when gnus-build-sparse-threads
3965 (gnus-build-sparse-threads))
3966 ;; Find the initial limit.
26c9afc3
MB
3967 (if show-all
3968 (let ((gnus-newsgroup-dormant nil))
eec82323 3969 (gnus-summary-initial-limit show-all))
26c9afc3 3970 (gnus-summary-initial-limit show-all))
eec82323
LMI
3971 ;; Generate the summary buffer.
3972 (unless no-display
3973 (gnus-summary-prepare))
3974 (when gnus-use-trees
3975 (gnus-tree-open group)
3976 (setq gnus-summary-highlight-line-function
3977 'gnus-tree-highlight-article))
3978 ;; If the summary buffer is empty, but there are some low-scored
3979 ;; articles or some excluded dormants, we include these in the
3980 ;; buffer.
3981 (when (and (zerop (buffer-size))
3982 (not no-display))
3983 (cond (gnus-newsgroup-dormant
3984 (gnus-summary-limit-include-dormant))
3985 ((and gnus-newsgroup-scored show-all)
3986 (gnus-summary-limit-include-expunged t))))
3987 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 3988 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
3989 (if (and (zerop (buffer-size))
3990 (not no-display))
3991 (progn
3992 ;; This newsgroup is empty.
3993 (gnus-summary-catchup-and-exit nil t)
3994 (gnus-message 6 "No unread news")
3995 (when kill-buffer
3996 (gnus-kill-or-deaden-summary kill-buffer))
3997 ;; Return nil from this function.
3998 nil)
3999 ;; Hide conversation thread subtrees. We cannot do this in
4000 ;; gnus-summary-prepare-hook since kill processing may not
4001 ;; work with hidden articles.
23f87bed 4002 (gnus-summary-maybe-hide-threads)
6748645f
LMI
4003 (when kill-buffer
4004 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 4005 (gnus-summary-auto-select-subject)
eec82323
LMI
4006 ;; Show first unread article if requested.
4007 (if (and (not no-article)
4008 (not no-display)
4009 gnus-newsgroup-unreads
4010 gnus-auto-select-first)
16409b0b
GM
4011 (progn
4012 (gnus-configure-windows 'summary)
23f87bed
MB
4013 (let ((art (gnus-summary-article-number)))
4014 (unless (and (not gnus-plugged)
4015 (or (memq art gnus-newsgroup-undownloaded)
4016 (memq art gnus-newsgroup-downloadable)))
4017 (gnus-summary-goto-article art))))
4018 ;; Don't select any articles.
eec82323 4019 (gnus-summary-position-point)
6748645f
LMI
4020 (gnus-configure-windows 'summary 'force)
4021 (gnus-set-mode-line 'summary))
23f87bed
MB
4022 (when (and gnus-auto-center-group
4023 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
4024 ;; Gotta use windows, because recenter does weird stuff if
4025 ;; the current buffer ain't the displayed window.
4026 (let ((owin (selected-window)))
4027 (select-window (get-buffer-window gnus-group-buffer t))
4028 (when (gnus-group-goto-group group)
4029 (recenter))
4030 (select-window owin)))
4031 ;; Mark this buffer as "prepared".
4032 (setq gnus-newsgroup-prepared t)
6748645f 4033 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
4034 (unless (gnus-ephemeral-group-p group)
4035 (gnus-group-update-group group))
eec82323
LMI
4036 t)))))
4037
23f87bed
MB
4038(defun gnus-summary-auto-select-subject ()
4039 "Select the subject line on initial group entry."
4040 (goto-char (point-min))
4041 (cond
4042 ((eq gnus-auto-select-subject 'best)
4043 (gnus-summary-best-unread-subject))
4044 ((eq gnus-auto-select-subject 'unread)
4045 (gnus-summary-first-unread-subject))
4046 ((eq gnus-auto-select-subject 'unseen)
4047 (gnus-summary-first-unseen-subject))
4048 ((eq gnus-auto-select-subject 'unseen-or-unread)
4049 (gnus-summary-first-unseen-or-unread-subject))
4050 ((eq gnus-auto-select-subject 'first)
4051 ;; Do nothing.
4052 )
4053 ((functionp gnus-auto-select-subject)
4054 (funcall gnus-auto-select-subject))))
4055
eec82323
LMI
4056(defun gnus-summary-prepare ()
4057 "Generate the summary buffer."
4058 (interactive)
c7a91ce1 4059 (let ((inhibit-read-only t))
eec82323
LMI
4060 (erase-buffer)
4061 (setq gnus-newsgroup-data nil
4062 gnus-newsgroup-data-reverse nil)
6748645f 4063 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
4064 ;; Generate the buffer, either with threads or without.
4065 (when gnus-newsgroup-headers
4066 (gnus-summary-prepare-threads
4067 (if gnus-show-threads
4068 (gnus-sort-gathered-threads
4069 (funcall gnus-summary-thread-gathering-function
4070 (gnus-sort-threads
4071 (gnus-cut-threads (gnus-make-threads)))))
4072 ;; Unthreaded display.
4073 (gnus-sort-articles gnus-newsgroup-headers))))
4074 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4075 ;; Call hooks for modifying summary buffer.
4076 (goto-char (point-min))
6748645f 4077 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
4078
4079(defsubst gnus-general-simplify-subject (subject)
23f87bed 4080 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
4081 (setq subject
4082 (cond
4083 ;; Truncate the subject.
6748645f
LMI
4084 (gnus-simplify-subject-functions
4085 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
4086 ((numberp gnus-summary-gather-subject-limit)
4087 (setq subject (gnus-simplify-subject-re subject))
4088 (if (> (length subject) gnus-summary-gather-subject-limit)
4089 (substring subject 0 gnus-summary-gather-subject-limit)
4090 subject))
4091 ;; Fuzzily simplify it.
4092 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4093 (gnus-simplify-subject-fuzzy subject))
4094 ;; Just remove the leading "Re:".
4095 (t
4096 (gnus-simplify-subject-re subject))))
4097
4098 (if (and gnus-summary-gather-exclude-subject
4099 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 4100 nil ; This article shouldn't be gathered
eec82323
LMI
4101 subject))
4102
4103(defun gnus-summary-simplify-subject-query ()
4104 "Query where the respool algorithm would put this article."
4105 (interactive)
eec82323 4106 (gnus-summary-select-article)
274f1353 4107 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
eec82323
LMI
4108
4109(defun gnus-gather-threads-by-subject (threads)
4110 "Gather threads by looking at Subject headers."
4111 (if (not gnus-summary-make-false-root)
4112 threads
4113 (let ((hashtb (gnus-make-hashtable 1024))
4114 (prev threads)
4115 (result threads)
4116 subject hthread whole-subject)
4117 (while threads
4118 (setq subject (gnus-general-simplify-subject
4119 (setq whole-subject (mail-header-subject
4120 (caar threads)))))
4121 (when subject
4122 (if (setq hthread (gnus-gethash subject hashtb))
4123 (progn
4124 ;; We enter a dummy root into the thread, if we
4125 ;; haven't done that already.
4126 (unless (stringp (caar hthread))
4127 (setcar hthread (list whole-subject (car hthread))))
4128 ;; We add this new gathered thread to this gathered
4129 ;; thread.
4130 (setcdr (car hthread)
4131 (nconc (cdar hthread) (list (car threads))))
4132 ;; Remove it from the list of threads.
4133 (setcdr prev (cdr threads))
4134 (setq threads prev))
4135 ;; Enter this thread into the hash table.
23f87bed
MB
4136 (gnus-sethash subject
4137 (if gnus-summary-make-false-root-always
4138 (progn
4139 ;; If you want a dummy root above all
4140 ;; threads...
4141 (setcar threads (list whole-subject
4142 (car threads)))
4143 threads)
4144 threads)
4145 hashtb)))
eec82323
LMI
4146 (setq prev threads)
4147 (setq threads (cdr threads)))
4148 result)))
4149
4150(defun gnus-gather-threads-by-references (threads)
4151 "Gather threads by looking at References headers."
4152 (let ((idhashtb (gnus-make-hashtable 1024))
4153 (thhashtb (gnus-make-hashtable 1024))
4154 (prev threads)
4155 (result threads)
4156 ids references id gthread gid entered ref)
4157 (while threads
4158 (when (setq references (mail-header-references (caar threads)))
4159 (setq id (mail-header-id (caar threads))
23f87bed 4160 ids (inline (gnus-split-references references))
eec82323
LMI
4161 entered nil)
4162 (while (setq ref (pop ids))
4163 (setq ids (delete ref ids))
4164 (if (not (setq gid (gnus-gethash ref idhashtb)))
4165 (progn
4166 (gnus-sethash ref id idhashtb)
4167 (gnus-sethash id threads thhashtb))
4168 (setq gthread (gnus-gethash gid thhashtb))
4169 (unless entered
4170 ;; We enter a dummy root into the thread, if we
4171 ;; haven't done that already.
4172 (unless (stringp (caar gthread))
4173 (setcar gthread (list (mail-header-subject (caar gthread))
4174 (car gthread))))
4175 ;; We add this new gathered thread to this gathered
4176 ;; thread.
4177 (setcdr (car gthread)
4178 (nconc (cdar gthread) (list (car threads)))))
4179 ;; Add it into the thread hash table.
4180 (gnus-sethash id gthread thhashtb)
4181 (setq entered t)
4182 ;; Remove it from the list of threads.
4183 (setcdr prev (cdr threads))
4184 (setq threads prev))))
4185 (setq prev threads)
4186 (setq threads (cdr threads)))
4187 result))
4188
4189(defun gnus-sort-gathered-threads (threads)
16409b0b 4190 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
4191 (let ((result threads))
4192 (while threads
4193 (when (stringp (caar threads))
4194 (setcdr (car threads)
16409b0b 4195 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
4196 (setq threads (cdr threads)))
4197 result))
4198
4199(defun gnus-thread-loop-p (root thread)
4200 "Say whether ROOT is in THREAD."
4201 (let ((stack (list thread))
4202 (infloop 0)
4203 th)
4204 (while (setq thread (pop stack))
4205 (setq th (cdr thread))
4206 (while (and th
4207 (not (eq (caar th) root)))
4208 (pop th))
4209 (if th
4210 ;; We have found a loop.
4211 (let (ref-dep)
4212 (setcdr thread (delq (car th) (cdr thread)))
4213 (if (boundp (setq ref-dep (intern "none"
4214 gnus-newsgroup-dependencies)))
4215 (setcdr (symbol-value ref-dep)
4216 (nconc (cdr (symbol-value ref-dep))
4217 (list (car th))))
4218 (set ref-dep (list nil (car th))))
4219 (setq infloop 1
4220 stack nil))
4221 ;; Push all the subthreads onto the stack.
4222 (push (cdr thread) stack)))
4223 infloop))
4224
4225(defun gnus-make-threads ()
01ccbb85 4226 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
4227 (let (threads)
4228 (while (catch 'infloop
4229 (mapatoms
4230 (lambda (refs)
4231 ;; Deal with self-referencing References loops.
4232 (when (and (car (symbol-value refs))
4233 (not (zerop
4234 (apply
4235 '+
4236 (mapcar
4237 (lambda (thread)
4238 (gnus-thread-loop-p
4239 (car (symbol-value refs)) thread))
4240 (cdr (symbol-value refs)))))))
4241 (setq threads nil)
4242 (throw 'infloop t))
4243 (unless (car (symbol-value refs))
23f87bed
MB
4244 ;; These threads do not refer back to any other
4245 ;; articles, so they're roots.
eec82323
LMI
4246 (setq threads (append (cdr (symbol-value refs)) threads))))
4247 gnus-newsgroup-dependencies)))
4248 threads))
4249
6748645f 4250;; Build the thread tree.
16409b0b 4251(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4252 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4253
4254If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4255if it was already present.
4256
4257If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4258will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4259Message-IDs will be renamed to a unique Message-ID before being
4260entered.
6748645f
LMI
4261
4262Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4263 (let* ((id (mail-header-id header))
4264 (id-dep (and id (intern id dependencies)))
23f87bed 4265 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4266 ;; Enter this `header' in the `dependencies' table.
4267 (cond
4268 ((not id-dep)
4269 (setq header nil))
4270 ;; The first two cases do the normal part: enter a new `header'
4271 ;; in the `dependencies' table.
4272 ((not (boundp id-dep))
4273 (set id-dep (list header)))
4274 ((null (car (symbol-value id-dep)))
4275 (setcar (symbol-value id-dep) header))
4276
4277 ;; From here the `header' was already present in the
4278 ;; `dependencies' table.
4279 (force-new
4280 ;; Overrides an existing entry;
4281 ;; just set the header part of the entry.
23f87bed
MB
4282 (setcar (symbol-value id-dep) header)
4283 (setq replaced t))
6748645f
LMI
4284
4285 ;; Renames the existing `header' to a unique Message-ID.
4286 ((not gnus-summary-ignore-duplicates)
4287 ;; An article with this Message-ID has already been seen.
4288 ;; We rename the Message-ID.
4289 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4290 (list header))
4291 (mail-header-set-id header id))
4292
4293 ;; The last case ignores an existing entry, except it adds any
4294 ;; additional Xrefs (in case the two articles came from different
4295 ;; servers.
4296 ;; Also sets `header' to `nil' meaning that the `dependencies'
4297 ;; table was *not* modified.
4298 (t
4299 (mail-header-set-xref
4300 (car (symbol-value id-dep))
4301 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4302 "")
4303 (or (mail-header-xref header) "")))
4304 (setq header nil)))
4305
23f87bed
MB
4306 (when (and header (not replaced))
4307 ;; First check that we are not creating a References loop.
4308 (setq parent-id (gnus-parent-id (mail-header-references header)))
4309 (setq ref parent-id)
6748645f
LMI
4310 (while (and ref
4311 (setq ref-dep (intern-soft ref dependencies))
4312 (boundp ref-dep)
4313 (setq ref-header (car (symbol-value ref-dep))))
4314 (if (string= id ref)
4315 ;; Yuk! This is a reference loop. Make the article be a
4316 ;; root article.
4317 (progn
4318 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4319 (setq ref nil)
4320 (setq parent-id nil))
6748645f 4321 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4322 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4323 (if (boundp ref-dep)
4324 (setcdr (symbol-value ref-dep)
4325 (nconc (cdr (symbol-value ref-dep))
4326 (list (symbol-value id-dep))))
4327 (set ref-dep (list nil (symbol-value id-dep)))))
4328 header))
4329
23f87bed
MB
4330(defun gnus-extract-message-id-from-in-reply-to (string)
4331 (if (string-match "<[^>]+>" string)
4332 (substring string (match-beginning 0) (match-end 0))
4333 nil))
4334
eec82323
LMI
4335(defun gnus-build-sparse-threads ()
4336 (let ((headers gnus-newsgroup-headers)
16409b0b 4337 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4338 (gnus-summary-ignore-duplicates t)
eec82323 4339 header references generation relations
6748645f 4340 subject child end new-child date)
eec82323
LMI
4341 ;; First we create an alist of generations/relations, where
4342 ;; generations is how much we trust the relation, and the relation
4343 ;; is parent/child.
4344 (gnus-message 7 "Making sparse threads...")
4345 (save-excursion
4346 (nnheader-set-temp-buffer " *gnus sparse threads*")
4347 (while (setq header (pop headers))
4348 (when (and (setq references (mail-header-references header))
4349 (not (string= references "")))
4350 (insert references)
4351 (setq child (mail-header-id header)
6748645f
LMI
4352 subject (mail-header-subject header)
4353 date (mail-header-date header)
4354 generation 0)
eec82323
LMI
4355 (while (search-backward ">" nil t)
4356 (setq end (1+ (point)))
4357 (when (search-backward "<" nil t)
6748645f 4358 (setq new-child (buffer-substring (point) end))
eec82323 4359 (push (list (incf generation)
6748645f
LMI
4360 child (setq child new-child)
4361 subject date)
eec82323 4362 relations)))
6748645f
LMI
4363 (when child
4364 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4365 (erase-buffer)))
4366 (kill-buffer (current-buffer)))
4367 ;; Sort over trustworthiness.
01c52d31
MB
4368 (dolist (relation (sort relations 'car-less-than-car))
4369 (when (gnus-dependencies-add-header
4370 (make-full-mail-header
4371 gnus-reffed-article-number
4372 (nth 3 relation) "" (or (nth 4 relation) "")
4373 (nth 1 relation)
4374 (or (nth 2 relation) "") 0 0 "")
4375 gnus-newsgroup-dependencies nil)
4376 (push gnus-reffed-article-number gnus-newsgroup-limit)
4377 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4378 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4379 gnus-newsgroup-reads)
4380 (decf gnus-reffed-article-number)))
eec82323
LMI
4381 (gnus-message 7 "Making sparse threads...done")))
4382
4383(defun gnus-build-old-threads ()
4384 ;; Look at all the articles that refer back to old articles, and
4385 ;; fetch the headers for the articles that aren't there. This will
4386 ;; build complete threads - if the roots haven't been expired by the
4387 ;; server, that is.
16409b0b
GM
4388 (let ((mail-parse-charset gnus-newsgroup-charset)
4389 id heads)
eec82323
LMI
4390 (mapatoms
4391 (lambda (refs)
4392 (when (not (car (symbol-value refs)))
4393 (setq heads (cdr (symbol-value refs)))
4394 (while heads
4395 (if (memq (mail-header-number (caar heads))
4396 gnus-newsgroup-dormant)
4397 (setq heads (cdr heads))
4398 (setq id (symbol-name refs))
4399 (while (and (setq id (gnus-build-get-header id))
6748645f 4400 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4401 (setq heads nil)))))
4402 gnus-newsgroup-dependencies)))
4403
23f87bed
MB
4404(defsubst gnus-remove-odd-characters (string)
4405 "Translate STRING into something that doesn't contain weird characters."
4406 (mm-subst-char-in-string
4407 ?\r ?\-
01c52d31 4408 (mm-subst-char-in-string ?\n ?\- string t) t))
23f87bed 4409
6748645f
LMI
4410;; This function has to be called with point after the article number
4411;; on the beginning of the line.
4412(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
01c52d31 4413 (let ((eol (point-at-eol))
6748645f 4414 (buffer (current-buffer))
23f87bed 4415 header references in-reply-to)
6748645f
LMI
4416
4417 ;; overview: [num subject from date id refs chars lines misc]
4418 (unwind-protect
23f87bed 4419 (let (x)
6748645f
LMI
4420 (narrow-to-region (point) eol)
4421 (unless (eobp)
4422 (forward-char))
4423
4424 (setq header
4425 (make-full-mail-header
4426 number ; number
23f87bed
MB
4427 (condition-case () ; subject
4428 (gnus-remove-odd-characters
4429 (funcall gnus-decode-encoded-word-function
4430 (setq x (nnheader-nov-field))))
4431 (error x))
4432 (condition-case () ; from
4433 (gnus-remove-odd-characters
343d6628 4434 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4435 (setq x (nnheader-nov-field))))
4436 (error x))
16409b0b 4437 (nnheader-nov-field) ; date
01c52d31 4438 (nnheader-nov-read-message-id number) ; id
23f87bed 4439 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4440 (nnheader-nov-read-integer) ; chars
4441 (nnheader-nov-read-integer) ; lines
4442 (unless (eobp)
8b93df01
DL
4443 (if (looking-at "Xref: ")
4444 (goto-char (match-end 0)))
4445 (nnheader-nov-field)) ; Xref
16409b0b 4446 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4447
4448 (widen))
4449
23f87bed
MB
4450 (when (and (string= references "")
4451 (setq in-reply-to (mail-header-extra header))
4452 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4453 (mail-header-set-references
4454 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4455
6748645f
LMI
4456 (when gnus-alter-header-function
4457 (funcall gnus-alter-header-function header))
4458 (gnus-dependencies-add-header header dependencies force-new)))
4459
eec82323 4460(defun gnus-build-get-header (id)
16409b0b
GM
4461 "Look through the buffer of NOV lines and find the header to ID.
4462Enter this line into the dependencies hash table, and return
4463the id of the parent article (if any)."
eec82323
LMI
4464 (let ((deps gnus-newsgroup-dependencies)
4465 found header)
4466 (prog1
c7a91ce1 4467 (with-current-buffer nntp-server-buffer
eec82323
LMI
4468 (let ((case-fold-search nil))
4469 (goto-char (point-min))
4470 (while (and (not found)
4471 (search-forward id nil t))
4472 (beginning-of-line)
4473 (setq found (looking-at
4474 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4475 (regexp-quote id))))
4476 (or found (beginning-of-line 2)))
4477 (when found
4478 (beginning-of-line)
4479 (and
4480 (setq header (gnus-nov-parse-line
4481 (read (current-buffer)) deps))
4482 (gnus-parent-id (mail-header-references header))))))
4483 (when header
4484 (let ((number (mail-header-number header)))
4485 (push number gnus-newsgroup-limit)
4486 (push header gnus-newsgroup-headers)
4487 (if (memq number gnus-newsgroup-unselected)
4488 (progn
23f87bed
MB
4489 (setq gnus-newsgroup-unreads
4490 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4491 number))
eec82323
LMI
4492 (setq gnus-newsgroup-unselected
4493 (delq number gnus-newsgroup-unselected)))
4494 (push number gnus-newsgroup-ancient)))))))
4495
6748645f
LMI
4496(defun gnus-build-all-threads ()
4497 "Read all the headers."
4498 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4499 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4500 (dependencies gnus-newsgroup-dependencies)
4501 header article)
c7a91ce1 4502 (with-current-buffer nntp-server-buffer
6748645f
LMI
4503 (let ((case-fold-search nil))
4504 (goto-char (point-min))
4505 (while (not (eobp))
4506 (ignore-errors
4507 (setq article (read (current-buffer))
16409b0b 4508 header (gnus-nov-parse-line article dependencies)))
6748645f 4509 (when header
01c52d31 4510 (with-current-buffer gnus-summary-buffer
6748645f
LMI
4511 (push header gnus-newsgroup-headers)
4512 (if (memq (setq article (mail-header-number header))
4513 gnus-newsgroup-unselected)
4514 (progn
23f87bed
MB
4515 (setq gnus-newsgroup-unreads
4516 (gnus-add-to-sorted-list
4517 gnus-newsgroup-unreads article))
6748645f
LMI
4518 (setq gnus-newsgroup-unselected
4519 (delq article gnus-newsgroup-unselected)))
4520 (push article gnus-newsgroup-ancient)))
4521 (forward-line 1)))))))
4522
eec82323 4523(defun gnus-summary-update-article-line (article header)
23f87bed 4524 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4525 (let* ((id (mail-header-id header))
4526 (thread (gnus-id-to-thread id)))
4527 (unless thread
4528 (error "Article in no thread"))
4529 ;; Update the thread.
4530 (setcar thread header)
4531 (gnus-summary-goto-subject article)
4532 (let* ((datal (gnus-data-find-list article))
4533 (data (car datal))
c7a91ce1 4534 (inhibit-read-only t)
eec82323
LMI
4535 (level (gnus-summary-thread-level)))
4536 (gnus-delete-line)
23f87bed
MB
4537 (let ((inserted (- (point)
4538 (progn
4539 (gnus-summary-insert-line
4540 header level nil
4541 (memq article gnus-newsgroup-undownloaded)
4542 (gnus-article-mark article)
4543 (memq article gnus-newsgroup-replied)
4544 (memq article gnus-newsgroup-expirable)
4545 ;; Only insert the Subject string when it's different
4546 ;; from the previous Subject string.
4547 (if (and
4548 gnus-show-threads
4549 (gnus-subject-equal
4550 (condition-case ()
4551 (mail-header-subject
4552 (gnus-data-header
4553 (cadr
4554 (gnus-data-find-list
4555 article
4556 (gnus-data-list t)))))
4557 ;; Error on the side of excessive subjects.
4558 (error ""))
4559 (mail-header-subject header)))
4560 ""
4561 (mail-header-subject header))
4562 nil (cdr (assq article gnus-newsgroup-scored))
4563 (memq article gnus-newsgroup-processable))
4564 (point)))))
4565 (when (cdr datal)
4566 (gnus-data-update-list
4567 (cdr datal)
4568 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4569
4570(defun gnus-summary-update-article (article &optional iheader)
4571 "Update ARTICLE in the summary buffer."
4572 (set-buffer gnus-summary-buffer)
6748645f 4573 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4574 (id (mail-header-id header))
4575 (data (gnus-data-find article))
4576 (thread (gnus-id-to-thread id))
4577 (references (mail-header-references header))
4578 (parent
4579 (gnus-id-to-thread
4580 (or (gnus-parent-id
4581 (when (and references
4582 (not (equal "" references)))
4583 references))
4584 "none")))
c7a91ce1 4585 (inhibit-read-only t)
6748645f 4586 (old (car thread)))
eec82323 4587 (when thread
eec82323 4588 (unless iheader
6748645f
LMI
4589 (setcar thread nil)
4590 (when parent
4591 (delq thread parent)))
4592 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4593 ;; Set the (possibly) new article number in the data structure.
4594 (gnus-data-set-number data (gnus-id-to-article id))
4595 (setcar thread old)
4596 nil))))
4597
6748645f
LMI
4598(defun gnus-rebuild-thread (id &optional line)
4599 "Rebuild the thread containing ID.
4600If LINE, insert the rebuilt thread starting on line LINE."
c7a91ce1 4601 (let ((inhibit-read-only t)
eec82323
LMI
4602 old-pos current thread data)
4603 (if (not gnus-show-threads)
4604 (setq thread (list (car (gnus-id-to-thread id))))
4605 ;; Get the thread this article is part of.
4606 (setq thread (gnus-remove-thread id)))
01c52d31 4607 (setq old-pos (point-at-bol))
eec82323 4608 (setq current (save-excursion
94384150 4609 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4610 (gnus-summary-article-number))))
4611 ;; If this is a gathered thread, we have to go some re-gathering.
4612 (when (stringp (car thread))
4613 (let ((subject (car thread))
4614 roots thr)
4615 (setq thread (cdr thread))
4616 (while thread
4617 (unless (memq (setq thr (gnus-id-to-thread
4618 (gnus-root-id
4619 (mail-header-id (caar thread)))))
4620 roots)
4621 (push thr roots))
4622 (setq thread (cdr thread)))
4623 ;; We now have all (unique) roots.
4624 (if (= (length roots) 1)
4625 ;; All the loose roots are now one solid root.
4626 (setq thread (car roots))
4627 (setq thread (cons subject (gnus-sort-threads roots))))))
4628 (let (threads)
4629 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4630 (when line
4631 (goto-char (point-min))
4632 (forward-line (1- line)))
eec82323
LMI
4633 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4634 (if gnus-show-threads
4635 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4636 (gnus-summary-prepare-unthreaded thread))
4637 (setq data (nreverse gnus-newsgroup-data))
4638 (setq threads gnus-newsgroup-threads))
4639 ;; We splice the new data into the data structure.
6748645f
LMI
4640 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4641 ;;!!! then we want to insert at the beginning of the buffer.
4642 ;;!!! That happens to be true with Gnus now, but that may
4643 ;;!!! change in the future. Perhaps.
4644 (gnus-data-enter-list
4645 (if line nil current) data (- (point) old-pos))
4646 (setq gnus-newsgroup-threads
4647 (nconc threads gnus-newsgroup-threads))
4648 (gnus-data-compute-positions))))
eec82323
LMI
4649
4650(defun gnus-number-to-header (number)
4651 "Return the header for article NUMBER."
4652 (let ((headers gnus-newsgroup-headers))
4653 (while (and headers
4654 (not (= number (mail-header-number (car headers)))))
4655 (pop headers))
4656 (when headers
4657 (car headers))))
4658
6748645f 4659(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4660 "Return the headers of the GENERATIONeth parent of HEADERS."
4661 (unless generation
4662 (setq generation 1))
a8151ef7 4663 (let ((parent t)
6748645f 4664 (headers in-headers)
a8151ef7 4665 references)
6748645f
LMI
4666 (while (and parent
4667 (not (zerop generation))
4668 (setq references (mail-header-references headers)))
4669 (setq headers (if (and references
4670 (setq parent (gnus-parent-id references)))
4671 (car (gnus-id-to-thread parent))
4672 nil))
4673 (decf generation))
4674 (and (not (eq headers in-headers))
4675 headers)))
eec82323
LMI
4676
4677(defun gnus-id-to-thread (id)
4678 "Return the (sub-)thread where ID appears."
4679 (gnus-gethash id gnus-newsgroup-dependencies))
4680
4681(defun gnus-id-to-article (id)
4682 "Return the article number of ID."
4683 (let ((thread (gnus-id-to-thread id)))
4684 (when (and thread
4685 (car thread))
4686 (mail-header-number (car thread)))))
4687
4688(defun gnus-id-to-header (id)
4689 "Return the article headers of ID."
4690 (car (gnus-id-to-thread id)))
4691
4692(defun gnus-article-displayed-root-p (article)
4693 "Say whether ARTICLE is a root(ish) article."
4694 (let ((level (gnus-summary-thread-level article))
4695 (refs (mail-header-references (gnus-summary-article-header article)))
4696 particle)
4697 (cond
4698 ((null level) nil)
4699 ((zerop level) t)
4700 ((null refs) t)
4701 ((null (gnus-parent-id refs)) t)
4702 ((and (= 1 level)
4703 (null (setq particle (gnus-id-to-article
4704 (gnus-parent-id refs))))
4705 (null (gnus-summary-thread-level particle)))))))
4706
4707(defun gnus-root-id (id)
4708 "Return the id of the root of the thread where ID appears."
4709 (let (last-id prev)
6748645f 4710 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4711 (setq last-id id
4712 id (gnus-parent-id (mail-header-references prev))))
4713 last-id))
4714
6748645f
LMI
4715(defun gnus-articles-in-thread (thread)
4716 "Return the list of articles in THREAD."
4717 (cons (mail-header-number (car thread))
4718 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4719
eec82323
LMI
4720(defun gnus-remove-thread (id &optional dont-remove)
4721 "Remove the thread that has ID in it."
6748645f 4722 (let (headers thread last-id)
eec82323 4723 ;; First go up in this thread until we find the root.
6748645f
LMI
4724 (setq last-id (gnus-root-id id)
4725 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4726 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4727 ;; been gathered into some loose thread, so we have to search
4728 ;; through the threads to find the thread we wanted.
4729 (let ((threads gnus-newsgroup-threads)
4730 sub)
4731 (while threads
4732 (setq sub (car threads))
4733 (if (stringp (car sub))
4734 ;; This is a gathered thread, so we look at the roots
4735 ;; below it to find whether this article is in this
4736 ;; gathered root.
4737 (progn
4738 (setq sub (cdr sub))
4739 (while sub
4740 (when (member (caar sub) headers)
4741 (setq thread (car threads)
4742 threads nil
4743 sub nil))
4744 (setq sub (cdr sub))))
4745 ;; It's an ordinary thread, so we check it.
4746 (when (eq (car sub) (car headers))
4747 (setq thread sub
4748 threads nil)))
4749 (setq threads (cdr threads)))
4750 ;; If this article is in no thread, then it's a root.
4751 (if thread
4752 (unless dont-remove
4753 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4754 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4755 (when thread
4756 (prog1
4757 thread ; We return this thread.
4758 (unless dont-remove
4759 (if (stringp (car thread))
4760 (progn
4761 ;; If we use dummy roots, then we have to remove the
4762 ;; dummy root as well.
4763 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4764 ;; We go to the dummy root by going to
4765 ;; the first sub-"thread", and then one line up.
4766 (gnus-summary-goto-article
4767 (mail-header-number (caadr thread)))
4768 (forward-line -1)
eec82323
LMI
4769 (gnus-delete-line)
4770 (gnus-data-compute-positions))
4771 (setq thread (cdr thread))
4772 (while thread
4773 (gnus-remove-thread-1 (car thread))
4774 (setq thread (cdr thread))))
4775 (gnus-remove-thread-1 thread))))))))
4776
4777(defun gnus-remove-thread-1 (thread)
4778 "Remove the thread THREAD recursively."
4779 (let ((number (mail-header-number (pop thread)))
4780 d)
4781 (setq thread (reverse thread))
4782 (while thread
4783 (gnus-remove-thread-1 (pop thread)))
4784 (when (setq d (gnus-data-find number))
4785 (goto-char (gnus-data-pos d))
16409b0b 4786 (gnus-summary-show-thread)
eec82323
LMI
4787 (gnus-data-remove
4788 number
01c52d31 4789 (- (point-at-bol)
eec82323 4790 (prog1
01c52d31 4791 (1+ (point-at-eol))
eec82323
LMI
4792 (gnus-delete-line)))))))
4793
4921bbdd 4794(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4795 (sort (mapcar (lambda (thread)
4796 (cons (car thread)
4797 (and (cdr thread)
4921bbdd 4798 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4799 threads) func))
4800
4921bbdd
CY
4801(defun gnus-sort-threads-loop (threads func)
4802 (let* ((superthread (cons nil threads))
4803 (stack (list (cons superthread threads)))
4804 remaining-threads thread)
4805 (while stack
4806 (setq remaining-threads (cdr (car stack)))
4807 (if remaining-threads
4808 (progn (setq thread (car remaining-threads))
4809 (setcdr (car stack) (cdr remaining-threads))
4810 (if (cdr thread)
4811 (push (cons thread (cdr thread)) stack)))
4812 (setq thread (caar stack))
4813 (setcdr thread (sort (cdr thread) func))
4814 (pop stack)))
4815 (cdr superthread)))
4816
eec82323
LMI
4817(defun gnus-sort-threads (threads)
4818 "Sort THREADS."
4819 (if (not gnus-thread-sort-functions)
4820 threads
6748645f 4821 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4822 (prog1
4823 (condition-case nil
4824 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4825 (gnus-sort-threads-recursive
4826 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4827 ;; Even after binding max-lisp-eval-depth, the recursive
4828 ;; sorter might fail for very long threads. In that case,
4829 ;; try using a (less well-tested) non-recursive sorter.
4830 (error (gnus-sort-threads-loop
4831 threads (gnus-make-sort-function
4832 gnus-thread-sort-functions))))
4833 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4834
4835(defun gnus-sort-articles (articles)
4836 "Sort ARTICLES."
4837 (when gnus-article-sort-functions
4838 (gnus-message 7 "Sorting articles...")
4839 (prog1
4840 (setq gnus-newsgroup-headers
4841 (sort articles (gnus-make-sort-function
4842 gnus-article-sort-functions)))
4843 (gnus-message 7 "Sorting articles...done"))))
4844
4845;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4846(defmacro gnus-thread-header (thread)
16409b0b
GM
4847 "Return header of first article in THREAD.
4848Note that THREAD must never, ever be anything else than a variable -
4849using some other form will lead to serious barfage."
eec82323
LMI
4850 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4851 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4852 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4853 (vector thread) 2))
4854
4855(defsubst gnus-article-sort-by-number (h1 h2)
4856 "Sort articles by article number."
4857 (< (mail-header-number h1)
4858 (mail-header-number h2)))
4859
4860(defun gnus-thread-sort-by-number (h1 h2)
4861 "Sort threads by root article number."
4862 (gnus-article-sort-by-number
4863 (gnus-thread-header h1) (gnus-thread-header h2)))
4864
23f87bed 4865(defsubst gnus-article-sort-by-random (h1 h2)
0b6799c3 4866 "Sort articles randomly."
23f87bed
MB
4867 (zerop (random 2)))
4868
4869(defun gnus-thread-sort-by-random (h1 h2)
0b6799c3 4870 "Sort threads randomly."
23f87bed
MB
4871 (gnus-article-sort-by-random
4872 (gnus-thread-header h1) (gnus-thread-header h2)))
4873
eec82323
LMI
4874(defsubst gnus-article-sort-by-lines (h1 h2)
4875 "Sort articles by article Lines header."
4876 (< (mail-header-lines h1)
4877 (mail-header-lines h2)))
4878
4879(defun gnus-thread-sort-by-lines (h1 h2)
4880 "Sort threads by root article Lines header."
4881 (gnus-article-sort-by-lines
4882 (gnus-thread-header h1) (gnus-thread-header h2)))
4883
16409b0b
GM
4884(defsubst gnus-article-sort-by-chars (h1 h2)
4885 "Sort articles by octet length."
4886 (< (mail-header-chars h1)
4887 (mail-header-chars h2)))
4888
4889(defun gnus-thread-sort-by-chars (h1 h2)
4890 "Sort threads by root article octet length."
4891 (gnus-article-sort-by-chars
4892 (gnus-thread-header h1) (gnus-thread-header h2)))
4893
eec82323
LMI
4894(defsubst gnus-article-sort-by-author (h1 h2)
4895 "Sort articles by root author."
b4fde39f 4896 (gnus-string<
eec82323
LMI
4897 (let ((extract (funcall
4898 gnus-extract-address-components
4899 (mail-header-from h1))))
4900 (or (car extract) (cadr extract) ""))
4901 (let ((extract (funcall
4902 gnus-extract-address-components
4903 (mail-header-from h2))))
4904 (or (car extract) (cadr extract) ""))))
4905
4906(defun gnus-thread-sort-by-author (h1 h2)
4907 "Sort threads by root author."
4908 (gnus-article-sort-by-author
4909 (gnus-thread-header h1) (gnus-thread-header h2)))
4910
01c52d31
MB
4911(defsubst gnus-article-sort-by-recipient (h1 h2)
4912 "Sort articles by recipient."
4913 (gnus-string<
4914 (let ((extract (funcall
4915 gnus-extract-address-components
4916 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4917 (or (car extract) (cadr extract)))
4918 (let ((extract (funcall
4919 gnus-extract-address-components
4920 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4921 (or (car extract) (cadr extract)))))
4922
4923(defun gnus-thread-sort-by-recipient (h1 h2)
4924 "Sort threads by root recipient."
4925 (gnus-article-sort-by-recipient
4926 (gnus-thread-header h1) (gnus-thread-header h2)))
4927
eec82323
LMI
4928(defsubst gnus-article-sort-by-subject (h1 h2)
4929 "Sort articles by root subject."
b4fde39f 4930 (gnus-string<
eec82323
LMI
4931 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4932 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4933
4934(defun gnus-thread-sort-by-subject (h1 h2)
4935 "Sort threads by root subject."
4936 (gnus-article-sort-by-subject
4937 (gnus-thread-header h1) (gnus-thread-header h2)))
4938
4939(defsubst gnus-article-sort-by-date (h1 h2)
4940 "Sort articles by root article date."
16409b0b 4941 (time-less-p
eec82323
LMI
4942 (gnus-date-get-time (mail-header-date h1))
4943 (gnus-date-get-time (mail-header-date h2))))
4944
4945(defun gnus-thread-sort-by-date (h1 h2)
4946 "Sort threads by root article date."
4947 (gnus-article-sort-by-date
4948 (gnus-thread-header h1) (gnus-thread-header h2)))
4949
4950(defsubst gnus-article-sort-by-score (h1 h2)
4951 "Sort articles by root article score.
4952Unscored articles will be counted as having a score of zero."
4953 (> (or (cdr (assq (mail-header-number h1)
4954 gnus-newsgroup-scored))
4955 gnus-summary-default-score 0)
4956 (or (cdr (assq (mail-header-number h2)
4957 gnus-newsgroup-scored))
4958 gnus-summary-default-score 0)))
4959
4960(defun gnus-thread-sort-by-score (h1 h2)
4961 "Sort threads by root article score."
4962 (gnus-article-sort-by-score
4963 (gnus-thread-header h1) (gnus-thread-header h2)))
4964
4965(defun gnus-thread-sort-by-total-score (h1 h2)
4966 "Sort threads by the sum of all scores in the thread.
4967Unscored articles will be counted as having a score of zero."
4968 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4969
4970(defun gnus-thread-total-score (thread)
16409b0b 4971 ;; This function find the total score of THREAD.
23f87bed
MB
4972 (cond
4973 ((null thread)
4974 0)
4975 ((consp thread)
4976 (if (stringp (car thread))
4977 (apply gnus-thread-score-function 0
4978 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4979 (gnus-thread-total-score-1 thread)))
4980 (t
4981 (gnus-thread-total-score-1 (list thread)))))
4982
4983(defun gnus-thread-sort-by-most-recent-number (h1 h2)
4984 "Sort threads such that the thread with the most recently arrived article comes first."
4985 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4986
4987(defun gnus-thread-highest-number (thread)
4988 "Return the highest article number in THREAD."
4989 (apply 'max (mapcar (lambda (header)
4990 (mail-header-number header))
4991 (message-flatten-list thread))))
4992
4993(defun gnus-thread-sort-by-most-recent-date (h1 h2)
4994 "Sort threads such that the thread with the most recently dated article comes first."
4995 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4996
4997(defun gnus-thread-latest-date (thread)
4998 "Return the highest article date in THREAD."
4999 (let ((previous-time 0))
5000 (apply 'max
5001 (mapcar
5002 (lambda (header)
5003 (setq previous-time
5004 (condition-case ()
9693d3c4 5005 (gnus-float-time (mail-header-parse-date
23f87bed
MB
5006 (mail-header-date header)))
5007 (error previous-time))))
5008 (sort
5009 (message-flatten-list thread)
5010 (lambda (h1 h2)
5011 (< (mail-header-number h1)
5012 (mail-header-number h2))))))))
eec82323
LMI
5013
5014(defun gnus-thread-total-score-1 (root)
5015 ;; This function find the total score of the thread below ROOT.
5016 (setq root (car root))
5017 (apply gnus-thread-score-function
5018 (or (append
5019 (mapcar 'gnus-thread-total-score
6748645f 5020 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
5021 (when (> (mail-header-number root) 0)
5022 (list (or (cdr (assq (mail-header-number root)
5023 gnus-newsgroup-scored))
5024 gnus-summary-default-score 0))))
5025 (list gnus-summary-default-score)
5026 '(0))))
5027
5028;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5029(defvar gnus-tmp-prev-subject nil)
5030(defvar gnus-tmp-false-parent nil)
5031(defvar gnus-tmp-root-expunged nil)
5032(defvar gnus-tmp-dummy-line nil)
5033
16409b0b
GM
5034(defun gnus-extra-header (type &optional header)
5035 "Return the extra header of TYPE."
5036 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5037 ""))
5038
23f87bed
MB
5039(defvar gnus-tmp-thread-tree-header-string "")
5040
5041(defcustom gnus-sum-thread-tree-root "> "
5042 "With %B spec, used for the root of a thread.
5043If nil, use subject instead."
bf247b6e 5044 :version "22.1"
ad136a7c 5045 :type '(radio (const :format "%v " nil) string)
23f87bed 5046 :group 'gnus-thread)
01c52d31 5047
23f87bed
MB
5048(defcustom gnus-sum-thread-tree-false-root "> "
5049 "With %B spec, used for a false root of a thread.
5050If nil, use subject instead."
bf247b6e 5051 :version "22.1"
ad136a7c 5052 :type '(radio (const :format "%v " nil) string)
23f87bed 5053 :group 'gnus-thread)
01c52d31 5054
23f87bed
MB
5055(defcustom gnus-sum-thread-tree-single-indent ""
5056 "With %B spec, used for a thread with just one message.
5057If nil, use subject instead."
bf247b6e 5058 :version "22.1"
ad136a7c 5059 :type '(radio (const :format "%v " nil) string)
23f87bed 5060 :group 'gnus-thread)
01c52d31 5061
23f87bed
MB
5062(defcustom gnus-sum-thread-tree-vertical "| "
5063 "With %B spec, used for drawing a vertical line."
bf247b6e 5064 :version "22.1"
23f87bed
MB
5065 :type 'string
5066 :group 'gnus-thread)
01c52d31 5067
23f87bed
MB
5068(defcustom gnus-sum-thread-tree-indent " "
5069 "With %B spec, used for indenting."
bf247b6e 5070 :version "22.1"
23f87bed
MB
5071 :type 'string
5072 :group 'gnus-thread)
01c52d31 5073
23f87bed
MB
5074(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5075 "With %B spec, used for a leaf with brothers."
bf247b6e 5076 :version "22.1"
23f87bed
MB
5077 :type 'string
5078 :group 'gnus-thread)
01c52d31 5079
23f87bed
MB
5080(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5081 "With %B spec, used for a leaf without brothers."
bf247b6e 5082 :version "22.1"
23f87bed
MB
5083 :type 'string
5084 :group 'gnus-thread)
5085
1fc34624
GM
5086(defcustom gnus-summary-display-while-building nil
5087 "If non-nil, show and update the summary buffer as it's being built.
5088If the value is t, update the buffer after every line is inserted. If
5089the value is an integer (N), update the display every N lines."
5090 :version "22.1"
5091 :group 'gnus-thread
5092 :type '(choice (const :tag "off" nil)
5093 number
5094 (const :tag "frequently" t)))
5095
eec82323
LMI
5096(defun gnus-summary-prepare-threads (threads)
5097 "Prepare summary buffer from THREADS and indentation LEVEL.
5098THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5099or a straight list of headers."
5100 (gnus-message 7 "Generating summary...")
5101
5102 (setq gnus-newsgroup-threads threads)
5103 (beginning-of-line)
5104
5105 (let ((gnus-tmp-level 0)
5106 (default-score (or gnus-summary-default-score 0))
5107 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
5108 (building-line-count gnus-summary-display-while-building)
5109 (building-count (integerp gnus-summary-display-while-building))
eec82323 5110 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
5111 new-roots gnus-tmp-new-adopts thread-end simp-subject
5112 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
5113 gnus-tmp-replied gnus-tmp-subject-or-nil
5114 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5115 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
5116 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5117 tree-stack)
eec82323 5118
23f87bed
MB
5119 (setq gnus-tmp-prev-subject nil
5120 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
5121
5122 (if (vectorp (car threads))
5123 ;; If this is a straight (sic) list of headers, then a
5124 ;; threaded summary display isn't required, so we just create
5125 ;; an unthreaded one.
5126 (gnus-summary-prepare-unthreaded threads)
5127
5128 ;; Do the threaded display.
5129
23f87bed
MB
5130 (if gnus-summary-display-while-building
5131 (switch-to-buffer (buffer-name)))
eec82323
LMI
5132 (while (or threads stack gnus-tmp-new-adopts new-roots)
5133
5134 (if (and (= gnus-tmp-level 0)
eec82323
LMI
5135 (or (not stack)
5136 (= (caar stack) 0))
5137 (not gnus-tmp-false-parent)
5138 (or gnus-tmp-new-adopts new-roots))
5139 (if gnus-tmp-new-adopts
5140 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5141 thread (list (car gnus-tmp-new-adopts))
5142 gnus-tmp-header (caar thread)
5143 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5144 (when new-roots
5145 (setq thread (list (car new-roots))
5146 gnus-tmp-header (caar thread)
5147 new-roots (cdr new-roots))))
5148
5149 (if threads
5150 ;; If there are some threads, we do them before the
5151 ;; threads on the stack.
5152 (setq thread threads
5153 gnus-tmp-header (caar thread))
5154 ;; There were no current threads, so we pop something off
5155 ;; the stack.
5156 (setq state (car stack)
5157 gnus-tmp-level (car state)
23f87bed
MB
5158 tree-stack (cadr state)
5159 thread (caddr state)
eec82323
LMI
5160 stack (cdr stack)
5161 gnus-tmp-header (caar thread))))
5162
5163 (setq gnus-tmp-false-parent nil)
5164 (setq gnus-tmp-root-expunged nil)
5165 (setq thread-end nil)
5166
5167 (if (stringp gnus-tmp-header)
5168 ;; The header is a dummy root.
5169 (cond
5170 ((eq gnus-summary-make-false-root 'adopt)
5171 ;; We let the first article adopt the rest.
5172 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5173 (cddar thread)))
5174 (setq gnus-tmp-gathered
5175 (nconc (mapcar
5176 (lambda (h) (mail-header-number (car h)))
5177 (cddar thread))
5178 gnus-tmp-gathered))
5179 (setq thread (cons (list (caar thread)
5180 (cadar thread))
5181 (cdr thread)))
5182 (setq gnus-tmp-level -1
5183 gnus-tmp-false-parent t))
5184 ((eq gnus-summary-make-false-root 'empty)
5185 ;; We print adopted articles with empty subject fields.
5186 (setq gnus-tmp-gathered
5187 (nconc (mapcar
5188 (lambda (h) (mail-header-number (car h)))
5189 (cddar thread))
5190 gnus-tmp-gathered))
5191 (setq gnus-tmp-level -1))
5192 ((eq gnus-summary-make-false-root 'dummy)
5193 ;; We remember that we probably want to output a dummy
5194 ;; root.
5195 (setq gnus-tmp-dummy-line gnus-tmp-header)
5196 (setq gnus-tmp-prev-subject gnus-tmp-header))
5197 (t
5198 ;; We do not make a root for the gathered
5199 ;; sub-threads at all.
5200 (setq gnus-tmp-level -1)))
5201
5202 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
5203 subject (mail-header-subject gnus-tmp-header)
5204 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
5205
5206 (cond
5207 ;; If the thread has changed subject, we might want to make
5208 ;; this subthread into a root.
5209 ((and (null gnus-thread-ignore-subject)
5210 (not (zerop gnus-tmp-level))
5211 gnus-tmp-prev-subject
23f87bed 5212 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5213 (setq new-roots (nconc new-roots (list (car thread)))
5214 thread-end t
5215 gnus-tmp-header nil))
5216 ;; If the article lies outside the current limit,
5217 ;; then we do not display it.
5218 ((not (memq number gnus-newsgroup-limit))
5219 (setq gnus-tmp-gathered
5220 (nconc (mapcar
5221 (lambda (h) (mail-header-number (car h)))
5222 (cdar thread))
5223 gnus-tmp-gathered))
5224 (setq gnus-tmp-new-adopts (if (cdar thread)
5225 (append gnus-tmp-new-adopts
5226 (cdar thread))
5227 gnus-tmp-new-adopts)
5228 thread-end t
5229 gnus-tmp-header nil)
5230 (when (zerop gnus-tmp-level)
5231 (setq gnus-tmp-root-expunged t)))
5232 ;; Perhaps this article is to be marked as read?
5233 ((and gnus-summary-mark-below
5234 (< (or (cdr (assq number gnus-newsgroup-scored))
5235 default-score)
5236 gnus-summary-mark-below)
5237 ;; Don't touch sparse articles.
5238 (not (gnus-summary-article-sparse-p number))
5239 (not (gnus-summary-article-ancient-p number)))
5240 (setq gnus-newsgroup-unreads
5241 (delq number gnus-newsgroup-unreads))
5242 (if gnus-newsgroup-auto-expire
23f87bed
MB
5243 (setq gnus-newsgroup-expirable
5244 (gnus-add-to-sorted-list
5245 gnus-newsgroup-expirable number))
eec82323
LMI
5246 (push (cons number gnus-low-score-mark)
5247 gnus-newsgroup-reads))))
5248
5249 (when gnus-tmp-header
5250 ;; We may have an old dummy line to output before this
5251 ;; article.
6748645f
LMI
5252 (when (and gnus-tmp-dummy-line
5253 (gnus-subject-equal
5254 gnus-tmp-dummy-line
5255 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
5256 (gnus-summary-insert-dummy-line
5257 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5258 (setq gnus-tmp-dummy-line nil))
5259
5260 ;; Compute the mark.
5261 (setq gnus-tmp-unread (gnus-article-mark number))
5262
5263 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5264 gnus-tmp-header gnus-tmp-level)
5265 gnus-newsgroup-data)
5266
5267 ;; Actually insert the line.
5268 (setq
5269 gnus-tmp-subject-or-nil
5270 (cond
5271 ((and gnus-thread-ignore-subject
5272 gnus-tmp-prev-subject
23f87bed 5273 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5274 subject)
5275 ((zerop gnus-tmp-level)
5276 (if (and (eq gnus-summary-make-false-root 'empty)
5277 (memq number gnus-tmp-gathered)
5278 gnus-tmp-prev-subject
23f87bed 5279 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5280 gnus-summary-same-subject
5281 subject))
5282 (t gnus-summary-same-subject)))
5283 (if (and (eq gnus-summary-make-false-root 'adopt)
5284 (= gnus-tmp-level 1)
5285 (memq number gnus-tmp-gathered))
5286 (setq gnus-tmp-opening-bracket ?\<
5287 gnus-tmp-closing-bracket ?\>)
5288 (setq gnus-tmp-opening-bracket ?\[
5289 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5290 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5291 (gnus-make-thread-indent-array
5292 (max (* 2 (length gnus-thread-indent-array))
5293 gnus-tmp-level)))
eec82323
LMI
5294 (setq
5295 gnus-tmp-indentation
5296 (aref gnus-thread-indent-array gnus-tmp-level)
5297 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5298 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5299 gnus-summary-default-score 0)
5300 gnus-tmp-score-char
5301 (if (or (null gnus-summary-default-score)
5302 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5303 gnus-summary-zcore-fuzz))
23f87bed 5304 ? ;Whitespace
eec82323
LMI
5305 (if (< gnus-tmp-score gnus-summary-default-score)
5306 gnus-score-below-mark gnus-score-over-mark))
5307 gnus-tmp-replied
5308 (cond ((memq number gnus-newsgroup-processable)
5309 gnus-process-mark)
5310 ((memq number gnus-newsgroup-cached)
5311 gnus-cached-mark)
5312 ((memq number gnus-newsgroup-replied)
5313 gnus-replied-mark)
23f87bed
MB
5314 ((memq number gnus-newsgroup-forwarded)
5315 gnus-forwarded-mark)
eec82323
LMI
5316 ((memq number gnus-newsgroup-saved)
5317 gnus-saved-mark)
23f87bed
MB
5318 ((memq number gnus-newsgroup-recent)
5319 gnus-recent-mark)
5320 ((memq number gnus-newsgroup-unseen)
5321 gnus-unseen-mark)
5322 (t gnus-no-mark))
5323 gnus-tmp-downloaded
5324 (cond ((memq number gnus-newsgroup-undownloaded)
5325 gnus-undownloaded-mark)
5326 (gnus-newsgroup-agentized
5327 gnus-downloaded-mark)
5328 (t
5329 gnus-no-mark))
eec82323
LMI
5330 gnus-tmp-from (mail-header-from gnus-tmp-header)
5331 gnus-tmp-name
5332 (cond
5333 ((string-match "<[^>]+> *$" gnus-tmp-from)
5334 (setq beg-match (match-beginning 0))
23f87bed
MB
5335 (or (and (string-match "^\".+\"" gnus-tmp-from)
5336 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5337 (substring gnus-tmp-from 0 beg-match)))
5338 ((string-match "(.+)" gnus-tmp-from)
5339 (substring gnus-tmp-from
5340 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5341 (t gnus-tmp-from))
5342
5343 ;; Do the %B string
5344 gnus-tmp-thread-tree-header-string
5345 (cond
5346 ((not gnus-show-threads) "")
5347 ((zerop gnus-tmp-level)
5348 (cond ((cdar thread)
5349 (or gnus-sum-thread-tree-root subject))
5350 (gnus-tmp-new-adopts
5351 (or gnus-sum-thread-tree-false-root subject))
5352 (t
5353 (or gnus-sum-thread-tree-single-indent subject))))
5354 (t
5355 (concat (apply 'concat
5356 (mapcar (lambda (item)
5357 (if (= item 1)
5358 gnus-sum-thread-tree-vertical
5359 gnus-sum-thread-tree-indent))
5360 (cdr (reverse tree-stack))))
5361 (if (nth 1 thread)
5362 gnus-sum-thread-tree-leaf-with-other
5363 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5364 (when (string= gnus-tmp-name "")
5365 (setq gnus-tmp-name gnus-tmp-from))
5366 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5367 (setq gnus-tmp-lines -1))
5368 (if (= gnus-tmp-lines -1)
5369 (setq gnus-tmp-lines "?")
5370 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5371 (gnus-put-text-property
64763fe3
MB
5372 (point)
5373 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 5374 'gnus-number number)
64763fe3
MB
5375 (when gnus-visual-p
5376 (forward-line -1)
5377 (gnus-run-hooks 'gnus-summary-update-hook)
5378 (forward-line 1))
eec82323 5379
64763fe3 5380 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5381
5382 (when (nth 1 thread)
23f87bed
MB
5383 (push (list (max 0 gnus-tmp-level)
5384 (copy-sequence tree-stack)
5385 (nthcdr 1 thread))
5386 stack))
5387 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5388 (incf gnus-tmp-level)
5389 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5390 (if gnus-summary-display-while-building
5391 (if building-count
5392 (progn
5393 ;; use a set frequency
5394 (setq building-line-count (1- building-line-count))
5395 (when (= building-line-count 0)
5396 (sit-for 0)
5397 (setq building-line-count
5398 gnus-summary-display-while-building)))
5399 ;; always
5400 (sit-for 0)))
eec82323
LMI
5401 (unless threads
5402 (setq gnus-tmp-level 0)))))
5403 (gnus-message 7 "Generating summary...done"))
5404
5405(defun gnus-summary-prepare-unthreaded (headers)
5406 "Generate an unthreaded summary buffer based on HEADERS."
5407 (let (header number mark)
5408
5409 (beginning-of-line)
5410
5411 (while headers
5412 ;; We may have to root out some bad articles...
5413 (when (memq (setq number (mail-header-number
5414 (setq header (pop headers))))
5415 gnus-newsgroup-limit)
5416 ;; Mark article as read when it has a low score.
5417 (when (and gnus-summary-mark-below
5418 (< (or (cdr (assq number gnus-newsgroup-scored))
5419 gnus-summary-default-score 0)
5420 gnus-summary-mark-below)
5421 (not (gnus-summary-article-ancient-p number)))
5422 (setq gnus-newsgroup-unreads
5423 (delq number gnus-newsgroup-unreads))
5424 (if gnus-newsgroup-auto-expire
5425 (push number gnus-newsgroup-expirable)
5426 (push (cons number gnus-low-score-mark)
5427 gnus-newsgroup-reads)))
5428
5429 (setq mark (gnus-article-mark number))
5430 (push (gnus-data-make number mark (1+ (point)) header 0)
5431 gnus-newsgroup-data)
5432 (gnus-summary-insert-line
5433 header 0 number
23f87bed 5434 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5435 mark (memq number gnus-newsgroup-replied)
5436 (memq number gnus-newsgroup-expirable)
5437 (mail-header-subject header) nil
5438 (cdr (assq number gnus-newsgroup-scored))
5439 (memq number gnus-newsgroup-processable))))))
5440
16409b0b
GM
5441(defun gnus-summary-remove-list-identifiers ()
5442 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5443 (let ((regexp (if (consp gnus-list-identifiers)
5444 (mapconcat 'identity gnus-list-identifiers " *\\|")
5445 gnus-list-identifiers))
5446 changed subject)
5447 (when regexp
01c52d31 5448 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
23f87bed
MB
5449 (dolist (header gnus-newsgroup-headers)
5450 (setq subject (mail-header-subject header)
5451 changed nil)
01c52d31 5452 (while (string-match regexp subject)
23f87bed 5453 (setq subject
01c52d31 5454 (concat (substring subject 0 (match-beginning 1))
23f87bed
MB
5455 (substring subject (match-end 0)))
5456 changed t))
23f87bed 5457 (when changed
01c52d31
MB
5458 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5459 (setq subject
5460 (concat (substring subject 0 (match-beginning 1))
5461 (substring subject (match-end 1)))))
23f87bed
MB
5462 (mail-header-set-subject header subject))))))
5463
5464(defun gnus-fetch-headers (articles)
5465 "Fetch headers of ARTICLES."
5466 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5467 (gnus-message 5 "Fetching headers for %s..." name)
5468 (prog1
5469 (if (eq 'nov
5470 (setq gnus-headers-retrieved-by
5471 (gnus-retrieve-headers
5472 articles gnus-newsgroup-name
5473 ;; We might want to fetch old headers, but
5474 ;; not if there is only 1 article.
5475 (and (or (and
5476 (not (eq gnus-fetch-old-headers 'some))
5477 (not (numberp gnus-fetch-old-headers)))
5478 (> (length articles) 1))
5479 gnus-fetch-old-headers))))
5480 (gnus-get-newsgroup-headers-xover
5481 articles nil nil gnus-newsgroup-name t)
5482 (gnus-get-newsgroup-headers))
5483 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5484
6748645f 5485(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5486 "Select newsgroup GROUP.
6748645f
LMI
5487If READ-ALL is non-nil, all articles in the group are selected.
5488If SELECT-ARTICLES, only select those articles from GROUP."
01c52d31 5489 (let* ((entry (gnus-group-entry group))
eec82323
LMI
5490 ;;!!! Dirty hack; should be removed.
5491 (gnus-summary-ignore-duplicates
23f87bed 5492 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5493 t
5494 gnus-summary-ignore-duplicates))
5495 (info (nth 2 entry))
01c52d31 5496 charset articles fetched-articles cached)
eec82323
LMI
5497
5498 (unless (gnus-check-server
475e0e0c
GM
5499 (set (make-local-variable 'gnus-current-select-method)
5500 (gnus-find-method-for-group group)))
eec82323 5501 (error "Couldn't open server"))
01c52d31 5502 (setq charset (gnus-group-name-charset gnus-current-select-method group))
eec82323
LMI
5503
5504 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5505 (gnus-activate-group group) ; Or we can activate it...
5506 (progn ; Or we bug out.
5507 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5508 (gnus-kill-buffer (current-buffer)))
01c52d31
MB
5509 (error
5510 "Couldn't activate group %s: %s"
5511 (mm-decode-coding-string group charset)
5512 (mm-decode-coding-string (gnus-status-message group) charset))))
eec82323
LMI
5513
5514 (unless (gnus-request-group group t)
01c52d31
MB
5515 (when (equal major-mode 'gnus-summary-mode)
5516 (gnus-kill-buffer (current-buffer)))
5517 (error "Couldn't request group %s: %s"
5518 (mm-decode-coding-string group charset)
5519 (mm-decode-coding-string (gnus-status-message group) charset)))
eec82323 5520
23f87bed 5521 (when gnus-agent
54506618 5522 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5523
23f87bed
MB
5524 (setq gnus-summary-use-undownloaded-faces
5525 (gnus-agent-find-parameter
5526 group
5527 'agent-enable-undownloaded-faces)))
5528
5529 (setq gnus-newsgroup-name group
5530 gnus-newsgroup-unselected nil
5531 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5532
5533 (let ((display (gnus-group-find-parameter group 'display)))
5534 (setq gnus-newsgroup-display
5535 (cond
5536 ((not (zerop (or (car-safe read-all) 0)))
5537 ;; The user entered the group with C-u SPC/RET, let's show
5538 ;; all articles.
5539 'gnus-not-ignore)
5540 ((eq display 'all)
5541 'gnus-not-ignore)
5542 ((arrayp display)
5543 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5544 ((numberp display)
5545 ;; The following is probably the "correct" solution, but
5546 ;; it makes Gnus fetch all headers and then limit the
5547 ;; articles (which is slow), so instead we hack the
5548 ;; select-articles parameter instead. -- Simon Josefsson
5549 ;; <jas@kth.se>
5550 ;;
5551 ;; (gnus-byte-compile
5552 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5553 ;; display)))))
5554 (setq select-articles
5555 (gnus-uncompress-range
5556 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5557 (if (> tmp 0)
5558 tmp
5559 1))
5560 (cdr (gnus-active group)))))
5561 nil)
5562 (t
5563 nil))))
eec82323 5564
23f87bed 5565 (gnus-summary-setup-default-charset)
eec82323
LMI
5566
5567 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5568 (when (gnus-virtual-group-p group)
5569 (setq cached gnus-newsgroup-cached))
5570
5571 (setq gnus-newsgroup-unreads
23f87bed
MB
5572 (gnus-sorted-ndifference
5573 (gnus-sorted-ndifference gnus-newsgroup-unreads
5574 gnus-newsgroup-marked)
eec82323
LMI
5575 gnus-newsgroup-dormant))
5576
5577 (setq gnus-newsgroup-processable nil)
5578
5579 (gnus-update-read-articles group gnus-newsgroup-unreads)
eec82323 5580
23f87bed
MB
5581 ;; Adjust and set lists of article marks.
5582 (when info
5583 (gnus-adjust-marked-articles info))
6748645f
LMI
5584 (if (setq articles select-articles)
5585 (setq gnus-newsgroup-unselected
23f87bed 5586 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5587 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5588
5589 (cond
5590 ((null articles)
5591 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5592 'quit)
5593 ((eq articles 0) nil)
5594 (t
5595 ;; Init the dependencies hash table.
5596 (setq gnus-newsgroup-dependencies
5597 (gnus-make-hashtable (length articles)))
16409b0b 5598 (gnus-set-global-variables)
eec82323 5599 ;; Retrieve the headers and read them in.
23f87bed
MB
5600
5601 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5602
5603 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5604 (when cached
5605 (setq gnus-newsgroup-cached cached))
5606
5607 ;; Suppress duplicates?
5608 (when gnus-suppress-duplicates
5609 (gnus-dup-suppress-articles))
5610
5611 ;; Set the initial limit.
5612 (setq gnus-newsgroup-limit (copy-sequence articles))
5613 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5614 (setq fetched-articles
5615 (mapcar (lambda (headers) (mail-header-number headers))
5616 gnus-newsgroup-headers))
5617 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5618 (setq gnus-newsgroup-unreads
23f87bed
MB
5619 (gnus-sorted-nintersection
5620 gnus-newsgroup-unreads fetched-articles))
5621 (gnus-compute-unseen-list)
5622
eec82323
LMI
5623 ;; Removed marked articles that do not exist.
5624 (gnus-update-missing-marks
23f87bed 5625 (gnus-sorted-difference articles fetched-articles))
eec82323 5626 ;; We might want to build some more threads first.
6748645f
LMI
5627 (when (and gnus-fetch-old-headers
5628 (eq gnus-headers-retrieved-by 'nov))
5629 (if (eq gnus-fetch-old-headers 'invisible)
5630 (gnus-build-all-threads)
5631 (gnus-build-old-threads)))
5632 ;; Let the Gnus agent mark articles as read.
5633 (when gnus-agent
5634 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5635 ;; Remove list identifiers from subject
5636 (when gnus-list-identifiers
5637 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5638 ;; Check whether auto-expire is to be done in this group.
5639 (setq gnus-newsgroup-auto-expire
5640 (gnus-group-auto-expirable-p group))
5641 ;; Set up the article buffer now, if necessary.
01c52d31
MB
5642 (unless (and gnus-single-article-buffer
5643 (equal gnus-article-buffer "*Article*"))
eec82323
LMI
5644 (gnus-article-setup-buffer))
5645 ;; First and last article in this newsgroup.
5646 (when gnus-newsgroup-headers
5647 (setq gnus-newsgroup-begin
5648 (mail-header-number (car gnus-newsgroup-headers))
5649 gnus-newsgroup-end
5650 (mail-header-number
5651 (gnus-last-element gnus-newsgroup-headers))))
5652 ;; GROUP is successfully selected.
5653 (or gnus-newsgroup-headers t)))))
5654
23f87bed
MB
5655(defun gnus-compute-unseen-list ()
5656 ;; The `seen' marks are treated specially.
5657 (if (not gnus-newsgroup-seen)
5658 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5659 (setq gnus-newsgroup-unseen
5660 (gnus-inverse-list-range-intersection
5661 gnus-newsgroup-articles gnus-newsgroup-seen))))
5662
d09ae6ca
GM
5663(declare-function gnus-get-predicate "gnus-agent" (predicate))
5664
23f87bed
MB
5665(defun gnus-summary-display-make-predicate (display)
5666 (require 'gnus-agent)
5667 (when (= (length display) 1)
5668 (setq display (car display)))
5669 (unless gnus-summary-display-cache
5670 (dolist (elem (append '((unread . unread)
5671 (read . read)
5672 (unseen . unseen))
5673 gnus-article-mark-lists))
5674 (push (cons (cdr elem)
5675 (gnus-byte-compile
5676 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5677 gnus-summary-display-cache)))
5678 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5679 (gnus-category-predicate-cache gnus-summary-display-cache))
5680 (gnus-get-predicate display)))
5681
5682;; Uses the dynamically bound `number' variable.
9efa445f 5683(defvar number)
23f87bed
MB
5684(defun gnus-article-marked-p (type &optional article)
5685 (let ((article (or article number)))
5686 (cond
5687 ((eq type 'tick)
5688 (memq article gnus-newsgroup-marked))
5689 ((eq type 'spam)
5690 (memq article gnus-newsgroup-spam-marked))
5691 ((eq type 'unsend)
5692 (memq article gnus-newsgroup-unsendable))
5693 ((eq type 'undownload)
5694 (memq article gnus-newsgroup-undownloaded))
5695 ((eq type 'download)
5696 (memq article gnus-newsgroup-downloadable))
5697 ((eq type 'unread)
5698 (memq article gnus-newsgroup-unreads))
5699 ((eq type 'read)
5700 (memq article gnus-newsgroup-reads))
5701 ((eq type 'dormant)
5702 (memq article gnus-newsgroup-dormant) )
5703 ((eq type 'expire)
5704 (memq article gnus-newsgroup-expirable))
5705 ((eq type 'reply)
5706 (memq article gnus-newsgroup-replied))
5707 ((eq type 'killed)
5708 (memq article gnus-newsgroup-killed))
5709 ((eq type 'bookmark)
5710 (assq article gnus-newsgroup-bookmarks))
5711 ((eq type 'score)
5712 (assq article gnus-newsgroup-scored))
5713 ((eq type 'save)
5714 (memq article gnus-newsgroup-saved))
5715 ((eq type 'cache)
5716 (memq article gnus-newsgroup-cached))
5717 ((eq type 'forward)
5718 (memq article gnus-newsgroup-forwarded))
5719 ((eq type 'seen)
5720 (not (memq article gnus-newsgroup-unseen)))
5721 ((eq type 'recent)
5722 (memq article gnus-newsgroup-recent))
5723 (t t))))
5724
eec82323 5725(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5726 "Find out what articles the user wants to read."
26c9afc3 5727 (let* ((articles
eec82323
LMI
5728 ;; Select all articles if `read-all' is non-nil, or if there
5729 ;; are no unread articles.
5730 (if (or read-all
5731 (and (zerop (length gnus-newsgroup-marked))
5732 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5733 ;; Fetch all if the predicate is non-nil.
5734 gnus-newsgroup-display)
5735 ;; We want to select the headers for all the articles in
5736 ;; the group, so we select either all the active
5737 ;; articles in the group, or (if that's nil), the
5738 ;; articles in the cache.
16409b0b 5739 (or
4b70e299 5740 (if gnus-newsgroup-maximum-articles
11abff8e
MB
5741 (let ((active (gnus-active group)))
5742 (gnus-uncompress-range
5743 (cons (max (car active)
4b70e299
MB
5744 (- (cdr active)
5745 gnus-newsgroup-maximum-articles
5746 -1))
11abff8e
MB
5747 (cdr active))))
5748 (gnus-uncompress-range (gnus-active group)))
16409b0b 5749 (gnus-cache-articles-in-group group))
23f87bed
MB
5750 ;; Select only the "normal" subset of articles.
5751 (gnus-sorted-nunion
5752 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5753 gnus-newsgroup-unreads)))
eec82323
LMI
5754 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5755 (scored (length scored-list))
5756 (number (length articles))
5757 (marked (+ (length gnus-newsgroup-marked)
5758 (length gnus-newsgroup-dormant)))
5759 (select
5760 (cond
5761 ((numberp read-all)
5762 read-all)
23f87bed
MB
5763 ((numberp gnus-newsgroup-display)
5764 gnus-newsgroup-display)
eec82323
LMI
5765 (t
5766 (condition-case ()
5767 (cond
5768 ((and (or (<= scored marked) (= scored number))
5769 (numberp gnus-large-newsgroup)
5770 (> number gnus-large-newsgroup))
23f87bed
MB
5771 (let* ((cursor-in-echo-area nil)
5772 (initial (gnus-parameter-large-newsgroup-initial
5773 gnus-newsgroup-name))
5774 (input
5775 (read-string
5776 (format
5777 "How many articles from %s (%s %d): "
01c52d31 5778 (gnus-group-decoded-name gnus-newsgroup-name)
23f87bed
MB
5779 (if initial "max" "default")
5780 number)
5781 (if initial
5782 (cons (number-to-string initial)
5783 0)))))
eec82323
LMI
5784 (if (string-match "^[ \t]*$" input) number input)))
5785 ((and (> scored marked) (< scored number)
5786 (> (- scored number) 20))
5787 (let ((input
5788 (read-string
5789 (format "%s %s (%d scored, %d total): "
5790 "How many articles from"
23f87bed
MB
5791 (gnus-group-decoded-name group)
5792 scored number))))
eec82323
LMI
5793 (if (string-match "^[ \t]*$" input)
5794 number input)))
5795 (t number))
d4dfaa19
DL
5796 (quit
5797 (message "Quit getting the articles to read")
5798 nil))))))
eec82323
LMI
5799 (setq select (if (stringp select) (string-to-number select) select))
5800 (if (or (null select) (zerop select))
5801 select
5802 (if (and (not (zerop scored)) (<= (abs select) scored))
5803 (progn
5804 (setq articles (sort scored-list '<))
5805 (setq number (length articles)))
5806 (setq articles (copy-sequence articles)))
5807
5808 (when (< (abs select) number)
5809 (if (< select 0)
5810 ;; Select the N oldest articles.
5811 (setcdr (nthcdr (1- (abs select)) articles) nil)
5812 ;; Select the N most recent articles.
5813 (setq articles (nthcdr (- number select) articles))))
5814 (setq gnus-newsgroup-unselected
23f87bed 5815 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5816 (when gnus-alter-articles-to-read-function
23f87bed 5817 (setq articles
a1506d29 5818 (sort
16409b0b 5819 (funcall gnus-alter-articles-to-read-function
23f87bed 5820 gnus-newsgroup-name articles)
16409b0b 5821 '<)))
eec82323
LMI
5822 articles)))
5823
5824(defun gnus-killed-articles (killed articles)
5825 (let (out)
5826 (while articles
5827 (when (inline (gnus-member-of-range (car articles) killed))
5828 (push (car articles) out))
5829 (setq articles (cdr articles)))
5830 out))
5831
5832(defun gnus-uncompress-marks (marks)
5833 "Uncompress the mark ranges in MARKS."
5834 (let ((uncompressed '(score bookmark))
5835 out)
5836 (while marks
5837 (if (memq (caar marks) uncompressed)
5838 (push (car marks) out)
5839 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5840 (setq marks (cdr marks)))
5841 out))
5842
23f87bed
MB
5843(defun gnus-article-mark-to-type (mark)
5844 "Return the type of MARK."
5845 (or (cadr (assq mark gnus-article-special-mark-lists))
5846 'list))
5847
5848(defun gnus-article-unpropagatable-p (mark)
5849 "Return whether MARK should be propagated to back end."
5850 (memq mark gnus-article-unpropagated-mark-lists))
5851
eec82323 5852(defun gnus-adjust-marked-articles (info)
16409b0b 5853 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5854 (let* ((marked-lists (gnus-info-marks info))
5855 (active (gnus-active (gnus-info-group info)))
5856 (min (car active))
5857 (max (cdr active))
5858 (types gnus-article-mark-lists)
54506618
MB
5859 marks var articles article mark mark-type
5860 bgn end)
eec82323 5861
23f87bed
MB
5862 (dolist (marks marked-lists)
5863 (setq mark (car marks)
5864 mark-type (gnus-article-mark-to-type mark)
5865 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5866
23f87bed
MB
5867 ;; We set the variable according to the type of the marks list,
5868 ;; and then adjust the marks to a subset of the active articles.
eec82323 5869 (cond
54506618 5870 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5871 ((eq mark-type 'list)
54506618
MB
5872 ;; Simultaneously uncompress and clip to active range
5873 ;; See gnus-uncompress-range for a description of possible marks
5874 (let (l lh)
5875 (if (not (cadr marks))
5876 (set var nil)
5877 (setq articles (if (numberp (cddr marks))
5878 (list (cdr marks))
5879 (cdr marks))
5880 lh (cons nil nil)
5881 l lh)
5882
5883 (while (setq article (pop articles))
5884 (cond ((consp article)
5885 (setq bgn (max (car article) min)
5886 end (min (cdr article) max))
5887 (while (<= bgn end)
5888 (setq l (setcdr l (cons bgn nil))
5889 bgn (1+ bgn))))
5890 ((and (<= min article)
5891 (>= max article))
5892 (setq l (setcdr l (cons article nil))))))
5893 (set var (cdr lh)))))
eec82323 5894 ;; Adjust assocs.
23f87bed
MB
5895 ((eq mark-type 'tuple)
5896 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5897 (when (not (listp (cdr (symbol-value var))))
5898 (set var (list (symbol-value var))))
5899 (when (not (listp (cdr articles)))
5900 (setq articles (list articles)))
eec82323
LMI
5901 (while articles
5902 (when (or (not (consp (setq article (pop articles))))
5903 (< (car article) min)
5904 (> (car article) max))
23f87bed
MB
5905 (set var (delq article (symbol-value var))))))
5906 ;; Adjust ranges (sloppily).
5907 ((eq mark-type 'range)
5908 (cond
5909 ((eq mark 'seen)
5910 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5911 ;; It should be (seen (NUM1 . NUM2)).
5912 (when (numberp (cddr marks))
5913 (setcdr marks (list (cdr marks))))
5914 (setq articles (cdr marks))
5915 (while (and articles
5916 (or (and (consp (car articles))
5917 (> min (cdar articles)))
5918 (and (numberp (car articles))
5919 (> min (car articles)))))
5920 (pop articles))
5921 (set var articles))))))))
eec82323
LMI
5922
5923(defun gnus-update-missing-marks (missing)
6748645f 5924 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 5925 (when missing
23f87bed 5926 (let (var m)
eec82323 5927 ;; Go through all types.
23f87bed
MB
5928 (dolist (elem gnus-article-mark-lists)
5929 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5930 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5931 (when (symbol-value var)
5932 ;; This list has articles. So we delete all missing
5933 ;; articles from it.
5934 (setq m missing)
5935 (while m
5936 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
5937
5938(defun gnus-update-marks ()
5939 "Enter the various lists of marked articles into the newsgroup info list."
5940 (let ((types gnus-article-mark-lists)
5941 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 5942 type list newmarked symbol delta-marks)
eec82323 5943 (when info
16409b0b 5944 ;; Add all marks lists to the list of marks lists.
eec82323 5945 (while (setq type (pop types))
16409b0b
GM
5946 (setq list (symbol-value
5947 (setq symbol
23f87bed 5948 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 5949
16409b0b 5950 (when list
eec82323
LMI
5951 ;; Get rid of the entries of the articles that have the
5952 ;; default score.
5953 (when (and (eq (cdr type) 'score)
5954 gnus-save-score
5955 list)
5956 (let* ((arts list)
5957 (prev (cons nil list))
5958 (all prev))
5959 (while arts
5960 (if (or (not (consp (car arts)))
5961 (= (cdar arts) gnus-summary-default-score))
5962 (setcdr prev (cdr arts))
5963 (setq prev arts))
5964 (setq arts (cdr arts)))
16409b0b
GM
5965 (setq list (cdr all)))))
5966
23f87bed
MB
5967 (when (eq (cdr type) 'seen)
5968 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5969
5970 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 5971 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 5972
23f87bed
MB
5973 (when (and (gnus-check-backend-function
5974 'request-set-mark gnus-newsgroup-name)
5975 (not (gnus-article-unpropagatable-p (cdr type))))
5976 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5977 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5978 (add (gnus-remove-from-range
5979 (gnus-copy-sequence list) old)))
5980 (when add
5981 (push (list add 'add (list (cdr type))) delta-marks))
5982 (when del
5983 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 5984
16409b0b
GM
5985 (when list
5986 (push (cons (cdr type) list) newmarked)))
5987
5988 (when delta-marks
5989 (unless (gnus-check-group gnus-newsgroup-name)
5990 (error "Can't open server for %s" gnus-newsgroup-name))
5991 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 5992
eec82323
LMI
5993 ;; Enter these new marks into the info of the group.
5994 (if (nthcdr 3 info)
5995 (setcar (nthcdr 3 info) newmarked)
5996 ;; Add the marks lists to the end of the info.
5997 (when newmarked
5998 (setcdr (nthcdr 2 info) (list newmarked))))
5999
6000 ;; Cut off the end of the info if there's nothing else there.
6001 (let ((i 5))
6002 (while (and (> i 2)
6003 (not (nth i info)))
6004 (when (nthcdr (decf i) info)
6005 (setcdr (nthcdr i info) nil)))))))
6006
6007(defun gnus-set-mode-line (where)
16409b0b 6008 "Set the mode line of the article or summary buffers.
eec82323
LMI
6009If WHERE is `summary', the summary mode line format will be used."
6010 ;; Is this mode line one we keep updated?
16409b0b
GM
6011 (when (and (memq where gnus-updated-mode-lines)
6012 (symbol-value
6013 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323 6014 (let (mode-string)
c7a91ce1
SM
6015 ;; We evaluate this in the summary buffer since these
6016 ;; variables are buffer-local to that buffer.
6017 (with-current-buffer gnus-summary-buffer
6018 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
6019 ;; below.
6020 (let* ((mformat (symbol-value
6021 (intern
6022 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
6023 (gnus-tmp-group-name (gnus-mode-string-quote
6024 (gnus-group-decoded-name
6025 gnus-newsgroup-name)))
eec82323
LMI
6026 (gnus-tmp-article-number (or gnus-current-article 0))
6027 (gnus-tmp-unread gnus-newsgroup-unreads)
6028 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6029 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6030 (gnus-tmp-unread-and-unselected
6031 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6032 (zerop gnus-tmp-unselected))
6033 "")
6034 ((zerop gnus-tmp-unselected)
6035 (format "{%d more}" gnus-tmp-unread-and-unticked))
6036 (t (format "{%d(+%d) more}"
6037 gnus-tmp-unread-and-unticked
6038 gnus-tmp-unselected))))
6039 (gnus-tmp-subject
6040 (if (and gnus-current-headers
6041 (vectorp gnus-current-headers))
6042 (gnus-mode-string-quote
6043 (mail-header-subject gnus-current-headers))
6044 ""))
6045 bufname-length max-len
23f87bed 6046 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
6047 (setq mode-string (eval mformat))
6048 (setq bufname-length (if (string-match "%b" mode-string)
6049 (- (length
6050 (buffer-name
6051 (if (eq where 'summary)
6052 nil
6053 (get-buffer gnus-article-buffer))))
6054 2)
6055 0))
6056 (setq max-len (max 4 (if gnus-mode-non-string-length
6057 (- (window-width)
6058 gnus-mode-non-string-length
6059 bufname-length)
6060 (length mode-string))))
6061 ;; We might have to chop a bit of the string off...
6062 (when (> (length mode-string) max-len)
6063 (setq mode-string
16409b0b 6064 (concat (truncate-string-to-width mode-string (- max-len 3))
eec82323
LMI
6065 "...")))
6066 ;; Pad the mode string a bit.
6067 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
6068 ;; Update the mode line.
6069 (setq mode-line-buffer-identification
6070 (gnus-mode-line-buffer-identification (list mode-string)))
6071 (set-buffer-modified-p t))))
6072
6073(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6074 "Go through the HEADERS list and add all Xrefs to a hash table.
6075The resulting hash table is returned, or nil if no Xrefs were found."
6076 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6077 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6078 (xref-hashtb (gnus-make-hashtable))
6079 start group entry number xrefs header)
6080 (while headers
6081 (setq header (pop headers))
6082 (when (and (setq xrefs (mail-header-xref header))
6083 (not (memq (setq number (mail-header-number header))
6084 unreads)))
6085 (setq start 0)
6086 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6087 (setq start (match-end 0))
6088 (setq group (if prefix
6089 (concat prefix (substring xrefs (match-beginning 1)
6090 (match-end 1)))
6091 (substring xrefs (match-beginning 1) (match-end 1))))
6092 (setq number
e9bd5782 6093 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
6094 (match-end 2))))
6095 (if (setq entry (gnus-gethash group xref-hashtb))
6096 (setcdr entry (cons number (cdr entry)))
6097 (gnus-sethash group (cons number nil) xref-hashtb)))))
6098 (and start xref-hashtb)))
6099
6100(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6101 "Look through all the headers and mark the Xrefs as read."
6102 (let ((virtual (gnus-virtual-group-p from-newsgroup))
01c52d31 6103 name info xref-hashtb idlist method nth4)
eec82323
LMI
6104 (save-excursion
6105 (set-buffer gnus-group-buffer)
6106 (when (setq xref-hashtb
6107 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6108 (mapatoms
6109 (lambda (group)
6110 (unless (string= from-newsgroup (setq name (symbol-name group)))
6111 (setq idlist (symbol-value group))
6112 ;; Dead groups are not updated.
6113 (and (prog1
01c52d31 6114 (setq info (gnus-get-info name))
eec82323
LMI
6115 (when (stringp (setq nth4 (gnus-info-method info)))
6116 (setq nth4 (gnus-server-to-method nth4))))
6117 ;; Only do the xrefs if the group has the same
6118 ;; select method as the group we have just read.
6119 (or (gnus-methods-equal-p
6120 nth4 (gnus-find-method-for-group from-newsgroup))
6121 virtual
6122 (equal nth4 (setq method (gnus-find-method-for-group
6123 from-newsgroup)))
6124 (and (equal (car nth4) (car method))
6125 (equal (nth 1 nth4) (nth 1 method))))
6126 gnus-use-cross-reference
6127 (or (not (eq gnus-use-cross-reference t))
6128 virtual
6129 ;; Only do cross-references on subscribed
6130 ;; groups, if that is what is wanted.
6131 (<= (gnus-info-level info) gnus-level-subscribed))
6132 (gnus-group-make-articles-read name idlist))))
6133 xref-hashtb)))))
6134
6748645f 6135(defun gnus-compute-read-articles (group articles)
01c52d31 6136 (let* ((entry (gnus-group-entry group))
6748645f
LMI
6137 (info (nth 2 entry))
6138 (active (gnus-active group))
6139 ninfo)
6140 (when entry
16409b0b 6141 ;; First peel off all invalid article numbers.
6748645f
LMI
6142 (when active
6143 (let ((ids articles)
6144 id first)
6145 (while (setq id (pop ids))
6146 (when (and first (> id (cdr active)))
6147 ;; We'll end up in this situation in one particular
6148 ;; obscure situation. If you re-scan a group and get
6149 ;; a new article that is cross-posted to a different
6150 ;; group that has not been re-scanned, you might get
6151 ;; crossposted article that has a higher number than
6152 ;; Gnus believes possible. So we re-activate this
6153 ;; group as well. This might mean doing the
6154 ;; crossposting thingy will *increase* the number
6155 ;; of articles in some groups. Tsk, tsk.
6156 (setq active (or (gnus-activate-group group) active)))
6157 (when (or (> id (cdr active))
6158 (< id (car active)))
6159 (setq articles (delq id articles))))))
6160 ;; If the read list is nil, we init it.
6161 (if (and active
6162 (null (gnus-info-read info))
6163 (> (car active) 1))
6164 (setq ninfo (cons 1 (1- (car active))))
6165 (setq ninfo (gnus-info-read info)))
6166 ;; Then we add the read articles to the range.
6167 (gnus-add-to-range
6168 ninfo (setq articles (sort articles '<))))))
6169
eec82323
LMI
6170(defun gnus-group-make-articles-read (group articles)
6171 "Update the info of GROUP to say that ARTICLES are read."
6172 (let* ((num 0)
01c52d31 6173 (entry (gnus-group-entry group))
eec82323
LMI
6174 (info (nth 2 entry))
6175 (active (gnus-active group))
6176 range)
6748645f
LMI
6177 (when entry
6178 (setq range (gnus-compute-read-articles group articles))
01c52d31 6179 (with-current-buffer gnus-group-buffer
6748645f
LMI
6180 (gnus-undo-register
6181 `(progn
6182 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6183 (gnus-info-set-read ',info ',(gnus-info-read info))
6184 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 6185 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
6186 (gnus-group-update-group ,group t))))
6187 ;; Add the read articles to the range.
6188 (gnus-info-set-read info range)
23f87bed 6189 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
6190 ;; Then we have to re-compute how many unread
6191 ;; articles there are in this group.
6192 (when active
6193 (cond
6194 ((not range)
6195 (setq num (- (1+ (cdr active)) (car active))))
6196 ((not (listp (cdr range)))
6197 (setq num (- (cdr active) (- (1+ (cdr range))
6198 (car range)))))
6199 (t
6200 (while range
6201 (if (numberp (car range))
6202 (setq num (1+ num))
6203 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6204 (setq range (cdr range)))
6205 (setq num (- (cdr active) num))))
6206 ;; Update the number of unread articles.
6207 (setcar entry num)
6208 ;; Update the group buffer.
23f87bed
MB
6209 (unless (gnus-ephemeral-group-p group)
6210 (gnus-group-update-group group t))))))
eec82323 6211
eec82323
LMI
6212(defvar gnus-newsgroup-none-id 0)
6213
6214(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6215 (let ((cur nntp-server-buffer)
6216 (dependencies
6217 (or dependencies
01c52d31
MB
6218 (with-current-buffer gnus-summary-buffer
6219 gnus-newsgroup-dependencies)))
6220 headers id end ref number
16409b0b
GM
6221 (mail-parse-charset gnus-newsgroup-charset)
6222 (mail-parse-ignored-charsets
c7a91ce1
SM
6223 (save-current-buffer (condition-case nil
6224 (set-buffer gnus-summary-buffer)
6225 (error))
6226 gnus-newsgroup-ignored-charsets)))
6227 (with-current-buffer nntp-server-buffer
eec82323
LMI
6228 ;; Translate all TAB characters into SPACE characters.
6229 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 6230 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 6231 (ietf-drums-unfold-fws)
6748645f 6232 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6233 (let ((case-fold-search t)
6748645f 6234 in-reply-to header p lines chars)
eec82323 6235 (goto-char (point-min))
01ccbb85 6236 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
6237 ;; do not begin with 2 or 3.
6238 (while (re-search-forward "^[23][0-9]+ " nil t)
6239 (setq id nil
6240 ref nil)
6241 ;; This implementation of this function, with nine
6242 ;; search-forwards instead of the one re-search-forward and
6243 ;; a case (which basically was the old function) is actually
01ccbb85 6244 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
6245 ;; can't have everything, I guess. Speed and elegance
6246 ;; doesn't always go hand in hand.
6247 (setq
6248 header
6249 (vector
6250 ;; Number.
6251 (prog1
01c52d31 6252 (setq number (read cur))
eec82323
LMI
6253 (end-of-line)
6254 (setq p (point))
6255 (narrow-to-region (point)
6256 (or (and (search-forward "\n.\n" nil t)
6257 (- (point) 2))
6258 (point))))
6259 ;; Subject.
6260 (progn
6261 (goto-char p)
23f87bed 6262 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
6263 (funcall gnus-decode-encoded-word-function
6264 (nnheader-header-value))
2bd3dcae 6265 "(none)"))
eec82323
LMI
6266 ;; From.
6267 (progn
6268 (goto-char p)
23f87bed 6269 (if (search-forward "\nfrom:" nil t)
343d6628 6270 (funcall gnus-decode-encoded-address-function
16409b0b 6271 (nnheader-header-value))
2bd3dcae 6272 "(nobody)"))
eec82323
LMI
6273 ;; Date.
6274 (progn
6275 (goto-char p)
23f87bed 6276 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6277 (nnheader-header-value) ""))
6278 ;; Message-ID.
6279 (progn
6280 (goto-char p)
6748645f
LMI
6281 (setq id (if (re-search-forward
6282 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6283 ;; We do it this way to make sure the Message-ID
6284 ;; is (somewhat) syntactically valid.
6285 (buffer-substring (match-beginning 1)
6286 (match-end 1))
eec82323
LMI
6287 ;; If there was no message-id, we just fake one
6288 ;; to make subsequent routines simpler.
01c52d31 6289 (nnheader-generate-fake-message-id number))))
eec82323
LMI
6290 ;; References.
6291 (progn
6292 (goto-char p)
23f87bed 6293 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6294 (progn
6295 (setq end (point))
6296 (prog1
6297 (nnheader-header-value)
6298 (setq ref
6299 (buffer-substring
6300 (progn
6301 (end-of-line)
6302 (search-backward ">" end t)
6303 (1+ (point)))
6304 (progn
6305 (search-backward "<" end t)
6306 (point))))))
6307 ;; Get the references from the in-reply-to header if there
6308 ;; were no references and the in-reply-to header looks
6309 ;; promising.
23f87bed 6310 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6311 (setq in-reply-to (nnheader-header-value))
6312 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6313 (let (ref2)
6314 (setq ref (substring in-reply-to (match-beginning 0)
6315 (match-end 0)))
6316 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6317 (setq ref2 (substring in-reply-to (match-beginning 0)
6318 (match-end 0)))
6319 (when (> (length ref2) (length ref))
6320 (setq ref ref2)))
6321 ref)
eec82323
LMI
6322 (setq ref nil))))
6323 ;; Chars.
6748645f
LMI
6324 (progn
6325 (goto-char p)
6326 (if (search-forward "\nchars: " nil t)
6327 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6328 chars -1)
6329 -1))
eec82323
LMI
6330 ;; Lines.
6331 (progn
6332 (goto-char p)
6333 (if (search-forward "\nlines: " nil t)
a8151ef7 6334 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6335 lines -1)
6336 -1))
eec82323
LMI
6337 ;; Xref.
6338 (progn
6339 (goto-char p)
23f87bed 6340 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6341 (nnheader-header-value)))
6342 ;; Extra.
6343 (when gnus-extra-headers
6344 (let ((extra gnus-extra-headers)
6345 out)
6346 (while extra
6347 (goto-char p)
6348 (when (search-forward
23f87bed 6349 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6350 (push (cons (car extra) (nnheader-header-value))
6351 out))
6352 (pop extra))
6353 out))))
eec82323
LMI
6354 (when (equal id ref)
6355 (setq ref nil))
6748645f
LMI
6356
6357 (when gnus-alter-header-function
6358 (funcall gnus-alter-header-function header)
6359 (setq id (mail-header-id header)
6360 ref (gnus-parent-id (mail-header-references header))))
6361
6362 (when (setq header
6363 (gnus-dependencies-add-header
6364 header dependencies force-new))
eec82323
LMI
6365 (push header headers))
6366 (goto-char (point-max))
6367 (widen))
6368 (nreverse headers)))))
6369
eec82323
LMI
6370;; Goes through the xover lines and returns a list of vectors
6371(defun gnus-get-newsgroup-headers-xover (sequence &optional
6372 force-new dependencies
6373 group also-fetch-heads)
16409b0b
GM
6374 "Parse the news overview data in the server buffer.
6375Return a list of headers that match SEQUENCE (see
6376`nntp-retrieve-headers')."
eec82323
LMI
6377 ;; Get the Xref when the users reads the articles since most/some
6378 ;; NNTP servers do not include Xrefs when using XOVER.
6379 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6380 (let ((mail-parse-charset gnus-newsgroup-charset)
6381 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6382 (cur nntp-server-buffer)
eec82323 6383 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6384 (allp (cond
6385 ((eq gnus-read-all-available-headers t)
6386 t)
14e6dc54
MB
6387 ((and (stringp gnus-read-all-available-headers)
6388 group)
23f87bed
MB
6389 (string-match gnus-read-all-available-headers group))
6390 (t
6391 nil)))
eec82323 6392 number headers header)
c7a91ce1 6393 (with-current-buffer nntp-server-buffer
16409b0b 6394 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6395 ;; Allow the user to mangle the headers before parsing them.
6748645f 6396 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6397 (goto-char (point-min))
23f87bed
MB
6398 (gnus-parse-without-error
6399 (while (and (or sequence allp)
6400 (not (eobp)))
6401 (setq number (read cur))
6402 (when (not allp)
6403 (while (and sequence
6404 (< (car sequence) number))
6405 (setq sequence (cdr sequence))))
6406 (when (and (or allp
6407 (and sequence
6408 (eq number (car sequence))))
6409 (progn
6410 (setq sequence (cdr sequence))
6411 (setq header (inline
6412 (gnus-nov-parse-line
6413 number dependencies force-new)))))
6414 (push header headers))
6415 (forward-line 1)))
eec82323
LMI
6416 ;; A common bug in inn is that if you have posted an article and
6417 ;; then retrieves the active file, it will answer correctly --
6418 ;; the new article is included. However, a NOV entry for the
6419 ;; article may not have been generated yet, so this may fail.
6420 ;; We work around this problem by retrieving the last few
6421 ;; headers using HEAD.
6422 (if (or (not also-fetch-heads)
6423 (not sequence))
6424 ;; We (probably) got all the headers.
6425 (nreverse headers)
6426 (let ((gnus-nov-is-evil t))
6427 (nconc
6428 (nreverse headers)
23f87bed 6429 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6430 (gnus-get-newsgroup-headers))))))))
6431
6432(defun gnus-article-get-xrefs ()
6433 "Fill in the Xref value in `gnus-current-headers', if necessary.
6434This is meant to be called in `gnus-article-internal-prepare-hook'."
01c52d31
MB
6435 (let ((headers (with-current-buffer gnus-summary-buffer
6436 gnus-current-headers)))
eec82323
LMI
6437 (or (not gnus-use-cross-reference)
6438 (not headers)
6439 (and (mail-header-xref headers)
6440 (not (string= (mail-header-xref headers) "")))
6441 (let ((case-fold-search t)
6442 xref)
6443 (save-restriction
6444 (nnheader-narrow-to-headers)
6445 (goto-char (point-min))
16409b0b
GM
6446 (when (or (and (not (eobp))
6447 (eq (downcase (char-after)) ?x)
eec82323
LMI
6448 (looking-at "Xref:"))
6449 (search-forward "\nXref:" nil t))
6450 (goto-char (1+ (match-end 0)))
01c52d31 6451 (setq xref (buffer-substring (point) (point-at-eol)))
eec82323
LMI
6452 (mail-header-set-xref headers xref)))))))
6453
6454(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6455 "Find article ID and insert the summary line for that article.
6456OLD-HEADER can either be a header or a line number to insert
6457the subject line on."
6458 (let* ((line (and (numberp old-header) old-header))
6459 (old-header (and (vectorp old-header) old-header))
6460 (header (cond ((and old-header use-old-header)
16409b0b
GM
6461 old-header)
6462 ((and (numberp id)
6463 (gnus-number-to-header id))
6464 (gnus-number-to-header id))
6465 (t
6466 (gnus-read-header id))))
6467 (number (and (numberp id) id))
6468 d)
eec82323
LMI
6469 (when header
6470 ;; Rebuild the thread that this article is part of and go to the
6471 ;; article we have fetched.
6472 (when (and (not gnus-show-threads)
6473 old-header)
6748645f
LMI
6474 (when (and number
6475 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6476 (goto-char (gnus-data-pos d))
6477 (gnus-data-remove
6478 number
01c52d31 6479 (- (point-at-bol)
eec82323 6480 (prog1
01c52d31 6481 (1+ (point-at-eol))
eec82323 6482 (gnus-delete-line))))))
23f87bed
MB
6483 ;; Remove list identifiers from subject.
6484 (when gnus-list-identifiers
6485 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6486 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6487 (when old-header
6488 (mail-header-set-number header (mail-header-number old-header)))
6489 (setq gnus-newsgroup-sparse
6490 (delq (setq number (mail-header-number header))
6491 gnus-newsgroup-sparse))
6492 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6493 (push number gnus-newsgroup-limit)
6494 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6495 (gnus-summary-goto-subject number nil t))
6496 (when (and (numberp number)
6497 (> number 0))
6498 ;; We have to update the boundaries even if we can't fetch the
6499 ;; article if ID is a number -- so that the next `P' or `N'
6500 ;; command will fetch the previous (or next) article even
6501 ;; if the one we tried to fetch this time has been canceled.
6502 (when (> number gnus-newsgroup-end)
6503 (setq gnus-newsgroup-end number))
6504 (when (< number gnus-newsgroup-begin)
6505 (setq gnus-newsgroup-begin number))
6506 (setq gnus-newsgroup-unselected
6507 (delq number gnus-newsgroup-unselected)))
6508 ;; Report back a success?
6509 (and header (mail-header-number header))))
6510
6511;;; Process/prefix in the summary buffer
6512
6513(defun gnus-summary-work-articles (n)
6748645f
LMI
6514 "Return a list of articles to be worked upon.
6515The prefix argument, the list of process marked articles, and the
6516current article will be taken into consideration."
c7a91ce1 6517 (with-current-buffer gnus-summary-buffer
6748645f
LMI
6518 (cond
6519 (n
6520 ;; A numerical prefix has been given.
6521 (setq n (prefix-numeric-value n))
6522 (let ((backward (< n 0))
6523 (n (abs (prefix-numeric-value n)))
6524 articles article)
6525 (save-excursion
6526 (while
6527 (and (> n 0)
6528 (push (setq article (gnus-summary-article-number))
6529 articles)
6530 (if backward
6531 (gnus-summary-find-prev nil article)
6532 (gnus-summary-find-next nil article)))
6533 (decf n)))
6534 (nreverse articles)))
6535 ((and (gnus-region-active-p) (mark))
6536 (message "region active")
6537 ;; Work on the region between point and mark.
6538 (let ((max (max (point) (mark)))
6539 articles article)
6540 (save-excursion
7dafe00b 6541 (goto-char (min (point) (mark)))
6748645f
LMI
6542 (while
6543 (and
6544 (push (setq article (gnus-summary-article-number)) articles)
6545 (gnus-summary-find-next nil article)
6546 (< (point) max)))
6547 (nreverse articles))))
6548 (gnus-newsgroup-processable
6549 ;; There are process-marked articles present.
6550 ;; Save current state.
6551 (gnus-summary-save-process-mark)
6552 ;; Return the list.
6553 (reverse gnus-newsgroup-processable))
6554 (t
6555 ;; Just return the current article.
6556 (list (gnus-summary-article-number))))))
6557
6558(defmacro gnus-summary-iterate (arg &rest forms)
6559 "Iterate over the process/prefixed articles and do FORMS.
6560ARG is the interactive prefix given to the command. FORMS will be
6561executed with point over the summary line of the articles."
6562 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6563 `(let ((,articles (gnus-summary-work-articles ,arg)))
6564 (while ,articles
6565 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6566 ,@forms
6567 (pop ,articles)))))
6748645f
LMI
6568
6569(put 'gnus-summary-iterate 'lisp-indent-function 1)
6570(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6571
6572(defun gnus-summary-save-process-mark ()
6573 "Push the current set of process marked articles on the stack."
6574 (interactive)
6575 (push (copy-sequence gnus-newsgroup-processable)
6576 gnus-newsgroup-process-stack))
6577
6578(defun gnus-summary-kill-process-mark ()
6579 "Push the current set of process marked articles on the stack and unmark."
6580 (interactive)
6581 (gnus-summary-save-process-mark)
6582 (gnus-summary-unmark-all-processable))
6583
6584(defun gnus-summary-yank-process-mark ()
6585 "Pop the last process mark state off the stack and restore it."
6586 (interactive)
6587 (unless gnus-newsgroup-process-stack
6588 (error "Empty mark stack"))
6589 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6590
6591(defun gnus-summary-process-mark-set (set)
6592 "Make SET into the current process marked articles."
6593 (gnus-summary-unmark-all-processable)
01c52d31 6594 (mapc 'gnus-summary-set-process-mark set))
eec82323
LMI
6595
6596;;; Searching and stuff
6597
6598(defun gnus-summary-search-group (&optional backward use-level)
6599 "Search for next unread newsgroup.
6600If optional argument BACKWARD is non-nil, search backward instead."
c7a91ce1 6601 (with-current-buffer gnus-group-buffer
eec82323
LMI
6602 (when (gnus-group-search-forward
6603 backward nil (if use-level (gnus-group-group-level) nil))
6604 (gnus-group-group-name))))
6605
6606(defun gnus-summary-best-group (&optional exclude-group)
6607 "Find the name of the best unread group.
6608If EXCLUDE-GROUP, do not go to this group."
01c52d31 6609 (with-current-buffer gnus-group-buffer
eec82323
LMI
6610 (save-excursion
6611 (gnus-group-best-unread-group exclude-group))))
6612
23f87bed
MB
6613(defun gnus-summary-find-next (&optional unread article backward)
6614 (if backward
6615 (gnus-summary-find-prev unread article)
eec82323
LMI
6616 (let* ((dummy (gnus-summary-article-intangible-p))
6617 (article (or article (gnus-summary-article-number)))
23f87bed 6618 (data (gnus-data-find-list article))
eec82323
LMI
6619 result)
6620 (when (and (not dummy)
6621 (or (not gnus-summary-check-current)
6622 (not unread)
23f87bed
MB
6623 (not (gnus-data-unread-p (car data)))))
6624 (setq data (cdr data)))
eec82323
LMI
6625 (when (setq result
6626 (if unread
6627 (progn
23f87bed
MB
6628 (while data
6629 (unless (memq (gnus-data-number (car data))
6630 (cond
6631 ((eq gnus-auto-goto-ignores
6632 'always-undownloaded)
6633 gnus-newsgroup-undownloaded)
6634 (gnus-plugged
6635 nil)
6636 ((eq gnus-auto-goto-ignores
6637 'unfetched)
6638 gnus-newsgroup-unfetched)
6639 ((eq gnus-auto-goto-ignores
6640 'undownloaded)
6641 gnus-newsgroup-undownloaded)))
6642 (when (gnus-data-unread-p (car data))
6643 (setq result (car data)
6644 data nil)))
6645 (setq data (cdr data)))
eec82323 6646 result)
23f87bed 6647 (car data)))
eec82323
LMI
6648 (goto-char (gnus-data-pos result))
6649 (gnus-data-number result)))))
6650
6651(defun gnus-summary-find-prev (&optional unread article)
6652 (let* ((eobp (eobp))
6653 (article (or article (gnus-summary-article-number)))
23f87bed 6654 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6655 result)
6656 (when (and (not eobp)
6657 (or (not gnus-summary-check-current)
6658 (not unread)
23f87bed
MB
6659 (not (gnus-data-unread-p (car data)))))
6660 (setq data (cdr data)))
eec82323
LMI
6661 (when (setq result
6662 (if unread
6663 (progn
23f87bed
MB
6664 (while data
6665 (unless (memq (gnus-data-number (car data))
6666 (cond
6667 ((eq gnus-auto-goto-ignores
6668 'always-undownloaded)
6669 gnus-newsgroup-undownloaded)
6670 (gnus-plugged
6671 nil)
6672 ((eq gnus-auto-goto-ignores
6673 'unfetched)
6674 gnus-newsgroup-unfetched)
6675 ((eq gnus-auto-goto-ignores
6676 'undownloaded)
6677 gnus-newsgroup-undownloaded)))
6678 (when (gnus-data-unread-p (car data))
6679 (setq result (car data)
6680 data nil)))
6681 (setq data (cdr data)))
eec82323 6682 result)
23f87bed 6683 (car data)))
eec82323
LMI
6684 (goto-char (gnus-data-pos result))
6685 (gnus-data-number result))))
6686
6687(defun gnus-summary-find-subject (subject &optional unread backward article)
6688 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6689 (article (or article (gnus-summary-article-number)))
6690 (articles (gnus-data-list backward))
6691 (arts (gnus-data-find-list article articles))
6692 result)
6693 (when (or (not gnus-summary-check-current)
6694 (not unread)
6695 (not (gnus-data-unread-p (car arts))))
6696 (setq arts (cdr arts)))
6697 (while arts
6698 (and (or (not unread)
6699 (gnus-data-unread-p (car arts)))
6700 (vectorp (gnus-data-header (car arts)))
6701 (gnus-subject-equal
6702 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6703 (setq result (car arts)
6704 arts nil))
6705 (setq arts (cdr arts)))
6706 (and result
6707 (goto-char (gnus-data-pos result))
6708 (gnus-data-number result))))
6709
6710(defun gnus-summary-search-forward (&optional unread subject backward)
6711 "Search forward for an article.
6712If UNREAD, look for unread articles. If SUBJECT, look for
6713articles with that subject. If BACKWARD, search backward instead."
6714 (cond (subject (gnus-summary-find-subject subject unread backward))
6715 (backward (gnus-summary-find-prev unread))
6716 (t (gnus-summary-find-next unread))))
6717
6718(defun gnus-recenter (&optional n)
6719 "Center point in window and redisplay frame.
6720Also do horizontal recentering."
6721 (interactive "P")
6722 (when (and gnus-auto-center-summary
6723 (not (eq gnus-auto-center-summary 'vertical)))
6724 (gnus-horizontal-recenter))
6725 (recenter n))
6726
6727(defun gnus-summary-recenter ()
6728 "Center point in the summary window.
6729If `gnus-auto-center-summary' is nil, or the article buffer isn't
6730displayed, no centering will be performed."
6731 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6732 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6733 (interactive)
23f87bed
MB
6734 ;; The user has to want it.
6735 (when gnus-auto-center-summary
6736 (let* ((top (cond ((< (window-height) 4) 0)
6737 ((< (window-height) 7) 1)
6738 (t (if (numberp gnus-auto-center-summary)
6739 gnus-auto-center-summary
01c52d31 6740 (/ (1- (window-height)) 2)))))
23f87bed
MB
6741 (height (1- (window-height)))
6742 (bottom (save-excursion (goto-char (point-max))
6743 (forward-line (- height))
6744 (point)))
6745 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6746 (when (get-buffer-window gnus-article-buffer)
6747 ;; Only do recentering when the article buffer is displayed,
6748 ;; Set the window start to either `bottom', which is the biggest
6749 ;; possible valid number, or the second line from the top,
6750 ;; whichever is the least.
db7ebd73
MB
6751 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6752 (if (> bottom top-pos)
6753 ;; Keep the second line from the top visible
01c52d31 6754 (set-window-start window top-pos)
db7ebd73
MB
6755 ;; Try to keep the bottom line visible; if it's partially
6756 ;; obscured, either scroll one more line to make it fully
6757 ;; visible, or revert to using TOP-POS.
6758 (save-excursion
6759 (goto-char (point-max))
6760 (forward-line -1)
6761 (let ((last-line-start (point)))
6762 (goto-char bottom)
6763 (set-window-start window (point) t)
6764 (when (not (pos-visible-in-window-p last-line-start window))
6765 (forward-line 1)
6766 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6767 ;; Do horizontal recentering while we're at it.
6768 (when (and (get-buffer-window (current-buffer) t)
6769 (not (eq gnus-auto-center-summary 'vertical)))
6770 (let ((selected (selected-window)))
6771 (select-window (get-buffer-window (current-buffer) t))
6772 (gnus-summary-position-point)
6773 (gnus-horizontal-recenter)
6774 (select-window selected))))))
6775
6776(defun gnus-summary-jump-to-group (newsgroup)
6777 "Move point to NEWSGROUP in group mode buffer."
6778 ;; Keep update point of group mode buffer if visible.
6779 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6780 (save-window-excursion
6781 ;; Take care of tree window mode.
6782 (when (get-buffer-window gnus-group-buffer)
6783 (pop-to-buffer gnus-group-buffer))
6784 (gnus-group-jump-to-group newsgroup))
6785 (save-excursion
6786 ;; Take care of tree window mode.
c7a91ce1 6787 (if (get-buffer-window gnus-group-buffer 0)
eec82323
LMI
6788 (pop-to-buffer gnus-group-buffer)
6789 (set-buffer gnus-group-buffer))
6790 (gnus-group-jump-to-group newsgroup))))
6791
6792;; This function returns a list of article numbers based on the
6793;; difference between the ranges of read articles in this group and
6794;; the range of active articles.
6795(defun gnus-list-of-unread-articles (group)
6796 (let* ((read (gnus-info-read (gnus-get-info group)))
6797 (active (or (gnus-active group) (gnus-activate-group group)))
01c52d31
MB
6798 (last (or (cdr active)
6799 (error "Group %s couldn't be activated " group)))
4b70e299
MB
6800 (bottom (if gnus-newsgroup-maximum-articles
6801 (max (car active)
6802 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6803 (car active)))
eec82323
LMI
6804 first nlast unread)
6805 ;; If none are read, then all are unread.
6806 (if (not read)
11abff8e 6807 (setq first bottom)
eec82323
LMI
6808 ;; If the range of read articles is a single range, then the
6809 ;; first unread article is the article after the last read
6810 ;; article. Sounds logical, doesn't it?
16409b0b 6811 (if (and (not (listp (cdr read)))
11abff8e 6812 (or (< (car read) bottom)
16409b0b
GM
6813 (progn (setq read (list read))
6814 nil)))
11abff8e 6815 (setq first (max bottom (1+ (cdr read))))
eec82323
LMI
6816 ;; `read' is a list of ranges.
6817 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6818 (caar read)))
6819 1)
11abff8e 6820 (setq first bottom))
eec82323
LMI
6821 (while read
6822 (when first
6823 (while (< first nlast)
54506618
MB
6824 (setq unread (cons first unread)
6825 first (1+ first))))
eec82323
LMI
6826 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6827 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6828 (setq read (cdr read)))))
6829 ;; And add the last unread articles.
6830 (while (<= first last)
54506618
MB
6831 (setq unread (cons first unread)
6832 first (1+ first)))
eec82323 6833 ;; Return the list of unread articles.
6748645f 6834 (delq 0 (nreverse unread))))
eec82323
LMI
6835
6836(defun gnus-list-of-read-articles (group)
6837 "Return a list of unread, unticked and non-dormant articles."
6838 (let* ((info (gnus-get-info group))
6839 (marked (gnus-info-marks info))
6840 (active (gnus-active group)))
6841 (and info active
23f87bed
MB
6842 (gnus-list-range-difference
6843 (gnus-list-range-difference
6844 (gnus-sorted-complement
11abff8e 6845 (gnus-uncompress-range
4b70e299 6846 (if gnus-newsgroup-maximum-articles
11abff8e 6847 (cons (max (car active)
4b70e299
MB
6848 (- (cdr active)
6849 gnus-newsgroup-maximum-articles
6850 -1))
11abff8e
MB
6851 (cdr active))
6852 active))
23f87bed
MB
6853 (gnus-list-of-unread-articles group))
6854 (cdr (assq 'dormant marked)))
6855 (cdr (assq 'tick marked))))))
eec82323 6856
54506618
MB
6857;; This function returns a sequence of article numbers based on the
6858;; difference between the ranges of read articles in this group and
6859;; the range of active articles.
6860(defun gnus-sequence-of-unread-articles (group)
6861 (let* ((read (gnus-info-read (gnus-get-info group)))
6862 (active (or (gnus-active group) (gnus-activate-group group)))
6863 (last (cdr active))
4b70e299
MB
6864 (bottom (if gnus-newsgroup-maximum-articles
6865 (max (car active)
6866 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6867 (car active)))
54506618
MB
6868 first nlast unread)
6869 ;; If none are read, then all are unread.
6870 (if (not read)
11abff8e 6871 (setq first bottom)
54506618
MB
6872 ;; If the range of read articles is a single range, then the
6873 ;; first unread article is the article after the last read
6874 ;; article. Sounds logical, doesn't it?
6875 (if (and (not (listp (cdr read)))
11abff8e 6876 (or (< (car read) bottom)
54506618
MB
6877 (progn (setq read (list read))
6878 nil)))
11abff8e 6879 (setq first (max bottom (1+ (cdr read))))
54506618
MB
6880 ;; `read' is a list of ranges.
6881 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6882 (caar read)))
6883 1)
11abff8e 6884 (setq first bottom))
54506618
MB
6885 (while read
6886 (when first
6887 (push (cons first nlast) unread))
6888 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6889 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6890 (setq read (cdr read)))))
6891 ;; And add the last unread articles.
ba0226dd
MB
6892 (cond ((not (and first last))
6893 nil)
6894 ((< first last)
6895 (push (cons first last) unread))
6896 ((= first last)
6897 (push first unread)))
54506618
MB
6898 ;; Return the sequence of unread articles.
6899 (delq 0 (nreverse unread))))
6900
eec82323
LMI
6901;; Various summary commands
6902
6748645f
LMI
6903(defun gnus-summary-select-article-buffer ()
6904 "Reconfigure windows to show article buffer."
6905 (interactive)
6906 (if (not (gnus-buffer-live-p gnus-article-buffer))
6907 (error "There is no article buffer for this summary buffer")
6908 (gnus-configure-windows 'article)
6909 (select-window (get-buffer-window gnus-article-buffer))))
6910
eec82323
LMI
6911(defun gnus-summary-universal-argument (arg)
6912 "Perform any operation on all articles that are process/prefixed."
6913 (interactive "P")
eec82323
LMI
6914 (let ((articles (gnus-summary-work-articles arg))
6915 func article)
6916 (if (eq
6917 (setq
6918 func
6919 (key-binding
6920 (read-key-sequence
6921 (substitute-command-keys
16409b0b 6922 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
6923 'undefined)
6924 (gnus-error 1 "Undefined key")
6925 (save-excursion
6926 (while articles
6927 (gnus-summary-goto-subject (setq article (pop articles)))
6928 (let (gnus-newsgroup-processable)
6929 (command-execute func))
6930 (gnus-summary-remove-process-mark article)))))
6931 (gnus-summary-position-point))
6932
6933(defun gnus-summary-toggle-truncation (&optional arg)
6934 "Toggle truncation of summary lines.
23f87bed 6935With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
6936 (interactive "P")
6937 (setq truncate-lines
6938 (if (null arg) (not truncate-lines)
6939 (> (prefix-numeric-value arg) 0)))
6940 (redraw-display))
6941
23f87bed
MB
6942(defun gnus-summary-find-for-reselect ()
6943 "Return the number of an article to stay on across a reselect.
6944The current article is considered, then following articles, then previous
6945articles. An article is sought which is not cancelled and isn't a temporary
6946insertion from another group. If there's no such then return a dummy 0."
6947 (let (found)
6948 (dolist (rev '(nil t))
6949 (unless found ; don't demand the reverse list if we don't need it
6950 (let ((data (gnus-data-find-list
6951 (gnus-summary-article-number) (gnus-data-list rev))))
6952 (while (and data (not found))
6953 (if (and (< 0 (gnus-data-number (car data)))
6954 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6955 (setq found (gnus-data-number (car data))))
6956 (setq data (cdr data))))))
6957 (or found 0)))
6958
eec82323
LMI
6959(defun gnus-summary-reselect-current-group (&optional all rescan)
6960 "Exit and then reselect the current newsgroup.
6961The prefix argument ALL means to select all articles."
6962 (interactive "P")
eec82323
LMI
6963 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6964 (error "Ephemeral groups can't be reselected"))
23f87bed 6965 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
6966 (group gnus-newsgroup-name))
6967 (setq gnus-newsgroup-begin nil)
23f87bed 6968 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
6969 ;; We have to adjust the point of group mode buffer because
6970 ;; point was moved to the next unread newsgroup by exiting.
6971 (gnus-summary-jump-to-group group)
6972 (when rescan
6973 (save-excursion
6974 (gnus-group-get-new-news-this-group 1)))
6975 (gnus-group-read-group all t)
6976 (gnus-summary-goto-subject current-subject nil t)))
6977
6978(defun gnus-summary-rescan-group (&optional all)
6979 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6980 (interactive "P")
6981 (gnus-summary-reselect-current-group all t))
6982
6983(defun gnus-summary-update-info (&optional non-destructive)
6984 (save-excursion
6985 (let ((group gnus-newsgroup-name))
6748645f
LMI
6986 (when group
6987 (when gnus-newsgroup-kill-headers
6988 (setq gnus-newsgroup-killed
6989 (gnus-compress-sequence
23f87bed
MB
6990 (gnus-sorted-union
6991 (gnus-list-range-intersection
6992 gnus-newsgroup-unselected gnus-newsgroup-killed)
6993 gnus-newsgroup-unreads)
6748645f
LMI
6994 t)))
6995 (unless (listp (cdr gnus-newsgroup-killed))
6996 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6997 (let ((headers gnus-newsgroup-headers))
6998 ;; Set the new ranges of read articles.
01c52d31 6999 (with-current-buffer gnus-group-buffer
6748645f
LMI
7000 (gnus-undo-force-boundary))
7001 (gnus-update-read-articles
23f87bed
MB
7002 group (gnus-sorted-union
7003 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
7004 ;; Set the current article marks.
7005 (let ((gnus-newsgroup-scored
7006 (if (and (not gnus-save-score)
7007 (not non-destructive))
7008 nil
7009 gnus-newsgroup-scored)))
7010 (save-excursion
7011 (gnus-update-marks)))
7012 ;; Do the cross-ref thing.
7013 (when gnus-use-cross-reference
7014 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7015 ;; Do not switch windows but change the buffer to work.
a8151ef7 7016 (set-buffer gnus-group-buffer)
6748645f
LMI
7017 (unless (gnus-ephemeral-group-p group)
7018 (gnus-group-update-group group)))))))
eec82323
LMI
7019
7020(defun gnus-summary-save-newsrc (&optional force)
7021 "Save the current number of read/marked articles in the dribble buffer.
7022The dribble buffer will then be saved.
7023If FORCE (the prefix), also save the .newsrc file(s)."
7024 (interactive "P")
7025 (gnus-summary-update-info t)
7026 (if force
7027 (gnus-save-newsrc-file)
7028 (gnus-dribble-save)))
7029
704f1663
GM
7030(declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7031
23f87bed 7032(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 7033 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 7034`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
7035 (interactive)
7036 (gnus-set-global-variables)
16409b0b 7037 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7038 (with-current-buffer gnus-article-buffer
16409b0b
GM
7039 (mm-destroy-parts gnus-article-mime-handles)
7040 ;; Set it to nil for safety reason.
7041 (setq gnus-article-mime-handle-alist nil)
7042 (setq gnus-article-mime-handles nil)))
eec82323 7043 (gnus-kill-save-kill-buffer)
6748645f 7044 (gnus-async-halt-prefetch)
eec82323
LMI
7045 (let* ((group gnus-newsgroup-name)
7046 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 7047 (gnus-group-is-exiting-p t)
eec82323 7048 (mode major-mode)
23f87bed 7049 (group-point nil)
eec82323 7050 (buf (current-buffer)))
16409b0b
GM
7051 (unless quit-config
7052 ;; Do adaptive scoring, and possibly save score files.
7053 (when gnus-newsgroup-adaptive
7054 (gnus-score-adaptive))
7055 (when gnus-use-scoring
7056 (gnus-score-save)))
6748645f 7057 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
7058 ;; If we have several article buffers, we kill them at exit.
7059 (unless gnus-single-article-buffer
01c52d31
MB
7060 (when (gnus-buffer-live-p gnus-article-buffer)
7061 (with-current-buffer gnus-article-buffer
7062 ;; Don't kill sticky article buffers
7063 (unless (eq major-mode 'gnus-sticky-article-mode)
7064 (gnus-kill-buffer gnus-article-buffer)
7065 (setq gnus-article-current nil))))
7066 (gnus-kill-buffer gnus-original-article-buffer))
eec82323
LMI
7067 (when gnus-use-cache
7068 (gnus-cache-possibly-remove-articles)
7069 (gnus-cache-save-buffers))
7070 (gnus-async-prefetch-remove-group group)
7071 (when gnus-suppress-duplicates
7072 (gnus-dup-enter-articles))
7073 (when gnus-use-trees
7074 (gnus-tree-close group))
16409b0b
GM
7075 (when gnus-use-cache
7076 (gnus-cache-write-active))
6748645f
LMI
7077 ;; Remove entries for this group.
7078 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
7079 ;; Make all changes in this group permanent.
7080 (unless quit-config
6748645f 7081 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 7082 (gnus-summary-update-info))
eec82323
LMI
7083 (gnus-close-group group)
7084 ;; Make sure where we were, and go to next newsgroup.
7085 (set-buffer gnus-group-buffer)
7086 (unless quit-config
7087 (gnus-group-jump-to-group group))
6748645f
LMI
7088 (gnus-run-hooks 'gnus-summary-exit-hook)
7089 (unless (or quit-config
01c52d31 7090 (not gnus-summary-next-group-on-exit)
6748645f
LMI
7091 ;; If this group has disappeared from the summary
7092 ;; buffer, don't skip forwards.
7093 (not (string= group (gnus-group-group-name))))
eec82323 7094 (gnus-group-next-unread-group 1))
a8151ef7 7095 (setq group-point (point))
eec82323
LMI
7096 (if temporary
7097 nil ;Nothing to do.
eec82323
LMI
7098 (set-buffer buf)
7099 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
7100 (progn
7101 (gnus-deaden-summary)
7102 (setq mode nil))
eec82323
LMI
7103 ;; We set all buffer-local variables to nil. It is unclear why
7104 ;; this is needed, but if we don't, buffer-local variables are
7105 ;; not garbage-collected, it seems. This would the lead to en
7106 ;; ever-growing Emacs.
7107 (gnus-summary-clear-local-variables)
23f87bed
MB
7108 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7109 (gnus-summary-clear-local-variables))
eec82323
LMI
7110 (when (get-buffer gnus-article-buffer)
7111 (bury-buffer gnus-article-buffer))
eec82323
LMI
7112 ;; Return to group mode buffer.
7113 (when (eq mode 'gnus-summary-mode)
7114 (gnus-kill-buffer buf)))
7115 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
7116 (set-buffer gnus-group-buffer)
7117 (if quit-config
7118 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
7119 (goto-char group-point)
7120 ;; If gnus-group-buffer is already displayed, make sure we also move
7121 ;; the cursor in the window that displays it.
7122 (let ((win (get-buffer-window (current-buffer) 0)))
7123 (if win (set-window-point win (point))))
d61c212b 7124 (unless leave-hidden
4e90f2b9 7125 (gnus-configure-windows 'group 'force)))
6748645f 7126 ;; Clear the current group name.
eec82323
LMI
7127 (unless quit-config
7128 (setq gnus-newsgroup-name nil)))))
7129
7130(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7131(defun gnus-summary-exit-no-update (&optional no-questions)
7132 "Quit reading current newsgroup without updating read article info."
7133 (interactive)
eec82323 7134 (let* ((group gnus-newsgroup-name)
23f87bed
MB
7135 (gnus-group-is-exiting-p t)
7136 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
7137 (quit-config (gnus-group-quit-config group)))
7138 (when (or no-questions
7139 gnus-expert-user
7140 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 7141 (gnus-async-halt-prefetch)
23f87bed 7142 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b 7143 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 7144 (with-current-buffer gnus-article-buffer
16409b0b
GM
7145 (mm-destroy-parts gnus-article-mime-handles)
7146 ;; Set it to nil for safety reason.
7147 (setq gnus-article-mime-handle-alist nil)
7148 (setq gnus-article-mime-handles nil)))
eec82323
LMI
7149 ;; If we have several article buffers, we kill them at exit.
7150 (unless gnus-single-article-buffer
7151 (gnus-kill-buffer gnus-article-buffer)
7152 (gnus-kill-buffer gnus-original-article-buffer)
7153 (setq gnus-article-current nil))
7154 (if (not gnus-kill-summary-on-exit)
7155 (gnus-deaden-summary)
7156 (gnus-close-group group)
7157 (gnus-summary-clear-local-variables)
23f87bed
MB
7158 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
7159 (gnus-summary-clear-local-variables))
7160 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
7161 (unless gnus-single-article-buffer
7162 (setq gnus-article-current nil))
7163 (when gnus-use-trees
7164 (gnus-tree-close group))
7165 (gnus-async-prefetch-remove-group group)
7166 (when (get-buffer gnus-article-buffer)
7167 (bury-buffer gnus-article-buffer))
7168 ;; Return to the group buffer.
7169 (gnus-configure-windows 'group 'force)
7170 ;; Clear the current group name.
7171 (setq gnus-newsgroup-name nil)
23f87bed
MB
7172 (unless (gnus-ephemeral-group-p group)
7173 (gnus-group-update-group group))
eec82323
LMI
7174 (when (equal (gnus-group-group-name) group)
7175 (gnus-group-next-unread-group 1))
7176 (when quit-config
23f87bed 7177 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
7178
7179(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
7180 "Handle movement when leaving an ephemeral group.
7181The state which existed when entering the ephemeral is reset."
eec82323
LMI
7182 (if (not (buffer-name (car quit-config)))
7183 (gnus-configure-windows 'group 'force)
7184 (set-buffer (car quit-config))
7185 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
7186 (gnus-set-global-variables))
7187 ((eq major-mode 'gnus-article-mode)
c7a91ce1 7188 (save-current-buffer
23f87bed
MB
7189 ;; The `gnus-summary-buffer' variable may point
7190 ;; to the old summary buffer when using a single
7191 ;; article buffer.
7192 (unless (gnus-buffer-live-p gnus-summary-buffer)
7193 (set-buffer gnus-group-buffer))
7194 (set-buffer gnus-summary-buffer)
7195 (gnus-set-global-variables))))
eec82323 7196 (if (or (eq (cdr quit-config) 'article)
23f87bed 7197 (eq (cdr quit-config) 'pick))
01c52d31
MB
7198 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7199 (gnus-configure-windows 'pick 'force)
7200 (gnus-configure-windows (cdr quit-config) 'force))
eec82323
LMI
7201 (gnus-configure-windows (cdr quit-config) 'force))
7202 (when (eq major-mode 'gnus-summary-mode)
01c52d31
MB
7203 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7204 next-unread-noselect))
7205 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7206 'next-noselect)
7207 (gnus-summary-next-subject 1 nil t))
7208 ((eq gnus-auto-select-on-ephemeral-exit
7209 'next-unread-noselect)
7210 (gnus-summary-next-subject 1 t t))))
7211 ;; Hide the article buffer which displays the article different
7212 ;; from the one that the cursor points to in the summary buffer.
7213 (gnus-configure-windows 'summary 'force))
7214 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7215 (gnus-summary-next-subject 1))
7216 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7217 (gnus-summary-next-subject 1 t))))
eec82323
LMI
7218 (gnus-summary-recenter)
7219 (gnus-summary-position-point))))
7220
7221;;; Dead summaries.
7222
7223(defvar gnus-dead-summary-mode-map nil)
7224
7225(unless gnus-dead-summary-mode-map
7226 (setq gnus-dead-summary-mode-map (make-keymap))
7227 (suppress-keymap gnus-dead-summary-mode-map)
7228 (substitute-key-definition
7229 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
23f87bed
MB
7230 (dolist (key '("\C-d" "\r" "\177" [delete]))
7231 (define-key gnus-dead-summary-mode-map
7232 key 'gnus-summary-wake-up-the-dead))
7233 (dolist (key '("q" "Q"))
7234 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
eec82323
LMI
7235
7236(defvar gnus-dead-summary-mode nil
7237 "Minor mode for Gnus summary buffers.")
7238
7239(defun gnus-dead-summary-mode (&optional arg)
7240 "Minor mode for Gnus summary buffers."
7241 (interactive "P")
7242 (when (eq major-mode 'gnus-summary-mode)
7243 (make-local-variable 'gnus-dead-summary-mode)
7244 (setq gnus-dead-summary-mode
7245 (if (null arg) (not gnus-dead-summary-mode)
7246 (> (prefix-numeric-value arg) 0)))
7247 (when gnus-dead-summary-mode
01c52d31 7248 (add-minor-mode
a8151ef7 7249 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
eec82323
LMI
7250
7251(defun gnus-deaden-summary ()
7252 "Make the current summary buffer into a dead summary buffer."
7253 ;; Kill any previous dead summary buffer.
7254 (when (and gnus-dead-summary
7255 (buffer-name gnus-dead-summary))
01c52d31 7256 (with-current-buffer gnus-dead-summary
eec82323
LMI
7257 (when gnus-dead-summary-mode
7258 (kill-buffer (current-buffer)))))
7259 ;; Make this the current dead summary.
7260 (setq gnus-dead-summary (current-buffer))
7261 (gnus-dead-summary-mode 1)
7262 (let ((name (buffer-name)))
7263 (when (string-match "Summary" name)
7264 (rename-buffer
7265 (concat (substring name 0 (match-beginning 0)) "Dead "
7266 (substring name (match-beginning 0)))
16409b0b
GM
7267 t)
7268 (bury-buffer))))
eec82323
LMI
7269
7270(defun gnus-kill-or-deaden-summary (buffer)
7271 "Kill or deaden the summary BUFFER."
6748645f
LMI
7272 (save-excursion
7273 (when (and (buffer-name buffer)
7274 (not gnus-single-article-buffer))
01c52d31 7275 (with-current-buffer buffer
6748645f
LMI
7276 (gnus-kill-buffer gnus-article-buffer)
7277 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
7278 (cond
7279 ;; Kill the buffer.
7280 (gnus-kill-summary-on-exit
7281 (when (and gnus-use-trees
7282 (gnus-buffer-exists-p buffer))
c7a91ce1 7283 (with-current-buffer buffer
23f87bed
MB
7284 (gnus-tree-close gnus-newsgroup-name)))
7285 (gnus-kill-buffer buffer))
7286 ;; Deaden the buffer.
7287 ((gnus-buffer-exists-p buffer)
c7a91ce1 7288 (with-current-buffer buffer
23f87bed 7289 (gnus-deaden-summary))))))
eec82323
LMI
7290
7291(defun gnus-summary-wake-up-the-dead (&rest args)
7292 "Wake up the dead summary buffer."
7293 (interactive)
7294 (gnus-dead-summary-mode -1)
7295 (let ((name (buffer-name)))
7296 (when (string-match "Dead " name)
7297 (rename-buffer
7298 (concat (substring name 0 (match-beginning 0))
7299 (substring name (match-end 0)))
7300 t)))
7301 (gnus-message 3 "This dead summary is now alive again"))
7302
7303;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7304(defun gnus-summary-fetch-faq (&optional faq-dir)
7305 "Fetch the FAQ for the current group.
7306If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7307in."
7308 (interactive
7309 (list
7310 (when current-prefix-arg
7311 (completing-read
8f688cb0 7312 "FAQ dir: " (and (listp gnus-group-faq-directory)
01c52d31 7313 (mapcar 'list
a8151ef7 7314 gnus-group-faq-directory))))))
eec82323
LMI
7315 (let (gnus-faq-buffer)
7316 (when (setq gnus-faq-buffer
7317 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7318 (gnus-configure-windows 'summary-faq))))
7319
7320;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7321(defun gnus-summary-describe-group (&optional force)
7322 "Describe the current newsgroup."
7323 (interactive "P")
7324 (gnus-group-describe-group force gnus-newsgroup-name))
7325
7326(defun gnus-summary-describe-briefly ()
7327 "Describe summary mode commands briefly."
7328 (interactive)
16409b0b 7329 (gnus-message 6 (substitute-command-keys "\\<gnus-summary-mode-map>\\[gnus-summary-next-page]:Select \\[gnus-summary-next-unread-article]:Forward \\[gnus-summary-prev-unread-article]:Backward \\[gnus-summary-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-summary-describe-briefly]:This help")))
eec82323
LMI
7330
7331;; Walking around group mode buffer from summary mode.
7332
7333(defun gnus-summary-next-group (&optional no-article target-group backward)
7334 "Exit current newsgroup and then select next unread newsgroup.
7335If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7336initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7337previous group instead."
7338 (interactive "P")
eec82323
LMI
7339 ;; Stop pre-fetching.
7340 (gnus-async-halt-prefetch)
7341 (let ((current-group gnus-newsgroup-name)
7342 (current-buffer (current-buffer))
7343 entered)
7344 ;; First we semi-exit this group to update Xrefs and all variables.
7345 ;; We can't do a real exit, because the window conf must remain
7346 ;; the same in case the user is prompted for info, and we don't
7347 ;; want the window conf to change before that...
7348 (gnus-summary-exit t)
7349 (while (not entered)
7350 ;; Then we find what group we are supposed to enter.
7351 (set-buffer gnus-group-buffer)
7352 (gnus-group-jump-to-group current-group)
7353 (setq target-group
7354 (or target-group
7355 (if (eq gnus-keep-same-level 'best)
7356 (gnus-summary-best-group gnus-newsgroup-name)
7357 (gnus-summary-search-group backward gnus-keep-same-level))))
7358 (if (not target-group)
7359 ;; There are no further groups, so we return to the group
7360 ;; buffer.
7361 (progn
7362 (gnus-message 5 "Returning to the group buffer")
7363 (setq entered t)
7364 (when (gnus-buffer-live-p current-buffer)
7365 (set-buffer current-buffer)
7366 (gnus-summary-exit))
6748645f 7367 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7368 ;; We try to enter the target group.
7369 (gnus-group-jump-to-group target-group)
7370 (let ((unreads (gnus-group-group-unread)))
7371 (if (and (or (eq t unreads)
7372 (and unreads (not (zerop unreads))))
23f87bed
MB
7373 (gnus-summary-read-group
7374 target-group nil no-article
7375 (and (buffer-name current-buffer) current-buffer)
7376 nil backward))
eec82323
LMI
7377 (setq entered t)
7378 (setq current-group target-group
7379 target-group nil)))))))
7380
7381(defun gnus-summary-prev-group (&optional no-article)
7382 "Exit current newsgroup and then select previous unread newsgroup.
7383If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7384 (interactive "P")
7385 (gnus-summary-next-group no-article nil t))
7386
7387;; Walking around summary lines.
7388
23f87bed
MB
7389(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7390 "Go to the first subject satisfying any non-nil constraint.
7391If UNREAD is non-nil, the article should be unread.
7392If UNDOWNLOADED is non-nil, the article should be undownloaded.
7393If UNSEEN is non-nil, the article should be unseen.
7394Returns the article selected or nil if there are no matching articles."
eec82323 7395 (interactive "P")
23f87bed
MB
7396 (cond
7397 ;; Empty summary.
7398 ((null gnus-newsgroup-data)
7399 (gnus-message 3 "No articles in the group")
7400 nil)
7401 ;; Pick the first article.
7402 ((not (or unread undownloaded unseen))
7403 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7404 (gnus-data-number (car gnus-newsgroup-data)))
7405 ;; Find the first unread article.
7406 (t
7407 (let ((data gnus-newsgroup-data))
7408 (while (and data
7409 (let ((num (gnus-data-number (car data))))
7410 (or (memq num gnus-newsgroup-unfetched)
7411 (not (or (and unread
7412 (memq num gnus-newsgroup-unreads))
7413 (and undownloaded
7414 (memq num gnus-newsgroup-undownloaded))
7415 (and unseen
7416 (memq num gnus-newsgroup-unseen)))))))
7417 (setq data (cdr data)))
7418 (prog1
7419 (if data
7420 (progn
7421 (goto-char (gnus-data-pos (car data)))
7422 (gnus-data-number (car data)))
7423 (gnus-message 3 "No more%s articles"
7424 (let* ((r (when unread " unread"))
7425 (d (when undownloaded " undownloaded"))
7426 (s (when unseen " unseen"))
7427 (l (delq nil (list r d s))))
7428 (cond ((= 3 (length l))
7429 (concat r "," d ", or" s))
7430 ((= 2 (length l))
7431 (concat (car l) ", or" (cadr l)))
7432 ((= 1 (length l))
7433 (car l))
7434 (t
7435 ""))))
7436 nil
7437 )
7438 (gnus-summary-position-point))))))
eec82323
LMI
7439
7440(defun gnus-summary-next-subject (n &optional unread dont-display)
7441 "Go to next N'th summary line.
7442If N is negative, go to the previous N'th subject line.
7443If UNREAD is non-nil, only unread articles are selected.
7444The difference between N and the actual number of steps taken is
7445returned."
7446 (interactive "p")
7447 (let ((backward (< n 0))
7448 (n (abs n)))
7449 (while (and (> n 0)
7450 (if backward
7451 (gnus-summary-find-prev unread)
7452 (gnus-summary-find-next unread)))
16409b0b
GM
7453 (unless (zerop (setq n (1- n)))
7454 (gnus-summary-show-thread)))
eec82323
LMI
7455 (when (/= 0 n)
7456 (gnus-message 7 "No more%s articles"
7457 (if unread " unread" "")))
7458 (unless dont-display
7459 (gnus-summary-recenter)
7460 (gnus-summary-position-point))
7461 n))
7462
7463(defun gnus-summary-next-unread-subject (n)
7464 "Go to next N'th unread summary line."
7465 (interactive "p")
7466 (gnus-summary-next-subject n t))
7467
7468(defun gnus-summary-prev-subject (n &optional unread)
7469 "Go to previous N'th summary line.
7470If optional argument UNREAD is non-nil, only unread article is selected."
7471 (interactive "p")
7472 (gnus-summary-next-subject (- n) unread))
7473
7474(defun gnus-summary-prev-unread-subject (n)
7475 "Go to previous N'th unread summary line."
7476 (interactive "p")
7477 (gnus-summary-next-subject (- n) t))
7478
23f87bed
MB
7479(defun gnus-summary-goto-subjects (articles)
7480 "Insert the subject header for ARTICLES in the current buffer."
7481 (save-excursion
7482 (dolist (article articles)
7483 (gnus-summary-goto-subject article t)))
7484 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7485 (gnus-summary-position-point))
132cf96d 7486
eec82323 7487(defun gnus-summary-goto-subject (article &optional force silent)
d55fe5bb 7488 "Go to the subject line of ARTICLE.
eec82323
LMI
7489If FORCE, also allow jumping to articles not currently shown."
7490 (interactive "nArticle number: ")
23f87bed
MB
7491 (unless (numberp article)
7492 (error "Article %s is not a number" article))
eec82323
LMI
7493 (let ((b (point))
7494 (data (gnus-data-find article)))
7495 ;; We read in the article if we have to.
7496 (and (not data)
7497 force
6748645f
LMI
7498 (gnus-summary-insert-subject
7499 article
7500 (if (or (numberp force) (vectorp force)) force)
7501 t)
eec82323
LMI
7502 (setq data (gnus-data-find article)))
7503 (goto-char b)
7504 (if (not data)
7505 (progn
7506 (unless silent
7507 (gnus-message 3 "Can't find article %d" article))
7508 nil)
23f87bed
MB
7509 (let ((pt (gnus-data-pos data)))
7510 (goto-char pt)
7511 (gnus-summary-set-article-display-arrow pt))
6748645f 7512 (gnus-summary-position-point)
eec82323
LMI
7513 article)))
7514
7515;; Walking around summary lines with displaying articles.
7516
7517(defun gnus-summary-expand-window (&optional arg)
7518 "Make the summary buffer take up the entire Emacs frame.
7519Given a prefix, will force an `article' buffer configuration."
7520 (interactive "P")
eec82323
LMI
7521 (if arg
7522 (gnus-configure-windows 'article 'force)
7523 (gnus-configure-windows 'summary 'force)))
7524
7525(defun gnus-summary-display-article (article &optional all-header)
7526 "Display ARTICLE in article buffer."
01c52d31
MB
7527 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7528 (with-current-buffer gnus-article-buffer
7529 (eq major-mode 'gnus-article-mode)))
7530 (gnus-article-setup-buffer))
eec82323 7531 (gnus-set-global-variables)
01c52d31
MB
7532 (with-current-buffer gnus-article-buffer
7533 (setq gnus-article-charset gnus-newsgroup-charset)
7534 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7535 (mm-enable-multibyte))
eec82323
LMI
7536 (if (null article)
7537 nil
7538 (prog1
7539 (if gnus-summary-display-article-function
7540 (funcall gnus-summary-display-article-function article all-header)
7541 (gnus-article-prepare article all-header))
6748645f 7542 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7543 (when (and gnus-current-article
7544 (not (zerop gnus-current-article)))
7545 (gnus-summary-goto-subject gnus-current-article))
7546 (gnus-summary-recenter)
7547 (when (and gnus-use-trees gnus-show-threads)
7548 (gnus-possibly-generate-tree article)
7549 (gnus-highlight-selected-tree article))
7550 ;; Successfully display article.
7551 (gnus-article-set-window-start
7552 (cdr (assq article gnus-newsgroup-bookmarks))))))
7553
7554(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7555 "Select the current article.
7556If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7557non-nil, the article will be re-fetched even if it already present in
7558the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7559be displayed."
7560 ;; Make sure we are in the summary buffer to work around bbdb bug.
7561 (unless (eq major-mode 'gnus-summary-mode)
7562 (set-buffer gnus-summary-buffer))
7563 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7564 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7565 gnus-summary-display-article-function)
eec82323
LMI
7566 (and (not pseudo)
7567 (gnus-summary-article-pseudo-p article)
a8151ef7 7568 (error "This is a pseudo-article"))
c7a91ce1 7569 (with-current-buffer gnus-summary-buffer
16409b0b
GM
7570 (if (or (and gnus-single-article-buffer
7571 (or (null gnus-current-article)
7572 (null gnus-article-current)
7573 (null (get-buffer gnus-article-buffer))
7574 (not (eq article (cdr gnus-article-current)))
7575 (not (equal (car gnus-article-current)
7576 gnus-newsgroup-name))))
7577 (and (not gnus-single-article-buffer)
7578 (or (null gnus-current-article)
7579 (not (eq gnus-current-article article))))
7580 force)
7581 ;; The requested article is different from the current article.
7582 (progn
16409b0b
GM
7583 (gnus-summary-display-article article all-headers)
7584 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7585 (with-current-buffer gnus-article-buffer
16409b0b 7586 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7587 (mm-disable-multibyte))))
16409b0b
GM
7588 (gnus-article-set-window-start
7589 (cdr (assq article gnus-newsgroup-bookmarks)))
7590 article)
16409b0b 7591 'old))))
eec82323 7592
23f87bed
MB
7593(defun gnus-summary-force-verify-and-decrypt ()
7594 "Display buttons for signed/encrypted parts and verify/decrypt them."
7595 (interactive)
7596 (let ((mm-verify-option 'known)
7597 (mm-decrypt-option 'known)
7598 (gnus-article-emulate-mime t)
7599 (gnus-buttonized-mime-types (append (list "multipart/signed"
7600 "multipart/encrypted")
7601 gnus-buttonized-mime-types)))
7602 (gnus-summary-select-article nil 'force)))
7603
eec82323
LMI
7604(defun gnus-summary-set-current-mark (&optional current-mark)
7605 "Obsolete function."
7606 nil)
7607
7608(defun gnus-summary-next-article (&optional unread subject backward push)
7609 "Select the next article.
7610If UNREAD, only unread articles are selected.
7611If SUBJECT, only articles with SUBJECT are selected.
7612If BACKWARD, the previous article is selected instead of the next."
7613 (interactive "P")
11e95b02
MB
7614 ;; Make sure we are in the summary buffer.
7615 (unless (eq major-mode 'gnus-summary-mode)
7616 (set-buffer gnus-summary-buffer))
eec82323
LMI
7617 (cond
7618 ;; Is there such an article?
7619 ((and (gnus-summary-search-forward unread subject backward)
7620 (or (gnus-summary-display-article (gnus-summary-article-number))
7621 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7622 (gnus-summary-position-point))
7623 ;; If not, we try the first unread, if that is wanted.
7624 ((and subject
7625 gnus-auto-select-same
7626 (gnus-summary-first-unread-article))
7627 (gnus-summary-position-point)
7628 (gnus-message 6 "Wrapped"))
7629 ;; Try to get next/previous article not displayed in this group.
7630 ((and gnus-auto-extend-newsgroup
7631 (not unread) (not subject))
7632 (gnus-summary-goto-article
7633 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7634 nil (count-lines (point-min) (point))))
eec82323
LMI
7635 ;; Go to next/previous group.
7636 (t
7637 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7638 (gnus-summary-jump-to-group gnus-newsgroup-name))
49e787c9
GM
7639 (let ((cmd (if (featurep 'xemacs)
7640 last-command-char
7641 last-command-event))
eec82323 7642 (point
01c52d31 7643 (with-current-buffer gnus-group-buffer
eec82323
LMI
7644 (point)))
7645 (group
7646 (if (eq gnus-keep-same-level 'best)
7647 (gnus-summary-best-group gnus-newsgroup-name)
7648 (gnus-summary-search-group backward gnus-keep-same-level))))
7649 ;; For some reason, the group window gets selected. We change
7650 ;; it back.
7651 (select-window (get-buffer-window (current-buffer)))
7652 ;; Select next unread newsgroup automagically.
7653 (cond
7654 ((or (not gnus-auto-select-next)
7655 (not cmd))
7656 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7657 ((or (eq gnus-auto-select-next 'quietly)
7658 (and (eq gnus-auto-select-next 'slightly-quietly)
7659 push)
7660 (and (eq gnus-auto-select-next 'almost-quietly)
7661 (gnus-summary-last-article-p)))
7662 ;; Select quietly.
7663 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7664 (gnus-summary-exit)
7665 (gnus-message 7 "No more%s articles (%s)..."
7666 (if unread " unread" "")
7667 (if group (concat "selecting " group)
7668 "exiting"))
7669 (gnus-summary-next-group nil group backward)))
7670 (t
7671 (when (gnus-key-press-event-p last-input-event)
7672 (gnus-summary-walk-group-buffer
7673 gnus-newsgroup-name cmd unread backward point))))))))
7674
7675(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7676 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7677 (?\C-p (gnus-group-prev-unread-group 1))))
7678 (cursor-in-echo-area t)
23f87bed 7679 keve key group ended prompt)
c7a91ce1 7680 (with-current-buffer gnus-group-buffer
eec82323
LMI
7681 (goto-char start)
7682 (setq group
7683 (if (eq gnus-keep-same-level 'best)
7684 (gnus-summary-best-group gnus-newsgroup-name)
7685 (gnus-summary-search-group backward gnus-keep-same-level))))
7686 (while (not ended)
23f87bed
MB
7687 (setq prompt
7688 (format
7689 "No more%s articles%s " (if unread " unread" "")
7690 (if (and group
7691 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7692 (format " (Type %s for %s [%s])"
91472578
MB
7693 (single-key-description cmd)
7694 (gnus-group-decoded-name group)
01c52d31 7695 (gnus-group-unread group))
23f87bed
MB
7696 (format " (Type %s to exit %s)"
7697 (single-key-description cmd)
91472578 7698 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7699 ;; Confirm auto selection.
23f87bed
MB
7700 (setq key (car (setq keve (gnus-read-event-char prompt)))
7701 ended t)
eec82323
LMI
7702 (cond
7703 ((assq key keystrokes)
7704 (let ((obuf (current-buffer)))
7705 (switch-to-buffer gnus-group-buffer)
7706 (when group
7707 (gnus-group-jump-to-group group))
7708 (eval (cadr (assq key keystrokes)))
7709 (setq group (gnus-group-group-name))
7710 (switch-to-buffer obuf))
7711 (setq ended nil))
7712 ((equal key cmd)
7713 (if (or (not group)
7714 (gnus-ephemeral-group-p gnus-newsgroup-name))
7715 (gnus-summary-exit)
7716 (gnus-summary-next-group nil group backward)))
7717 (t
7718 (push (cdr keve) unread-command-events))))))
7719
7720(defun gnus-summary-next-unread-article ()
7721 "Select unread article after current one."
7722 (interactive)
7723 (gnus-summary-next-article
7724 (or (not (eq gnus-summary-goto-unread 'never))
7725 (gnus-summary-last-article-p (gnus-summary-article-number)))
7726 (and gnus-auto-select-same
7727 (gnus-summary-article-subject))))
7728
7729(defun gnus-summary-prev-article (&optional unread subject)
bbbe940b 7730 "Select the article before the current one.
eec82323
LMI
7731If UNREAD is non-nil, only unread articles are selected."
7732 (interactive "P")
7733 (gnus-summary-next-article unread subject t))
7734
7735(defun gnus-summary-prev-unread-article ()
7736 "Select unread article before current one."
7737 (interactive)
7738 (gnus-summary-prev-article
7739 (or (not (eq gnus-summary-goto-unread 'never))
7740 (gnus-summary-first-article-p (gnus-summary-article-number)))
7741 (and gnus-auto-select-same
7742 (gnus-summary-article-subject))))
7743
23f87bed 7744(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7745 "Show next page of the selected article.
7746If at the end of the current article, select the next article.
7747LINES says how many lines should be scrolled up.
7748
7749If CIRCULAR is non-nil, go to the start of the article instead of
7750selecting the next article when reaching the end of the current
23f87bed
MB
7751article.
7752
7753If STOP is non-nil, just stop when reaching the end of the message.
7754
7755Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7756 (interactive "P")
7757 (setq gnus-summary-buffer (current-buffer))
7758 (gnus-set-global-variables)
7759 (let ((article (gnus-summary-article-number))
7760 (article-window (get-buffer-window gnus-article-buffer t))
7761 endp)
6748645f
LMI
7762 ;; If the buffer is empty, we have no article.
7763 (unless article
7764 (error "No article to select"))
eec82323
LMI
7765 (gnus-configure-windows 'article)
7766 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7767 (if (and (eq gnus-summary-goto-unread 'never)
7768 (not (gnus-summary-last-article-p article)))
7769 (gnus-summary-next-article)
7770 (gnus-summary-next-unread-article))
7771 (if (or (null gnus-current-article)
7772 (null gnus-article-current)
7773 (/= article (cdr gnus-article-current))
7774 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7775 ;; Selected subject is different from current article's.
7776 (gnus-summary-display-article article)
7777 (when article-window
7778 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7779 (setq endp (or (gnus-article-next-page lines)
7780 (gnus-article-only-boring-p))))
eec82323 7781 (when endp
23f87bed
MB
7782 (cond (stop
7783 (gnus-message 3 "End of message"))
7784 (circular
eec82323
LMI
7785 (gnus-summary-beginning-of-article))
7786 (lines
7787 (gnus-message 3 "End of message"))
7788 ((null lines)
7789 (if (and (eq gnus-summary-goto-unread 'never)
7790 (not (gnus-summary-last-article-p article)))
7791 (gnus-summary-next-article)
7792 (gnus-summary-next-unread-article))))))))
7793 (gnus-summary-recenter)
7794 (gnus-summary-position-point)))
7795
7796(defun gnus-summary-prev-page (&optional lines move)
7797 "Show previous page of selected article.
7798Argument LINES specifies lines to be scrolled down.
7799If MOVE, move to the previous unread article if point is at
7800the beginning of the buffer."
7801 (interactive "P")
eec82323
LMI
7802 (let ((article (gnus-summary-article-number))
7803 (article-window (get-buffer-window gnus-article-buffer t))
7804 endp)
7805 (gnus-configure-windows 'article)
7806 (if (or (null gnus-current-article)
7807 (null gnus-article-current)
7808 (/= article (cdr gnus-article-current))
7809 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7810 ;; Selected subject is different from current article's.
7811 (gnus-summary-display-article article)
7812 (gnus-summary-recenter)
7813 (when article-window
7814 (gnus-eval-in-buffer-window gnus-article-buffer
7815 (setq endp (gnus-article-prev-page lines)))
7816 (when (and move endp)
7817 (cond (lines
7818 (gnus-message 3 "Beginning of message"))
7819 ((null lines)
7820 (if (and (eq gnus-summary-goto-unread 'never)
7821 (not (gnus-summary-first-article-p article)))
7822 (gnus-summary-prev-article)
7823 (gnus-summary-prev-unread-article))))))))
7824 (gnus-summary-position-point))
7825
7826(defun gnus-summary-prev-page-or-article (&optional lines)
7827 "Show previous page of selected article.
7828Argument LINES specifies lines to be scrolled down.
7829If at the beginning of the article, go to the next article."
7830 (interactive "P")
7831 (gnus-summary-prev-page lines t))
7832
7833(defun gnus-summary-scroll-up (lines)
7834 "Scroll up (or down) one line current article.
7835Argument LINES specifies lines to be scrolled up (or down if negative)."
7836 (interactive "p")
eec82323
LMI
7837 (gnus-configure-windows 'article)
7838 (gnus-summary-show-thread)
7839 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7840 (gnus-eval-in-buffer-window gnus-article-buffer
7841 (cond ((> lines 0)
7842 (when (gnus-article-next-page lines)
7843 (gnus-message 3 "End of message")))
7844 ((< lines 0)
7845 (gnus-article-prev-page (- lines))))))
7846 (gnus-summary-recenter)
7847 (gnus-summary-position-point))
7848
6748645f
LMI
7849(defun gnus-summary-scroll-down (lines)
7850 "Scroll down (or up) one line current article.
7851Argument LINES specifies lines to be scrolled down (or up if negative)."
7852 (interactive "p")
7853 (gnus-summary-scroll-up (- lines)))
7854
eec82323
LMI
7855(defun gnus-summary-next-same-subject ()
7856 "Select next article which has the same subject as current one."
7857 (interactive)
eec82323
LMI
7858 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7859
7860(defun gnus-summary-prev-same-subject ()
7861 "Select previous article which has the same subject as current one."
7862 (interactive)
eec82323
LMI
7863 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7864
7865(defun gnus-summary-next-unread-same-subject ()
7866 "Select next unread article which has the same subject as current one."
7867 (interactive)
eec82323
LMI
7868 (gnus-summary-next-article t (gnus-summary-article-subject)))
7869
7870(defun gnus-summary-prev-unread-same-subject ()
7871 "Select previous unread article which has the same subject as current one."
7872 (interactive)
eec82323
LMI
7873 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7874
7875(defun gnus-summary-first-unread-article ()
7876 "Select the first unread article.
7877Return nil if there are no unread articles."
7878 (interactive)
eec82323
LMI
7879 (prog1
7880 (when (gnus-summary-first-subject t)
7881 (gnus-summary-show-thread)
7882 (gnus-summary-first-subject t)
7883 (gnus-summary-display-article (gnus-summary-article-number)))
7884 (gnus-summary-position-point)))
7885
16409b0b
GM
7886(defun gnus-summary-first-unread-subject ()
7887 "Place the point on the subject line of the first unread article.
7888Return nil if there are no unread articles."
7889 (interactive)
7890 (prog1
7891 (when (gnus-summary-first-subject t)
7892 (gnus-summary-show-thread)
7893 (gnus-summary-first-subject t))
7894 (gnus-summary-position-point)))
7895
23f87bed
MB
7896(defun gnus-summary-first-unseen-subject ()
7897 "Place the point on the subject line of the first unseen article.
7898Return nil if there are no unseen articles."
7899 (interactive)
7900 (prog1
7901 (when (gnus-summary-first-subject nil nil t)
7902 (gnus-summary-show-thread)
7903 (gnus-summary-first-subject nil nil t))
7904 (gnus-summary-position-point)))
7905
7906(defun gnus-summary-first-unseen-or-unread-subject ()
7907 "Place the point on the subject line of the first unseen article or,
7908if all article have been seen, on the subject line of the first unread
7909article."
7910 (interactive)
7911 (prog1
7912 (unless (when (gnus-summary-first-subject nil nil t)
7913 (gnus-summary-show-thread)
7914 (gnus-summary-first-subject nil nil t))
7915 (when (gnus-summary-first-subject t)
7916 (gnus-summary-show-thread)
7917 (gnus-summary-first-subject t)))
7918 (gnus-summary-position-point)))
7919
eec82323
LMI
7920(defun gnus-summary-first-article ()
7921 "Select the first article.
7922Return nil if there are no articles."
7923 (interactive)
eec82323
LMI
7924 (prog1
7925 (when (gnus-summary-first-subject)
16409b0b
GM
7926 (gnus-summary-show-thread)
7927 (gnus-summary-first-subject)
7928 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
7929 (gnus-summary-position-point)))
7930
23f87bed
MB
7931(defun gnus-summary-best-unread-article (&optional arg)
7932 "Select the unread article with the highest score.
7933If given a prefix argument, select the next unread article that has a
7934score higher than the default score."
7935 (interactive "P")
7936 (let ((article (if arg
7937 (gnus-summary-better-unread-subject)
7938 (gnus-summary-best-unread-subject))))
7939 (if article
7940 (gnus-summary-goto-article article)
7941 (error "No unread articles"))))
7942
7943(defun gnus-summary-best-unread-subject ()
7944 "Select the unread subject with the highest score."
eec82323 7945 (interactive)
eec82323
LMI
7946 (let ((best -1000000)
7947 (data gnus-newsgroup-data)
7948 article score)
7949 (while data
7950 (and (gnus-data-unread-p (car data))
7951 (> (setq score
7952 (gnus-summary-article-score (gnus-data-number (car data))))
7953 best)
7954 (setq best score
7955 article (gnus-data-number (car data))))
7956 (setq data (cdr data)))
23f87bed
MB
7957 (when article
7958 (gnus-summary-goto-subject article))
7959 (gnus-summary-position-point)
7960 article))
7961
7962(defun gnus-summary-better-unread-subject ()
7963 "Select the first unread subject that has a score over the default score."
7964 (interactive)
7965 (let ((data gnus-newsgroup-data)
7966 article score)
7967 (while (and (setq article (gnus-data-number (car data)))
7968 (or (gnus-data-read-p (car data))
7969 (not (> (gnus-summary-article-score article)
7970 gnus-summary-default-score))))
7971 (setq data (cdr data)))
7972 (when article
7973 (gnus-summary-goto-subject article))
7974 (gnus-summary-position-point)
7975 article))
eec82323
LMI
7976
7977(defun gnus-summary-last-subject ()
7978 "Go to the last displayed subject line in the group."
7979 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7980 (when article
7981 (gnus-summary-goto-subject article))))
7982
7983(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
7984 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7985If ALL-HEADERS is non-nil, no header lines are hidden.
7986If FORCE, go to the article even if it isn't displayed. If FORCE
7987is a number, it is the line the article is to be displayed on."
eec82323
LMI
7988 (interactive
7989 (list
6748645f
LMI
7990 (completing-read
7991 "Article number or Message-ID: "
7992 (mapcar (lambda (number) (list (int-to-string number)))
7993 gnus-newsgroup-limit))
eec82323
LMI
7994 current-prefix-arg
7995 t))
7996 (prog1
6748645f 7997 (if (and (stringp article)
23f87bed 7998 (string-match "@\\|%40" article))
6748645f
LMI
7999 (gnus-summary-refer-article article)
8000 (when (stringp article)
8001 (setq article (string-to-number article)))
8002 (if (gnus-summary-goto-subject article force)
8003 (gnus-summary-display-article article all-headers)
8004 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
8005 (gnus-summary-position-point)))
8006
8007(defun gnus-summary-goto-last-article ()
8008 "Go to the previously read article."
8009 (interactive)
8010 (prog1
8011 (when gnus-last-article
6748645f 8012 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
8013 (gnus-summary-position-point)))
8014
8015(defun gnus-summary-pop-article (number)
8016 "Pop one article off the history and go to the previous.
8017NUMBER articles will be popped off."
8018 (interactive "p")
8019 (let (to)
8020 (setq gnus-newsgroup-history
8021 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8022 (if to
6748645f 8023 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
8024 (error "Article history empty")))
8025 (gnus-summary-position-point))
8026
8027;; Summary commands and functions for limiting the summary buffer.
8028
8029(defun gnus-summary-limit-to-articles (n)
8030 "Limit the summary buffer to the next N articles.
8031If not given a prefix, use the process marked articles instead."
8032 (interactive "P")
eec82323
LMI
8033 (prog1
8034 (let ((articles (gnus-summary-work-articles n)))
8035 (setq gnus-newsgroup-processable nil)
8036 (gnus-summary-limit articles))
8037 (gnus-summary-position-point)))
8038
8039(defun gnus-summary-pop-limit (&optional total)
8040 "Restore the previous limit.
8041If given a prefix, remove all limits."
8042 (interactive "P")
eec82323
LMI
8043 (when total
8044 (setq gnus-newsgroup-limits
8045 (list (mapcar (lambda (h) (mail-header-number h))
8046 gnus-newsgroup-headers))))
8047 (unless gnus-newsgroup-limits
8048 (error "No limit to pop"))
8049 (prog1
8050 (gnus-summary-limit nil 'pop)
8051 (gnus-summary-position-point)))
8052
47b63dfa
SZ
8053(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8054 "Limit the summary buffer to articles that have subjects that match a regexp.
8055If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 8056 (interactive
47b63dfa
SZ
8057 (list (read-string (if current-prefix-arg
8058 "Exclude subject (regexp): "
a1506d29 8059 "Limit to subject (regexp): "))
47b63dfa 8060 nil current-prefix-arg))
eec82323
LMI
8061 (unless header
8062 (setq header "subject"))
8063 (when (not (equal "" subject))
8064 (prog1
8065 (let ((articles (gnus-summary-find-matching
a1506d29 8066 (or header "subject") subject 'all nil nil
47b63dfa 8067 not-matching)))
eec82323
LMI
8068 (unless articles
8069 (error "Found no matches for \"%s\"" subject))
8070 (gnus-summary-limit articles))
8071 (gnus-summary-position-point))))
8072
ef6e0ec7 8073(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
8074 "Limit the summary buffer to articles that have authors that match a regexp.
8075If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 8076 (interactive
47b63dfa
SZ
8077 (list (read-string (if current-prefix-arg
8078 "Exclude author (regexp): "
a1506d29 8079 "Limit to author (regexp): "))
ef6e0ec7
SZ
8080 current-prefix-arg))
8081 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323 8082
01c52d31
MB
8083(defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8084 "Limit the summary buffer to articles with the given RECIPIENT.
8085
8086If NOT-MATCHING, exclude RECIPIENT.
8087
8088To and Cc headers are checked. You need to include them in
8089`nnmail-extra-headers'."
8090 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8091 (interactive
8092 (list (read-string (format "%s recipient (regexp): "
8093 (if current-prefix-arg "Exclude" "Limit to")))
8094 current-prefix-arg))
8095 (when (not (equal "" recipient))
8096 (prog1 (let* ((to
8097 (if (memq 'To nnmail-extra-headers)
8098 (gnus-summary-find-matching
8099 (cons 'extra 'To) recipient 'all nil nil
8100 not-matching)
8101 (gnus-message
8102 1 "`To' isn't present in `nnmail-extra-headers'")
8103 (sit-for 1)
8104 nil))
8105 (cc
8106 (if (memq 'Cc nnmail-extra-headers)
8107 (gnus-summary-find-matching
8108 (cons 'extra 'Cc) recipient 'all nil nil
8109 not-matching)
8110 (gnus-message
8111 1 "`Cc' isn't present in `nnmail-extra-headers'")
8112 (sit-for 1)
8113 nil))
8114 (articles
8115 (if not-matching
8116 ;; We need the numbers that are in both lists:
8117 (mapcar (lambda (a)
8118 (and (memq a to) a))
8119 cc)
8120 (nconc to cc))))
8121 (unless articles
8122 (error "Found no matches for \"%s\"" recipient))
8123 (gnus-summary-limit articles))
8124 (gnus-summary-position-point))))
8125
8126(defun gnus-summary-limit-to-address (address &optional not-matching)
8127 "Limit the summary buffer to articles with the given ADDRESS.
8128
8129If NOT-MATCHING, exclude ADDRESS.
8130
8131To, Cc and From headers are checked. You need to include `To' and `Cc'
8132in `nnmail-extra-headers'."
8133 (interactive
8134 (list (read-string (format "%s address (regexp): "
8135 (if current-prefix-arg "Exclude" "Limit to")))
8136 current-prefix-arg))
8137 (when (not (equal "" address))
8138 (prog1 (let* ((to
8139 (if (memq 'To nnmail-extra-headers)
8140 (gnus-summary-find-matching
8141 (cons 'extra 'To) address 'all nil nil
8142 not-matching)
8143 (gnus-message
8144 1 "`To' isn't present in `nnmail-extra-headers'")
8145 (sit-for 1)
8146 t))
8147 (cc
8148 (if (memq 'Cc nnmail-extra-headers)
8149 (gnus-summary-find-matching
8150 (cons 'extra 'Cc) address 'all nil nil
8151 not-matching)
8152 (gnus-message
8153 1 "`Cc' isn't present in `nnmail-extra-headers'")
8154 (sit-for 1)
8155 t))
8156 (from
8157 (gnus-summary-find-matching "from" address
8158 'all nil nil not-matching))
8159 (articles
8160 (if not-matching
8161 ;; We need the numbers that are in all lists:
8162 (if (eq cc t)
8163 (if (eq to t)
8164 from
8165 (mapcar (lambda (a) (car (memq a from))) to))
8166 (if (eq to t)
8167 (mapcar (lambda (a) (car (memq a from))) cc)
8168 (mapcar (lambda (a) (car (memq a from)))
8169 (mapcar (lambda (a) (car (memq a to)))
8170 cc))))
8171 (nconc (if (eq to t) nil to)
8172 (if (eq cc t) nil cc)
8173 from))))
8174 (unless articles
8175 (error "Found no matches for \"%s\"" address))
8176 (gnus-summary-limit articles))
8177 (gnus-summary-position-point))))
8178
8179(defun gnus-summary-limit-strange-charsets-predicate (header)
8180 (let ((string (concat (mail-header-subject header)
8181 (mail-header-from header)))
8182 charset found)
8183 (dotimes (i (1- (length string)))
8184 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8185 (when (string-match "unicode\\|big\\|japanese" charset)
8186 (setq found t)))
8187 found))
8188
8189(defun gnus-summary-limit-to-predicate (predicate)
8190 "Limit to articles where PREDICATE returns non-nil.
8191PREDICATE will be called with the header structures of the
8192articles."
8193 (let ((articles nil)
8194 (case-fold-search t))
8195 (dolist (header gnus-newsgroup-headers)
8196 (when (funcall predicate header)
8197 (push (mail-header-number header) articles)))
8198 (gnus-summary-limit (nreverse articles))))
8199
eec82323
LMI
8200(defun gnus-summary-limit-to-age (age &optional younger-p)
8201 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8202If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8203articles that are younger than AGE days."
16409b0b
GM
8204 (interactive
8205 (let ((younger current-prefix-arg)
8206 (days-got nil)
8207 days)
8208 (while (not days-got)
8209 (setq days (if younger
23f87bed
MB
8210 (read-string "Limit to articles younger than (in days, older when negative): ")
8211 (read-string
8212 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
8213 (when (> (length days) 0)
8214 (setq days (read days)))
8215 (if (numberp days)
23f87bed
MB
8216 (progn
8217 (setq days-got t)
01c52d31
MB
8218 (when (< days 0)
8219 (setq younger (not younger))
8220 (setq days (* days -1))))
16409b0b
GM
8221 (message "Please enter a number.")
8222 (sleep-for 1)))
8223 (list days younger)))
eec82323
LMI
8224 (prog1
8225 (let ((data gnus-newsgroup-data)
16409b0b 8226 (cutoff (days-to-time age))
eec82323
LMI
8227 articles d date is-younger)
8228 (while (setq d (pop data))
8229 (when (and (vectorp (gnus-data-header d))
8230 (setq date (mail-header-date (gnus-data-header d))))
16409b0b
GM
8231 (setq is-younger (time-less-p
8232 (time-since (condition-case ()
8233 (date-to-time date)
8234 (error '(0 0))))
eec82323 8235 cutoff))
6748645f
LMI
8236 (when (if younger-p
8237 is-younger
8238 (not is-younger))
eec82323
LMI
8239 (push (gnus-data-number d) articles))))
8240 (gnus-summary-limit (nreverse articles)))
8241 (gnus-summary-position-point)))
8242
47b63dfa 8243(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
8244 "Limit the summary buffer to articles that match an 'extra' header."
8245 (interactive
8246 (let ((header
8247 (intern
23f87bed 8248 (gnus-completing-read-with-default
16409b0b 8249 (symbol-name (car gnus-extra-headers))
47b63dfa 8250 (if current-prefix-arg
81df110a
RF
8251 "Exclude extra header"
8252 "Limit extra header")
16409b0b
GM
8253 (mapcar (lambda (x)
8254 (cons (symbol-name x) x))
8255 gnus-extra-headers)
8256 nil
8257 t))))
8258 (list header
a1506d29 8259 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
8260 (if current-prefix-arg "Exclude" "Limit to")
8261 header))
8262 current-prefix-arg)))
16409b0b
GM
8263 (when (not (equal "" regexp))
8264 (prog1
8265 (let ((articles (gnus-summary-find-matching
a1506d29 8266 (cons 'extra header) regexp 'all nil nil
47b63dfa 8267 not-matching)))
16409b0b
GM
8268 (unless articles
8269 (error "Found no matches for \"%s\"" regexp))
8270 (gnus-summary-limit articles))
8271 (gnus-summary-position-point))))
8272
23f87bed
MB
8273(defun gnus-summary-limit-to-display-predicate ()
8274 "Limit the summary buffer to the predicated in the `display' group parameter."
8275 (interactive)
8276 (unless gnus-newsgroup-display
8277 (error "There is no `display' group parameter"))
8278 (let (articles)
8279 (dolist (number gnus-newsgroup-articles)
8280 (when (funcall gnus-newsgroup-display)
8281 (push number articles)))
8282 (gnus-summary-limit articles))
8283 (gnus-summary-position-point))
8284
eec82323
LMI
8285(defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
8286(make-obsolete
265ac10b 8287 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread "Emacs 20.4")
eec82323
LMI
8288
8289(defun gnus-summary-limit-to-unread (&optional all)
8290 "Limit the summary buffer to articles that are not marked as read.
8291If ALL is non-nil, limit strictly to unread articles."
8292 (interactive "P")
8293 (if all
8294 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8295 (gnus-summary-limit-to-marks
8296 ;; Concat all the marks that say that an article is read and have
8297 ;; those removed.
8298 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 8299 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
8300 gnus-low-score-mark gnus-expirable-mark
8301 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8302 gnus-duplicate-mark gnus-souped-mark)
8303 'reverse)))
8304
01c52d31
MB
8305(defun gnus-summary-limit-to-headers (match &optional reverse)
8306 "Limit the summary buffer to articles that have headers that match MATCH.
8307If REVERSE (the prefix), limit to articles that don't match."
8308 (interactive "sMatch headers (regexp): \nP")
8309 (gnus-summary-limit-to-bodies match reverse t))
8310
8311(defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8312 "Limit the summary buffer to articles that have bodies that match MATCH.
8313If REVERSE (the prefix), limit to articles that don't match."
8314 (interactive "sMatch body (regexp): \nP")
8315 (let ((articles nil)
8316 (gnus-select-article-hook nil) ;Disable hook.
8317 (gnus-article-prepare-hook nil)
8318 (gnus-use-article-prefetch nil)
8319 (gnus-keep-backlog nil)
8320 (gnus-break-pages nil)
8321 (gnus-summary-display-arrow nil)
8322 (gnus-updated-mode-lines nil)
8323 (gnus-auto-center-summary nil)
8324 (gnus-display-mime-function nil))
8325 (dolist (data gnus-newsgroup-data)
8326 (let (gnus-mark-article-hook)
8327 (gnus-summary-select-article t t nil (gnus-data-number data)))
8328 (save-excursion
8329 (set-buffer gnus-article-buffer)
8330 (article-goto-body)
8331 (let* ((case-fold-search t)
8332 (found (if headersp
8333 (re-search-backward match nil t)
8334 (re-search-forward match nil t))))
8335 (when (or (and found
8336 (not reverse))
8337 (and (not found)
8338 reverse))
8339 (push (gnus-data-number data) articles)))))
8340 (if (not articles)
8341 (message "No messages matched")
8342 (gnus-summary-limit articles)))
8343 (gnus-summary-position-point))
8344
8345(defun gnus-summary-limit-to-singletons (&optional threadsp)
8346 "Limit the summary buffer to articles that aren't part on any thread.
8347If THREADSP (the prefix), limit to articles that are in threads."
8348 (interactive "P")
8349 (let ((articles nil)
8350 thread-articles
8351 threads)
8352 (dolist (thread gnus-newsgroup-threads)
8353 (if (stringp (car thread))
8354 (dolist (thread (cdr thread))
8355 (push thread threads))
8356 (push thread threads)))
8357 (dolist (thread threads)
8358 (setq thread-articles (gnus-articles-in-thread thread))
8359 (when (or (and threadsp
8360 (> (length thread-articles) 1))
8361 (and (not threadsp)
8362 (= (length thread-articles) 1)))
8363 (setq articles (nconc thread-articles articles))))
8364 (if (not articles)
8365 (message "No messages matched")
8366 (gnus-summary-limit articles))
8367 (gnus-summary-position-point)))
8368
8369(defun gnus-summary-limit-to-replied (&optional unreplied)
8370 "Limit the summary buffer to replied articles.
8371If UNREPLIED (the prefix), limit to unreplied articles."
8372 (interactive "P")
8373 (if unreplied
8374 (gnus-summary-limit
8375 (gnus-set-difference gnus-newsgroup-articles
8376 gnus-newsgroup-replied))
8377 (gnus-summary-limit gnus-newsgroup-replied))
8378 (gnus-summary-position-point))
8379
eec82323
LMI
8380(defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
8381(make-obsolete 'gnus-summary-delete-marked-with
265ac10b 8382 'gnus-summary-limit-exclude-marks "Emacs 20.4")
eec82323
LMI
8383
8384(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8385 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8386If REVERSE, limit the summary buffer to articles that are marked
8387with MARKS. MARKS can either be a string of marks or a list of marks.
8388Returns how many articles were removed."
8389 (interactive "sMarks: ")
8390 (gnus-summary-limit-to-marks marks t))
8391
8392(defun gnus-summary-limit-to-marks (marks &optional reverse)
8393 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8394If REVERSE (the prefix), limit the summary buffer to articles that are
8395not marked with MARKS. MARKS can either be a string of marks or a
8396list of marks.
8397Returns how many articles were removed."
6748645f 8398 (interactive "sMarks: \nP")
eec82323
LMI
8399 (prog1
8400 (let ((data gnus-newsgroup-data)
8401 (marks (if (listp marks) marks
8402 (append marks nil))) ; Transform to list.
8403 articles)
8404 (while data
8405 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8406 (memq (gnus-data-mark (car data)) marks))
8407 (push (gnus-data-number (car data)) articles))
8408 (setq data (cdr data)))
8409 (gnus-summary-limit articles))
8410 (gnus-summary-position-point)))
8411
23f87bed 8412(defun gnus-summary-limit-to-score (score)
eec82323 8413 "Limit to articles with score at or above SCORE."
23f87bed 8414 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
8415 (let ((data gnus-newsgroup-data)
8416 articles)
8417 (while data
8418 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8419 score)
8420 (push (gnus-data-number (car data)) articles))
8421 (setq data (cdr data)))
8422 (prog1
8423 (gnus-summary-limit articles)
8424 (gnus-summary-position-point))))
8425
23f87bed
MB
8426(defun gnus-summary-limit-to-unseen ()
8427 "Limit to unseen articles."
8428 (interactive)
8429 (prog1
8430 (gnus-summary-limit gnus-newsgroup-unseen)
8431 (gnus-summary-position-point)))
8432
6748645f 8433(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
8434 "Display all the hidden articles that is in the thread with ID in it.
8435When called interactively, ID is the Message-ID of the current
8436article."
6748645f
LMI
8437 (interactive (list (mail-header-id (gnus-summary-article-header))))
8438 (let ((articles (gnus-articles-in-thread
8439 (gnus-id-to-thread (gnus-root-id id)))))
8440 (prog1
8441 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
8442 (gnus-summary-limit-include-matching-articles
8443 "subject"
8444 (regexp-quote (gnus-simplify-subject-re
8445 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
8446 (gnus-summary-position-point))))
8447
23f87bed
MB
8448(defun gnus-summary-limit-include-matching-articles (header regexp)
8449 "Display all the hidden articles that have HEADERs that match REGEXP."
8450 (interactive (list (read-string "Match on header: ")
8451 (read-string "Regexp: ")))
8452 (let ((articles (gnus-find-matching-articles header regexp)))
8453 (prog1
8454 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8455 (gnus-summary-position-point))))
8456
8457(defun gnus-summary-insert-dormant-articles ()
8458 "Insert all the dormant articles for this group into the current buffer."
8459 (interactive)
8460 (let ((gnus-verbose (max 6 gnus-verbose)))
8461 (if (not gnus-newsgroup-dormant)
db629244 8462 (gnus-message 3 "No dormant articles for this group")
23f87bed
MB
8463 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8464
01c52d31
MB
8465(defun gnus-summary-insert-ticked-articles ()
8466 "Insert ticked articles for this group into the current buffer."
8467 (interactive)
8468 (let ((gnus-verbose (max 6 gnus-verbose)))
8469 (if (not gnus-newsgroup-marked)
8470 (gnus-message 3 "No ticked articles for this group")
8471 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8472
eec82323 8473(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
8474 "Display all the hidden articles that are marked as dormant.
8475Note that this command only works on a subset of the articles currently
8476fetched for this group."
eec82323 8477 (interactive)
eec82323
LMI
8478 (unless gnus-newsgroup-dormant
8479 (error "There are no dormant articles in this group"))
8480 (prog1
8481 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8482 (gnus-summary-position-point)))
8483
8484(defun gnus-summary-limit-exclude-dormant ()
8485 "Hide all dormant articles."
8486 (interactive)
eec82323
LMI
8487 (prog1
8488 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8489 (gnus-summary-position-point)))
8490
8491(defun gnus-summary-limit-exclude-childless-dormant ()
8492 "Hide all dormant articles that have no children."
8493 (interactive)
eec82323
LMI
8494 (let ((data (gnus-data-list t))
8495 articles d children)
8496 ;; Find all articles that are either not dormant or have
8497 ;; children.
8498 (while (setq d (pop data))
8499 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8500 (and (setq children
8501 (gnus-article-children (gnus-data-number d)))
8502 (let (found)
8503 (while children
8504 (when (memq (car children) articles)
8505 (setq children nil
8506 found t))
8507 (pop children))
8508 found)))
8509 (push (gnus-data-number d) articles)))
8510 ;; Do the limiting.
8511 (prog1
8512 (gnus-summary-limit articles)
8513 (gnus-summary-position-point))))
8514
8515(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8516 "Mark all unread excluded articles as read.
8517If ALL, mark even excluded ticked and dormants as read."
8518 (interactive "P")
23f87bed
MB
8519 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8520 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8521 (sort
8522 (mapcar (lambda (h) (mail-header-number h))
8523 gnus-newsgroup-headers)
8524 '<)
23f87bed 8525 gnus-newsgroup-limit))
eec82323 8526 article)
6748645f 8527 (setq gnus-newsgroup-unreads
23f87bed
MB
8528 (gnus-sorted-intersection gnus-newsgroup-unreads
8529 gnus-newsgroup-limit))
eec82323
LMI
8530 (if all
8531 (setq gnus-newsgroup-dormant nil
8532 gnus-newsgroup-marked nil
8533 gnus-newsgroup-reads
8534 (nconc
8535 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8536 gnus-newsgroup-reads))
8537 (while (setq article (pop articles))
8538 (unless (or (memq article gnus-newsgroup-dormant)
8539 (memq article gnus-newsgroup-marked))
8540 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8541
8542(defun gnus-summary-limit (articles &optional pop)
8543 (if pop
8544 ;; We pop the previous limit off the stack and use that.
8545 (setq articles (car gnus-newsgroup-limits)
8546 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8547 ;; We use the new limit, so we push the old limit on the stack.
8548 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8549 ;; Set the limit.
8550 (setq gnus-newsgroup-limit articles)
8551 (let ((total (length gnus-newsgroup-data))
8552 (data (gnus-data-find-list (gnus-summary-article-number)))
8553 (gnus-summary-mark-below nil) ; Inhibit this.
8554 found)
8555 ;; This will do all the work of generating the new summary buffer
8556 ;; according to the new limit.
8557 (gnus-summary-prepare)
8558 ;; Hide any threads, possibly.
23f87bed 8559 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8560 ;; Try to return to the article you were at, or one in the
8561 ;; neighborhood.
8562 (when data
8563 ;; We try to find some article after the current one.
8564 (while data
8565 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8566 (setq data nil
8567 found t))
8568 (setq data (cdr data))))
8569 (unless found
8570 ;; If there is no data, that means that we were after the last
8571 ;; article. The same goes when we can't find any articles
8572 ;; after the current one.
8573 (goto-char (point-max))
8574 (gnus-summary-find-prev))
6748645f 8575 (gnus-set-mode-line 'summary)
eec82323
LMI
8576 ;; We return how many articles were removed from the summary
8577 ;; buffer as a result of the new limit.
8578 (- total (length gnus-newsgroup-data))))
8579
8580(defsubst gnus-invisible-cut-children (threads)
8581 (let ((num 0))
8582 (while threads
8583 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8584 (incf num))
8585 (pop threads))
8586 (< num 2)))
8587
8588(defsubst gnus-cut-thread (thread)
8589 "Go forwards in the thread until we find an article that we want to display."
8590 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8591 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8592 (numberp gnus-fetch-old-headers)
eec82323
LMI
8593 (eq gnus-build-sparse-threads 'some)
8594 (eq gnus-build-sparse-threads 'more))
8595 ;; Deal with old-fetched headers and sparse threads.
8596 (while (and
8597 thread
8598 (or
8599 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8600 (gnus-summary-article-ancient-p
8601 (mail-header-number (car thread))))
6748645f
LMI
8602 (if (or (<= (length (cdr thread)) 1)
8603 (eq gnus-fetch-old-headers 'invisible))
8604 (setq gnus-newsgroup-limit
8605 (delq (mail-header-number (car thread))
8606 gnus-newsgroup-limit)
8607 thread (cadr thread))
8608 (when (gnus-invisible-cut-children (cdr thread))
8609 (let ((th (cdr thread)))
8610 (while th
8611 (if (memq (mail-header-number (caar th))
a8151ef7 8612 gnus-newsgroup-limit)
6748645f
LMI
8613 (setq thread (car th)
8614 th nil)
8615 (setq th (cdr th))))))))))
eec82323
LMI
8616 thread)
8617
8618(defun gnus-cut-threads (threads)
23f87bed 8619 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8620 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8621 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8622 (numberp gnus-fetch-old-headers)
eec82323
LMI
8623 (eq gnus-build-sparse-threads 'some)
8624 (eq gnus-build-sparse-threads 'more))
8625 (let ((th threads))
8626 (while th
8627 (setcar th (gnus-cut-thread (car th)))
8628 (setq th (cdr th)))))
8629 ;; Remove nixed out threads.
8630 (delq nil threads))
8631
8632(defun gnus-summary-initial-limit (&optional show-if-empty)
8633 "Figure out what the initial limit is supposed to be on group entry.
8634This entails weeding out unwanted dormants, low-scored articles,
8635fetch-old-headers verbiage, and so on."
8636 ;; Most groups have nothing to remove.
f394fa25
MB
8637 (unless (or gnus-inhibit-limiting
8638 (and (null gnus-newsgroup-dormant)
8639 (eq gnus-newsgroup-display 'gnus-not-ignore)
8640 (not (eq gnus-fetch-old-headers 'some))
8641 (not (numberp gnus-fetch-old-headers))
8642 (not (eq gnus-fetch-old-headers 'invisible))
8643 (null gnus-summary-expunge-below)
8644 (not (eq gnus-build-sparse-threads 'some))
8645 (not (eq gnus-build-sparse-threads 'more))
8646 (null gnus-thread-expunge-below)
8647 (not gnus-use-nocem)))
eec82323
LMI
8648 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8649 (setq gnus-newsgroup-limit nil)
8650 (mapatoms
8651 (lambda (node)
8652 (unless (car (symbol-value node))
8653 ;; These threads have no parents -- they are roots.
8654 (let ((nodes (cdr (symbol-value node)))
8655 thread)
8656 (while nodes
8657 (if (and gnus-thread-expunge-below
8658 (< (gnus-thread-total-score (car nodes))
8659 gnus-thread-expunge-below))
8660 (gnus-expunge-thread (pop nodes))
8661 (setq thread (pop nodes))
8662 (gnus-summary-limit-children thread))))))
8663 gnus-newsgroup-dependencies)
8664 ;; If this limitation resulted in an empty group, we might
8665 ;; pop the previous limit and use it instead.
8666 (when (and (not gnus-newsgroup-limit)
8667 show-if-empty)
8668 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8669 gnus-newsgroup-limit))
8670
8671(defun gnus-summary-limit-children (thread)
8672 "Return 1 if this subthread is visible and 0 if it is not."
8673 ;; First we get the number of visible children to this thread. This
8674 ;; is done by recursing down the thread using this function, so this
8675 ;; will really go down to a leaf article first, before slowly
8676 ;; working its way up towards the root.
8677 (when thread
04b61ae9 8678 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8679 (children
eec82323
LMI
8680 (if (cdr thread)
8681 (apply '+ (mapcar 'gnus-summary-limit-children
8682 (cdr thread)))
8683 0))
8684 (number (mail-header-number (car thread)))
8685 score)
8686 (if (and
8687 (not (memq number gnus-newsgroup-marked))
8688 (or
8689 ;; If this article is dormant and has absolutely no visible
8690 ;; children, then this article isn't visible.
8691 (and (memq number gnus-newsgroup-dormant)
8692 (zerop children))
8693 ;; If this is "fetch-old-headered" and there is no
8694 ;; visible children, then we don't want this article.
16409b0b
GM
8695 (and (or (eq gnus-fetch-old-headers 'some)
8696 (numberp gnus-fetch-old-headers))
eec82323
LMI
8697 (gnus-summary-article-ancient-p number)
8698 (zerop children))
6748645f
LMI
8699 ;; If this is "fetch-old-headered" and `invisible', then
8700 ;; we don't want this article.
8701 (and (eq gnus-fetch-old-headers 'invisible)
8702 (gnus-summary-article-ancient-p number))
eec82323
LMI
8703 ;; If this is a sparsely inserted article with no children,
8704 ;; we don't want it.
8705 (and (eq gnus-build-sparse-threads 'some)
8706 (gnus-summary-article-sparse-p number)
8707 (zerop children))
8708 ;; If we use expunging, and this article is really
8709 ;; low-scored, then we don't want this article.
8710 (when (and gnus-summary-expunge-below
8711 (< (setq score
8712 (or (cdr (assq number gnus-newsgroup-scored))
8713 gnus-summary-default-score))
8714 gnus-summary-expunge-below))
8715 ;; We increase the expunge-tally here, but that has
8716 ;; nothing to do with the limits, really.
8717 (incf gnus-newsgroup-expunged-tally)
8718 ;; We also mark as read here, if that's wanted.
8719 (when (and gnus-summary-mark-below
8720 (< score gnus-summary-mark-below))
8721 (setq gnus-newsgroup-unreads
8722 (delq number gnus-newsgroup-unreads))
8723 (if gnus-newsgroup-auto-expire
8724 (push number gnus-newsgroup-expirable)
8725 (push (cons number gnus-low-score-mark)
8726 gnus-newsgroup-reads)))
8727 t)
23f87bed
MB
8728 ;; Do the `display' group parameter.
8729 (and gnus-newsgroup-display
8730 (not (funcall gnus-newsgroup-display)))
eec82323 8731 ;; Check NoCeM things.
01c52d31
MB
8732 (when (and gnus-use-nocem
8733 (gnus-nocem-unwanted-article-p
8734 (mail-header-id (car thread))))
8735 (setq gnus-newsgroup-unreads
8736 (delq number gnus-newsgroup-unreads))
8737 t)))
eec82323
LMI
8738 ;; Nope, invisible article.
8739 0
8740 ;; Ok, this article is to be visible, so we add it to the limit
8741 ;; and return 1.
8742 (push number gnus-newsgroup-limit)
8743 1))))
8744
8745(defun gnus-expunge-thread (thread)
8746 "Mark all articles in THREAD as read."
8747 (let* ((number (mail-header-number (car thread))))
8748 (incf gnus-newsgroup-expunged-tally)
8749 ;; We also mark as read here, if that's wanted.
8750 (setq gnus-newsgroup-unreads
8751 (delq number gnus-newsgroup-unreads))
8752 (if gnus-newsgroup-auto-expire
8753 (push number gnus-newsgroup-expirable)
8754 (push (cons number gnus-low-score-mark)
8755 gnus-newsgroup-reads)))
8756 ;; Go recursively through all subthreads.
8757 (mapcar 'gnus-expunge-thread (cdr thread)))
8758
8759;; Summary article oriented commands
8760
8761(defun gnus-summary-refer-parent-article (n)
8762 "Refer parent article N times.
8763If N is negative, go to ancestor -N instead.
8764The difference between N and the number of articles fetched is returned."
8765 (interactive "p")
eec82323
LMI
8766 (let ((skip 1)
8767 error header ref)
8768 (when (not (natnump n))
8769 (setq skip (abs n)
8770 n 1))
8771 (while (and (> n 0)
8772 (not error))
8773 (setq header (gnus-summary-article-header))
8774 (if (and (eq (mail-header-number header)
8775 (cdr gnus-article-current))
8776 (equal gnus-newsgroup-name
8777 (car gnus-article-current)))
8778 ;; If we try to find the parent of the currently
8779 ;; displayed article, then we take a look at the actual
8780 ;; References header, since this is slightly more
8781 ;; reliable than the References field we got from the
8782 ;; server.
c7a91ce1 8783 (with-current-buffer gnus-original-article-buffer
eec82323
LMI
8784 (nnheader-narrow-to-headers)
8785 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8786 (when (setq ref (message-fetch-field "in-reply-to"))
8787 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8788 (widen))
8789 (setq ref
8790 ;; It's not the current article, so we take a bet on
8791 ;; the value we got from the server.
8792 (mail-header-references header)))
8793 (if (and ref
8794 (not (equal ref "")))
8795 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8796 (gnus-message 1 "Couldn't find parent"))
8797 (gnus-message 1 "No references in article %d"
8798 (gnus-summary-article-number))
8799 (setq error t))
8800 (decf n))
8801 (gnus-summary-position-point)
8802 n))
8803
8804(defun gnus-summary-refer-references ()
8805 "Fetch all articles mentioned in the References header.
6748645f 8806Return the number of articles fetched."
eec82323 8807 (interactive)
eec82323
LMI
8808 (let ((ref (mail-header-references (gnus-summary-article-header)))
8809 (current (gnus-summary-article-number))
8810 (n 0))
8811 (if (or (not ref)
8812 (equal ref ""))
8813 (error "No References in the current article")
8814 ;; For each Message-ID in the References header...
8815 (while (string-match "<[^>]*>" ref)
8816 (incf n)
8817 ;; ... fetch that article.
8818 (gnus-summary-refer-article
8819 (prog1 (match-string 0 ref)
8820 (setq ref (substring ref (match-end 0))))))
8821 (gnus-summary-goto-subject current)
8822 (gnus-summary-position-point)
8823 n)))
8824
6748645f
LMI
8825(defun gnus-summary-refer-thread (&optional limit)
8826 "Fetch all articles in the current thread.
8827If LIMIT (the numerical prefix), fetch that many old headers instead
8828of what's specified by the `gnus-refer-thread-limit' variable."
8829 (interactive "P")
8830 (let ((id (mail-header-id (gnus-summary-article-header)))
8831 (limit (if limit (prefix-numeric-value limit)
8832 gnus-refer-thread-limit)))
6748645f
LMI
8833 (unless (eq gnus-fetch-old-headers 'invisible)
8834 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8835 ;; Retrieve the headers and read them in.
23f87bed
MB
8836 (if (eq (if (numberp limit)
8837 (gnus-retrieve-headers
8838 (list (min
8839 (+ (mail-header-number
8840 (gnus-summary-article-header))
8841 limit)
8842 gnus-newsgroup-end))
8843 gnus-newsgroup-name (* limit 2))
8844 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8845 ;; headers.
8846 (gnus-retrieve-headers (list gnus-newsgroup-end)
8847 gnus-newsgroup-name limit))
6748645f
LMI
8848 'nov)
8849 (gnus-build-all-threads)
23f87bed 8850 (error "Can't fetch thread from back ends that don't support NOV"))
6748645f
LMI
8851 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8852 (gnus-summary-limit-include-thread id)))
8853
16409b0b
GM
8854(defun gnus-summary-refer-article (message-id)
8855 "Fetch an article specified by MESSAGE-ID."
8856 (interactive "sMessage-ID: ")
eec82323
LMI
8857 (when (and (stringp message-id)
8858 (not (zerop (length message-id))))
23f87bed 8859 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8860 ;; Construct the correct Message-ID if necessary.
8861 ;; Suggested by tale@pawl.rpi.edu.
8862 (unless (string-match "^<" message-id)
8863 (setq message-id (concat "<" message-id)))
8864 (unless (string-match ">$" message-id)
8865 (setq message-id (concat message-id ">")))
23f87bed
MB
8866 ;; People often post MIDs from URLs, so unhex it:
8867 (unless (string-match "@" message-id)
8868 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8869 (let* ((header (gnus-id-to-header message-id))
8870 (sparse (and header
8871 (gnus-summary-article-sparse-p
a8151ef7
LMI
8872 (mail-header-number header))
8873 (memq (mail-header-number header)
16409b0b
GM
8874 gnus-newsgroup-limit)))
8875 number)
6748645f
LMI
8876 (cond
8877 ;; If the article is present in the buffer we just go to it.
8878 ((and header
8879 (or (not (gnus-summary-article-sparse-p
8880 (mail-header-number header)))
8881 sparse))
8882 (prog1
8883 (gnus-summary-goto-article
8884 (mail-header-number header) nil t)
8885 (when sparse
8886 (gnus-summary-update-article (mail-header-number header)))))
8887 (t
16409b0b
GM
8888 ;; We fetch the article.
8889 (catch 'found
8890 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8891 (when (and (gnus-check-server gnus-override-method)
8892 ;; Fetch the header,
8893 (setq number (gnus-summary-insert-subject message-id)))
8894 ;; and display the article.
eec82323 8895 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8896 (throw 'found t)))
8897 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8898
8899(defun gnus-refer-article-methods ()
8f688cb0 8900 "Return a list of referable methods."
16409b0b
GM
8901 (cond
8902 ;; No method, so we default to current and native.
8903 ((null gnus-refer-article-method)
8904 (list gnus-current-select-method gnus-select-method))
8905 ;; Current.
8906 ((eq 'current gnus-refer-article-method)
8907 (list gnus-current-select-method))
8908 ;; List of select methods.
d4dfaa19
DL
8909 ((not (and (symbolp (car gnus-refer-article-method))
8910 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
8911 (let (out)
8912 (dolist (method gnus-refer-article-method)
8913 (push (if (eq 'current method)
8914 gnus-current-select-method
8915 method)
8916 out))
8917 (nreverse out)))
8918 ;; One single select method.
8919 (t
8920 (list gnus-refer-article-method))))
6748645f
LMI
8921
8922(defun gnus-summary-edit-parameters ()
8923 "Edit the group parameters of the current group."
8924 (interactive)
8925 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 8926
16409b0b
GM
8927(defun gnus-summary-customize-parameters ()
8928 "Customize the group parameters of the current group."
8929 (interactive)
8930 (gnus-group-customize gnus-newsgroup-name))
8931
eec82323
LMI
8932(defun gnus-summary-enter-digest-group (&optional force)
8933 "Enter an nndoc group based on the current article.
8934If FORCE, force a digest interpretation. If not, try
8935to guess what the document format is."
8936 (interactive "P")
eec82323 8937 (let ((conf gnus-current-window-configuration))
23f87bed
MB
8938 (save-window-excursion
8939 (save-excursion
8940 (let (gnus-article-prepare-hook
8941 gnus-display-mime-function
8942 gnus-break-pages)
8943 (gnus-summary-select-article))))
eec82323
LMI
8944 (setq gnus-current-window-configuration conf)
8945 (let* ((name (format "%s-%d"
8946 (gnus-group-prefixed-name
8947 gnus-newsgroup-name (list 'nndoc ""))
01c52d31 8948 (with-current-buffer gnus-summary-buffer
eec82323
LMI
8949 gnus-current-article)))
8950 (ogroup gnus-newsgroup-name)
8951 (params (append (gnus-info-params (gnus-get-info ogroup))
8952 (list (cons 'to-group ogroup))
23f87bed 8953 (list (cons 'parent-group ogroup))
eec82323
LMI
8954 (list (cons 'save-article-group ogroup))))
8955 (case-fold-search t)
8956 (buf (current-buffer))
16409b0b 8957 dig to-address)
c7a91ce1 8958 (with-current-buffer gnus-original-article-buffer
16409b0b
GM
8959 ;; Have the digest group inherit the main mail address of
8960 ;; the parent article.
23f87bed
MB
8961 (when (setq to-address (or (gnus-fetch-field "reply-to")
8962 (gnus-fetch-field "from")))
343d6628
MB
8963 (setq params
8964 (append
8965 (list (cons 'to-address
8966 (funcall gnus-decode-encoded-address-function
8967 to-address))))))
eec82323
LMI
8968 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8969 (insert-buffer-substring gnus-original-article-buffer)
8970 ;; Remove lines that may lead nndoc to misinterpret the
8971 ;; document type.
8972 (narrow-to-region
8973 (goto-char (point-min))
8974 (or (search-forward "\n\n" nil t) (point)))
8975 (goto-char (point-min))
16409b0b 8976 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8977 (widen))
8978 (unwind-protect
23f87bed 8979 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
8980 (gnus-newsgroup-ephemeral-ignored-charsets
8981 gnus-newsgroup-ignored-charsets))
8982 (gnus-group-read-ephemeral-group
8983 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8984 (nndoc-article-type
23f87bed
MB
8985 ,(if force 'mbox 'guess)))
8986 t nil nil nil
8987 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8988 "ADAPT")))))
16409b0b 8989 ;; Make all postings to this group go to the parent group.
23f87bed
MB
8990 (nconc (gnus-info-params (gnus-get-info name))
8991 params)
8992 ;; Couldn't select this doc group.
8993 (switch-to-buffer buf)
8994 (gnus-set-global-variables)
8995 (gnus-configure-windows 'summary)
8996 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
8997 (kill-buffer dig)))))
8998
8999(defun gnus-summary-read-document (n)
9000 "Open a new group based on the current article(s).
9001This will allow you to read digests and other similar
9002documents as newsgroups.
9003Obeys the standard process/prefix convention."
9004 (interactive "P")
01c52d31 9005 (let* ((ogroup gnus-newsgroup-name)
eec82323
LMI
9006 (params (append (gnus-info-params (gnus-get-info ogroup))
9007 (list (cons 'to-group ogroup))))
01c52d31
MB
9008 group egroup groups vgroup)
9009 (dolist (article (gnus-summary-work-articles n))
eec82323
LMI
9010 (setq group (format "%s-%d" gnus-newsgroup-name article))
9011 (gnus-summary-remove-process-mark article)
9012 (when (gnus-summary-display-article article)
9013 (save-excursion
16409b0b 9014 (with-temp-buffer
eec82323
LMI
9015 (insert-buffer-substring gnus-original-article-buffer)
9016 ;; Remove some headers that may lead nndoc to make
9017 ;; the wrong guess.
9018 (message-narrow-to-head)
9019 (goto-char (point-min))
01c52d31 9020 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
9021 (widen)
9022 (if (setq egroup
9023 (gnus-group-read-ephemeral-group
9024 group `(nndoc ,group (nndoc-address ,(current-buffer))
9025 (nndoc-article-type guess))
9026 t nil t))
9027 (progn
c7a91ce1 9028 ;; Make all postings to this group go to the parent group.
eec82323
LMI
9029 (nconc (gnus-info-params (gnus-get-info egroup))
9030 params)
9031 (push egroup groups))
9032 ;; Couldn't select this doc group.
9033 (gnus-error 3 "Article couldn't be entered"))))))
9034 ;; Now we have selected all the documents.
9035 (cond
9036 ((not groups)
9037 (error "None of the articles could be interpreted as documents"))
9038 ((gnus-group-read-ephemeral-group
9039 (setq vgroup (format
9040 "nnvirtual:%s-%s" gnus-newsgroup-name
9041 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9042 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9043 t
9044 (cons (current-buffer) 'summary)))
9045 (t
9046 (error "Couldn't select virtual nndoc group")))))
9047
9048(defun gnus-summary-isearch-article (&optional regexp-p)
9049 "Do incremental search forward on the current article.
9050If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9051 (interactive "P")
eec82323
LMI
9052 (gnus-summary-select-article)
9053 (gnus-configure-windows 'article)
9054 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
9055 (save-restriction
9056 (widen)
9057 (isearch-forward regexp-p))))
eec82323 9058
01c52d31
MB
9059(defun gnus-summary-repeat-search-article-forward ()
9060 "Repeat the previous search forwards."
9061 (interactive)
9062 (unless gnus-last-search-regexp
9063 (error "No previous search"))
9064 (gnus-summary-search-article-forward gnus-last-search-regexp))
9065
9066(defun gnus-summary-repeat-search-article-backward ()
9067 "Repeat the previous search backwards."
9068 (interactive)
9069 (unless gnus-last-search-regexp
9070 (error "No previous search"))
9071 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9072
eec82323
LMI
9073(defun gnus-summary-search-article-forward (regexp &optional backward)
9074 "Search for an article containing REGEXP forward.
9075If BACKWARD, search backward instead."
9076 (interactive
9077 (list (read-string
9078 (format "Search article %s (regexp%s): "
9079 (if current-prefix-arg "backward" "forward")
9080 (if gnus-last-search-regexp
9081 (concat ", default " gnus-last-search-regexp)
9082 "")))
9083 current-prefix-arg))
eec82323
LMI
9084 (if (string-equal regexp "")
9085 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
9086 (setq gnus-last-search-regexp regexp)
9087 (setq gnus-article-before-search gnus-current-article))
9088 ;; Intentionally set gnus-last-article.
9089 (setq gnus-last-article gnus-article-before-search)
9090 (let ((gnus-last-article gnus-last-article))
9091 (if (gnus-summary-search-article regexp backward)
9092 (gnus-summary-show-thread)
abc40aab 9093 (signal 'search-failed (list regexp)))))
eec82323
LMI
9094
9095(defun gnus-summary-search-article-backward (regexp)
9096 "Search for an article containing REGEXP backward."
9097 (interactive
9098 (list (read-string
9099 (format "Search article backward (regexp%s): "
9100 (if gnus-last-search-regexp
9101 (concat ", default " gnus-last-search-regexp)
9102 "")))))
9103 (gnus-summary-search-article-forward regexp 'backward))
9104
9105(defun gnus-summary-search-article (regexp &optional backward)
9106 "Search for an article containing REGEXP.
9107Optional argument BACKWARD means do search for backward.
9108`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
9109 ;; We have to require this here to make sure that the following
9110 ;; dynamic binding isn't shadowed by autoloading.
9111 (require 'gnus-async)
16409b0b 9112 (require 'gnus-art)
eec82323 9113 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 9114 (gnus-article-prepare-hook nil)
eec82323
LMI
9115 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9116 (gnus-use-article-prefetch nil)
9117 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 9118 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
9119 (gnus-visual nil)
9120 (gnus-keep-backlog nil)
9121 (gnus-break-pages nil)
9122 (gnus-summary-display-arrow nil)
9123 (gnus-updated-mode-lines nil)
9124 (gnus-auto-center-summary nil)
eec82323 9125 (sum (current-buffer))
16409b0b 9126 (gnus-display-mime-function nil)
eec82323
LMI
9127 (found nil)
9128 point)
9129 (gnus-save-hidden-threads
9130 (gnus-summary-select-article)
9131 (set-buffer gnus-article-buffer)
16409b0b 9132 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
9133 (when backward
9134 (forward-line -1))
9135 (while (not found)
9136 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9137 (if (if backward
9138 (re-search-backward regexp nil t)
9139 (re-search-forward regexp nil t))
9140 ;; We found the regexp.
9141 (progn
9142 (setq found 'found)
9143 (beginning-of-line)
9144 (set-window-start
9145 (get-buffer-window (current-buffer))
9146 (point))
9147 (forward-line 1)
16409b0b
GM
9148 (set-window-point
9149 (get-buffer-window (current-buffer))
9150 (point))
eec82323
LMI
9151 (set-buffer sum)
9152 (setq point (point)))
9153 ;; We didn't find it, so we go to the next article.
9154 (set-buffer sum)
9155 (setq found 'not)
9156 (while (eq found 'not)
9157 (if (not (if backward (gnus-summary-find-prev)
9158 (gnus-summary-find-next)))
9159 ;; No more articles.
9160 (setq found t)
9161 ;; Select the next article and adjust point.
9162 (unless (gnus-summary-article-sparse-p
9163 (gnus-summary-article-number))
9164 (setq found nil)
9165 (gnus-summary-select-article)
9166 (set-buffer gnus-article-buffer)
9167 (widen)
9168 (goto-char (if backward (point-max) (point-min))))))))
9169 (gnus-message 7 ""))
9170 ;; Return whether we found the regexp.
9171 (when (eq found 'found)
9172 (goto-char point)
9173 (gnus-summary-show-thread)
9174 (gnus-summary-goto-subject gnus-current-article)
9175 (gnus-summary-position-point)
9176 t)))
9177
23f87bed
MB
9178(defun gnus-find-matching-articles (header regexp)
9179 "Return a list of all articles that match REGEXP on HEADER.
9180This search includes all articles in the current group that Gnus has
9181fetched headers for, whether they are displayed or not."
9182 (let ((articles nil)
c7a91ce1 9183 ;; Can't eta-reduce because it's a macro.
23f87bed
MB
9184 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9185 (case-fold-search t))
9186 (dolist (header gnus-newsgroup-headers)
9187 (when (string-match regexp (funcall func header))
9188 (push (mail-header-number header) articles)))
9189 (nreverse articles)))
9190
eec82323 9191(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 9192 not-case-fold not-matching)
eec82323
LMI
9193 "Return a list of all articles that match REGEXP on HEADER.
9194The search stars on the current article and goes forwards unless
9195BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9196If UNREAD is non-nil, only unread articles will
9197be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 9198in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
9199not match REGEXP on HEADER."
9200 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
9201 articles d func)
9202 (if (consp header)
9203 (if (eq (car header) 'extra)
9204 (setq func
9205 `(lambda (h)
9206 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9207 "")))
9208 (error "%s is an invalid header" header))
9209 (unless (fboundp (intern (concat "mail-header-" header)))
9210 (error "%s is not a valid header" header))
9211 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
9212 (dolist (d (if (eq backward 'all)
9213 gnus-newsgroup-data
9214 (gnus-data-find-list
9215 (gnus-summary-article-number)
9216 (gnus-data-list backward))))
9217 (when (and (or (not unread) ; We want all articles...
9218 (gnus-data-unread-p d)) ; Or just unreads.
9219 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9220 (if not-matching
a1506d29 9221 (not (string-match
47b63dfa
SZ
9222 regexp
9223 (funcall func (gnus-data-header d))))
9224 (string-match regexp
9225 (funcall func (gnus-data-header d)))))
9226 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
9227 (nreverse articles)))
9228
9229(defun gnus-summary-execute-command (header regexp command &optional backward)
9230 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9231If HEADER is an empty string (or nil), the match is done on the entire
9232article. If BACKWARD (the prefix) is non-nil, search backward instead."
9233 (interactive
9234 (list (let ((completion-ignore-case t))
9235 (completing-read
9236 "Header name: "
23f87bed
MB
9237 (mapcar (lambda (header) (list (format "%s" header)))
9238 (append
9239 '("Number" "Subject" "From" "Lines" "Date"
9240 "Message-ID" "Xref" "References" "Body")
9241 gnus-extra-headers))
eec82323
LMI
9242 nil 'require-match))
9243 (read-string "Regexp: ")
9244 (read-key-sequence "Command: ")
9245 current-prefix-arg))
9246 (when (equal header "Body")
9247 (setq header ""))
eec82323
LMI
9248 ;; Hidden thread subtrees must be searched as well.
9249 (gnus-summary-show-all-threads)
9250 ;; We don't want to change current point nor window configuration.
9251 (save-excursion
9252 (save-window-excursion
23f87bed
MB
9253 (let (gnus-visual
9254 gnus-treat-strip-trailing-blank-lines
9255 gnus-treat-strip-leading-blank-lines
9256 gnus-treat-strip-multiple-blank-lines
9257 gnus-treat-hide-boring-headers
9258 gnus-treat-fold-newsgroups
9259 gnus-article-prepare-hook)
9260 (gnus-message 6 "Executing %s..." (key-description command))
9261 ;; We'd like to execute COMMAND interactively so as to give arguments.
9262 (gnus-execute header regexp
9263 `(call-interactively ',(key-binding command))
9264 backward)
9265 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
9266
9267(defun gnus-summary-beginning-of-article ()
9268 "Scroll the article back to the beginning."
9269 (interactive)
eec82323
LMI
9270 (gnus-summary-select-article)
9271 (gnus-configure-windows 'article)
9272 (gnus-eval-in-buffer-window gnus-article-buffer
9273 (widen)
9274 (goto-char (point-min))
23f87bed 9275 (when gnus-break-pages
eec82323
LMI
9276 (gnus-narrow-to-page))))
9277
9278(defun gnus-summary-end-of-article ()
9279 "Scroll to the end of the article."
9280 (interactive)
eec82323
LMI
9281 (gnus-summary-select-article)
9282 (gnus-configure-windows 'article)
9283 (gnus-eval-in-buffer-window gnus-article-buffer
9284 (widen)
9285 (goto-char (point-max))
9286 (recenter -3)
23f87bed 9287 (when gnus-break-pages
eec82323
LMI
9288 (gnus-narrow-to-page))))
9289
23f87bed
MB
9290(defun gnus-summary-print-truncate-and-quote (string &optional len)
9291 "Truncate to LEN and quote all \"(\"'s in STRING."
9292 (gnus-replace-in-string (if (and len (> (length string) len))
9293 (substring string 0 len)
9294 string)
9295 "[()]" "\\\\\\&"))
9296
6748645f 9297(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
9298 "Generate and print a PostScript image of the process-marked (mail) articles.
9299
9300If used interactively, print the current article if none are
9301process-marked. With prefix arg, prompt the user for the name of the
9302file to save in.
6748645f 9303
23f87bed
MB
9304When used from Lisp, accept two optional args FILENAME and N. N means
9305to print the next N articles. If N is negative, print the N previous
9306articles. If N is nil and articles have been marked with the process
9307mark, print these instead.
eec82323 9308
16409b0b 9309If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
9310printer. If FILENAME is a string, save the PostScript image in a file with
9311that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 9312to save in."
676a7cc9 9313 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
9314 (dolist (article (gnus-summary-work-articles n))
9315 (gnus-summary-select-article nil nil 'pseudo article)
9316 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 9317 (gnus-print-buffer))
676a7cc9
SZ
9318 (gnus-summary-remove-process-mark article))
9319 (ps-despool filename))
eec82323 9320
23f87bed
MB
9321(defun gnus-print-buffer ()
9322 (let ((buffer (generate-new-buffer " *print*")))
9323 (unwind-protect
9324 (progn
9325 (copy-to-buffer buffer (point-min) (point-max))
9326 (set-buffer buffer)
9327 (gnus-remove-text-with-property 'gnus-decoration)
9328 (when (gnus-visual-p 'article-highlight 'highlight)
9329 ;; Copy-to-buffer doesn't copy overlay. So redo
9330 ;; highlight.
9331 (let ((gnus-article-buffer buffer))
9332 (gnus-article-highlight-citation t)
9333 (gnus-article-highlight-signature)
9334 (gnus-article-emphasize)
9335 (gnus-article-delete-invisible-text)))
9336 (let ((ps-left-header
9337 (list
9338 (concat "("
9339 (gnus-summary-print-truncate-and-quote
9340 (mail-header-subject gnus-current-headers)
9341 66) ")")
9342 (concat "("
9343 (gnus-summary-print-truncate-and-quote
9344 (mail-header-from gnus-current-headers)
9345 45) ")")))
9346 (ps-right-header
9347 (list
9348 "/pagenumberstring load"
9349 (concat "("
9350 (mail-header-date gnus-current-headers) ")"))))
9351 (gnus-run-hooks 'gnus-ps-print-hook)
9352 (save-excursion
a7b50e1c 9353 (if ps-print-color-p
23f87bed
MB
9354 (ps-spool-buffer-with-faces)
9355 (ps-spool-buffer)))))
9356 (kill-buffer buffer))))
9357
eec82323 9358(defun gnus-summary-show-article (&optional arg)
23f87bed 9359 "Force redisplaying of the current article.
16409b0b
GM
9360If ARG (the prefix) is a number, show the article with the charset
9361defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 9362input.
16409b0b 9363If ARG (the prefix) is non-nil and not a number, show the raw article
23f87bed
MB
9364without any article massaging functions being run. Normally, the key
9365strokes are `C-u g'."
eec82323 9366 (interactive "P")
16409b0b
GM
9367 (cond
9368 ((numberp arg)
23f87bed 9369 (gnus-summary-show-article t)
16409b0b
GM
9370 (let ((gnus-newsgroup-charset
9371 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
9372 (mm-read-coding-system
9373 "View as charset: " ;; actually it is coding system.
01c52d31 9374 (with-current-buffer gnus-article-buffer
23f87bed 9375 (mm-detect-coding-region (point) (point-max))))))
16409b0b 9376 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
9377 (gnus-summary-select-article nil 'force)
9378 (let ((deps gnus-newsgroup-dependencies)
9379 head header lines)
c7a91ce1 9380 (with-current-buffer gnus-original-article-buffer
23f87bed
MB
9381 (save-restriction
9382 (message-narrow-to-head)
9383 (setq head (buffer-string))
9384 (goto-char (point-min))
9385 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9386 (goto-char (point-max))
9387 (widen)
9388 (setq lines (1- (count-lines (point) (point-max))))))
9389 (with-temp-buffer
9390 (insert (format "211 %d Article retrieved.\n"
9391 (cdr gnus-article-current)))
9392 (insert head)
9393 (if lines (insert (format "Lines: %d\n" lines)))
9394 (insert ".\n")
9395 (let ((nntp-server-buffer (current-buffer)))
9396 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9397 (gnus-data-set-header
9398 (gnus-data-find (cdr gnus-article-current))
9399 header)
9400 (gnus-summary-update-article-line
9401 (cdr gnus-article-current) header)
9402 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9403 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
9404 ((not arg)
9405 ;; Select the article the normal way.
9406 (gnus-summary-select-article nil 'force))
9407 (t
9408 ;; We have to require this here to make sure that the following
9409 ;; dynamic binding isn't shadowed by autoloading.
9410 (require 'gnus-async)
9411 (require 'gnus-art)
eec82323
LMI
9412 ;; Bind the article treatment functions to nil.
9413 (let ((gnus-have-all-headers t)
eec82323 9414 gnus-article-prepare-hook
16409b0b
GM
9415 gnus-article-decode-hook
9416 gnus-display-mime-function
9417 gnus-break-pages)
9418 ;; Destroy any MIME parts.
9419 (when (gnus-buffer-live-p gnus-article-buffer)
c7a91ce1 9420 (with-current-buffer gnus-article-buffer
16409b0b
GM
9421 (mm-destroy-parts gnus-article-mime-handles)
9422 ;; Set it to nil for safety reason.
9423 (setq gnus-article-mime-handle-alist nil)
9424 (setq gnus-article-mime-handles nil)))
9425 (gnus-summary-select-article nil 'force))))
eec82323
LMI
9426 (gnus-summary-goto-subject gnus-current-article)
9427 (gnus-summary-position-point))
9428
23f87bed
MB
9429(defun gnus-summary-show-raw-article ()
9430 "Show the raw article without any article massaging functions being run."
9431 (interactive)
9432 (gnus-summary-show-article t))
9433
eec82323
LMI
9434(defun gnus-summary-verbose-headers (&optional arg)
9435 "Toggle permanent full header display.
9436If ARG is a positive number, turn header display on.
9437If ARG is a negative number, turn header display off."
9438 (interactive "P")
eec82323
LMI
9439 (setq gnus-show-all-headers
9440 (cond ((or (not (numberp arg))
9441 (zerop arg))
9442 (not gnus-show-all-headers))
9443 ((natnump arg)
9444 t)))
9445 (gnus-summary-show-article))
9446
9447(defun gnus-summary-toggle-header (&optional arg)
9448 "Show the headers if they are hidden, or hide them if they are shown.
9449If ARG is a positive number, show the entire header.
9450If ARG is a negative number, hide the unwanted header lines."
9451 (interactive "P")
23f87bed
MB
9452 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9453 (get-buffer-window gnus-article-buffer t))))
9454 (with-current-buffer gnus-article-buffer
9455 (widen)
9456 (article-narrow-to-head)
c7a91ce1 9457 (let* ((inhibit-read-only t)
16409b0b 9458 (inhibit-point-motion-hooks t)
23f87bed
MB
9459 (hidden (if (numberp arg)
9460 (>= arg 0)
f0096211
MB
9461 (or (not (looking-at "[^ \t\n]+:"))
9462 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
9463 s e)
9464 (delete-region (point-min) (point-max))
667e0ba6
SM
9465 (with-current-buffer gnus-original-article-buffer
9466 (goto-char (setq s (point-min)))
23f87bed
MB
9467 (setq e (if (search-forward "\n\n" nil t)
9468 (1- (point))
9469 (point-max))))
667e0ba6 9470 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
9471 (run-hooks 'gnus-article-decode-hook)
9472 (if hidden
9473 (let ((gnus-treat-hide-headers nil)
9474 (gnus-treat-hide-boring-headers nil))
9475 (gnus-delete-wash-type 'headers)
9476 (gnus-treat-article 'head))
9477 (gnus-treat-article 'head))
9478 (widen)
9479 (if window
9480 (set-window-start window (goto-char (point-min))))
9481 (if gnus-break-pages
9482 (gnus-narrow-to-page)
9483 (when (gnus-visual-p 'page-marker)
c7a91ce1 9484 (let ((inhibit-read-only t))
23f87bed
MB
9485 (gnus-remove-text-with-property 'gnus-prev)
9486 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9487 (gnus-set-mode-line 'article)))))
eec82323
LMI
9488
9489(defun gnus-summary-show-all-headers ()
9490 "Make all header lines visible."
9491 (interactive)
23f87bed 9492 (gnus-summary-toggle-header 1))
eec82323 9493
eec82323
LMI
9494(defun gnus-summary-caesar-message (&optional arg)
9495 "Caesar rotate the current article by 13.
01c52d31
MB
9496With a non-numerical prefix, also rotate headers. A numerical
9497prefix specifies how many places to rotate each letter forward."
eec82323 9498 (interactive "P")
eec82323
LMI
9499 (gnus-summary-select-article)
9500 (let ((mail-header-separator ""))
9501 (gnus-eval-in-buffer-window gnus-article-buffer
9502 (save-restriction
9503 (widen)
9504 (let ((start (window-start))
c7a91ce1 9505 (inhibit-read-only t))
01c52d31
MB
9506 (if (equal arg '(4))
9507 (message-caesar-buffer-body nil t)
9508 (message-caesar-buffer-body arg))
ff4d3926
MB
9509 (set-window-start (get-buffer-window (current-buffer)) start)))))
9510 ;; Create buttons and stuff...
9511 (gnus-treat-article nil))
eec82323 9512
704f1663
GM
9513(declare-function idna-to-unicode "ext:idna" (str))
9514
01c52d31
MB
9515(defun gnus-summary-idna-message (&optional arg)
9516 "Decode IDNA encoded domain names in the current articles.
9517IDNA encoded domain names looks like `xn--bar'. If a string
9518remain unencoded after running this function, it is likely an
9519invalid IDNA string (`xn--bar' is invalid).
9520
9521You must have GNU Libidn (`http://www.gnu.org/software/libidn/')
9522installed for this command to work."
9523 (interactive "P")
9524 (if (not (and (condition-case nil (require 'idna)
9525 (file-error))
9526 (mm-coding-system-p 'utf-8)
9527 (executable-find (symbol-value 'idna-program))))
9528 (gnus-message
9529 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9530 (gnus-summary-select-article)
9531 (let ((mail-header-separator ""))
9532 (gnus-eval-in-buffer-window gnus-article-buffer
9533 (save-restriction
9534 (widen)
9535 (let ((start (window-start))
9536 buffer-read-only)
9537 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9538 (replace-match (idna-to-unicode (match-string 1))))
9539 (set-window-start (get-buffer-window (current-buffer)) start)))))))
23f87bed
MB
9540
9541(defun gnus-summary-morse-message (&optional arg)
9542 "Morse decode the current article."
9543 (interactive "P")
9544 (gnus-summary-select-article)
9545 (let ((mail-header-separator ""))
9546 (gnus-eval-in-buffer-window gnus-article-buffer
9547 (save-excursion
9548 (save-restriction
9549 (widen)
9550 (let ((pos (window-start))
c7a91ce1 9551 (inhibit-read-only t))
23f87bed
MB
9552 (goto-char (point-min))
9553 (when (message-goto-body)
9554 (gnus-narrow-to-body))
9555 (goto-char (point-min))
01c52d31 9556