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