Detect if text foreground and background are equals
[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
5a9dffec 13;; the Free Software Foundation; either version 3, or (at your option)
eec82323
LMI
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
4b70e299
MB
1032(defcustom gnus-newsgroup-maximum-articles nil
1033 "The maximum number of articles a newsgroup.
1034If this is a number, old articles in a newsgroup exceeding this number
1035are silently ignored. If it is nil, no article is ignored. Note that
1036setting this variable to a number might prevent you from reading very
1037old articles."
1038 :group 'gnus-group-select
1039 :version "22.2"
1040 :type '(choice (const :tag "No limit" nil)
1041 integer))
1042
23f87bed
MB
1043(gnus-define-group-parameter
1044 ignored-charsets
1045 :type list
1046 :function-document
1047 "Return the ignored charsets of GROUP."
1048 :variable gnus-group-ignored-charsets-alist
1049 :variable-default
1050 '(("alt\\.chinese\\.text" iso-8859-1))
1051 :variable-document
1052 "Alist of regexps (to match group names) and charsets that should be ignored.
16409b0b
GM
1053When these charsets are used in the \"charset\" parameter, the
1054default charset will be used instead."
23f87bed
MB
1055 :variable-group gnus-charset
1056 :variable-type '(repeat (cons (regexp :tag "Group")
1057 (repeat symbol)))
1058 :parameter-type '(choice :tag "Ignored charsets"
1059 :value nil
1060 (repeat (symbol)))
1061 :parameter-document "\
1062List of charsets that should be ignored.
1063
1064When these charsets are used in the \"charset\" parameter, the
1065default charset will be used instead.")
16409b0b
GM
1066
1067(defcustom gnus-group-highlight-words-alist nil
1068 "Alist of group regexps and highlight regexps.
1069This variable uses the same syntax as `gnus-emphasis-alist'."
58e39d05 1070 :version "21.1"
16409b0b
GM
1071 :type '(repeat (cons (regexp :tag "Group")
1072 (repeat (list (regexp :tag "Highlight regexp")
1073 (number :tag "Group for entire word" 0)
1074 (number :tag "Group for displayed part" 0)
1075 (symbol :tag "Face"
1076 gnus-emphasis-highlight-words)))))
1077 :group 'gnus-summary-visual)
1078
1079(defcustom gnus-summary-show-article-charset-alist
1080 nil
1081 "Alist of number and charset.
1082The article will be shown with the charset corresponding to the
1083numbered argument.
1084For example: ((1 . cn-gb-2312) (2 . big5))."
58e39d05 1085 :version "21.1"
16409b0b
GM
1086 :type '(repeat (cons (number :tag "Argument" 1)
1087 (symbol :tag "Charset")))
1088 :group 'gnus-charset)
1089
1090(defcustom gnus-preserve-marks t
1091 "Whether marks are preserved when moving, copying and respooling messages."
58e39d05 1092 :version "21.1"
16409b0b
GM
1093 :type 'boolean
1094 :group 'gnus-summary-marks)
1095
1096(defcustom gnus-alter-articles-to-read-function nil
1097 "Function to be called to alter the list of articles to be selected."
8fc7a9a1 1098 :type '(choice (const nil) function)
16409b0b
GM
1099 :group 'gnus-summary)
1100
1101(defcustom gnus-orphan-score nil
1102 "*All orphans get this score added. Set in the score file."
1103 :group 'gnus-score-default
1104 :type '(choice (const nil)
1105 integer))
1106
8b93df01 1107(defcustom gnus-summary-save-parts-default-mime "image/.*"
23f87bed
MB
1108 "*A regexp to match MIME parts when saving multiple parts of a
1109message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1110This regexp will be used by default when prompting the user for which
1111type of files to save."
8b93df01
DL
1112 :group 'gnus-summary
1113 :type 'regexp)
1114
23f87bed
MB
1115(defcustom gnus-read-all-available-headers nil
1116 "Whether Gnus should parse all headers made available to it.
1117This is mostly relevant for slow back ends where the user may
1118wish to widen the summary buffer to include all headers
1119that were fetched. Say, for nnultimate groups."
bf247b6e 1120 :version "22.1"
23f87bed
MB
1121 :group 'gnus-summary
1122 :type '(choice boolean regexp))
1123
1124(defcustom gnus-summary-muttprint-program "muttprint"
1125 "Command (and optional arguments) used to run Muttprint."
bf247b6e 1126 :version "22.1"
23f87bed
MB
1127 :group 'gnus-summary
1128 :type 'string)
1129
1130(defcustom gnus-article-loose-mime nil
1131 "If non-nil, don't require MIME-Version header.
1132Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
a08b59c9 1133supply the MIME-Version header or deliberately strip it from the mail.
23f87bed
MB
1134Set it to non-nil, Gnus will treat some articles as MIME even if
1135the MIME-Version header is missed."
bf247b6e 1136 :version "22.1"
23f87bed
MB
1137 :type 'boolean
1138 :group 'gnus-article-mime)
1139
1140(defcustom gnus-article-emulate-mime t
1141 "If non-nil, use MIME emulation for uuencode and the like.
1142This means that Gnus will search message bodies for text that look
1143like uuencoded bits, yEncoded bits, and so on, and present that using
1144the normal Gnus MIME machinery."
bf247b6e 1145 :version "22.1"
23f87bed
MB
1146 :type 'boolean
1147 :group 'gnus-article-mime)
8b93df01 1148
eec82323
LMI
1149;;; Internal variables
1150
23f87bed 1151(defvar gnus-summary-display-cache nil)
16409b0b
GM
1152(defvar gnus-article-mime-handles nil)
1153(defvar gnus-article-decoded-p nil)
23f87bed
MB
1154(defvar gnus-article-charset nil)
1155(defvar gnus-article-ignored-charsets nil)
eec82323
LMI
1156(defvar gnus-scores-exclude-files nil)
1157(defvar gnus-page-broken nil)
1158
1159(defvar gnus-original-article nil)
1160(defvar gnus-article-internal-prepare-hook nil)
1161(defvar gnus-newsgroup-process-stack nil)
1162
1163(defvar gnus-thread-indent-array nil)
1164(defvar gnus-thread-indent-array-level gnus-thread-indent-level)
16409b0b
GM
1165(defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1166 "Function called to sort the articles within a thread after it has been gathered together.")
eec82323 1167
8b93df01 1168(defvar gnus-summary-save-parts-type-history nil)
23f87bed 1169(defvar gnus-summary-save-parts-last-directory mm-default-directory)
8b93df01 1170
eec82323
LMI
1171;; Avoid highlighting in kill files.
1172(defvar gnus-summary-inhibit-highlight nil)
1173(defvar gnus-newsgroup-selected-overlay nil)
1174(defvar gnus-inhibit-limiting nil)
1175(defvar gnus-newsgroup-adaptive-score-file nil)
1176(defvar gnus-current-score-file nil)
1177(defvar gnus-current-move-group nil)
1178(defvar gnus-current-copy-group nil)
1179(defvar gnus-current-crosspost-group nil)
23f87bed 1180(defvar gnus-newsgroup-display nil)
eec82323
LMI
1181
1182(defvar gnus-newsgroup-dependencies nil)
1183(defvar gnus-newsgroup-adaptive nil)
1184(defvar gnus-summary-display-article-function nil)
1185(defvar gnus-summary-highlight-line-function nil
1186 "Function called after highlighting a summary line.")
1187
1188(defvar gnus-summary-line-format-alist
1189 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1190 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1191 (?s gnus-tmp-subject-or-nil ?s)
1192 (?n gnus-tmp-name ?s)
1193 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1194 ?s)
1195 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1196 gnus-tmp-from) ?s)
1197 (?F gnus-tmp-from ?s)
1198 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1199 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1200 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
6748645f 1201 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
eec82323
LMI
1202 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1203 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1204 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
23f87bed
MB
1205 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1206 (?L gnus-tmp-lines ?s)
1207 (?O gnus-tmp-downloaded ?c)
eec82323
LMI
1208 (?I gnus-tmp-indentation ?s)
1209 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1210 (?R gnus-tmp-replied ?c)
1211 (?\[ gnus-tmp-opening-bracket ?c)
1212 (?\] gnus-tmp-closing-bracket ?c)
1213 (?\> (make-string gnus-tmp-level ? ) ?s)
1214 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1215 (?i gnus-tmp-score ?d)
1216 (?z gnus-tmp-score-char ?c)
1217 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1218 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1219 (?U gnus-tmp-unread ?c)
23f87bed
MB
1220 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1221 ?s)
eec82323
LMI
1222 (?t (gnus-summary-number-of-articles-in-thread
1223 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1224 ?d)
1225 (?e (gnus-summary-number-of-articles-in-thread
1226 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1227 ?c)
1228 (?u gnus-tmp-user-defined ?s)
23f87bed
MB
1229 (?P (gnus-pick-line-number) ?d)
1230 (?B gnus-tmp-thread-tree-header-string ?s)
1231 (user-date (gnus-user-date
1232 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
16409b0b
GM
1233 "An alist of format specifications that can appear in summary lines.
1234These are paired with what variables they correspond with, along with
1235the type of the variable (string, integer, character, etc).")
eec82323
LMI
1236
1237(defvar gnus-summary-dummy-line-format-alist
1238 `((?S gnus-tmp-subject ?s)
1239 (?N gnus-tmp-number ?d)
1240 (?u gnus-tmp-user-defined ?s)))
1241
1242(defvar gnus-summary-mode-line-format-alist
1243 `((?G gnus-tmp-group-name ?s)
1244 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1245 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1246 (?A gnus-tmp-article-number ?d)
1247 (?Z gnus-tmp-unread-and-unselected ?s)
1248 (?V gnus-version ?s)
1249 (?U gnus-tmp-unread-and-unticked ?d)
1250 (?S gnus-tmp-subject ?s)
1251 (?e gnus-tmp-unselected ?d)
1252 (?u gnus-tmp-user-defined ?s)
1253 (?d (length gnus-newsgroup-dormant) ?d)
1254 (?t (length gnus-newsgroup-marked) ?d)
23f87bed 1255 (?h (length gnus-newsgroup-spam-marked) ?d)
eec82323 1256 (?r (length gnus-newsgroup-reads) ?d)
6748645f 1257 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
eec82323
LMI
1258 (?E gnus-newsgroup-expunged-tally ?d)
1259 (?s (gnus-current-score-file-nondirectory) ?s)))
1260
1261(defvar gnus-last-search-regexp nil
1262 "Default regexp for article search command.")
1263
1264(defvar gnus-last-shell-command nil
1265 "Default shell command on article.")
1266
23f87bed
MB
1267(defvar gnus-newsgroup-agentized nil
1268 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
eec82323
LMI
1269(defvar gnus-newsgroup-begin nil)
1270(defvar gnus-newsgroup-end nil)
1271(defvar gnus-newsgroup-last-rmail nil)
1272(defvar gnus-newsgroup-last-mail nil)
1273(defvar gnus-newsgroup-last-folder nil)
1274(defvar gnus-newsgroup-last-file nil)
26c9afc3 1275(defvar gnus-newsgroup-last-directory nil)
eec82323
LMI
1276(defvar gnus-newsgroup-auto-expire nil)
1277(defvar gnus-newsgroup-active nil)
1278
1279(defvar gnus-newsgroup-data nil)
1280(defvar gnus-newsgroup-data-reverse nil)
1281(defvar gnus-newsgroup-limit nil)
1282(defvar gnus-newsgroup-limits nil)
23f87bed 1283(defvar gnus-summary-use-undownloaded-faces nil)
eec82323
LMI
1284
1285(defvar gnus-newsgroup-unreads nil
23f87bed 1286 "Sorted list of unread articles in the current newsgroup.")
eec82323
LMI
1287
1288(defvar gnus-newsgroup-unselected nil
23f87bed 1289 "Sorted list of unselected unread articles in the current newsgroup.")
eec82323
LMI
1290
1291(defvar gnus-newsgroup-reads nil
1292 "Alist of read articles and article marks in the current newsgroup.")
1293
1294(defvar gnus-newsgroup-expunged-tally nil)
1295
1296(defvar gnus-newsgroup-marked nil
23f87bed
MB
1297 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1298
1299(defvar gnus-newsgroup-spam-marked nil
1300 "List of ranges of articles that have been marked as spam.")
eec82323
LMI
1301
1302(defvar gnus-newsgroup-killed nil
1303 "List of ranges of articles that have been through the scoring process.")
1304
1305(defvar gnus-newsgroup-cached nil
23f87bed 1306 "Sorted list of articles that come from the article cache.")
eec82323
LMI
1307
1308(defvar gnus-newsgroup-saved nil
1309 "List of articles that have been saved.")
1310
1311(defvar gnus-newsgroup-kill-headers nil)
1312
1313(defvar gnus-newsgroup-replied nil
1314 "List of articles that have been replied to in the current newsgroup.")
1315
23f87bed
MB
1316(defvar gnus-newsgroup-forwarded nil
1317 "List of articles that have been forwarded in the current newsgroup.")
1318
1319(defvar gnus-newsgroup-recent nil
1320 "List of articles that have are recent in the current newsgroup.")
1321
eec82323 1322(defvar gnus-newsgroup-expirable nil
23f87bed 1323 "Sorted list of articles in the current newsgroup that can be expired.")
eec82323
LMI
1324
1325(defvar gnus-newsgroup-processable nil
1326 "List of articles in the current newsgroup that can be processed.")
1327
6748645f 1328(defvar gnus-newsgroup-downloadable nil
23f87bed
MB
1329 "Sorted list of articles in the current newsgroup that can be processed.")
1330
1331(defvar gnus-newsgroup-unfetched nil
1332 "Sorted list of articles in the current newsgroup whose headers have
1333not been fetched into the agent.
1334
1335This list will always be a subset of gnus-newsgroup-undownloaded.")
6748645f
LMI
1336
1337(defvar gnus-newsgroup-undownloaded nil
23f87bed 1338 "List of articles in the current newsgroup that haven't been downloaded.")
6748645f
LMI
1339
1340(defvar gnus-newsgroup-unsendable nil
1341 "List of articles in the current newsgroup that won't be sent.")
1342
eec82323
LMI
1343(defvar gnus-newsgroup-bookmarks nil
1344 "List of articles in the current newsgroup that have bookmarks.")
1345
1346(defvar gnus-newsgroup-dormant nil
23f87bed
MB
1347 "Sorted list of dormant articles in the current newsgroup.")
1348
1349(defvar gnus-newsgroup-unseen nil
1350 "List of unseen articles in the current newsgroup.")
1351
1352(defvar gnus-newsgroup-seen nil
1353 "Range of seen articles in the current newsgroup.")
1354
1355(defvar gnus-newsgroup-articles nil
1356 "List of articles in the current newsgroup.")
eec82323
LMI
1357
1358(defvar gnus-newsgroup-scored nil
1359 "List of scored articles in the current newsgroup.")
1360
1361(defvar gnus-newsgroup-headers nil
1362 "List of article headers in the current newsgroup.")
1363
1364(defvar gnus-newsgroup-threads nil)
1365
1366(defvar gnus-newsgroup-prepared nil
1367 "Whether the current group has been prepared properly.")
1368
1369(defvar gnus-newsgroup-ancient nil
1370 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1371
1372(defvar gnus-newsgroup-sparse nil)
1373
1374(defvar gnus-current-article nil)
1375(defvar gnus-article-current nil)
1376(defvar gnus-current-headers nil)
1377(defvar gnus-have-all-headers nil)
1378(defvar gnus-last-article nil)
1379(defvar gnus-newsgroup-history nil)
16409b0b
GM
1380(defvar gnus-newsgroup-charset nil)
1381(defvar gnus-newsgroup-ephemeral-charset nil)
1382(defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
eec82323 1383
23f87bed
MB
1384(defvar gnus-article-before-search nil)
1385
1386(defvar gnus-summary-local-variables
eec82323
LMI
1387 '(gnus-newsgroup-name
1388 gnus-newsgroup-begin gnus-newsgroup-end
1389 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1390 gnus-newsgroup-last-folder gnus-newsgroup-last-file
26c9afc3 1391 gnus-newsgroup-last-directory
eec82323
LMI
1392 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1393 gnus-newsgroup-unselected gnus-newsgroup-marked
23f87bed 1394 gnus-newsgroup-spam-marked
eec82323 1395 gnus-newsgroup-reads gnus-newsgroup-saved
23f87bed
MB
1396 gnus-newsgroup-replied gnus-newsgroup-forwarded
1397 gnus-newsgroup-recent
1398 gnus-newsgroup-expirable
eec82323 1399 gnus-newsgroup-processable gnus-newsgroup-killed
6748645f 1400 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
23f87bed
MB
1401 gnus-newsgroup-unfetched
1402 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1403 gnus-newsgroup-seen gnus-newsgroup-articles
eec82323
LMI
1404 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1405 gnus-newsgroup-headers gnus-newsgroup-threads
1406 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1407 gnus-current-article gnus-current-headers gnus-have-all-headers
1408 gnus-last-article gnus-article-internal-prepare-hook
1409 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1410 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1411 gnus-thread-expunge-below
16409b0b
GM
1412 gnus-score-alist gnus-current-score-file
1413 (gnus-summary-expunge-below . global)
eec82323 1414 (gnus-summary-mark-below . global)
16409b0b 1415 (gnus-orphan-score . global)
eec82323
LMI
1416 gnus-newsgroup-active gnus-scores-exclude-files
1417 gnus-newsgroup-history gnus-newsgroup-ancient
1418 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1419 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1420 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1421 (gnus-newsgroup-expunged-tally . 0)
1422 gnus-cache-removable-articles gnus-newsgroup-cached
1423 gnus-newsgroup-data gnus-newsgroup-data-reverse
16409b0b 1424 gnus-newsgroup-limit gnus-newsgroup-limits
23f87bed
MB
1425 gnus-newsgroup-charset gnus-newsgroup-display
1426 gnus-summary-use-undownloaded-faces)
eec82323
LMI
1427 "Variables that are buffer-local to the summary buffers.")
1428
23f87bed
MB
1429(defvar gnus-newsgroup-variables nil
1430 "A list of variables that have separate values in different newsgroups.
1431A list of newsgroup (summary buffer) local variables, or cons of
1432variables and their default expressions to be evalled (when the default
1433values are not nil), that should be made global while the summary buffer
1434is active.
1435
1436Note: The default expressions will be evaluated (using function `eval')
1437before assignment to the local variable rather than just assigned to it.
1438If the default expression is the symbol `global', that symbol will not
1439be evaluated but the global value of the local variable will be used
1440instead.
1441
1442These variables can be used to set variables in the group parameters
1443while still allowing them to affect operations done in other buffers.
1444For example:
1445
1446\(setq gnus-newsgroup-variables
1447 '(message-use-followup-to
1448 (gnus-visible-headers .
1449 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1450")
1451
eec82323 1452;; Byte-compiler warning.
23f87bed
MB
1453(eval-when-compile
1454 ;; Bind features so that require will believe that gnus-sum has
1455 ;; already been loaded (avoids infinite recursion)
1456 (let ((features (cons 'gnus-sum features)))
1457 ;; Several of the declarations in gnus-sum are needed to load the
1458 ;; following files. Right now, these definitions have been
1459 ;; compiled but not defined (evaluated). We could either do a
1460 ;; eval-and-compile about all of the declarations or evaluate the
1461 ;; source file.
1462 (if (boundp 'gnus-newsgroup-variables)
1463 nil
1464 (load "gnus-sum.el" t t t))
1465 (require 'gnus)
1466 (require 'gnus-agent)
1467 (require 'gnus-art)))
eec82323 1468
16409b0b
GM
1469;; MIME stuff.
1470
1471(defvar gnus-decode-encoded-word-methods
1472 '(mail-decode-encoded-word-string)
1473 "List of methods used to decode encoded words.
1474
23f87bed
MB
1475This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1476is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1477\(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
16409b0b
GM
1478whose names match REGEXP.
1479
1480For example:
23f87bed 1481\((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
16409b0b
GM
1482 mail-decode-encoded-word-string
1483 (\"chinese\" . rfc1843-decode-string))")
1484
1485(defvar gnus-decode-encoded-word-methods-cache nil)
1486
1487(defun gnus-multi-decode-encoded-word-string (string)
1488 "Apply the functions from `gnus-encoded-word-methods' that match."
1489 (unless (and gnus-decode-encoded-word-methods-cache
1490 (eq gnus-newsgroup-name
1491 (car gnus-decode-encoded-word-methods-cache)))
1492 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1493 (mapcar (lambda (x)
1494 (if (symbolp x)
1495 (nconc gnus-decode-encoded-word-methods-cache (list x))
1496 (if (and gnus-newsgroup-name
1497 (string-match (car x) gnus-newsgroup-name))
1498 (nconc gnus-decode-encoded-word-methods-cache
1499 (list (cdr x))))))
23f87bed 1500 gnus-decode-encoded-word-methods))
16409b0b
GM
1501 (let ((xlist gnus-decode-encoded-word-methods-cache))
1502 (pop xlist)
1503 (while xlist
1504 (setq string (funcall (pop xlist) string))))
1505 string)
1506
eec82323
LMI
1507;; Subject simplification.
1508
6748645f 1509(defun gnus-simplify-whitespace (str)
16409b0b 1510 "Remove excessive whitespace from STR."
23f87bed
MB
1511 ;; Multiple spaces.
1512 (while (string-match "[ \t][ \t]+" str)
1513 (setq str (concat (substring str 0 (match-beginning 0))
1514 " "
1515 (substring str (match-end 0)))))
1516 ;; Leading spaces.
1517 (when (string-match "^[ \t]+" str)
1518 (setq str (substring str (match-end 0))))
1519 ;; Trailing spaces.
1520 (when (string-match "[ \t]+$" str)
1521 (setq str (substring str 0 (match-beginning 0))))
1522 str)
1523
1524(defun gnus-simplify-all-whitespace (str)
1525 "Remove all whitespace from STR."
1526 (while (string-match "[ \t\n]+" str)
1527 (setq str (replace-match "" nil nil str)))
1528 str)
6748645f 1529
eec82323
LMI
1530(defsubst gnus-simplify-subject-re (subject)
1531 "Remove \"Re:\" from subject lines."
23f87bed 1532 (if (string-match message-subject-re-regexp subject)
eec82323
LMI
1533 (substring subject (match-end 0))
1534 subject))
1535
1536(defun gnus-simplify-subject (subject &optional re-only)
1537 "Remove `Re:' and words in parentheses.
1538If RE-ONLY is non-nil, strip leading `Re:'s only."
1539 (let ((case-fold-search t)) ;Ignore case.
1540 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1541 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1542 (setq subject (substring subject (match-end 0))))
1543 ;; Remove uninteresting prefixes.
1544 (when (and (not re-only)
1545 gnus-simplify-ignored-prefixes
1546 (string-match gnus-simplify-ignored-prefixes subject))
1547 (setq subject (substring subject (match-end 0))))
1548 ;; Remove words in parentheses from end.
1549 (unless re-only
1550 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1551 (setq subject (substring subject 0 (match-beginning 0)))))
1552 ;; Return subject string.
1553 subject))
1554
1555;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1556;; all whitespace.
1557(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1558 (goto-char (point-min))
1559 (while (re-search-forward regexp nil t)
16409b0b 1560 (replace-match (or newtext ""))))
eec82323
LMI
1561
1562(defun gnus-simplify-buffer-fuzzy ()
1563 "Simplify string in the buffer fuzzily.
1564The string in the accessible portion of the current buffer is simplified.
1565It is assumed to be a single-line subject.
1566Whitespace is generally cleaned up, and miscellaneous leading/trailing
1567matter is removed. Additional things can be deleted by setting
16409b0b 1568`gnus-simplify-subject-fuzzy-regexp'."
eec82323
LMI
1569 (let ((case-fold-search t)
1570 (modified-tick))
1571 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1572
1573 (while (not (eq modified-tick (buffer-modified-tick)))
1574 (setq modified-tick (buffer-modified-tick))
1575 (cond
1576 ((listp gnus-simplify-subject-fuzzy-regexp)
1577 (mapcar 'gnus-simplify-buffer-fuzzy-step
1578 gnus-simplify-subject-fuzzy-regexp))
1579 (gnus-simplify-subject-fuzzy-regexp
1580 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1581 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1582 (gnus-simplify-buffer-fuzzy-step
1583 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1584 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1585
1586 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1587 (gnus-simplify-buffer-fuzzy-step " +" " ")
1588 (gnus-simplify-buffer-fuzzy-step " $")
1589 (gnus-simplify-buffer-fuzzy-step "^ +")))
1590
1591(defun gnus-simplify-subject-fuzzy (subject)
1592 "Simplify a subject string fuzzily.
6748645f 1593See `gnus-simplify-buffer-fuzzy' for details."
eec82323
LMI
1594 (save-excursion
1595 (gnus-set-work-buffer)
1596 (let ((case-fold-search t))
6748645f
LMI
1597 ;; Remove uninteresting prefixes.
1598 (when (and gnus-simplify-ignored-prefixes
1599 (string-match gnus-simplify-ignored-prefixes subject))
1600 (setq subject (substring subject (match-end 0))))
eec82323
LMI
1601 (insert subject)
1602 (inline (gnus-simplify-buffer-fuzzy))
1603 (buffer-string))))
1604
1605(defsubst gnus-simplify-subject-fully (subject)
23f87bed 1606 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
eec82323 1607 (cond
6748645f
LMI
1608 (gnus-simplify-subject-functions
1609 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1610 ((null gnus-summary-gather-subject-limit)
1611 (gnus-simplify-subject-re subject))
1612 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1613 (gnus-simplify-subject-fuzzy subject))
1614 ((numberp gnus-summary-gather-subject-limit)
1615 (gnus-limit-string (gnus-simplify-subject-re subject)
1616 gnus-summary-gather-subject-limit))
1617 (t
1618 subject)))
1619
1620(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f 1621 "Check whether two subjects are equal.
23f87bed 1622If optional argument SIMPLE-FIRST is t, first argument is already
6748645f 1623simplified."
eec82323
LMI
1624 (cond
1625 ((null simple-first)
1626 (equal (gnus-simplify-subject-fully s1)
1627 (gnus-simplify-subject-fully s2)))
1628 (t
1629 (equal s1
1630 (gnus-simplify-subject-fully s2)))))
1631
1632(defun gnus-summary-bubble-group ()
1633 "Increase the score of the current group.
1634This is a handy function to add to `gnus-summary-exit-hook' to
1635increase the score of each group you read."
1636 (gnus-group-add-score gnus-newsgroup-name))
1637
1638\f
1639;;;
1640;;; Gnus summary mode
1641;;;
1642
1643(put 'gnus-summary-mode 'mode-class 'special)
1644
1653df0f
SZ
1645(defvar gnus-article-commands-menu)
1646
23f87bed
MB
1647;; Non-orthogonal keys
1648
1649(gnus-define-keys gnus-summary-mode-map
1650 " " gnus-summary-next-page
1651 "\177" gnus-summary-prev-page
1652 [delete] gnus-summary-prev-page
1653 [backspace] gnus-summary-prev-page
1654 "\r" gnus-summary-scroll-up
1655 "\M-\r" gnus-summary-scroll-down
1656 "n" gnus-summary-next-unread-article
1657 "p" gnus-summary-prev-unread-article
1658 "N" gnus-summary-next-article
1659 "P" gnus-summary-prev-article
1660 "\M-\C-n" gnus-summary-next-same-subject
1661 "\M-\C-p" gnus-summary-prev-same-subject
1662 "\M-n" gnus-summary-next-unread-subject
1663 "\M-p" gnus-summary-prev-unread-subject
1664 "." gnus-summary-first-unread-article
1665 "," gnus-summary-best-unread-article
1666 "\M-s" gnus-summary-search-article-forward
1667 "\M-r" gnus-summary-search-article-backward
1668 "<" gnus-summary-beginning-of-article
1669 ">" gnus-summary-end-of-article
1670 "j" gnus-summary-goto-article
1671 "^" gnus-summary-refer-parent-article
1672 "\M-^" gnus-summary-refer-article
1673 "u" gnus-summary-tick-article-forward
1674 "!" gnus-summary-tick-article-forward
1675 "U" gnus-summary-tick-article-backward
1676 "d" gnus-summary-mark-as-read-forward
1677 "D" gnus-summary-mark-as-read-backward
1678 "E" gnus-summary-mark-as-expirable
1679 "\M-u" gnus-summary-clear-mark-forward
1680 "\M-U" gnus-summary-clear-mark-backward
1681 "k" gnus-summary-kill-same-subject-and-select
1682 "\C-k" gnus-summary-kill-same-subject
1683 "\M-\C-k" gnus-summary-kill-thread
1684 "\M-\C-l" gnus-summary-lower-thread
1685 "e" gnus-summary-edit-article
1686 "#" gnus-summary-mark-as-processable
1687 "\M-#" gnus-summary-unmark-as-processable
1688 "\M-\C-t" gnus-summary-toggle-threads
1689 "\M-\C-s" gnus-summary-show-thread
1690 "\M-\C-h" gnus-summary-hide-thread
1691 "\M-\C-f" gnus-summary-next-thread
1692 "\M-\C-b" gnus-summary-prev-thread
1693 [(meta down)] gnus-summary-next-thread
1694 [(meta up)] gnus-summary-prev-thread
1695 "\M-\C-u" gnus-summary-up-thread
1696 "\M-\C-d" gnus-summary-down-thread
1697 "&" gnus-summary-execute-command
1698 "c" gnus-summary-catchup-and-exit
1699 "\C-w" gnus-summary-mark-region-as-read
1700 "\C-t" gnus-summary-toggle-truncation
1701 "?" gnus-summary-mark-as-dormant
1702 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1703 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1704 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1705 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1706 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1707 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1708 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1709 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1710 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1711 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1712 "=" gnus-summary-expand-window
1713 "\C-x\C-s" gnus-summary-reselect-current-group
1714 "\M-g" gnus-summary-rescan-group
1715 "w" gnus-summary-stop-page-breaking
1716 "\C-c\C-r" gnus-summary-caesar-message
1717 "f" gnus-summary-followup
1718 "F" gnus-summary-followup-with-original
1719 "C" gnus-summary-cancel-article
1720 "r" gnus-summary-reply
1721 "R" gnus-summary-reply-with-original
1722 "\C-c\C-f" gnus-summary-mail-forward
1723 "o" gnus-summary-save-article
1724 "\C-o" gnus-summary-save-article-mail
1725 "|" gnus-summary-pipe-output
1726 "\M-k" gnus-summary-edit-local-kill
1727 "\M-K" gnus-summary-edit-global-kill
1728 ;; "V" gnus-version
1729 "\C-c\C-d" gnus-summary-describe-group
1730 "q" gnus-summary-exit
1731 "Q" gnus-summary-exit-no-update
1732 "\C-c\C-i" gnus-info-find-node
1733 gnus-mouse-2 gnus-mouse-pick-article
132cf96d 1734 [follow-link] mouse-face
23f87bed
MB
1735 "m" gnus-summary-mail-other-window
1736 "a" gnus-summary-post-news
1737 "i" gnus-summary-news-other-window
1738 "x" gnus-summary-limit-to-unread
1739 "s" gnus-summary-isearch-article
1740 "t" gnus-summary-toggle-header
1741 "g" gnus-summary-show-article
1742 "l" gnus-summary-goto-last-article
1743 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1744 "\C-d" gnus-summary-enter-digest-group
1745 "\M-\C-d" gnus-summary-read-document
1746 "\M-\C-e" gnus-summary-edit-parameters
1747 "\M-\C-a" gnus-summary-customize-parameters
1748 "\C-c\C-b" gnus-bug
1749 "*" gnus-cache-enter-article
1750 "\M-*" gnus-cache-remove-article
1751 "\M-&" gnus-summary-universal-argument
1752 "\C-l" gnus-recenter
1753 "I" gnus-summary-increase-score
1754 "L" gnus-summary-lower-score
1755 "\M-i" gnus-symbolic-argument
1756 "h" gnus-summary-select-article-buffer
1757
1758 "b" gnus-article-view-part
1759 "\M-t" gnus-summary-toggle-display-buttonized
1760
1761 "V" gnus-summary-score-map
1762 "X" gnus-uu-extract-map
1763 "S" gnus-summary-send-map)
1764
1765;; Sort of orthogonal keymap
1766(gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1767 "t" gnus-summary-tick-article-forward
1768 "!" gnus-summary-tick-article-forward
1769 "d" gnus-summary-mark-as-read-forward
1770 "r" gnus-summary-mark-as-read-forward
1771 "c" gnus-summary-clear-mark-forward
1772 " " gnus-summary-clear-mark-forward
1773 "e" gnus-summary-mark-as-expirable
1774 "x" gnus-summary-mark-as-expirable
1775 "?" gnus-summary-mark-as-dormant
1776 "b" gnus-summary-set-bookmark
1777 "B" gnus-summary-remove-bookmark
1778 "#" gnus-summary-mark-as-processable
1779 "\M-#" gnus-summary-unmark-as-processable
1780 "S" gnus-summary-limit-include-expunged
1781 "C" gnus-summary-catchup
1782 "H" gnus-summary-catchup-to-here
1783 "h" gnus-summary-catchup-from-here
1784 "\C-c" gnus-summary-catchup-all
1785 "k" gnus-summary-kill-same-subject-and-select
1786 "K" gnus-summary-kill-same-subject
1787 "P" gnus-uu-mark-map)
1788
1789(gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1790 "c" gnus-summary-clear-above
1791 "u" gnus-summary-tick-above
1792 "m" gnus-summary-mark-above
1793 "k" gnus-summary-kill-below)
1794
1795(gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1796 "/" gnus-summary-limit-to-subject
1797 "n" gnus-summary-limit-to-articles
1798 "w" gnus-summary-pop-limit
1799 "s" gnus-summary-limit-to-subject
1800 "a" gnus-summary-limit-to-author
1801 "u" gnus-summary-limit-to-unread
1802 "m" gnus-summary-limit-to-marks
1803 "M" gnus-summary-limit-exclude-marks
1804 "v" gnus-summary-limit-to-score
1805 "*" gnus-summary-limit-include-cached
1806 "D" gnus-summary-limit-include-dormant
1807 "T" gnus-summary-limit-include-thread
1808 "d" gnus-summary-limit-exclude-dormant
1809 "t" gnus-summary-limit-to-age
1810 "." gnus-summary-limit-to-unseen
1811 "x" gnus-summary-limit-to-extra
1812 "p" gnus-summary-limit-to-display-predicate
1813 "E" gnus-summary-limit-include-expunged
1814 "c" gnus-summary-limit-exclude-childless-dormant
1815 "C" gnus-summary-limit-mark-excluded-as-read
1816 "o" gnus-summary-insert-old-articles
1817 "N" gnus-summary-insert-new-articles)
1818
1819(gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1820 "n" gnus-summary-next-unread-article
1821 "p" gnus-summary-prev-unread-article
1822 "N" gnus-summary-next-article
1823 "P" gnus-summary-prev-article
1824 "\C-n" gnus-summary-next-same-subject
1825 "\C-p" gnus-summary-prev-same-subject
1826 "\M-n" gnus-summary-next-unread-subject
1827 "\M-p" gnus-summary-prev-unread-subject
1828 "f" gnus-summary-first-unread-article
1829 "b" gnus-summary-best-unread-article
1830 "j" gnus-summary-goto-article
1831 "g" gnus-summary-goto-subject
1832 "l" gnus-summary-goto-last-article
1833 "o" gnus-summary-pop-article)
1834
1835(gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1836 "k" gnus-summary-kill-thread
1837 "l" gnus-summary-lower-thread
1838 "i" gnus-summary-raise-thread
1839 "T" gnus-summary-toggle-threads
1840 "t" gnus-summary-rethread-current
1841 "^" gnus-summary-reparent-thread
1842 "s" gnus-summary-show-thread
1843 "S" gnus-summary-show-all-threads
1844 "h" gnus-summary-hide-thread
1845 "H" gnus-summary-hide-all-threads
1846 "n" gnus-summary-next-thread
1847 "p" gnus-summary-prev-thread
1848 "u" gnus-summary-up-thread
1849 "o" gnus-summary-top-thread
1850 "d" gnus-summary-down-thread
1851 "#" gnus-uu-mark-thread
1852 "\M-#" gnus-uu-unmark-thread)
1853
1854(gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1855 "g" gnus-summary-prepare
1856 "c" gnus-summary-insert-cached-articles
1857 "d" gnus-summary-insert-dormant-articles)
1858
1859(gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1860 "c" gnus-summary-catchup-and-exit
1861 "C" gnus-summary-catchup-all-and-exit
1862 "E" gnus-summary-exit-no-update
1863 "Q" gnus-summary-exit
1864 "Z" gnus-summary-exit
1865 "n" gnus-summary-catchup-and-goto-next-group
1866 "R" gnus-summary-reselect-current-group
1867 "G" gnus-summary-rescan-group
1868 "N" gnus-summary-next-group
1869 "s" gnus-summary-save-newsrc
1870 "P" gnus-summary-prev-group)
1871
1872(gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1873 " " gnus-summary-next-page
1874 "n" gnus-summary-next-page
1875 "\177" gnus-summary-prev-page
1876 [delete] gnus-summary-prev-page
1877 "p" gnus-summary-prev-page
1878 "\r" gnus-summary-scroll-up
1879 "\M-\r" gnus-summary-scroll-down
1880 "<" gnus-summary-beginning-of-article
1881 ">" gnus-summary-end-of-article
1882 "b" gnus-summary-beginning-of-article
1883 "e" gnus-summary-end-of-article
1884 "^" gnus-summary-refer-parent-article
1885 "r" gnus-summary-refer-parent-article
1886 "D" gnus-summary-enter-digest-group
1887 "R" gnus-summary-refer-references
1888 "T" gnus-summary-refer-thread
1889 "g" gnus-summary-show-article
1890 "s" gnus-summary-isearch-article
1891 "P" gnus-summary-print-article
1892 "M" gnus-mailing-list-insinuate
1893 "t" gnus-article-babel)
1894
1895(gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1896 "b" gnus-article-add-buttons
1897 "B" gnus-article-add-buttons-to-head
1898 "o" gnus-article-treat-overstrike
1899 "e" gnus-article-emphasize
1900 "w" gnus-article-fill-cited-article
1901 "Q" gnus-article-fill-long-lines
1902 "C" gnus-article-capitalize-sentences
1903 "c" gnus-article-remove-cr
1904 "q" gnus-article-de-quoted-unreadable
1905 "6" gnus-article-de-base64-unreadable
1906 "Z" gnus-article-decode-HZ
1907 "h" gnus-article-wash-html
1908 "u" gnus-article-unsplit-urls
1909 "s" gnus-summary-force-verify-and-decrypt
1910 "f" gnus-article-display-x-face
1911 "l" gnus-summary-stop-page-breaking
1912 "r" gnus-summary-caesar-message
1913 "m" gnus-summary-morse-message
1914 "t" gnus-summary-toggle-header
1915 "g" gnus-treat-smiley
1916 "v" gnus-summary-verbose-headers
1917 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1918 "p" gnus-article-verify-x-pgp-sig
1919 "d" gnus-article-treat-dumbquotes)
1920
1921(gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1922 ;; mnemonic: deuglif*Y*
1923 "u" gnus-article-outlook-unwrap-lines
1924 "a" gnus-article-outlook-repair-attribution
1925 "c" gnus-article-outlook-rearrange-citation
1926 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1927
1928(gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1929 "a" gnus-article-hide
1930 "h" gnus-article-hide-headers
1931 "b" gnus-article-hide-boring-headers
1932 "s" gnus-article-hide-signature
1933 "c" gnus-article-hide-citation
1934 "C" gnus-article-hide-citation-in-followups
1935 "l" gnus-article-hide-list-identifiers
1936 "B" gnus-article-strip-banner
1937 "P" gnus-article-hide-pem
1938 "\C-c" gnus-article-hide-citation-maybe)
1939
1940(gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1941 "a" gnus-article-highlight
1942 "h" gnus-article-highlight-headers
1943 "c" gnus-article-highlight-citation
1944 "s" gnus-article-highlight-signature)
1945
1946(gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1947 "f" gnus-article-treat-fold-headers
1948 "u" gnus-article-treat-unfold-headers
1949 "n" gnus-article-treat-fold-newsgroups)
1950
1951(gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1952 "x" gnus-article-display-x-face
1953 "d" gnus-article-display-face
1954 "s" gnus-treat-smiley
1955 "D" gnus-article-remove-images
1956 "f" gnus-treat-from-picon
1957 "m" gnus-treat-mail-picon
1958 "n" gnus-treat-newsgroups-picon)
1959
1960(gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1961 "w" gnus-article-decode-mime-words
1962 "c" gnus-article-decode-charset
1963 "v" gnus-mime-view-all-parts
1964 "b" gnus-article-view-part)
1965
1966(gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1967 "z" gnus-article-date-ut
1968 "u" gnus-article-date-ut
1969 "l" gnus-article-date-local
1970 "p" gnus-article-date-english
1971 "e" gnus-article-date-lapsed
1972 "o" gnus-article-date-original
1973 "i" gnus-article-date-iso8601
1974 "s" gnus-article-date-user)
1975
1976(gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1977 "t" gnus-article-remove-trailing-blank-lines
1978 "l" gnus-article-strip-leading-blank-lines
1979 "m" gnus-article-strip-multiple-blank-lines
1980 "a" gnus-article-strip-blank-lines
1981 "A" gnus-article-strip-all-blank-lines
1982 "s" gnus-article-strip-leading-space
1983 "e" gnus-article-strip-trailing-space
1984 "w" gnus-article-remove-leading-whitespace)
1985
1986(gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1987 "v" gnus-version
1988 "f" gnus-summary-fetch-faq
1989 "d" gnus-summary-describe-group
1990 "h" gnus-summary-describe-briefly
1991 "i" gnus-info-find-node
1992 "c" gnus-group-fetch-charter
1993 "C" gnus-group-fetch-control)
1994
1995(gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1996 "e" gnus-summary-expire-articles
1997 "\M-\C-e" gnus-summary-expire-articles-now
1998 "\177" gnus-summary-delete-article
1999 [delete] gnus-summary-delete-article
2000 [backspace] gnus-summary-delete-article
2001 "m" gnus-summary-move-article
2002 "r" gnus-summary-respool-article
2003 "w" gnus-summary-edit-article
2004 "c" gnus-summary-copy-article
2005 "B" gnus-summary-crosspost-article
2006 "q" gnus-summary-respool-query
2007 "t" gnus-summary-respool-trace
2008 "i" gnus-summary-import-article
2009 "I" gnus-summary-create-article
2010 "p" gnus-summary-article-posted-p)
2011
2012(gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2013 "o" gnus-summary-save-article
2014 "m" gnus-summary-save-article-mail
2015 "F" gnus-summary-write-article-file
2016 "r" gnus-summary-save-article-rmail
2017 "f" gnus-summary-save-article-file
2018 "b" gnus-summary-save-article-body-file
26c9afc3 2019 "B" gnus-summary-write-article-body-file
23f87bed
MB
2020 "h" gnus-summary-save-article-folder
2021 "v" gnus-summary-save-article-vm
2022 "p" gnus-summary-pipe-output
2023 "P" gnus-summary-muttprint
2024 "s" gnus-soup-add-article)
2025
2026(gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2027 "b" gnus-summary-display-buttonized
2028 "m" gnus-summary-repair-multipart
2029 "v" gnus-article-view-part
2030 "o" gnus-article-save-part
2031 "c" gnus-article-copy-part
2032 "C" gnus-article-view-part-as-charset
2033 "e" gnus-article-view-part-externally
2034 "E" gnus-article-encrypt-body
2035 "i" gnus-article-inline-part
2036 "|" gnus-article-pipe-part)
2037
2038(gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2039 "p" gnus-summary-mark-as-processable
2040 "u" gnus-summary-unmark-as-processable
2041 "U" gnus-summary-unmark-all-processable
2042 "v" gnus-uu-mark-over
2043 "s" gnus-uu-mark-series
2044 "r" gnus-uu-mark-region
2045 "g" gnus-uu-unmark-region
2046 "R" gnus-uu-mark-by-regexp
2047 "G" gnus-uu-unmark-by-regexp
2048 "t" gnus-uu-mark-thread
2049 "T" gnus-uu-unmark-thread
2050 "a" gnus-uu-mark-all
2051 "b" gnus-uu-mark-buffer
2052 "S" gnus-uu-mark-sparse
2053 "k" gnus-summary-kill-process-mark
2054 "y" gnus-summary-yank-process-mark
2055 "w" gnus-summary-save-process-mark
2056 "i" gnus-uu-invert-processable)
2057
2058(gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2059 ;;"x" gnus-uu-extract-any
2060 "m" gnus-summary-save-parts
2061 "u" gnus-uu-decode-uu
2062 "U" gnus-uu-decode-uu-and-save
2063 "s" gnus-uu-decode-unshar
2064 "S" gnus-uu-decode-unshar-and-save
2065 "o" gnus-uu-decode-save
2066 "O" gnus-uu-decode-save
2067 "b" gnus-uu-decode-binhex
2068 "B" gnus-uu-decode-binhex
2069 "p" gnus-uu-decode-postscript
2070 "P" gnus-uu-decode-postscript-and-save)
2071
2072(gnus-define-keys
2073 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2074 "u" gnus-uu-decode-uu-view
2075 "U" gnus-uu-decode-uu-and-save-view
2076 "s" gnus-uu-decode-unshar-view
2077 "S" gnus-uu-decode-unshar-and-save-view
2078 "o" gnus-uu-decode-save-view
2079 "O" gnus-uu-decode-save-view
2080 "b" gnus-uu-decode-binhex-view
2081 "B" gnus-uu-decode-binhex-view
2082 "p" gnus-uu-decode-postscript-view
2083 "P" gnus-uu-decode-postscript-and-save-view)
2084
2085(defvar gnus-article-post-menu nil)
2086
2087(defconst gnus-summary-menu-maxlen 20)
2088
2089(defun gnus-summary-menu-split (menu)
2090 ;; If we have lots of elements, divide them into groups of 20
2091 ;; and make a pane (or submenu) for each one.
2092 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2093 (let ((menu menu) sublists next
2094 (i 1))
2095 (while menu
2096 ;; Pull off the next gnus-summary-menu-maxlen elements
2097 ;; and make them the next element of sublist.
2098 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2099 (if next
2100 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2101 nil))
2102 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2103 (aref (car (last menu)) 0)) menu)
2104 sublists))
2105 (setq i (1+ i))
2106 (setq menu next))
2107 (nreverse sublists))
2108 ;; Few elements--put them all in one pane.
2109 menu))
eec82323
LMI
2110
2111(defun gnus-summary-make-menu-bar ()
2112 (gnus-turn-off-edit-menu 'summary)
2113
2114 (unless (boundp 'gnus-summary-misc-menu)
2115
2116 (easy-menu-define
23f87bed
MB
2117 gnus-summary-kill-menu gnus-summary-mode-map ""
2118 (cons
2119 "Score"
2120 (nconc
2121 (list
2122 ["Customize" gnus-score-customize t])
2123 (gnus-make-score-map 'increase)
2124 (gnus-make-score-map 'lower)
2125 '(("Mark"
2126 ["Kill below" gnus-summary-kill-below t]
2127 ["Mark above" gnus-summary-mark-above t]
2128 ["Tick above" gnus-summary-tick-above t]
2129 ["Clear above" gnus-summary-clear-above t])
2130 ["Current score" gnus-summary-current-score t]
2131 ["Set score" gnus-summary-set-score t]
2132 ["Switch current score file..." gnus-score-change-score-file t]
2133 ["Set mark below..." gnus-score-set-mark-below t]
2134 ["Set expunge below..." gnus-score-set-expunge-below t]
2135 ["Edit current score file" gnus-score-edit-current-scores t]
2136 ["Edit score file" gnus-score-edit-file t]
2137 ["Trace score" gnus-score-find-trace t]
2138 ["Find words" gnus-score-find-favourite-words t]
2139 ["Rescore buffer" gnus-summary-rescore t]
2140 ["Increase score..." gnus-summary-increase-score t]
2141 ["Lower score..." gnus-summary-lower-score t]))))
2142
2143 ;; Define both the Article menu in the summary buffer and the
2144 ;; equivalent Commands menu in the article buffer here for
2145 ;; consistency.
6748645f 2146 (let ((innards
23f87bed
MB
2147 `(("Hide"
2148 ["All" gnus-article-hide t]
2149 ["Headers" gnus-article-hide-headers t]
2150 ["Signature" gnus-article-hide-signature t]
2151 ["Citation" gnus-article-hide-citation t]
16409b0b 2152 ["List identifiers" gnus-article-hide-list-identifiers t]
16409b0b 2153 ["Banner" gnus-article-strip-banner t]
23f87bed
MB
2154 ["Boring headers" gnus-article-hide-boring-headers t])
2155 ("Highlight"
2156 ["All" gnus-article-highlight t]
2157 ["Headers" gnus-article-highlight-headers t]
2158 ["Signature" gnus-article-highlight-signature t]
2159 ["Citation" gnus-article-highlight-citation t])
16409b0b
GM
2160 ("MIME"
2161 ["Words" gnus-article-decode-mime-words t]
2162 ["Charset" gnus-article-decode-charset t]
2163 ["QP" gnus-article-de-quoted-unreadable t]
2164 ["Base64" gnus-article-de-base64-unreadable t]
23f87bed
MB
2165 ["View MIME buttons" gnus-summary-display-buttonized t]
2166 ["View all" gnus-mime-view-all-parts t]
2167 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2168 ["Encrypt body" gnus-article-encrypt-body
2169 :active (not (gnus-group-read-only-p))
2170 ,@(if (featurep 'xemacs) nil
2171 '(:help "Encrypt the message body on disk"))]
2172 ["Extract all parts..." gnus-summary-save-parts t]
2173 ("Multipart"
2174 ["Repair multipart" gnus-summary-repair-multipart t]
2175 ["Pipe part..." gnus-article-pipe-part t]
2176 ["Inline part" gnus-article-inline-part t]
2177 ["Encrypt body" gnus-article-encrypt-body
2178 :active (not (gnus-group-read-only-p))
2179 ,@(if (featurep 'xemacs) nil
2180 '(:help "Encrypt the message body on disk"))]
2181 ["View part externally" gnus-article-view-part-externally t]
2182 ["View part with charset..." gnus-article-view-part-as-charset t]
2183 ["Copy part" gnus-article-copy-part t]
2184 ["Save part..." gnus-article-save-part t]
2185 ["View part" gnus-article-view-part t]))
2186 ("Date"
2187 ["Local" gnus-article-date-local t]
2188 ["ISO8601" gnus-article-date-iso8601 t]
2189 ["UT" gnus-article-date-ut t]
2190 ["Original" gnus-article-date-original t]
2191 ["Lapsed" gnus-article-date-lapsed t]
2192 ["User-defined" gnus-article-date-user t])
2193 ("Display"
2194 ["Remove images" gnus-article-remove-images t]
2195 ["Toggle smiley" gnus-treat-smiley t]
2196 ["Show X-Face" gnus-article-display-x-face t]
2197 ["Show picons in From" gnus-treat-from-picon t]
2198 ["Show picons in mail headers" gnus-treat-mail-picon t]
2199 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2200 ("View as different encoding"
2201 ,@(gnus-summary-menu-split
2202 (mapcar
2203 (lambda (cs)
2204 ;; Since easymenu under Emacs doesn't allow
2205 ;; lambda forms for menu commands, we should
2206 ;; provide intern'ed function symbols.
2207 (let ((command (intern (format "\
2208gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2209 (fset command
2210 `(lambda ()
2211 (interactive)
2212 (let ((gnus-summary-show-article-charset-alist
2213 '((1 . ,cs))))
2214 (gnus-summary-show-article 1))))
2215 `[,(symbol-name cs) ,command t]))
2216 (sort (if (fboundp 'coding-system-list)
2217 (coding-system-list)
2218 (mapcar 'car mm-mime-mule-charset-alist))
2219 'string<)))))
2220 ("Washing"
2221 ("Remove Blanks"
2222 ["Leading" gnus-article-strip-leading-blank-lines t]
2223 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2224 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2225 ["All of the above" gnus-article-strip-blank-lines t]
2226 ["All" gnus-article-strip-all-blank-lines t]
2227 ["Leading space" gnus-article-strip-leading-space t]
2228 ["Trailing space" gnus-article-strip-trailing-space t]
2229 ["Leading space in headers"
2230 gnus-article-remove-leading-whitespace t])
2231 ["Overstrike" gnus-article-treat-overstrike t]
2232 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2233 ["Emphasis" gnus-article-emphasize t]
2234 ["Word wrap" gnus-article-fill-cited-article t]
16409b0b
GM
2235 ["Fill long lines" gnus-article-fill-long-lines t]
2236 ["Capitalize sentences" gnus-article-capitalize-sentences t]
23f87bed
MB
2237 ["Remove CR" gnus-article-remove-cr t]
2238 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2239 ["Base64" gnus-article-de-base64-unreadable t]
2240 ["Rot 13" gnus-summary-caesar-message
2241 ,@(if (featurep 'xemacs) '(t)
2242 '(:help "\"Caesar rotate\" article by 13"))]
2243 ["Morse decode" gnus-summary-morse-message t]
2244 ["Unix pipe..." gnus-summary-pipe-message t]
2245 ["Add buttons" gnus-article-add-buttons t]
2246 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2247 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2248 ["Verbose header" gnus-summary-verbose-headers t]
2249 ["Toggle header" gnus-summary-toggle-header t]
2250 ["Unfold headers" gnus-article-treat-unfold-headers t]
2251 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
16409b0b 2252 ["Html" gnus-article-wash-html t]
23f87bed
MB
2253 ["Unsplit URLs" gnus-article-unsplit-urls t]
2254 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2255 ["Decode HZ" gnus-article-decode-HZ t]
2256 ("(Outlook) Deuglify"
2257 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2258 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2259 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2260 ["Full (Outlook) deuglify"
2261 gnus-article-outlook-deuglify-article t])
2262 )
2263 ("Output"
2264 ["Save in default format..." gnus-summary-save-article
2265 ,@(if (featurep 'xemacs) '(t)
2266 '(:help "Save article using default method"))]
2267 ["Save in file..." gnus-summary-save-article-file
2268 ,@(if (featurep 'xemacs) '(t)
2269 '(:help "Save article in file"))]
2270 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2271 ["Save in MH folder..." gnus-summary-save-article-folder t]
2272 ["Save in VM folder..." gnus-summary-save-article-vm t]
2273 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2274 ["Save body in file..." gnus-summary-save-article-body-file t]
2275 ["Pipe through a filter..." gnus-summary-pipe-output t]
2276 ["Add to SOUP packet" gnus-soup-add-article t]
2277 ["Print with Muttprint..." gnus-summary-muttprint t]
531e5812
MB
2278 ["Print" gnus-summary-print-article
2279 ,@(if (featurep 'xemacs) '(t)
2280 '(:help "Generate and print a PostScript image"))])
2281 ("Copy, move,... (Backend)"
707f2b38 2282 ,@(if (featurep 'xemacs) nil
531e5812 2283 '(:help "Copying, moving, expiring articles..."))
23f87bed
MB
2284 ["Respool article..." gnus-summary-respool-article t]
2285 ["Move article..." gnus-summary-move-article
2286 (gnus-check-backend-function
2287 'request-move-article gnus-newsgroup-name)]
2288 ["Copy article..." gnus-summary-copy-article t]
2289 ["Crosspost article..." gnus-summary-crosspost-article
2290 (gnus-check-backend-function
2291 'request-replace-article gnus-newsgroup-name)]
2292 ["Import file..." gnus-summary-import-article
2293 (gnus-check-backend-function
2294 'request-accept-article gnus-newsgroup-name)]
2295 ["Create article..." gnus-summary-create-article
2296 (gnus-check-backend-function
2297 'request-accept-article gnus-newsgroup-name)]
2298 ["Check if posted" gnus-summary-article-posted-p t]
2299 ["Edit article" gnus-summary-edit-article
2300 (not (gnus-group-read-only-p))]
2301 ["Delete article" gnus-summary-delete-article
2302 (gnus-check-backend-function
2303 'request-expire-articles gnus-newsgroup-name)]
2304 ["Query respool" gnus-summary-respool-query t]
6748645f 2305 ["Trace respool" gnus-summary-respool-trace t]
23f87bed
MB
2306 ["Delete expirable articles" gnus-summary-expire-articles-now
2307 (gnus-check-backend-function
2308 'request-expire-articles gnus-newsgroup-name)])
2309 ("Extract"
2310 ["Uudecode" gnus-uu-decode-uu
2311 ,@(if (featurep 'xemacs) '(t)
2312 '(:help "Decode uuencoded article(s)"))]
2313 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2314 ["Unshar" gnus-uu-decode-unshar t]
2315 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2316 ["Save" gnus-uu-decode-save t]
2317 ["Binhex" gnus-uu-decode-binhex t]
2318 ["Postscript" gnus-uu-decode-postscript t]
2319 ["All MIME parts" gnus-summary-save-parts t])
2320 ("Cache"
2321 ["Enter article" gnus-cache-enter-article t]
2322 ["Remove article" gnus-cache-remove-article t])
16409b0b 2323 ["Translate" gnus-article-babel t]
23f87bed
MB
2324 ["Select article buffer" gnus-summary-select-article-buffer t]
2325 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2326 ["Isearch article..." gnus-summary-isearch-article t]
2327 ["Beginning of the article" gnus-summary-beginning-of-article t]
2328 ["End of the article" gnus-summary-end-of-article t]
2329 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2330 ["Fetch referenced articles" gnus-summary-refer-references t]
2331 ["Fetch current thread" gnus-summary-refer-thread t]
2332 ["Fetch article with id..." gnus-summary-refer-article t]
2333 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2334 ["Redisplay" gnus-summary-show-article t]
2335 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
6748645f 2336 (easy-menu-define
23f87bed
MB
2337 gnus-summary-article-menu gnus-summary-mode-map ""
2338 (cons "Article" innards))
6748645f 2339
1653df0f
SZ
2340 (if (not (keymapp gnus-summary-article-menu))
2341 (easy-menu-define
2342 gnus-article-commands-menu gnus-article-mode-map ""
2343 (cons "Commands" innards))
2344 ;; in Emacs, don't share menu.
a1506d29 2345 (setq gnus-article-commands-menu
1653df0f
SZ
2346 (copy-keymap gnus-summary-article-menu))
2347 (define-key gnus-article-mode-map [menu-bar commands]
2348 (cons "Commands" gnus-article-commands-menu))))
eec82323
LMI
2349
2350 (easy-menu-define
23f87bed
MB
2351 gnus-summary-thread-menu gnus-summary-mode-map ""
2352 '("Threads"
2353 ["Find all messages in thread" gnus-summary-refer-thread t]
2354 ["Toggle threading" gnus-summary-toggle-threads t]
2355 ["Hide threads" gnus-summary-hide-all-threads t]
2356 ["Show threads" gnus-summary-show-all-threads t]
2357 ["Hide thread" gnus-summary-hide-thread t]
2358 ["Show thread" gnus-summary-show-thread t]
2359 ["Go to next thread" gnus-summary-next-thread t]
2360 ["Go to previous thread" gnus-summary-prev-thread t]
2361 ["Go down thread" gnus-summary-down-thread t]
2362 ["Go up thread" gnus-summary-up-thread t]
2363 ["Top of thread" gnus-summary-top-thread t]
2364 ["Mark thread as read" gnus-summary-kill-thread t]
2365 ["Lower thread score" gnus-summary-lower-thread t]
2366 ["Raise thread score" gnus-summary-raise-thread t]
2367 ["Rethread current" gnus-summary-rethread-current t]))
eec82323
LMI
2368
2369 (easy-menu-define
23f87bed
MB
2370 gnus-summary-post-menu gnus-summary-mode-map ""
2371 `("Post"
2372 ["Send a message (mail or news)" gnus-summary-post-news
2373 ,@(if (featurep 'xemacs) '(t)
531e5812 2374 '(:help "Compose a new message (mail or news)"))]
23f87bed
MB
2375 ["Followup" gnus-summary-followup
2376 ,@(if (featurep 'xemacs) '(t)
2377 '(:help "Post followup to this article"))]
2378 ["Followup and yank" gnus-summary-followup-with-original
2379 ,@(if (featurep 'xemacs) '(t)
2380 '(:help "Post followup to this article, quoting its contents"))]
2381 ["Supersede article" gnus-summary-supersede-article t]
2382 ["Cancel article" gnus-summary-cancel-article
2383 ,@(if (featurep 'xemacs) '(t)
2384 '(:help "Cancel an article you posted"))]
2385 ["Reply" gnus-summary-reply t]
2386 ["Reply and yank" gnus-summary-reply-with-original t]
2387 ["Wide reply" gnus-summary-wide-reply t]
2388 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2389 ,@(if (featurep 'xemacs) '(t)
2390 '(:help "Mail a reply, quoting this article"))]
2391 ["Very wide reply" gnus-summary-very-wide-reply t]
2392 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2393 ,@(if (featurep 'xemacs) '(t)
2394 '(:help "Mail a very wide reply, quoting this article"))]
2395 ["Mail forward" gnus-summary-mail-forward t]
2396 ["Post forward" gnus-summary-post-forward t]
2397 ["Digest and mail" gnus-uu-digest-mail-forward t]
2398 ["Digest and post" gnus-uu-digest-post-forward t]
2399 ["Resend message" gnus-summary-resend-message t]
2400 ["Resend message edit" gnus-summary-resend-message-edit t]
2401 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2402 ["Send a mail" gnus-summary-mail-other-window t]
2403 ["Create a local message" gnus-summary-news-other-window t]
2404 ["Uuencode and post" gnus-uu-post-news
2405 ,@(if (featurep 'xemacs) '(t)
2406 '(:help "Post a uuencoded article"))]
2407 ["Followup via news" gnus-summary-followup-to-mail t]
2408 ["Followup via news and yank"
2409 gnus-summary-followup-to-mail-with-original t]
2410 ;;("Draft"
2411 ;;["Send" gnus-summary-send-draft t]
2412 ;;["Send bounced" gnus-resend-bounced-mail t])
2413 ))
2414
2415 (cond
2416 ((not (keymapp gnus-summary-post-menu))
2417 (setq gnus-article-post-menu gnus-summary-post-menu))
2418 ((not gnus-article-post-menu)
2419 ;; Don't share post menu.
2420 (setq gnus-article-post-menu
2421 (copy-keymap gnus-summary-post-menu))))
2422 (define-key gnus-article-mode-map [menu-bar post]
2423 (cons "Post" gnus-article-post-menu))
eec82323
LMI
2424
2425 (easy-menu-define
23f87bed
MB
2426 gnus-summary-misc-menu gnus-summary-mode-map ""
2427 `("Gnus"
2428 ("Mark Read"
2429 ["Mark as read" gnus-summary-mark-as-read-forward t]
2430 ["Mark same subject and select"
2431 gnus-summary-kill-same-subject-and-select t]
2432 ["Mark same subject" gnus-summary-kill-same-subject t]
2433 ["Catchup" gnus-summary-catchup
2434 ,@(if (featurep 'xemacs) '(t)
2435 '(:help "Mark unread articles in this group as read"))]
2436 ["Catchup all" gnus-summary-catchup-all t]
2437 ["Catchup to here" gnus-summary-catchup-to-here t]
2438 ["Catchup from here" gnus-summary-catchup-from-here t]
2439 ["Catchup region" gnus-summary-mark-region-as-read
2440 (gnus-mark-active-p)]
2441 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2442 ("Mark Various"
2443 ["Tick" gnus-summary-tick-article-forward t]
2444 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2445 ["Remove marks" gnus-summary-clear-mark-forward t]
2446 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2447 ["Set bookmark" gnus-summary-set-bookmark t]
2448 ["Remove bookmark" gnus-summary-remove-bookmark t])
2449 ("Limit to"
2450 ["Marks..." gnus-summary-limit-to-marks t]
2451 ["Subject..." gnus-summary-limit-to-subject t]
2452 ["Author..." gnus-summary-limit-to-author t]
2453 ["Age..." gnus-summary-limit-to-age t]
2454 ["Extra..." gnus-summary-limit-to-extra t]
2455 ["Score..." gnus-summary-limit-to-score t]
2456 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2457 ["Unread" gnus-summary-limit-to-unread t]
2458 ["Unseen" gnus-summary-limit-to-unseen t]
2459 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
996aa8c1 2460 ["Next or process marked articles" gnus-summary-limit-to-articles t]
23f87bed
MB
2461 ["Pop limit" gnus-summary-pop-limit t]
2462 ["Show dormant" gnus-summary-limit-include-dormant t]
2463 ["Hide childless dormant"
2464 gnus-summary-limit-exclude-childless-dormant t]
2465 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2466 ["Hide marked" gnus-summary-limit-exclude-marks t]
2467 ["Show expunged" gnus-summary-limit-include-expunged t])
2468 ("Process Mark"
2469 ["Set mark" gnus-summary-mark-as-processable t]
2470 ["Remove mark" gnus-summary-unmark-as-processable t]
2471 ["Remove all marks" gnus-summary-unmark-all-processable t]
2472 ["Mark above" gnus-uu-mark-over t]
2473 ["Mark series" gnus-uu-mark-series t]
2474 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2475 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2476 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2477 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2478 ["Mark all" gnus-uu-mark-all t]
2479 ["Mark buffer" gnus-uu-mark-buffer t]
2480 ["Mark sparse" gnus-uu-mark-sparse t]
2481 ["Mark thread" gnus-uu-mark-thread t]
2482 ["Unmark thread" gnus-uu-unmark-thread t]
2483 ("Process Mark Sets"
2484 ["Kill" gnus-summary-kill-process-mark t]
2485 ["Yank" gnus-summary-yank-process-mark
2486 gnus-newsgroup-process-stack]
2487 ["Save" gnus-summary-save-process-mark t]
2488 ["Run command on marked..." gnus-summary-universal-argument t]))
2489 ("Scroll article"
2490 ["Page forward" gnus-summary-next-page
2491 ,@(if (featurep 'xemacs) '(t)
2492 '(:help "Show next page of article"))]
2493 ["Page backward" gnus-summary-prev-page
2494 ,@(if (featurep 'xemacs) '(t)
2495 '(:help "Show previous page of article"))]
2496 ["Line forward" gnus-summary-scroll-up t])
2497 ("Move"
2498 ["Next unread article" gnus-summary-next-unread-article t]
2499 ["Previous unread article" gnus-summary-prev-unread-article t]
2500 ["Next article" gnus-summary-next-article t]
2501 ["Previous article" gnus-summary-prev-article t]
2502 ["Next unread subject" gnus-summary-next-unread-subject t]
2503 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2504 ["Next article same subject" gnus-summary-next-same-subject t]
2505 ["Previous article same subject" gnus-summary-prev-same-subject t]
2506 ["First unread article" gnus-summary-first-unread-article t]
2507 ["Best unread article" gnus-summary-best-unread-article t]
2508 ["Go to subject number..." gnus-summary-goto-subject t]
2509 ["Go to article number..." gnus-summary-goto-article t]
2510 ["Go to the last article" gnus-summary-goto-last-article t]
2511 ["Pop article off history" gnus-summary-pop-article t])
2512 ("Sort"
2513 ["Sort by number" gnus-summary-sort-by-number t]
2514 ["Sort by author" gnus-summary-sort-by-author t]
2515 ["Sort by subject" gnus-summary-sort-by-subject t]
2516 ["Sort by date" gnus-summary-sort-by-date t]
2517 ["Sort by score" gnus-summary-sort-by-score t]
2518 ["Sort by lines" gnus-summary-sort-by-lines t]
2519 ["Sort by characters" gnus-summary-sort-by-chars t]
2520 ["Randomize" gnus-summary-sort-by-random t]
2521 ["Original sort" gnus-summary-sort-by-original t])
2522 ("Help"
2523 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2524 ["Describe group" gnus-summary-describe-group t]
2525 ["Fetch charter" gnus-group-fetch-charter
2526 ,@(if (featurep 'xemacs) nil
2527 '(:help "Display the charter of the current group"))]
2528 ["Fetch control message" gnus-group-fetch-control
2529 ,@(if (featurep 'xemacs) nil
2530 '(:help "Display the archived control message for the current group"))]
2531 ["Read manual" gnus-info-find-node t])
2532 ("Modes"
2533 ["Pick and read" gnus-pick-mode t]
2534 ["Binary" gnus-binary-mode t])
2535 ("Regeneration"
2536 ["Regenerate" gnus-summary-prepare t]
2537 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2538 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2539 ["Toggle threading" gnus-summary-toggle-threads t])
2540 ["See old articles" gnus-summary-insert-old-articles t]
2541 ["See new articles" gnus-summary-insert-new-articles t]
2542 ["Filter articles..." gnus-summary-execute-command t]
2543 ["Run command on articles..." gnus-summary-universal-argument t]
2544 ["Search articles forward..." gnus-summary-search-article-forward t]
2545 ["Search articles backward..." gnus-summary-search-article-backward t]
2546 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2547 ["Expand window" gnus-summary-expand-window t]
2548 ["Expire expirable articles" gnus-summary-expire-articles
2549 (gnus-check-backend-function
2550 'request-expire-articles gnus-newsgroup-name)]
2551 ["Edit local kill file" gnus-summary-edit-local-kill t]
2552 ["Edit main kill file" gnus-summary-edit-global-kill t]
2553 ["Edit group parameters" gnus-summary-edit-parameters t]
2554 ["Customize group parameters" gnus-summary-customize-parameters t]
2555 ["Send a bug report" gnus-bug t]
2556 ("Exit"
2557 ["Catchup and exit" gnus-summary-catchup-and-exit
2558 ,@(if (featurep 'xemacs) '(t)
2559 '(:help "Mark unread articles in this group as read, then exit"))]
2560 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2561 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2562 ["Exit group" gnus-summary-exit
2563 ,@(if (featurep 'xemacs) '(t)
2564 '(:help "Exit current group, return to group selection mode"))]
2565 ["Exit group without updating" gnus-summary-exit-no-update t]
2566 ["Exit and goto next group" gnus-summary-next-group t]
2567 ["Exit and goto prev group" gnus-summary-prev-group t]
2568 ["Reselect group" gnus-summary-reselect-current-group t]
2569 ["Rescan group" gnus-summary-rescan-group t]
2570 ["Update dribble" gnus-summary-save-newsrc t])))
eec82323 2571
6748645f 2572 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323 2573
60bd5589
DL
2574(defvar gnus-summary-tool-bar-map nil)
2575
18c06a99
RS
2576;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2577;; affect _new_ message buffers. We might add a function that walks thru all
2578;; summary-mode buffers and force the update.
2579(defun gnus-summary-tool-bar-update (&optional symbol value)
2580 "Update summary mode toolbar.
2581Setter function for custom variables."
2582 (setq-default gnus-summary-tool-bar-map nil)
2583 (when symbol
2584 ;; When used as ":set" function:
2585 (set-default symbol value))
2586 (when (gnus-buffer-live-p gnus-summary-buffer)
2587 (with-current-buffer gnus-summary-buffer
2588 (gnus-summary-make-tool-bar))))
2589
2590(defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2591 'gnus-summary-tool-bar-gnome
2592 'gnus-summary-tool-bar-retro)
2593 "Specifies the Gnus summary tool bar.
2594
2595It can be either a list or a symbol refering to a list. See
2596`gmm-tool-bar-from-list' for the format of the list. The
2597default key map is `gnus-summary-mode-map'.
2598
2599Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2600`gnus-summary-tool-bar-retro'."
2601 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2602 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2603 (repeat :tag "User defined list" gmm-tool-bar-item)
2604 (symbol))
25bf7349 2605 :version "22.1" ;; Gnus 5.10.9
18c06a99
RS
2606 :initialize 'custom-initialize-default
2607 :set 'gnus-summary-tool-bar-update
2608 :group 'gnus-summary)
2609
2610(defcustom gnus-summary-tool-bar-gnome
2611 '((gnus-summary-post-news "mail/compose" nil)
2612 (gnus-summary-insert-new-articles "mail/inbox" nil
2613 :visible (or (not gnus-agent)
2614 gnus-plugged))
2615 (gnus-summary-reply-with-original "mail/reply")
2616 (gnus-summary-reply "mail/reply" nil :visible nil)
2617 (gnus-summary-followup-with-original "mail/reply-all")
2618 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2619 (gnus-summary-mail-forward "mail/forward")
2620 (gnus-summary-save-article "mail/save")
2621 (gnus-summary-search-article-forward "search" nil :visible nil)
2622 (gnus-summary-print-article "print")
2623 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2624 ;; Some new commands that may need more suitable icons:
2625 (gnus-summary-save-newsrc "save" nil :visible nil)
2626 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2627 (gnus-summary-prev-article "left-arrow")
2628 (gnus-summary-next-article "right-arrow")
2629 (gnus-summary-next-page "next-page")
2630 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2631 ;;
2632 ;; Maybe some sort-by-... could be added:
2633 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2634 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2635 (gnus-summary-mark-as-expirable
2636 "delete" nil
2637 :visible (gnus-check-backend-function 'request-expire-articles
2638 gnus-newsgroup-name))
2639 (gnus-summary-mark-as-spam
2640 "mail/spam" t
2641 :visible (and (fboundp 'spam-group-ham-contents-p)
2642 (spam-group-ham-contents-p gnus-newsgroup-name))
2643 :help "Mark as spam")
2644 (gnus-summary-mark-as-read-forward
2645 "mail/not-spam" nil
2646 :visible (and (fboundp 'spam-group-spam-contents-p)
2647 (spam-group-spam-contents-p gnus-newsgroup-name)))
2648 ;;
2649 (gnus-summary-exit "exit")
2650 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2651 (gnus-info-find-node "help"))
2652 "List of functions for the summary tool bar (GNOME style).
2653
2654See `gmm-tool-bar-from-list' for the format of the list."
2655 :type '(repeat gmm-tool-bar-item)
25bf7349 2656 :version "22.1" ;; Gnus 5.10.9
18c06a99
RS
2657 :initialize 'custom-initialize-default
2658 :set 'gnus-summary-tool-bar-update
2659 :group 'gnus-summary)
2660
2661(defcustom gnus-summary-tool-bar-retro
2662 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2663 (gnus-summary-next-unread-article "gnus/next-ur")
2664 (gnus-summary-post-news "gnus/post")
2665 (gnus-summary-followup-with-original "gnus/fuwo")
2666 (gnus-summary-followup "gnus/followup")
2667 (gnus-summary-reply-with-original "gnus/reply-wo")
2668 (gnus-summary-reply "gnus/reply")
2669 (gnus-summary-caesar-message "gnus/rot13")
2670 (gnus-uu-decode-uu "gnus/uu-decode")
2671 (gnus-summary-save-article-file "gnus/save-aif")
2672 (gnus-summary-save-article "gnus/save-art")
2673 (gnus-uu-post-news "gnus/uu-post")
2674 (gnus-summary-catchup "gnus/catchup")
2675 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2676 (gnus-summary-exit "gnus/exit-summ")
2677 ;; Some new command that may need more suitable icons:
2678 (gnus-summary-print-article "gnus/print" nil :visible nil)
2679 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2680 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2681 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2682 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2683 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2684 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2685 ;;
2686 (gnus-info-find-node "gnus/help" nil :visible nil))
2687 "List of functions for the summary tool bar (retro look).
2688
2689See `gmm-tool-bar-from-list' for the format of the list."
2690 :type '(repeat gmm-tool-bar-item)
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(defcustom gnus-summary-tool-bar-zap-list t
2697 "List of icon items from the global tool bar.
2698These items are not displayed in the Gnus summary mode tool bar.
2699
2700See `gmm-tool-bar-from-list' for the format of the list."
2701 :type 'gmm-tool-bar-zap-list
25bf7349 2702 :version "22.1" ;; Gnus 5.10.9
18c06a99
RS
2703 :initialize 'custom-initialize-default
2704 :set 'gnus-summary-tool-bar-update
2705 :group 'gnus-summary)
2706
2707(defvar image-load-path)
2708
2709(defun gnus-summary-make-tool-bar (&optional force)
2710 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2711When FORCE, rebuild the tool bar."
2712 (when (and (not (featurep 'xemacs))
2713 (boundp 'tool-bar-mode)
2714 tool-bar-mode
2715 (or (not gnus-summary-tool-bar-map) force))
2716 (let* ((load-path
2717 (gmm-image-load-path-for-library "gnus"
2718 "mail/save.xpm"
2719 nil t))
2720 (image-load-path (cons (car load-path)
2721 (when (boundp 'image-load-path)
2722 image-load-path)))
2723 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2724 gnus-summary-tool-bar-zap-list
2725 'gnus-summary-mode-map)))
2726 (when map
2727 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2728 ;; uses it's value.
2729 (setq gnus-summary-tool-bar-map map))))
2730 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
60bd5589 2731
eec82323
LMI
2732(defun gnus-score-set-default (var value)
2733 "A version of set that updates the GNU Emacs menu-bar."
2734 (set var value)
2735 ;; It is the message that forces the active status to be updated.
2736 (message ""))
2737
2738(defun gnus-make-score-map (type)
2739 "Make a summary score map of type TYPE."
2740 (if t
2741 nil
2742 (let ((headers '(("author" "from" string)
2743 ("subject" "subject" string)
2744 ("article body" "body" string)
2745 ("article head" "head" string)
2746 ("xref" "xref" string)
16409b0b 2747 ("extra header" "extra" string)
eec82323
LMI
2748 ("lines" "lines" number)
2749 ("followups to author" "followup" string)))
2750 (types '((number ("less than" <)
2751 ("greater than" >)
2752 ("equal" =))
2753 (string ("substring" s)
2754 ("exact string" e)
2755 ("fuzzy string" f)
2756 ("regexp" r))))
2757 (perms '(("temporary" (current-time-string))
2758 ("permanent" nil)
2759 ("immediate" now)))
2760 header)
2761 (list
2762 (apply
2763 'nconc
2764 (list
2765 (if (eq type 'lower)
2766 "Lower score"
2767 "Increase score"))
2768 (let (outh)
2769 (while headers
2770 (setq header (car headers))
2771 (setq outh
2772 (cons
2773 (apply
2774 'nconc
2775 (list (car header))
2776 (let ((ts (cdr (assoc (nth 2 header) types)))
2777 outt)
2778 (while ts
2779 (setq outt
2780 (cons
2781 (apply
2782 'nconc
2783 (list (caar ts))
2784 (let ((ps perms)
2785 outp)
2786 (while ps
2787 (setq outp
2788 (cons
2789 (vector
2790 (caar ps)
2791 (list
2792 'gnus-summary-score-entry
2793 (nth 1 header)
2794 (if (or (string= (nth 1 header)
2795 "head")
2796 (string= (nth 1 header)
2797 "body"))
2798 ""
2799 (list 'gnus-summary-header
2800 (nth 1 header)))
2801 (list 'quote (nth 1 (car ts)))
16409b0b
GM
2802 (list 'gnus-score-delta-default
2803 nil)
eec82323
LMI
2804 (nth 1 (car ps))
2805 t)
2806 t)
2807 outp))
2808 (setq ps (cdr ps)))
2809 (list (nreverse outp))))
2810 outt))
2811 (setq ts (cdr ts)))
2812 (list (nreverse outt))))
2813 outh))
2814 (setq headers (cdr headers)))
2815 (list (nreverse outh))))))))
2816
2817\f
2818
2819(defun gnus-summary-mode (&optional group)
2820 "Major mode for reading articles.
2821
2822All normal editing commands are switched off.
2823\\<gnus-summary-mode-map>
2824Each line in this buffer represents one article. To read an
2825article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2826and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2827respectively.
2828
2829You can also post articles and send mail from this buffer. To
23f87bed 2830follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
eec82323
LMI
2831of an article, type `\\[gnus-summary-reply]'.
2832
2833There are approx. one gazillion commands you can execute in this
2834buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2835
2836The following commands are available:
2837
2838\\{gnus-summary-mode-map}"
2839 (interactive)
eec82323 2840 (kill-all-local-variables)
60bd5589
DL
2841 (when (gnus-visual-p 'summary-menu 'menu)
2842 (gnus-summary-make-menu-bar)
2843 (gnus-summary-make-tool-bar))
eec82323 2844 (gnus-summary-make-local-variables)
23f87bed
MB
2845 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2846 (gnus-summary-make-local-variables))
eec82323
LMI
2847 (gnus-make-thread-indent-array)
2848 (gnus-simplify-mode-line)
2849 (setq major-mode 'gnus-summary-mode)
2850 (setq mode-name "Summary")
2851 (make-local-variable 'minor-mode-alist)
2852 (use-local-map gnus-summary-mode-map)
16409b0b 2853 (buffer-disable-undo)
eec82323
LMI
2854 (setq buffer-read-only t) ;Disable modification
2855 (setq truncate-lines t)
2856 (setq selective-display t)
2857 (setq selective-display-ellipses t) ;Display `...'
2858 (gnus-summary-set-display-table)
2859 (gnus-set-default-directory)
2860 (setq gnus-newsgroup-name group)
2861 (make-local-variable 'gnus-summary-line-format)
2862 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
2863 (make-local-variable 'gnus-summary-dummy-line-format)
2864 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323 2865 (make-local-variable 'gnus-summary-mark-positions)
23f87bed 2866 (gnus-make-local-hook 'pre-command-hook)
6748645f 2867 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
cfcd5c91 2868 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
23f87bed 2869 (turn-on-gnus-mailing-list-mode)
87545352 2870 (mm-enable-multibyte)
eec82323
LMI
2871 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2872 (gnus-update-summary-mark-positions))
2873
2874(defun gnus-summary-make-local-variables ()
2875 "Make all the local summary buffer variables."
16409b0b
GM
2876 (let (global)
2877 (dolist (local gnus-summary-local-variables)
eec82323
LMI
2878 (if (consp local)
2879 (progn
2880 (if (eq (cdr local) 'global)
2881 ;; Copy the global value of the variable.
2882 (setq global (symbol-value (car local)))
2883 ;; Use the value from the list.
2884 (setq global (eval (cdr local))))
16409b0b 2885 (set (make-local-variable (car local)) global))
eec82323 2886 ;; Simple nil-valued local variable.
16409b0b 2887 (set (make-local-variable local) nil)))))
eec82323
LMI
2888
2889(defun gnus-summary-clear-local-variables ()
2890 (let ((locals gnus-summary-local-variables))
2891 (while locals
2892 (if (consp (car locals))
2893 (and (vectorp (caar locals))
2894 (set (caar locals) nil))
2895 (and (vectorp (car locals))
2896 (set (car locals) nil)))
2897 (setq locals (cdr locals)))))
2898
2899;; Summary data functions.
2900
2901(defmacro gnus-data-number (data)
2902 `(car ,data))
2903
2904(defmacro gnus-data-set-number (data number)
2905 `(setcar ,data ,number))
2906
2907(defmacro gnus-data-mark (data)
2908 `(nth 1 ,data))
2909
2910(defmacro gnus-data-set-mark (data mark)
2911 `(setcar (nthcdr 1 ,data) ,mark))
2912
2913(defmacro gnus-data-pos (data)
2914 `(nth 2 ,data))
2915
2916(defmacro gnus-data-set-pos (data pos)
2917 `(setcar (nthcdr 2 ,data) ,pos))
2918
2919(defmacro gnus-data-header (data)
2920 `(nth 3 ,data))
2921
2922(defmacro gnus-data-set-header (data header)
2923 `(setf (nth 3 ,data) ,header))
2924
2925(defmacro gnus-data-level (data)
2926 `(nth 4 ,data))
2927
2928(defmacro gnus-data-unread-p (data)
2929 `(= (nth 1 ,data) gnus-unread-mark))
2930
2931(defmacro gnus-data-read-p (data)
2932 `(/= (nth 1 ,data) gnus-unread-mark))
2933
2934(defmacro gnus-data-pseudo-p (data)
2935 `(consp (nth 3 ,data)))
2936
2937(defmacro gnus-data-find (number)
2938 `(assq ,number gnus-newsgroup-data))
2939
2940(defmacro gnus-data-find-list (number &optional data)
2941 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2942 (memq (assq ,number bdata)
2943 bdata)))
2944
2945(defmacro gnus-data-make (number mark pos header level)
2946 `(list ,number ,mark ,pos ,header ,level))
2947
2948(defun gnus-data-enter (after-article number mark pos header level offset)
2949 (let ((data (gnus-data-find-list after-article)))
2950 (unless data
2951 (error "No such article: %d" after-article))
2952 (setcdr data (cons (gnus-data-make number mark pos header level)
2953 (cdr data)))
2954 (setq gnus-newsgroup-data-reverse nil)
2955 (gnus-data-update-list (cddr data) offset)))
2956
2957(defun gnus-data-enter-list (after-article list &optional offset)
2958 (when list
2959 (let ((data (and after-article (gnus-data-find-list after-article)))
2960 (ilist list))
6748645f
LMI
2961 (if (not (or data
2962 after-article))
2963 (let ((odata gnus-newsgroup-data))
2964 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 2965 (when offset
6748645f 2966 (gnus-data-update-list odata offset)))
23f87bed 2967 ;; Find the last element in the list to be spliced into the main
6748645f
LMI
2968 ;; list.
2969 (while (cdr list)
2970 (setq list (cdr list)))
2971 (if (not data)
2972 (progn
2973 (setcdr list gnus-newsgroup-data)
2974 (setq gnus-newsgroup-data ilist)
2975 (when offset
2976 (gnus-data-update-list (cdr list) offset)))
2977 (setcdr list (cdr data))
2978 (setcdr data ilist)
2979 (when offset
2980 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
2981 (setq gnus-newsgroup-data-reverse nil))))
2982
2983(defun gnus-data-remove (article &optional offset)
2984 (let ((data gnus-newsgroup-data))
2985 (if (= (gnus-data-number (car data)) article)
2986 (progn
2987 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2988 gnus-newsgroup-data-reverse nil)
2989 (when offset
2990 (gnus-data-update-list gnus-newsgroup-data offset)))
2991 (while (cdr data)
2992 (when (= (gnus-data-number (cadr data)) article)
2993 (setcdr data (cddr data))
2994 (when offset
2995 (gnus-data-update-list (cdr data) offset))
2996 (setq data nil
2997 gnus-newsgroup-data-reverse nil))
2998 (setq data (cdr data))))))
2999
3000(defmacro gnus-data-list (backward)
3001 `(if ,backward
3002 (or gnus-newsgroup-data-reverse
3003 (setq gnus-newsgroup-data-reverse
3004 (reverse gnus-newsgroup-data)))
3005 gnus-newsgroup-data))
3006
3007(defun gnus-data-update-list (data offset)
3008 "Add OFFSET to the POS of all data entries in DATA."
6748645f 3009 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
3010 (while data
3011 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3012 (setq data (cdr data))))
3013
eec82323
LMI
3014(defun gnus-summary-article-pseudo-p (article)
3015 "Say whether this article is a pseudo article or not."
3016 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3017
3018(defmacro gnus-summary-article-sparse-p (article)
3019 "Say whether this article is a sparse article or not."
a8151ef7 3020 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
3021
3022(defmacro gnus-summary-article-ancient-p (article)
3023 "Say whether this article is a sparse article or not."
3024 `(memq ,article gnus-newsgroup-ancient))
3025
3026(defun gnus-article-parent-p (number)
3027 "Say whether this article is a parent or not."
3028 (let ((data (gnus-data-find-list number)))
23f87bed 3029 (and (cdr data) ; There has to be an article after...
eec82323
LMI
3030 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3031 (gnus-data-level (nth 1 data))))))
3032
3033(defun gnus-article-children (number)
3034 "Return a list of all children to NUMBER."
3035 (let* ((data (gnus-data-find-list number))
3036 (level (gnus-data-level (car data)))
3037 children)
3038 (setq data (cdr data))
3039 (while (and data
3040 (= (gnus-data-level (car data)) (1+ level)))
3041 (push (gnus-data-number (car data)) children)
3042 (setq data (cdr data)))
3043 children))
3044
3045(defmacro gnus-summary-skip-intangible ()
3046 "If the current article is intangible, then jump to a different article."
3047 '(let ((to (get-text-property (point) 'gnus-intangible)))
3048 (and to (gnus-summary-goto-subject to))))
3049
3050(defmacro gnus-summary-article-intangible-p ()
3051 "Say whether this article is intangible or not."
3052 '(get-text-property (point) 'gnus-intangible))
3053
3054(defun gnus-article-read-p (article)
3055 "Say whether ARTICLE is read or not."
3056 (not (or (memq article gnus-newsgroup-marked)
23f87bed 3057 (memq article gnus-newsgroup-spam-marked)
eec82323
LMI
3058 (memq article gnus-newsgroup-unreads)
3059 (memq article gnus-newsgroup-unselected)
3060 (memq article gnus-newsgroup-dormant))))
3061
3062;; Some summary mode macros.
3063
3064(defmacro gnus-summary-article-number ()
3065 "The article number of the article on the current line.
8f688cb0 3066If there isn't an article number here, then we return the current
eec82323
LMI
3067article number."
3068 '(progn
3069 (gnus-summary-skip-intangible)
3070 (or (get-text-property (point) 'gnus-number)
3071 (gnus-summary-last-subject))))
3072
3073(defmacro gnus-summary-article-header (&optional number)
6748645f 3074 "Return the header of article NUMBER."
eec82323
LMI
3075 `(gnus-data-header (gnus-data-find
3076 ,(or number '(gnus-summary-article-number)))))
3077
3078(defmacro gnus-summary-thread-level (&optional number)
6748645f 3079 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
3080 `(if (and (eq gnus-summary-make-false-root 'dummy)
3081 (get-text-property (point) 'gnus-intangible))
3082 0
3083 (gnus-data-level (gnus-data-find
3084 ,(or number '(gnus-summary-article-number))))))
3085
3086(defmacro gnus-summary-article-mark (&optional number)
6748645f 3087 "Return the mark of article NUMBER."
eec82323
LMI
3088 `(gnus-data-mark (gnus-data-find
3089 ,(or number '(gnus-summary-article-number)))))
3090
3091(defmacro gnus-summary-article-pos (&optional number)
6748645f 3092 "Return the position of the line of article NUMBER."
eec82323
LMI
3093 `(gnus-data-pos (gnus-data-find
3094 ,(or number '(gnus-summary-article-number)))))
3095
3096(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3097(defmacro gnus-summary-article-subject (&optional number)
3098 "Return current subject string or nil if nothing."
3099 `(let ((headers
3100 ,(if number
3101 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3102 '(gnus-data-header (assq (gnus-summary-article-number)
3103 gnus-newsgroup-data)))))
3104 (and headers
3105 (vectorp headers)
3106 (mail-header-subject headers))))
3107
3108(defmacro gnus-summary-article-score (&optional number)
3109 "Return current article score."
3110 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3111 gnus-newsgroup-scored))
3112 gnus-summary-default-score 0))
3113
3114(defun gnus-summary-article-children (&optional number)
6748645f 3115 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
3116 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3117 (level (gnus-data-level (car data)))
3118 l children)
3119 (while (and (setq data (cdr data))
3120 (> (setq l (gnus-data-level (car data))) level))
3121 (and (= (1+ level) l)
3122 (push (gnus-data-number (car data))
3123 children)))
3124 (nreverse children)))
3125
3126(defun gnus-summary-article-parent (&optional number)
6748645f 3127 "Return the article number of the parent of article NUMBER."
eec82323
LMI
3128 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3129 (gnus-data-list t)))
3130 (level (gnus-data-level (car data))))
3131 (if (zerop level)
3132 () ; This is a root.
3133 ;; We search until we find an article with a level less than
3134 ;; this one. That function has to be the parent.
3135 (while (and (setq data (cdr data))
3136 (not (< (gnus-data-level (car data)) level))))
3137 (and data (gnus-data-number (car data))))))
3138
3139(defun gnus-unread-mark-p (mark)
3140 "Say whether MARK is the unread mark."
3141 (= mark gnus-unread-mark))
3142
3143(defun gnus-read-mark-p (mark)
3144 "Say whether MARK is one of the marks that mark as read.
3145This is all marks except unread, ticked, dormant, and expirable."
3146 (not (or (= mark gnus-unread-mark)
3147 (= mark gnus-ticked-mark)
23f87bed 3148 (= mark gnus-spam-mark)
eec82323
LMI
3149 (= mark gnus-dormant-mark)
3150 (= mark gnus-expirable-mark))))
3151
3152(defmacro gnus-article-mark (number)
6748645f
LMI
3153 "Return the MARK of article NUMBER.
3154This macro should only be used when computing the mark the \"first\"
3155time; i.e., when generating the summary lines. After that,
3156`gnus-summary-article-mark' should be used to examine the
3157marks of articles."
eec82323 3158 `(cond
6748645f 3159 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
6748645f 3160 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
3161 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3162 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
23f87bed 3163 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
eec82323
LMI
3164 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3165 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3166 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3167 gnus-ancient-mark))))
3168
3169;; Saving hidden threads.
3170
eec82323
LMI
3171(defmacro gnus-save-hidden-threads (&rest forms)
3172 "Save hidden threads, eval FORMS, and restore the hidden threads."
3173 (let ((config (make-symbol "config")))
3174 `(let ((,config (gnus-hidden-threads-configuration)))
3175 (unwind-protect
3176 (save-excursion
3177 ,@forms)
3178 (gnus-restore-hidden-threads-configuration ,config)))))
23f87bed
MB
3179(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3180(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
eec82323 3181
107ecebb
AS
3182(defun gnus-data-compute-positions ()
3183 "Compute the positions of all articles."
3184 (setq gnus-newsgroup-data-reverse nil)
3185 (let ((data gnus-newsgroup-data))
3186 (save-excursion
3187 (gnus-save-hidden-threads
3188 (gnus-summary-show-all-threads)
3189 (goto-char (point-min))
3190 (while data
3191 (while (get-text-property (point) 'gnus-intangible)
3192 (forward-line 1))
3193 (gnus-data-set-pos (car data) (+ (point) 3))
3194 (setq data (cdr data))
3195 (forward-line 1))))))
3196
16409b0b
GM
3197(defun gnus-hidden-threads-configuration ()
3198 "Return the current hidden threads configuration."
3199 (save-excursion
3200 (let (config)
3201 (goto-char (point-min))
3202 (while (search-forward "\r" nil t)
3203 (push (1- (point)) config))
3204 config)))
3205
3206(defun gnus-restore-hidden-threads-configuration (config)
3207 "Restore hidden threads configuration from CONFIG."
3208 (save-excursion
3209 (let (point buffer-read-only)
3210 (while (setq point (pop config))
3211 (when (and (< point (point-max))
3212 (goto-char point)
3213 (eq (char-after) ?\n))
3214 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3215
eec82323
LMI
3216;; Various summary mode internalish functions.
3217
3218(defun gnus-mouse-pick-article (e)
3219 (interactive "e")
3220 (mouse-set-point e)
3221 (gnus-summary-next-page nil t))
3222
3223(defun gnus-summary-set-display-table ()
16409b0b
GM
3224 "Change the display table.
3225Odd characters have a tendency to mess
3226up nicely formatted displays - we make all possible glyphs
3227display only a single character."
eec82323
LMI
3228
3229 ;; We start from the standard display table, if any.
3230 (let ((table (or (copy-sequence standard-display-table)
3231 (make-display-table)))
3232 (i 32))
3233 ;; Nix out all the control chars...
3234 (while (>= (setq i (1- i)) 0)
3235 (aset table i [??]))
23f87bed 3236 ;; ... but not newline and cr, of course. (cr is necessary for the
eec82323
LMI
3237 ;; selective display).
3238 (aset table ?\n nil)
3239 (aset table ?\r nil)
6748645f
LMI
3240 ;; We keep TAB as well.
3241 (aset table ?\t nil)
719120ef 3242 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
fe62aacc 3243 ;; Emacs 23 (unicode), that are not set already.
719120ef
MB
3244 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3245 160
3246 256)))
eec82323
LMI
3247 (while (>= (setq i (1- i)) 127)
3248 ;; Only modify if the entry is nil.
3249 (unless (aref table i)
3250 (aset table i [??]))))
3251 (setq buffer-display-table table)))
3252
23f87bed
MB
3253(defun gnus-summary-set-article-display-arrow (pos)
3254 "Update the overlay arrow to point to line at position POS."
3255 (when (and gnus-summary-display-arrow
3256 (boundp 'overlay-arrow-position)
3257 (boundp 'overlay-arrow-string))
3258 (save-excursion
3259 (goto-char pos)
3260 (beginning-of-line)
3261 (unless overlay-arrow-position
3262 (setq overlay-arrow-position (make-marker)))
3263 (setq overlay-arrow-string "=>"
3264 overlay-arrow-position (set-marker overlay-arrow-position
3265 (point)
3266 (current-buffer))))))
3267
eec82323
LMI
3268(defun gnus-summary-setup-buffer (group)
3269 "Initialize summary buffer."
23f87bed
MB
3270 (let ((buffer (gnus-summary-buffer-name group))
3271 (dead-name (concat "*Dead Summary "
3272 (gnus-group-decoded-name group) "*")))
3273 ;; If a dead summary buffer exists, we kill it.
3274 (when (gnus-buffer-live-p dead-name)
3275 (gnus-kill-buffer dead-name))
eec82323
LMI
3276 (if (get-buffer buffer)
3277 (progn
3278 (set-buffer buffer)
3279 (setq gnus-summary-buffer (current-buffer))
3280 (not gnus-newsgroup-prepared))
3281 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 3282 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323
LMI
3283 (gnus-summary-mode group)
3284 (when gnus-carpal
3285 (gnus-carpal-setup-buffer 'summary))
3286 (unless gnus-single-article-buffer
3287 (make-local-variable 'gnus-article-buffer)
3288 (make-local-variable 'gnus-article-current)
3289 (make-local-variable 'gnus-original-article-buffer))
3290 (setq gnus-newsgroup-name group)
23f87bed
MB
3291 ;; Set any local variables in the group parameters.
3292 (gnus-summary-set-local-parameters gnus-newsgroup-name)
eec82323
LMI
3293 t)))
3294
3295(defun gnus-set-global-variables ()
16409b0b
GM
3296 "Set the global equivalents of the buffer-local variables.
3297They are set to the latest values they had. These reflect the summary
3298buffer that was in action when the last article was fetched."
eec82323
LMI
3299 (when (eq major-mode 'gnus-summary-mode)
3300 (setq gnus-summary-buffer (current-buffer))
3301 (let ((name gnus-newsgroup-name)
3302 (marked gnus-newsgroup-marked)
23f87bed 3303 (spam gnus-newsgroup-spam-marked)
eec82323
LMI
3304 (unread gnus-newsgroup-unreads)
3305 (headers gnus-current-headers)
3306 (data gnus-newsgroup-data)
3307 (summary gnus-summary-buffer)
3308 (article-buffer gnus-article-buffer)
3309 (original gnus-original-article-buffer)
3310 (gac gnus-article-current)
3311 (reffed gnus-reffed-article-number)
16409b0b 3312 (score-file gnus-current-score-file)
23f87bed
MB
3313 (default-charset gnus-newsgroup-charset)
3314 vlist)
3315 (let ((locals gnus-newsgroup-variables))
3316 (while locals
3317 (if (consp (car locals))
3318 (push (eval (caar locals)) vlist)
3319 (push (eval (car locals)) vlist))
3320 (setq locals (cdr locals)))
3321 (setq vlist (nreverse vlist)))
eec82323
LMI
3322 (save-excursion
3323 (set-buffer gnus-group-buffer)
6748645f
LMI
3324 (setq gnus-newsgroup-name name
3325 gnus-newsgroup-marked marked
23f87bed 3326 gnus-newsgroup-spam-marked spam
6748645f
LMI
3327 gnus-newsgroup-unreads unread
3328 gnus-current-headers headers
3329 gnus-newsgroup-data data
3330 gnus-article-current gac
3331 gnus-summary-buffer summary
3332 gnus-article-buffer article-buffer
3333 gnus-original-article-buffer original
3334 gnus-reffed-article-number reffed
16409b0b
GM
3335 gnus-current-score-file score-file
3336 gnus-newsgroup-charset default-charset)
23f87bed
MB
3337 (let ((locals gnus-newsgroup-variables))
3338 (while locals
3339 (if (consp (car locals))
3340 (set (caar locals) (pop vlist))
3341 (set (car locals) (pop vlist)))
3342 (setq locals (cdr locals))))
eec82323
LMI
3343 ;; The article buffer also has local variables.
3344 (when (gnus-buffer-live-p gnus-article-buffer)
3345 (set-buffer gnus-article-buffer)
3346 (setq gnus-summary-buffer summary))))))
3347
3348(defun gnus-summary-article-unread-p (article)
3349 "Say whether ARTICLE is unread or not."
3350 (memq article gnus-newsgroup-unreads))
3351
3352(defun gnus-summary-first-article-p (&optional article)
3353 "Return whether ARTICLE is the first article in the buffer."
3354 (if (not (setq article (or article (gnus-summary-article-number))))
3355 nil
3356 (eq article (caar gnus-newsgroup-data))))
3357
3358(defun gnus-summary-last-article-p (&optional article)
3359 "Return whether ARTICLE is the last article in the buffer."
3360 (if (not (setq article (or article (gnus-summary-article-number))))
16409b0b
GM
3361 ;; All non-existent numbers are the last article. :-)
3362 t
eec82323
LMI
3363 (not (cdr (gnus-data-find-list article)))))
3364
4921bbdd
CY
3365(defun gnus-make-thread-indent-array (&optional n)
3366 (when (or n
3367 (progn (setq n 200) nil)
3368 (null gnus-thread-indent-array)
3369 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3370 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3371 gnus-thread-indent-array-level gnus-thread-indent-level)
3372 (while (>= n 0)
3373 (aset gnus-thread-indent-array n
6a30c01d 3374 (make-string (* n gnus-thread-indent-level) ? ))
4921bbdd 3375 (setq n (1- n)))))
eec82323
LMI
3376
3377(defun gnus-update-summary-mark-positions ()
3378 "Compute where the summary marks are to go."
3379 (save-excursion
6748645f 3380 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323 3381 (set-buffer gnus-summary-buffer))
5153a47a
MB
3382 (let ((spec gnus-summary-line-format-spec)
3383 pos)
eec82323
LMI
3384 (save-excursion
3385 (gnus-set-work-buffer)
5153a47a
MB
3386 (let ((gnus-tmp-unread ?Z)
3387 (gnus-replied-mark ?Z)
3388 (gnus-score-below-mark ?Z)
3389 (gnus-score-over-mark ?Z)
3390 (gnus-undownloaded-mark ?Z)
3391 (gnus-summary-line-format-spec spec)
54506618 3392 (gnus-newsgroup-downloadable '(0))
5153a47a
MB
3393 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3394 case-fold-search ignores)
3395 ;; Here, all marks are bound to Z.
3396 (gnus-summary-insert-line header
3397 0 nil t gnus-tmp-unread t nil "" nil 1)
3398 (goto-char (point-min))
3399 ;; Memorize the positions of the same characters as dummy marks.
3400 (while (re-search-forward "[A-D]" nil t)
3401 (push (point) ignores))
54506618 3402 (erase-buffer)
5153a47a
MB
3403 ;; We use A-D as dummy marks in order to know column positions
3404 ;; where marks should be inserted.
3405 (setq gnus-tmp-unread ?A
3406 gnus-replied-mark ?B
3407 gnus-score-below-mark ?C
3408 gnus-score-over-mark ?C
3409 gnus-undownloaded-mark ?D)
3410 (gnus-summary-insert-line header
3411 0 nil t gnus-tmp-unread t nil "" nil 1)
3412 ;; Ignore characters which aren't dummy marks.
3413 (dolist (p ignores)
3414 (delete-region (goto-char (1- p)) p)
3415 (insert ?Z))
eec82323 3416 (goto-char (point-min))
7c3bb5a5 3417 (setq pos (list (cons 'unread
5153a47a 3418 (and (search-forward "A" nil t)
7c3bb5a5 3419 (- (point) (point-min) 1)))))
eec82323 3420 (goto-char (point-min))
5153a47a 3421 (push (cons 'replied (and (search-forward "B" nil t)
667e0ba6 3422 (- (point) (point-min) 1)))
eec82323
LMI
3423 pos)
3424 (goto-char (point-min))
5153a47a 3425 (push (cons 'score (and (search-forward "C" nil t)
667e0ba6 3426 (- (point) (point-min) 1)))
6748645f
LMI
3427 pos)
3428 (goto-char (point-min))
5153a47a 3429 (push (cons 'download (and (search-forward "D" nil t)
7c3bb5a5 3430 (- (point) (point-min) 1)))
eec82323
LMI
3431 pos)))
3432 (setq gnus-summary-mark-positions pos))))
3433
3434(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3435 "Insert a dummy root in the summary buffer."
3436 (beginning-of-line)
3437 (gnus-add-text-properties
3438 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3439 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3440
23f87bed
MB
3441(defun gnus-summary-extract-address-component (from)
3442 (or (car (funcall gnus-extract-address-components from))
3443 from))
3444
3445(defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3446 (let ((mail-parse-charset gnus-newsgroup-charset)
3447 ; Is it really necessary to do this next part for each summary line?
3448 ; Luckily, doesn't seem to slow things down much.
16409b0b
GM
3449 (mail-parse-ignored-charsets
3450 (save-excursion (set-buffer gnus-summary-buffer)
3451 gnus-newsgroup-ignored-charsets)))
23f87bed
MB
3452 (or
3453 (and gnus-ignored-from-addresses
3454 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3455 (let ((extra-headers (mail-header-extra header))
3456 to
3457 newsgroups)
3458 (cond
3459 ((setq to (cdr (assq 'To extra-headers)))
3460 (concat "-> "
3461 (inline
3462 (gnus-summary-extract-address-component
343d6628 3463 (funcall gnus-decode-encoded-address-function to)))))
23f87bed
MB
3464 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3465 (concat "=> " newsgroups)))))
3466 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
16409b0b 3467
eec82323
LMI
3468(defun gnus-summary-insert-line (gnus-tmp-header
3469 gnus-tmp-level gnus-tmp-current
23f87bed 3470 undownloaded gnus-tmp-unread gnus-tmp-replied
eec82323
LMI
3471 gnus-tmp-expirable gnus-tmp-subject-or-nil
3472 &optional gnus-tmp-dummy gnus-tmp-score
3473 gnus-tmp-process)
4921bbdd
CY
3474 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3475 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3476 gnus-tmp-level)))
eec82323
LMI
3477 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3478 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3479 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3480 (gnus-tmp-score-char
3481 (if (or (null gnus-summary-default-score)
3482 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3483 gnus-summary-zcore-fuzz))
23f87bed 3484 ? ;Whitespace
eec82323
LMI
3485 (if (< gnus-tmp-score gnus-summary-default-score)
3486 gnus-score-below-mark gnus-score-over-mark)))
23f87bed 3487 (gnus-tmp-number (mail-header-number gnus-tmp-header))
eec82323
LMI
3488 (gnus-tmp-replied
3489 (cond (gnus-tmp-process gnus-process-mark)
3490 ((memq gnus-tmp-current gnus-newsgroup-cached)
3491 gnus-cached-mark)
3492 (gnus-tmp-replied gnus-replied-mark)
23f87bed
MB
3493 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3494 gnus-forwarded-mark)
eec82323
LMI
3495 ((memq gnus-tmp-current gnus-newsgroup-saved)
3496 gnus-saved-mark)
23f87bed
MB
3497 ((memq gnus-tmp-number gnus-newsgroup-recent)
3498 gnus-recent-mark)
3499 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3500 gnus-unseen-mark)
3501 (t gnus-no-mark)))
3502 (gnus-tmp-downloaded
3503 (cond (undownloaded
3504 gnus-undownloaded-mark)
3505 (gnus-newsgroup-agentized
3506 gnus-downloaded-mark)
3507 (t
3508 gnus-no-mark)))
eec82323
LMI
3509 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3510 (gnus-tmp-name
3511 (cond
3512 ((string-match "<[^>]+> *$" gnus-tmp-from)
3513 (let ((beg (match-beginning 0)))
23f87bed
MB
3514 (or (and (string-match "^\".+\"" gnus-tmp-from)
3515 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
3516 (substring gnus-tmp-from 0 beg))))
3517 ((string-match "(.+)" gnus-tmp-from)
3518 (substring gnus-tmp-from
3519 (1+ (match-beginning 0)) (1- (match-end 0))))
3520 (t gnus-tmp-from)))
3521 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
eec82323
LMI
3522 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3523 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3524 (buffer-read-only nil))
3525 (when (string= gnus-tmp-name "")
3526 (setq gnus-tmp-name gnus-tmp-from))
3527 (unless (numberp gnus-tmp-lines)
23f87bed
MB
3528 (setq gnus-tmp-lines -1))
3529 (if (= gnus-tmp-lines -1)
3530 (setq gnus-tmp-lines "?")
3531 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3532 (gnus-put-text-property
eec82323
LMI
3533 (point)
3534 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 3535 'gnus-number gnus-tmp-number)
eec82323
LMI
3536 (when (gnus-visual-p 'summary-highlight 'highlight)
3537 (forward-line -1)
6748645f 3538 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3539 (forward-line 1))))
3540
3541(defun gnus-summary-update-line (&optional dont-update)
16409b0b 3542 "Update summary line after change."
eec82323
LMI
3543 (when (and gnus-summary-default-score
3544 (not gnus-summary-inhibit-highlight))
3545 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3546 (article (gnus-summary-article-number))
3547 (score (gnus-summary-article-score article)))
3548 (unless dont-update
3549 (if (and gnus-summary-mark-below
3550 (< (gnus-summary-article-score)
3551 gnus-summary-mark-below))
3552 ;; This article has a low score, so we mark it as read.
3553 (when (memq article gnus-newsgroup-unreads)
3554 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3555 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3556 ;; This article was previously marked as read on account
3557 ;; of a low score, but now it has risen, so we mark it as
3558 ;; unread.
3559 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3560 (gnus-summary-update-mark
3561 (if (or (null gnus-summary-default-score)
3562 (<= (abs (- score gnus-summary-default-score))
3563 gnus-summary-zcore-fuzz))
23f87bed 3564 ? ;Whitespace
eec82323
LMI
3565 (if (< score gnus-summary-default-score)
3566 gnus-score-below-mark gnus-score-over-mark))
3567 'score))
3568 ;; Do visual highlighting.
3569 (when (gnus-visual-p 'summary-highlight 'highlight)
6748645f 3570 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
3571
3572(defvar gnus-tmp-new-adopts nil)
3573
3574(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3575 "Return the number of articles in THREAD.
3576This may be 0 in some cases -- if none of the articles in
3577the thread are to be displayed."
3578 (let* ((number
23f87bed 3579 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
eec82323
LMI
3580 (cond
3581 ((not (listp thread))
3582 1)
3583 ((and (consp thread) (cdr thread))
3584 (apply
3585 '+ 1 (mapcar
3586 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3587 ((null thread)
3588 1)
3589 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3590 1)
3591 (t 0))))
3592 (when (and level (zerop level) gnus-tmp-new-adopts)
3593 (incf number
3594 (apply '+ (mapcar
3595 'gnus-summary-number-of-articles-in-thread
3596 gnus-tmp-new-adopts))))
3597 (if char
3598 (if (> number 1) gnus-not-empty-thread-mark
3599 gnus-empty-thread-mark)
3600 number)))
3601
23f87bed
MB
3602(defsubst gnus-summary-line-message-size (head)
3603 "Return pretty-printed version of message size.
3604This function is intended to be used in
3605`gnus-summary-line-format-alist'."
3606 (let ((c (or (mail-header-chars head) -1)))
3607 (cond ((< c 0) "n/a") ; chars not available
3608 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3609 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3610 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3611 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3612
3613
eec82323
LMI
3614(defun gnus-summary-set-local-parameters (group)
3615 "Go through the local params of GROUP and set all variable specs in that list."
3616 (let ((params (gnus-group-find-parameter group))
23f87bed 3617 (vars '(quit-config)) ; Ignore quit-config.
eec82323
LMI
3618 elem)
3619 (while params
3620 (setq elem (car params)
3621 params (cdr params))
3622 (and (consp elem) ; Has to be a cons.
3623 (consp (cdr elem)) ; The cdr has to be a list.
3624 (symbolp (car elem)) ; Has to be a symbol in there.
23f87bed 3625 (not (memq (car elem) vars))
eec82323 3626 (ignore-errors ; So we set it.
23f87bed 3627 (push (car elem) vars)
eec82323
LMI
3628 (make-local-variable (car elem))
3629 (set (car elem) (eval (nth 1 elem))))))))
3630
3631(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
3632 kill-buffer no-display backward
3633 select-articles)
eec82323
LMI
3634 "Start reading news in newsgroup GROUP.
3635If SHOW-ALL is non-nil, already read articles are also listed.
3636If NO-ARTICLE is non-nil, no article is selected initially.
3637If NO-DISPLAY, don't generate a summary buffer."
3638 (let (result)
3639 (while (and group
3640 (null (setq result
3641 (let ((gnus-auto-select-next nil))
6748645f
LMI
3642 (or (gnus-summary-read-group-1
3643 group show-all no-article
3644 kill-buffer no-display
3645 select-articles)
3646 (setq show-all nil
16409b0b 3647 select-articles nil)))))
eec82323
LMI
3648 (eq gnus-auto-select-next 'quietly))
3649 (set-buffer gnus-group-buffer)
6748645f
LMI
3650 ;; The entry function called above goes to the next
3651 ;; group automatically, so we go two groups back
3652 ;; if we are searching for the previous group.
3653 (when backward
3654 (gnus-group-prev-unread-group 2))
eec82323
LMI
3655 (if (not (equal group (gnus-group-group-name)))
3656 (setq group (gnus-group-group-name))
3657 (setq group nil)))
3658 result))
3659
3660(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
3661 kill-buffer no-display
3662 &optional select-articles)
eec82323 3663 ;; Killed foreign groups can't be entered.
23f87bed
MB
3664 ;; (when (and (not (gnus-group-native-p group))
3665 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3666 ;; (error "Dead non-native groups can't be entered"))
3667 (gnus-message 5 "Retrieving newsgroup: %s..."
3668 (gnus-group-decoded-name group))
eec82323
LMI
3669 (let* ((new-group (gnus-summary-setup-buffer group))
3670 (quit-config (gnus-group-quit-config group))
6748645f
LMI
3671 (did-select (and new-group (gnus-select-newsgroup
3672 group show-all select-articles))))
eec82323
LMI
3673 (cond
3674 ;; This summary buffer exists already, so we just select it.
3675 ((not new-group)
3676 (gnus-set-global-variables)
3677 (when kill-buffer
3678 (gnus-kill-or-deaden-summary kill-buffer))
3679 (gnus-configure-windows 'summary 'force)
3680 (gnus-set-mode-line 'summary)
3681 (gnus-summary-position-point)
3682 (message "")
3683 t)
3684 ;; We couldn't select this group.
3685 ((null did-select)
3686 (when (and (eq major-mode 'gnus-summary-mode)
3687 (not (equal (current-buffer) kill-buffer)))
3688 (kill-buffer (current-buffer))
3689 (if (not quit-config)
3690 (progn
6748645f
LMI
3691 ;; Update the info -- marks might need to be removed,
3692 ;; for instance.
3693 (gnus-summary-update-info)
eec82323
LMI
3694 (set-buffer gnus-group-buffer)
3695 (gnus-group-jump-to-group group)
3696 (gnus-group-next-unread-group 1))
3697 (gnus-handle-ephemeral-exit quit-config)))
23f87bed
MB
3698 (let ((grpinfo (gnus-get-info group)))
3699 (if (null (gnus-info-read grpinfo))
3700 (gnus-message 3 "Group %s contains no messages"
3701 (gnus-group-decoded-name group))
3702 (gnus-message 3 "Can't select group")))
eec82323
LMI
3703 nil)
3704 ;; The user did a `C-g' while prompting for number of articles,
3705 ;; so we exit this group.
3706 ((eq did-select 'quit)
3707 (and (eq major-mode 'gnus-summary-mode)
3708 (not (equal (current-buffer) kill-buffer))
3709 (kill-buffer (current-buffer)))
3710 (when kill-buffer
3711 (gnus-kill-or-deaden-summary kill-buffer))
3712 (if (not quit-config)
3713 (progn
3714 (set-buffer gnus-group-buffer)
3715 (gnus-group-jump-to-group group)
3716 (gnus-group-next-unread-group 1)
3717 (gnus-configure-windows 'group 'force))
3718 (gnus-handle-ephemeral-exit quit-config))
3719 ;; Finally signal the quit.
3720 (signal 'quit nil))
3721 ;; The group was successfully selected.
3722 (t
3723 (gnus-set-global-variables)
3724 ;; Save the active value in effect when the group was entered.
3725 (setq gnus-newsgroup-active
3726 (gnus-copy-sequence
3727 (gnus-active gnus-newsgroup-name)))
3728 ;; You can change the summary buffer in some way with this hook.
6748645f 3729 (gnus-run-hooks 'gnus-select-group-hook)
5153a47a
MB
3730 (when (memq 'summary (gnus-update-format-specifications
3731 nil 'summary 'summary-mode 'summary-dummy))
3732 ;; The format specification for the summary line was updated,
3733 ;; so we need to update the mark positions as well.
3734 (gnus-update-summary-mark-positions))
eec82323
LMI
3735 ;; Do score processing.
3736 (when gnus-use-scoring
3737 (gnus-possibly-score-headers))
3738 ;; Check whether to fill in the gaps in the threads.
3739 (when gnus-build-sparse-threads
3740 (gnus-build-sparse-threads))
3741 ;; Find the initial limit.
26c9afc3
MB
3742 (if show-all
3743 (let ((gnus-newsgroup-dormant nil))
eec82323 3744 (gnus-summary-initial-limit show-all))
26c9afc3 3745 (gnus-summary-initial-limit show-all))
eec82323
LMI
3746 ;; Generate the summary buffer.
3747 (unless no-display
3748 (gnus-summary-prepare))
3749 (when gnus-use-trees
3750 (gnus-tree-open group)
3751 (setq gnus-summary-highlight-line-function
3752 'gnus-tree-highlight-article))
3753 ;; If the summary buffer is empty, but there are some low-scored
3754 ;; articles or some excluded dormants, we include these in the
3755 ;; buffer.
3756 (when (and (zerop (buffer-size))
3757 (not no-display))
3758 (cond (gnus-newsgroup-dormant
3759 (gnus-summary-limit-include-dormant))
3760 ((and gnus-newsgroup-scored show-all)
3761 (gnus-summary-limit-include-expunged t))))
3762 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 3763 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
3764 (if (and (zerop (buffer-size))
3765 (not no-display))
3766 (progn
3767 ;; This newsgroup is empty.
3768 (gnus-summary-catchup-and-exit nil t)
3769 (gnus-message 6 "No unread news")
3770 (when kill-buffer
3771 (gnus-kill-or-deaden-summary kill-buffer))
3772 ;; Return nil from this function.
3773 nil)
3774 ;; Hide conversation thread subtrees. We cannot do this in
3775 ;; gnus-summary-prepare-hook since kill processing may not
3776 ;; work with hidden articles.
23f87bed 3777 (gnus-summary-maybe-hide-threads)
6748645f
LMI
3778 (when kill-buffer
3779 (gnus-kill-or-deaden-summary kill-buffer))
23f87bed 3780 (gnus-summary-auto-select-subject)
eec82323
LMI
3781 ;; Show first unread article if requested.
3782 (if (and (not no-article)
3783 (not no-display)
3784 gnus-newsgroup-unreads
3785 gnus-auto-select-first)
16409b0b
GM
3786 (progn
3787 (gnus-configure-windows 'summary)
23f87bed
MB
3788 (let ((art (gnus-summary-article-number)))
3789 (unless (and (not gnus-plugged)
3790 (or (memq art gnus-newsgroup-undownloaded)
3791 (memq art gnus-newsgroup-downloadable)))
3792 (gnus-summary-goto-article art))))
3793 ;; Don't select any articles.
eec82323 3794 (gnus-summary-position-point)
6748645f
LMI
3795 (gnus-configure-windows 'summary 'force)
3796 (gnus-set-mode-line 'summary))
23f87bed
MB
3797 (when (and gnus-auto-center-group
3798 (get-buffer-window gnus-group-buffer t))
eec82323
LMI
3799 ;; Gotta use windows, because recenter does weird stuff if
3800 ;; the current buffer ain't the displayed window.
3801 (let ((owin (selected-window)))
3802 (select-window (get-buffer-window gnus-group-buffer t))
3803 (when (gnus-group-goto-group group)
3804 (recenter))
3805 (select-window owin)))
3806 ;; Mark this buffer as "prepared".
3807 (setq gnus-newsgroup-prepared t)
6748645f 3808 (gnus-run-hooks 'gnus-summary-prepared-hook)
23f87bed
MB
3809 (unless (gnus-ephemeral-group-p group)
3810 (gnus-group-update-group group))
eec82323
LMI
3811 t)))))
3812
23f87bed
MB
3813(defun gnus-summary-auto-select-subject ()
3814 "Select the subject line on initial group entry."
3815 (goto-char (point-min))
3816 (cond
3817 ((eq gnus-auto-select-subject 'best)
3818 (gnus-summary-best-unread-subject))
3819 ((eq gnus-auto-select-subject 'unread)
3820 (gnus-summary-first-unread-subject))
3821 ((eq gnus-auto-select-subject 'unseen)
3822 (gnus-summary-first-unseen-subject))
3823 ((eq gnus-auto-select-subject 'unseen-or-unread)
3824 (gnus-summary-first-unseen-or-unread-subject))
3825 ((eq gnus-auto-select-subject 'first)
3826 ;; Do nothing.
3827 )
3828 ((functionp gnus-auto-select-subject)
3829 (funcall gnus-auto-select-subject))))
3830
eec82323
LMI
3831(defun gnus-summary-prepare ()
3832 "Generate the summary buffer."
3833 (interactive)
3834 (let ((buffer-read-only nil))
3835 (erase-buffer)
3836 (setq gnus-newsgroup-data nil
3837 gnus-newsgroup-data-reverse nil)
6748645f 3838 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
3839 ;; Generate the buffer, either with threads or without.
3840 (when gnus-newsgroup-headers
3841 (gnus-summary-prepare-threads
3842 (if gnus-show-threads
3843 (gnus-sort-gathered-threads
3844 (funcall gnus-summary-thread-gathering-function
3845 (gnus-sort-threads
3846 (gnus-cut-threads (gnus-make-threads)))))
3847 ;; Unthreaded display.
3848 (gnus-sort-articles gnus-newsgroup-headers))))
3849 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3850 ;; Call hooks for modifying summary buffer.
3851 (goto-char (point-min))
6748645f 3852 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
3853
3854(defsubst gnus-general-simplify-subject (subject)
23f87bed 3855 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
eec82323
LMI
3856 (setq subject
3857 (cond
3858 ;; Truncate the subject.
6748645f
LMI
3859 (gnus-simplify-subject-functions
3860 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
3861 ((numberp gnus-summary-gather-subject-limit)
3862 (setq subject (gnus-simplify-subject-re subject))
3863 (if (> (length subject) gnus-summary-gather-subject-limit)
3864 (substring subject 0 gnus-summary-gather-subject-limit)
3865 subject))
3866 ;; Fuzzily simplify it.
3867 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3868 (gnus-simplify-subject-fuzzy subject))
3869 ;; Just remove the leading "Re:".
3870 (t
3871 (gnus-simplify-subject-re subject))))
3872
3873 (if (and gnus-summary-gather-exclude-subject
3874 (string-match gnus-summary-gather-exclude-subject subject))
23f87bed 3875 nil ; This article shouldn't be gathered
eec82323
LMI
3876 subject))
3877
3878(defun gnus-summary-simplify-subject-query ()
3879 "Query where the respool algorithm would put this article."
3880 (interactive)
eec82323
LMI
3881 (gnus-summary-select-article)
3882 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3883
3884(defun gnus-gather-threads-by-subject (threads)
3885 "Gather threads by looking at Subject headers."
3886 (if (not gnus-summary-make-false-root)
3887 threads
3888 (let ((hashtb (gnus-make-hashtable 1024))
3889 (prev threads)
3890 (result threads)
3891 subject hthread whole-subject)
3892 (while threads
3893 (setq subject (gnus-general-simplify-subject
3894 (setq whole-subject (mail-header-subject
3895 (caar threads)))))
3896 (when subject
3897 (if (setq hthread (gnus-gethash subject hashtb))
3898 (progn
3899 ;; We enter a dummy root into the thread, if we
3900 ;; haven't done that already.
3901 (unless (stringp (caar hthread))
3902 (setcar hthread (list whole-subject (car hthread))))
3903 ;; We add this new gathered thread to this gathered
3904 ;; thread.
3905 (setcdr (car hthread)
3906 (nconc (cdar hthread) (list (car threads))))
3907 ;; Remove it from the list of threads.
3908 (setcdr prev (cdr threads))
3909 (setq threads prev))
3910 ;; Enter this thread into the hash table.
23f87bed
MB
3911 (gnus-sethash subject
3912 (if gnus-summary-make-false-root-always
3913 (progn
3914 ;; If you want a dummy root above all
3915 ;; threads...
3916 (setcar threads (list whole-subject
3917 (car threads)))
3918 threads)
3919 threads)
3920 hashtb)))
eec82323
LMI
3921 (setq prev threads)
3922 (setq threads (cdr threads)))
3923 result)))
3924
3925(defun gnus-gather-threads-by-references (threads)
3926 "Gather threads by looking at References headers."
3927 (let ((idhashtb (gnus-make-hashtable 1024))
3928 (thhashtb (gnus-make-hashtable 1024))
3929 (prev threads)
3930 (result threads)
3931 ids references id gthread gid entered ref)
3932 (while threads
3933 (when (setq references (mail-header-references (caar threads)))
3934 (setq id (mail-header-id (caar threads))
23f87bed 3935 ids (inline (gnus-split-references references))
eec82323
LMI
3936 entered nil)
3937 (while (setq ref (pop ids))
3938 (setq ids (delete ref ids))
3939 (if (not (setq gid (gnus-gethash ref idhashtb)))
3940 (progn
3941 (gnus-sethash ref id idhashtb)
3942 (gnus-sethash id threads thhashtb))
3943 (setq gthread (gnus-gethash gid thhashtb))
3944 (unless entered
3945 ;; We enter a dummy root into the thread, if we
3946 ;; haven't done that already.
3947 (unless (stringp (caar gthread))
3948 (setcar gthread (list (mail-header-subject (caar gthread))
3949 (car gthread))))
3950 ;; We add this new gathered thread to this gathered
3951 ;; thread.
3952 (setcdr (car gthread)
3953 (nconc (cdar gthread) (list (car threads)))))
3954 ;; Add it into the thread hash table.
3955 (gnus-sethash id gthread thhashtb)
3956 (setq entered t)
3957 ;; Remove it from the list of threads.
3958 (setcdr prev (cdr threads))
3959 (setq threads prev))))
3960 (setq prev threads)
3961 (setq threads (cdr threads)))
3962 result))
3963
3964(defun gnus-sort-gathered-threads (threads)
16409b0b 3965 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
eec82323
LMI
3966 (let ((result threads))
3967 (while threads
3968 (when (stringp (caar threads))
3969 (setcdr (car threads)
16409b0b 3970 (sort (cdar threads) gnus-sort-gathered-threads-function)))
eec82323
LMI
3971 (setq threads (cdr threads)))
3972 result))
3973
3974(defun gnus-thread-loop-p (root thread)
3975 "Say whether ROOT is in THREAD."
3976 (let ((stack (list thread))
3977 (infloop 0)
3978 th)
3979 (while (setq thread (pop stack))
3980 (setq th (cdr thread))
3981 (while (and th
3982 (not (eq (caar th) root)))
3983 (pop th))
3984 (if th
3985 ;; We have found a loop.
3986 (let (ref-dep)
3987 (setcdr thread (delq (car th) (cdr thread)))
3988 (if (boundp (setq ref-dep (intern "none"
3989 gnus-newsgroup-dependencies)))
3990 (setcdr (symbol-value ref-dep)
3991 (nconc (cdr (symbol-value ref-dep))
3992 (list (car th))))
3993 (set ref-dep (list nil (car th))))
3994 (setq infloop 1
3995 stack nil))
3996 ;; Push all the subthreads onto the stack.
3997 (push (cdr thread) stack)))
3998 infloop))
3999
4000(defun gnus-make-threads ()
01ccbb85 4001 "Go through the dependency hashtb and find the roots. Return all threads."
eec82323
LMI
4002 (let (threads)
4003 (while (catch 'infloop
4004 (mapatoms
4005 (lambda (refs)
4006 ;; Deal with self-referencing References loops.
4007 (when (and (car (symbol-value refs))
4008 (not (zerop
4009 (apply
4010 '+
4011 (mapcar
4012 (lambda (thread)
4013 (gnus-thread-loop-p
4014 (car (symbol-value refs)) thread))
4015 (cdr (symbol-value refs)))))))
4016 (setq threads nil)
4017 (throw 'infloop t))
4018 (unless (car (symbol-value refs))
23f87bed
MB
4019 ;; These threads do not refer back to any other
4020 ;; articles, so they're roots.
eec82323
LMI
4021 (setq threads (append (cdr (symbol-value refs)) threads))))
4022 gnus-newsgroup-dependencies)))
4023 threads))
4024
6748645f 4025;; Build the thread tree.
16409b0b 4026(defsubst gnus-dependencies-add-header (header dependencies force-new)
6748645f
LMI
4027 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4028
4029If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4030if it was already present.
4031
4032If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4033will not be entered in the DEPENDENCIES table. Otherwise duplicate
23f87bed
MB
4034Message-IDs will be renamed to a unique Message-ID before being
4035entered.
6748645f
LMI
4036
4037Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4038 (let* ((id (mail-header-id header))
4039 (id-dep (and id (intern id dependencies)))
23f87bed 4040 parent-id ref ref-dep ref-header replaced)
6748645f
LMI
4041 ;; Enter this `header' in the `dependencies' table.
4042 (cond
4043 ((not id-dep)
4044 (setq header nil))
4045 ;; The first two cases do the normal part: enter a new `header'
4046 ;; in the `dependencies' table.
4047 ((not (boundp id-dep))
4048 (set id-dep (list header)))
4049 ((null (car (symbol-value id-dep)))
4050 (setcar (symbol-value id-dep) header))
4051
4052 ;; From here the `header' was already present in the
4053 ;; `dependencies' table.
4054 (force-new
4055 ;; Overrides an existing entry;
4056 ;; just set the header part of the entry.
23f87bed
MB
4057 (setcar (symbol-value id-dep) header)
4058 (setq replaced t))
6748645f
LMI
4059
4060 ;; Renames the existing `header' to a unique Message-ID.
4061 ((not gnus-summary-ignore-duplicates)
4062 ;; An article with this Message-ID has already been seen.
4063 ;; We rename the Message-ID.
4064 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4065 (list header))
4066 (mail-header-set-id header id))
4067
4068 ;; The last case ignores an existing entry, except it adds any
4069 ;; additional Xrefs (in case the two articles came from different
4070 ;; servers.
4071 ;; Also sets `header' to `nil' meaning that the `dependencies'
4072 ;; table was *not* modified.
4073 (t
4074 (mail-header-set-xref
4075 (car (symbol-value id-dep))
4076 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4077 "")
4078 (or (mail-header-xref header) "")))
4079 (setq header nil)))
4080
23f87bed
MB
4081 (when (and header (not replaced))
4082 ;; First check that we are not creating a References loop.
4083 (setq parent-id (gnus-parent-id (mail-header-references header)))
4084 (setq ref parent-id)
6748645f
LMI
4085 (while (and ref
4086 (setq ref-dep (intern-soft ref dependencies))
4087 (boundp ref-dep)
4088 (setq ref-header (car (symbol-value ref-dep))))
4089 (if (string= id ref)
4090 ;; Yuk! This is a reference loop. Make the article be a
4091 ;; root article.
4092 (progn
4093 (mail-header-set-references (car (symbol-value id-dep)) "none")
23f87bed
MB
4094 (setq ref nil)
4095 (setq parent-id nil))
6748645f 4096 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
23f87bed 4097 (setq ref-dep (intern (or parent-id "none") dependencies))
6748645f
LMI
4098 (if (boundp ref-dep)
4099 (setcdr (symbol-value ref-dep)
4100 (nconc (cdr (symbol-value ref-dep))
4101 (list (symbol-value id-dep))))
4102 (set ref-dep (list nil (symbol-value id-dep)))))
4103 header))
4104
23f87bed
MB
4105(defun gnus-extract-message-id-from-in-reply-to (string)
4106 (if (string-match "<[^>]+>" string)
4107 (substring string (match-beginning 0) (match-end 0))
4108 nil))
4109
eec82323
LMI
4110(defun gnus-build-sparse-threads ()
4111 (let ((headers gnus-newsgroup-headers)
16409b0b 4112 (mail-parse-charset gnus-newsgroup-charset)
6748645f 4113 (gnus-summary-ignore-duplicates t)
eec82323 4114 header references generation relations
6748645f 4115 subject child end new-child date)
eec82323
LMI
4116 ;; First we create an alist of generations/relations, where
4117 ;; generations is how much we trust the relation, and the relation
4118 ;; is parent/child.
4119 (gnus-message 7 "Making sparse threads...")
4120 (save-excursion
4121 (nnheader-set-temp-buffer " *gnus sparse threads*")
4122 (while (setq header (pop headers))
4123 (when (and (setq references (mail-header-references header))
4124 (not (string= references "")))
4125 (insert references)
4126 (setq child (mail-header-id header)
6748645f
LMI
4127 subject (mail-header-subject header)
4128 date (mail-header-date header)
4129 generation 0)
eec82323
LMI
4130 (while (search-backward ">" nil t)
4131 (setq end (1+ (point)))
4132 (when (search-backward "<" nil t)
6748645f 4133 (setq new-child (buffer-substring (point) end))
eec82323 4134 (push (list (incf generation)
6748645f
LMI
4135 child (setq child new-child)
4136 subject date)
eec82323 4137 relations)))
6748645f
LMI
4138 (when child
4139 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
4140 (erase-buffer)))
4141 (kill-buffer (current-buffer)))
4142 ;; Sort over trustworthiness.
6748645f
LMI
4143 (mapcar
4144 (lambda (relation)
4145 (when (gnus-dependencies-add-header
4146 (make-full-mail-header
4147 gnus-reffed-article-number
4148 (nth 3 relation) "" (or (nth 4 relation) "")
4149 (nth 1 relation)
4150 (or (nth 2 relation) "") 0 0 "")
4151 gnus-newsgroup-dependencies nil)
4152 (push gnus-reffed-article-number gnus-newsgroup-limit)
4153 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4154 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4155 gnus-newsgroup-reads)
4156 (decf gnus-reffed-article-number)))
4157 (sort relations 'car-less-than-car))
eec82323
LMI
4158 (gnus-message 7 "Making sparse threads...done")))
4159
4160(defun gnus-build-old-threads ()
4161 ;; Look at all the articles that refer back to old articles, and
4162 ;; fetch the headers for the articles that aren't there. This will
4163 ;; build complete threads - if the roots haven't been expired by the
4164 ;; server, that is.
16409b0b
GM
4165 (let ((mail-parse-charset gnus-newsgroup-charset)
4166 id heads)
eec82323
LMI
4167 (mapatoms
4168 (lambda (refs)
4169 (when (not (car (symbol-value refs)))
4170 (setq heads (cdr (symbol-value refs)))
4171 (while heads
4172 (if (memq (mail-header-number (caar heads))
4173 gnus-newsgroup-dormant)
4174 (setq heads (cdr heads))
4175 (setq id (symbol-name refs))
4176 (while (and (setq id (gnus-build-get-header id))
6748645f 4177 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
4178 (setq heads nil)))))
4179 gnus-newsgroup-dependencies)))
4180
23f87bed
MB
4181(defsubst gnus-remove-odd-characters (string)
4182 "Translate STRING into something that doesn't contain weird characters."
4183 (mm-subst-char-in-string
4184 ?\r ?\-
4185 (mm-subst-char-in-string
4186 ?\n ?\- string)))
4187
6748645f
LMI
4188;; This function has to be called with point after the article number
4189;; on the beginning of the line.
4190(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4191 (let ((eol (gnus-point-at-eol))
4192 (buffer (current-buffer))
23f87bed 4193 header references in-reply-to)
6748645f
LMI
4194
4195 ;; overview: [num subject from date id refs chars lines misc]
4196 (unwind-protect
23f87bed 4197 (let (x)
6748645f
LMI
4198 (narrow-to-region (point) eol)
4199 (unless (eobp)
4200 (forward-char))
4201
4202 (setq header
4203 (make-full-mail-header
4204 number ; number
23f87bed
MB
4205 (condition-case () ; subject
4206 (gnus-remove-odd-characters
4207 (funcall gnus-decode-encoded-word-function
4208 (setq x (nnheader-nov-field))))
4209 (error x))
4210 (condition-case () ; from
4211 (gnus-remove-odd-characters
343d6628 4212 (funcall gnus-decode-encoded-address-function
23f87bed
MB
4213 (setq x (nnheader-nov-field))))
4214 (error x))
16409b0b
GM
4215 (nnheader-nov-field) ; date
4216 (nnheader-nov-read-message-id) ; id
23f87bed 4217 (setq references (nnheader-nov-field)) ; refs
16409b0b
GM
4218 (nnheader-nov-read-integer) ; chars
4219 (nnheader-nov-read-integer) ; lines
4220 (unless (eobp)
8b93df01
DL
4221 (if (looking-at "Xref: ")
4222 (goto-char (match-end 0)))
4223 (nnheader-nov-field)) ; Xref
16409b0b 4224 (nnheader-nov-parse-extra)))) ; extra
6748645f
LMI
4225
4226 (widen))
4227
23f87bed
MB
4228 (when (and (string= references "")
4229 (setq in-reply-to (mail-header-extra header))
4230 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4231 (mail-header-set-references
4232 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4233
6748645f
LMI
4234 (when gnus-alter-header-function
4235 (funcall gnus-alter-header-function header))
4236 (gnus-dependencies-add-header header dependencies force-new)))
4237
eec82323 4238(defun gnus-build-get-header (id)
16409b0b
GM
4239 "Look through the buffer of NOV lines and find the header to ID.
4240Enter this line into the dependencies hash table, and return
4241the id of the parent article (if any)."
eec82323
LMI
4242 (let ((deps gnus-newsgroup-dependencies)
4243 found header)
4244 (prog1
4245 (save-excursion
4246 (set-buffer nntp-server-buffer)
4247 (let ((case-fold-search nil))
4248 (goto-char (point-min))
4249 (while (and (not found)
4250 (search-forward id nil t))
4251 (beginning-of-line)
4252 (setq found (looking-at
4253 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4254 (regexp-quote id))))
4255 (or found (beginning-of-line 2)))
4256 (when found
4257 (beginning-of-line)
4258 (and
4259 (setq header (gnus-nov-parse-line
4260 (read (current-buffer)) deps))
4261 (gnus-parent-id (mail-header-references header))))))
4262 (when header
4263 (let ((number (mail-header-number header)))
4264 (push number gnus-newsgroup-limit)
4265 (push header gnus-newsgroup-headers)
4266 (if (memq number gnus-newsgroup-unselected)
4267 (progn
23f87bed
MB
4268 (setq gnus-newsgroup-unreads
4269 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4270 number))
eec82323
LMI
4271 (setq gnus-newsgroup-unselected
4272 (delq number gnus-newsgroup-unselected)))
4273 (push number gnus-newsgroup-ancient)))))))
4274
6748645f
LMI
4275(defun gnus-build-all-threads ()
4276 "Read all the headers."
4277 (let ((gnus-summary-ignore-duplicates t)
16409b0b 4278 (mail-parse-charset gnus-newsgroup-charset)
6748645f
LMI
4279 (dependencies gnus-newsgroup-dependencies)
4280 header article)
4281 (save-excursion
4282 (set-buffer nntp-server-buffer)
4283 (let ((case-fold-search nil))
4284 (goto-char (point-min))
4285 (while (not (eobp))
4286 (ignore-errors
4287 (setq article (read (current-buffer))
16409b0b 4288 header (gnus-nov-parse-line article dependencies)))
6748645f
LMI
4289 (when header
4290 (save-excursion
4291 (set-buffer gnus-summary-buffer)
4292 (push header gnus-newsgroup-headers)
4293 (if (memq (setq article (mail-header-number header))
4294 gnus-newsgroup-unselected)
4295 (progn
23f87bed
MB
4296 (setq gnus-newsgroup-unreads
4297 (gnus-add-to-sorted-list
4298 gnus-newsgroup-unreads article))
6748645f
LMI
4299 (setq gnus-newsgroup-unselected
4300 (delq article gnus-newsgroup-unselected)))
4301 (push article gnus-newsgroup-ancient)))
4302 (forward-line 1)))))))
4303
eec82323 4304(defun gnus-summary-update-article-line (article header)
23f87bed 4305 "Update the line for ARTICLE using HEADER."
eec82323
LMI
4306 (let* ((id (mail-header-id header))
4307 (thread (gnus-id-to-thread id)))
4308 (unless thread
4309 (error "Article in no thread"))
4310 ;; Update the thread.
4311 (setcar thread header)
4312 (gnus-summary-goto-subject article)
4313 (let* ((datal (gnus-data-find-list article))
4314 (data (car datal))
eec82323
LMI
4315 (buffer-read-only nil)
4316 (level (gnus-summary-thread-level)))
4317 (gnus-delete-line)
23f87bed
MB
4318 (let ((inserted (- (point)
4319 (progn
4320 (gnus-summary-insert-line
4321 header level nil
4322 (memq article gnus-newsgroup-undownloaded)
4323 (gnus-article-mark article)
4324 (memq article gnus-newsgroup-replied)
4325 (memq article gnus-newsgroup-expirable)
4326 ;; Only insert the Subject string when it's different
4327 ;; from the previous Subject string.
4328 (if (and
4329 gnus-show-threads
4330 (gnus-subject-equal
4331 (condition-case ()
4332 (mail-header-subject
4333 (gnus-data-header
4334 (cadr
4335 (gnus-data-find-list
4336 article
4337 (gnus-data-list t)))))
4338 ;; Error on the side of excessive subjects.
4339 (error ""))
4340 (mail-header-subject header)))
4341 ""
4342 (mail-header-subject header))
4343 nil (cdr (assq article gnus-newsgroup-scored))
4344 (memq article gnus-newsgroup-processable))
4345 (point)))))
4346 (when (cdr datal)
4347 (gnus-data-update-list
4348 (cdr datal)
4349 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
eec82323
LMI
4350
4351(defun gnus-summary-update-article (article &optional iheader)
4352 "Update ARTICLE in the summary buffer."
4353 (set-buffer gnus-summary-buffer)
6748645f 4354 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
4355 (id (mail-header-id header))
4356 (data (gnus-data-find article))
4357 (thread (gnus-id-to-thread id))
4358 (references (mail-header-references header))
4359 (parent
4360 (gnus-id-to-thread
4361 (or (gnus-parent-id
4362 (when (and references
4363 (not (equal "" references)))
4364 references))
4365 "none")))
4366 (buffer-read-only nil)
6748645f 4367 (old (car thread)))
eec82323 4368 (when thread
eec82323 4369 (unless iheader
6748645f
LMI
4370 (setcar thread nil)
4371 (when parent
4372 (delq thread parent)))
4373 (if (gnus-summary-insert-subject id header)
eec82323
LMI
4374 ;; Set the (possibly) new article number in the data structure.
4375 (gnus-data-set-number data (gnus-id-to-article id))
4376 (setcar thread old)
4377 nil))))
4378
6748645f
LMI
4379(defun gnus-rebuild-thread (id &optional line)
4380 "Rebuild the thread containing ID.
4381If LINE, insert the rebuilt thread starting on line LINE."
eec82323
LMI
4382 (let ((buffer-read-only nil)
4383 old-pos current thread data)
4384 (if (not gnus-show-threads)
4385 (setq thread (list (car (gnus-id-to-thread id))))
4386 ;; Get the thread this article is part of.
4387 (setq thread (gnus-remove-thread id)))
4388 (setq old-pos (gnus-point-at-bol))
4389 (setq current (save-excursion
94384150 4390 (and (re-search-backward "[\r\n]" nil t)
eec82323
LMI
4391 (gnus-summary-article-number))))
4392 ;; If this is a gathered thread, we have to go some re-gathering.
4393 (when (stringp (car thread))
4394 (let ((subject (car thread))
4395 roots thr)
4396 (setq thread (cdr thread))
4397 (while thread
4398 (unless (memq (setq thr (gnus-id-to-thread
4399 (gnus-root-id
4400 (mail-header-id (caar thread)))))
4401 roots)
4402 (push thr roots))
4403 (setq thread (cdr thread)))
4404 ;; We now have all (unique) roots.
4405 (if (= (length roots) 1)
4406 ;; All the loose roots are now one solid root.
4407 (setq thread (car roots))
4408 (setq thread (cons subject (gnus-sort-threads roots))))))
4409 (let (threads)
4410 ;; We then insert this thread into the summary buffer.
6748645f
LMI
4411 (when line
4412 (goto-char (point-min))
4413 (forward-line (1- line)))
eec82323
LMI
4414 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4415 (if gnus-show-threads
4416 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4417 (gnus-summary-prepare-unthreaded thread))
4418 (setq data (nreverse gnus-newsgroup-data))
4419 (setq threads gnus-newsgroup-threads))
4420 ;; We splice the new data into the data structure.
6748645f
LMI
4421 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4422 ;;!!! then we want to insert at the beginning of the buffer.
4423 ;;!!! That happens to be true with Gnus now, but that may
4424 ;;!!! change in the future. Perhaps.
4425 (gnus-data-enter-list
4426 (if line nil current) data (- (point) old-pos))
4427 (setq gnus-newsgroup-threads
4428 (nconc threads gnus-newsgroup-threads))
4429 (gnus-data-compute-positions))))
eec82323
LMI
4430
4431(defun gnus-number-to-header (number)
4432 "Return the header for article NUMBER."
4433 (let ((headers gnus-newsgroup-headers))
4434 (while (and headers
4435 (not (= number (mail-header-number (car headers)))))
4436 (pop headers))
4437 (when headers
4438 (car headers))))
4439
6748645f 4440(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
4441 "Return the headers of the GENERATIONeth parent of HEADERS."
4442 (unless generation
4443 (setq generation 1))
a8151ef7 4444 (let ((parent t)
6748645f 4445 (headers in-headers)
a8151ef7 4446 references)
6748645f
LMI
4447 (while (and parent
4448 (not (zerop generation))
4449 (setq references (mail-header-references headers)))
4450 (setq headers (if (and references
4451 (setq parent (gnus-parent-id references)))
4452 (car (gnus-id-to-thread parent))
4453 nil))
4454 (decf generation))
4455 (and (not (eq headers in-headers))
4456 headers)))
eec82323
LMI
4457
4458(defun gnus-id-to-thread (id)
4459 "Return the (sub-)thread where ID appears."
4460 (gnus-gethash id gnus-newsgroup-dependencies))
4461
4462(defun gnus-id-to-article (id)
4463 "Return the article number of ID."
4464 (let ((thread (gnus-id-to-thread id)))
4465 (when (and thread
4466 (car thread))
4467 (mail-header-number (car thread)))))
4468
4469(defun gnus-id-to-header (id)
4470 "Return the article headers of ID."
4471 (car (gnus-id-to-thread id)))
4472
4473(defun gnus-article-displayed-root-p (article)
4474 "Say whether ARTICLE is a root(ish) article."
4475 (let ((level (gnus-summary-thread-level article))
4476 (refs (mail-header-references (gnus-summary-article-header article)))
4477 particle)
4478 (cond
4479 ((null level) nil)
4480 ((zerop level) t)
4481 ((null refs) t)
4482 ((null (gnus-parent-id refs)) t)
4483 ((and (= 1 level)
4484 (null (setq particle (gnus-id-to-article
4485 (gnus-parent-id refs))))
4486 (null (gnus-summary-thread-level particle)))))))
4487
4488(defun gnus-root-id (id)
4489 "Return the id of the root of the thread where ID appears."
4490 (let (last-id prev)
6748645f 4491 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
4492 (setq last-id id
4493 id (gnus-parent-id (mail-header-references prev))))
4494 last-id))
4495
6748645f
LMI
4496(defun gnus-articles-in-thread (thread)
4497 "Return the list of articles in THREAD."
4498 (cons (mail-header-number (car thread))
4499 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4500
eec82323
LMI
4501(defun gnus-remove-thread (id &optional dont-remove)
4502 "Remove the thread that has ID in it."
6748645f 4503 (let (headers thread last-id)
eec82323 4504 ;; First go up in this thread until we find the root.
6748645f
LMI
4505 (setq last-id (gnus-root-id id)
4506 headers (message-flatten-list (gnus-id-to-thread last-id)))
01ccbb85 4507 ;; We have now found the real root of this thread. It might have
eec82323
LMI
4508 ;; been gathered into some loose thread, so we have to search
4509 ;; through the threads to find the thread we wanted.
4510 (let ((threads gnus-newsgroup-threads)
4511 sub)
4512 (while threads
4513 (setq sub (car threads))
4514 (if (stringp (car sub))
4515 ;; This is a gathered thread, so we look at the roots
4516 ;; below it to find whether this article is in this
4517 ;; gathered root.
4518 (progn
4519 (setq sub (cdr sub))
4520 (while sub
4521 (when (member (caar sub) headers)
4522 (setq thread (car threads)
4523 threads nil
4524 sub nil))
4525 (setq sub (cdr sub))))
4526 ;; It's an ordinary thread, so we check it.
4527 (when (eq (car sub) (car headers))
4528 (setq thread sub
4529 threads nil)))
4530 (setq threads (cdr threads)))
4531 ;; If this article is in no thread, then it's a root.
4532 (if thread
4533 (unless dont-remove
4534 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 4535 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
4536 (when thread
4537 (prog1
4538 thread ; We return this thread.
4539 (unless dont-remove
4540 (if (stringp (car thread))
4541 (progn
4542 ;; If we use dummy roots, then we have to remove the
4543 ;; dummy root as well.
4544 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
4545 ;; We go to the dummy root by going to
4546 ;; the first sub-"thread", and then one line up.
4547 (gnus-summary-goto-article
4548 (mail-header-number (caadr thread)))
4549 (forward-line -1)
eec82323
LMI
4550 (gnus-delete-line)
4551 (gnus-data-compute-positions))
4552 (setq thread (cdr thread))
4553 (while thread
4554 (gnus-remove-thread-1 (car thread))
4555 (setq thread (cdr thread))))
4556 (gnus-remove-thread-1 thread))))))))
4557
4558(defun gnus-remove-thread-1 (thread)
4559 "Remove the thread THREAD recursively."
4560 (let ((number (mail-header-number (pop thread)))
4561 d)
4562 (setq thread (reverse thread))
4563 (while thread
4564 (gnus-remove-thread-1 (pop thread)))
4565 (when (setq d (gnus-data-find number))
4566 (goto-char (gnus-data-pos d))
16409b0b 4567 (gnus-summary-show-thread)
eec82323
LMI
4568 (gnus-data-remove
4569 number
4570 (- (gnus-point-at-bol)
4571 (prog1
4572 (1+ (gnus-point-at-eol))
4573 (gnus-delete-line)))))))
4574
4921bbdd 4575(defun gnus-sort-threads-recursive (threads func)
16409b0b
GM
4576 (sort (mapcar (lambda (thread)
4577 (cons (car thread)
4578 (and (cdr thread)
4921bbdd 4579 (gnus-sort-threads-recursive (cdr thread) func))))
16409b0b
GM
4580 threads) func))
4581
4921bbdd
CY
4582(defun gnus-sort-threads-loop (threads func)
4583 (let* ((superthread (cons nil threads))
4584 (stack (list (cons superthread threads)))
4585 remaining-threads thread)
4586 (while stack
4587 (setq remaining-threads (cdr (car stack)))
4588 (if remaining-threads
4589 (progn (setq thread (car remaining-threads))
4590 (setcdr (car stack) (cdr remaining-threads))
4591 (if (cdr thread)
4592 (push (cons thread (cdr thread)) stack)))
4593 (setq thread (caar stack))
4594 (setcdr thread (sort (cdr thread) func))
4595 (pop stack)))
4596 (cdr superthread)))
4597
eec82323
LMI
4598(defun gnus-sort-threads (threads)
4599 "Sort THREADS."
4600 (if (not gnus-thread-sort-functions)
4601 threads
6748645f 4602 (gnus-message 8 "Sorting threads...")
4921bbdd
CY
4603 (prog1
4604 (condition-case nil
4605 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4606 (gnus-sort-threads-recursive
4607 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4608 ;; Even after binding max-lisp-eval-depth, the recursive
4609 ;; sorter might fail for very long threads. In that case,
4610 ;; try using a (less well-tested) non-recursive sorter.
4611 (error (gnus-sort-threads-loop
4612 threads (gnus-make-sort-function
4613 gnus-thread-sort-functions))))
4614 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
4615
4616(defun gnus-sort-articles (articles)
4617 "Sort ARTICLES."
4618 (when gnus-article-sort-functions
4619 (gnus-message 7 "Sorting articles...")
4620 (prog1
4621 (setq gnus-newsgroup-headers
4622 (sort articles (gnus-make-sort-function
4623 gnus-article-sort-functions)))
4624 (gnus-message 7 "Sorting articles...done"))))
4625
4626;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4627(defmacro gnus-thread-header (thread)
16409b0b
GM
4628 "Return header of first article in THREAD.
4629Note that THREAD must never, ever be anything else than a variable -
4630using some other form will lead to serious barfage."
eec82323
LMI
4631 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4632 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
16409b0b 4633 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
eec82323
LMI
4634 (vector thread) 2))
4635
4636(defsubst gnus-article-sort-by-number (h1 h2)
4637 "Sort articles by article number."
4638 (< (mail-header-number h1)
4639 (mail-header-number h2)))
4640
4641(defun gnus-thread-sort-by-number (h1 h2)
4642 "Sort threads by root article number."
4643 (gnus-article-sort-by-number
4644 (gnus-thread-header h1) (gnus-thread-header h2)))
4645
23f87bed
MB
4646(defsubst gnus-article-sort-by-random (h1 h2)
4647 "Sort articles by article number."
4648 (zerop (random 2)))
4649
4650(defun gnus-thread-sort-by-random (h1 h2)
4651 "Sort threads by root article number."
4652 (gnus-article-sort-by-random
4653 (gnus-thread-header h1) (gnus-thread-header h2)))
4654
eec82323
LMI
4655(defsubst gnus-article-sort-by-lines (h1 h2)
4656 "Sort articles by article Lines header."
4657 (< (mail-header-lines h1)
4658 (mail-header-lines h2)))
4659
4660(defun gnus-thread-sort-by-lines (h1 h2)
4661 "Sort threads by root article Lines header."
4662 (gnus-article-sort-by-lines
4663 (gnus-thread-header h1) (gnus-thread-header h2)))
4664
16409b0b
GM
4665(defsubst gnus-article-sort-by-chars (h1 h2)
4666 "Sort articles by octet length."
4667 (< (mail-header-chars h1)
4668 (mail-header-chars h2)))
4669
4670(defun gnus-thread-sort-by-chars (h1 h2)
4671 "Sort threads by root article octet length."
4672 (gnus-article-sort-by-chars
4673 (gnus-thread-header h1) (gnus-thread-header h2)))
4674
eec82323
LMI
4675(defsubst gnus-article-sort-by-author (h1 h2)
4676 "Sort articles by root author."
b4fde39f 4677 (gnus-string<
eec82323
LMI
4678 (let ((extract (funcall
4679 gnus-extract-address-components
4680 (mail-header-from h1))))
4681 (or (car extract) (cadr extract) ""))
4682 (let ((extract (funcall
4683 gnus-extract-address-components
4684 (mail-header-from h2))))
4685 (or (car extract) (cadr extract) ""))))
4686
4687(defun gnus-thread-sort-by-author (h1 h2)
4688 "Sort threads by root author."
4689 (gnus-article-sort-by-author
4690 (gnus-thread-header h1) (gnus-thread-header h2)))
4691
4692(defsubst gnus-article-sort-by-subject (h1 h2)
4693 "Sort articles by root subject."
b4fde39f 4694 (gnus-string<
eec82323
LMI
4695 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4696 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4697
4698(defun gnus-thread-sort-by-subject (h1 h2)
4699 "Sort threads by root subject."
4700 (gnus-article-sort-by-subject
4701 (gnus-thread-header h1) (gnus-thread-header h2)))
4702
4703(defsubst gnus-article-sort-by-date (h1 h2)
4704 "Sort articles by root article date."
16409b0b 4705 (time-less-p
eec82323
LMI
4706 (gnus-date-get-time (mail-header-date h1))
4707 (gnus-date-get-time (mail-header-date h2))))
4708
4709(defun gnus-thread-sort-by-date (h1 h2)
4710 "Sort threads by root article date."
4711 (gnus-article-sort-by-date
4712 (gnus-thread-header h1) (gnus-thread-header h2)))
4713
4714(defsubst gnus-article-sort-by-score (h1 h2)
4715 "Sort articles by root article score.
4716Unscored articles will be counted as having a score of zero."
4717 (> (or (cdr (assq (mail-header-number h1)
4718 gnus-newsgroup-scored))
4719 gnus-summary-default-score 0)
4720 (or (cdr (assq (mail-header-number h2)
4721 gnus-newsgroup-scored))
4722 gnus-summary-default-score 0)))
4723
4724(defun gnus-thread-sort-by-score (h1 h2)
4725 "Sort threads by root article score."
4726 (gnus-article-sort-by-score
4727 (gnus-thread-header h1) (gnus-thread-header h2)))
4728
4729(defun gnus-thread-sort-by-total-score (h1 h2)
4730 "Sort threads by the sum of all scores in the thread.
4731Unscored articles will be counted as having a score of zero."
4732 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4733
4734(defun gnus-thread-total-score (thread)
16409b0b 4735 ;; This function find the total score of THREAD.
23f87bed
MB
4736 (cond
4737 ((null thread)
4738 0)
4739 ((consp thread)
4740 (if (stringp (car thread))
4741 (apply gnus-thread-score-function 0
4742 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4743 (gnus-thread-total-score-1 thread)))
4744 (t
4745 (gnus-thread-total-score-1 (list thread)))))
4746
4747(defun gnus-thread-sort-by-most-recent-number (h1 h2)
4748 "Sort threads such that the thread with the most recently arrived article comes first."
4749 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4750
4751(defun gnus-thread-highest-number (thread)
4752 "Return the highest article number in THREAD."
4753 (apply 'max (mapcar (lambda (header)
4754 (mail-header-number header))
4755 (message-flatten-list thread))))
4756
4757(defun gnus-thread-sort-by-most-recent-date (h1 h2)
4758 "Sort threads such that the thread with the most recently dated article comes first."
4759 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4760
4761(defun gnus-thread-latest-date (thread)
4762 "Return the highest article date in THREAD."
4763 (let ((previous-time 0))
4764 (apply 'max
4765 (mapcar
4766 (lambda (header)
4767 (setq previous-time
4768 (condition-case ()
4769 (time-to-seconds (mail-header-parse-date
4770 (mail-header-date header)))
4771 (error previous-time))))
4772 (sort
4773 (message-flatten-list thread)
4774 (lambda (h1 h2)
4775 (< (mail-header-number h1)
4776 (mail-header-number h2))))))))
eec82323
LMI
4777
4778(defun gnus-thread-total-score-1 (root)
4779 ;; This function find the total score of the thread below ROOT.
4780 (setq root (car root))
4781 (apply gnus-thread-score-function
4782 (or (append
4783 (mapcar 'gnus-thread-total-score
6748645f 4784 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
4785 (when (> (mail-header-number root) 0)
4786 (list (or (cdr (assq (mail-header-number root)
4787 gnus-newsgroup-scored))
4788 gnus-summary-default-score 0))))
4789 (list gnus-summary-default-score)
4790 '(0))))
4791
4792;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4793(defvar gnus-tmp-prev-subject nil)
4794(defvar gnus-tmp-false-parent nil)
4795(defvar gnus-tmp-root-expunged nil)
4796(defvar gnus-tmp-dummy-line nil)
4797
60bd5589 4798(eval-when-compile (defvar gnus-tmp-header))
16409b0b
GM
4799(defun gnus-extra-header (type &optional header)
4800 "Return the extra header of TYPE."
4801 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4802 ""))
4803
23f87bed
MB
4804(defvar gnus-tmp-thread-tree-header-string "")
4805
4806(defcustom gnus-sum-thread-tree-root "> "
4807 "With %B spec, used for the root of a thread.
4808If nil, use subject instead."
bf247b6e 4809 :version "22.1"
ad136a7c 4810 :type '(radio (const :format "%v " nil) string)
23f87bed
MB
4811 :group 'gnus-thread)
4812(defcustom gnus-sum-thread-tree-false-root "> "
4813 "With %B spec, used for a false root of a thread.
4814If nil, use subject instead."
bf247b6e 4815 :version "22.1"
ad136a7c 4816 :type '(radio (const :format "%v " nil) string)
23f87bed
MB
4817 :group 'gnus-thread)
4818(defcustom gnus-sum-thread-tree-single-indent ""
4819 "With %B spec, used for a thread with just one message.
4820If nil, use subject instead."
bf247b6e 4821 :version "22.1"
ad136a7c 4822 :type '(radio (const :format "%v " nil) string)
23f87bed
MB
4823 :group 'gnus-thread)
4824(defcustom gnus-sum-thread-tree-vertical "| "
4825 "With %B spec, used for drawing a vertical line."
bf247b6e 4826 :version "22.1"
23f87bed
MB
4827 :type 'string
4828 :group 'gnus-thread)
4829(defcustom gnus-sum-thread-tree-indent " "
4830 "With %B spec, used for indenting."
bf247b6e 4831 :version "22.1"
23f87bed
MB
4832 :type 'string
4833 :group 'gnus-thread)
4834(defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4835 "With %B spec, used for a leaf with brothers."
bf247b6e 4836 :version "22.1"
23f87bed
MB
4837 :type 'string
4838 :group 'gnus-thread)
4839(defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4840 "With %B spec, used for a leaf without brothers."
bf247b6e 4841 :version "22.1"
23f87bed
MB
4842 :type 'string
4843 :group 'gnus-thread)
4844
eec82323
LMI
4845(defun gnus-summary-prepare-threads (threads)
4846 "Prepare summary buffer from THREADS and indentation LEVEL.
4847THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4848or a straight list of headers."
4849 (gnus-message 7 "Generating summary...")
4850
4851 (setq gnus-newsgroup-threads threads)
4852 (beginning-of-line)
4853
4854 (let ((gnus-tmp-level 0)
4855 (default-score (or gnus-summary-default-score 0))
4856 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
23f87bed
MB
4857 (building-line-count gnus-summary-display-while-building)
4858 (building-count (integerp gnus-summary-display-while-building))
eec82323 4859 thread number subject stack state gnus-tmp-gathered beg-match
23f87bed
MB
4860 new-roots gnus-tmp-new-adopts thread-end simp-subject
4861 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
eec82323
LMI
4862 gnus-tmp-replied gnus-tmp-subject-or-nil
4863 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4864 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
23f87bed
MB
4865 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4866 tree-stack)
eec82323 4867
23f87bed
MB
4868 (setq gnus-tmp-prev-subject nil
4869 gnus-tmp-thread-tree-header-string "")
eec82323
LMI
4870
4871 (if (vectorp (car threads))
4872 ;; If this is a straight (sic) list of headers, then a
4873 ;; threaded summary display isn't required, so we just create
4874 ;; an unthreaded one.
4875 (gnus-summary-prepare-unthreaded threads)
4876
4877 ;; Do the threaded display.
4878
23f87bed
MB
4879 (if gnus-summary-display-while-building
4880 (switch-to-buffer (buffer-name)))
eec82323
LMI
4881 (while (or threads stack gnus-tmp-new-adopts new-roots)
4882
4883 (if (and (= gnus-tmp-level 0)
eec82323
LMI
4884 (or (not stack)
4885 (= (caar stack) 0))
4886 (not gnus-tmp-false-parent)
4887 (or gnus-tmp-new-adopts new-roots))
4888 (if gnus-tmp-new-adopts
4889 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4890 thread (list (car gnus-tmp-new-adopts))
4891 gnus-tmp-header (caar thread)
4892 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4893 (when new-roots
4894 (setq thread (list (car new-roots))
4895 gnus-tmp-header (caar thread)
4896 new-roots (cdr new-roots))))
4897
4898 (if threads
4899 ;; If there are some threads, we do them before the
4900 ;; threads on the stack.
4901 (setq thread threads
4902 gnus-tmp-header (caar thread))
4903 ;; There were no current threads, so we pop something off
4904 ;; the stack.
4905 (setq state (car stack)
4906 gnus-tmp-level (car state)
23f87bed
MB
4907 tree-stack (cadr state)
4908 thread (caddr state)
eec82323
LMI
4909 stack (cdr stack)
4910 gnus-tmp-header (caar thread))))
4911
4912 (setq gnus-tmp-false-parent nil)
4913 (setq gnus-tmp-root-expunged nil)
4914 (setq thread-end nil)
4915
4916 (if (stringp gnus-tmp-header)
4917 ;; The header is a dummy root.
4918 (cond
4919 ((eq gnus-summary-make-false-root 'adopt)
4920 ;; We let the first article adopt the rest.
4921 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4922 (cddar thread)))
4923 (setq gnus-tmp-gathered
4924 (nconc (mapcar
4925 (lambda (h) (mail-header-number (car h)))
4926 (cddar thread))
4927 gnus-tmp-gathered))
4928 (setq thread (cons (list (caar thread)
4929 (cadar thread))
4930 (cdr thread)))
4931 (setq gnus-tmp-level -1
4932 gnus-tmp-false-parent t))
4933 ((eq gnus-summary-make-false-root 'empty)
4934 ;; We print adopted articles with empty subject fields.
4935 (setq gnus-tmp-gathered
4936 (nconc (mapcar
4937 (lambda (h) (mail-header-number (car h)))
4938 (cddar thread))
4939 gnus-tmp-gathered))
4940 (setq gnus-tmp-level -1))
4941 ((eq gnus-summary-make-false-root 'dummy)
4942 ;; We remember that we probably want to output a dummy
4943 ;; root.
4944 (setq gnus-tmp-dummy-line gnus-tmp-header)
4945 (setq gnus-tmp-prev-subject gnus-tmp-header))
4946 (t
4947 ;; We do not make a root for the gathered
4948 ;; sub-threads at all.
4949 (setq gnus-tmp-level -1)))
4950
4951 (setq number (mail-header-number gnus-tmp-header)
23f87bed
MB
4952 subject (mail-header-subject gnus-tmp-header)
4953 simp-subject (gnus-simplify-subject-fully subject))
eec82323
LMI
4954
4955 (cond
4956 ;; If the thread has changed subject, we might want to make
4957 ;; this subthread into a root.
4958 ((and (null gnus-thread-ignore-subject)
4959 (not (zerop gnus-tmp-level))
4960 gnus-tmp-prev-subject
23f87bed 4961 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
4962 (setq new-roots (nconc new-roots (list (car thread)))
4963 thread-end t
4964 gnus-tmp-header nil))
4965 ;; If the article lies outside the current limit,
4966 ;; then we do not display it.
4967 ((not (memq number gnus-newsgroup-limit))
4968 (setq gnus-tmp-gathered
4969 (nconc (mapcar
4970 (lambda (h) (mail-header-number (car h)))
4971 (cdar thread))
4972 gnus-tmp-gathered))
4973 (setq gnus-tmp-new-adopts (if (cdar thread)
4974 (append gnus-tmp-new-adopts
4975 (cdar thread))
4976 gnus-tmp-new-adopts)
4977 thread-end t
4978 gnus-tmp-header nil)
4979 (when (zerop gnus-tmp-level)
4980 (setq gnus-tmp-root-expunged t)))
4981 ;; Perhaps this article is to be marked as read?
4982 ((and gnus-summary-mark-below
4983 (< (or (cdr (assq number gnus-newsgroup-scored))
4984 default-score)
4985 gnus-summary-mark-below)
4986 ;; Don't touch sparse articles.
4987 (not (gnus-summary-article-sparse-p number))
4988 (not (gnus-summary-article-ancient-p number)))
4989 (setq gnus-newsgroup-unreads
4990 (delq number gnus-newsgroup-unreads))
4991 (if gnus-newsgroup-auto-expire
23f87bed
MB
4992 (setq gnus-newsgroup-expirable
4993 (gnus-add-to-sorted-list
4994 gnus-newsgroup-expirable number))
eec82323
LMI
4995 (push (cons number gnus-low-score-mark)
4996 gnus-newsgroup-reads))))
4997
4998 (when gnus-tmp-header
4999 ;; We may have an old dummy line to output before this
5000 ;; article.
6748645f
LMI
5001 (when (and gnus-tmp-dummy-line
5002 (gnus-subject-equal
5003 gnus-tmp-dummy-line
5004 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
5005 (gnus-summary-insert-dummy-line
5006 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5007 (setq gnus-tmp-dummy-line nil))
5008
5009 ;; Compute the mark.
5010 (setq gnus-tmp-unread (gnus-article-mark number))
5011
5012 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5013 gnus-tmp-header gnus-tmp-level)
5014 gnus-newsgroup-data)
5015
5016 ;; Actually insert the line.
5017 (setq
5018 gnus-tmp-subject-or-nil
5019 (cond
5020 ((and gnus-thread-ignore-subject
5021 gnus-tmp-prev-subject
23f87bed 5022 (not (string= gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5023 subject)
5024 ((zerop gnus-tmp-level)
5025 (if (and (eq gnus-summary-make-false-root 'empty)
5026 (memq number gnus-tmp-gathered)
5027 gnus-tmp-prev-subject
23f87bed 5028 (string= gnus-tmp-prev-subject simp-subject))
eec82323
LMI
5029 gnus-summary-same-subject
5030 subject))
5031 (t gnus-summary-same-subject)))
5032 (if (and (eq gnus-summary-make-false-root 'adopt)
5033 (= gnus-tmp-level 1)
5034 (memq number gnus-tmp-gathered))
5035 (setq gnus-tmp-opening-bracket ?\<
5036 gnus-tmp-closing-bracket ?\>)
5037 (setq gnus-tmp-opening-bracket ?\[
5038 gnus-tmp-closing-bracket ?\]))
4921bbdd
CY
5039 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5040 (gnus-make-thread-indent-array
5041 (max (* 2 (length gnus-thread-indent-array))
5042 gnus-tmp-level)))
eec82323
LMI
5043 (setq
5044 gnus-tmp-indentation
5045 (aref gnus-thread-indent-array gnus-tmp-level)
5046 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5047 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5048 gnus-summary-default-score 0)
5049 gnus-tmp-score-char
5050 (if (or (null gnus-summary-default-score)
5051 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5052 gnus-summary-zcore-fuzz))
23f87bed 5053 ? ;Whitespace
eec82323
LMI
5054 (if (< gnus-tmp-score gnus-summary-default-score)
5055 gnus-score-below-mark gnus-score-over-mark))
5056 gnus-tmp-replied
5057 (cond ((memq number gnus-newsgroup-processable)
5058 gnus-process-mark)
5059 ((memq number gnus-newsgroup-cached)
5060 gnus-cached-mark)
5061 ((memq number gnus-newsgroup-replied)
5062 gnus-replied-mark)
23f87bed
MB
5063 ((memq number gnus-newsgroup-forwarded)
5064 gnus-forwarded-mark)
eec82323
LMI
5065 ((memq number gnus-newsgroup-saved)
5066 gnus-saved-mark)
23f87bed
MB
5067 ((memq number gnus-newsgroup-recent)
5068 gnus-recent-mark)
5069 ((memq number gnus-newsgroup-unseen)
5070 gnus-unseen-mark)
5071 (t gnus-no-mark))
5072 gnus-tmp-downloaded
5073 (cond ((memq number gnus-newsgroup-undownloaded)
5074 gnus-undownloaded-mark)
5075 (gnus-newsgroup-agentized
5076 gnus-downloaded-mark)
5077 (t
5078 gnus-no-mark))
eec82323
LMI
5079 gnus-tmp-from (mail-header-from gnus-tmp-header)
5080 gnus-tmp-name
5081 (cond
5082 ((string-match "<[^>]+> *$" gnus-tmp-from)
5083 (setq beg-match (match-beginning 0))
23f87bed
MB
5084 (or (and (string-match "^\".+\"" gnus-tmp-from)
5085 (substring gnus-tmp-from 1 (1- (match-end 0))))
eec82323
LMI
5086 (substring gnus-tmp-from 0 beg-match)))
5087 ((string-match "(.+)" gnus-tmp-from)
5088 (substring gnus-tmp-from
5089 (1+ (match-beginning 0)) (1- (match-end 0))))
23f87bed
MB
5090 (t gnus-tmp-from))
5091
5092 ;; Do the %B string
5093 gnus-tmp-thread-tree-header-string
5094 (cond
5095 ((not gnus-show-threads) "")
5096 ((zerop gnus-tmp-level)
5097 (cond ((cdar thread)
5098 (or gnus-sum-thread-tree-root subject))
5099 (gnus-tmp-new-adopts
5100 (or gnus-sum-thread-tree-false-root subject))
5101 (t
5102 (or gnus-sum-thread-tree-single-indent subject))))
5103 (t
5104 (concat (apply 'concat
5105 (mapcar (lambda (item)
5106 (if (= item 1)
5107 gnus-sum-thread-tree-vertical
5108 gnus-sum-thread-tree-indent))
5109 (cdr (reverse tree-stack))))
5110 (if (nth 1 thread)
5111 gnus-sum-thread-tree-leaf-with-other
5112 gnus-sum-thread-tree-single-leaf)))))
eec82323
LMI
5113 (when (string= gnus-tmp-name "")
5114 (setq gnus-tmp-name gnus-tmp-from))
5115 (unless (numberp gnus-tmp-lines)
23f87bed
MB
5116 (setq gnus-tmp-lines -1))
5117 (if (= gnus-tmp-lines -1)
5118 (setq gnus-tmp-lines "?")
5119 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5120 (gnus-put-text-property
eec82323
LMI
5121 (point)
5122 (progn (eval gnus-summary-line-format-spec) (point))
23f87bed 5123 'gnus-number number)
eec82323
LMI
5124 (when gnus-visual-p
5125 (forward-line -1)
6748645f 5126 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
5127 (forward-line 1))
5128
23f87bed 5129 (setq gnus-tmp-prev-subject simp-subject)))
eec82323
LMI
5130
5131 (when (nth 1 thread)
23f87bed
MB
5132 (push (list (max 0 gnus-tmp-level)
5133 (copy-sequence tree-stack)
5134 (nthcdr 1 thread))
5135 stack))
5136 (push (if (nth 1 thread) 1 0) tree-stack)
eec82323
LMI
5137 (incf gnus-tmp-level)
5138 (setq threads (if thread-end nil (cdar thread)))
23f87bed
MB
5139 (if gnus-summary-display-while-building
5140 (if building-count
5141 (progn
5142 ;; use a set frequency
5143 (setq building-line-count (1- building-line-count))
5144 (when (= building-line-count 0)
5145 (sit-for 0)
5146 (setq building-line-count
5147 gnus-summary-display-while-building)))
5148 ;; always
5149 (sit-for 0)))
eec82323
LMI
5150 (unless threads
5151 (setq gnus-tmp-level 0)))))
5152 (gnus-message 7 "Generating summary...done"))
5153
5154(defun gnus-summary-prepare-unthreaded (headers)
5155 "Generate an unthreaded summary buffer based on HEADERS."
5156 (let (header number mark)
5157
5158 (beginning-of-line)
5159
5160 (while headers
5161 ;; We may have to root out some bad articles...
5162 (when (memq (setq number (mail-header-number
5163 (setq header (pop headers))))
5164 gnus-newsgroup-limit)
5165 ;; Mark article as read when it has a low score.
5166 (when (and gnus-summary-mark-below
5167 (< (or (cdr (assq number gnus-newsgroup-scored))
5168 gnus-summary-default-score 0)
5169 gnus-summary-mark-below)
5170 (not (gnus-summary-article-ancient-p number)))
5171 (setq gnus-newsgroup-unreads
5172 (delq number gnus-newsgroup-unreads))
5173 (if gnus-newsgroup-auto-expire
5174 (push number gnus-newsgroup-expirable)
5175 (push (cons number gnus-low-score-mark)
5176 gnus-newsgroup-reads)))
5177
5178 (setq mark (gnus-article-mark number))
5179 (push (gnus-data-make number mark (1+ (point)) header 0)
5180 gnus-newsgroup-data)
5181 (gnus-summary-insert-line
5182 header 0 number
23f87bed 5183 (memq number gnus-newsgroup-undownloaded)
eec82323
LMI
5184 mark (memq number gnus-newsgroup-replied)
5185 (memq number gnus-newsgroup-expirable)
5186 (mail-header-subject header) nil
5187 (cdr (assq number gnus-newsgroup-scored))
5188 (memq number gnus-newsgroup-processable))))))
5189
16409b0b
GM
5190(defun gnus-summary-remove-list-identifiers ()
5191 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
23f87bed
MB
5192 (let ((regexp (if (consp gnus-list-identifiers)
5193 (mapconcat 'identity gnus-list-identifiers " *\\|")
5194 gnus-list-identifiers))
5195 changed subject)
5196 (when regexp
5197 (dolist (header gnus-newsgroup-headers)
5198 (setq subject (mail-header-subject header)
5199 changed nil)
5200 (while (string-match
5201 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
5202 subject)
5203 (setq subject
5204 (concat (substring subject 0 (match-beginning 2))
5205 (substring subject (match-end 0)))
5206 changed t))
5207 (when (and changed
5208 (string-match
5209 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
5210 (setq subject
5211 (concat (substring subject 0 (match-beginning 1))
5212 (substring subject (match-end 1)))))
5213 (when changed
5214 (mail-header-set-subject header subject))))))
5215
5216(defun gnus-fetch-headers (articles)
5217 "Fetch headers of ARTICLES."
5218 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5219 (gnus-message 5 "Fetching headers for %s..." name)
5220 (prog1
5221 (if (eq 'nov
5222 (setq gnus-headers-retrieved-by
5223 (gnus-retrieve-headers
5224 articles gnus-newsgroup-name
5225 ;; We might want to fetch old headers, but
5226 ;; not if there is only 1 article.
5227 (and (or (and
5228 (not (eq gnus-fetch-old-headers 'some))
5229 (not (numberp gnus-fetch-old-headers)))
5230 (> (length articles) 1))
5231 gnus-fetch-old-headers))))
5232 (gnus-get-newsgroup-headers-xover
5233 articles nil nil gnus-newsgroup-name t)
5234 (gnus-get-newsgroup-headers))
5235 (gnus-message 5 "Fetching headers for %s...done" name))))
16409b0b 5236
6748645f 5237(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 5238 "Select newsgroup GROUP.
6748645f
LMI
5239If READ-ALL is non-nil, all articles in the group are selected.
5240If SELECT-ARTICLES, only select those articles from GROUP."
eec82323
LMI
5241 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5242 ;;!!! Dirty hack; should be removed.
5243 (gnus-summary-ignore-duplicates
23f87bed 5244 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
5245 t
5246 gnus-summary-ignore-duplicates))
5247 (info (nth 2 entry))
5248 articles fetched-articles cached)
5249
5250 (unless (gnus-check-server
475e0e0c
GM
5251 (set (make-local-variable 'gnus-current-select-method)
5252 (gnus-find-method-for-group group)))
eec82323
LMI
5253 (error "Couldn't open server"))
5254
5255 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5256 (gnus-activate-group group) ; Or we can activate it...
5257 (progn ; Or we bug out.
5258 (when (equal major-mode 'gnus-summary-mode)
23f87bed
MB
5259 (gnus-kill-buffer (current-buffer)))
5260 (error "Couldn't activate group %s: %s"
c86d4601 5261 (gnus-group-decoded-name group) (gnus-status-message group))))
eec82323
LMI
5262
5263 (unless (gnus-request-group group t)
5264 (when (equal major-mode 'gnus-summary-mode)
23f87bed 5265 (gnus-kill-buffer (current-buffer)))
eec82323 5266 (error "Couldn't request group %s: %s"
c86d4601 5267 (gnus-group-decoded-name group) (gnus-status-message group)))
eec82323 5268
23f87bed 5269 (when gnus-agent
54506618 5270 (gnus-agent-possibly-alter-active group (gnus-active group) info)
132cf96d 5271
23f87bed
MB
5272 (setq gnus-summary-use-undownloaded-faces
5273 (gnus-agent-find-parameter
5274 group
5275 'agent-enable-undownloaded-faces)))
5276
5277 (setq gnus-newsgroup-name group
5278 gnus-newsgroup-unselected nil
5279 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5280
5281 (let ((display (gnus-group-find-parameter group 'display)))
5282 (setq gnus-newsgroup-display
5283 (cond
5284 ((not (zerop (or (car-safe read-all) 0)))
5285 ;; The user entered the group with C-u SPC/RET, let's show
5286 ;; all articles.
5287 'gnus-not-ignore)
5288 ((eq display 'all)
5289 'gnus-not-ignore)
5290 ((arrayp display)
5291 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5292 ((numberp display)
5293 ;; The following is probably the "correct" solution, but
5294 ;; it makes Gnus fetch all headers and then limit the
5295 ;; articles (which is slow), so instead we hack the
5296 ;; select-articles parameter instead. -- Simon Josefsson
5297 ;; <jas@kth.se>
5298 ;;
5299 ;; (gnus-byte-compile
5300 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5301 ;; display)))))
5302 (setq select-articles
5303 (gnus-uncompress-range
5304 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5305 (if (> tmp 0)
5306 tmp
5307 1))
5308 (cdr (gnus-active group)))))
5309 nil)
5310 (t
5311 nil))))
eec82323 5312
23f87bed 5313 (gnus-summary-setup-default-charset)
eec82323
LMI
5314
5315 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5316 (when (gnus-virtual-group-p group)
5317 (setq cached gnus-newsgroup-cached))
5318
5319 (setq gnus-newsgroup-unreads
23f87bed
MB
5320 (gnus-sorted-ndifference
5321 (gnus-sorted-ndifference gnus-newsgroup-unreads
5322 gnus-newsgroup-marked)
eec82323
LMI
5323 gnus-newsgroup-dormant))
5324
5325 (setq gnus-newsgroup-processable nil)
5326
5327 (gnus-update-read-articles group gnus-newsgroup-unreads)
eec82323 5328
23f87bed
MB
5329 ;; Adjust and set lists of article marks.
5330 (when info
5331 (gnus-adjust-marked-articles info))
6748645f
LMI
5332 (if (setq articles select-articles)
5333 (setq gnus-newsgroup-unselected
23f87bed 5334 (gnus-sorted-difference gnus-newsgroup-unreads articles))
6748645f 5335 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
5336
5337 (cond
5338 ((null articles)
5339 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5340 'quit)
5341 ((eq articles 0) nil)
5342 (t
5343 ;; Init the dependencies hash table.
5344 (setq gnus-newsgroup-dependencies
5345 (gnus-make-hashtable (length articles)))
16409b0b 5346 (gnus-set-global-variables)
eec82323 5347 ;; Retrieve the headers and read them in.
23f87bed
MB
5348
5349 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
eec82323
LMI
5350
5351 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5352 (when cached
5353 (setq gnus-newsgroup-cached cached))
5354
5355 ;; Suppress duplicates?
5356 (when gnus-suppress-duplicates
5357 (gnus-dup-suppress-articles))
5358
5359 ;; Set the initial limit.
5360 (setq gnus-newsgroup-limit (copy-sequence articles))
5361 ;; Remove canceled articles from the list of unread articles.
23f87bed
MB
5362 (setq fetched-articles
5363 (mapcar (lambda (headers) (mail-header-number headers))
5364 gnus-newsgroup-headers))
5365 (setq gnus-newsgroup-articles fetched-articles)
eec82323 5366 (setq gnus-newsgroup-unreads
23f87bed
MB
5367 (gnus-sorted-nintersection
5368 gnus-newsgroup-unreads fetched-articles))
5369 (gnus-compute-unseen-list)
5370
eec82323
LMI
5371 ;; Removed marked articles that do not exist.
5372 (gnus-update-missing-marks
23f87bed 5373 (gnus-sorted-difference articles fetched-articles))
eec82323 5374 ;; We might want to build some more threads first.
6748645f
LMI
5375 (when (and gnus-fetch-old-headers
5376 (eq gnus-headers-retrieved-by 'nov))
5377 (if (eq gnus-fetch-old-headers 'invisible)
5378 (gnus-build-all-threads)
5379 (gnus-build-old-threads)))
5380 ;; Let the Gnus agent mark articles as read.
5381 (when gnus-agent
5382 (gnus-agent-get-undownloaded-list))
16409b0b
GM
5383 ;; Remove list identifiers from subject
5384 (when gnus-list-identifiers
5385 (gnus-summary-remove-list-identifiers))
eec82323
LMI
5386 ;; Check whether auto-expire is to be done in this group.
5387 (setq gnus-newsgroup-auto-expire
5388 (gnus-group-auto-expirable-p group))
5389 ;; Set up the article buffer now, if necessary.
5390 (unless gnus-single-article-buffer
5391 (gnus-article-setup-buffer))
5392 ;; First and last article in this newsgroup.
5393 (when gnus-newsgroup-headers
5394 (setq gnus-newsgroup-begin
5395 (mail-header-number (car gnus-newsgroup-headers))
5396 gnus-newsgroup-end
5397 (mail-header-number
5398 (gnus-last-element gnus-newsgroup-headers))))
5399 ;; GROUP is successfully selected.
5400 (or gnus-newsgroup-headers t)))))
5401
23f87bed
MB
5402(defun gnus-compute-unseen-list ()
5403 ;; The `seen' marks are treated specially.
5404 (if (not gnus-newsgroup-seen)
5405 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5406 (setq gnus-newsgroup-unseen
5407 (gnus-inverse-list-range-intersection
5408 gnus-newsgroup-articles gnus-newsgroup-seen))))
5409
5410(defun gnus-summary-display-make-predicate (display)
5411 (require 'gnus-agent)
5412 (when (= (length display) 1)
5413 (setq display (car display)))
5414 (unless gnus-summary-display-cache
5415 (dolist (elem (append '((unread . unread)
5416 (read . read)
5417 (unseen . unseen))
5418 gnus-article-mark-lists))
5419 (push (cons (cdr elem)
5420 (gnus-byte-compile
5421 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5422 gnus-summary-display-cache)))
5423 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5424 (gnus-category-predicate-cache gnus-summary-display-cache))
5425 (gnus-get-predicate display)))
5426
5427;; Uses the dynamically bound `number' variable.
5428(eval-when-compile
5429 (defvar number))
5430(defun gnus-article-marked-p (type &optional article)
5431 (let ((article (or article number)))
5432 (cond
5433 ((eq type 'tick)
5434 (memq article gnus-newsgroup-marked))
5435 ((eq type 'spam)
5436 (memq article gnus-newsgroup-spam-marked))
5437 ((eq type 'unsend)
5438 (memq article gnus-newsgroup-unsendable))
5439 ((eq type 'undownload)
5440 (memq article gnus-newsgroup-undownloaded))
5441 ((eq type 'download)
5442 (memq article gnus-newsgroup-downloadable))
5443 ((eq type 'unread)
5444 (memq article gnus-newsgroup-unreads))
5445 ((eq type 'read)
5446 (memq article gnus-newsgroup-reads))
5447 ((eq type 'dormant)
5448 (memq article gnus-newsgroup-dormant) )
5449 ((eq type 'expire)
5450 (memq article gnus-newsgroup-expirable))
5451 ((eq type 'reply)
5452 (memq article gnus-newsgroup-replied))
5453 ((eq type 'killed)
5454 (memq article gnus-newsgroup-killed))
5455 ((eq type 'bookmark)
5456 (assq article gnus-newsgroup-bookmarks))
5457 ((eq type 'score)
5458 (assq article gnus-newsgroup-scored))
5459 ((eq type 'save)
5460 (memq article gnus-newsgroup-saved))
5461 ((eq type 'cache)
5462 (memq article gnus-newsgroup-cached))
5463 ((eq type 'forward)
5464 (memq article gnus-newsgroup-forwarded))
5465 ((eq type 'seen)
5466 (not (memq article gnus-newsgroup-unseen)))
5467 ((eq type 'recent)
5468 (memq article gnus-newsgroup-recent))
5469 (t t))))
5470
eec82323 5471(defun gnus-articles-to-read (group &optional read-all)
16409b0b 5472 "Find out what articles the user wants to read."
26c9afc3 5473 (let* ((articles
eec82323
LMI
5474 ;; Select all articles if `read-all' is non-nil, or if there
5475 ;; are no unread articles.
5476 (if (or read-all
5477 (and (zerop (length gnus-newsgroup-marked))
5478 (zerop (length gnus-newsgroup-unreads)))
23f87bed
MB
5479 ;; Fetch all if the predicate is non-nil.
5480 gnus-newsgroup-display)
5481 ;; We want to select the headers for all the articles in
5482 ;; the group, so we select either all the active
5483 ;; articles in the group, or (if that's nil), the
5484 ;; articles in the cache.
16409b0b 5485 (or
4b70e299 5486 (if gnus-newsgroup-maximum-articles
11abff8e
MB
5487 (let ((active (gnus-active group)))
5488 (gnus-uncompress-range
5489 (cons (max (car active)
4b70e299
MB
5490 (- (cdr active)
5491 gnus-newsgroup-maximum-articles
5492 -1))
11abff8e
MB
5493 (cdr active))))
5494 (gnus-uncompress-range (gnus-active group)))
16409b0b 5495 (gnus-cache-articles-in-group group))
23f87bed
MB
5496 ;; Select only the "normal" subset of articles.
5497 (gnus-sorted-nunion
5498 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5499 gnus-newsgroup-unreads)))
eec82323
LMI
5500 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5501 (scored (length scored-list))
5502 (number (length articles))
5503 (marked (+ (length gnus-newsgroup-marked)
5504 (length gnus-newsgroup-dormant)))
5505 (select
5506 (cond
5507 ((numberp read-all)
5508 read-all)
23f87bed
MB
5509 ((numberp gnus-newsgroup-display)
5510 gnus-newsgroup-display)
eec82323
LMI
5511 (t
5512 (condition-case ()
5513 (cond
5514 ((and (or (<= scored marked) (= scored number))
5515 (numberp gnus-large-newsgroup)
5516 (> number gnus-large-newsgroup))
23f87bed
MB
5517 (let* ((cursor-in-echo-area nil)
5518 (initial (gnus-parameter-large-newsgroup-initial
5519 gnus-newsgroup-name))
5520 (input
5521 (read-string
5522 (format
5523 "How many articles from %s (%s %d): "
5524 (gnus-limit-string
5525 (gnus-group-decoded-name gnus-newsgroup-name)
5526 35)
5527 (if initial "max" "default")
5528 number)
5529 (if initial
5530 (cons (number-to-string initial)
5531 0)))))
eec82323
LMI
5532 (if (string-match "^[ \t]*$" input) number input)))
5533 ((and (> scored marked) (< scored number)
5534 (> (- scored number) 20))
5535 (let ((input
5536 (read-string
5537 (format "%s %s (%d scored, %d total): "
5538 "How many articles from"
23f87bed
MB
5539 (gnus-group-decoded-name group)
5540 scored number))))
eec82323
LMI
5541 (if (string-match "^[ \t]*$" input)
5542 number input)))
5543 (t number))
d4dfaa19
DL
5544 (quit
5545 (message "Quit getting the articles to read")
5546 nil))))))
eec82323
LMI
5547 (setq select (if (stringp select) (string-to-number select) select))
5548 (if (or (null select) (zerop select))
5549 select
5550 (if (and (not (zerop scored)) (<= (abs select) scored))
5551 (progn
5552 (setq articles (sort scored-list '<))
5553 (setq number (length articles)))
5554 (setq articles (copy-sequence articles)))
5555
5556 (when (< (abs select) number)
5557 (if (< select 0)
5558 ;; Select the N oldest articles.
5559 (setcdr (nthcdr (1- (abs select)) articles) nil)
5560 ;; Select the N most recent articles.
5561 (setq articles (nthcdr (- number select) articles))))
5562 (setq gnus-newsgroup-unselected
23f87bed 5563 (gnus-sorted-difference gnus-newsgroup-unreads articles))
16409b0b 5564 (when gnus-alter-articles-to-read-function
23f87bed 5565 (setq articles
a1506d29 5566 (sort
16409b0b 5567 (funcall gnus-alter-articles-to-read-function
23f87bed 5568 gnus-newsgroup-name articles)
16409b0b 5569 '<)))
eec82323
LMI
5570 articles)))
5571
5572(defun gnus-killed-articles (killed articles)
5573 (let (out)
5574 (while articles
5575 (when (inline (gnus-member-of-range (car articles) killed))
5576 (push (car articles) out))
5577 (setq articles (cdr articles)))
5578 out))
5579
5580(defun gnus-uncompress-marks (marks)
5581 "Uncompress the mark ranges in MARKS."
5582 (let ((uncompressed '(score bookmark))
5583 out)
5584 (while marks
5585 (if (memq (caar marks) uncompressed)
5586 (push (car marks) out)
5587 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5588 (setq marks (cdr marks)))
5589 out))
5590
23f87bed
MB
5591(defun gnus-article-mark-to-type (mark)
5592 "Return the type of MARK."
5593 (or (cadr (assq mark gnus-article-special-mark-lists))
5594 'list))
5595
5596(defun gnus-article-unpropagatable-p (mark)
5597 "Return whether MARK should be propagated to back end."
5598 (memq mark gnus-article-unpropagated-mark-lists))
5599
eec82323 5600(defun gnus-adjust-marked-articles (info)
16409b0b 5601 "Set all article lists and remove all marks that are no longer valid."
eec82323
LMI
5602 (let* ((marked-lists (gnus-info-marks info))
5603 (active (gnus-active (gnus-info-group info)))
5604 (min (car active))
5605 (max (cdr active))
5606 (types gnus-article-mark-lists)
54506618
MB
5607 marks var articles article mark mark-type
5608 bgn end)
eec82323 5609
23f87bed
MB
5610 (dolist (marks marked-lists)
5611 (setq mark (car marks)
5612 mark-type (gnus-article-mark-to-type mark)
5613 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
eec82323 5614
23f87bed
MB
5615 ;; We set the variable according to the type of the marks list,
5616 ;; and then adjust the marks to a subset of the active articles.
eec82323 5617 (cond
54506618 5618 ;; Adjust "simple" lists - compressed yet unsorted
23f87bed 5619 ((eq mark-type 'list)
54506618
MB
5620 ;; Simultaneously uncompress and clip to active range
5621 ;; See gnus-uncompress-range for a description of possible marks
5622 (let (l lh)
5623 (if (not (cadr marks))
5624 (set var nil)
5625 (setq articles (if (numberp (cddr marks))
5626 (list (cdr marks))
5627 (cdr marks))
5628 lh (cons nil nil)
5629 l lh)
5630
5631 (while (setq article (pop articles))
5632 (cond ((consp article)
5633 (setq bgn (max (car article) min)
5634 end (min (cdr article) max))
5635 (while (<= bgn end)
5636 (setq l (setcdr l (cons bgn nil))
5637 bgn (1+ bgn))))
5638 ((and (<= min article)
5639 (>= max article))
5640 (setq l (setcdr l (cons article nil))))))
5641 (set var (cdr lh)))))
eec82323 5642 ;; Adjust assocs.
23f87bed
MB
5643 ((eq mark-type 'tuple)
5644 (set var (setq articles (cdr marks)))
a8151ef7
LMI
5645 (when (not (listp (cdr (symbol-value var))))
5646 (set var (list (symbol-value var))))
5647 (when (not (listp (cdr articles)))
5648 (setq articles (list articles)))
eec82323
LMI
5649 (while articles
5650 (when (or (not (consp (setq article (pop articles))))
5651 (< (car article) min)
5652 (> (car article) max))
23f87bed
MB
5653 (set var (delq article (symbol-value var))))))
5654 ;; Adjust ranges (sloppily).
5655 ((eq mark-type 'range)
5656 (cond
5657 ((eq mark 'seen)
5658 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5659 ;; It should be (seen (NUM1 . NUM2)).
5660 (when (numberp (cddr marks))
5661 (setcdr marks (list (cdr marks))))
5662 (setq articles (cdr marks))
5663 (while (and articles
5664 (or (and (consp (car articles))
5665 (> min (cdar articles)))
5666 (and (numberp (car articles))
5667 (> min (car articles)))))
5668 (pop articles))
5669 (set var articles))))))))
eec82323
LMI
5670
5671(defun gnus-update-missing-marks (missing)
6748645f 5672 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323 5673 (when missing
23f87bed 5674 (let (var m)
eec82323 5675 ;; Go through all types.
23f87bed
MB
5676 (dolist (elem gnus-article-mark-lists)
5677 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5678 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5679 (when (symbol-value var)
5680 ;; This list has articles. So we delete all missing
5681 ;; articles from it.
5682 (setq m missing)
5683 (while m
5684 (set var (delq (pop m) (symbol-value var))))))))))
eec82323
LMI
5685
5686(defun gnus-update-marks ()
5687 "Enter the various lists of marked articles into the newsgroup info list."
5688 (let ((types gnus-article-mark-lists)
5689 (info (gnus-get-info gnus-newsgroup-name))
16409b0b 5690 type list newmarked symbol delta-marks)
eec82323 5691 (when info
16409b0b 5692 ;; Add all marks lists to the list of marks lists.
eec82323 5693 (while (setq type (pop types))
16409b0b
GM
5694 (setq list (symbol-value
5695 (setq symbol
23f87bed 5696 (intern (format "gnus-newsgroup-%s" (car type))))))
eec82323 5697
16409b0b 5698 (when list
eec82323
LMI
5699 ;; Get rid of the entries of the articles that have the
5700 ;; default score.
5701 (when (and (eq (cdr type) 'score)
5702 gnus-save-score
5703 list)
5704 (let* ((arts list)
5705 (prev (cons nil list))
5706 (all prev))
5707 (while arts
5708 (if (or (not (consp (car arts)))
5709 (= (cdar arts) gnus-summary-default-score))
5710 (setcdr prev (cdr arts))
5711 (setq prev arts))
5712 (setq arts (cdr arts)))
16409b0b
GM
5713 (setq list (cdr all)))))
5714
23f87bed
MB
5715 (when (eq (cdr type) 'seen)
5716 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5717
5718 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
16409b0b 5719 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
a1506d29 5720
23f87bed
MB
5721 (when (and (gnus-check-backend-function
5722 'request-set-mark gnus-newsgroup-name)
5723 (not (gnus-article-unpropagatable-p (cdr type))))
5724 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5725 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5726 (add (gnus-remove-from-range
5727 (gnus-copy-sequence list) old)))
5728 (when add
5729 (push (list add 'add (list (cdr type))) delta-marks))
5730 (when del
5731 (push (list del 'del (list (cdr type))) delta-marks))))
a1506d29 5732
16409b0b
GM
5733 (when list
5734 (push (cons (cdr type) list) newmarked)))
5735
5736 (when delta-marks
5737 (unless (gnus-check-group gnus-newsgroup-name)
5738 (error "Can't open server for %s" gnus-newsgroup-name))
5739 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
a1506d29 5740
eec82323
LMI
5741 ;; Enter these new marks into the info of the group.
5742 (if (nthcdr 3 info)
5743 (setcar (nthcdr 3 info) newmarked)
5744 ;; Add the marks lists to the end of the info.
5745 (when newmarked
5746 (setcdr (nthcdr 2 info) (list newmarked))))
5747
5748 ;; Cut off the end of the info if there's nothing else there.
5749 (let ((i 5))
5750 (while (and (> i 2)
5751 (not (nth i info)))
5752 (when (nthcdr (decf i) info)
5753 (setcdr (nthcdr i info) nil)))))))
5754
5755(defun gnus-set-mode-line (where)
16409b0b 5756 "Set the mode line of the article or summary buffers.
eec82323
LMI
5757If WHERE is `summary', the summary mode line format will be used."
5758 ;; Is this mode line one we keep updated?
16409b0b
GM
5759 (when (and (memq where gnus-updated-mode-lines)
5760 (symbol-value
5761 (intern (format "gnus-%s-mode-line-format-spec" where))))
eec82323
LMI
5762 (let (mode-string)
5763 (save-excursion
5764 ;; We evaluate this in the summary buffer since these
5765 ;; variables are buffer-local to that buffer.
5766 (set-buffer gnus-summary-buffer)
23f87bed 5767 ;; We bind all these variables that are used in the `eval' form
eec82323
LMI
5768 ;; below.
5769 (let* ((mformat (symbol-value
5770 (intern
5771 (format "gnus-%s-mode-line-format-spec" where))))
b90a6149
MB
5772 (gnus-tmp-group-name (gnus-mode-string-quote
5773 (gnus-group-decoded-name
5774 gnus-newsgroup-name)))
eec82323
LMI
5775 (gnus-tmp-article-number (or gnus-current-article 0))
5776 (gnus-tmp-unread gnus-newsgroup-unreads)
5777 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5778 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5779 (gnus-tmp-unread-and-unselected
5780 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5781 (zerop gnus-tmp-unselected))
5782 "")
5783 ((zerop gnus-tmp-unselected)
5784 (format "{%d more}" gnus-tmp-unread-and-unticked))
5785 (t (format "{%d(+%d) more}"
5786 gnus-tmp-unread-and-unticked
5787 gnus-tmp-unselected))))
5788 (gnus-tmp-subject
5789 (if (and gnus-current-headers
5790 (vectorp gnus-current-headers))
5791 (gnus-mode-string-quote
5792 (mail-header-subject gnus-current-headers))
5793 ""))
5794 bufname-length max-len
23f87bed 5795 gnus-tmp-header) ;; passed as argument to any user-format-funcs
eec82323
LMI
5796 (setq mode-string (eval mformat))
5797 (setq bufname-length (if (string-match "%b" mode-string)
5798 (- (length
5799 (buffer-name
5800 (if (eq where 'summary)
5801 nil
5802 (get-buffer gnus-article-buffer))))
5803 2)
5804 0))
5805 (setq max-len (max 4 (if gnus-mode-non-string-length
5806 (- (window-width)
5807 gnus-mode-non-string-length
5808 bufname-length)
5809 (length mode-string))))
5810 ;; We might have to chop a bit of the string off...
5811 (when (> (length mode-string) max-len)
5812 (setq mode-string
16409b0b 5813 (concat (truncate-string-to-width mode-string (- max-len 3))
eec82323
LMI
5814 "...")))
5815 ;; Pad the mode string a bit.
5816 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5817 ;; Update the mode line.
5818 (setq mode-line-buffer-identification
5819 (gnus-mode-line-buffer-identification (list mode-string)))
5820 (set-buffer-modified-p t))))
5821
5822(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5823 "Go through the HEADERS list and add all Xrefs to a hash table.
5824The resulting hash table is returned, or nil if no Xrefs were found."
5825 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5826 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5827 (xref-hashtb (gnus-make-hashtable))
5828 start group entry number xrefs header)
5829 (while headers
5830 (setq header (pop headers))
5831 (when (and (setq xrefs (mail-header-xref header))
5832 (not (memq (setq number (mail-header-number header))
5833 unreads)))
5834 (setq start 0)
5835 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5836 (setq start (match-end 0))
5837 (setq group (if prefix
5838 (concat prefix (substring xrefs (match-beginning 1)
5839 (match-end 1)))
5840 (substring xrefs (match-beginning 1) (match-end 1))))
5841 (setq number
e9bd5782 5842 (string-to-number (substring xrefs (match-beginning 2)
eec82323
LMI
5843 (match-end 2))))
5844 (if (setq entry (gnus-gethash group xref-hashtb))
5845 (setcdr entry (cons number (cdr entry)))
5846 (gnus-sethash group (cons number nil) xref-hashtb)))))
5847 (and start xref-hashtb)))
5848
5849(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5850 "Look through all the headers and mark the Xrefs as read."
5851 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5852 name entry info xref-hashtb idlist method nth4)
5853 (save-excursion
5854 (set-buffer gnus-group-buffer)
5855 (when (setq xref-hashtb
5856 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5857 (mapatoms
5858 (lambda (group)
5859 (unless (string= from-newsgroup (setq name (symbol-name group)))
5860 (setq idlist (symbol-value group))
5861 ;; Dead groups are not updated.
5862 (and (prog1
5863 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5864 info (nth 2 entry))
5865 (when (stringp (setq nth4 (gnus-info-method info)))
5866 (setq nth4 (gnus-server-to-method nth4))))
5867 ;; Only do the xrefs if the group has the same
5868 ;; select method as the group we have just read.
5869 (or (gnus-methods-equal-p
5870 nth4 (gnus-find-method-for-group from-newsgroup))
5871 virtual
5872 (equal nth4 (setq method (gnus-find-method-for-group
5873 from-newsgroup)))
5874 (and (equal (car nth4) (car method))
5875 (equal (nth 1 nth4) (nth 1 method))))
5876 gnus-use-cross-reference
5877 (or (not (eq gnus-use-cross-reference t))
5878 virtual
5879 ;; Only do cross-references on subscribed
5880 ;; groups, if that is what is wanted.
5881 (<= (gnus-info-level info) gnus-level-subscribed))
5882 (gnus-group-make-articles-read name idlist))))
5883 xref-hashtb)))))
5884
6748645f
LMI
5885(defun gnus-compute-read-articles (group articles)
5886 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5887 (info (nth 2 entry))
5888 (active (gnus-active group))
5889 ninfo)
5890 (when entry
16409b0b 5891 ;; First peel off all invalid article numbers.
6748645f
LMI
5892 (when active
5893 (let ((ids articles)
5894 id first)
5895 (while (setq id (pop ids))
5896 (when (and first (> id (cdr active)))
5897 ;; We'll end up in this situation in one particular
5898 ;; obscure situation. If you re-scan a group and get
5899 ;; a new article that is cross-posted to a different
5900 ;; group that has not been re-scanned, you might get
5901 ;; crossposted article that has a higher number than
5902 ;; Gnus believes possible. So we re-activate this
5903 ;; group as well. This might mean doing the
5904 ;; crossposting thingy will *increase* the number
5905 ;; of articles in some groups. Tsk, tsk.
5906 (setq active (or (gnus-activate-group group) active)))
5907 (when (or (> id (cdr active))
5908 (< id (car active)))
5909 (setq articles (delq id articles))))))
5910 ;; If the read list is nil, we init it.
5911 (if (and active
5912 (null (gnus-info-read info))
5913 (> (car active) 1))
5914 (setq ninfo (cons 1 (1- (car active))))
5915 (setq ninfo (gnus-info-read info)))
5916 ;; Then we add the read articles to the range.
5917 (gnus-add-to-range
5918 ninfo (setq articles (sort articles '<))))))
5919
eec82323
LMI
5920(defun gnus-group-make-articles-read (group articles)
5921 "Update the info of GROUP to say that ARTICLES are read."
5922 (let* ((num 0)
5923 (entry (gnus-gethash group gnus-newsrc-hashtb))
5924 (info (nth 2 entry))
5925 (active (gnus-active group))
5926 range)
6748645f
LMI
5927 (when entry
5928 (setq range (gnus-compute-read-articles group articles))
5929 (save-excursion
5930 (set-buffer gnus-group-buffer)
5931 (gnus-undo-register
5932 `(progn
5933 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5934 (gnus-info-set-read ',info ',(gnus-info-read info))
5935 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
23f87bed 5936 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
6748645f
LMI
5937 (gnus-group-update-group ,group t))))
5938 ;; Add the read articles to the range.
5939 (gnus-info-set-read info range)
23f87bed 5940 (gnus-request-set-mark group (list (list range 'add '(read))))
6748645f
LMI
5941 ;; Then we have to re-compute how many unread
5942 ;; articles there are in this group.
5943 (when active
5944 (cond
5945 ((not range)
5946 (setq num (- (1+ (cdr active)) (car active))))
5947 ((not (listp (cdr range)))
5948 (setq num (- (cdr active) (- (1+ (cdr range))
5949 (car range)))))
5950 (t
5951 (while range
5952 (if (numberp (car range))
5953 (setq num (1+ num))
5954 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5955 (setq range (cdr range)))
5956 (setq num (- (cdr active) num))))
5957 ;; Update the number of unread articles.
5958 (setcar entry num)
5959 ;; Update the group buffer.
23f87bed
MB
5960 (unless (gnus-ephemeral-group-p group)
5961 (gnus-group-update-group group t))))))
eec82323 5962
eec82323
LMI
5963(defvar gnus-newsgroup-none-id 0)
5964
5965(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5966 (let ((cur nntp-server-buffer)
5967 (dependencies
5968 (or dependencies
5969 (save-excursion (set-buffer gnus-summary-buffer)
5970 gnus-newsgroup-dependencies)))
16409b0b
GM
5971 headers id end ref
5972 (mail-parse-charset gnus-newsgroup-charset)
5973 (mail-parse-ignored-charsets
5974 (save-excursion (condition-case nil
5975 (set-buffer gnus-summary-buffer)
5976 (error))
5977 gnus-newsgroup-ignored-charsets)))
eec82323
LMI
5978 (save-excursion
5979 (set-buffer nntp-server-buffer)
5980 ;; Translate all TAB characters into SPACE characters.
5981 (subst-char-in-region (point-min) (point-max) ?\t ? t)
16409b0b 5982 (subst-char-in-region (point-min) (point-max) ?\r ? t)
23f87bed 5983 (ietf-drums-unfold-fws)
6748645f 5984 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 5985 (let ((case-fold-search t)
6748645f 5986 in-reply-to header p lines chars)
eec82323 5987 (goto-char (point-min))
01ccbb85 5988 ;; Search to the beginning of the next header. Error messages
eec82323
LMI
5989 ;; do not begin with 2 or 3.
5990 (while (re-search-forward "^[23][0-9]+ " nil t)
5991 (setq id nil
5992 ref nil)
5993 ;; This implementation of this function, with nine
5994 ;; search-forwards instead of the one re-search-forward and
5995 ;; a case (which basically was the old function) is actually
01ccbb85 5996 ;; about twice as fast, even though it looks messier. You
eec82323
LMI
5997 ;; can't have everything, I guess. Speed and elegance
5998 ;; doesn't always go hand in hand.
5999 (setq
6000 header
6001 (vector
6002 ;; Number.
6003 (prog1
6004 (read cur)
6005 (end-of-line)
6006 (setq p (point))
6007 (narrow-to-region (point)
6008 (or (and (search-forward "\n.\n" nil t)
6009 (- (point) 2))
6010 (point))))
6011 ;; Subject.
6012 (progn
6013 (goto-char p)
23f87bed 6014 (if (search-forward "\nsubject:" nil t)
16409b0b
GM
6015 (funcall gnus-decode-encoded-word-function
6016 (nnheader-header-value))
2bd3dcae 6017 "(none)"))
eec82323
LMI
6018 ;; From.
6019 (progn
6020 (goto-char p)
23f87bed 6021 (if (search-forward "\nfrom:" nil t)
343d6628 6022 (funcall gnus-decode-encoded-address-function
16409b0b 6023 (nnheader-header-value))
2bd3dcae 6024 "(nobody)"))
eec82323
LMI
6025 ;; Date.
6026 (progn
6027 (goto-char p)
23f87bed 6028 (if (search-forward "\ndate:" nil t)
eec82323
LMI
6029 (nnheader-header-value) ""))
6030 ;; Message-ID.
6031 (progn
6032 (goto-char p)
6748645f
LMI
6033 (setq id (if (re-search-forward
6034 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6035 ;; We do it this way to make sure the Message-ID
6036 ;; is (somewhat) syntactically valid.
6037 (buffer-substring (match-beginning 1)
6038 (match-end 1))
eec82323
LMI
6039 ;; If there was no message-id, we just fake one
6040 ;; to make subsequent routines simpler.
6041 (nnheader-generate-fake-message-id))))
6042 ;; References.
6043 (progn
6044 (goto-char p)
23f87bed 6045 (if (search-forward "\nreferences:" nil t)
eec82323
LMI
6046 (progn
6047 (setq end (point))
6048 (prog1
6049 (nnheader-header-value)
6050 (setq ref
6051 (buffer-substring
6052 (progn
6053 (end-of-line)
6054 (search-backward ">" end t)
6055 (1+ (point)))
6056 (progn
6057 (search-backward "<" end t)
6058 (point))))))
6059 ;; Get the references from the in-reply-to header if there
6060 ;; were no references and the in-reply-to header looks
6061 ;; promising.
23f87bed 6062 (if (and (search-forward "\nin-reply-to:" nil t)
eec82323
LMI
6063 (setq in-reply-to (nnheader-header-value))
6064 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
6065 (let (ref2)
6066 (setq ref (substring in-reply-to (match-beginning 0)
6067 (match-end 0)))
6068 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6069 (setq ref2 (substring in-reply-to (match-beginning 0)
6070 (match-end 0)))
6071 (when (> (length ref2) (length ref))
6072 (setq ref ref2)))
6073 ref)
eec82323
LMI
6074 (setq ref nil))))
6075 ;; Chars.
6748645f
LMI
6076 (progn
6077 (goto-char p)
6078 (if (search-forward "\nchars: " nil t)
6079 (if (numberp (setq chars (ignore-errors (read cur))))
23f87bed
MB
6080 chars -1)
6081 -1))
eec82323
LMI
6082 ;; Lines.
6083 (progn
6084 (goto-char p)
6085 (if (search-forward "\nlines: " nil t)
a8151ef7 6086 (if (numberp (setq lines (ignore-errors (read cur))))
23f87bed
MB
6087 lines -1)
6088 -1))
eec82323
LMI
6089 ;; Xref.
6090 (progn
6091 (goto-char p)
23f87bed 6092 (and (search-forward "\nxref:" nil t)
16409b0b
GM
6093 (nnheader-header-value)))
6094 ;; Extra.
6095 (when gnus-extra-headers
6096 (let ((extra gnus-extra-headers)
6097 out)
6098 (while extra
6099 (goto-char p)
6100 (when (search-forward
23f87bed 6101 (concat "\n" (symbol-name (car extra)) ":") nil t)
16409b0b
GM
6102 (push (cons (car extra) (nnheader-header-value))
6103 out))
6104 (pop extra))
6105 out))))
eec82323
LMI
6106 (when (equal id ref)
6107 (setq ref nil))
6748645f
LMI
6108
6109 (when gnus-alter-header-function
6110 (funcall gnus-alter-header-function header)
6111 (setq id (mail-header-id header)
6112 ref (gnus-parent-id (mail-header-references header))))
6113
6114 (when (setq header
6115 (gnus-dependencies-add-header
6116 header dependencies force-new))
eec82323
LMI
6117 (push header headers))
6118 (goto-char (point-max))
6119 (widen))
6120 (nreverse headers)))))
6121
eec82323
LMI
6122;; Goes through the xover lines and returns a list of vectors
6123(defun gnus-get-newsgroup-headers-xover (sequence &optional
6124 force-new dependencies
6125 group also-fetch-heads)
16409b0b
GM
6126 "Parse the news overview data in the server buffer.
6127Return a list of headers that match SEQUENCE (see
6128`nntp-retrieve-headers')."
eec82323
LMI
6129 ;; Get the Xref when the users reads the articles since most/some
6130 ;; NNTP servers do not include Xrefs when using XOVER.
6131 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
16409b0b
GM
6132 (let ((mail-parse-charset gnus-newsgroup-charset)
6133 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6134 (cur nntp-server-buffer)
eec82323 6135 (dependencies (or dependencies gnus-newsgroup-dependencies))
23f87bed
MB
6136 (allp (cond
6137 ((eq gnus-read-all-available-headers t)
6138 t)
14e6dc54
MB
6139 ((and (stringp gnus-read-all-available-headers)
6140 group)
23f87bed
MB
6141 (string-match gnus-read-all-available-headers group))
6142 (t
6143 nil)))
eec82323
LMI
6144 number headers header)
6145 (save-excursion
6146 (set-buffer nntp-server-buffer)
16409b0b 6147 (subst-char-in-region (point-min) (point-max) ?\r ? t)
eec82323 6148 ;; Allow the user to mangle the headers before parsing them.
6748645f 6149 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 6150 (goto-char (point-min))
23f87bed
MB
6151 (gnus-parse-without-error
6152 (while (and (or sequence allp)
6153 (not (eobp)))
6154 (setq number (read cur))
6155 (when (not allp)
6156 (while (and sequence
6157 (< (car sequence) number))
6158 (setq sequence (cdr sequence))))
6159 (when (and (or allp
6160 (and sequence
6161 (eq number (car sequence))))
6162 (progn
6163 (setq sequence (cdr sequence))
6164 (setq header (inline
6165 (gnus-nov-parse-line
6166 number dependencies force-new)))))
6167 (push header headers))
6168 (forward-line 1)))
eec82323
LMI
6169 ;; A common bug in inn is that if you have posted an article and
6170 ;; then retrieves the active file, it will answer correctly --
6171 ;; the new article is included. However, a NOV entry for the
6172 ;; article may not have been generated yet, so this may fail.
6173 ;; We work around this problem by retrieving the last few
6174 ;; headers using HEAD.
6175 (if (or (not also-fetch-heads)
6176 (not sequence))
6177 ;; We (probably) got all the headers.
6178 (nreverse headers)
6179 (let ((gnus-nov-is-evil t))
6180 (nconc
6181 (nreverse headers)
23f87bed 6182 (when (eq (gnus-retrieve-headers sequence group) 'headers)
eec82323
LMI
6183 (gnus-get-newsgroup-headers))))))))
6184
6185(defun gnus-article-get-xrefs ()
6186 "Fill in the Xref value in `gnus-current-headers', if necessary.
6187This is meant to be called in `gnus-article-internal-prepare-hook'."
6188 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6189 gnus-current-headers)))
6190 (or (not gnus-use-cross-reference)
6191 (not headers)
6192 (and (mail-header-xref headers)
6193 (not (string= (mail-header-xref headers) "")))
6194 (let ((case-fold-search t)
6195 xref)
6196 (save-restriction
6197 (nnheader-narrow-to-headers)
6198 (goto-char (point-min))
16409b0b
GM
6199 (when (or (and (not (eobp))
6200 (eq (downcase (char-after)) ?x)
eec82323
LMI
6201 (looking-at "Xref:"))
6202 (search-forward "\nXref:" nil t))
6203 (goto-char (1+ (match-end 0)))
23f87bed 6204 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
eec82323
LMI
6205 (mail-header-set-xref headers xref)))))))
6206
6207(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
6208 "Find article ID and insert the summary line for that article.
6209OLD-HEADER can either be a header or a line number to insert
6210the subject line on."
6211 (let* ((line (and (numberp old-header) old-header))
6212 (old-header (and (vectorp old-header) old-header))
6213 (header (cond ((and old-header use-old-header)
16409b0b
GM
6214 old-header)
6215 ((and (numberp id)
6216 (gnus-number-to-header id))
6217 (gnus-number-to-header id))
6218 (t
6219 (gnus-read-header id))))
6220 (number (and (numberp id) id))
6221 d)
eec82323
LMI
6222 (when header
6223 ;; Rebuild the thread that this article is part of and go to the
6224 ;; article we have fetched.
6225 (when (and (not gnus-show-threads)
6226 old-header)
6748645f
LMI
6227 (when (and number
6228 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
6229 (goto-char (gnus-data-pos d))
6230 (gnus-data-remove
6231 number
6232 (- (gnus-point-at-bol)
6233 (prog1
6234 (1+ (gnus-point-at-eol))
6235 (gnus-delete-line))))))
23f87bed
MB
6236 ;; Remove list identifiers from subject.
6237 (when gnus-list-identifiers
6238 (let ((gnus-newsgroup-headers (list header)))
c3bc41c2 6239 (gnus-summary-remove-list-identifiers)))
eec82323
LMI
6240 (when old-header
6241 (mail-header-set-number header (mail-header-number old-header)))
6242 (setq gnus-newsgroup-sparse
6243 (delq (setq number (mail-header-number header))
6244 gnus-newsgroup-sparse))
6245 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
6246 (push number gnus-newsgroup-limit)
6247 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
6248 (gnus-summary-goto-subject number nil t))
6249 (when (and (numberp number)
6250 (> number 0))
6251 ;; We have to update the boundaries even if we can't fetch the
6252 ;; article if ID is a number -- so that the next `P' or `N'
6253 ;; command will fetch the previous (or next) article even
6254 ;; if the one we tried to fetch this time has been canceled.
6255 (when (> number gnus-newsgroup-end)
6256 (setq gnus-newsgroup-end number))
6257 (when (< number gnus-newsgroup-begin)
6258 (setq gnus-newsgroup-begin number))
6259 (setq gnus-newsgroup-unselected
6260 (delq number gnus-newsgroup-unselected)))
6261 ;; Report back a success?
6262 (and header (mail-header-number header))))
6263
6264;;; Process/prefix in the summary buffer
6265
6266(defun gnus-summary-work-articles (n)
6748645f
LMI
6267 "Return a list of articles to be worked upon.
6268The prefix argument, the list of process marked articles, and the
6269current article will be taken into consideration."
6270 (save-excursion
6271 (set-buffer gnus-summary-buffer)
6272 (cond
6273 (n
6274 ;; A numerical prefix has been given.
6275 (setq n (prefix-numeric-value n))
6276 (let ((backward (< n 0))
6277 (n (abs (prefix-numeric-value n)))
6278 articles article)
6279 (save-excursion
6280 (while
6281 (and (> n 0)
6282 (push (setq article (gnus-summary-article-number))
6283 articles)
6284 (if backward
6285 (gnus-summary-find-prev nil article)
6286 (gnus-summary-find-next nil article)))
6287 (decf n)))
6288 (nreverse articles)))
6289 ((and (gnus-region-active-p) (mark))
6290 (message "region active")
6291 ;; Work on the region between point and mark.
6292 (let ((max (max (point) (mark)))
6293 articles article)
6294 (save-excursion
7dafe00b 6295 (goto-char (min (point) (mark)))
6748645f
LMI
6296 (while
6297 (and
6298 (push (setq article (gnus-summary-article-number)) articles)
6299 (gnus-summary-find-next nil article)
6300 (< (point) max)))
6301 (nreverse articles))))
6302 (gnus-newsgroup-processable
6303 ;; There are process-marked articles present.
6304 ;; Save current state.
6305 (gnus-summary-save-process-mark)
6306 ;; Return the list.
6307 (reverse gnus-newsgroup-processable))
6308 (t
6309 ;; Just return the current article.
6310 (list (gnus-summary-article-number))))))
6311
6312(defmacro gnus-summary-iterate (arg &rest forms)
6313 "Iterate over the process/prefixed articles and do FORMS.
6314ARG is the interactive prefix given to the command. FORMS will be
6315executed with point over the summary line of the articles."
6316 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6317 `(let ((,articles (gnus-summary-work-articles ,arg)))
6318 (while ,articles
6319 (gnus-summary-goto-subject (car ,articles))
16409b0b
GM
6320 ,@forms
6321 (pop ,articles)))))
6748645f
LMI
6322
6323(put 'gnus-summary-iterate 'lisp-indent-function 1)
6324(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
6325
6326(defun gnus-summary-save-process-mark ()
6327 "Push the current set of process marked articles on the stack."
6328 (interactive)
6329 (push (copy-sequence gnus-newsgroup-processable)
6330 gnus-newsgroup-process-stack))
6331
6332(defun gnus-summary-kill-process-mark ()
6333 "Push the current set of process marked articles on the stack and unmark."
6334 (interactive)
6335 (gnus-summary-save-process-mark)
6336 (gnus-summary-unmark-all-processable))
6337
6338(defun gnus-summary-yank-process-mark ()
6339 "Pop the last process mark state off the stack and restore it."
6340 (interactive)
6341 (unless gnus-newsgroup-process-stack
6342 (error "Empty mark stack"))
6343 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6344
6345(defun gnus-summary-process-mark-set (set)
6346 "Make SET into the current process marked articles."
6347 (gnus-summary-unmark-all-processable)
6348 (while set
6349 (gnus-summary-set-process-mark (pop set))))
6350
6351;;; Searching and stuff
6352
6353(defun gnus-summary-search-group (&optional backward use-level)
6354 "Search for next unread newsgroup.
6355If optional argument BACKWARD is non-nil, search backward instead."
6356 (save-excursion
6357 (set-buffer gnus-group-buffer)
6358 (when (gnus-group-search-forward
6359 backward nil (if use-level (gnus-group-group-level) nil))
6360 (gnus-group-group-name))))
6361
6362(defun gnus-summary-best-group (&optional exclude-group)
6363 "Find the name of the best unread group.
6364If EXCLUDE-GROUP, do not go to this group."
6365 (save-excursion
6366 (set-buffer gnus-group-buffer)
6367 (save-excursion
6368 (gnus-group-best-unread-group exclude-group))))
6369
23f87bed
MB
6370(defun gnus-summary-find-next (&optional unread article backward)
6371 (if backward
6372 (gnus-summary-find-prev unread article)
eec82323
LMI
6373 (let* ((dummy (gnus-summary-article-intangible-p))
6374 (article (or article (gnus-summary-article-number)))
23f87bed 6375 (data (gnus-data-find-list article))
eec82323
LMI
6376 result)
6377 (when (and (not dummy)
6378 (or (not gnus-summary-check-current)
6379 (not unread)
23f87bed
MB
6380 (not (gnus-data-unread-p (car data)))))
6381 (setq data (cdr data)))
eec82323
LMI
6382 (when (setq result
6383 (if unread
6384 (progn
23f87bed
MB
6385 (while data
6386 (unless (memq (gnus-data-number (car data))
6387 (cond
6388 ((eq gnus-auto-goto-ignores
6389 'always-undownloaded)
6390 gnus-newsgroup-undownloaded)
6391 (gnus-plugged
6392 nil)
6393 ((eq gnus-auto-goto-ignores
6394 'unfetched)
6395 gnus-newsgroup-unfetched)
6396 ((eq gnus-auto-goto-ignores
6397 'undownloaded)
6398 gnus-newsgroup-undownloaded)))
6399 (when (gnus-data-unread-p (car data))
6400 (setq result (car data)
6401 data nil)))
6402 (setq data (cdr data)))
eec82323 6403 result)
23f87bed 6404 (car data)))
eec82323
LMI
6405 (goto-char (gnus-data-pos result))
6406 (gnus-data-number result)))))
6407
6408(defun gnus-summary-find-prev (&optional unread article)
6409 (let* ((eobp (eobp))
6410 (article (or article (gnus-summary-article-number)))
23f87bed 6411 (data (gnus-data-find-list article (gnus-data-list 'rev)))
eec82323
LMI
6412 result)
6413 (when (and (not eobp)
6414 (or (not gnus-summary-check-current)
6415 (not unread)
23f87bed
MB
6416 (not (gnus-data-unread-p (car data)))))
6417 (setq data (cdr data)))
eec82323
LMI
6418 (when (setq result
6419 (if unread
6420 (progn
23f87bed
MB
6421 (while data
6422 (unless (memq (gnus-data-number (car data))
6423 (cond
6424 ((eq gnus-auto-goto-ignores
6425 'always-undownloaded)
6426 gnus-newsgroup-undownloaded)
6427 (gnus-plugged
6428 nil)
6429 ((eq gnus-auto-goto-ignores
6430 'unfetched)
6431 gnus-newsgroup-unfetched)
6432 ((eq gnus-auto-goto-ignores
6433 'undownloaded)
6434 gnus-newsgroup-undownloaded)))
6435 (when (gnus-data-unread-p (car data))
6436 (setq result (car data)
6437 data nil)))
6438 (setq data (cdr data)))
eec82323 6439 result)
23f87bed 6440 (car data)))
eec82323
LMI
6441 (goto-char (gnus-data-pos result))
6442 (gnus-data-number result))))
6443
6444(defun gnus-summary-find-subject (subject &optional unread backward article)
6445 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6446 (article (or article (gnus-summary-article-number)))
6447 (articles (gnus-data-list backward))
6448 (arts (gnus-data-find-list article articles))
6449 result)
6450 (when (or (not gnus-summary-check-current)
6451 (not unread)
6452 (not (gnus-data-unread-p (car arts))))
6453 (setq arts (cdr arts)))
6454 (while arts
6455 (and (or (not unread)
6456 (gnus-data-unread-p (car arts)))
6457 (vectorp (gnus-data-header (car arts)))
6458 (gnus-subject-equal
6459 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6460 (setq result (car arts)
6461 arts nil))
6462 (setq arts (cdr arts)))
6463 (and result
6464 (goto-char (gnus-data-pos result))
6465 (gnus-data-number result))))
6466
6467(defun gnus-summary-search-forward (&optional unread subject backward)
6468 "Search forward for an article.
6469If UNREAD, look for unread articles. If SUBJECT, look for
6470articles with that subject. If BACKWARD, search backward instead."
6471 (cond (subject (gnus-summary-find-subject subject unread backward))
6472 (backward (gnus-summary-find-prev unread))
6473 (t (gnus-summary-find-next unread))))
6474
6475(defun gnus-recenter (&optional n)
6476 "Center point in window and redisplay frame.
6477Also do horizontal recentering."
6478 (interactive "P")
6479 (when (and gnus-auto-center-summary
6480 (not (eq gnus-auto-center-summary 'vertical)))
6481 (gnus-horizontal-recenter))
6482 (recenter n))
6483
6484(defun gnus-summary-recenter ()
6485 "Center point in the summary window.
6486If `gnus-auto-center-summary' is nil, or the article buffer isn't
6487displayed, no centering will be performed."
6488 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6489 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
16409b0b 6490 (interactive)
23f87bed
MB
6491 ;; The user has to want it.
6492 (when gnus-auto-center-summary
6493 (let* ((top (cond ((< (window-height) 4) 0)
6494 ((< (window-height) 7) 1)
6495 (t (if (numberp gnus-auto-center-summary)
6496 gnus-auto-center-summary
6497 2))))
6498 (height (1- (window-height)))
6499 (bottom (save-excursion (goto-char (point-max))
6500 (forward-line (- height))
6501 (point)))
6502 (window (get-buffer-window (current-buffer))))
eec82323
LMI
6503 (when (get-buffer-window gnus-article-buffer)
6504 ;; Only do recentering when the article buffer is displayed,
6505 ;; Set the window start to either `bottom', which is the biggest
6506 ;; possible valid number, or the second line from the top,
6507 ;; whichever is the least.
db7ebd73
MB
6508 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6509 (if (> bottom top-pos)
6510 ;; Keep the second line from the top visible
6511 (set-window-start window top-pos t)
6512 ;; Try to keep the bottom line visible; if it's partially
6513 ;; obscured, either scroll one more line to make it fully
6514 ;; visible, or revert to using TOP-POS.
6515 (save-excursion
6516 (goto-char (point-max))
6517 (forward-line -1)
6518 (let ((last-line-start (point)))
6519 (goto-char bottom)
6520 (set-window-start window (point) t)
6521 (when (not (pos-visible-in-window-p last-line-start window))
6522 (forward-line 1)
6523 (set-window-start window (min (point) top-pos) t)))))))
eec82323
LMI
6524 ;; Do horizontal recentering while we're at it.
6525 (when (and (get-buffer-window (current-buffer) t)
6526 (not (eq gnus-auto-center-summary 'vertical)))
6527 (let ((selected (selected-window)))
6528 (select-window (get-buffer-window (current-buffer) t))
6529 (gnus-summary-position-point)
6530 (gnus-horizontal-recenter)
6531 (select-window selected))))))
6532
6533(defun gnus-summary-jump-to-group (newsgroup)
6534 "Move point to NEWSGROUP in group mode buffer."
6535 ;; Keep update point of group mode buffer if visible.
6536 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6537 (save-window-excursion
6538 ;; Take care of tree window mode.
6539 (when (get-buffer-window gnus-group-buffer)
6540 (pop-to-buffer gnus-group-buffer))
6541 (gnus-group-jump-to-group newsgroup))
6542 (save-excursion
6543 ;; Take care of tree window mode.
6544 (if (get-buffer-window gnus-group-buffer)
6545 (pop-to-buffer gnus-group-buffer)
6546 (set-buffer gnus-group-buffer))
6547 (gnus-group-jump-to-group newsgroup))))
6548
6549;; This function returns a list of article numbers based on the
6550;; difference between the ranges of read articles in this group and
6551;; the range of active articles.
6552(defun gnus-list-of-unread-articles (group)
6553 (let* ((read (gnus-info-read (gnus-get-info group)))
6554 (active (or (gnus-active group) (gnus-activate-group group)))
6555 (last (cdr active))
4b70e299
MB
6556 (bottom (if gnus-newsgroup-maximum-articles
6557 (max (car active)
6558 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6559 (car active)))
eec82323
LMI
6560 first nlast unread)
6561 ;; If none are read, then all are unread.
6562 (if (not read)
11abff8e 6563 (setq first bottom)
eec82323
LMI
6564 ;; If the range of read articles is a single range, then the
6565 ;; first unread article is the article after the last read
6566 ;; article. Sounds logical, doesn't it?
16409b0b 6567 (if (and (not (listp (cdr read)))
11abff8e 6568 (or (< (car read) bottom)
16409b0b
GM
6569 (progn (setq read (list read))
6570 nil)))
11abff8e 6571 (setq first (max bottom (1+ (cdr read))))
eec82323
LMI
6572 ;; `read' is a list of ranges.
6573 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6574 (caar read)))
6575 1)
11abff8e 6576 (setq first bottom))
eec82323
LMI
6577 (while read
6578 (when first
6579 (while (< first nlast)
54506618
MB
6580 (setq unread (cons first unread)
6581 first (1+ first))))
eec82323
LMI
6582 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6583 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6584 (setq read (cdr read)))))
6585 ;; And add the last unread articles.
6586 (while (<= first last)
54506618
MB
6587 (setq unread (cons first unread)
6588 first (1+ first)))
eec82323 6589 ;; Return the list of unread articles.
6748645f 6590 (delq 0 (nreverse unread))))
eec82323
LMI
6591
6592(defun gnus-list-of-read-articles (group)
6593 "Return a list of unread, unticked and non-dormant articles."
6594 (let* ((info (gnus-get-info group))
6595 (marked (gnus-info-marks info))
6596 (active (gnus-active group)))
6597 (and info active
23f87bed
MB
6598 (gnus-list-range-difference
6599 (gnus-list-range-difference
6600 (gnus-sorted-complement
11abff8e 6601 (gnus-uncompress-range
4b70e299 6602 (if gnus-newsgroup-maximum-articles
11abff8e 6603 (cons (max (car active)
4b70e299
MB
6604 (- (cdr active)
6605 gnus-newsgroup-maximum-articles
6606 -1))
11abff8e
MB
6607 (cdr active))
6608 active))
23f87bed
MB
6609 (gnus-list-of-unread-articles group))
6610 (cdr (assq 'dormant marked)))
6611 (cdr (assq 'tick marked))))))
eec82323 6612
54506618
MB
6613;; This function returns a sequence of article numbers based on the
6614;; difference between the ranges of read articles in this group and
6615;; the range of active articles.
6616(defun gnus-sequence-of-unread-articles (group)
6617 (let* ((read (gnus-info-read (gnus-get-info group)))
6618 (active (or (gnus-active group) (gnus-activate-group group)))
6619 (last (cdr active))
4b70e299
MB
6620 (bottom (if gnus-newsgroup-maximum-articles
6621 (max (car active)
6622 (- last gnus-newsgroup-maximum-articles -1))
11abff8e 6623 (car active)))
54506618
MB
6624 first nlast unread)
6625 ;; If none are read, then all are unread.
6626 (if (not read)
11abff8e 6627 (setq first bottom)
54506618
MB
6628 ;; If the range of read articles is a single range, then the
6629 ;; first unread article is the article after the last read
6630 ;; article. Sounds logical, doesn't it?
6631 (if (and (not (listp (cdr read)))
11abff8e 6632 (or (< (car read) bottom)
54506618
MB
6633 (progn (setq read (list read))
6634 nil)))
11abff8e 6635 (setq first (max bottom (1+ (cdr read))))
54506618
MB
6636 ;; `read' is a list of ranges.
6637 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6638 (caar read)))
6639 1)
11abff8e 6640 (setq first bottom))
54506618
MB
6641 (while read
6642 (when first
6643 (push (cons first nlast) unread))
6644 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6645 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6646 (setq read (cdr read)))))
6647 ;; And add the last unread articles.
ba0226dd
MB
6648 (cond ((not (and first last))
6649 nil)
6650 ((< first last)
6651 (push (cons first last) unread))
6652 ((= first last)
6653 (push first unread)))
54506618
MB
6654 ;; Return the sequence of unread articles.
6655 (delq 0 (nreverse unread))))
6656
eec82323
LMI
6657;; Various summary commands
6658
6748645f
LMI
6659(defun gnus-summary-select-article-buffer ()
6660 "Reconfigure windows to show article buffer."
6661 (interactive)
6662 (if (not (gnus-buffer-live-p gnus-article-buffer))
6663 (error "There is no article buffer for this summary buffer")
6664 (gnus-configure-windows 'article)
6665 (select-window (get-buffer-window gnus-article-buffer))))
6666
eec82323
LMI
6667(defun gnus-summary-universal-argument (arg)
6668 "Perform any operation on all articles that are process/prefixed."
6669 (interactive "P")
eec82323
LMI
6670 (let ((articles (gnus-summary-work-articles arg))
6671 func article)
6672 (if (eq
6673 (setq
6674 func
6675 (key-binding
6676 (read-key-sequence
6677 (substitute-command-keys
16409b0b 6678 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
eec82323
LMI
6679 'undefined)
6680 (gnus-error 1 "Undefined key")
6681 (save-excursion
6682 (while articles
6683 (gnus-summary-goto-subject (setq article (pop articles)))
6684 (let (gnus-newsgroup-processable)
6685 (command-execute func))
6686 (gnus-summary-remove-process-mark article)))))
6687 (gnus-summary-position-point))
6688
6689(defun gnus-summary-toggle-truncation (&optional arg)
6690 "Toggle truncation of summary lines.
23f87bed 6691With ARG, turn line truncation on if ARG is positive."
eec82323
LMI
6692 (interactive "P")
6693 (setq truncate-lines
6694 (if (null arg) (not truncate-lines)
6695 (> (prefix-numeric-value arg) 0)))
6696 (redraw-display))
6697
23f87bed
MB
6698(defun gnus-summary-find-for-reselect ()
6699 "Return the number of an article to stay on across a reselect.
6700The current article is considered, then following articles, then previous
6701articles. An article is sought which is not cancelled and isn't a temporary
6702insertion from another group. If there's no such then return a dummy 0."
6703 (let (found)
6704 (dolist (rev '(nil t))
6705 (unless found ; don't demand the reverse list if we don't need it
6706 (let ((data (gnus-data-find-list
6707 (gnus-summary-article-number) (gnus-data-list rev))))
6708 (while (and data (not found))
6709 (if (and (< 0 (gnus-data-number (car data)))
6710 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6711 (setq found (gnus-data-number (car data))))
6712 (setq data (cdr data))))))
6713 (or found 0)))
6714
eec82323
LMI
6715(defun gnus-summary-reselect-current-group (&optional all rescan)
6716 "Exit and then reselect the current newsgroup.
6717The prefix argument ALL means to select all articles."
6718 (interactive "P")
eec82323
LMI
6719 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6720 (error "Ephemeral groups can't be reselected"))
23f87bed 6721 (let ((current-subject (gnus-summary-find-for-reselect))
eec82323
LMI
6722 (group gnus-newsgroup-name))
6723 (setq gnus-newsgroup-begin nil)
23f87bed 6724 (gnus-summary-exit nil 'leave-hidden)
eec82323
LMI
6725 ;; We have to adjust the point of group mode buffer because
6726 ;; point was moved to the next unread newsgroup by exiting.
6727 (gnus-summary-jump-to-group group)
6728 (when rescan
6729 (save-excursion
6730 (gnus-group-get-new-news-this-group 1)))
6731 (gnus-group-read-group all t)
6732 (gnus-summary-goto-subject current-subject nil t)))
6733
6734(defun gnus-summary-rescan-group (&optional all)
6735 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6736 (interactive "P")
6737 (gnus-summary-reselect-current-group all t))
6738
6739(defun gnus-summary-update-info (&optional non-destructive)
6740 (save-excursion
6741 (let ((group gnus-newsgroup-name))
6748645f
LMI
6742 (when group
6743 (when gnus-newsgroup-kill-headers
6744 (setq gnus-newsgroup-killed
6745 (gnus-compress-sequence
23f87bed
MB
6746 (gnus-sorted-union
6747 (gnus-list-range-intersection
6748 gnus-newsgroup-unselected gnus-newsgroup-killed)
6749 gnus-newsgroup-unreads)
6748645f
LMI
6750 t)))
6751 (unless (listp (cdr gnus-newsgroup-killed))
6752 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6753 (let ((headers gnus-newsgroup-headers))
6754 ;; Set the new ranges of read articles.
6755 (save-excursion
6756 (set-buffer gnus-group-buffer)
6757 (gnus-undo-force-boundary))
6758 (gnus-update-read-articles
23f87bed
MB
6759 group (gnus-sorted-union
6760 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6748645f
LMI
6761 ;; Set the current article marks.
6762 (let ((gnus-newsgroup-scored
6763 (if (and (not gnus-save-score)
6764 (not non-destructive))
6765 nil
6766 gnus-newsgroup-scored)))
6767 (save-excursion
6768 (gnus-update-marks)))
6769 ;; Do the cross-ref thing.
6770 (when gnus-use-cross-reference
6771 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6772 ;; Do not switch windows but change the buffer to work.
a8151ef7 6773 (set-buffer gnus-group-buffer)
6748645f
LMI
6774 (unless (gnus-ephemeral-group-p group)
6775 (gnus-group-update-group group)))))))
eec82323
LMI
6776
6777(defun gnus-summary-save-newsrc (&optional force)
6778 "Save the current number of read/marked articles in the dribble buffer.
6779The dribble buffer will then be saved.
6780If FORCE (the prefix), also save the .newsrc file(s)."
6781 (interactive "P")
6782 (gnus-summary-update-info t)
6783 (if force
6784 (gnus-save-newsrc-file)
6785 (gnus-dribble-save)))
6786
23f87bed 6787(defun gnus-summary-exit (&optional temporary leave-hidden)
eec82323 6788 "Exit reading current newsgroup, and then return to group selection mode.
16409b0b 6789`gnus-exit-group-hook' is called with no arguments if that value is non-nil."
eec82323
LMI
6790 (interactive)
6791 (gnus-set-global-variables)
16409b0b
GM
6792 (when (gnus-buffer-live-p gnus-article-buffer)
6793 (save-excursion
6794 (set-buffer gnus-article-buffer)
6795 (mm-destroy-parts gnus-article-mime-handles)
6796 ;; Set it to nil for safety reason.
6797 (setq gnus-article-mime-handle-alist nil)
6798 (setq gnus-article-mime-handles nil)))
eec82323 6799 (gnus-kill-save-kill-buffer)
6748645f 6800 (gnus-async-halt-prefetch)
eec82323
LMI
6801 (let* ((group gnus-newsgroup-name)
6802 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
23f87bed 6803 (gnus-group-is-exiting-p t)
eec82323 6804 (mode major-mode)
23f87bed 6805 (group-point nil)
eec82323 6806 (buf (current-buffer)))
16409b0b
GM
6807 (unless quit-config
6808 ;; Do adaptive scoring, and possibly save score files.
6809 (when gnus-newsgroup-adaptive
6810 (gnus-score-adaptive))
6811 (when gnus-use-scoring
6812 (gnus-score-save)))
6748645f 6813 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
6814 ;; If we have several article buffers, we kill them at exit.
6815 (unless gnus-single-article-buffer
6816 (gnus-kill-buffer gnus-original-article-buffer)
6817 (setq gnus-article-current nil))
6818 (when gnus-use-cache
6819 (gnus-cache-possibly-remove-articles)
6820 (gnus-cache-save-buffers))
6821 (gnus-async-prefetch-remove-group group)
6822 (when gnus-suppress-duplicates
6823 (gnus-dup-enter-articles))
6824 (when gnus-use-trees
6825 (gnus-tree-close group))
16409b0b
GM
6826 (when gnus-use-cache
6827 (gnus-cache-write-active))
6748645f
LMI
6828 ;; Remove entries for this group.
6829 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
6830 ;; Make all changes in this group permanent.
6831 (unless quit-config
6748645f 6832 (gnus-run-hooks 'gnus-exit-group-hook)
16409b0b 6833 (gnus-summary-update-info))
eec82323
LMI
6834 (gnus-close-group group)
6835 ;; Make sure where we were, and go to next newsgroup.
6836 (set-buffer gnus-group-buffer)
6837 (unless quit-config
6838 (gnus-group-jump-to-group group))
6748645f
LMI
6839 (gnus-run-hooks 'gnus-summary-exit-hook)
6840 (unless (or quit-config
6841 ;; If this group has disappeared from the summary
6842 ;; buffer, don't skip forwards.
6843 (not (string= group (gnus-group-group-name))))
eec82323 6844 (gnus-group-next-unread-group 1))
a8151ef7 6845 (setq group-point (point))
eec82323
LMI
6846 (if temporary
6847 nil ;Nothing to do.
6848 ;; If we have several article buffers, we kill them at exit.
6849 (unless gnus-single-article-buffer
6850 (gnus-kill-buffer gnus-article-buffer)
6851 (gnus-kill-buffer gnus-original-article-buffer)
6852 (setq gnus-article-current nil))
6853 (set-buffer buf)
6854 (if (not gnus-kill-summary-on-exit)
23f87bed
MB
6855 (progn
6856 (gnus-deaden-summary)
6857 (setq mode nil))
eec82323
LMI
6858 ;; We set all buffer-local variables to nil. It is unclear why
6859 ;; this is needed, but if we don't, buffer-local variables are
6860 ;; not garbage-collected, it seems. This would the lead to en
6861 ;; ever-growing Emacs.
6862 (gnus-summary-clear-local-variables)
23f87bed
MB
6863 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6864 (gnus-summary-clear-local-variables))
eec82323
LMI
6865 (when (get-buffer gnus-article-buffer)
6866 (bury-buffer gnus-article-buffer))
6867 ;; We clear the global counterparts of the buffer-local
6868 ;; variables as well, just to be on the safe side.
6869 (set-buffer gnus-group-buffer)
6870 (gnus-summary-clear-local-variables)
23f87bed
MB
6871 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6872 (gnus-summary-clear-local-variables))
eec82323
LMI
6873 ;; Return to group mode buffer.
6874 (when (eq mode 'gnus-summary-mode)
6875 (gnus-kill-buffer buf)))
6876 (setq gnus-current-select-method gnus-select-method)
d61c212b
SM
6877 (set-buffer gnus-group-buffer)
6878 (if quit-config
6879 (gnus-handle-ephemeral-exit quit-config)
4e90f2b9
SM
6880 (goto-char group-point)
6881 ;; If gnus-group-buffer is already displayed, make sure we also move
6882 ;; the cursor in the window that displays it.
6883 (let ((win (get-buffer-window (current-buffer) 0)))
6884 (if win (set-window-point win (point))))
d61c212b 6885 (unless leave-hidden
4e90f2b9 6886 (gnus-configure-windows 'group 'force)))
6748645f 6887 ;; Clear the current group name.
eec82323
LMI
6888 (unless quit-config
6889 (setq gnus-newsgroup-name nil)))))
6890
6891(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6892(defun gnus-summary-exit-no-update (&optional no-questions)
6893 "Quit reading current newsgroup without updating read article info."
6894 (interactive)
eec82323 6895 (let* ((group gnus-newsgroup-name)
23f87bed
MB
6896 (gnus-group-is-exiting-p t)
6897 (gnus-group-is-exiting-without-update-p t)
eec82323
LMI
6898 (quit-config (gnus-group-quit-config group)))
6899 (when (or no-questions
6900 gnus-expert-user
6901 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f 6902 (gnus-async-halt-prefetch)
23f87bed 6903 (run-hooks 'gnus-summary-prepare-exit-hook)
16409b0b
GM
6904 (when (gnus-buffer-live-p gnus-article-buffer)
6905 (save-excursion
6906 (set-buffer gnus-article-buffer)
6907 (mm-destroy-parts gnus-article-mime-handles)
6908 ;; Set it to nil for safety reason.
6909 (setq gnus-article-mime-handle-alist nil)
6910 (setq gnus-article-mime-handles nil)))
eec82323
LMI
6911 ;; If we have several article buffers, we kill them at exit.
6912 (unless gnus-single-article-buffer
6913 (gnus-kill-buffer gnus-article-buffer)
6914 (gnus-kill-buffer gnus-original-article-buffer)
6915 (setq gnus-article-current nil))
6916 (if (not gnus-kill-summary-on-exit)
6917 (gnus-deaden-summary)
6918 (gnus-close-group group)
6919 (gnus-summary-clear-local-variables)
23f87bed
MB
6920 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6921 (gnus-summary-clear-local-variables))
eec82323
LMI
6922 (set-buffer gnus-group-buffer)
6923 (gnus-summary-clear-local-variables)
23f87bed
MB
6924 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6925 (gnus-summary-clear-local-variables))
6926 (gnus-kill-buffer gnus-summary-buffer))
eec82323
LMI
6927 (unless gnus-single-article-buffer
6928 (setq gnus-article-current nil))
6929 (when gnus-use-trees
6930 (gnus-tree-close group))
6931 (gnus-async-prefetch-remove-group group)
6932 (when (get-buffer gnus-article-buffer)
6933 (bury-buffer gnus-article-buffer))
6934 ;; Return to the group buffer.
6935 (gnus-configure-windows 'group 'force)
6936 ;; Clear the current group name.
6937 (setq gnus-newsgroup-name nil)
23f87bed
MB
6938 (unless (gnus-ephemeral-group-p group)
6939 (gnus-group-update-group group))
eec82323
LMI
6940 (when (equal (gnus-group-group-name) group)
6941 (gnus-group-next-unread-group 1))
6942 (when quit-config
23f87bed 6943 (gnus-handle-ephemeral-exit quit-config)))))
eec82323
LMI
6944
6945(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
6946 "Handle movement when leaving an ephemeral group.
6947The state which existed when entering the ephemeral is reset."
eec82323
LMI
6948 (if (not (buffer-name (car quit-config)))
6949 (gnus-configure-windows 'group 'force)
6950 (set-buffer (car quit-config))
6951 (cond ((eq major-mode 'gnus-summary-mode)
23f87bed
MB
6952 (gnus-set-global-variables))
6953 ((eq major-mode 'gnus-article-mode)
6954 (save-excursion
6955 ;; The `gnus-summary-buffer' variable may point
6956 ;; to the old summary buffer when using a single
6957 ;; article buffer.
6958 (unless (gnus-buffer-live-p gnus-summary-buffer)
6959 (set-buffer gnus-group-buffer))
6960 (set-buffer gnus-summary-buffer)
6961 (gnus-set-global-variables))))
eec82323 6962 (if (or (eq (cdr quit-config) 'article)
23f87bed
MB
6963 (eq (cdr quit-config) 'pick))
6964 (progn
6965 ;; The current article may be from the ephemeral group
6966 ;; thus it is best that we reload this article
6967 ;;
6968 ;; If we're exiting from a large digest, this can be
6969 ;; extremely slow. So, it's better not to reload it. -- jh.
6970 ;;(gnus-summary-show-article)
6971 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6972 (gnus-configure-windows 'pick 'force)
6973 (gnus-configure-windows (cdr quit-config) 'force)))
eec82323
LMI
6974 (gnus-configure-windows (cdr quit-config) 'force))
6975 (when (eq major-mode 'gnus-summary-mode)
6976 (gnus-summary-next-subject 1 nil t)
6977 (gnus-summary-recenter)
6978 (gnus-summary-position-point))))
6979
6980;;; Dead summaries.
6981
6982(defvar gnus-dead-summary-mode-map nil)
6983
6984(unless gnus-dead-summary-mode-map
6985 (setq gnus-dead-summary-mode-map (make-keymap))
6986 (suppress-keymap gnus-dead-summary-mode-map)
6987 (substitute-key-definition
6988 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
23f87bed
MB
6989 (dolist (key '("\C-d" "\r" "\177" [delete]))
6990 (define-key gnus-dead-summary-mode-map
6991 key 'gnus-summary-wake-up-the-dead))
6992 (dolist (key '("q" "Q"))
6993 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
eec82323
LMI
6994
6995(defvar gnus-dead-summary-mode nil
6996 "Minor mode for Gnus summary buffers.")
6997
6998(defun gnus-dead-summary-mode (&optional arg)
6999 "Minor mode for Gnus summary buffers."
7000 (interactive "P")
7001 (when (eq major-mode 'gnus-summary-mode)
7002 (make-local-variable 'gnus-dead-summary-mode)
7003 (setq gnus-dead-summary-mode
7004 (if (null arg) (not gnus-dead-summary-mode)
7005 (> (prefix-numeric-value arg) 0)))
7006 (when gnus-dead-summary-mode
a8151ef7
LMI
7007 (gnus-add-minor-mode
7008 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
eec82323
LMI
7009
7010(defun gnus-deaden-summary ()
7011 "Make the current summary buffer into a dead summary buffer."
7012 ;; Kill any previous dead summary buffer.
7013 (when (and gnus-dead-summary
7014 (buffer-name gnus-dead-summary))
7015 (save-excursion
7016 (set-buffer gnus-dead-summary)
7017 (when gnus-dead-summary-mode
7018 (kill-buffer (current-buffer)))))
7019 ;; Make this the current dead summary.
7020 (setq gnus-dead-summary (current-buffer))
7021 (gnus-dead-summary-mode 1)
7022 (let ((name (buffer-name)))
7023 (when (string-match "Summary" name)
7024 (rename-buffer
7025 (concat (substring name 0 (match-beginning 0)) "Dead "
7026 (substring name (match-beginning 0)))
16409b0b
GM
7027 t)
7028 (bury-buffer))))
eec82323
LMI
7029
7030(defun gnus-kill-or-deaden-summary (buffer)
7031 "Kill or deaden the summary BUFFER."
6748645f
LMI
7032 (save-excursion
7033 (when (and (buffer-name buffer)
7034 (not gnus-single-article-buffer))
7035 (save-excursion
7036 (set-buffer buffer)
7037 (gnus-kill-buffer gnus-article-buffer)
7038 (gnus-kill-buffer gnus-original-article-buffer)))
23f87bed
MB
7039 (cond
7040 ;; Kill the buffer.
7041 (gnus-kill-summary-on-exit
7042 (when (and gnus-use-trees
7043 (gnus-buffer-exists-p buffer))
7044 (save-excursion
7045 (set-buffer buffer)
7046 (gnus-tree-close gnus-newsgroup-name)))
7047 (gnus-kill-buffer buffer))
7048 ;; Deaden the buffer.
7049 ((gnus-buffer-exists-p buffer)
7050 (save-excursion
7051 (set-buffer buffer)
7052 (gnus-deaden-summary))))))
eec82323
LMI
7053
7054(defun gnus-summary-wake-up-the-dead (&rest args)
7055 "Wake up the dead summary buffer."
7056 (interactive)
7057 (gnus-dead-summary-mode -1)
7058 (let ((name (buffer-name)))
7059 (when (string-match "Dead " name)
7060 (rename-buffer
7061 (concat (substring name 0 (match-beginning 0))
7062 (substring name (match-end 0)))
7063 t)))
7064 (gnus-message 3 "This dead summary is now alive again"))
7065
7066;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7067(defun gnus-summary-fetch-faq (&optional faq-dir)
7068 "Fetch the FAQ for the current group.
7069If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7070in."
7071 (interactive
7072 (list
7073 (when current-prefix-arg
7074 (completing-read
8f688cb0 7075 "FAQ dir: " (and (listp gnus-group-faq-directory)
a8151ef7
LMI
7076 (mapcar (lambda (file) (list file))
7077 gnus-group-faq-directory))))))
eec82323
LMI
7078 (let (gnus-faq-buffer)
7079 (when (setq gnus-faq-buffer
7080 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7081 (gnus-configure-windows 'summary-faq))))
7082
7083;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7084(defun gnus-summary-describe-group (&optional force)
7085 "Describe the current newsgroup."
7086 (interactive "P")
7087 (gnus-group-describe-group force gnus-newsgroup-name))
7088
7089(defun gnus-summary-describe-briefly ()
7090 "Describe summary mode commands briefly."
7091 (interactive)
16409b0b 7092 (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
7093
7094;; Walking around group mode buffer from summary mode.
7095
7096(defun gnus-summary-next-group (&optional no-article target-group backward)
7097 "Exit current newsgroup and then select next unread newsgroup.
7098If prefix argument NO-ARTICLE is non-nil, no article is selected
23f87bed 7099initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
eec82323
LMI
7100previous group instead."
7101 (interactive "P")
eec82323
LMI
7102 ;; Stop pre-fetching.
7103 (gnus-async-halt-prefetch)
7104 (let ((current-group gnus-newsgroup-name)
7105 (current-buffer (current-buffer))
7106 entered)
7107 ;; First we semi-exit this group to update Xrefs and all variables.
7108 ;; We can't do a real exit, because the window conf must remain
7109 ;; the same in case the user is prompted for info, and we don't
7110 ;; want the window conf to change before that...
7111 (gnus-summary-exit t)
7112 (while (not entered)
7113 ;; Then we find what group we are supposed to enter.
7114 (set-buffer gnus-group-buffer)
7115 (gnus-group-jump-to-group current-group)
7116 (setq target-group
7117 (or target-group
7118 (if (eq gnus-keep-same-level 'best)
7119 (gnus-summary-best-group gnus-newsgroup-name)
7120 (gnus-summary-search-group backward gnus-keep-same-level))))
7121 (if (not target-group)
7122 ;; There are no further groups, so we return to the group
7123 ;; buffer.
7124 (progn
7125 (gnus-message 5 "Returning to the group buffer")
7126 (setq entered t)
7127 (when (gnus-buffer-live-p current-buffer)
7128 (set-buffer current-buffer)
7129 (gnus-summary-exit))
6748645f 7130 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
7131 ;; We try to enter the target group.
7132 (gnus-group-jump-to-group target-group)
7133 (let ((unreads (gnus-group-group-unread)))
7134 (if (and (or (eq t unreads)
7135 (and unreads (not (zerop unreads))))
23f87bed
MB
7136 (gnus-summary-read-group
7137 target-group nil no-article
7138 (and (buffer-name current-buffer) current-buffer)
7139 nil backward))
eec82323
LMI
7140 (setq entered t)
7141 (setq current-group target-group
7142 target-group nil)))))))
7143
7144(defun gnus-summary-prev-group (&optional no-article)
7145 "Exit current newsgroup and then select previous unread newsgroup.
7146If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7147 (interactive "P")
7148 (gnus-summary-next-group no-article nil t))
7149
7150;; Walking around summary lines.
7151
23f87bed
MB
7152(defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7153 "Go to the first subject satisfying any non-nil constraint.
7154If UNREAD is non-nil, the article should be unread.
7155If UNDOWNLOADED is non-nil, the article should be undownloaded.
7156If UNSEEN is non-nil, the article should be unseen.
7157Returns the article selected or nil if there are no matching articles."
eec82323 7158 (interactive "P")
23f87bed
MB
7159 (cond
7160 ;; Empty summary.
7161 ((null gnus-newsgroup-data)
7162 (gnus-message 3 "No articles in the group")
7163 nil)
7164 ;; Pick the first article.
7165 ((not (or unread undownloaded unseen))
7166 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7167 (gnus-data-number (car gnus-newsgroup-data)))
7168 ;; Find the first unread article.
7169 (t
7170 (let ((data gnus-newsgroup-data))
7171 (while (and data
7172 (let ((num (gnus-data-number (car data))))
7173 (or (memq num gnus-newsgroup-unfetched)
7174 (not (or (and unread
7175 (memq num gnus-newsgroup-unreads))
7176 (and undownloaded
7177 (memq num gnus-newsgroup-undownloaded))
7178 (and unseen
7179 (memq num gnus-newsgroup-unseen)))))))
7180 (setq data (cdr data)))
7181 (prog1
7182 (if data
7183 (progn
7184 (goto-char (gnus-data-pos (car data)))
7185 (gnus-data-number (car data)))
7186 (gnus-message 3 "No more%s articles"
7187 (let* ((r (when unread " unread"))
7188 (d (when undownloaded " undownloaded"))
7189 (s (when unseen " unseen"))
7190 (l (delq nil (list r d s))))
7191 (cond ((= 3 (length l))
7192 (concat r "," d ", or" s))
7193 ((= 2 (length l))
7194 (concat (car l) ", or" (cadr l)))
7195 ((= 1 (length l))
7196 (car l))
7197 (t
7198 ""))))
7199 nil
7200 )
7201 (gnus-summary-position-point))))))
eec82323
LMI
7202
7203(defun gnus-summary-next-subject (n &optional unread dont-display)
7204 "Go to next N'th summary line.
7205If N is negative, go to the previous N'th subject line.
7206If UNREAD is non-nil, only unread articles are selected.
7207The difference between N and the actual number of steps taken is
7208returned."
7209 (interactive "p")
7210 (let ((backward (< n 0))
7211 (n (abs n)))
7212 (while (and (> n 0)
7213 (if backward
7214 (gnus-summary-find-prev unread)
7215 (gnus-summary-find-next unread)))
16409b0b
GM
7216 (unless (zerop (setq n (1- n)))
7217 (gnus-summary-show-thread)))
eec82323
LMI
7218 (when (/= 0 n)
7219 (gnus-message 7 "No more%s articles"
7220 (if unread " unread" "")))
7221 (unless dont-display
7222 (gnus-summary-recenter)
7223 (gnus-summary-position-point))
7224 n))
7225
7226(defun gnus-summary-next-unread-subject (n)
7227 "Go to next N'th unread summary line."
7228 (interactive "p")
7229 (gnus-summary-next-subject n t))
7230
7231(defun gnus-summary-prev-subject (n &optional unread)
7232 "Go to previous N'th summary line.
7233If optional argument UNREAD is non-nil, only unread article is selected."
7234 (interactive "p")
7235 (gnus-summary-next-subject (- n) unread))
7236
7237(defun gnus-summary-prev-unread-subject (n)
7238 "Go to previous N'th unread summary line."
7239 (interactive "p")
7240 (gnus-summary-next-subject (- n) t))
7241
23f87bed
MB
7242(defun gnus-summary-goto-subjects (articles)
7243 "Insert the subject header for ARTICLES in the current buffer."
7244 (save-excursion
7245 (dolist (article articles)
7246 (gnus-summary-goto-subject article t)))
7247 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7248 (gnus-summary-position-point))
132cf96d 7249
eec82323
LMI
7250(defun gnus-summary-goto-subject (article &optional force silent)
7251 "Go the subject line of ARTICLE.
7252If FORCE, also allow jumping to articles not currently shown."
7253 (interactive "nArticle number: ")
23f87bed
MB
7254 (unless (numberp article)
7255 (error "Article %s is not a number" article))
eec82323
LMI
7256 (let ((b (point))
7257 (data (gnus-data-find article)))
7258 ;; We read in the article if we have to.
7259 (and (not data)
7260 force
6748645f
LMI
7261 (gnus-summary-insert-subject
7262 article
7263 (if (or (numberp force) (vectorp force)) force)
7264 t)
eec82323
LMI
7265 (setq data (gnus-data-find article)))
7266 (goto-char b)
7267 (if (not data)
7268 (progn
7269 (unless silent
7270 (gnus-message 3 "Can't find article %d" article))
7271 nil)
23f87bed
MB
7272 (let ((pt (gnus-data-pos data)))
7273 (goto-char pt)
7274 (gnus-summary-set-article-display-arrow pt))
6748645f 7275 (gnus-summary-position-point)
eec82323
LMI
7276 article)))
7277
7278;; Walking around summary lines with displaying articles.
7279
7280(defun gnus-summary-expand-window (&optional arg)
7281 "Make the summary buffer take up the entire Emacs frame.
7282Given a prefix, will force an `article' buffer configuration."
7283 (interactive "P")
eec82323
LMI
7284 (if arg
7285 (gnus-configure-windows 'article 'force)
7286 (gnus-configure-windows 'summary 'force)))
7287
7288(defun gnus-summary-display-article (article &optional all-header)
7289 "Display ARTICLE in article buffer."
d4dfaa19
DL
7290 (when (gnus-buffer-live-p gnus-article-buffer)
7291 (with-current-buffer gnus-article-buffer
87545352 7292 (mm-enable-multibyte)))
eec82323 7293 (gnus-set-global-variables)
23f87bed
MB
7294 (when (gnus-buffer-live-p gnus-article-buffer)
7295 (with-current-buffer gnus-article-buffer
7296 (setq gnus-article-charset gnus-newsgroup-charset)
7297 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7298 (mm-enable-multibyte)))
eec82323
LMI
7299 (if (null article)
7300 nil
7301 (prog1
7302 (if gnus-summary-display-article-function
7303 (funcall gnus-summary-display-article-function article all-header)
7304 (gnus-article-prepare article all-header))
6748645f 7305 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
7306 (when (and gnus-current-article
7307 (not (zerop gnus-current-article)))
7308 (gnus-summary-goto-subject gnus-current-article))
7309 (gnus-summary-recenter)
7310 (when (and gnus-use-trees gnus-show-threads)
7311 (gnus-possibly-generate-tree article)
7312 (gnus-highlight-selected-tree article))
7313 ;; Successfully display article.
7314 (gnus-article-set-window-start
7315 (cdr (assq article gnus-newsgroup-bookmarks))))))
7316
7317(defun gnus-summary-select-article (&optional all-headers force pseudo article)
7318 "Select the current article.
7319If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7320non-nil, the article will be re-fetched even if it already present in
7321the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7322be displayed."
7323 ;; Make sure we are in the summary buffer to work around bbdb bug.
7324 (unless (eq major-mode 'gnus-summary-mode)
7325 (set-buffer gnus-summary-buffer))
7326 (let ((article (or article (gnus-summary-article-number)))
f0529b5b 7327 (all-headers (not (not all-headers))) ;Must be t or nil.
16409b0b 7328 gnus-summary-display-article-function)
eec82323
LMI
7329 (and (not pseudo)
7330 (gnus-summary-article-pseudo-p article)
a8151ef7 7331 (error "This is a pseudo-article"))
16409b0b
GM
7332 (save-excursion
7333 (set-buffer gnus-summary-buffer)
7334 (if (or (and gnus-single-article-buffer
7335 (or (null gnus-current-article)
7336 (null gnus-article-current)
7337 (null (get-buffer gnus-article-buffer))
7338 (not (eq article (cdr gnus-article-current)))
7339 (not (equal (car gnus-article-current)
7340 gnus-newsgroup-name))))
7341 (and (not gnus-single-article-buffer)
7342 (or (null gnus-current-article)
7343 (not (eq gnus-current-article article))))
7344 force)
7345 ;; The requested article is different from the current article.
7346 (progn
16409b0b
GM
7347 (gnus-summary-display-article article all-headers)
7348 (when (gnus-buffer-live-p gnus-article-buffer)
23f87bed 7349 (with-current-buffer gnus-article-buffer
16409b0b 7350 (if (not gnus-article-decoded-p) ;; a local variable
87545352 7351 (mm-disable-multibyte))))
16409b0b
GM
7352 (gnus-article-set-window-start
7353 (cdr (assq article gnus-newsgroup-bookmarks)))
7354 article)
16409b0b 7355 'old))))
eec82323 7356
23f87bed
MB
7357(defun gnus-summary-force-verify-and-decrypt ()
7358 "Display buttons for signed/encrypted parts and verify/decrypt them."
7359 (interactive)
7360 (let ((mm-verify-option 'known)
7361 (mm-decrypt-option 'known)
7362 (gnus-article-emulate-mime t)
7363 (gnus-buttonized-mime-types (append (list "multipart/signed"
7364 "multipart/encrypted")
7365 gnus-buttonized-mime-types)))
7366 (gnus-summary-select-article nil 'force)))
7367
eec82323
LMI
7368(defun gnus-summary-set-current-mark (&optional current-mark)
7369 "Obsolete function."
7370 nil)
7371
7372(defun gnus-summary-next-article (&optional unread subject backward push)
7373 "Select the next article.
7374If UNREAD, only unread articles are selected.
7375If SUBJECT, only articles with SUBJECT are selected.
7376If BACKWARD, the previous article is selected instead of the next."
7377 (interactive "P")
11e95b02
MB
7378 ;; Make sure we are in the summary buffer.
7379 (unless (eq major-mode 'gnus-summary-mode)
7380 (set-buffer gnus-summary-buffer))
eec82323
LMI
7381 (cond
7382 ;; Is there such an article?
7383 ((and (gnus-summary-search-forward unread subject backward)
7384 (or (gnus-summary-display-article (gnus-summary-article-number))
7385 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7386 (gnus-summary-position-point))
7387 ;; If not, we try the first unread, if that is wanted.
7388 ((and subject
7389 gnus-auto-select-same
7390 (gnus-summary-first-unread-article))
7391 (gnus-summary-position-point)
7392 (gnus-message 6 "Wrapped"))
7393 ;; Try to get next/previous article not displayed in this group.
7394 ((and gnus-auto-extend-newsgroup
7395 (not unread) (not subject))
7396 (gnus-summary-goto-article
7397 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 7398 nil (count-lines (point-min) (point))))
eec82323
LMI
7399 ;; Go to next/previous group.
7400 (t
7401 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7402 (gnus-summary-jump-to-group gnus-newsgroup-name))
7403 (let ((cmd last-command-char)
7404 (point
7405 (save-excursion
7406 (set-buffer gnus-group-buffer)
7407 (point)))
7408 (group
7409 (if (eq gnus-keep-same-level 'best)
7410 (gnus-summary-best-group gnus-newsgroup-name)
7411 (gnus-summary-search-group backward gnus-keep-same-level))))
7412 ;; For some reason, the group window gets selected. We change
7413 ;; it back.
7414 (select-window (get-buffer-window (current-buffer)))
7415 ;; Select next unread newsgroup automagically.
7416 (cond
7417 ((or (not gnus-auto-select-next)
7418 (not cmd))
7419 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7420 ((or (eq gnus-auto-select-next 'quietly)
7421 (and (eq gnus-auto-select-next 'slightly-quietly)
7422 push)
7423 (and (eq gnus-auto-select-next 'almost-quietly)
7424 (gnus-summary-last-article-p)))
7425 ;; Select quietly.
7426 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7427 (gnus-summary-exit)
7428 (gnus-message 7 "No more%s articles (%s)..."
7429 (if unread " unread" "")
7430 (if group (concat "selecting " group)
7431 "exiting"))
7432 (gnus-summary-next-group nil group backward)))
7433 (t
7434 (when (gnus-key-press-event-p last-input-event)
7435 (gnus-summary-walk-group-buffer
7436 gnus-newsgroup-name cmd unread backward point))))))))
7437
7438(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7439 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7440 (?\C-p (gnus-group-prev-unread-group 1))))
7441 (cursor-in-echo-area t)
23f87bed 7442 keve key group ended prompt)
eec82323
LMI
7443 (save-excursion
7444 (set-buffer gnus-group-buffer)
7445 (goto-char start)
7446 (setq group
7447 (if (eq gnus-keep-same-level 'best)
7448 (gnus-summary-best-group gnus-newsgroup-name)
7449 (gnus-summary-search-group backward gnus-keep-same-level))))
7450 (while (not ended)
23f87bed
MB
7451 (setq prompt
7452 (format
7453 "No more%s articles%s " (if unread " unread" "")
7454 (if (and group
7455 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7456 (format " (Type %s for %s [%s])"
91472578
MB
7457 (single-key-description cmd)
7458 (gnus-group-decoded-name group)
23f87bed
MB
7459 (car (gnus-gethash group gnus-newsrc-hashtb)))
7460 (format " (Type %s to exit %s)"
7461 (single-key-description cmd)
91472578 7462 (gnus-group-decoded-name gnus-newsgroup-name)))))
eec82323 7463 ;; Confirm auto selection.
23f87bed
MB
7464 (setq key (car (setq keve (gnus-read-event-char prompt)))
7465 ended t)
eec82323
LMI
7466 (cond
7467 ((assq key keystrokes)
7468 (let ((obuf (current-buffer)))
7469 (switch-to-buffer gnus-group-buffer)
7470 (when group
7471 (gnus-group-jump-to-group group))
7472 (eval (cadr (assq key keystrokes)))
7473 (setq group (gnus-group-group-name))
7474 (switch-to-buffer obuf))
7475 (setq ended nil))
7476 ((equal key cmd)
7477 (if (or (not group)
7478 (gnus-ephemeral-group-p gnus-newsgroup-name))
7479 (gnus-summary-exit)
7480 (gnus-summary-next-group nil group backward)))
7481 (t
7482 (push (cdr keve) unread-command-events))))))
7483
7484(defun gnus-summary-next-unread-article ()
7485 "Select unread article after current one."
7486 (interactive)
7487 (gnus-summary-next-article
7488 (or (not (eq gnus-summary-goto-unread 'never))
7489 (gnus-summary-last-article-p (gnus-summary-article-number)))
7490 (and gnus-auto-select-same
7491 (gnus-summary-article-subject))))
7492
7493(defun gnus-summary-prev-article (&optional unread subject)
7494 "Select the article after the current one.
7495If UNREAD is non-nil, only unread articles are selected."
7496 (interactive "P")
7497 (gnus-summary-next-article unread subject t))
7498
7499(defun gnus-summary-prev-unread-article ()
7500 "Select unread article before current one."
7501 (interactive)
7502 (gnus-summary-prev-article
7503 (or (not (eq gnus-summary-goto-unread 'never))
7504 (gnus-summary-first-article-p (gnus-summary-article-number)))
7505 (and gnus-auto-select-same
7506 (gnus-summary-article-subject))))
7507
23f87bed 7508(defun gnus-summary-next-page (&optional lines circular stop)
eec82323
LMI
7509 "Show next page of the selected article.
7510If at the end of the current article, select the next article.
7511LINES says how many lines should be scrolled up.
7512
7513If CIRCULAR is non-nil, go to the start of the article instead of
7514selecting the next article when reaching the end of the current
23f87bed
MB
7515article.
7516
7517If STOP is non-nil, just stop when reaching the end of the message.
7518
7519Also see the variable `gnus-article-skip-boring'."
eec82323
LMI
7520 (interactive "P")
7521 (setq gnus-summary-buffer (current-buffer))
7522 (gnus-set-global-variables)
7523 (let ((article (gnus-summary-article-number))
7524 (article-window (get-buffer-window gnus-article-buffer t))
7525 endp)
6748645f
LMI
7526 ;; If the buffer is empty, we have no article.
7527 (unless article
7528 (error "No article to select"))
eec82323
LMI
7529 (gnus-configure-windows 'article)
7530 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7531 (if (and (eq gnus-summary-goto-unread 'never)
7532 (not (gnus-summary-last-article-p article)))
7533 (gnus-summary-next-article)
7534 (gnus-summary-next-unread-article))
7535 (if (or (null gnus-current-article)
7536 (null gnus-article-current)
7537 (/= article (cdr gnus-article-current))
7538 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7539 ;; Selected subject is different from current article's.
7540 (gnus-summary-display-article article)
7541 (when article-window
7542 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed
MB
7543 (setq endp (or (gnus-article-next-page lines)
7544 (gnus-article-only-boring-p))))
eec82323 7545 (when endp
23f87bed
MB
7546 (cond (stop
7547 (gnus-message 3 "End of message"))
7548 (circular
eec82323
LMI
7549 (gnus-summary-beginning-of-article))
7550 (lines
7551 (gnus-message 3 "End of message"))
7552 ((null lines)
7553 (if (and (eq gnus-summary-goto-unread 'never)
7554 (not (gnus-summary-last-article-p article)))
7555 (gnus-summary-next-article)
7556 (gnus-summary-next-unread-article))))))))
7557 (gnus-summary-recenter)
7558 (gnus-summary-position-point)))
7559
7560(defun gnus-summary-prev-page (&optional lines move)
7561 "Show previous page of selected article.
7562Argument LINES specifies lines to be scrolled down.
7563If MOVE, move to the previous unread article if point is at
7564the beginning of the buffer."
7565 (interactive "P")
eec82323
LMI
7566 (let ((article (gnus-summary-article-number))
7567 (article-window (get-buffer-window gnus-article-buffer t))
7568 endp)
7569 (gnus-configure-windows 'article)
7570 (if (or (null gnus-current-article)
7571 (null gnus-article-current)
7572 (/= article (cdr gnus-article-current))
7573 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7574 ;; Selected subject is different from current article's.
7575 (gnus-summary-display-article article)
7576 (gnus-summary-recenter)
7577 (when article-window
7578 (gnus-eval-in-buffer-window gnus-article-buffer
7579 (setq endp (gnus-article-prev-page lines)))
7580 (when (and move endp)
7581 (cond (lines
7582 (gnus-message 3 "Beginning of message"))
7583 ((null lines)
7584 (if (and (eq gnus-summary-goto-unread 'never)
7585 (not (gnus-summary-first-article-p article)))
7586 (gnus-summary-prev-article)
7587 (gnus-summary-prev-unread-article))))))))
7588 (gnus-summary-position-point))
7589
7590(defun gnus-summary-prev-page-or-article (&optional lines)
7591 "Show previous page of selected article.
7592Argument LINES specifies lines to be scrolled down.
7593If at the beginning of the article, go to the next article."
7594 (interactive "P")
7595 (gnus-summary-prev-page lines t))
7596
7597(defun gnus-summary-scroll-up (lines)
7598 "Scroll up (or down) one line current article.
7599Argument LINES specifies lines to be scrolled up (or down if negative)."
7600 (interactive "p")
eec82323
LMI
7601 (gnus-configure-windows 'article)
7602 (gnus-summary-show-thread)
7603 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7604 (gnus-eval-in-buffer-window gnus-article-buffer
7605 (cond ((> lines 0)
7606 (when (gnus-article-next-page lines)
7607 (gnus-message 3 "End of message")))
7608 ((< lines 0)
7609 (gnus-article-prev-page (- lines))))))
7610 (gnus-summary-recenter)
7611 (gnus-summary-position-point))
7612
6748645f
LMI
7613(defun gnus-summary-scroll-down (lines)
7614 "Scroll down (or up) one line current article.
7615Argument LINES specifies lines to be scrolled down (or up if negative)."
7616 (interactive "p")
7617 (gnus-summary-scroll-up (- lines)))
7618
eec82323
LMI
7619(defun gnus-summary-next-same-subject ()
7620 "Select next article which has the same subject as current one."
7621 (interactive)
eec82323
LMI
7622 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7623
7624(defun gnus-summary-prev-same-subject ()
7625 "Select previous article which has the same subject as current one."
7626 (interactive)
eec82323
LMI
7627 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7628
7629(defun gnus-summary-next-unread-same-subject ()
7630 "Select next unread article which has the same subject as current one."
7631 (interactive)
eec82323
LMI
7632 (gnus-summary-next-article t (gnus-summary-article-subject)))
7633
7634(defun gnus-summary-prev-unread-same-subject ()
7635 "Select previous unread article which has the same subject as current one."
7636 (interactive)
eec82323
LMI
7637 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7638
7639(defun gnus-summary-first-unread-article ()
7640 "Select the first unread article.
7641Return nil if there are no unread articles."
7642 (interactive)
eec82323
LMI
7643 (prog1
7644 (when (gnus-summary-first-subject t)
7645 (gnus-summary-show-thread)
7646 (gnus-summary-first-subject t)
7647 (gnus-summary-display-article (gnus-summary-article-number)))
7648 (gnus-summary-position-point)))
7649
16409b0b
GM
7650(defun gnus-summary-first-unread-subject ()
7651 "Place the point on the subject line of the first unread article.
7652Return nil if there are no unread articles."
7653 (interactive)
7654 (prog1
7655 (when (gnus-summary-first-subject t)
7656 (gnus-summary-show-thread)
7657 (gnus-summary-first-subject t))
7658 (gnus-summary-position-point)))
7659
23f87bed
MB
7660(defun gnus-summary-first-unseen-subject ()
7661 "Place the point on the subject line of the first unseen article.
7662Return nil if there are no unseen articles."
7663 (interactive)
7664 (prog1
7665 (when (gnus-summary-first-subject nil nil t)
7666 (gnus-summary-show-thread)
7667 (gnus-summary-first-subject nil nil t))
7668 (gnus-summary-position-point)))
7669
7670(defun gnus-summary-first-unseen-or-unread-subject ()
7671 "Place the point on the subject line of the first unseen article or,
7672if all article have been seen, on the subject line of the first unread
7673article."
7674 (interactive)
7675 (prog1
7676 (unless (when (gnus-summary-first-subject nil nil t)
7677 (gnus-summary-show-thread)
7678 (gnus-summary-first-subject nil nil t))
7679 (when (gnus-summary-first-subject t)
7680 (gnus-summary-show-thread)
7681 (gnus-summary-first-subject t)))
7682 (gnus-summary-position-point)))
7683
eec82323
LMI
7684(defun gnus-summary-first-article ()
7685 "Select the first article.
7686Return nil if there are no articles."
7687 (interactive)
eec82323
LMI
7688 (prog1
7689 (when (gnus-summary-first-subject)
16409b0b
GM
7690 (gnus-summary-show-thread)
7691 (gnus-summary-first-subject)
7692 (gnus-summary-display-article (gnus-summary-article-number)))
eec82323
LMI
7693 (gnus-summary-position-point)))
7694
23f87bed
MB
7695(defun gnus-summary-best-unread-article (&optional arg)
7696 "Select the unread article with the highest score.
7697If given a prefix argument, select the next unread article that has a
7698score higher than the default score."
7699 (interactive "P")
7700 (let ((article (if arg
7701 (gnus-summary-better-unread-subject)
7702 (gnus-summary-best-unread-subject))))
7703 (if article
7704 (gnus-summary-goto-article article)
7705 (error "No unread articles"))))
7706
7707(defun gnus-summary-best-unread-subject ()
7708 "Select the unread subject with the highest score."
eec82323 7709 (interactive)
eec82323
LMI
7710 (let ((best -1000000)
7711 (data gnus-newsgroup-data)
7712 article score)
7713 (while data
7714 (and (gnus-data-unread-p (car data))
7715 (> (setq score
7716 (gnus-summary-article-score (gnus-data-number (car data))))
7717 best)
7718 (setq best score
7719 article (gnus-data-number (car data))))
7720 (setq data (cdr data)))
23f87bed
MB
7721 (when article
7722 (gnus-summary-goto-subject article))
7723 (gnus-summary-position-point)
7724 article))
7725
7726(defun gnus-summary-better-unread-subject ()
7727 "Select the first unread subject that has a score over the default score."
7728 (interactive)
7729 (let ((data gnus-newsgroup-data)
7730 article score)
7731 (while (and (setq article (gnus-data-number (car data)))
7732 (or (gnus-data-read-p (car data))
7733 (not (> (gnus-summary-article-score article)
7734 gnus-summary-default-score))))
7735 (setq data (cdr data)))
7736 (when article
7737 (gnus-summary-goto-subject article))
7738 (gnus-summary-position-point)
7739 article))
eec82323
LMI
7740
7741(defun gnus-summary-last-subject ()
7742 "Go to the last displayed subject line in the group."
7743 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7744 (when article
7745 (gnus-summary-goto-subject article))))
7746
7747(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
7748 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7749If ALL-HEADERS is non-nil, no header lines are hidden.
7750If FORCE, go to the article even if it isn't displayed. If FORCE
7751is a number, it is the line the article is to be displayed on."
eec82323
LMI
7752 (interactive
7753 (list
6748645f
LMI
7754 (completing-read
7755 "Article number or Message-ID: "
7756 (mapcar (lambda (number) (list (int-to-string number)))
7757 gnus-newsgroup-limit))
eec82323
LMI
7758 current-prefix-arg
7759 t))
7760 (prog1
6748645f 7761 (if (and (stringp article)
23f87bed 7762 (string-match "@\\|%40" article))
6748645f
LMI
7763 (gnus-summary-refer-article article)
7764 (when (stringp article)
7765 (setq article (string-to-number article)))
7766 (if (gnus-summary-goto-subject article force)
7767 (gnus-summary-display-article article all-headers)
7768 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
7769 (gnus-summary-position-point)))
7770
7771(defun gnus-summary-goto-last-article ()
7772 "Go to the previously read article."
7773 (interactive)
7774 (prog1
7775 (when gnus-last-article
6748645f 7776 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
7777 (gnus-summary-position-point)))
7778
7779(defun gnus-summary-pop-article (number)
7780 "Pop one article off the history and go to the previous.
7781NUMBER articles will be popped off."
7782 (interactive "p")
7783 (let (to)
7784 (setq gnus-newsgroup-history
7785 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7786 (if to
6748645f 7787 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
7788 (error "Article history empty")))
7789 (gnus-summary-position-point))
7790
7791;; Summary commands and functions for limiting the summary buffer.
7792
7793(defun gnus-summary-limit-to-articles (n)
7794 "Limit the summary buffer to the next N articles.
7795If not given a prefix, use the process marked articles instead."
7796 (interactive "P")
eec82323
LMI
7797 (prog1
7798 (let ((articles (gnus-summary-work-articles n)))
7799 (setq gnus-newsgroup-processable nil)
7800 (gnus-summary-limit articles))
7801 (gnus-summary-position-point)))
7802
7803(defun gnus-summary-pop-limit (&optional total)
7804 "Restore the previous limit.
7805If given a prefix, remove all limits."
7806 (interactive "P")
eec82323
LMI
7807 (when total
7808 (setq gnus-newsgroup-limits
7809 (list (mapcar (lambda (h) (mail-header-number h))
7810 gnus-newsgroup-headers))))
7811 (unless gnus-newsgroup-limits
7812 (error "No limit to pop"))
7813 (prog1
7814 (gnus-summary-limit nil 'pop)
7815 (gnus-summary-position-point)))
7816
47b63dfa
SZ
7817(defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7818 "Limit the summary buffer to articles that have subjects that match a regexp.
7819If NOT-MATCHING, excluding articles that have subjects that match a regexp."
a1506d29 7820 (interactive
47b63dfa
SZ
7821 (list (read-string (if current-prefix-arg
7822 "Exclude subject (regexp): "
a1506d29 7823 "Limit to subject (regexp): "))
47b63dfa 7824 nil current-prefix-arg))
eec82323
LMI
7825 (unless header
7826 (setq header "subject"))
7827 (when (not (equal "" subject))
7828 (prog1
7829 (let ((articles (gnus-summary-find-matching
a1506d29 7830 (or header "subject") subject 'all nil nil
47b63dfa 7831 not-matching)))
eec82323
LMI
7832 (unless articles
7833 (error "Found no matches for \"%s\"" subject))
7834 (gnus-summary-limit articles))
7835 (gnus-summary-position-point))))
7836
ef6e0ec7 7837(defun gnus-summary-limit-to-author (from &optional not-matching)
47b63dfa
SZ
7838 "Limit the summary buffer to articles that have authors that match a regexp.
7839If NOT-MATCHING, excluding articles that have authors that match a regexp."
a1506d29 7840 (interactive
47b63dfa
SZ
7841 (list (read-string (if current-prefix-arg
7842 "Exclude author (regexp): "
a1506d29 7843 "Limit to author (regexp): "))
ef6e0ec7
SZ
7844 current-prefix-arg))
7845 (gnus-summary-limit-to-subject from "from" not-matching))
eec82323
LMI
7846
7847(defun gnus-summary-limit-to-age (age &optional younger-p)
7848 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7849If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7850articles that are younger than AGE days."
16409b0b
GM
7851 (interactive
7852 (let ((younger current-prefix-arg)
7853 (days-got nil)
7854 days)
7855 (while (not days-got)
7856 (setq days (if younger
23f87bed
MB
7857 (read-string "Limit to articles younger than (in days, older when negative): ")
7858 (read-string
7859 "Limit to articles older than (in days, younger when negative): ")))
16409b0b
GM
7860 (when (> (length days) 0)
7861 (setq days (read days)))
7862 (if (numberp days)
23f87bed
MB
7863 (progn
7864 (setq days-got t)
7865 (if (< days 0)
7866 (progn
7867 (setq younger (not younger))
7868 (setq days (* days -1)))))
16409b0b
GM
7869 (message "Please enter a number.")
7870 (sleep-for 1)))
7871 (list days younger)))
eec82323
LMI
7872 (prog1
7873 (let ((data gnus-newsgroup-data)
16409b0b 7874 (cutoff (days-to-time age))
eec82323
LMI
7875 articles d date is-younger)
7876 (while (setq d (pop data))
7877 (when (and (vectorp (gnus-data-header d))
7878 (setq date (mail-header-date (gnus-data-header d))))
16409b0b
GM
7879 (setq is-younger (time-less-p
7880 (time-since (condition-case ()
7881 (date-to-time date)
7882 (error '(0 0))))
eec82323 7883 cutoff))
6748645f
LMI
7884 (when (if younger-p
7885 is-younger
7886 (not is-younger))
eec82323
LMI
7887 (push (gnus-data-number d) articles))))
7888 (gnus-summary-limit (nreverse articles)))
7889 (gnus-summary-position-point)))
7890
47b63dfa 7891(defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
16409b0b
GM
7892 "Limit the summary buffer to articles that match an 'extra' header."
7893 (interactive
7894 (let ((header
7895 (intern
23f87bed 7896 (gnus-completing-read-with-default
16409b0b 7897 (symbol-name (car gnus-extra-headers))
47b63dfa 7898 (if current-prefix-arg
81df110a
RF
7899 "Exclude extra header"
7900 "Limit extra header")
16409b0b
GM
7901 (mapcar (lambda (x)
7902 (cons (symbol-name x) x))
7903 gnus-extra-headers)
7904 nil
7905 t))))
7906 (list header
a1506d29 7907 (read-string (format "%s header %s (regexp): "
47b63dfa
SZ
7908 (if current-prefix-arg "Exclude" "Limit to")
7909 header))
7910 current-prefix-arg)))
16409b0b
GM
7911 (when (not (equal "" regexp))
7912 (prog1
7913 (let ((articles (gnus-summary-find-matching
a1506d29 7914 (cons 'extra header) regexp 'all nil nil
47b63dfa 7915 not-matching)))
16409b0b
GM
7916 (unless articles
7917 (error "Found no matches for \"%s\"" regexp))
7918 (gnus-summary-limit articles))
7919 (gnus-summary-position-point))))
7920
23f87bed
MB
7921(defun gnus-summary-limit-to-display-predicate ()
7922 "Limit the summary buffer to the predicated in the `display' group parameter."
7923 (interactive)
7924 (unless gnus-newsgroup-display
7925 (error "There is no `display' group parameter"))
7926 (let (articles)
7927 (dolist (number gnus-newsgroup-articles)
7928 (when (funcall gnus-newsgroup-display)
7929 (push number articles)))
7930 (gnus-summary-limit articles))
7931 (gnus-summary-position-point))
7932
eec82323
LMI
7933(defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7934(make-obsolete
7935 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7936
7937(defun gnus-summary-limit-to-unread (&optional all)
7938 "Limit the summary buffer to articles that are not marked as read.
7939If ALL is non-nil, limit strictly to unread articles."
7940 (interactive "P")
7941 (if all
7942 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7943 (gnus-summary-limit-to-marks
7944 ;; Concat all the marks that say that an article is read and have
7945 ;; those removed.
7946 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
23f87bed 7947 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
eec82323
LMI
7948 gnus-low-score-mark gnus-expirable-mark
7949 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7950 gnus-duplicate-mark gnus-souped-mark)
7951 'reverse)))
7952
7953(defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7954(make-obsolete 'gnus-summary-delete-marked-with
81ceefe2 7955 'gnus-summary-limit-exclude-marks)
eec82323
LMI
7956
7957(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7958 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7959If REVERSE, limit the summary buffer to articles that are marked
7960with MARKS. MARKS can either be a string of marks or a list of marks.
7961Returns how many articles were removed."
7962 (interactive "sMarks: ")
7963 (gnus-summary-limit-to-marks marks t))
7964
7965(defun gnus-summary-limit-to-marks (marks &optional reverse)
7966 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7967If REVERSE (the prefix), limit the summary buffer to articles that are
7968not marked with MARKS. MARKS can either be a string of marks or a
7969list of marks.
7970Returns how many articles were removed."
6748645f 7971 (interactive "sMarks: \nP")
eec82323
LMI
7972 (prog1
7973 (let ((data gnus-newsgroup-data)
7974 (marks (if (listp marks) marks
7975 (append marks nil))) ; Transform to list.
7976 articles)
7977 (while data
7978 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7979 (memq (gnus-data-mark (car data)) marks))
7980 (push (gnus-data-number (car data)) articles))
7981 (setq data (cdr data)))
7982 (gnus-summary-limit articles))
7983 (gnus-summary-position-point)))
7984
23f87bed 7985(defun gnus-summary-limit-to-score (score)
eec82323 7986 "Limit to articles with score at or above SCORE."
23f87bed 7987 (interactive "NLimit to articles with score of at least: ")
eec82323
LMI
7988 (let ((data gnus-newsgroup-data)
7989 articles)
7990 (while data
7991 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7992 score)
7993 (push (gnus-data-number (car data)) articles))
7994 (setq data (cdr data)))
7995 (prog1
7996 (gnus-summary-limit articles)
7997 (gnus-summary-position-point))))
7998
23f87bed
MB
7999(defun gnus-summary-limit-to-unseen ()
8000 "Limit to unseen articles."
8001 (interactive)
8002 (prog1
8003 (gnus-summary-limit gnus-newsgroup-unseen)
8004 (gnus-summary-position-point)))
8005
6748645f 8006(defun gnus-summary-limit-include-thread (id)
23f87bed
MB
8007 "Display all the hidden articles that is in the thread with ID in it.
8008When called interactively, ID is the Message-ID of the current
8009article."
6748645f
LMI
8010 (interactive (list (mail-header-id (gnus-summary-article-header))))
8011 (let ((articles (gnus-articles-in-thread
8012 (gnus-id-to-thread (gnus-root-id id)))))
8013 (prog1
8014 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
23f87bed
MB
8015 (gnus-summary-limit-include-matching-articles
8016 "subject"
8017 (regexp-quote (gnus-simplify-subject-re
8018 (mail-header-subject (gnus-id-to-header id)))))
6748645f
LMI
8019 (gnus-summary-position-point))))
8020
23f87bed
MB
8021(defun gnus-summary-limit-include-matching-articles (header regexp)
8022 "Display all the hidden articles that have HEADERs that match REGEXP."
8023 (interactive (list (read-string "Match on header: ")
8024 (read-string "Regexp: ")))
8025 (let ((articles (gnus-find-matching-articles header regexp)))
8026 (prog1
8027 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8028 (gnus-summary-position-point))))
8029
8030(defun gnus-summary-insert-dormant-articles ()
8031 "Insert all the dormant articles for this group into the current buffer."
8032 (interactive)
8033 (let ((gnus-verbose (max 6 gnus-verbose)))
8034 (if (not gnus-newsgroup-dormant)
db629244 8035 (gnus-message 3 "No dormant articles for this group")
23f87bed
MB
8036 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8037
eec82323 8038(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
8039 "Display all the hidden articles that are marked as dormant.
8040Note that this command only works on a subset of the articles currently
8041fetched for this group."
eec82323 8042 (interactive)
eec82323
LMI
8043 (unless gnus-newsgroup-dormant
8044 (error "There are no dormant articles in this group"))
8045 (prog1
8046 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8047 (gnus-summary-position-point)))
8048
8049(defun gnus-summary-limit-exclude-dormant ()
8050 "Hide all dormant articles."
8051 (interactive)
eec82323
LMI
8052 (prog1
8053 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8054 (gnus-summary-position-point)))
8055
8056(defun gnus-summary-limit-exclude-childless-dormant ()
8057 "Hide all dormant articles that have no children."
8058 (interactive)
eec82323
LMI
8059 (let ((data (gnus-data-list t))
8060 articles d children)
8061 ;; Find all articles that are either not dormant or have
8062 ;; children.
8063 (while (setq d (pop data))
8064 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8065 (and (setq children
8066 (gnus-article-children (gnus-data-number d)))
8067 (let (found)
8068 (while children
8069 (when (memq (car children) articles)
8070 (setq children nil
8071 found t))
8072 (pop children))
8073 found)))
8074 (push (gnus-data-number d) articles)))
8075 ;; Do the limiting.
8076 (prog1
8077 (gnus-summary-limit articles)
8078 (gnus-summary-position-point))))
8079
8080(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8081 "Mark all unread excluded articles as read.
8082If ALL, mark even excluded ticked and dormants as read."
8083 (interactive "P")
23f87bed
MB
8084 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8085 (let ((articles (gnus-sorted-ndifference
eec82323
LMI
8086 (sort
8087 (mapcar (lambda (h) (mail-header-number h))
8088 gnus-newsgroup-headers)
8089 '<)
23f87bed 8090 gnus-newsgroup-limit))
eec82323 8091 article)
6748645f 8092 (setq gnus-newsgroup-unreads
23f87bed
MB
8093 (gnus-sorted-intersection gnus-newsgroup-unreads
8094 gnus-newsgroup-limit))
eec82323
LMI
8095 (if all
8096 (setq gnus-newsgroup-dormant nil
8097 gnus-newsgroup-marked nil
8098 gnus-newsgroup-reads
8099 (nconc
8100 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8101 gnus-newsgroup-reads))
8102 (while (setq article (pop articles))
8103 (unless (or (memq article gnus-newsgroup-dormant)
8104 (memq article gnus-newsgroup-marked))
8105 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8106
8107(defun gnus-summary-limit (articles &optional pop)
8108 (if pop
8109 ;; We pop the previous limit off the stack and use that.
8110 (setq articles (car gnus-newsgroup-limits)
8111 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8112 ;; We use the new limit, so we push the old limit on the stack.
8113 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8114 ;; Set the limit.
8115 (setq gnus-newsgroup-limit articles)
8116 (let ((total (length gnus-newsgroup-data))
8117 (data (gnus-data-find-list (gnus-summary-article-number)))
8118 (gnus-summary-mark-below nil) ; Inhibit this.
8119 found)
8120 ;; This will do all the work of generating the new summary buffer
8121 ;; according to the new limit.
8122 (gnus-summary-prepare)
8123 ;; Hide any threads, possibly.
23f87bed 8124 (gnus-summary-maybe-hide-threads)
eec82323
LMI
8125 ;; Try to return to the article you were at, or one in the
8126 ;; neighborhood.
8127 (when data
8128 ;; We try to find some article after the current one.
8129 (while data
8130 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8131 (setq data nil
8132 found t))
8133 (setq data (cdr data))))
8134 (unless found
8135 ;; If there is no data, that means that we were after the last
8136 ;; article. The same goes when we can't find any articles
8137 ;; after the current one.
8138 (goto-char (point-max))
8139 (gnus-summary-find-prev))
6748645f 8140 (gnus-set-mode-line 'summary)
eec82323
LMI
8141 ;; We return how many articles were removed from the summary
8142 ;; buffer as a result of the new limit.
8143 (- total (length gnus-newsgroup-data))))
8144
8145(defsubst gnus-invisible-cut-children (threads)
8146 (let ((num 0))
8147 (while threads
8148 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8149 (incf num))
8150 (pop threads))
8151 (< num 2)))
8152
8153(defsubst gnus-cut-thread (thread)
8154 "Go forwards in the thread until we find an article that we want to display."
8155 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8156 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8157 (numberp gnus-fetch-old-headers)
eec82323
LMI
8158 (eq gnus-build-sparse-threads 'some)
8159 (eq gnus-build-sparse-threads 'more))
8160 ;; Deal with old-fetched headers and sparse threads.
8161 (while (and
8162 thread
8163 (or
8164 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8165 (gnus-summary-article-ancient-p
8166 (mail-header-number (car thread))))
6748645f
LMI
8167 (if (or (<= (length (cdr thread)) 1)
8168 (eq gnus-fetch-old-headers 'invisible))
8169 (setq gnus-newsgroup-limit
8170 (delq (mail-header-number (car thread))
8171 gnus-newsgroup-limit)
8172 thread (cadr thread))
8173 (when (gnus-invisible-cut-children (cdr thread))
8174 (let ((th (cdr thread)))
8175 (while th
8176 (if (memq (mail-header-number (caar th))
a8151ef7 8177 gnus-newsgroup-limit)
6748645f
LMI
8178 (setq thread (car th)
8179 th nil)
8180 (setq th (cdr th))))))))))
eec82323
LMI
8181 thread)
8182
8183(defun gnus-cut-threads (threads)
23f87bed 8184 "Cut off all uninteresting articles from the beginning of THREADS."
eec82323 8185 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 8186 (eq gnus-fetch-old-headers 'invisible)
16409b0b 8187 (numberp gnus-fetch-old-headers)
eec82323
LMI
8188 (eq gnus-build-sparse-threads 'some)
8189 (eq gnus-build-sparse-threads 'more))
8190 (let ((th threads))
8191 (while th
8192 (setcar th (gnus-cut-thread (car th)))
8193 (setq th (cdr th)))))
8194 ;; Remove nixed out threads.
8195 (delq nil threads))
8196
8197(defun gnus-summary-initial-limit (&optional show-if-empty)
8198 "Figure out what the initial limit is supposed to be on group entry.
8199This entails weeding out unwanted dormants, low-scored articles,
8200fetch-old-headers verbiage, and so on."
8201 ;; Most groups have nothing to remove.
8202 (if (or gnus-inhibit-limiting
8203 (and (null gnus-newsgroup-dormant)
23f87bed 8204 (eq gnus-newsgroup-display 'gnus-not-ignore)
eec82323 8205 (not (eq gnus-fetch-old-headers 'some))
16409b0b 8206 (not (numberp gnus-fetch-old-headers))
6748645f 8207 (not (eq gnus-fetch-old-headers 'invisible))
eec82323
LMI
8208 (null gnus-summary-expunge-below)
8209 (not (eq gnus-build-sparse-threads 'some))
8210 (not (eq gnus-build-sparse-threads 'more))
8211 (null gnus-thread-expunge-below)
8212 (not gnus-use-nocem)))
8213 () ; Do nothing.
8214 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8215 (setq gnus-newsgroup-limit nil)
8216 (mapatoms
8217 (lambda (node)
8218 (unless (car (symbol-value node))
8219 ;; These threads have no parents -- they are roots.
8220 (let ((nodes (cdr (symbol-value node)))
8221 thread)
8222 (while nodes
8223 (if (and gnus-thread-expunge-below
8224 (< (gnus-thread-total-score (car nodes))
8225 gnus-thread-expunge-below))
8226 (gnus-expunge-thread (pop nodes))
8227 (setq thread (pop nodes))
8228 (gnus-summary-limit-children thread))))))
8229 gnus-newsgroup-dependencies)
8230 ;; If this limitation resulted in an empty group, we might
8231 ;; pop the previous limit and use it instead.
8232 (when (and (not gnus-newsgroup-limit)
8233 show-if-empty)
8234 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8235 gnus-newsgroup-limit))
8236
8237(defun gnus-summary-limit-children (thread)
8238 "Return 1 if this subthread is visible and 0 if it is not."
8239 ;; First we get the number of visible children to this thread. This
8240 ;; is done by recursing down the thread using this function, so this
8241 ;; will really go down to a leaf article first, before slowly
8242 ;; working its way up towards the root.
8243 (when thread
04b61ae9 8244 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
23f87bed 8245 (children
eec82323
LMI
8246 (if (cdr thread)
8247 (apply '+ (mapcar 'gnus-summary-limit-children
8248 (cdr thread)))
8249 0))
8250 (number (mail-header-number (car thread)))
8251 score)
8252 (if (and
8253 (not (memq number gnus-newsgroup-marked))
8254 (or
8255 ;; If this article is dormant and has absolutely no visible
8256 ;; children, then this article isn't visible.
8257 (and (memq number gnus-newsgroup-dormant)
8258 (zerop children))
8259 ;; If this is "fetch-old-headered" and there is no
8260 ;; visible children, then we don't want this article.
16409b0b
GM
8261 (and (or (eq gnus-fetch-old-headers 'some)
8262 (numberp gnus-fetch-old-headers))
eec82323
LMI
8263 (gnus-summary-article-ancient-p number)
8264 (zerop children))
6748645f
LMI
8265 ;; If this is "fetch-old-headered" and `invisible', then
8266 ;; we don't want this article.
8267 (and (eq gnus-fetch-old-headers 'invisible)
8268 (gnus-summary-article-ancient-p number))
eec82323
LMI
8269 ;; If this is a sparsely inserted article with no children,
8270 ;; we don't want it.
8271 (and (eq gnus-build-sparse-threads 'some)
8272 (gnus-summary-article-sparse-p number)
8273 (zerop children))
8274 ;; If we use expunging, and this article is really
8275 ;; low-scored, then we don't want this article.
8276 (when (and gnus-summary-expunge-below
8277 (< (setq score
8278 (or (cdr (assq number gnus-newsgroup-scored))
8279 gnus-summary-default-score))
8280 gnus-summary-expunge-below))
8281 ;; We increase the expunge-tally here, but that has
8282 ;; nothing to do with the limits, really.
8283 (incf gnus-newsgroup-expunged-tally)
8284 ;; We also mark as read here, if that's wanted.
8285 (when (and gnus-summary-mark-below
8286 (< score gnus-summary-mark-below))
8287 (setq gnus-newsgroup-unreads
8288 (delq number gnus-newsgroup-unreads))
8289 (if gnus-newsgroup-auto-expire
8290 (push number gnus-newsgroup-expirable)
8291 (push (cons number gnus-low-score-mark)
8292 gnus-newsgroup-reads)))
8293 t)
23f87bed
MB
8294 ;; Do the `display' group parameter.
8295 (and gnus-newsgroup-display
8296 (not (funcall gnus-newsgroup-display)))
eec82323
LMI
8297 ;; Check NoCeM things.
8298 (if (and gnus-use-nocem
8299 (gnus-nocem-unwanted-article-p
8300 (mail-header-id (car thread))))
8301 (progn
a8151ef7 8302 (setq gnus-newsgroup-unreads
eec82323
LMI
8303 (delq number gnus-newsgroup-unreads))
8304 t))))
8305 ;; Nope, invisible article.
8306 0
8307 ;; Ok, this article is to be visible, so we add it to the limit
8308 ;; and return 1.
8309 (push number gnus-newsgroup-limit)
8310 1))))
8311
8312(defun gnus-expunge-thread (thread)
8313 "Mark all articles in THREAD as read."
8314 (let* ((number (mail-header-number (car thread))))
8315 (incf gnus-newsgroup-expunged-tally)
8316 ;; We also mark as read here, if that's wanted.
8317 (setq gnus-newsgroup-unreads
8318 (delq number gnus-newsgroup-unreads))
8319 (if gnus-newsgroup-auto-expire
8320 (push number gnus-newsgroup-expirable)
8321 (push (cons number gnus-low-score-mark)
8322 gnus-newsgroup-reads)))
8323 ;; Go recursively through all subthreads.
8324 (mapcar 'gnus-expunge-thread (cdr thread)))
8325
8326;; Summary article oriented commands
8327
8328(defun gnus-summary-refer-parent-article (n)
8329 "Refer parent article N times.
8330If N is negative, go to ancestor -N instead.
8331The difference between N and the number of articles fetched is returned."
8332 (interactive "p")
eec82323
LMI
8333 (let ((skip 1)
8334 error header ref)
8335 (when (not (natnump n))
8336 (setq skip (abs n)
8337 n 1))
8338 (while (and (> n 0)
8339 (not error))
8340 (setq header (gnus-summary-article-header))
8341 (if (and (eq (mail-header-number header)
8342 (cdr gnus-article-current))
8343 (equal gnus-newsgroup-name
8344 (car gnus-article-current)))
8345 ;; If we try to find the parent of the currently
8346 ;; displayed article, then we take a look at the actual
8347 ;; References header, since this is slightly more
8348 ;; reliable than the References field we got from the
8349 ;; server.
8350 (save-excursion
8351 (set-buffer gnus-original-article-buffer)
8352 (nnheader-narrow-to-headers)
8353 (unless (setq ref (message-fetch-field "references"))
23f87bed
MB
8354 (when (setq ref (message-fetch-field "in-reply-to"))
8355 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
eec82323
LMI
8356 (widen))
8357 (setq ref
8358 ;; It's not the current article, so we take a bet on
8359 ;; the value we got from the server.
8360 (mail-header-references header)))
8361 (if (and ref
8362 (not (equal ref "")))
8363 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8364 (gnus-message 1 "Couldn't find parent"))
8365 (gnus-message 1 "No references in article %d"
8366 (gnus-summary-article-number))
8367 (setq error t))
8368 (decf n))
8369 (gnus-summary-position-point)
8370 n))
8371
8372(defun gnus-summary-refer-references ()
8373 "Fetch all articles mentioned in the References header.
6748645f 8374Return the number of articles fetched."
eec82323 8375 (interactive)
eec82323
LMI
8376 (let ((ref (mail-header-references (gnus-summary-article-header)))
8377 (current (gnus-summary-article-number))
8378 (n 0))
8379 (if (or (not ref)
8380 (equal ref ""))
8381 (error "No References in the current article")
8382 ;; For each Message-ID in the References header...
8383 (while (string-match "<[^>]*>" ref)
8384 (incf n)
8385 ;; ... fetch that article.
8386 (gnus-summary-refer-article
8387 (prog1 (match-string 0 ref)
8388 (setq ref (substring ref (match-end 0))))))
8389 (gnus-summary-goto-subject current)
8390 (gnus-summary-position-point)
8391 n)))
8392
6748645f
LMI
8393(defun gnus-summary-refer-thread (&optional limit)
8394 "Fetch all articles in the current thread.
8395If LIMIT (the numerical prefix), fetch that many old headers instead
8396of what's specified by the `gnus-refer-thread-limit' variable."
8397 (interactive "P")
8398 (let ((id (mail-header-id (gnus-summary-article-header)))
8399 (limit (if limit (prefix-numeric-value limit)
8400 gnus-refer-thread-limit)))
6748645f
LMI
8401 (unless (eq gnus-fetch-old-headers 'invisible)
8402 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8403 ;; Retrieve the headers and read them in.
23f87bed
MB
8404 (if (eq (if (numberp limit)
8405 (gnus-retrieve-headers
8406 (list (min
8407 (+ (mail-header-number
8408 (gnus-summary-article-header))
8409 limit)
8410 gnus-newsgroup-end))
8411 gnus-newsgroup-name (* limit 2))
8412 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8413 ;; headers.
8414 (gnus-retrieve-headers (list gnus-newsgroup-end)
8415 gnus-newsgroup-name limit))
6748645f
LMI
8416 'nov)
8417 (gnus-build-all-threads)
23f87bed 8418 (error "Can't fetch thread from back ends that don't support NOV"))
6748645f
LMI
8419 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8420 (gnus-summary-limit-include-thread id)))
8421
16409b0b
GM
8422(defun gnus-summary-refer-article (message-id)
8423 "Fetch an article specified by MESSAGE-ID."
8424 (interactive "sMessage-ID: ")
eec82323
LMI
8425 (when (and (stringp message-id)
8426 (not (zerop (length message-id))))
23f87bed 8427 (setq message-id (gnus-replace-in-string message-id " " ""))
eec82323
LMI
8428 ;; Construct the correct Message-ID if necessary.
8429 ;; Suggested by tale@pawl.rpi.edu.
8430 (unless (string-match "^<" message-id)
8431 (setq message-id (concat "<" message-id)))
8432 (unless (string-match ">$" message-id)
8433 (setq message-id (concat message-id ">")))
23f87bed
MB
8434 ;; People often post MIDs from URLs, so unhex it:
8435 (unless (string-match "@" message-id)
8436 (setq message-id (gnus-url-unhex-string message-id)))
eec82323
LMI
8437 (let* ((header (gnus-id-to-header message-id))
8438 (sparse (and header
8439 (gnus-summary-article-sparse-p
a8151ef7
LMI
8440 (mail-header-number header))
8441 (memq (mail-header-number header)
16409b0b
GM
8442 gnus-newsgroup-limit)))
8443 number)
6748645f
LMI
8444 (cond
8445 ;; If the article is present in the buffer we just go to it.
8446 ((and header
8447 (or (not (gnus-summary-article-sparse-p
8448 (mail-header-number header)))
8449 sparse))
8450 (prog1
8451 (gnus-summary-goto-article
8452 (mail-header-number header) nil t)
8453 (when sparse
8454 (gnus-summary-update-article (mail-header-number header)))))
8455 (t
16409b0b
GM
8456 ;; We fetch the article.
8457 (catch 'found
8458 (dolist (gnus-override-method (gnus-refer-article-methods))
23f87bed
MB
8459 (when (and (gnus-check-server gnus-override-method)
8460 ;; Fetch the header,
8461 (setq number (gnus-summary-insert-subject message-id)))
8462 ;; and display the article.
eec82323 8463 (gnus-summary-select-article nil nil nil number)
16409b0b
GM
8464 (throw 'found t)))
8465 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8466
8467(defun gnus-refer-article-methods ()
8f688cb0 8468 "Return a list of referable methods."
16409b0b
GM
8469 (cond
8470 ;; No method, so we default to current and native.
8471 ((null gnus-refer-article-method)
8472 (list gnus-current-select-method gnus-select-method))
8473 ;; Current.
8474 ((eq 'current gnus-refer-article-method)
8475 (list gnus-current-select-method))
8476 ;; List of select methods.
d4dfaa19
DL
8477 ((not (and (symbolp (car gnus-refer-article-method))
8478 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
16409b0b
GM
8479 (let (out)
8480 (dolist (method gnus-refer-article-method)
8481 (push (if (eq 'current method)
8482 gnus-current-select-method
8483 method)
8484 out))
8485 (nreverse out)))
8486 ;; One single select method.
8487 (t
8488 (list gnus-refer-article-method))))
6748645f
LMI
8489
8490(defun gnus-summary-edit-parameters ()
8491 "Edit the group parameters of the current group."
8492 (interactive)
8493 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323 8494
16409b0b
GM
8495(defun gnus-summary-customize-parameters ()
8496 "Customize the group parameters of the current group."
8497 (interactive)
8498 (gnus-group-customize gnus-newsgroup-name))
8499
eec82323
LMI
8500(defun gnus-summary-enter-digest-group (&optional force)
8501 "Enter an nndoc group based on the current article.
8502If FORCE, force a digest interpretation. If not, try
8503to guess what the document format is."
8504 (interactive "P")
eec82323 8505 (let ((conf gnus-current-window-configuration))
23f87bed
MB
8506 (save-window-excursion
8507 (save-excursion
8508 (let (gnus-article-prepare-hook
8509 gnus-display-mime-function
8510 gnus-break-pages)
8511 (gnus-summary-select-article))))
eec82323
LMI
8512 (setq gnus-current-window-configuration conf)
8513 (let* ((name (format "%s-%d"
8514 (gnus-group-prefixed-name
8515 gnus-newsgroup-name (list 'nndoc ""))
8516 (save-excursion
8517 (set-buffer gnus-summary-buffer)
8518 gnus-current-article)))
8519 (ogroup gnus-newsgroup-name)
8520 (params (append (gnus-info-params (gnus-get-info ogroup))
8521 (list (cons 'to-group ogroup))
23f87bed 8522 (list (cons 'parent-group ogroup))
eec82323
LMI
8523 (list (cons 'save-article-group ogroup))))
8524 (case-fold-search t)
8525 (buf (current-buffer))
16409b0b 8526 dig to-address)
eec82323 8527 (save-excursion
16409b0b
GM
8528 (set-buffer gnus-original-article-buffer)
8529 ;; Have the digest group inherit the main mail address of
8530 ;; the parent article.
23f87bed
MB
8531 (when (setq to-address (or (gnus-fetch-field "reply-to")
8532 (gnus-fetch-field "from")))
343d6628
MB
8533 (setq params
8534 (append
8535 (list (cons 'to-address
8536 (funcall gnus-decode-encoded-address-function
8537 to-address))))))
eec82323
LMI
8538 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8539 (insert-buffer-substring gnus-original-article-buffer)
8540 ;; Remove lines that may lead nndoc to misinterpret the
8541 ;; document type.
8542 (narrow-to-region
8543 (goto-char (point-min))
8544 (or (search-forward "\n\n" nil t) (point)))
8545 (goto-char (point-min))
16409b0b 8546 (delete-matching-lines "^Path:\\|^From ")
eec82323
LMI
8547 (widen))
8548 (unwind-protect
23f87bed 8549 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
16409b0b
GM
8550 (gnus-newsgroup-ephemeral-ignored-charsets
8551 gnus-newsgroup-ignored-charsets))
8552 (gnus-group-read-ephemeral-group
8553 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8554 (nndoc-article-type
23f87bed
MB
8555 ,(if force 'mbox 'guess)))
8556 t nil nil nil
8557 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8558 "ADAPT")))))
16409b0b 8559 ;; Make all postings to this group go to the parent group.
23f87bed
MB
8560 (nconc (gnus-info-params (gnus-get-info name))
8561 params)
8562 ;; Couldn't select this doc group.
8563 (switch-to-buffer buf)
8564 (gnus-set-global-variables)
8565 (gnus-configure-windows 'summary)
8566 (gnus-message 3 "Article couldn't be entered?"))
eec82323
LMI
8567 (kill-buffer dig)))))
8568
8569(defun gnus-summary-read-document (n)
8570 "Open a new group based on the current article(s).
8571This will allow you to read digests and other similar
8572documents as newsgroups.
8573Obeys the standard process/prefix convention."
8574 (interactive "P")
8575 (let* ((articles (gnus-summary-work-articles n))
8576 (ogroup gnus-newsgroup-name)
8577 (params (append (gnus-info-params (gnus-get-info ogroup))
8578 (list (cons 'to-group ogroup))))
8579 article group egroup groups vgroup)
8580 (while (setq article (pop articles))
8581 (setq group (format "%s-%d" gnus-newsgroup-name article))
8582 (gnus-summary-remove-process-mark article)
8583 (when (gnus-summary-display-article article)
8584 (save-excursion
16409b0b 8585 (with-temp-buffer
eec82323
LMI
8586 (insert-buffer-substring gnus-original-article-buffer)
8587 ;; Remove some headers that may lead nndoc to make
8588 ;; the wrong guess.
8589 (message-narrow-to-head)
8590 (goto-char (point-min))
8591 (delete-matching-lines "^\\(Path\\):\\|^From ")
8592 (widen)
8593 (if (setq egroup
8594 (gnus-group-read-ephemeral-group
8595 group `(nndoc ,group (nndoc-address ,(current-buffer))
8596 (nndoc-article-type guess))
8597 t nil t))
8598 (progn
23f87bed 8599 ;; Make all postings to this group go to the parent group.
eec82323
LMI
8600 (nconc (gnus-info-params (gnus-get-info egroup))
8601 params)
8602 (push egroup groups))
8603 ;; Couldn't select this doc group.
8604 (gnus-error 3 "Article couldn't be entered"))))))
8605 ;; Now we have selected all the documents.
8606 (cond
8607 ((not groups)
8608 (error "None of the articles could be interpreted as documents"))
8609 ((gnus-group-read-ephemeral-group
8610 (setq vgroup (format
8611 "nnvirtual:%s-%s" gnus-newsgroup-name
8612 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8613 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8614 t
8615 (cons (current-buffer) 'summary)))
8616 (t
8617 (error "Couldn't select virtual nndoc group")))))
8618
8619(defun gnus-summary-isearch-article (&optional regexp-p)
8620 "Do incremental search forward on the current article.
8621If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8622 (interactive "P")
eec82323
LMI
8623 (gnus-summary-select-article)
8624 (gnus-configure-windows 'article)
8625 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
8626 (save-restriction
8627 (widen)
8628 (isearch-forward regexp-p))))
eec82323
LMI
8629
8630(defun gnus-summary-search-article-forward (regexp &optional backward)
8631 "Search for an article containing REGEXP forward.
8632If BACKWARD, search backward instead."
8633 (interactive
8634 (list (read-string
8635 (format "Search article %s (regexp%s): "
8636 (if current-prefix-arg "backward" "forward")
8637 (if gnus-last-search-regexp
8638 (concat ", default " gnus-last-search-regexp)
8639 "")))
8640 current-prefix-arg))
eec82323
LMI
8641 (if (string-equal regexp "")
8642 (setq regexp (or gnus-last-search-regexp ""))
23f87bed
MB
8643 (setq gnus-last-search-regexp regexp)
8644 (setq gnus-article-before-search gnus-current-article))
8645 ;; Intentionally set gnus-last-article.
8646 (setq gnus-last-article gnus-article-before-search)
8647 (let ((gnus-last-article gnus-last-article))
8648 (if (gnus-summary-search-article regexp backward)
8649 (gnus-summary-show-thread)
abc40aab 8650 (signal 'search-failed (list regexp)))))
eec82323
LMI
8651
8652(defun gnus-summary-search-article-backward (regexp)
8653 "Search for an article containing REGEXP backward."
8654 (interactive
8655 (list (read-string
8656 (format "Search article backward (regexp%s): "
8657 (if gnus-last-search-regexp
8658 (concat ", default " gnus-last-search-regexp)
8659 "")))))
8660 (gnus-summary-search-article-forward regexp 'backward))
8661
8662(defun gnus-summary-search-article (regexp &optional backward)
8663 "Search for an article containing REGEXP.
8664Optional argument BACKWARD means do search for backward.
8665`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
8666 ;; We have to require this here to make sure that the following
8667 ;; dynamic binding isn't shadowed by autoloading.
8668 (require 'gnus-async)
16409b0b 8669 (require 'gnus-art)
eec82323 8670 (let ((gnus-select-article-hook nil) ;Disable hook.
16409b0b 8671 (gnus-article-prepare-hook nil)
eec82323
LMI
8672 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8673 (gnus-use-article-prefetch nil)
8674 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 8675 (gnus-use-trees nil) ;Inhibit updating tree buffer.
23f87bed
MB
8676 (gnus-visual nil)
8677 (gnus-keep-backlog nil)
8678 (gnus-break-pages nil)
8679 (gnus-summary-display-arrow nil)
8680 (gnus-updated-mode-lines nil)
8681 (gnus-auto-center-summary nil)
eec82323 8682 (sum (current-buffer))
16409b0b 8683 (gnus-display-mime-function nil)
eec82323
LMI
8684 (found nil)
8685 point)
8686 (gnus-save-hidden-threads
8687 (gnus-summary-select-article)
8688 (set-buffer gnus-article-buffer)
16409b0b 8689 (goto-char (window-point (get-buffer-window (current-buffer))))
eec82323
LMI
8690 (when backward
8691 (forward-line -1))
8692 (while (not found)
8693 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8694 (if (if backward
8695 (re-search-backward regexp nil t)
8696 (re-search-forward regexp nil t))
8697 ;; We found the regexp.
8698 (progn
8699 (setq found 'found)
8700 (beginning-of-line)
8701 (set-window-start
8702 (get-buffer-window (current-buffer))
8703 (point))
8704 (forward-line 1)
16409b0b
GM
8705 (set-window-point
8706 (get-buffer-window (current-buffer))
8707 (point))
eec82323
LMI
8708 (set-buffer sum)
8709 (setq point (point)))
8710 ;; We didn't find it, so we go to the next article.
8711 (set-buffer sum)
8712 (setq found 'not)
8713 (while (eq found 'not)
8714 (if (not (if backward (gnus-summary-find-prev)
8715 (gnus-summary-find-next)))
8716 ;; No more articles.
8717 (setq found t)
8718 ;; Select the next article and adjust point.
8719 (unless (gnus-summary-article-sparse-p
8720 (gnus-summary-article-number))
8721 (setq found nil)
8722 (gnus-summary-select-article)
8723 (set-buffer gnus-article-buffer)
8724 (widen)
8725 (goto-char (if backward (point-max) (point-min))))))))
8726 (gnus-message 7 ""))
8727 ;; Return whether we found the regexp.
8728 (when (eq found 'found)
8729 (goto-char point)
8730 (gnus-summary-show-thread)
8731 (gnus-summary-goto-subject gnus-current-article)
8732 (gnus-summary-position-point)
8733 t)))
8734
23f87bed
MB
8735(defun gnus-find-matching-articles (header regexp)
8736 "Return a list of all articles that match REGEXP on HEADER.
8737This search includes all articles in the current group that Gnus has
8738fetched headers for, whether they are displayed or not."
8739 (let ((articles nil)
8740 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8741 (case-fold-search t))
8742 (dolist (header gnus-newsgroup-headers)
8743 (when (string-match regexp (funcall func header))
8744 (push (mail-header-number header) articles)))
8745 (nreverse articles)))
8746
eec82323 8747(defun gnus-summary-find-matching (header regexp &optional backward unread
47b63dfa 8748 not-case-fold not-matching)
eec82323
LMI
8749 "Return a list of all articles that match REGEXP on HEADER.
8750The search stars on the current article and goes forwards unless
8751BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8752If UNREAD is non-nil, only unread articles will
8753be taken into consideration. If NOT-CASE-FOLD, case won't be folded
a1506d29 8754in the comparisons. If NOT-MATCHING, return a list of all articles that
47b63dfa
SZ
8755not match REGEXP on HEADER."
8756 (let ((case-fold-search (not not-case-fold))
16409b0b
GM
8757 articles d func)
8758 (if (consp header)
8759 (if (eq (car header) 'extra)
8760 (setq func
8761 `(lambda (h)
8762 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8763 "")))
8764 (error "%s is an invalid header" header))
8765 (unless (fboundp (intern (concat "mail-header-" header)))
8766 (error "%s is not a valid header" header))
8767 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
47b63dfa
SZ
8768 (dolist (d (if (eq backward 'all)
8769 gnus-newsgroup-data
8770 (gnus-data-find-list
8771 (gnus-summary-article-number)
8772 (gnus-data-list backward))))
8773 (when (and (or (not unread) ; We want all articles...
8774 (gnus-data-unread-p d)) ; Or just unreads.
8775 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8776 (if not-matching
a1506d29 8777 (not (string-match
47b63dfa
SZ
8778 regexp
8779 (funcall func (gnus-data-header d))))
8780 (string-match regexp
8781 (funcall func (gnus-data-header d)))))
8782 (push (gnus-data-number d) articles))) ; Success!
eec82323
LMI
8783 (nreverse articles)))
8784
8785(defun gnus-summary-execute-command (header regexp command &optional backward)
8786 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8787If HEADER is an empty string (or nil), the match is done on the entire
8788article. If BACKWARD (the prefix) is non-nil, search backward instead."
8789 (interactive
8790 (list (let ((completion-ignore-case t))
8791 (completing-read
8792 "Header name: "
23f87bed
MB
8793 (mapcar (lambda (header) (list (format "%s" header)))
8794 (append
8795 '("Number" "Subject" "From" "Lines" "Date"
8796 "Message-ID" "Xref" "References" "Body")
8797 gnus-extra-headers))
eec82323
LMI
8798 nil 'require-match))
8799 (read-string "Regexp: ")
8800 (read-key-sequence "Command: ")
8801 current-prefix-arg))
8802 (when (equal header "Body")
8803 (setq header ""))
eec82323
LMI
8804 ;; Hidden thread subtrees must be searched as well.
8805 (gnus-summary-show-all-threads)
8806 ;; We don't want to change current point nor window configuration.
8807 (save-excursion
8808 (save-window-excursion
23f87bed
MB
8809 (let (gnus-visual
8810 gnus-treat-strip-trailing-blank-lines
8811 gnus-treat-strip-leading-blank-lines
8812 gnus-treat-strip-multiple-blank-lines
8813 gnus-treat-hide-boring-headers
8814 gnus-treat-fold-newsgroups
8815 gnus-article-prepare-hook)
8816 (gnus-message 6 "Executing %s..." (key-description command))
8817 ;; We'd like to execute COMMAND interactively so as to give arguments.
8818 (gnus-execute header regexp
8819 `(call-interactively ',(key-binding command))
8820 backward)
8821 (gnus-message 6 "Executing %s...done" (key-description command))))))
eec82323
LMI
8822
8823(defun gnus-summary-beginning-of-article ()
8824 "Scroll the article back to the beginning."
8825 (interactive)
eec82323
LMI
8826 (gnus-summary-select-article)
8827 (gnus-configure-windows 'article)
8828 (gnus-eval-in-buffer-window gnus-article-buffer
8829 (widen)
8830 (goto-char (point-min))
23f87bed 8831 (when gnus-break-pages
eec82323
LMI
8832 (gnus-narrow-to-page))))
8833
8834(defun gnus-summary-end-of-article ()
8835 "Scroll to the end of the article."
8836 (interactive)
eec82323
LMI
8837 (gnus-summary-select-article)
8838 (gnus-configure-windows 'article)
8839 (gnus-eval-in-buffer-window gnus-article-buffer
8840 (widen)
8841 (goto-char (point-max))
8842 (recenter -3)
23f87bed
MB
8843 (when gnus-break-pages
8844 (when (re-search-backward page-delimiter nil t)
8845 (narrow-to-region (match-end 0) (point-max)))
eec82323
LMI
8846 (gnus-narrow-to-page))))
8847
23f87bed
MB
8848(defun gnus-summary-print-truncate-and-quote (string &optional len)
8849 "Truncate to LEN and quote all \"(\"'s in STRING."
8850 (gnus-replace-in-string (if (and len (> (length string) len))
8851 (substring string 0 len)
8852 string)
8853 "[()]" "\\\\\\&"))
8854
6748645f 8855(defun gnus-summary-print-article (&optional filename n)
23f87bed
MB
8856 "Generate and print a PostScript image of the process-marked (mail) articles.
8857
8858If used interactively, print the current article if none are
8859process-marked. With prefix arg, prompt the user for the name of the
8860file to save in.
6748645f 8861
23f87bed
MB
8862When used from Lisp, accept two optional args FILENAME and N. N means
8863to print the next N articles. If N is negative, print the N previous
8864articles. If N is nil and articles have been marked with the process
8865mark, print these instead.
eec82323 8866
16409b0b 8867If the optional first argument FILENAME is nil, send the image to the
6748645f
LMI
8868printer. If FILENAME is a string, save the PostScript image in a file with
8869that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 8870to save in."
676a7cc9 8871 (interactive (list (ps-print-preprint current-prefix-arg)))
6748645f
LMI
8872 (dolist (article (gnus-summary-work-articles n))
8873 (gnus-summary-select-article nil nil 'pseudo article)
8874 (gnus-eval-in-buffer-window gnus-article-buffer
23f87bed 8875 (gnus-print-buffer))
676a7cc9
SZ
8876 (gnus-summary-remove-process-mark article))
8877 (ps-despool filename))
eec82323 8878
23f87bed
MB
8879(defun gnus-print-buffer ()
8880 (let ((buffer (generate-new-buffer " *print*")))
8881 (unwind-protect
8882 (progn
8883 (copy-to-buffer buffer (point-min) (point-max))
8884 (set-buffer buffer)
8885 (gnus-remove-text-with-property 'gnus-decoration)
8886 (when (gnus-visual-p 'article-highlight 'highlight)
8887 ;; Copy-to-buffer doesn't copy overlay. So redo
8888 ;; highlight.
8889 (let ((gnus-article-buffer buffer))
8890 (gnus-article-highlight-citation t)
8891 (gnus-article-highlight-signature)
8892 (gnus-article-emphasize)
8893 (gnus-article-delete-invisible-text)))
8894 (let ((ps-left-header
8895 (list
8896 (concat "("
8897 (gnus-summary-print-truncate-and-quote
8898 (mail-header-subject gnus-current-headers)
8899 66) ")")
8900 (concat "("
8901 (gnus-summary-print-truncate-and-quote
8902 (mail-header-from gnus-current-headers)
8903 45) ")")))
8904 (ps-right-header
8905 (list
8906 "/pagenumberstring load"
8907 (concat "("
8908 (mail-header-date gnus-current-headers) ")"))))
8909 (gnus-run-hooks 'gnus-ps-print-hook)
8910 (save-excursion
8911 (if window-system
8912 (ps-spool-buffer-with-faces)
8913 (ps-spool-buffer)))))
8914 (kill-buffer buffer))))
8915
eec82323 8916(defun gnus-summary-show-article (&optional arg)
23f87bed 8917 "Force redisplaying of the current article.
16409b0b
GM
8918If ARG (the prefix) is a number, show the article with the charset
8919defined in `gnus-summary-show-article-charset-alist', or the charset
23f87bed 8920input.
16409b0b 8921If ARG (the prefix) is non-nil and not a number, show the raw article
23f87bed
MB
8922without any article massaging functions being run. Normally, the key
8923strokes are `C-u g'."
eec82323 8924 (interactive "P")
16409b0b
GM
8925 (cond
8926 ((numberp arg)
23f87bed 8927 (gnus-summary-show-article t)
16409b0b
GM
8928 (let ((gnus-newsgroup-charset
8929 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
23f87bed
MB
8930 (mm-read-coding-system
8931 "View as charset: " ;; actually it is coding system.
8932 (save-excursion
8933 (set-buffer gnus-article-buffer)
8934 (mm-detect-coding-region (point) (point-max))))))
16409b0b 8935 (gnus-newsgroup-ignored-charsets 'gnus-all))
23f87bed
MB
8936 (gnus-summary-select-article nil 'force)
8937 (let ((deps gnus-newsgroup-dependencies)
8938 head header lines)
8939 (save-excursion
8940 (set-buffer gnus-original-article-buffer)
8941 (save-restriction
8942 (message-narrow-to-head)
8943 (setq head (buffer-string))
8944 (goto-char (point-min))
8945 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8946 (goto-char (point-max))
8947 (widen)
8948 (setq lines (1- (count-lines (point) (point-max))))))
8949 (with-temp-buffer
8950 (insert (format "211 %d Article retrieved.\n"
8951 (cdr gnus-article-current)))
8952 (insert head)
8953 (if lines (insert (format "Lines: %d\n" lines)))
8954 (insert ".\n")
8955 (let ((nntp-server-buffer (current-buffer)))
8956 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8957 (gnus-data-set-header
8958 (gnus-data-find (cdr gnus-article-current))
8959 header)
8960 (gnus-summary-update-article-line
8961 (cdr gnus-article-current) header)
8962 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8963 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
16409b0b
GM
8964 ((not arg)
8965 ;; Select the article the normal way.
8966 (gnus-summary-select-article nil 'force))
8967 (t
8968 ;; We have to require this here to make sure that the following
8969 ;; dynamic binding isn't shadowed by autoloading.
8970 (require 'gnus-async)
8971 (require 'gnus-art)
eec82323
LMI
8972 ;; Bind the article treatment functions to nil.
8973 (let ((gnus-have-all-headers t)
eec82323 8974 gnus-article-prepare-hook
16409b0b
GM
8975 gnus-article-decode-hook
8976 gnus-display-mime-function
8977 gnus-break-pages)
8978 ;; Destroy any MIME parts.
8979 (when (gnus-buffer-live-p gnus-article-buffer)
8980 (save-excursion
8981 (set-buffer gnus-article-buffer)
8982 (mm-destroy-parts gnus-article-mime-handles)
8983 ;; Set it to nil for safety reason.
8984 (setq gnus-article-mime-handle-alist nil)
8985 (setq gnus-article-mime-handles nil)))
8986 (gnus-summary-select-article nil 'force))))
eec82323
LMI
8987 (gnus-summary-goto-subject gnus-current-article)
8988 (gnus-summary-position-point))
8989
23f87bed
MB
8990(defun gnus-summary-show-raw-article ()
8991 "Show the raw article without any article massaging functions being run."
8992 (interactive)
8993 (gnus-summary-show-article t))
8994
eec82323
LMI
8995(defun gnus-summary-verbose-headers (&optional arg)
8996 "Toggle permanent full header display.
8997If ARG is a positive number, turn header display on.
8998If ARG is a negative number, turn header display off."
8999 (interactive "P")
eec82323
LMI
9000 (setq gnus-show-all-headers
9001 (cond ((or (not (numberp arg))
9002 (zerop arg))
9003 (not gnus-show-all-headers))
9004 ((natnump arg)
9005 t)))
9006 (gnus-summary-show-article))
9007
9008(defun gnus-summary-toggle-header (&optional arg)
9009 "Show the headers if they are hidden, or hide them if they are shown.
9010If ARG is a positive number, show the entire header.
9011If ARG is a negative number, hide the unwanted header lines."
9012 (interactive "P")
23f87bed
MB
9013 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9014 (get-buffer-window gnus-article-buffer t))))
9015 (with-current-buffer gnus-article-buffer
9016 (widen)
9017 (article-narrow-to-head)
16409b0b
GM
9018 (let* ((buffer-read-only nil)
9019 (inhibit-point-motion-hooks t)
23f87bed
MB
9020 (hidden (if (numberp arg)
9021 (>= arg 0)
f0096211
MB
9022 (or (not (looking-at "[^ \t\n]+:"))
9023 (gnus-article-hidden-text-p 'headers))))
23f87bed
MB
9024 s e)
9025 (delete-region (point-min) (point-max))
667e0ba6
SM
9026 (with-current-buffer gnus-original-article-buffer
9027 (goto-char (setq s (point-min)))
23f87bed
MB
9028 (setq e (if (search-forward "\n\n" nil t)
9029 (1- (point))
9030 (point-max))))
667e0ba6 9031 (insert-buffer-substring gnus-original-article-buffer s e)
23f87bed
MB
9032 (run-hooks 'gnus-article-decode-hook)
9033 (if hidden
9034 (let ((gnus-treat-hide-headers nil)
9035 (gnus-treat-hide-boring-headers nil))
9036 (gnus-delete-wash-type 'headers)
9037 (gnus-treat-article 'head))
9038 (gnus-treat-article 'head))
9039 (widen)
9040 (if window
9041 (set-window-start window (goto-char (point-min))))
9042 (if gnus-break-pages
9043 (gnus-narrow-to-page)
9044 (when (gnus-visual-p 'page-marker)
9045 (let ((buffer-read-only nil))
9046 (gnus-remove-text-with-property 'gnus-prev)
9047 (gnus-remove-text-with-property 'gnus-next))))
16409b0b 9048 (gnus-set-mode-line 'article)))))
eec82323
LMI
9049
9050(defun gnus-summary-show-all-headers ()
9051 "Make all header lines visible."
9052 (interactive)
23f87bed 9053 (gnus-summary-toggle-header 1))
eec82323 9054
eec82323
LMI
9055(defun gnus-summary-caesar-message (&optional arg)
9056 "Caesar rotate the current article by 13.
9057The numerical prefix specifies how many places to rotate each letter
9058forward."
9059 (interactive "P")
eec82323
LMI
9060 (gnus-summary-select-article)
9061 (let ((mail-header-separator ""))
9062 (gnus-eval-in-buffer-window gnus-article-buffer
9063 (save-restriction
9064 (widen)
9065 (let ((start (window-start))
9066 buffer-read-only)
9067 (message-caesar-buffer-body arg)
ff4d3926
MB
9068 (set-window-start (get-buffer-window (current-buffer)) start)))))
9069 ;; Create buttons and stuff...
9070 (gnus-treat-article nil))
eec82323 9071
23f87bed
MB
9072(autoload 'unmorse-region "morse"
9073 "Convert morse coded text in region to ordinary ASCII text."
9074 t)
9075
9076(defun gnus-summary-morse-message (&optional arg)
9077 "Morse decode the current article."
9078 (interactive "P")
9079 (gnus-summary-select-article)
9080 (let ((mail-header-separator ""))
9081 (gnus-eval-in-buffer-window gnus-article-buffer
9082 (save-excursion
9083 (save-restriction
9084 (widen)
9085 (let ((pos (window-start))
9086 buffer-read-only)
9087 (goto-char (point-min))
9088 (when (message-goto-body)
9089 (gnus-narrow-to-body))
9090 (goto-char (point-min))
9091