(gnus-summary-highlight): Fix typo in docstring.
[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,
d7a0267c 4;; 2005, 2006, 2007 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
11;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
13;; the Free Software Foundation; either version 2, or (at your option)
14;; any later version.
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
22;; along with GNU Emacs; see the file COPYING. If not, write to the
3a35cf56
LK
23;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24;; Boston, MA 02110-1301, USA.
eec82323
LMI
25
26;;; Commentary:
27
28;;; Code:
29
23f87bed
MB
30(eval-when-compile
31 (require 'cl)
f67d6742 32 (defvar tool-bar-mode))
5ab7173c 33
eec82323
LMI
34(require 'gnus)
35(require 'gnus-group)
36(require 'gnus-spec)
37(require 'gnus-range)
38(require 'gnus-int)
39(require 'gnus-undo)
6748645f 40(require 'gnus-util)
18c06a99 41(require 'gmm-utils)
16409b0b 42(require 'mm-decode)
08c9a385 43(require 'nnoo)
23f87bed 44
6748645f 45(autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
d4dfaa19 46(autoload 'gnus-cache-write-active "gnus-cache")
23f87bed
MB
47(autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
48(autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
531e5812 49(autoload 'gnus-pick-line-number "gnus-salt" nil t)
08c9a385 50(autoload 'mm-uu-dissect "mm-uu")
23f87bed
MB
51(autoload 'gnus-article-outlook-deuglify-article "deuglify"
52 "Deuglify broken Outlook (Express) articles and redisplay."
53 t)
54(autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
55(autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
56(autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
eec82323
LMI
57
58(defcustom gnus-kill-summary-on-exit t
59 "*If non-nil, kill the summary buffer when you exit from it.
60If nil, the summary will become a \"*Dead Summary*\" buffer, and
61it will be killed sometime later."
62 :group 'gnus-summary-exit
63 :type 'boolean)
64
65(defcustom gnus-fetch-old-headers nil
66 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
67If an unread article in the group refers to an older, already read (or
68just marked as read) article, the old article will not normally be
1232b9cb 69displayed in the Summary buffer. If this variable is t, Gnus
eec82323 70will attempt to grab the headers to the old articles, and thereby
6748645f
LMI
71build complete threads. If it has the value `some', only enough
72headers to connect otherwise loose threads will be displayed. This
73variable can also be a number. In that case, no more than that number
74of old headers will be fetched. If it has the value `invisible', all
75old headers will be fetched, but none will be displayed.
eec82323
LMI
76
77The server has to support NOV for any of this to work."
78 :group 'gnus-thread
79 :type '(choice (const :tag "off" nil)
1232b9cb 80 (const :tag "on" t)
eec82323 81 (const some)
1232b9cb 82 (const invisible)
eec82323
LMI
83 number
84 (sexp :menu-tag "other" t)))
85
6748645f
LMI
86(defcustom gnus-refer-thread-limit 200
87 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
88If t, fetch all the available old headers."
89 :group 'gnus-thread
90 :type '(choice number
91 (sexp :menu-tag "other" t)))
92
eec82323
LMI
93(defcustom gnus-summary-make-false-root 'adopt
94 "*nil means that Gnus won't gather loose threads.
95If the root of a thread has expired or been read in a previous
96session, the information necessary to build a complete thread has been
97lost. Instead of having many small sub-threads from this original thread
98scattered all over the summary buffer, Gnus can gather them.
99
100If non-nil, Gnus will try to gather all loose sub-threads from an
101original thread into one large thread.
102
103If this variable is non-nil, it should be one of `none', `adopt',
104`dummy' or `empty'.
105
106If this variable is `none', Gnus will not make a false root, but just
107present the sub-threads after another.
108If this variable is `dummy', Gnus will create a dummy root that will
109have all the sub-threads as children.
110If this variable is `adopt', Gnus will make one of the \"children\"
111the parent and mark all the step-children as such.
112If this variable is `empty', the \"children\" are printed with empty
01ccbb85 113subject fields. (Or rather, they will be printed with a string
eec82323
LMI
114given by the `gnus-summary-same-subject' variable.)"
115 :group 'gnus-thread
116 :type '(choice (const :tag "off" nil)
117 (const none)
118 (const dummy)
119 (const adopt)
120 (const empty)))
121
23f87bed
MB
122(defcustom gnus-summary-make-false-root-always nil
123 "Always make a false dummy root."
bf247b6e 124 :version "22.1"
23f87bed
MB
125 :group 'gnus-thread
126 :type 'boolean)
127
eec82323
LMI
128(defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
129 "*A regexp to match subjects to be excluded from loose thread gathering.
130As loose thread gathering is done on subjects only, that means that
131there can be many false gatherings performed. By rooting out certain
132common subjects, gathering might become saner."
133 :group 'gnus-thread
134 :type 'regexp)
135
136(defcustom gnus-summary-gather-subject-limit nil
137 "*Maximum length of subject comparisons when gathering loose threads.
138Use nil to compare full subjects. Setting this variable to a low
139number will help gather threads that have been corrupted by
140newsreaders chopping off subject lines, but it might also mean that
141unrelated articles that have subject that happen to begin with the
142same few characters will be incorrectly gathered.
143
144If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
145comparing subjects."
146 :group 'gnus-thread
147 :type '(choice (const :tag "off" nil)
148 (const fuzzy)
149 (sexp :menu-tag "on" t)))
150
6748645f
LMI
151(defcustom gnus-simplify-subject-functions nil
152 "List of functions taking a string argument that simplify subjects.
153The functions are applied recursively.
154
23f87bed
MB
155Useful functions to put in this list include:
156`gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
157`gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
6748645f
LMI
158 :group 'gnus-thread
159 :type '(repeat function))
160
eec82323 161(defcustom gnus-simplify-ignored-prefixes nil
23f87bed 162 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
eec82323
LMI
163 :group 'gnus-thread
164 :type '(choice (const :tag "off" nil)
165 regexp))
166
167(defcustom gnus-build-sparse-threads nil
168 "*If non-nil, fill in the gaps in threads.
169If `some', only fill in the gaps that are needed to tie loose threads
170together. If `more', fill in all leaf nodes that Gnus can find. If
171non-nil and non-`some', fill in all gaps that Gnus manages to guess."
172 :group 'gnus-thread
173 :type '(choice (const :tag "off" nil)
174 (const some)
175 (const more)
176 (sexp :menu-tag "all" t)))
177
178(defcustom gnus-summary-thread-gathering-function
179 'gnus-gather-threads-by-subject
6748645f 180 "*Function used for gathering loose threads.
eec82323
LMI
181There are two pre-defined functions: `gnus-gather-threads-by-subject',
182which only takes Subjects into consideration; and
183`gnus-gather-threads-by-references', which compared the References
184headers of the articles to find matches."
185 :group 'gnus-thread
22115a9e
RS
186 :type '(radio (function-item gnus-gather-threads-by-subject)
187 (function-item gnus-gather-threads-by-references)
188 (function :tag "other")))
eec82323 189
eec82323
LMI
190(defcustom gnus-summary-same-subject ""
191 "*String indicating that the current article has the same subject as the previous.
192This variable will only be used if the value of
193`gnus-summary-make-false-root' is `empty'."
194 :group 'gnus-summary-format
195 :type 'string)
196
197(defcustom gnus-summary-goto-unread t
16409b0b
GM
198 "*If t, many commands will go to the next unread article.
199This applies to marking commands as well as other commands that
200\"naturally\" select the next article, like, for instance, `SPC' at
201the end of an article.
202
203If nil, the marking commands do NOT go to the next unread article
2642ac8f 204\(they go to the next article instead). If `never', commands that
16409b0b
GM
205usually go to the next unread article, will go to the next article,
206whether it is read or not."
eec82323
LMI
207 :group 'gnus-summary-marks
208 :link '(custom-manual "(gnus)Setting Marks")
209 :type '(choice (const :tag "off" nil)
210 (const never)
211 (sexp :menu-tag "on" t)))
212
213(defcustom gnus-summary-default-score 0
214 "*Default article score level.
215All scores generated by the score files will be added to this score.
216If this variable is nil, scoring will be disabled."
217 :group 'gnus-score-default
218 :type '(choice (const :tag "disable")
219 integer))
220
23f87bed
MB
221(defcustom gnus-summary-default-high-score 0
222 "*Default threshold for a high scored article.
223An article will be highlighted as high scored if its score is greater
224than this score."
bf247b6e 225 :version "22.1"
23f87bed
MB
226 :group 'gnus-score-default
227 :type 'integer)
228
229(defcustom gnus-summary-default-low-score 0
230 "*Default threshold for a low scored article.
231An article will be highlighted as low scored if its score is smaller
232than this score."
bf247b6e 233 :version "22.1"
23f87bed
MB
234 :group 'gnus-score-default
235 :type 'integer)
236
eec82323
LMI
237(defcustom gnus-summary-zcore-fuzz 0
238 "*Fuzziness factor for the zcore in the summary buffer.
239Articles with scores closer than this to `gnus-summary-default-score'
240will not be marked."
241 :group 'gnus-summary-format
242 :type 'integer)
243
244(defcustom gnus-simplify-subject-fuzzy-regexp nil
245 "*Strings to be removed when doing fuzzy matches.
246This can either be a regular expression or list of regular expressions
247that will be removed from subject strings if fuzzy subject
248simplification is selected."
249 :group 'gnus-thread
250 :type '(repeat regexp))
251
252(defcustom gnus-show-threads t
253 "*If non-nil, display threads in summary mode."
254 :group 'gnus-thread
255 :type 'boolean)
256
257(defcustom gnus-thread-hide-subtree nil
258 "*If non-nil, hide all threads initially.
23f87bed 259This can be a predicate specifier which says which threads to hide.
eec82323 260If threads are hidden, you have to run the command
4a2358e9 261`gnus-summary-show-thread' by hand or select an article."
eec82323 262 :group 'gnus-thread
23f87bed
MB
263 :type '(radio (sexp :format "Non-nil\n"
264 :match (lambda (widget value)
265 (not (or (consp value) (functionp value))))
266 :value t)
267 (const nil)
ad136a7c 268 (sexp :tag "Predicate specifier")))
eec82323
LMI
269
270(defcustom gnus-thread-hide-killed t
271 "*If non-nil, hide killed threads automatically."
272 :group 'gnus-thread
273 :type 'boolean)
274
6748645f
LMI
275(defcustom gnus-thread-ignore-subject t
276 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
277If nil, articles that have different subjects from their parents will
278start separate threads."
eec82323
LMI
279 :group 'gnus-thread
280 :type 'boolean)
281
282(defcustom gnus-thread-operation-ignore-subject t
283 "*If non-nil, subjects will be ignored when doing thread commands.
284This affects commands like `gnus-summary-kill-thread' and
285`gnus-summary-lower-thread'.
286
287If this variable is nil, articles in the same thread with different
288subjects will not be included in the operation in question. If this
289variable is `fuzzy', only articles that have subjects that are fuzzily
290equal will be included."
291 :group 'gnus-thread
292 :type '(choice (const :tag "off" nil)
293 (const fuzzy)
294 (sexp :tag "on" t)))
295
296(defcustom gnus-thread-indent-level 4
297 "*Number that says how much each sub-thread should be indented."
298 :group 'gnus-thread
299 :type 'integer)
300
301(defcustom gnus-auto-extend-newsgroup t
302 "*If non-nil, extend newsgroup forward and backward when requested."
303 :group 'gnus-summary-choose
304 :type 'boolean)
305
306(defcustom gnus-auto-select-first t
651408cb
MB
307 "If non-nil, select an article on group entry.
308An article is selected automatically when entering a group
309e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
310`gnus-summary-catchup-and-goto-next-group'.
311
312Which article is selected is controlled by the variable
313`gnus-auto-select-subject'.
23f87bed
MB
314
315If you want to prevent automatic selection of articles in some
316newsgroups, set the variable to nil in `gnus-select-group-hook'."
651408cb
MB
317 ;; Commands include...
318 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
319 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
320 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
eec82323
LMI
321 :group 'gnus-group-select
322 :type '(choice (const :tag "none" nil)
23f87bed
MB
323 (sexp :menu-tag "first" t)))
324
325(defcustom gnus-auto-select-subject 'unread
326 "*Says what subject to place under point when entering a group.
327
328This variable can either be the symbols `first' (place point on the
329first subject), `unread' (place point on the subject line of the first
330unread article), `best' (place point on the subject line of the
331higest-scored article), `unseen' (place point on the subject line of
99b5aab7 332the first unseen article), `unseen-or-unread' (place point on the subject
23f87bed
MB
333line of the first unseen article or, if all article have been seen, on the
334subject line of the first unread article), or a function to be called to
335place point on some subject line."
bf247b6e 336 :version "22.1"
23f87bed
MB
337 :group 'gnus-group-select
338 :type '(choice (const best)
339 (const unread)
340 (const first)
341 (const unseen)
342 (const unseen-or-unread)))
eec82323
LMI
343
344(defcustom gnus-auto-select-next t
345 "*If non-nil, offer to go to the next group from the end of the previous.
346If the value is t and the next newsgroup is empty, Gnus will exit
23f87bed
MB
347summary mode and go back to group mode. If the value is neither nil
348nor t, Gnus will select the following unread newsgroup. In
eec82323
LMI
349particular, if the value is the symbol `quietly', the next unread
350newsgroup will be selected without any confirmation, and if it is
351`almost-quietly', the next group will be selected without any
352confirmation if you are located on the last article in the group.
23f87bed 353Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
eec82323
LMI
354will go to the next group without confirmation."
355 :group 'gnus-summary-maneuvering
356 :type '(choice (const :tag "off" nil)
357 (const quietly)
358 (const almost-quietly)
359 (const slightly-quietly)
360 (sexp :menu-tag "on" t)))
361
362(defcustom gnus-auto-select-same nil
6748645f
LMI
363 "*If non-nil, select the next article with the same subject.
364If there are no more articles with the same subject, go to
365the first unread article."
eec82323
LMI
366 :group 'gnus-summary-maneuvering
367 :type 'boolean)
368
23f87bed
MB
369(defcustom gnus-auto-goto-ignores 'unfetched
370 "*Says how to handle unfetched articles when maneuvering.
371
372This variable can either be the symbols nil (maneuver to any
373article), `undownloaded' (maneuvering while unplugged ignores articles
374that have not been fetched), `always-undownloaded' (maneuvering always
375ignores articles that have not been fetched), `unfetched' (maneuvering
376ignores articles whose headers have not been fetched).
377
378NOTE: The list of unfetched articles will always be nil when plugged
379and, when unplugged, a subset of the undownloaded article list."
bf247b6e 380 :version "22.1"
23f87bed
MB
381 :group 'gnus-summary-maneuvering
382 :type '(choice (const :tag "None" nil)
383 (const :tag "Undownloaded when unplugged" undownloaded)
384 (const :tag "Undownloaded" always-undownloaded)
385 (const :tag "Unfetched" unfetched)))
386
eec82323
LMI
387(defcustom gnus-summary-check-current nil
388 "*If non-nil, consider the current article when moving.
389The \"unread\" movement commands will stay on the same line if the
390current article is unread."
391 :group 'gnus-summary-maneuvering
392 :type 'boolean)
393
394(defcustom gnus-auto-center-summary t
395 "*If non-nil, always center the current summary buffer.
396In particular, if `vertical' do only vertical recentering. If non-nil
397and non-`vertical', do both horizontal and vertical recentering."
398 :group 'gnus-summary-maneuvering
399 :type '(choice (const :tag "none" nil)
400 (const vertical)
16409b0b 401 (integer :tag "height")
eec82323
LMI
402 (sexp :menu-tag "both" t)))
403
23f87bed
MB
404(defvar gnus-auto-center-group t
405 "*If non-nil, always center the group buffer.")
406
eec82323
LMI
407(defcustom gnus-show-all-headers nil
408 "*If non-nil, don't hide any headers."
409 :group 'gnus-article-hiding
410 :group 'gnus-article-headers
411 :type 'boolean)
412
413(defcustom gnus-summary-ignore-duplicates nil
414 "*If non-nil, ignore articles with identical Message-ID headers."
415 :group 'gnus-summary
416 :type 'boolean)
6748645f 417
eec82323
LMI
418(defcustom gnus-single-article-buffer t
419 "*If non-nil, display all articles in the same buffer.
420If nil, each group will get its own article buffer."
421 :group 'gnus-article-various
422 :type 'boolean)
423
424(defcustom gnus-break-pages t
425 "*If non-nil, do page breaking on articles.
426The page delimiter is specified by the `gnus-page-delimiter'
427variable."
428 :group 'gnus-article-various
429 :type 'boolean)
430
eec82323
LMI
431(defcustom gnus-move-split-methods nil
432 "*Variable used to suggest where articles are to be moved to.
23f87bed
MB
433It uses the same syntax as the `gnus-split-methods' variable.
434However, whereas `gnus-split-methods' specifies file names as targets,
435this variable specifies group names."
eec82323 436 :group 'gnus-summary-mail
6748645f
LMI
437 :type '(repeat (choice (list :value (fun) function)
438 (cons :value ("" "") regexp (repeat string))
439 (sexp :value nil))))
eec82323 440
e62e7654
MB
441;; FIXME: Although the custom type is `character' for the following variables,
442;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
443
23f87bed 444(defcustom gnus-unread-mark ? ;Whitespace
eec82323
LMI
445 "*Mark used for unread articles."
446 :group 'gnus-summary-marks
447 :type 'character)
448
449(defcustom gnus-ticked-mark ?!
450 "*Mark used for ticked articles."
451 :group 'gnus-summary-marks
452 :type 'character)
453
454(defcustom gnus-dormant-mark ??
455 "*Mark used for dormant articles."
456 :group 'gnus-summary-marks
457 :type 'character)
458
459(defcustom gnus-del-mark ?r
460 "*Mark used for del'd articles."
461 :group 'gnus-summary-marks
462 :type 'character)
463
464(defcustom gnus-read-mark ?R
465 "*Mark used for read articles."
466 :group 'gnus-summary-marks
467 :type 'character)
468
469(defcustom gnus-expirable-mark ?E
470 "*Mark used for expirable articles."
471 :group 'gnus-summary-marks
472 :type 'character)
473
474(defcustom gnus-killed-mark ?K
475 "*Mark used for killed articles."
476 :group 'gnus-summary-marks
477 :type 'character)
478
23f87bed
MB
479(defcustom gnus-spam-mark ?$
480 "*Mark used for spam articles."
bf247b6e 481 :version "22.1"
23f87bed
MB
482 :group 'gnus-summary-marks
483 :type 'character)
484
eec82323 485(defcustom gnus-souped-mark ?F
23f87bed 486 "*Mark used for souped articles."
eec82323
LMI
487 :group 'gnus-summary-marks
488 :type 'character)
489
490(defcustom gnus-kill-file-mark ?X
491 "*Mark used for articles killed by kill files."
492 :group 'gnus-summary-marks
493 :type 'character)
494
495(defcustom gnus-low-score-mark ?Y
496 "*Mark used for articles with a low score."
497 :group 'gnus-summary-marks
498 :type 'character)
499
500(defcustom gnus-catchup-mark ?C
501 "*Mark used for articles that are caught up."
502 :group 'gnus-summary-marks
503 :type 'character)
504
505(defcustom gnus-replied-mark ?A
506 "*Mark used for articles that have been replied to."
507 :group 'gnus-summary-marks
508 :type 'character)
509
23f87bed
MB
510(defcustom gnus-forwarded-mark ?F
511 "*Mark used for articles that have been forwarded."
bf247b6e 512 :version "22.1"
23f87bed
MB
513 :group 'gnus-summary-marks
514 :type 'character)
515
516(defcustom gnus-recent-mark ?N
517 "*Mark used for articles that are recent."
bf247b6e 518 :version "22.1"
23f87bed
MB
519 :group 'gnus-summary-marks
520 :type 'character)
521
eec82323
LMI
522(defcustom gnus-cached-mark ?*
523 "*Mark used for articles that are in the cache."
524 :group 'gnus-summary-marks
525 :type 'character)
526
527(defcustom gnus-saved-mark ?S
23f87bed
MB
528 "*Mark used for articles that have been saved."
529 :group 'gnus-summary-marks
530 :type 'character)
531
532(defcustom gnus-unseen-mark ?.
533 "*Mark used for articles that haven't been seen."
bf247b6e 534 :version "22.1"
23f87bed
MB
535 :group 'gnus-summary-marks
536 :type 'character)
537
538(defcustom gnus-no-mark ? ;Whitespace
539 "*Mark used for articles that have no other secondary mark."
bf247b6e 540 :version "22.1"
eec82323
LMI
541 :group 'gnus-summary-marks
542 :type 'character)
543
544(defcustom gnus-ancient-mark ?O
545 "*Mark used for ancient articles."
546 :group 'gnus-summary-marks
547 :type 'character)
548
549(defcustom gnus-sparse-mark ?Q
550 "*Mark used for sparsely reffed articles."
551 :group 'gnus-summary-marks
552 :type 'character)
553
554(defcustom gnus-canceled-mark ?G
555 "*Mark used for canceled articles."
556 :group 'gnus-summary-marks
557 :type 'character)
558
559(defcustom gnus-duplicate-mark ?M
560 "*Mark used for duplicate articles."
561 :group 'gnus-summary-marks
562 :type 'character)
563
23f87bed 564(defcustom gnus-undownloaded-mark ?-
6748645f 565 "*Mark used for articles that weren't downloaded."
bf247b6e 566 :version "22.1"
6748645f
LMI
567 :group 'gnus-summary-marks
568 :type 'character)
569
23f87bed
MB
570(defcustom gnus-downloaded-mark ?+
571 "*Mark used for articles that were downloaded."
572 :group 'gnus-summary-marks
573 :type 'character)
574
6748645f
LMI
575(defcustom gnus-downloadable-mark ?%
576 "*Mark used for articles that are to be downloaded."
577 :group 'gnus-summary-marks
578 :type 'character)
579
580(defcustom gnus-unsendable-mark ?=
581 "*Mark used for articles that won't be sent."
582 :group 'gnus-summary-marks
583 :type 'character)
584
eec82323
LMI
585(defcustom gnus-score-over-mark ?+
586 "*Score mark used for articles with high scores."
587 :group 'gnus-summary-marks
588 :type 'character)
589
590(defcustom gnus-score-below-mark ?-
591 "*Score mark used for articles with low scores."
592 :group 'gnus-summary-marks
593 :type 'character)
594
23f87bed 595(defcustom gnus-empty-thread-mark ? ;Whitespace
eec82323
LMI
596 "*There is no thread under the article."
597 :group 'gnus-summary-marks
598 :type 'character)
599
600(defcustom gnus-not-empty-thread-mark ?=
601 "*There is a thread under the article."
602 :group 'gnus-summary-marks
603 :type 'character)
604
605(defcustom gnus-view-pseudo-asynchronously nil
606 "*If non-nil, Gnus will view pseudo-articles asynchronously."
607 :group 'gnus-extract-view
608 :type 'boolean)
609
16409b0b
GM
610(defcustom gnus-auto-expirable-marks
611 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
612 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
613 gnus-souped-mark gnus-duplicate-mark)
614 "*The list of marks converted into expiration if a group is auto-expirable."
58e39d05 615 :version "21.1"
16409b0b
GM
616 :group 'gnus-summary
617 :type '(repeat character))
618
619(defcustom gnus-inhibit-user-auto-expire t
620 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
58e39d05 621 :version "21.1"
16409b0b
GM
622 :group 'gnus-summary
623 :type 'boolean)
624
eec82323
LMI
625(defcustom gnus-view-pseudos nil
626 "*If `automatic', pseudo-articles will be viewed automatically.
627If `not-confirm', pseudos will be viewed automatically, and the user
628will not be asked to confirm the command."
629 :group 'gnus-extract-view
630 :type '(choice (const :tag "off" nil)
631 (const automatic)
632 (const not-confirm)))
633
634(defcustom gnus-view-pseudos-separately t
635 "*If non-nil, one pseudo-article will be created for each file to be viewed.
636If nil, all files that use the same viewing command will be given as a
637list of parameters to that command."
638 :group 'gnus-extract-view
639 :type 'boolean)
640
641(defcustom gnus-insert-pseudo-articles t
642 "*If non-nil, insert pseudo-articles when decoding articles."
643 :group 'gnus-extract-view
644 :type 'boolean)
645
646(defcustom gnus-summary-dummy-line-format
23f87bed 647 " %(: :%) %S\n"
eec82323
LMI
648 "*The format specification for the dummy roots in the summary buffer.
649It works along the same lines as a normal formatting string,
650with some simple extensions.
651
23f87bed
MB
652%S The subject
653
654General format specifiers can also be used.
655See `(gnus)Formatting Variables'."
656 :link '(custom-manual "(gnus)Formatting Variables")
eec82323
LMI
657 :group 'gnus-threading
658 :type 'string)
659
16409b0b 660(defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
eec82323
LMI
661 "*The format specification for the summary mode line.
662It works along the same lines as a normal formatting string,
663with some simple extensions:
664
665%G Group name
666%p Unprefixed group name
667%A Current article number
6748645f 668%z Current article score
eec82323
LMI
669%V Gnus version
670%U Number of unread articles in the group
671%e Number of unselected articles in the group
672%Z A string with unread/unselected article counts
673%g Shortish group name
674%S Subject of the current article
675%u User-defined spec
676%s Current score file name
677%d Number of dormant articles
678%r Number of articles that have been marked as read in this session
679%E Number of articles expunged by the score files"
680 :group 'gnus-summary-format
681 :type 'string)
682
16409b0b
GM
683(defcustom gnus-list-identifiers nil
684 "Regexp that matches list identifiers to be removed from subject.
685This can also be a list of regexps."
58e39d05 686 :version "21.1"
16409b0b
GM
687 :group 'gnus-summary-format
688 :group 'gnus-article-hiding
689 :type '(choice (const :tag "none" nil)
690 (regexp :value ".*")
691 (repeat :value (".*") regexp)))
692
eec82323
LMI
693(defcustom gnus-summary-mark-below 0
694 "*Mark all articles with a score below this variable as read.
695This variable is local to each summary buffer and usually set by the
696score file."
697 :group 'gnus-score-default
698 :type 'integer)
699
700(defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
701 "*List of functions used for sorting articles in the summary buffer.
23f87bed
MB
702
703Each function takes two articles and returns non-nil if the first
704article should be sorted before the other. If you use more than one
705function, the primary sort function should be the last. You should
706probably always include `gnus-article-sort-by-number' in the list of
707sorting functions -- preferably first. Also note that sorting by date
708is often much slower than sorting by number, and the sorting order is
709very similar. (Sorting by date means sorting by the time the message
710was sent, sorting by number means sorting by arrival time.)
711
712Ready-made functions include `gnus-article-sort-by-number',
713`gnus-article-sort-by-author', `gnus-article-sort-by-subject',
714`gnus-article-sort-by-date', `gnus-article-sort-by-random'
715and `gnus-article-sort-by-score'.
716
717When threading is turned on, the variable `gnus-thread-sort-functions'
718controls how articles are sorted."
eec82323
LMI
719 :group 'gnus-summary-sort
720 :type '(repeat (choice (function-item gnus-article-sort-by-number)
721 (function-item gnus-article-sort-by-author)
722 (function-item gnus-article-sort-by-subject)
723 (function-item gnus-article-sort-by-date)
724 (function-item gnus-article-sort-by-score)
23f87bed 725 (function-item gnus-article-sort-by-random)
eec82323
LMI
726 (function :tag "other"))))
727
728(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
729 "*List of functions used for sorting threads in the summary buffer.
730By default, threads are sorted by article number.
731
23f87bed
MB
732Each function takes two threads and returns non-nil if the first
733thread should be sorted before the other. If you use more than one
734function, the primary sort function should be the last. You should
735probably always include `gnus-thread-sort-by-number' in the list of
736sorting functions -- preferably first. Also note that sorting by date
737is often much slower than sorting by number, and the sorting order is
738very similar. (Sorting by date means sorting by the time the message
739was sent, sorting by number means sorting by arrival time.)
eec82323
LMI
740
741Ready-made functions include `gnus-thread-sort-by-number',
742`gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
23f87bed
MB
743`gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
744`gnus-thread-sort-by-most-recent-number',
745`gnus-thread-sort-by-most-recent-date',
746`gnus-thread-sort-by-random', and
747`gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
748
749When threading is turned off, the variable
750`gnus-article-sort-functions' controls how articles are sorted."
eec82323
LMI
751 :group 'gnus-summary-sort
752 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
753 (function-item gnus-thread-sort-by-author)
754 (function-item gnus-thread-sort-by-subject)
755 (function-item gnus-thread-sort-by-date)
756 (function-item gnus-thread-sort-by-score)
757 (function-item gnus-thread-sort-by-total-score)
23f87bed 758 (function-item gnus-thread-sort-by-random)
eec82323
LMI
759 (function :tag "other"))))
760
761(defcustom gnus-thread-score-function '+
762 "*Function used for calculating the total score of a thread.
763
764The function is called with the scores of the article and each
765subthread and should then return the score of the thread.
766
767Some functions you can use are `+', `max', or `min'."
768 :group 'gnus-summary-sort
769 :type 'function)
770
771(defcustom gnus-summary-expunge-below nil
6748645f
LMI
772 "All articles that have a score less than this variable will be expunged.
773This variable is local to the summary buffers."
eec82323
LMI
774 :group 'gnus-score-default
775 :type '(choice (const :tag "off" nil)
776 integer))
777
778(defcustom gnus-thread-expunge-below nil
779 "All threads that have a total score less than this variable will be expunged.
780See `gnus-thread-score-function' for en explanation of what a
6748645f
LMI
781\"thread score\" is.
782
783This variable is local to the summary buffers."
16409b0b 784 :group 'gnus-threading
eec82323
LMI
785 :group 'gnus-score-default
786 :type '(choice (const :tag "off" nil)
787 integer))
788
789(defcustom gnus-summary-mode-hook nil
790 "*A hook for Gnus summary mode.
791This hook is run before any variables are set in the summary buffer."
23f87bed 792 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
eec82323
LMI
793 :group 'gnus-summary-various
794 :type 'hook)
795
23f87bed
MB
796;; Extracted from gnus-xmas-redefine in order to preserve user settings
797(when (featurep 'xemacs)
798 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
799 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
800 (add-hook 'gnus-summary-mode-hook
801 'gnus-xmas-switch-horizontal-scrollbar-off))
802
eec82323
LMI
803(defcustom gnus-summary-menu-hook nil
804 "*Hook run after the creation of the summary mode menu."
805 :group 'gnus-summary-visual
806 :type 'hook)
807
808(defcustom gnus-summary-exit-hook nil
809 "*A hook called on exit from the summary buffer.
810It will be called with point in the group buffer."
811 :group 'gnus-summary-exit
812 :type 'hook)
813
814(defcustom gnus-summary-prepare-hook nil
815 "*A hook called after the summary buffer has been generated.
816If you want to modify the summary buffer, you can use this hook."
817 :group 'gnus-summary-various
818 :type 'hook)
819
6748645f
LMI
820(defcustom gnus-summary-prepared-hook nil
821 "*A hook called as the last thing after the summary buffer has been generated."
822 :group 'gnus-summary-various
823 :type 'hook)
824
eec82323
LMI
825(defcustom gnus-summary-generate-hook nil
826 "*A hook run just before generating the summary buffer.
827This hook is commonly used to customize threading variables and the
828like."
829 :group 'gnus-summary-various
830 :type 'hook)
831
832(defcustom gnus-select-group-hook nil
833 "*A hook called when a newsgroup is selected.
834
835If you'd like to simplify subjects like the
836`gnus-summary-next-same-subject' command does, you can use the
837following hook:
838
23f87bed
MB
839 (add-hook gnus-select-group-hook
840 (lambda ()
841 (mapcar (lambda (header)
842 (mail-header-set-subject
843 header
844 (gnus-simplify-subject
845 (mail-header-subject header) 're-only)))
846 gnus-newsgroup-headers)))"
eec82323
LMI
847 :group 'gnus-group-select
848 :type 'hook)
849
850(defcustom gnus-select-article-hook nil
851 "*A hook called when an article is selected."
852 :group 'gnus-summary-choose
23f87bed 853 :options '(gnus-agent-fetch-selected-article)
eec82323
LMI
854 :type 'hook)
855
856(defcustom gnus-visual-mark-article-hook
857 (list 'gnus-highlight-selected-summary)
858 "*Hook run after selecting an article in the summary buffer.
859It is meant to be used for highlighting the article in some way. It
860is not run if `gnus-visual' is nil."
861 :group 'gnus-summary-visual
862 :type 'hook)
863
16409b0b 864(defcustom gnus-parse-headers-hook nil
eec82323
LMI
865 "*A hook called before parsing the headers."
866 :group 'gnus-various
867 :type 'hook)
868
869(defcustom gnus-exit-group-hook nil
16409b0b
GM
870 "*A hook called when exiting summary mode.
871This hook is not called from the non-updating exit commands like `Q'."
eec82323
LMI
872 :group 'gnus-various
873 :type 'hook)
874
875(defcustom gnus-summary-update-hook
876 (list 'gnus-summary-highlight-line)
877 "*A hook called when a summary line is changed.
878The hook will not be called if `gnus-visual' is nil.
879
880The default function `gnus-summary-highlight-line' will
881highlight the line according to the `gnus-summary-highlight'
882variable."
883 :group 'gnus-summary-visual
884 :type 'hook)
885
886(defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
887 "*A hook called when an article is selected for the first time.
888The hook is intended to mark an article as read (or unread)
889automatically when it is selected."
890 :group 'gnus-summary-choose
891 :type 'hook)
892
893(defcustom gnus-group-no-more-groups-hook nil
894 "*A hook run when returning to group mode having no more (unread) groups."
895 :group 'gnus-group-select
896 :type 'hook)
897
898(defcustom gnus-ps-print-hook nil
899 "*A hook run before ps-printing something from Gnus."
900 :group 'gnus-summary
901 :type 'hook)
902
23f87bed
MB
903(defcustom gnus-summary-article-move-hook nil
904 "*A hook called after an article is moved, copied, respooled, or crossposted."
bf247b6e 905 :version "22.1"
23f87bed
MB
906 :group 'gnus-summary
907 :type 'hook)
908
909(defcustom gnus-summary-article-delete-hook nil
910 "*A hook called after an article is deleted."
bf247b6e 911 :version "22.1"
23f87bed
MB
912 :group 'gnus-summary
913 :type 'hook)
914
915(defcustom gnus-summary-article-expire-hook nil
916 "*A hook called after an article is expired."
bf247b6e 917 :version "22.1"
23f87bed
MB
918 :group 'gnus-summary
919 :type 'hook)
920
921(defcustom gnus-summary-display-arrow
922 (and (fboundp 'display-graphic-p)
923 (display-graphic-p))
924 "*If non-nil, display an arrow highlighting the current article."
bf247b6e 925 :version "22.1"
23f87bed
MB
926 :group 'gnus-summary
927 :type 'boolean)
928
0f49874b 929(defcustom gnus-summary-selected-face 'gnus-summary-selected
eec82323
LMI
930 "Face used for highlighting the current article in the summary buffer."
931 :group 'gnus-summary-visual
932 :type 'face)
933
23f87bed
MB
934(defvar gnus-tmp-downloaded nil)
935
eec82323 936(defcustom gnus-summary-highlight
23f87bed 937 '(((eq mark gnus-canceled-mark)
0f49874b 938 . gnus-summary-cancelled)
23f87bed 939 ((and uncached (> score default-high))
0f49874b 940 . gnus-summary-high-undownloaded)
23f87bed 941 ((and uncached (< score default-low))
0f49874b 942 . gnus-summary-low-undownloaded)
23f87bed 943 (uncached
0f49874b 944 . gnus-summary-normal-undownloaded)
23f87bed
MB
945 ((and (> score default-high)
946 (or (eq mark gnus-dormant-mark)
947 (eq mark gnus-ticked-mark)))
0f49874b 948 . gnus-summary-high-ticked)
23f87bed
MB
949 ((and (< score default-low)
950 (or (eq mark gnus-dormant-mark)
951 (eq mark gnus-ticked-mark)))
0f49874b 952 . gnus-summary-low-ticked)
23f87bed
MB
953 ((or (eq mark gnus-dormant-mark)
954 (eq mark gnus-ticked-mark))
0f49874b 955 . gnus-summary-normal-ticked)
23f87bed 956 ((and (> score default-high) (eq mark gnus-ancient-mark))
0f49874b 957 . gnus-summary-high-ancient)
23f87bed 958 ((and (< score default-low) (eq mark gnus-ancient-mark))
0f49874b 959 . gnus-summary-low-ancient)
23f87bed 960 ((eq mark gnus-ancient-mark)
0f49874b 961 . gnus-summary-normal-ancient)
23f87bed 962 ((and (> score default-high) (eq mark gnus-unread-mark))
0f49874b 963 . gnus-summary-high-unread)
23f87bed 964 ((and (< score default-low) (eq mark gnus-unread-mark))
0f49874b 965 . gnus-summary-low-unread)
23f87bed 966 ((eq mark gnus-unread-mark)
0f49874b 967 . gnus-summary-normal-unread)
23f87bed 968 ((> score default-high)
0f49874b 969 . gnus-summary-high-read)
23f87bed 970 ((< score default-low)
0f49874b 971 . gnus-summary-low-read)
eec82323 972 (t
0f49874b 973 . gnus-summary-normal-read))
6748645f 974 "*Controls the highlighting of summary buffer lines.
eec82323 975
107cf8ec 976A list of (FORM . FACE) pairs. When deciding how a particular
23f87bed
MB
977summary line should be displayed, each form is evaluated. The content
978of the face field after the first true form is used. You can change
979how those summary lines are displayed, by editing the face field.
eec82323
LMI
980
981You can use the following variables in the FORM field.
982
107cf8ec 983score: The article's score.
23f87bed
MB
984default: The default article score.
985default-high: The default score for high scored articles.
986default-low: The default score for low scored articles.
987below: The score below which articles are automatically marked as read.
988mark: The article's mark.
989uncached: Non-nil if the article is uncached."
eec82323
LMI
990 :group 'gnus-summary-visual
991 :type '(repeat (cons (sexp :tag "Form" nil)
992 face)))
993
6748645f
LMI
994(defcustom gnus-alter-header-function nil
995 "Function called to allow alteration of article header structures.
996The function is called with one parameter, the article header vector,
0ab0f2d3
SZ
997which it may alter in any way."
998 :type '(choice (const :tag "None" nil)
999 function)
1000 :group 'gnus-summary)
eec82323 1001
16409b0b 1002(defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
343d6628
MB
1003 "Function used to decode a string with encoded words.")
1004
1005(defvar gnus-decode-encoded-address-function
1006 'mail-decode-encoded-address-string
1007 "Function used to decode addresses with encoded words.")
16409b0b 1008
23f87bed 1009(defcustom gnus-extra-headers '(To Newsgroups)
16409b0b 1010 "*Extra headers to parse."
58e39d05 1011 :version "21.1"
16409b0b
GM
1012 :group 'gnus-summary
1013 :type '(repeat symbol))
1014
1015(defcustom gnus-ignored-from-addresses
343d6628 1016 (and user-mail-address
7cd9f860
CY
1017 (not (string= user-mail-address ""))
1018 (regexp-quote user-mail-address))
16409b0b 1019 "*Regexp of From headers that may be suppressed in favor of To headers."
58e39d05 1020 :version "21.1"
16409b0b
GM
1021 :group 'gnus-summary
1022 :type 'regexp)
1023
16409b0b
GM
1024(defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1025 "List of charsets that should be ignored.
1026When these charsets are used in the \"charset\" parameter, the
1027default charset will be used instead."
58e39d05 1028 :version "21.1"
16409b0b
GM
1029 :type '(repeat symbol)
1030 :group 'gnus-charset)
1031
23f87bed
MB
1032(gnus-define-group-parameter
1033 ignored-charsets
1034 :type list
1035 :function-document
1036 "Return the ignored charsets of GROUP."
1037 :variable gnus-group-ignored-charsets-alist
1038 :variable-default
1039 '(("alt\\.chinese\\.text" iso-8859-1))
1040 :variable-document
1041 "Alist of regexps (to match group names) and charsets that should be ignored.
16409b0b
GM
1042When these charsets are used in the \"charset\" parameter, the
1043default charset will be used instead."
23f87bed
MB
1044 :variable-group gnus-charset
1045 :variable-type '(repeat (cons (regexp :tag "Group")
1046 (repeat symbol)))
1047 :parameter-type '(choice :tag "Ignored charsets"
1048 :value nil
1049 (repeat (symbol)))
1050 :parameter-document "\
1051List of charsets that should be ignored.
1052
1053When these charsets are used in the \"charset\" parameter, the
1054default charset will be used instead.")
16409b0b
GM
1055
1056(defcustom gnus-group-highlight-words-alist nil
1057 "Alist of group regexps and highlight regexps.
1058This variable uses the same syntax as `gnus-emphasis-alist'."
58e39d05 1059 :version "21.1"
16409b0b
GM
1060 :type '(repeat (cons (regexp :tag "Group")
1061 (repeat (list (regexp :tag "Highlight regexp")
1062 (number :tag "Group for entire word" 0)
1063 (number :tag "Group for displayed part" 0)
1064 (symbol :tag "Face"
1065 gnus-emphasis-highlight-words)))))
1066 :group 'gnus-summary-visual)
1067
1068(defcustom gnus-summary-show-article-charset-alist
1069 nil
1070 "Alist of number and charset.
1071The article will be shown with the charset corresponding to the
1072numbered argument.
1073For example: ((1 . cn-gb-2312) (2 . big5))."
58e39d05 1074 :version "21.1"
16409b0b
GM
1075 :type '(repeat (cons (number :tag "Argument" 1)
1076 (symbol :tag "Charset")))
1077 :group 'gnus-charset)
1078
1079(defcustom gnus-preserve-marks t
1080 "Whether marks are preserved when moving, copying and respooling messages."
58e39d05 1081 :version "21.1"
16409b0b
GM
1082 :type 'boolean
1083 :group 'gnus-summary-marks)
1084
1085(defcustom gnus-alter-articles-to-read-function nil
1086 "Function to be called to alter the list of articles to be selected."
8fc7a9a1 1087 :type '(choice (const nil) function)
16409b0b
GM
1088 :group 'gnus-summary)
1089
1090(defcustom gnus-orphan-score nil
1091 "*All orphans get this score added. Set in the score file."
1092 :group 'gnus-score-default
1093 :type '(choice (const nil)
1094 integer))
1095
8b93df01 1096(defcustom gnus-summary-save-parts-default-mime "image/.*"
23f87bed
MB
1097 "*A regexp to match MIME parts when saving multiple parts of a
1098message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1099This regexp will be used by default when prompting the user for which
1100type of files to save."
8b93df01
DL
1101 :group 'gnus-summary
1102 :type 'regexp)
1103
23f87bed
MB
1104(defcustom gnus-read-all-available-headers nil
1105 "Whether Gnus should parse all headers made available to it.
1106This is mostly relevant for slow back ends where the user may
1107wish to widen the summary buffer to include all headers
1108that were fetched. Say, for nnultimate groups."
bf247b6e 1109 :version "22.1"
23f87bed
MB
1110 :group 'gnus-summary
1111 :type '(choice boolean regexp))
1112
1113(defcustom gnus-summary-muttprint-program "muttprint"
1114 "Command (and optional arguments) used to run Muttprint."
bf247b6e 1115 :version "22.1"
23f87bed
MB
1116 :group 'gnus-summary
1117 :type 'string)
1118
1119(defcustom gnus-article-loose-mime nil
1120 "If non-nil, don't require MIME-Version header.
1121Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
a08b59c9 1122supply the MIME-Version header or deliberately strip it from the mail.
23f87bed
MB
1123Set it to non-nil, Gnus will treat some articles as MIME even if
1124the MIME-Version header is missed."
bf247b6e 1125 :version "22.1"
23f87bed
MB
1126 :type 'boolean
1127 :group 'gnus-article-mime)
1128
1129(defcustom gnus-article-emulate-mime t
1130 "If non-nil, use MIME emulation for uuencode and the like.
1131This means that Gnus will search message bodies for text that look
1132like uuencoded bits, yEncoded bits, and so on, and present that using
1133the normal Gnus MIME machinery."
bf247b6e 1134 :version "22.1"
23f87bed
MB
1135 :type 'boolean
1136 :group 'gnus-article-mime)
8b93df01 1137
eec82323
LMI
1138;;; Internal variables
1139
23f87bed 1140(defvar gnus-summary-display-cache nil)
16409b0b
GM
1141(defvar gnus-article-mime-handles nil)
1142(defvar gnus-article-decoded-p nil)
23f87bed
MB
1143(defvar gnus-article-charset nil)
1144(defvar gnus-article-ignored-charsets nil)
eec82323
LMI
1145(defvar gnus-scores-exclude-files nil)
1146(defvar gnus-page-broken nil)
1147
1148(defvar gnus-original-article nil)
1149(defvar gnus-article-internal-prepare-hook nil)
1150(defvar gnus-newsgroup-process-stack nil)
1151
1152(defvar gnus-thread-indent-array nil)
1153(defvar gnus-thread-indent-array-level gnus-thread-indent-level)
16409b0b
GM
1154(defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1155 "Function called to sort the articles within a thread after it has been gathered together.")
eec82323 1156
8b93df01 1157(defvar gnus-summary-save-parts-type-history nil)
23f87bed 1158(defvar gnus-summary-save-parts-last-directory mm-default-directory)
8b93df01 1159
eec82323
LMI
1160;; Avoid highlighting in kill files.
1161(defvar gnus-summary-inhibit-highlight nil)
1162(defvar gnus-newsgroup-selected-overlay nil)
1163(defvar gnus-inhibit-limiting nil)
1164(defvar gnus-newsgroup-adaptive-score-file nil)
1165(defvar gnus-current-score-file nil)
1166(defvar gnus-current-move-group nil)
1167(defvar gnus-current-copy-group nil)
1168(defvar gnus-current-crosspost-group nil)
23f87bed 1169(defvar gnus-newsgroup-display nil)
eec82323
LMI
1170
1171(defvar gnus-newsgroup-dependencies nil)
1172(defvar gnus-newsgroup-adaptive nil)
1173(defvar gnus-summary-display-article-function nil)
1174(defvar gnus-summary-highlight-line-function nil
1175 "Function called after highlighting a summary line.")
1176
1177(defvar gnus-summary-line-format-alist
1178 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1179 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1180 (?s gnus-tmp-subject-or-nil ?s)
1181 (?n gnus-tmp-name ?s)
1182 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1183 ?s)
1184 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1185 gnus-tmp-from) ?s)
1186 (?F gnus-tmp-from ?s)
1187 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1188 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1189 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
6748645f 1190 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
eec82323
LMI
1191 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1192 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1193 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
23f87bed
MB
1194 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1195 (?L gnus-tmp-lines ?s)
1196 (?O gnus-tmp-downloaded ?c)
eec82323
LMI
1197 (?I gnus-tmp-indentation ?s)
1198 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1199 (?R gnus-tmp-replied ?c)
1200 (?\[ gnus-tmp-opening-bracket ?c)
1201 (?\] gnus-tmp-closing-bracket ?c)
1202 (?\> (make-string gnus-tmp-level ? ) ?s)
1203 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1204 (?i gnus-tmp-score ?d)
1205 (?z gnus-tmp-score-char ?c)
1206 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1207 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1208 (?U gnus-tmp-unread ?c)
23f87bed
MB
1209 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1210 ?s)
eec82323
LMI
1211 (?t (gnus-summary-number-of-articles-in-thread
1212 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1213 ?d)
1214 (?e (gnus-summary-number-of-articles-in-thread
1215 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1216 ?c)
1217 (?u gnus-tmp-user-defined ?s)
23f87bed
MB
1218 (?P (gnus-pick-line-number) ?d)
1219 (?B gnus-tmp-thread-tree-header-string ?s)
1220 (user-date (gnus-user-date
1221 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
16409b0b
GM
1222 "An alist of format specifications that can appear in summary lines.
1223These are paired with what variables they correspond with, along with
1224the type of the variable (string, integer, character, etc).")
eec82323
LMI
1225
1226(defvar gnus-summary-dummy-line-format-alist
1227 `((?S gnus-tmp-subject ?s)
1228 (?N gnus-tmp-number ?d)
1229 (?u gnus-tmp-user-defined ?s)))
1230
1231(defvar gnus-summary-mode-line-format-alist
1232 `((?G gnus-tmp-group-name ?s)
1233 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1234 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1235 (?A gnus-tmp-article-number ?d)
1236 (?Z gnus-tmp-unread-and-unselected ?s)
1237 (?V gnus-version ?s)
1238 (?U gnus-tmp-unread-and-unticked ?d)
1239 (?S gnus-tmp-subject ?s)
1240 (?e gnus-tmp-unselected ?d)
1241 (?u gnus-tmp-user-defined ?s)
1242 (?d (length gnus-newsgroup-dormant) ?d)
1243 (?t (length gnus-newsgroup-marked) ?d)
23f87bed 1244 (?h (length gnus-newsgroup-spam-marked) ?d)
eec82323 1245 (?r (length gnus-newsgroup-reads) ?d)
6748645f 1246 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
eec82323
LMI
1247 (?E gnus-newsgroup-expunged-tally ?d)
1248 (?s (gnus-current-score-file-nondirectory) ?s)))
1249
1250(defvar gnus-last-search-regexp nil
1251 "Default regexp for article search command.")
1252
1253(defvar gnus-last-shell-command nil
1254 "Default shell command on article.")
1255
23f87bed
MB
1256(defvar gnus-newsgroup-agentized nil
1257 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
eec82323
LMI
1258(defvar gnus-newsgroup-begin nil)
1259(defvar gnus-newsgroup-end nil)
1260(defvar gnus-newsgroup-last-rmail nil)
1261(defvar gnus-newsgroup-last-mail nil)
1262(defvar gnus-newsgroup-last-folder nil)
1263(defvar gnus-newsgroup-last-file nil)
26c9afc3 1264(defvar gnus-newsgroup-last-directory nil)
eec82323
LMI
1265(defvar gnus-newsgroup-auto-expire nil)
1266(defvar gnus-newsgroup-active nil)
1267
1268(defvar gnus-newsgroup-data nil)
1269(defvar gnus-newsgroup-data-reverse nil)
1270(defvar gnus-newsgroup-limit nil)
1271(defvar gnus-newsgroup-limits nil)
23f87bed 1272(defvar gnus-summary-use-undownloaded-faces nil)
eec82323
LMI
1273
1274(defvar gnus-newsgroup-unreads nil
23f87bed 1275 "Sorted list of unread articles in the current newsgroup.")
eec82323
LMI
1276
1277(defvar gnus-newsgroup-unselected nil
23f87bed 1278 "Sorted list of unselected unread articles in the current newsgroup.")
eec82323
LMI
1279
1280(defvar gnus-newsgroup-reads nil
1281 "Alist of read articles and article marks in the current newsgroup.")
1282
1283(defvar gnus-newsgroup-expunged-tally nil)
1284
1285(defvar gnus-newsgroup-marked nil
23f87bed
MB
1286 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1287
1288(defvar gnus-newsgroup-spam-marked nil
1289 "List of ranges of articles that have been marked as spam.")
eec82323
LMI
1290
1291(defvar gnus-newsgroup-killed nil
1292 "List of ranges of articles that have been through the scoring process.")
1293
1294(defvar gnus-newsgroup-cached nil
23f87bed 1295 "Sorted list of articles that come from the article cache.")
eec82323
LMI
1296
1297(defvar gnus-newsgroup-saved nil
1298 "List of articles that have been saved.")
1299
1300(defvar gnus-newsgroup-kill-headers nil)
1301
1302(defvar gnus-newsgroup-replied nil
1303 "List of articles that have been replied to in the current newsgroup.")
1304
23f87bed
MB
1305(defvar gnus-newsgroup-forwarded nil
1306 "List of articles that have been forwarded in the current newsgroup.")
1307
1308(defvar gnus-newsgroup-recent nil
1309 "List of articles that have are recent in the current newsgroup.")
1310
eec82323 1311(defvar gnus-newsgroup-expirable nil
23f87bed 1312 "Sorted list of articles in the current newsgroup that can be expired.")
eec82323
LMI
1313
1314(defvar gnus-newsgroup-processable nil
1315 "List of articles in the current newsgroup that can be processed.")
1316
6748645f 1317(defvar gnus-newsgroup-downloadable nil
23f87bed
MB
1318 "Sorted list of articles in the current newsgroup that can be processed.")
1319
1320(defvar gnus-newsgroup-unfetched nil
1321 "Sorted list of articles in the current newsgroup whose headers have
1322not been fetched into the agent.
1323
1324This list will always be a subset of gnus-newsgroup-undownloaded.")
6748645f
LMI
1325
1326(defvar gnus-newsgroup-undownloaded nil
23f87bed 1327 "List of articles in the current newsgroup that haven't been downloaded.")
6748645f
LMI
1328
1329(defvar gnus-newsgroup-unsendable nil
1330 "List of articles in the current newsgroup that won't be sent.")
1331
eec82323
LMI
1332(defvar gnus-newsgroup-bookmarks nil
1333 "List of articles in the current newsgroup that have bookmarks.")
1334
1335(defvar gnus-newsgroup-dormant nil
23f87bed
MB
1336 "Sorted list of dormant articles in the current newsgroup.")
1337
1338(defvar gnus-newsgroup-unseen nil
1339 "List of unseen articles in the current newsgroup.")
1340
1341(defvar gnus-newsgroup-seen nil
1342 "Range of seen articles in the current newsgroup.")
1343
1344(defvar gnus-newsgroup-articles nil
1345 "List of articles in the current newsgroup.")
eec82323
LMI
1346
1347(defvar gnus-newsgroup-scored nil
1348 "List of scored articles in the current newsgroup.")
1349
1350(defvar gnus-newsgroup-headers nil
1351 "List of article headers in the current newsgroup.")
1352
1353(defvar gnus-newsgroup-threads nil)
1354
1355(defvar gnus-newsgroup-prepared nil
1356 "Whether the current group has been prepared properly.")
1357
1358(defvar gnus-newsgroup-ancient nil
1359 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1360
1361(defvar gnus-newsgroup-sparse nil)
1362
1363(defvar gnus-current-article nil)
1364(defvar gnus-article-current nil)
1365(defvar gnus-current-headers nil)
1366(defvar gnus-have-all-headers nil)
1367(defvar gnus-last-article nil)
1368(defvar gnus-newsgroup-history nil)
16409b0b
GM
1369(defvar gnus-newsgroup-charset nil)
1370(defvar gnus-newsgroup-ephemeral-charset nil)
1371(defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
eec82323 1372
23f87bed
MB
1373(defvar gnus-article-before-search nil)
1374
1375(defvar gnus-summary-local-variables
eec82323
LMI
1376 '(gnus-newsgroup-name
1377 gnus-newsgroup-begin gnus-newsgroup-end
1378 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1379 gnus-newsgroup-last-folder gnus-newsgroup-last-file
26c9afc3 1380 gnus-newsgroup-last-directory
eec82323
LMI
1381 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1382 gnus-newsgroup-unselected gnus-newsgroup-marked
23f87bed 1383 gnus-newsgroup-spam-marked
eec82323 1384 gnus-newsgroup-reads gnus-newsgroup-saved
23f87bed
MB
1385 gnus-newsgroup-replied gnus-newsgroup-forwarded
1386 gnus-newsgroup-recent
1387 gnus-newsgroup-expirable
eec82323 1388 gnus-newsgroup-processable gnus-newsgroup-killed
6748645f 1389 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
23f87bed
MB
1390 gnus-newsgroup-unfetched
1391 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1392 gnus-newsgroup-seen gnus-newsgroup-articles
eec82323
LMI
1393 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1394 gnus-newsgroup-headers gnus-newsgroup-threads
1395 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1396 gnus-current-article gnus-current-headers gnus-have-all-headers
1397 gnus-last-article gnus-article-internal-prepare-hook
1398 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1399 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1400 gnus-thread-expunge-below
16409b0b
GM
1401 gnus-score-alist gnus-current-score-file
1402 (gnus-summary-expunge-below . global)
eec82323 1403 (gnus-summary-mark-below . global)
16409b0b 1404 (gnus-orphan-score . global)
eec82323
LMI
1405 gnus-newsgroup-active gnus-scores-exclude-files
1406 gnus-newsgroup-history gnus-newsgroup-ancient
1407 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1408 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1409 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1410 (gnus-newsgroup-expunged-tally . 0)
1411 gnus-cache-removable-articles gnus-newsgroup-cached
1412 gnus-newsgroup-data gnus-newsgroup-data-reverse
16409b0b 1413 gnus-newsgroup-limit gnus-newsgroup-limits
23f87bed
MB
1414 gnus-newsgroup-charset gnus-newsgroup-display
1415 gnus-summary-use-undownloaded-faces)
eec82323
LMI
1416 "Variables that are buffer-local to the summary buffers.")
1417
23f87bed
MB
1418(defvar gnus-newsgroup-variables nil
1419 "A list of variables that have separate values in different newsgroups.
1420A list of newsgroup (summary buffer) local variables, or cons of
1421variables and their default expressions to be evalled (when the default
1422values are not nil), that should be made global while the summary buffer
1423is active.
1424
1425Note: The default expressions will be evaluated (using function `eval')
1426before assignment to the local variable rather than just assigned to it.
1427If the default expression is the symbol `global', that symbol will not
1428be evaluated but the global value of the local variable will be used
1429instead.
1430
1431These variables can be used to set variables in the group parameters
1432while still allowing them to affect operations done in other buffers.
1433For example:
1434
1435\(setq gnus-newsgroup-variables
1436 '(message-use-followup-to
1437 (gnus-visible-headers .
1438 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1439")
1440
eec82323 1441;; Byte-compiler warning.
23f87bed
MB
1442(eval-when-compile
1443 ;; Bind features so that require will believe that gnus-sum has
1444 ;; already been loaded (avoids infinite recursion)
1445 (let ((features (cons 'gnus-sum features)))
1446 ;; Several of the declarations in gnus-sum are needed to load the
1447 ;; following files. Right now, these definitions have been
1448 ;; compiled but not defined (evaluated). We could either do a
1449 ;; eval-and-compile about all of the declarations or evaluate the
1450 ;; source file.
1451 (if (boundp 'gnus-newsgroup-variables)
1452 nil
1453 (load "gnus-sum.el" t t t))
1454 (require 'gnus)
1455 (require 'gnus-agent)
1456 (require 'gnus-art)))
eec82323 1457
16409b0b
GM
1458;; MIME stuff.
1459
1460(defvar gnus-decode-encoded-word-methods
1461 '(mail-decode-encoded-word-string)
1462 "List of methods used to decode encoded words.
1463
23f87bed
MB
1464This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1465is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1466\(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
16409b0b
GM
1467whose names match REGEXP.
1468
1469For example:
23f87bed 1470\((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
16409b0b
GM
1471 mail-decode-encoded-word-string
1472 (\"chinese\" . rfc1843-decode-string))")
1473
1474(defvar gnus-decode-encoded-word-methods-cache nil)
1475
1476(defun gnus-multi-decode-encoded-word-string (string)
1477 "Apply the functions from `gnus-encoded-word-methods' that match."
1478 (unless (and gnus-decode-encoded-word-methods-cache
1479 (eq gnus-newsgroup-name
1480 (car gnus-decode-encoded-word-methods-cache)))
1481 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1482 (mapcar (lambda (x)
1483 (if (symbolp x)
1484 (nconc gnus-decode-encoded-word-methods-cache (list x))
1485 (if (and gnus-newsgroup-name
1486 (string-match (car x) gnus-newsgroup-name))
1487 (nconc gnus-decode-encoded-word-methods-cache
1488 (list (cdr x))))))
23f87bed 1489 gnus-decode-encoded-word-methods))
16409b0b
GM
1490 (let ((xlist gnus-decode-encoded-word-methods-cache))
1491 (pop xlist)
1492 (while xlist
1493 (setq string (funcall (pop xlist) string))))
1494 string)
1495
eec82323
LMI
1496;; Subject simplification.
1497
6748645f 1498(defun gnus-simplify-whitespace (str)
16409b0b 1499 "Remove excessive whitespace from STR."
23f87bed
MB
1500 ;; Multiple spaces.
1501 (while (string-match "[ \t][ \t]+" str)
1502 (setq str (concat (substring str 0 (match-beginning 0))
1503 " "
1504 (substring str (match-end 0)))))
1505 ;; Leading spaces.
1506 (when (string-match "^[ \t]+" str)
1507 (setq str (substring str (match-end 0))))
1508 ;; Trailing spaces.
1509 (when (string-match "[ \t]+$" str)
1510 (setq str (substring str 0 (match-beginning 0))))
1511 str)
1512
1513(defun gnus-simplify-all-whitespace (str)
1514 "Remove all whitespace from STR."
1515 (while (string-match "[ \t\n]+" str)
1516 (setq str (replace-match "" nil nil str)))
1517 str)
6748645f 1518
eec82323
LMI
1519(defsubst gnus-simplify-subject-re (subject)
1520 "Remove \"Re:\" from subject lines."
23f87bed 1521 (if (string-match message-subject-re-regexp subject)
eec82323
LMI
1522 (substring subject (match-end 0))
1523 subject))
1524
1525(defun gnus-simplify-subject (subject &optional re-only)
1526 "Remove `Re:' and words in parentheses.
1527If RE-ONLY is non-nil, strip leading `Re:'s only."
1528 (let ((case-fold-search t)) ;Ignore case.
1529 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1530 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1531 (setq subject (substring subject (match-end 0))))
1532 ;; Remove uninteresting prefixes.
1533 (when (and (not re-only)
1534 gnus-simplify-ignored-prefixes
1535 (string-match gnus-simplify-ignored-prefixes subject))
1536 (setq subject (substring subject (match-end 0))))
1537 ;; Remove words in parentheses from end.
1538 (unless re-only
1539 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1540 (setq subject (substring subject 0 (match-beginning 0)))))
1541 ;; Return subject string.
1542 subject))
1543
1544;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1545;; all whitespace.
1546(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1547 (goto-char (point-min))
1548 (while (re-search-forward regexp nil t)
16409b0b 1549 (replace-match (or newtext ""))))
eec82323
LMI
1550
1551(defun gnus-simplify-buffer-fuzzy ()
1552 "Simplify string in the buffer fuzzily.
1553The string in the accessible portion of the current buffer is simplified.
1554It is assumed to be a single-line subject.
1555Whitespace is generally cleaned up, and miscellaneous leading/trailing
1556matter is removed. Additional things can be deleted by setting
16409b0b 1557`gnus-simplify-subject-fuzzy-regexp'."
eec82323
LMI
1558 (let ((case-fold-search t)
1559 (modified-tick))
1560 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1561
1562 (while (not (eq modified-tick (buffer-modified-tick)))
1563 (setq modified-tick (buffer-modified-tick))
1564 (cond
1565 ((listp gnus-simplify-subject-fuzzy-regexp)
1566 (mapcar 'gnus-simplify-buffer-fuzzy-step
1567 gnus-simplify-subject-fuzzy-regexp))
1568 (gnus-simplify-subject-fuzzy-regexp
1569 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1570 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1571 (gnus-simplify-buffer-fuzzy-step
1572 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1573 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1574
1575 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1576 (gnus-simplify-buffer-fuzzy-step " +" " ")
1577 (gnus-simplify-buffer-fuzzy-step " $")
1578 (gnus-simplify-buffer-fuzzy-step "^ +")))
1579
1580(defun gnus-simplify-subject-fuzzy (subject)
1581 "Simplify a subject string fuzzily.
6748645f 1582See `gnus-simplify-buffer-fuzzy' for details."
eec82323
LMI
1583 (save-excursion
1584 (gnus-set-work-buffer)
1585 (let ((case-fold-search t))
6748645f
LMI
1586 ;; Remove uninteresting prefixes.
1587 (when (and gnus-simplify-ignored-prefixes
1588 (string-match gnus-simplify-ignored-prefixes subject))
1589 (setq subject (substring subject (match-end 0))))
eec82323
LMI
1590 (insert subject)
1591 (inline (gnus-simplify-buffer-fuzzy))
1592 (buffer-string))))
1593
1594(defsubst gnus-simplify-subject-fully (subject)
23f87bed 1595 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
eec82323 1596 (cond
6748645f
LMI
1597 (gnus-simplify-subject-functions
1598 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1599 ((null gnus-summary-gather-subject-limit)
1600 (gnus-simplify-subject-re subject))
1601 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1602 (gnus-simplify-subject-fuzzy subject))
1603 ((numberp gnus-summary-gather-subject-limit)
1604 (gnus-limit-string (gnus-simplify-subject-re subject)
1605 gnus-summary-gather-subject-limit))
1606 (t
1607 subject)))
1608
1609(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f 1610 "Check whether two subjects are equal.
23f87bed 1611If optional argument SIMPLE-FIRST is t, first argument is already
6748645f 1612simplified."
eec82323
LMI
1613 (cond
1614 ((null simple-first)
1615 (equal (gnus-simplify-subject-fully s1)
1616 (gnus-simplify-subject-fully s2)))
1617 (t
1618 (equal s1
1619 (gnus-simplify-subject-fully s2)))))
1620
1621(defun gnus-summary-bubble-group ()
1622 "Increase the score of the current group.
1623This is a handy function to add to `gnus-summary-exit-hook' to
1624increase the score of each group you read."
1625 (gnus-group-add-score gnus-newsgroup-name))
1626
1627\f
1628;;;
1629;;; Gnus summary mode
1630;;;
1631
1632(put 'gnus-summary-mode 'mode-class 'special)
1633
1653df0f
SZ
1634(defvar gnus-article-commands-menu)
1635
23f87bed
MB
1636;; Non-orthogonal keys
1637
1638(gnus-define-keys gnus-summary-mode-map
1639 " " gnus-summary-next-page
1640 "\177" gnus-summary-prev-page
1641 [delete] gnus-summary-prev-page
1642 [backspace] gnus-summary-prev-page
1643 "\r" gnus-summary-scroll-up
1644 "\M-\r" gnus-summary-scroll-down
1645 "n" gnus-summary-next-unread-article
1646 "p" gnus-summary-prev-unread-article
1647 "N" gnus-summary-next-article
1648 "P" gnus-summary-prev-article
1649 "\M-\C-n" gnus-summary-next-same-subject
1650 "\M-\C-p" gnus-summary-prev-same-subject
1651 "\M-n" gnus-summary-next-unread-subject
1652 "\M-p" gnus-summary-prev-unread-subject
1653 "." gnus-summary-first-unread-article
1654 "," gnus-summary-best-unread-article
1655 "\M-s" gnus-summary-search-article-forward
1656 "\M-r" gnus-summary-search-article-backward
1657 "<" gnus-summary-beginning-of-article
1658 ">" gnus-summary-end-of-article
1659 "j" gnus-summary-goto-article
1660 "^" gnus-summary-refer-parent-article
1661 "\M-^" gnus-summary-refer-article
1662 "u" gnus-summary-tick-article-forward
1663 "!" gnus-summary-tick-article-forward
1664 "U" gnus-summary-tick-article-backward
1665 "d" gnus-summary-mark-as-read-forward
1666 "D" gnus-summary-mark-as-read-backward
1667 "E" gnus-summary-mark-as-expirable
1668 "\M-u" gnus-summary-clear-mark-forward
1669 "\M-U" gnus-summary-clear-mark-backward
1670 "k" gnus-summary-kill-same-subject-and-select
1671 "\C-k" gnus-summary-kill-same-subject
1672 "\M-\C-k" gnus-summary-kill-thread
1673 "\M-\C-l" gnus-summary-lower-thread
1674 "e" gnus-summary-edit-article
1675 "#" gnus-summary-mark-as-processable
1676 "\M-#" gnus-summary-unmark-as-processable
1677 "\M-\C-t" gnus-summary-toggle-threads
1678 "\M-\C-s" gnus-summary-show-thread
1679 "\M-\C-h" gnus-summary-hide-thread
1680 "\M-\C-f" gnus-summary-next-thread
1681 "\M-\C-b" gnus-summary-prev-thread
1682 [(meta down)] gnus-summary-next-thread
1683 [(meta up)] gnus-summary-prev-thread
1684 "\M-\C-u" gnus-summary-up-thread
1685 "\M-\C-d" gnus-summary-down-thread
1686 "&" gnus-summary-execute-command
1687 "c" gnus-summary-catchup-and-exit
1688 "\C-w" gnus-summary-mark-region-as-read
1689 "\C-t" gnus-summary-toggle-truncation
1690 "?" gnus-summary-mark-as-dormant
1691 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1692 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1693 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1694 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1695 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1696 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1697 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1698 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1699 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1700 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1701 "=" gnus-summary-expand-window
1702 "\C-x\C-s" gnus-summary-reselect-current-group
1703 "\M-g" gnus-summary-rescan-group
1704 "w" gnus-summary-stop-page-breaking
1705 "\C-c\C-r" gnus-summary-caesar-message
1706 "f" gnus-summary-followup
1707 "F" gnus-summary-followup-with-original
1708 "C" gnus-summary-cancel-article
1709 "r" gnus-summary-reply
1710 "R" gnus-summary-reply-with-original
1711 "\C-c\C-f" gnus-summary-mail-forward
1712 "o" gnus-summary-save-article
1713 "\C-o" gnus-summary-save-article-mail
1714 "|" gnus-summary-pipe-output
1715 "\M-k" gnus-summary-edit-local-kill
1716 "\M-K" gnus-summary-edit-global-kill
1717 ;; "V" gnus-version
1718 "\C-c\C-d" gnus-summary-describe-group
1719 "q" gnus-summary-exit
1720 "Q" gnus-summary-exit-no-update
1721 "\C-c\C-i" gnus-info-find-node
1722 gnus-mouse-2 gnus-mouse-pick-article
132cf96d 1723 [follow-link] mouse-face
23f87bed
MB
1724 "m" gnus-summary-mail-other-window
1725 "a" gnus-summary-post-news
1726 "i" gnus-summary-news-other-window
1727 "x" gnus-summary-limit-to-unread
1728 "s" gnus-summary-isearch-article
1729 "t" gnus-summary-toggle-header
1730 "g" gnus-summary-show-article
1731 "l" gnus-summary-goto-last-article
1732 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1733 "\C-d" gnus-summary-enter-digest-group
1734 "\M-\C-d" gnus-summary-read-document
1735 "\M-\C-e" gnus-summary-edit-parameters
1736 "\M-\C-a" gnus-summary-customize-parameters
1737 "\C-c\C-b" gnus-bug
1738 "*" gnus-cache-enter-article
1739 "\M-*" gnus-cache-remove-article
1740 "\M-&" gnus-summary-universal-argument
1741 "\C-l" gnus-recenter
1742 "I" gnus-summary-increase-score
1743 "L" gnus-summary-lower-score
1744 "\M-i" gnus-symbolic-argument
1745 "h" gnus-summary-select-article-buffer
1746
1747 "b" gnus-article-view-part
1748 "\M-t" gnus-summary-toggle-display-buttonized
1749
1750 "V" gnus-summary-score-map
1751 "X" gnus-uu-extract-map
1752 "S" gnus-summary-send-map)
1753
1754;; Sort of orthogonal keymap
1755(gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1756 "t" gnus-summary-tick-article-forward
1757 "!" gnus-summary-tick-article-forward
1758 "d" gnus-summary-mark-as-read-forward
1759 "r" gnus-summary-mark-as-read-forward
1760 "c" gnus-summary-clear-mark-forward
1761 " " gnus-summary-clear-mark-forward
1762 "e" gnus-summary-mark-as-expirable
1763 "x" gnus-summary-mark-as-expirable
1764 "?" gnus-summary-mark-as-dormant
1765 "b" gnus-summary-set-bookmark
1766 "B" gnus-summary-remove-bookmark
1767 "#" gnus-summary-mark-as-processable
1768 "\M-#" gnus-summary-unmark-as-processable
1769 "S" gnus-summary-limit-include-expunged
1770 "C" gnus-summary-catchup
1771 "H" gnus-summary-catchup-to-here
1772 "h" gnus-summary-catchup-from-here
1773 "\C-c" gnus-summary-catchup-all
1774 "k" gnus-summary-kill-same-subject-and-select
1775 "K" gnus-summary-kill-same-subject
1776 "P" gnus-uu-mark-map)
1777
1778(gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1779 "c" gnus-summary-clear-above
1780 "u" gnus-summary-tick-above
1781 "m" gnus-summary-mark-above
1782 "k" gnus-summary-kill-below)
1783
1784(gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1785 "/" gnus-summary-limit-to-subject
1786 "n" gnus-summary-limit-to-articles
1787 "w" gnus-summary-pop-limit
1788 "s" gnus-summary-limit-to-subject
1789 "a" gnus-summary-limit-to-author
1790 "u" gnus-summary-limit-to-unread
1791 "m" gnus-summary-limit-to-marks
1792 "M" gnus-summary-limit-exclude-marks
1793 "v" gnus-summary-limit-to-score
1794 "*" gnus-summary-limit-include-cached
1795 "D" gnus-summary-limit-include-dormant
1796 "T" gnus-summary-limit-include-thread
1797 "d" gnus-summary-limit-exclude-dormant
1798 "t" gnus-summary-limit-to-age
1799 "." gnus-summary-limit-to-unseen
1800 "x" gnus-summary-limit-to-extra
1801 "p" gnus-summary-limit-to-display-predicate
1802 "E" gnus-summary-limit-include-expunged
1803 "c" gnus-summary-limit-exclude-childless-dormant
1804 "C" gnus-summary-limit-mark-excluded-as-read
1805 "o" gnus-summary-insert-old-articles
1806 "N" gnus-summary-insert-new-articles)
1807
1808(gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1809 "n" gnus-summary-next-unread-article
1810 "p" gnus-summary-prev-unread-article
1811 "N" gnus-summary-next-article
1812 "P" gnus-summary-prev-article
1813 "\C-n" gnus-summary-next-same-subject
1814 "\C-p" gnus-summary-prev-same-subject
1815 "\M-n" gnus-summary-next-unread-subject
1816 "\M-p" gnus-summary-prev-unread-subject
1817 "f" gnus-summary-first-unread-article
1818 "b" gnus-summary-best-unread-article
1819 "j" gnus-summary-goto-article
1820 "g" gnus-summary-goto-subject
1821 "l" gnus-summary-goto-last-article
1822 "o" gnus-summary-pop-article)
1823
1824(gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1825 "k" gnus-summary-kill-thread
1826 "l" gnus-summary-lower-thread
1827 "i" gnus-summary-raise-thread
1828 "T" gnus-summary-toggle-threads
1829 "t" gnus-summary-rethread-current
1830 "^" gnus-summary-reparent-thread
1831 "s" gnus-summary-show-thread
1832 "S" gnus-summary-show-all-threads
1833 "h" gnus-summary-hide-thread
1834 "H" gnus-summary-hide-all-threads
1835 "n" gnus-summary-next-thread
1836 "p" gnus-summary-prev-thread
1837 "u" gnus-summary-up-thread
1838 "o" gnus-summary-top-thread
1839 "d" gnus-summary-down-thread
1840 "#" gnus-uu-mark-thread
1841 "\M-#" gnus-uu-unmark-thread)
1842
1843(gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1844 "g" gnus-summary-prepare
1845 "c" gnus-summary-insert-cached-articles
1846 "d" gnus-summary-insert-dormant-articles)
1847
1848(gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1849 "c" gnus-summary-catchup-and-exit
1850 "C" gnus-summary-catchup-all-and-exit
1851 "E" gnus-summary-exit-no-update
1852 "Q" gnus-summary-exit
1853 "Z" gnus-summary-exit
1854 "n" gnus-summary-catchup-and-goto-next-group
1855 "R" gnus-summary-reselect-current-group
1856 "G" gnus-summary-rescan-group
1857 "N" gnus-summary-next-group
1858 "s" gnus-summary-save-newsrc
1859 "P" gnus-summary-prev-group)
1860
1861(gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1862 " " gnus-summary-next-page
1863 "n" gnus-summary-next-page
1864 "\177" gnus-summary-prev-page
1865 [delete] gnus-summary-prev-page
1866 "p" gnus-summary-prev-page
1867 "\r" gnus-summary-scroll-up
1868 "\M-\r" gnus-summary-scroll-down
1869 "<" gnus-summary-beginning-of-article
1870 ">" gnus-summary-end-of-article
1871 "b" gnus-summary-beginning-of-article
1872 "e" gnus-summary-end-of-article
1873 "^" gnus-summary-refer-parent-article
1874 "r" gnus-summary-refer-parent-article
1875 "D" gnus-summary-enter-digest-group
1876 "R" gnus-summary-refer-references
1877 "T" gnus-summary-refer-thread
1878 "g" gnus-summary-show-article
1879 "s" gnus-summary-isearch-article
1880 "P" gnus-summary-print-article
1881 "M" gnus-mailing-list-insinuate
1882 "t" gnus-article-babel)
1883
1884(gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1885 "b" gnus-article-add-buttons
1886 "B" gnus-article-add-buttons-to-head
1887 "o" gnus-article-treat-overstrike
1888 "e" gnus-article-emphasize
1889 "w" gnus-article-fill-cited-article
1890 "Q" gnus-article-fill-long-lines
1891 "C" gnus-article-capitalize-sentences
1892 "c" gnus-article-remove-cr
1893 "q" gnus-article-de-quoted-unreadable
1894 "6" gnus-article-de-base64-unreadable
1895 "Z" gnus-article-decode-HZ
1896 "h" gnus-article-wash-html
1897 "u" gnus-article-unsplit-urls
1898 "s" gnus-summary-force-verify-and-decrypt
1899 "f" gnus-article-display-x-face
1900 "l" gnus-summary-stop-page-breaking
1901 "r" gnus-summary-caesar-message
1902 "m" gnus-summary-morse-message
1903 "t" gnus-summary-toggle-header
1904 "g" gnus-treat-smiley
1905 "v" gnus-summary-verbose-headers
1906 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1907 "p" gnus-article-verify-x-pgp-sig
1908 "d" gnus-article-treat-dumbquotes)
1909
1910(gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1911 ;; mnemonic: deuglif*Y*
1912 "u" gnus-article-outlook-unwrap-lines
1913 "a" gnus-article-outlook-repair-attribution
1914 "c" gnus-article-outlook-rearrange-citation
1915 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1916
1917(gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1918 "a" gnus-article-hide
1919 "h" gnus-article-hide-headers
1920 "b" gnus-article-hide-boring-headers
1921 "s" gnus-article-hide-signature
1922 "c" gnus-article-hide-citation
1923 "C" gnus-article-hide-citation-in-followups
1924 "l" gnus-article-hide-list-identifiers
1925 "B" gnus-article-strip-banner
1926 "P" gnus-article-hide-pem
1927 "\C-c" gnus-article-hide-citation-maybe)
1928
1929(gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1930 "a" gnus-article-highlight
1931 "h" gnus-article-highlight-headers
1932 "c" gnus-article-highlight-citation
1933 "s" gnus-article-highlight-signature)
1934
1935(gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1936 "f" gnus-article-treat-fold-headers
1937 "u" gnus-article-treat-unfold-headers
1938 "n" gnus-article-treat-fold-newsgroups)
1939
1940(gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1941 "x" gnus-article-display-x-face
1942 "d" gnus-article-display-face
1943 "s" gnus-treat-smiley
1944 "D" gnus-article-remove-images
1945 "f" gnus-treat-from-picon
1946 "m" gnus-treat-mail-picon
1947 "n" gnus-treat-newsgroups-picon)
1948
1949(gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1950 "w" gnus-article-decode-mime-words
1951 "c" gnus-article-decode-charset
1952 "v" gnus-mime-view-all-parts
1953 "b" gnus-article-view-part)
1954
1955(gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1956 "z" gnus-article-date-ut
1957 "u" gnus-article-date-ut
1958 "l" gnus-article-date-local
1959 "p" gnus-article-date-english
1960 "e" gnus-article-date-lapsed
1961 "o" gnus-article-date-original
1962 "i" gnus-article-date-iso8601
1963 "s" gnus-article-date-user)
1964
1965(gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1966 "t" gnus-article-remove-trailing-blank-lines
1967 "l" gnus-article-strip-leading-blank-lines
1968 "m" gnus-article-strip-multiple-blank-lines
1969 "a" gnus-article-strip-blank-lines
1970 "A" gnus-article-strip-all-blank-lines
1971 "s" gnus-article-strip-leading-space
1972 "e" gnus-article-strip-trailing-space
1973 "w" gnus-article-remove-leading-whitespace)
1974
1975(gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1976 "v" gnus-version
1977 "f" gnus-summary-fetch-faq
1978 "d" gnus-summary-describe-group
1979 "h" gnus-summary-describe-briefly
1980 "i" gnus-info-find-node
1981 "c" gnus-group-fetch-charter
1982 "C" gnus-group-fetch-control)
1983
1984(gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1985 "e" gnus-summary-expire-articles
1986 "\M-\C-e" gnus-summary-expire-articles-now
1987 "\177" gnus-summary-delete-article
1988 [delete] gnus-summary-delete-article
1989 [backspace] gnus-summary-delete-article
1990 "m" gnus-summary-move-article
1991 "r" gnus-summary-respool-article
1992 "w" gnus-summary-edit-article
1993 "c" gnus-summary-copy-article
1994 "B" gnus-summary-crosspost-article
1995 "q" gnus-summary-respool-query
1996 "t" gnus-summary-respool-trace
1997 "i" gnus-summary-import-article
1998 "I" gnus-summary-create-article
1999 "p" gnus-summary-article-posted-p)
2000
2001(gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2002 "o" gnus-summary-save-article
2003 "m" gnus-summary-save-article-mail
2004 "F" gnus-summary-write-article-file
2005 "r" gnus-summary-save-article-rmail
2006 "f" gnus-summary-save-article-file
2007 "b" gnus-summary-save-article-body-file
26c9afc3 2008 "B" gnus-summary-write-article-body-file
23f87bed
MB
2009 "h" gnus-summary-save-article-folder
2010 "v" gnus-summary-save-article-vm
2011 "p" gnus-summary-pipe-output
2012 "P" gnus-summary-muttprint
2013 "s" gnus-soup-add-article)
2014
2015(gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2016 "b" gnus-summary-display-buttonized
2017 "m" gnus-summary-repair-multipart
2018 "v" gnus-article-view-part
2019 "o" gnus-article-save-part
2020 "c" gnus-article-copy-part
2021 "C" gnus-article-view-part-as-charset
2022 "e" gnus-article-view-part-externally
2023 "E" gnus-article-encrypt-body
2024 "i" gnus-article-inline-part
2025 "|" gnus-article-pipe-part)
2026
2027(gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2028 "p" gnus-summary-mark-as-processable
2029 "u" gnus-summary-unmark-as-processable
2030 "U" gnus-summary-unmark-all-processable
2031 "v" gnus-uu-mark-over
2032 "s" gnus-uu-mark-series
2033 "r" gnus-uu-mark-region
2034 "g" gnus-uu-unmark-region
2035 "R" gnus-uu-mark-by-regexp
2036 "G" gnus-uu-unmark-by-regexp
2037 "t" gnus-uu-mark-thread
2038 "T" gnus-uu-unmark-thread
2039 "a" gnus-uu-mark-all
2040 "b" gnus-uu-mark-buffer
2041 "S" gnus-uu-mark-sparse
2042 "k" gnus-summary-kill-process-mark
2043 "y" gnus-summary-yank-process-mark
2044 "w" gnus-summary-save-process-mark
2045 "i" gnus-uu-invert-processable)
2046
2047(gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2048 ;;"x" gnus-uu-extract-any
2049 "m" gnus-summary-save-parts
2050 "u" gnus-uu-decode-uu
2051 "U" gnus-uu-decode-uu-and-save
2052 "s" gnus-uu-decode-unshar
2053 "S" gnus-uu-decode-unshar-and-save
2054 "o" gnus-uu-decode-save
2055 "O" gnus-uu-decode-save
2056 "b" gnus-uu-decode-binhex
2057 "B" gnus-uu-decode-binhex
2058 "p" gnus-uu-decode-postscript
2059 "P" gnus-uu-decode-postscript-and-save)
2060
2061(gnus-define-keys
2062 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2063 "u" gnus-uu-decode-uu-view
2064 "U" gnus-uu-decode-uu-and-save-view
2065 "s" gnus-uu-decode-unshar-view
2066 "S" gnus-uu-decode-unshar-and-save-view
2067 "o" gnus-uu-decode-save-view
2068 "O" gnus-uu-decode-save-view
2069 "b" gnus-uu-decode-binhex-view
2070 "B" gnus-uu-decode-binhex-view
2071 "p" gnus-uu-decode-postscript-view
2072 "P" gnus-uu-decode-postscript-and-save-view)
2073
2074(defvar gnus-article-post-menu nil)
2075
2076(defconst gnus-summary-menu-maxlen 20)
2077
2078(defun gnus-summary-menu-split (menu)
2079 ;; If we have lots of elements, divide them into groups of 20
2080 ;; and make a pane (or submenu) for each one.
2081 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2082 (let ((menu menu) sublists next
2083 (i 1))
2084 (while menu
2085 ;; Pull off the next gnus-summary-menu-maxlen elements
2086 ;; and make them the next element of sublist.
2087 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2088 (if next
2089 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2090 nil))
2091 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2092 (aref (car (last menu)) 0)) menu)
2093 sublists))
2094 (setq i (1+ i))
2095 (setq menu next))
2096 (nreverse sublists))
2097 ;; Few elements--put them all in one pane.
2098 menu))
eec82323
LMI
2099
2100(defun gnus-summary-make-menu-bar ()
2101 (gnus-turn-off-edit-menu 'summary)
2102
2103 (unless (boundp 'gnus-summary-misc-menu)
2104
2105 (easy-menu-define
23f87bed
MB
2106 gnus-summary-kill-menu gnus-summary-mode-map ""
2107 (cons
2108 "Score"
2109 (nconc
2110 (list
2111 ["Customize" gnus-score-customize t])
2112 (gnus-make-score-map 'increase)
2113 (gnus-make-score-map 'lower)
2114 '(("Mark"
2115 ["Kill below" gnus-summary-kill-below t]
2116 ["Mark above" gnus-summary-mark-above t]
2117 ["Tick above" gnus-summary-tick-above t]
2118 ["Clear above" gnus-summary-clear-above t])
2119 ["Current score" gnus-summary-current-score t]
2120 ["Set score" gnus-summary-set-score t]
2121 ["Switch current score file..." gnus-score-change-score-file t]
2122 ["Set mark below..." gnus-score-set-mark-below t]
2123 ["Set expunge below..." gnus-score-set-expunge-below t]
2124 ["Edit current score file" gnus-score-edit-current-scores t]
2125 ["Edit score file" gnus-score-edit-file t]
2126 ["Trace score" gnus-score-find-trace t]
2127 ["Find words" gnus-score-find-favourite-words t]
2128 ["Rescore buffer" gnus-summary-rescore t]
2129 ["Increase score..." gnus-summary-increase-score t]
2130 ["Lower score..." gnus-summary-lower-score t]))))
2131
2132 ;; Define both the Article menu in the summary buffer and the
2133 ;; equivalent Commands menu in the article buffer here for
2134 ;; consistency.
6748645f 2135 (let ((innards
23f87bed
MB
2136 `(("Hide"
2137 ["All" gnus-article-hide t]
2138 ["Headers" gnus-article-hide-headers t]
2139 ["Signature" gnus-article-hide-signature t]
2140 ["Citation" gnus-article-hide-citation t]
16409b0b 2141 ["List identifiers" gnus-article-hide-list-identifiers t]
16409b0b 2142 ["Banner" gnus-article-strip-banner t]
23f87bed
MB
2143 ["Boring headers" gnus-article-hide-boring-headers t])
2144 ("Highlight"
2145 ["All" gnus-article-highlight t]
2146 ["Headers" gnus-article-highlight-headers t]
2147 ["Signature" gnus-article-highlight-signature t]
2148 ["Citation" gnus-article-highlight-citation t])
16409b0b
GM
2149 ("MIME"
2150 ["Words" gnus-article-decode-mime-words t]
2151 ["Charset" gnus-article-decode-charset t]
2152 ["QP" gnus-article-de-quoted-unreadable t]
2153 ["Base64" gnus-article-de-base64-unreadable t]
23f87bed
MB
2154 ["View MIME buttons" gnus-summary-display-buttonized t]
2155 ["View all" gnus-mime-view-all-parts t]
2156 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2157 ["Encrypt body" gnus-article-encrypt-body
2158 :active (not (gnus-group-read-only-p))
2159 ,@(if (featurep 'xemacs) nil
2160 '(:help "Encrypt the message body on disk"))]
2161 ["Extract all parts..." gnus-summary-save-parts t]
2162 ("Multipart"
2163 ["Repair multipart" gnus-summary-repair-multipart t]
2164 ["Pipe part..." gnus-article-pipe-part t]
2165 ["Inline part" gnus-article-inline-part t]
2166 ["Encrypt body" gnus-article-encrypt-body
2167 :active (not (gnus-group-read-only-p))
2168 ,@(if (featurep 'xemacs) nil
2169 '(:help "Encrypt the message body on disk"))]
2170 ["View part externally" gnus-article-view-part-externally t]
2171 ["View part with charset..." gnus-article-view-part-as-charset t]
2172 ["Copy part" gnus-article-copy-part t]
2173 ["Save part..." gnus-article-save-part t]
2174 ["View part" gnus-article-view-part t]))
2175 ("Date"
2176 ["Local" gnus-article-date-local t]
2177 ["ISO8601" gnus-article-date-iso8601 t]
2178 ["UT" gnus-article-date-ut t]
2179 ["Original" gnus-article-date-original t]
2180 ["Lapsed" gnus-article-date-lapsed t]
2181 ["User-defined" gnus-article-date-user t])
2182 ("Display"
2183 ["Remove images" gnus-article-remove-images t]
2184 ["Toggle smiley" gnus-treat-smiley t]
2185 ["Show X-Face" gnus-article-display-x-face t]
2186 ["Show picons in From" gnus-treat-from-picon t]
2187 ["Show picons in mail headers" gnus-treat-mail-picon t]
2188 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2189 ("View as different encoding"
2190 ,@(gnus-summary-menu-split
2191 (mapcar
2192 (lambda (cs)
2193 ;; Since easymenu under Emacs doesn't allow
2194 ;; lambda forms for menu commands, we should
2195 ;; provide intern'ed function symbols.
2196 (let ((command (intern (format "\
2197gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2198 (fset command
2199 `(lambda ()
2200 (interactive)
2201 (let ((gnus-summary-show-article-charset-alist
2202 '((1 . ,cs))))
2203 (gnus-summary-show-article 1))))
2204 `[,(symbol-name cs) ,command t]))
2205 (sort (if (fboundp 'coding-system-list)
2206 (coding-system-list)
2207 (mapcar 'car mm-mime-mule-charset-alist))
2208 'string<)))))
2209 ("Washing"
2210 ("Remove Blanks"
2211 ["Leading" gnus-article-strip-leading-blank-lines t]
2212 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2213 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2214 ["All of the above" gnus-article-strip-blank-lines t]
2215 ["All" gnus-article-strip-all-blank-lines t]
2216 ["Leading space" gnus-article-strip-leading-space t]
2217 ["Trailing space" gnus-article-strip-trailing-space t]
2218 ["Leading space in headers"
2219 gnus-article-remove-leading-whitespace t])
2220 ["Overstrike" gnus-article-treat-overstrike t]
2221 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2222 ["Emphasis" gnus-article-emphasize t]
2223 ["Word wrap" gnus-article-fill-cited-article t]
16409b0b
GM
2224 ["Fill long lines" gnus-article-fill-long-lines t]
2225 ["Capitalize sentences" gnus-article-capitalize-sentences t]
23f87bed
MB
2226 ["Remove CR" gnus-article-remove-cr t]
2227 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2228 ["Base64" gnus-article-de-base64-unreadable t]
2229 ["Rot 13" gnus-summary-caesar-message
2230 ,@(if (featurep 'xemacs) '(t)
2231 '(:help "\"Caesar rotate\" article by 13"))]
2232 ["Morse decode" gnus-summary-morse-message t]
2233 ["Unix pipe..." gnus-summary-pipe-message t]
2234 ["Add buttons" gnus-article-add-buttons t]
2235 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2236 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2237 ["Verbose header" gnus-summary-verbose-headers t]
2238 ["Toggle header" gnus-summary-toggle-header t]
2239 ["Unfold headers" gnus-article-treat-unfold-headers t]
2240 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
16409b0b 2241 ["Html" gnus-article-wash-html t]
23f87bed
MB
2242 ["Unsplit URLs" gnus-article-unsplit-urls t]
2243 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2244 ["Decode HZ" gnus-article-decode-HZ t]
2245 ("(Outlook) Deuglify"
2246 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2247 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2248 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2249 ["Full (Outlook) deuglify"
2250 gnus-article-outlook-deuglify-article t])
2251 )
2252 ("Output"
2253 ["Save in default format..." gnus-summary-save-article
2254 ,@(if (featurep 'xemacs) '(t)
2255 '(:help "Save article using default method"))]
2256 ["Save in file..." gnus-summary-save-article-file
2257 ,@(if (featurep 'xemacs) '(t)
2258 '(:help "Save article in file"))]
2259 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2260 ["Save in MH folder..." gnus-summary-save-article-folder t]
2261 ["Save in VM folder..." gnus-summary-save-article-vm t]
2262 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2263 ["Save body in file..." gnus-summary-save-article-body-file t]
2264 ["Pipe through a filter..." gnus-summary-pipe-output t]
2265 ["Add to SOUP packet" gnus-soup-add-article t]
2266 ["Print with Muttprint..." gnus-summary-muttprint t]
531e5812
MB
2267 ["Print" gnus-summary-print-article
2268 ,@(if (featurep 'xemacs) '(t)
2269 '(:help "Generate and print a PostScript image"))])
2270 ("Copy, move,... (Backend)"
707f2b38 2271 ,@(if (featurep 'xemacs) nil
531e5812 2272 '(:help "Copying, moving, expiring articles..."))
23f87bed
MB
2273 ["Respool article..." gnus-summary-respool-article t]
2274 ["Move article..." gnus-summary-move-article
2275 (gnus-check-backend-function
2276 'request-move-article gnus-newsgroup-name)]
2277 ["Copy article..." gnus-summary-copy-article t]
2278 ["Crosspost article..." gnus-summary-crosspost-article
2279 (gnus-check-backend-function
2280 'request-replace-article gnus-newsgroup-name)]
2281 ["Import file..." gnus-summary-import-article
2282 (gnus-check-backend-function
2283 'request-accept-article gnus-newsgroup-name)]
2284 ["Create article..." gnus-summary-create-article
2285 (gnus-check-backend-function
2286 'request-accept-article gnus-newsgroup-name)]
2287 ["Check if posted" gnus-summary-article-posted-p t]
2288 ["Edit article" gnus-summary-edit-article
2289 (not (gnus-group-read-only-p))]
2290 ["Delete article" gnus-summary-delete-article
2291 (gnus-check-backend-function
2292 'request-expire-articles gnus-newsgroup-name)]
2293 ["Query respool" gnus-summary-respool-query t]
6748645f 2294 ["Trace respool" gnus-summary-respool-trace t]
23f87bed
MB
2295 ["Delete expirable articles" gnus-summary-expire-articles-now
2296 (gnus-check-backend-function
2297 'request-expire-articles gnus-newsgroup-name)])
2298 ("Extract"
2299 ["Uudecode" gnus-uu-decode-uu
2300 ,@(if (featurep 'xemacs) '(t)
2301 '(:help "Decode uuencoded article(s)"))]
2302 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2303 ["Unshar" gnus-uu-decode-unshar t]
2304 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2305 ["Save" gnus-uu-decode-save t]
2306 ["Binhex" gnus-uu-decode-binhex t]
2307 ["Postscript" gnus-uu-decode-postscript t]
2308 ["All MIME parts" gnus-summary-save-parts t])
2309 ("Cache"
2310 ["Enter article" gnus-cache-enter-article t]
2311 ["Remove article" gnus-cache-remove-article t])
16409b0b 2312 ["Translate" gnus-article-babel t]
23f87bed
MB
2313 ["Select article buffer" gnus-summary-select-article-buffer t]
2314 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2315 ["Isearch article..." gnus-summary-isearch-article t]
2316 ["Beginning of the article" gnus-summary-beginning-of-article t]
2317 ["End of the article" gnus-summary-end-of-article t]
2318 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2319 ["Fetch referenced articles" gnus-summary-refer-references t]
2320 ["Fetch current thread" gnus-summary-refer-thread t]
2321 ["Fetch article with id..." gnus-summary-refer-article t]
2322 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2323 ["Redisplay" gnus-summary-show-article t]
2324 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
6748645f 2325 (easy-menu-define
23f87bed
MB
2326 gnus-summary-article-menu gnus-summary-mode-map ""
2327 (cons "Article" innards))
6748645f 2328
1653df0f
SZ
2329 (if (not (keymapp gnus-summary-article-menu))
2330 (easy-menu-define
2331 gnus-article-commands-menu gnus-article-mode-map ""
2332 (cons "Commands" innards))
2333 ;; in Emacs, don't share menu.
a1506d29 2334 (setq gnus-article-commands-menu
1653df0f
SZ
2335 (copy-keymap gnus-summary-article-menu))
2336 (define-key gnus-article-mode-map [menu-bar commands]
2337 (cons "Commands" gnus-article-commands-menu))))
eec82323
LMI
2338
2339 (easy-menu-define
23f87bed
MB
2340 gnus-summary-thread-menu gnus-summary-mode-map ""
2341 '("Threads"
2342 ["Find all messages in thread" gnus-summary-refer-thread t]
2343 ["Toggle threading" gnus-summary-toggle-threads t]
2344 ["Hide threads" gnus-summary-hide-all-threads t]
2345 ["Show threads" gnus-summary-show-all-threads t]
2346 ["Hide thread" gnus-summary-hide-thread t]
2347 ["Show thread" gnus-summary-show-thread t]
2348 ["Go to next thread" gnus-summary-next-thread t]
2349 ["Go to previous thread" gnus-summary-prev-thread t]
2350 ["Go down thread" gnus-summary-down-thread t]
2351 ["Go up thread" gnus-summary-up-thread t]
2352 ["Top of thread" gnus-summary-top-thread t]
2353 ["Mark thread as read" gnus-summary-kill-thread t]
2354 ["Lower thread score" gnus-summary-lower-thread t]
2355 ["Raise thread score" gnus-summary-raise-thread t]
2356 ["Rethread current" gnus-summary-rethread-current t]))
eec82323
LMI
2357
2358 (easy-menu-define
23f87bed
MB
2359 gnus-summary-post-menu gnus-summary-mode-map ""
2360 `("Post"
2361 ["Send a message (mail or news)" gnus-summary-post-news
2362 ,@(if (featurep 'xemacs) '(t)
531e5812 2363 '(:help "Compose a new message (mail or news)"))]
23f87bed
MB
2364 ["Followup" gnus-summary-followup
2365 ,@(if (featurep 'xemacs) '(t)
2366 '(:help "Post followup to this article"))]
2367 ["Followup and yank" gnus-summary-followup-with-original
2368 ,@(if (featurep 'xemacs) '(t)
2369 '(:help "Post followup to this article, quoting its contents"))]
2370 ["Supersede article" gnus-summary-supersede-article t]
2371 ["Cancel article" gnus-summary-cancel-article
2372 ,@(if (featurep 'xemacs) '(t)
2373 '(:help "Cancel an article you posted"))]
2374 ["Reply" gnus-summary-reply t]
2375 ["Reply and yank" gnus-summary-reply-with-original t]
2376 ["Wide reply" gnus-summary-wide-reply t]
2377 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2378 ,@(if (featurep 'xemacs) '(t)
2379 '(:help "Mail a reply, quoting this article"))]
2380 ["Very wide reply" gnus-summary-very-wide-reply t]
2381 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2382 ,@(if (featurep 'xemacs) '(t)
2383 '(:help "Mail a very wide reply, quoting this article"))]
2384 ["Mail forward" gnus-summary-mail-forward t]
2385 ["Post forward" gnus-summary-post-forward t]
2386 ["Digest and mail" gnus-uu-digest-mail-forward t]
2387 ["Digest and post" gnus-uu-digest-post-forward t]
2388 ["Resend message" gnus-summary-resend-message t]
2389 ["Resend message edit" gnus-summary-resend-message-edit t]
2390 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2391 ["Send a mail" gnus-summary-mail-other-window t]
2392 ["Create a local message" gnus-summary-news-other-window t]
2393 ["Uuencode and post" gnus-uu-post-news
2394 ,@(if (featurep 'xemacs) '(t)
2395 '(:help "Post a uuencoded article"))]
2396 ["Followup via news" gnus-summary-followup-to-mail t]
2397 ["Followup via news and yank"
2398 gnus-summary-followup-to-mail-with-original t]
2399 ;;("Draft"
2400 ;;["Send" gnus-summary-send-draft t]
2401 ;;["Send bounced" gnus-resend-bounced-mail t])
2402 ))
2403
2404 (cond
2405 ((not (keymapp gnus-summary-post-menu))
2406 (setq gnus-article-post-menu gnus-summary-post-menu))
2407 ((not gnus-article-post-menu)
2408 ;; Don't share post menu.
2409 (setq gnus-article-post-menu
2410 (copy-keymap gnus-summary-post-menu))))
2411 (define-key gnus-article-mode-map [menu-bar post]
2412 (cons "Post" gnus-article-post-menu))
eec82323
LMI
2413
2414 (easy-menu-define
23f87bed
MB
2415 gnus-summary-misc-menu gnus-summary-mode-map ""
2416 `("Gnus"
2417 ("Mark Read"
2418 ["Mark as read" gnus-summary-mark-as-read-forward t]
2419 ["Mark same subject and select"
2420 gnus-summary-kill-same-subject-and-select t]
2421 ["Mark same subject" gnus-summary-kill-same-subject t]
2422 ["Catchup" gnus-summary-catchup
2423 ,@(if (featurep 'xemacs) '(t)
2424 '(:help "Mark unread articles in this group as read"))]
2425 ["Catchup all" gnus-summary-catchup-all t]
2426 ["Catchup to here" gnus-summary-catchup-to-here t]
2427 ["Catchup from here" gnus-summary-catchup-from-here t]
2428 ["Catchup region" gnus-summary-mark-region-as-read
2429 (gnus-mark-active-p)]
2430 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2431 ("Mark Various"
2432 ["Tick" gnus-summary-tick-article-forward t]
2433 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2434 ["Remove marks" gnus-summary-clear-mark-forward t]
2435 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2436 ["Set bookmark" gnus-summary-set-bookmark t]
2437 ["Remove bookmark" gnus-summary-remove-bookmark t])
2438 ("Limit to"
2439 ["Marks..." gnus-summary-limit-to-marks t]
2440 ["Subject..." gnus-summary-limit-to-subject t]
2441 ["Author..." gnus-summary-limit-to-author t]
2442 ["Age..." gnus-summary-limit-to-age t]
2443 ["Extra..." gnus-summary-limit-to-extra t]
2444 ["Score..." gnus-summary-limit-to-score t]
2445 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2446 ["Unread" gnus-summary-limit-to-unread t]
2447 ["Unseen" gnus-summary-limit-to-unseen t]
2448 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
996aa8c1 2449 ["Next or process marked articles" gnus-summary-limit-to-articles t]
23f87bed
MB
2450 ["Pop limit" gnus-summary-pop-limit t]
2451 ["Show dormant" gnus-summary-limit-include-dormant t]
2452 ["Hide childless dormant"
2453 gnus-summary-limit-exclude-childless-dormant t]
2454 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2455 ["Hide marked" gnus-summary-limit-exclude-marks t]
2456 ["Show expunged" gnus-summary-limit-include-expunged t])
2457 ("Process Mark"
2458 ["Set mark" gnus-summary-mark-as-processable t]
2459 ["Remove mark" gnus-summary-unmark-as-processable t]
2460 ["Remove all marks" gnus-summary-unmark-all-processable t]
2461 ["Mark above" gnus-uu-mark-over t]
2462 ["Mark series" gnus-uu-mark-series t]
2463 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2464 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2465 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2466 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2467 ["Mark all" gnus-uu-mark-all t]
2468 ["Mark buffer" gnus-uu-mark-buffer t]
2469 ["Mark sparse" gnus-uu-mark-sparse t]
2470 ["Mark thread" gnus-uu-mark-thread t]
2471 ["Unmark thread" gnus-uu-unmark-thread t]
2472 ("Process Mark Sets"
2473 ["Kill" gnus-summary-kill-process-mark t]
2474 ["Yank" gnus-summary-yank-process-mark
2475 gnus-newsgroup-process-stack]
2476 ["Save" gnus-summary-save-process-mark t]
2477 ["Run command on marked..." gnus-summary-universal-argument t]))
2478 ("Scroll article"
2479 ["Page forward" gnus-summary-next-page
2480 ,@(if (featurep 'xemacs) '(t)
2481 '(:help "Show next page of article"))]
2482 ["Page backward" gnus-summary-prev-page
2483 ,@(if (featurep 'xemacs) '(t)
2484 '(:help "Show previous page of article"))]
2485 ["Line forward" gnus-summary-scroll-up t])
2486 ("Move"
2487 ["Next unread article" gnus-summary-next-unread-article t]
2488 ["Previous unread article" gnus-summary-prev-unread-article t]
2489 ["Next article" gnus-summary-next-article t]
2490 ["Previous article" gnus-summary-prev-article t]
2491 ["Next unread subject" gnus-summary-next-unread-subject t]
2492 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2493 ["Next article same subject" gnus-summary-next-same-subject t]
2494 ["Previous article same subject" gnus-summary-prev-same-subject t]
2495 ["First unread article" gnus-summary-first-unread-article t]
2496 ["Best unread article" gnus-summary-best-unread-article t]
2497 ["Go to subject number..." gnus-summary-goto-subject t]
2498 ["Go to article number..." gnus-summary-goto-article t]
2499 ["Go to the last article" gnus-summary-goto-last-article t]
2500 ["Pop article off history" gnus-summary-pop-article t])
2501 ("Sort"
2502 ["Sort by number" gnus-summary-sort-by-number t]
2503 ["Sort by author" gnus-summary-sort-by-author t]
2504 ["Sort by subject" gnus-summary-sort-by-subject t]
2505 ["Sort by date" gnus-summary-sort-by-date t]
2506 ["Sort by score" gnus-summary-sort-by-score t]
2507 ["Sort by lines" gnus-summary-sort-by-lines t]
2508 ["Sort by characters" gnus-summary-sort-by-chars t]
2509 ["Randomize" gnus-summary-sort-by-random t]
2510 ["Original sort" gnus-summary-sort-by-original t])
2511 ("Help"
2512 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2513 ["Describe group" gnus-summary-describe-group t]
2514 ["Fetch charter" gnus-group-fetch-charter
2515 ,@(if (featurep 'xemacs) nil
2516 '(:help "Display the charter of the current group"))]
2517 ["Fetch control message" gnus-group-fetch-control
2518 ,@(if (featurep 'xemacs) nil
2519 '(:help "Display the archived control message for the current group"))]
2520 ["Read manual" gnus-info-find-node t])
2521 ("Modes"
2522 ["Pick and read" gnus-pick-mode t]
2523 ["Binary" gnus-binary-mode t])
2524 ("Regeneration"
2525 ["Regenerate" gnus-summary-prepare t]
2526 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2527 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2528 ["Toggle threading" gnus-summary-toggle-threads t])
2529 ["See old articles" gnus-summary-insert-old-articles t]
2530 ["See new articles" gnus-summary-insert-new-articles t]
2531 ["Filter articles..." gnus-summary-execute-command t]
2532 ["Run command on articles..." gnus-summary-universal-argument t]
2533 ["Search articles forward..." gnus-summary-search-article-forward t]
2534 ["Search articles backward..." gnus-summary-search-article-backward t]
2535 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2536 ["Expand window" gnus-summary-expand-window t]
2537 ["Expire expirable articles" gnus-summary-expire-articles
2538 (gnus-check-backend-function
2539 'request-expire-articles gnus-newsgroup-name)]
2540 ["Edit local kill file" gnus-summary-edit-local-kill t]
2541 ["Edit main kill file" gnus-summary-edit-global-kill t]
2542 ["Edit group parameters" gnus-summary-edit-parameters t]
2543 ["Customize group parameters" gnus-summary-customize-parameters t]
2544 ["Send a bug report" gnus-bug t]
2545 ("Exit"
2546 ["Catchup and exit" gnus-summary-catchup-and-exit
2547 ,@(if (featurep 'xemacs) '(t)
2548 '(:help "Mark unread articles in this group as read, then exit"))]
2549 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2550 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2551 ["Exit group" gnus-summary-exit
2552 ,@(if (featurep 'xemacs) '(t)
2553 '(:help "Exit current group, return to group selection mode"))]
2554 ["Exit group without updating" gnus-summary-exit-no-update t]
2555 ["Exit and goto next group" gnus-summary-next-group t]
2556 ["Exit and goto prev group" gnus-summary-prev-group t]
2557 ["Reselect group" gnus-summary-reselect-current-group t]
2558 ["Rescan group" gnus-summary-rescan-group t]
2559 ["Update dribble" gnus-summary-save-newsrc t])))
eec82323 2560
6748645f 2561 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323 2562
60bd5589
DL
2563(defvar gnus-summary-tool-bar-map nil)
2564
18c06a99
RS
2565;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2566;; affect _new_ message buffers. We might add a function that walks thru all
2567;; summary-mode buffers and force the update.
2568(defun gnus-summary-tool-bar-update (&optional symbol value)
2569 "Update summary mode toolbar.
2570Setter function for custom variables."
2571 (setq-default gnus-summary-tool-bar-map nil)
2572 (when symbol
2573 ;; When used as ":set" function:
2574 (set-default symbol value))
2575 (when (gnus-buffer-live-p gnus-summary-buffer)
2576 (with-current-buffer gnus-summary-buffer
2577 (gnus-summary-make-tool-bar))))
2578
2579(defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2580 'gnus-summary-tool-bar-gnome
2581 'gnus-summary-tool-bar-retro)
2582 "Specifies the Gnus summary tool bar.
2583
2584It can be either a list or a symbol refering to a list. See
2585`gmm-tool-bar-from-list' for the format of the list. The
2586default key map is `gnus-summary-mode-map'.
2587
2588Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2589`gnus-summary-tool-bar-retro'."
2590 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2591 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2592 (repeat :tag "User defined list" gmm-tool-bar-item)
2593 (symbol))
25bf7349 2594 :version "22.1" ;; Gnus 5.10.9
18c06a99
RS
2595 :initialize 'custom-initialize-default
2596 :set 'gnus-summary-tool-bar-update
2597 :group 'gnus-summary)
2598
2599(defcustom gnus-summary-tool-bar-gnome
2600 '((gnus-summary-post-news "mail/compose" nil)
2601 (gnus-summary-insert-new-articles "mail/inbox" nil
2602 :visible (or (not gnus-agent)
2603 gnus-plugged))
2604 (gnus-summary-reply-with-original "mail/reply")
2605 (gnus-summary-reply "mail/reply" nil :visible nil)
2606 (gnus-summary-followup-with-original "mail/reply-all")
2607 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2608 (gnus-summary-mail-forward "mail/forward")
2609 (gnus-summary-save-article "mail/save")
2610 (gnus-summary-search-article-forward "search" nil :visible nil)
2611 (gnus-summary-print-article "print")
2612 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2613 ;; Some new commands that may need more suitable icons:
2614 (gnus-summary-save-newsrc "save" nil :visible nil)
2615 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2616 (gnus-summary-prev-article "left-arrow")
2617 (gnus-summary-next-article "right-arrow")
2618 (gnus-summary-next-page "next-page")
2619 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2620 ;;
2621 ;; Maybe some sort-by-... could be added:
2622 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2623 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2624 (gnus-summary-mark-as-expirable
2625 "delete" nil
2626 :visible (gnus-check-backend-function 'request-expire-articles
2627 gnus-newsgroup-name))
2628 (gnus-summary-mark-as-spam
2629 "mail/spam" t
2630 :visible (and (fboundp 'spam-group-ham-contents-p)
2631 (spam-group-ham-contents-p gnus-newsgroup-name))
2632 :help "Mark as spam")
2633 (gnus-summary-mark-as-read-forward
2634 "mail/not-spam" nil
2635 :visible (and (fboundp 'spam-group-spam-contents-p)
2636 (spam-group-spam-contents-p gnus-newsgroup-name)))
2637 ;;
2638 (gnus-summary-exit "exit")
2639 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2640 (gnus-info-find-node "help"))
2641 "List of functions for the summary tool bar (GNOME style).
2642
2643See `gmm-tool-bar-from-list' for the format of the list."
2644 :type '(repeat gmm-tool-bar-item)
25bf7349 2645 :version "22.1" ;; Gnus 5.10.9
18c06a99
RS
2646 :initialize 'custom-initialize-default
2647 :set 'gnus-summary-tool-bar-update
2648 :group 'gnus-summary)
2649
2650(defcustom gnus-summary-tool-bar-retro
2651 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2652 (gnus-summary-next-unread-article "gnus/next-ur")
2653 (gnus-summary-post-news "gnus/post")
2654 (gnus-summary-followup-with-original "gnus/fuwo")
2655 (gnus-summary-followup "gnus/followup")
2656 (gnus-summary-reply-with-original "gnus/reply-wo")
2657 (gnus-summary-reply "gnus/reply")
2658 (gnus-summary-caesar-message "gnus/rot13")
2659 (gnus-uu-decode-uu "gnus/uu-decode")
2660 (gnus-summary-save-article-file "gnus/save-aif")
2661 (gnus-summary-save-article "gnus/save-art")
2662 (gnus-uu-post-news "gnus/uu-post")
2663 (gnus-summary-catchup "gnus/catchup")
2664 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2665 (gnus-summary-exit "gnus/exit-summ")
2666 ;; Some new command that may need more suitable icons:
2667 (gnus-summary-print-article "gnus/print" nil :visible nil)
2668 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2669 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2670 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2671 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2672 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2673 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2674 ;;
2675 (gnus-info-find-node "gnus/help" nil :visible nil))
2676 "List of functions for the summary tool bar (retro look).
2677
2678See `gmm-tool-bar-from-list' for the format of the list."
2679 :type '(repeat gmm-tool-bar-item)
25bf7349 2680 :version "22.1" ;; Gnus 5.10.9
18c06a99
RS
2681 :initialize 'custom-initialize-default
2682 :set 'gnus-summary-tool-bar-update
2683 :group 'gnus-summary)
2684
2685(defcustom gnus-summary-tool-bar-zap-list t
2686 "List of icon items from the global tool bar.
2687These items are not displayed in the Gnus summary mode tool bar.
2688
2689See `gmm-tool-bar-from-list' for the format of the list."
2690 :type 'gmm-tool-bar-zap-list
25bf7349 2691 :version "22.1" ;; Gnus 5.10.9
18c06a99
RS
2692 :initialize 'custom-initialize-default
2693 :set 'gnus-summary-tool-bar-update
2694 :group 'gnus-summary)
2695
2696(defvar image-load-path)
2697
2698(defun gnus-summary-make-tool-bar (&optional force)
2699 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2700When FORCE, rebuild the tool bar."
2701 (when (and (not (featurep 'xemacs))
2702 (boundp 'tool-bar-mode)
2703 tool-bar-mode
2704 (or (not gnus-summary-tool-bar-map) force))
2705 (let* ((load-path
2706 (gmm-image-load-path-for-library "gnus"
2707 "mail/save.xpm"
2708 nil t))
2709 (image-load-path (cons (car load-path)
2710 (when (boundp 'image-load-path)
2711 image-load-path)))
2712 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2713 gnus-summary-tool-bar-zap-list
2714 'gnus-summary-mode-map)))
2715 (when map
2716 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2717 ;; uses it's value.
2718 (setq gnus-summary-tool-bar-map map))))
2719 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
60bd5589 2720
eec82323
LMI
2721(defun gnus-score-set-default (var value)
2722 "A version of set that updates the GNU Emacs menu-bar."
2723 (set var value)
2724 ;; It is the message that forces the active status to be updated.
2725 (message ""))
2726
2727(defun gnus-make-score-map (type)
2728 "Make a summary score map of type TYPE."
2729 (if t
2730 nil
2731 (let ((headers '(("author" "from" string)
2732 ("subject" "subject" string)
2733 ("article body" "body" string)
2734 ("article head" "head" string)
2735 ("xref" "xref" string)
16409b0b 2736 ("extra header" "extra" string)
eec82323
LMI
2737 ("lines" "lines" number)
2738 ("followups to author" "followup" string)))
2739 (types '((number ("less than" <)
2740 ("greater than" >)
2741 ("equal" =))
2742 (string ("substring" s)
2743 ("exact string" e)
2744 ("fuzzy string" f)
2745 ("regexp" r))))
2746 (perms '(("temporary" (current-time-string))
2747 ("permanent" nil)
2748 ("immediate" now)))
2749 header)
2750 (list
2751 (apply
2752 'nconc
2753 (list
2754 (if (eq type 'lower)
2755 "Lower score"
2756 "Increase score"))
2757 (let (outh)
2758 (while headers
2759 (setq header (car headers))
2760 (setq outh
2761 (cons
2762 (apply
2763 'nconc
2764 (list (car header))
2765 (let ((ts (cdr (assoc (nth 2 header) types)))
2766 outt)
2767 (while ts
2768 (setq outt
2769 (cons
2770 (apply
2771 'nconc
2772 (list (caar ts))
2773 (let ((ps perms)
2774 outp)
2775 (while ps
2776 (setq outp
2777 (cons
2778 (vector
2779 (caar ps)
2780 (list
2781 'gnus-summary-score-entry
2782 (nth 1 header)
2783 (if (or (string= (nth 1 header)
2784 "head")
2785 (string= (nth 1 header)
2786 "body"))
2787 ""
2788 (list 'gnus-summary-header
2789 (nth 1 header)))
2790 (list 'quote (nth 1 (car ts)))
16409b0b
GM
2791 (list 'gnus-score-delta-default
2792 nil)
eec82323
LMI
2793 (nth 1 (car ps))
2794 t)
2795 t)
2796 outp))
2797 (setq ps (cdr ps)))
2798 (list (nreverse outp))))
2799 outt))
2800 (setq ts (cdr ts)))
2801 (list (nreverse outt))))
2802 outh))
2803 (setq headers (cdr headers)))
2804 (list (nreverse outh))))))))
2805
2806\f
2807
2808(defun gnus-summary-mode (&optional group)
2809 "Major mode for reading articles.
2810
2811All normal editing commands are switched off.
2812\\<gnus-summary-mode-map>
2813Each line in this buffer represents one article. To read an
2814article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2815and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2816respectively.
2817
2818You can also post articles and send mail from this buffer. To
23f87bed 2819follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
eec82323
LMI
2820of an article, type `\\[gnus-summary-reply]'.
2821
2822There are approx. one gazillion commands you can execute in this
2823buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2824
2825The following commands are available:
2826
2827\\{gnus-summary-mode-map}"
2828 (interactive)
eec82323 2829 (kill-all-local-variables)
60bd5589
DL
2830 (when (gnus-visual-p 'summary-menu 'menu)
2831 (gnus-summary-make-menu-bar)
2832 (gnus-summary-make-tool-bar))
eec82323 2833 (gnus-summary-make-local-variables)
23f87bed
MB
2834 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2835 (gnus-summary-make-local-variables))
eec82323
LMI
2836 (gnus-make-thread-indent-array)
2837 (gnus-simplify-mode-line)
2838 (setq major-mode 'gnus-summary-mode)
2839 (setq mode-name "Summary")
2840 (make-local-variable 'minor-mode-alist)
2841 (use-local-map gnus-summary-mode-map)
16409b0b 2842 (buffer-disable-undo)
eec82323
LMI
2843 (setq buffer-read-only t) ;Disable modification
2844 (setq truncate-lines t)
2845 (setq selective-display t)
2846 (setq selective-display-ellipses t) ;Display `...'
2847 (gnus-summary-set-display-table)
2848 (gnus-set-default-directory)
2849 (setq gnus-newsgroup-name group)
2850 (make-local-variable 'gnus-summary-line-format)
2851 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
2852 (make-local-variable 'gnus-summary-dummy-line-format)
2853 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323 2854 (make-local-variable 'gnus-summary-mark-positions)
23f87bed 2855 (gnus-make-local-hook 'pre-command-hook)
6748645f 2856 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
cfcd5c91 2857 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
23f87bed 2858 (turn-on-gnus-mailing-list-mode)
87545352 2859 (mm-enable-multibyte)
eec82323
LMI
2860 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2861 (gnus-update-summary-mark-positions))
2862
2863(defun gnus-summary-make-local-variables ()
2864 "Make all the local summary buffer variables."
16409b0b
GM
2865 (let (global)
2866 (dolist (local gnus-summary-local-variables)
eec82323
LMI
2867 (if (consp local)
2868 (progn
2869 (if (eq (cdr local) 'global)
2870 ;; Copy the global value of the variable.
2871 (setq global (symbol-value (car local)))
2872 ;; Use the value from the list.
2873 (setq global (eval (cdr local))))
16409b0b 2874 (set (make-local-variable (car local)) global))
eec82323 2875 ;; Simple nil-valued local variable.
16409b0b 2876 (set (make-local-variable local) nil)))))
eec82323
LMI
2877
2878(defun gnus-summary-clear-local-variables ()
2879 (let ((locals gnus-summary-local-variables))
2880 (while locals
2881 (if (consp (car locals))
2882 (and (vectorp (caar locals))
2883 (set (caar locals) nil))
2884 (and (vectorp (car locals))
2885 (set (car locals) nil)))
2886 (setq locals (cdr locals)))))
2887
2888;; Summary data functions.
2889
2890(defmacro gnus-data-number (data)
2891 `(car ,data))
2892
2893(defmacro gnus-data-set-number (data number)
2894 `(setcar ,data ,number))
2895
2896(defmacro gnus-data-mark (data)
2897 `(nth 1 ,data))
2898
2899(defmacro gnus-data-set-mark (data mark)
2900 `(setcar (nthcdr 1 ,data) ,mark))
2901
2902(defmacro gnus-data-pos (data)
2903 `(nth 2 ,data))
2904
2905(defmacro gnus-data-set-pos (data pos)
2906 `(setcar (nthcdr 2 ,data) ,pos))
2907
2908(defmacro gnus-data-header (data)
2909 `(nth 3 ,data))
2910
2911(defmacro gnus-data-set-header (data header)
2912 `(setf (nth 3 ,data) ,header))
2913
2914(defmacro gnus-data-level (data)
2915 `(nth 4 ,data))
2916
2917(defmacro gnus-data-unread-p (data)
2918 `(= (nth 1 ,data) gnus-unread-mark))
2919
2920(defmacro gnus-data-read-p (data)
2921 `(/= (nth 1 ,data) gnus-unread-mark))
2922
2923(defmacro gnus-data-pseudo-p (data)
2924 `(consp (nth 3 ,data)))
2925
2926(defmacro gnus-data-find (number)
2927 `(assq ,number gnus-newsgroup-data))
2928
2929(defmacro gnus-data-find-list (number &optional data)
2930 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2931 (memq (assq ,number bdata)
2932 bdata)))
2933
2934(defmacro gnus-data-make (number mark pos header level)
2935 `(list ,number ,mark ,pos ,header ,level))
2936
2937(defun gnus-data-enter (after-article number mark pos header level offset)
2938 (let ((data (gnus-data-find-list after-article)))
2939 (unless data
2940 (error "No such article: %d" after-article))
2941 (setcdr data (cons (gnus-data-make number mark pos header level)
2942 (cdr data)))
2943 (setq gnus-newsgroup-data-reverse nil)
2944 (gnus-data-update-list (cddr data) offset)))
2945
2946(defun gnus-data-enter-list (after-article list &optional offset)
2947 (when list
2948 (let ((data (and after-article (gnus-data-find-list after-article)))
2949 (ilist list))
6748645f
LMI
2950 (if (not (or data
2951 after-article))
2952 (let ((odata gnus-newsgroup-data))
2953 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 2954 (when offset
6748645f 2955 (gnus-data-update-list odata offset)))
23f87bed 2956 ;; Find the last element in the list to be spliced into the main
6748645f
LMI
2957 ;; list.
2958 (while (cdr list)
2959 (setq list (cdr list)))
2960 (if (not data)
2961 (progn
2962 (setcdr list gnus-newsgroup-data)
2963 (setq gnus-newsgroup-data ilist)
2964 (when offset
2965 (gnus-data-update-list (cdr list) offset)))
2966 (setcdr list (cdr data))
2967 (setcdr data ilist)
2968 (when offset
2969 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
2970 (setq gnus-newsgroup-data-reverse nil))))
2971
2972(defun gnus-data-remove (article &optional offset)
2973 (let ((data gnus-newsgroup-data))
2974 (if (= (gnus-data-number (car data)) article)
2975 (progn
2976 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2977 gnus-newsgroup-data-reverse nil)
2978 (when offset
2979 (gnus-data-update-list gnus-newsgroup-data offset)))
2980 (while (cdr data)
2981 (when (= (gnus-data-number (cadr data)) article)
2982 (setcdr data (cddr data))
2983 (when offset
2984 (gnus-data-update-list (cdr data) offset))
2985 (setq data nil
2986 gnus-newsgroup-data-reverse nil))
2987 (setq data (cdr data))))))
2988
2989(defmacro gnus-data-list (backward)
2990 `(if ,backward
2991 (or gnus-newsgroup-data-reverse
2992 (setq gnus-newsgroup-data-reverse
2993 (reverse gnus-newsgroup-data)))
2994 gnus-newsgroup-data))
2995
2996(defun gnus-data-update-list (data offset)
2997 "Add OFFSET to the POS of all data entries in DATA."
6748645f 2998 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
2999 (while data
3000 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3001 (setq data (cdr data))))
3002
eec82323
LMI
3003(defun gnus-summary-article-pseudo-p (article)
3004 "Say whether this article is a pseudo article or not."
3005 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3006
3007(defmacro gnus-summary-article-sparse-p (article)
3008 "Say whether this article is a sparse article or not."
a8151ef7 3009 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
3010
3011(defmacro gnus-summary-article-ancient-p (article)
3012 "Say whether this article is a sparse article or not."
3013 `(memq ,article gnus-newsgroup-ancient))
3014
3015(defun gnus-article-parent-p (number)
3016 "Say whether this article is a parent or not."
3017 (let ((data (gnus-data-find-list number)))
23f87bed 3018 (and (cdr data) ; There has to be an article after...
eec82323
LMI
3019 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3020 (gnus-data-level (nth 1 data))))))
3021
3022(defun gnus-article-children (number)
3023 "Return a list of all children to NUMBER."
3024 (let* ((data (gnus-data-find-list number))
3025 (level (gnus-data-level (car data)))
3026 children)
3027 (setq data (cdr data))
3028 (while (and data
3029 (= (gnus-data-level (car data)) (1+ level)))
3030 (push (gnus-data-number (car data)) children)
3031 (setq data (cdr data)))
3032 children))
3033
3034(defmacro gnus-summary-skip-intangible ()
3035 "If the current article is intangible, then jump to a different article."
3036 '(let ((to (get-text-property (point) 'gnus-intangible)))
3037 (and to (gnus-summary-goto-subject to))))
3038
3039(defmacro gnus-summary-article-intangible-p ()
3040 "Say whether this article is intangible or not."
3041 '(get-text-property (point) 'gnus-intangible))
3042
3043(defun gnus-article-read-p (article)
3044 "Say whether ARTICLE is read or not."
3045 (not (or (memq article gnus-newsgroup-marked)
23f87bed 3046 (memq article gnus-newsgroup-spam-marked)
eec82323
LMI
3047 (memq article gnus-newsgroup-unreads)
3048 (memq article gnus-newsgroup-unselected)
3049 (memq article gnus-newsgroup-dormant))))
3050
3051;; Some summary mode macros.
3052
3053(defmacro gnus-summary-article-number ()
3054 "The article number of the article on the current line.
8f688cb0 3055If there isn't an article number here, then we return the current
eec82323
LMI
3056article number."
3057 '(progn
3058 (gnus-summary-skip-intangible)
3059 (or (get-text-property (point) 'gnus-number)
3060 (gnus-summary-last-subject))))
3061
3062(defmacro gnus-summary-article-header (&optional number)
6748645f 3063 "Return the header of article NUMBER."
eec82323
LMI
3064 `(gnus-data-header (gnus-data-find
3065 ,(or number '(gnus-summary-article-number)))))
3066
3067(defmacro gnus-summary-thread-level (&optional number)
6748645f 3068 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
3069 `(if (and (eq gnus-summary-make-false-root 'dummy)
3070 (get-text-property (point) 'gnus-intangible))
3071 0
3072 (gnus-data-level (gnus-data-find
3073 ,(or number '(gnus-summary-article-number))))))
3074
3075(defmacro gnus-summary-article-mark (&optional number)
6748645f 3076 "Return the mark of article NUMBER."
eec82323
LMI
3077 `(gnus-data-mark (gnus-data-find
3078 ,(or number '(gnus-summary-article-number)))))
3079
3080(defmacro gnus-summary-article-pos (&optional number)
6748645f 3081 "Return the position of the line of article NUMBER."
eec82323
LMI
3082 `(gnus-data-pos (gnus-data-find
3083 ,(or number '(gnus-summary-article-number)))))
3084
3085(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3086(defmacro gnus-summary-article-subject (&optional number)
3087 "Return current subject string or nil if nothing."
3088 `(let ((headers
3089 ,(if number
3090 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3091 '(gnus-data-header (assq (gnus-summary-article-number)
3092 gnus-newsgroup-data)))))
3093 (and headers
3094 (vectorp headers)
3095 (mail-header-subject headers))))
3096
3097(defmacro gnus-summary-article-score (&optional number)
3098 "Return current article score."
3099 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3100 gnus-newsgroup-scored))
3101 gnus-summary-default-score 0))
3102
3103(defun gnus-summary-article-children (&optional number)
6748645f 3104 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
3105 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3106 (level (gnus-data-level (car data)))
3107 l children)
3108 (while (and (setq data (cdr data))
3109 (> (setq l (gnus-data-level (car data))) level))
3110 (and (= (1+ level) l)
3111 (push (gnus-data-number (car data))
3112 children)))
3113 (nreverse children)))
3114
3115(defun gnus-summary-article-parent (&optional number)
6748645f 3116 "Return the article number of the parent of article NUMBER."
eec82323
LMI
3117 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3118 (gnus-data-list t)))
3119 (level (gnus-data-level (car data))))
3120 (if (zerop level)
3121 () ; This is a root.
3122 ;; We search until we find an article with a level less than
3123 ;; this one. That function has to be the parent.
3124 (while (and (setq data (cdr data))
3125 (not (< (gnus-data-level (car data)) level))))
3126 (and data (gnus-data-number (car data))))))
3127
3128(defun gnus-unread-mark-p (mark)
3129 "Say whether MARK is the unread mark."
3130 (= mark gnus-unread-mark))
3131
3132(defun gnus-read-mark-p (mark)
3133 "Say whether MARK is one of the marks that mark as read.
3134This is all marks except unread, ticked, dormant, and expirable."
3135 (not (or (= mark gnus-unread-mark)
3136 (= mark gnus-ticked-mark)
23f87bed 3137 (= mark gnus-spam-mark)
eec82323
LMI
3138 (= mark gnus-dormant-mark)
3139 (= mark gnus-expirable-mark))))
3140
3141(defmacro gnus-article-mark (number)
6748645f
LMI
3142 "Return the MARK of article NUMBER.
3143This macro should only be used when computing the mark the \"first\"
3144time; i.e., when generating the summary lines. After that,
3145`gnus-summary-article-mark' should be used to examine the
3146marks of articles."
eec82323 3147 `(cond
6748645f 3148 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
6748645f 3149 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
3150 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3151 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
23f87bed 3152 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
eec82323
LMI
3153 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3154 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3155 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3156 gnus-ancient-mark))))
3157
3158;; Saving hidden threads.
3159
eec82323
LMI
3160(defmacro gnus-save-hidden-threads (&rest forms)
3161 "Save hidden threads, eval FORMS, and restore the hidden threads."
3162 (let ((config (make-symbol "config")))
3163 `(let ((,config (gnus-hidden-threads-configuration)))
3164 (unwind-protect
3165 (save-excursion
3166 ,@forms)
3167 (gnus-restore-hidden-threads-configuration ,config)))))
23f87bed
MB
3168(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3169(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
eec82323 3170
107ecebb
AS
3171(defun gnus-data-compute-positions ()
3172 "Compute the positions of all articles."
3173 (setq gnus-newsgroup-data-reverse nil)
3174 (let ((data gnus-newsgroup-data))
3175 (save-excursion
3176 (gnus-save-hidden-threads
3177 (gnus-summary-show-all-threads)
3178 (goto-char (point-min))
3179 (while data
3180 (while (get-text-property (point) 'gnus-intangible)
3181 (forward-line 1))
3182 (gnus-data-set-pos (car data) (+ (point) 3))
3183 (setq data (cdr data))
3184 (forward-line 1))))))
3185
16409b0b
GM
3186(defun gnus-hidden-threads-configuration ()
3187 "Return the current hidden threads configuration."
3188 (save-excursion
3189 (let (config)
3190 (goto-char (point-min))
3191 (while (search-forward "\r" nil t)
3192 (push (1- (point)) config))
3193 config)))
3194
3195(defun gnus-restore-hidden-threads-configuration (config)
3196 "Restore hidden threads configuration from CONFIG."
3197 (save-excursion
3198 (let (point buffer-read-only)
3199 (while (setq point (pop config))
3200 (when (and (< point (point-max))
3201 (goto-char point)
3202 (eq (char-after) ?\n))
3203 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3204
eec82323
LMI
3205;; Various summary mode internalish functions.
3206
3207(defun gnus-mouse-pick-article (e)
3208 (interactive "e")
3209 (mouse-set-point e)
3210 (gnus-summary-next-page nil t))
3211
3212(defun gnus-summary-set-display-table ()
16409b0b
GM
3213 "Change the display table.
3214Odd characters have a tendency to mess
3215up nicely formatted displays - we make all possible glyphs
3216display only a single character."
eec82323
LMI
3217
3218 ;; We start from the standard display table, if any.
3219 (let ((table (or (copy-sequence standard-display-table)
3220 (make-display-table)))
3221 (i 32))
3222 ;; Nix out all the control chars...
3223 (while (>= (setq i (1- i)) 0)
3224 (aset table i [??]))
23f87bed 3225 ;; ... but not newline and cr, of course. (cr is necessary for the
eec82323
LMI
3226 ;; selective display).
3227 (aset table ?\n nil)
3228 (aset table ?\r nil)
6748645f
LMI
3229 ;; We keep TAB as well.
3230 (aset table ?\t nil)
719120ef 3231 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
fe62aacc 3232 ;; Emacs 23 (unicode), that are not set already.
719120ef
MB
3233 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3234 160
3235 256)))
eec82323
LMI
3236 (while (>= (setq i (1- i)) 127)
3237 ;; Only modify if the entry is nil.
3238 (unless (aref table i)
3239 (aset table i [??]))))
3240 (setq buffer-display-table table)))
3241
23f87bed
MB
3242(defun gnus-summary-set-article-display-arrow (pos)
3243 "Update the overlay arrow to point to line at position POS."
3244 (when (and gnus-summary-display-arrow
3245 (boundp 'overlay-arrow-position)
3246 (boundp 'overlay-arrow-string))
3247 (save-excursion
3248 (goto-char pos)
3249 (beginning-of-line)
3250 (unless overlay-arrow-position
3251 (setq overlay-arrow-position (make-marker)))
3252 (setq overlay-arrow-string "=>"
3253 overlay-arrow-position (set-marker overlay-arrow-position
3254 (point)
3255 (current-buffer))))))
3256
eec82323
LMI
3257(defun gnus-summary-setup-buffer (group)
3258 "Initialize summary buffer."
23f87bed
MB
3259 (let ((buffer (gnus-summary-buffer-name group))
3260 (dead-name (concat "*Dead Summary "
3261 (gnus-group-decoded-name group) "*")))
3262 ;; If a dead summary buffer exists, we kill it.
3263 (when (gnus-buffer-live-p dead-name)
3264 (gnus-kill-buffer dead-name))
eec82323
LMI
3265 (if (get-buffer buffer)
3266 (progn
3267 (set-buffer buffer)
3268 (setq gnus-summary-buffer (current-buffer))
3269 (not gnus-newsgroup-prepared))
3270 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 3271 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323
LMI
3272 (gnus-summary-mode group)
3273 (when gnus-carpal
3274 (gnus-carpal-setup-buffer 'summary))
3275 (unless gnus-single-article-buffer
3276 (make-local-variable 'gnus-article-buffer)
3277 (make-local-variable 'gnus-article-current)
3278 (make-local-variable 'gnus-original-article-buffer))
3279 (setq gnus-newsgroup-name group)
23f87bed
MB
3280 ;; Set any local variables in the group parameters.
3281 (gnus-summary-set-local-parameters gnus-newsgroup-name)
eec82323
LMI
3282 t)))
3283
3284(defun gnus-set-global-variables ()
16409b0b
GM
3285 "Set the global equivalents of the buffer-local variables.
3286They are set to the latest values they had. These reflect the summary
3287buffer that was in action when the last article was fetched."
eec82323
LMI
3288 (when (eq major-mode 'gnus-summary-mode)
3289 (setq gnus-summary-buffer (current-buffer))
3290 (let ((name gnus-newsgroup-name)
3291 (marked gnus-newsgroup-marked)
23f87bed 3292 (spam gnus-newsgroup-spam-marked)
eec82323
LMI
3293 (unread gnus-newsgroup-unreads)
3294 (headers gnus-current-headers)
3295 (data gnus-newsgroup-data)
3296 (summary gnus-summary-buffer)
3297 (article-buffer gnus-article-buffer)
3298 (original gnus-original-article-buffer)
3299 (gac gnus-article-current)
3300 (reffed gnus-reffed-article-number)
16409b0b 3301 (score-file gnus-current-score-file)
23f87bed
MB
3302 (default-charset gnus-newsgroup-charset)
3303 vlist)
3304 (let ((locals gnus-newsgroup-variables))
3305 (while locals
3306 (if (consp (car locals))
3307 (push (eval (caar locals)) vlist)
3308 (push (eval (car locals)) vlist))
3309 (setq locals (cdr locals)))
3310 (setq vlist (nreverse vlist)))
eec82323
LMI
3311 (save-excursion
3312 (set-buffer gnus-group-buffer)
6748645f
LMI
3313 (setq gnus-newsgroup-name name
3314 gnus-newsgroup-marked marked
23f87bed 3315 gnus-newsgroup-spam-marked spam
6748645f
LMI
3316 gnus-newsgroup-unreads unread
3317 gnus-current-headers headers
3318 gnus-newsgroup-data data
3319 gnus-article-current gac
3320 gnus-summary-buffer summary
3321 gnus-article-buffer article-buffer
3322 gnus-original-article-buffer original
3323 gnus-reffed-article-number reffed
16409b0b
GM
3324 gnus-current-score-file score-file
3325 gnus-newsgroup-charset default-charset)
23f87bed
MB
3326 (let ((locals gnus-newsgroup-variables))
3327 (while locals
3328 (if (consp (car locals))
3329 (set (caar locals) (pop vlist))
3330 (set (car locals) (pop vlist)))
3331 (setq locals (cdr locals))))
eec82323
LMI
3332 ;; The article buffer also has local variables.
3333 (when (gnus-buffer-live-p gnus-article-buffer)
3334 (set-buffer gnus-article-buffer)
3335 (setq gnus-summary-buffer summary))))))
3336
3337(defun gnus-summary-article-unread-p (article)
3338 "Say whether ARTICLE is unread or not."
3339 (memq article gnus-newsgroup-unreads))
3340
3341(defun gnus-summary-first-article-p (&optional article)
3342 "Return whether ARTICLE is the first article in the buffer."
3343 (if (not (setq article (or article (gnus-summary-article-number))))
3344 nil
3345 (eq article (caar gnus-newsgroup-data))))
3346
3347(defun gnus-summary-last-article-p (&optional article)
3348 "Return whether ARTICLE is the last article in the buffer."
3349 (if (not (setq article (or article (gnus-summary-article-number))))
16409b0b
GM
3350 ;; All non-existent numbers are the last article. :-)
3351 t
eec82323
LMI
3352 (not (cdr (gnus-data-find-list article)))))
3353
4921bbdd
CY
3354(defun gnus-make-thread-indent-array (&optional n)
3355 (when (or n
3356 (progn (setq n 200) nil)
3357 (null gnus-thread-indent-array)
3358 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3359 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3360 gnus-thread-indent-array-level gnus-thread-indent-level)
3361 (while (>= n 0)
3362 (aset gnus-thread-indent-array n
6a30c01d 3363 (make-string (* n gnus-thread-indent-level) ? ))
4921bbdd 3364 (setq n (1- n)))))
eec82323
LMI
3365
3366(defun gnus-update-summary-mark-positions ()
3367 "Compute where the summary marks are to go."
3368 (save-excursion
6748645f 3369 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3370 (set-buffer gnus-summary-buffer))
5153a47a
MB
3371 (let ((spec gnus-summary-line-format-spec)
3372 pos)
eec82323
LMI
3373 (save-excursion
3374 (gnus-set-work-buffer)
5153a47a
MB
3375 (let ((gnus-tmp-unread ?Z)
3376 (gnus-replied-mark ?Z)
3377 (gnus-score-below-mark ?Z)
3378 (gnus-score-over-mark ?Z)
3379 (gnus-undownloaded-mark ?Z)
3380 (gnus-summary-line-format-spec spec)
54506618 3381 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3382 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3383 case-fold-search ignores)
3384 ;; Here, all marks are bound to Z.
3385 (gnus-summary-insert-line header
3386 0 nil t gnus-tmp-unread t nil "" nil 1)
3387 (goto-char (point-min))
3388 ;; Memorize the positions of the same characters as dummy marks.
3389 (while (re-search-forward "[A-D]" nil t)
3390 (push (point) ignores))
54506618 3391 (erase-buffer)
5153a47a
MB
3392 ;; We use A-D as dummy marks in order to know column positions
3393 ;; where marks should be inserted.
3394 (setq gnus-tmp-unread ?A
3395 gnus-replied-mark ?B
3396 gnus-score-below-mark ?C
3397 gnus-score-over-mark ?C
3398 gnus-undownloaded-mark ?D)
3399 (gnus-summary-insert-line header
3400 0 nil t gnus-tmp-unread t nil "" nil 1)
3401 ;; Ignore characters which aren't dummy marks.
3402 (dolist (p ignores)
3403 (delete-region (goto-char (1- p)) p)
3404 (insert ?Z))
eec82323 3405 (goto-char (point-min))
7c3bb5a5 3406 (setq pos (list (cons 'unread
5153a47a 3407 (and (search-forward "A" nil t)
7c3bb5a5 3408 (- (point) (point-min) 1)))))
eec82323 3409 (goto-char (point-min))
5153a47a 3410 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3411 (- (point) (point-min) 1)))
eec82323
LMI
3412 pos)
3413 (goto-char (point-min))
5153a47a 3414 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3415 (- (point) (point-min) 1)))
6748645f
LMI
3416 pos)
3417 (goto-char (point-min))
5153a47a 3418 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3419 (- (point) (point-min) 1)))
eec82323
LMI
3420 pos)))
3421 (setq gnus-summary-mark-positions pos))))
3422
3423(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3424 "Insert a dummy root in the summary buffer."
3425 (beginning-of-line)
3426 (gnus-add-text-properties
3427 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3428 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3429
23f87bed
MB
3430(defun gnus-summary-extract-address-component (from)
3431 (or (car (funcall gnus-extract-address-components from))
3432 from))
3433
3434(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3435 (let ((mail-parse-charset gnus-newsgroup-charset)
3436 ; Is it really necessary to do this next part for each summary line?
3437 ; Luckily, doesn't seem to slow things down much.
16409b0b
GM
3438 (mail-parse-ignored-charsets
3439 (save-excursion (set-buffer gnus-summary-buffer)
3440 gnus-newsgroup-ignored-charsets)))
23f87bed
MB
3441 (or
3442 (and gnus-ignored-from-addresses
3443 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3444 (let ((extra-headers (mail-header-extra header))
3445 to
3446 newsgroups)
3447 (cond
3448 ((setq to (cdr (assq 'To extra-headers)))
3449 (concat "-> "
3450 (inline
3451 (gnus-summary-extract-address-component
343d6628 3452 (funcall gnus-decode-encoded-address-function to)))))
23f87bed
MB
3453 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3454 (concat "=> " newsgroups)))))
3455 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3456
eec82323
LMI
3457(defun gnus-summary-insert-line (gnus-tmp-header
3458 gnus-tmp-level gnus-tmp-current
23f87bed 3459 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3460 gnus-tmp-expirable gnus-tmp-subject-or-nil
3461 &optional gnus-tmp-dummy gnus-tmp-score
3462 gnus-tmp-process)
4921bbdd
CY
3463 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3464 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3465 gnus-tmp-level)))
eec82323
LMI
3466 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3467 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3468 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3469 (gnus-tmp-score-char
3470 (if (or (null gnus-summary-default-score)
3471 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3472 gnus-summary-zcore-fuzz))
23f87bed 3473 ? ;Whitespace
eec82323
LMI
3474 (if (< gnus-tmp-score gnus-summary-default-score)
3475 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3476 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3477 (gnus-tmp-replied
3478 (cond (gnus-tmp-process gnus-process-mark)
3479 ((memq gnus-tmp-current gnus-newsgroup-cached)
3480 gnus-cached-mark)
3481 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3482 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3483 gnus-forwarded-mark)
eec82323
LMI
3484 ((memq gnus-tmp-current gnus-newsgroup-saved)
3485 gnus-saved-mark)
23f87bed
MB
3486 ((memq gnus-tmp-number gnus-newsgroup-recent)
3487 gnus-recent-mark)
3488 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3489 gnus-unseen-mark)
3490 (t gnus-no-mark)))
3491 (gnus-tmp-downloaded
3492 (cond (undownloaded
3493 gnus-undownloaded-mark)
3494 (gnus-newsgroup-agentized
3495 gnus-downloaded-mark)
3496 (t
3497 gnus-no-mark)))
eec82323
LMI
3498 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3499 (gnus-tmp-name
3500 (cond
3501 ((string-match "<[^>]+> *$" gnus-tmp-from)
3502 (let ((beg (match-beginning 0)))
23f87bed
MB
3503 (or (and (string-match "^\".+\"" gnus-tmp-from)
3504 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3505 (substring gnus-tmp-from 0 beg))))
3506 ((string-match "(.+)" gnus-tmp-from)
3507 (substring gnus-tmp-from
3508 (1+ (match-beginning 0)) (1- (match-end 0))))
3509 (t gnus-tmp-from)))
3510 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3511 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3512 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3513 (buffer-read-only nil))
3514 (when (string= gnus-tmp-name "")
3515 (setq gnus-tmp-name gnus-tmp-from))
3516 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3517 (setq gnus-tmp-lines -1))
3518 (if (= gnus-tmp-lines -1)
3519 (setq gnus-tmp-lines "?")
3520 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3521 (gnus-put-text-property
eec82323
LMI
3522 (point)
3523 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 3524 'gnus-number gnus-tmp-number)
eec82323
LMI
3525 (when (gnus-visual-p 'summary-highlight 'highlight)
3526 (forward-line -1)
6748645f 3527 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3528 (forward-line 1))))
3529
3530(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3531 "Update summary line after change."
eec82323
LMI
3532 (when (and gnus-summary-default-score
3533 (not gnus-summary-inhibit-highlight))
3534 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3535 (article (gnus-summary-article-number))
3536 (score (gnus-summary-article-score article)))
3537 (unless dont-update
3538 (if (and gnus-summary-mark-below
3539 (< (gnus-summary-article-score)
3540 gnus-summary-mark-below))
3541 ;; This article has a low score, so we mark it as read.
3542 (when (memq article gnus-newsgroup-unreads)
3543 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3544 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3545 ;; This article was previously marked as read on account
3546 ;; of a low score, but now it has risen, so we mark it as
3547 ;; unread.
3548 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3549 (gnus-summary-update-mark
3550 (if (or (null gnus-summary-default-score)
3551 (<= (abs (- score gnus-summary-default-score))
3552 gnus-summary-zcore-fuzz))
23f87bed 3553 ? ;Whitespace
eec82323
LMI
3554 (if (< score gnus-summary-default-score)
3555 gnus-score-below-mark gnus-score-over-mark))
3556 'score))
3557 ;; Do visual highlighting.
3558 (when (gnus-visual-p 'summary-highlight 'highlight)
6748645f 3559 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3560
3561(defvar gnus-tmp-new-adopts nil)
3562
3563(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3564 "Return the number of articles in THREAD.
3565This may be 0 in some cases -- if none of the articles in
3566the thread are to be displayed."
3567 (let* ((number
23f87bed 3568 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3569 (cond
3570 ((not (listp thread))
3571 1)
3572 ((and (consp thread) (cdr thread))
3573 (apply
3574 '+ 1 (mapcar
3575 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3576 ((null thread)
3577 1)
3578 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3579 1)
3580 (t 0))))
3581 (when (and level (zerop level) gnus-tmp-new-adopts)
3582 (incf number
3583 (apply '+ (mapcar
3584 'gnus-summary-number-of-articles-in-thread
3585 gnus-tmp-new-adopts))))
3586 (if char
3587 (if (> number 1) gnus-not-empty-thread-mark
3588 gnus-empty-thread-mark)
3589 number)))
3590
23f87bed
MB
3591(defsubst gnus-summary-line-message-size (head)
3592 "Return pretty-printed version of message size.
3593This function is intended to be used in
3594`gnus-summary-line-format-alist'."
3595 (let ((c (or (mail-header-chars head) -1)))
3596 (cond ((< c 0) "n/a") ; chars not available
3597 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3598 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3599 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3600 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3601
3602
eec82323
LMI
3603(defun gnus-summary-set-local-parameters (group)
3604 "Go through the local params of GROUP and set all variable specs in that list."
3605 (let ((params (gnus-group-find-parameter group))
23f87bed 3606 (vars '(quit-config)) ; Ignore quit-config.
eec82323
LMI
3607 elem)
3608 (while params
3609 (setq elem (car params)
3610 params (cdr params))
3611 (and (consp elem) ; Has to be a cons.
3612 (consp (cdr elem)) ; The cdr has to be a list.
3613 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3614 (not (memq (car elem) vars))
eec82323 3615 (ignore-errors ; So we set it.
23f87bed 3616 (push (car elem) vars)
eec82323
LMI
3617 (make-local-variable (car elem))
3618 (set (car elem) (eval (nth 1 elem))))))))
3619
3620(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3621 kill-buffer no-display backward
3622 select-articles)
eec82323
LMI
3623 "Start reading news in newsgroup GROUP.
3624If SHOW-ALL is non-nil, already read articles are also listed.
3625If NO-ARTICLE is non-nil, no article is selected initially.
3626If NO-DISPLAY, don't generate a summary buffer."
3627 (let (result)
3628 (while (and group
3629 (null (setq result
3630 (let ((gnus-auto-select-next nil))
6748645f
LMI
3631 (or (gnus-summary-read-group-1
3632 group show-all no-article
3633 kill-buffer no-display
3634 select-articles)
3635 (setq show-all nil
16409b0b 3636 select-articles nil)))))
eec82323
LMI
3637 (eq gnus-auto-select-next 'quietly))
3638 (set-buffer gnus-group-buffer)
6748645f
LMI
3639 ;; The entry function called above goes to the next
3640 ;; group automatically, so we go two groups back
3641 ;; if we are searching for the previous group.
3642 (when backward
3643 (gnus-group-prev-unread-group 2))
eec82323
LMI
3644 (if (not (equal group (gnus-group-group-name)))
3645 (setq group (gnus-group-group-name))
3646 (setq group nil)))
3647 result))
3648
3649(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3650 kill-buffer no-display
3651 &optional select-articles)
eec82323 3652 ;; Killed foreign groups can't be entered.
23f87bed
MB
3653 ;; (when (and (not (gnus-group-native-p group))
3654 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3655 ;; (error "Dead non-native groups can't be entered"))
3656 (gnus-message 5 "Retrieving newsgroup: %s..."
3657 (gnus-group-decoded-name group))
eec82323
LMI
3658 (let* ((new-group (gnus-summary-setup-buffer group))
3659 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3660 (did-select (and new-group (gnus-select-newsgroup
3661 group show-all select-articles))))
eec82323
LMI
3662 (cond
3663 ;; This summary buffer exists already, so we just select it.
3664 ((not new-group)
3665 (gnus-set-global-variables)
3666 (when kill-buffer
3667 (gnus-kill-or-deaden-summary kill-buffer))
3668 (gnus-configure-windows 'summary 'force)
3669 (gnus-set-mode-line 'summary)
3670 (gnus-summary-position-point)
3671 (message "")
3672 t)
3673 ;; We couldn't select this group.
3674 ((null did-select)
3675 (when (and (eq major-mode 'gnus-summary-mode)
3676 (not (equal (current-buffer) kill-buffer)))
3677 (kill-buffer (current-buffer))
3678 (if (not quit-config)
3679 (progn
6748645f
LMI
3680 ;; Update the info -- marks might need to be removed,
3681 ;; for instance.
3682 (gnus-summary-update-info)
eec82323
LMI
3683 (set-buffer gnus-group-buffer)
3684 (gnus-group-jump-to-group group)
3685 (gnus-group-next-unread-group 1))
3686 (gnus-handle-ephemeral-exit quit-config)))
23f87bed
MB
3687 (let ((grpinfo (gnus-get-info group)))
3688 (if (null (gnus-info-read grpinfo))
3689 (gnus-message 3 "Group %s contains no messages"
3690 (gnus-group-decoded-name group))
3691 (gnus-message 3 "Can't select group")))
eec82323
LMI
3692 nil)
3693 ;; The user did a `C-g' while prompting for number of articles,
3694 ;; so we exit this group.
3695 ((eq did-select 'quit)
3696 (and (eq major-mode 'gnus-summary-mode)
3697 (not (equal (current-buffer) kill-buffer))
3698 (kill-buffer (current-buffer)))
3699 (when kill-buffer
3700 (gnus-kill-or-deaden-summary kill-buffer))
3701 (if (not quit-config)
3702 (progn
3703 (set-buffer gnus-group-buffer)
3704 (gnus-group-jump-to-group group)
3705 (gnus-group-next-unread-group 1)
3706 (gnus-configure-windows 'group 'force))
3707 (gnus-handle-ephemeral-exit quit-config))
3708 ;; Finally signal the quit.
3709 (signal 'quit nil))
3710 ;; The group was successfully selected.
3711 (t
3712 (gnus-set-global-variables)
3713 ;; Save the active value in effect when the group was entered.
3714 (setq gnus-newsgroup-active
3715 (gnus-copy-sequence
3716 (gnus-active gnus-newsgroup-name)))
3717 ;; You can change the summary buffer in some way with this hook.
6748645f 3718 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
3719 (when (memq 'summary (gnus-update-format-specifications
3720 nil 'summary 'summary-mode 'summary-dummy))
3721 ;; The format specification for the summary line was updated,
3722 ;; so we need to update the mark positions as well.
3723 (gnus-update-summary-mark-positions))
eec82323
LMI
3724 ;; Do score processing.
3725 (when gnus-use-scoring
3726 (gnus-possibly-score-headers))
3727 ;; Check whether to fill in the gaps in the threads.
3728 (when gnus-build-sparse-threads
3729 (gnus-build-sparse-threads))
3730 ;; Find the initial limit.
26c9afc3
MB
3731 (if show-all
3732 (let ((gnus-newsgroup-dormant nil))
eec82323 3733 (gnus-summary-initial-limit show-all))
26c9afc3 3734 (gnus-summary-initial-limit show-all))
eec82323
LMI
3735 ;; Generate the summary buffer.
3736 (unless no-display
3737 (gnus-summary-prepare))
3738 (when gnus-use-trees
3739 (gnus-tree-open group)
3740 (setq gnus-summary-highlight-line-function
3741 'gnus-tree-highlight-article))
3742 ;; If the summary buffer is empty, but there are some low-scored
3743 ;; articles or some excluded dormants, we include these in the
3744 ;; buffer.
3745 (when (and (zerop (buffer-size))
3746 (not no-display))
3747 (cond (gnus-newsgroup-dormant
3748 (gnus-summary-limit-include-dormant))
3749 ((and gnus-newsgroup-scored show-all)
3750 (gnus-summary-limit-include-expunged t))))
3751 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 3752 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
3753 (if (and (zerop (buffer-size))
3754 (not no-display))
3755 (progn
3756 ;; This newsgroup is empty.
3757 (gnus-summary-catchup-and-exit nil t)
3758 (gnus-message 6 "No unread news")
3759 (when kill-buffer
3760 (gnus-kill-or-deaden-summary kill-buffer))
3761 ;; Return nil from this function.
3762 nil)
3763 ;; Hide conversation thread subtrees. We cannot do this in
3764 ;; gnus-summary-prepare-hook since kill processing may not
3765 ;; work with hidden articles.
23f87bed 3766 (gnus-summary-maybe-hide-threads)
6748645f
LMI
3767 (when kill-buffer
3768 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 3769 (gnus-summary-auto-select-subject)
eec82323
LMI
3770 ;; Show first unread article if requested.
3771 (if (and (not no-article)
3772 (not no-display)
3773 gnus-newsgroup-unreads
3774 gnus-auto-select-first)
16409b0b
GM
3775 (progn
3776 (gnus-configure-windows 'summary)
23f87bed
MB
3777 (let ((art (gnus-summary-article-number)))
3778 (unless (and (not gnus-plugged)
3779 (or (memq art gnus-newsgroup-undownloaded)
3780 (memq art gnus-newsgroup-downloadable)))
3781 (gnus-summary-goto-article art))))
3782 ;; Don't select any articles.
eec82323 3783 (gnus-summary-position-point)
6748645f
LMI
3784 (gnus-configure-windows 'summary 'force)
3785 (gnus-set-mode-line 'summary))
23f87bed
MB
3786 (when (and gnus-auto-center-group
3787 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
3788 ;; Gotta use windows, because recenter does weird stuff if
3789 ;; the current buffer ain't the displayed window.
3790 (let ((owin (selected-window)))
3791 (select-window (get-buffer-window gnus-group-buffer t))
3792 (when (gnus-group-goto-group group)
3793 (recenter))
3794 (select-window owin)))
3795 ;; Mark this buffer as "prepared".
3796 (setq gnus-newsgroup-prepared t)
6748645f 3797 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
3798 (unless (gnus-ephemeral-group-p group)
3799 (gnus-group-update-group group))
eec82323
LMI
3800 t)))))
3801
23f87bed
MB
3802(defun gnus-summary-auto-select-subject ()
3803 "Select the subject line on initial group entry."
3804 (goto-char (point-min))
3805 (cond
3806 ((eq gnus-auto-select-subject 'best)
3807 (gnus-summary-best-unread-subject))
3808 ((eq gnus-auto-select-subject 'unread)
3809 (gnus-summary-first-unread-subject))
3810 ((eq gnus-auto-select-subject 'unseen)
3811 (gnus-summary-first-unseen-subject))
3812 ((eq gnus-auto-select-subject 'unseen-or-unread)
3813 (gnus-summary-first-unseen-or-unread-subject))
3814 ((eq gnus-auto-select-subject 'first)
3815 ;; Do nothing.
3816 )
3817 ((functionp gnus-auto-select-subject)
3818 (funcall gnus-auto-select-subject))))
3819
eec82323
LMI
3820(defun gnus-summary-prepare ()
3821 "Generate the summary buffer."
3822 (interactive)
3823 (let ((buffer-read-only nil))
3824 (erase-buffer)
3825 (setq gnus-newsgroup-data nil
3826 gnus-newsgroup-data-reverse nil)
6748645f 3827 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
3828 ;; Generate the buffer, either with threads or without.
3829 (when gnus-newsgroup-headers
3830 (gnus-summary-prepare-threads
3831 (if gnus-show-threads
3832 (gnus-sort-gathered-threads
3833 (funcall gnus-summary-thread-gathering-function
3834 (gnus-sort-threads
3835 (gnus-cut-threads (gnus-make-threads)))))
3836 ;; Unthreaded display.
3837 (gnus-sort-articles gnus-newsgroup-headers))))
3838 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3839 ;; Call hooks for modifying summary buffer.
3840 (goto-char (point-min))
6748645f 3841 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
3842
3843(defsubst gnus-general-simplify-subject (subject)
23f87bed 3844 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
3845 (setq subject
3846 (cond
3847 ;; Truncate the subject.
6748645f
LMI
3848 (gnus-simplify-subject-functions
3849 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
3850 ((numberp gnus-summary-gather-subject-limit)
3851 (setq subject (gnus-simplify-subject-re subject))
3852 (if (> (length subject) gnus-summary-gather-subject-limit)
3853 (substring subject 0 gnus-summary-gather-subject-limit)
3854 subject))
3855 ;; Fuzzily simplify it.
3856 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3857 (gnus-simplify-subject-fuzzy subject))
3858 ;; Just remove the leading "Re:".
3859 (t
3860 (gnus-simplify-subject-re subject))))
3861
3862 (if (and gnus-summary-gather-exclude-subject
3863 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 3864 nil ; This article shouldn't be gathered
eec82323
LMI
3865 subject))
3866
3867(defun gnus-summary-simplify-subject-query ()
3868 "Query where the respool algorithm would put this article."
3869 (interactive)
eec82323
LMI
3870 (gnus-summary-select-article)
3871 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3872
3873(defun gnus-gather-threads-by-subject (threads)
3874 "Gather threads by looking at Subject headers."
3875 (if (not gnus-summary-make-false-root)
3876 threads
3877 (let ((hashtb (gnus-make-hashtable 1024))
3878 (prev threads)
3879 (result threads)
3880 subject hthread whole-subject)
3881 (while threads
3882 (setq subject (gnus-general-simplify-subject
3883 (setq whole-subject (mail-header-subject
3884 (caar threads)))))
3885 (when subject
3886 (if (setq hthread (gnus-gethash subject hashtb))
3887 (progn
3888 ;; We enter a dummy root into the thread, if we
3889 ;; haven't done that already.
3890 (unless (stringp (caar hthread))
3891 (setcar hthread (list whole-subject (car hthread))))
3892 ;; We add this new gathered thread to this gathered
3893 ;; thread.
3894 (setcdr (car hthread)
3895 (nconc (cdar hthread) (list (car threads))))
3896 ;; Remove it from the list of threads.
3897 (setcdr prev (cdr threads))
3898 (setq threads prev))
3899 ;; Enter this thread into the hash table.
23f87bed
MB
3900 (gnus-sethash subject
3901 (if gnus-summary-make-false-root-always
3902 (progn
3903 ;; If you want a dummy root above all
3904 ;; threads...
3905 (setcar threads (list whole-subject
3906 (car threads)))
3907 threads)
3908 threads)
3909 hashtb)))
eec82323
LMI
3910 (setq prev threads)
3911 (setq threads (cdr threads)))
3912 result)))
3913
3914(defun gnus-gather-threads-by-references (threads)
3915 "Gather threads by looking at References headers."
3916 (let ((idhashtb (gnus-make-hashtable 1024))
3917 (thhashtb (gnus-make-hashtable 1024))
3918 (prev threads)
3919 (result threads)
3920 ids references id gthread gid entered ref)
3921 (while threads
3922 (when (setq references (mail-header-references (caar threads)))
3923 (setq id (mail-header-id (caar threads))
23f87bed 3924 ids (inline (gnus-split-references references))
eec82323
LMI
3925 entered nil)
3926 (while (setq ref (pop ids))
3927 (setq ids (delete ref ids))
3928 (if (not (setq gid (gnus-gethash ref idhashtb)))
3929 (progn
3930 (gnus-sethash ref id idhashtb)
3931 (gnus-sethash id threads thhashtb))
3932 (setq gthread (gnus-gethash gid thhashtb))
3933 (unless entered
3934 ;; We enter a dummy root into the thread, if we
3935 ;; haven't done that already.
3936 (unless (stringp (caar gthread))
3937 (setcar gthread (list (mail-header-subject (caar gthread))
3938 (car gthread))))
3939 ;; We add this new gathered thread to this gathered
3940 ;; thread.
3941 (setcdr (car gthread)
3942 (nconc (cdar gthread) (list (car threads)))))
3943 ;; Add it into the thread hash table.
3944 (gnus-sethash id gthread thhashtb)
3945 (setq entered t)
3946 ;; Remove it from the list of threads.
3947 (setcdr prev (cdr threads))
3948 (setq threads prev))))
3949 (setq prev threads)
3950 (setq threads (cdr threads)))
3951 result))
3952
3953(defun gnus-sort-gathered-threads (threads)
16409b0b 3954 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
3955 (let ((result threads))
3956 (while threads
3957 (when (stringp (caar threads))
3958 (setcdr (car threads)
16409b0b 3959 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
3960 (setq threads (cdr threads)))
3961 result))
3962
3963(defun gnus-thread-loop-p (root thread)
3964 "Say whether ROOT is in THREAD."
3965 (let ((stack (list thread))
3966 (infloop 0)
3967 th)
3968 (while (setq thread (pop stack))
3969 (setq th (cdr thread))
3970 (while (and th
3971 (not (eq (caar th) root)))
3972 (pop th))
3973 (if th
3974 ;; We have found a loop.
3975 (let (ref-dep)
3976 (setcdr thread (delq (car th) (cdr thread)))
3977 (if (boundp (setq ref-dep (intern "none"
3978 gnus-newsgroup-dependencies)))
3979 (setcdr (symbol-value ref-dep)
3980 (nconc (cdr (symbol-value ref-dep))
3981 (list (car th))))
3982 (set ref-dep (list nil (car th))))
3983 (setq infloop 1
3984 stack nil))
3985 ;; Push all the subthreads onto the stack.
3986 (push (cdr thread) stack)))
3987 infloop))
3988
3989(defun gnus-make-threads ()
01ccbb85 3990 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
3991 (let (threads)
3992 (while (catch 'infloop
3993 (mapatoms
3994 (lambda (refs)
3995 ;; Deal with self-referencing References loops.
3996 (when (and (car (symbol-value refs))
3997 (not (zerop
3998 (apply
3999 '+
4000 (mapcar
4001 (lambda (thread)
4002 (gnus-thread-loop-p
4003 (car (symbol-value refs)) thread))
4004 (cdr (symbol-value refs)))))))
4005 (setq threads nil)
4006 (throw 'infloop t))
4007 (unless (car (symbol-value refs))
23f87bed
MB
4008 ;; These threads do not refer back to any other
4009 ;; articles, so they're roots.
eec82323
LMI
4010 (setq threads (append (cdr (symbol-value refs)) threads))))
4011 gnus-newsgroup-dependencies)))
4012 threads))
4013
6748645f 4014;; Build the thread tree.
16409b0b 4015(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4016 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4017
4018If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4019if it was already present.
4020
4021If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4022will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4023Message-IDs will be renamed to a unique Message-ID before being
4024entered.
6748645f
LMI
4025
4026Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4027 (let* ((id (mail-header-id header))
4028 (id-dep (and id (intern id dependencies)))
23f87bed 4029 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4030 ;; Enter this `header' in the `dependencies' table.
4031 (cond
4032 ((not id-dep)
4033 (setq header nil))
4034 ;; The first two cases do the normal part: enter a new `header'
4035 ;; in the `dependencies' table.
4036 ((not (boundp id-dep))
4037 (set id-dep (list header)))
4038 ((null (car (symbol-value id-dep)))
4039 (setcar (symbol-value id-dep) header))
4040
4041 ;; From here the `header' was already present in the
4042 ;; `dependencies' table.
4043 (force-new
4044 ;; Overrides an existing entry;
4045 ;; just set the header part of the entry.
23f87bed
MB
4046 (setcar (symbol-value id-dep) header)
4047 (setq replaced t))
6748645f
LMI
4048
4049 ;; Renames the existing `header' to a unique Message-ID.
4050 ((not gnus-summary-ignore-duplicates)
4051 ;; An article with this Message-ID has already been seen.
4052 ;; We rename the Message-ID.
4053 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4054 (list header))
4055 (mail-header-set-id header id))
4056
4057 ;; The last case ignores an existing entry, except it adds any
4058 ;; additional Xrefs (in case the two articles came from different
4059 ;; servers.
4060 ;; Also sets `header' to `nil' meaning that the `dependencies'
4061 ;; table was *not* modified.
4062 (t
4063 (mail-header-set-xref
4064 (car (symbol-value id-dep))
4065 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4066 "")
4067 (or (mail-header-xref header) "")))
4068 (setq header nil)))
4069
23f87bed
MB
4070 (when (and header (not replaced))
4071 ;; First check that we are not creating a References loop.
4072 (setq parent-id (gnus-parent-id (mail-header-references header)))
4073 (setq ref parent-id)
6748645f
LMI
4074 (while (and ref
4075 (setq ref-dep (intern-soft ref dependencies))
4076 (boundp ref-dep)
4077 (setq ref-header (car (symbol-value ref-dep))))
4078 (if (string= id ref)
4079 ;; Yuk! This is a reference loop. Make the article be a
4080 ;; root article.
4081 (progn
4082 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4083 (setq ref nil)
4084 (setq parent-id nil))
6748645f 4085 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4086 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4087 (if (boundp ref-dep)
4088 (setcdr (symbol-value ref-dep)
4089 (nconc (cdr (symbol-value ref-dep))
4090 (list (symbol-value id-dep))))
4091 (set ref-dep (list nil (symbol-value id-dep)))))
4092 header))
4093
23f87bed
MB
4094(defun gnus-extract-message-id-from-in-reply-to (string)
4095 (if (string-match "<[^>]+>" string)
4096 (substring string (match-beginning 0) (match-end 0))
4097 nil))
4098
eec82323
LMI
4099(defun gnus-build-sparse-threads ()
4100 (let ((headers gnus-newsgroup-headers)
16409b0b 4101 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4102 (gnus-summary-ignore-duplicates t)
eec82323 4103 header references generation relations
6748645f 4104 subject child end new-child date)
eec82323
LMI
4105 ;; First we create an alist of generations/relations, where
4106 ;; generations is how much we trust the relation, and the relation
4107 ;; is parent/child.
4108 (gnus-message 7 "Making sparse threads...")
4109 (save-excursion
4110 (nnheader-set-temp-buffer " *gnus sparse threads*")
4111 (while (setq header (pop headers))
4112 (when (and (setq references (mail-header-references header))
4113 (not (string= references "")))
4114 (insert references)
4115 (setq child (mail-header-id header)
6748645f
LMI
4116 subject (mail-header-subject header)
4117 date (mail-header-date header)
4118 generation 0)
eec82323
LMI
4119 (while (search-backward ">" nil t)
4120 (setq end (1+ (point)))
4121 (when (search-backward "<" nil t)
6748645f 4122 (setq new-child (buffer-substring (point) end))
eec82323 4123 (push (list (incf generation)
6748645f
LMI
4124 child (setq child new-child)
4125 subject date)
eec82323 4126 relations)))
6748645f
LMI
4127 (when child
4128 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4129 (erase-buffer)))
4130 (kill-buffer (current-buffer)))
4131 ;; Sort over trustworthiness.
6748645f
LMI
4132 (mapcar
4133 (lambda (relation)
4134 (when (gnus-dependencies-add-header
4135 (make-full-mail-header
4136 gnus-reffed-article-number
4137 (nth 3 relation) "" (or (nth 4 relation) "")
4138 (nth 1 relation)
4139 (or (nth 2 relation) "") 0 0 "")
4140 gnus-newsgroup-dependencies nil)
4141 (push gnus-reffed-article-number gnus-newsgroup-limit)
4142 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4143 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4144 gnus-newsgroup-reads)
4145 (decf gnus-reffed-article-number)))
4146 (sort relations 'car-less-than-car))
eec82323
LMI
4147 (gnus-message 7 "Making sparse threads...done")))
4148
4149(defun gnus-build-old-threads ()
4150 ;; Look at all the articles that refer back to old articles, and
4151 ;; fetch the headers for the articles that aren't there. This will
4152 ;; build complete threads - if the roots haven't been expired by the
4153 ;; server, that is.
16409b0b
GM
4154 (let ((mail-parse-charset gnus-newsgroup-charset)
4155 id heads)
eec82323
LMI
4156 (mapatoms
4157 (lambda (refs)
4158 (when (not (car (symbol-value refs)))
4159 (setq heads (cdr (symbol-value refs)))
4160 (while heads
4161 (if (memq (mail-header-number (caar heads))
4162 gnus-newsgroup-dormant)
4163 (setq heads (cdr heads))
4164 (setq id (symbol-name refs))
4165 (while (and (setq id (gnus-build-get-header id))
6748645f 4166 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4167 (setq heads nil)))))
4168 gnus-newsgroup-dependencies)))
4169
23f87bed
MB
4170(defsubst gnus-remove-odd-characters (string)
4171 "Translate STRING into something that doesn't contain weird characters."
4172 (mm-subst-char-in-string
4173 ?\r ?\-
4174 (mm-subst-char-in-string
4175 ?\n ?\- string)))
4176
6748645f
LMI
4177;; This function has to be called with point after the article number
4178;; on the beginning of the line.
4179(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4180 (let ((eol (gnus-point-at-eol))
4181 (buffer (current-buffer))
23f87bed 4182 header references in-reply-to)
6748645f
LMI
4183
4184 ;; overview: [num subject from date id refs chars lines misc]
4185 (unwind-protect
23f87bed 4186 (let (x)
6748645f
LMI
4187 (narrow-to-region (point) eol)
4188 (unless (eobp)
4189 (forward-char))
4190
4191 (setq header
4192 (make-full-mail-header
4193 number ; number
23f87bed
MB
4194 (condition-case () ; subject
4195 (gnus-remove-odd-characters
4196 (funcall gnus-decode-encoded-word-function
4197 (setq x (nnheader-nov-field))))
4198 (error x))
4199 (condition-case () ; from
4200 (gnus-remove-odd-characters
343d6628 4201 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4202 (setq x (nnheader-nov-field))))
4203 (error x))
16409b0b
GM
4204 (nnheader-nov-field) ; date
4205 (nnheader-nov-read-message-id) ; id
23f87bed 4206 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4207 (nnheader-nov-read-integer) ; chars
4208 (nnheader-nov-read-integer) ; lines
4209 (unless (eobp)
8b93df01
DL
4210 (if (looking-at "Xref: ")
4211 (goto-char (match-end 0)))
4212 (nnheader-nov-field)) ; Xref
16409b0b 4213 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4214
4215 (widen))
4216
23f87bed
MB
4217 (when (and (string= references "")
4218 (setq in-reply-to (mail-header-extra header))
4219 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4220 (mail-header-set-references
4221 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4222
6748645f
LMI
4223 (when gnus-alter-header-function
4224 (funcall gnus-alter-header-function header))
4225 (gnus-dependencies-add-header header dependencies force-new)))
4226
eec82323 4227(defun gnus-build-get-header (id)
16409b0b
GM
4228 "Look through the buffer of NOV lines and find the header to ID.
4229Enter this line into the dependencies hash table, and return
4230the id of the parent article (if any)."
eec82323
LMI
4231 (let ((deps gnus-newsgroup-dependencies)
4232 found header)
4233 (prog1
4234 (save-excursion
4235 (set-buffer nntp-server-buffer)
4236 (let ((case-fold-search nil))
4237 (goto-char (point-min))
4238 (while (and (not found)
4239 (search-forward id nil t))
4240 (beginning-of-line)
4241 (setq found (looking-at
4242 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4243 (regexp-quote id))))
4244 (or found (beginning-of-line 2)))
4245 (when found
4246 (beginning-of-line)
4247 (and
4248 (setq header (gnus-nov-parse-line
4249 (read (current-buffer)) deps))
4250 (gnus-parent-id (mail-header-references header))))))
4251 (when header
4252 (let ((number (mail-header-number header)))
4253 (push number gnus-newsgroup-limit)
4254 (push header gnus-newsgroup-headers)
4255 (if (memq number gnus-newsgroup-unselected)
4256 (progn
23f87bed
MB
4257 (setq gnus-newsgroup-unreads
4258 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4259 number))
eec82323
LMI
4260 (setq gnus-newsgroup-unselected
4261 (delq number gnus-newsgroup-unselected)))
4262 (push number gnus-newsgroup-ancient)))))))
4263
6748645f
LMI
4264(defun gnus-build-all-threads ()
4265 "Read all the headers."
4266 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4267 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4268 (dependencies gnus-newsgroup-dependencies)
4269 header article)
4270 (save-excursion
4271 (set-buffer nntp-server-buffer)
4272 (let ((case-fold-search nil))
4273 (goto-char (point-min))
4274 (while (not (eobp))
4275 (ignore-errors
4276 (setq article (read (current-buffer))
16409b0b 4277 header (gnus-nov-parse-line article dependencies)))
6748645f
LMI
4278 (when header
4279 (save-excursion
4280 (set-buffer gnus-summary-buffer)
4281 (push header gnus-newsgroup-headers)
4282 (if (memq (setq article (mail-header-number header))
4283 gnus-newsgroup-unselected)
4284 (progn
23f87bed
MB
4285 (setq gnus-newsgroup-unreads
4286 (gnus-add-to-sorted-list
4287 gnus-newsgroup-unreads article))
6748645f
LMI
4288 (setq gnus-newsgroup-unselected
4289 (delq article gnus-newsgroup-unselected)))
4290 (push article gnus-newsgroup-ancient)))
4291 (forward-line 1)))))))
4292
eec82323 4293(defun gnus-summary-update-article-line (article header)
23f87bed 4294 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4295 (let* ((id (mail-header-id header))
4296 (thread (gnus-id-to-thread id)))
4297 (unless thread
4298 (error "Article in no thread"))
4299 ;; Update the thread.
4300 (setcar thread header)
4301 (gnus-summary-goto-subject article)
4302 (let* ((datal (gnus-data-find-list article))
4303 (data (car datal))
eec82323
LMI
4304 (buffer-read-only nil)
4305 (level (gnus-summary-thread-level)))
4306 (gnus-delete-line)
23f87bed
MB
4307 (let ((inserted (- (point)
4308 (progn
4309 (gnus-summary-insert-line
4310 header level nil
4311 (memq article gnus-newsgroup-undownloaded)
4312 (gnus-article-mark article)
4313 (memq article gnus-newsgroup-replied)
4314 (memq article gnus-newsgroup-expirable)
4315 ;; Only insert the Subject string when it's different
4316 ;; from the previous Subject string.
4317 (if (and
4318 gnus-show-threads
4319 (gnus-subject-equal
4320 (condition-case ()
4321 (mail-header-subject
4322 (gnus-data-header
4323 (cadr
4324 (gnus-data-find-list
4325 article
4326 (gnus-data-list t)))))
4327 ;; Error on the side of excessive subjects.
4328 (error ""))
4329 (mail-header-subject header)))
4330 ""
4331 (mail-header-subject header))
4332 nil (cdr (assq article gnus-newsgroup-scored))
4333 (memq article gnus-newsgroup-processable))
4334 (point)))))
4335 (when (cdr datal)
4336 (gnus-data-update-list
4337 (cdr datal)
4338 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4339
4340(defun gnus-summary-update-article (article &optional iheader)
4341 "Update ARTICLE in the summary buffer."
4342 (set-buffer gnus-summary-buffer)
6748645f 4343 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4344 (id (mail-header-id header))
4345 (data (gnus-data-find article))
4346 (thread (gnus-id-to-thread id))
4347 (references (mail-header-references header))
4348 (parent
4349 (gnus-id-to-thread
4350 (or (gnus-parent-id
4351 (when (and references
4352 (not (equal "" references)))
4353 references))
4354 "none")))
4355 (buffer-read-only nil)
6748645f 4356 (old (car thread)))
eec82323 4357 (when thread
eec82323 4358 (unless iheader
6748645f
LMI
4359 (setcar thread nil)
4360 (when parent
4361 (delq thread parent)))
4362 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4363 ;; Set the (possibly) new article number in the data structure.
4364 (gnus-data-set-number data (gnus-id-to-article id))
4365 (setcar thread old)
4366 nil))))
4367
6748645f
LMI
4368(defun gnus-rebuild-thread (id &optional line)
4369 "Rebuild the thread containing ID.
4370If LINE, insert the rebuilt thread starting on line LINE."
eec82323
LMI
4371 (let ((buffer-read-only nil)
4372 old-pos current thread data)
4373 (if (not gnus-show-threads)
4374 (setq thread (list (car (gnus-id-to-thread id))))
4375 ;; Get the thread this article is part of.
4376 (setq thread (gnus-remove-thread id)))
4377 (setq old-pos (gnus-point-at-bol))
4378 (setq current (save-excursion
94384150 4379 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4380 (gnus-summary-article-number))))
4381 ;; If this is a gathered thread, we have to go some re-gathering.
4382 (when (stringp (car thread))
4383 (let ((subject (car thread))
4384 roots thr)
4385 (setq thread (cdr thread))
4386 (while thread
4387 (unless (memq (setq thr (gnus-id-to-thread
4388 (gnus-root-id
4389 (mail-header-id (caar thread)))))
4390 roots)
4391 (push thr roots))
4392 (setq thread (cdr thread)))
4393 ;; We now have all (unique) roots.
4394 (if (= (length roots) 1)
4395 ;; All the loose roots are now one solid root.
4396 (setq thread (car roots))
4397 (setq thread (cons subject (gnus-sort-threads roots))))))
4398 (let (threads)
4399 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4400 (when line
4401 (goto-char (point-min))
4402 (forward-line (1- line)))
eec82323
LMI
4403 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4404 (if gnus-show-threads
4405 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4406 (gnus-summary-prepare-unthreaded thread))
4407 (setq data (nreverse gnus-newsgroup-data))
4408 (setq threads gnus-newsgroup-threads))
4409 ;; We splice the new data into the data structure.
6748645f
LMI
4410 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4411 ;;!!! then we want to insert at the beginning of the buffer.
4412 ;;!!! That happens to be true with Gnus now, but that may
4413 ;;!!! change in the future. Perhaps.
4414 (gnus-data-enter-list
4415 (if line nil current) data (- (point) old-pos))
4416 (setq gnus-newsgroup-threads
4417 (nconc threads gnus-newsgroup-threads))
4418 (gnus-data-compute-positions))))
eec82323
LMI
4419
4420(defun gnus-number-to-header (number)
4421 "Return the header for article NUMBER."
4422 (let ((headers gnus-newsgroup-headers))
4423 (while (and headers
4424 (not (= number (mail-header-number (car headers)))))
4425 (pop headers))
4426 (when headers
4427 (car headers))))
4428
6748645f 4429(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4430 "Return the headers of the GENERATIONeth parent of HEADERS."
4431 (unless generation
4432 (setq generation 1))
a8151ef7 4433 (let ((parent t)
6748645f 4434 (headers in-headers)
a8151ef7 4435 references)
6748645f
LMI
4436 (while (and parent
4437 (not (zerop generation))
4438 (setq references (mail-header-references headers)))
4439 (setq headers (if (and references
4440 (setq parent (gnus-parent-id references)))
4441 (car (gnus-id-to-thread parent))
4442 nil))
4443 (decf generation))
4444 (and (not (eq headers in-headers))
4445 headers)))
eec82323
LMI
4446
4447(defun gnus-id-to-thread (id)
4448 "Return the (sub-)thread where ID appears."
4449 (gnus-gethash id gnus-newsgroup-dependencies))
4450
4451(defun gnus-id-to-article (id)
4452 "Return the article number of ID."
4453 (let ((thread (gnus-id-to-thread id)))
4454 (when (and thread
4455 (car thread))
4456 (mail-header-number (car thread)))))
4457
4458(defun gnus-id-to-header (id)
4459 "Return the article headers of ID."
4460 (car (gnus-id-to-thread id)))
4461
4462(defun gnus-article-displayed-root-p (article)
4463 "Say whether ARTICLE is a root(ish) article."
4464 (let ((level (gnus-summary-thread-level article))
4465 (refs (mail-header-references (gnus-summary-article-header article)))
4466 particle)
4467 (cond
4468 ((null level) nil)
4469 ((zerop level) t)
4470 ((null refs) t)
4471 ((null (gnus-parent-id refs)) t)
4472 ((and (= 1 level)
4473 (null (setq particle (gnus-id-to-article
4474 (gnus-parent-id refs))))
4475 (null (gnus-summary-thread-level particle)))))))
4476
4477(defun gnus-root-id (id)
4478 "Return the id of the root of the thread where ID appears."
4479 (let (last-id prev)
6748645f 4480 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4481 (setq last-id id
4482 id (gnus-parent-id (mail-header-references prev))))
4483 last-id))
4484
6748645f
LMI
4485(defun gnus-articles-in-thread (thread)
4486 "Return the list of articles in THREAD."
4487 (cons (mail-header-number (car thread))
4488 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4489
eec82323
LMI
4490(defun gnus-remove-thread (id &optional dont-remove)
4491 "Remove the thread that has ID in it."
6748645f 4492 (let (headers thread last-id)
eec82323 4493 ;; First go up in this thread until we find the root.
6748645f
LMI
4494 (setq last-id (gnus-root-id id)
4495 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4496 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4497 ;; been gathered into some loose thread, so we have to search
4498 ;; through the threads to find the thread we wanted.
4499 (let ((threads gnus-newsgroup-threads)
4500 sub)
4501 (while threads
4502 (setq sub (car threads))
4503 (if (stringp (car sub))
4504 ;; This is a gathered thread, so we look at the roots
4505 ;; below it to find whether this article is in this
4506 ;; gathered root.
4507 (progn
4508 (setq sub (cdr sub))
4509 (while sub
4510 (when (member (caar sub) headers)
4511 (setq thread (car threads)
4512 threads nil
4513 sub nil))
4514 (setq sub (cdr sub))))
4515 ;; It's an ordinary thread, so we check it.
4516 (when (eq (car sub) (car headers))
4517 (setq thread sub
4518 threads nil)))
4519 (setq threads (cdr threads)))
4520 ;; If this article is in no thread, then it's a root.
4521 (if thread
4522 (unless dont-remove
4523 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4524 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4525 (when thread
4526 (prog1
4527 thread ; We return this thread.
4528 (unless dont-remove
4529 (if (stringp (car thread))
4530 (progn
4531 ;; If we use dummy roots, then we have to remove the
4532 ;; dummy root as well.
4533 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4534 ;; We go to the dummy root by going to
4535 ;; the first sub-"thread", and then one line up.
4536 (gnus-summary-goto-article
4537 (mail-header-number (caadr thread)))
4538 (forward-line -1)
eec82323
LMI
4539 (gnus-delete-line)
4540 (gnus-data-compute-positions))
4541 (setq thread (cdr thread))
4542 (while thread
4543 (gnus-remove-thread-1 (car thread))
4544 (setq thread (cdr thread))))
4545 (gnus-remove-thread-1 thread))))))))
4546
4547(defun gnus-remove-thread-1 (thread)
4548 "Remove the thread THREAD recursively."
4549 (let ((number (mail-header-number (pop thread)))
4550 d)
4551 (setq thread (reverse thread))
4552 (while thread
4553 (gnus-remove-thread-1 (pop thread)))
4554 (when (setq d (gnus-data-find number))
4555 (goto-char (gnus-data-pos d))
16409b0b 4556 (gnus-summary-show-thread)
eec82323
LMI
4557 (gnus-data-remove
4558 number
4559 (- (gnus-point-at-bol)
4560 (prog1
4561 (1+ (gnus-point-at-eol))
4562 (gnus-delete-line)))))))
4563
4921bbdd 4564(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4565 (sort (mapcar (lambda (thread)
4566 (cons (car thread)
4567 (and (cdr thread)
4921bbdd 4568 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4569 threads) func))
4570
4921bbdd
CY
4571(defun gnus-sort-threads-loop (threads func)
4572 (let* ((superthread (cons nil threads))
4573 (stack (list (cons superthread threads)))
4574 remaining-threads thread)
4575 (while stack
4576 (setq remaining-threads (cdr (car stack)))
4577 (if remaining-threads
4578 (progn (setq thread (car remaining-threads))
4579 (setcdr (car stack) (cdr remaining-threads))
4580 (if (cdr thread)
4581 (push (cons thread (cdr thread)) stack)))
4582 (setq thread (caar stack))
4583 (setcdr thread (sort (cdr thread) func))
4584 (pop stack)))
4585 (cdr superthread)))
4586
eec82323
LMI
4587(defun gnus-sort-threads (threads)
4588 "Sort THREADS."
4589 (if (not gnus-thread-sort-functions)
4590 threads
6748645f 4591 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4592 (prog1
4593 (condition-case nil
4594 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4595 (gnus-sort-threads-recursive
4596 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4597 ;; Even after binding max-lisp-eval-depth, the recursive
4598 ;; sorter might fail for very long threads. In that case,
4599 ;; try using a (less well-tested) non-recursive sorter.
4600 (error (gnus-sort-threads-loop
4601 threads (gnus-make-sort-function
4602 gnus-thread-sort-functions))))
4603 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4604
4605(defun gnus-sort-articles (articles)
4606 "Sort ARTICLES."
4607 (when gnus-article-sort-functions
4608 (gnus-message 7 "Sorting articles...")
4609 (prog1
4610 (setq gnus-newsgroup-headers
4611 (sort articles (gnus-make-sort-function
4612 gnus-article-sort-functions)))
4613 (gnus-message 7 "Sorting articles...done"))))
4614
4615;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4616(defmacro gnus-thread-header (thread)
16409b0b
GM
4617 "Return header of first article in THREAD.
4618Note that THREAD must never, ever be anything else than a variable -
4619using some other form will lead to serious barfage."
eec82323
LMI
4620 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4621 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4622 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4623 (vector thread) 2))
4624
4625(defsubst gnus-article-sort-by-number (h1 h2)
4626 "Sort articles by article number."
4627 (< (mail-header-number h1)
4628 (mail-header-number h2)))
4629
4630(defun gnus-thread-sort-by-number (h1 h2)
4631 "Sort threads by root article number."
4632 (gnus-article-sort-by-number
4633 (gnus-thread-header h1) (gnus-thread-header h2)))
4634
23f87bed
MB
4635(defsubst gnus-article-sort-by-random (h1 h2)
4636 "Sort articles by article number."
4637 (zerop (random 2)))
4638
4639(defun gnus-thread-sort-by-random (h1 h2)
4640 "Sort threads by root article number."
4641 (gnus-article-sort-by-random
4642 (gnus-thread-header h1) (gnus-thread-header h2)))
4643
eec82323
LMI
4644(defsubst gnus-article-sort-by-lines (h1 h2)
4645 "Sort articles by article Lines header."
4646 (< (mail-header-lines h1)
4647 (mail-header-lines h2)))
4648
4649(defun gnus-thread-sort-by-lines (h1 h2)
4650 "Sort threads by root article Lines header."
4651 (gnus-article-sort-by-lines
4652 (gnus-thread-header h1) (gnus-thread-header h2)))
4653
16409b0b
GM
4654(defsubst gnus-article-sort-by-chars (h1 h2)
4655 "Sort articles by octet length."
4656 (< (mail-header-chars h1)
4657 (mail-header-chars h2)))
4658
4659(defun gnus-thread-sort-by-chars (h1 h2)
4660 "Sort threads by root article octet length."
4661 (gnus-article-sort-by-chars
4662 (gnus-thread-header h1) (gnus-thread-header h2)))
4663
eec82323
LMI
4664(defsubst gnus-article-sort-by-author (h1 h2)
4665 "Sort articles by root author."
4666 (string-lessp
4667 (let ((extract (funcall
4668 gnus-extract-address-components
4669 (mail-header-from h1))))
4670 (or (car extract) (cadr extract) ""))
4671 (let ((extract (funcall
4672 gnus-extract-address-components
4673 (mail-header-from h2))))
4674 (or (car extract) (cadr extract) ""))))
4675
4676(defun gnus-thread-sort-by-author (h1 h2)
4677 "Sort threads by root author."
4678 (gnus-article-sort-by-author
4679 (gnus-thread-header h1) (gnus-thread-header h2)))
4680
4681(defsubst gnus-article-sort-by-subject (h1 h2)
4682 "Sort articles by root subject."
4683 (string-lessp
4684 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4685 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4686
4687(defun gnus-thread-sort-by-subject (h1 h2)
4688 "Sort threads by root subject."
4689 (gnus-article-sort-by-subject
4690 (gnus-thread-header h1) (gnus-thread-header h2)))
4691
4692(defsubst gnus-article-sort-by-date (h1 h2)
4693 "Sort articles by root article date."
16409b0b 4694 (time-less-p
eec82323
LMI
4695 (gnus-date-get-time (mail-header-date h1))
4696 (gnus-date-get-time (mail-header-date h2))))
4697
4698(defun gnus-thread-sort-by-date (h1 h2)
4699 "Sort threads by root article date."
4700 (gnus-article-sort-by-date
4701 (gnus-thread-header h1) (gnus-thread-header h2)))
4702
4703(defsubst gnus-article-sort-by-score (h1 h2)
4704 "Sort articles by root article score.
4705Unscored articles will be counted as having a score of zero."
4706 (> (or (cdr (assq (mail-header-number h1)
4707 gnus-newsgroup-scored))
4708 gnus-summary-default-score 0)
4709 (or (cdr (assq (mail-header-number h2)
4710 gnus-newsgroup-scored))
4711 gnus-summary-default-score 0)))
4712
4713(defun gnus-thread-sort-by-score (h1 h2)
4714 "Sort threads by root article score."
4715 (gnus-article-sort-by-score
4716 (gnus-thread-header h1) (gnus-thread-header h2)))
4717
4718(defun gnus-thread-sort-by-total-score (h1 h2)
4719 "Sort threads by the sum of all scores in the thread.
4720Unscored articles will be counted as having a score of zero."
4721 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4722
4723(defun gnus-thread-total-score (thread)
16409b0b 4724 ;; This function find the total score of THREAD.
23f87bed
MB
4725 (cond
4726 ((null thread)
4727 0)
4728 ((consp thread)
4729 (if (stringp (car thread))
4730 (apply gnus-thread-score-function 0
4731 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4732 (gnus-thread-total-score-1 thread)))
4733 (t
4734 (gnus-thread-total-score-1 (list thread)))))
4735
4736(defun gnus-thread-sort-by-most-recent-number (h1 h2)
4737 "Sort threads such that the thread with the most recently arrived article comes first."
4738 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4739
4740(defun gnus-thread-highest-number (thread)
4741 "Return the highest article number in THREAD."
4742 (apply 'max (mapcar (lambda (header)
4743 (mail-header-number header))
4744 (message-flatten-list thread))))
4745
4746(defun gnus-thread-sort-by-most-recent-date (h1 h2)
4747 "Sort threads such that the thread with the most recently dated article comes first."
4748 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4749
4750(defun gnus-thread-latest-date (thread)
4751 "Return the highest article date in THREAD."
4752 (let ((previous-time 0))
4753 (apply 'max
4754 (mapcar
4755 (lambda (header)
4756 (setq previous-time
4757 (condition-case ()
4758 (time-to-seconds (mail-header-parse-date
4759 (mail-header-date header)))
4760 (error previous-time))))
4761 (sort
4762 (message-flatten-list thread)
4763 (lambda (h1 h2)
4764 (< (mail-header-number h1)
4765 (mail-header-number h2))))))))
eec82323
LMI
4766
4767(defun gnus-thread-total-score-1 (root)
4768 ;; This function find the total score of the thread below ROOT.
4769 (setq root (car root))
4770 (apply gnus-thread-score-function
4771 (or (append
4772 (mapcar 'gnus-thread-total-score
6748645f 4773 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
4774 (when (> (mail-header-number root) 0)
4775 (list (or (cdr (assq (mail-header-number root)
4776 gnus-newsgroup-scored))
4777 gnus-summary-default-score 0))))
4778 (list gnus-summary-default-score)
4779 '(0))))
4780
4781;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4782(defvar gnus-tmp-prev-subject nil)
4783(defvar gnus-tmp-false-parent nil)
4784(defvar gnus-tmp-root-expunged nil)
4785(defvar gnus-tmp-dummy-line nil)
4786
60bd5589 4787(eval-when-compile (defvar gnus-tmp-header))
16409b0b
GM
4788(defun gnus-extra-header (type &optional header)
4789 "Return the extra header of TYPE."
4790 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4791 ""))
4792
23f87bed
MB
4793(defvar gnus-tmp-thread-tree-header-string "")
4794
4795(defcustom gnus-sum-thread-tree-root "> "
4796 "With %B spec, used for the root of a thread.
4797If nil, use subject instead."
bf247b6e 4798 :version "22.1"
ad136a7c 4799 :type '(radio (const :format "%v " nil) string)
23f87bed
MB
4800 :group 'gnus-thread)
4801(defcustom gnus-sum-thread-tree-false-root "> "
4802 "With %B spec, used for a false root of a thread.
4803If nil, use subject instead."
bf247b6e 4804 :version "22.1"
ad136a7c 4805 :type '(radio (const :format "%v " nil) string)
23f87bed
MB
4806 :group 'gnus-thread)
4807(defcustom gnus-sum-thread-tree-single-indent ""
4808 "With %B spec, used for a thread with just one message.
4809If nil, use subject instead."
bf247b6e 4810 :version "22.1"
ad136a7c 4811 :type '(radio (const :format "%v " nil) string)
23f87bed
MB
4812 :group 'gnus-thread)
4813(defcustom gnus-sum-thread-tree-vertical "| "
4814 "With %B spec, used for drawing a vertical line."
bf247b6e 4815 :version "22.1"
23f87bed
MB
4816 :type 'string
4817 :group 'gnus-thread)
4818(defcustom gnus-sum-thread-tree-indent " "
4819 "With %B spec, used for indenting."
bf247b6e 4820 :version "22.1"
23f87bed
MB
4821 :type 'string
4822 :group 'gnus-thread)
4823(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4824 "With %B spec, used for a leaf with brothers."
bf247b6e 4825 :version "22.1"
23f87bed
MB
4826 :type 'string
4827 :group 'gnus-thread)
4828(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4829 "With %B spec, used for a leaf without brothers."
bf247b6e 4830 :version "22.1"
23f87bed
MB
4831 :type 'string
4832 :group 'gnus-thread)
4833
eec82323
LMI
4834(defun gnus-summary-prepare-threads (threads)
4835 "Prepare summary buffer from THREADS and indentation LEVEL.
4836THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4837or a straight list of headers."
4838 (gnus-message 7 "Generating summary...")
4839
4840 (setq gnus-newsgroup-threads threads)
4841 (beginning-of-line)
4842
4843 (let ((gnus-tmp-level 0)
4844 (default-score (or gnus-summary-default-score 0))
4845 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
4846 (building-line-count gnus-summary-display-while-building)
4847 (building-count (integerp gnus-summary-display-while-building))
eec82323 4848 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
4849 new-roots gnus-tmp-new-adopts thread-end simp-subject
4850 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
4851 gnus-tmp-replied gnus-tmp-subject-or-nil
4852 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4853 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
4854 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4855 tree-stack)
eec82323 4856
23f87bed
MB
4857 (setq gnus-tmp-prev-subject nil
4858 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
4859
4860 (if (vectorp (car threads))
4861 ;; If this is a straight (sic) list of headers, then a
4862 ;; threaded summary display isn't required, so we just create
4863 ;; an unthreaded one.
4864 (gnus-summary-prepare-unthreaded threads)
4865
4866 ;; Do the threaded display.
4867
23f87bed
MB
4868 (if gnus-summary-display-while-building
4869 (switch-to-buffer (buffer-name)))
eec82323
LMI
4870 (while (or threads stack gnus-tmp-new-adopts new-roots)
4871
4872 (if (and (= gnus-tmp-level 0)
eec82323
LMI
4873 (or (not stack)
4874 (= (caar stack) 0))
4875 (not gnus-tmp-false-parent)
4876 (or gnus-tmp-new-adopts new-roots))
4877 (if gnus-tmp-new-adopts
4878 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4879 thread (list (car gnus-tmp-new-adopts))
4880 gnus-tmp-header (caar thread)
4881 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4882 (when new-roots
4883 (setq thread (list (car new-roots))
4884 gnus-tmp-header (caar thread)
4885 new-roots (cdr new-roots))))
4886
4887 (if threads
4888 ;; If there are some threads, we do them before the
4889 ;; threads on the stack.
4890 (setq thread threads
4891 gnus-tmp-header (caar thread))
4892 ;; There were no current threads, so we pop something off
4893 ;; the stack.
4894 (setq state (car stack)
4895 gnus-tmp-level (car state)
23f87bed
MB
4896 tree-stack (cadr state)
4897 thread (caddr state)
eec82323
LMI
4898 stack (cdr stack)
4899 gnus-tmp-header (caar thread))))
4900
4901 (setq gnus-tmp-false-parent nil)
4902 (setq gnus-tmp-root-expunged nil)
4903 (setq thread-end nil)
4904
4905 (if (stringp gnus-tmp-header)
4906 ;; The header is a dummy root.
4907 (cond
4908 ((eq gnus-summary-make-false-root 'adopt)
4909 ;; We let the first article adopt the rest.
4910 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4911 (cddar thread)))
4912 (setq gnus-tmp-gathered
4913 (nconc (mapcar
4914 (lambda (h) (mail-header-number (car h)))
4915 (cddar thread))
4916 gnus-tmp-gathered))
4917 (setq thread (cons (list (caar thread)
4918 (cadar thread))
4919 (cdr thread)))
4920 (setq gnus-tmp-level -1
4921 gnus-tmp-false-parent t))
4922 ((eq gnus-summary-make-false-root 'empty)
4923 ;; We print adopted articles with empty subject fields.
4924 (setq gnus-tmp-gathered
4925 (nconc (mapcar
4926 (lambda (h) (mail-header-number (car h)))
4927 (cddar thread))
4928 gnus-tmp-gathered))
4929 (setq gnus-tmp-level -1))
4930 ((eq gnus-summary-make-false-root 'dummy)
4931 ;; We remember that we probably want to output a dummy
4932 ;; root.
4933 (setq gnus-tmp-dummy-line gnus-tmp-header)
4934 (setq gnus-tmp-prev-subject gnus-tmp-header))
4935 (t
4936 ;; We do not make a root for the gathered
4937 ;; sub-threads at all.
4938 (setq gnus-tmp-level -1)))
4939
4940 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
4941 subject (mail-header-subject gnus-tmp-header)
4942 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
4943
4944 (cond
4945 ;; If the thread has changed subject, we might want to make
4946 ;; this subthread into a root.
4947 ((and (null gnus-thread-ignore-subject)
4948 (not (zerop gnus-tmp-level))
4949 gnus-tmp-prev-subject
23f87bed 4950 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
4951 (setq new-roots (nconc new-roots (list (car thread)))
4952 thread-end t
4953 gnus-tmp-header nil))
4954 ;; If the article lies outside the current limit,
4955 ;; then we do not display it.
4956 ((not (memq number gnus-newsgroup-limit))
4957 (setq gnus-tmp-gathered
4958 (nconc (mapcar
4959 (lambda (h) (mail-header-number (car h)))
4960 (cdar thread))
4961 gnus-tmp-gathered))
4962 (setq gnus-tmp-new-adopts (if (cdar thread)
4963 (append gnus-tmp-new-adopts
4964 (cdar thread))
4965 gnus-tmp-new-adopts)
4966 thread-end t
4967 gnus-tmp-header nil)
4968 (when (zerop gnus-tmp-level)
4969 (setq gnus-tmp-root-expunged t)))
4970 ;; Perhaps this article is to be marked as read?
4971 ((and gnus-summary-mark-below
4972 (< (or (cdr (assq number gnus-newsgroup-scored))
4973 default-score)
4974 gnus-summary-mark-below)
4975 ;; Don't touch sparse articles.
4976 (not (gnus-summary-article-sparse-p number))
4977 (not (gnus-summary-article-ancient-p number)))
4978 (setq gnus-newsgroup-unreads
4979 (delq number gnus-newsgroup-unreads))
4980 (if gnus-newsgroup-auto-expire
23f87bed
MB
4981 (setq gnus-newsgroup-expirable
4982 (gnus-add-to-sorted-list
4983 gnus-newsgroup-expirable number))
eec82323
LMI
4984 (push (cons number gnus-low-score-mark)
4985 gnus-newsgroup-reads))))
4986
4987 (when gnus-tmp-header
4988 ;; We may have an old dummy line to output before this
4989 ;; article.
6748645f
LMI
4990 (when (and gnus-tmp-dummy-line
4991 (gnus-subject-equal
4992 gnus-tmp-dummy-line
4993 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
4994 (gnus-summary-insert-dummy-line
4995 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4996 (setq gnus-tmp-dummy-line nil))
4997
4998 ;; Compute the mark.
4999 (setq gnus-tmp-unread (gnus-article-mark number))
5000
5001 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5002 gnus-tmp-header gnus-tmp-level)
5003 gnus-newsgroup-data)
5004
5005 ;; Actually insert the line.
5006 (setq
5007 gnus-tmp-subject-or-nil
5008 (cond
5009 ((and gnus-thread-ignore-subject
5010 gnus-tmp-prev-subject
23f87bed 5011 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5012 subject)
5013 ((zerop gnus-tmp-level)
5014 (if (and (eq gnus-summary-make-false-root 'empty)
5015 (memq number gnus-tmp-gathered)
5016 gnus-tmp-prev-subject
23f87bed 5017 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5018 gnus-summary-same-subject
5019 subject))
5020 (t gnus-summary-same-subject)))
5021 (if (and (eq gnus-summary-make-false-root 'adopt)
5022 (= gnus-tmp-level 1)
5023 (memq number gnus-tmp-gathered))
5024 (setq gnus-tmp-opening-bracket ?\<
5025 gnus-tmp-closing-bracket ?\>)
5026 (setq gnus-tmp-opening-bracket ?\[
5027 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5028 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5029 (gnus-make-thread-indent-array
5030 (max (* 2 (length gnus-thread-indent-array))
5031 gnus-tmp-level)))
eec82323
LMI
5032 (setq
5033 gnus-tmp-indentation
5034 (aref gnus-thread-indent-array gnus-tmp-level)
5035 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5036 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5037 gnus-summary-default-score 0)
5038 gnus-tmp-score-char
5039 (if (or (null gnus-summary-default-score)
5040 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5041 gnus-summary-zcore-fuzz))
23f87bed 5042 ? ;Whitespace
eec82323
LMI
5043 (if (< gnus-tmp-score gnus-summary-default-score)
5044 gnus-score-below-mark gnus-score-over-mark))
5045 gnus-tmp-replied
5046 (cond ((memq number gnus-newsgroup-processable)
5047 gnus-process-mark)
5048 ((memq number gnus-newsgroup-cached)
5049 gnus-cached-mark)
5050 ((memq number gnus-newsgroup-replied)
5051 gnus-replied-mark)
23f87bed
MB
5052 ((memq number gnus-newsgroup-forwarded)
5053 gnus-forwarded-mark)
eec82323
LMI
5054 ((memq number gnus-newsgroup-saved)
5055 gnus-saved-mark)
23f87bed
MB
5056 ((memq number gnus-newsgroup-recent)
5057 gnus-recent-mark)
5058 ((memq number gnus-newsgroup-unseen)
5059 gnus-unseen-mark)
5060 (t gnus-no-mark))
5061 gnus-tmp-downloaded
5062 (cond ((memq number gnus-newsgroup-undownloaded)
5063 gnus-undownloaded-mark)
5064 (gnus-newsgroup-agentized
5065 gnus-downloaded-mark)
5066 (t
5067 gnus-no-mark))
eec82323
LMI
5068 gnus-tmp-from (mail-header-from gnus-tmp-header)
5069 gnus-tmp-name
5070 (cond
5071 ((string-match "<[^>]+> *$" gnus-tmp-from)
5072 (setq beg-match (match-beginning 0))
23f87bed
MB
5073 (or (and (string-match "^\".+\"" gnus-tmp-from)
5074 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5075 (substring gnus-tmp-from 0 beg-match)))
5076 ((string-match "(.+)" gnus-tmp-from)
5077 (substring gnus-tmp-from
5078 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5079 (t gnus-tmp-from))
5080
5081 ;; Do the %B string
5082 gnus-tmp-thread-tree-header-string
5083 (cond
5084 ((not gnus-show-threads) "")
5085 ((zerop gnus-tmp-level)
5086 (cond ((cdar thread)
5087 (or gnus-sum-thread-tree-root subject))
5088 (gnus-tmp-new-adopts
5089 (or gnus-sum-thread-tree-false-root subject))
5090 (t
5091 (or gnus-sum-thread-tree-single-indent subject))))
5092 (t
5093 (concat (apply 'concat
5094 (mapcar (lambda (item)
5095 (if (= item 1)
5096 gnus-sum-thread-tree-vertical
5097 gnus-sum-thread-tree-indent))
5098 (cdr (reverse tree-stack))))
5099 (if (nth 1 thread)
5100 gnus-sum-thread-tree-leaf-with-other
5101 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5102 (when (string= gnus-tmp-name "")
5103 (setq gnus-tmp-name gnus-tmp-from))
5104 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5105 (setq gnus-tmp-lines -1))
5106 (if (= gnus-tmp-lines -1)
5107 (setq gnus-tmp-lines "?")
5108 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5109 (gnus-put-text-property
eec82323
LMI
5110 (point)
5111 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 5112 'gnus-number number)
eec82323
LMI
5113 (when gnus-visual-p
5114 (forward-line -1)
6748645f 5115 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
5116 (forward-line 1))
5117
23f87bed 5118 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5119
5120 (when (nth 1 thread)
23f87bed
MB
5121 (push (list (max 0 gnus-tmp-level)
5122 (copy-sequence tree-stack)
5123 (nthcdr 1 thread))
5124 stack))
5125 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5126 (incf gnus-tmp-level)
5127 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5128 (if gnus-summary-display-while-building
5129 (if building-count
5130 (progn
5131 ;; use a set frequency
5132 (setq building-line-count (1- building-line-count))
5133 (when (= building-line-count 0)
5134 (sit-for 0)
5135 (setq building-line-count
5136 gnus-summary-display-while-building)))
5137 ;; always
5138 (sit-for 0)))
eec82323
LMI
5139 (unless threads
5140 (setq gnus-tmp-level 0)))))
5141 (gnus-message 7 "Generating summary...done"))
5142
5143(defun gnus-summary-prepare-unthreaded (headers)
5144 "Generate an unthreaded summary buffer based on HEADERS."
5145 (let (header number mark)
5146
5147 (beginning-of-line)
5148
5149 (while headers
5150 ;; We may have to root out some bad articles...
5151 (when (memq (setq number (mail-header-number
5152 (setq header (pop headers))))
5153 gnus-newsgroup-limit)
5154 ;; Mark article as read when it has a low score.
5155 (when (and gnus-summary-mark-below
5156 (< (or (cdr (assq number gnus-newsgroup-scored))
5157 gnus-summary-default-score 0)
5158 gnus-summary-mark-below)
5159 (not (gnus-summary-article-ancient-p number)))
5160 (setq gnus-newsgroup-unreads
5161 (delq number gnus-newsgroup-unreads))
5162 (if gnus-newsgroup-auto-expire
5163 (push number gnus-newsgroup-expirable)
5164 (push (cons number gnus-low-score-mark)
5165 gnus-newsgroup-reads)))
5166
5167 (setq mark (gnus-article-mark number))
5168 (push (gnus-data-make number mark (1+ (point)) header 0)
5169 gnus-newsgroup-data)
5170 (gnus-summary-insert-line
5171 header 0 number
23f87bed 5172 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5173 mark (memq number gnus-newsgroup-replied)
5174 (memq number gnus-newsgroup-expirable)
5175 (mail-header-subject header) nil
5176 (cdr (assq number gnus-newsgroup-scored))
5177 (memq number gnus-newsgroup-processable))))))
5178
16409b0b
GM
5179(defun gnus-summary-remove-list-identifiers ()
5180 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5181 (let ((regexp (if (consp gnus-list-identifiers)
5182 (mapconcat 'identity gnus-list-identifiers " *\\|")
5183 gnus-list-identifiers))
5184 changed subject)
5185 (when regexp
5186 (dolist (header gnus-newsgroup-headers)
5187 (setq subject (mail-header-subject header)
5188 changed nil)
5189 (while (string-match
5190 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
5191 subject)
5192 (setq subject
5193 (concat (substring subject 0 (match-beginning 2))
5194 (substring subject (match-end 0)))
5195 changed t))
5196 (when (and changed
5197 (string-match
5198 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
5199 (setq subject
5200 (concat (substring subject 0 (match-beginning 1))
5201 (substring subject (match-end 1)))))
5202 (when changed
5203 (mail-header-set-subject header subject))))))
5204
5205(defun gnus-fetch-headers (articles)
5206 "Fetch headers of ARTICLES."
5207 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5208 (gnus-message 5 "Fetching headers for %s..." name)
5209 (prog1
5210 (if (eq 'nov
5211 (setq gnus-headers-retrieved-by
5212 (gnus-retrieve-headers
5213 articles gnus-newsgroup-name
5214 ;; We might want to fetch old headers, but
5215 ;; not if there is only 1 article.
5216 (and (or (and
5217 (not (eq gnus-fetch-old-headers 'some))
5218 (not (numberp gnus-fetch-old-headers)))
5219 (> (length articles) 1))
5220 gnus-fetch-old-headers))))
5221 (gnus-get-newsgroup-headers-xover
5222 articles nil nil gnus-newsgroup-name t)
5223 (gnus-get-newsgroup-headers))
5224 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5225
6748645f 5226(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5227 "Select newsgroup GROUP.
6748645f
LMI
5228If READ-ALL is non-nil, all articles in the group are selected.
5229If SELECT-ARTICLES, only select those articles from GROUP."
eec82323
LMI
5230 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5231 ;;!!! Dirty hack; should be removed.
5232 (gnus-summary-ignore-duplicates
23f87bed 5233 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5234 t
5235 gnus-summary-ignore-duplicates))
5236 (info (nth 2 entry))
5237 articles fetched-articles cached)
5238
5239 (unless (gnus-check-server
475e0e0c
GM
5240 (set (make-local-variable 'gnus-current-select-method)
5241 (gnus-find-method-for-group group)))
eec82323
LMI
5242 (error "Couldn't open server"))
5243
5244 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5245 (gnus-activate-group group) ; Or we can activate it...
5246 (progn ; Or we bug out.
5247 (when (equal major-mode 'gnus-summary-mode)
23f87bed
MB
5248 (gnus-kill-buffer (current-buffer)))
5249 (error "Couldn't activate group %s: %s"
c86d4601 5250 (gnus-group-decoded-name group) (gnus-status-message group))))
eec82323
LMI
5251
5252 (unless (gnus-request-group group t)
5253 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5254 (gnus-kill-buffer (current-buffer)))
eec82323 5255 (error "Couldn't request group %s: %s"
c86d4601 5256 (gnus-group-decoded-name group) (gnus-status-message group)))
eec82323 5257
23f87bed 5258 (when gnus-agent
54506618 5259 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5260
23f87bed
MB
5261 (setq gnus-summary-use-undownloaded-faces
5262 (gnus-agent-find-parameter
5263 group
5264 'agent-enable-undownloaded-faces)))
5265
5266 (setq gnus-newsgroup-name group
5267 gnus-newsgroup-unselected nil
5268 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5269
5270 (let ((display (gnus-group-find-parameter group 'display)))
5271 (setq gnus-newsgroup-display
5272 (cond
5273 ((not (zerop (or (car-safe read-all) 0)))
5274 ;; The user entered the group with C-u SPC/RET, let's show
5275 ;; all articles.
5276 'gnus-not-ignore)
5277 ((eq display 'all)
5278 'gnus-not-ignore)
5279 ((arrayp display)
5280 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5281 ((numberp display)
5282 ;; The following is probably the "correct" solution, but
5283 ;; it makes Gnus fetch all headers and then limit the
5284 ;; articles (which is slow), so instead we hack the
5285 ;; select-articles parameter instead. -- Simon Josefsson
5286 ;; <jas@kth.se>
5287 ;;
5288 ;; (gnus-byte-compile
5289 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5290 ;; display)))))
5291 (setq select-articles
5292 (gnus-uncompress-range
5293 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5294 (if (> tmp 0)
5295 tmp
5296 1))
5297 (cdr (gnus-active group)))))
5298 nil)
5299 (t
5300 nil))))
eec82323 5301
23f87bed 5302 (gnus-summary-setup-default-charset)
eec82323
LMI
5303
5304 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5305 (when (gnus-virtual-group-p group)
5306 (setq cached gnus-newsgroup-cached))
5307
5308 (setq gnus-newsgroup-unreads
23f87bed
MB
5309 (gnus-sorted-ndifference
5310 (gnus-sorted-ndifference gnus-newsgroup-unreads
5311 gnus-newsgroup-marked)
eec82323
LMI
5312 gnus-newsgroup-dormant))
5313
5314 (setq gnus-newsgroup-processable nil)
5315
5316 (gnus-update-read-articles group gnus-newsgroup-unreads)
eec82323 5317
23f87bed
MB
5318 ;; Adjust and set lists of article marks.
5319 (when info
5320 (gnus-adjust-marked-articles info))
6748645f
LMI
5321 (if (setq articles select-articles)
5322 (setq gnus-newsgroup-unselected
23f87bed 5323 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5324 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5325
5326 (cond
5327 ((null articles)
5328 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5329 'quit)
5330 ((eq articles 0) nil)
5331 (t
5332 ;; Init the dependencies hash table.
5333 (setq gnus-newsgroup-dependencies
5334 (gnus-make-hashtable (length articles)))
16409b0b 5335 (gnus-set-global-variables)
eec82323 5336 ;; Retrieve the headers and read them in.
23f87bed
MB
5337
5338 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5339
5340 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5341 (when cached
5342 (setq gnus-newsgroup-cached cached))
5343
5344 ;; Suppress duplicates?
5345 (when gnus-suppress-duplicates
5346 (gnus-dup-suppress-articles))
5347
5348 ;; Set the initial limit.
5349 (setq gnus-newsgroup-limit (copy-sequence articles))
5350 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5351 (setq fetched-articles
5352 (mapcar (lambda (headers) (mail-header-number headers))
5353 gnus-newsgroup-headers))
5354 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5355 (setq gnus-newsgroup-unreads
23f87bed
MB
5356 (gnus-sorted-nintersection
5357 gnus-newsgroup-unreads fetched-articles))
5358 (gnus-compute-unseen-list)
5359
eec82323
LMI
5360 ;; Removed marked articles that do not exist.
5361 (gnus-update-missing-marks
23f87bed 5362 (gnus-sorted-difference articles fetched-articles))
eec82323 5363 ;; We might want to build some more threads first.
6748645f
LMI
5364 (when (and gnus-fetch-old-headers
5365 (eq gnus-headers-retrieved-by 'nov))
5366 (if (eq gnus-fetch-old-headers 'invisible)
5367 (gnus-build-all-threads)
5368 (gnus-build-old-threads)))
5369 ;; Let the Gnus agent mark articles as read.
5370 (when gnus-agent
5371 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5372 ;; Remove list identifiers from subject
5373 (when gnus-list-identifiers
5374 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5375 ;; Check whether auto-expire is to be done in this group.
5376 (setq gnus-newsgroup-auto-expire
5377 (gnus-group-auto-expirable-p group))
5378 ;; Set up the article buffer now, if necessary.
5379 (unless gnus-single-article-buffer
5380 (gnus-article-setup-buffer))
5381 ;; First and last article in this newsgroup.
5382 (when gnus-newsgroup-headers
5383 (setq gnus-newsgroup-begin
5384 (mail-header-number (car gnus-newsgroup-headers))
5385 gnus-newsgroup-end
5386 (mail-header-number
5387 (gnus-last-element gnus-newsgroup-headers))))
5388 ;; GROUP is successfully selected.
5389 (or gnus-newsgroup-headers t)))))
5390
23f87bed
MB
5391(defun gnus-compute-unseen-list ()
5392 ;; The `seen' marks are treated specially.
5393 (if (not gnus-newsgroup-seen)
5394 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5395 (setq gnus-newsgroup-unseen
5396 (gnus-inverse-list-range-intersection
5397 gnus-newsgroup-articles gnus-newsgroup-seen))))
5398
5399(defun gnus-summary-display-make-predicate (display)
5400 (require 'gnus-agent)
5401 (when (= (length display) 1)
5402 (setq display (car display)))
5403 (unless gnus-summary-display-cache
5404 (dolist (elem (append '((unread . unread)
5405 (read . read)
5406 (unseen . unseen))
5407 gnus-article-mark-lists))
5408 (push (cons (cdr elem)
5409 (gnus-byte-compile
5410 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5411 gnus-summary-display-cache)))
5412 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5413 (gnus-category-predicate-cache gnus-summary-display-cache))
5414 (gnus-get-predicate display)))
5415
5416;; Uses the dynamically bound `number' variable.
5417(eval-when-compile
5418 (defvar number))
5419(defun gnus-article-marked-p (type &optional article)
5420 (let ((article (or article number)))
5421 (cond
5422 ((eq type 'tick)
5423 (memq article gnus-newsgroup-marked))
5424 ((eq type 'spam)
5425 (memq article gnus-newsgroup-spam-marked))
5426 ((eq type 'unsend)
5427 (memq article gnus-newsgroup-unsendable))
5428 ((eq type 'undownload)
5429 (memq article gnus-newsgroup-undownloaded))
5430 ((eq type 'download)
5431 (memq article gnus-newsgroup-downloadable))
5432 ((eq type 'unread)
5433 (memq article gnus-newsgroup-unreads))
5434 ((eq type 'read)
5435 (memq article gnus-newsgroup-reads))
5436 ((eq type 'dormant)
5437 (memq article gnus-newsgroup-dormant) )
5438 ((eq type 'expire)
5439 (memq article gnus-newsgroup-expirable))
5440 ((eq type 'reply)
5441 (memq article gnus-newsgroup-replied))
5442 ((eq type 'killed)
5443 (memq article gnus-newsgroup-killed))
5444 ((eq type 'bookmark)
5445 (assq article gnus-newsgroup-bookmarks))
5446 ((eq type 'score)
5447 (assq article gnus-newsgroup-scored))
5448 ((eq type 'save)
5449 (memq article gnus-newsgroup-saved))
5450 ((eq type 'cache)
5451 (memq article gnus-newsgroup-cached))
5452 ((eq type 'forward)
5453 (memq article gnus-newsgroup-forwarded))
5454 ((eq type 'seen)
5455 (not (memq article gnus-newsgroup-unseen)))
5456 ((eq type 'recent)
5457 (memq article gnus-newsgroup-recent))
5458 (t t))))
5459
eec82323 5460(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5461 "Find out what articles the user wants to read."
26c9afc3 5462 (let* ((articles
eec82323
LMI
5463 ;; Select all articles if `read-all' is non-nil, or if there
5464 ;; are no unread articles.
5465 (if (or read-all
5466 (and (zerop (length gnus-newsgroup-marked))
5467 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5468 ;; Fetch all if the predicate is non-nil.
5469 gnus-newsgroup-display)
5470 ;; We want to select the headers for all the articles in
5471 ;; the group, so we select either all the active
5472 ;; articles in the group, or (if that's nil), the
5473 ;; articles in the cache.
16409b0b
GM
5474 (or
5475 (gnus-uncompress-range (gnus-active group))
5476 (gnus-cache-articles-in-group group))
23f87bed
MB
5477 ;; Select only the "normal" subset of articles.
5478 (gnus-sorted-nunion
5479 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5480 gnus-newsgroup-unreads)))
eec82323
LMI
5481 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5482 (scored (length scored-list))
5483 (number (length articles))
5484 (marked (+ (length gnus-newsgroup-marked)
5485 (length gnus-newsgroup-dormant)))
5486 (select
5487 (cond
5488 ((numberp read-all)
5489 read-all)
23f87bed
MB
5490 ((numberp gnus-newsgroup-display)
5491 gnus-newsgroup-display)
eec82323
LMI
5492 (t
5493 (condition-case ()
5494 (cond
5495 ((and (or (<= scored marked) (= scored number))
5496 (numberp gnus-large-newsgroup)
5497 (> number gnus-large-newsgroup))
23f87bed
MB
5498 (let* ((cursor-in-echo-area nil)
5499 (initial (gnus-parameter-large-newsgroup-initial
5500 gnus-newsgroup-name))
5501 (input
5502 (read-string
5503 (format
5504 "How many articles from %s (%s %d): "
5505 (gnus-limit-string
5506 (gnus-group-decoded-name gnus-newsgroup-name)
5507 35)
5508 (if initial "max" "default")
5509 number)
5510 (if initial
5511 (cons (number-to-string initial)
5512 0)))))
eec82323
LMI
5513 (if (string-match "^[ \t]*$" input) number input)))
5514 ((and (> scored marked) (< scored number)
5515 (> (- scored number) 20))
5516 (let ((input
5517 (read-string
5518 (format "%s %s (%d scored, %d total): "
5519 "How many articles from"
23f87bed
MB
5520 (gnus-group-decoded-name group)
5521 scored number))))
eec82323
LMI
5522 (if (string-match "^[ \t]*$" input)
5523 number input)))
5524 (t number))
d4dfaa19
DL
5525 (quit
5526 (message "Quit getting the articles to read")
5527 nil))))))
eec82323
LMI
5528 (setq select (if (stringp select) (string-to-number select) select))
5529 (if (or (null select) (zerop select))
5530 select
5531 (if (and (not (zerop scored)) (<= (abs select) scored))
5532 (progn
5533 (setq articles (sort scored-list '<))
5534 (setq number (length articles)))
5535 (setq articles (copy-sequence articles)))
5536
5537 (when (< (abs select) number)
5538 (if (< select 0)
5539 ;; Select the N oldest articles.
5540 (setcdr (nthcdr (1- (abs select)) articles) nil)
5541 ;; Select the N most recent articles.
5542 (setq articles (nthcdr (- number select) articles))))
5543 (setq gnus-newsgroup-unselected
23f87bed 5544 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5545 (when gnus-alter-articles-to-read-function
23f87bed 5546 (setq articles
a1506d29 5547 (sort
16409b0b 5548 (funcall gnus-alter-articles-to-read-function
23f87bed 5549 gnus-newsgroup-name articles)
16409b0b 5550 '<)))
eec82323
LMI
5551 articles)))
5552
5553(defun gnus-killed-articles (killed articles)
5554 (let (out)
5555 (while articles
5556 (when (inline (gnus-member-of-range (car articles) killed))
5557 (push (car articles) out))
5558 (setq articles (cdr articles)))
5559 out))
5560
5561(defun gnus-uncompress-marks (marks)
5562 "Uncompress the mark ranges in MARKS."
5563 (let ((uncompressed '(score bookmark))
5564 out)
5565 (while marks
5566 (if (memq (caar marks) uncompressed)
5567 (push (car marks) out)
5568 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5569 (setq marks (cdr marks)))
5570 out))
5571
23f87bed
MB
5572(defun gnus-article-mark-to-type (mark)
5573 "Return the type of MARK."
5574 (or (cadr (assq mark gnus-article-special-mark-lists))
5575 'list))
5576
5577(defun gnus-article-unpropagatable-p (mark)
5578 "Return whether MARK should be propagated to back end."
5579 (memq mark gnus-article-unpropagated-mark-lists))
5580
eec82323 5581(defun gnus-adjust-marked-articles (info)
16409b0b 5582 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5583 (let* ((marked-lists (gnus-info-marks info))
5584 (active (gnus-active (gnus-info-group info)))
5585 (min (car active))
5586 (max (cdr active))
5587 (types gnus-article-mark-lists)
54506618
MB
5588 marks var articles article mark mark-type
5589 bgn end)
eec82323 5590
23f87bed
MB
5591 (dolist (marks marked-lists)
5592 (setq mark (car marks)
5593 mark-type (gnus-article-mark-to-type mark)
5594 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5595
23f87bed
MB
5596 ;; We set the variable according to the type of the marks list,
5597 ;; and then adjust the marks to a subset of the active articles.
eec82323 5598 (cond
54506618 5599 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5600 ((eq mark-type 'list)
54506618
MB
5601 ;; Simultaneously uncompress and clip to active range
5602 ;; See gnus-uncompress-range for a description of possible marks
5603 (let (l lh)
5604 (if (not (cadr marks))
5605 (set var nil)
5606 (setq articles (if (numberp (cddr marks))
5607 (list (cdr marks))
5608 (cdr marks))
5609 lh (cons nil nil)
5610 l lh)
5611
5612 (while (setq article (pop articles))
5613 (cond ((consp article)
5614 (setq bgn (max (car article) min)
5615 end (min (cdr article) max))
5616 (while (<= bgn end)
5617 (setq l (setcdr l (cons bgn nil))
5618 bgn (1+ bgn))))
5619 ((and (<= min article)
5620 (>= max article))
5621 (setq l (setcdr l (cons article nil))))))
5622 (set var (cdr lh)))))
eec82323 5623 ;; Adjust assocs.
23f87bed
MB
5624 ((eq mark-type 'tuple)
5625 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5626 (when (not (listp (cdr (symbol-value var))))
5627 (set var (list (symbol-value var))))
5628 (when (not (listp (cdr articles)))
5629 (setq articles (list articles)))
eec82323
LMI
5630 (while articles
5631 (when (or (not (consp (setq article (pop articles))))
5632 (< (car article) min)
5633 (> (car article) max))
23f87bed
MB
5634 (set var (delq article (symbol-value var))))))
5635 ;; Adjust ranges (sloppily).
5636 ((eq mark-type 'range)
5637 (cond
5638 ((eq mark 'seen)
5639 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5640 ;; It should be (seen (NUM1 . NUM2)).
5641 (when (numberp (cddr marks))
5642 (setcdr marks (list (cdr marks))))
5643 (setq articles (cdr marks))
5644 (while (and articles
5645 (or (and (consp (car articles))
5646 (> min (cdar articles)))
5647 (and (numberp (car articles))
5648 (> min (car articles)))))
5649 (pop articles))
5650 (set var articles))))))))
eec82323
LMI
5651
5652(defun gnus-update-missing-marks (missing)
6748645f 5653 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 5654 (when missing
23f87bed 5655 (let (var m)
eec82323 5656 ;; Go through all types.
23f87bed
MB
5657 (dolist (elem gnus-article-mark-lists)
5658 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5659 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5660 (when (symbol-value var)
5661 ;; This list has articles. So we delete all missing
5662 ;; articles from it.
5663 (setq m missing)
5664 (while m
5665 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
5666
5667(defun gnus-update-marks ()
5668 "Enter the various lists of marked articles into the newsgroup info list."
5669 (let ((types gnus-article-mark-lists)
5670 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 5671 type list newmarked symbol delta-marks)
eec82323 5672 (when info
16409b0b 5673 ;; Add all marks lists to the list of marks lists.
eec82323 5674 (while (setq type (pop types))
16409b0b
GM
5675 (setq list (symbol-value
5676 (setq symbol
23f87bed 5677 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 5678
16409b0b 5679 (when list
eec82323
LMI
5680 ;; Get rid of the entries of the articles that have the
5681 ;; default score.
5682 (when (and (eq (cdr type) 'score)
5683 gnus-save-score
5684 list)
5685 (let* ((arts list)
5686 (prev (cons nil list))
5687 (all prev))
5688 (while arts
5689 (if (or (not (consp (car arts)))
5690 (= (cdar arts) gnus-summary-default-score))
5691 (setcdr prev (cdr arts))
5692 (setq prev arts))
5693 (setq arts (cdr arts)))
16409b0b
GM
5694 (setq list (cdr all)))))
5695
23f87bed
MB
5696 (when (eq (cdr type) 'seen)
5697 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5698
5699 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 5700 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 5701
23f87bed
MB
5702 (when (and (gnus-check-backend-function
5703 'request-set-mark gnus-newsgroup-name)
5704 (not (gnus-article-unpropagatable-p (cdr type))))
5705 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5706 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5707 (add (gnus-remove-from-range
5708 (gnus-copy-sequence list) old)))
5709 (when add
5710 (push (list add 'add (list (cdr type))) delta-marks))
5711 (when del
5712 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 5713
16409b0b
GM
5714 (when list
5715 (push (cons (cdr type) list) newmarked)))
5716
5717 (when delta-marks
5718 (unless (gnus-check-group gnus-newsgroup-name)
5719 (error "Can't open server for %s" gnus-newsgroup-name))
5720 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 5721
eec82323
LMI
5722 ;; Enter these new marks into the info of the group.
5723 (if (nthcdr 3 info)
5724 (setcar (nthcdr 3 info) newmarked)
5725 ;; Add the marks lists to the end of the info.
5726 (when newmarked
5727 (setcdr (nthcdr 2 info) (list newmarked))))
5728
5729 ;; Cut off the end of the info if there's nothing else there.
5730 (let ((i 5))
5731 (while (and (> i 2)
5732 (not (nth i info)))
5733 (when (nthcdr (decf i) info)
5734 (setcdr (nthcdr i info) nil)))))))
5735
5736(defun gnus-set-mode-line (where)
16409b0b 5737 "Set the mode line of the article or summary buffers.
eec82323
LMI
5738If WHERE is `summary', the summary mode line format will be used."
5739 ;; Is this mode line one we keep updated?
16409b0b
GM
5740 (when (and (memq where gnus-updated-mode-lines)
5741 (symbol-value
5742 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323
LMI
5743 (let (mode-string)
5744 (save-excursion
5745 ;; We evaluate this in the summary buffer since these
5746 ;; variables are buffer-local to that buffer.
5747 (set-buffer gnus-summary-buffer)
23f87bed 5748 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
5749 ;; below.
5750 (let* ((mformat (symbol-value
5751 (intern
5752 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
5753 (gnus-tmp-group-name (gnus-mode-string-quote
5754 (gnus-group-decoded-name
5755 gnus-newsgroup-name)))
eec82323
LMI
5756 (gnus-tmp-article-number (or gnus-current-article 0))
5757 (gnus-tmp-unread gnus-newsgroup-unreads)
5758 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5759 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5760 (gnus-tmp-unread-and-unselected
5761 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5762 (zerop gnus-tmp-unselected))
5763 "")
5764 ((zerop gnus-tmp-unselected)
5765 (format "{%d more}" gnus-tmp-unread-and-unticked))
5766 (t (format "{%d(+%d) more}"
5767 gnus-tmp-unread-and-unticked
5768 gnus-tmp-unselected))))
5769 (gnus-tmp-subject
5770 (if (and gnus-current-headers
5771 (vectorp gnus-current-headers))
5772 (gnus-mode-string-quote
5773 (mail-header-subject gnus-current-headers))
5774 ""))
5775 bufname-length max-len
23f87bed 5776 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
5777 (setq mode-string (eval mformat))
5778 (setq bufname-length (if (string-match "%b" mode-string)
5779 (- (length
5780 (buffer-name
5781 (if (eq where 'summary)
5782 nil
5783 (get-buffer gnus-article-buffer))))
5784 2)
5785 0))
5786 (setq max-len (max 4 (if gnus-mode-non-string-length
5787 (- (window-width)
5788 gnus-mode-non-string-length
5789 bufname-length)
5790 (length mode-string))))
5791 ;; We might have to chop a bit of the string off...
5792 (when (> (length mode-string) max-len)
5793 (setq mode-string
16409b0b 5794 (concat (truncate-string-to-width mode-string (- max-len 3))
eec82323
LMI
5795 "...")))
5796 ;; Pad the mode string a bit.
5797 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5798 ;; Update the mode line.
5799 (setq mode-line-buffer-identification
5800 (gnus-mode-line-buffer-identification (list mode-string)))
5801 (set-buffer-modified-p t))))
5802
5803(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5804 "Go through the HEADERS list and add all Xrefs to a hash table.
5805The resulting hash table is returned, or nil if no Xrefs were found."
5806 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5807 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5808 (xref-hashtb (gnus-make-hashtable))
5809 start group entry number xrefs header)
5810 (while headers
5811 (setq header (pop headers))
5812 (when (and (setq xrefs (mail-header-xref header))
5813 (not (memq (setq number (mail-header-number header))
5814 unreads)))
5815 (setq start 0)
5816 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5817 (setq start (match-end 0))
5818 (setq group (if prefix
5819 (concat prefix (substring xrefs (match-beginning 1)
5820 (match-end 1)))
5821 (substring xrefs (match-beginning 1) (match-end 1))))
5822 (setq number
e9bd5782 5823 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
5824 (match-end 2))))
5825 (if (setq entry (gnus-gethash group xref-hashtb))
5826 (setcdr entry (cons number (cdr entry)))
5827 (gnus-sethash group (cons number nil) xref-hashtb)))))
5828 (and start xref-hashtb)))
5829
5830(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5831 "Look through all the headers and mark the Xrefs as read."
5832 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5833 name entry info xref-hashtb idlist method nth4)
5834 (save-excursion
5835 (set-buffer gnus-group-buffer)
5836 (when (setq xref-hashtb
5837 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5838 (mapatoms
5839 (lambda (group)
5840 (unless (string= from-newsgroup (setq name (symbol-name group)))
5841 (setq idlist (symbol-value group))
5842 ;; Dead groups are not updated.
5843 (and (prog1
5844 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5845 info (nth 2 entry))
5846 (when (stringp (setq nth4 (gnus-info-method info)))
5847 (setq nth4 (gnus-server-to-method nth4))))
5848 ;; Only do the xrefs if the group has the same
5849 ;; select method as the group we have just read.
5850 (or (gnus-methods-equal-p
5851 nth4 (gnus-find-method-for-group from-newsgroup))
5852 virtual
5853 (equal nth4 (setq method (gnus-find-method-for-group
5854 from-newsgroup)))
5855 (and (equal (car nth4) (car method))
5856 (equal (nth 1 nth4) (nth 1 method))))
5857 gnus-use-cross-reference
5858 (or (not (eq gnus-use-cross-reference t))
5859 virtual
5860 ;; Only do cross-references on subscribed
5861 ;; groups, if that is what is wanted.
5862 (<= (gnus-info-level info) gnus-level-subscribed))
5863 (gnus-group-make-articles-read name idlist))))
5864 xref-hashtb)))))
5865
6748645f
LMI
5866(defun gnus-compute-read-articles (group articles)
5867 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5868 (info (nth 2 entry))
5869 (active (gnus-active group))
5870 ninfo)
5871 (when entry
16409b0b 5872 ;; First peel off all invalid article numbers.
6748645f
LMI
5873 (when active
5874 (let ((ids articles)
5875 id first)
5876 (while (setq id (pop ids))
5877 (when (and first (> id (cdr active)))
5878 ;; We'll end up in this situation in one particular
5879 ;; obscure situation. If you re-scan a group and get
5880 ;; a new article that is cross-posted to a different
5881 ;; group that has not been re-scanned, you might get
5882 ;; crossposted article that has a higher number than
5883 ;; Gnus believes possible. So we re-activate this
5884 ;; group as well. This might mean doing the
5885 ;; crossposting thingy will *increase* the number
5886 ;; of articles in some groups. Tsk, tsk.
5887 (setq active (or (gnus-activate-group group) active)))
5888 (when (or (> id (cdr active))
5889 (< id (car active)))
5890 (setq articles (delq id articles))))))
5891 ;; If the read list is nil, we init it.
5892 (if (and active
5893 (null (gnus-info-read info))
5894 (> (car active) 1))
5895 (setq ninfo (cons 1 (1- (car active))))
5896 (setq ninfo (gnus-info-read info)))
5897 ;; Then we add the read articles to the range.
5898 (gnus-add-to-range
5899 ninfo (setq articles (sort articles '<))))))
5900
eec82323
LMI
5901(defun gnus-group-make-articles-read (group articles)
5902 "Update the info of GROUP to say that ARTICLES are read."
5903 (let* ((num 0)
5904 (entry (gnus-gethash group gnus-newsrc-hashtb))
5905 (info (nth 2 entry))
5906 (active (gnus-active group))
5907 range)
6748645f
LMI
5908 (when entry
5909 (setq range (gnus-compute-read-articles group articles))
5910 (save-excursion
5911 (set-buffer gnus-group-buffer)
5912 (gnus-undo-register
5913 `(progn
5914 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5915 (gnus-info-set-read ',info ',(gnus-info-read info))
5916 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 5917 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
5918 (gnus-group-update-group ,group t))))
5919 ;; Add the read articles to the range.
5920 (gnus-info-set-read info range)
23f87bed 5921 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
5922 ;; Then we have to re-compute how many unread
5923 ;; articles there are in this group.
5924 (when active
5925 (cond
5926 ((not range)
5927 (setq num (- (1+ (cdr active)) (car active))))
5928 ((not (listp (cdr range)))
5929 (setq num (- (cdr active) (- (1+ (cdr range))
5930 (car range)))))
5931 (t
5932 (while range
5933 (if (numberp (car range))
5934 (setq num (1+ num))
5935 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5936 (setq range (cdr range)))
5937 (setq num (- (cdr active) num))))
5938 ;; Update the number of unread articles.
5939 (setcar entry num)
5940 ;; Update the group buffer.
23f87bed
MB
5941 (unless (gnus-ephemeral-group-p group)
5942 (gnus-group-update-group group t))))))
eec82323 5943
eec82323
LMI
5944(defvar gnus-newsgroup-none-id 0)
5945
5946(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5947 (let ((cur nntp-server-buffer)
5948 (dependencies
5949 (or dependencies
5950 (save-excursion (set-buffer gnus-summary-buffer)
5951 gnus-newsgroup-dependencies)))
16409b0b
GM
5952 headers id end ref
5953 (mail-parse-charset gnus-newsgroup-charset)
5954 (mail-parse-ignored-charsets
5955 (save-excursion (condition-case nil
5956 (set-buffer gnus-summary-buffer)
5957 (error))
5958 gnus-newsgroup-ignored-charsets)))
eec82323
LMI
5959 (save-excursion
5960 (set-buffer nntp-server-buffer)
5961 ;; Translate all TAB characters into SPACE characters.
5962 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 5963 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 5964 (ietf-drums-unfold-fws)
6748645f 5965 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 5966 (let ((case-fold-search t)
6748645f 5967 in-reply-to header p lines chars)
eec82323 5968 (goto-char (point-min))
01ccbb85 5969 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
5970 ;; do not begin with 2 or 3.
5971 (while (re-search-forward "^[23][0-9]+ " nil t)
5972 (setq id nil
5973 ref nil)
5974 ;; This implementation of this function, with nine
5975 ;; search-forwards instead of the one re-search-forward and
5976 ;; a case (which basically was the old function) is actually
01ccbb85 5977 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
5978 ;; can't have everything, I guess. Speed and elegance
5979 ;; doesn't always go hand in hand.
5980 (setq
5981 header
5982 (vector
5983 ;; Number.
5984 (prog1
5985 (read cur)
5986 (end-of-line)
5987 (setq p (point))
5988 (narrow-to-region (point)
5989 (or (and (search-forward "\n.\n" nil t)
5990 (- (point) 2))
5991 (point))))
5992 ;; Subject.
5993 (progn
5994 (goto-char p)
23f87bed 5995 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
5996 (funcall gnus-decode-encoded-word-function
5997 (nnheader-header-value))
2bd3dcae 5998 "(none)"))
eec82323
LMI
5999 ;; From.
6000 (progn
6001 (goto-char p)
23f87bed 6002 (if (search-forward "\nfrom:" nil t)
343d6628 6003 (funcall gnus-decode-encoded-address-function
16409b0b 6004 (nnheader-header-value))
2bd3dcae 6005 "(nobody)"))
eec82323
LMI
6006 ;; Date.
6007 (progn
6008 (goto-char p)
23f87bed 6009 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6010 (nnheader-header-value) ""))
6011 ;; Message-ID.
6012 (progn
6013 (goto-char p)
6748645f
LMI
6014 (setq id (if (re-search-forward
6015 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6016 ;; We do it this way to make sure the Message-ID
6017 ;; is (somewhat) syntactically valid.
6018 (buffer-substring (match-beginning 1)
6019 (match-end 1))
eec82323
LMI
6020 ;; If there was no message-id, we just fake one
6021 ;; to make subsequent routines simpler.
6022 (nnheader-generate-fake-message-id))))
6023 ;; References.
6024 (progn
6025 (goto-char p)
23f87bed 6026 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6027 (progn
6028 (setq end (point))
6029 (prog1
6030 (nnheader-header-value)
6031 (setq ref
6032 (buffer-substring
6033 (progn
6034 (end-of-line)
6035 (search-backward ">" end t)
6036 (1+ (point)))
6037 (progn
6038 (search-backward "<" end t)
6039 (point))))))
6040 ;; Get the references from the in-reply-to header if there
6041 ;; were no references and the in-reply-to header looks
6042 ;; promising.
23f87bed 6043 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6044 (setq in-reply-to (nnheader-header-value))
6045 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6046 (let (ref2)
6047 (setq ref (substring in-reply-to (match-beginning 0)
6048 (match-end 0)))
6049 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6050 (setq ref2 (substring in-reply-to (match-beginning 0)
6051 (match-end 0)))
6052 (when (> (length ref2) (length ref))
6053 (setq ref ref2)))
6054 ref)
eec82323
LMI
6055 (setq ref nil))))
6056 ;; Chars.
6748645f
LMI
6057 (progn
6058 (goto-char p)
6059 (if (search-forward "\nchars: " nil t)
6060 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6061 chars -1)
6062 -1))
eec82323
LMI
6063 ;; Lines.
6064 (progn
6065 (goto-char p)
6066 (if (search-forward "\nlines: " nil t)
a8151ef7 6067 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6068 lines -1)
6069 -1))
eec82323
LMI
6070 ;; Xref.
6071 (progn
6072 (goto-char p)
23f87bed 6073 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6074 (nnheader-header-value)))
6075 ;; Extra.
6076 (when gnus-extra-headers
6077 (let ((extra gnus-extra-headers)
6078 out)
6079 (while extra
6080 (goto-char p)
6081 (when (search-forward
23f87bed 6082 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6083 (push (cons (car extra) (nnheader-header-value))
6084 out))
6085 (pop extra))
6086 out))))
eec82323
LMI
6087 (when (equal id ref)
6088 (setq ref nil))
6748645f
LMI
6089
6090 (when gnus-alter-header-function
6091 (funcall gnus-alter-header-function header)
6092 (setq id (mail-header-id header)
6093 ref (gnus-parent-id (mail-header-references header))))
6094
6095 (when (setq header
6096 (gnus-dependencies-add-header
6097 header dependencies force-new))
eec82323
LMI
6098 (push header headers))
6099 (goto-char (point-max))
6100 (widen))
6101 (nreverse headers)))))
6102
eec82323
LMI
6103;; Goes through the xover lines and returns a list of vectors
6104(defun gnus-get-newsgroup-headers-xover (sequence &optional
6105 force-new dependencies
6106 group also-fetch-heads)
16409b0b
GM
6107 "Parse the news overview data in the server buffer.
6108Return a list of headers that match SEQUENCE (see
6109`nntp-retrieve-headers')."
eec82323
LMI
6110 ;; Get the Xref when the users reads the articles since most/some
6111 ;; NNTP servers do not include Xrefs when using XOVER.
6112 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6113 (let ((mail-parse-charset gnus-newsgroup-charset)
6114 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6115 (cur nntp-server-buffer)
eec82323 6116 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6117 (allp (cond
6118 ((eq gnus-read-all-available-headers t)
6119 t)
14e6dc54
MB
6120 ((and (stringp gnus-read-all-available-headers)
6121 group)
23f87bed
MB
6122 (string-match gnus-read-all-available-headers group))
6123 (t
6124 nil)))
eec82323
LMI
6125 number headers header)
6126 (save-excursion
6127 (set-buffer nntp-server-buffer)
16409b0b 6128 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6129 ;; Allow the user to mangle the headers before parsing them.
6748645f 6130 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6131 (goto-char (point-min))
23f87bed
MB
6132 (gnus-parse-without-error
6133 (while (and (or sequence allp)
6134 (not (eobp)))
6135 (setq number (read cur))
6136 (when (not allp)
6137 (while (and sequence
6138 (< (car sequence) number))
6139 (setq sequence (cdr sequence))))
6140 (when (and (or allp
6141 (and sequence
6142 (eq number (car sequence))))
6143 (progn
6144 (setq sequence (cdr sequence))
6145 (setq header (inline
6146 (gnus-nov-parse-line
6147 number dependencies force-new)))))
6148 (push header headers))
6149 (forward-line 1)))
eec82323
LMI
6150 ;; A common bug in inn is that if you have posted an article and
6151 ;; then retrieves the active file, it will answer correctly --
6152 ;; the new article is included. However, a NOV entry for the
6153 ;; article may not have been generated yet, so this may fail.
6154 ;; We work around this problem by retrieving the last few
6155 ;; headers using HEAD.
6156 (if (or (not also-fetch-heads)
6157 (not sequence))
6158 ;; We (probably) got all the headers.
6159 (nreverse headers)
6160 (let ((gnus-nov-is-evil t))
6161 (nconc
6162 (nreverse headers)
23f87bed 6163 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6164 (gnus-get-newsgroup-headers))))))))
6165
6166(defun gnus-article-get-xrefs ()
6167 "Fill in the Xref value in `gnus-current-headers', if necessary.
6168This is meant to be called in `gnus-article-internal-prepare-hook'."
6169 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6170 gnus-current-headers)))
6171 (or (not gnus-use-cross-reference)
6172 (not headers)
6173 (and (mail-header-xref headers)
6174 (not (string= (mail-header-xref headers) "")))
6175 (let ((case-fold-search t)
6176 xref)
6177 (save-restriction
6178 (nnheader-narrow-to-headers)
6179 (goto-char (point-min))
16409b0b
GM
6180 (when (or (and (not (eobp))
6181 (eq (downcase (char-after)) ?x)
eec82323
LMI
6182 (looking-at "Xref:"))
6183 (search-forward "\nXref:" nil t))
6184 (goto-char (1+ (match-end 0)))
23f87bed 6185 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
eec82323
LMI
6186 (mail-header-set-xref headers xref)))))))
6187
6188(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6189 "Find article ID and insert the summary line for that article.
6190OLD-HEADER can either be a header or a line number to insert
6191the subject line on."
6192 (let* ((line (and (numberp old-header) old-header))
6193 (old-header (and (vectorp old-header) old-header))
6194 (header (cond ((and old-header use-old-header)
16409b0b
GM
6195 old-header)
6196 ((and (numberp id)
6197 (gnus-number-to-header id))
6198 (gnus-number-to-header id))
6199 (t
6200 (gnus-read-header id))))
6201 (number (and (numberp id) id))
6202 d)
eec82323
LMI
6203 (when header
6204 ;; Rebuild the thread that this article is part of and go to the
6205 ;; article we have fetched.
6206 (when (and (not gnus-show-threads)
6207 old-header)
6748645f
LMI
6208 (when (and number
6209 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6210 (goto-char (gnus-data-pos d))
6211 (gnus-data-remove
6212 number
6213 (- (gnus-point-at-bol)
6214 (prog1
6215 (1+ (gnus-point-at-eol))
6216 (gnus-delete-line))))))
23f87bed
MB
6217 ;; Remove list identifiers from subject.
6218 (when gnus-list-identifiers
6219 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6220 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6221 (when old-header
6222 (mail-header-set-number header (mail-header-number old-header)))
6223 (setq gnus-newsgroup-sparse
6224 (delq (setq number (mail-header-number header))
6225 gnus-newsgroup-sparse))
6226 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6227 (push number gnus-newsgroup-limit)
6228 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6229 (gnus-summary-goto-subject number nil t))
6230 (when (and (numberp number)
6231 (> number 0))
6232 ;; We have to update the boundaries even if we can't fetch the
6233 ;; article if ID is a number -- so that the next `P' or `N'
6234 ;; command will fetch the previous (or next) article even
6235 ;; if the one we tried to fetch this time has been canceled.
6236 (when (> number gnus-newsgroup-end)
6237 (setq gnus-newsgroup-end number))
6238 (when (< number gnus-newsgroup-begin)
6239 (setq gnus-newsgroup-begin number))
6240 (setq gnus-newsgroup-unselected
6241 (delq number gnus-newsgroup-unselected)))
6242 ;; Report back a success?
6243 (and header (mail-header-number header))))
6244
6245;;; Process/prefix in the summary buffer
6246
6247(defun gnus-summary-work-articles (n)
6748645f
LMI
6248 "Return a list of articles to be worked upon.
6249The prefix argument, the list of process marked articles, and the
6250current article will be taken into consideration."
6251 (save-excursion
6252 (set-buffer gnus-summary-buffer)
6253 (cond
6254 (n
6255 ;; A numerical prefix has been given.
6256 (setq n (prefix-numeric-value n))
6257 (let ((backward (< n 0))
6258 (n (abs (prefix-numeric-value n)))
6259 articles article)
6260 (save-excursion
6261 (while
6262 (and (> n 0)
6263 (push (setq article (gnus-summary-article-number))
6264 articles)
6265 (if backward
6266 (gnus-summary-find-prev nil article)
6267 (gnus-summary-find-next nil article)))
6268 (decf n)))
6269 (nreverse articles)))
6270 ((and (gnus-region-active-p) (mark))
6271 (message "region active")
6272 ;; Work on the region between point and mark.
6273 (let ((max (max (point) (mark)))
6274 articles article)
6275 (save-excursion
7dafe00b 6276 (goto-char (min (point) (mark)))
6748645f
LMI
6277 (while
6278 (and
6279 (push (setq article (gnus-summary-article-number)) articles)
6280 (gnus-summary-find-next nil article)
6281 (< (point) max)))
6282 (nreverse articles))))
6283 (gnus-newsgroup-processable
6284 ;; There are process-marked articles present.
6285 ;; Save current state.
6286 (gnus-summary-save-process-mark)
6287 ;; Return the list.
6288 (reverse gnus-newsgroup-processable))
6289 (t
6290 ;; Just return the current article.
6291 (list (gnus-summary-article-number))))))
6292
6293(defmacro gnus-summary-iterate (arg &rest forms)
6294 "Iterate over the process/prefixed articles and do FORMS.
6295ARG is the interactive prefix given to the command. FORMS will be
6296executed with point over the summary line of the articles."
6297 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6298 `(let ((,articles (gnus-summary-work-articles ,arg)))
6299 (while ,articles
6300 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6301 ,@forms
6302 (pop ,articles)))))
6748645f
LMI
6303
6304(put 'gnus-summary-iterate 'lisp-indent-function 1)
6305(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6306
6307(defun gnus-summary-save-process-mark ()
6308 "Push the current set of process marked articles on the stack."
6309 (interactive)
6310 (push (copy-sequence gnus-newsgroup-processable)
6311 gnus-newsgroup-process-stack))
6312
6313(defun gnus-summary-kill-process-mark ()
6314 "Push the current set of process marked articles on the stack and unmark."
6315 (interactive)
6316 (gnus-summary-save-process-mark)
6317 (gnus-summary-unmark-all-processable))
6318
6319(defun gnus-summary-yank-process-mark ()
6320 "Pop the last process mark state off the stack and restore it."
6321 (interactive)
6322 (unless gnus-newsgroup-process-stack
6323 (error "Empty mark stack"))
6324 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6325
6326(defun gnus-summary-process-mark-set (set)
6327 "Make SET into the current process marked articles."
6328 (gnus-summary-unmark-all-processable)
6329 (while set
6330 (gnus-summary-set-process-mark (pop set))))
6331
6332;;; Searching and stuff
6333
6334(defun gnus-summary-search-group (&optional backward use-level)
6335 "Search for next unread newsgroup.
6336If optional argument BACKWARD is non-nil, search backward instead."
6337 (save-excursion
6338 (set-buffer gnus-group-buffer)
6339 (when (gnus-group-search-forward
6340 backward nil (if use-level (gnus-group-group-level) nil))
6341 (gnus-group-group-name))))
6342
6343(defun gnus-summary-best-group (&optional exclude-group)
6344 "Find the name of the best unread group.
6345If EXCLUDE-GROUP, do not go to this group."
6346 (save-excursion
6347 (set-buffer gnus-group-buffer)
6348 (save-excursion
6349 (gnus-group-best-unread-group exclude-group))))
6350
23f87bed
MB
6351(defun gnus-summary-find-next (&optional unread article backward)
6352 (if backward
6353 (gnus-summary-find-prev unread article)
eec82323
LMI
6354 (let* ((dummy (gnus-summary-article-intangible-p))
6355 (article (or article (gnus-summary-article-number)))
23f87bed 6356 (data (gnus-data-find-list article))
eec82323
LMI
6357 result)
6358 (when (and (not dummy)
6359 (or (not gnus-summary-check-current)
6360 (not unread)
23f87bed
MB
6361 (not (gnus-data-unread-p (car data)))))
6362 (setq data (cdr data)))
eec82323
LMI
6363 (when (setq result
6364 (if unread
6365 (progn
23f87bed
MB
6366 (while data
6367 (unless (memq (gnus-data-number (car data))
6368 (cond
6369 ((eq gnus-auto-goto-ignores
6370 'always-undownloaded)
6371 gnus-newsgroup-undownloaded)
6372 (gnus-plugged
6373 nil)
6374 ((eq gnus-auto-goto-ignores
6375 'unfetched)
6376 gnus-newsgroup-unfetched)
6377 ((eq gnus-auto-goto-ignores
6378 'undownloaded)
6379 gnus-newsgroup-undownloaded)))
6380 (when (gnus-data-unread-p (car data))
6381 (setq result (car data)
6382 data nil)))
6383 (setq data (cdr data)))
eec82323 6384 result)
23f87bed 6385 (car data)))
eec82323
LMI
6386 (goto-char (gnus-data-pos result))
6387 (gnus-data-number result)))))
6388
6389(defun gnus-summary-find-prev (&optional unread article)
6390 (let* ((eobp (eobp))
6391 (article (or article (gnus-summary-article-number)))
23f87bed 6392 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6393 result)
6394 (when (and (not eobp)
6395 (or (not gnus-summary-check-current)
6396 (not unread)
23f87bed
MB
6397 (not (gnus-data-unread-p (car data)))))
6398 (setq data (cdr data)))
eec82323
LMI
6399 (when (setq result
6400 (if unread
6401 (progn
23f87bed
MB
6402 (while data
6403 (unless (memq (gnus-data-number (car data))
6404 (cond
6405 ((eq gnus-auto-goto-ignores
6406 'always-undownloaded)
6407 gnus-newsgroup-undownloaded)
6408 (gnus-plugged
6409 nil)
6410 ((eq gnus-auto-goto-ignores
6411 'unfetched)
6412 gnus-newsgroup-unfetched)
6413 ((eq gnus-auto-goto-ignores
6414 'undownloaded)
6415 gnus-newsgroup-undownloaded)))
6416 (when (gnus-data-unread-p (car data))
6417 (setq result (car data)
6418 data nil)))
6419 (setq data (cdr data)))
eec82323 6420 result)
23f87bed 6421 (car data)))
eec82323
LMI
6422 (goto-char (gnus-data-pos result))
6423 (gnus-data-number result))))
6424
6425(defun gnus-summary-find-subject (subject &optional unread backward article)
6426 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6427 (article (or article (gnus-summary-article-number)))
6428 (articles (gnus-data-list backward))
6429 (arts (gnus-data-find-list article articles))
6430 result)
6431 (when (or (not gnus-summary-check-current)
6432 (not unread)
6433 (not (gnus-data-unread-p (car arts))))
6434 (setq arts (cdr arts)))
6435 (while arts
6436 (and (or (not unread)
6437 (gnus-data-unread-p (car arts)))
6438 (vectorp (gnus-data-header (car arts)))
6439 (gnus-subject-equal
6440 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6441 (setq result (car arts)
6442 arts nil))
6443 (setq arts (cdr arts)))
6444 (and result
6445 (goto-char (gnus-data-pos result))
6446 (gnus-data-number result))))
6447
6448(defun gnus-summary-search-forward (&optional unread subject backward)
6449 "Search forward for an article.
6450If UNREAD, look for unread articles. If SUBJECT, look for
6451articles with that subject. If BACKWARD, search backward instead."
6452 (cond (subject (gnus-summary-find-subject subject unread backward))
6453 (backward (gnus-summary-find-prev unread))
6454 (t (gnus-summary-find-next unread))))
6455
6456(defun gnus-recenter (&optional n)
6457 "Center point in window and redisplay frame.
6458Also do horizontal recentering."
6459 (interactive "P")
6460 (when (and gnus-auto-center-summary
6461 (not (eq gnus-auto-center-summary 'vertical)))
6462 (gnus-horizontal-recenter))
6463 (recenter n))
6464
6465(defun gnus-summary-recenter ()
6466 "Center point in the summary window.
6467If `gnus-auto-center-summary' is nil, or the article buffer isn't
6468displayed, no centering will be performed."
6469 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6470 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6471 (interactive)
23f87bed
MB
6472 ;; The user has to want it.
6473 (when gnus-auto-center-summary
6474 (let* ((top (cond ((< (window-height) 4) 0)
6475 ((< (window-height) 7) 1)
6476 (t (if (numberp gnus-auto-center-summary)
6477 gnus-auto-center-summary
6478 2))))
6479 (height (1- (window-height)))
6480 (bottom (save-excursion (goto-char (point-max))
6481 (forward-line (- height))
6482 (point)))
6483 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6484 (when (get-buffer-window gnus-article-buffer)
6485 ;; Only do recentering when the article buffer is displayed,
6486 ;; Set the window start to either `bottom', which is the biggest
6487 ;; possible valid number, or the second line from the top,
6488 ;; whichever is the least.
db7ebd73
MB
6489 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6490 (if (> bottom top-pos)
6491 ;; Keep the second line from the top visible
6492 (set-window-start window top-pos t)
6493 ;; Try to keep the bottom line visible; if it's partially
6494 ;; obscured, either scroll one more line to make it fully
6495 ;; visible, or revert to using TOP-POS.
6496 (save-excursion
6497 (goto-char (point-max))
6498 (forward-line -1)
6499 (let ((last-line-start (point)))
6500 (goto-char bottom)
6501 (set-window-start window (point) t)
6502 (when (not (pos-visible-in-window-p last-line-start window))
6503 (forward-line 1)
6504 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6505 ;; Do horizontal recentering while we're at it.
6506 (when (and (get-buffer-window (current-buffer) t)
6507 (not (eq gnus-auto-center-summary 'vertical)))
6508 (let ((selected (selected-window)))
6509 (select-window (get-buffer-window (current-buffer) t))
6510 (gnus-summary-position-point)
6511 (gnus-horizontal-recenter)
6512 (select-window selected))))))
6513
6514(defun gnus-summary-jump-to-group (newsgroup)
6515 "Move point to NEWSGROUP in group mode buffer."
6516 ;; Keep update point of group mode buffer if visible.
6517 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6518 (save-window-excursion
6519 ;; Take care of tree window mode.
6520 (when (get-buffer-window gnus-group-buffer)
6521 (pop-to-buffer gnus-group-buffer))
6522 (gnus-group-jump-to-group newsgroup))
6523 (save-excursion
6524 ;; Take care of tree window mode.
6525 (if (get-buffer-window gnus-group-buffer)
6526 (pop-to-buffer gnus-group-buffer)
6527 (set-buffer gnus-group-buffer))
6528 (gnus-group-jump-to-group newsgroup))))
6529
6530;; This function returns a list of article numbers based on the
6531;; difference between the ranges of read articles in this group and
6532;; the range of active articles.
6533(defun gnus-list-of-unread-articles (group)
6534 (let* ((read (gnus-info-read (gnus-get-info group)))
6535 (active (or (gnus-active group) (gnus-activate-group group)))
6536 (last (cdr active))
6537 first nlast unread)
6538 ;; If none are read, then all are unread.
6539 (if (not read)
6540 (setq first (car active))
6541 ;; If the range of read articles is a single range, then the
6542 ;; first unread article is the article after the last read
6543 ;; article. Sounds logical, doesn't it?
16409b0b
GM
6544 (if (and (not (listp (cdr read)))
6545 (or (< (car read) (car active))
6546 (progn (setq read (list read))
6547 nil)))
6748645f 6548 (setq first (max (car active) (1+ (cdr read))))
eec82323
LMI
6549 ;; `read' is a list of ranges.
6550 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6551 (caar read)))
6552 1)
6748645f 6553 (setq first (car active)))
eec82323
LMI
6554 (while read
6555 (when first
6556 (while (< first nlast)
54506618
MB
6557 (setq unread (cons first unread)
6558 first (1+ first))))
eec82323
LMI
6559 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6560 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6561 (setq read (cdr read)))))
6562 ;; And add the last unread articles.
6563 (while (<= first last)
54506618
MB
6564 (setq unread (cons first unread)
6565 first (1+ first)))
eec82323 6566 ;; Return the list of unread articles.
6748645f 6567 (delq 0 (nreverse unread))))
eec82323
LMI
6568
6569(defun gnus-list-of-read-articles (group)
6570 "Return a list of unread, unticked and non-dormant articles."
6571 (let* ((info (gnus-get-info group))
6572 (marked (gnus-info-marks info))
6573 (active (gnus-active group)))
6574 (and info active
23f87bed
MB
6575 (gnus-list-range-difference
6576 (gnus-list-range-difference
6577 (gnus-sorted-complement
6578 (gnus-uncompress-range active)
6579 (gnus-list-of-unread-articles group))
6580 (cdr (assq 'dormant marked)))
6581 (cdr (assq 'tick marked))))))
eec82323 6582
54506618
MB
6583;; This function returns a sequence of article numbers based on the
6584;; difference between the ranges of read articles in this group and
6585;; the range of active articles.
6586(defun gnus-sequence-of-unread-articles (group)
6587 (let* ((read (gnus-info-read (gnus-get-info group)))
6588 (active (or (gnus-active group) (gnus-activate-group group)))
6589 (last (cdr active))
6590 first nlast unread)
6591 ;; If none are read, then all are unread.
6592 (if (not read)
6593 (setq first (car active))
6594 ;; If the range of read articles is a single range, then the
6595 ;; first unread article is the article after the last read
6596 ;; article. Sounds logical, doesn't it?
6597 (if (and (not (listp (cdr read)))
6598 (or (< (car read) (car active))
6599 (progn (setq read (list read))
6600 nil)))
6601 (setq first (max (car active) (1+ (cdr read))))
6602 ;; `read' is a list of ranges.
6603 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6604 (caar read)))
6605 1)
6606 (setq first (car active)))
6607 (while read
6608 (when first
6609 (push (cons first nlast) unread))
6610 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6611 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6612 (setq read (cdr read)))))
6613 ;; And add the last unread articles.
ba0226dd
MB
6614 (cond ((not (and first last))
6615 nil)
6616 ((< first last)
6617 (push (cons first last) unread))
6618 ((= first last)
6619 (push first unread)))
54506618
MB
6620 ;; Return the sequence of unread articles.
6621 (delq 0 (nreverse unread))))
6622
eec82323
LMI
6623;; Various summary commands
6624
6748645f
LMI
6625(defun gnus-summary-select-article-buffer ()
6626 "Reconfigure windows to show article buffer."
6627 (interactive)
6628 (if (not (gnus-buffer-live-p gnus-article-buffer))
6629 (error "There is no article buffer for this summary buffer")
6630 (gnus-configure-windows 'article)
6631 (select-window (get-buffer-window gnus-article-buffer))))
6632
eec82323
LMI
6633(defun gnus-summary-universal-argument (arg)
6634 "Perform any operation on all articles that are process/prefixed."
6635 (interactive "P")
eec82323
LMI
6636 (let ((articles (gnus-summary-work-articles arg))
6637 func article)
6638 (if (eq
6639 (setq
6640 func
6641 (key-binding
6642 (read-key-sequence
6643 (substitute-command-keys
16409b0b 6644 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
6645 'undefined)
6646 (gnus-error 1 "Undefined key")
6647 (save-excursion
6648 (while articles
6649 (gnus-summary-goto-subject (setq article (pop articles)))
6650 (let (gnus-newsgroup-processable)
6651 (command-execute func))
6652 (gnus-summary-remove-process-mark article)))))
6653 (gnus-summary-position-point))
6654
6655(defun gnus-summary-toggle-truncation (&optional arg)
6656 "Toggle truncation of summary lines.
23f87bed 6657With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
6658 (interactive "P")
6659 (setq truncate-lines
6660 (if (null arg) (not truncate-lines)
6661 (> (prefix-numeric-value arg) 0)))
6662 (redraw-display))
6663
23f87bed
MB
6664(defun gnus-summary-find-for-reselect ()
6665 "Return the number of an article to stay on across a reselect.
6666The current article is considered, then following articles, then previous
6667articles. An article is sought which is not cancelled and isn't a temporary
6668insertion from another group. If there's no such then return a dummy 0."
6669 (let (found)
6670 (dolist (rev '(nil t))
6671 (unless found ; don't demand the reverse list if we don't need it
6672 (let ((data (gnus-data-find-list
6673 (gnus-summary-article-number) (gnus-data-list rev))))
6674 (while (and data (not found))
6675 (if (and (< 0 (gnus-data-number (car data)))
6676 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6677 (setq found (gnus-data-number (car data))))
6678 (setq data (cdr data))))))
6679 (or found 0)))
6680
eec82323
LMI
6681(defun gnus-summary-reselect-current-group (&optional all rescan)
6682 "Exit and then reselect the current newsgroup.
6683The prefix argument ALL means to select all articles."
6684 (interactive "P")
eec82323
LMI
6685 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6686 (error "Ephemeral groups can't be reselected"))
23f87bed 6687 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
6688 (group gnus-newsgroup-name))
6689 (setq gnus-newsgroup-begin nil)
23f87bed 6690 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
6691 ;; We have to adjust the point of group mode buffer because
6692 ;; point was moved to the next unread newsgroup by exiting.
6693 (gnus-summary-jump-to-group group)
6694 (when rescan
6695 (save-excursion
6696 (gnus-group-get-new-news-this-group 1)))
6697 (gnus-group-read-group all t)
6698 (gnus-summary-goto-subject current-subject nil t)))
6699
6700(defun gnus-summary-rescan-group (&optional all)
6701 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6702 (interactive "P")
6703 (gnus-summary-reselect-current-group all t))
6704
6705(defun gnus-summary-update-info (&optional non-destructive)
6706 (save-excursion
6707 (let ((group gnus-newsgroup-name))
6748645f
LMI
6708 (when group
6709 (when gnus-newsgroup-kill-headers
6710 (setq gnus-newsgroup-killed
6711 (gnus-compress-sequence
23f87bed
MB
6712 (gnus-sorted-union
6713 (gnus-list-range-intersection
6714 gnus-newsgroup-unselected gnus-newsgroup-killed)
6715 gnus-newsgroup-unreads)
6748645f
LMI
6716 t)))
6717 (unless (listp (cdr gnus-newsgroup-killed))
6718 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6719 (let ((headers gnus-newsgroup-headers))
6720 ;; Set the new ranges of read articles.
6721 (save-excursion
6722 (set-buffer gnus-group-buffer)
6723 (gnus-undo-force-boundary))
6724 (gnus-update-read-articles
23f87bed
MB
6725 group (gnus-sorted-union
6726 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
6727 ;; Set the current article marks.
6728 (let ((gnus-newsgroup-scored
6729 (if (and (not gnus-save-score)
6730 (not non-destructive))
6731 nil
6732 gnus-newsgroup-scored)))
6733 (save-excursion
6734 (gnus-update-marks)))
6735 ;; Do the cross-ref thing.
6736 (when gnus-use-cross-reference
6737 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6738 ;; Do not switch windows but change the buffer to work.
a8151ef7 6739 (set-buffer gnus-group-buffer)
6748645f
LMI
6740 (unless (gnus-ephemeral-group-p group)
6741 (gnus-group-update-group group)))))))
eec82323
LMI
6742
6743(defun gnus-summary-save-newsrc (&optional force)
6744 "Save the current number of read/marked articles in the dribble buffer.
6745The dribble buffer will then be saved.
6746If FORCE (the prefix), also save the .newsrc file(s)."
6747 (interactive "P")
6748 (gnus-summary-update-info t)
6749 (if force
6750 (gnus-save-newsrc-file)
6751 (gnus-dribble-save)))
6752
23f87bed 6753(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 6754 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 6755`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
6756 (interactive)
6757 (gnus-set-global-variables)
16409b0b
GM
6758 (when (gnus-buffer-live-p gnus-article-buffer)
6759 (save-excursion
6760 (set-buffer gnus-article-buffer)
6761 (mm-destroy-parts gnus-article-mime-handles)
6762 ;; Set it to nil for safety reason.
6763 (setq gnus-article-mime-handle-alist nil)
6764 (setq gnus-article-mime-handles nil)))
eec82323 6765 (gnus-kill-save-kill-buffer)
6748645f 6766 (gnus-async-halt-prefetch)
eec82323
LMI
6767 (let* ((group gnus-newsgroup-name)
6768 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 6769 (gnus-group-is-exiting-p t)
eec82323 6770 (mode major-mode)
23f87bed 6771 (group-point nil)
eec82323 6772 (buf (current-buffer)))
16409b0b
GM
6773 (unless quit-config
6774 ;; Do adaptive scoring, and possibly save score files.
6775 (when gnus-newsgroup-adaptive
6776 (gnus-score-adaptive))
6777 (when gnus-use-scoring
6778 (gnus-score-save)))
6748645f 6779 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
6780 ;; If we have several article buffers, we kill them at exit.
6781 (unless gnus-single-article-buffer
6782 (gnus-kill-buffer gnus-original-article-buffer)
6783 (setq gnus-article-current nil))
6784 (when gnus-use-cache
6785 (gnus-cache-possibly-remove-articles)
6786 (gnus-cache-save-buffers))
6787 (gnus-async-prefetch-remove-group group)
6788 (when gnus-suppress-duplicates
6789 (gnus-dup-enter-articles))
6790 (when gnus-use-trees
6791 (gnus-tree-close group))
16409b0b
GM
6792 (when gnus-use-cache
6793 (gnus-cache-write-active))
6748645f
LMI
6794 ;; Remove entries for this group.
6795 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
6796 ;; Make all changes in this group permanent.
6797 (unless quit-config
6748645f 6798 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 6799 (gnus-summary-update-info))
eec82323
LMI
6800 (gnus-close-group group)
6801 ;; Make sure where we were, and go to next newsgroup.
6802 (set-buffer gnus-group-buffer)
6803 (unless quit-config
6804 (gnus-group-jump-to-group group))
6748645f
LMI
6805 (gnus-run-hooks 'gnus-summary-exit-hook)
6806 (unless (or quit-config
6807 ;; If this group has disappeared from the summary
6808 ;; buffer, don't skip forwards.
6809 (not (string= group (gnus-group-group-name))))
eec82323 6810 (gnus-group-next-unread-group 1))
a8151ef7 6811 (setq group-point (point))
eec82323
LMI
6812 (if temporary
6813 nil ;Nothing to do.
6814 ;; If we have several article buffers, we kill them at exit.
6815 (unless gnus-single-article-buffer
6816 (gnus-kill-buffer gnus-article-buffer)
6817 (gnus-kill-buffer gnus-original-article-buffer)
6818 (setq gnus-article-current nil))
6819 (set-buffer buf)
6820 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
6821 (progn
6822 (gnus-deaden-summary)
6823 (setq mode nil))
eec82323
LMI
6824 ;; We set all buffer-local variables to nil. It is unclear why
6825 ;; this is needed, but if we don't, buffer-local variables are
6826 ;; not garbage-collected, it seems. This would the lead to en
6827 ;; ever-growing Emacs.
6828 (gnus-summary-clear-local-variables)
23f87bed
MB
6829 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6830 (gnus-summary-clear-local-variables))
eec82323
LMI
6831 (when (get-buffer gnus-article-buffer)
6832 (bury-buffer gnus-article-buffer))
6833 ;; We clear the global counterparts of the buffer-local
6834 ;; variables as well, just to be on the safe side.
6835 (set-buffer gnus-group-buffer)
6836 (gnus-summary-clear-local-variables)
23f87bed
MB
6837 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6838 (gnus-summary-clear-local-variables))
eec82323
LMI
6839 ;; Return to group mode buffer.
6840 (when (eq mode 'gnus-summary-mode)
6841 (gnus-kill-buffer buf)))
6842 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
6843 (set-buffer gnus-group-buffer)
6844 (if quit-config
6845 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
6846 (goto-char group-point)
6847 ;; If gnus-group-buffer is already displayed, make sure we also move
6848 ;; the cursor in the window that displays it.
6849 (let ((win (get-buffer-window (current-buffer) 0)))
6850 (if win (set-window-point win (point))))
d61c212b 6851 (unless leave-hidden
4e90f2b9 6852 (gnus-configure-windows 'group 'force)))
6748645f 6853 ;; Clear the current group name.
eec82323
LMI
6854 (unless quit-config
6855 (setq gnus-newsgroup-name nil)))))
6856
6857(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6858(defun gnus-summary-exit-no-update (&optional no-questions)
6859 "Quit reading current newsgroup without updating read article info."
6860 (interactive)
eec82323 6861 (let* ((group gnus-newsgroup-name)
23f87bed
MB
6862 (gnus-group-is-exiting-p t)
6863 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
6864 (quit-config (gnus-group-quit-config group)))
6865 (when (or no-questions
6866 gnus-expert-user
6867 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 6868 (gnus-async-halt-prefetch)
23f87bed 6869 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b
GM
6870 (when (gnus-buffer-live-p gnus-article-buffer)
6871 (save-excursion
6872 (set-buffer gnus-article-buffer)
6873 (mm-destroy-parts gnus-article-mime-handles)
6874 ;; Set it to nil for safety reason.
6875 (setq gnus-article-mime-handle-alist nil)
6876 (setq gnus-article-mime-handles nil)))
eec82323
LMI
6877 ;; If we have several article buffers, we kill them at exit.
6878 (unless gnus-single-article-buffer
6879 (gnus-kill-buffer gnus-article-buffer)
6880 (gnus-kill-buffer gnus-original-article-buffer)
6881 (setq gnus-article-current nil))
6882 (if (not gnus-kill-summary-on-exit)
6883 (gnus-deaden-summary)
6884 (gnus-close-group group)
6885 (gnus-summary-clear-local-variables)
23f87bed
MB
6886 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6887 (gnus-summary-clear-local-variables))
eec82323
LMI
6888 (set-buffer gnus-group-buffer)
6889 (gnus-summary-clear-local-variables)
23f87bed
MB
6890 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6891 (gnus-summary-clear-local-variables))
6892 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
6893 (unless gnus-single-article-buffer
6894 (setq gnus-article-current nil))
6895 (when gnus-use-trees
6896 (gnus-tree-close group))
6897 (gnus-async-prefetch-remove-group group)
6898 (when (get-buffer gnus-article-buffer)
6899 (bury-buffer gnus-article-buffer))
6900 ;; Return to the group buffer.
6901 (gnus-configure-windows 'group 'force)
6902 ;; Clear the current group name.
6903 (setq gnus-newsgroup-name nil)
23f87bed
MB
6904 (unless (gnus-ephemeral-group-p group)
6905 (gnus-group-update-group group))
eec82323
LMI
6906 (when (equal (gnus-group-group-name) group)
6907 (gnus-group-next-unread-group 1))
6908 (when quit-config
23f87bed 6909 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
6910
6911(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
6912 "Handle movement when leaving an ephemeral group.
6913The state which existed when entering the ephemeral is reset."
eec82323
LMI
6914 (if (not (buffer-name (car quit-config)))
6915 (gnus-configure-windows 'group 'force)
6916 (set-buffer (car quit-config))
6917 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
6918 (gnus-set-global-variables))
6919 ((eq major-mode 'gnus-article-mode)
6920 (save-excursion
6921 ;; The `gnus-summary-buffer' variable may point
6922 ;; to the old summary buffer when using a single
6923 ;; article buffer.
6924 (unless (gnus-buffer-live-p gnus-summary-buffer)
6925 (set-buffer gnus-group-buffer))
6926 (set-buffer gnus-summary-buffer)
6927 (gnus-set-global-variables))))
eec82323 6928 (if (or (eq (cdr quit-config) 'article)
23f87bed
MB
6929 (eq (cdr quit-config) 'pick))
6930 (progn
6931 ;; The current article may be from the ephemeral group
6932 ;; thus it is best that we reload this article
6933 ;;
6934 ;; If we're exiting from a large digest, this can be
6935 ;; extremely slow. So, it's better not to reload it. -- jh.
6936 ;;(gnus-summary-show-article)
6937 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6938 (gnus-configure-windows 'pick 'force)
6939 (gnus-configure-windows (cdr quit-config) 'force)))
eec82323
LMI
6940 (gnus-configure-windows (cdr quit-config) 'force))
6941 (when (eq major-mode 'gnus-summary-mode)
6942 (gnus-summary-next-subject 1 nil t)
6943 (gnus-summary-recenter)
6944 (gnus-summary-position-point))))
6945
6946;;; Dead summaries.
6947
6948(defvar gnus-dead-summary-mode-map nil)
6949
6950(unless gnus-dead-summary-mode-map
6951 (setq gnus-dead-summary-mode-map (make-keymap))
6952 (suppress-keymap gnus-dead-summary-mode-map)
6953 (substitute-key-definition
6954 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
23f87bed
MB
6955 (dolist (key '("\C-d" "\r" "\177" [delete]))
6956 (define-key gnus-dead-summary-mode-map
6957 key 'gnus-summary-wake-up-the-dead))
6958 (dolist (key '("q" "Q"))
6959 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
eec82323
LMI
6960
6961(defvar gnus-dead-summary-mode nil
6962 "Minor mode for Gnus summary buffers.")
6963
6964(defun gnus-dead-summary-mode (&optional arg)
6965 "Minor mode for Gnus summary buffers."
6966 (interactive "P")
6967 (when (eq major-mode 'gnus-summary-mode)
6968 (make-local-variable 'gnus-dead-summary-mode)
6969 (setq gnus-dead-summary-mode
6970 (if (null arg) (not gnus-dead-summary-mode)
6971 (> (prefix-numeric-value arg) 0)))
6972 (when gnus-dead-summary-mode
a8151ef7
LMI
6973 (gnus-add-minor-mode
6974 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
eec82323
LMI
6975
6976(defun gnus-deaden-summary ()
6977 "Make the current summary buffer into a dead summary buffer."
6978 ;; Kill any previous dead summary buffer.
6979 (when (and gnus-dead-summary
6980 (buffer-name gnus-dead-summary))
6981 (save-excursion
6982 (set-buffer gnus-dead-summary)
6983 (when gnus-dead-summary-mode
6984 (kill-buffer (current-buffer)))))
6985 ;; Make this the current dead summary.
6986 (setq gnus-dead-summary (current-buffer))
6987 (gnus-dead-summary-mode 1)
6988 (let ((name (buffer-name)))
6989 (when (string-match "Summary" name)
6990 (rename-buffer
6991 (concat (substring name 0 (match-beginning 0)) "Dead "
6992 (substring name (match-beginning 0)))
16409b0b
GM
6993 t)
6994 (bury-buffer))))
eec82323
LMI
6995
6996(defun gnus-kill-or-deaden-summary (buffer)
6997 "Kill or deaden the summary BUFFER."
6748645f
LMI
6998 (save-excursion
6999 (when (and (buffer-name buffer)
7000 (not gnus-single-article-buffer))
7001 (save-excursion
7002 (set-buffer buffer)
7003 (gnus-kill-buffer gnus-article-buffer)
7004 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
7005 (cond
7006 ;; Kill the buffer.
7007 (gnus-kill-summary-on-exit
7008 (when (and gnus-use-trees
7009 (gnus-buffer-exists-p buffer))
7010 (save-excursion
7011 (set-buffer buffer)
7012 (gnus-tree-close gnus-newsgroup-name)))
7013 (gnus-kill-buffer buffer))
7014 ;; Deaden the buffer.
7015 ((gnus-buffer-exists-p buffer)
7016 (save-excursion
7017 (set-buffer buffer)
7018 (gnus-deaden-summary))))))
eec82323
LMI
7019
7020(defun gnus-summary-wake-up-the-dead (&rest args)
7021 "Wake up the dead summary buffer."
7022 (interactive)
7023 (gnus-dead-summary-mode -1)
7024 (let ((name (buffer-name)))
7025 (when (string-match "Dead " name)
7026 (rename-buffer
7027 (concat (substring name 0 (match-beginning 0))
7028 (substring name (match-end 0)))
7029 t)))
7030 (gnus-message 3 "This dead summary is now alive again"))
7031
7032;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7033(defun gnus-summary-fetch-faq (&optional faq-dir)
7034 "Fetch the FAQ for the current group.
7035If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7036in."
7037 (interactive
7038 (list
7039 (when current-prefix-arg
7040 (completing-read
8f688cb0 7041 "FAQ dir: " (and (listp gnus-group-faq-directory)
a8151ef7
LMI
7042 (mapcar (lambda (file) (list file))
7043 gnus-group-faq-directory))))))
eec82323
LMI
7044 (let (gnus-faq-buffer)
7045 (when (setq gnus-faq-buffer
7046 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7047 (gnus-configure-windows 'summary-faq))))
7048
7049;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7050(defun gnus-summary-describe-group (&optional force)
7051 "Describe the current newsgroup."
7052 (interactive "P")
7053 (gnus-group-describe-group force gnus-newsgroup-name))
7054
7055(defun gnus-summary-describe-briefly ()
7056 "Describe summary mode commands briefly."
7057 (interactive)
16409b0b 7058 (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
7059
7060;; Walking around group mode buffer from summary mode.
7061
7062(defun gnus-summary-next-group (&optional no-article target-group backward)
7063 "Exit current newsgroup and then select next unread newsgroup.
7064If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7065initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7066previous group instead."
7067 (interactive "P")
eec82323
LMI
7068 ;; Stop pre-fetching.
7069 (gnus-async-halt-prefetch)
7070 (let ((current-group gnus-newsgroup-name)
7071 (current-buffer (current-buffer))
7072 entered)
7073 ;; First we semi-exit this group to update Xrefs and all variables.
7074 ;; We can't do a real exit, because the window conf must remain
7075 ;; the same in case the user is prompted for info, and we don't
7076 ;; want the window conf to change before that...
7077 (gnus-summary-exit t)
7078 (while (not entered)
7079 ;; Then we find what group we are supposed to enter.
7080 (set-buffer gnus-group-buffer)
7081 (gnus-group-jump-to-group current-group)
7082 (setq target-group
7083 (or target-group
7084 (if (eq gnus-keep-same-level 'best)
7085 (gnus-summary-best-group gnus-newsgroup-name)
7086 (gnus-summary-search-group backward gnus-keep-same-level))))
7087 (if (not target-group)
7088 ;; There are no further groups, so we return to the group
7089 ;; buffer.
7090 (progn
7091 (gnus-message 5 "Returning to the group buffer")
7092 (setq entered t)
7093 (when (gnus-buffer-live-p current-buffer)
7094 (set-buffer current-buffer)
7095 (gnus-summary-exit))
6748645f 7096 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7097 ;; We try to enter the target group.
7098 (gnus-group-jump-to-group target-group)
7099 (let ((unreads (gnus-group-group-unread)))
7100 (if (and (or (eq t unreads)
7101 (and unreads (not (zerop unreads))))
23f87bed
MB
7102 (gnus-summary-read-group
7103 target-group nil no-article
7104 (and (buffer-name current-buffer) current-buffer)
7105 nil backward))
eec82323
LMI
7106 (setq entered t)
7107 (setq current-group target-group
7108 target-group nil)))))))
7109
7110(defun gnus-summary-prev-group (&optional no-article)
7111 "Exit current newsgroup and then select previous unread newsgroup.
7112If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7113 (interactive "P")
7114 (gnus-summary-next-group no-article nil t))
7115
7116;; Walking around summary lines.
7117
23f87bed
MB
7118(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7119 "Go to the first subject satisfying any non-nil constraint.
7120If UNREAD is non-nil, the article should be unread.
7121If UNDOWNLOADED is non-nil, the article should be undownloaded.
7122If UNSEEN is non-nil, the article should be unseen.
7123Returns the article selected or nil if there are no matching articles."
eec82323 7124 (interactive "P")
23f87bed
MB
7125 (cond
7126 ;; Empty summary.
7127 ((null gnus-newsgroup-data)
7128 (gnus-message 3 "No articles in the group")
7129 nil)
7130 ;; Pick the first article.
7131 ((not (or unread undownloaded unseen))
7132 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7133 (gnus-data-number (car gnus-newsgroup-data)))
7134 ;; Find the first unread article.
7135 (t
7136 (let ((data gnus-newsgroup-data))
7137 (while (and data
7138 (let ((num (gnus-data-number (car data))))
7139 (or (memq num gnus-newsgroup-unfetched)
7140 (not (or (and unread
7141 (memq num gnus-newsgroup-unreads))
7142 (and undownloaded
7143 (memq num gnus-newsgroup-undownloaded))
7144 (and unseen
7145 (memq num gnus-newsgroup-unseen)))))))
7146 (setq data (cdr data)))
7147 (prog1
7148 (if data
7149 (progn
7150 (goto-char (gnus-data-pos (car data)))
7151 (gnus-data-number (car data)))
7152 (gnus-message 3 "No more%s articles"
7153 (let* ((r (when unread " unread"))
7154 (d (when undownloaded " undownloaded"))
7155 (s (when unseen " unseen"))
7156 (l (delq nil (list r d s))))
7157 (cond ((= 3 (length l))
7158 (concat r "," d ", or" s))
7159 ((= 2 (length l))
7160 (concat (car l) ", or" (cadr l)))
7161 ((= 1 (length l))
7162 (car l))
7163 (t
7164 ""))))
7165 nil
7166 )
7167 (gnus-summary-position-point))))))
eec82323
LMI
7168
7169(defun gnus-summary-next-subject (n &optional unread dont-display)
7170 "Go to next N'th summary line.
7171If N is negative, go to the previous N'th subject line.
7172If UNREAD is non-nil, only unread articles are selected.
7173The difference between N and the actual number of steps taken is
7174returned."
7175 (interactive "p")
7176 (let ((backward (< n 0))
7177 (n (abs n)))
7178 (while (and (> n 0)
7179 (if backward
7180 (gnus-summary-find-prev unread)
7181 (gnus-summary-find-next unread)))
16409b0b
GM
7182 (unless (zerop (setq n (1- n)))
7183 (gnus-summary-show-thread)))
eec82323
LMI
7184 (when (/= 0 n)
7185 (gnus-message 7 "No more%s articles"
7186 (if unread " unread" "")))
7187 (unless dont-display
7188 (gnus-summary-recenter)
7189 (gnus-summary-position-point))
7190 n))
7191
7192(defun gnus-summary-next-unread-subject (n)
7193 "Go to next N'th unread summary line."
7194 (interactive "p")
7195 (gnus-summary-next-subject n t))
7196
7197(defun gnus-summary-prev-subject (n &optional unread)
7198 "Go to previous N'th summary line.
7199If optional argument UNREAD is non-nil, only unread article is selected."
7200 (interactive "p")
7201 (gnus-summary-next-subject (- n) unread))
7202
7203(defun gnus-summary-prev-unread-subject (n)
7204 "Go to previous N'th unread summary line."
7205 (interactive "p")
7206 (gnus-summary-next-subject (- n) t))
7207
23f87bed
MB
7208(defun gnus-summary-goto-subjects (articles)
7209 "Insert the subject header for ARTICLES in the current buffer."
7210 (save-excursion
7211 (dolist (article articles)
7212 (gnus-summary-goto-subject article t)))
7213 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7214 (gnus-summary-position-point))
132cf96d 7215
eec82323
LMI
7216(defun gnus-summary-goto-subject (article &optional force silent)
7217 "Go the subject line of ARTICLE.
7218If FORCE, also allow jumping to articles not currently shown."
7219 (interactive "nArticle number: ")
23f87bed
MB
7220 (unless (numberp article)
7221 (error "Article %s is not a number" article))
eec82323
LMI
7222 (let ((b (point))
7223 (data (gnus-data-find article)))
7224 ;; We read in the article if we have to.
7225 (and (not data)
7226 force
6748645f
LMI
7227 (gnus-summary-insert-subject
7228 article
7229 (if (or (numberp force) (vectorp force)) force)
7230 t)
eec82323
LMI
7231 (setq data (gnus-data-find article)))
7232 (goto-char b)
7233 (if (not data)
7234 (progn
7235 (unless silent
7236 (gnus-message 3 "Can't find article %d" article))
7237 nil)
23f87bed
MB
7238 (let ((pt (gnus-data-pos data)))
7239 (goto-char pt)
7240 (gnus-summary-set-article-display-arrow pt))
6748645f 7241 (gnus-summary-position-point)
eec82323
LMI
7242 article)))
7243
7244;; Walking around summary lines with displaying articles.
7245
7246(defun gnus-summary-expand-window (&optional arg)
7247 "Make the summary buffer take up the entire Emacs frame.
7248Given a prefix, will force an `article' buffer configuration."
7249 (interactive "P")
eec82323
LMI
7250 (if arg
7251 (gnus-configure-windows 'article 'force)
7252 (gnus-configure-windows 'summary 'force)))
7253
7254(defun gnus-summary-display-article (article &optional all-header)
7255 "Display ARTICLE in article buffer."
d4dfaa19
DL
7256 (when (gnus-buffer-live-p gnus-article-buffer)
7257 (with-current-buffer gnus-article-buffer
87545352 7258 (mm-enable-multibyte)))
eec82323 7259 (gnus-set-global-variables)
23f87bed
MB
7260 (when (gnus-buffer-live-p gnus-article-buffer)
7261 (with-current-buffer gnus-article-buffer
7262 (setq gnus-article-charset gnus-newsgroup-charset)
7263 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7264 (mm-enable-multibyte)))
eec82323
LMI
7265 (if (null article)
7266 nil
7267 (prog1
7268 (if gnus-summary-display-article-function
7269 (funcall gnus-summary-display-article-function article all-header)
7270 (gnus-article-prepare article all-header))
6748645f 7271 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7272 (when (and gnus-current-article
7273 (not (zerop gnus-current-article)))
7274 (gnus-summary-goto-subject gnus-current-article))
7275 (gnus-summary-recenter)
7276 (when (and gnus-use-trees gnus-show-threads)
7277 (gnus-possibly-generate-tree article)
7278 (gnus-highlight-selected-tree article))
7279 ;; Successfully display article.
7280 (gnus-article-set-window-start
7281 (cdr (assq article gnus-newsgroup-bookmarks))))))
7282
7283(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7284 "Select the current article.
7285If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7286non-nil, the article will be re-fetched even if it already present in
7287the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7288be displayed."
7289 ;; Make sure we are in the summary buffer to work around bbdb bug.
7290 (unless (eq major-mode 'gnus-summary-mode)
7291 (set-buffer gnus-summary-buffer))
7292 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7293 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7294 gnus-summary-display-article-function)
eec82323
LMI
7295 (and (not pseudo)
7296 (gnus-summary-article-pseudo-p article)
a8151ef7 7297 (error "This is a pseudo-article"))
16409b0b
GM
7298 (save-excursion
7299 (set-buffer gnus-summary-buffer)
7300 (if (or (and gnus-single-article-buffer
7301 (or (null gnus-current-article)
7302 (null gnus-article-current)
7303 (null (get-buffer gnus-article-buffer))
7304 (not (eq article (cdr gnus-article-current)))
7305 (not (equal (car gnus-article-current)
7306 gnus-newsgroup-name))))
7307 (and (not gnus-single-article-buffer)
7308 (or (null gnus-current-article)
7309 (not (eq gnus-current-article article))))
7310 force)
7311 ;; The requested article is different from the current article.
7312 (progn
16409b0b
GM
7313 (gnus-summary-display-article article all-headers)
7314 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7315 (with-current-buffer gnus-article-buffer
16409b0b 7316 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7317 (mm-disable-multibyte))))
16409b0b
GM
7318 (gnus-article-set-window-start
7319 (cdr (assq article gnus-newsgroup-bookmarks)))
7320 article)
16409b0b 7321 'old))))
eec82323 7322
23f87bed
MB
7323(defun gnus-summary-force-verify-and-decrypt ()
7324 "Display buttons for signed/encrypted parts and verify/decrypt them."
7325 (interactive)
7326 (let ((mm-verify-option 'known)
7327 (mm-decrypt-option 'known)
7328 (gnus-article-emulate-mime t)
7329 (gnus-buttonized-mime-types (append (list "multipart/signed"
7330 "multipart/encrypted")
7331 gnus-buttonized-mime-types)))
7332 (gnus-summary-select-article nil 'force)))
7333
eec82323
LMI
7334(defun gnus-summary-set-current-mark (&optional current-mark)
7335 "Obsolete function."
7336 nil)
7337
7338(defun gnus-summary-next-article (&optional unread subject backward push)
7339 "Select the next article.
7340If UNREAD, only unread articles are selected.
7341If SUBJECT, only articles with SUBJECT are selected.
7342If BACKWARD, the previous article is selected instead of the next."
7343 (interactive "P")
11e95b02
MB
7344 ;; Make sure we are in the summary buffer.
7345 (unless (eq major-mode 'gnus-summary-mode)
7346 (set-buffer gnus-summary-buffer))
eec82323
LMI
7347 (cond
7348 ;; Is there such an article?
7349 ((and (gnus-summary-search-forward unread subject backward)
7350 (or (gnus-summary-display-article (gnus-summary-article-number))
7351 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7352 (gnus-summary-position-point))
7353 ;; If not, we try the first unread, if that is wanted.
7354 ((and subject
7355 gnus-auto-select-same
7356 (gnus-summary-first-unread-article))
7357 (gnus-summary-position-point)
7358 (gnus-message 6 "Wrapped"))
7359 ;; Try to get next/previous article not displayed in this group.
7360 ((and gnus-auto-extend-newsgroup
7361 (not unread) (not subject))
7362 (gnus-summary-goto-article
7363 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7364 nil (count-lines (point-min) (point))))
eec82323
LMI
7365 ;; Go to next/previous group.
7366 (t
7367 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7368 (gnus-summary-jump-to-group gnus-newsgroup-name))
7369 (let ((cmd last-command-char)
7370 (point
7371 (save-excursion
7372 (set-buffer gnus-group-buffer)
7373 (point)))
7374 (group
7375 (if (eq gnus-keep-same-level 'best)
7376 (gnus-summary-best-group gnus-newsgroup-name)
7377 (gnus-summary-search-group backward gnus-keep-same-level))))
7378 ;; For some reason, the group window gets selected. We change
7379 ;; it back.
7380 (select-window (get-buffer-window (current-buffer)))
7381 ;; Select next unread newsgroup automagically.
7382 (cond
7383 ((or (not gnus-auto-select-next)
7384 (not cmd))
7385 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7386 ((or (eq gnus-auto-select-next 'quietly)
7387 (and (eq gnus-auto-select-next 'slightly-quietly)
7388 push)
7389 (and (eq gnus-auto-select-next 'almost-quietly)
7390 (gnus-summary-last-article-p)))
7391 ;; Select quietly.
7392 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7393 (gnus-summary-exit)
7394 (gnus-message 7 "No more%s articles (%s)..."
7395 (if unread " unread" "")
7396 (if group (concat "selecting " group)
7397 "exiting"))
7398 (gnus-summary-next-group nil group backward)))
7399 (t
7400 (when (gnus-key-press-event-p last-input-event)
7401 (gnus-summary-walk-group-buffer
7402 gnus-newsgroup-name cmd unread backward point))))))))
7403
7404(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7405 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7406 (?\C-p (gnus-group-prev-unread-group 1))))
7407 (cursor-in-echo-area t)
23f87bed 7408 keve key group ended prompt)
eec82323
LMI
7409 (save-excursion
7410 (set-buffer gnus-group-buffer)
7411 (goto-char start)
7412 (setq group
7413 (if (eq gnus-keep-same-level 'best)
7414 (gnus-summary-best-group gnus-newsgroup-name)
7415 (gnus-summary-search-group backward gnus-keep-same-level))))
7416 (while (not ended)
23f87bed
MB
7417 (setq prompt
7418 (format
7419 "No more%s articles%s " (if unread " unread" "")
7420 (if (and group
7421 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7422 (format " (Type %s for %s [%s])"
91472578
MB
7423 (single-key-description cmd)
7424 (gnus-group-decoded-name group)
23f87bed
MB
7425 (car (gnus-gethash group gnus-newsrc-hashtb)))
7426 (format " (Type %s to exit %s)"
7427 (single-key-description cmd)
91472578 7428 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7429 ;; Confirm auto selection.
23f87bed
MB
7430 (setq key (car (setq keve (gnus-read-event-char prompt)))
7431 ended t)
eec82323
LMI
7432 (cond
7433 ((assq key keystrokes)
7434 (let ((obuf (current-buffer)))
7435 (switch-to-buffer gnus-group-buffer)
7436 (when group
7437 (gnus-group-jump-to-group group))
7438 (eval (cadr (assq key keystrokes)))
7439 (setq group (gnus-group-group-name))
7440 (switch-to-buffer obuf))
7441 (setq ended nil))
7442 ((equal key cmd)
7443 (if (or (not group)
7444 (gnus-ephemeral-group-p gnus-newsgroup-name))
7445 (gnus-summary-exit)
7446 (gnus-summary-next-group nil group backward)))
7447 (t
7448 (push (cdr keve) unread-command-events))))))
7449
7450(defun gnus-summary-next-unread-article ()
7451 "Select unread article after current one."
7452 (interactive)
7453 (gnus-summary-next-article
7454 (or (not (eq gnus-summary-goto-unread 'never))
7455 (gnus-summary-last-article-p (gnus-summary-article-number)))
7456 (and gnus-auto-select-same
7457 (gnus-summary-article-subject))))
7458
7459(defun gnus-summary-prev-article (&optional unread subject)
7460 "Select the article after the current one.
7461If UNREAD is non-nil, only unread articles are selected."
7462 (interactive "P")
7463 (gnus-summary-next-article unread subject t))
7464
7465(defun gnus-summary-prev-unread-article ()
7466 "Select unread article before current one."
7467 (interactive)
7468 (gnus-summary-prev-article
7469 (or (not (eq gnus-summary-goto-unread 'never))
7470 (gnus-summary-first-article-p (gnus-summary-article-number)))
7471 (and gnus-auto-select-same
7472 (gnus-summary-article-subject))))
7473
23f87bed 7474(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7475 "Show next page of the selected article.
7476If at the end of the current article, select the next article.
7477LINES says how many lines should be scrolled up.
7478
7479If CIRCULAR is non-nil, go to the start of the article instead of
7480selecting the next article when reaching the end of the current
23f87bed
MB
7481article.
7482
7483If STOP is non-nil, just stop when reaching the end of the message.
7484
7485Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7486 (interactive "P")
7487 (setq gnus-summary-buffer (current-buffer))
7488 (gnus-set-global-variables)
7489 (let ((article (gnus-summary-article-number))
7490 (article-window (get-buffer-window gnus-article-buffer t))
7491 endp)
6748645f
LMI
7492 ;; If the buffer is empty, we have no article.
7493 (unless article
7494 (error "No article to select"))
eec82323
LMI
7495 (gnus-configure-windows 'article)
7496 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7497 (if (and (eq gnus-summary-goto-unread 'never)
7498 (not (gnus-summary-last-article-p article)))
7499 (gnus-summary-next-article)
7500 (gnus-summary-next-unread-article))
7501 (if (or (null gnus-current-article)
7502 (null gnus-article-current)
7503 (/= article (cdr gnus-article-current))
7504 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7505 ;; Selected subject is different from current article's.
7506 (gnus-summary-display-article article)
7507 (when article-window
7508 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7509 (setq endp (or (gnus-article-next-page lines)
7510 (gnus-article-only-boring-p))))
eec82323 7511 (when endp
23f87bed
MB
7512 (cond (stop
7513 (gnus-message 3 "End of message"))
7514 (circular
eec82323
LMI
7515 (gnus-summary-beginning-of-article))
7516 (lines
7517 (gnus-message 3 "End of message"))
7518 ((null lines)
7519 (if (and (eq gnus-summary-goto-unread 'never)
7520 (not (gnus-summary-last-article-p article)))
7521 (gnus-summary-next-article)
7522 (gnus-summary-next-unread-article))))))))
7523 (gnus-summary-recenter)
7524 (gnus-summary-position-point)))
7525
7526(defun gnus-summary-prev-page (&optional lines move)
7527 "Show previous page of selected article.
7528Argument LINES specifies lines to be scrolled down.
7529If MOVE, move to the previous unread article if point is at
7530the beginning of the buffer."
7531 (interactive "P")
eec82323
LMI
7532 (let ((article (gnus-summary-article-number))
7533 (article-window (get-buffer-window gnus-article-buffer t))
7534 endp)
7535 (gnus-configure-windows 'article)
7536 (if (or (null gnus-current-article)
7537 (null gnus-article-current)
7538 (/= article (cdr gnus-article-current))
7539 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7540 ;; Selected subject is different from current article's.
7541 (gnus-summary-display-article article)
7542 (gnus-summary-recenter)
7543 (when article-window
7544 (gnus-eval-in-buffer-window gnus-article-buffer
7545 (setq endp (gnus-article-prev-page lines)))
7546 (when (and move endp)
7547 (cond (lines
7548 (gnus-message 3 "Beginning of message"))
7549 ((null lines)
7550 (if (and (eq gnus-summary-goto-unread 'never)
7551 (not (gnus-summary-first-article-p article)))
7552 (gnus-summary-prev-article)
7553 (gnus-summary-prev-unread-article))))))))
7554 (gnus-summary-position-point))
7555
7556(defun gnus-summary-prev-page-or-article (&optional lines)
7557 "Show previous page of selected article.
7558Argument LINES specifies lines to be scrolled down.
7559If at the beginning of the article, go to the next article."
7560 (interactive "P")
7561 (gnus-summary-prev-page lines t))
7562
7563(defun gnus-summary-scroll-up (lines)
7564 "Scroll up (or down) one line current article.
7565Argument LINES specifies lines to be scrolled up (or down if negative)."
7566 (interactive "p")
eec82323
LMI
7567 (gnus-configure-windows 'article)
7568 (gnus-summary-show-thread)
7569 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7570 (gnus-eval-in-buffer-window gnus-article-buffer
7571 (cond ((> lines 0)
7572 (when (gnus-article-next-page lines)
7573 (gnus-message 3 "End of message")))
7574 ((< lines 0)
7575 (gnus-article-prev-page (- lines))))))
7576 (gnus-summary-recenter)
7577 (gnus-summary-position-point))
7578
6748645f
LMI
7579(defun gnus-summary-scroll-down (lines)
7580 "Scroll down (or up) one line current article.
7581Argument LINES specifies lines to be scrolled down (or up if negative)."
7582 (interactive "p")
7583 (gnus-summary-scroll-up (- lines)))
7584
eec82323
LMI
7585(defun gnus-summary-next-same-subject ()
7586 "Select next article which has the same subject as current one."
7587 (interactive)
eec82323
LMI
7588 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7589
7590(defun gnus-summary-prev-same-subject ()
7591 "Select previous article which has the same subject as current one."
7592 (interactive)
eec82323
LMI
7593 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7594
7595(defun gnus-summary-next-unread-same-subject ()
7596 "Select next unread article which has the same subject as current one."
7597 (interactive)
eec82323
LMI
7598 (gnus-summary-next-article t (gnus-summary-article-subject)))
7599
7600(defun gnus-summary-prev-unread-same-subject ()
7601 "Select previous unread article which has the same subject as current one."
7602 (interactive)
eec82323
LMI
7603 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7604
7605(defun gnus-summary-first-unread-article ()
7606 "Select the first unread article.
7607Return nil if there are no unread articles."
7608 (interactive)
eec82323
LMI
7609 (prog1
7610 (when (gnus-summary-first-subject t)
7611 (gnus-summary-show-thread)
7612 (gnus-summary-first-subject t)
7613 (gnus-summary-display-article (gnus-summary-article-number)))
7614 (gnus-summary-position-point)))
7615
16409b0b
GM
7616(defun gnus-summary-first-unread-subject ()
7617 "Place the point on the subject line of the first unread article.
7618Return nil if there are no unread articles."
7619 (interactive)
7620 (prog1
7621 (when (gnus-summary-first-subject t)
7622 (gnus-summary-show-thread)
7623 (gnus-summary-first-subject t))
7624 (gnus-summary-position-point)))
7625
23f87bed
MB
7626(defun gnus-summary-first-unseen-subject ()
7627 "Place the point on the subject line of the first unseen article.
7628Return nil if there are no unseen articles."
7629 (interactive)
7630 (prog1
7631 (when (gnus-summary-first-subject nil nil t)
7632 (gnus-summary-show-thread)
7633 (gnus-summary-first-subject nil nil t))
7634 (gnus-summary-position-point)))
7635
7636(defun gnus-summary-first-unseen-or-unread-subject ()
7637 "Place the point on the subject line of the first unseen article or,
7638if all article have been seen, on the subject line of the first unread
7639article."
7640 (interactive)
7641 (prog1
7642 (unless (when (gnus-summary-first-subject nil nil t)
7643 (gnus-summary-show-thread)
7644 (gnus-summary-first-subject nil nil t))
7645 (when (gnus-summary-first-subject t)
7646 (gnus-summary-show-thread)
7647 (gnus-summary-first-subject t)))
7648 (gnus-summary-position-point)))
7649
eec82323
LMI
7650(defun gnus-summary-first-article ()
7651 "Select the first article.
7652Return nil if there are no articles."
7653 (interactive)
eec82323
LMI
7654 (prog1
7655 (when (gnus-summary-first-subject)
16409b0b
GM
7656 (gnus-summary-show-thread)
7657 (gnus-summary-first-subject)
7658 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
7659 (gnus-summary-position-point)))
7660
23f87bed
MB
7661(defun gnus-summary-best-unread-article (&optional arg)
7662 "Select the unread article with the highest score.
7663If given a prefix argument, select the next unread article that has a
7664score higher than the default score."
7665 (interactive "P")
7666 (let ((article (if arg
7667 (gnus-summary-better-unread-subject)
7668 (gnus-summary-best-unread-subject))))
7669 (if article
7670 (gnus-summary-goto-article article)
7671 (error "No unread articles"))))
7672
7673(defun gnus-summary-best-unread-subject ()
7674 "Select the unread subject with the highest score."
eec82323 7675 (interactive)
eec82323
LMI
7676 (let ((best -1000000)
7677 (data gnus-newsgroup-data)
7678 article score)
7679 (while data
7680 (and (gnus-data-unread-p (car data))
7681 (> (setq score
7682 (gnus-summary-article-score (gnus-data-number (car data))))
7683 best)
7684 (setq best score
7685 article (gnus-data-number (car data))))
7686 (setq data (cdr data)))
23f87bed
MB
7687 (when article
7688 (gnus-summary-goto-subject article))
7689 (gnus-summary-position-point)
7690 article))
7691
7692(defun gnus-summary-better-unread-subject ()
7693 "Select the first unread subject that has a score over the default score."
7694 (interactive)
7695 (let ((data gnus-newsgroup-data)
7696 article score)
7697 (while (and (setq article (gnus-data-number (car data)))
7698 (or (gnus-data-read-p (car data))
7699 (not (> (gnus-summary-article-score article)
7700 gnus-summary-default-score))))
7701 (setq data (cdr data)))
7702 (when article
7703 (gnus-summary-goto-subject article))
7704 (gnus-summary-position-point)
7705 article))
eec82323
LMI
7706
7707(defun gnus-summary-last-subject ()
7708 "Go to the last displayed subject line in the group."
7709 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7710 (when article
7711 (gnus-summary-goto-subject article))))
7712
7713(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
7714 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7715If ALL-HEADERS is non-nil, no header lines are hidden.
7716If FORCE, go to the article even if it isn't displayed. If FORCE
7717is a number, it is the line the article is to be displayed on."
eec82323
LMI
7718 (interactive
7719 (list
6748645f
LMI
7720 (completing-read
7721 "Article number or Message-ID: "
7722 (mapcar (lambda (number) (list (int-to-string number)))
7723 gnus-newsgroup-limit))
eec82323
LMI
7724 current-prefix-arg
7725 t))
7726 (prog1
6748645f 7727 (if (and (stringp article)
23f87bed 7728 (string-match "@\\|%40" article))
6748645f
LMI
7729 (gnus-summary-refer-article article)
7730 (when (stringp article)
7731 (setq article (string-to-number article)))
7732 (if (gnus-summary-goto-subject article force)
7733 (gnus-summary-display-article article all-headers)
7734 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
7735 (gnus-summary-position-point)))
7736
7737(defun gnus-summary-goto-last-article ()
7738 "Go to the previously read article."
7739 (interactive)
7740 (prog1
7741 (when gnus-last-article
6748645f 7742 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
7743 (gnus-summary-position-point)))
7744
7745(defun gnus-summary-pop-article (number)
7746 "Pop one article off the history and go to the previous.
7747NUMBER articles will be popped off."
7748 (interactive "p")
7749 (let (to)
7750 (setq gnus-newsgroup-history
7751 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7752 (if to
6748645f 7753 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
7754 (error "Article history empty")))
7755 (gnus-summary-position-point))
7756
7757;; Summary commands and functions for limiting the summary buffer.
7758
7759(defun gnus-summary-limit-to-articles (n)
7760 "Limit the summary buffer to the next N articles.
7761If not given a prefix, use the process marked articles instead."
7762 (interactive "P")
eec82323
LMI
7763 (prog1
7764 (let ((articles (gnus-summary-work-articles n)))
7765 (setq gnus-newsgroup-processable nil)
7766 (gnus-summary-limit articles))
7767 (gnus-summary-position-point)))
7768
7769(defun gnus-summary-pop-limit (&optional total)
7770 "Restore the previous limit.
7771If given a prefix, remove all limits."
7772 (interactive "P")
eec82323
LMI
7773 (when total
7774 (setq gnus-newsgroup-limits
7775 (list (mapcar (lambda (h) (mail-header-number h))
7776 gnus-newsgroup-headers))))
7777 (unless gnus-newsgroup-limits
7778 (error "No limit to pop"))
7779 (prog1
7780 (gnus-summary-limit nil 'pop)
7781 (gnus-summary-position-point)))
7782
47b63dfa
SZ
7783(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7784 "Limit the summary buffer to articles that have subjects that match a regexp.
7785If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 7786 (interactive
47b63dfa
SZ
7787 (list (read-string (if current-prefix-arg
7788 "Exclude subject (regexp): "
a1506d29 7789 "Limit to subject (regexp): "))
47b63dfa 7790 nil current-prefix-arg))
eec82323
LMI
7791 (unless header
7792 (setq header "subject"))
7793 (when (not (equal "" subject))
7794 (prog1
7795 (let ((articles (gnus-summary-find-matching
a1506d29 7796 (or header "subject") subject 'all nil nil
47b63dfa 7797 not-matching)))
eec82323
LMI
7798 (unless articles
7799 (error "Found no matches for \"%s\"" subject))
7800 (gnus-summary-limit articles))
7801 (gnus-summary-position-point))))
7802
ef6e0ec7 7803(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
7804 "Limit the summary buffer to articles that have authors that match a regexp.
7805If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 7806 (interactive
47b63dfa
SZ
7807 (list (read-string (if current-prefix-arg
7808 "Exclude author (regexp): "
a1506d29 7809 "Limit to author (regexp): "))
ef6e0ec7
SZ
7810 current-prefix-arg))
7811 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323
LMI
7812
7813(defun gnus-summary-limit-to-age (age &optional younger-p)
7814 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7815If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7816articles that are younger than AGE days."
16409b0b
GM
7817 (interactive
7818 (let ((younger current-prefix-arg)
7819 (days-got nil)
7820 days)
7821 (while (not days-got)
7822 (setq days (if younger
23f87bed
MB
7823 (read-string "Limit to articles younger than (in days, older when negative): ")
7824 (read-string
7825 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
7826 (when (> (length days) 0)
7827 (setq days (read days)))
7828 (if (numberp days)
23f87bed
MB
7829 (progn
7830 (setq days-got t)
7831 (if (< days 0)
7832 (progn
7833 (setq younger (not younger))
7834 (setq days (* days -1)))))
16409b0b
GM
7835 (message "Please enter a number.")
7836 (sleep-for 1)))
7837 (list days younger)))
eec82323
LMI
7838 (prog1
7839 (let ((data gnus-newsgroup-data)
16409b0b 7840 (cutoff (days-to-time age))
eec82323
LMI
7841 articles d date is-younger)
7842 (while (setq d (pop data))
7843 (when (and (vectorp (gnus-data-header d))
7844 (setq date (mail-header-date (gnus-data-header d))))
16409b0b
GM
7845 (setq is-younger (time-less-p
7846 (time-since (condition-case ()
7847 (date-to-time date)
7848 (error '(0 0))))
eec82323 7849 cutoff))
6748645f
LMI
7850 (when (if younger-p
7851 is-younger
7852 (not is-younger))
eec82323
LMI
7853 (push (gnus-data-number d) articles))))
7854 (gnus-summary-limit (nreverse articles)))
7855 (gnus-summary-position-point)))
7856
47b63dfa 7857(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
7858 "Limit the summary buffer to articles that match an 'extra' header."
7859 (interactive
7860 (let ((header
7861 (intern
23f87bed 7862 (gnus-completing-read-with-default
16409b0b 7863 (symbol-name (car gnus-extra-headers))
47b63dfa 7864 (if current-prefix-arg
81df110a
RF
7865 "Exclude extra header"
7866 "Limit extra header")
16409b0b
GM
7867 (mapcar (lambda (x)
7868 (cons (symbol-name x) x))
7869 gnus-extra-headers)
7870 nil
7871 t))))
7872 (list header
a1506d29 7873 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
7874 (if current-prefix-arg "Exclude" "Limit to")
7875 header))
7876 current-prefix-arg)))
16409b0b
GM
7877 (when (not (equal "" regexp))
7878 (prog1
7879 (let ((articles (gnus-summary-find-matching
a1506d29 7880 (cons 'extra header) regexp 'all nil nil
47b63dfa 7881 not-matching)))
16409b0b
GM
7882 (unless articles
7883 (error "Found no matches for \"%s\"" regexp))
7884 (gnus-summary-limit articles))
7885 (gnus-summary-position-point))))
7886
23f87bed
MB
7887(defun gnus-summary-limit-to-display-predicate ()
7888 "Limit the summary buffer to the predicated in the `display' group parameter."
7889 (interactive)
7890 (unless gnus-newsgroup-display
7891 (error "There is no `display' group parameter"))
7892 (let (articles)
7893 (dolist (number gnus-newsgroup-articles)
7894 (when (funcall gnus-newsgroup-display)
7895 (push number articles)))
7896 (gnus-summary-limit articles))
7897 (gnus-summary-position-point))
7898
eec82323
LMI
7899(defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7900(make-obsolete
7901 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7902
7903(defun gnus-summary-limit-to-unread (&optional all)
7904 "Limit the summary buffer to articles that are not marked as read.
7905If ALL is non-nil, limit strictly to unread articles."
7906 (interactive "P")
7907 (if all
7908 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7909 (gnus-summary-limit-to-marks
7910 ;; Concat all the marks that say that an article is read and have
7911 ;; those removed.
7912 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 7913 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
7914 gnus-low-score-mark gnus-expirable-mark
7915 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7916 gnus-duplicate-mark gnus-souped-mark)
7917 'reverse)))
7918
7919(defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7920(make-obsolete 'gnus-summary-delete-marked-with
81ceefe2 7921 'gnus-summary-limit-exclude-marks)
eec82323
LMI
7922
7923(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7924 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7925If REVERSE, limit the summary buffer to articles that are marked
7926with MARKS. MARKS can either be a string of marks or a list of marks.
7927Returns how many articles were removed."
7928 (interactive "sMarks: ")
7929 (gnus-summary-limit-to-marks marks t))
7930
7931(defun gnus-summary-limit-to-marks (marks &optional reverse)
7932 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7933If REVERSE (the prefix), limit the summary buffer to articles that are
7934not marked with MARKS. MARKS can either be a string of marks or a
7935list of marks.
7936Returns how many articles were removed."
6748645f 7937 (interactive "sMarks: \nP")
eec82323
LMI
7938 (prog1
7939 (let ((data gnus-newsgroup-data)
7940 (marks (if (listp marks) marks
7941 (append marks nil))) ; Transform to list.
7942 articles)
7943 (while data
7944 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7945 (memq (gnus-data-mark (car data)) marks))
7946 (push (gnus-data-number (car data)) articles))
7947 (setq data (cdr data)))
7948 (gnus-summary-limit articles))
7949 (gnus-summary-position-point)))
7950
23f87bed 7951(defun gnus-summary-limit-to-score (score)
eec82323 7952 "Limit to articles with score at or above SCORE."
23f87bed 7953 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
7954 (let ((data gnus-newsgroup-data)
7955 articles)
7956 (while data
7957 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7958 score)
7959 (push (gnus-data-number (car data)) articles))
7960 (setq data (cdr data)))
7961 (prog1
7962 (gnus-summary-limit articles)
7963 (gnus-summary-position-point))))
7964
23f87bed
MB
7965(defun gnus-summary-limit-to-unseen ()
7966 "Limit to unseen articles."
7967 (interactive)
7968 (prog1
7969 (gnus-summary-limit gnus-newsgroup-unseen)
7970 (gnus-summary-position-point)))
7971
6748645f 7972(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
7973 "Display all the hidden articles that is in the thread with ID in it.
7974When called interactively, ID is the Message-ID of the current
7975article."
6748645f
LMI
7976 (interactive (list (mail-header-id (gnus-summary-article-header))))
7977 (let ((articles (gnus-articles-in-thread
7978 (gnus-id-to-thread (gnus-root-id id)))))
7979 (prog1
7980 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
7981 (gnus-summary-limit-include-matching-articles
7982 "subject"
7983 (regexp-quote (gnus-simplify-subject-re
7984 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
7985 (gnus-summary-position-point))))
7986
23f87bed
MB
7987(defun gnus-summary-limit-include-matching-articles (header regexp)
7988 "Display all the hidden articles that have HEADERs that match REGEXP."
7989 (interactive (list (read-string "Match on header: ")
7990 (read-string "Regexp: ")))
7991 (let ((articles (gnus-find-matching-articles header regexp)))
7992 (prog1
7993 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7994 (gnus-summary-position-point))))
7995
7996(defun gnus-summary-insert-dormant-articles ()
7997 "Insert all the dormant articles for this group into the current buffer."
7998 (interactive)
7999 (let ((gnus-verbose (max 6 gnus-verbose)))
8000 (if (not gnus-newsgroup-dormant)
db629244 8001 (gnus-message 3 "No dormant articles for this group")
23f87bed
MB
8002 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8003
eec82323 8004(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
8005 "Display all the hidden articles that are marked as dormant.
8006Note that this command only works on a subset of the articles currently
8007fetched for this group."
eec82323 8008 (interactive)
eec82323
LMI
8009 (unless gnus-newsgroup-dormant
8010 (error "There are no dormant articles in this group"))
8011 (prog1
8012 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8013 (gnus-summary-position-point)))
8014
8015(defun gnus-summary-limit-exclude-dormant ()
8016 "Hide all dormant articles."
8017 (interactive)
eec82323
LMI
8018 (prog1
8019 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8020 (gnus-summary-position-point)))
8021
8022(defun gnus-summary-limit-exclude-childless-dormant ()
8023 "Hide all dormant articles that have no children."
8024 (interactive)
eec82323
LMI
8025 (let ((data (gnus-data-list t))
8026 articles d children)
8027 ;; Find all articles that are either not dormant or have
8028 ;; children.
8029 (while (setq d (pop data))
8030 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8031 (and (setq children
8032 (gnus-article-children (gnus-data-number d)))
8033 (let (found)
8034 (while children
8035 (when (memq (car children) articles)
8036 (setq children nil
8037 found t))
8038 (pop children))
8039 found)))
8040 (push (gnus-data-number d) articles)))
8041 ;; Do the limiting.
8042 (prog1
8043 (gnus-summary-limit articles)
8044 (gnus-summary-position-point))))
8045
8046(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8047 "Mark all unread excluded articles as read.
8048If ALL, mark even excluded ticked and dormants as read."
8049 (interactive "P")
23f87bed
MB
8050 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8051 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8052 (sort
8053 (mapcar (lambda (h) (mail-header-number h))
8054 gnus-newsgroup-headers)
8055 '<)
23f87bed 8056 gnus-newsgroup-limit))
eec82323 8057 article)
6748645f 8058 (setq gnus-newsgroup-unreads
23f87bed
MB
8059 (gnus-sorted-intersection gnus-newsgroup-unreads
8060 gnus-newsgroup-limit))
eec82323
LMI
8061 (if all
8062 (setq gnus-newsgroup-dormant nil
8063 gnus-newsgroup-marked nil
8064 gnus-newsgroup-reads
8065 (nconc
8066 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8067 gnus-newsgroup-reads))
8068 (while (setq article (pop articles))
8069 (unless (or (memq article gnus-newsgroup-dormant)
8070 (memq article gnus-newsgroup-marked))
8071 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8072
8073(defun gnus-summary-limit (articles &optional pop)
8074 (if pop
8075 ;; We pop the previous limit off the stack and use that.
8076 (setq articles (car gnus-newsgroup-limits)
8077 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8078 ;; We use the new limit, so we push the old limit on the stack.
8079 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8080 ;; Set the limit.
8081 (setq gnus-newsgroup-limit articles)
8082 (let ((total (length gnus-newsgroup-data))
8083 (data (gnus-data-find-list (gnus-summary-article-number)))
8084 (gnus-summary-mark-below nil) ; Inhibit this.
8085 found)
8086 ;; This will do all the work of generating the new summary buffer
8087 ;; according to the new limit.
8088 (gnus-summary-prepare)
8089 ;; Hide any threads, possibly.
23f87bed 8090 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8091 ;; Try to return to the article you were at, or one in the
8092 ;; neighborhood.
8093 (when data
8094 ;; We try to find some article after the current one.
8095 (while data
8096 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8097 (setq data nil
8098 found t))
8099 (setq data (cdr data))))
8100 (unless found
8101 ;; If there is no data, that means that we were after the last
8102 ;; article. The same goes when we can't find any articles
8103 ;; after the current one.
8104 (goto-char (point-max))
8105 (gnus-summary-find-prev))
6748645f 8106 (gnus-set-mode-line 'summary)
eec82323
LMI
8107 ;; We return how many articles were removed from the summary
8108 ;; buffer as a result of the new limit.
8109 (- total (length gnus-newsgroup-data))))
8110
8111(defsubst gnus-invisible-cut-children (threads)
8112 (let ((num 0))
8113 (while threads
8114 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8115 (incf num))
8116 (pop threads))
8117 (< num 2)))
8118
8119(defsubst gnus-cut-thread (thread)
8120 "Go forwards in the thread until we find an article that we want to display."
8121 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8122 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8123 (numberp gnus-fetch-old-headers)
eec82323
LMI
8124 (eq gnus-build-sparse-threads 'some)
8125 (eq gnus-build-sparse-threads 'more))
8126 ;; Deal with old-fetched headers and sparse threads.
8127 (while (and
8128 thread
8129 (or
8130 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8131 (gnus-summary-article-ancient-p
8132 (mail-header-number (car thread))))
6748645f
LMI
8133 (if (or (<= (length (cdr thread)) 1)
8134 (eq gnus-fetch-old-headers 'invisible))
8135 (setq gnus-newsgroup-limit
8136 (delq (mail-header-number (car thread))
8137 gnus-newsgroup-limit)
8138 thread (cadr thread))
8139 (when (gnus-invisible-cut-children (cdr thread))
8140 (let ((th (cdr thread)))
8141 (while th
8142 (if (memq (mail-header-number (caar th))
a8151ef7 8143 gnus-newsgroup-limit)
6748645f
LMI
8144 (setq thread (car th)
8145 th nil)
8146 (setq th (cdr th))))))))))
eec82323
LMI
8147 thread)
8148
8149(defun gnus-cut-threads (threads)
23f87bed 8150 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8151 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8152 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8153 (numberp gnus-fetch-old-headers)
eec82323
LMI
8154 (eq gnus-build-sparse-threads 'some)
8155 (eq gnus-build-sparse-threads 'more))
8156 (let ((th threads))
8157 (while th
8158 (setcar th (gnus-cut-thread (car th)))
8159 (setq th (cdr th)))))
8160 ;; Remove nixed out threads.
8161 (delq nil threads))
8162
8163(defun gnus-summary-initial-limit (&optional show-if-empty)
8164 "Figure out what the initial limit is supposed to be on group entry.
8165This entails weeding out unwanted dormants, low-scored articles,
8166fetch-old-headers verbiage, and so on."
8167 ;; Most groups have nothing to remove.
8168 (if (or gnus-inhibit-limiting
8169 (and (null gnus-newsgroup-dormant)
23f87bed 8170 (eq gnus-newsgroup-display 'gnus-not-ignore)
eec82323 8171 (not (eq gnus-fetch-old-headers 'some))
16409b0b 8172 (not (numberp gnus-fetch-old-headers))
6748645f 8173 (not (eq gnus-fetch-old-headers 'invisible))
eec82323
LMI
8174 (null gnus-summary-expunge-below)
8175 (not (eq gnus-build-sparse-threads 'some))
8176 (not (eq gnus-build-sparse-threads 'more))
8177 (null gnus-thread-expunge-below)
8178 (not gnus-use-nocem)))
8179 () ; Do nothing.
8180 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8181 (setq gnus-newsgroup-limit nil)
8182 (mapatoms
8183 (lambda (node)
8184 (unless (car (symbol-value node))
8185 ;; These threads have no parents -- they are roots.
8186 (let ((nodes (cdr (symbol-value node)))
8187 thread)
8188 (while nodes
8189 (if (and gnus-thread-expunge-below
8190 (< (gnus-thread-total-score (car nodes))
8191 gnus-thread-expunge-below))
8192 (gnus-expunge-thread (pop nodes))
8193 (setq thread (pop nodes))
8194 (gnus-summary-limit-children thread))))))
8195 gnus-newsgroup-dependencies)
8196 ;; If this limitation resulted in an empty group, we might
8197 ;; pop the previous limit and use it instead.
8198 (when (and (not gnus-newsgroup-limit)
8199 show-if-empty)
8200 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8201 gnus-newsgroup-limit))
8202
8203(defun gnus-summary-limit-children (thread)
8204 "Return 1 if this subthread is visible and 0 if it is not."
8205 ;; First we get the number of visible children to this thread. This
8206 ;; is done by recursing down the thread using this function, so this
8207 ;; will really go down to a leaf article first, before slowly
8208 ;; working its way up towards the root.
8209 (when thread
04b61ae9 8210 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8211 (children
eec82323
LMI
8212 (if (cdr thread)
8213 (apply '+ (mapcar 'gnus-summary-limit-children
8214 (cdr thread)))
8215 0))
8216 (number (mail-header-number (car thread)))
8217 score)
8218 (if (and
8219 (not (memq number gnus-newsgroup-marked))
8220 (or
8221 ;; If this article is dormant and has absolutely no visible
8222 ;; children, then this article isn't visible.
8223 (and (memq number gnus-newsgroup-dormant)
8224 (zerop children))
8225 ;; If this is "fetch-old-headered" and there is no
8226 ;; visible children, then we don't want this article.
16409b0b
GM
8227 (and (or (eq gnus-fetch-old-headers 'some)
8228 (numberp gnus-fetch-old-headers))
eec82323
LMI
8229 (gnus-summary-article-ancient-p number)
8230 (zerop children))
6748645f
LMI
8231 ;; If this is "fetch-old-headered" and `invisible', then
8232 ;; we don't want this article.
8233 (and (eq gnus-fetch-old-headers 'invisible)
8234 (gnus-summary-article-ancient-p number))
eec82323
LMI
8235 ;; If this is a sparsely inserted article with no children,
8236 ;; we don't want it.
8237 (and (eq gnus-build-sparse-threads 'some)
8238 (gnus-summary-article-sparse-p number)
8239 (zerop children))
8240 ;; If we use expunging, and this article is really
8241 ;; low-scored, then we don't want this article.
8242 (when (and gnus-summary-expunge-below
8243 (< (setq score
8244 (or (cdr (assq number gnus-newsgroup-scored))
8245 gnus-summary-default-score))
8246 gnus-summary-expunge-below))
8247 ;; We increase the expunge-tally here, but that has
8248 ;; nothing to do with the limits, really.
8249 (incf gnus-newsgroup-expunged-tally)
8250 ;; We also mark as read here, if that's wanted.
8251 (when (and gnus-summary-mark-below
8252 (< score gnus-summary-mark-below))
8253 (setq gnus-newsgroup-unreads
8254 (delq number gnus-newsgroup-unreads))
8255 (if gnus-newsgroup-auto-expire
8256 (push number gnus-newsgroup-expirable)
8257 (push (cons number gnus-low-score-mark)
8258 gnus-newsgroup-reads)))
8259 t)
23f87bed
MB
8260 ;; Do the `display' group parameter.
8261 (and gnus-newsgroup-display
8262 (not (funcall gnus-newsgroup-display)))
eec82323
LMI
8263 ;; Check NoCeM things.
8264 (if (and gnus-use-nocem
8265 (gnus-nocem-unwanted-article-p
8266 (mail-header-id (car thread))))
8267 (progn
a8151ef7 8268 (setq gnus-newsgroup-unreads
eec82323
LMI
8269 (delq number gnus-newsgroup-unreads))
8270 t))))
8271 ;; Nope, invisible article.
8272 0
8273 ;; Ok, this article is to be visible, so we add it to the limit
8274 ;; and return 1.
8275 (push number gnus-newsgroup-limit)
8276 1))))
8277
8278(defun gnus-expunge-thread (thread)
8279 "Mark all articles in THREAD as read."
8280 (let* ((number (mail-header-number (car thread))))
8281 (incf gnus-newsgroup-expunged-tally)
8282 ;; We also mark as read here, if that's wanted.
8283 (setq gnus-newsgroup-unreads
8284 (delq number gnus-newsgroup-unreads))
8285 (if gnus-newsgroup-auto-expire
8286 (push number gnus-newsgroup-expirable)
8287 (push (cons number gnus-low-score-mark)
8288 gnus-newsgroup-reads)))
8289 ;; Go recursively through all subthreads.
8290 (mapcar 'gnus-expunge-thread (cdr thread)))
8291
8292;; Summary article oriented commands
8293
8294(defun gnus-summary-refer-parent-article (n)
8295 "Refer parent article N times.
8296If N is negative, go to ancestor -N instead.
8297The difference between N and the number of articles fetched is returned."
8298 (interactive "p")
eec82323
LMI
8299 (let ((skip 1)
8300 error header ref)
8301 (when (not (natnump n))
8302 (setq skip (abs n)
8303 n 1))
8304 (while (and (> n 0)
8305 (not error))
8306 (setq header (gnus-summary-article-header))
8307 (if (and (eq (mail-header-number header)
8308 (cdr gnus-article-current))
8309 (equal gnus-newsgroup-name
8310 (car gnus-article-current)))
8311 ;; If we try to find the parent of the currently
8312 ;; displayed article, then we take a look at the actual
8313 ;; References header, since this is slightly more
8314 ;; reliable than the References field we got from the
8315 ;; server.
8316 (save-excursion
8317 (set-buffer gnus-original-article-buffer)
8318 (nnheader-narrow-to-headers)
8319 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8320 (when (setq ref (message-fetch-field "in-reply-to"))
8321 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8322 (widen))
8323 (setq ref
8324 ;; It's not the current article, so we take a bet on
8325 ;; the value we got from the server.
8326 (mail-header-references header)))
8327 (if (and ref
8328 (not (equal ref "")))
8329 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8330 (gnus-message 1 "Couldn't find parent"))
8331 (gnus-message 1 "No references in article %d"
8332 (gnus-summary-article-number))
8333 (setq error t))
8334 (decf n))
8335 (gnus-summary-position-point)
8336 n))
8337
8338(defun gnus-summary-refer-references ()
8339 "Fetch all articles mentioned in the References header.
6748645f 8340Return the number of articles fetched."
eec82323 8341 (interactive)
eec82323
LMI
8342 (let ((ref (mail-header-references (gnus-summary-article-header)))
8343 (current (gnus-summary-article-number))
8344 (n 0))
8345 (if (or (not ref)
8346 (equal ref ""))
8347 (error "No References in the current article")
8348 ;; For each Message-ID in the References header...
8349 (while (string-match "<[^>]*>" ref)
8350 (incf n)
8351 ;; ... fetch that article.
8352 (gnus-summary-refer-article
8353 (prog1 (match-string 0 ref)
8354 (setq ref (substring ref (match-end 0))))))
8355 (gnus-summary-goto-subject current)
8356 (gnus-summary-position-point)
8357 n)))
8358
6748645f
LMI
8359(defun gnus-summary-refer-thread (&optional limit)
8360 "Fetch all articles in the current thread.
8361If LIMIT (the numerical prefix), fetch that many old headers instead
8362of what's specified by the `gnus-refer-thread-limit' variable."
8363 (interactive "P")
8364 (let ((id (mail-header-id (gnus-summary-article-header)))
8365 (limit (if limit (prefix-numeric-value limit)
8366 gnus-refer-thread-limit)))
6748645f
LMI
8367 (unless (eq gnus-fetch-old-headers 'invisible)
8368 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8369 ;; Retrieve the headers and read them in.
23f87bed
MB
8370 (if (eq (if (numberp limit)
8371 (gnus-retrieve-headers
8372 (list (min
8373 (+ (mail-header-number
8374 (gnus-summary-article-header))
8375 limit)
8376 gnus-newsgroup-end))
8377 gnus-newsgroup-name (* limit 2))
8378 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8379 ;; headers.
8380 (gnus-retrieve-headers (list gnus-newsgroup-end)
8381 gnus-newsgroup-name limit))
6748645f
LMI
8382 'nov)
8383 (gnus-build-all-threads)
23f87bed 8384 (error "Can't fetch thread from back ends that don't support NOV"))
6748645f
LMI
8385 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8386 (gnus-summary-limit-include-thread id)))
8387
16409b0b
GM
8388(defun gnus-summary-refer-article (message-id)
8389 "Fetch an article specified by MESSAGE-ID."
8390 (interactive "sMessage-ID: ")
eec82323
LMI
8391 (when (and (stringp message-id)
8392 (not (zerop (length message-id))))
23f87bed 8393 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8394 ;; Construct the correct Message-ID if necessary.
8395 ;; Suggested by tale@pawl.rpi.edu.
8396 (unless (string-match "^<" message-id)
8397 (setq message-id (concat "<" message-id)))
8398 (unless (string-match ">$" message-id)
8399 (setq message-id (concat message-id ">")))
23f87bed
MB
8400 ;; People often post MIDs from URLs, so unhex it:
8401 (unless (string-match "@" message-id)
8402 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8403 (let* ((header (gnus-id-to-header message-id))
8404 (sparse (and header
8405 (gnus-summary-article-sparse-p
a8151ef7
LMI
8406 (mail-header-number header))
8407 (memq (mail-header-number header)
16409b0b
GM
8408 gnus-newsgroup-limit)))
8409 number)
6748645f
LMI
8410 (cond
8411 ;; If the article is present in the buffer we just go to it.
8412 ((and header
8413 (or (not (gnus-summary-article-sparse-p
8414 (mail-header-number header)))
8415 sparse))
8416 (prog1
8417 (gnus-summary-goto-article
8418 (mail-header-number header) nil t)
8419 (when sparse
8420 (gnus-summary-update-article (mail-header-number header)))))
8421 (t
16409b0b
GM
8422 ;; We fetch the article.
8423 (catch 'found
8424 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8425 (when (and (gnus-check-server gnus-override-method)
8426 ;; Fetch the header,
8427 (setq number (gnus-summary-insert-subject message-id)))
8428 ;; and display the article.
eec82323 8429 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8430 (throw 'found t)))
8431 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8432
8433(defun gnus-refer-article-methods ()
8f688cb0 8434 "Return a list of referable methods."
16409b0b
GM
8435 (cond
8436 ;; No method, so we default to current and native.
8437 ((null gnus-refer-article-method)
8438 (list gnus-current-select-method gnus-select-method))
8439 ;; Current.
8440 ((eq 'current gnus-refer-article-method)
8441 (list gnus-current-select-method))
8442 ;; List of select methods.
d4dfaa19
DL
8443 ((not (and (symbolp (car gnus-refer-article-method))
8444 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
8445 (let (out)
8446 (dolist (method gnus-refer-article-method)
8447 (push (if (eq 'current method)
8448 gnus-current-select-method
8449 method)
8450 out))
8451 (nreverse out)))
8452 ;; One single select method.
8453 (t
8454 (list gnus-refer-article-method))))
6748645f
LMI
8455
8456(defun gnus-summary-edit-parameters ()
8457 "Edit the group parameters of the current group."
8458 (interactive)
8459 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 8460
16409b0b
GM
8461(defun gnus-summary-customize-parameters ()
8462 "Customize the group parameters of the current group."
8463 (interactive)
8464 (gnus-group-customize gnus-newsgroup-name))
8465
eec82323
LMI
8466(defun gnus-summary-enter-digest-group (&optional force)
8467 "Enter an nndoc group based on the current article.
8468If FORCE, force a digest interpretation. If not, try
8469to guess what the document format is."
8470 (interactive "P")
eec82323 8471 (let ((conf gnus-current-window-configuration))
23f87bed
MB
8472 (save-window-excursion
8473 (save-excursion
8474 (let (gnus-article-prepare-hook
8475 gnus-display-mime-function
8476 gnus-break-pages)
8477 (gnus-summary-select-article))))
eec82323
LMI
8478 (setq gnus-current-window-configuration conf)
8479 (let* ((name (format "%s-%d"
8480 (gnus-group-prefixed-name
8481 gnus-newsgroup-name (list 'nndoc ""))
8482 (save-excursion
8483 (set-buffer gnus-summary-buffer)
8484 gnus-current-article)))
8485 (ogroup gnus-newsgroup-name)
8486 (params (append (gnus-info-params (gnus-get-info ogroup))
8487 (list (cons 'to-group ogroup))
23f87bed 8488 (list (cons 'parent-group ogroup))
eec82323
LMI
8489 (list (cons 'save-article-group ogroup))))
8490 (case-fold-search t)
8491 (buf (current-buffer))
16409b0b 8492 dig to-address)
eec82323 8493 (save-excursion
16409b0b
GM
8494 (set-buffer gnus-original-article-buffer)
8495 ;; Have the digest group inherit the main mail address of
8496 ;; the parent article.
23f87bed
MB
8497 (when (setq to-address (or (gnus-fetch-field "reply-to")
8498 (gnus-fetch-field "from")))
343d6628
MB
8499 (setq params
8500 (append
8501 (list (cons 'to-address
8502 (funcall gnus-decode-encoded-address-function
8503 to-address))))))
eec82323
LMI
8504 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8505 (insert-buffer-substring gnus-original-article-buffer)
8506 ;; Remove lines that may lead nndoc to misinterpret the
8507 ;; document type.
8508 (narrow-to-region
8509 (goto-char (point-min))
8510 (or (search-forward "\n\n" nil t) (point)))
8511 (goto-char (point-min))
16409b0b 8512 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8513 (widen))
8514 (unwind-protect
23f87bed 8515 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
8516 (gnus-newsgroup-ephemeral-ignored-charsets
8517 gnus-newsgroup-ignored-charsets))
8518 (gnus-group-read-ephemeral-group
8519 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8520 (nndoc-article-type
23f87bed
MB
8521 ,(if force 'mbox 'guess)))
8522 t nil nil nil
8523 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8524 "ADAPT")))))
16409b0b 8525 ;; Make all postings to this group go to the parent group.
23f87bed
MB
8526 (nconc (gnus-info-params (gnus-get-info name))
8527 params)
8528 ;; Couldn't select this doc group.
8529 (switch-to-buffer buf)
8530 (gnus-set-global-variables)
8531 (gnus-configure-windows 'summary)
8532 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
8533 (kill-buffer dig)))))
8534
8535(defun gnus-summary-read-document (n)
8536 "Open a new group based on the current article(s).
8537This will allow you to read digests and other similar
8538documents as newsgroups.
8539Obeys the standard process/prefix convention."
8540 (interactive "P")
8541 (let* ((articles (gnus-summary-work-articles n))
8542 (ogroup gnus-newsgroup-name)
8543 (params (append (gnus-info-params (gnus-get-info ogroup))
8544 (list (cons 'to-group ogroup))))
8545 article group egroup groups vgroup)
8546 (while (setq article (pop articles))
8547 (setq group (format "%s-%d" gnus-newsgroup-name article))
8548 (gnus-summary-remove-process-mark article)
8549 (when (gnus-summary-display-article article)
8550 (save-excursion
16409b0b 8551 (with-temp-buffer
eec82323
LMI
8552 (insert-buffer-substring gnus-original-article-buffer)
8553 ;; Remove some headers that may lead nndoc to make
8554 ;; the wrong guess.
8555 (message-narrow-to-head)
8556 (goto-char (point-min))
8557 (delete-matching-lines "^\\(Path\\):\\|^From ")
8558 (widen)
8559 (if (setq egroup
8560 (gnus-group-read-ephemeral-group
8561 group `(nndoc ,group (nndoc-address ,(current-buffer))
8562 (nndoc-article-type guess))
8563 t nil t))
8564 (progn
23f87bed 8565 ;; Make all postings to this group go to the parent group.
eec82323
LMI
8566 (nconc (gnus-info-params (gnus-get-info egroup))
8567 params)
8568 (push egroup groups))
8569 ;; Couldn't select this doc group.
8570 (gnus-error 3 "Article couldn't be entered"))))))
8571 ;; Now we have selected all the documents.
8572 (cond
8573 ((not groups)
8574 (error "None of the articles could be interpreted as documents"))
8575 ((gnus-group-read-ephemeral-group
8576 (setq vgroup (format
8577 "nnvirtual:%s-%s" gnus-newsgroup-name
8578 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8579 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8580 t
8581 (cons (current-buffer) 'summary)))
8582 (t
8583 (error "Couldn't select virtual nndoc group")))))
8584
8585(defun gnus-summary-isearch-article (&optional regexp-p)
8586 "Do incremental search forward on the current article.
8587If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8588 (interactive "P")
eec82323
LMI
8589 (gnus-summary-select-article)
8590 (gnus-configure-windows 'article)
8591 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
8592 (save-restriction
8593 (widen)
8594 (isearch-forward regexp-p))))
eec82323
LMI
8595
8596(defun gnus-summary-search-article-forward (regexp &optional backward)
8597 "Search for an article containing REGEXP forward.
8598If BACKWARD, search backward instead."
8599 (interactive
8600 (list (read-string
8601 (format "Search article %s (regexp%s): "
8602 (if current-prefix-arg "backward" "forward")
8603 (if gnus-last-search-regexp
8604 (concat ", default " gnus-last-search-regexp)
8605 "")))
8606 current-prefix-arg))
eec82323
LMI
8607 (if (string-equal regexp "")
8608 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
8609 (setq gnus-last-search-regexp regexp)
8610 (setq gnus-article-before-search gnus-current-article))
8611 ;; Intentionally set gnus-last-article.
8612 (setq gnus-last-article gnus-article-before-search)
8613 (let ((gnus-last-article gnus-last-article))
8614 (if (gnus-summary-search-article regexp backward)
8615 (gnus-summary-show-thread)
abc40aab 8616 (signal 'search-failed (list regexp)))))
eec82323
LMI
8617
8618(defun gnus-summary-search-article-backward (regexp)
8619 "Search for an article containing REGEXP backward."
8620 (interactive
8621 (list (read-string
8622 (format "Search article backward (regexp%s): "
8623 (if gnus-last-search-regexp
8624 (concat ", default " gnus-last-search-regexp)
8625 "")))))
8626 (gnus-summary-search-article-forward regexp 'backward))
8627
8628(defun gnus-summary-search-article (regexp &optional backward)
8629 "Search for an article containing REGEXP.
8630Optional argument BACKWARD means do search for backward.
8631`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
8632 ;; We have to require this here to make sure that the following
8633 ;; dynamic binding isn't shadowed by autoloading.
8634 (require 'gnus-async)
16409b0b 8635 (require 'gnus-art)
eec82323 8636 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 8637 (gnus-article-prepare-hook nil)
eec82323
LMI
8638 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8639 (gnus-use-article-prefetch nil)
8640 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 8641 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
8642 (gnus-visual nil)
8643 (gnus-keep-backlog nil)
8644 (gnus-break-pages nil)
8645 (gnus-summary-display-arrow nil)
8646 (gnus-updated-mode-lines nil)
8647 (gnus-auto-center-summary nil)
eec82323 8648 (sum (current-buffer))
16409b0b 8649 (gnus-display-mime-function nil)
eec82323
LMI
8650 (found nil)
8651 point)
8652 (gnus-save-hidden-threads
8653 (gnus-summary-select-article)
8654 (set-buffer gnus-article-buffer)
16409b0b 8655 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
8656 (when backward
8657 (forward-line -1))
8658 (while (not found)
8659 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8660 (if (if backward
8661 (re-search-backward regexp nil t)
8662 (re-search-forward regexp nil t))
8663 ;; We found the regexp.
8664 (progn
8665 (setq found 'found)
8666 (beginning-of-line)
8667 (set-window-start
8668 (get-buffer-window (current-buffer))
8669 (point))
8670 (forward-line 1)
16409b0b
GM
8671 (set-window-point
8672 (get-buffer-window (current-buffer))
8673 (point))
eec82323
LMI
8674 (set-buffer sum)
8675 (setq point (point)))
8676 ;; We didn't find it, so we go to the next article.
8677 (set-buffer sum)
8678 (setq found 'not)
8679 (while (eq found 'not)
8680 (if (not (if backward (gnus-summary-find-prev)
8681 (gnus-summary-find-next)))
8682 ;; No more articles.
8683 (setq found t)
8684 ;; Select the next article and adjust point.
8685 (unless (gnus-summary-article-sparse-p
8686 (gnus-summary-article-number))
8687 (setq found nil)
8688 (gnus-summary-select-article)
8689 (set-buffer gnus-article-buffer)
8690 (widen)
8691 (goto-char (if backward (point-max) (point-min))))))))
8692 (gnus-message 7 ""))
8693 ;; Return whether we found the regexp.
8694 (when (eq found 'found)
8695 (goto-char point)
8696 (gnus-summary-show-thread)
8697 (gnus-summary-goto-subject gnus-current-article)
8698 (gnus-summary-position-point)
8699 t)))
8700
23f87bed
MB
8701(defun gnus-find-matching-articles (header regexp)
8702 "Return a list of all articles that match REGEXP on HEADER.
8703This search includes all articles in the current group that Gnus has
8704fetched headers for, whether they are displayed or not."
8705 (let ((articles nil)
8706 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8707 (case-fold-search t))
8708 (dolist (header gnus-newsgroup-headers)
8709 (when (string-match regexp (funcall func header))
8710 (push (mail-header-number header) articles)))
8711 (nreverse articles)))
8712
eec82323 8713(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 8714 not-case-fold not-matching)
eec82323
LMI
8715 "Return a list of all articles that match REGEXP on HEADER.
8716The search stars on the current article and goes forwards unless
8717BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8718If UNREAD is non-nil, only unread articles will
8719be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 8720in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
8721not match REGEXP on HEADER."
8722 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
8723 articles d func)
8724 (if (consp header)
8725 (if (eq (car header) 'extra)
8726 (setq func
8727 `(lambda (h)
8728 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8729 "")))
8730 (error "%s is an invalid header" header))
8731 (unless (fboundp (intern (concat "mail-header-" header)))
8732 (error "%s is not a valid header" header))
8733 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
8734 (dolist (d (if (eq backward 'all)
8735 gnus-newsgroup-data
8736 (gnus-data-find-list
8737 (gnus-summary-article-number)
8738 (gnus-data-list backward))))
8739 (when (and (or (not unread) ; We want all articles...
8740 (gnus-data-unread-p d)) ; Or just unreads.
8741 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8742 (if not-matching
a1506d29 8743 (not (string-match
47b63dfa
SZ
8744 regexp
8745 (funcall func (gnus-data-header d))))
8746 (string-match regexp
8747 (funcall func (gnus-data-header d)))))
8748 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
8749 (nreverse articles)))
8750
8751(defun gnus-summary-execute-command (header regexp command &optional backward)
8752 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8753If HEADER is an empty string (or nil), the match is done on the entire
8754article. If BACKWARD (the prefix) is non-nil, search backward instead."
8755 (interactive
8756 (list (let ((completion-ignore-case t))
8757 (completing-read
8758 "Header name: "
23f87bed
MB
8759 (mapcar (lambda (header) (list (format "%s" header)))
8760 (append
8761 '("Number" "Subject" "From" "Lines" "Date"
8762 "Message-ID" "Xref" "References" "Body")
8763 gnus-extra-headers))
eec82323
LMI
8764 nil 'require-match))
8765 (read-string "Regexp: ")
8766 (read-key-sequence "Command: ")
8767 current-prefix-arg))
8768 (when (equal header "Body")
8769 (setq header ""))
eec82323
LMI
8770 ;; Hidden thread subtrees must be searched as well.
8771 (gnus-summary-show-all-threads)
8772 ;; We don't want to change current point nor window configuration.
8773 (save-excursion
8774 (save-window-excursion
23f87bed
MB
8775 (let (gnus-visual
8776 gnus-treat-strip-trailing-blank-lines
8777 gnus-treat-strip-leading-blank-lines
8778 gnus-treat-strip-multiple-blank-lines
8779 gnus-treat-hide-boring-headers
8780 gnus-treat-fold-newsgroups
8781 gnus-article-prepare-hook)
8782 (gnus-message 6 "Executing %s..." (key-description command))
8783 ;; We'd like to execute COMMAND interactively so as to give arguments.
8784 (gnus-execute header regexp
8785 `(call-interactively ',(key-binding command))
8786 backward)
8787 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
8788
8789(defun gnus-summary-beginning-of-article ()
8790 "Scroll the article back to the beginning."
8791 (interactive)
eec82323
LMI
8792 (gnus-summary-select-article)
8793 (gnus-configure-windows 'article)
8794 (gnus-eval-in-buffer-window gnus-article-buffer
8795 (widen)
8796 (goto-char (point-min))
23f87bed 8797 (when gnus-break-pages
eec82323
LMI
8798 (gnus-narrow-to-page))))
8799
8800(defun gnus-summary-end-of-article ()
8801 "Scroll to the end of the article."
8802 (interactive)
eec82323
LMI
8803 (gnus-summary-select-article)
8804 (gnus-configure-windows 'article)
8805 (gnus-eval-in-buffer-window gnus-article-buffer
8806 (widen)
8807 (goto-char (point-max))
8808 (recenter -3)
23f87bed
MB
8809 (when gnus-break-pages
8810 (when (re-search-backward page-delimiter nil t)
8811 (narrow-to-region (match-end 0) (point-max)))
eec82323
LMI
8812 (gnus-narrow-to-page))))
8813
23f87bed
MB
8814(defun gnus-summary-print-truncate-and-quote (string &optional len)
8815 "Truncate to LEN and quote all \"(\"'s in STRING."
8816 (gnus-replace-in-string (if (and len (> (length string) len))
8817 (substring string 0 len)
8818 string)
8819 "[()]" "\\\\\\&"))
8820
6748645f 8821(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
8822 "Generate and print a PostScript image of the process-marked (mail) articles.
8823
8824If used interactively, print the current article if none are
8825process-marked. With prefix arg, prompt the user for the name of the
8826file to save in.
6748645f 8827
23f87bed
MB
8828When used from Lisp, accept two optional args FILENAME and N. N means
8829to print the next N articles. If N is negative, print the N previous
8830articles. If N is nil and articles have been marked with the process
8831mark, print these instead.
eec82323 8832
16409b0b 8833If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
8834printer. If FILENAME is a string, save the PostScript image in a file with
8835that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 8836to save in."
676a7cc9 8837 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
8838 (dolist (article (gnus-summary-work-articles n))
8839 (gnus-summary-select-article nil nil 'pseudo article)
8840 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 8841 (gnus-print-buffer))
676a7cc9
SZ
8842 (gnus-summary-remove-process-mark article))
8843 (ps-despool filename))
eec82323 8844
23f87bed
MB
8845(defun gnus-print-buffer ()
8846 (let ((buffer (generate-new-buffer " *print*")))
8847 (unwind-protect
8848 (progn
8849 (copy-to-buffer buffer (point-min) (point-max))
8850 (set-buffer buffer)
8851 (gnus-remove-text-with-property 'gnus-decoration)
8852 (when (gnus-visual-p 'article-highlight 'highlight)
8853 ;; Copy-to-buffer doesn't copy overlay. So redo
8854 ;; highlight.
8855 (let ((gnus-article-buffer buffer))
8856 (gnus-article-highlight-citation t)
8857 (gnus-article-highlight-signature)
8858 (gnus-article-emphasize)
8859 (gnus-article-delete-invisible-text)))
8860 (let ((ps-left-header
8861 (list
8862 (concat "("
8863 (gnus-summary-print-truncate-and-quote
8864 (mail-header-subject gnus-current-headers)
8865 66) ")")
8866 (concat "("
8867 (gnus-summary-print-truncate-and-quote
8868 (mail-header-from gnus-current-headers)
8869 45) ")")))
8870 (ps-right-header
8871 (list
8872 "/pagenumberstring load"
8873 (concat "("
8874 (mail-header-date gnus-current-headers) ")"))))
8875 (gnus-run-hooks 'gnus-ps-print-hook)
8876 (save-excursion
8877 (if window-system
8878 (ps-spool-buffer-with-faces)
8879 (ps-spool-buffer)))))
8880 (kill-buffer buffer))))
8881
eec82323 8882(defun gnus-summary-show-article (&optional arg)
23f87bed 8883 "Force redisplaying of the current article.
16409b0b
GM
8884If ARG (the prefix) is a number, show the article with the charset
8885defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 8886input.
16409b0b 8887If ARG (the prefix) is non-nil and not a number, show the raw article
23f87bed
MB
8888without any article massaging functions being run. Normally, the key
8889strokes are `C-u g'."
eec82323 8890 (interactive "P")
16409b0b
GM
8891 (cond
8892 ((numberp arg)
23f87bed 8893 (gnus-summary-show-article t)
16409b0b
GM
8894 (let ((gnus-newsgroup-charset
8895 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
8896 (mm-read-coding-system
8897 "View as charset: " ;; actually it is coding system.
8898 (save-excursion
8899 (set-buffer gnus-article-buffer)
8900 (mm-detect-coding-region (point) (point-max))))))
16409b0b 8901 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
8902 (gnus-summary-select-article nil 'force)
8903 (let ((deps gnus-newsgroup-dependencies)
8904 head header lines)
8905 (save-excursion
8906 (set-buffer gnus-original-article-buffer)
8907 (save-restriction
8908 (message-narrow-to-head)
8909 (setq head (buffer-string))
8910 (goto-char (point-min))
8911 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8912 (goto-char (point-max))
8913 (widen)
8914 (setq lines (1- (count-lines (point) (point-max))))))
8915 (with-temp-buffer
8916 (insert (format "211 %d Article retrieved.\n"
8917 (cdr gnus-article-current)))
8918 (insert head)
8919 (if lines (insert (format "Lines: %d\n" lines)))
8920 (insert ".\n")
8921 (let ((nntp-server-buffer (current-buffer)))
8922 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8923 (gnus-data-set-header
8924 (gnus-data-find (cdr gnus-article-current))
8925 header)
8926 (gnus-summary-update-article-line
8927 (cdr gnus-article-current) header)
8928 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8929 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
8930 ((not arg)
8931 ;; Select the article the normal way.
8932 (gnus-summary-select-article nil 'force))
8933 (t
8934 ;; We have to require this here to make sure that the following
8935 ;; dynamic binding isn't shadowed by autoloading.
8936 (require 'gnus-async)
8937 (require 'gnus-art)
eec82323
LMI
8938 ;; Bind the article treatment functions to nil.
8939 (let ((gnus-have-all-headers t)
eec82323 8940 gnus-article-prepare-hook
16409b0b
GM
8941 gnus-article-decode-hook
8942 gnus-display-mime-function
8943 gnus-break-pages)
8944 ;; Destroy any MIME parts.
8945 (when (gnus-buffer-live-p gnus-article-buffer)
8946 (save-excursion
8947 (set-buffer gnus-article-buffer)
8948 (mm-destroy-parts gnus-article-mime-handles)
8949 ;; Set it to nil for safety reason.
8950 (setq gnus-article-mime-handle-alist nil)
8951 (setq gnus-article-mime-handles nil)))
8952 (gnus-summary-select-article nil 'force))))
eec82323
LMI
8953 (gnus-summary-goto-subject gnus-current-article)
8954 (gnus-summary-position-point))
8955
23f87bed
MB
8956(defun gnus-summary-show-raw-article ()
8957 "Show the raw article without any article massaging functions being run."
8958 (interactive)
8959 (gnus-summary-show-article t))
8960
eec82323
LMI
8961(defun gnus-summary-verbose-headers (&optional arg)
8962 "Toggle permanent full header display.
8963If ARG is a positive number, turn header display on.
8964If ARG is a negative number, turn header display off."
8965 (interactive "P")
eec82323
LMI
8966 (setq gnus-show-all-headers
8967 (cond ((or (not (numberp arg))
8968 (zerop arg))
8969 (not gnus-show-all-headers))
8970 ((natnump arg)
8971 t)))
8972 (gnus-summary-show-article))
8973
8974(defun gnus-summary-toggle-header (&optional arg)
8975 "Show the headers if they are hidden, or hide them if they are shown.
8976If ARG is a positive number, show the entire header.
8977If ARG is a negative number, hide the unwanted header lines."
8978 (interactive "P")
23f87bed
MB
8979 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8980 (get-buffer-window gnus-article-buffer t))))
8981 (with-current-buffer gnus-article-buffer
8982 (widen)
8983 (article-narrow-to-head)
16409b0b
GM
8984 (let* ((buffer-read-only nil)
8985 (inhibit-point-motion-hooks t)
23f87bed
MB
8986 (hidden (if (numberp arg)
8987 (>= arg 0)
f0096211
MB
8988 (or (not (looking-at "[^ \t\n]+:"))
8989 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
8990 s e)
8991 (delete-region (point-min) (point-max))
667e0ba6
SM
8992 (with-current-buffer gnus-original-article-buffer
8993 (goto-char (setq s (point-min)))
23f87bed
MB
8994 (setq e (if (search-forward "\n\n" nil t)
8995 (1- (point))
8996 (point-max))))
667e0ba6 8997 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
8998 (run-hooks 'gnus-article-decode-hook)
8999 (if hidden
9000 (let ((gnus-treat-hide-headers nil)
9001 (gnus-treat-hide-boring-headers nil))
9002 (gnus-delete-wash-type 'headers)
9003 (gnus-treat-article 'head))
9004 (gnus-treat-article 'head))
9005 (widen)
9006 (if window
9007 (set-window-start window (goto-char (point-min))))
9008 (if gnus-break-pages
9009 (gnus-narrow-to-page)
9010 (when (gnus-visual-p 'page-marker)
9011 (let ((buffer-read-only nil))
9012 (gnus-remove-text-with-property 'gnus-prev)
9013 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9014 (gnus-set-mode-line 'article)))))
eec82323
LMI
9015
9016(defun gnus-summary-show-all-headers ()
9017 "Make all header lines visible."
9018 (interactive)
23f87bed 9019 (gnus-summary-toggle-header 1))
eec82323 9020
eec82323
LMI
9021(defun gnus-summary-caesar-message (&optional arg)
9022 "Caesar rotate the current article by 13.
9023The numerical prefix specifies how many places to rotate each letter
9024forward."
9025 (interactive "P")
eec82323
LMI
9026 (gnus-summary-select-article)
9027 (let ((mail-header-separator ""))
9028 (gnus-eval-in-buffer-window gnus-article-buffer
9029 (save-restriction
9030 (widen)
9031 (let ((start (window-start))
9032 buffer-read-only)
9033 (message-caesar-buffer-body arg)
ff4d3926
MB
9034 (set-window-start (get-buffer-window (current-buffer)) start)))))
9035 ;; Create buttons and stuff...
9036 (gnus-treat-article nil))
eec82323 9037
23f87bed
MB
9038(autoload 'unmorse-region "morse"
9039 "Convert morse coded text in region to ordinary ASCII text."
9040 t)
9041
9042(defun gnus-summary-morse-message (&optional arg)
9043 "Morse decode the current article."
9044 (interactive "P")
9045 (gnus-summary-select-article)
9046 (let ((mail-header-separator ""))
9047 (gnus-eval-in-buffer-window gnus-article-buffer
9048 (save-excursion
9049 (save-restriction
9050 (widen)
9051 (let ((pos (window-start))
9052 buffer-read-only)
9053 (goto-char (point-min))
9054 (when (message-goto-body)
9055 (gnus-narrow-to-body))
9056 (goto-char (point-min))
9057