(gnus-uu-default-view-rules): Don't use `xv'.
[bpt/emacs.git] / lisp / gnus / gnus-sum.el
CommitLineData
eec82323 1;;; gnus-sum.el --- summary mode commands for Gnus
6748645f 2;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
eec82323 3
6748645f 4;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
eec82323
LMI
5;; Keywords: news
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software; you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation; either version 2, or (at your option)
12;; any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs; see the file COPYING. If not, write to the
21;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22;; Boston, MA 02111-1307, USA.
23
24;;; Commentary:
25
26;;; Code:
27
5ab7173c
RS
28(eval-when-compile (require 'cl))
29
6748645f
LMI
30(eval-when-compile (require 'cl))
31
eec82323
LMI
32(require 'gnus)
33(require 'gnus-group)
34(require 'gnus-spec)
35(require 'gnus-range)
36(require 'gnus-int)
37(require 'gnus-undo)
6748645f
LMI
38(require 'gnus-util)
39(autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
eec82323
LMI
40
41(defcustom gnus-kill-summary-on-exit t
42 "*If non-nil, kill the summary buffer when you exit from it.
43If nil, the summary will become a \"*Dead Summary*\" buffer, and
44it will be killed sometime later."
45 :group 'gnus-summary-exit
46 :type 'boolean)
47
48(defcustom gnus-fetch-old-headers nil
49 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
50If an unread article in the group refers to an older, already read (or
51just marked as read) article, the old article will not normally be
52displayed in the Summary buffer. If this variable is non-nil, Gnus
53will attempt to grab the headers to the old articles, and thereby
6748645f
LMI
54build complete threads. If it has the value `some', only enough
55headers to connect otherwise loose threads will be displayed. This
56variable can also be a number. In that case, no more than that number
57of old headers will be fetched. If it has the value `invisible', all
58old headers will be fetched, but none will be displayed.
eec82323
LMI
59
60The server has to support NOV for any of this to work."
61 :group 'gnus-thread
62 :type '(choice (const :tag "off" nil)
63 (const some)
64 number
65 (sexp :menu-tag "other" t)))
66
6748645f
LMI
67(defcustom gnus-refer-thread-limit 200
68 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
69If t, fetch all the available old headers."
70 :group 'gnus-thread
71 :type '(choice number
72 (sexp :menu-tag "other" t)))
73
eec82323
LMI
74(defcustom gnus-summary-make-false-root 'adopt
75 "*nil means that Gnus won't gather loose threads.
76If the root of a thread has expired or been read in a previous
77session, the information necessary to build a complete thread has been
78lost. Instead of having many small sub-threads from this original thread
79scattered all over the summary buffer, Gnus can gather them.
80
81If non-nil, Gnus will try to gather all loose sub-threads from an
82original thread into one large thread.
83
84If this variable is non-nil, it should be one of `none', `adopt',
85`dummy' or `empty'.
86
87If this variable is `none', Gnus will not make a false root, but just
88present the sub-threads after another.
89If this variable is `dummy', Gnus will create a dummy root that will
90have all the sub-threads as children.
91If this variable is `adopt', Gnus will make one of the \"children\"
92the parent and mark all the step-children as such.
93If this variable is `empty', the \"children\" are printed with empty
94subject fields. (Or rather, they will be printed with a string
95given by the `gnus-summary-same-subject' variable.)"
96 :group 'gnus-thread
97 :type '(choice (const :tag "off" nil)
98 (const none)
99 (const dummy)
100 (const adopt)
101 (const empty)))
102
103(defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
104 "*A regexp to match subjects to be excluded from loose thread gathering.
105As loose thread gathering is done on subjects only, that means that
106there can be many false gatherings performed. By rooting out certain
107common subjects, gathering might become saner."
108 :group 'gnus-thread
109 :type 'regexp)
110
111(defcustom gnus-summary-gather-subject-limit nil
112 "*Maximum length of subject comparisons when gathering loose threads.
113Use nil to compare full subjects. Setting this variable to a low
114number will help gather threads that have been corrupted by
115newsreaders chopping off subject lines, but it might also mean that
116unrelated articles that have subject that happen to begin with the
117same few characters will be incorrectly gathered.
118
119If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
120comparing subjects."
121 :group 'gnus-thread
122 :type '(choice (const :tag "off" nil)
123 (const fuzzy)
124 (sexp :menu-tag "on" t)))
125
6748645f
LMI
126(defcustom gnus-simplify-subject-functions nil
127 "List of functions taking a string argument that simplify subjects.
128The functions are applied recursively.
129
130Useful functions to put in this list include: `gnus-simplify-subject-re',
131`gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
132 :group 'gnus-thread
133 :type '(repeat function))
134
eec82323
LMI
135(defcustom gnus-simplify-ignored-prefixes nil
136 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
137 :group 'gnus-thread
138 :type '(choice (const :tag "off" nil)
139 regexp))
140
141(defcustom gnus-build-sparse-threads nil
142 "*If non-nil, fill in the gaps in threads.
143If `some', only fill in the gaps that are needed to tie loose threads
144together. If `more', fill in all leaf nodes that Gnus can find. If
145non-nil and non-`some', fill in all gaps that Gnus manages to guess."
146 :group 'gnus-thread
147 :type '(choice (const :tag "off" nil)
148 (const some)
149 (const more)
150 (sexp :menu-tag "all" t)))
151
152(defcustom gnus-summary-thread-gathering-function
153 'gnus-gather-threads-by-subject
6748645f 154 "*Function used for gathering loose threads.
eec82323
LMI
155There are two pre-defined functions: `gnus-gather-threads-by-subject',
156which only takes Subjects into consideration; and
157`gnus-gather-threads-by-references', which compared the References
158headers of the articles to find matches."
159 :group 'gnus-thread
22115a9e
RS
160 :type '(radio (function-item gnus-gather-threads-by-subject)
161 (function-item gnus-gather-threads-by-references)
162 (function :tag "other")))
eec82323 163
eec82323
LMI
164(defcustom gnus-summary-same-subject ""
165 "*String indicating that the current article has the same subject as the previous.
166This variable will only be used if the value of
167`gnus-summary-make-false-root' is `empty'."
168 :group 'gnus-summary-format
169 :type 'string)
170
171(defcustom gnus-summary-goto-unread t
172 "*If t, marking commands will go to the next unread article.
173If `never', commands that usually go to the next unread article, will
174go to the next article, whether it is read or not.
175If nil, only the marking commands will go to the next (un)read article."
176 :group 'gnus-summary-marks
177 :link '(custom-manual "(gnus)Setting Marks")
178 :type '(choice (const :tag "off" nil)
179 (const never)
180 (sexp :menu-tag "on" t)))
181
182(defcustom gnus-summary-default-score 0
183 "*Default article score level.
184All scores generated by the score files will be added to this score.
185If this variable is nil, scoring will be disabled."
186 :group 'gnus-score-default
187 :type '(choice (const :tag "disable")
188 integer))
189
190(defcustom gnus-summary-zcore-fuzz 0
191 "*Fuzziness factor for the zcore in the summary buffer.
192Articles with scores closer than this to `gnus-summary-default-score'
193will not be marked."
194 :group 'gnus-summary-format
195 :type 'integer)
196
197(defcustom gnus-simplify-subject-fuzzy-regexp nil
198 "*Strings to be removed when doing fuzzy matches.
199This can either be a regular expression or list of regular expressions
200that will be removed from subject strings if fuzzy subject
201simplification is selected."
202 :group 'gnus-thread
203 :type '(repeat regexp))
204
205(defcustom gnus-show-threads t
206 "*If non-nil, display threads in summary mode."
207 :group 'gnus-thread
208 :type 'boolean)
209
210(defcustom gnus-thread-hide-subtree nil
211 "*If non-nil, hide all threads initially.
212If threads are hidden, you have to run the command
213`gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
214to expose hidden threads."
215 :group 'gnus-thread
216 :type 'boolean)
217
218(defcustom gnus-thread-hide-killed t
219 "*If non-nil, hide killed threads automatically."
220 :group 'gnus-thread
221 :type 'boolean)
222
6748645f
LMI
223(defcustom gnus-thread-ignore-subject t
224 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
225If nil, articles that have different subjects from their parents will
226start separate threads."
eec82323
LMI
227 :group 'gnus-thread
228 :type 'boolean)
229
230(defcustom gnus-thread-operation-ignore-subject t
231 "*If non-nil, subjects will be ignored when doing thread commands.
232This affects commands like `gnus-summary-kill-thread' and
233`gnus-summary-lower-thread'.
234
235If this variable is nil, articles in the same thread with different
236subjects will not be included in the operation in question. If this
237variable is `fuzzy', only articles that have subjects that are fuzzily
238equal will be included."
239 :group 'gnus-thread
240 :type '(choice (const :tag "off" nil)
241 (const fuzzy)
242 (sexp :tag "on" t)))
243
244(defcustom gnus-thread-indent-level 4
245 "*Number that says how much each sub-thread should be indented."
246 :group 'gnus-thread
247 :type 'integer)
248
249(defcustom gnus-auto-extend-newsgroup t
250 "*If non-nil, extend newsgroup forward and backward when requested."
251 :group 'gnus-summary-choose
252 :type 'boolean)
253
254(defcustom gnus-auto-select-first t
255 "*If nil, don't select the first unread article when entering a group.
256If this variable is `best', select the highest-scored unread article
257in the group. If neither nil nor `best', select the first unread
258article.
259
260If you want to prevent automatic selection of the first unread article
261in some newsgroups, set the variable to nil in
262`gnus-select-group-hook'."
263 :group 'gnus-group-select
264 :type '(choice (const :tag "none" nil)
265 (const best)
266 (sexp :menu-tag "first" t)))
267
268(defcustom gnus-auto-select-next t
269 "*If non-nil, offer to go to the next group from the end of the previous.
270If the value is t and the next newsgroup is empty, Gnus will exit
271summary mode and go back to group mode. If the value is neither nil
272nor t, Gnus will select the following unread newsgroup. In
273particular, if the value is the symbol `quietly', the next unread
274newsgroup will be selected without any confirmation, and if it is
275`almost-quietly', the next group will be selected without any
276confirmation if you are located on the last article in the group.
277Finally, if this variable is `slightly-quietly', the `Z n' command
278will go to the next group without confirmation."
279 :group 'gnus-summary-maneuvering
280 :type '(choice (const :tag "off" nil)
281 (const quietly)
282 (const almost-quietly)
283 (const slightly-quietly)
284 (sexp :menu-tag "on" t)))
285
286(defcustom gnus-auto-select-same nil
6748645f
LMI
287 "*If non-nil, select the next article with the same subject.
288If there are no more articles with the same subject, go to
289the first unread article."
eec82323
LMI
290 :group 'gnus-summary-maneuvering
291 :type 'boolean)
292
293(defcustom gnus-summary-check-current nil
294 "*If non-nil, consider the current article when moving.
295The \"unread\" movement commands will stay on the same line if the
296current article is unread."
297 :group 'gnus-summary-maneuvering
298 :type 'boolean)
299
300(defcustom gnus-auto-center-summary t
301 "*If non-nil, always center the current summary buffer.
302In particular, if `vertical' do only vertical recentering. If non-nil
303and non-`vertical', do both horizontal and vertical recentering."
304 :group 'gnus-summary-maneuvering
305 :type '(choice (const :tag "none" nil)
306 (const vertical)
307 (sexp :menu-tag "both" t)))
308
309(defcustom gnus-show-all-headers nil
310 "*If non-nil, don't hide any headers."
311 :group 'gnus-article-hiding
312 :group 'gnus-article-headers
313 :type 'boolean)
314
315(defcustom gnus-summary-ignore-duplicates nil
316 "*If non-nil, ignore articles with identical Message-ID headers."
317 :group 'gnus-summary
318 :type 'boolean)
6748645f 319
eec82323
LMI
320(defcustom gnus-single-article-buffer t
321 "*If non-nil, display all articles in the same buffer.
322If nil, each group will get its own article buffer."
323 :group 'gnus-article-various
324 :type 'boolean)
325
326(defcustom gnus-break-pages t
327 "*If non-nil, do page breaking on articles.
328The page delimiter is specified by the `gnus-page-delimiter'
329variable."
330 :group 'gnus-article-various
331 :type 'boolean)
332
333(defcustom gnus-show-mime nil
334 "*If non-nil, do mime processing of articles.
335The articles will simply be fed to the function given by
336`gnus-show-mime-method'."
337 :group 'gnus-article-mime
338 :type 'boolean)
339
340(defcustom gnus-move-split-methods nil
341 "*Variable used to suggest where articles are to be moved to.
342It uses the same syntax as the `gnus-split-methods' variable."
343 :group 'gnus-summary-mail
6748645f
LMI
344 :type '(repeat (choice (list :value (fun) function)
345 (cons :value ("" "") regexp (repeat string))
346 (sexp :value nil))))
eec82323 347
6748645f 348(defcustom gnus-unread-mark ? ;space
eec82323
LMI
349 "*Mark used for unread articles."
350 :group 'gnus-summary-marks
351 :type 'character)
352
353(defcustom gnus-ticked-mark ?!
354 "*Mark used for ticked articles."
355 :group 'gnus-summary-marks
356 :type 'character)
357
358(defcustom gnus-dormant-mark ??
359 "*Mark used for dormant articles."
360 :group 'gnus-summary-marks
361 :type 'character)
362
363(defcustom gnus-del-mark ?r
364 "*Mark used for del'd articles."
365 :group 'gnus-summary-marks
366 :type 'character)
367
368(defcustom gnus-read-mark ?R
369 "*Mark used for read articles."
370 :group 'gnus-summary-marks
371 :type 'character)
372
373(defcustom gnus-expirable-mark ?E
374 "*Mark used for expirable articles."
375 :group 'gnus-summary-marks
376 :type 'character)
377
378(defcustom gnus-killed-mark ?K
379 "*Mark used for killed articles."
380 :group 'gnus-summary-marks
381 :type 'character)
382
383(defcustom gnus-souped-mark ?F
384 "*Mark used for killed articles."
385 :group 'gnus-summary-marks
386 :type 'character)
387
388(defcustom gnus-kill-file-mark ?X
389 "*Mark used for articles killed by kill files."
390 :group 'gnus-summary-marks
391 :type 'character)
392
393(defcustom gnus-low-score-mark ?Y
394 "*Mark used for articles with a low score."
395 :group 'gnus-summary-marks
396 :type 'character)
397
398(defcustom gnus-catchup-mark ?C
399 "*Mark used for articles that are caught up."
400 :group 'gnus-summary-marks
401 :type 'character)
402
403(defcustom gnus-replied-mark ?A
404 "*Mark used for articles that have been replied to."
405 :group 'gnus-summary-marks
406 :type 'character)
407
408(defcustom gnus-cached-mark ?*
409 "*Mark used for articles that are in the cache."
410 :group 'gnus-summary-marks
411 :type 'character)
412
413(defcustom gnus-saved-mark ?S
414 "*Mark used for articles that have been saved to."
415 :group 'gnus-summary-marks
416 :type 'character)
417
418(defcustom gnus-ancient-mark ?O
419 "*Mark used for ancient articles."
420 :group 'gnus-summary-marks
421 :type 'character)
422
423(defcustom gnus-sparse-mark ?Q
424 "*Mark used for sparsely reffed articles."
425 :group 'gnus-summary-marks
426 :type 'character)
427
428(defcustom gnus-canceled-mark ?G
429 "*Mark used for canceled articles."
430 :group 'gnus-summary-marks
431 :type 'character)
432
433(defcustom gnus-duplicate-mark ?M
434 "*Mark used for duplicate articles."
435 :group 'gnus-summary-marks
436 :type 'character)
437
6748645f
LMI
438(defcustom gnus-undownloaded-mark ?@
439 "*Mark used for articles that weren't downloaded."
440 :group 'gnus-summary-marks
441 :type 'character)
442
443(defcustom gnus-downloadable-mark ?%
444 "*Mark used for articles that are to be downloaded."
445 :group 'gnus-summary-marks
446 :type 'character)
447
448(defcustom gnus-unsendable-mark ?=
449 "*Mark used for articles that won't be sent."
450 :group 'gnus-summary-marks
451 :type 'character)
452
eec82323
LMI
453(defcustom gnus-score-over-mark ?+
454 "*Score mark used for articles with high scores."
455 :group 'gnus-summary-marks
456 :type 'character)
457
458(defcustom gnus-score-below-mark ?-
459 "*Score mark used for articles with low scores."
460 :group 'gnus-summary-marks
461 :type 'character)
462
6748645f 463(defcustom gnus-empty-thread-mark ? ;space
eec82323
LMI
464 "*There is no thread under the article."
465 :group 'gnus-summary-marks
466 :type 'character)
467
468(defcustom gnus-not-empty-thread-mark ?=
469 "*There is a thread under the article."
470 :group 'gnus-summary-marks
471 :type 'character)
472
473(defcustom gnus-view-pseudo-asynchronously nil
474 "*If non-nil, Gnus will view pseudo-articles asynchronously."
475 :group 'gnus-extract-view
476 :type 'boolean)
477
478(defcustom gnus-view-pseudos nil
479 "*If `automatic', pseudo-articles will be viewed automatically.
480If `not-confirm', pseudos will be viewed automatically, and the user
481will not be asked to confirm the command."
482 :group 'gnus-extract-view
483 :type '(choice (const :tag "off" nil)
484 (const automatic)
485 (const not-confirm)))
486
487(defcustom gnus-view-pseudos-separately t
488 "*If non-nil, one pseudo-article will be created for each file to be viewed.
489If nil, all files that use the same viewing command will be given as a
490list of parameters to that command."
491 :group 'gnus-extract-view
492 :type 'boolean)
493
494(defcustom gnus-insert-pseudo-articles t
495 "*If non-nil, insert pseudo-articles when decoding articles."
496 :group 'gnus-extract-view
497 :type 'boolean)
498
499(defcustom gnus-summary-dummy-line-format
6748645f 500 " %(: :%) %S\n"
eec82323
LMI
501 "*The format specification for the dummy roots in the summary buffer.
502It works along the same lines as a normal formatting string,
503with some simple extensions.
504
505%S The subject"
506 :group 'gnus-threading
507 :type 'string)
508
509(defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
510 "*The format specification for the summary mode line.
511It works along the same lines as a normal formatting string,
512with some simple extensions:
513
514%G Group name
515%p Unprefixed group name
516%A Current article number
6748645f 517%z Current article score
eec82323
LMI
518%V Gnus version
519%U Number of unread articles in the group
520%e Number of unselected articles in the group
521%Z A string with unread/unselected article counts
522%g Shortish group name
523%S Subject of the current article
524%u User-defined spec
525%s Current score file name
526%d Number of dormant articles
527%r Number of articles that have been marked as read in this session
528%E Number of articles expunged by the score files"
529 :group 'gnus-summary-format
530 :type 'string)
531
532(defcustom gnus-summary-mark-below 0
533 "*Mark all articles with a score below this variable as read.
534This variable is local to each summary buffer and usually set by the
535score file."
536 :group 'gnus-score-default
537 :type 'integer)
538
539(defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
540 "*List of functions used for sorting articles in the summary buffer.
541This variable is only used when not using a threaded display."
542 :group 'gnus-summary-sort
543 :type '(repeat (choice (function-item gnus-article-sort-by-number)
544 (function-item gnus-article-sort-by-author)
545 (function-item gnus-article-sort-by-subject)
546 (function-item gnus-article-sort-by-date)
547 (function-item gnus-article-sort-by-score)
548 (function :tag "other"))))
549
550(defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
551 "*List of functions used for sorting threads in the summary buffer.
552By default, threads are sorted by article number.
553
554Each function takes two threads and return non-nil if the first thread
555should be sorted before the other. If you use more than one function,
556the primary sort function should be the last. You should probably
557always include `gnus-thread-sort-by-number' in the list of sorting
558functions -- preferably first.
559
560Ready-made functions include `gnus-thread-sort-by-number',
561`gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
562`gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
563`gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
564 :group 'gnus-summary-sort
565 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
566 (function-item gnus-thread-sort-by-author)
567 (function-item gnus-thread-sort-by-subject)
568 (function-item gnus-thread-sort-by-date)
569 (function-item gnus-thread-sort-by-score)
570 (function-item gnus-thread-sort-by-total-score)
571 (function :tag "other"))))
572
573(defcustom gnus-thread-score-function '+
574 "*Function used for calculating the total score of a thread.
575
576The function is called with the scores of the article and each
577subthread and should then return the score of the thread.
578
579Some functions you can use are `+', `max', or `min'."
580 :group 'gnus-summary-sort
581 :type 'function)
582
583(defcustom gnus-summary-expunge-below nil
6748645f
LMI
584 "All articles that have a score less than this variable will be expunged.
585This variable is local to the summary buffers."
eec82323
LMI
586 :group 'gnus-score-default
587 :type '(choice (const :tag "off" nil)
588 integer))
589
590(defcustom gnus-thread-expunge-below nil
591 "All threads that have a total score less than this variable will be expunged.
592See `gnus-thread-score-function' for en explanation of what a
6748645f
LMI
593\"thread score\" is.
594
595This variable is local to the summary buffers."
eec82323
LMI
596 :group 'gnus-treading
597 :group 'gnus-score-default
598 :type '(choice (const :tag "off" nil)
599 integer))
600
601(defcustom gnus-summary-mode-hook nil
602 "*A hook for Gnus summary mode.
603This hook is run before any variables are set in the summary buffer."
604 :group 'gnus-summary-various
605 :type 'hook)
606
607(defcustom gnus-summary-menu-hook nil
608 "*Hook run after the creation of the summary mode menu."
609 :group 'gnus-summary-visual
610 :type 'hook)
611
612(defcustom gnus-summary-exit-hook nil
613 "*A hook called on exit from the summary buffer.
614It will be called with point in the group buffer."
615 :group 'gnus-summary-exit
616 :type 'hook)
617
618(defcustom gnus-summary-prepare-hook nil
619 "*A hook called after the summary buffer has been generated.
620If you want to modify the summary buffer, you can use this hook."
621 :group 'gnus-summary-various
622 :type 'hook)
623
6748645f
LMI
624(defcustom gnus-summary-prepared-hook nil
625 "*A hook called as the last thing after the summary buffer has been generated."
626 :group 'gnus-summary-various
627 :type 'hook)
628
eec82323
LMI
629(defcustom gnus-summary-generate-hook nil
630 "*A hook run just before generating the summary buffer.
631This hook is commonly used to customize threading variables and the
632like."
633 :group 'gnus-summary-various
634 :type 'hook)
635
636(defcustom gnus-select-group-hook nil
637 "*A hook called when a newsgroup is selected.
638
639If you'd like to simplify subjects like the
640`gnus-summary-next-same-subject' command does, you can use the
641following hook:
642
643 (setq gnus-select-group-hook
644 (list
645 (lambda ()
646 (mapcar (lambda (header)
647 (mail-header-set-subject
648 header
649 (gnus-simplify-subject
650 (mail-header-subject header) 're-only)))
651 gnus-newsgroup-headers))))"
652 :group 'gnus-group-select
653 :type 'hook)
654
655(defcustom gnus-select-article-hook nil
656 "*A hook called when an article is selected."
657 :group 'gnus-summary-choose
658 :type 'hook)
659
660(defcustom gnus-visual-mark-article-hook
661 (list 'gnus-highlight-selected-summary)
662 "*Hook run after selecting an article in the summary buffer.
663It is meant to be used for highlighting the article in some way. It
664is not run if `gnus-visual' is nil."
665 :group 'gnus-summary-visual
666 :type 'hook)
667
80bb5a78 668(defcustom gnus-structured-field-decoder
06dee88c
KH
669 (if (and (featurep 'mule)
670 (boundp 'enable-multibyte-characters))
80bb5a78 671 (lambda (string)
06dee88c 672 (if (and enable-multibyte-characters gnus-mule-coding-system)
80bb5a78 673 (decode-coding-string string gnus-mule-coding-system)
06dee88c
KH
674 string))
675 'identity)
2bd3dcae
KH
676 "Function to decode non-ASCII characters in structured field for summary."
677 :group 'gnus-various
678 :type 'function)
679
80bb5a78 680(defcustom gnus-unstructured-field-decoder
06dee88c
KH
681 (if (and (featurep 'mule)
682 (boundp 'enable-multibyte-characters))
80bb5a78 683 (lambda (string)
06dee88c 684 (if (and enable-multibyte-characters gnus-mule-coding-system)
80bb5a78 685 (decode-coding-string string gnus-mule-coding-system)
06dee88c
KH
686 string))
687 'identity)
2bd3dcae
KH
688 "Function to decode non-ASCII characters in unstructured field for summary."
689 :group 'gnus-various
690 :type 'function)
691
eec82323 692(defcustom gnus-parse-headers-hook
a8151ef7 693 (list 'gnus-hack-decode-rfc1522 'gnus-decode-rfc1522)
eec82323
LMI
694 "*A hook called before parsing the headers."
695 :group 'gnus-various
696 :type 'hook)
697
698(defcustom gnus-exit-group-hook nil
699 "*A hook called when exiting (not quitting) summary mode."
700 :group 'gnus-various
701 :type 'hook)
702
703(defcustom gnus-summary-update-hook
704 (list 'gnus-summary-highlight-line)
705 "*A hook called when a summary line is changed.
706The hook will not be called if `gnus-visual' is nil.
707
708The default function `gnus-summary-highlight-line' will
709highlight the line according to the `gnus-summary-highlight'
710variable."
711 :group 'gnus-summary-visual
712 :type 'hook)
713
714(defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
715 "*A hook called when an article is selected for the first time.
716The hook is intended to mark an article as read (or unread)
717automatically when it is selected."
718 :group 'gnus-summary-choose
719 :type 'hook)
720
721(defcustom gnus-group-no-more-groups-hook nil
722 "*A hook run when returning to group mode having no more (unread) groups."
723 :group 'gnus-group-select
724 :type 'hook)
725
726(defcustom gnus-ps-print-hook nil
727 "*A hook run before ps-printing something from Gnus."
728 :group 'gnus-summary
729 :type 'hook)
730
731(defcustom gnus-summary-selected-face 'gnus-summary-selected-face
732 "Face used for highlighting the current article in the summary buffer."
733 :group 'gnus-summary-visual
734 :type 'face)
735
736(defcustom gnus-summary-highlight
737 '(((= mark gnus-canceled-mark)
738 . gnus-summary-cancelled-face)
739 ((and (> score default)
740 (or (= mark gnus-dormant-mark)
741 (= mark gnus-ticked-mark)))
742 . gnus-summary-high-ticked-face)
743 ((and (< score default)
744 (or (= mark gnus-dormant-mark)
745 (= mark gnus-ticked-mark)))
746 . gnus-summary-low-ticked-face)
747 ((or (= mark gnus-dormant-mark)
748 (= mark gnus-ticked-mark))
749 . gnus-summary-normal-ticked-face)
750 ((and (> score default) (= mark gnus-ancient-mark))
751 . gnus-summary-high-ancient-face)
752 ((and (< score default) (= mark gnus-ancient-mark))
753 . gnus-summary-low-ancient-face)
754 ((= mark gnus-ancient-mark)
755 . gnus-summary-normal-ancient-face)
756 ((and (> score default) (= mark gnus-unread-mark))
757 . gnus-summary-high-unread-face)
758 ((and (< score default) (= mark gnus-unread-mark))
759 . gnus-summary-low-unread-face)
6748645f
LMI
760 ((= mark gnus-unread-mark)
761 . gnus-summary-normal-unread-face)
762 ((and (> score default) (memq mark (list gnus-downloadable-mark
763 gnus-undownloaded-mark)))
764 . gnus-summary-high-unread-face)
765 ((and (< score default) (memq mark (list gnus-downloadable-mark
766 gnus-undownloaded-mark)))
767 . gnus-summary-low-unread-face)
768 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
eec82323
LMI
769 . gnus-summary-normal-unread-face)
770 ((> score default)
771 . gnus-summary-high-read-face)
772 ((< score default)
773 . gnus-summary-low-read-face)
774 (t
775 . gnus-summary-normal-read-face))
6748645f 776 "*Controls the highlighting of summary buffer lines.
eec82323
LMI
777
778A list of (FORM . FACE) pairs. When deciding how a a particular
779summary line should be displayed, each form is evaluated. The content
780of the face field after the first true form is used. You can change
781how those summary lines are displayed, by editing the face field.
782
783You can use the following variables in the FORM field.
784
785score: The articles score
786default: The default article score.
787below: The score below which articles are automatically marked as read.
788mark: The articles mark."
789 :group 'gnus-summary-visual
790 :type '(repeat (cons (sexp :tag "Form" nil)
791 face)))
792
6748645f
LMI
793(defcustom gnus-alter-header-function nil
794 "Function called to allow alteration of article header structures.
795The function is called with one parameter, the article header vector,
796which it may alter in any way.")
eec82323
LMI
797
798;;; Internal variables
799
800(defvar gnus-scores-exclude-files nil)
801(defvar gnus-page-broken nil)
802
803(defvar gnus-original-article nil)
804(defvar gnus-article-internal-prepare-hook nil)
805(defvar gnus-newsgroup-process-stack nil)
806
807(defvar gnus-thread-indent-array nil)
808(defvar gnus-thread-indent-array-level gnus-thread-indent-level)
809
810;; Avoid highlighting in kill files.
811(defvar gnus-summary-inhibit-highlight nil)
812(defvar gnus-newsgroup-selected-overlay nil)
813(defvar gnus-inhibit-limiting nil)
814(defvar gnus-newsgroup-adaptive-score-file nil)
815(defvar gnus-current-score-file nil)
816(defvar gnus-current-move-group nil)
817(defvar gnus-current-copy-group nil)
818(defvar gnus-current-crosspost-group nil)
819
820(defvar gnus-newsgroup-dependencies nil)
821(defvar gnus-newsgroup-adaptive nil)
822(defvar gnus-summary-display-article-function nil)
823(defvar gnus-summary-highlight-line-function nil
824 "Function called after highlighting a summary line.")
825
826(defvar gnus-summary-line-format-alist
827 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
828 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
829 (?s gnus-tmp-subject-or-nil ?s)
830 (?n gnus-tmp-name ?s)
831 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
832 ?s)
833 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
834 gnus-tmp-from) ?s)
835 (?F gnus-tmp-from ?s)
836 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
837 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
838 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
6748645f 839 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
eec82323
LMI
840 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
841 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
842 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
843 (?L gnus-tmp-lines ?d)
844 (?I gnus-tmp-indentation ?s)
845 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
846 (?R gnus-tmp-replied ?c)
847 (?\[ gnus-tmp-opening-bracket ?c)
848 (?\] gnus-tmp-closing-bracket ?c)
849 (?\> (make-string gnus-tmp-level ? ) ?s)
850 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
851 (?i gnus-tmp-score ?d)
852 (?z gnus-tmp-score-char ?c)
853 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
854 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
855 (?U gnus-tmp-unread ?c)
856 (?t (gnus-summary-number-of-articles-in-thread
857 (and (boundp 'thread) (car thread)) gnus-tmp-level)
858 ?d)
859 (?e (gnus-summary-number-of-articles-in-thread
860 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
861 ?c)
862 (?u gnus-tmp-user-defined ?s)
863 (?P (gnus-pick-line-number) ?d))
864 "An alist of format specifications that can appear in summary lines,
865and what variables they correspond with, along with the type of the
866variable (string, integer, character, etc).")
867
868(defvar gnus-summary-dummy-line-format-alist
869 `((?S gnus-tmp-subject ?s)
870 (?N gnus-tmp-number ?d)
871 (?u gnus-tmp-user-defined ?s)))
872
873(defvar gnus-summary-mode-line-format-alist
874 `((?G gnus-tmp-group-name ?s)
875 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
876 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
877 (?A gnus-tmp-article-number ?d)
878 (?Z gnus-tmp-unread-and-unselected ?s)
879 (?V gnus-version ?s)
880 (?U gnus-tmp-unread-and-unticked ?d)
881 (?S gnus-tmp-subject ?s)
882 (?e gnus-tmp-unselected ?d)
883 (?u gnus-tmp-user-defined ?s)
884 (?d (length gnus-newsgroup-dormant) ?d)
885 (?t (length gnus-newsgroup-marked) ?d)
886 (?r (length gnus-newsgroup-reads) ?d)
6748645f 887 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
eec82323
LMI
888 (?E gnus-newsgroup-expunged-tally ?d)
889 (?s (gnus-current-score-file-nondirectory) ?s)))
890
891(defvar gnus-last-search-regexp nil
892 "Default regexp for article search command.")
893
894(defvar gnus-last-shell-command nil
895 "Default shell command on article.")
896
897(defvar gnus-newsgroup-begin nil)
898(defvar gnus-newsgroup-end nil)
899(defvar gnus-newsgroup-last-rmail nil)
900(defvar gnus-newsgroup-last-mail nil)
901(defvar gnus-newsgroup-last-folder nil)
902(defvar gnus-newsgroup-last-file nil)
903(defvar gnus-newsgroup-auto-expire nil)
904(defvar gnus-newsgroup-active nil)
905
906(defvar gnus-newsgroup-data nil)
907(defvar gnus-newsgroup-data-reverse nil)
908(defvar gnus-newsgroup-limit nil)
909(defvar gnus-newsgroup-limits nil)
910
911(defvar gnus-newsgroup-unreads nil
912 "List of unread articles in the current newsgroup.")
913
914(defvar gnus-newsgroup-unselected nil
915 "List of unselected unread articles in the current newsgroup.")
916
917(defvar gnus-newsgroup-reads nil
918 "Alist of read articles and article marks in the current newsgroup.")
919
920(defvar gnus-newsgroup-expunged-tally nil)
921
922(defvar gnus-newsgroup-marked nil
923 "List of ticked articles in the current newsgroup (a subset of unread art).")
924
925(defvar gnus-newsgroup-killed nil
926 "List of ranges of articles that have been through the scoring process.")
927
928(defvar gnus-newsgroup-cached nil
929 "List of articles that come from the article cache.")
930
931(defvar gnus-newsgroup-saved nil
932 "List of articles that have been saved.")
933
934(defvar gnus-newsgroup-kill-headers nil)
935
936(defvar gnus-newsgroup-replied nil
937 "List of articles that have been replied to in the current newsgroup.")
938
939(defvar gnus-newsgroup-expirable nil
940 "List of articles in the current newsgroup that can be expired.")
941
942(defvar gnus-newsgroup-processable nil
943 "List of articles in the current newsgroup that can be processed.")
944
6748645f
LMI
945(defvar gnus-newsgroup-downloadable nil
946 "List of articles in the current newsgroup that can be processed.")
947
948(defvar gnus-newsgroup-undownloaded nil
949 "List of articles in the current newsgroup that haven't been downloaded..")
950
951(defvar gnus-newsgroup-unsendable nil
952 "List of articles in the current newsgroup that won't be sent.")
953
eec82323
LMI
954(defvar gnus-newsgroup-bookmarks nil
955 "List of articles in the current newsgroup that have bookmarks.")
956
957(defvar gnus-newsgroup-dormant nil
958 "List of dormant articles in the current newsgroup.")
959
960(defvar gnus-newsgroup-scored nil
961 "List of scored articles in the current newsgroup.")
962
963(defvar gnus-newsgroup-headers nil
964 "List of article headers in the current newsgroup.")
965
966(defvar gnus-newsgroup-threads nil)
967
968(defvar gnus-newsgroup-prepared nil
969 "Whether the current group has been prepared properly.")
970
971(defvar gnus-newsgroup-ancient nil
972 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
973
974(defvar gnus-newsgroup-sparse nil)
975
976(defvar gnus-current-article nil)
977(defvar gnus-article-current nil)
978(defvar gnus-current-headers nil)
979(defvar gnus-have-all-headers nil)
980(defvar gnus-last-article nil)
981(defvar gnus-newsgroup-history nil)
982
983(defconst gnus-summary-local-variables
984 '(gnus-newsgroup-name
985 gnus-newsgroup-begin gnus-newsgroup-end
986 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
987 gnus-newsgroup-last-folder gnus-newsgroup-last-file
988 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
989 gnus-newsgroup-unselected gnus-newsgroup-marked
990 gnus-newsgroup-reads gnus-newsgroup-saved
991 gnus-newsgroup-replied gnus-newsgroup-expirable
992 gnus-newsgroup-processable gnus-newsgroup-killed
6748645f
LMI
993 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
994 gnus-newsgroup-unsendable
eec82323
LMI
995 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
996 gnus-newsgroup-headers gnus-newsgroup-threads
997 gnus-newsgroup-prepared gnus-summary-highlight-line-function
998 gnus-current-article gnus-current-headers gnus-have-all-headers
999 gnus-last-article gnus-article-internal-prepare-hook
1000 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1001 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1002 gnus-thread-expunge-below
1003 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1004 (gnus-summary-mark-below . global)
1005 gnus-newsgroup-active gnus-scores-exclude-files
1006 gnus-newsgroup-history gnus-newsgroup-ancient
1007 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1008 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1009 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1010 (gnus-newsgroup-expunged-tally . 0)
1011 gnus-cache-removable-articles gnus-newsgroup-cached
1012 gnus-newsgroup-data gnus-newsgroup-data-reverse
1013 gnus-newsgroup-limit gnus-newsgroup-limits)
1014 "Variables that are buffer-local to the summary buffers.")
1015
1016;; Byte-compiler warning.
1017(defvar gnus-article-mode-map)
1018
1019;; Subject simplification.
1020
6748645f
LMI
1021(defun gnus-simplify-whitespace (str)
1022 "Remove excessive whitespace."
1023 (let ((mystr str))
1024 ;; Multiple spaces.
1025 (while (string-match "[ \t][ \t]+" mystr)
1026 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1027 " "
1028 (substring mystr (match-end 0)))))
1029 ;; Leading spaces.
1030 (when (string-match "^[ \t]+" mystr)
1031 (setq mystr (substring mystr (match-end 0))))
1032 ;; Trailing spaces.
1033 (when (string-match "[ \t]+$" mystr)
1034 (setq mystr (substring mystr 0 (match-beginning 0))))
1035 mystr))
1036
eec82323
LMI
1037(defsubst gnus-simplify-subject-re (subject)
1038 "Remove \"Re:\" from subject lines."
1039 (if (string-match "^[Rr][Ee]: *" subject)
1040 (substring subject (match-end 0))
1041 subject))
1042
1043(defun gnus-simplify-subject (subject &optional re-only)
1044 "Remove `Re:' and words in parentheses.
1045If RE-ONLY is non-nil, strip leading `Re:'s only."
1046 (let ((case-fold-search t)) ;Ignore case.
1047 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1048 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1049 (setq subject (substring subject (match-end 0))))
1050 ;; Remove uninteresting prefixes.
1051 (when (and (not re-only)
1052 gnus-simplify-ignored-prefixes
1053 (string-match gnus-simplify-ignored-prefixes subject))
1054 (setq subject (substring subject (match-end 0))))
1055 ;; Remove words in parentheses from end.
1056 (unless re-only
1057 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1058 (setq subject (substring subject 0 (match-beginning 0)))))
1059 ;; Return subject string.
1060 subject))
1061
1062;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1063;; all whitespace.
1064(defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1065 (goto-char (point-min))
1066 (while (re-search-forward regexp nil t)
1067 (replace-match (or newtext ""))))
1068
1069(defun gnus-simplify-buffer-fuzzy ()
1070 "Simplify string in the buffer fuzzily.
1071The string in the accessible portion of the current buffer is simplified.
1072It is assumed to be a single-line subject.
1073Whitespace is generally cleaned up, and miscellaneous leading/trailing
1074matter is removed. Additional things can be deleted by setting
1075gnus-simplify-subject-fuzzy-regexp."
1076 (let ((case-fold-search t)
1077 (modified-tick))
1078 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1079
1080 (while (not (eq modified-tick (buffer-modified-tick)))
1081 (setq modified-tick (buffer-modified-tick))
1082 (cond
1083 ((listp gnus-simplify-subject-fuzzy-regexp)
1084 (mapcar 'gnus-simplify-buffer-fuzzy-step
1085 gnus-simplify-subject-fuzzy-regexp))
1086 (gnus-simplify-subject-fuzzy-regexp
1087 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1088 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1089 (gnus-simplify-buffer-fuzzy-step
1090 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1091 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1092
1093 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1094 (gnus-simplify-buffer-fuzzy-step " +" " ")
1095 (gnus-simplify-buffer-fuzzy-step " $")
1096 (gnus-simplify-buffer-fuzzy-step "^ +")))
1097
1098(defun gnus-simplify-subject-fuzzy (subject)
1099 "Simplify a subject string fuzzily.
6748645f 1100See `gnus-simplify-buffer-fuzzy' for details."
eec82323
LMI
1101 (save-excursion
1102 (gnus-set-work-buffer)
1103 (let ((case-fold-search t))
6748645f
LMI
1104 ;; Remove uninteresting prefixes.
1105 (when (and gnus-simplify-ignored-prefixes
1106 (string-match gnus-simplify-ignored-prefixes subject))
1107 (setq subject (substring subject (match-end 0))))
eec82323
LMI
1108 (insert subject)
1109 (inline (gnus-simplify-buffer-fuzzy))
1110 (buffer-string))))
1111
1112(defsubst gnus-simplify-subject-fully (subject)
1113 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1114 (cond
6748645f
LMI
1115 (gnus-simplify-subject-functions
1116 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
1117 ((null gnus-summary-gather-subject-limit)
1118 (gnus-simplify-subject-re subject))
1119 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1120 (gnus-simplify-subject-fuzzy subject))
1121 ((numberp gnus-summary-gather-subject-limit)
1122 (gnus-limit-string (gnus-simplify-subject-re subject)
1123 gnus-summary-gather-subject-limit))
1124 (t
1125 subject)))
1126
1127(defsubst gnus-subject-equal (s1 s2 &optional simple-first)
6748645f
LMI
1128 "Check whether two subjects are equal.
1129If optional argument simple-first is t, first argument is already
1130simplified."
eec82323
LMI
1131 (cond
1132 ((null simple-first)
1133 (equal (gnus-simplify-subject-fully s1)
1134 (gnus-simplify-subject-fully s2)))
1135 (t
1136 (equal s1
1137 (gnus-simplify-subject-fully s2)))))
1138
1139(defun gnus-summary-bubble-group ()
1140 "Increase the score of the current group.
1141This is a handy function to add to `gnus-summary-exit-hook' to
1142increase the score of each group you read."
1143 (gnus-group-add-score gnus-newsgroup-name))
1144
1145\f
1146;;;
1147;;; Gnus summary mode
1148;;;
1149
1150(put 'gnus-summary-mode 'mode-class 'special)
1151
1152(when t
1153 ;; Non-orthogonal keys
1154
1155 (gnus-define-keys gnus-summary-mode-map
1156 " " gnus-summary-next-page
1157 "\177" gnus-summary-prev-page
1158 [delete] gnus-summary-prev-page
6748645f 1159 [backspace] gnus-summary-prev-page
eec82323 1160 "\r" gnus-summary-scroll-up
6748645f 1161 "\M-\r" gnus-summary-scroll-down
eec82323
LMI
1162 "n" gnus-summary-next-unread-article
1163 "p" gnus-summary-prev-unread-article
1164 "N" gnus-summary-next-article
1165 "P" gnus-summary-prev-article
1166 "\M-\C-n" gnus-summary-next-same-subject
1167 "\M-\C-p" gnus-summary-prev-same-subject
1168 "\M-n" gnus-summary-next-unread-subject
1169 "\M-p" gnus-summary-prev-unread-subject
1170 "." gnus-summary-first-unread-article
1171 "," gnus-summary-best-unread-article
1172 "\M-s" gnus-summary-search-article-forward
1173 "\M-r" gnus-summary-search-article-backward
1174 "<" gnus-summary-beginning-of-article
1175 ">" gnus-summary-end-of-article
1176 "j" gnus-summary-goto-article
1177 "^" gnus-summary-refer-parent-article
1178 "\M-^" gnus-summary-refer-article
1179 "u" gnus-summary-tick-article-forward
1180 "!" gnus-summary-tick-article-forward
1181 "U" gnus-summary-tick-article-backward
1182 "d" gnus-summary-mark-as-read-forward
1183 "D" gnus-summary-mark-as-read-backward
1184 "E" gnus-summary-mark-as-expirable
1185 "\M-u" gnus-summary-clear-mark-forward
1186 "\M-U" gnus-summary-clear-mark-backward
1187 "k" gnus-summary-kill-same-subject-and-select
1188 "\C-k" gnus-summary-kill-same-subject
1189 "\M-\C-k" gnus-summary-kill-thread
1190 "\M-\C-l" gnus-summary-lower-thread
1191 "e" gnus-summary-edit-article
1192 "#" gnus-summary-mark-as-processable
1193 "\M-#" gnus-summary-unmark-as-processable
1194 "\M-\C-t" gnus-summary-toggle-threads
1195 "\M-\C-s" gnus-summary-show-thread
1196 "\M-\C-h" gnus-summary-hide-thread
1197 "\M-\C-f" gnus-summary-next-thread
1198 "\M-\C-b" gnus-summary-prev-thread
1199 "\M-\C-u" gnus-summary-up-thread
1200 "\M-\C-d" gnus-summary-down-thread
1201 "&" gnus-summary-execute-command
1202 "c" gnus-summary-catchup-and-exit
1203 "\C-w" gnus-summary-mark-region-as-read
1204 "\C-t" gnus-summary-toggle-truncation
1205 "?" gnus-summary-mark-as-dormant
1206 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1207 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1208 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1209 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1210 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1211 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1212 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1213 "=" gnus-summary-expand-window
1214 "\C-x\C-s" gnus-summary-reselect-current-group
1215 "\M-g" gnus-summary-rescan-group
1216 "w" gnus-summary-stop-page-breaking
1217 "\C-c\C-r" gnus-summary-caesar-message
1218 "\M-t" gnus-summary-toggle-mime
1219 "f" gnus-summary-followup
1220 "F" gnus-summary-followup-with-original
1221 "C" gnus-summary-cancel-article
1222 "r" gnus-summary-reply
1223 "R" gnus-summary-reply-with-original
1224 "\C-c\C-f" gnus-summary-mail-forward
1225 "o" gnus-summary-save-article
1226 "\C-o" gnus-summary-save-article-mail
1227 "|" gnus-summary-pipe-output
1228 "\M-k" gnus-summary-edit-local-kill
1229 "\M-K" gnus-summary-edit-global-kill
1230 ;; "V" gnus-version
1231 "\C-c\C-d" gnus-summary-describe-group
1232 "q" gnus-summary-exit
1233 "Q" gnus-summary-exit-no-update
1234 "\C-c\C-i" gnus-info-find-node
1235 gnus-mouse-2 gnus-mouse-pick-article
1236 "m" gnus-summary-mail-other-window
1237 "a" gnus-summary-post-news
1238 "x" gnus-summary-limit-to-unread
1239 "s" gnus-summary-isearch-article
1240 "t" gnus-article-hide-headers
1241 "g" gnus-summary-show-article
1242 "l" gnus-summary-goto-last-article
1243 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1244 "\C-d" gnus-summary-enter-digest-group
1245 "\M-\C-d" gnus-summary-read-document
6748645f 1246 "\M-\C-e" gnus-summary-edit-parameters
eec82323
LMI
1247 "\C-c\C-b" gnus-bug
1248 "*" gnus-cache-enter-article
1249 "\M-*" gnus-cache-remove-article
1250 "\M-&" gnus-summary-universal-argument
1251 "\C-l" gnus-recenter
1252 "I" gnus-summary-increase-score
1253 "L" gnus-summary-lower-score
6748645f
LMI
1254 "\M-i" gnus-symbolic-argument
1255 "h" gnus-summary-select-article-buffer
eec82323
LMI
1256
1257 "V" gnus-summary-score-map
1258 "X" gnus-uu-extract-map
1259 "S" gnus-summary-send-map)
1260
1261 ;; Sort of orthogonal keymap
1262 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1263 "t" gnus-summary-tick-article-forward
1264 "!" gnus-summary-tick-article-forward
1265 "d" gnus-summary-mark-as-read-forward
1266 "r" gnus-summary-mark-as-read-forward
1267 "c" gnus-summary-clear-mark-forward
1268 " " gnus-summary-clear-mark-forward
1269 "e" gnus-summary-mark-as-expirable
1270 "x" gnus-summary-mark-as-expirable
1271 "?" gnus-summary-mark-as-dormant
1272 "b" gnus-summary-set-bookmark
1273 "B" gnus-summary-remove-bookmark
1274 "#" gnus-summary-mark-as-processable
1275 "\M-#" gnus-summary-unmark-as-processable
1276 "S" gnus-summary-limit-include-expunged
1277 "C" gnus-summary-catchup
1278 "H" gnus-summary-catchup-to-here
1279 "\C-c" gnus-summary-catchup-all
1280 "k" gnus-summary-kill-same-subject-and-select
1281 "K" gnus-summary-kill-same-subject
1282 "P" gnus-uu-mark-map)
1283
1284 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1285 "c" gnus-summary-clear-above
1286 "u" gnus-summary-tick-above
1287 "m" gnus-summary-mark-above
1288 "k" gnus-summary-kill-below)
1289
1290 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1291 "/" gnus-summary-limit-to-subject
1292 "n" gnus-summary-limit-to-articles
1293 "w" gnus-summary-pop-limit
1294 "s" gnus-summary-limit-to-subject
1295 "a" gnus-summary-limit-to-author
1296 "u" gnus-summary-limit-to-unread
1297 "m" gnus-summary-limit-to-marks
1298 "v" gnus-summary-limit-to-score
6748645f 1299 "*" gnus-summary-limit-include-cached
eec82323 1300 "D" gnus-summary-limit-include-dormant
6748645f 1301 "T" gnus-summary-limit-include-thread
eec82323
LMI
1302 "d" gnus-summary-limit-exclude-dormant
1303 "t" gnus-summary-limit-to-age
1304 "E" gnus-summary-limit-include-expunged
1305 "c" gnus-summary-limit-exclude-childless-dormant
1306 "C" gnus-summary-limit-mark-excluded-as-read)
1307
1308 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1309 "n" gnus-summary-next-unread-article
1310 "p" gnus-summary-prev-unread-article
1311 "N" gnus-summary-next-article
1312 "P" gnus-summary-prev-article
1313 "\C-n" gnus-summary-next-same-subject
1314 "\C-p" gnus-summary-prev-same-subject
1315 "\M-n" gnus-summary-next-unread-subject
1316 "\M-p" gnus-summary-prev-unread-subject
1317 "f" gnus-summary-first-unread-article
1318 "b" gnus-summary-best-unread-article
1319 "j" gnus-summary-goto-article
1320 "g" gnus-summary-goto-subject
1321 "l" gnus-summary-goto-last-article
a8151ef7 1322 "o" gnus-summary-pop-article)
eec82323
LMI
1323
1324 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1325 "k" gnus-summary-kill-thread
1326 "l" gnus-summary-lower-thread
1327 "i" gnus-summary-raise-thread
1328 "T" gnus-summary-toggle-threads
1329 "t" gnus-summary-rethread-current
1330 "^" gnus-summary-reparent-thread
1331 "s" gnus-summary-show-thread
1332 "S" gnus-summary-show-all-threads
1333 "h" gnus-summary-hide-thread
1334 "H" gnus-summary-hide-all-threads
1335 "n" gnus-summary-next-thread
1336 "p" gnus-summary-prev-thread
1337 "u" gnus-summary-up-thread
1338 "o" gnus-summary-top-thread
1339 "d" gnus-summary-down-thread
1340 "#" gnus-uu-mark-thread
1341 "\M-#" gnus-uu-unmark-thread)
1342
1343 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1344 "g" gnus-summary-prepare
1345 "c" gnus-summary-insert-cached-articles)
1346
1347 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1348 "c" gnus-summary-catchup-and-exit
1349 "C" gnus-summary-catchup-all-and-exit
1350 "E" gnus-summary-exit-no-update
1351 "Q" gnus-summary-exit
1352 "Z" gnus-summary-exit
1353 "n" gnus-summary-catchup-and-goto-next-group
1354 "R" gnus-summary-reselect-current-group
1355 "G" gnus-summary-rescan-group
1356 "N" gnus-summary-next-group
1357 "s" gnus-summary-save-newsrc
1358 "P" gnus-summary-prev-group)
1359
1360 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1361 " " gnus-summary-next-page
1362 "n" gnus-summary-next-page
1363 "\177" gnus-summary-prev-page
1364 [delete] gnus-summary-prev-page
1365 "p" gnus-summary-prev-page
1366 "\r" gnus-summary-scroll-up
6748645f 1367 "\M-\r" gnus-summary-scroll-down
eec82323
LMI
1368 "<" gnus-summary-beginning-of-article
1369 ">" gnus-summary-end-of-article
1370 "b" gnus-summary-beginning-of-article
1371 "e" gnus-summary-end-of-article
1372 "^" gnus-summary-refer-parent-article
1373 "r" gnus-summary-refer-parent-article
1374 "R" gnus-summary-refer-references
6748645f 1375 "T" gnus-summary-refer-thread
eec82323
LMI
1376 "g" gnus-summary-show-article
1377 "s" gnus-summary-isearch-article
1378 "P" gnus-summary-print-article)
1379
1380 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1381 "b" gnus-article-add-buttons
1382 "B" gnus-article-add-buttons-to-head
1383 "o" gnus-article-treat-overstrike
1384 "e" gnus-article-emphasize
1385 "w" gnus-article-fill-cited-article
1386 "c" gnus-article-remove-cr
1387 "q" gnus-article-de-quoted-unreadable
1388 "f" gnus-article-display-x-face
1389 "l" gnus-summary-stop-page-breaking
1390 "r" gnus-summary-caesar-message
1391 "t" gnus-article-hide-headers
1392 "v" gnus-summary-verbose-headers
1393 "m" gnus-summary-toggle-mime
6748645f
LMI
1394 "h" gnus-article-treat-html
1395 "d" gnus-article-treat-dumbquotes)
eec82323
LMI
1396
1397 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1398 "a" gnus-article-hide
1399 "h" gnus-article-hide-headers
1400 "b" gnus-article-hide-boring-headers
1401 "s" gnus-article-hide-signature
1402 "c" gnus-article-hide-citation
6748645f 1403 "C" gnus-article-hide-citation-in-followups
eec82323
LMI
1404 "p" gnus-article-hide-pgp
1405 "P" gnus-article-hide-pem
1406 "\C-c" gnus-article-hide-citation-maybe)
1407
1408 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1409 "a" gnus-article-highlight
1410 "h" gnus-article-highlight-headers
1411 "c" gnus-article-highlight-citation
1412 "s" gnus-article-highlight-signature)
1413
1414 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1415 "z" gnus-article-date-ut
1416 "u" gnus-article-date-ut
1417 "l" gnus-article-date-local
1418 "e" gnus-article-date-lapsed
1419 "o" gnus-article-date-original
6748645f 1420 "i" gnus-article-date-iso8601
eec82323
LMI
1421 "s" gnus-article-date-user)
1422
1423 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1424 "t" gnus-article-remove-trailing-blank-lines
1425 "l" gnus-article-strip-leading-blank-lines
1426 "m" gnus-article-strip-multiple-blank-lines
1427 "a" gnus-article-strip-blank-lines
6748645f 1428 "A" gnus-article-strip-all-blank-lines
eec82323
LMI
1429 "s" gnus-article-strip-leading-space)
1430
1431 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1432 "v" gnus-version
1433 "f" gnus-summary-fetch-faq
1434 "d" gnus-summary-describe-group
1435 "h" gnus-summary-describe-briefly
1436 "i" gnus-info-find-node)
1437
1438 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1439 "e" gnus-summary-expire-articles
1440 "\M-\C-e" gnus-summary-expire-articles-now
1441 "\177" gnus-summary-delete-article
1442 [delete] gnus-summary-delete-article
1443 "m" gnus-summary-move-article
1444 "r" gnus-summary-respool-article
1445 "w" gnus-summary-edit-article
1446 "c" gnus-summary-copy-article
1447 "B" gnus-summary-crosspost-article
1448 "q" gnus-summary-respool-query
6748645f 1449 "t" gnus-summary-respool-trace
eec82323
LMI
1450 "i" gnus-summary-import-article
1451 "p" gnus-summary-article-posted-p)
1452
1453 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1454 "o" gnus-summary-save-article
1455 "m" gnus-summary-save-article-mail
1456 "F" gnus-summary-write-article-file
1457 "r" gnus-summary-save-article-rmail
1458 "f" gnus-summary-save-article-file
1459 "b" gnus-summary-save-article-body-file
1460 "h" gnus-summary-save-article-folder
1461 "v" gnus-summary-save-article-vm
1462 "p" gnus-summary-pipe-output
1463 "s" gnus-soup-add-article))
1464
1465(defun gnus-summary-make-menu-bar ()
1466 (gnus-turn-off-edit-menu 'summary)
1467
1468 (unless (boundp 'gnus-summary-misc-menu)
1469
1470 (easy-menu-define
1471 gnus-summary-kill-menu gnus-summary-mode-map ""
1472 (cons
1473 "Score"
1474 (nconc
1475 (list
1476 ["Enter score..." gnus-summary-score-entry t]
1477 ["Customize" gnus-score-customize t])
1478 (gnus-make-score-map 'increase)
1479 (gnus-make-score-map 'lower)
1480 '(("Mark"
1481 ["Kill below" gnus-summary-kill-below t]
1482 ["Mark above" gnus-summary-mark-above t]
1483 ["Tick above" gnus-summary-tick-above t]
1484 ["Clear above" gnus-summary-clear-above t])
1485 ["Current score" gnus-summary-current-score t]
1486 ["Set score" gnus-summary-set-score t]
1487 ["Switch current score file..." gnus-score-change-score-file t]
1488 ["Set mark below..." gnus-score-set-mark-below t]
1489 ["Set expunge below..." gnus-score-set-expunge-below t]
1490 ["Edit current score file" gnus-score-edit-current-scores t]
1491 ["Edit score file" gnus-score-edit-file t]
1492 ["Trace score" gnus-score-find-trace t]
1493 ["Find words" gnus-score-find-favourite-words t]
1494 ["Rescore buffer" gnus-summary-rescore t]
1495 ["Increase score..." gnus-summary-increase-score t]
1496 ["Lower score..." gnus-summary-lower-score t]))))
1497
6748645f
LMI
1498 ;; Define both the Article menu in the summary buffer and the equivalent
1499 ;; Commands menu in the article buffer here for consistency.
1500 (let ((innards
1501 '(("Hide"
1502 ["All" gnus-article-hide t]
1503 ["Headers" gnus-article-hide-headers t]
1504 ["Signature" gnus-article-hide-signature t]
1505 ["Citation" gnus-article-hide-citation t]
1506 ["PGP" gnus-article-hide-pgp t]
1507 ["Boring headers" gnus-article-hide-boring-headers t])
1508 ("Highlight"
1509 ["All" gnus-article-highlight t]
1510 ["Headers" gnus-article-highlight-headers t]
1511 ["Signature" gnus-article-highlight-signature t]
1512 ["Citation" gnus-article-highlight-citation t])
1513 ("Date"
1514 ["Local" gnus-article-date-local t]
1515 ["ISO8601" gnus-article-date-iso8601 t]
1516 ["UT" gnus-article-date-ut t]
1517 ["Original" gnus-article-date-original t]
1518 ["Lapsed" gnus-article-date-lapsed t]
1519 ["User-defined" gnus-article-date-user t])
1520 ("Washing"
1521 ("Remove Blanks"
1522 ["Leading" gnus-article-strip-leading-blank-lines t]
1523 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1524 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1525 ["All of the above" gnus-article-strip-blank-lines t]
1526 ["All" gnus-article-strip-all-blank-lines t]
1527 ["Leading space" gnus-article-strip-leading-space t])
1528 ["Overstrike" gnus-article-treat-overstrike t]
1529 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1530 ["Emphasis" gnus-article-emphasize t]
1531 ["Word wrap" gnus-article-fill-cited-article t]
1532 ["CR" gnus-article-remove-cr t]
1533 ["Show X-Face" gnus-article-display-x-face t]
1534 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1535 ["UnHTMLize" gnus-article-treat-html t]
1536 ["Rot 13" gnus-summary-caesar-message t]
1537 ["Unix pipe" gnus-summary-pipe-message t]
1538 ["Add buttons" gnus-article-add-buttons t]
1539 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1540 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1541 ["Toggle MIME" gnus-summary-toggle-mime t]
1542 ["Verbose header" gnus-summary-verbose-headers t]
1543 ["Toggle header" gnus-summary-toggle-header t])
1544 ("Output"
1545 ["Save in default format" gnus-summary-save-article t]
1546 ["Save in file" gnus-summary-save-article-file t]
1547 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1548 ["Save in MH folder" gnus-summary-save-article-folder t]
1549 ["Save in VM folder" gnus-summary-save-article-vm t]
1550 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1551 ["Save body in file" gnus-summary-save-article-body-file t]
1552 ["Pipe through a filter" gnus-summary-pipe-output t]
1553 ["Add to SOUP packet" gnus-soup-add-article t]
1554 ["Print" gnus-summary-print-article t])
1555 ("Backend"
1556 ["Respool article..." gnus-summary-respool-article t]
1557 ["Move article..." gnus-summary-move-article
1558 (gnus-check-backend-function
1559 'request-move-article gnus-newsgroup-name)]
1560 ["Copy article..." gnus-summary-copy-article t]
1561 ["Crosspost article..." gnus-summary-crosspost-article
1562 (gnus-check-backend-function
1563 'request-replace-article gnus-newsgroup-name)]
1564 ["Import file..." gnus-summary-import-article t]
1565 ["Check if posted" gnus-summary-article-posted-p t]
1566 ["Edit article" gnus-summary-edit-article
1567 (not (gnus-group-read-only-p))]
1568 ["Delete article" gnus-summary-delete-article
1569 (gnus-check-backend-function
1570 'request-expire-articles gnus-newsgroup-name)]
1571 ["Query respool" gnus-summary-respool-query t]
1572 ["Trace respool" gnus-summary-respool-trace t]
1573 ["Delete expirable articles" gnus-summary-expire-articles-now
1574 (gnus-check-backend-function
1575 'request-expire-articles gnus-newsgroup-name)])
1576 ("Extract"
1577 ["Uudecode" gnus-uu-decode-uu t]
1578 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1579 ["Unshar" gnus-uu-decode-unshar t]
1580 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1581 ["Save" gnus-uu-decode-save t]
1582 ["Binhex" gnus-uu-decode-binhex t]
1583 ["Postscript" gnus-uu-decode-postscript t])
1584 ("Cache"
1585 ["Enter article" gnus-cache-enter-article t]
1586 ["Remove article" gnus-cache-remove-article t])
1587 ["Select article buffer" gnus-summary-select-article-buffer t]
1588 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1589 ["Isearch article..." gnus-summary-isearch-article t]
1590 ["Beginning of the article" gnus-summary-beginning-of-article t]
1591 ["End of the article" gnus-summary-end-of-article t]
1592 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1593 ["Fetch referenced articles" gnus-summary-refer-references t]
1594 ["Fetch current thread" gnus-summary-refer-thread t]
1595 ["Fetch article with id..." gnus-summary-refer-article t]
1596 ["Redisplay" gnus-summary-show-article t])))
1597 (easy-menu-define
1598 gnus-summary-article-menu gnus-summary-mode-map ""
1599 (cons "Article" innards))
1600
1601 (easy-menu-define
1602 gnus-article-commands-menu gnus-article-mode-map ""
1603 (cons "Commands" innards)))
eec82323
LMI
1604
1605 (easy-menu-define
1606 gnus-summary-thread-menu gnus-summary-mode-map ""
1607 '("Threads"
1608 ["Toggle threading" gnus-summary-toggle-threads t]
1609 ["Hide threads" gnus-summary-hide-all-threads t]
1610 ["Show threads" gnus-summary-show-all-threads t]
1611 ["Hide thread" gnus-summary-hide-thread t]
1612 ["Show thread" gnus-summary-show-thread t]
1613 ["Go to next thread" gnus-summary-next-thread t]
1614 ["Go to previous thread" gnus-summary-prev-thread t]
1615 ["Go down thread" gnus-summary-down-thread t]
1616 ["Go up thread" gnus-summary-up-thread t]
1617 ["Top of thread" gnus-summary-top-thread t]
1618 ["Mark thread as read" gnus-summary-kill-thread t]
1619 ["Lower thread score" gnus-summary-lower-thread t]
1620 ["Raise thread score" gnus-summary-raise-thread t]
1621 ["Rethread current" gnus-summary-rethread-current t]
1622 ))
1623
1624 (easy-menu-define
1625 gnus-summary-post-menu gnus-summary-mode-map ""
1626 '("Post"
1627 ["Post an article" gnus-summary-post-news t]
1628 ["Followup" gnus-summary-followup t]
1629 ["Followup and yank" gnus-summary-followup-with-original t]
1630 ["Supersede article" gnus-summary-supersede-article t]
1631 ["Cancel article" gnus-summary-cancel-article t]
1632 ["Reply" gnus-summary-reply t]
1633 ["Reply and yank" gnus-summary-reply-with-original t]
1634 ["Wide reply" gnus-summary-wide-reply t]
1635 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1636 ["Mail forward" gnus-summary-mail-forward t]
1637 ["Post forward" gnus-summary-post-forward t]
1638 ["Digest and mail" gnus-uu-digest-mail-forward t]
1639 ["Digest and post" gnus-uu-digest-post-forward t]
1640 ["Resend message" gnus-summary-resend-message t]
1641 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1642 ["Send a mail" gnus-summary-mail-other-window t]
1643 ["Uuencode and post" gnus-uu-post-news t]
1644 ["Followup via news" gnus-summary-followup-to-mail t]
1645 ["Followup via news and yank"
1646 gnus-summary-followup-to-mail-with-original t]
1647 ;;("Draft"
1648 ;;["Send" gnus-summary-send-draft t]
1649 ;;["Send bounced" gnus-resend-bounced-mail t])
1650 ))
1651
1652 (easy-menu-define
1653 gnus-summary-misc-menu gnus-summary-mode-map ""
1654 '("Misc"
1655 ("Mark Read"
1656 ["Mark as read" gnus-summary-mark-as-read-forward t]
1657 ["Mark same subject and select"
1658 gnus-summary-kill-same-subject-and-select t]
1659 ["Mark same subject" gnus-summary-kill-same-subject t]
1660 ["Catchup" gnus-summary-catchup t]
1661 ["Catchup all" gnus-summary-catchup-all t]
1662 ["Catchup to here" gnus-summary-catchup-to-here t]
1663 ["Catchup region" gnus-summary-mark-region-as-read t]
1664 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1665 ("Mark Various"
1666 ["Tick" gnus-summary-tick-article-forward t]
1667 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1668 ["Remove marks" gnus-summary-clear-mark-forward t]
1669 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1670 ["Set bookmark" gnus-summary-set-bookmark t]
1671 ["Remove bookmark" gnus-summary-remove-bookmark t])
1672 ("Mark Limit"
1673 ["Marks..." gnus-summary-limit-to-marks t]
1674 ["Subject..." gnus-summary-limit-to-subject t]
1675 ["Author..." gnus-summary-limit-to-author t]
1676 ["Age..." gnus-summary-limit-to-age t]
1677 ["Score" gnus-summary-limit-to-score t]
1678 ["Unread" gnus-summary-limit-to-unread t]
1679 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1680 ["Articles" gnus-summary-limit-to-articles t]
1681 ["Pop limit" gnus-summary-pop-limit t]
1682 ["Show dormant" gnus-summary-limit-include-dormant t]
1683 ["Hide childless dormant"
1684 gnus-summary-limit-exclude-childless-dormant t]
1685 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1686 ["Show expunged" gnus-summary-show-all-expunged t])
1687 ("Process Mark"
1688 ["Set mark" gnus-summary-mark-as-processable t]
1689 ["Remove mark" gnus-summary-unmark-as-processable t]
1690 ["Remove all marks" gnus-summary-unmark-all-processable t]
1691 ["Mark above" gnus-uu-mark-over t]
1692 ["Mark series" gnus-uu-mark-series t]
1693 ["Mark region" gnus-uu-mark-region t]
6748645f 1694 ["Unmark region" gnus-uu-unmark-region t]
eec82323 1695 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
6748645f 1696 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
eec82323
LMI
1697 ["Mark all" gnus-uu-mark-all t]
1698 ["Mark buffer" gnus-uu-mark-buffer t]
1699 ["Mark sparse" gnus-uu-mark-sparse t]
1700 ["Mark thread" gnus-uu-mark-thread t]
1701 ["Unmark thread" gnus-uu-unmark-thread t]
1702 ("Process Mark Sets"
1703 ["Kill" gnus-summary-kill-process-mark t]
1704 ["Yank" gnus-summary-yank-process-mark
1705 gnus-newsgroup-process-stack]
1706 ["Save" gnus-summary-save-process-mark t]))
1707 ("Scroll article"
1708 ["Page forward" gnus-summary-next-page t]
1709 ["Page backward" gnus-summary-prev-page t]
1710 ["Line forward" gnus-summary-scroll-up t])
1711 ("Move"
1712 ["Next unread article" gnus-summary-next-unread-article t]
1713 ["Previous unread article" gnus-summary-prev-unread-article t]
1714 ["Next article" gnus-summary-next-article t]
1715 ["Previous article" gnus-summary-prev-article t]
1716 ["Next unread subject" gnus-summary-next-unread-subject t]
1717 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1718 ["Next article same subject" gnus-summary-next-same-subject t]
1719 ["Previous article same subject" gnus-summary-prev-same-subject t]
1720 ["First unread article" gnus-summary-first-unread-article t]
1721 ["Best unread article" gnus-summary-best-unread-article t]
1722 ["Go to subject number..." gnus-summary-goto-subject t]
1723 ["Go to article number..." gnus-summary-goto-article t]
1724 ["Go to the last article" gnus-summary-goto-last-article t]
1725 ["Pop article off history" gnus-summary-pop-article t])
1726 ("Sort"
1727 ["Sort by number" gnus-summary-sort-by-number t]
1728 ["Sort by author" gnus-summary-sort-by-author t]
1729 ["Sort by subject" gnus-summary-sort-by-subject t]
1730 ["Sort by date" gnus-summary-sort-by-date t]
1731 ["Sort by score" gnus-summary-sort-by-score t]
1732 ["Sort by lines" gnus-summary-sort-by-lines t])
1733 ("Help"
1734 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1735 ["Describe group" gnus-summary-describe-group t]
1736 ["Read manual" gnus-info-find-node t])
1737 ("Modes"
1738 ["Pick and read" gnus-pick-mode t]
1739 ["Binary" gnus-binary-mode t])
1740 ("Regeneration"
1741 ["Regenerate" gnus-summary-prepare t]
1742 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1743 ["Toggle threading" gnus-summary-toggle-threads t])
1744 ["Filter articles..." gnus-summary-execute-command t]
1745 ["Run command on subjects..." gnus-summary-universal-argument t]
1746 ["Search articles forward..." gnus-summary-search-article-forward t]
1747 ["Search articles backward..." gnus-summary-search-article-backward t]
1748 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1749 ["Expand window" gnus-summary-expand-window t]
1750 ["Expire expirable articles" gnus-summary-expire-articles
1751 (gnus-check-backend-function
1752 'request-expire-articles gnus-newsgroup-name)]
1753 ["Edit local kill file" gnus-summary-edit-local-kill t]
1754 ["Edit main kill file" gnus-summary-edit-global-kill t]
6748645f
LMI
1755 ["Edit group parameters" gnus-summary-edit-parameters t]
1756 ["Send a bug report" gnus-bug t]
eec82323
LMI
1757 ("Exit"
1758 ["Catchup and exit" gnus-summary-catchup-and-exit t]
6748645f 1759 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
eec82323
LMI
1760 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1761 ["Exit group" gnus-summary-exit t]
1762 ["Exit group without updating" gnus-summary-exit-no-update t]
1763 ["Exit and goto next group" gnus-summary-next-group t]
1764 ["Exit and goto prev group" gnus-summary-prev-group t]
1765 ["Reselect group" gnus-summary-reselect-current-group t]
1766 ["Rescan group" gnus-summary-rescan-group t]
1767 ["Update dribble" gnus-summary-save-newsrc t])))
1768
6748645f 1769 (gnus-run-hooks 'gnus-summary-menu-hook)))
eec82323
LMI
1770
1771(defun gnus-score-set-default (var value)
1772 "A version of set that updates the GNU Emacs menu-bar."
1773 (set var value)
1774 ;; It is the message that forces the active status to be updated.
1775 (message ""))
1776
1777(defun gnus-make-score-map (type)
1778 "Make a summary score map of type TYPE."
1779 (if t
1780 nil
1781 (let ((headers '(("author" "from" string)
1782 ("subject" "subject" string)
1783 ("article body" "body" string)
1784 ("article head" "head" string)
1785 ("xref" "xref" string)
1786 ("lines" "lines" number)
1787 ("followups to author" "followup" string)))
1788 (types '((number ("less than" <)
1789 ("greater than" >)
1790 ("equal" =))
1791 (string ("substring" s)
1792 ("exact string" e)
1793 ("fuzzy string" f)
1794 ("regexp" r))))
1795 (perms '(("temporary" (current-time-string))
1796 ("permanent" nil)
1797 ("immediate" now)))
1798 header)
1799 (list
1800 (apply
1801 'nconc
1802 (list
1803 (if (eq type 'lower)
1804 "Lower score"
1805 "Increase score"))
1806 (let (outh)
1807 (while headers
1808 (setq header (car headers))
1809 (setq outh
1810 (cons
1811 (apply
1812 'nconc
1813 (list (car header))
1814 (let ((ts (cdr (assoc (nth 2 header) types)))
1815 outt)
1816 (while ts
1817 (setq outt
1818 (cons
1819 (apply
1820 'nconc
1821 (list (caar ts))
1822 (let ((ps perms)
1823 outp)
1824 (while ps
1825 (setq outp
1826 (cons
1827 (vector
1828 (caar ps)
1829 (list
1830 'gnus-summary-score-entry
1831 (nth 1 header)
1832 (if (or (string= (nth 1 header)
1833 "head")
1834 (string= (nth 1 header)
1835 "body"))
1836 ""
1837 (list 'gnus-summary-header
1838 (nth 1 header)))
1839 (list 'quote (nth 1 (car ts)))
1840 (list 'gnus-score-default nil)
1841 (nth 1 (car ps))
1842 t)
1843 t)
1844 outp))
1845 (setq ps (cdr ps)))
1846 (list (nreverse outp))))
1847 outt))
1848 (setq ts (cdr ts)))
1849 (list (nreverse outt))))
1850 outh))
1851 (setq headers (cdr headers)))
1852 (list (nreverse outh))))))))
1853
1854\f
1855
1856(defun gnus-summary-mode (&optional group)
1857 "Major mode for reading articles.
1858
1859All normal editing commands are switched off.
1860\\<gnus-summary-mode-map>
1861Each line in this buffer represents one article. To read an
1862article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1863and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1864respectively.
1865
1866You can also post articles and send mail from this buffer. To
1867follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1868of an article, type `\\[gnus-summary-reply]'.
1869
1870There are approx. one gazillion commands you can execute in this
1871buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1872
1873The following commands are available:
1874
1875\\{gnus-summary-mode-map}"
1876 (interactive)
1877 (when (gnus-visual-p 'summary-menu 'menu)
1878 (gnus-summary-make-menu-bar))
1879 (kill-all-local-variables)
1880 (gnus-summary-make-local-variables)
1881 (gnus-make-thread-indent-array)
1882 (gnus-simplify-mode-line)
1883 (setq major-mode 'gnus-summary-mode)
1884 (setq mode-name "Summary")
1885 (make-local-variable 'minor-mode-alist)
1886 (use-local-map gnus-summary-mode-map)
1887 (buffer-disable-undo (current-buffer))
1888 (setq buffer-read-only t) ;Disable modification
1889 (setq truncate-lines t)
1890 (setq selective-display t)
1891 (setq selective-display-ellipses t) ;Display `...'
1892 (gnus-summary-set-display-table)
1893 (gnus-set-default-directory)
1894 (setq gnus-newsgroup-name group)
1895 (make-local-variable 'gnus-summary-line-format)
1896 (make-local-variable 'gnus-summary-line-format-spec)
6748645f
LMI
1897 (make-local-variable 'gnus-summary-dummy-line-format)
1898 (make-local-variable 'gnus-summary-dummy-line-format-spec)
eec82323
LMI
1899 (make-local-variable 'gnus-summary-mark-positions)
1900 (make-local-hook 'post-command-hook)
1901 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
6748645f
LMI
1902 (make-local-hook 'pre-command-hook)
1903 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1904 (gnus-run-hooks 'gnus-summary-mode-hook)
eec82323
LMI
1905 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1906 (gnus-update-summary-mark-positions))
1907
1908(defun gnus-summary-make-local-variables ()
1909 "Make all the local summary buffer variables."
1910 (let ((locals gnus-summary-local-variables)
1911 global local)
1912 (while (setq local (pop locals))
1913 (if (consp local)
1914 (progn
1915 (if (eq (cdr local) 'global)
1916 ;; Copy the global value of the variable.
1917 (setq global (symbol-value (car local)))
1918 ;; Use the value from the list.
1919 (setq global (eval (cdr local))))
1920 (make-local-variable (car local))
1921 (set (car local) global))
1922 ;; Simple nil-valued local variable.
1923 (make-local-variable local)
1924 (set local nil)))))
1925
1926(defun gnus-summary-clear-local-variables ()
1927 (let ((locals gnus-summary-local-variables))
1928 (while locals
1929 (if (consp (car locals))
1930 (and (vectorp (caar locals))
1931 (set (caar locals) nil))
1932 (and (vectorp (car locals))
1933 (set (car locals) nil)))
1934 (setq locals (cdr locals)))))
1935
1936;; Summary data functions.
1937
1938(defmacro gnus-data-number (data)
1939 `(car ,data))
1940
1941(defmacro gnus-data-set-number (data number)
1942 `(setcar ,data ,number))
1943
1944(defmacro gnus-data-mark (data)
1945 `(nth 1 ,data))
1946
1947(defmacro gnus-data-set-mark (data mark)
1948 `(setcar (nthcdr 1 ,data) ,mark))
1949
1950(defmacro gnus-data-pos (data)
1951 `(nth 2 ,data))
1952
1953(defmacro gnus-data-set-pos (data pos)
1954 `(setcar (nthcdr 2 ,data) ,pos))
1955
1956(defmacro gnus-data-header (data)
1957 `(nth 3 ,data))
1958
1959(defmacro gnus-data-set-header (data header)
1960 `(setf (nth 3 ,data) ,header))
1961
1962(defmacro gnus-data-level (data)
1963 `(nth 4 ,data))
1964
1965(defmacro gnus-data-unread-p (data)
1966 `(= (nth 1 ,data) gnus-unread-mark))
1967
1968(defmacro gnus-data-read-p (data)
1969 `(/= (nth 1 ,data) gnus-unread-mark))
1970
1971(defmacro gnus-data-pseudo-p (data)
1972 `(consp (nth 3 ,data)))
1973
1974(defmacro gnus-data-find (number)
1975 `(assq ,number gnus-newsgroup-data))
1976
1977(defmacro gnus-data-find-list (number &optional data)
1978 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1979 (memq (assq ,number bdata)
1980 bdata)))
1981
1982(defmacro gnus-data-make (number mark pos header level)
1983 `(list ,number ,mark ,pos ,header ,level))
1984
1985(defun gnus-data-enter (after-article number mark pos header level offset)
1986 (let ((data (gnus-data-find-list after-article)))
1987 (unless data
1988 (error "No such article: %d" after-article))
1989 (setcdr data (cons (gnus-data-make number mark pos header level)
1990 (cdr data)))
1991 (setq gnus-newsgroup-data-reverse nil)
1992 (gnus-data-update-list (cddr data) offset)))
1993
1994(defun gnus-data-enter-list (after-article list &optional offset)
1995 (when list
1996 (let ((data (and after-article (gnus-data-find-list after-article)))
1997 (ilist list))
6748645f
LMI
1998 (if (not (or data
1999 after-article))
2000 (let ((odata gnus-newsgroup-data))
2001 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
eec82323 2002 (when offset
6748645f
LMI
2003 (gnus-data-update-list odata offset)))
2004 ;; Find the last element in the list to be spliced into the main
2005 ;; list.
2006 (while (cdr list)
2007 (setq list (cdr list)))
2008 (if (not data)
2009 (progn
2010 (setcdr list gnus-newsgroup-data)
2011 (setq gnus-newsgroup-data ilist)
2012 (when offset
2013 (gnus-data-update-list (cdr list) offset)))
2014 (setcdr list (cdr data))
2015 (setcdr data ilist)
2016 (when offset
2017 (gnus-data-update-list (cdr list) offset))))
eec82323
LMI
2018 (setq gnus-newsgroup-data-reverse nil))))
2019
2020(defun gnus-data-remove (article &optional offset)
2021 (let ((data gnus-newsgroup-data))
2022 (if (= (gnus-data-number (car data)) article)
2023 (progn
2024 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2025 gnus-newsgroup-data-reverse nil)
2026 (when offset
2027 (gnus-data-update-list gnus-newsgroup-data offset)))
2028 (while (cdr data)
2029 (when (= (gnus-data-number (cadr data)) article)
2030 (setcdr data (cddr data))
2031 (when offset
2032 (gnus-data-update-list (cdr data) offset))
2033 (setq data nil
2034 gnus-newsgroup-data-reverse nil))
2035 (setq data (cdr data))))))
2036
2037(defmacro gnus-data-list (backward)
2038 `(if ,backward
2039 (or gnus-newsgroup-data-reverse
2040 (setq gnus-newsgroup-data-reverse
2041 (reverse gnus-newsgroup-data)))
2042 gnus-newsgroup-data))
2043
2044(defun gnus-data-update-list (data offset)
2045 "Add OFFSET to the POS of all data entries in DATA."
6748645f 2046 (setq gnus-newsgroup-data-reverse nil)
eec82323
LMI
2047 (while data
2048 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2049 (setq data (cdr data))))
2050
eec82323
LMI
2051(defun gnus-summary-article-pseudo-p (article)
2052 "Say whether this article is a pseudo article or not."
2053 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2054
2055(defmacro gnus-summary-article-sparse-p (article)
2056 "Say whether this article is a sparse article or not."
a8151ef7 2057 `(memq ,article gnus-newsgroup-sparse))
eec82323
LMI
2058
2059(defmacro gnus-summary-article-ancient-p (article)
2060 "Say whether this article is a sparse article or not."
2061 `(memq ,article gnus-newsgroup-ancient))
2062
2063(defun gnus-article-parent-p (number)
2064 "Say whether this article is a parent or not."
2065 (let ((data (gnus-data-find-list number)))
2066 (and (cdr data) ; There has to be an article after...
2067 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2068 (gnus-data-level (nth 1 data))))))
2069
2070(defun gnus-article-children (number)
2071 "Return a list of all children to NUMBER."
2072 (let* ((data (gnus-data-find-list number))
2073 (level (gnus-data-level (car data)))
2074 children)
2075 (setq data (cdr data))
2076 (while (and data
2077 (= (gnus-data-level (car data)) (1+ level)))
2078 (push (gnus-data-number (car data)) children)
2079 (setq data (cdr data)))
2080 children))
2081
2082(defmacro gnus-summary-skip-intangible ()
2083 "If the current article is intangible, then jump to a different article."
2084 '(let ((to (get-text-property (point) 'gnus-intangible)))
2085 (and to (gnus-summary-goto-subject to))))
2086
2087(defmacro gnus-summary-article-intangible-p ()
2088 "Say whether this article is intangible or not."
2089 '(get-text-property (point) 'gnus-intangible))
2090
2091(defun gnus-article-read-p (article)
2092 "Say whether ARTICLE is read or not."
2093 (not (or (memq article gnus-newsgroup-marked)
2094 (memq article gnus-newsgroup-unreads)
2095 (memq article gnus-newsgroup-unselected)
2096 (memq article gnus-newsgroup-dormant))))
2097
2098;; Some summary mode macros.
2099
2100(defmacro gnus-summary-article-number ()
2101 "The article number of the article on the current line.
2102If there isn's an article number here, then we return the current
2103article number."
2104 '(progn
2105 (gnus-summary-skip-intangible)
2106 (or (get-text-property (point) 'gnus-number)
2107 (gnus-summary-last-subject))))
2108
2109(defmacro gnus-summary-article-header (&optional number)
6748645f 2110 "Return the header of article NUMBER."
eec82323
LMI
2111 `(gnus-data-header (gnus-data-find
2112 ,(or number '(gnus-summary-article-number)))))
2113
2114(defmacro gnus-summary-thread-level (&optional number)
6748645f 2115 "Return the level of thread that starts with article NUMBER."
eec82323
LMI
2116 `(if (and (eq gnus-summary-make-false-root 'dummy)
2117 (get-text-property (point) 'gnus-intangible))
2118 0
2119 (gnus-data-level (gnus-data-find
2120 ,(or number '(gnus-summary-article-number))))))
2121
2122(defmacro gnus-summary-article-mark (&optional number)
6748645f 2123 "Return the mark of article NUMBER."
eec82323
LMI
2124 `(gnus-data-mark (gnus-data-find
2125 ,(or number '(gnus-summary-article-number)))))
2126
2127(defmacro gnus-summary-article-pos (&optional number)
6748645f 2128 "Return the position of the line of article NUMBER."
eec82323
LMI
2129 `(gnus-data-pos (gnus-data-find
2130 ,(or number '(gnus-summary-article-number)))))
2131
2132(defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2133(defmacro gnus-summary-article-subject (&optional number)
2134 "Return current subject string or nil if nothing."
2135 `(let ((headers
2136 ,(if number
2137 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2138 '(gnus-data-header (assq (gnus-summary-article-number)
2139 gnus-newsgroup-data)))))
2140 (and headers
2141 (vectorp headers)
2142 (mail-header-subject headers))))
2143
2144(defmacro gnus-summary-article-score (&optional number)
2145 "Return current article score."
2146 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2147 gnus-newsgroup-scored))
2148 gnus-summary-default-score 0))
2149
2150(defun gnus-summary-article-children (&optional number)
6748645f 2151 "Return a list of article numbers that are children of article NUMBER."
eec82323
LMI
2152 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2153 (level (gnus-data-level (car data)))
2154 l children)
2155 (while (and (setq data (cdr data))
2156 (> (setq l (gnus-data-level (car data))) level))
2157 (and (= (1+ level) l)
2158 (push (gnus-data-number (car data))
2159 children)))
2160 (nreverse children)))
2161
2162(defun gnus-summary-article-parent (&optional number)
6748645f 2163 "Return the article number of the parent of article NUMBER."
eec82323
LMI
2164 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2165 (gnus-data-list t)))
2166 (level (gnus-data-level (car data))))
2167 (if (zerop level)
2168 () ; This is a root.
2169 ;; We search until we find an article with a level less than
2170 ;; this one. That function has to be the parent.
2171 (while (and (setq data (cdr data))
2172 (not (< (gnus-data-level (car data)) level))))
2173 (and data (gnus-data-number (car data))))))
2174
2175(defun gnus-unread-mark-p (mark)
2176 "Say whether MARK is the unread mark."
2177 (= mark gnus-unread-mark))
2178
2179(defun gnus-read-mark-p (mark)
2180 "Say whether MARK is one of the marks that mark as read.
2181This is all marks except unread, ticked, dormant, and expirable."
2182 (not (or (= mark gnus-unread-mark)
2183 (= mark gnus-ticked-mark)
2184 (= mark gnus-dormant-mark)
2185 (= mark gnus-expirable-mark))))
2186
2187(defmacro gnus-article-mark (number)
6748645f
LMI
2188 "Return the MARK of article NUMBER.
2189This macro should only be used when computing the mark the \"first\"
2190time; i.e., when generating the summary lines. After that,
2191`gnus-summary-article-mark' should be used to examine the
2192marks of articles."
eec82323 2193 `(cond
6748645f
LMI
2194 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2195 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2196 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
eec82323
LMI
2197 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2198 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2199 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2200 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2201 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2202 gnus-ancient-mark))))
2203
2204;; Saving hidden threads.
2205
2206(put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2207(put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2208
2209(defmacro gnus-save-hidden-threads (&rest forms)
2210 "Save hidden threads, eval FORMS, and restore the hidden threads."
2211 (let ((config (make-symbol "config")))
2212 `(let ((,config (gnus-hidden-threads-configuration)))
2213 (unwind-protect
2214 (save-excursion
2215 ,@forms)
2216 (gnus-restore-hidden-threads-configuration ,config)))))
2217
2218(defun gnus-hidden-threads-configuration ()
2219 "Return the current hidden threads configuration."
2220 (save-excursion
2221 (let (config)
2222 (goto-char (point-min))
2223 (while (search-forward "\r" nil t)
2224 (push (1- (point)) config))
2225 config)))
2226
2227(defun gnus-restore-hidden-threads-configuration (config)
2228 "Restore hidden threads configuration from CONFIG."
2229 (let (point buffer-read-only)
2230 (while (setq point (pop config))
2231 (when (and (< point (point-max))
2232 (goto-char point)
2233 (= (following-char) ?\n))
2234 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2235
107ecebb
AS
2236;; This needs to be put here because it uses the
2237;; gnus-save-hidden-threads macro
2238(defun gnus-data-compute-positions ()
2239 "Compute the positions of all articles."
2240 (setq gnus-newsgroup-data-reverse nil)
2241 (let ((data gnus-newsgroup-data))
2242 (save-excursion
2243 (gnus-save-hidden-threads
2244 (gnus-summary-show-all-threads)
2245 (goto-char (point-min))
2246 (while data
2247 (while (get-text-property (point) 'gnus-intangible)
2248 (forward-line 1))
2249 (gnus-data-set-pos (car data) (+ (point) 3))
2250 (setq data (cdr data))
2251 (forward-line 1))))))
2252
eec82323
LMI
2253;; Various summary mode internalish functions.
2254
2255(defun gnus-mouse-pick-article (e)
2256 (interactive "e")
2257 (mouse-set-point e)
2258 (gnus-summary-next-page nil t))
2259
2260(defun gnus-summary-set-display-table ()
2261 ;; Change the display table. Odd characters have a tendency to mess
2262 ;; up nicely formatted displays - we make all possible glyphs
2263 ;; display only a single character.
2264
2265 ;; We start from the standard display table, if any.
2266 (let ((table (or (copy-sequence standard-display-table)
2267 (make-display-table)))
2268 (i 32))
2269 ;; Nix out all the control chars...
2270 (while (>= (setq i (1- i)) 0)
2271 (aset table i [??]))
2272 ;; ... but not newline and cr, of course. (cr is necessary for the
2273 ;; selective display).
2274 (aset table ?\n nil)
2275 (aset table ?\r nil)
6748645f
LMI
2276 ;; We keep TAB as well.
2277 (aset table ?\t nil)
eec82323
LMI
2278 ;; We nix out any glyphs over 126 that are not set already.
2279 (let ((i 256))
2280 (while (>= (setq i (1- i)) 127)
2281 ;; Only modify if the entry is nil.
2282 (unless (aref table i)
2283 (aset table i [??]))))
2284 (setq buffer-display-table table)))
2285
2286(defun gnus-summary-setup-buffer (group)
2287 "Initialize summary buffer."
2288 (let ((buffer (concat "*Summary " group "*")))
2289 (if (get-buffer buffer)
2290 (progn
2291 (set-buffer buffer)
2292 (setq gnus-summary-buffer (current-buffer))
2293 (not gnus-newsgroup-prepared))
2294 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
6748645f 2295 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
eec82323
LMI
2296 (gnus-summary-mode group)
2297 (when gnus-carpal
2298 (gnus-carpal-setup-buffer 'summary))
2299 (unless gnus-single-article-buffer
2300 (make-local-variable 'gnus-article-buffer)
2301 (make-local-variable 'gnus-article-current)
2302 (make-local-variable 'gnus-original-article-buffer))
2303 (setq gnus-newsgroup-name group)
2304 t)))
2305
2306(defun gnus-set-global-variables ()
2307 ;; Set the global equivalents of the summary buffer-local variables
2308 ;; to the latest values they had. These reflect the summary buffer
2309 ;; that was in action when the last article was fetched.
2310 (when (eq major-mode 'gnus-summary-mode)
2311 (setq gnus-summary-buffer (current-buffer))
2312 (let ((name gnus-newsgroup-name)
2313 (marked gnus-newsgroup-marked)
2314 (unread gnus-newsgroup-unreads)
2315 (headers gnus-current-headers)
2316 (data gnus-newsgroup-data)
2317 (summary gnus-summary-buffer)
2318 (article-buffer gnus-article-buffer)
2319 (original gnus-original-article-buffer)
2320 (gac gnus-article-current)
2321 (reffed gnus-reffed-article-number)
2322 (score-file gnus-current-score-file))
2323 (save-excursion
2324 (set-buffer gnus-group-buffer)
6748645f
LMI
2325 (setq gnus-newsgroup-name name
2326 gnus-newsgroup-marked marked
2327 gnus-newsgroup-unreads unread
2328 gnus-current-headers headers
2329 gnus-newsgroup-data data
2330 gnus-article-current gac
2331 gnus-summary-buffer summary
2332 gnus-article-buffer article-buffer
2333 gnus-original-article-buffer original
2334 gnus-reffed-article-number reffed
2335 gnus-current-score-file score-file)
eec82323
LMI
2336 ;; The article buffer also has local variables.
2337 (when (gnus-buffer-live-p gnus-article-buffer)
2338 (set-buffer gnus-article-buffer)
2339 (setq gnus-summary-buffer summary))))))
2340
2341(defun gnus-summary-article-unread-p (article)
2342 "Say whether ARTICLE is unread or not."
2343 (memq article gnus-newsgroup-unreads))
2344
2345(defun gnus-summary-first-article-p (&optional article)
2346 "Return whether ARTICLE is the first article in the buffer."
2347 (if (not (setq article (or article (gnus-summary-article-number))))
2348 nil
2349 (eq article (caar gnus-newsgroup-data))))
2350
2351(defun gnus-summary-last-article-p (&optional article)
2352 "Return whether ARTICLE is the last article in the buffer."
2353 (if (not (setq article (or article (gnus-summary-article-number))))
2354 t ; All non-existent numbers are the last article. :-)
2355 (not (cdr (gnus-data-find-list article)))))
2356
2357(defun gnus-make-thread-indent-array ()
2358 (let ((n 200))
2359 (unless (and gnus-thread-indent-array
2360 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2361 (setq gnus-thread-indent-array (make-vector 201 "")
2362 gnus-thread-indent-array-level gnus-thread-indent-level)
2363 (while (>= n 0)
2364 (aset gnus-thread-indent-array n
2365 (make-string (* n gnus-thread-indent-level) ? ))
2366 (setq n (1- n))))))
2367
2368(defun gnus-update-summary-mark-positions ()
2369 "Compute where the summary marks are to go."
2370 (save-excursion
6748645f 2371 (when (gnus-buffer-exists-p gnus-summary-buffer)
eec82323
LMI
2372 (set-buffer gnus-summary-buffer))
2373 (let ((gnus-replied-mark 129)
2374 (gnus-score-below-mark 130)
2375 (gnus-score-over-mark 130)
6748645f 2376 (gnus-download-mark 131)
eec82323 2377 (spec gnus-summary-line-format-spec)
6748645f 2378 gnus-visual pos)
eec82323
LMI
2379 (save-excursion
2380 (gnus-set-work-buffer)
6748645f
LMI
2381 (let ((gnus-summary-line-format-spec spec)
2382 (gnus-newsgroup-downloadable '((0 . t))))
eec82323
LMI
2383 (gnus-summary-insert-line
2384 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2385 (goto-char (point-min))
2386 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2387 (- (point) 2)))))
2388 (goto-char (point-min))
2389 (push (cons 'replied (and (search-forward "\201" nil t)
2390 (- (point) 2)))
2391 pos)
2392 (goto-char (point-min))
2393 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
6748645f
LMI
2394 pos)
2395 (goto-char (point-min))
2396 (push (cons 'download
2397 (and (search-forward "\203" nil t) (- (point) 2)))
eec82323
LMI
2398 pos)))
2399 (setq gnus-summary-mark-positions pos))))
2400
2401(defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2402 "Insert a dummy root in the summary buffer."
2403 (beginning-of-line)
2404 (gnus-add-text-properties
2405 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2406 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2407
2408(defun gnus-summary-insert-line (gnus-tmp-header
2409 gnus-tmp-level gnus-tmp-current
2410 gnus-tmp-unread gnus-tmp-replied
2411 gnus-tmp-expirable gnus-tmp-subject-or-nil
2412 &optional gnus-tmp-dummy gnus-tmp-score
2413 gnus-tmp-process)
2414 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2415 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2416 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2417 (gnus-tmp-score-char
2418 (if (or (null gnus-summary-default-score)
2419 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2420 gnus-summary-zcore-fuzz))
6748645f 2421 ? ;space
eec82323
LMI
2422 (if (< gnus-tmp-score gnus-summary-default-score)
2423 gnus-score-below-mark gnus-score-over-mark)))
2424 (gnus-tmp-replied
2425 (cond (gnus-tmp-process gnus-process-mark)
2426 ((memq gnus-tmp-current gnus-newsgroup-cached)
2427 gnus-cached-mark)
2428 (gnus-tmp-replied gnus-replied-mark)
2429 ((memq gnus-tmp-current gnus-newsgroup-saved)
2430 gnus-saved-mark)
2431 (t gnus-unread-mark)))
2432 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2433 (gnus-tmp-name
2434 (cond
2435 ((string-match "<[^>]+> *$" gnus-tmp-from)
2436 (let ((beg (match-beginning 0)))
2437 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2438 (substring gnus-tmp-from (1+ (match-beginning 0))
2439 (1- (match-end 0))))
2440 (substring gnus-tmp-from 0 beg))))
2441 ((string-match "(.+)" gnus-tmp-from)
2442 (substring gnus-tmp-from
2443 (1+ (match-beginning 0)) (1- (match-end 0))))
2444 (t gnus-tmp-from)))
2445 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2446 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2447 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2448 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2449 (buffer-read-only nil))
2450 (when (string= gnus-tmp-name "")
2451 (setq gnus-tmp-name gnus-tmp-from))
2452 (unless (numberp gnus-tmp-lines)
2453 (setq gnus-tmp-lines 0))
6748645f 2454 (gnus-put-text-property-excluding-characters-with-faces
eec82323
LMI
2455 (point)
2456 (progn (eval gnus-summary-line-format-spec) (point))
2457 'gnus-number gnus-tmp-number)
2458 (when (gnus-visual-p 'summary-highlight 'highlight)
2459 (forward-line -1)
6748645f 2460 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
2461 (forward-line 1))))
2462
2463(defun gnus-summary-update-line (&optional dont-update)
2464 ;; Update summary line after change.
2465 (when (and gnus-summary-default-score
2466 (not gnus-summary-inhibit-highlight))
2467 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2468 (article (gnus-summary-article-number))
2469 (score (gnus-summary-article-score article)))
2470 (unless dont-update
2471 (if (and gnus-summary-mark-below
2472 (< (gnus-summary-article-score)
2473 gnus-summary-mark-below))
2474 ;; This article has a low score, so we mark it as read.
2475 (when (memq article gnus-newsgroup-unreads)
2476 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2477 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2478 ;; This article was previously marked as read on account
2479 ;; of a low score, but now it has risen, so we mark it as
2480 ;; unread.
2481 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2482 (gnus-summary-update-mark
2483 (if (or (null gnus-summary-default-score)
2484 (<= (abs (- score gnus-summary-default-score))
2485 gnus-summary-zcore-fuzz))
6748645f 2486 ? ;space
eec82323
LMI
2487 (if (< score gnus-summary-default-score)
2488 gnus-score-below-mark gnus-score-over-mark))
2489 'score))
2490 ;; Do visual highlighting.
2491 (when (gnus-visual-p 'summary-highlight 'highlight)
6748645f 2492 (gnus-run-hooks 'gnus-summary-update-hook)))))
eec82323
LMI
2493
2494(defvar gnus-tmp-new-adopts nil)
2495
2496(defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2497 "Return the number of articles in THREAD.
2498This may be 0 in some cases -- if none of the articles in
2499the thread are to be displayed."
2500 (let* ((number
2501 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2502 (cond
2503 ((not (listp thread))
2504 1)
2505 ((and (consp thread) (cdr thread))
2506 (apply
2507 '+ 1 (mapcar
2508 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2509 ((null thread)
2510 1)
2511 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2512 1)
2513 (t 0))))
2514 (when (and level (zerop level) gnus-tmp-new-adopts)
2515 (incf number
2516 (apply '+ (mapcar
2517 'gnus-summary-number-of-articles-in-thread
2518 gnus-tmp-new-adopts))))
2519 (if char
2520 (if (> number 1) gnus-not-empty-thread-mark
2521 gnus-empty-thread-mark)
2522 number)))
2523
2524(defun gnus-summary-set-local-parameters (group)
2525 "Go through the local params of GROUP and set all variable specs in that list."
2526 (let ((params (gnus-group-find-parameter group))
2527 elem)
2528 (while params
2529 (setq elem (car params)
2530 params (cdr params))
2531 (and (consp elem) ; Has to be a cons.
2532 (consp (cdr elem)) ; The cdr has to be a list.
2533 (symbolp (car elem)) ; Has to be a symbol in there.
6748645f 2534 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
eec82323
LMI
2535 (ignore-errors ; So we set it.
2536 (make-local-variable (car elem))
2537 (set (car elem) (eval (nth 1 elem))))))))
2538
2539(defun gnus-summary-read-group (group &optional show-all no-article
6748645f
LMI
2540 kill-buffer no-display backward
2541 select-articles)
eec82323
LMI
2542 "Start reading news in newsgroup GROUP.
2543If SHOW-ALL is non-nil, already read articles are also listed.
2544If NO-ARTICLE is non-nil, no article is selected initially.
2545If NO-DISPLAY, don't generate a summary buffer."
2546 (let (result)
2547 (while (and group
2548 (null (setq result
2549 (let ((gnus-auto-select-next nil))
6748645f
LMI
2550 (or (gnus-summary-read-group-1
2551 group show-all no-article
2552 kill-buffer no-display
2553 select-articles)
2554 (setq show-all nil
2555 select-articles nil)))))
eec82323
LMI
2556 (eq gnus-auto-select-next 'quietly))
2557 (set-buffer gnus-group-buffer)
6748645f
LMI
2558 ;; The entry function called above goes to the next
2559 ;; group automatically, so we go two groups back
2560 ;; if we are searching for the previous group.
2561 (when backward
2562 (gnus-group-prev-unread-group 2))
eec82323
LMI
2563 (if (not (equal group (gnus-group-group-name)))
2564 (setq group (gnus-group-group-name))
2565 (setq group nil)))
2566 result))
2567
2568(defun gnus-summary-read-group-1 (group show-all no-article
6748645f
LMI
2569 kill-buffer no-display
2570 &optional select-articles)
eec82323
LMI
2571 ;; Killed foreign groups can't be entered.
2572 (when (and (not (gnus-group-native-p group))
2573 (not (gnus-gethash group gnus-newsrc-hashtb)))
2574 (error "Dead non-native groups can't be entered"))
2575 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2576 (let* ((new-group (gnus-summary-setup-buffer group))
2577 (quit-config (gnus-group-quit-config group))
6748645f
LMI
2578 (did-select (and new-group (gnus-select-newsgroup
2579 group show-all select-articles))))
eec82323
LMI
2580 (cond
2581 ;; This summary buffer exists already, so we just select it.
2582 ((not new-group)
2583 (gnus-set-global-variables)
2584 (when kill-buffer
2585 (gnus-kill-or-deaden-summary kill-buffer))
2586 (gnus-configure-windows 'summary 'force)
2587 (gnus-set-mode-line 'summary)
2588 (gnus-summary-position-point)
2589 (message "")
2590 t)
2591 ;; We couldn't select this group.
2592 ((null did-select)
2593 (when (and (eq major-mode 'gnus-summary-mode)
2594 (not (equal (current-buffer) kill-buffer)))
2595 (kill-buffer (current-buffer))
2596 (if (not quit-config)
2597 (progn
6748645f
LMI
2598 ;; Update the info -- marks might need to be removed,
2599 ;; for instance.
2600 (gnus-summary-update-info)
eec82323
LMI
2601 (set-buffer gnus-group-buffer)
2602 (gnus-group-jump-to-group group)
2603 (gnus-group-next-unread-group 1))
2604 (gnus-handle-ephemeral-exit quit-config)))
2605 (gnus-message 3 "Can't select group")
2606 nil)
2607 ;; The user did a `C-g' while prompting for number of articles,
2608 ;; so we exit this group.
2609 ((eq did-select 'quit)
2610 (and (eq major-mode 'gnus-summary-mode)
2611 (not (equal (current-buffer) kill-buffer))
2612 (kill-buffer (current-buffer)))
2613 (when kill-buffer
2614 (gnus-kill-or-deaden-summary kill-buffer))
2615 (if (not quit-config)
2616 (progn
2617 (set-buffer gnus-group-buffer)
2618 (gnus-group-jump-to-group group)
2619 (gnus-group-next-unread-group 1)
2620 (gnus-configure-windows 'group 'force))
2621 (gnus-handle-ephemeral-exit quit-config))
2622 ;; Finally signal the quit.
2623 (signal 'quit nil))
2624 ;; The group was successfully selected.
2625 (t
2626 (gnus-set-global-variables)
2627 ;; Save the active value in effect when the group was entered.
2628 (setq gnus-newsgroup-active
2629 (gnus-copy-sequence
2630 (gnus-active gnus-newsgroup-name)))
2631 ;; You can change the summary buffer in some way with this hook.
6748645f 2632 (gnus-run-hooks 'gnus-select-group-hook)
eec82323
LMI
2633 ;; Set any local variables in the group parameters.
2634 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2635 (gnus-update-format-specifications
2636 nil 'summary 'summary-mode 'summary-dummy)
2637 ;; Do score processing.
2638 (when gnus-use-scoring
2639 (gnus-possibly-score-headers))
2640 ;; Check whether to fill in the gaps in the threads.
2641 (when gnus-build-sparse-threads
2642 (gnus-build-sparse-threads))
2643 ;; Find the initial limit.
2644 (if gnus-show-threads
2645 (if show-all
2646 (let ((gnus-newsgroup-dormant nil))
2647 (gnus-summary-initial-limit show-all))
2648 (gnus-summary-initial-limit show-all))
2649 (setq gnus-newsgroup-limit
2650 (mapcar
2651 (lambda (header) (mail-header-number header))
2652 gnus-newsgroup-headers)))
2653 ;; Generate the summary buffer.
2654 (unless no-display
2655 (gnus-summary-prepare))
2656 (when gnus-use-trees
2657 (gnus-tree-open group)
2658 (setq gnus-summary-highlight-line-function
2659 'gnus-tree-highlight-article))
2660 ;; If the summary buffer is empty, but there are some low-scored
2661 ;; articles or some excluded dormants, we include these in the
2662 ;; buffer.
2663 (when (and (zerop (buffer-size))
2664 (not no-display))
2665 (cond (gnus-newsgroup-dormant
2666 (gnus-summary-limit-include-dormant))
2667 ((and gnus-newsgroup-scored show-all)
2668 (gnus-summary-limit-include-expunged t))))
2669 ;; Function `gnus-apply-kill-file' must be called in this hook.
6748645f 2670 (gnus-run-hooks 'gnus-apply-kill-hook)
eec82323
LMI
2671 (if (and (zerop (buffer-size))
2672 (not no-display))
2673 (progn
2674 ;; This newsgroup is empty.
2675 (gnus-summary-catchup-and-exit nil t)
2676 (gnus-message 6 "No unread news")
2677 (when kill-buffer
2678 (gnus-kill-or-deaden-summary kill-buffer))
2679 ;; Return nil from this function.
2680 nil)
2681 ;; Hide conversation thread subtrees. We cannot do this in
2682 ;; gnus-summary-prepare-hook since kill processing may not
2683 ;; work with hidden articles.
2684 (and gnus-show-threads
2685 gnus-thread-hide-subtree
2686 (gnus-summary-hide-all-threads))
6748645f
LMI
2687 (when kill-buffer
2688 (gnus-kill-or-deaden-summary kill-buffer))
eec82323
LMI
2689 ;; Show first unread article if requested.
2690 (if (and (not no-article)
2691 (not no-display)
2692 gnus-newsgroup-unreads
2693 gnus-auto-select-first)
2694 (unless (if (eq gnus-auto-select-first 'best)
2695 (gnus-summary-best-unread-article)
2696 (gnus-summary-first-unread-article))
2697 (gnus-configure-windows 'summary))
2698 ;; Don't select any articles, just move point to the first
2699 ;; article in the group.
2700 (goto-char (point-min))
2701 (gnus-summary-position-point)
6748645f
LMI
2702 (gnus-configure-windows 'summary 'force)
2703 (gnus-set-mode-line 'summary))
eec82323
LMI
2704 (when (get-buffer-window gnus-group-buffer t)
2705 ;; Gotta use windows, because recenter does weird stuff if
2706 ;; the current buffer ain't the displayed window.
2707 (let ((owin (selected-window)))
2708 (select-window (get-buffer-window gnus-group-buffer t))
2709 (when (gnus-group-goto-group group)
2710 (recenter))
2711 (select-window owin)))
2712 ;; Mark this buffer as "prepared".
2713 (setq gnus-newsgroup-prepared t)
6748645f 2714 (gnus-run-hooks 'gnus-summary-prepared-hook)
eec82323
LMI
2715 t)))))
2716
2717(defun gnus-summary-prepare ()
2718 "Generate the summary buffer."
2719 (interactive)
2720 (let ((buffer-read-only nil))
2721 (erase-buffer)
2722 (setq gnus-newsgroup-data nil
2723 gnus-newsgroup-data-reverse nil)
6748645f 2724 (gnus-run-hooks 'gnus-summary-generate-hook)
eec82323
LMI
2725 ;; Generate the buffer, either with threads or without.
2726 (when gnus-newsgroup-headers
2727 (gnus-summary-prepare-threads
2728 (if gnus-show-threads
2729 (gnus-sort-gathered-threads
2730 (funcall gnus-summary-thread-gathering-function
2731 (gnus-sort-threads
2732 (gnus-cut-threads (gnus-make-threads)))))
2733 ;; Unthreaded display.
2734 (gnus-sort-articles gnus-newsgroup-headers))))
2735 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2736 ;; Call hooks for modifying summary buffer.
2737 (goto-char (point-min))
6748645f 2738 (gnus-run-hooks 'gnus-summary-prepare-hook)))
eec82323
LMI
2739
2740(defsubst gnus-general-simplify-subject (subject)
2741 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2742 (setq subject
2743 (cond
2744 ;; Truncate the subject.
6748645f
LMI
2745 (gnus-simplify-subject-functions
2746 (gnus-map-function gnus-simplify-subject-functions subject))
eec82323
LMI
2747 ((numberp gnus-summary-gather-subject-limit)
2748 (setq subject (gnus-simplify-subject-re subject))
2749 (if (> (length subject) gnus-summary-gather-subject-limit)
2750 (substring subject 0 gnus-summary-gather-subject-limit)
2751 subject))
2752 ;; Fuzzily simplify it.
2753 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2754 (gnus-simplify-subject-fuzzy subject))
2755 ;; Just remove the leading "Re:".
2756 (t
2757 (gnus-simplify-subject-re subject))))
2758
2759 (if (and gnus-summary-gather-exclude-subject
2760 (string-match gnus-summary-gather-exclude-subject subject))
2761 nil ; This article shouldn't be gathered
2762 subject))
2763
2764(defun gnus-summary-simplify-subject-query ()
2765 "Query where the respool algorithm would put this article."
2766 (interactive)
eec82323
LMI
2767 (gnus-summary-select-article)
2768 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2769
2770(defun gnus-gather-threads-by-subject (threads)
2771 "Gather threads by looking at Subject headers."
2772 (if (not gnus-summary-make-false-root)
2773 threads
2774 (let ((hashtb (gnus-make-hashtable 1024))
2775 (prev threads)
2776 (result threads)
2777 subject hthread whole-subject)
2778 (while threads
2779 (setq subject (gnus-general-simplify-subject
2780 (setq whole-subject (mail-header-subject
2781 (caar threads)))))
2782 (when subject
2783 (if (setq hthread (gnus-gethash subject hashtb))
2784 (progn
2785 ;; We enter a dummy root into the thread, if we
2786 ;; haven't done that already.
2787 (unless (stringp (caar hthread))
2788 (setcar hthread (list whole-subject (car hthread))))
2789 ;; We add this new gathered thread to this gathered
2790 ;; thread.
2791 (setcdr (car hthread)
2792 (nconc (cdar hthread) (list (car threads))))
2793 ;; Remove it from the list of threads.
2794 (setcdr prev (cdr threads))
2795 (setq threads prev))
2796 ;; Enter this thread into the hash table.
2797 (gnus-sethash subject threads hashtb)))
2798 (setq prev threads)
2799 (setq threads (cdr threads)))
2800 result)))
2801
2802(defun gnus-gather-threads-by-references (threads)
2803 "Gather threads by looking at References headers."
2804 (let ((idhashtb (gnus-make-hashtable 1024))
2805 (thhashtb (gnus-make-hashtable 1024))
2806 (prev threads)
2807 (result threads)
2808 ids references id gthread gid entered ref)
2809 (while threads
2810 (when (setq references (mail-header-references (caar threads)))
2811 (setq id (mail-header-id (caar threads))
2812 ids (gnus-split-references references)
2813 entered nil)
2814 (while (setq ref (pop ids))
2815 (setq ids (delete ref ids))
2816 (if (not (setq gid (gnus-gethash ref idhashtb)))
2817 (progn
2818 (gnus-sethash ref id idhashtb)
2819 (gnus-sethash id threads thhashtb))
2820 (setq gthread (gnus-gethash gid thhashtb))
2821 (unless entered
2822 ;; We enter a dummy root into the thread, if we
2823 ;; haven't done that already.
2824 (unless (stringp (caar gthread))
2825 (setcar gthread (list (mail-header-subject (caar gthread))
2826 (car gthread))))
2827 ;; We add this new gathered thread to this gathered
2828 ;; thread.
2829 (setcdr (car gthread)
2830 (nconc (cdar gthread) (list (car threads)))))
2831 ;; Add it into the thread hash table.
2832 (gnus-sethash id gthread thhashtb)
2833 (setq entered t)
2834 ;; Remove it from the list of threads.
2835 (setcdr prev (cdr threads))
2836 (setq threads prev))))
2837 (setq prev threads)
2838 (setq threads (cdr threads)))
2839 result))
2840
2841(defun gnus-sort-gathered-threads (threads)
2842 "Sort subtreads inside each gathered thread by article number."
2843 (let ((result threads))
2844 (while threads
2845 (when (stringp (caar threads))
2846 (setcdr (car threads)
2847 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2848 (setq threads (cdr threads)))
2849 result))
2850
2851(defun gnus-thread-loop-p (root thread)
2852 "Say whether ROOT is in THREAD."
2853 (let ((stack (list thread))
2854 (infloop 0)
2855 th)
2856 (while (setq thread (pop stack))
2857 (setq th (cdr thread))
2858 (while (and th
2859 (not (eq (caar th) root)))
2860 (pop th))
2861 (if th
2862 ;; We have found a loop.
2863 (let (ref-dep)
2864 (setcdr thread (delq (car th) (cdr thread)))
2865 (if (boundp (setq ref-dep (intern "none"
2866 gnus-newsgroup-dependencies)))
2867 (setcdr (symbol-value ref-dep)
2868 (nconc (cdr (symbol-value ref-dep))
2869 (list (car th))))
2870 (set ref-dep (list nil (car th))))
2871 (setq infloop 1
2872 stack nil))
2873 ;; Push all the subthreads onto the stack.
2874 (push (cdr thread) stack)))
2875 infloop))
2876
2877(defun gnus-make-threads ()
2878 "Go through the dependency hashtb and find the roots. Return all threads."
2879 (let (threads)
2880 (while (catch 'infloop
2881 (mapatoms
2882 (lambda (refs)
2883 ;; Deal with self-referencing References loops.
2884 (when (and (car (symbol-value refs))
2885 (not (zerop
2886 (apply
2887 '+
2888 (mapcar
2889 (lambda (thread)
2890 (gnus-thread-loop-p
2891 (car (symbol-value refs)) thread))
2892 (cdr (symbol-value refs)))))))
2893 (setq threads nil)
2894 (throw 'infloop t))
2895 (unless (car (symbol-value refs))
2896 ;; These threads do not refer back to any other articles,
2897 ;; so they're roots.
2898 (setq threads (append (cdr (symbol-value refs)) threads))))
2899 gnus-newsgroup-dependencies)))
2900 threads))
2901
6748645f
LMI
2902;; Build the thread tree.
2903(defun gnus-dependencies-add-header (header dependencies force-new)
2904 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2905
2906If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2907if it was already present.
2908
2909If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
2910will not be entered in the DEPENDENCIES table. Otherwise duplicate
2911Message-IDs will be renamed be renamed to a unique Message-ID before
2912being entered.
2913
2914Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
2915 (let* ((id (mail-header-id header))
2916 (id-dep (and id (intern id dependencies)))
2917 ref ref-dep ref-header)
2918 ;; Enter this `header' in the `dependencies' table.
2919 (cond
2920 ((not id-dep)
2921 (setq header nil))
2922 ;; The first two cases do the normal part: enter a new `header'
2923 ;; in the `dependencies' table.
2924 ((not (boundp id-dep))
2925 (set id-dep (list header)))
2926 ((null (car (symbol-value id-dep)))
2927 (setcar (symbol-value id-dep) header))
2928
2929 ;; From here the `header' was already present in the
2930 ;; `dependencies' table.
2931 (force-new
2932 ;; Overrides an existing entry;
2933 ;; just set the header part of the entry.
2934 (setcar (symbol-value id-dep) header))
2935
2936 ;; Renames the existing `header' to a unique Message-ID.
2937 ((not gnus-summary-ignore-duplicates)
2938 ;; An article with this Message-ID has already been seen.
2939 ;; We rename the Message-ID.
2940 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
2941 (list header))
2942 (mail-header-set-id header id))
2943
2944 ;; The last case ignores an existing entry, except it adds any
2945 ;; additional Xrefs (in case the two articles came from different
2946 ;; servers.
2947 ;; Also sets `header' to `nil' meaning that the `dependencies'
2948 ;; table was *not* modified.
2949 (t
2950 (mail-header-set-xref
2951 (car (symbol-value id-dep))
2952 (concat (or (mail-header-xref (car (symbol-value id-dep)))
2953 "")
2954 (or (mail-header-xref header) "")))
2955 (setq header nil)))
2956
2957 (when header
2958 ;; First check if that we are not creating a References loop.
2959 (setq ref (gnus-parent-id (mail-header-references header)))
2960 (while (and ref
2961 (setq ref-dep (intern-soft ref dependencies))
2962 (boundp ref-dep)
2963 (setq ref-header (car (symbol-value ref-dep))))
2964 (if (string= id ref)
2965 ;; Yuk! This is a reference loop. Make the article be a
2966 ;; root article.
2967 (progn
2968 (mail-header-set-references (car (symbol-value id-dep)) "none")
2969 (setq ref nil))
2970 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
2971 (setq ref (gnus-parent-id (mail-header-references header)))
2972 (setq ref-dep (intern (or ref "none") dependencies))
2973 (if (boundp ref-dep)
2974 (setcdr (symbol-value ref-dep)
2975 (nconc (cdr (symbol-value ref-dep))
2976 (list (symbol-value id-dep))))
2977 (set ref-dep (list nil (symbol-value id-dep)))))
2978 header))
2979
eec82323
LMI
2980(defun gnus-build-sparse-threads ()
2981 (let ((headers gnus-newsgroup-headers)
6748645f 2982 (gnus-summary-ignore-duplicates t)
eec82323 2983 header references generation relations
6748645f 2984 subject child end new-child date)
eec82323
LMI
2985 ;; First we create an alist of generations/relations, where
2986 ;; generations is how much we trust the relation, and the relation
2987 ;; is parent/child.
2988 (gnus-message 7 "Making sparse threads...")
2989 (save-excursion
2990 (nnheader-set-temp-buffer " *gnus sparse threads*")
2991 (while (setq header (pop headers))
2992 (when (and (setq references (mail-header-references header))
2993 (not (string= references "")))
2994 (insert references)
2995 (setq child (mail-header-id header)
6748645f
LMI
2996 subject (mail-header-subject header)
2997 date (mail-header-date header)
2998 generation 0)
eec82323
LMI
2999 (while (search-backward ">" nil t)
3000 (setq end (1+ (point)))
3001 (when (search-backward "<" nil t)
6748645f 3002 (setq new-child (buffer-substring (point) end))
eec82323 3003 (push (list (incf generation)
6748645f
LMI
3004 child (setq child new-child)
3005 subject date)
eec82323 3006 relations)))
6748645f
LMI
3007 (when child
3008 (push (list (1+ generation) child nil subject) relations))
eec82323
LMI
3009 (erase-buffer)))
3010 (kill-buffer (current-buffer)))
3011 ;; Sort over trustworthiness.
6748645f
LMI
3012 (mapcar
3013 (lambda (relation)
3014 (when (gnus-dependencies-add-header
3015 (make-full-mail-header
3016 gnus-reffed-article-number
3017 (nth 3 relation) "" (or (nth 4 relation) "")
3018 (nth 1 relation)
3019 (or (nth 2 relation) "") 0 0 "")
3020 gnus-newsgroup-dependencies nil)
3021 (push gnus-reffed-article-number gnus-newsgroup-limit)
3022 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3023 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3024 gnus-newsgroup-reads)
3025 (decf gnus-reffed-article-number)))
3026 (sort relations 'car-less-than-car))
eec82323
LMI
3027 (gnus-message 7 "Making sparse threads...done")))
3028
3029(defun gnus-build-old-threads ()
3030 ;; Look at all the articles that refer back to old articles, and
3031 ;; fetch the headers for the articles that aren't there. This will
3032 ;; build complete threads - if the roots haven't been expired by the
3033 ;; server, that is.
3034 (let (id heads)
3035 (mapatoms
3036 (lambda (refs)
3037 (when (not (car (symbol-value refs)))
3038 (setq heads (cdr (symbol-value refs)))
3039 (while heads
3040 (if (memq (mail-header-number (caar heads))
3041 gnus-newsgroup-dormant)
3042 (setq heads (cdr heads))
3043 (setq id (symbol-name refs))
3044 (while (and (setq id (gnus-build-get-header id))
6748645f 3045 (not (car (gnus-id-to-thread id)))))
eec82323
LMI
3046 (setq heads nil)))))
3047 gnus-newsgroup-dependencies)))
3048
6748645f
LMI
3049;; The following macros and functions were written by Felix Lee
3050;; <flee@cse.psu.edu>.
3051
3052(defmacro gnus-nov-read-integer ()
3053 '(prog1
3054 (if (= (following-char) ?\t)
3055 0
3056 (let ((num (ignore-errors (read buffer))))
3057 (if (numberp num) num 0)))
3058 (unless (eobp)
3059 (search-forward "\t" eol 'move))))
3060
3061(defmacro gnus-nov-skip-field ()
3062 '(search-forward "\t" eol 'move))
3063
3064(defmacro gnus-nov-field ()
3065 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
3066
3067;; This function has to be called with point after the article number
3068;; on the beginning of the line.
3069(defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3070 (let ((eol (gnus-point-at-eol))
3071 (buffer (current-buffer))
3072 header)
3073
3074 ;; overview: [num subject from date id refs chars lines misc]
3075 (unwind-protect
3076 (progn
3077 (narrow-to-region (point) eol)
3078 (unless (eobp)
3079 (forward-char))
3080
3081 (setq header
3082 (make-full-mail-header
3083 number ; number
3084 (funcall
3085 gnus-unstructured-field-decoder (gnus-nov-field)) ; subject
3086 (funcall
3087 gnus-structured-field-decoder (gnus-nov-field)) ; from
3088 (gnus-nov-field) ; date
3089 (or (gnus-nov-field)
3090 (nnheader-generate-fake-message-id)) ; id
3091 (gnus-nov-field) ; refs
3092 (gnus-nov-read-integer) ; chars
3093 (gnus-nov-read-integer) ; lines
3094 (unless (= (following-char) ?\n)
3095 (gnus-nov-field))))) ; misc
3096
3097 (widen))
3098
3099 (when gnus-alter-header-function
3100 (funcall gnus-alter-header-function header))
3101 (gnus-dependencies-add-header header dependencies force-new)))
3102
eec82323
LMI
3103(defun gnus-build-get-header (id)
3104 ;; Look through the buffer of NOV lines and find the header to
3105 ;; ID. Enter this line into the dependencies hash table, and return
3106 ;; the id of the parent article (if any).
3107 (let ((deps gnus-newsgroup-dependencies)
3108 found header)
3109 (prog1
3110 (save-excursion
3111 (set-buffer nntp-server-buffer)
3112 (let ((case-fold-search nil))
3113 (goto-char (point-min))
3114 (while (and (not found)
3115 (search-forward id nil t))
3116 (beginning-of-line)
3117 (setq found (looking-at
3118 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3119 (regexp-quote id))))
3120 (or found (beginning-of-line 2)))
3121 (when found
3122 (beginning-of-line)
3123 (and
3124 (setq header (gnus-nov-parse-line
3125 (read (current-buffer)) deps))
3126 (gnus-parent-id (mail-header-references header))))))
3127 (when header
3128 (let ((number (mail-header-number header)))
3129 (push number gnus-newsgroup-limit)
3130 (push header gnus-newsgroup-headers)
3131 (if (memq number gnus-newsgroup-unselected)
3132 (progn
3133 (push number gnus-newsgroup-unreads)
3134 (setq gnus-newsgroup-unselected
3135 (delq number gnus-newsgroup-unselected)))
3136 (push number gnus-newsgroup-ancient)))))))
3137
6748645f
LMI
3138(defun gnus-build-all-threads ()
3139 "Read all the headers."
3140 (let ((gnus-summary-ignore-duplicates t)
3141 (dependencies gnus-newsgroup-dependencies)
3142 header article)
3143 (save-excursion
3144 (set-buffer nntp-server-buffer)
3145 (let ((case-fold-search nil))
3146 (goto-char (point-min))
3147 (while (not (eobp))
3148 (ignore-errors
3149 (setq article (read (current-buffer))
3150 header (gnus-nov-parse-line
3151 article dependencies)))
3152 (when header
3153 (save-excursion
3154 (set-buffer gnus-summary-buffer)
3155 (push header gnus-newsgroup-headers)
3156 (if (memq (setq article (mail-header-number header))
3157 gnus-newsgroup-unselected)
3158 (progn
3159 (push article gnus-newsgroup-unreads)
3160 (setq gnus-newsgroup-unselected
3161 (delq article gnus-newsgroup-unselected)))
3162 (push article gnus-newsgroup-ancient)))
3163 (forward-line 1)))))))
3164
eec82323
LMI
3165(defun gnus-summary-update-article-line (article header)
3166 "Update the line for ARTICLE using HEADERS."
3167 (let* ((id (mail-header-id header))
3168 (thread (gnus-id-to-thread id)))
3169 (unless thread
3170 (error "Article in no thread"))
3171 ;; Update the thread.
3172 (setcar thread header)
3173 (gnus-summary-goto-subject article)
3174 (let* ((datal (gnus-data-find-list article))
3175 (data (car datal))
3176 (length (when (cdr datal)
3177 (- (gnus-data-pos data)
3178 (gnus-data-pos (cadr datal)))))
3179 (buffer-read-only nil)
3180 (level (gnus-summary-thread-level)))
3181 (gnus-delete-line)
3182 (gnus-summary-insert-line
3183 header level nil (gnus-article-mark article)
3184 (memq article gnus-newsgroup-replied)
3185 (memq article gnus-newsgroup-expirable)
3186 ;; Only insert the Subject string when it's different
3187 ;; from the previous Subject string.
3188 (if (gnus-subject-equal
3189 (condition-case ()
3190 (mail-header-subject
3191 (gnus-data-header
3192 (cadr
3193 (gnus-data-find-list
3194 article
3195 (gnus-data-list t)))))
3196 ;; Error on the side of excessive subjects.
3197 (error ""))
3198 (mail-header-subject header))
3199 ""
3200 (mail-header-subject header))
3201 nil (cdr (assq article gnus-newsgroup-scored))
3202 (memq article gnus-newsgroup-processable))
3203 (when length
3204 (gnus-data-update-list
3205 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3206
3207(defun gnus-summary-update-article (article &optional iheader)
3208 "Update ARTICLE in the summary buffer."
3209 (set-buffer gnus-summary-buffer)
6748645f 3210 (let* ((header (gnus-summary-article-header article))
eec82323
LMI
3211 (id (mail-header-id header))
3212 (data (gnus-data-find article))
3213 (thread (gnus-id-to-thread id))
3214 (references (mail-header-references header))
3215 (parent
3216 (gnus-id-to-thread
3217 (or (gnus-parent-id
3218 (when (and references
3219 (not (equal "" references)))
3220 references))
3221 "none")))
3222 (buffer-read-only nil)
6748645f 3223 (old (car thread)))
eec82323 3224 (when thread
eec82323 3225 (unless iheader
6748645f
LMI
3226 (setcar thread nil)
3227 (when parent
3228 (delq thread parent)))
3229 (if (gnus-summary-insert-subject id header)
eec82323
LMI
3230 ;; Set the (possibly) new article number in the data structure.
3231 (gnus-data-set-number data (gnus-id-to-article id))
3232 (setcar thread old)
3233 nil))))
3234
6748645f
LMI
3235(defun gnus-rebuild-thread (id &optional line)
3236 "Rebuild the thread containing ID.
3237If LINE, insert the rebuilt thread starting on line LINE."
eec82323
LMI
3238 (let ((buffer-read-only nil)
3239 old-pos current thread data)
3240 (if (not gnus-show-threads)
3241 (setq thread (list (car (gnus-id-to-thread id))))
3242 ;; Get the thread this article is part of.
3243 (setq thread (gnus-remove-thread id)))
3244 (setq old-pos (gnus-point-at-bol))
3245 (setq current (save-excursion
3246 (and (zerop (forward-line -1))
3247 (gnus-summary-article-number))))
3248 ;; If this is a gathered thread, we have to go some re-gathering.
3249 (when (stringp (car thread))
3250 (let ((subject (car thread))
3251 roots thr)
3252 (setq thread (cdr thread))
3253 (while thread
3254 (unless (memq (setq thr (gnus-id-to-thread
3255 (gnus-root-id
3256 (mail-header-id (caar thread)))))
3257 roots)
3258 (push thr roots))
3259 (setq thread (cdr thread)))
3260 ;; We now have all (unique) roots.
3261 (if (= (length roots) 1)
3262 ;; All the loose roots are now one solid root.
3263 (setq thread (car roots))
3264 (setq thread (cons subject (gnus-sort-threads roots))))))
3265 (let (threads)
3266 ;; We then insert this thread into the summary buffer.
6748645f
LMI
3267 (when line
3268 (goto-char (point-min))
3269 (forward-line (1- line)))
eec82323
LMI
3270 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3271 (if gnus-show-threads
3272 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3273 (gnus-summary-prepare-unthreaded thread))
3274 (setq data (nreverse gnus-newsgroup-data))
3275 (setq threads gnus-newsgroup-threads))
3276 ;; We splice the new data into the data structure.
6748645f
LMI
3277 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3278 ;;!!! then we want to insert at the beginning of the buffer.
3279 ;;!!! That happens to be true with Gnus now, but that may
3280 ;;!!! change in the future. Perhaps.
3281 (gnus-data-enter-list
3282 (if line nil current) data (- (point) old-pos))
3283 (setq gnus-newsgroup-threads
3284 (nconc threads gnus-newsgroup-threads))
3285 (gnus-data-compute-positions))))
eec82323
LMI
3286
3287(defun gnus-number-to-header (number)
3288 "Return the header for article NUMBER."
3289 (let ((headers gnus-newsgroup-headers))
3290 (while (and headers
3291 (not (= number (mail-header-number (car headers)))))
3292 (pop headers))
3293 (when headers
3294 (car headers))))
3295
6748645f 3296(defun gnus-parent-headers (in-headers &optional generation)
eec82323
LMI
3297 "Return the headers of the GENERATIONeth parent of HEADERS."
3298 (unless generation
3299 (setq generation 1))
a8151ef7 3300 (let ((parent t)
6748645f 3301 (headers in-headers)
a8151ef7 3302 references)
6748645f
LMI
3303 (while (and parent
3304 (not (zerop generation))
3305 (setq references (mail-header-references headers)))
3306 (setq headers (if (and references
3307 (setq parent (gnus-parent-id references)))
3308 (car (gnus-id-to-thread parent))
3309 nil))
3310 (decf generation))
3311 (and (not (eq headers in-headers))
3312 headers)))
eec82323
LMI
3313
3314(defun gnus-id-to-thread (id)
3315 "Return the (sub-)thread where ID appears."
3316 (gnus-gethash id gnus-newsgroup-dependencies))
3317
3318(defun gnus-id-to-article (id)
3319 "Return the article number of ID."
3320 (let ((thread (gnus-id-to-thread id)))
3321 (when (and thread
3322 (car thread))
3323 (mail-header-number (car thread)))))
3324
3325(defun gnus-id-to-header (id)
3326 "Return the article headers of ID."
3327 (car (gnus-id-to-thread id)))
3328
3329(defun gnus-article-displayed-root-p (article)
3330 "Say whether ARTICLE is a root(ish) article."
3331 (let ((level (gnus-summary-thread-level article))
3332 (refs (mail-header-references (gnus-summary-article-header article)))
3333 particle)
3334 (cond
3335 ((null level) nil)
3336 ((zerop level) t)
3337 ((null refs) t)
3338 ((null (gnus-parent-id refs)) t)
3339 ((and (= 1 level)
3340 (null (setq particle (gnus-id-to-article
3341 (gnus-parent-id refs))))
3342 (null (gnus-summary-thread-level particle)))))))
3343
3344(defun gnus-root-id (id)
3345 "Return the id of the root of the thread where ID appears."
3346 (let (last-id prev)
6748645f 3347 (while (and id (setq prev (car (gnus-id-to-thread id))))
eec82323
LMI
3348 (setq last-id id
3349 id (gnus-parent-id (mail-header-references prev))))
3350 last-id))
3351
6748645f
LMI
3352(defun gnus-articles-in-thread (thread)
3353 "Return the list of articles in THREAD."
3354 (cons (mail-header-number (car thread))
3355 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3356
eec82323
LMI
3357(defun gnus-remove-thread (id &optional dont-remove)
3358 "Remove the thread that has ID in it."
6748645f 3359 (let (headers thread last-id)
eec82323 3360 ;; First go up in this thread until we find the root.
6748645f
LMI
3361 (setq last-id (gnus-root-id id)
3362 headers (message-flatten-list (gnus-id-to-thread last-id)))
eec82323
LMI
3363 ;; We have now found the real root of this thread. It might have
3364 ;; been gathered into some loose thread, so we have to search
3365 ;; through the threads to find the thread we wanted.
3366 (let ((threads gnus-newsgroup-threads)
3367 sub)
3368 (while threads
3369 (setq sub (car threads))
3370 (if (stringp (car sub))
3371 ;; This is a gathered thread, so we look at the roots
3372 ;; below it to find whether this article is in this
3373 ;; gathered root.
3374 (progn
3375 (setq sub (cdr sub))
3376 (while sub
3377 (when (member (caar sub) headers)
3378 (setq thread (car threads)
3379 threads nil
3380 sub nil))
3381 (setq sub (cdr sub))))
3382 ;; It's an ordinary thread, so we check it.
3383 (when (eq (car sub) (car headers))
3384 (setq thread sub
3385 threads nil)))
3386 (setq threads (cdr threads)))
3387 ;; If this article is in no thread, then it's a root.
3388 (if thread
3389 (unless dont-remove
3390 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
6748645f 3391 (setq thread (gnus-id-to-thread last-id)))
eec82323
LMI
3392 (when thread
3393 (prog1
3394 thread ; We return this thread.
3395 (unless dont-remove
3396 (if (stringp (car thread))
3397 (progn
3398 ;; If we use dummy roots, then we have to remove the
3399 ;; dummy root as well.
3400 (when (eq gnus-summary-make-false-root 'dummy)
6748645f
LMI
3401 ;; We go to the dummy root by going to
3402 ;; the first sub-"thread", and then one line up.
3403 (gnus-summary-goto-article
3404 (mail-header-number (caadr thread)))
3405 (forward-line -1)
eec82323
LMI
3406 (gnus-delete-line)
3407 (gnus-data-compute-positions))
3408 (setq thread (cdr thread))
3409 (while thread
3410 (gnus-remove-thread-1 (car thread))
3411 (setq thread (cdr thread))))
6748645f 3412 (gnus-summary-show-all-threads)
eec82323
LMI
3413 (gnus-remove-thread-1 thread))))))))
3414
3415(defun gnus-remove-thread-1 (thread)
3416 "Remove the thread THREAD recursively."
3417 (let ((number (mail-header-number (pop thread)))
3418 d)
3419 (setq thread (reverse thread))
3420 (while thread
3421 (gnus-remove-thread-1 (pop thread)))
3422 (when (setq d (gnus-data-find number))
3423 (goto-char (gnus-data-pos d))
3424 (gnus-data-remove
3425 number
3426 (- (gnus-point-at-bol)
3427 (prog1
3428 (1+ (gnus-point-at-eol))
3429 (gnus-delete-line)))))))
3430
3431(defun gnus-sort-threads (threads)
3432 "Sort THREADS."
3433 (if (not gnus-thread-sort-functions)
3434 threads
6748645f 3435 (gnus-message 8 "Sorting threads...")
eec82323
LMI
3436 (prog1
3437 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
6748645f 3438 (gnus-message 8 "Sorting threads...done"))))
eec82323
LMI
3439
3440(defun gnus-sort-articles (articles)
3441 "Sort ARTICLES."
3442 (when gnus-article-sort-functions
3443 (gnus-message 7 "Sorting articles...")
3444 (prog1
3445 (setq gnus-newsgroup-headers
3446 (sort articles (gnus-make-sort-function
3447 gnus-article-sort-functions)))
3448 (gnus-message 7 "Sorting articles...done"))))
3449
3450;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3451(defmacro gnus-thread-header (thread)
3452 ;; Return header of first article in THREAD.
3453 ;; Note that THREAD must never, ever be anything else than a variable -
3454 ;; using some other form will lead to serious barfage.
3455 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3456 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3457 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3458 (vector thread) 2))
3459
3460(defsubst gnus-article-sort-by-number (h1 h2)
3461 "Sort articles by article number."
3462 (< (mail-header-number h1)
3463 (mail-header-number h2)))
3464
3465(defun gnus-thread-sort-by-number (h1 h2)
3466 "Sort threads by root article number."
3467 (gnus-article-sort-by-number
3468 (gnus-thread-header h1) (gnus-thread-header h2)))
3469
3470(defsubst gnus-article-sort-by-lines (h1 h2)
3471 "Sort articles by article Lines header."
3472 (< (mail-header-lines h1)
3473 (mail-header-lines h2)))
3474
3475(defun gnus-thread-sort-by-lines (h1 h2)
3476 "Sort threads by root article Lines header."
3477 (gnus-article-sort-by-lines
3478 (gnus-thread-header h1) (gnus-thread-header h2)))
3479
3480(defsubst gnus-article-sort-by-author (h1 h2)
3481 "Sort articles by root author."
3482 (string-lessp
3483 (let ((extract (funcall
3484 gnus-extract-address-components
3485 (mail-header-from h1))))
3486 (or (car extract) (cadr extract) ""))
3487 (let ((extract (funcall
3488 gnus-extract-address-components
3489 (mail-header-from h2))))
3490 (or (car extract) (cadr extract) ""))))
3491
3492(defun gnus-thread-sort-by-author (h1 h2)
3493 "Sort threads by root author."
3494 (gnus-article-sort-by-author
3495 (gnus-thread-header h1) (gnus-thread-header h2)))
3496
3497(defsubst gnus-article-sort-by-subject (h1 h2)
3498 "Sort articles by root subject."
3499 (string-lessp
3500 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3501 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3502
3503(defun gnus-thread-sort-by-subject (h1 h2)
3504 "Sort threads by root subject."
3505 (gnus-article-sort-by-subject
3506 (gnus-thread-header h1) (gnus-thread-header h2)))
3507
3508(defsubst gnus-article-sort-by-date (h1 h2)
3509 "Sort articles by root article date."
3510 (gnus-time-less
3511 (gnus-date-get-time (mail-header-date h1))
3512 (gnus-date-get-time (mail-header-date h2))))
3513
3514(defun gnus-thread-sort-by-date (h1 h2)
3515 "Sort threads by root article date."
3516 (gnus-article-sort-by-date
3517 (gnus-thread-header h1) (gnus-thread-header h2)))
3518
3519(defsubst gnus-article-sort-by-score (h1 h2)
3520 "Sort articles by root article score.
3521Unscored articles will be counted as having a score of zero."
3522 (> (or (cdr (assq (mail-header-number h1)
3523 gnus-newsgroup-scored))
3524 gnus-summary-default-score 0)
3525 (or (cdr (assq (mail-header-number h2)
3526 gnus-newsgroup-scored))
3527 gnus-summary-default-score 0)))
3528
3529(defun gnus-thread-sort-by-score (h1 h2)
3530 "Sort threads by root article score."
3531 (gnus-article-sort-by-score
3532 (gnus-thread-header h1) (gnus-thread-header h2)))
3533
3534(defun gnus-thread-sort-by-total-score (h1 h2)
3535 "Sort threads by the sum of all scores in the thread.
3536Unscored articles will be counted as having a score of zero."
3537 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3538
3539(defun gnus-thread-total-score (thread)
3540 ;; This function find the total score of THREAD.
3541 (cond ((null thread)
3542 0)
3543 ((consp thread)
3544 (if (stringp (car thread))
3545 (apply gnus-thread-score-function 0
3546 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3547 (gnus-thread-total-score-1 thread)))
3548 (t
3549 (gnus-thread-total-score-1 (list thread)))))
3550
3551(defun gnus-thread-total-score-1 (root)
3552 ;; This function find the total score of the thread below ROOT.
3553 (setq root (car root))
3554 (apply gnus-thread-score-function
3555 (or (append
3556 (mapcar 'gnus-thread-total-score
6748645f 3557 (cdr (gnus-id-to-thread (mail-header-id root))))
eec82323
LMI
3558 (when (> (mail-header-number root) 0)
3559 (list (or (cdr (assq (mail-header-number root)
3560 gnus-newsgroup-scored))
3561 gnus-summary-default-score 0))))
3562 (list gnus-summary-default-score)
3563 '(0))))
3564
3565;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3566(defvar gnus-tmp-prev-subject nil)
3567(defvar gnus-tmp-false-parent nil)
3568(defvar gnus-tmp-root-expunged nil)
3569(defvar gnus-tmp-dummy-line nil)
3570
3571(defun gnus-summary-prepare-threads (threads)
3572 "Prepare summary buffer from THREADS and indentation LEVEL.
3573THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3574or a straight list of headers."
3575 (gnus-message 7 "Generating summary...")
3576
3577 (setq gnus-newsgroup-threads threads)
3578 (beginning-of-line)
3579
3580 (let ((gnus-tmp-level 0)
3581 (default-score (or gnus-summary-default-score 0))
3582 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3583 thread number subject stack state gnus-tmp-gathered beg-match
3584 new-roots gnus-tmp-new-adopts thread-end
3585 gnus-tmp-header gnus-tmp-unread
3586 gnus-tmp-replied gnus-tmp-subject-or-nil
3587 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3588 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3589 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3590
3591 (setq gnus-tmp-prev-subject nil)
3592
3593 (if (vectorp (car threads))
3594 ;; If this is a straight (sic) list of headers, then a
3595 ;; threaded summary display isn't required, so we just create
3596 ;; an unthreaded one.
3597 (gnus-summary-prepare-unthreaded threads)
3598
3599 ;; Do the threaded display.
3600
3601 (while (or threads stack gnus-tmp-new-adopts new-roots)
3602
3603 (if (and (= gnus-tmp-level 0)
eec82323
LMI
3604 (or (not stack)
3605 (= (caar stack) 0))
3606 (not gnus-tmp-false-parent)
3607 (or gnus-tmp-new-adopts new-roots))
3608 (if gnus-tmp-new-adopts
3609 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3610 thread (list (car gnus-tmp-new-adopts))
3611 gnus-tmp-header (caar thread)
3612 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3613 (when new-roots
3614 (setq thread (list (car new-roots))
3615 gnus-tmp-header (caar thread)
3616 new-roots (cdr new-roots))))
3617
3618 (if threads
3619 ;; If there are some threads, we do them before the
3620 ;; threads on the stack.
3621 (setq thread threads
3622 gnus-tmp-header (caar thread))
3623 ;; There were no current threads, so we pop something off
3624 ;; the stack.
3625 (setq state (car stack)
3626 gnus-tmp-level (car state)
3627 thread (cdr state)
3628 stack (cdr stack)
3629 gnus-tmp-header (caar thread))))
3630
3631 (setq gnus-tmp-false-parent nil)
3632 (setq gnus-tmp-root-expunged nil)
3633 (setq thread-end nil)
3634
3635 (if (stringp gnus-tmp-header)
3636 ;; The header is a dummy root.
3637 (cond
3638 ((eq gnus-summary-make-false-root 'adopt)
3639 ;; We let the first article adopt the rest.
3640 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3641 (cddar thread)))
3642 (setq gnus-tmp-gathered
3643 (nconc (mapcar
3644 (lambda (h) (mail-header-number (car h)))
3645 (cddar thread))
3646 gnus-tmp-gathered))
3647 (setq thread (cons (list (caar thread)
3648 (cadar thread))
3649 (cdr thread)))
3650 (setq gnus-tmp-level -1
3651 gnus-tmp-false-parent t))
3652 ((eq gnus-summary-make-false-root 'empty)
3653 ;; We print adopted articles with empty subject fields.
3654 (setq gnus-tmp-gathered
3655 (nconc (mapcar
3656 (lambda (h) (mail-header-number (car h)))
3657 (cddar thread))
3658 gnus-tmp-gathered))
3659 (setq gnus-tmp-level -1))
3660 ((eq gnus-summary-make-false-root 'dummy)
3661 ;; We remember that we probably want to output a dummy
3662 ;; root.
3663 (setq gnus-tmp-dummy-line gnus-tmp-header)
3664 (setq gnus-tmp-prev-subject gnus-tmp-header))
3665 (t
3666 ;; We do not make a root for the gathered
3667 ;; sub-threads at all.
3668 (setq gnus-tmp-level -1)))
3669
3670 (setq number (mail-header-number gnus-tmp-header)
3671 subject (mail-header-subject gnus-tmp-header))
3672
3673 (cond
3674 ;; If the thread has changed subject, we might want to make
3675 ;; this subthread into a root.
3676 ((and (null gnus-thread-ignore-subject)
3677 (not (zerop gnus-tmp-level))
3678 gnus-tmp-prev-subject
3679 (not (inline
3680 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3681 (setq new-roots (nconc new-roots (list (car thread)))
3682 thread-end t
3683 gnus-tmp-header nil))
3684 ;; If the article lies outside the current limit,
3685 ;; then we do not display it.
3686 ((not (memq number gnus-newsgroup-limit))
3687 (setq gnus-tmp-gathered
3688 (nconc (mapcar
3689 (lambda (h) (mail-header-number (car h)))
3690 (cdar thread))
3691 gnus-tmp-gathered))
3692 (setq gnus-tmp-new-adopts (if (cdar thread)
3693 (append gnus-tmp-new-adopts
3694 (cdar thread))
3695 gnus-tmp-new-adopts)
3696 thread-end t
3697 gnus-tmp-header nil)
3698 (when (zerop gnus-tmp-level)
3699 (setq gnus-tmp-root-expunged t)))
3700 ;; Perhaps this article is to be marked as read?
3701 ((and gnus-summary-mark-below
3702 (< (or (cdr (assq number gnus-newsgroup-scored))
3703 default-score)
3704 gnus-summary-mark-below)
3705 ;; Don't touch sparse articles.
3706 (not (gnus-summary-article-sparse-p number))
3707 (not (gnus-summary-article-ancient-p number)))
3708 (setq gnus-newsgroup-unreads
3709 (delq number gnus-newsgroup-unreads))
3710 (if gnus-newsgroup-auto-expire
3711 (push number gnus-newsgroup-expirable)
3712 (push (cons number gnus-low-score-mark)
3713 gnus-newsgroup-reads))))
3714
3715 (when gnus-tmp-header
3716 ;; We may have an old dummy line to output before this
3717 ;; article.
6748645f
LMI
3718 (when (and gnus-tmp-dummy-line
3719 (gnus-subject-equal
3720 gnus-tmp-dummy-line
3721 (mail-header-subject gnus-tmp-header)))
eec82323
LMI
3722 (gnus-summary-insert-dummy-line
3723 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3724 (setq gnus-tmp-dummy-line nil))
3725
3726 ;; Compute the mark.
3727 (setq gnus-tmp-unread (gnus-article-mark number))
3728
3729 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3730 gnus-tmp-header gnus-tmp-level)
3731 gnus-newsgroup-data)
3732
3733 ;; Actually insert the line.
3734 (setq
3735 gnus-tmp-subject-or-nil
3736 (cond
3737 ((and gnus-thread-ignore-subject
3738 gnus-tmp-prev-subject
3739 (not (inline (gnus-subject-equal
3740 gnus-tmp-prev-subject subject))))
3741 subject)
3742 ((zerop gnus-tmp-level)
3743 (if (and (eq gnus-summary-make-false-root 'empty)
3744 (memq number gnus-tmp-gathered)
3745 gnus-tmp-prev-subject
3746 (inline (gnus-subject-equal
3747 gnus-tmp-prev-subject subject)))
3748 gnus-summary-same-subject
3749 subject))
3750 (t gnus-summary-same-subject)))
3751 (if (and (eq gnus-summary-make-false-root 'adopt)
3752 (= gnus-tmp-level 1)
3753 (memq number gnus-tmp-gathered))
3754 (setq gnus-tmp-opening-bracket ?\<
3755 gnus-tmp-closing-bracket ?\>)
3756 (setq gnus-tmp-opening-bracket ?\[
3757 gnus-tmp-closing-bracket ?\]))
3758 (setq
3759 gnus-tmp-indentation
3760 (aref gnus-thread-indent-array gnus-tmp-level)
3761 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3762 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3763 gnus-summary-default-score 0)
3764 gnus-tmp-score-char
3765 (if (or (null gnus-summary-default-score)
3766 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3767 gnus-summary-zcore-fuzz))
6748645f 3768 ? ;space
eec82323
LMI
3769 (if (< gnus-tmp-score gnus-summary-default-score)
3770 gnus-score-below-mark gnus-score-over-mark))
3771 gnus-tmp-replied
3772 (cond ((memq number gnus-newsgroup-processable)
3773 gnus-process-mark)
3774 ((memq number gnus-newsgroup-cached)
3775 gnus-cached-mark)
3776 ((memq number gnus-newsgroup-replied)
3777 gnus-replied-mark)
3778 ((memq number gnus-newsgroup-saved)
3779 gnus-saved-mark)
3780 (t gnus-unread-mark))
3781 gnus-tmp-from (mail-header-from gnus-tmp-header)
3782 gnus-tmp-name
3783 (cond
3784 ((string-match "<[^>]+> *$" gnus-tmp-from)
3785 (setq beg-match (match-beginning 0))
3786 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3787 (substring gnus-tmp-from (1+ (match-beginning 0))
3788 (1- (match-end 0))))
3789 (substring gnus-tmp-from 0 beg-match)))
3790 ((string-match "(.+)" gnus-tmp-from)
3791 (substring gnus-tmp-from
3792 (1+ (match-beginning 0)) (1- (match-end 0))))
3793 (t gnus-tmp-from)))
3794 (when (string= gnus-tmp-name "")
3795 (setq gnus-tmp-name gnus-tmp-from))
3796 (unless (numberp gnus-tmp-lines)
3797 (setq gnus-tmp-lines 0))
6748645f 3798 (gnus-put-text-property-excluding-characters-with-faces
eec82323
LMI
3799 (point)
3800 (progn (eval gnus-summary-line-format-spec) (point))
3801 'gnus-number number)
3802 (when gnus-visual-p
3803 (forward-line -1)
6748645f 3804 (gnus-run-hooks 'gnus-summary-update-hook)
eec82323
LMI
3805 (forward-line 1))
3806
3807 (setq gnus-tmp-prev-subject subject)))
3808
3809 (when (nth 1 thread)
3810 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3811 (incf gnus-tmp-level)
3812 (setq threads (if thread-end nil (cdar thread)))
3813 (unless threads
3814 (setq gnus-tmp-level 0)))))
3815 (gnus-message 7 "Generating summary...done"))
3816
3817(defun gnus-summary-prepare-unthreaded (headers)
3818 "Generate an unthreaded summary buffer based on HEADERS."
3819 (let (header number mark)
3820
3821 (beginning-of-line)
3822
3823 (while headers
3824 ;; We may have to root out some bad articles...
3825 (when (memq (setq number (mail-header-number
3826 (setq header (pop headers))))
3827 gnus-newsgroup-limit)
3828 ;; Mark article as read when it has a low score.
3829 (when (and gnus-summary-mark-below
3830 (< (or (cdr (assq number gnus-newsgroup-scored))
3831 gnus-summary-default-score 0)
3832 gnus-summary-mark-below)
3833 (not (gnus-summary-article-ancient-p number)))
3834 (setq gnus-newsgroup-unreads
3835 (delq number gnus-newsgroup-unreads))
3836 (if gnus-newsgroup-auto-expire
3837 (push number gnus-newsgroup-expirable)
3838 (push (cons number gnus-low-score-mark)
3839 gnus-newsgroup-reads)))
3840
3841 (setq mark (gnus-article-mark number))
3842 (push (gnus-data-make number mark (1+ (point)) header 0)
3843 gnus-newsgroup-data)
3844 (gnus-summary-insert-line
3845 header 0 number
3846 mark (memq number gnus-newsgroup-replied)
3847 (memq number gnus-newsgroup-expirable)
3848 (mail-header-subject header) nil
3849 (cdr (assq number gnus-newsgroup-scored))
3850 (memq number gnus-newsgroup-processable))))))
3851
6748645f 3852(defun gnus-select-newsgroup (group &optional read-all select-articles)
eec82323 3853 "Select newsgroup GROUP.
6748645f
LMI
3854If READ-ALL is non-nil, all articles in the group are selected.
3855If SELECT-ARTICLES, only select those articles from GROUP."
eec82323
LMI
3856 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3857 ;;!!! Dirty hack; should be removed.
3858 (gnus-summary-ignore-duplicates
6748645f 3859 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
eec82323
LMI
3860 t
3861 gnus-summary-ignore-duplicates))
3862 (info (nth 2 entry))
3863 articles fetched-articles cached)
3864
3865 (unless (gnus-check-server
3866 (setq gnus-current-select-method
3867 (gnus-find-method-for-group group)))
3868 (error "Couldn't open server"))
3869
3870 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3871 (gnus-activate-group group) ; Or we can activate it...
3872 (progn ; Or we bug out.
3873 (when (equal major-mode 'gnus-summary-mode)
3874 (kill-buffer (current-buffer)))
3875 (error "Couldn't request group %s: %s"
3876 group (gnus-status-message group))))
3877
3878 (unless (gnus-request-group group t)
3879 (when (equal major-mode 'gnus-summary-mode)
3880 (kill-buffer (current-buffer)))
3881 (error "Couldn't request group %s: %s"
3882 group (gnus-status-message group)))
3883
3884 (setq gnus-newsgroup-name group)
3885 (setq gnus-newsgroup-unselected nil)
3886 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3887
3888 ;; Adjust and set lists of article marks.
3889 (when info
3890 (gnus-adjust-marked-articles info))
3891
3892 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3893 (when (gnus-virtual-group-p group)
3894 (setq cached gnus-newsgroup-cached))
3895
3896 (setq gnus-newsgroup-unreads
3897 (gnus-set-difference
3898 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3899 gnus-newsgroup-dormant))
3900
3901 (setq gnus-newsgroup-processable nil)
3902
3903 (gnus-update-read-articles group gnus-newsgroup-unreads)
eec82323 3904
6748645f
LMI
3905 (if (setq articles select-articles)
3906 (setq gnus-newsgroup-unselected
3907 (gnus-sorted-intersection
3908 gnus-newsgroup-unreads
3909 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3910 (setq articles (gnus-articles-to-read group read-all)))
eec82323
LMI
3911
3912 (cond
3913 ((null articles)
3914 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3915 'quit)
3916 ((eq articles 0) nil)
3917 (t
3918 ;; Init the dependencies hash table.
3919 (setq gnus-newsgroup-dependencies
3920 (gnus-make-hashtable (length articles)))
3921 ;; Retrieve the headers and read them in.
3922 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3923 (setq gnus-newsgroup-headers
3924 (if (eq 'nov
3925 (setq gnus-headers-retrieved-by
3926 (gnus-retrieve-headers
3927 articles gnus-newsgroup-name
3928 ;; We might want to fetch old headers, but
3929 ;; not if there is only 1 article.
6748645f 3930 (and (or (and
eec82323
LMI
3931 (not (eq gnus-fetch-old-headers 'some))
3932 (not (numberp gnus-fetch-old-headers)))
6748645f
LMI
3933 (> (length articles) 1))
3934 gnus-fetch-old-headers))))
eec82323
LMI
3935 (gnus-get-newsgroup-headers-xover
3936 articles nil nil gnus-newsgroup-name t)
3937 (gnus-get-newsgroup-headers)))
3938 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3939
3940 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3941 (when cached
3942 (setq gnus-newsgroup-cached cached))
3943
3944 ;; Suppress duplicates?
3945 (when gnus-suppress-duplicates
3946 (gnus-dup-suppress-articles))
3947
3948 ;; Set the initial limit.
3949 (setq gnus-newsgroup-limit (copy-sequence articles))
3950 ;; Remove canceled articles from the list of unread articles.
3951 (setq gnus-newsgroup-unreads
3952 (gnus-set-sorted-intersection
3953 gnus-newsgroup-unreads
3954 (setq fetched-articles
3955 (mapcar (lambda (headers) (mail-header-number headers))
3956 gnus-newsgroup-headers))))
3957 ;; Removed marked articles that do not exist.
3958 (gnus-update-missing-marks
3959 (gnus-sorted-complement fetched-articles articles))
3960 ;; We might want to build some more threads first.
6748645f
LMI
3961 (when (and gnus-fetch-old-headers
3962 (eq gnus-headers-retrieved-by 'nov))
3963 (if (eq gnus-fetch-old-headers 'invisible)
3964 (gnus-build-all-threads)
3965 (gnus-build-old-threads)))
3966 ;; Let the Gnus agent mark articles as read.
3967 (when gnus-agent
3968 (gnus-agent-get-undownloaded-list))
eec82323
LMI
3969 ;; Check whether auto-expire is to be done in this group.
3970 (setq gnus-newsgroup-auto-expire
3971 (gnus-group-auto-expirable-p group))
3972 ;; Set up the article buffer now, if necessary.
3973 (unless gnus-single-article-buffer
3974 (gnus-article-setup-buffer))
3975 ;; First and last article in this newsgroup.
3976 (when gnus-newsgroup-headers
3977 (setq gnus-newsgroup-begin
3978 (mail-header-number (car gnus-newsgroup-headers))
3979 gnus-newsgroup-end
3980 (mail-header-number
3981 (gnus-last-element gnus-newsgroup-headers))))
3982 ;; GROUP is successfully selected.
3983 (or gnus-newsgroup-headers t)))))
3984
3985(defun gnus-articles-to-read (group &optional read-all)
3986 ;; Find out what articles the user wants to read.
3987 (let* ((articles
3988 ;; Select all articles if `read-all' is non-nil, or if there
3989 ;; are no unread articles.
3990 (if (or read-all
3991 (and (zerop (length gnus-newsgroup-marked))
3992 (zerop (length gnus-newsgroup-unreads)))
3993 (eq (gnus-group-find-parameter group 'display)
3994 'all))
3995 (gnus-uncompress-range (gnus-active group))
3996 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3997 (copy-sequence gnus-newsgroup-unreads))
3998 '<)))
3999 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4000 (scored (length scored-list))
4001 (number (length articles))
4002 (marked (+ (length gnus-newsgroup-marked)
4003 (length gnus-newsgroup-dormant)))
4004 (select
4005 (cond
4006 ((numberp read-all)
4007 read-all)
4008 (t
4009 (condition-case ()
4010 (cond
4011 ((and (or (<= scored marked) (= scored number))
4012 (numberp gnus-large-newsgroup)
4013 (> number gnus-large-newsgroup))
4014 (let ((input
4015 (read-string
4016 (format
4017 "How many articles from %s (default %d): "
4018 (gnus-limit-string gnus-newsgroup-name 35)
4019 number))))
4020 (if (string-match "^[ \t]*$" input) number input)))
4021 ((and (> scored marked) (< scored number)
4022 (> (- scored number) 20))
4023 (let ((input
4024 (read-string
4025 (format "%s %s (%d scored, %d total): "
4026 "How many articles from"
4027 group scored number))))
4028 (if (string-match "^[ \t]*$" input)
4029 number input)))
4030 (t number))
4031 (quit nil))))))
4032 (setq select (if (stringp select) (string-to-number select) select))
4033 (if (or (null select) (zerop select))
4034 select
4035 (if (and (not (zerop scored)) (<= (abs select) scored))
4036 (progn
4037 (setq articles (sort scored-list '<))
4038 (setq number (length articles)))
4039 (setq articles (copy-sequence articles)))
4040
4041 (when (< (abs select) number)
4042 (if (< select 0)
4043 ;; Select the N oldest articles.
4044 (setcdr (nthcdr (1- (abs select)) articles) nil)
4045 ;; Select the N most recent articles.
4046 (setq articles (nthcdr (- number select) articles))))
4047 (setq gnus-newsgroup-unselected
4048 (gnus-sorted-intersection
4049 gnus-newsgroup-unreads
4050 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4051 articles)))
4052
4053(defun gnus-killed-articles (killed articles)
4054 (let (out)
4055 (while articles
4056 (when (inline (gnus-member-of-range (car articles) killed))
4057 (push (car articles) out))
4058 (setq articles (cdr articles)))
4059 out))
4060
4061(defun gnus-uncompress-marks (marks)
4062 "Uncompress the mark ranges in MARKS."
4063 (let ((uncompressed '(score bookmark))
4064 out)
4065 (while marks
4066 (if (memq (caar marks) uncompressed)
4067 (push (car marks) out)
4068 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4069 (setq marks (cdr marks)))
4070 out))
4071
4072(defun gnus-adjust-marked-articles (info)
4073 "Set all article lists and remove all marks that are no longer legal."
4074 (let* ((marked-lists (gnus-info-marks info))
4075 (active (gnus-active (gnus-info-group info)))
4076 (min (car active))
4077 (max (cdr active))
4078 (types gnus-article-mark-lists)
4079 (uncompressed '(score bookmark killed))
4080 marks var articles article mark)
4081
4082 (while marked-lists
4083 (setq marks (pop marked-lists))
4084 (set (setq var (intern (format "gnus-newsgroup-%s"
4085 (car (rassq (setq mark (car marks))
4086 types)))))
4087 (if (memq (car marks) uncompressed) (cdr marks)
4088 (gnus-uncompress-range (cdr marks))))
4089
4090 (setq articles (symbol-value var))
4091
4092 ;; All articles have to be subsets of the active articles.
4093 (cond
4094 ;; Adjust "simple" lists.
4095 ((memq mark '(tick dormant expire reply save))
4096 (while articles
4097 (when (or (< (setq article (pop articles)) min) (> article max))
4098 (set var (delq article (symbol-value var))))))
4099 ;; Adjust assocs.
4100 ((memq mark uncompressed)
a8151ef7
LMI
4101 (when (not (listp (cdr (symbol-value var))))
4102 (set var (list (symbol-value var))))
4103 (when (not (listp (cdr articles)))
4104 (setq articles (list articles)))
eec82323
LMI
4105 (while articles
4106 (when (or (not (consp (setq article (pop articles))))
4107 (< (car article) min)
4108 (> (car article) max))
4109 (set var (delq article (symbol-value var))))))))))
4110
4111(defun gnus-update-missing-marks (missing)
6748645f 4112 "Go through the list of MISSING articles and remove them from the mark lists."
eec82323
LMI
4113 (when missing
4114 (let ((types gnus-article-mark-lists)
4115 var m)
4116 ;; Go through all types.
4117 (while types
4118 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4119 (when (symbol-value var)
4120 ;; This list has articles. So we delete all missing articles
4121 ;; from it.
4122 (setq m missing)
4123 (while m
4124 (set var (delq (pop m) (symbol-value var)))))))))
4125
4126(defun gnus-update-marks ()
4127 "Enter the various lists of marked articles into the newsgroup info list."
4128 (let ((types gnus-article-mark-lists)
4129 (info (gnus-get-info gnus-newsgroup-name))
4130 (uncompressed '(score bookmark killed))
4131 type list newmarked symbol)
4132 (when info
4133 ;; Add all marks lists that are non-nil to the list of marks lists.
4134 (while (setq type (pop types))
4135 (when (setq list (symbol-value
4136 (setq symbol
4137 (intern (format "gnus-newsgroup-%s"
4138 (car type))))))
4139
4140 ;; Get rid of the entries of the articles that have the
4141 ;; default score.
4142 (when (and (eq (cdr type) 'score)
4143 gnus-save-score
4144 list)
4145 (let* ((arts list)
4146 (prev (cons nil list))
4147 (all prev))
4148 (while arts
4149 (if (or (not (consp (car arts)))
4150 (= (cdar arts) gnus-summary-default-score))
4151 (setcdr prev (cdr arts))
4152 (setq prev arts))
4153 (setq arts (cdr arts)))
4154 (setq list (cdr all))))
4155
4156 (push (cons (cdr type)
4157 (if (memq (cdr type) uncompressed) list
4158 (gnus-compress-sequence
4159 (set symbol (sort list '<)) t)))
4160 newmarked)))
4161
4162 ;; Enter these new marks into the info of the group.
4163 (if (nthcdr 3 info)
4164 (setcar (nthcdr 3 info) newmarked)
4165 ;; Add the marks lists to the end of the info.
4166 (when newmarked
4167 (setcdr (nthcdr 2 info) (list newmarked))))
4168
4169 ;; Cut off the end of the info if there's nothing else there.
4170 (let ((i 5))
4171 (while (and (> i 2)
4172 (not (nth i info)))
4173 (when (nthcdr (decf i) info)
4174 (setcdr (nthcdr i info) nil)))))))
4175
4176(defun gnus-set-mode-line (where)
4177 "This function sets the mode line of the article or summary buffers.
4178If WHERE is `summary', the summary mode line format will be used."
4179 ;; Is this mode line one we keep updated?
4180 (when (memq where gnus-updated-mode-lines)
4181 (let (mode-string)
4182 (save-excursion
4183 ;; We evaluate this in the summary buffer since these
4184 ;; variables are buffer-local to that buffer.
4185 (set-buffer gnus-summary-buffer)
4186 ;; We bind all these variables that are used in the `eval' form
4187 ;; below.
4188 (let* ((mformat (symbol-value
4189 (intern
4190 (format "gnus-%s-mode-line-format-spec" where))))
4191 (gnus-tmp-group-name gnus-newsgroup-name)
4192 (gnus-tmp-article-number (or gnus-current-article 0))
4193 (gnus-tmp-unread gnus-newsgroup-unreads)
4194 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4195 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4196 (gnus-tmp-unread-and-unselected
4197 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4198 (zerop gnus-tmp-unselected))
4199 "")
4200 ((zerop gnus-tmp-unselected)
4201 (format "{%d more}" gnus-tmp-unread-and-unticked))
4202 (t (format "{%d(+%d) more}"
4203 gnus-tmp-unread-and-unticked
4204 gnus-tmp-unselected))))
4205 (gnus-tmp-subject
4206 (if (and gnus-current-headers
4207 (vectorp gnus-current-headers))
4208 (gnus-mode-string-quote
4209 (mail-header-subject gnus-current-headers))
4210 ""))
4211 bufname-length max-len
4212 gnus-tmp-header);; passed as argument to any user-format-funcs
4213 (setq mode-string (eval mformat))
4214 (setq bufname-length (if (string-match "%b" mode-string)
4215 (- (length
4216 (buffer-name
4217 (if (eq where 'summary)
4218 nil
4219 (get-buffer gnus-article-buffer))))
4220 2)
4221 0))
4222 (setq max-len (max 4 (if gnus-mode-non-string-length
4223 (- (window-width)
4224 gnus-mode-non-string-length
4225 bufname-length)
4226 (length mode-string))))
4227 ;; We might have to chop a bit of the string off...
4228 (when (> (length mode-string) max-len)
4229 (setq mode-string
4230 (concat (gnus-truncate-string mode-string (- max-len 3))
4231 "...")))
4232 ;; Pad the mode string a bit.
4233 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4234 ;; Update the mode line.
4235 (setq mode-line-buffer-identification
4236 (gnus-mode-line-buffer-identification (list mode-string)))
4237 (set-buffer-modified-p t))))
4238
4239(defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4240 "Go through the HEADERS list and add all Xrefs to a hash table.
4241The resulting hash table is returned, or nil if no Xrefs were found."
4242 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4243 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4244 (xref-hashtb (gnus-make-hashtable))
4245 start group entry number xrefs header)
4246 (while headers
4247 (setq header (pop headers))
4248 (when (and (setq xrefs (mail-header-xref header))
4249 (not (memq (setq number (mail-header-number header))
4250 unreads)))
4251 (setq start 0)
4252 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4253 (setq start (match-end 0))
4254 (setq group (if prefix
4255 (concat prefix (substring xrefs (match-beginning 1)
4256 (match-end 1)))
4257 (substring xrefs (match-beginning 1) (match-end 1))))
4258 (setq number
4259 (string-to-int (substring xrefs (match-beginning 2)
4260 (match-end 2))))
4261 (if (setq entry (gnus-gethash group xref-hashtb))
4262 (setcdr entry (cons number (cdr entry)))
4263 (gnus-sethash group (cons number nil) xref-hashtb)))))
4264 (and start xref-hashtb)))
4265
4266(defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4267 "Look through all the headers and mark the Xrefs as read."
4268 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4269 name entry info xref-hashtb idlist method nth4)
4270 (save-excursion
4271 (set-buffer gnus-group-buffer)
4272 (when (setq xref-hashtb
4273 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4274 (mapatoms
4275 (lambda (group)
4276 (unless (string= from-newsgroup (setq name (symbol-name group)))
4277 (setq idlist (symbol-value group))
4278 ;; Dead groups are not updated.
4279 (and (prog1
4280 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4281 info (nth 2 entry))
4282 (when (stringp (setq nth4 (gnus-info-method info)))
4283 (setq nth4 (gnus-server-to-method nth4))))
4284 ;; Only do the xrefs if the group has the same
4285 ;; select method as the group we have just read.
4286 (or (gnus-methods-equal-p
4287 nth4 (gnus-find-method-for-group from-newsgroup))
4288 virtual
4289 (equal nth4 (setq method (gnus-find-method-for-group
4290 from-newsgroup)))
4291 (and (equal (car nth4) (car method))
4292 (equal (nth 1 nth4) (nth 1 method))))
4293 gnus-use-cross-reference
4294 (or (not (eq gnus-use-cross-reference t))
4295 virtual
4296 ;; Only do cross-references on subscribed
4297 ;; groups, if that is what is wanted.
4298 (<= (gnus-info-level info) gnus-level-subscribed))
4299 (gnus-group-make-articles-read name idlist))))
4300 xref-hashtb)))))
4301
6748645f
LMI
4302(defun gnus-compute-read-articles (group articles)
4303 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4304 (info (nth 2 entry))
4305 (active (gnus-active group))
4306 ninfo)
4307 (when entry
4308 ;; First peel off all illegal article numbers.
4309 (when active
4310 (let ((ids articles)
4311 id first)
4312 (while (setq id (pop ids))
4313 (when (and first (> id (cdr active)))
4314 ;; We'll end up in this situation in one particular
4315 ;; obscure situation. If you re-scan a group and get
4316 ;; a new article that is cross-posted to a different
4317 ;; group that has not been re-scanned, you might get
4318 ;; crossposted article that has a higher number than
4319 ;; Gnus believes possible. So we re-activate this
4320 ;; group as well. This might mean doing the
4321 ;; crossposting thingy will *increase* the number
4322 ;; of articles in some groups. Tsk, tsk.
4323 (setq active (or (gnus-activate-group group) active)))
4324 (when (or (> id (cdr active))
4325 (< id (car active)))
4326 (setq articles (delq id articles))))))
4327 ;; If the read list is nil, we init it.
4328 (if (and active
4329 (null (gnus-info-read info))
4330 (> (car active) 1))
4331 (setq ninfo (cons 1 (1- (car active))))
4332 (setq ninfo (gnus-info-read info)))
4333 ;; Then we add the read articles to the range.
4334 (gnus-add-to-range
4335 ninfo (setq articles (sort articles '<))))))
4336
eec82323
LMI
4337(defun gnus-group-make-articles-read (group articles)
4338 "Update the info of GROUP to say that ARTICLES are read."
4339 (let* ((num 0)
4340 (entry (gnus-gethash group gnus-newsrc-hashtb))
4341 (info (nth 2 entry))
4342 (active (gnus-active group))
4343 range)
6748645f
LMI
4344 (when entry
4345 (setq range (gnus-compute-read-articles group articles))
4346 (save-excursion
4347 (set-buffer gnus-group-buffer)
4348 (gnus-undo-register
4349 `(progn
4350 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4351 (gnus-info-set-read ',info ',(gnus-info-read info))
4352 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4353 (gnus-group-update-group ,group t))))
4354 ;; Add the read articles to the range.
4355 (gnus-info-set-read info range)
4356 ;; Then we have to re-compute how many unread
4357 ;; articles there are in this group.
4358 (when active
4359 (cond
4360 ((not range)
4361 (setq num (- (1+ (cdr active)) (car active))))
4362 ((not (listp (cdr range)))
4363 (setq num (- (cdr active) (- (1+ (cdr range))
4364 (car range)))))
4365 (t
4366 (while range
4367 (if (numberp (car range))
4368 (setq num (1+ num))
4369 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4370 (setq range (cdr range)))
4371 (setq num (- (cdr active) num))))
4372 ;; Update the number of unread articles.
4373 (setcar entry num)
4374 ;; Update the group buffer.
4375 (gnus-group-update-group group t)))))
eec82323
LMI
4376
4377(defun gnus-methods-equal-p (m1 m2)
4378 (let ((m1 (or m1 gnus-select-method))
4379 (m2 (or m2 gnus-select-method)))
4380 (or (equal m1 m2)
4381 (and (eq (car m1) (car m2))
4382 (or (not (memq 'address (assoc (symbol-name (car m1))
4383 gnus-valid-select-methods)))
4384 (equal (nth 1 m1) (nth 1 m2)))))))
4385
4386(defvar gnus-newsgroup-none-id 0)
4387
4388(defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4389 (let ((cur nntp-server-buffer)
4390 (dependencies
4391 (or dependencies
4392 (save-excursion (set-buffer gnus-summary-buffer)
4393 gnus-newsgroup-dependencies)))
6748645f 4394 headers id end ref)
eec82323
LMI
4395 (save-excursion
4396 (set-buffer nntp-server-buffer)
4397 ;; Translate all TAB characters into SPACE characters.
4398 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6748645f 4399 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323 4400 (let ((case-fold-search t)
6748645f 4401 in-reply-to header p lines chars)
eec82323
LMI
4402 (goto-char (point-min))
4403 ;; Search to the beginning of the next header. Error messages
4404 ;; do not begin with 2 or 3.
4405 (while (re-search-forward "^[23][0-9]+ " nil t)
4406 (setq id nil
4407 ref nil)
4408 ;; This implementation of this function, with nine
4409 ;; search-forwards instead of the one re-search-forward and
4410 ;; a case (which basically was the old function) is actually
4411 ;; about twice as fast, even though it looks messier. You
4412 ;; can't have everything, I guess. Speed and elegance
4413 ;; doesn't always go hand in hand.
4414 (setq
4415 header
4416 (vector
4417 ;; Number.
4418 (prog1
4419 (read cur)
4420 (end-of-line)
4421 (setq p (point))
4422 (narrow-to-region (point)
4423 (or (and (search-forward "\n.\n" nil t)
4424 (- (point) 2))
4425 (point))))
4426 ;; Subject.
4427 (progn
4428 (goto-char p)
4429 (if (search-forward "\nsubject: " nil t)
2bd3dcae
KH
4430 (funcall
4431 gnus-unstructured-field-decoder (nnheader-header-value))
4432 "(none)"))
eec82323
LMI
4433 ;; From.
4434 (progn
4435 (goto-char p)
4436 (if (search-forward "\nfrom: " nil t)
2bd3dcae
KH
4437 (funcall
4438 gnus-structured-field-decoder (nnheader-header-value))
4439 "(nobody)"))
eec82323
LMI
4440 ;; Date.
4441 (progn
4442 (goto-char p)
4443 (if (search-forward "\ndate: " nil t)
4444 (nnheader-header-value) ""))
4445 ;; Message-ID.
4446 (progn
4447 (goto-char p)
6748645f
LMI
4448 (setq id (if (re-search-forward
4449 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4450 ;; We do it this way to make sure the Message-ID
4451 ;; is (somewhat) syntactically valid.
4452 (buffer-substring (match-beginning 1)
4453 (match-end 1))
eec82323
LMI
4454 ;; If there was no message-id, we just fake one
4455 ;; to make subsequent routines simpler.
4456 (nnheader-generate-fake-message-id))))
4457 ;; References.
4458 (progn
4459 (goto-char p)
4460 (if (search-forward "\nreferences: " nil t)
4461 (progn
4462 (setq end (point))
4463 (prog1
4464 (nnheader-header-value)
4465 (setq ref
4466 (buffer-substring
4467 (progn
4468 (end-of-line)
4469 (search-backward ">" end t)
4470 (1+ (point)))
4471 (progn
4472 (search-backward "<" end t)
4473 (point))))))
4474 ;; Get the references from the in-reply-to header if there
4475 ;; were no references and the in-reply-to header looks
4476 ;; promising.
4477 (if (and (search-forward "\nin-reply-to: " nil t)
4478 (setq in-reply-to (nnheader-header-value))
4479 (string-match "<[^>]+>" in-reply-to))
6748645f
LMI
4480 (let (ref2)
4481 (setq ref (substring in-reply-to (match-beginning 0)
4482 (match-end 0)))
4483 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4484 (setq ref2 (substring in-reply-to (match-beginning 0)
4485 (match-end 0)))
4486 (when (> (length ref2) (length ref))
4487 (setq ref ref2)))
4488 ref)
eec82323
LMI
4489 (setq ref nil))))
4490 ;; Chars.
6748645f
LMI
4491 (progn
4492 (goto-char p)
4493 (if (search-forward "\nchars: " nil t)
4494 (if (numberp (setq chars (ignore-errors (read cur))))
4495 chars 0)
4496 0))
eec82323
LMI
4497 ;; Lines.
4498 (progn
4499 (goto-char p)
4500 (if (search-forward "\nlines: " nil t)
a8151ef7 4501 (if (numberp (setq lines (ignore-errors (read cur))))
eec82323
LMI
4502 lines 0)
4503 0))
4504 ;; Xref.
4505 (progn
4506 (goto-char p)
4507 (and (search-forward "\nxref: " nil t)
4508 (nnheader-header-value)))))
4509 (when (equal id ref)
4510 (setq ref nil))
6748645f
LMI
4511
4512 (when gnus-alter-header-function
4513 (funcall gnus-alter-header-function header)
4514 (setq id (mail-header-id header)
4515 ref (gnus-parent-id (mail-header-references header))))
4516
4517 (when (setq header
4518 (gnus-dependencies-add-header
4519 header dependencies force-new))
eec82323
LMI
4520 (push header headers))
4521 (goto-char (point-max))
4522 (widen))
4523 (nreverse headers)))))
4524
eec82323
LMI
4525;; Goes through the xover lines and returns a list of vectors
4526(defun gnus-get-newsgroup-headers-xover (sequence &optional
4527 force-new dependencies
4528 group also-fetch-heads)
4529 "Parse the news overview data in the server buffer, and return a
4530list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4531 ;; Get the Xref when the users reads the articles since most/some
4532 ;; NNTP servers do not include Xrefs when using XOVER.
4533 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4534 (let ((cur nntp-server-buffer)
4535 (dependencies (or dependencies gnus-newsgroup-dependencies))
4536 number headers header)
4537 (save-excursion
4538 (set-buffer nntp-server-buffer)
4539 ;; Allow the user to mangle the headers before parsing them.
6748645f 4540 (gnus-run-hooks 'gnus-parse-headers-hook)
eec82323
LMI
4541 (goto-char (point-min))
4542 (while (not (eobp))
4543 (condition-case ()
4544 (while (and sequence (not (eobp)))
4545 (setq number (read cur))
4546 (while (and sequence
4547 (< (car sequence) number))
4548 (setq sequence (cdr sequence)))
4549 (and sequence
4550 (eq number (car sequence))
4551 (progn
4552 (setq sequence (cdr sequence))
4553 (setq header (inline
4554 (gnus-nov-parse-line
4555 number dependencies force-new))))
4556 (push header headers))
4557 (forward-line 1))
4558 (error
4559 (gnus-error 4 "Strange nov line (%d)"
4560 (count-lines (point-min) (point)))))
4561 (forward-line 1))
4562 ;; A common bug in inn is that if you have posted an article and
4563 ;; then retrieves the active file, it will answer correctly --
4564 ;; the new article is included. However, a NOV entry for the
4565 ;; article may not have been generated yet, so this may fail.
4566 ;; We work around this problem by retrieving the last few
4567 ;; headers using HEAD.
4568 (if (or (not also-fetch-heads)
4569 (not sequence))
4570 ;; We (probably) got all the headers.
4571 (nreverse headers)
4572 (let ((gnus-nov-is-evil t))
4573 (nconc
4574 (nreverse headers)
4575 (when (gnus-retrieve-headers sequence group)
4576 (gnus-get-newsgroup-headers))))))))
4577
4578(defun gnus-article-get-xrefs ()
4579 "Fill in the Xref value in `gnus-current-headers', if necessary.
4580This is meant to be called in `gnus-article-internal-prepare-hook'."
4581 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4582 gnus-current-headers)))
4583 (or (not gnus-use-cross-reference)
4584 (not headers)
4585 (and (mail-header-xref headers)
4586 (not (string= (mail-header-xref headers) "")))
4587 (let ((case-fold-search t)
4588 xref)
4589 (save-restriction
4590 (nnheader-narrow-to-headers)
4591 (goto-char (point-min))
4592 (when (or (and (eq (downcase (following-char)) ?x)
4593 (looking-at "Xref:"))
4594 (search-forward "\nXref:" nil t))
4595 (goto-char (1+ (match-end 0)))
4596 (setq xref (buffer-substring (point)
4597 (progn (end-of-line) (point))))
4598 (mail-header-set-xref headers xref)))))))
4599
4600(defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6748645f
LMI
4601 "Find article ID and insert the summary line for that article.
4602OLD-HEADER can either be a header or a line number to insert
4603the subject line on."
4604 (let* ((line (and (numberp old-header) old-header))
4605 (old-header (and (vectorp old-header) old-header))
4606 (header (cond ((and old-header use-old-header)
4607 old-header)
4608 ((and (numberp id)
4609 (gnus-number-to-header id))
4610 (gnus-number-to-header id))
4611 (t
4612 (gnus-read-header id))))
eec82323 4613 (number (and (numberp id) id))
6748645f 4614 d)
eec82323
LMI
4615 (when header
4616 ;; Rebuild the thread that this article is part of and go to the
4617 ;; article we have fetched.
4618 (when (and (not gnus-show-threads)
4619 old-header)
6748645f
LMI
4620 (when (and number
4621 (setq d (gnus-data-find (mail-header-number old-header))))
eec82323
LMI
4622 (goto-char (gnus-data-pos d))
4623 (gnus-data-remove
4624 number
4625 (- (gnus-point-at-bol)
4626 (prog1
4627 (1+ (gnus-point-at-eol))
4628 (gnus-delete-line))))))
4629 (when old-header
4630 (mail-header-set-number header (mail-header-number old-header)))
4631 (setq gnus-newsgroup-sparse
4632 (delq (setq number (mail-header-number header))
4633 gnus-newsgroup-sparse))
4634 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6748645f
LMI
4635 (push number gnus-newsgroup-limit)
4636 (gnus-rebuild-thread (mail-header-id header) line)
eec82323
LMI
4637 (gnus-summary-goto-subject number nil t))
4638 (when (and (numberp number)
4639 (> number 0))
4640 ;; We have to update the boundaries even if we can't fetch the
4641 ;; article if ID is a number -- so that the next `P' or `N'
4642 ;; command will fetch the previous (or next) article even
4643 ;; if the one we tried to fetch this time has been canceled.
4644 (when (> number gnus-newsgroup-end)
4645 (setq gnus-newsgroup-end number))
4646 (when (< number gnus-newsgroup-begin)
4647 (setq gnus-newsgroup-begin number))
4648 (setq gnus-newsgroup-unselected
4649 (delq number gnus-newsgroup-unselected)))
4650 ;; Report back a success?
4651 (and header (mail-header-number header))))
4652
4653;;; Process/prefix in the summary buffer
4654
4655(defun gnus-summary-work-articles (n)
6748645f
LMI
4656 "Return a list of articles to be worked upon.
4657The prefix argument, the list of process marked articles, and the
4658current article will be taken into consideration."
4659 (save-excursion
4660 (set-buffer gnus-summary-buffer)
4661 (cond
4662 (n
4663 ;; A numerical prefix has been given.
4664 (setq n (prefix-numeric-value n))
4665 (let ((backward (< n 0))
4666 (n (abs (prefix-numeric-value n)))
4667 articles article)
4668 (save-excursion
4669 (while
4670 (and (> n 0)
4671 (push (setq article (gnus-summary-article-number))
4672 articles)
4673 (if backward
4674 (gnus-summary-find-prev nil article)
4675 (gnus-summary-find-next nil article)))
4676 (decf n)))
4677 (nreverse articles)))
4678 ((and (gnus-region-active-p) (mark))
4679 (message "region active")
4680 ;; Work on the region between point and mark.
4681 (let ((max (max (point) (mark)))
4682 articles article)
4683 (save-excursion
4684 (goto-char (min (min (point) (mark))))
4685 (while
4686 (and
4687 (push (setq article (gnus-summary-article-number)) articles)
4688 (gnus-summary-find-next nil article)
4689 (< (point) max)))
4690 (nreverse articles))))
4691 (gnus-newsgroup-processable
4692 ;; There are process-marked articles present.
4693 ;; Save current state.
4694 (gnus-summary-save-process-mark)
4695 ;; Return the list.
4696 (reverse gnus-newsgroup-processable))
4697 (t
4698 ;; Just return the current article.
4699 (list (gnus-summary-article-number))))))
4700
4701(defmacro gnus-summary-iterate (arg &rest forms)
4702 "Iterate over the process/prefixed articles and do FORMS.
4703ARG is the interactive prefix given to the command. FORMS will be
4704executed with point over the summary line of the articles."
4705 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4706 `(let ((,articles (gnus-summary-work-articles ,arg)))
4707 (while ,articles
4708 (gnus-summary-goto-subject (car ,articles))
4709 ,@forms))))
4710
4711(put 'gnus-summary-iterate 'lisp-indent-function 1)
4712(put 'gnus-summary-iterate 'edebug-form-spec '(form body))
eec82323
LMI
4713
4714(defun gnus-summary-save-process-mark ()
4715 "Push the current set of process marked articles on the stack."
4716 (interactive)
4717 (push (copy-sequence gnus-newsgroup-processable)
4718 gnus-newsgroup-process-stack))
4719
4720(defun gnus-summary-kill-process-mark ()
4721 "Push the current set of process marked articles on the stack and unmark."
4722 (interactive)
4723 (gnus-summary-save-process-mark)
4724 (gnus-summary-unmark-all-processable))
4725
4726(defun gnus-summary-yank-process-mark ()
4727 "Pop the last process mark state off the stack and restore it."
4728 (interactive)
4729 (unless gnus-newsgroup-process-stack
4730 (error "Empty mark stack"))
4731 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4732
4733(defun gnus-summary-process-mark-set (set)
4734 "Make SET into the current process marked articles."
4735 (gnus-summary-unmark-all-processable)
4736 (while set
4737 (gnus-summary-set-process-mark (pop set))))
4738
4739;;; Searching and stuff
4740
4741(defun gnus-summary-search-group (&optional backward use-level)
4742 "Search for next unread newsgroup.
4743If optional argument BACKWARD is non-nil, search backward instead."
4744 (save-excursion
4745 (set-buffer gnus-group-buffer)
4746 (when (gnus-group-search-forward
4747 backward nil (if use-level (gnus-group-group-level) nil))
4748 (gnus-group-group-name))))
4749
4750(defun gnus-summary-best-group (&optional exclude-group)
4751 "Find the name of the best unread group.
4752If EXCLUDE-GROUP, do not go to this group."
4753 (save-excursion
4754 (set-buffer gnus-group-buffer)
4755 (save-excursion
4756 (gnus-group-best-unread-group exclude-group))))
4757
6748645f 4758(defun gnus-summary-find-next (&optional unread article backward undownloaded)
eec82323
LMI
4759 (if backward (gnus-summary-find-prev)
4760 (let* ((dummy (gnus-summary-article-intangible-p))
4761 (article (or article (gnus-summary-article-number)))
4762 (arts (gnus-data-find-list article))
4763 result)
4764 (when (and (not dummy)
4765 (or (not gnus-summary-check-current)
4766 (not unread)
4767 (not (gnus-data-unread-p (car arts)))))
4768 (setq arts (cdr arts)))
4769 (when (setq result
4770 (if unread
4771 (progn
4772 (while arts
6748645f
LMI
4773 (when (or (and undownloaded
4774 (eq gnus-undownloaded-mark
4775 (gnus-data-mark (car arts))))
4776 (gnus-data-unread-p (car arts)))
eec82323
LMI
4777 (setq result (car arts)
4778 arts nil))
4779 (setq arts (cdr arts)))
4780 result)
4781 (car arts)))
4782 (goto-char (gnus-data-pos result))
4783 (gnus-data-number result)))))
4784
4785(defun gnus-summary-find-prev (&optional unread article)
4786 (let* ((eobp (eobp))
4787 (article (or article (gnus-summary-article-number)))
4788 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4789 result)
4790 (when (and (not eobp)
4791 (or (not gnus-summary-check-current)
4792 (not unread)
4793 (not (gnus-data-unread-p (car arts)))))
4794 (setq arts (cdr arts)))
4795 (when (setq result
4796 (if unread
4797 (progn
4798 (while arts
4799 (when (gnus-data-unread-p (car arts))
4800 (setq result (car arts)
4801 arts nil))
4802 (setq arts (cdr arts)))
4803 result)
4804 (car arts)))
4805 (goto-char (gnus-data-pos result))
4806 (gnus-data-number result))))
4807
4808(defun gnus-summary-find-subject (subject &optional unread backward article)
4809 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4810 (article (or article (gnus-summary-article-number)))
4811 (articles (gnus-data-list backward))
4812 (arts (gnus-data-find-list article articles))
4813 result)
4814 (when (or (not gnus-summary-check-current)
4815 (not unread)
4816 (not (gnus-data-unread-p (car arts))))
4817 (setq arts (cdr arts)))
4818 (while arts
4819 (and (or (not unread)
4820 (gnus-data-unread-p (car arts)))
4821 (vectorp (gnus-data-header (car arts)))
4822 (gnus-subject-equal
4823 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4824 (setq result (car arts)
4825 arts nil))
4826 (setq arts (cdr arts)))
4827 (and result
4828 (goto-char (gnus-data-pos result))
4829 (gnus-data-number result))))
4830
4831(defun gnus-summary-search-forward (&optional unread subject backward)
4832 "Search forward for an article.
4833If UNREAD, look for unread articles. If SUBJECT, look for
4834articles with that subject. If BACKWARD, search backward instead."
4835 (cond (subject (gnus-summary-find-subject subject unread backward))
4836 (backward (gnus-summary-find-prev unread))
4837 (t (gnus-summary-find-next unread))))
4838
4839(defun gnus-recenter (&optional n)
4840 "Center point in window and redisplay frame.
4841Also do horizontal recentering."
4842 (interactive "P")
4843 (when (and gnus-auto-center-summary
4844 (not (eq gnus-auto-center-summary 'vertical)))
4845 (gnus-horizontal-recenter))
4846 (recenter n))
4847
4848(defun gnus-summary-recenter ()
4849 "Center point in the summary window.
4850If `gnus-auto-center-summary' is nil, or the article buffer isn't
4851displayed, no centering will be performed."
4852 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4853 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4854 (let* ((top (cond ((< (window-height) 4) 0)
4855 ((< (window-height) 7) 1)
4856 (t 2)))
4857 (height (1- (window-height)))
4858 (bottom (save-excursion (goto-char (point-max))
4859 (forward-line (- height))
4860 (point)))
4861 (window (get-buffer-window (current-buffer))))
4862 ;; The user has to want it.
4863 (when gnus-auto-center-summary
4864 (when (get-buffer-window gnus-article-buffer)
4865 ;; Only do recentering when the article buffer is displayed,
4866 ;; Set the window start to either `bottom', which is the biggest
4867 ;; possible valid number, or the second line from the top,
4868 ;; whichever is the least.
4869 (set-window-start
4870 window (min bottom (save-excursion
4871 (forward-line (- top)) (point)))))
4872 ;; Do horizontal recentering while we're at it.
4873 (when (and (get-buffer-window (current-buffer) t)
4874 (not (eq gnus-auto-center-summary 'vertical)))
4875 (let ((selected (selected-window)))
4876 (select-window (get-buffer-window (current-buffer) t))
4877 (gnus-summary-position-point)
4878 (gnus-horizontal-recenter)
4879 (select-window selected))))))
4880
4881(defun gnus-summary-jump-to-group (newsgroup)
4882 "Move point to NEWSGROUP in group mode buffer."
4883 ;; Keep update point of group mode buffer if visible.
4884 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4885 (save-window-excursion
4886 ;; Take care of tree window mode.
4887 (when (get-buffer-window gnus-group-buffer)
4888 (pop-to-buffer gnus-group-buffer))
4889 (gnus-group-jump-to-group newsgroup))
4890 (save-excursion
4891 ;; Take care of tree window mode.
4892 (if (get-buffer-window gnus-group-buffer)
4893 (pop-to-buffer gnus-group-buffer)
4894 (set-buffer gnus-group-buffer))
4895 (gnus-group-jump-to-group newsgroup))))
4896
4897;; This function returns a list of article numbers based on the
4898;; difference between the ranges of read articles in this group and
4899;; the range of active articles.
4900(defun gnus-list-of-unread-articles (group)
4901 (let* ((read (gnus-info-read (gnus-get-info group)))
4902 (active (or (gnus-active group) (gnus-activate-group group)))
4903 (last (cdr active))
4904 first nlast unread)
4905 ;; If none are read, then all are unread.
4906 (if (not read)
4907 (setq first (car active))
4908 ;; If the range of read articles is a single range, then the
4909 ;; first unread article is the article after the last read
4910 ;; article. Sounds logical, doesn't it?
4911 (if (not (listp (cdr read)))
6748645f 4912 (setq first (max (car active) (1+ (cdr read))))
eec82323
LMI
4913 ;; `read' is a list of ranges.
4914 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4915 (caar read)))
4916 1)
6748645f 4917 (setq first (car active)))
eec82323
LMI
4918 (while read
4919 (when first
4920 (while (< first nlast)
4921 (push first unread)
4922 (setq first (1+ first))))
4923 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4924 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4925 (setq read (cdr read)))))
4926 ;; And add the last unread articles.
4927 (while (<= first last)
4928 (push first unread)
4929 (setq first (1+ first)))
4930 ;; Return the list of unread articles.
6748645f 4931 (delq 0 (nreverse unread))))
eec82323
LMI
4932
4933(defun gnus-list-of-read-articles (group)
4934 "Return a list of unread, unticked and non-dormant articles."
4935 (let* ((info (gnus-get-info group))
4936 (marked (gnus-info-marks info))
4937 (active (gnus-active group)))
4938 (and info active
4939 (gnus-set-difference
4940 (gnus-sorted-complement
4941 (gnus-uncompress-range active)
4942 (gnus-list-of-unread-articles group))
4943 (append
4944 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4945 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4946
4947;; Various summary commands
4948
6748645f
LMI
4949(defun gnus-summary-select-article-buffer ()
4950 "Reconfigure windows to show article buffer."
4951 (interactive)
4952 (if (not (gnus-buffer-live-p gnus-article-buffer))
4953 (error "There is no article buffer for this summary buffer")
4954 (gnus-configure-windows 'article)
4955 (select-window (get-buffer-window gnus-article-buffer))))
4956
eec82323
LMI
4957(defun gnus-summary-universal-argument (arg)
4958 "Perform any operation on all articles that are process/prefixed."
4959 (interactive "P")
eec82323
LMI
4960 (let ((articles (gnus-summary-work-articles arg))
4961 func article)
4962 (if (eq
4963 (setq
4964 func
4965 (key-binding
4966 (read-key-sequence
4967 (substitute-command-keys
4968 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4969 ))))
4970 'undefined)
4971 (gnus-error 1 "Undefined key")
4972 (save-excursion
4973 (while articles
4974 (gnus-summary-goto-subject (setq article (pop articles)))
4975 (let (gnus-newsgroup-processable)
4976 (command-execute func))
4977 (gnus-summary-remove-process-mark article)))))
4978 (gnus-summary-position-point))
4979
4980(defun gnus-summary-toggle-truncation (&optional arg)
4981 "Toggle truncation of summary lines.
4982With arg, turn line truncation on iff arg is positive."
4983 (interactive "P")
4984 (setq truncate-lines
4985 (if (null arg) (not truncate-lines)
4986 (> (prefix-numeric-value arg) 0)))
4987 (redraw-display))
4988
4989(defun gnus-summary-reselect-current-group (&optional all rescan)
4990 "Exit and then reselect the current newsgroup.
4991The prefix argument ALL means to select all articles."
4992 (interactive "P")
eec82323
LMI
4993 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4994 (error "Ephemeral groups can't be reselected"))
4995 (let ((current-subject (gnus-summary-article-number))
4996 (group gnus-newsgroup-name))
4997 (setq gnus-newsgroup-begin nil)
4998 (gnus-summary-exit)
4999 ;; We have to adjust the point of group mode buffer because
5000 ;; point was moved to the next unread newsgroup by exiting.
5001 (gnus-summary-jump-to-group group)
5002 (when rescan
5003 (save-excursion
5004 (gnus-group-get-new-news-this-group 1)))
5005 (gnus-group-read-group all t)
5006 (gnus-summary-goto-subject current-subject nil t)))
5007
5008(defun gnus-summary-rescan-group (&optional all)
5009 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5010 (interactive "P")
5011 (gnus-summary-reselect-current-group all t))
5012
5013(defun gnus-summary-update-info (&optional non-destructive)
5014 (save-excursion
5015 (let ((group gnus-newsgroup-name))
6748645f
LMI
5016 (when group
5017 (when gnus-newsgroup-kill-headers
5018 (setq gnus-newsgroup-killed
5019 (gnus-compress-sequence
5020 (nconc
5021 (gnus-set-sorted-intersection
5022 (gnus-uncompress-range gnus-newsgroup-killed)
5023 (setq gnus-newsgroup-unselected
5024 (sort gnus-newsgroup-unselected '<)))
5025 (setq gnus-newsgroup-unreads
5026 (sort gnus-newsgroup-unreads '<)))
5027 t)))
5028 (unless (listp (cdr gnus-newsgroup-killed))
5029 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5030 (let ((headers gnus-newsgroup-headers))
5031 ;; Set the new ranges of read articles.
5032 (save-excursion
5033 (set-buffer gnus-group-buffer)
5034 (gnus-undo-force-boundary))
5035 (gnus-update-read-articles
5036 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5037 ;; Set the current article marks.
5038 (let ((gnus-newsgroup-scored
5039 (if (and (not gnus-save-score)
5040 (not non-destructive))
5041 nil
5042 gnus-newsgroup-scored)))
5043 (save-excursion
5044 (gnus-update-marks)))
5045 ;; Do the cross-ref thing.
5046 (when gnus-use-cross-reference
5047 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5048 ;; Do not switch windows but change the buffer to work.
a8151ef7 5049 (set-buffer gnus-group-buffer)
6748645f
LMI
5050 (unless (gnus-ephemeral-group-p group)
5051 (gnus-group-update-group group)))))))
eec82323
LMI
5052
5053(defun gnus-summary-save-newsrc (&optional force)
5054 "Save the current number of read/marked articles in the dribble buffer.
5055The dribble buffer will then be saved.
5056If FORCE (the prefix), also save the .newsrc file(s)."
5057 (interactive "P")
5058 (gnus-summary-update-info t)
5059 (if force
5060 (gnus-save-newsrc-file)
5061 (gnus-dribble-save)))
5062
5063(defun gnus-summary-exit (&optional temporary)
5064 "Exit reading current newsgroup, and then return to group selection mode.
5065gnus-exit-group-hook is called with no arguments if that value is non-nil."
5066 (interactive)
5067 (gnus-set-global-variables)
5068 (gnus-kill-save-kill-buffer)
6748645f 5069 (gnus-async-halt-prefetch)
eec82323
LMI
5070 (let* ((group gnus-newsgroup-name)
5071 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5072 (mode major-mode)
a8151ef7 5073 (group-point nil)
eec82323 5074 (buf (current-buffer)))
6748645f 5075 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
5076 ;; If we have several article buffers, we kill them at exit.
5077 (unless gnus-single-article-buffer
5078 (gnus-kill-buffer gnus-original-article-buffer)
5079 (setq gnus-article-current nil))
5080 (when gnus-use-cache
5081 (gnus-cache-possibly-remove-articles)
5082 (gnus-cache-save-buffers))
5083 (gnus-async-prefetch-remove-group group)
5084 (when gnus-suppress-duplicates
5085 (gnus-dup-enter-articles))
5086 (when gnus-use-trees
5087 (gnus-tree-close group))
6748645f
LMI
5088 ;; Remove entries for this group.
5089 (nnmail-purge-split-history (gnus-group-real-name group))
eec82323
LMI
5090 ;; Make all changes in this group permanent.
5091 (unless quit-config
6748645f
LMI
5092 (gnus-run-hooks 'gnus-exit-group-hook)
5093 (gnus-summary-update-info)
5094 ;; Do adaptive scoring, and possibly save score files.
5095 (when gnus-newsgroup-adaptive
5096 (gnus-score-adaptive))
5097 (when gnus-use-scoring
5098 (gnus-score-save)))
eec82323
LMI
5099 (gnus-close-group group)
5100 ;; Make sure where we were, and go to next newsgroup.
5101 (set-buffer gnus-group-buffer)
5102 (unless quit-config
5103 (gnus-group-jump-to-group group))
6748645f
LMI
5104 (gnus-run-hooks 'gnus-summary-exit-hook)
5105 (unless (or quit-config
5106 ;; If this group has disappeared from the summary
5107 ;; buffer, don't skip forwards.
5108 (not (string= group (gnus-group-group-name))))
eec82323 5109 (gnus-group-next-unread-group 1))
a8151ef7 5110 (setq group-point (point))
eec82323
LMI
5111 (if temporary
5112 nil ;Nothing to do.
5113 ;; If we have several article buffers, we kill them at exit.
5114 (unless gnus-single-article-buffer
5115 (gnus-kill-buffer gnus-article-buffer)
5116 (gnus-kill-buffer gnus-original-article-buffer)
5117 (setq gnus-article-current nil))
5118 (set-buffer buf)
5119 (if (not gnus-kill-summary-on-exit)
5120 (gnus-deaden-summary)
5121 ;; We set all buffer-local variables to nil. It is unclear why
5122 ;; this is needed, but if we don't, buffer-local variables are
5123 ;; not garbage-collected, it seems. This would the lead to en
5124 ;; ever-growing Emacs.
5125 (gnus-summary-clear-local-variables)
5126 (when (get-buffer gnus-article-buffer)
5127 (bury-buffer gnus-article-buffer))
5128 ;; We clear the global counterparts of the buffer-local
5129 ;; variables as well, just to be on the safe side.
5130 (set-buffer gnus-group-buffer)
5131 (gnus-summary-clear-local-variables)
5132 ;; Return to group mode buffer.
5133 (when (eq mode 'gnus-summary-mode)
5134 (gnus-kill-buffer buf)))
5135 (setq gnus-current-select-method gnus-select-method)
5136 (pop-to-buffer gnus-group-buffer)
eec82323
LMI
5137 (if (not quit-config)
5138 (progn
a8151ef7 5139 (goto-char group-point)
eec82323
LMI
5140 (gnus-configure-windows 'group 'force))
5141 (gnus-handle-ephemeral-exit quit-config))
6748645f 5142 ;; Clear the current group name.
eec82323
LMI
5143 (unless quit-config
5144 (setq gnus-newsgroup-name nil)))))
5145
5146(defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5147(defun gnus-summary-exit-no-update (&optional no-questions)
5148 "Quit reading current newsgroup without updating read article info."
5149 (interactive)
eec82323
LMI
5150 (let* ((group gnus-newsgroup-name)
5151 (quit-config (gnus-group-quit-config group)))
5152 (when (or no-questions
5153 gnus-expert-user
5154 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6748645f
LMI
5155 (gnus-async-halt-prefetch)
5156 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
eec82323
LMI
5157 ;; If we have several article buffers, we kill them at exit.
5158 (unless gnus-single-article-buffer
5159 (gnus-kill-buffer gnus-article-buffer)
5160 (gnus-kill-buffer gnus-original-article-buffer)
5161 (setq gnus-article-current nil))
5162 (if (not gnus-kill-summary-on-exit)
5163 (gnus-deaden-summary)
5164 (gnus-close-group group)
5165 (gnus-summary-clear-local-variables)
5166 (set-buffer gnus-group-buffer)
5167 (gnus-summary-clear-local-variables)
5168 (when (get-buffer gnus-summary-buffer)
5169 (kill-buffer gnus-summary-buffer)))
5170 (unless gnus-single-article-buffer
5171 (setq gnus-article-current nil))
5172 (when gnus-use-trees
5173 (gnus-tree-close group))
5174 (gnus-async-prefetch-remove-group group)
5175 (when (get-buffer gnus-article-buffer)
5176 (bury-buffer gnus-article-buffer))
5177 ;; Return to the group buffer.
5178 (gnus-configure-windows 'group 'force)
5179 ;; Clear the current group name.
5180 (setq gnus-newsgroup-name nil)
5181 (when (equal (gnus-group-group-name) group)
5182 (gnus-group-next-unread-group 1))
5183 (when quit-config
5184 (gnus-handle-ephemeral-exit quit-config)))))
5185
5186(defun gnus-handle-ephemeral-exit (quit-config)
6748645f
LMI
5187 "Handle movement when leaving an ephemeral group.
5188The state which existed when entering the ephemeral is reset."
eec82323
LMI
5189 (if (not (buffer-name (car quit-config)))
5190 (gnus-configure-windows 'group 'force)
5191 (set-buffer (car quit-config))
5192 (cond ((eq major-mode 'gnus-summary-mode)
5193 (gnus-set-global-variables))
5194 ((eq major-mode 'gnus-article-mode)
5195 (save-excursion
5196 ;; The `gnus-summary-buffer' variable may point
5197 ;; to the old summary buffer when using a single
5198 ;; article buffer.
5199 (unless (gnus-buffer-live-p gnus-summary-buffer)
5200 (set-buffer gnus-group-buffer))
5201 (set-buffer gnus-summary-buffer)
5202 (gnus-set-global-variables))))
5203 (if (or (eq (cdr quit-config) 'article)
5204 (eq (cdr quit-config) 'pick))
5205 (progn
5206 ;; The current article may be from the ephemeral group
5207 ;; thus it is best that we reload this article
5208 (gnus-summary-show-article)
5209 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5210 (gnus-configure-windows 'pick 'force)
5211 (gnus-configure-windows (cdr quit-config) 'force)))
5212 (gnus-configure-windows (cdr quit-config) 'force))
5213 (when (eq major-mode 'gnus-summary-mode)
5214 (gnus-summary-next-subject 1 nil t)
5215 (gnus-summary-recenter)
5216 (gnus-summary-position-point))))
5217
5218;;; Dead summaries.
5219
5220(defvar gnus-dead-summary-mode-map nil)
5221
5222(unless gnus-dead-summary-mode-map
5223 (setq gnus-dead-summary-mode-map (make-keymap))
5224 (suppress-keymap gnus-dead-summary-mode-map)
5225 (substitute-key-definition
5226 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
a8151ef7 5227 (let ((keys '("\C-d" "\r" "\177" [delete])))
eec82323
LMI
5228 (while keys
5229 (define-key gnus-dead-summary-mode-map
5230 (pop keys) 'gnus-summary-wake-up-the-dead))))
5231
5232(defvar gnus-dead-summary-mode nil
5233 "Minor mode for Gnus summary buffers.")
5234
5235(defun gnus-dead-summary-mode (&optional arg)
5236 "Minor mode for Gnus summary buffers."
5237 (interactive "P")
5238 (when (eq major-mode 'gnus-summary-mode)
5239 (make-local-variable 'gnus-dead-summary-mode)
5240 (setq gnus-dead-summary-mode
5241 (if (null arg) (not gnus-dead-summary-mode)
5242 (> (prefix-numeric-value arg) 0)))
5243 (when gnus-dead-summary-mode
a8151ef7
LMI
5244 (gnus-add-minor-mode
5245 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
eec82323
LMI
5246
5247(defun gnus-deaden-summary ()
5248 "Make the current summary buffer into a dead summary buffer."
5249 ;; Kill any previous dead summary buffer.
5250 (when (and gnus-dead-summary
5251 (buffer-name gnus-dead-summary))
5252 (save-excursion
5253 (set-buffer gnus-dead-summary)
5254 (when gnus-dead-summary-mode
5255 (kill-buffer (current-buffer)))))
5256 ;; Make this the current dead summary.
5257 (setq gnus-dead-summary (current-buffer))
5258 (gnus-dead-summary-mode 1)
5259 (let ((name (buffer-name)))
5260 (when (string-match "Summary" name)
5261 (rename-buffer
5262 (concat (substring name 0 (match-beginning 0)) "Dead "
5263 (substring name (match-beginning 0)))
5264 t))))
5265
5266(defun gnus-kill-or-deaden-summary (buffer)
5267 "Kill or deaden the summary BUFFER."
6748645f
LMI
5268 (save-excursion
5269 (when (and (buffer-name buffer)
5270 (not gnus-single-article-buffer))
5271 (save-excursion
5272 (set-buffer buffer)
5273 (gnus-kill-buffer gnus-article-buffer)
5274 (gnus-kill-buffer gnus-original-article-buffer)))
5275 (cond (gnus-kill-summary-on-exit
5276 (when (and gnus-use-trees
5277 (gnus-buffer-exists-p buffer))
5278 (save-excursion
5279 (set-buffer buffer)
5280 (gnus-tree-close gnus-newsgroup-name)))
5281 (gnus-kill-buffer buffer))
5282 ((gnus-buffer-exists-p buffer)
eec82323 5283 (save-excursion
6748645f
LMI
5284 (set-buffer buffer)
5285 (gnus-deaden-summary))))))
eec82323
LMI
5286
5287(defun gnus-summary-wake-up-the-dead (&rest args)
5288 "Wake up the dead summary buffer."
5289 (interactive)
5290 (gnus-dead-summary-mode -1)
5291 (let ((name (buffer-name)))
5292 (when (string-match "Dead " name)
5293 (rename-buffer
5294 (concat (substring name 0 (match-beginning 0))
5295 (substring name (match-end 0)))
5296 t)))
5297 (gnus-message 3 "This dead summary is now alive again"))
5298
5299;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5300(defun gnus-summary-fetch-faq (&optional faq-dir)
5301 "Fetch the FAQ for the current group.
5302If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5303in."
5304 (interactive
5305 (list
5306 (when current-prefix-arg
5307 (completing-read
5308 "Faq dir: " (and (listp gnus-group-faq-directory)
a8151ef7
LMI
5309 (mapcar (lambda (file) (list file))
5310 gnus-group-faq-directory))))))
eec82323
LMI
5311 (let (gnus-faq-buffer)
5312 (when (setq gnus-faq-buffer
5313 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5314 (gnus-configure-windows 'summary-faq))))
5315
5316;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5317(defun gnus-summary-describe-group (&optional force)
5318 "Describe the current newsgroup."
5319 (interactive "P")
5320 (gnus-group-describe-group force gnus-newsgroup-name))
5321
5322(defun gnus-summary-describe-briefly ()
5323 "Describe summary mode commands briefly."
5324 (interactive)
5325 (gnus-message 6
5326 (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")))
5327
5328;; Walking around group mode buffer from summary mode.
5329
5330(defun gnus-summary-next-group (&optional no-article target-group backward)
5331 "Exit current newsgroup and then select next unread newsgroup.
5332If prefix argument NO-ARTICLE is non-nil, no article is selected
5333initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5334previous group instead."
5335 (interactive "P")
eec82323
LMI
5336 ;; Stop pre-fetching.
5337 (gnus-async-halt-prefetch)
5338 (let ((current-group gnus-newsgroup-name)
5339 (current-buffer (current-buffer))
5340 entered)
5341 ;; First we semi-exit this group to update Xrefs and all variables.
5342 ;; We can't do a real exit, because the window conf must remain
5343 ;; the same in case the user is prompted for info, and we don't
5344 ;; want the window conf to change before that...
5345 (gnus-summary-exit t)
5346 (while (not entered)
5347 ;; Then we find what group we are supposed to enter.
5348 (set-buffer gnus-group-buffer)
5349 (gnus-group-jump-to-group current-group)
5350 (setq target-group
5351 (or target-group
5352 (if (eq gnus-keep-same-level 'best)
5353 (gnus-summary-best-group gnus-newsgroup-name)
5354 (gnus-summary-search-group backward gnus-keep-same-level))))
5355 (if (not target-group)
5356 ;; There are no further groups, so we return to the group
5357 ;; buffer.
5358 (progn
5359 (gnus-message 5 "Returning to the group buffer")
5360 (setq entered t)
5361 (when (gnus-buffer-live-p current-buffer)
5362 (set-buffer current-buffer)
5363 (gnus-summary-exit))
6748645f 5364 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
eec82323
LMI
5365 ;; We try to enter the target group.
5366 (gnus-group-jump-to-group target-group)
5367 (let ((unreads (gnus-group-group-unread)))
5368 (if (and (or (eq t unreads)
5369 (and unreads (not (zerop unreads))))
5370 (gnus-summary-read-group
a8151ef7 5371 target-group nil no-article
6748645f
LMI
5372 (and (buffer-name current-buffer) current-buffer)
5373 nil backward))
eec82323
LMI
5374 (setq entered t)
5375 (setq current-group target-group
5376 target-group nil)))))))
5377
5378(defun gnus-summary-prev-group (&optional no-article)
5379 "Exit current newsgroup and then select previous unread newsgroup.
5380If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5381 (interactive "P")
5382 (gnus-summary-next-group no-article nil t))
5383
5384;; Walking around summary lines.
5385
6748645f 5386(defun gnus-summary-first-subject (&optional unread undownloaded)
eec82323
LMI
5387 "Go to the first unread subject.
5388If UNREAD is non-nil, go to the first unread article.
5389Returns the article selected or nil if there are no unread articles."
5390 (interactive "P")
5391 (prog1
5392 (cond
5393 ;; Empty summary.
5394 ((null gnus-newsgroup-data)
5395 (gnus-message 3 "No articles in the group")
5396 nil)
5397 ;; Pick the first article.
5398 ((not unread)
5399 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5400 (gnus-data-number (car gnus-newsgroup-data)))
5401 ;; No unread articles.
5402 ((null gnus-newsgroup-unreads)
5403 (gnus-message 3 "No more unread articles")
5404 nil)
5405 ;; Find the first unread article.
5406 (t
5407 (let ((data gnus-newsgroup-data))
5408 (while (and data
6748645f
LMI
5409 (and (not (and undownloaded
5410 (eq gnus-undownloaded-mark
5411 (gnus-data-mark (car data)))))
5412 (not (gnus-data-unread-p (car data)))))
eec82323
LMI
5413 (setq data (cdr data)))
5414 (when data
5415 (goto-char (gnus-data-pos (car data)))
5416 (gnus-data-number (car data))))))
5417 (gnus-summary-position-point)))
5418
5419(defun gnus-summary-next-subject (n &optional unread dont-display)
5420 "Go to next N'th summary line.
5421If N is negative, go to the previous N'th subject line.
5422If UNREAD is non-nil, only unread articles are selected.
5423The difference between N and the actual number of steps taken is
5424returned."
5425 (interactive "p")
5426 (let ((backward (< n 0))
5427 (n (abs n)))
5428 (while (and (> n 0)
5429 (if backward
5430 (gnus-summary-find-prev unread)
5431 (gnus-summary-find-next unread)))
6748645f 5432 (gnus-summary-show-thread)
eec82323
LMI
5433 (setq n (1- n)))
5434 (when (/= 0 n)
5435 (gnus-message 7 "No more%s articles"
5436 (if unread " unread" "")))
5437 (unless dont-display
5438 (gnus-summary-recenter)
5439 (gnus-summary-position-point))
5440 n))
5441
5442(defun gnus-summary-next-unread-subject (n)
5443 "Go to next N'th unread summary line."
5444 (interactive "p")
5445 (gnus-summary-next-subject n t))
5446
5447(defun gnus-summary-prev-subject (n &optional unread)
5448 "Go to previous N'th summary line.
5449If optional argument UNREAD is non-nil, only unread article is selected."
5450 (interactive "p")
5451 (gnus-summary-next-subject (- n) unread))
5452
5453(defun gnus-summary-prev-unread-subject (n)
5454 "Go to previous N'th unread summary line."
5455 (interactive "p")
5456 (gnus-summary-next-subject (- n) t))
5457
5458(defun gnus-summary-goto-subject (article &optional force silent)
5459 "Go the subject line of ARTICLE.
5460If FORCE, also allow jumping to articles not currently shown."
5461 (interactive "nArticle number: ")
5462 (let ((b (point))
5463 (data (gnus-data-find article)))
5464 ;; We read in the article if we have to.
5465 (and (not data)
5466 force
6748645f
LMI
5467 (gnus-summary-insert-subject
5468 article
5469 (if (or (numberp force) (vectorp force)) force)
5470 t)
eec82323
LMI
5471 (setq data (gnus-data-find article)))
5472 (goto-char b)
5473 (if (not data)
5474 (progn
5475 (unless silent
5476 (gnus-message 3 "Can't find article %d" article))
5477 nil)
5478 (goto-char (gnus-data-pos data))
6748645f 5479 (gnus-summary-position-point)
eec82323
LMI
5480 article)))
5481
5482;; Walking around summary lines with displaying articles.
5483
5484(defun gnus-summary-expand-window (&optional arg)
5485 "Make the summary buffer take up the entire Emacs frame.
5486Given a prefix, will force an `article' buffer configuration."
5487 (interactive "P")
eec82323
LMI
5488 (if arg
5489 (gnus-configure-windows 'article 'force)
5490 (gnus-configure-windows 'summary 'force)))
5491
5492(defun gnus-summary-display-article (article &optional all-header)
5493 "Display ARTICLE in article buffer."
5494 (gnus-set-global-variables)
5495 (if (null article)
5496 nil
5497 (prog1
5498 (if gnus-summary-display-article-function
5499 (funcall gnus-summary-display-article-function article all-header)
5500 (gnus-article-prepare article all-header))
6748645f 5501 (gnus-run-hooks 'gnus-select-article-hook)
eec82323
LMI
5502 (when (and gnus-current-article
5503 (not (zerop gnus-current-article)))
5504 (gnus-summary-goto-subject gnus-current-article))
5505 (gnus-summary-recenter)
5506 (when (and gnus-use-trees gnus-show-threads)
5507 (gnus-possibly-generate-tree article)
5508 (gnus-highlight-selected-tree article))
5509 ;; Successfully display article.
5510 (gnus-article-set-window-start
5511 (cdr (assq article gnus-newsgroup-bookmarks))))))
5512
5513(defun gnus-summary-select-article (&optional all-headers force pseudo article)
5514 "Select the current article.
5515If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5516non-nil, the article will be re-fetched even if it already present in
5517the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5518be displayed."
5519 ;; Make sure we are in the summary buffer to work around bbdb bug.
5520 (unless (eq major-mode 'gnus-summary-mode)
5521 (set-buffer gnus-summary-buffer))
5522 (let ((article (or article (gnus-summary-article-number)))
5523 (all-headers (not (not all-headers))) ;Must be T or NIL.
5524 gnus-summary-display-article-function
5525 did)
5526 (and (not pseudo)
5527 (gnus-summary-article-pseudo-p article)
a8151ef7 5528 (error "This is a pseudo-article"))
eec82323
LMI
5529 (prog1
5530 (save-excursion
5531 (set-buffer gnus-summary-buffer)
5532 (if (or (and gnus-single-article-buffer
5533 (or (null gnus-current-article)
5534 (null gnus-article-current)
5535 (null (get-buffer gnus-article-buffer))
5536 (not (eq article (cdr gnus-article-current)))
5537 (not (equal (car gnus-article-current)
5538 gnus-newsgroup-name))))
5539 (and (not gnus-single-article-buffer)
5540 (or (null gnus-current-article)
5541 (not (eq gnus-current-article article))))
5542 force)
5543 ;; The requested article is different from the current article.
5544 (prog1
5545 (gnus-summary-display-article article all-headers)
5546 (setq did article))
5547 (when (or all-headers gnus-show-all-headers)
5548 (gnus-article-show-all-headers))
5549 'old))
5550 (when did
5551 (gnus-article-set-window-start
5552 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5553
5554(defun gnus-summary-set-current-mark (&optional current-mark)
5555 "Obsolete function."
5556 nil)
5557
5558(defun gnus-summary-next-article (&optional unread subject backward push)
5559 "Select the next article.
5560If UNREAD, only unread articles are selected.
5561If SUBJECT, only articles with SUBJECT are selected.
5562If BACKWARD, the previous article is selected instead of the next."
5563 (interactive "P")
eec82323
LMI
5564 (cond
5565 ;; Is there such an article?
5566 ((and (gnus-summary-search-forward unread subject backward)
5567 (or (gnus-summary-display-article (gnus-summary-article-number))
5568 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5569 (gnus-summary-position-point))
5570 ;; If not, we try the first unread, if that is wanted.
5571 ((and subject
5572 gnus-auto-select-same
5573 (gnus-summary-first-unread-article))
5574 (gnus-summary-position-point)
5575 (gnus-message 6 "Wrapped"))
5576 ;; Try to get next/previous article not displayed in this group.
5577 ((and gnus-auto-extend-newsgroup
5578 (not unread) (not subject))
5579 (gnus-summary-goto-article
5580 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6748645f 5581 nil (count-lines (point-min) (point))))
eec82323
LMI
5582 ;; Go to next/previous group.
5583 (t
5584 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5585 (gnus-summary-jump-to-group gnus-newsgroup-name))
5586 (let ((cmd last-command-char)
5587 (point
5588 (save-excursion
5589 (set-buffer gnus-group-buffer)
5590 (point)))
5591 (group
5592 (if (eq gnus-keep-same-level 'best)
5593 (gnus-summary-best-group gnus-newsgroup-name)
5594 (gnus-summary-search-group backward gnus-keep-same-level))))
5595 ;; For some reason, the group window gets selected. We change
5596 ;; it back.
5597 (select-window (get-buffer-window (current-buffer)))
5598 ;; Select next unread newsgroup automagically.
5599 (cond
5600 ((or (not gnus-auto-select-next)
5601 (not cmd))
5602 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5603 ((or (eq gnus-auto-select-next 'quietly)
5604 (and (eq gnus-auto-select-next 'slightly-quietly)
5605 push)
5606 (and (eq gnus-auto-select-next 'almost-quietly)
5607 (gnus-summary-last-article-p)))
5608 ;; Select quietly.
5609 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5610 (gnus-summary-exit)
5611 (gnus-message 7 "No more%s articles (%s)..."
5612 (if unread " unread" "")
5613 (if group (concat "selecting " group)
5614 "exiting"))
5615 (gnus-summary-next-group nil group backward)))
5616 (t
5617 (when (gnus-key-press-event-p last-input-event)
5618 (gnus-summary-walk-group-buffer
5619 gnus-newsgroup-name cmd unread backward point))))))))
5620
5621(defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5622 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5623 (?\C-p (gnus-group-prev-unread-group 1))))
5624 (cursor-in-echo-area t)
5625 keve key group ended)
5626 (save-excursion
5627 (set-buffer gnus-group-buffer)
5628 (goto-char start)
5629 (setq group
5630 (if (eq gnus-keep-same-level 'best)
5631 (gnus-summary-best-group gnus-newsgroup-name)
5632 (gnus-summary-search-group backward gnus-keep-same-level))))
5633 (while (not ended)
5634 (gnus-message
5635 5 "No more%s articles%s" (if unread " unread" "")
5636 (if (and group
5637 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5638 (format " (Type %s for %s [%s])"
5639 (single-key-description cmd) group
5640 (car (gnus-gethash group gnus-newsrc-hashtb)))
5641 (format " (Type %s to exit %s)"
5642 (single-key-description cmd)
5643 gnus-newsgroup-name)))
5644 ;; Confirm auto selection.
5645 (setq key (car (setq keve (gnus-read-event-char))))
5646 (setq ended t)
5647 (cond
5648 ((assq key keystrokes)
5649 (let ((obuf (current-buffer)))
5650 (switch-to-buffer gnus-group-buffer)
5651 (when group
5652 (gnus-group-jump-to-group group))
5653 (eval (cadr (assq key keystrokes)))
5654 (setq group (gnus-group-group-name))
5655 (switch-to-buffer obuf))
5656 (setq ended nil))
5657 ((equal key cmd)
5658 (if (or (not group)
5659 (gnus-ephemeral-group-p gnus-newsgroup-name))
5660 (gnus-summary-exit)
5661 (gnus-summary-next-group nil group backward)))
5662 (t
5663 (push (cdr keve) unread-command-events))))))
5664
5665(defun gnus-summary-next-unread-article ()
5666 "Select unread article after current one."
5667 (interactive)
5668 (gnus-summary-next-article
5669 (or (not (eq gnus-summary-goto-unread 'never))
5670 (gnus-summary-last-article-p (gnus-summary-article-number)))
5671 (and gnus-auto-select-same
5672 (gnus-summary-article-subject))))
5673
5674(defun gnus-summary-prev-article (&optional unread subject)
5675 "Select the article after the current one.
5676If UNREAD is non-nil, only unread articles are selected."
5677 (interactive "P")
5678 (gnus-summary-next-article unread subject t))
5679
5680(defun gnus-summary-prev-unread-article ()
5681 "Select unread article before current one."
5682 (interactive)
5683 (gnus-summary-prev-article
5684 (or (not (eq gnus-summary-goto-unread 'never))
5685 (gnus-summary-first-article-p (gnus-summary-article-number)))
5686 (and gnus-auto-select-same
5687 (gnus-summary-article-subject))))
5688
5689(defun gnus-summary-next-page (&optional lines circular)
5690 "Show next page of the selected article.
5691If at the end of the current article, select the next article.
5692LINES says how many lines should be scrolled up.
5693
5694If CIRCULAR is non-nil, go to the start of the article instead of
5695selecting the next article when reaching the end of the current
5696article."
5697 (interactive "P")
5698 (setq gnus-summary-buffer (current-buffer))
5699 (gnus-set-global-variables)
5700 (let ((article (gnus-summary-article-number))
5701 (article-window (get-buffer-window gnus-article-buffer t))
5702 endp)
6748645f
LMI
5703 ;; If the buffer is empty, we have no article.
5704 (unless article
5705 (error "No article to select"))
eec82323
LMI
5706 (gnus-configure-windows 'article)
5707 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5708 (if (and (eq gnus-summary-goto-unread 'never)
5709 (not (gnus-summary-last-article-p article)))
5710 (gnus-summary-next-article)
5711 (gnus-summary-next-unread-article))
5712 (if (or (null gnus-current-article)
5713 (null gnus-article-current)
5714 (/= article (cdr gnus-article-current))
5715 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5716 ;; Selected subject is different from current article's.
5717 (gnus-summary-display-article article)
5718 (when article-window
5719 (gnus-eval-in-buffer-window gnus-article-buffer
5720 (setq endp (gnus-article-next-page lines)))
5721 (when endp
5722 (cond (circular
5723 (gnus-summary-beginning-of-article))
5724 (lines
5725 (gnus-message 3 "End of message"))
5726 ((null lines)
5727 (if (and (eq gnus-summary-goto-unread 'never)
5728 (not (gnus-summary-last-article-p article)))
5729 (gnus-summary-next-article)
5730 (gnus-summary-next-unread-article))))))))
5731 (gnus-summary-recenter)
5732 (gnus-summary-position-point)))
5733
5734(defun gnus-summary-prev-page (&optional lines move)
5735 "Show previous page of selected article.
5736Argument LINES specifies lines to be scrolled down.
5737If MOVE, move to the previous unread article if point is at
5738the beginning of the buffer."
5739 (interactive "P")
eec82323
LMI
5740 (let ((article (gnus-summary-article-number))
5741 (article-window (get-buffer-window gnus-article-buffer t))
5742 endp)
5743 (gnus-configure-windows 'article)
5744 (if (or (null gnus-current-article)
5745 (null gnus-article-current)
5746 (/= article (cdr gnus-article-current))
5747 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5748 ;; Selected subject is different from current article's.
5749 (gnus-summary-display-article article)
5750 (gnus-summary-recenter)
5751 (when article-window
5752 (gnus-eval-in-buffer-window gnus-article-buffer
5753 (setq endp (gnus-article-prev-page lines)))
5754 (when (and move endp)
5755 (cond (lines
5756 (gnus-message 3 "Beginning of message"))
5757 ((null lines)
5758 (if (and (eq gnus-summary-goto-unread 'never)
5759 (not (gnus-summary-first-article-p article)))
5760 (gnus-summary-prev-article)
5761 (gnus-summary-prev-unread-article))))))))
5762 (gnus-summary-position-point))
5763
5764(defun gnus-summary-prev-page-or-article (&optional lines)
5765 "Show previous page of selected article.
5766Argument LINES specifies lines to be scrolled down.
5767If at the beginning of the article, go to the next article."
5768 (interactive "P")
5769 (gnus-summary-prev-page lines t))
5770
5771(defun gnus-summary-scroll-up (lines)
5772 "Scroll up (or down) one line current article.
5773Argument LINES specifies lines to be scrolled up (or down if negative)."
5774 (interactive "p")
eec82323
LMI
5775 (gnus-configure-windows 'article)
5776 (gnus-summary-show-thread)
5777 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5778 (gnus-eval-in-buffer-window gnus-article-buffer
5779 (cond ((> lines 0)
5780 (when (gnus-article-next-page lines)
5781 (gnus-message 3 "End of message")))
5782 ((< lines 0)
5783 (gnus-article-prev-page (- lines))))))
5784 (gnus-summary-recenter)
5785 (gnus-summary-position-point))
5786
6748645f
LMI
5787(defun gnus-summary-scroll-down (lines)
5788 "Scroll down (or up) one line current article.
5789Argument LINES specifies lines to be scrolled down (or up if negative)."
5790 (interactive "p")
5791 (gnus-summary-scroll-up (- lines)))
5792
eec82323
LMI
5793(defun gnus-summary-next-same-subject ()
5794 "Select next article which has the same subject as current one."
5795 (interactive)
eec82323
LMI
5796 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5797
5798(defun gnus-summary-prev-same-subject ()
5799 "Select previous article which has the same subject as current one."
5800 (interactive)
eec82323
LMI
5801 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5802
5803(defun gnus-summary-next-unread-same-subject ()
5804 "Select next unread article which has the same subject as current one."
5805 (interactive)
eec82323
LMI
5806 (gnus-summary-next-article t (gnus-summary-article-subject)))
5807
5808(defun gnus-summary-prev-unread-same-subject ()
5809 "Select previous unread article which has the same subject as current one."
5810 (interactive)
eec82323
LMI
5811 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5812
5813(defun gnus-summary-first-unread-article ()
5814 "Select the first unread article.
5815Return nil if there are no unread articles."
5816 (interactive)
eec82323
LMI
5817 (prog1
5818 (when (gnus-summary-first-subject t)
5819 (gnus-summary-show-thread)
5820 (gnus-summary-first-subject t)
5821 (gnus-summary-display-article (gnus-summary-article-number)))
5822 (gnus-summary-position-point)))
5823
5824(defun gnus-summary-first-article ()
5825 "Select the first article.
5826Return nil if there are no articles."
5827 (interactive)
eec82323
LMI
5828 (prog1
5829 (when (gnus-summary-first-subject)
5830 (gnus-summary-show-thread)
5831 (gnus-summary-first-subject)
5832 (gnus-summary-display-article (gnus-summary-article-number)))
5833 (gnus-summary-position-point)))
5834
5835(defun gnus-summary-best-unread-article ()
5836 "Select the unread article with the highest score."
5837 (interactive)
eec82323
LMI
5838 (let ((best -1000000)
5839 (data gnus-newsgroup-data)
5840 article score)
5841 (while data
5842 (and (gnus-data-unread-p (car data))
5843 (> (setq score
5844 (gnus-summary-article-score (gnus-data-number (car data))))
5845 best)
5846 (setq best score
5847 article (gnus-data-number (car data))))
5848 (setq data (cdr data)))
5849 (prog1
5850 (if article
5851 (gnus-summary-goto-article article)
5852 (error "No unread articles"))
5853 (gnus-summary-position-point))))
5854
5855(defun gnus-summary-last-subject ()
5856 "Go to the last displayed subject line in the group."
5857 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5858 (when article
5859 (gnus-summary-goto-subject article))))
5860
5861(defun gnus-summary-goto-article (article &optional all-headers force)
6748645f
LMI
5862 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
5863If ALL-HEADERS is non-nil, no header lines are hidden.
5864If FORCE, go to the article even if it isn't displayed. If FORCE
5865is a number, it is the line the article is to be displayed on."
eec82323
LMI
5866 (interactive
5867 (list
6748645f
LMI
5868 (completing-read
5869 "Article number or Message-ID: "
5870 (mapcar (lambda (number) (list (int-to-string number)))
5871 gnus-newsgroup-limit))
eec82323
LMI
5872 current-prefix-arg
5873 t))
5874 (prog1
6748645f
LMI
5875 (if (and (stringp article)
5876 (string-match "@" article))
5877 (gnus-summary-refer-article article)
5878 (when (stringp article)
5879 (setq article (string-to-number article)))
5880 (if (gnus-summary-goto-subject article force)
5881 (gnus-summary-display-article article all-headers)
5882 (gnus-message 4 "Couldn't go to article %s" article) nil))
eec82323
LMI
5883 (gnus-summary-position-point)))
5884
5885(defun gnus-summary-goto-last-article ()
5886 "Go to the previously read article."
5887 (interactive)
5888 (prog1
5889 (when gnus-last-article
6748645f 5890 (gnus-summary-goto-article gnus-last-article nil t))
eec82323
LMI
5891 (gnus-summary-position-point)))
5892
5893(defun gnus-summary-pop-article (number)
5894 "Pop one article off the history and go to the previous.
5895NUMBER articles will be popped off."
5896 (interactive "p")
5897 (let (to)
5898 (setq gnus-newsgroup-history
5899 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5900 (if to
6748645f 5901 (gnus-summary-goto-article (car to) nil t)
eec82323
LMI
5902 (error "Article history empty")))
5903 (gnus-summary-position-point))
5904
5905;; Summary commands and functions for limiting the summary buffer.
5906
5907(defun gnus-summary-limit-to-articles (n)
5908 "Limit the summary buffer to the next N articles.
5909If not given a prefix, use the process marked articles instead."
5910 (interactive "P")
eec82323
LMI
5911 (prog1
5912 (let ((articles (gnus-summary-work-articles n)))
5913 (setq gnus-newsgroup-processable nil)
5914 (gnus-summary-limit articles))
5915 (gnus-summary-position-point)))
5916
5917(defun gnus-summary-pop-limit (&optional total)
5918 "Restore the previous limit.
5919If given a prefix, remove all limits."
5920 (interactive "P")
eec82323
LMI
5921 (when total
5922 (setq gnus-newsgroup-limits
5923 (list (mapcar (lambda (h) (mail-header-number h))
5924 gnus-newsgroup-headers))))
5925 (unless gnus-newsgroup-limits
5926 (error "No limit to pop"))
5927 (prog1
5928 (gnus-summary-limit nil 'pop)
5929 (gnus-summary-position-point)))
5930
5931(defun gnus-summary-limit-to-subject (subject &optional header)
5932 "Limit the summary buffer to articles that have subjects that match a regexp."
5933 (interactive "sLimit to subject (regexp): ")
5934 (unless header
5935 (setq header "subject"))
5936 (when (not (equal "" subject))
5937 (prog1
5938 (let ((articles (gnus-summary-find-matching
5939 (or header "subject") subject 'all)))
5940 (unless articles
5941 (error "Found no matches for \"%s\"" subject))
5942 (gnus-summary-limit articles))
5943 (gnus-summary-position-point))))
5944
5945(defun gnus-summary-limit-to-author (from)
5946 "Limit the summary buffer to articles that have authors that match a regexp."
5947 (interactive "sLimit to author (regexp): ")
5948 (gnus-summary-limit-to-subject from "from"))
5949
5950(defun gnus-summary-limit-to-age (age &optional younger-p)
5951 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5952If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5953articles that are younger than AGE days."
5954 (interactive "nTime in days: \nP")
5955 (prog1
5956 (let ((data gnus-newsgroup-data)
5957 (cutoff (nnmail-days-to-time age))
5958 articles d date is-younger)
5959 (while (setq d (pop data))
5960 (when (and (vectorp (gnus-data-header d))
5961 (setq date (mail-header-date (gnus-data-header d))))
5962 (setq is-younger (nnmail-time-less
5963 (nnmail-time-since (nnmail-date-to-time date))
5964 cutoff))
6748645f
LMI
5965 (when (if younger-p
5966 is-younger
5967 (not is-younger))
eec82323
LMI
5968 (push (gnus-data-number d) articles))))
5969 (gnus-summary-limit (nreverse articles)))
5970 (gnus-summary-position-point)))
5971
5972(defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5973(make-obsolete
5974 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5975
5976(defun gnus-summary-limit-to-unread (&optional all)
5977 "Limit the summary buffer to articles that are not marked as read.
5978If ALL is non-nil, limit strictly to unread articles."
5979 (interactive "P")
5980 (if all
5981 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5982 (gnus-summary-limit-to-marks
5983 ;; Concat all the marks that say that an article is read and have
5984 ;; those removed.
5985 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5986 gnus-killed-mark gnus-kill-file-mark
5987 gnus-low-score-mark gnus-expirable-mark
5988 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5989 gnus-duplicate-mark gnus-souped-mark)
5990 'reverse)))
5991
5992(defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5993(make-obsolete 'gnus-summary-delete-marked-with
5994 'gnus-summary-limit-exlude-marks)
5995
5996(defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5997 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5998If REVERSE, limit the summary buffer to articles that are marked
5999with MARKS. MARKS can either be a string of marks or a list of marks.
6000Returns how many articles were removed."
6001 (interactive "sMarks: ")
6002 (gnus-summary-limit-to-marks marks t))
6003
6004(defun gnus-summary-limit-to-marks (marks &optional reverse)
6005 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6006If REVERSE (the prefix), limit the summary buffer to articles that are
6007not marked with MARKS. MARKS can either be a string of marks or a
6008list of marks.
6009Returns how many articles were removed."
6748645f 6010 (interactive "sMarks: \nP")
eec82323
LMI
6011 (prog1
6012 (let ((data gnus-newsgroup-data)
6013 (marks (if (listp marks) marks
6014 (append marks nil))) ; Transform to list.
6015 articles)
6016 (while data
6017 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6018 (memq (gnus-data-mark (car data)) marks))
6019 (push (gnus-data-number (car data)) articles))
6020 (setq data (cdr data)))
6021 (gnus-summary-limit articles))
6022 (gnus-summary-position-point)))
6023
6024(defun gnus-summary-limit-to-score (&optional score)
6025 "Limit to articles with score at or above SCORE."
6026 (interactive "P")
eec82323
LMI
6027 (setq score (if score
6028 (prefix-numeric-value score)
6029 (or gnus-summary-default-score 0)))
6030 (let ((data gnus-newsgroup-data)
6031 articles)
6032 (while data
6033 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6034 score)
6035 (push (gnus-data-number (car data)) articles))
6036 (setq data (cdr data)))
6037 (prog1
6038 (gnus-summary-limit articles)
6039 (gnus-summary-position-point))))
6040
6748645f
LMI
6041(defun gnus-summary-limit-include-thread (id)
6042 "Display all the hidden articles that in the current thread."
6043 (interactive (list (mail-header-id (gnus-summary-article-header))))
6044 (let ((articles (gnus-articles-in-thread
6045 (gnus-id-to-thread (gnus-root-id id)))))
6046 (prog1
6047 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6048 (gnus-summary-position-point))))
6049
eec82323 6050(defun gnus-summary-limit-include-dormant ()
6748645f
LMI
6051 "Display all the hidden articles that are marked as dormant.
6052Note that this command only works on a subset of the articles currently
6053fetched for this group."
eec82323 6054 (interactive)
eec82323
LMI
6055 (unless gnus-newsgroup-dormant
6056 (error "There are no dormant articles in this group"))
6057 (prog1
6058 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6059 (gnus-summary-position-point)))
6060
6061(defun gnus-summary-limit-exclude-dormant ()
6062 "Hide all dormant articles."
6063 (interactive)
eec82323
LMI
6064 (prog1
6065 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6066 (gnus-summary-position-point)))
6067
6068(defun gnus-summary-limit-exclude-childless-dormant ()
6069 "Hide all dormant articles that have no children."
6070 (interactive)
eec82323
LMI
6071 (let ((data (gnus-data-list t))
6072 articles d children)
6073 ;; Find all articles that are either not dormant or have
6074 ;; children.
6075 (while (setq d (pop data))
6076 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6077 (and (setq children
6078 (gnus-article-children (gnus-data-number d)))
6079 (let (found)
6080 (while children
6081 (when (memq (car children) articles)
6082 (setq children nil
6083 found t))
6084 (pop children))
6085 found)))
6086 (push (gnus-data-number d) articles)))
6087 ;; Do the limiting.
6088 (prog1
6089 (gnus-summary-limit articles)
6090 (gnus-summary-position-point))))
6091
6092(defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6093 "Mark all unread excluded articles as read.
6094If ALL, mark even excluded ticked and dormants as read."
6095 (interactive "P")
6096 (let ((articles (gnus-sorted-complement
6097 (sort
6098 (mapcar (lambda (h) (mail-header-number h))
6099 gnus-newsgroup-headers)
6100 '<)
6101 (sort gnus-newsgroup-limit '<)))
6102 article)
6748645f
LMI
6103 (setq gnus-newsgroup-unreads
6104 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
eec82323
LMI
6105 (if all
6106 (setq gnus-newsgroup-dormant nil
6107 gnus-newsgroup-marked nil
6108 gnus-newsgroup-reads
6109 (nconc
6110 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6111 gnus-newsgroup-reads))
6112 (while (setq article (pop articles))
6113 (unless (or (memq article gnus-newsgroup-dormant)
6114 (memq article gnus-newsgroup-marked))
6115 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6116
6117(defun gnus-summary-limit (articles &optional pop)
6118 (if pop
6119 ;; We pop the previous limit off the stack and use that.
6120 (setq articles (car gnus-newsgroup-limits)
6121 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6122 ;; We use the new limit, so we push the old limit on the stack.
6123 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6124 ;; Set the limit.
6125 (setq gnus-newsgroup-limit articles)
6126 (let ((total (length gnus-newsgroup-data))
6127 (data (gnus-data-find-list (gnus-summary-article-number)))
6128 (gnus-summary-mark-below nil) ; Inhibit this.
6129 found)
6130 ;; This will do all the work of generating the new summary buffer
6131 ;; according to the new limit.
6132 (gnus-summary-prepare)
6133 ;; Hide any threads, possibly.
6134 (and gnus-show-threads
6135 gnus-thread-hide-subtree
6136 (gnus-summary-hide-all-threads))
6137 ;; Try to return to the article you were at, or one in the
6138 ;; neighborhood.
6139 (when data
6140 ;; We try to find some article after the current one.
6141 (while data
6142 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6143 (setq data nil
6144 found t))
6145 (setq data (cdr data))))
6146 (unless found
6147 ;; If there is no data, that means that we were after the last
6148 ;; article. The same goes when we can't find any articles
6149 ;; after the current one.
6150 (goto-char (point-max))
6151 (gnus-summary-find-prev))
6748645f 6152 (gnus-set-mode-line 'summary)
eec82323
LMI
6153 ;; We return how many articles were removed from the summary
6154 ;; buffer as a result of the new limit.
6155 (- total (length gnus-newsgroup-data))))
6156
6157(defsubst gnus-invisible-cut-children (threads)
6158 (let ((num 0))
6159 (while threads
6160 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6161 (incf num))
6162 (pop threads))
6163 (< num 2)))
6164
6165(defsubst gnus-cut-thread (thread)
6166 "Go forwards in the thread until we find an article that we want to display."
6167 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 6168 (eq gnus-fetch-old-headers 'invisible)
eec82323
LMI
6169 (eq gnus-build-sparse-threads 'some)
6170 (eq gnus-build-sparse-threads 'more))
6171 ;; Deal with old-fetched headers and sparse threads.
6172 (while (and
6173 thread
6174 (or
6175 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6176 (gnus-summary-article-ancient-p
6177 (mail-header-number (car thread))))
6748645f
LMI
6178 (if (or (<= (length (cdr thread)) 1)
6179 (eq gnus-fetch-old-headers 'invisible))
6180 (setq gnus-newsgroup-limit
6181 (delq (mail-header-number (car thread))
6182 gnus-newsgroup-limit)
6183 thread (cadr thread))
6184 (when (gnus-invisible-cut-children (cdr thread))
6185 (let ((th (cdr thread)))
6186 (while th
6187 (if (memq (mail-header-number (caar th))
a8151ef7 6188 gnus-newsgroup-limit)
6748645f
LMI
6189 (setq thread (car th)
6190 th nil)
6191 (setq th (cdr th))))))))))
eec82323
LMI
6192 thread)
6193
6194(defun gnus-cut-threads (threads)
6195 "Cut off all uninteresting articles from the beginning of threads."
6196 (when (or (eq gnus-fetch-old-headers 'some)
6748645f 6197 (eq gnus-fetch-old-headers 'invisible)
eec82323
LMI
6198 (eq gnus-build-sparse-threads 'some)
6199 (eq gnus-build-sparse-threads 'more))
6200 (let ((th threads))
6201 (while th
6202 (setcar th (gnus-cut-thread (car th)))
6203 (setq th (cdr th)))))
6204 ;; Remove nixed out threads.
6205 (delq nil threads))
6206
6207(defun gnus-summary-initial-limit (&optional show-if-empty)
6208 "Figure out what the initial limit is supposed to be on group entry.
6209This entails weeding out unwanted dormants, low-scored articles,
6210fetch-old-headers verbiage, and so on."
6211 ;; Most groups have nothing to remove.
6212 (if (or gnus-inhibit-limiting
6213 (and (null gnus-newsgroup-dormant)
6214 (not (eq gnus-fetch-old-headers 'some))
6748645f 6215 (not (eq gnus-fetch-old-headers 'invisible))
eec82323
LMI
6216 (null gnus-summary-expunge-below)
6217 (not (eq gnus-build-sparse-threads 'some))
6218 (not (eq gnus-build-sparse-threads 'more))
6219 (null gnus-thread-expunge-below)
6220 (not gnus-use-nocem)))
6221 () ; Do nothing.
6222 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6223 (setq gnus-newsgroup-limit nil)
6224 (mapatoms
6225 (lambda (node)
6226 (unless (car (symbol-value node))
6227 ;; These threads have no parents -- they are roots.
6228 (let ((nodes (cdr (symbol-value node)))
6229 thread)
6230 (while nodes
6231 (if (and gnus-thread-expunge-below
6232 (< (gnus-thread-total-score (car nodes))
6233 gnus-thread-expunge-below))
6234 (gnus-expunge-thread (pop nodes))
6235 (setq thread (pop nodes))
6236 (gnus-summary-limit-children thread))))))
6237 gnus-newsgroup-dependencies)
6238 ;; If this limitation resulted in an empty group, we might
6239 ;; pop the previous limit and use it instead.
6240 (when (and (not gnus-newsgroup-limit)
6241 show-if-empty)
6242 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6243 gnus-newsgroup-limit))
6244
6245(defun gnus-summary-limit-children (thread)
6246 "Return 1 if this subthread is visible and 0 if it is not."
6247 ;; First we get the number of visible children to this thread. This
6248 ;; is done by recursing down the thread using this function, so this
6249 ;; will really go down to a leaf article first, before slowly
6250 ;; working its way up towards the root.
6251 (when thread
6252 (let ((children
6253 (if (cdr thread)
6254 (apply '+ (mapcar 'gnus-summary-limit-children
6255 (cdr thread)))
6256 0))
6257 (number (mail-header-number (car thread)))
6258 score)
6259 (if (and
6260 (not (memq number gnus-newsgroup-marked))
6261 (or
6262 ;; If this article is dormant and has absolutely no visible
6263 ;; children, then this article isn't visible.
6264 (and (memq number gnus-newsgroup-dormant)
6265 (zerop children))
6266 ;; If this is "fetch-old-headered" and there is no
6267 ;; visible children, then we don't want this article.
6268 (and (eq gnus-fetch-old-headers 'some)
6269 (gnus-summary-article-ancient-p number)
6270 (zerop children))
6748645f
LMI
6271 ;; If this is "fetch-old-headered" and `invisible', then
6272 ;; we don't want this article.
6273 (and (eq gnus-fetch-old-headers 'invisible)
6274 (gnus-summary-article-ancient-p number))
eec82323
LMI
6275 ;; If this is a sparsely inserted article with no children,
6276 ;; we don't want it.
6277 (and (eq gnus-build-sparse-threads 'some)
6278 (gnus-summary-article-sparse-p number)
6279 (zerop children))
6280 ;; If we use expunging, and this article is really
6281 ;; low-scored, then we don't want this article.
6282 (when (and gnus-summary-expunge-below
6283 (< (setq score
6284 (or (cdr (assq number gnus-newsgroup-scored))
6285 gnus-summary-default-score))
6286 gnus-summary-expunge-below))
6287 ;; We increase the expunge-tally here, but that has
6288 ;; nothing to do with the limits, really.
6289 (incf gnus-newsgroup-expunged-tally)
6290 ;; We also mark as read here, if that's wanted.
6291 (when (and gnus-summary-mark-below
6292 (< score gnus-summary-mark-below))
6293 (setq gnus-newsgroup-unreads
6294 (delq number gnus-newsgroup-unreads))
6295 (if gnus-newsgroup-auto-expire
6296 (push number gnus-newsgroup-expirable)
6297 (push (cons number gnus-low-score-mark)
6298 gnus-newsgroup-reads)))
6299 t)
6300 ;; Check NoCeM things.
6301 (if (and gnus-use-nocem
6302 (gnus-nocem-unwanted-article-p
6303 (mail-header-id (car thread))))
6304 (progn
a8151ef7 6305 (setq gnus-newsgroup-unreads
eec82323
LMI
6306 (delq number gnus-newsgroup-unreads))
6307 t))))
6308 ;; Nope, invisible article.
6309 0
6310 ;; Ok, this article is to be visible, so we add it to the limit
6311 ;; and return 1.
6312 (push number gnus-newsgroup-limit)
6313 1))))
6314
6315(defun gnus-expunge-thread (thread)
6316 "Mark all articles in THREAD as read."
6317 (let* ((number (mail-header-number (car thread))))
6318 (incf gnus-newsgroup-expunged-tally)
6319 ;; We also mark as read here, if that's wanted.
6320 (setq gnus-newsgroup-unreads
6321 (delq number gnus-newsgroup-unreads))
6322 (if gnus-newsgroup-auto-expire
6323 (push number gnus-newsgroup-expirable)
6324 (push (cons number gnus-low-score-mark)
6325 gnus-newsgroup-reads)))
6326 ;; Go recursively through all subthreads.
6327 (mapcar 'gnus-expunge-thread (cdr thread)))
6328
6329;; Summary article oriented commands
6330
6331(defun gnus-summary-refer-parent-article (n)
6332 "Refer parent article N times.
6333If N is negative, go to ancestor -N instead.
6334The difference between N and the number of articles fetched is returned."
6335 (interactive "p")
eec82323
LMI
6336 (let ((skip 1)
6337 error header ref)
6338 (when (not (natnump n))
6339 (setq skip (abs n)
6340 n 1))
6341 (while (and (> n 0)
6342 (not error))
6343 (setq header (gnus-summary-article-header))
6344 (if (and (eq (mail-header-number header)
6345 (cdr gnus-article-current))
6346 (equal gnus-newsgroup-name
6347 (car gnus-article-current)))
6348 ;; If we try to find the parent of the currently
6349 ;; displayed article, then we take a look at the actual
6350 ;; References header, since this is slightly more
6351 ;; reliable than the References field we got from the
6352 ;; server.
6353 (save-excursion
6354 (set-buffer gnus-original-article-buffer)
6355 (nnheader-narrow-to-headers)
6356 (unless (setq ref (message-fetch-field "references"))
6357 (setq ref (message-fetch-field "in-reply-to")))
6358 (widen))
6359 (setq ref
6360 ;; It's not the current article, so we take a bet on
6361 ;; the value we got from the server.
6362 (mail-header-references header)))
6363 (if (and ref
6364 (not (equal ref "")))
6365 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6366 (gnus-message 1 "Couldn't find parent"))
6367 (gnus-message 1 "No references in article %d"
6368 (gnus-summary-article-number))
6369 (setq error t))
6370 (decf n))
6371 (gnus-summary-position-point)
6372 n))
6373
6374(defun gnus-summary-refer-references ()
6375 "Fetch all articles mentioned in the References header.
6748645f 6376Return the number of articles fetched."
eec82323 6377 (interactive)
eec82323
LMI
6378 (let ((ref (mail-header-references (gnus-summary-article-header)))
6379 (current (gnus-summary-article-number))
6380 (n 0))
6381 (if (or (not ref)
6382 (equal ref ""))
6383 (error "No References in the current article")
6384 ;; For each Message-ID in the References header...
6385 (while (string-match "<[^>]*>" ref)
6386 (incf n)
6387 ;; ... fetch that article.
6388 (gnus-summary-refer-article
6389 (prog1 (match-string 0 ref)
6390 (setq ref (substring ref (match-end 0))))))
6391 (gnus-summary-goto-subject current)
6392 (gnus-summary-position-point)
6393 n)))
6394
6748645f
LMI
6395(defun gnus-summary-refer-thread (&optional limit)
6396 "Fetch all articles in the current thread.
6397If LIMIT (the numerical prefix), fetch that many old headers instead
6398of what's specified by the `gnus-refer-thread-limit' variable."
6399 (interactive "P")
6400 (let ((id (mail-header-id (gnus-summary-article-header)))
6401 (limit (if limit (prefix-numeric-value limit)
6402 gnus-refer-thread-limit)))
6403 ;; We want to fetch LIMIT *old* headers, but we also have to
6404 ;; re-fetch all the headers in the current buffer, because many of
6405 ;; them may be undisplayed. So we adjust LIMIT.
6406 (when (numberp limit)
6407 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6408 (unless (eq gnus-fetch-old-headers 'invisible)
6409 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6410 ;; Retrieve the headers and read them in.
6411 (if (eq (gnus-retrieve-headers
6412 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6413 'nov)
6414 (gnus-build-all-threads)
6415 (error "Can't fetch thread from backends that don't support NOV"))
6416 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6417 (gnus-summary-limit-include-thread id)))
6418
eec82323
LMI
6419(defun gnus-summary-refer-article (message-id &optional arg)
6420 "Fetch an article specified by MESSAGE-ID.
6421If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6422or `gnus-select-method', no matter what backend the article comes from."
6423 (interactive "sMessage-ID: \nP")
6424 (when (and (stringp message-id)
6425 (not (zerop (length message-id))))
6426 ;; Construct the correct Message-ID if necessary.
6427 ;; Suggested by tale@pawl.rpi.edu.
6428 (unless (string-match "^<" message-id)
6429 (setq message-id (concat "<" message-id)))
6430 (unless (string-match ">$" message-id)
6431 (setq message-id (concat message-id ">")))
6432 (let* ((header (gnus-id-to-header message-id))
6433 (sparse (and header
6434 (gnus-summary-article-sparse-p
a8151ef7
LMI
6435 (mail-header-number header))
6436 (memq (mail-header-number header)
6437 gnus-newsgroup-limit))))
6748645f
LMI
6438 (cond
6439 ;; If the article is present in the buffer we just go to it.
6440 ((and header
6441 (or (not (gnus-summary-article-sparse-p
6442 (mail-header-number header)))
6443 sparse))
6444 (prog1
6445 (gnus-summary-goto-article
6446 (mail-header-number header) nil t)
6447 (when sparse
6448 (gnus-summary-update-article (mail-header-number header)))))
6449 (t
eec82323
LMI
6450 ;; We fetch the article
6451 (let ((gnus-override-method
6452 (cond ((gnus-news-group-p gnus-newsgroup-name)
6453 gnus-refer-article-method)
6454 (arg
6455 (or gnus-refer-article-method gnus-select-method))
6456 (t nil)))
6457 number)
6458 ;; Start the special refer-article method, if necessary.
6459 (when (and gnus-refer-article-method
6460 (gnus-news-group-p gnus-newsgroup-name))
6461 (gnus-check-server gnus-refer-article-method))
6462 ;; Fetch the header, and display the article.
6463 (if (setq number (gnus-summary-insert-subject message-id))
6464 (gnus-summary-select-article nil nil nil number)
6748645f
LMI
6465 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6466
6467(defun gnus-summary-edit-parameters ()
6468 "Edit the group parameters of the current group."
6469 (interactive)
6470 (gnus-group-edit-group gnus-newsgroup-name 'params))
eec82323
LMI
6471
6472(defun gnus-summary-enter-digest-group (&optional force)
6473 "Enter an nndoc group based on the current article.
6474If FORCE, force a digest interpretation. If not, try
6475to guess what the document format is."
6476 (interactive "P")
eec82323
LMI
6477 (let ((conf gnus-current-window-configuration))
6478 (save-excursion
6479 (gnus-summary-select-article))
6480 (setq gnus-current-window-configuration conf)
6481 (let* ((name (format "%s-%d"
6482 (gnus-group-prefixed-name
6483 gnus-newsgroup-name (list 'nndoc ""))
6484 (save-excursion
6485 (set-buffer gnus-summary-buffer)
6486 gnus-current-article)))
6487 (ogroup gnus-newsgroup-name)
6488 (params (append (gnus-info-params (gnus-get-info ogroup))
6489 (list (cons 'to-group ogroup))
6490 (list (cons 'save-article-group ogroup))))
6491 (case-fold-search t)
6492 (buf (current-buffer))
6493 dig)
6494 (save-excursion
6495 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6496 (insert-buffer-substring gnus-original-article-buffer)
6497 ;; Remove lines that may lead nndoc to misinterpret the
6498 ;; document type.
6499 (narrow-to-region
6500 (goto-char (point-min))
6501 (or (search-forward "\n\n" nil t) (point)))
6502 (goto-char (point-min))
6503 (delete-matching-lines "^\\(Path\\):\\|^From ")
6504 (widen))
6505 (unwind-protect
6506 (if (gnus-group-read-ephemeral-group
6507 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6508 (nndoc-article-type
6509 ,(if force 'digest 'guess))) t)
6510 ;; Make all postings to this group go to the parent group.
6511 (nconc (gnus-info-params (gnus-get-info name))
6512 params)
6513 ;; Couldn't select this doc group.
6514 (switch-to-buffer buf)
6515 (gnus-set-global-variables)
6516 (gnus-configure-windows 'summary)
6517 (gnus-message 3 "Article couldn't be entered?"))
6518 (kill-buffer dig)))))
6519
6520(defun gnus-summary-read-document (n)
6521 "Open a new group based on the current article(s).
6522This will allow you to read digests and other similar
6523documents as newsgroups.
6524Obeys the standard process/prefix convention."
6525 (interactive "P")
6526 (let* ((articles (gnus-summary-work-articles n))
6527 (ogroup gnus-newsgroup-name)
6528 (params (append (gnus-info-params (gnus-get-info ogroup))
6529 (list (cons 'to-group ogroup))))
6530 article group egroup groups vgroup)
6531 (while (setq article (pop articles))
6532 (setq group (format "%s-%d" gnus-newsgroup-name article))
6533 (gnus-summary-remove-process-mark article)
6534 (when (gnus-summary-display-article article)
6535 (save-excursion
6536 (nnheader-temp-write nil
6537 (insert-buffer-substring gnus-original-article-buffer)
6538 ;; Remove some headers that may lead nndoc to make
6539 ;; the wrong guess.
6540 (message-narrow-to-head)
6541 (goto-char (point-min))
6542 (delete-matching-lines "^\\(Path\\):\\|^From ")
6543 (widen)
6544 (if (setq egroup
6545 (gnus-group-read-ephemeral-group
6546 group `(nndoc ,group (nndoc-address ,(current-buffer))
6547 (nndoc-article-type guess))
6548 t nil t))
6549 (progn
6550 ;; Make all postings to this group go to the parent group.
6551 (nconc (gnus-info-params (gnus-get-info egroup))
6552 params)
6553 (push egroup groups))
6554 ;; Couldn't select this doc group.
6555 (gnus-error 3 "Article couldn't be entered"))))))
6556 ;; Now we have selected all the documents.
6557 (cond
6558 ((not groups)
6559 (error "None of the articles could be interpreted as documents"))
6560 ((gnus-group-read-ephemeral-group
6561 (setq vgroup (format
6562 "nnvirtual:%s-%s" gnus-newsgroup-name
6563 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6564 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6565 t
6566 (cons (current-buffer) 'summary)))
6567 (t
6568 (error "Couldn't select virtual nndoc group")))))
6569
6570(defun gnus-summary-isearch-article (&optional regexp-p)
6571 "Do incremental search forward on the current article.
6572If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6573 (interactive "P")
eec82323
LMI
6574 (gnus-summary-select-article)
6575 (gnus-configure-windows 'article)
6576 (gnus-eval-in-buffer-window gnus-article-buffer
6748645f
LMI
6577 (save-restriction
6578 (widen)
6579 (isearch-forward regexp-p))))
eec82323
LMI
6580
6581(defun gnus-summary-search-article-forward (regexp &optional backward)
6582 "Search for an article containing REGEXP forward.
6583If BACKWARD, search backward instead."
6584 (interactive
6585 (list (read-string
6586 (format "Search article %s (regexp%s): "
6587 (if current-prefix-arg "backward" "forward")
6588 (if gnus-last-search-regexp
6589 (concat ", default " gnus-last-search-regexp)
6590 "")))
6591 current-prefix-arg))
eec82323
LMI
6592 (if (string-equal regexp "")
6593 (setq regexp (or gnus-last-search-regexp ""))
6594 (setq gnus-last-search-regexp regexp))
6595 (if (gnus-summary-search-article regexp backward)
6596 (gnus-summary-show-thread)
6597 (error "Search failed: \"%s\"" regexp)))
6598
6599(defun gnus-summary-search-article-backward (regexp)
6600 "Search for an article containing REGEXP backward."
6601 (interactive
6602 (list (read-string
6603 (format "Search article backward (regexp%s): "
6604 (if gnus-last-search-regexp
6605 (concat ", default " gnus-last-search-regexp)
6606 "")))))
6607 (gnus-summary-search-article-forward regexp 'backward))
6608
6609(defun gnus-summary-search-article (regexp &optional backward)
6610 "Search for an article containing REGEXP.
6611Optional argument BACKWARD means do search for backward.
6612`gnus-select-article-hook' is not called during the search."
a8151ef7
LMI
6613 ;; We have to require this here to make sure that the following
6614 ;; dynamic binding isn't shadowed by autoloading.
6615 (require 'gnus-async)
eec82323
LMI
6616 (let ((gnus-select-article-hook nil) ;Disable hook.
6617 (gnus-article-display-hook nil)
6618 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6619 (gnus-use-article-prefetch nil)
6620 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
a8151ef7 6621 (gnus-use-trees nil) ;Inhibit updating tree buffer.
eec82323
LMI
6622 (sum (current-buffer))
6623 (found nil)
6624 point)
6625 (gnus-save-hidden-threads
6626 (gnus-summary-select-article)
6627 (set-buffer gnus-article-buffer)
6628 (when backward
6629 (forward-line -1))
6630 (while (not found)
6631 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6632 (if (if backward
6633 (re-search-backward regexp nil t)
6634 (re-search-forward regexp nil t))
6635 ;; We found the regexp.
6636 (progn
6637 (setq found 'found)
6638 (beginning-of-line)
6639 (set-window-start
6640 (get-buffer-window (current-buffer))
6641 (point))
6642 (forward-line 1)
6643 (set-buffer sum)
6644 (setq point (point)))
6645 ;; We didn't find it, so we go to the next article.
6646 (set-buffer sum)
6647 (setq found 'not)
6648 (while (eq found 'not)
6649 (if (not (if backward (gnus-summary-find-prev)
6650 (gnus-summary-find-next)))
6651 ;; No more articles.
6652 (setq found t)
6653 ;; Select the next article and adjust point.
6654 (unless (gnus-summary-article-sparse-p
6655 (gnus-summary-article-number))
6656 (setq found nil)
6657 (gnus-summary-select-article)
6658 (set-buffer gnus-article-buffer)
6659 (widen)
6660 (goto-char (if backward (point-max) (point-min))))))))
6661 (gnus-message 7 ""))
6662 ;; Return whether we found the regexp.
6663 (when (eq found 'found)
6664 (goto-char point)
6665 (gnus-summary-show-thread)
6666 (gnus-summary-goto-subject gnus-current-article)
6667 (gnus-summary-position-point)
6668 t)))
6669
6670(defun gnus-summary-find-matching (header regexp &optional backward unread
6671 not-case-fold)
6672 "Return a list of all articles that match REGEXP on HEADER.
6673The search stars on the current article and goes forwards unless
6674BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6675If UNREAD is non-nil, only unread articles will
6676be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6677in the comparisons."
6678 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6679 (gnus-data-find-list
6680 (gnus-summary-article-number) (gnus-data-list backward))))
6681 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6682 (case-fold-search (not not-case-fold))
6683 articles d)
6684 (unless (fboundp (intern (concat "mail-header-" header)))
6685 (error "%s is not a valid header" header))
6686 (while data
6687 (setq d (car data))
6688 (and (or (not unread) ; We want all articles...
6689 (gnus-data-unread-p d)) ; Or just unreads.
6690 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6691 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6692 (push (gnus-data-number d) articles)) ; Success!
6693 (setq data (cdr data)))
6694 (nreverse articles)))
6695
6696(defun gnus-summary-execute-command (header regexp command &optional backward)
6697 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6698If HEADER is an empty string (or nil), the match is done on the entire
6699article. If BACKWARD (the prefix) is non-nil, search backward instead."
6700 (interactive
6701 (list (let ((completion-ignore-case t))
6702 (completing-read
6703 "Header name: "
6704 (mapcar (lambda (string) (list string))
6705 '("Number" "Subject" "From" "Lines" "Date"
6706 "Message-ID" "Xref" "References" "Body"))
6707 nil 'require-match))
6708 (read-string "Regexp: ")
6709 (read-key-sequence "Command: ")
6710 current-prefix-arg))
6711 (when (equal header "Body")
6712 (setq header ""))
eec82323
LMI
6713 ;; Hidden thread subtrees must be searched as well.
6714 (gnus-summary-show-all-threads)
6715 ;; We don't want to change current point nor window configuration.
6716 (save-excursion
6717 (save-window-excursion
6718 (gnus-message 6 "Executing %s..." (key-description command))
6719 ;; We'd like to execute COMMAND interactively so as to give arguments.
6720 (gnus-execute header regexp
6721 `(call-interactively ',(key-binding command))
6722 backward)
6723 (gnus-message 6 "Executing %s...done" (key-description command)))))
6724
6725(defun gnus-summary-beginning-of-article ()
6726 "Scroll the article back to the beginning."
6727 (interactive)
eec82323
LMI
6728 (gnus-summary-select-article)
6729 (gnus-configure-windows 'article)
6730 (gnus-eval-in-buffer-window gnus-article-buffer
6731 (widen)
6732 (goto-char (point-min))
6733 (when gnus-page-broken
6734 (gnus-narrow-to-page))))
6735
6736(defun gnus-summary-end-of-article ()
6737 "Scroll to the end of the article."
6738 (interactive)
eec82323
LMI
6739 (gnus-summary-select-article)
6740 (gnus-configure-windows 'article)
6741 (gnus-eval-in-buffer-window gnus-article-buffer
6742 (widen)
6743 (goto-char (point-max))
6744 (recenter -3)
6745 (when gnus-page-broken
6746 (gnus-narrow-to-page))))
6747
6748645f
LMI
6748(defun gnus-summary-print-article (&optional filename n)
6749 "Generate and print a PostScript image of the N next (mail) articles.
6750
6751If N is negative, print the N previous articles. If N is nil and articles
6752have been marked with the process mark, print these instead.
eec82323 6753
6748645f
LMI
6754If the optional second argument FILENAME is nil, send the image to the
6755printer. If FILENAME is a string, save the PostScript image in a file with
6756that name. If FILENAME is a number, prompt the user for the name of the file
eec82323 6757to save in."
6748645f
LMI
6758 (interactive (list (ps-print-preprint current-prefix-arg)
6759 current-prefix-arg))
6760 (dolist (article (gnus-summary-work-articles n))
6761 (gnus-summary-select-article nil nil 'pseudo article)
6762 (gnus-eval-in-buffer-window gnus-article-buffer
6763 (let ((buffer (generate-new-buffer " *print*")))
6764 (unwind-protect
6765 (progn
6766 (copy-to-buffer buffer (point-min) (point-max))
6767 (set-buffer buffer)
6768 (gnus-article-delete-invisible-text)
6769 (let ((ps-left-header
6770 (list
6771 (concat "("
6772 (mail-header-subject gnus-current-headers) ")")
6773 (concat "("
6774 (mail-header-from gnus-current-headers) ")")))
6775 (ps-right-header
6776 (list
6777 "/pagenumberstring load"
6778 (concat "("
6779 (mail-header-date gnus-current-headers) ")"))))
6780 (gnus-run-hooks 'gnus-ps-print-hook)
6781 (save-excursion
6782 (ps-print-buffer-with-faces filename))))
6783 (kill-buffer buffer))))))
eec82323
LMI
6784
6785(defun gnus-summary-show-article (&optional arg)
6786 "Force re-fetching of the current article.
6787If ARG (the prefix) is non-nil, show the raw article without any
6788article massaging functions being run."
6789 (interactive "P")
eec82323
LMI
6790 (if (not arg)
6791 ;; Select the article the normal way.
6792 (gnus-summary-select-article nil 'force)
6793 ;; Bind the article treatment functions to nil.
6794 (let ((gnus-have-all-headers t)
6795 gnus-article-display-hook
6796 gnus-article-prepare-hook
6797 gnus-break-pages
6798 gnus-show-mime
6799 gnus-visual)
6800 (gnus-summary-select-article nil 'force)))
6801 (gnus-summary-goto-subject gnus-current-article)
6802 (gnus-summary-position-point))
6803
6804(defun gnus-summary-verbose-headers (&optional arg)
6805 "Toggle permanent full header display.
6806If ARG is a positive number, turn header display on.
6807If ARG is a negative number, turn header display off."
6808 (interactive "P")
eec82323
LMI
6809 (setq gnus-show-all-headers
6810 (cond ((or (not (numberp arg))
6811 (zerop arg))
6812 (not gnus-show-all-headers))
6813 ((natnump arg)
6814 t)))
6815 (gnus-summary-show-article))
6816
6817(defun gnus-summary-toggle-header (&optional arg)
6818 "Show the headers if they are hidden, or hide them if they are shown.
6819If ARG is a positive number, show the entire header.
6820If ARG is a negative number, hide the unwanted header lines."
6821 (interactive "P")
eec82323
LMI
6822 (save-excursion
6823 (set-buffer gnus-article-buffer)
6824 (let* ((buffer-read-only nil)
6825 (inhibit-point-motion-hooks t)
6826 (hidden (text-property-any
6827 (goto-char (point-min)) (search-forward "\n\n")
6828 'invisible t))
6829 e)
6830 (goto-char (point-min))
6831 (when (search-forward "\n\n" nil t)
6832 (delete-region (point-min) (1- (point))))
6833 (goto-char (point-min))
6834 (save-excursion
6835 (set-buffer gnus-original-article-buffer)
6836 (goto-char (point-min))
6837 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6838 (insert-buffer-substring gnus-original-article-buffer 1 e)
6839 (let ((article-inhibit-hiding t))
6748645f 6840 (gnus-run-hooks 'gnus-article-display-hook))
eec82323
LMI
6841 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6842 (gnus-article-hide-headers)))))
6843
6844(defun gnus-summary-show-all-headers ()
6845 "Make all header lines visible."
6846 (interactive)
eec82323
LMI
6847 (gnus-article-show-all-headers))
6848
6849(defun gnus-summary-toggle-mime (&optional arg)
6850 "Toggle MIME processing.
6851If ARG is a positive number, turn MIME processing on."
6852 (interactive "P")
eec82323
LMI
6853 (setq gnus-show-mime
6854 (if (null arg) (not gnus-show-mime)
6855 (> (prefix-numeric-value arg) 0)))
6856 (gnus-summary-select-article t 'force))
6857
6858(defun gnus-summary-caesar-message (&optional arg)
6859 "Caesar rotate the current article by 13.
6860The numerical prefix specifies how many places to rotate each letter
6861forward."
6862 (interactive "P")
eec82323
LMI
6863 (gnus-summary-select-article)
6864 (let ((mail-header-separator ""))
6865 (gnus-eval-in-buffer-window gnus-article-buffer
6866 (save-restriction
6867 (widen)
6868 (let ((start (window-start))
6869 buffer-read-only)
6870 (message-caesar-buffer-body arg)
6871 (set-window-start (get-buffer-window (current-buffer)) start))))))
6872
6873(defun gnus-summary-stop-page-breaking ()
6874 "Stop page breaking in the current article."
6875 (interactive)
eec82323
LMI
6876 (gnus-summary-select-article)
6877 (gnus-eval-in-buffer-window gnus-article-buffer
6878 (widen)
6879 (when (gnus-visual-p 'page-marker)
6880 (let ((buffer-read-only nil))
6881 (gnus-remove-text-with-property 'gnus-prev)
6748645f
LMI
6882 (gnus-remove-text-with-property 'gnus-next))
6883 (setq gnus-page-broken nil))))
eec82323
LMI
6884
6885(defun gnus-summary-move-article (&optional n to-newsgroup
6886 select-method action)
6887 "Move the current article to a different newsgroup.
6888If N is a positive number, move the N next articles.
6889If N is a negative number, move the N previous articles.
6890If N is nil and any articles have been marked with the process mark,
6891move those articles instead.
6892If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6893If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6894re-spool using this method.
6895
6896For this function to work, both the current newsgroup and the
6897newsgroup that you want to move to have to support the `request-move'
6898and `request-accept' functions."
6899 (interactive "P")
6900 (unless action
6901 (setq action 'move))
eec82323
LMI
6902 ;; Disable marking as read.
6903 (let (gnus-mark-article-hook)
6904 (save-window-excursion
6905 (gnus-summary-select-article)))
6906 ;; Check whether the source group supports the required functions.
6907 (cond ((and (eq action 'move)
6908 (not (gnus-check-backend-function
6909 'request-move-article gnus-newsgroup-name)))
6910 (error "The current group does not support article moving"))
6911 ((and (eq action 'crosspost)
6912 (not (gnus-check-backend-function
6913 'request-replace-article gnus-newsgroup-name)))
6914 (error "The current group does not support article editing")))
6915 (let ((articles (gnus-summary-work-articles n))
6916 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6917 (names '((move "Move" "Moving")
6918 (copy "Copy" "Copying")
6919 (crosspost "Crosspost" "Crossposting")))
6920 (copy-buf (save-excursion
6921 (nnheader-set-temp-buffer " *copy article*")))
6922 art-group to-method new-xref article to-groups)
6923 (unless (assq action names)
6924 (error "Unknown action %s" action))
6925 ;; Read the newsgroup name.
6926 (when (and (not to-newsgroup)
6927 (not select-method))
6928 (setq to-newsgroup
6929 (gnus-read-move-group-name
6930 (cadr (assq action names))
6931 (symbol-value (intern (format "gnus-current-%s-group" action)))
6932 articles prefix))
6933 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6934 (setq to-method (or select-method
6935 (gnus-group-name-to-method to-newsgroup)))
6936 ;; Check the method we are to move this article to...
6937 (unless (gnus-check-backend-function
6938 'request-accept-article (car to-method))
6939 (error "%s does not support article copying" (car to-method)))
6940 (unless (gnus-check-server to-method)
6941 (error "Can't open server %s" (car to-method)))
6942 (gnus-message 6 "%s to %s: %s..."
6943 (caddr (assq action names))
6944 (or (car select-method) to-newsgroup) articles)
6945 (while articles
6946 (setq article (pop articles))
6947 (setq
6948 art-group
6949 (cond
6950 ;; Move the article.
6951 ((eq action 'move)
a8151ef7
LMI
6952 ;; Remove this article from future suppression.
6953 (gnus-dup-unsuppress-article article)
eec82323
LMI
6954 (gnus-request-move-article
6955 article ; Article to move
6956 gnus-newsgroup-name ; From newsgroup
6957 (nth 1 (gnus-find-method-for-group
6958 gnus-newsgroup-name)) ; Server
6959 (list 'gnus-request-accept-article
6960 to-newsgroup (list 'quote select-method)
6961 (not articles)) ; Accept form
6962 (not articles))) ; Only save nov last time
6963 ;; Copy the article.
6964 ((eq action 'copy)
6965 (save-excursion
6966 (set-buffer copy-buf)
6748645f
LMI
6967 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
6968 (gnus-request-accept-article
6969 to-newsgroup select-method (not articles)))))
eec82323
LMI
6970 ;; Crosspost the article.
6971 ((eq action 'crosspost)
6972 (let ((xref (message-tokenize-header
6973 (mail-header-xref (gnus-summary-article-header article))
6974 " ")))
6975 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6976 ":" article))
6977 (unless xref
6978 (setq xref (list (system-name))))
6979 (setq new-xref
6980 (concat
6981 (mapconcat 'identity
6982 (delete "Xref:" (delete new-xref xref))
6983 " ")
6984 " " new-xref))
6985 (save-excursion
6986 (set-buffer copy-buf)
6987 ;; First put the article in the destination group.
6988 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6989 (when (consp (setq art-group
6990 (gnus-request-accept-article
6991 to-newsgroup select-method (not articles))))
6992 (setq new-xref (concat new-xref " " (car art-group)
6993 ":" (cdr art-group)))
6994 ;; Now we have the new Xrefs header, so we insert
6995 ;; it and replace the new article.
6996 (nnheader-replace-header "Xref" new-xref)
6997 (gnus-request-replace-article
6998 (cdr art-group) to-newsgroup (current-buffer))
6999 art-group))))))
7000 (cond
7001 ((not art-group)
7002 (gnus-message 1 "Couldn't %s article %s"
7003 (cadr (assq action names)) article))
7004 ((and (eq art-group 'junk)
7005 (eq action 'move))
7006 (gnus-summary-mark-article article gnus-canceled-mark)
7007 (gnus-message 4 "Deleted article %s" article))
7008 (t
6748645f
LMI
7009 (let* ((pto-group (gnus-group-prefixed-name
7010 (car art-group) to-method))
7011 (entry
7012 (gnus-gethash pto-group gnus-newsrc-hashtb))
eec82323
LMI
7013 (info (nth 2 entry))
7014 (to-group (gnus-info-group info)))
7015 ;; Update the group that has been moved to.
7016 (when (and info
7017 (memq action '(move copy)))
7018 (unless (member to-group to-groups)
7019 (push to-group to-groups))
7020
7021 (unless (memq article gnus-newsgroup-unreads)
7022 (gnus-info-set-read
7023 info (gnus-add-to-range (gnus-info-read info)
7024 (list (cdr art-group)))))
7025
7026 ;; Copy any marks over to the new group.
7027 (let ((marks gnus-article-mark-lists)
7028 (to-article (cdr art-group)))
7029
7030 ;; See whether the article is to be put in the cache.
7031 (when gnus-use-cache
7032 (gnus-cache-possibly-enter-article
7033 to-group to-article
7034 (let ((header (copy-sequence
7035 (gnus-summary-article-header article))))
7036 (mail-header-set-number header to-article)
7037 header)
7038 (memq article gnus-newsgroup-marked)
7039 (memq article gnus-newsgroup-dormant)
7040 (memq article gnus-newsgroup-unreads)))
7041
7042 (when (and (equal to-group gnus-newsgroup-name)
7043 (not (memq article gnus-newsgroup-unreads)))
7044 ;; Mark this article as read in this group.
7045 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7046 (setcdr (gnus-active to-group) to-article)
7047 (setcdr gnus-newsgroup-active to-article))
7048
7049 (while marks
7050 (when (memq article (symbol-value
7051 (intern (format "gnus-newsgroup-%s"
7052 (caar marks)))))
7053 ;; If the other group is the same as this group,
7054 ;; then we have to add the mark to the list.
7055 (when (equal to-group gnus-newsgroup-name)
7056 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7057 (cons to-article
7058 (symbol-value
7059 (intern (format "gnus-newsgroup-%s"
7060 (caar marks)))))))
7061 ;; Copy the marks to other group.
7062 (gnus-add-marked-articles
7063 to-group (cdar marks) (list to-article) info))
7064 (setq marks (cdr marks)))
7065
7066 (gnus-dribble-enter
7067 (concat "(gnus-group-set-info '"
7068 (gnus-prin1-to-string (gnus-get-info to-group))
7069 ")"))))
7070
7071 ;; Update the Xref header in this article to point to
7072 ;; the new crossposted article we have just created.
7073 (when (eq action 'crosspost)
7074 (save-excursion
7075 (set-buffer copy-buf)
7076 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7077 (nnheader-replace-header "Xref" new-xref)
7078 (gnus-request-replace-article
7079 article gnus-newsgroup-name (current-buffer)))))
7080
6748645f
LMI
7081 ;;;!!!Why is this necessary?
7082 (set-buffer gnus-summary-buffer)
7083
eec82323
LMI
7084 (gnus-summary-goto-subject article)
7085 (when (eq action 'move)
7086 (gnus-summary-mark-article article gnus-canceled-mark))))
7087 (gnus-summary-remove-process-mark article))
7088 ;; Re-activate all groups that have been moved to.
7089 (while to-groups
7090 (save-excursion
7091 (set-buffer gnus-group-buffer)
7092 (when (gnus-group-goto-group (car to-groups) t)
a8151ef7 7093 (gnus-group-get-new-news-this-group 1 t))
eec82323
LMI
7094 (pop to-groups)))
7095
7096 (gnus-kill-buffer copy-buf)
7097 (gnus-summary-position-point)
7098 (gnus-set-mode-line 'summary)))
7099
7100(defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7101 "Move the current article to a different newsgroup.
7102If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7103If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7104re-spool using this method."
7105 (interactive "P")
7106 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7107
7108(defun gnus-summary-crosspost-article (&optional n)
7109 "Crosspost the current article to some other group."
7110 (interactive "P")
7111 (gnus-summary-move-article n nil nil 'crosspost))
7112
7113(defcustom gnus-summary-respool-default-method nil
7114 "Default method for respooling an article.
7115If nil, use to the current newsgroup method."
04ad70ac
KH
7116 :type '(choice (gnus-select-method :value (nnml ""))
7117 (const nil))
eec82323
LMI
7118 :group 'gnus-summary-mail)
7119
7120(defun gnus-summary-respool-article (&optional n method)
7121 "Respool the current article.
7122The article will be squeezed through the mail spooling process again,
7123which means that it will be put in some mail newsgroup or other
7124depending on `nnmail-split-methods'.
7125If N is a positive number, respool the N next articles.
7126If N is a negative number, respool the N previous articles.
7127If N is nil and any articles have been marked with the process mark,
7128respool those articles instead.
7129
7130Respooling can be done both from mail groups and \"real\" newsgroups.
7131In the former case, the articles in question will be moved from the
7132current group into whatever groups they are destined to. In the
7133latter case, they will be copied into the relevant groups."
7134 (interactive
7135 (list current-prefix-arg
7136 (let* ((methods (gnus-methods-using 'respool))
7137 (methname
7138 (symbol-name (or gnus-summary-respool-default-method
7139 (car (gnus-find-method-for-group
7140 gnus-newsgroup-name)))))
7141 (method
7142 (gnus-completing-read
7143 methname "What backend do you want to use when respooling?"
7144 methods nil t nil 'gnus-mail-method-history))
7145 ms)
7146 (cond
7147 ((zerop (length (setq ms (gnus-servers-using-backend
7148 (intern method)))))
7149 (list (intern method) ""))
7150 ((= 1 (length ms))
7151 (car ms))
7152 (t
7153 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7154 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7155 ms-alist))))))))
eec82323
LMI
7156 (unless method
7157 (error "No method given for respooling"))
7158 (if (assoc (symbol-name
7159 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7160 (gnus-methods-using 'respool))
7161 (gnus-summary-move-article n nil method)
7162 (gnus-summary-copy-article n nil method)))
7163
7164(defun gnus-summary-import-article (file)
6748645f 7165 "Import an arbitrary file into a mail newsgroup."
eec82323 7166 (interactive "fImport file: ")
eec82323
LMI
7167 (let ((group gnus-newsgroup-name)
7168 (now (current-time))
7169 atts lines)
7170 (unless (gnus-check-backend-function 'request-accept-article group)
7171 (error "%s does not support article importing" group))
7172 (or (file-readable-p file)
7173 (not (file-regular-p file))
7174 (error "Can't read %s" file))
7175 (save-excursion
6748645f 7176 (set-buffer (gnus-get-buffer-create " *import file*"))
eec82323
LMI
7177 (buffer-disable-undo (current-buffer))
7178 (erase-buffer)
7179 (insert-file-contents file)
7180 (goto-char (point-min))
7181 (unless (nnheader-article-p)
7182 ;; This doesn't look like an article, so we fudge some headers.
7183 (setq atts (file-attributes file)
7184 lines (count-lines (point-min) (point-max)))
7185 (insert "From: " (read-string "From: ") "\n"
7186 "Subject: " (read-string "Subject: ") "\n"
7187 "Date: " (timezone-make-date-arpa-standard
7188 (current-time-string (nth 5 atts))
7189 (current-time-zone now)
7190 (current-time-zone now))
7191 "\n"
7192 "Message-ID: " (message-make-message-id) "\n"
7193 "Lines: " (int-to-string lines) "\n"
7194 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7195 (gnus-request-accept-article group nil t)
7196 (kill-buffer (current-buffer)))))
7197
7198(defun gnus-summary-article-posted-p ()
7199 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7200This will be the case if the article has both been mailed and posted."
7201 (interactive)
7202 (let ((id (mail-header-references (gnus-summary-article-header)))
7203 (gnus-override-method
7204 (or gnus-refer-article-method gnus-select-method)))
7205 (if (gnus-request-head id "")
7206 (gnus-message 2 "The current message was found on %s"
7207 gnus-override-method)
7208 (gnus-message 2 "The current message couldn't be found on %s"
7209 gnus-override-method)
7210 nil)))
7211
7212(defun gnus-summary-expire-articles (&optional now)
7213 "Expire all articles that are marked as expirable in the current group."
7214 (interactive)
eec82323
LMI
7215 (when (gnus-check-backend-function
7216 'request-expire-articles gnus-newsgroup-name)
7217 ;; This backend supports expiry.
7218 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7219 (expirable (if total
7220 (progn
7221 ;; We need to update the info for
7222 ;; this group for `gnus-list-of-read-articles'
7223 ;; to give us the right answer.
6748645f 7224 (gnus-run-hooks 'gnus-exit-group-hook)
eec82323
LMI
7225 (gnus-summary-update-info)
7226 (gnus-list-of-read-articles gnus-newsgroup-name))
7227 (setq gnus-newsgroup-expirable
7228 (sort gnus-newsgroup-expirable '<))))
7229 (expiry-wait (if now 'immediate
7230 (gnus-group-find-parameter
7231 gnus-newsgroup-name 'expiry-wait)))
7232 es)
7233 (when expirable
7234 ;; There are expirable articles in this group, so we run them
7235 ;; through the expiry process.
7236 (gnus-message 6 "Expiring articles...")
7237 ;; The list of articles that weren't expired is returned.
6748645f
LMI
7238 (save-excursion
7239 (if expiry-wait
7240 (let ((nnmail-expiry-wait-function nil)
7241 (nnmail-expiry-wait expiry-wait))
7242 (setq es (gnus-request-expire-articles
7243 expirable gnus-newsgroup-name)))
7244 (setq es (gnus-request-expire-articles
7245 expirable gnus-newsgroup-name))))
eec82323
LMI
7246 (unless total
7247 (setq gnus-newsgroup-expirable es))
7248 ;; We go through the old list of expirable, and mark all
7249 ;; really expired articles as nonexistent.
7250 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7251 (let ((gnus-use-cache nil))
7252 (while expirable
7253 (unless (memq (car expirable) es)
7254 (when (gnus-data-find (car expirable))
7255 (gnus-summary-mark-article
7256 (car expirable) gnus-canceled-mark)))
7257 (setq expirable (cdr expirable)))))
7258 (gnus-message 6 "Expiring articles...done")))))
7259
7260(defun gnus-summary-expire-articles-now ()
7261 "Expunge all expirable articles in the current group.
7262This means that *all* articles that are marked as expirable will be
7263deleted forever, right now."
7264 (interactive)
eec82323
LMI
7265 (or gnus-expert-user
7266 (gnus-yes-or-no-p
7267 "Are you really, really, really sure you want to delete all these messages? ")
7268 (error "Phew!"))
7269 (gnus-summary-expire-articles t))
7270
7271;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7272(defun gnus-summary-delete-article (&optional n)
7273 "Delete the N next (mail) articles.
7274This command actually deletes articles. This is not a marking
7275command. The article will disappear forever from your life, never to
7276return.
7277If N is negative, delete backwards.
7278If N is nil and articles have been marked with the process mark,
7279delete these instead."
7280 (interactive "P")
eec82323
LMI
7281 (unless (gnus-check-backend-function 'request-expire-articles
7282 gnus-newsgroup-name)
a8151ef7 7283 (error "The current newsgroup does not support article deletion"))
eec82323 7284 ;; Compute the list of articles to delete.
6748645f 7285 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
eec82323
LMI
7286 not-deleted)
7287 (if (and gnus-novice-user
7288 (not (gnus-yes-or-no-p
7289 (format "Do you really want to delete %s forever? "
7290 (if (> (length articles) 1)
7291 (format "these %s articles" (length articles))
7292 "this article")))))
7293 ()
7294 ;; Delete the articles.
7295 (setq not-deleted (gnus-request-expire-articles
7296 articles gnus-newsgroup-name 'force))
7297 (while articles
7298 (gnus-summary-remove-process-mark (car articles))
7299 ;; The backend might not have been able to delete the article
7300 ;; after all.
7301 (unless (memq (car articles) not-deleted)
7302 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7303 (setq articles (cdr articles)))
7304 (when not-deleted
7305 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7306 (gnus-summary-position-point)
7307 (gnus-set-mode-line 'summary)
7308 not-deleted))
7309
7310(defun gnus-summary-edit-article (&optional force)
7311 "Edit the current article.
7312This will have permanent effect only in mail groups.
7313If FORCE is non-nil, allow editing of articles even in read-only
7314groups."
7315 (interactive "P")
7316 (save-excursion
7317 (set-buffer gnus-summary-buffer)
7318 (gnus-set-global-variables)
7319 (when (and (not force)
7320 (gnus-group-read-only-p))
a8151ef7 7321 (error "The current newsgroup does not support article editing"))
eec82323
LMI
7322 ;; Select article if needed.
7323 (unless (eq (gnus-summary-article-number)
7324 gnus-current-article)
7325 (gnus-summary-select-article t))
a8151ef7 7326 (gnus-article-date-original)
eec82323 7327 (gnus-article-edit-article
6748645f 7328 `(lambda (no-highlight)
eec82323
LMI
7329 (gnus-summary-edit-article-done
7330 ,(or (mail-header-references gnus-current-headers) "")
6748645f 7331 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))
eec82323
LMI
7332
7333(defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7334
6748645f
LMI
7335(defun gnus-summary-edit-article-done (&optional references read-only buffer
7336 no-highlight)
eec82323
LMI
7337 "Make edits to the current article permanent."
7338 (interactive)
7339 ;; Replace the article.
6748645f
LMI
7340 (let ((buf (current-buffer)))
7341 (nnheader-temp-write nil
7342 (insert-buffer buf)
7343 (if (and (not read-only)
7344 (not (gnus-request-replace-article
7345 (cdr gnus-article-current) (car gnus-article-current)
7346 (current-buffer))))
7347 (error "Couldn't replace article")
7348 ;; Update the summary buffer.
7349 (if (and references
7350 (equal (message-tokenize-header references " ")
7351 (message-tokenize-header
7352 (or (message-fetch-field "references") "") " ")))
7353 ;; We only have to update this line.
7354 (save-excursion
7355 (save-restriction
7356 (message-narrow-to-head)
7357 (let ((head (buffer-string))
7358 header)
7359 (nnheader-temp-write nil
7360 (insert (format "211 %d Article retrieved.\n"
7361 (cdr gnus-article-current)))
7362 (insert head)
7363 (insert ".\n")
7364 (let ((nntp-server-buffer (current-buffer)))
7365 (setq header (car (gnus-get-newsgroup-headers
7366 (save-excursion
7367 (set-buffer gnus-summary-buffer)
7368 gnus-newsgroup-dependencies)
7369 t))))
7370 (save-excursion
7371 (set-buffer gnus-summary-buffer)
7372 (gnus-data-set-header
7373 (gnus-data-find (cdr gnus-article-current))
7374 header)
7375 (gnus-summary-update-article-line
7376 (cdr gnus-article-current) header))))))
7377 ;; Update threads.
7378 (set-buffer (or buffer gnus-summary-buffer))
7379 (gnus-summary-update-article (cdr gnus-article-current)))
7380 ;; Prettify the article buffer again.
7381 (unless no-highlight
7382 (save-excursion
7383 (set-buffer gnus-article-buffer)
7384 (gnus-run-hooks 'gnus-article-display-hook)
7385 (set-buffer gnus-original-article-buffer)
7386 (gnus-request-article
7387 (cdr gnus-article-current)
7388 (car gnus-article-current) (current-buffer))))
7389 ;; Prettify the summary buffer line.
7390 (when (gnus-visual-p 'summary-highlight 'highlight)
7391 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
eec82323
LMI
7392
7393(defun gnus-summary-edit-wash (key)
6748645f 7394 "Perform editing command KEY in the article buffer."
eec82323
LMI
7395 (interactive
7396 (list
7397 (progn
7398 (message "%s" (concat (this-command-keys) "- "))
7399 (read-char))))
7400 (message "")
7401 (gnus-summary-edit-article)
7402 (execute-kbd-macro (concat (this-command-keys) key))
7403 (gnus-article-edit-done))
7404
7405;;; Respooling
7406
6748645f 7407(defun gnus-summary-respool-query (&optional silent trace)
eec82323
LMI
7408 "Query where the respool algorithm would put this article."
7409 (interactive)
eec82323
LMI
7410 (let (gnus-mark-article-hook)
7411 (gnus-summary-select-article)
7412 (save-excursion
7413 (set-buffer gnus-original-article-buffer)
7414 (save-restriction
7415 (message-narrow-to-head)
6748645f 7416 (let ((groups (nnmail-article-group 'identity trace)))
eec82323
LMI
7417 (unless silent
7418 (if groups
7419 (message "This message would go to %s"
7420 (mapconcat 'car groups ", "))
7421 (message "This message would go to no groups"))
7422 groups))))))
7423
6748645f
LMI
7424(defun gnus-summary-respool-trace ()
7425 "Trace where the respool algorithm would put this article.
7426Display a buffer showing all fancy splitting patterns which matched."
7427 (interactive)
7428 (gnus-summary-respool-query nil t))
7429
eec82323
LMI
7430;; Summary marking commands.
7431
7432(defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7433 "Mark articles which has the same subject as read, and then select the next.
7434If UNMARK is positive, remove any kind of mark.
7435If UNMARK is negative, tick articles."
7436 (interactive "P")
eec82323
LMI
7437 (when unmark
7438 (setq unmark (prefix-numeric-value unmark)))
7439 (let ((count
7440 (gnus-summary-mark-same-subject
7441 (gnus-summary-article-subject) unmark)))
7442 ;; Select next unread article. If auto-select-same mode, should
7443 ;; select the first unread article.
7444 (gnus-summary-next-article t (and gnus-auto-select-same
7445 (gnus-summary-article-subject)))
7446 (gnus-message 7 "%d article%s marked as %s"
7447 count (if (= count 1) " is" "s are")
7448 (if unmark "unread" "read"))))
7449
7450(defun gnus-summary-kill-same-subject (&optional unmark)
7451 "Mark articles which has the same subject as read.
7452If UNMARK is positive, remove any kind of mark.
7453If UNMARK is negative, tick articles."
7454 (interactive "P")
eec82323
LMI
7455 (when unmark
7456 (setq unmark (prefix-numeric-value unmark)))
7457 (let ((count
7458 (gnus-summary-mark-same-subject
7459 (gnus-summary-article-subject) unmark)))
7460 ;; If marked as read, go to next unread subject.
7461 (when (null unmark)
7462 ;; Go to next unread subject.
7463 (gnus-summary-next-subject 1 t))
7464 (gnus-message 7 "%d articles are marked as %s"
7465 count (if unmark "unread" "read"))))
7466
7467(defun gnus-summary-mark-same-subject (subject &optional unmark)
7468 "Mark articles with same SUBJECT as read, and return marked number.
7469If optional argument UNMARK is positive, remove any kinds of marks.
7470If optional argument UNMARK is negative, mark articles as unread instead."
7471 (let ((count 1))
7472 (save-excursion
7473 (cond
7474 ((null unmark) ; Mark as read.
7475 (while (and
7476 (progn
7477 (gnus-summary-mark-article-as-read gnus-killed-mark)
7478 (gnus-summary-show-thread) t)
7479 (gnus-summary-find-subject subject))
7480 (setq count (1+ count))))
7481 ((> unmark 0) ; Tick.
7482 (while (and
7483 (progn
7484 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7485 (gnus-summary-show-thread) t)
7486 (gnus-summary-find-subject subject))
7487 (setq count (1+ count))))
7488 (t ; Mark as unread.
7489 (while (and
7490 (progn
7491 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7492 (gnus-summary-show-thread) t)
7493 (gnus-summary-find-subject subject))
7494 (setq count (1+ count)))))
7495 (gnus-set-mode-line 'summary)
7496 ;; Return the number of marked articles.
7497 count)))
7498
7499(defun gnus-summary-mark-as-processable (n &optional unmark)
7500 "Set the process mark on the next N articles.
7501If N is negative, mark backward instead. If UNMARK is non-nil, remove
7502the process mark instead. The difference between N and the actual
7503number of articles marked is returned."
7504 (interactive "p")
eec82323
LMI
7505 (let ((backward (< n 0))
7506 (n (abs n)))
7507 (while (and
7508 (> n 0)
7509 (if unmark
7510 (gnus-summary-remove-process-mark
7511 (gnus-summary-article-number))
7512 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7513 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7514 (setq n (1- n)))
7515 (when (/= 0 n)
7516 (gnus-message 7 "No more articles"))
7517 (gnus-summary-recenter)
7518 (gnus-summary-position-point)
7519 n))
7520
7521(defun gnus-summary-unmark-as-processable (n)
7522 "Remove the process mark from the next N articles.
6748645f
LMI
7523If N is negative, unmark backward instead. The difference between N and
7524the actual number of articles unmarked is returned."
eec82323 7525 (interactive "p")
eec82323
LMI
7526 (gnus-summary-mark-as-processable n t))
7527
7528(defun gnus-summary-unmark-all-processable ()
7529 "Remove the process mark from all articles."
7530 (interactive)
eec82323
LMI
7531 (save-excursion
7532 (while gnus-newsgroup-processable
7533 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7534 (gnus-summary-position-point))
7535
7536(defun gnus-summary-mark-as-expirable (n)
7537 "Mark N articles forward as expirable.
7538If N is negative, mark backward instead. The difference between N and
7539the actual number of articles marked is returned."
7540 (interactive "p")
eec82323
LMI
7541 (gnus-summary-mark-forward n gnus-expirable-mark))
7542
7543(defun gnus-summary-mark-article-as-replied (article)
7544 "Mark ARTICLE replied and update the summary line."
7545 (push article gnus-newsgroup-replied)
7546 (let ((buffer-read-only nil))
7547 (when (gnus-summary-goto-subject article)
7548 (gnus-summary-update-secondary-mark article))))
7549
7550(defun gnus-summary-set-bookmark (article)
7551 "Set a bookmark in current article."
7552 (interactive (list (gnus-summary-article-number)))
eec82323
LMI
7553 (when (or (not (get-buffer gnus-article-buffer))
7554 (not gnus-current-article)
7555 (not gnus-article-current)
7556 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7557 (error "No current article selected"))
7558 ;; Remove old bookmark, if one exists.
7559 (let ((old (assq article gnus-newsgroup-bookmarks)))
7560 (when old
7561 (setq gnus-newsgroup-bookmarks
7562 (delq old gnus-newsgroup-bookmarks))))
7563 ;; Set the new bookmark, which is on the form
7564 ;; (article-number . line-number-in-body).
7565 (push
7566 (cons article
7567 (save-excursion
7568 (set-buffer gnus-article-buffer)
7569 (count-lines
7570 (min (point)
7571 (save-excursion
7572 (goto-char (point-min))
7573 (search-forward "\n\n" nil t)
7574 (point)))
7575 (point))))
7576 gnus-newsgroup-bookmarks)
7577 (gnus-message 6 "A bookmark has been added to the current article."))
7578
7579(defun gnus-summary-remove-bookmark (article)
7580 "Remove the bookmark from the current article."
7581 (interactive (list (gnus-summary-article-number)))
eec82323
LMI
7582 ;; Remove old bookmark, if one exists.
7583 (let ((old (assq article gnus-newsgroup-bookmarks)))
7584 (if old
7585 (progn
7586 (setq gnus-newsgroup-bookmarks
7587 (delq old gnus-newsgroup-bookmarks))
7588 (gnus-message 6 "Removed bookmark."))
7589 (gnus-message 6 "No bookmark in current article."))))
7590
7591;; Suggested by Daniel Quinlan <quinlan@best.com>.
7592(defun gnus-summary-mark-as-dormant (n)
7593 "Mark N articles forward as dormant.
7594If N is negative, mark backward instead. The difference between N and
7595the actual number of articles marked is returned."
7596 (interactive "p")
eec82323
LMI
7597 (gnus-summary-mark-forward n gnus-dormant-mark))
7598
7599(defun gnus-summary-set-process-mark (article)
7600 "Set the process mark on ARTICLE and update the summary line."
7601 (setq gnus-newsgroup-processable
7602 (cons article
7603 (delq article gnus-newsgroup-processable)))
7604 (when (gnus-summary-goto-subject article)
7605 (gnus-summary-show-thread)
6748645f 7606 (gnus-summary-goto-subject article)
eec82323
LMI
7607 (gnus-summary-update-secondary-mark article)))
7608
7609(defun gnus-summary-remove-process-mark (article)
7610 "Remove the process mark from ARTICLE and update the summary line."
7611 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7612 (when (gnus-summary-goto-subject article)
7613 (gnus-summary-show-thread)
6748645f 7614 (gnus-summary-goto-subject article)
eec82323
LMI
7615 (gnus-summary-update-secondary-mark article)))
7616
7617(defun gnus-summary-set-saved-mark (article)
7618 "Set the process mark on ARTICLE and update the summary line."
7619 (push article gnus-newsgroup-saved)
7620 (when (gnus-summary-goto-subject article)
7621 (gnus-summary-update-secondary-mark article)))
7622
7623(defun gnus-summary-mark-forward (n &optional mark no-expire)
7624 "Mark N articles as read forwards.
7625If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7626The difference between N and the actual number of articles marked is
7627returned."
7628 (interactive "p")
eec82323
LMI
7629 (let ((backward (< n 0))
7630 (gnus-summary-goto-unread
7631 (and gnus-summary-goto-unread
7632 (not (eq gnus-summary-goto-unread 'never))
7633 (not (memq mark (list gnus-unread-mark
7634 gnus-ticked-mark gnus-dormant-mark)))))
7635 (n (abs n))
7636 (mark (or mark gnus-del-mark)))
7637 (while (and (> n 0)
7638 (gnus-summary-mark-article nil mark no-expire)
7639 (zerop (gnus-summary-next-subject
7640 (if backward -1 1)
7641 (and gnus-summary-goto-unread
7642 (not (eq gnus-summary-goto-unread 'never)))
7643 t)))
7644 (setq n (1- n)))
7645 (when (/= 0 n)
7646 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7647 (gnus-summary-recenter)
7648 (gnus-summary-position-point)
7649 (gnus-set-mode-line 'summary)
7650 n))
7651
7652(defun gnus-summary-mark-article-as-read (mark)
7653 "Mark the current article quickly as read with MARK."
7654 (let ((article (gnus-summary-article-number)))
7655 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7656 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7657 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7658 (push (cons article mark) gnus-newsgroup-reads)
7659 ;; Possibly remove from cache, if that is used.
7660 (when gnus-use-cache
7661 (gnus-cache-enter-remove-article article))
7662 ;; Allow the backend to change the mark.
7663 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7664 ;; Check for auto-expiry.
7665 (when (and gnus-newsgroup-auto-expire
7666 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7667 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7668 (= mark gnus-ancient-mark)
7669 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7670 (= mark gnus-duplicate-mark)))
7671 (setq mark gnus-expirable-mark)
6748645f
LMI
7672 ;; Let the backend know about the mark change.
7673 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
eec82323
LMI
7674 (push article gnus-newsgroup-expirable))
7675 ;; Set the mark in the buffer.
7676 (gnus-summary-update-mark mark 'unread)
7677 t))
7678
7679(defun gnus-summary-mark-article-as-unread (mark)
7680 "Mark the current article quickly as unread with MARK."
6748645f
LMI
7681 (let* ((article (gnus-summary-article-number))
7682 (old-mark (gnus-summary-article-mark article)))
7683 ;; Allow the backend to change the mark.
7684 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7685 (if (eq mark old-mark)
7686 t
7687 (if (<= article 0)
7688 (progn
7689 (gnus-error 1 "Can't mark negative article numbers")
7690 nil)
7691 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7692 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7693 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7694 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7695 (cond ((= mark gnus-ticked-mark)
7696 (push article gnus-newsgroup-marked))
7697 ((= mark gnus-dormant-mark)
7698 (push article gnus-newsgroup-dormant))
7699 (t
7700 (push article gnus-newsgroup-unreads)))
7701 (gnus-pull article gnus-newsgroup-reads)
eec82323 7702
6748645f
LMI
7703 ;; See whether the article is to be put in the cache.
7704 (and gnus-use-cache
7705 (vectorp (gnus-summary-article-header article))
7706 (save-excursion
7707 (gnus-cache-possibly-enter-article
7708 gnus-newsgroup-name article
7709 (gnus-summary-article-header article)
7710 (= mark gnus-ticked-mark)
7711 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7712
7713 ;; Fix the mark.
7714 (gnus-summary-update-mark mark 'unread)
7715 t))))
eec82323
LMI
7716
7717(defun gnus-summary-mark-article (&optional article mark no-expire)
7718 "Mark ARTICLE with MARK. MARK can be any character.
7719Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7720`??' (dormant) and `?E' (expirable).
7721If MARK is nil, then the default character `?D' is used.
7722If ARTICLE is nil, then the article on the current line will be
7723marked."
7724 ;; The mark might be a string.
7725 (when (stringp mark)
7726 (setq mark (aref mark 0)))
7727 ;; If no mark is given, then we check auto-expiring.
7728 (and (not no-expire)
7729 gnus-newsgroup-auto-expire
7730 (or (not mark)
7731 (and (gnus-characterp mark)
7732 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7733 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7734 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7735 (= mark gnus-duplicate-mark))))
7736 (setq mark gnus-expirable-mark))
7737 (let* ((mark (or mark gnus-del-mark))
6748645f
LMI
7738 (article (or article (gnus-summary-article-number)))
7739 (old-mark (gnus-summary-article-mark article)))
7740 ;; Allow the backend to change the mark.
7741 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7742 (if (eq mark old-mark)
7743 t
7744 (unless article
7745 (error "No article on current line"))
7746 (if (not (if (or (= mark gnus-unread-mark)
7747 (= mark gnus-ticked-mark)
7748 (= mark gnus-dormant-mark))
7749 (gnus-mark-article-as-unread article mark)
7750 (gnus-mark-article-as-read article mark)))
7751 t
7752 ;; See whether the article is to be put in the cache.
7753 (and gnus-use-cache
7754 (not (= mark gnus-canceled-mark))
7755 (vectorp (gnus-summary-article-header article))
7756 (save-excursion
7757 (gnus-cache-possibly-enter-article
7758 gnus-newsgroup-name article
7759 (gnus-summary-article-header article)
7760 (= mark gnus-ticked-mark)
7761 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7762
7763 (when (gnus-summary-goto-subject article nil t)
7764 (let ((buffer-read-only nil))
7765 (gnus-summary-show-thread)
7766 ;; Fix the mark.
7767 (gnus-summary-update-mark mark 'unread)
7768 t))))))
eec82323
LMI
7769
7770(defun gnus-summary-update-secondary-mark (article)
7771 "Update the secondary (read, process, cache) mark."
7772 (gnus-summary-update-mark
7773 (cond ((memq article gnus-newsgroup-processable)
7774 gnus-process-mark)
7775 ((memq article gnus-newsgroup-cached)
7776 gnus-cached-mark)
7777 ((memq article gnus-newsgroup-replied)
7778 gnus-replied-mark)
7779 ((memq article gnus-newsgroup-saved)
7780 gnus-saved-mark)
7781 (t gnus-unread-mark))
7782 'replied)
7783 (when (gnus-visual-p 'summary-highlight 'highlight)
6748645f 7784 (gnus-run-hooks 'gnus-summary-update-hook))
eec82323
LMI
7785 t)
7786
7787(defun gnus-summary-update-mark (mark type)
7788 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7789 (buffer-read-only nil))
7790 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7791 (when (looking-at "\r")
7792 (incf forward))
7793 (when (and forward
7794 (<= (+ forward (point)) (point-max)))
7795 ;; Go to the right position on the line.
7796 (goto-char (+ forward (point)))
7797 ;; Replace the old mark with the new mark.
7798 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7799 ;; Optionally update the marks by some user rule.
7800 (when (eq type 'unread)
7801 (gnus-data-set-mark
7802 (gnus-data-find (gnus-summary-article-number)) mark)
7803 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7804
7805(defun gnus-mark-article-as-read (article &optional mark)
7806 "Enter ARTICLE in the pertinent lists and remove it from others."
7807 ;; Make the article expirable.
7808 (let ((mark (or mark gnus-del-mark)))
7809 (if (= mark gnus-expirable-mark)
7810 (push article gnus-newsgroup-expirable)
7811 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7812 ;; Remove from unread and marked lists.
7813 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7814 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7815 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7816 (push (cons article mark) gnus-newsgroup-reads)
7817 ;; Possibly remove from cache, if that is used.
7818 (when gnus-use-cache
6748645f
LMI
7819 (gnus-cache-enter-remove-article article))
7820 t))
eec82323
LMI
7821
7822(defun gnus-mark-article-as-unread (article &optional mark)
7823 "Enter ARTICLE in the pertinent lists and remove it from others."
7824 (let ((mark (or mark gnus-ticked-mark)))
6748645f
LMI
7825 (if (<= article 0)
7826 (progn
7827 (gnus-error 1 "Can't mark negative article numbers")
7828 nil)
7829 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7830 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7831 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7832 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
eec82323 7833
6748645f
LMI
7834 ;; Unsuppress duplicates?
7835 (when gnus-suppress-duplicates
7836 (gnus-dup-unsuppress-article article))
7837
7838 (cond ((= mark gnus-ticked-mark)
7839 (push article gnus-newsgroup-marked))
7840 ((= mark gnus-dormant-mark)
7841 (push article gnus-newsgroup-dormant))
7842 (t
7843 (push article gnus-newsgroup-unreads)))
7844 (gnus-pull article gnus-newsgroup-reads)
7845 t)))
eec82323
LMI
7846
7847(defalias 'gnus-summary-mark-as-unread-forward
7848 'gnus-summary-tick-article-forward)
7849(make-obsolete 'gnus-summary-mark-as-unread-forward
7850 'gnus-summary-tick-article-forward)
7851(defun gnus-summary-tick-article-forward (n)
7852 "Tick N articles forwards.
7853If N is negative, tick backwards instead.
7854The difference between N and the number of articles ticked is returned."
7855 (interactive "p")
7856 (gnus-summary-mark-forward n gnus-ticked-mark))
7857
7858(defalias 'gnus-summary-mark-as-unread-backward
7859 'gnus-summary-tick-article-backward)
7860(make-obsolete 'gnus-summary-mark-as-unread-backward
7861 'gnus-summary-tick-article-backward)
7862(defun gnus-summary-tick-article-backward (n)
7863 "Tick N articles backwards.
7864The difference between N and the number of articles ticked is returned."
7865 (interactive "p")
7866 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7867
7868(defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7869(make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7870(defun gnus-summary-tick-article (&optional article clear-mark)
7871 "Mark current article as unread.
7872Optional 1st argument ARTICLE specifies article number to be marked as unread.
7873Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7874 (interactive)
7875 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7876 gnus-ticked-mark)))
7877
7878(defun gnus-summary-mark-as-read-forward (n)
7879 "Mark N articles as read forwards.
7880If N is negative, mark backwards instead.
7881The difference between N and the actual number of articles marked is
7882returned."
7883 (interactive "p")
7884 (gnus-summary-mark-forward n gnus-del-mark t))
7885
7886(defun gnus-summary-mark-as-read-backward (n)
7887 "Mark the N articles as read backwards.
7888The difference between N and the actual number of articles marked is
7889returned."
7890 (interactive "p")
7891 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7892
7893(defun gnus-summary-mark-as-read (&optional article mark)
7894 "Mark current article as read.
7895ARTICLE specifies the article to be marked as read.
7896MARK specifies a string to be inserted at the beginning of the line."
7897 (gnus-summary-mark-article article mark))
7898
7899(defun gnus-summary-clear-mark-forward (n)
7900 "Clear marks from N articles forward.
7901If N is negative, clear backward instead.
7902The difference between N and the number of marks cleared is returned."
7903 (interactive "p")
7904 (gnus-summary-mark-forward n gnus-unread-mark))
7905
7906(defun gnus-summary-clear-mark-backward (n)
7907 "Clear marks from N articles backward.
7908The difference between N and the number of marks cleared is returned."
7909 (interactive "p")
7910 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7911
7912(defun gnus-summary-mark-unread-as-read ()
7913 "Intended to be used by `gnus-summary-mark-article-hook'."
7914 (when (memq gnus-current-article gnus-newsgroup-unreads)
7915 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7916
7917(defun gnus-summary-mark-read-and-unread-as-read ()
7918 "Intended to be used by `gnus-summary-mark-article-hook'."
7919 (let ((mark (gnus-summary-article-mark)))
7920 (when (or (gnus-unread-mark-p mark)
7921 (gnus-read-mark-p mark))
7922 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7923
7924(defun gnus-summary-mark-region-as-read (point mark all)
7925 "Mark all unread articles between point and mark as read.
7926If given a prefix, mark all articles between point and mark as read,
7927even ticked and dormant ones."
7928 (interactive "r\nP")
7929 (save-excursion
7930 (let (article)
7931 (goto-char point)
7932 (beginning-of-line)
7933 (while (and
7934 (< (point) mark)
7935 (progn
7936 (when (or all
7937 (memq (setq article (gnus-summary-article-number))
7938 gnus-newsgroup-unreads))
7939 (gnus-summary-mark-article article gnus-del-mark))
7940 t)
7941 (gnus-summary-find-next))))))
7942
7943(defun gnus-summary-mark-below (score mark)
7944 "Mark articles with score less than SCORE with MARK."
7945 (interactive "P\ncMark: ")
eec82323
LMI
7946 (setq score (if score
7947 (prefix-numeric-value score)
7948 (or gnus-summary-default-score 0)))
7949 (save-excursion
7950 (set-buffer gnus-summary-buffer)
7951 (goto-char (point-min))
7952 (while
7953 (progn
7954 (and (< (gnus-summary-article-score) score)
7955 (gnus-summary-mark-article nil mark))
7956 (gnus-summary-find-next)))))
7957
7958(defun gnus-summary-kill-below (&optional score)
7959 "Mark articles with score below SCORE as read."
7960 (interactive "P")
eec82323
LMI
7961 (gnus-summary-mark-below score gnus-killed-mark))
7962
7963(defun gnus-summary-clear-above (&optional score)
7964 "Clear all marks from articles with score above SCORE."
7965 (interactive "P")
eec82323
LMI
7966 (gnus-summary-mark-above score gnus-unread-mark))
7967
7968(defun gnus-summary-tick-above (&optional score)
7969 "Tick all articles with score above SCORE."
7970 (interactive "P")
eec82323
LMI
7971 (gnus-summary-mark-above score gnus-ticked-mark))
7972
7973(defun gnus-summary-mark-above (score mark)
7974 "Mark articles with score over SCORE with MARK."
7975 (interactive "P\ncMark: ")
eec82323
LMI
7976 (setq score (if score
7977 (prefix-numeric-value score)
7978 (or gnus-summary-default-score 0)))
7979 (save-excursion
7980 (set-buffer gnus-summary-buffer)
7981 (goto-char (point-min))
7982 (while (and (progn
7983 (when (> (gnus-summary-article-score) score)
7984 (gnus-summary-mark-article nil mark))
7985 t)
7986 (gnus-summary-find-next)))))
7987
7988;; Suggested by Daniel Quinlan <quinlan@best.com>.
7989(defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7990(defun gnus-summary-limit-include-expunged (&optional no-error)
7991 "Display all the hidden articles that were expunged for low scores."
7992 (interactive)
eec82323
LMI
7993 (let ((buffer-read-only nil))
7994 (let ((scored gnus-newsgroup-scored)
7995 headers h)
7996 (while scored
7997 (unless (gnus-summary-goto-subject (caar scored))
7998 (and (setq h (gnus-summary-article-header (caar scored)))
7999 (< (cdar scored) gnus-summary-expunge-below)
8000 (push h headers)))
8001 (setq scored (cdr scored)))
8002 (if (not headers)
8003 (when (not no-error)
a8151ef7 8004 (error "No expunged articles hidden"))
eec82323
LMI
8005 (goto-char (point-min))
8006 (gnus-summary-prepare-unthreaded (nreverse headers))
8007 (goto-char (point-min))
8008 (gnus-summary-position-point)
8009 t))))
8010
8011(defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8012 "Mark all unread articles in this newsgroup as read.
8013If prefix argument ALL is non-nil, ticked and dormant articles will
8014also be marked as read.
8015If QUIETLY is non-nil, no questions will be asked.
8016If TO-HERE is non-nil, it should be a point in the buffer. All
8017articles before this point will be marked as read.
8018Note that this function will only catch up the unread article
8019in the current summary buffer limitation.
8020The number of articles marked as read is returned."
8021 (interactive "P")
eec82323
LMI
8022 (prog1
8023 (save-excursion
8024 (when (or quietly
8025 (not gnus-interactive-catchup) ;Without confirmation?
8026 gnus-expert-user
8027 (gnus-y-or-n-p
8028 (if all
8029 "Mark absolutely all articles as read? "
8030 "Mark all unread articles as read? ")))
8031 (if (and not-mark
8032 (not gnus-newsgroup-adaptive)
8033 (not gnus-newsgroup-auto-expire)
a8151ef7
LMI
8034 (not gnus-suppress-duplicates)
8035 (or (not gnus-use-cache)
6748645f 8036 (eq gnus-use-cache 'passive)))
eec82323
LMI
8037 (progn
8038 (when all
8039 (setq gnus-newsgroup-marked nil
8040 gnus-newsgroup-dormant nil))
6748645f 8041 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
eec82323
LMI
8042 ;; We actually mark all articles as canceled, which we
8043 ;; have to do when using auto-expiry or adaptive scoring.
8044 (gnus-summary-show-all-threads)
6748645f 8045 (when (gnus-summary-first-subject (not all) t)
eec82323
LMI
8046 (while (and
8047 (if to-here (< (point) to-here) t)
8048 (gnus-summary-mark-article-as-read gnus-catchup-mark)
6748645f 8049 (gnus-summary-find-next (not all) nil nil t))))
eec82323
LMI
8050 (gnus-set-mode-line 'summary))
8051 t))
8052 (gnus-summary-position-point)))
8053
8054(defun gnus-summary-catchup-to-here (&optional all)
8055 "Mark all unticked articles before the current one as read.
8056If ALL is non-nil, also mark ticked and dormant articles as read."
8057 (interactive "P")
eec82323
LMI
8058 (save-excursion
8059 (gnus-save-hidden-threads
8060 (let ((beg (point)))
8061 ;; We check that there are unread articles.
8062 (when (or all (gnus-summary-find-prev))
8063 (gnus-summary-catchup all t beg)))))
8064 (gnus-summary-position-point))
8065
8066(defun gnus-summary-catchup-all (&optional quietly)
8067 "Mark all articles in this newsgroup as read."
8068 (interactive "P")
eec82323
LMI
8069 (gnus-summary-catchup t quietly))
8070
8071(defun gnus-summary-catchup-and-exit (&optional all quietly)
8072 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8073If prefix argument ALL is non-nil, all articles are marked as read."
8074 (interactive "P")
eec82323
LMI
8075 (when (gnus-summary-catchup all quietly nil 'fast)
8076 ;; Select next newsgroup or exit.
6748645f
LMI
8077 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8078 (eq gnus-auto-select-next 'quietly))
eec82323
LMI
8079 (gnus-summary-next-group nil)
8080 (gnus-summary-exit))))
8081
8082(defun gnus-summary-catchup-all-and-exit (&optional quietly)
8083 "Mark all articles in this newsgroup as read, and then exit."
8084 (interactive "P")
eec82323
LMI
8085 (gnus-summary-catchup-and-exit t quietly))
8086
8087;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8088(defun gnus-summary-catchup-and-goto-next-group (&optional all)
8089 "Mark all articles in this group as read and select the next group.
8090If given a prefix, mark all articles, unread as well as ticked, as
8091read."
8092 (interactive "P")
eec82323
LMI
8093 (save-excursion
8094 (gnus-summary-catchup all))
8095 (gnus-summary-next-article t nil nil t))
8096
8097;; Thread-based commands.
8098
8099(defun gnus-summary-articles-in-thread (&optional article)
8100 "Return a list of all articles in the current thread.
8101If ARTICLE is non-nil, return all articles in the thread that starts
8102with that article."
8103 (let* ((article (or article (gnus-summary-article-number)))
8104 (data (gnus-data-find-list article))
8105 (top-level (gnus-data-level (car data)))
8106 (top-subject
8107 (cond ((null gnus-thread-operation-ignore-subject)
8108 (gnus-simplify-subject-re
8109 (mail-header-subject (gnus-data-header (car data)))))
8110 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8111 (gnus-simplify-subject-fuzzy
8112 (mail-header-subject (gnus-data-header (car data)))))
8113 (t nil)))
8114 (end-point (save-excursion
8115 (if (gnus-summary-go-to-next-thread)
8116 (point) (point-max))))
8117 articles)
8118 (while (and data
8119 (< (gnus-data-pos (car data)) end-point))
8120 (when (or (not top-subject)
8121 (string= top-subject
8122 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8123 (gnus-simplify-subject-fuzzy
8124 (mail-header-subject
8125 (gnus-data-header (car data))))
8126 (gnus-simplify-subject-re
8127 (mail-header-subject
8128 (gnus-data-header (car data)))))))
8129 (push (gnus-data-number (car data)) articles))
8130 (unless (and (setq data (cdr data))
8131 (> (gnus-data-level (car data)) top-level))
8132 (setq data nil)))
8133 ;; Return the list of articles.
8134 (nreverse articles)))
8135
8136(defun gnus-summary-rethread-current ()
8137 "Rethread the thread the current article is part of."
8138 (interactive)
eec82323
LMI
8139 (let* ((gnus-show-threads t)
8140 (article (gnus-summary-article-number))
8141 (id (mail-header-id (gnus-summary-article-header)))
8142 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8143 (unless id
8144 (error "No article on the current line"))
8145 (gnus-rebuild-thread id)
8146 (gnus-summary-goto-subject article)))
8147
8148(defun gnus-summary-reparent-thread ()
8149 "Make the current article child of the marked (or previous) article.
8150
8151Note that the re-threading will only work if `gnus-thread-ignore-subject'
8152is non-nil or the Subject: of both articles are the same."
8153 (interactive)
8154 (unless (not (gnus-group-read-only-p))
a8151ef7 8155 (error "The current newsgroup does not support article editing"))
eec82323 8156 (unless (<= (length gnus-newsgroup-processable) 1)
a8151ef7 8157 (error "No more than one article may be marked"))
eec82323
LMI
8158 (save-window-excursion
8159 (let ((gnus-article-buffer " *reparent*")
8160 (current-article (gnus-summary-article-number))
8161 ;; First grab the marked article, otherwise one line up.
8162 (parent-article (if (not (null gnus-newsgroup-processable))
8163 (car gnus-newsgroup-processable)
8164 (save-excursion
8165 (if (eq (forward-line -1) 0)
8166 (gnus-summary-article-number)
a8151ef7 8167 (error "Beginning of summary buffer"))))))
eec82323 8168 (unless (not (eq current-article parent-article))
a8151ef7 8169 (error "An article may not be self-referential"))
eec82323
LMI
8170 (let ((message-id (mail-header-id
8171 (gnus-summary-article-header parent-article))))
8172 (unless (and message-id (not (equal message-id "")))
a8151ef7 8173 (error "No message-id in desired parent"))
6748645f
LMI
8174 ;; We don't want the article to be marked as read.
8175 (let (gnus-mark-article-hook)
8176 (gnus-summary-select-article t t nil current-article))
eec82323
LMI
8177 (set-buffer gnus-original-article-buffer)
8178 (let ((buf (format "%s" (buffer-string))))
8179 (nnheader-temp-write nil
8180 (insert buf)
8181 (goto-char (point-min))
6748645f
LMI
8182 (if (re-search-forward "^References: " nil t)
8183 (progn
8184 (re-search-forward "^[^ \t]" nil t)
8185 (forward-line -1)
8186 (end-of-line)
8187 (insert " " message-id))
eec82323
LMI
8188 (insert "References: " message-id "\n"))
8189 (unless (gnus-request-replace-article
8190 current-article (car gnus-article-current)
8191 (current-buffer))
a8151ef7 8192 (error "Couldn't replace article"))))
eec82323
LMI
8193 (set-buffer gnus-summary-buffer)
8194 (gnus-summary-unmark-all-processable)
6748645f 8195 (gnus-summary-update-article current-article)
eec82323 8196 (gnus-summary-rethread-current)
a8151ef7 8197 (gnus-message 3 "Article %d is now the child of article %d"
eec82323
LMI
8198 current-article parent-article)))))
8199
8200(defun gnus-summary-toggle-threads (&optional arg)
8201 "Toggle showing conversation threads.
8202If ARG is positive number, turn showing conversation threads on."
8203 (interactive "P")
eec82323
LMI
8204 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8205 (setq gnus-show-threads
8206 (if (null arg) (not gnus-show-threads)
8207 (> (prefix-numeric-value arg) 0)))
8208 (gnus-summary-prepare)
8209 (gnus-summary-goto-subject current)
8210 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8211 (gnus-summary-position-point)))
8212
8213(defun gnus-summary-show-all-threads ()
8214 "Show all threads."
8215 (interactive)
eec82323
LMI
8216 (save-excursion
8217 (let ((buffer-read-only nil))
8218 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8219 (gnus-summary-position-point))
8220
8221(defun gnus-summary-show-thread ()
8222 "Show thread subtrees.
8223Returns nil if no thread was there to be shown."
8224 (interactive)
eec82323
LMI
8225 (let ((buffer-read-only nil)
8226 (orig (point))
8227 ;; first goto end then to beg, to have point at beg after let
8228 (end (progn (end-of-line) (point)))
8229 (beg (progn (beginning-of-line) (point))))
8230 (prog1
8231 ;; Any hidden lines here?
8232 (search-forward "\r" end t)
8233 (subst-char-in-region beg end ?\^M ?\n t)
8234 (goto-char orig)
8235 (gnus-summary-position-point))))
8236
8237(defun gnus-summary-hide-all-threads ()
8238 "Hide all thread subtrees."
8239 (interactive)
eec82323
LMI
8240 (save-excursion
8241 (goto-char (point-min))
8242 (gnus-summary-hide-thread)
8243 (while (zerop (gnus-summary-next-thread 1 t))
8244 (gnus-summary-hide-thread)))
8245 (gnus-summary-position-point))
8246
8247(defun gnus-summary-hide-thread ()
8248 "Hide thread subtrees.
8249Returns nil if no threads were there to be hidden."
8250 (interactive)
eec82323
LMI
8251 (let ((buffer-read-only nil)
8252 (start (point))
8253 (article (gnus-summary-article-number)))
8254 (goto-char start)
8255 ;; Go forward until either the buffer ends or the subthread
8256 ;; ends.
8257 (when (and (not (eobp))
8258 (or (zerop (gnus-summary-next-thread 1 t))
8259 (goto-char (point-max))))
8260 (prog1
8261 (if (and (> (point) start)
8262 (search-backward "\n" start t))
8263 (progn
8264 (subst-char-in-region start (point) ?\n ?\^M)
8265 (gnus-summary-goto-subject article))
8266 (goto-char start)
8267 nil)
8268 ;;(gnus-summary-position-point)
8269 ))))
8270
8271(defun gnus-summary-go-to-next-thread (&optional previous)
8272 "Go to the same level (or less) next thread.
8273If PREVIOUS is non-nil, go to previous thread instead.
8274Return the article number moved to, or nil if moving was impossible."
8275 (let ((level (gnus-summary-thread-level))
8276 (way (if previous -1 1))
8277 (beg (point)))
8278 (forward-line way)
8279 (while (and (not (eobp))
8280 (< level (gnus-summary-thread-level)))
8281 (forward-line way))
8282 (if (eobp)
8283 (progn
8284 (goto-char beg)
8285 nil)
8286 (setq beg (point))
8287 (prog1
8288 (gnus-summary-article-number)
8289 (goto-char beg)))))
8290
8291(defun gnus-summary-next-thread (n &optional silent)
8292 "Go to the same level next N'th thread.
8293If N is negative, search backward instead.
8294Returns the difference between N and the number of skips actually
8295done.
8296
8297If SILENT, don't output messages."
8298 (interactive "p")
eec82323
LMI
8299 (let ((backward (< n 0))
8300 (n (abs n)))
8301 (while (and (> n 0)
8302 (gnus-summary-go-to-next-thread backward))
8303 (decf n))
8304 (unless silent
8305 (gnus-summary-position-point))
8306 (when (and (not silent) (/= 0 n))
8307 (gnus-message 7 "No more threads"))
8308 n))
8309
8310(defun gnus-summary-prev-thread (n)
8311 "Go to the same level previous N'th thread.
8312Returns the difference between N and the number of skips actually
8313done."
8314 (interactive "p")
eec82323
LMI
8315 (gnus-summary-next-thread (- n)))
8316
8317(defun gnus-summary-go-down-thread ()
8318 "Go down one level in the current thread."
8319 (let ((children (gnus-summary-article-children)))
8320 (when children
8321 (gnus-summary-goto-subject (car children)))))
8322
8323(defun gnus-summary-go-up-thread ()
8324 "Go up one level in the current thread."
8325 (let ((parent (gnus-summary-article-parent)))
8326 (when parent
8327 (gnus-summary-goto-subject parent))))
8328
8329(defun gnus-summary-down-thread (n)
8330 "Go down thread N steps.
8331If N is negative, go up instead.
8332Returns the difference between N and how many steps down that were
8333taken."
8334 (interactive "p")
eec82323
LMI
8335 (let ((up (< n 0))
8336 (n (abs n)))
8337 (while (and (> n 0)
8338 (if up (gnus-summary-go-up-thread)
8339 (gnus-summary-go-down-thread)))
8340 (setq n (1- n)))
8341 (gnus-summary-position-point)
8342 (when (/= 0 n)
8343 (gnus-message 7 "Can't go further"))
8344 n))
8345
8346(defun gnus-summary-up-thread (n)
8347 "Go up thread N steps.
8348If N is negative, go up instead.
8349Returns the difference between N and how many steps down that were
8350taken."
8351 (interactive "p")
eec82323
LMI
8352 (gnus-summary-down-thread (- n)))
8353
8354(defun gnus-summary-top-thread ()
8355 "Go to the top of the thread."
8356 (interactive)
eec82323
LMI
8357 (while (gnus-summary-go-up-thread))
8358 (gnus-summary-article-number))
8359
8360(defun gnus-summary-kill-thread (&optional unmark)
8361 "Mark articles under current thread as read.
8362If the prefix argument is positive, remove any kinds of marks.
8363If the prefix argument is negative, tick articles instead."
8364 (interactive "P")
eec82323
LMI
8365 (when unmark
8366 (setq unmark (prefix-numeric-value unmark)))
8367 (let ((articles (gnus-summary-articles-in-thread)))
8368 (save-excursion
8369 ;; Expand the thread.
8370 (gnus-summary-show-thread)
8371 ;; Mark all the articles.
8372 (while articles
8373 (gnus-summary-goto-subject (car articles))
8374 (cond ((null unmark)
8375 (gnus-summary-mark-article-as-read gnus-killed-mark))
8376 ((> unmark 0)
8377 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8378 (t
8379 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8380 (setq articles (cdr articles))))
8381 ;; Hide killed subtrees.
8382 (and (null unmark)
8383 gnus-thread-hide-killed
8384 (gnus-summary-hide-thread))
8385 ;; If marked as read, go to next unread subject.
8386 (when (null unmark)
8387 ;; Go to next unread subject.
8388 (gnus-summary-next-subject 1 t)))
8389 (gnus-set-mode-line 'summary))
8390
8391;; Summary sorting commands
8392
8393(defun gnus-summary-sort-by-number (&optional reverse)
8394 "Sort the summary buffer by article number.
8395Argument REVERSE means reverse order."
8396 (interactive "P")
8397 (gnus-summary-sort 'number reverse))
8398
8399(defun gnus-summary-sort-by-author (&optional reverse)
8400 "Sort the summary buffer by author name alphabetically.
8401If case-fold-search is non-nil, case of letters is ignored.
8402Argument REVERSE means reverse order."
8403 (interactive "P")
8404 (gnus-summary-sort 'author reverse))
8405
8406(defun gnus-summary-sort-by-subject (&optional reverse)
8407 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8408If case-fold-search is non-nil, case of letters is ignored.
8409Argument REVERSE means reverse order."
8410 (interactive "P")
8411 (gnus-summary-sort 'subject reverse))
8412
8413(defun gnus-summary-sort-by-date (&optional reverse)
8414 "Sort the summary buffer by date.
8415Argument REVERSE means reverse order."
8416 (interactive "P")
8417 (gnus-summary-sort 'date reverse))
8418
8419(defun gnus-summary-sort-by-score (&optional reverse)
8420 "Sort the summary buffer by score.
8421Argument REVERSE means reverse order."
8422 (interactive "P")
8423 (gnus-summary-sort 'score reverse))
8424
8425(defun gnus-summary-sort-by-lines (&optional reverse)
8426 "Sort the summary buffer by article length.
8427Argument REVERSE means reverse order."
8428 (interactive "P")
8429 (gnus-summary-sort 'lines reverse))
8430
8431(defun gnus-summary-sort (predicate reverse)
8432 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
eec82323
LMI
8433 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8434 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8435 (gnus-thread-sort-functions
8436 (list
8437 (if (not reverse)
8438 thread
8439 `(lambda (t1 t2)
8440 (,thread t2 t1)))))
8441 (gnus-article-sort-functions
8442 (list
8443 (if (not reverse)
8444 article
8445 `(lambda (t1 t2)
8446 (,article t2 t1)))))
8447 (buffer-read-only)
8448 (gnus-summary-prepare-hook nil))
8449 ;; We do the sorting by regenerating the threads.
8450 (gnus-summary-prepare)
8451 ;; Hide subthreads if needed.
8452 (when (and gnus-show-threads gnus-thread-hide-subtree)
8453 (gnus-summary-hide-all-threads))))
8454
8455;; Summary saving commands.
8456
8457(defun gnus-summary-save-article (&optional n not-saved)
8458 "Save the current article using the default saver function.
8459If N is a positive number, save the N next articles.
8460If N is a negative number, save the N previous articles.
8461If N is nil and any articles have been marked with the process mark,
8462save those articles instead.
8463The variable `gnus-default-article-saver' specifies the saver function."
8464 (interactive "P")
eec82323
LMI
8465 (let* ((articles (gnus-summary-work-articles n))
8466 (save-buffer (save-excursion
8467 (nnheader-set-temp-buffer " *Gnus Save*")))
8468 (num (length articles))
8469 header article file)
8470 (while articles
8471 (setq header (gnus-summary-article-header
8472 (setq article (pop articles))))
8473 (if (not (vectorp header))
8474 ;; This is a pseudo-article.
8475 (if (assq 'name header)
8476 (gnus-copy-file (cdr (assq 'name header)))
8477 (gnus-message 1 "Article %d is unsaveable" article))
8478 ;; This is a real article.
8479 (save-window-excursion
8480 (gnus-summary-select-article t nil nil article))
8481 (save-excursion
8482 (set-buffer save-buffer)
8483 (erase-buffer)
8484 (insert-buffer-substring gnus-original-article-buffer))
8485 (setq file (gnus-article-save save-buffer file num))
8486 (gnus-summary-remove-process-mark article)
8487 (unless not-saved
8488 (gnus-summary-set-saved-mark article))))
8489 (gnus-kill-buffer save-buffer)
8490 (gnus-summary-position-point)
8491 (gnus-set-mode-line 'summary)
8492 n))
8493
8494(defun gnus-summary-pipe-output (&optional arg)
8495 "Pipe the current article to a subprocess.
8496If N is a positive number, pipe the N next articles.
8497If N is a negative number, pipe the N previous articles.
8498If N is nil and any articles have been marked with the process mark,
8499pipe those articles instead."
8500 (interactive "P")
eec82323
LMI
8501 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8502 (gnus-summary-save-article arg t))
8503 (gnus-configure-windows 'pipe))
8504
8505(defun gnus-summary-save-article-mail (&optional arg)
8506 "Append the current article to an mail file.
8507If N is a positive number, save the N next articles.
8508If N is a negative number, save the N previous articles.
8509If N is nil and any articles have been marked with the process mark,
8510save those articles instead."
8511 (interactive "P")
eec82323
LMI
8512 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8513 (gnus-summary-save-article arg)))
8514
8515(defun gnus-summary-save-article-rmail (&optional arg)
8516 "Append the current article to an rmail file.
8517If N is a positive number, save the N next articles.
8518If N is a negative number, save the N previous articles.
8519If N is nil and any articles have been marked with the process mark,
8520save those articles instead."
8521 (interactive "P")
eec82323
LMI
8522 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8523 (gnus-summary-save-article arg)))
8524
8525(defun gnus-summary-save-article-file (&optional arg)
8526 "Append the current article to a file.
8527If N is a positive number, save the N next articles.
8528If N is a negative number, save the N previous articles.
8529If N is nil and any articles have been marked with the process mark,
8530save those articles instead."
8531 (interactive "P")
eec82323
LMI
8532 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8533 (gnus-summary-save-article arg)))
8534
8535(defun gnus-summary-write-article-file (&optional arg)
8536 "Write the current article to a file, deleting the previous file.
8537If N is a positive number, save the N next articles.
8538If N is a negative number, save the N previous articles.
8539If N is nil and any articles have been marked with the process mark,
8540save those articles instead."
8541 (interactive "P")
eec82323
LMI
8542 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8543 (gnus-summary-save-article arg)))
8544
8545(defun gnus-summary-save-article-body-file (&optional arg)
8546 "Append the current article body to a file.
8547If N is a positive number, save the N next articles.
8548If N is a negative number, save the N previous articles.
8549If N is nil and any articles have been marked with the process mark,
8550save those articles instead."
8551 (interactive "P")
eec82323
LMI
8552 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8553 (gnus-summary-save-article arg)))
8554
8555(defun gnus-summary-pipe-message (program)
8556 "Pipe the current article through PROGRAM."
8557 (interactive "sProgram: ")
eec82323 8558 (gnus-summary-select-article)
6748645f 8559 (let ((mail-header-separator ""))
eec82323
LMI
8560 (gnus-eval-in-buffer-window gnus-article-buffer
8561 (save-restriction
8562 (widen)
8563 (let ((start (window-start))
8564 buffer-read-only)
8565 (message-pipe-buffer-body program)
8566 (set-window-start (get-buffer-window (current-buffer)) start))))))
8567
8568(defun gnus-get-split-value (methods)
8569 "Return a value based on the split METHODS."
8570 (let (split-name method result match)
8571 (when methods
8572 (save-excursion
8573 (set-buffer gnus-original-article-buffer)
8574 (save-restriction
8575 (nnheader-narrow-to-headers)
8576 (while methods
8577 (goto-char (point-min))
8578 (setq method (pop methods))
8579 (setq match (car method))
8580 (when (cond
8581 ((stringp match)
8582 ;; Regular expression.
8583 (ignore-errors
8584 (re-search-forward match nil t)))
8585 ((gnus-functionp match)
8586 ;; Function.
8587 (save-restriction
8588 (widen)
8589 (setq result (funcall match gnus-newsgroup-name))))
8590 ((consp match)
8591 ;; Form.
8592 (save-restriction
8593 (widen)
8594 (setq result (eval match)))))
8595 (setq split-name (append (cdr method) split-name))
8596 (cond ((stringp result)
8597 (push (expand-file-name
8598 result gnus-article-save-directory)
8599 split-name))
8600 ((consp result)
8601 (setq split-name (append result split-name)))))))))
8602 split-name))
8603
8604(defun gnus-valid-move-group-p (group)
8605 (and (boundp group)
8606 (symbol-name group)
8607 (memq 'respool
8608 (assoc (symbol-name
8609 (car (gnus-find-method-for-group
8610 (symbol-name group))))
8611 gnus-valid-select-methods))))
8612
8613(defun gnus-read-move-group-name (prompt default articles prefix)
8614 "Read a group name."
8615 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8616 (minibuffer-confirm-incomplete nil) ; XEmacs
8617 (prom
8618 (format "%s %s to:"
8619 prompt
8620 (if (> (length articles) 1)
8621 (format "these %d articles" (length articles))
8622 "this article")))
8623 (to-newsgroup
8624 (cond
8625 ((null split-name)
8626 (gnus-completing-read default prom
8627 gnus-active-hashtb
8628 'gnus-valid-move-group-p
8629 nil prefix
8630 'gnus-group-history))
8631 ((= 1 (length split-name))
8632 (gnus-completing-read (car split-name) prom
8633 gnus-active-hashtb
8634 'gnus-valid-move-group-p
8635 nil nil
8636 'gnus-group-history))
8637 (t
8638 (gnus-completing-read nil prom
8639 (mapcar (lambda (el) (list el))
8640 (nreverse split-name))
8641 nil nil nil
8642 'gnus-group-history)))))
8643 (when to-newsgroup
8644 (if (or (string= to-newsgroup "")
8645 (string= to-newsgroup prefix))
8646 (setq to-newsgroup default))
8647 (unless to-newsgroup
8648 (error "No group name entered"))
8649 (or (gnus-active to-newsgroup)
8650 (gnus-activate-group to-newsgroup)
8651 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8652 to-newsgroup))
8653 (or (and (gnus-request-create-group
8654 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8655 (gnus-activate-group to-newsgroup nil nil
8656 (gnus-group-name-to-method
8657 to-newsgroup)))
8658 (error "Couldn't create group %s" to-newsgroup)))
8659 (error "No such group: %s" to-newsgroup)))
8660 to-newsgroup))
8661
8662;; Summary extract commands
8663
8664(defun gnus-summary-insert-pseudos (pslist &optional not-view)
8665 (let ((buffer-read-only nil)
8666 (article (gnus-summary-article-number))
8667 after-article b e)
8668 (unless (gnus-summary-goto-subject article)
8669 (error "No such article: %d" article))
8670 (gnus-summary-position-point)
8671 ;; If all commands are to be bunched up on one line, we collect
8672 ;; them here.
8673 (unless gnus-view-pseudos-separately
8674 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8675 files action)
8676 (while ps
8677 (setq action (cdr (assq 'action (car ps))))
8678 (setq files (list (cdr (assq 'name (car ps)))))
8679 (while (and ps (cdr ps)
8680 (string= (or action "1")
8681 (or (cdr (assq 'action (cadr ps))) "2")))
8682 (push (cdr (assq 'name (cadr ps))) files)
8683 (setcdr ps (cddr ps)))
8684 (when files
8685 (when (not (string-match "%s" action))
8686 (push " " files))
8687 (push " " files)
8688 (when (assq 'execute (car ps))
8689 (setcdr (assq 'execute (car ps))
8690 (funcall (if (string-match "%s" action)
8691 'format 'concat)
8692 action
8693 (mapconcat
8694 (lambda (f)
8695 (if (equal f " ")
8696 f
8697 (gnus-quote-arg-for-sh-or-csh f)))
8698 files " ")))))
8699 (setq ps (cdr ps)))))
8700 (if (and gnus-view-pseudos (not not-view))
8701 (while pslist
8702 (when (assq 'execute (car pslist))
8703 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8704 (eq gnus-view-pseudos 'not-confirm)))
8705 (setq pslist (cdr pslist)))
8706 (save-excursion
8707 (while pslist
8708 (setq after-article (or (cdr (assq 'article (car pslist)))
8709 (gnus-summary-article-number)))
8710 (gnus-summary-goto-subject after-article)
8711 (forward-line 1)
8712 (setq b (point))
8713 (insert " " (file-name-nondirectory
8714 (cdr (assq 'name (car pslist))))
8715 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8716 (setq e (point))
8717 (forward-line -1) ; back to `b'
8718 (gnus-add-text-properties
8719 b (1- e) (list 'gnus-number gnus-reffed-article-number
8720 gnus-mouse-face-prop gnus-mouse-face))
8721 (gnus-data-enter
8722 after-article gnus-reffed-article-number
8723 gnus-unread-mark b (car pslist) 0 (- e b))
8724 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8725 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8726 (setq pslist (cdr pslist)))))))
8727
8728(defun gnus-pseudos< (p1 p2)
8729 (let ((c1 (cdr (assq 'action p1)))
8730 (c2 (cdr (assq 'action p2))))
8731 (and c1 c2 (string< c1 c2))))
8732
8733(defun gnus-request-pseudo-article (props)
8734 (cond ((assq 'execute props)
8735 (gnus-execute-command (cdr (assq 'execute props)))))
8736 (let ((gnus-current-article (gnus-summary-article-number)))
6748645f 8737 (gnus-run-hooks 'gnus-mark-article-hook)))
eec82323
LMI
8738
8739(defun gnus-execute-command (command &optional automatic)
8740 (save-excursion
8741 (gnus-article-setup-buffer)
8742 (set-buffer gnus-article-buffer)
8743 (setq buffer-read-only nil)
a8151ef7
LMI
8744 (let ((command (if automatic command
8745 (read-string "Command: " (cons command 0)))))
eec82323
LMI
8746 (erase-buffer)
8747 (insert "$ " command "\n\n")
8748 (if gnus-view-pseudo-asynchronously
8749 (start-process "gnus-execute" (current-buffer) shell-file-name
8750 shell-command-switch command)
8751 (call-process shell-file-name nil t nil
8752 shell-command-switch command)))))
8753
8754;; Summary kill commands.
8755
8756(defun gnus-summary-edit-global-kill (article)
8757 "Edit the \"global\" kill file."
8758 (interactive (list (gnus-summary-article-number)))
eec82323
LMI
8759 (gnus-group-edit-global-kill article))
8760
8761(defun gnus-summary-edit-local-kill ()
8762 "Edit a local kill file applied to the current newsgroup."
8763 (interactive)
eec82323 8764 (setq gnus-current-headers (gnus-summary-article-header))
eec82323
LMI
8765 (gnus-group-edit-local-kill
8766 (gnus-summary-article-number) gnus-newsgroup-name))
8767
8768;;; Header reading.
8769
8770(defun gnus-read-header (id &optional header)
8771 "Read the headers of article ID and enter them into the Gnus system."
8772 (let ((group gnus-newsgroup-name)
8773 (gnus-override-method
8774 (and (gnus-news-group-p gnus-newsgroup-name)
8775 gnus-refer-article-method))
8776 where)
8777 ;; First we check to see whether the header in question is already
8778 ;; fetched.
8779 (if (stringp id)
8780 ;; This is a Message-ID.
8781 (setq header (or header (gnus-id-to-header id)))
8782 ;; This is an article number.
8783 (setq header (or header (gnus-summary-article-header id))))
8784 (if (and header
8785 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8786 ;; We have found the header.
8787 header
6748645f
LMI
8788 ;; If this is a sparse article, we have to nix out its
8789 ;; previous entry in the thread hashtb.
8790 (when (and header
8791 (gnus-summary-article-sparse-p (mail-header-number header)))
8792 (let* ((parent (gnus-parent-id (mail-header-references header)))
8793 (thread (and parent (gnus-id-to-thread parent))))
8794 (when thread
8795 (delq (assq header thread) thread))))
eec82323
LMI
8796 ;; We have to really fetch the header to this article.
8797 (save-excursion
8798 (set-buffer nntp-server-buffer)
8799 (when (setq where (gnus-request-head id group))
8800 (nnheader-fold-continuation-lines)
8801 (goto-char (point-max))
8802 (insert ".\n")
8803 (goto-char (point-min))
8804 (insert "211 ")
8805 (princ (cond
8806 ((numberp id) id)
8807 ((cdr where) (cdr where))
8808 (header (mail-header-number header))
8809 (t gnus-reffed-article-number))
8810 (current-buffer))
8811 (insert " Article retrieved.\n"))
8812 (if (or (not where)
8813 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8814 () ; Malformed head.
8815 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8816 (when (and (stringp id)
8817 (not (string= (gnus-group-real-name group)
8818 (car where))))
8819 ;; If we fetched by Message-ID and the article came
8820 ;; from a different group, we fudge some bogus article
8821 ;; numbers for this article.
8822 (mail-header-set-number header gnus-reffed-article-number))
8823 (save-excursion
8824 (set-buffer gnus-summary-buffer)
8825 (decf gnus-reffed-article-number)
8826 (gnus-remove-header (mail-header-number header))
8827 (push header gnus-newsgroup-headers)
8828 (setq gnus-current-headers header)
8829 (push (mail-header-number header) gnus-newsgroup-limit)))
8830 header)))))
8831
8832(defun gnus-remove-header (number)
8833 "Remove header NUMBER from `gnus-newsgroup-headers'."
8834 (if (and gnus-newsgroup-headers
8835 (= number (mail-header-number (car gnus-newsgroup-headers))))
8836 (pop gnus-newsgroup-headers)
8837 (let ((headers gnus-newsgroup-headers))
8838 (while (and (cdr headers)
8839 (not (= number (mail-header-number (cadr headers)))))
8840 (pop headers))
8841 (when (cdr headers)
8842 (setcdr headers (cddr headers))))))
8843
8844;;;
8845;;; summary highlights
8846;;;
8847
8848(defun gnus-highlight-selected-summary ()
8849 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8850 ;; Highlight selected article in summary buffer
8851 (when gnus-summary-selected-face
8852 (save-excursion
8853 (let* ((beg (progn (beginning-of-line) (point)))
8854 (end (progn (end-of-line) (point)))
8855 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8856 (from (if (get-text-property beg gnus-mouse-face-prop)
8857 beg
8858 (or (next-single-property-change
8859 beg gnus-mouse-face-prop nil end)
8860 beg)))
8861 (to
8862 (if (= from end)
8863 (- from 2)
8864 (or (next-single-property-change
8865 from gnus-mouse-face-prop nil end)
8866 end))))
8867 ;; If no mouse-face prop on line we will have to = from = end,
8868 ;; so we highlight the entire line instead.
8869 (when (= (+ to 2) from)
8870 (setq from beg)
8871 (setq to end))
8872 (if gnus-newsgroup-selected-overlay
8873 ;; Move old overlay.
8874 (gnus-move-overlay
8875 gnus-newsgroup-selected-overlay from to (current-buffer))
8876 ;; Create new overlay.
8877 (gnus-overlay-put
8878 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8879 'face gnus-summary-selected-face))))))
8880
8881;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8882(defun gnus-summary-highlight-line ()
8883 "Highlight current line according to `gnus-summary-highlight'."
8884 (let* ((list gnus-summary-highlight)
8885 (p (point))
8886 (end (progn (end-of-line) (point)))
8887 ;; now find out where the line starts and leave point there.
8888 (beg (progn (beginning-of-line) (point)))
8889 (article (gnus-summary-article-number))
8890 (score (or (cdr (assq (or article gnus-current-article)
8891 gnus-newsgroup-scored))
8892 gnus-summary-default-score 0))
8893 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8894 (inhibit-read-only t))
8895 ;; Eval the cars of the lists until we find a match.
8896 (let ((default gnus-summary-default-score))
8897 (while (and list
8898 (not (eval (caar list))))
8899 (setq list (cdr list))))
8900 (let ((face (cdar list)))
8901 (unless (eq face (get-text-property beg 'face))
6748645f 8902 (gnus-put-text-property-excluding-characters-with-faces
eec82323
LMI
8903 beg end 'face
8904 (setq face (if (boundp face) (symbol-value face) face)))
8905 (when gnus-summary-highlight-line-function
8906 (funcall gnus-summary-highlight-line-function article face))))
8907 (goto-char p)))
8908
6748645f 8909(defun gnus-update-read-articles (group unread &optional compute)
eec82323
LMI
8910 "Update the list of read articles in GROUP."
8911 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8912 (entry (gnus-gethash group gnus-newsrc-hashtb))
8913 (info (nth 2 entry))
8914 (prev 1)
8915 (unread (sort (copy-sequence unread) '<))
8916 read)
8917 (if (or (not info) (not active))
8918 ;; There is no info on this group if it was, in fact,
8919 ;; killed. Gnus stores no information on killed groups, so
8920 ;; there's nothing to be done.
8921 ;; One could store the information somewhere temporarily,
8922 ;; perhaps... Hmmm...
8923 ()
8924 ;; Remove any negative articles numbers.
8925 (while (and unread (< (car unread) 0))
8926 (setq unread (cdr unread)))
8927 ;; Remove any expired article numbers
8928 (while (and unread (< (car unread) (car active)))
8929 (setq unread (cdr unread)))
8930 ;; Compute the ranges of read articles by looking at the list of
8931 ;; unread articles.
8932 (while unread
8933 (when (/= (car unread) prev)
8934 (push (if (= prev (1- (car unread))) prev
8935 (cons prev (1- (car unread))))
8936 read))
8937 (setq prev (1+ (car unread)))
8938 (setq unread (cdr unread)))
8939 (when (<= prev (cdr active))
8940 (push (cons prev (cdr active)) read))
6748645f
LMI
8941 (if compute
8942 (if (> (length read) 1) (nreverse read) read)
8943 (save-excursion
8944 (set-buffer gnus-group-buffer)
8945 (gnus-undo-register
8946 `(progn
8947 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8948 (gnus-info-set-read ',info ',(gnus-info-read info))
8949 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8950 (gnus-group-update-group ,group t))))
8951 ;; Enter this list into the group info.
8952 (gnus-info-set-read
8953 info (if (> (length read) 1) (nreverse read) read))
8954 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8955 (gnus-get-unread-articles-in-group info (gnus-active group))
8956 t))))
eec82323
LMI
8957
8958(defun gnus-offer-save-summaries ()
8959 "Offer to save all active summary buffers."
8960 (save-excursion
8961 (let ((buflist (buffer-list))
8962 buffers bufname)
8963 ;; Go through all buffers and find all summaries.
8964 (while buflist
8965 (and (setq bufname (buffer-name (car buflist)))
8966 (string-match "Summary" bufname)
8967 (save-excursion
8968 (set-buffer bufname)
8969 ;; We check that this is, indeed, a summary buffer.
8970 (and (eq major-mode 'gnus-summary-mode)
8971 ;; Also make sure this isn't bogus.
8972 gnus-newsgroup-prepared
8973 ;; Also make sure that this isn't a dead summary buffer.
8974 (not gnus-dead-summary-mode)))
8975 (push bufname buffers))
8976 (setq buflist (cdr buflist)))
8977 ;; Go through all these summary buffers and offer to save them.
8978 (when buffers
8979 (map-y-or-n-p
8980 "Update summary buffer %s? "
6748645f
LMI
8981 (lambda (buf)
8982 (switch-to-buffer buf)
8983 (gnus-summary-exit))
eec82323
LMI
8984 buffers)))))
8985
a8151ef7
LMI
8986(gnus-ems-redefine)
8987
eec82323
LMI
8988(provide 'gnus-sum)
8989
8990(run-hooks 'gnus-sum-load-hook)
8991
8992;;; gnus-sum.el ends here