1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
7 ;; This file is part of GNU Emacs.
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)
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.
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.
35 (defcustom gnus-kill-summary-on-exit t
36 "*If non-nil, kill the summary buffer when you exit from it.
37 If nil, the summary will become a \"*Dead Summary*\" buffer, and
38 it will be killed sometime later."
39 :group 'gnus-summary-exit
42 (defcustom gnus-fetch-old-headers nil
43 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
44 If an unread article in the group refers to an older, already read (or
45 just marked as read) article, the old article will not normally be
46 displayed in the Summary buffer. If this variable is non-nil, Gnus
47 will attempt to grab the headers to the old articles, and thereby
48 build complete threads. If it has the value `some', only enough
49 headers to connect otherwise loose threads will be displayed.
50 This variable can also be a number. In that case, no more than that
51 number of old headers will be fetched.
53 The server has to support NOV for any of this to work."
55 :type '(choice (const :tag "off" nil)
58 (sexp :menu-tag "other" t)))
60 (defcustom gnus-summary-make-false-root 'adopt
61 "*nil means that Gnus won't gather loose threads.
62 If the root of a thread has expired or been read in a previous
63 session, the information necessary to build a complete thread has been
64 lost. Instead of having many small sub-threads from this original thread
65 scattered all over the summary buffer, Gnus can gather them.
67 If non-nil, Gnus will try to gather all loose sub-threads from an
68 original thread into one large thread.
70 If this variable is non-nil, it should be one of `none', `adopt',
73 If this variable is `none', Gnus will not make a false root, but just
74 present the sub-threads after another.
75 If this variable is `dummy', Gnus will create a dummy root that will
76 have all the sub-threads as children.
77 If this variable is `adopt', Gnus will make one of the \"children\"
78 the parent and mark all the step-children as such.
79 If this variable is `empty', the \"children\" are printed with empty
80 subject fields. (Or rather, they will be printed with a string
81 given by the `gnus-summary-same-subject' variable.)"
83 :type '(choice (const :tag "off" nil)
89 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
90 "*A regexp to match subjects to be excluded from loose thread gathering.
91 As loose thread gathering is done on subjects only, that means that
92 there can be many false gatherings performed. By rooting out certain
93 common subjects, gathering might become saner."
97 (defcustom gnus-summary-gather-subject-limit nil
98 "*Maximum length of subject comparisons when gathering loose threads.
99 Use nil to compare full subjects. Setting this variable to a low
100 number will help gather threads that have been corrupted by
101 newsreaders chopping off subject lines, but it might also mean that
102 unrelated articles that have subject that happen to begin with the
103 same few characters will be incorrectly gathered.
105 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
108 :type '(choice (const :tag "off" nil)
110 (sexp :menu-tag "on" t)))
112 (defcustom gnus-simplify-ignored-prefixes nil
113 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
115 :type '(choice (const :tag "off" nil)
118 (defcustom gnus-build-sparse-threads nil
119 "*If non-nil, fill in the gaps in threads.
120 If `some', only fill in the gaps that are needed to tie loose threads
121 together. If `more', fill in all leaf nodes that Gnus can find. If
122 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
124 :type '(choice (const :tag "off" nil)
127 (sexp :menu-tag "all" t)))
129 (defcustom gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
130 "Function used for gathering loose threads.
131 There are two pre-defined functions: `gnus-gather-threads-by-subject',
132 which only takes Subjects into consideration; and
133 `gnus-gather-threads-by-references', which compared the References
134 headers of the articles to find matches."
136 :type '(set (function-item gnus-gather-threads-by-subject)
137 (function-item gnus-gather-threads-by-references)
138 (function :tag "other")))
140 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
141 (defcustom gnus-summary-same-subject ""
142 "*String indicating that the current article has the same subject as the previous.
143 This variable will only be used if the value of
144 `gnus-summary-make-false-root' is `empty'."
145 :group 'gnus-summary-format
148 (defcustom gnus-summary-goto-unread t
149 "*If t, marking commands will go to the next unread article.
150 If `never', commands that usually go to the next unread article, will
151 go to the next article, whether it is read or not.
152 If nil, only the marking commands will go to the next (un)read article."
153 :group 'gnus-summary-marks
154 :link '(custom-manual "(gnus)Setting Marks")
155 :type '(choice (const :tag "off" nil)
157 (sexp :menu-tag "on" t)))
159 (defcustom gnus-summary-default-score 0
160 "*Default article score level.
161 If this variable is nil, scoring will be disabled."
163 :type '(choice (const :tag "disable")
166 (defcustom gnus-summary-zcore-fuzz 0
167 "*Fuzziness factor for the zcore in the summary buffer.
168 Articles with scores closer than this to `gnus-summary-default-score'
170 :group 'gnus-summary-format
173 (defcustom gnus-simplify-subject-fuzzy-regexp nil
174 "*Strings to be removed when doing fuzzy matches.
175 This can either be a regular expression or list of regular expressions
176 that will be removed from subject strings if fuzzy subject
177 simplification is selected."
179 :type '(repeat regexp))
181 (defcustom gnus-show-threads t
182 "*If non-nil, display threads in summary mode."
186 (defcustom gnus-thread-hide-subtree nil
187 "*If non-nil, hide all threads initially.
188 If threads are hidden, you have to run the command
189 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
190 to expose hidden threads."
194 (defcustom gnus-thread-hide-killed t
195 "*If non-nil, hide killed threads automatically."
199 (defcustom gnus-thread-ignore-subject nil
200 "*If non-nil, ignore subjects and do all threading based on the Reference header.
201 If nil, which is the default, articles that have different subjects
202 from their parents will start separate threads."
206 (defcustom gnus-thread-operation-ignore-subject t
207 "*If non-nil, subjects will be ignored when doing thread commands.
208 This affects commands like `gnus-summary-kill-thread' and
209 `gnus-summary-lower-thread'.
211 If this variable is nil, articles in the same thread with different
212 subjects will not be included in the operation in question. If this
213 variable is `fuzzy', only articles that have subjects that are fuzzily
214 equal will be included."
216 :type '(choice (const :tag "off" nil)
220 (defcustom gnus-thread-indent-level 4
221 "*Number that says how much each sub-thread should be indented."
225 (defcustom gnus-auto-extend-newsgroup t
226 "*If non-nil, extend newsgroup forward and backward when requested."
227 :group 'gnus-summary-choose
230 (defcustom gnus-auto-select-first t
231 "*If nil, don't select the first unread article when entering a group.
232 If this variable is `best', select the highest-scored unread article
233 in the group. If neither nil nor `best', select the first unread
236 If you want to prevent automatic selection of the first unread article
237 in some newsgroups, set the variable to nil in
238 `gnus-select-group-hook'."
239 :group 'gnus-group-select
240 :type '(choice (const :tag "none" nil)
242 (sexp :menu-tag "first" t)))
244 (defcustom gnus-auto-select-next t
245 "*If non-nil, offer to go to the next group from the end of the previous.
246 If the value is t and the next newsgroup is empty, Gnus will exit
247 summary mode and go back to group mode. If the value is neither nil
248 nor t, Gnus will select the following unread newsgroup. In
249 particular, if the value is the symbol `quietly', the next unread
250 newsgroup will be selected without any confirmation, and if it is
251 `almost-quietly', the next group will be selected without any
252 confirmation if you are located on the last article in the group.
253 Finally, if this variable is `slightly-quietly', the `Z n' command
254 will go to the next group without confirmation."
255 :group 'gnus-summary-maneuvering
256 :type '(choice (const :tag "off" nil)
258 (const almost-quietly)
259 (const slightly-quietly)
260 (sexp :menu-tag "on" t)))
262 (defcustom gnus-auto-select-same nil
263 "*If non-nil, select the next article with the same subject."
264 :group 'gnus-summary-maneuvering
267 (defcustom gnus-summary-check-current nil
268 "*If non-nil, consider the current article when moving.
269 The \"unread\" movement commands will stay on the same line if the
270 current article is unread."
271 :group 'gnus-summary-maneuvering
274 (defcustom gnus-auto-center-summary t
275 "*If non-nil, always center the current summary buffer.
276 In particular, if `vertical' do only vertical recentering. If non-nil
277 and non-`vertical', do both horizontal and vertical recentering."
278 :group 'gnus-summary-maneuvering
279 :type '(choice (const :tag "none" nil)
281 (sexp :menu-tag "both" t)))
283 (defcustom gnus-show-all-headers nil
284 "*If non-nil, don't hide any headers."
285 :group 'gnus-article-hiding
286 :group 'gnus-article-headers
289 (defcustom gnus-single-article-buffer t
290 "*If non-nil, display all articles in the same buffer.
291 If nil, each group will get its own article buffer."
292 :group 'gnus-article-various
295 (defcustom gnus-break-pages t
296 "*If non-nil, do page breaking on articles.
297 The page delimiter is specified by the `gnus-page-delimiter'
299 :group 'gnus-article-various
302 (defcustom gnus-show-mime nil
303 "*If non-nil, do mime processing of articles.
304 The articles will simply be fed to the function given by
305 `gnus-show-mime-method'."
306 :group 'gnus-article-mime
309 (defcustom gnus-move-split-methods nil
310 "*Variable used to suggest where articles are to be moved to.
311 It uses the same syntax as the `gnus-split-methods' variable."
312 :group 'gnus-summary-mail
313 :type '(repeat (choice (list function)
314 (cons regexp (repeat string))
317 ;; Mark variables suggested by Thomas Michanek
318 ;; <Thomas.Michanek@telelogic.se>.
320 (defcustom gnus-unread-mark ?
321 "*Mark used for unread articles."
322 :group 'gnus-summary-marks
325 (defcustom gnus-ticked-mark ?!
326 "*Mark used for ticked articles."
327 :group 'gnus-summary-marks
330 (defcustom gnus-dormant-mark ??
331 "*Mark used for dormant articles."
332 :group 'gnus-summary-marks
335 (defcustom gnus-del-mark ?r
336 "*Mark used for del'd articles."
337 :group 'gnus-summary-marks
340 (defcustom gnus-read-mark ?R
341 "*Mark used for read articles."
342 :group 'gnus-summary-marks
345 (defcustom gnus-expirable-mark ?E
346 "*Mark used for expirable articles."
347 :group 'gnus-summary-marks
350 (defcustom gnus-killed-mark ?K
351 "*Mark used for killed articles."
352 :group 'gnus-summary-marks
355 (defcustom gnus-souped-mark ?F
356 "*Mark used for killed articles."
357 :group 'gnus-summary-marks
360 (defcustom gnus-kill-file-mark ?X
361 "*Mark used for articles killed by kill files."
362 :group 'gnus-summary-marks
365 (defcustom gnus-low-score-mark ?Y
366 "*Mark used for articles with a low score."
367 :group 'gnus-summary-marks
370 (defcustom gnus-catchup-mark ?C
371 "*Mark used for articles that are caught up."
372 :group 'gnus-summary-marks
375 (defcustom gnus-replied-mark ?A
376 "*Mark used for articles that have been replied to."
377 :group 'gnus-summary-marks
380 (defcustom gnus-cached-mark ?*
381 "*Mark used for articles that are in the cache."
382 :group 'gnus-summary-marks
385 (defcustom gnus-saved-mark ?S
386 "*Mark used for articles that have been saved to."
387 :group 'gnus-summary-marks
390 (defcustom gnus-ancient-mark ?O
391 "*Mark used for ancient articles."
392 :group 'gnus-summary-marks
395 (defcustom gnus-sparse-mark ?Q
396 "*Mark used for sparsely reffed articles."
397 :group 'gnus-summary-marks
400 (defcustom gnus-canceled-mark ?G
401 "*Mark used for canceled articles."
402 :group 'gnus-summary-marks
405 (defcustom gnus-duplicate-mark ?M
406 "*Mark used for duplicate articles."
407 :group 'gnus-summary-marks
410 (defcustom gnus-score-over-mark ?+
411 "*Score mark used for articles with high scores."
412 :group 'gnus-summary-marks
415 (defcustom gnus-score-below-mark ?-
416 "*Score mark used for articles with low scores."
417 :group 'gnus-summary-marks
420 (defcustom gnus-empty-thread-mark ?
421 "*There is no thread under the article."
422 :group 'gnus-summary-marks
425 (defcustom gnus-not-empty-thread-mark ?=
426 "*There is a thread under the article."
427 :group 'gnus-summary-marks
430 (defcustom gnus-view-pseudo-asynchronously nil
431 "*If non-nil, Gnus will view pseudo-articles asynchronously."
432 :group 'gnus-extract-view
435 (defcustom gnus-view-pseudos nil
436 "*If `automatic', pseudo-articles will be viewed automatically.
437 If `not-confirm', pseudos will be viewed automatically, and the user
438 will not be asked to confirm the command."
439 :group 'gnus-extract-view
440 :type '(choice (const :tag "off" nil)
442 (const not-confirm)))
444 (defcustom gnus-view-pseudos-separately t
445 "*If non-nil, one pseudo-article will be created for each file to be viewed.
446 If nil, all files that use the same viewing command will be given as a
447 list of parameters to that command."
448 :group 'gnus-extract-view
451 (defcustom gnus-insert-pseudo-articles t
452 "*If non-nil, insert pseudo-articles when decoding articles."
453 :group 'gnus-extract-view
456 (defcustom gnus-summary-dummy-line-format
458 "*The format specification for the dummy roots in the summary buffer.
459 It works along the same lines as a normal formatting string,
460 with some simple extensions.
463 :group 'gnus-threading
466 (defcustom gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
467 "*The format specification for the summary mode line.
468 It works along the same lines as a normal formatting string,
469 with some simple extensions:
472 %p Unprefixed group name
473 %A Current article number
475 %U Number of unread articles in the group
476 %e Number of unselected articles in the group
477 %Z A string with unread/unselected article counts
478 %g Shortish group name
479 %S Subject of the current article
481 %s Current score file name
482 %d Number of dormant articles
483 %r Number of articles that have been marked as read in this session
484 %E Number of articles expunged by the score files"
485 :group 'gnus-summary-format
488 (defcustom gnus-summary-mark-below 0
489 "*Mark all articles with a score below this variable as read.
490 This variable is local to each summary buffer and usually set by the
495 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
496 "*List of functions used for sorting articles in the summary buffer.
497 This variable is only used when not using a threaded display."
498 :group 'gnus-summary-sort
499 :type '(repeat (choice (function-item gnus-article-sort-by-number)
500 (function-item gnus-article-sort-by-author)
501 (function-item gnus-article-sort-by-subject)
502 (function-item gnus-article-sort-by-date)
503 (function-item gnus-article-sort-by-score)
504 (function :tag "other"))))
506 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
507 "*List of functions used for sorting threads in the summary buffer.
508 By default, threads are sorted by article number.
510 Each function takes two threads and return non-nil if the first thread
511 should be sorted before the other. If you use more than one function,
512 the primary sort function should be the last. You should probably
513 always include `gnus-thread-sort-by-number' in the list of sorting
514 functions -- preferably first.
516 Ready-made functions include `gnus-thread-sort-by-number',
517 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
518 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
519 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
520 :group 'gnus-summary-sort
521 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
522 (function-item gnus-thread-sort-by-author)
523 (function-item gnus-thread-sort-by-subject)
524 (function-item gnus-thread-sort-by-date)
525 (function-item gnus-thread-sort-by-score)
526 (function-item gnus-thread-sort-by-total-score)
527 (function :tag "other"))))
529 (defcustom gnus-thread-score-function '+
530 "*Function used for calculating the total score of a thread.
532 The function is called with the scores of the article and each
533 subthread and should then return the score of the thread.
535 Some functions you can use are `+', `max', or `min'."
536 :group 'gnus-summary-sort
539 (defcustom gnus-summary-expunge-below nil
540 "All articles that have a score less than this variable will be expunged."
542 :type '(choice (const :tag "off" nil)
545 (defcustom gnus-thread-expunge-below nil
546 "All threads that have a total score less than this variable will be expunged.
547 See `gnus-thread-score-function' for en explanation of what a
548 \"thread score\" is."
549 :group 'gnus-treading
551 :type '(choice (const :tag "off" nil)
554 (defcustom gnus-summary-mode-hook nil
555 "*A hook for Gnus summary mode.
556 This hook is run before any variables are set in the summary buffer."
557 :group 'gnus-summary-various
560 (defcustom gnus-summary-menu-hook nil
561 "*Hook run after the creation of the summary mode menu."
562 :group 'gnus-summary-visual
565 (defcustom gnus-summary-exit-hook nil
566 "*A hook called on exit from the summary buffer.
567 It will be called with point in the group buffer."
568 :group 'gnus-summary-exit
571 (defcustom gnus-summary-prepare-hook nil
572 "*A hook called after the summary buffer has been generated.
573 If you want to modify the summary buffer, you can use this hook."
574 :group 'gnus-summary-various
577 (defcustom gnus-summary-generate-hook nil
578 "*A hook run just before generating the summary buffer.
579 This hook is commonly used to customize threading variables and the
581 :group 'gnus-summary-various
584 (defcustom gnus-select-group-hook nil
585 "*A hook called when a newsgroup is selected.
587 If you'd like to simplify subjects like the
588 `gnus-summary-next-same-subject' command does, you can use the
591 (setq gnus-select-group-hook
594 (mapcar (lambda (header)
595 (mail-header-set-subject
597 (gnus-simplify-subject
598 (mail-header-subject header) 're-only)))
599 gnus-newsgroup-headers))))"
600 :group 'gnus-group-select
603 (defcustom gnus-select-article-hook nil
604 "*A hook called when an article is selected."
605 :group 'gnus-summary-choose
608 (defcustom gnus-visual-mark-article-hook
609 (list 'gnus-highlight-selected-summary)
610 "*Hook run after selecting an article in the summary buffer.
611 It is meant to be used for highlighting the article in some way. It
612 is not run if `gnus-visual' is nil."
613 :group 'gnus-summary-visual
616 (defcustom gnus-parse-headers-hook
617 (list 'gnus-decode-rfc1522)
618 "*A hook called before parsing the headers."
622 (defcustom gnus-exit-group-hook nil
623 "*A hook called when exiting (not quitting) summary mode."
627 (defcustom gnus-summary-update-hook
628 (list 'gnus-summary-highlight-line)
629 "*A hook called when a summary line is changed.
630 The hook will not be called if `gnus-visual' is nil.
632 The default function `gnus-summary-highlight-line' will
633 highlight the line according to the `gnus-summary-highlight'
635 :group 'gnus-summary-visual
638 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
639 "*A hook called when an article is selected for the first time.
640 The hook is intended to mark an article as read (or unread)
641 automatically when it is selected."
642 :group 'gnus-summary-choose
645 (defcustom gnus-group-no-more-groups-hook nil
646 "*A hook run when returning to group mode having no more (unread) groups."
647 :group 'gnus-group-select
650 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
651 "Face used for highlighting the current article in the summary buffer."
652 :group 'gnus-summary-visual
655 (defcustom gnus-summary-highlight
656 '(((= mark gnus-canceled-mark)
657 . gnus-summary-cancelled-face)
658 ((and (> score default)
659 (or (= mark gnus-dormant-mark)
660 (= mark gnus-ticked-mark)))
661 . gnus-summary-high-ticked-face)
662 ((and (< score default)
663 (or (= mark gnus-dormant-mark)
664 (= mark gnus-ticked-mark)))
665 . gnus-summary-low-ticked-face)
666 ((or (= mark gnus-dormant-mark)
667 (= mark gnus-ticked-mark))
668 . gnus-summary-normal-ticked-face)
669 ((and (> score default) (= mark gnus-ancient-mark))
670 . gnus-summary-high-ancient-face)
671 ((and (< score default) (= mark gnus-ancient-mark))
672 . gnus-summary-low-ancient-face)
673 ((= mark gnus-ancient-mark)
674 . gnus-summary-normal-ancient-face)
675 ((and (> score default) (= mark gnus-unread-mark))
676 . gnus-summary-high-unread-face)
677 ((and (< score default) (= mark gnus-unread-mark))
678 . gnus-summary-low-unread-face)
679 ((and (= mark gnus-unread-mark))
680 . gnus-summary-normal-unread-face)
682 . gnus-summary-high-read-face)
684 . gnus-summary-low-read-face)
686 . gnus-summary-normal-read-face))
687 "Controls the highlighting of summary buffer lines.
689 A list of (FORM . FACE) pairs. When deciding how a a particular
690 summary line should be displayed, each form is evaluated. The content
691 of the face field after the first true form is used. You can change
692 how those summary lines are displayed, by editing the face field.
694 You can use the following variables in the FORM field.
696 score: The articles score
697 default: The default article score.
698 below: The score below which articles are automatically marked as read.
699 mark: The articles mark."
700 :group 'gnus-summary-visual
701 :type '(repeat (cons (sexp :tag "Form" nil)
704 ;;; Internal variables
706 (defvar gnus-scores-exclude-files nil)
708 (defvar gnus-summary-display-table
709 ;; Change the display table. Odd characters have a tendency to mess
710 ;; up nicely formatted displays - we make all possible glyphs
711 ;; display only a single character.
713 ;; We start from the standard display table, if any.
714 (let ((table (or (copy-sequence standard-display-table)
715 (make-display-table)))
716 ;; Nix out all the control chars...
718 (while (>= (setq i (1- i)) 0)
720 ;; ... but not newline and cr, of course. (cr is necessary for the
721 ;; selective display).
724 ;; We nix out any glyphs over 126 that are not set already.
726 (while (>= (setq i (1- i)) 127)
727 ;; Only modify if the entry is nil.
729 (aset table i [??]))))
731 "Display table used in summary mode buffers.")
733 (defvar gnus-original-article nil)
734 (defvar gnus-article-internal-prepare-hook nil)
735 (defvar gnus-newsgroup-process-stack nil)
737 (defvar gnus-thread-indent-array nil)
738 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
740 ;; Avoid highlighting in kill files.
741 (defvar gnus-summary-inhibit-highlight nil)
742 (defvar gnus-newsgroup-selected-overlay nil)
743 (defvar gnus-inhibit-limiting nil)
744 (defvar gnus-newsgroup-adaptive-score-file nil)
745 (defvar gnus-current-score-file nil)
746 (defvar gnus-current-move-group nil)
747 (defvar gnus-current-copy-group nil)
748 (defvar gnus-current-crosspost-group nil)
750 (defvar gnus-newsgroup-dependencies nil)
751 (defvar gnus-newsgroup-adaptive nil)
752 (defvar gnus-summary-display-article-function nil)
753 (defvar gnus-summary-highlight-line-function nil
754 "Function called after highlighting a summary line.")
756 (defvar gnus-summary-line-format-alist
757 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
758 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
759 (?s gnus-tmp-subject-or-nil ?s)
760 (?n gnus-tmp-name ?s)
761 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
763 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
765 (?F gnus-tmp-from ?s)
766 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
767 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
768 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
769 (?o (gnus-date-iso8601 gnus-tmp-header) ?s)
770 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
771 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
772 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
773 (?L gnus-tmp-lines ?d)
774 (?I gnus-tmp-indentation ?s)
775 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
776 (?R gnus-tmp-replied ?c)
777 (?\[ gnus-tmp-opening-bracket ?c)
778 (?\] gnus-tmp-closing-bracket ?c)
779 (?\> (make-string gnus-tmp-level ? ) ?s)
780 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
781 (?i gnus-tmp-score ?d)
782 (?z gnus-tmp-score-char ?c)
783 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
784 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
785 (?U gnus-tmp-unread ?c)
786 (?t (gnus-summary-number-of-articles-in-thread
787 (and (boundp 'thread) (car thread)) gnus-tmp-level)
789 (?e (gnus-summary-number-of-articles-in-thread
790 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
792 (?u gnus-tmp-user-defined ?s)
793 (?P (gnus-pick-line-number) ?d))
794 "An alist of format specifications that can appear in summary lines,
795 and what variables they correspond with, along with the type of the
796 variable (string, integer, character, etc).")
798 (defvar gnus-summary-dummy-line-format-alist
799 `((?S gnus-tmp-subject ?s)
800 (?N gnus-tmp-number ?d)
801 (?u gnus-tmp-user-defined ?s)))
803 (defvar gnus-summary-mode-line-format-alist
804 `((?G gnus-tmp-group-name ?s)
805 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
806 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
807 (?A gnus-tmp-article-number ?d)
808 (?Z gnus-tmp-unread-and-unselected ?s)
810 (?U gnus-tmp-unread-and-unticked ?d)
811 (?S gnus-tmp-subject ?s)
812 (?e gnus-tmp-unselected ?d)
813 (?u gnus-tmp-user-defined ?s)
814 (?d (length gnus-newsgroup-dormant) ?d)
815 (?t (length gnus-newsgroup-marked) ?d)
816 (?r (length gnus-newsgroup-reads) ?d)
817 (?E gnus-newsgroup-expunged-tally ?d)
818 (?s (gnus-current-score-file-nondirectory) ?s)))
820 (defvar gnus-last-search-regexp nil
821 "Default regexp for article search command.")
823 (defvar gnus-last-shell-command nil
824 "Default shell command on article.")
826 (defvar gnus-newsgroup-begin nil)
827 (defvar gnus-newsgroup-end nil)
828 (defvar gnus-newsgroup-last-rmail nil)
829 (defvar gnus-newsgroup-last-mail nil)
830 (defvar gnus-newsgroup-last-folder nil)
831 (defvar gnus-newsgroup-last-file nil)
832 (defvar gnus-newsgroup-auto-expire nil)
833 (defvar gnus-newsgroup-active nil)
835 (defvar gnus-newsgroup-data nil)
836 (defvar gnus-newsgroup-data-reverse nil)
837 (defvar gnus-newsgroup-limit nil)
838 (defvar gnus-newsgroup-limits nil)
840 (defvar gnus-newsgroup-unreads nil
841 "List of unread articles in the current newsgroup.")
843 (defvar gnus-newsgroup-unselected nil
844 "List of unselected unread articles in the current newsgroup.")
846 (defvar gnus-newsgroup-reads nil
847 "Alist of read articles and article marks in the current newsgroup.")
849 (defvar gnus-newsgroup-expunged-tally nil)
851 (defvar gnus-newsgroup-marked nil
852 "List of ticked articles in the current newsgroup (a subset of unread art).")
854 (defvar gnus-newsgroup-killed nil
855 "List of ranges of articles that have been through the scoring process.")
857 (defvar gnus-newsgroup-cached nil
858 "List of articles that come from the article cache.")
860 (defvar gnus-newsgroup-saved nil
861 "List of articles that have been saved.")
863 (defvar gnus-newsgroup-kill-headers nil)
865 (defvar gnus-newsgroup-replied nil
866 "List of articles that have been replied to in the current newsgroup.")
868 (defvar gnus-newsgroup-expirable nil
869 "List of articles in the current newsgroup that can be expired.")
871 (defvar gnus-newsgroup-processable nil
872 "List of articles in the current newsgroup that can be processed.")
874 (defvar gnus-newsgroup-bookmarks nil
875 "List of articles in the current newsgroup that have bookmarks.")
877 (defvar gnus-newsgroup-dormant nil
878 "List of dormant articles in the current newsgroup.")
880 (defvar gnus-newsgroup-scored nil
881 "List of scored articles in the current newsgroup.")
883 (defvar gnus-newsgroup-headers nil
884 "List of article headers in the current newsgroup.")
886 (defvar gnus-newsgroup-threads nil)
888 (defvar gnus-newsgroup-prepared nil
889 "Whether the current group has been prepared properly.")
891 (defvar gnus-newsgroup-ancient nil
892 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
894 (defvar gnus-newsgroup-sparse nil)
896 (defvar gnus-current-article nil)
897 (defvar gnus-article-current nil)
898 (defvar gnus-current-headers nil)
899 (defvar gnus-have-all-headers nil)
900 (defvar gnus-last-article nil)
901 (defvar gnus-newsgroup-history nil)
903 (defconst gnus-summary-local-variables
904 '(gnus-newsgroup-name
905 gnus-newsgroup-begin gnus-newsgroup-end
906 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
907 gnus-newsgroup-last-folder gnus-newsgroup-last-file
908 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
909 gnus-newsgroup-unselected gnus-newsgroup-marked
910 gnus-newsgroup-reads gnus-newsgroup-saved
911 gnus-newsgroup-replied gnus-newsgroup-expirable
912 gnus-newsgroup-processable gnus-newsgroup-killed
913 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
914 gnus-newsgroup-headers gnus-newsgroup-threads
915 gnus-newsgroup-prepared gnus-summary-highlight-line-function
916 gnus-current-article gnus-current-headers gnus-have-all-headers
917 gnus-last-article gnus-article-internal-prepare-hook
918 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
919 gnus-newsgroup-scored gnus-newsgroup-kill-headers
920 gnus-thread-expunge-below
921 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
922 (gnus-summary-mark-below . global)
923 gnus-newsgroup-active gnus-scores-exclude-files
924 gnus-newsgroup-history gnus-newsgroup-ancient
925 gnus-newsgroup-sparse gnus-newsgroup-process-stack
926 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
927 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
928 (gnus-newsgroup-expunged-tally . 0)
929 gnus-cache-removable-articles gnus-newsgroup-cached
930 gnus-newsgroup-data gnus-newsgroup-data-reverse
931 gnus-newsgroup-limit gnus-newsgroup-limits)
932 "Variables that are buffer-local to the summary buffers.")
934 ;; Byte-compiler warning.
935 (defvar gnus-article-mode-map)
937 ;; Subject simplification.
939 (defsubst gnus-simplify-subject-re (subject)
940 "Remove \"Re:\" from subject lines."
941 (if (string-match "^[Rr][Ee]: *" subject)
942 (substring subject (match-end 0))
945 (defun gnus-simplify-subject (subject &optional re-only)
946 "Remove `Re:' and words in parentheses.
947 If RE-ONLY is non-nil, strip leading `Re:'s only."
948 (let ((case-fold-search t)) ;Ignore case.
949 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
950 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
951 (setq subject (substring subject (match-end 0))))
952 ;; Remove uninteresting prefixes.
953 (when (and (not re-only)
954 gnus-simplify-ignored-prefixes
955 (string-match gnus-simplify-ignored-prefixes subject))
956 (setq subject (substring subject (match-end 0))))
957 ;; Remove words in parentheses from end.
959 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
960 (setq subject (substring subject 0 (match-beginning 0)))))
961 ;; Return subject string.
964 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
966 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
967 (goto-char (point-min))
968 (while (re-search-forward regexp nil t)
969 (replace-match (or newtext ""))))
971 (defun gnus-simplify-buffer-fuzzy ()
972 "Simplify string in the buffer fuzzily.
973 The string in the accessible portion of the current buffer is simplified.
974 It is assumed to be a single-line subject.
975 Whitespace is generally cleaned up, and miscellaneous leading/trailing
976 matter is removed. Additional things can be deleted by setting
977 gnus-simplify-subject-fuzzy-regexp."
978 (let ((case-fold-search t)
980 (gnus-simplify-buffer-fuzzy-step "\t" " ")
982 (while (not (eq modified-tick (buffer-modified-tick)))
983 (setq modified-tick (buffer-modified-tick))
985 ((listp gnus-simplify-subject-fuzzy-regexp)
986 (mapcar 'gnus-simplify-buffer-fuzzy-step
987 gnus-simplify-subject-fuzzy-regexp))
988 (gnus-simplify-subject-fuzzy-regexp
989 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
990 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
991 (gnus-simplify-buffer-fuzzy-step
992 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
993 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
995 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
996 (gnus-simplify-buffer-fuzzy-step " +" " ")
997 (gnus-simplify-buffer-fuzzy-step " $")
998 (gnus-simplify-buffer-fuzzy-step "^ +")))
1000 (defun gnus-simplify-subject-fuzzy (subject)
1001 "Simplify a subject string fuzzily.
1002 See gnus-simplify-buffer-fuzzy for details."
1004 (gnus-set-work-buffer)
1005 (let ((case-fold-search t))
1007 (inline (gnus-simplify-buffer-fuzzy))
1010 (defsubst gnus-simplify-subject-fully (subject)
1011 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1013 ((null gnus-summary-gather-subject-limit)
1014 (gnus-simplify-subject-re subject))
1015 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1016 (gnus-simplify-subject-fuzzy subject))
1017 ((numberp gnus-summary-gather-subject-limit)
1018 (gnus-limit-string (gnus-simplify-subject-re subject)
1019 gnus-summary-gather-subject-limit))
1023 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1024 "Check whether two subjects are equal. If optional argument
1025 simple-first is t, first argument is already simplified."
1027 ((null simple-first)
1028 (equal (gnus-simplify-subject-fully s1)
1029 (gnus-simplify-subject-fully s2)))
1032 (gnus-simplify-subject-fully s2)))))
1034 (defun gnus-offer-save-summaries ()
1035 "Offer to save all active summary buffers."
1037 (let ((buflist (buffer-list))
1039 ;; Go through all buffers and find all summaries.
1041 (and (setq bufname (buffer-name (car buflist)))
1042 (string-match "Summary" bufname)
1044 (set-buffer bufname)
1045 ;; We check that this is, indeed, a summary buffer.
1046 (and (eq major-mode 'gnus-summary-mode)
1047 ;; Also make sure this isn't bogus.
1048 gnus-newsgroup-prepared))
1049 (push bufname buffers))
1050 (setq buflist (cdr buflist)))
1051 ;; Go through all these summary buffers and offer to save them.
1054 "Update summary buffer %s? "
1055 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
1058 (defun gnus-summary-bubble-group ()
1059 "Increase the score of the current group.
1060 This is a handy function to add to `gnus-summary-exit-hook' to
1061 increase the score of each group you read."
1062 (gnus-group-add-score gnus-newsgroup-name))
1066 ;;; Gnus summary mode
1069 (put 'gnus-summary-mode 'mode-class 'special)
1072 ;; Non-orthogonal keys
1074 (gnus-define-keys gnus-summary-mode-map
1075 " " gnus-summary-next-page
1076 "\177" gnus-summary-prev-page
1077 [delete] gnus-summary-prev-page
1078 "\r" gnus-summary-scroll-up
1079 "n" gnus-summary-next-unread-article
1080 "p" gnus-summary-prev-unread-article
1081 "N" gnus-summary-next-article
1082 "P" gnus-summary-prev-article
1083 "\M-\C-n" gnus-summary-next-same-subject
1084 "\M-\C-p" gnus-summary-prev-same-subject
1085 "\M-n" gnus-summary-next-unread-subject
1086 "\M-p" gnus-summary-prev-unread-subject
1087 "." gnus-summary-first-unread-article
1088 "," gnus-summary-best-unread-article
1089 "\M-s" gnus-summary-search-article-forward
1090 "\M-r" gnus-summary-search-article-backward
1091 "<" gnus-summary-beginning-of-article
1092 ">" gnus-summary-end-of-article
1093 "j" gnus-summary-goto-article
1094 "^" gnus-summary-refer-parent-article
1095 "\M-^" gnus-summary-refer-article
1096 "u" gnus-summary-tick-article-forward
1097 "!" gnus-summary-tick-article-forward
1098 "U" gnus-summary-tick-article-backward
1099 "d" gnus-summary-mark-as-read-forward
1100 "D" gnus-summary-mark-as-read-backward
1101 "E" gnus-summary-mark-as-expirable
1102 "\M-u" gnus-summary-clear-mark-forward
1103 "\M-U" gnus-summary-clear-mark-backward
1104 "k" gnus-summary-kill-same-subject-and-select
1105 "\C-k" gnus-summary-kill-same-subject
1106 "\M-\C-k" gnus-summary-kill-thread
1107 "\M-\C-l" gnus-summary-lower-thread
1108 "e" gnus-summary-edit-article
1109 "#" gnus-summary-mark-as-processable
1110 "\M-#" gnus-summary-unmark-as-processable
1111 "\M-\C-t" gnus-summary-toggle-threads
1112 "\M-\C-s" gnus-summary-show-thread
1113 "\M-\C-h" gnus-summary-hide-thread
1114 "\M-\C-f" gnus-summary-next-thread
1115 "\M-\C-b" gnus-summary-prev-thread
1116 "\M-\C-u" gnus-summary-up-thread
1117 "\M-\C-d" gnus-summary-down-thread
1118 "&" gnus-summary-execute-command
1119 "c" gnus-summary-catchup-and-exit
1120 "\C-w" gnus-summary-mark-region-as-read
1121 "\C-t" gnus-summary-toggle-truncation
1122 "?" gnus-summary-mark-as-dormant
1123 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1124 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1125 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1126 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1127 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1128 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1129 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1130 "=" gnus-summary-expand-window
1131 "\C-x\C-s" gnus-summary-reselect-current-group
1132 "\M-g" gnus-summary-rescan-group
1133 "w" gnus-summary-stop-page-breaking
1134 "\C-c\C-r" gnus-summary-caesar-message
1135 "\M-t" gnus-summary-toggle-mime
1136 "f" gnus-summary-followup
1137 "F" gnus-summary-followup-with-original
1138 "C" gnus-summary-cancel-article
1139 "r" gnus-summary-reply
1140 "R" gnus-summary-reply-with-original
1141 "\C-c\C-f" gnus-summary-mail-forward
1142 "o" gnus-summary-save-article
1143 "\C-o" gnus-summary-save-article-mail
1144 "|" gnus-summary-pipe-output
1145 "\M-k" gnus-summary-edit-local-kill
1146 "\M-K" gnus-summary-edit-global-kill
1148 "\C-c\C-d" gnus-summary-describe-group
1149 "q" gnus-summary-exit
1150 "Q" gnus-summary-exit-no-update
1151 "\C-c\C-i" gnus-info-find-node
1152 gnus-mouse-2 gnus-mouse-pick-article
1153 "m" gnus-summary-mail-other-window
1154 "a" gnus-summary-post-news
1155 "x" gnus-summary-limit-to-unread
1156 "s" gnus-summary-isearch-article
1157 "t" gnus-article-hide-headers
1158 "g" gnus-summary-show-article
1159 "l" gnus-summary-goto-last-article
1160 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1161 "\C-d" gnus-summary-enter-digest-group
1162 "\M-\C-d" gnus-summary-read-document
1164 "*" gnus-cache-enter-article
1165 "\M-*" gnus-cache-remove-article
1166 "\M-&" gnus-summary-universal-argument
1167 "\C-l" gnus-recenter
1168 "I" gnus-summary-increase-score
1169 "L" gnus-summary-lower-score
1171 "V" gnus-summary-score-map
1172 "X" gnus-uu-extract-map
1173 "S" gnus-summary-send-map)
1175 ;; Sort of orthogonal keymap
1176 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1177 "t" gnus-summary-tick-article-forward
1178 "!" gnus-summary-tick-article-forward
1179 "d" gnus-summary-mark-as-read-forward
1180 "r" gnus-summary-mark-as-read-forward
1181 "c" gnus-summary-clear-mark-forward
1182 " " gnus-summary-clear-mark-forward
1183 "e" gnus-summary-mark-as-expirable
1184 "x" gnus-summary-mark-as-expirable
1185 "?" gnus-summary-mark-as-dormant
1186 "b" gnus-summary-set-bookmark
1187 "B" gnus-summary-remove-bookmark
1188 "#" gnus-summary-mark-as-processable
1189 "\M-#" gnus-summary-unmark-as-processable
1190 "S" gnus-summary-limit-include-expunged
1191 "C" gnus-summary-catchup
1192 "H" gnus-summary-catchup-to-here
1193 "\C-c" gnus-summary-catchup-all
1194 "k" gnus-summary-kill-same-subject-and-select
1195 "K" gnus-summary-kill-same-subject
1196 "P" gnus-uu-mark-map)
1198 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1199 "c" gnus-summary-clear-above
1200 "u" gnus-summary-tick-above
1201 "m" gnus-summary-mark-above
1202 "k" gnus-summary-kill-below)
1204 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1205 "/" gnus-summary-limit-to-subject
1206 "n" gnus-summary-limit-to-articles
1207 "w" gnus-summary-pop-limit
1208 "s" gnus-summary-limit-to-subject
1209 "a" gnus-summary-limit-to-author
1210 "u" gnus-summary-limit-to-unread
1211 "m" gnus-summary-limit-to-marks
1212 "v" gnus-summary-limit-to-score
1213 "D" gnus-summary-limit-include-dormant
1214 "d" gnus-summary-limit-exclude-dormant
1215 "t" gnus-summary-limit-to-age
1216 "E" gnus-summary-limit-include-expunged
1217 "c" gnus-summary-limit-exclude-childless-dormant
1218 "C" gnus-summary-limit-mark-excluded-as-read)
1220 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1221 "n" gnus-summary-next-unread-article
1222 "p" gnus-summary-prev-unread-article
1223 "N" gnus-summary-next-article
1224 "P" gnus-summary-prev-article
1225 "\C-n" gnus-summary-next-same-subject
1226 "\C-p" gnus-summary-prev-same-subject
1227 "\M-n" gnus-summary-next-unread-subject
1228 "\M-p" gnus-summary-prev-unread-subject
1229 "f" gnus-summary-first-unread-article
1230 "b" gnus-summary-best-unread-article
1231 "j" gnus-summary-goto-article
1232 "g" gnus-summary-goto-subject
1233 "l" gnus-summary-goto-last-article
1234 "p" gnus-summary-pop-article)
1236 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1237 "k" gnus-summary-kill-thread
1238 "l" gnus-summary-lower-thread
1239 "i" gnus-summary-raise-thread
1240 "T" gnus-summary-toggle-threads
1241 "t" gnus-summary-rethread-current
1242 "^" gnus-summary-reparent-thread
1243 "s" gnus-summary-show-thread
1244 "S" gnus-summary-show-all-threads
1245 "h" gnus-summary-hide-thread
1246 "H" gnus-summary-hide-all-threads
1247 "n" gnus-summary-next-thread
1248 "p" gnus-summary-prev-thread
1249 "u" gnus-summary-up-thread
1250 "o" gnus-summary-top-thread
1251 "d" gnus-summary-down-thread
1252 "#" gnus-uu-mark-thread
1253 "\M-#" gnus-uu-unmark-thread)
1255 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1256 "g" gnus-summary-prepare
1257 "c" gnus-summary-insert-cached-articles)
1259 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1260 "c" gnus-summary-catchup-and-exit
1261 "C" gnus-summary-catchup-all-and-exit
1262 "E" gnus-summary-exit-no-update
1263 "Q" gnus-summary-exit
1264 "Z" gnus-summary-exit
1265 "n" gnus-summary-catchup-and-goto-next-group
1266 "R" gnus-summary-reselect-current-group
1267 "G" gnus-summary-rescan-group
1268 "N" gnus-summary-next-group
1269 "s" gnus-summary-save-newsrc
1270 "P" gnus-summary-prev-group)
1272 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1273 " " gnus-summary-next-page
1274 "n" gnus-summary-next-page
1275 "\177" gnus-summary-prev-page
1276 [delete] gnus-summary-prev-page
1277 "p" gnus-summary-prev-page
1278 "\r" gnus-summary-scroll-up
1279 "<" gnus-summary-beginning-of-article
1280 ">" gnus-summary-end-of-article
1281 "b" gnus-summary-beginning-of-article
1282 "e" gnus-summary-end-of-article
1283 "^" gnus-summary-refer-parent-article
1284 "r" gnus-summary-refer-parent-article
1285 "R" gnus-summary-refer-references
1286 "g" gnus-summary-show-article
1287 "s" gnus-summary-isearch-article
1288 "P" gnus-summary-print-article)
1290 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1291 "b" gnus-article-add-buttons
1292 "B" gnus-article-add-buttons-to-head
1293 "o" gnus-article-treat-overstrike
1294 "e" gnus-article-emphasize
1295 "w" gnus-article-fill-cited-article
1296 "c" gnus-article-remove-cr
1297 "q" gnus-article-de-quoted-unreadable
1298 "f" gnus-article-display-x-face
1299 "l" gnus-summary-stop-page-breaking
1300 "r" gnus-summary-caesar-message
1301 "t" gnus-article-hide-headers
1302 "v" gnus-summary-verbose-headers
1303 "m" gnus-summary-toggle-mime)
1305 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1306 "a" gnus-article-hide
1307 "h" gnus-article-hide-headers
1308 "b" gnus-article-hide-boring-headers
1309 "s" gnus-article-hide-signature
1310 "c" gnus-article-hide-citation
1311 "p" gnus-article-hide-pgp
1312 "P" gnus-article-hide-pem
1313 "\C-c" gnus-article-hide-citation-maybe)
1315 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1316 "a" gnus-article-highlight
1317 "h" gnus-article-highlight-headers
1318 "c" gnus-article-highlight-citation
1319 "s" gnus-article-highlight-signature)
1321 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1322 "z" gnus-article-date-ut
1323 "u" gnus-article-date-ut
1324 "l" gnus-article-date-local
1325 "e" gnus-article-date-lapsed
1326 "o" gnus-article-date-original
1327 "s" gnus-article-date-user)
1329 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1330 "t" gnus-article-remove-trailing-blank-lines
1331 "l" gnus-article-strip-leading-blank-lines
1332 "m" gnus-article-strip-multiple-blank-lines
1333 "a" gnus-article-strip-blank-lines)
1335 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1337 "f" gnus-summary-fetch-faq
1338 "d" gnus-summary-describe-group
1339 "h" gnus-summary-describe-briefly
1340 "i" gnus-info-find-node)
1342 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1343 "e" gnus-summary-expire-articles
1344 "\M-\C-e" gnus-summary-expire-articles-now
1345 "\177" gnus-summary-delete-article
1346 [delete] gnus-summary-delete-article
1347 "m" gnus-summary-move-article
1348 "r" gnus-summary-respool-article
1349 "w" gnus-summary-edit-article
1350 "c" gnus-summary-copy-article
1351 "B" gnus-summary-crosspost-article
1352 "q" gnus-summary-respool-query
1353 "i" gnus-summary-import-article
1354 "p" gnus-summary-article-posted-p)
1356 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1357 "o" gnus-summary-save-article
1358 "m" gnus-summary-save-article-mail
1359 "F" gnus-summary-write-article-file
1360 "r" gnus-summary-save-article-rmail
1361 "f" gnus-summary-save-article-file
1362 "b" gnus-summary-save-article-body-file
1363 "h" gnus-summary-save-article-folder
1364 "v" gnus-summary-save-article-vm
1365 "p" gnus-summary-pipe-output
1366 "s" gnus-soup-add-article))
1368 (defun gnus-summary-make-menu-bar ()
1369 (gnus-turn-off-edit-menu 'summary)
1371 (unless (boundp 'gnus-summary-misc-menu)
1374 gnus-summary-kill-menu gnus-summary-mode-map ""
1379 ["Enter score..." gnus-summary-score-entry t]
1380 ["Customize" gnus-score-customize t])
1381 (gnus-make-score-map 'increase)
1382 (gnus-make-score-map 'lower)
1384 ["Kill below" gnus-summary-kill-below t]
1385 ["Mark above" gnus-summary-mark-above t]
1386 ["Tick above" gnus-summary-tick-above t]
1387 ["Clear above" gnus-summary-clear-above t])
1388 ["Current score" gnus-summary-current-score t]
1389 ["Set score" gnus-summary-set-score t]
1390 ["Switch current score file..." gnus-score-change-score-file t]
1391 ["Set mark below..." gnus-score-set-mark-below t]
1392 ["Set expunge below..." gnus-score-set-expunge-below t]
1393 ["Edit current score file" gnus-score-edit-current-scores t]
1394 ["Edit score file" gnus-score-edit-file t]
1395 ["Trace score" gnus-score-find-trace t]
1396 ["Find words" gnus-score-find-favourite-words t]
1397 ["Rescore buffer" gnus-summary-rescore t]
1398 ["Increase score..." gnus-summary-increase-score t]
1399 ["Lower score..." gnus-summary-lower-score t]))))
1402 ["Ask" (gnus-score-set-default 'gnus-score-default-header nil)
1404 :selected (null gnus-score-default-header)]
1405 ["From" (gnus-score-set-default 'gnus-score-default-header 'a)
1407 :selected (eq gnus-score-default-header 'a)]
1408 ["Subject" (gnus-score-set-default 'gnus-score-default-header 's)
1410 :selected (eq gnus-score-default-header 's)]
1412 (gnus-score-set-default 'gnus-score-default-header 'b)
1414 :selected (eq gnus-score-default-header 'b )]
1416 (gnus-score-set-default 'gnus-score-default-header 'h)
1418 :selected (eq gnus-score-default-header 'h )]
1419 ["Message-ID" (gnus-score-set-default 'gnus-score-default-header 'i)
1421 :selected (eq gnus-score-default-header 'i )]
1422 ["Thread" (gnus-score-set-default 'gnus-score-default-header 't)
1424 :selected (eq gnus-score-default-header 't )]
1426 (gnus-score-set-default 'gnus-score-default-header 'x)
1428 :selected (eq gnus-score-default-header 'x )]
1429 ["Lines" (gnus-score-set-default 'gnus-score-default-header 'l)
1431 :selected (eq gnus-score-default-header 'l )]
1432 ["Date" (gnus-score-set-default 'gnus-score-default-header 'd)
1434 :selected (eq gnus-score-default-header 'd )]
1435 ["Followups to author"
1436 (gnus-score-set-default 'gnus-score-default-header 'f)
1438 :selected (eq gnus-score-default-header 'f )])
1440 ["Ask" (gnus-score-set-default 'gnus-score-default-type nil)
1442 :selected (null gnus-score-default-type)]
1443 ;; The `:active' key is commented out in the following,
1444 ;; because the GNU Emacs hack to support radio buttons use
1445 ;; active to indicate which button is selected.
1446 ["Substring" (gnus-score-set-default 'gnus-score-default-type 's)
1448 ;; :active (not (memq gnus-score-default-header '(l d)))
1449 :selected (eq gnus-score-default-type 's)]
1450 ["Regexp" (gnus-score-set-default 'gnus-score-default-type 'r)
1452 ;; :active (not (memq gnus-score-default-header '(l d)))
1453 :selected (eq gnus-score-default-type 'r)]
1454 ["Exact" (gnus-score-set-default 'gnus-score-default-type 'e)
1456 ;; :active (not (memq gnus-score-default-header '(l d)))
1457 :selected (eq gnus-score-default-type 'e)]
1458 ["Fuzzy" (gnus-score-set-default 'gnus-score-default-type 'f)
1460 ;; :active (not (memq gnus-score-default-header '(l d)))
1461 :selected (eq gnus-score-default-type 'f)]
1462 ["Before date" (gnus-score-set-default 'gnus-score-default-type 'b)
1464 ;; :active (eq (gnus-score-default-header 'd))
1465 :selected (eq gnus-score-default-type 'b)]
1466 ["At date" (gnus-score-set-default 'gnus-score-default-type 'n)
1468 ;; :active (eq (gnus-score-default-header 'd))
1469 :selected (eq gnus-score-default-type 'n)]
1470 ["After date" (gnus-score-set-default 'gnus-score-default-type 'a)
1472 ;; :active (eq (gnus-score-default-header 'd))
1473 :selected (eq gnus-score-default-type 'a)]
1475 (gnus-score-set-default 'gnus-score-default-type '<)
1477 ;; :active (eq (gnus-score-default-header 'l))
1478 :selected (eq gnus-score-default-type '<)]
1480 (gnus-score-set-default 'gnus-score-default-type '=)
1482 ;; :active (eq (gnus-score-default-header 'l))
1483 :selected (eq gnus-score-default-type '=)]
1484 ["Greater than number"
1485 (gnus-score-set-default 'gnus-score-default-type '>)
1487 ;; :active (eq (gnus-score-default-header 'l))
1488 :selected (eq gnus-score-default-type '>)])
1489 ["Default fold" gnus-score-default-fold-toggle
1491 :selected gnus-score-default-fold]
1493 ["Ask" (gnus-score-set-default 'gnus-score-default-duration nil)
1495 :selected (null gnus-score-default-duration)]
1497 (gnus-score-set-default 'gnus-score-default-duration 'p)
1499 :selected (eq gnus-score-default-duration 'p)]
1501 (gnus-score-set-default 'gnus-score-default-duration 't)
1503 :selected (eq gnus-score-default-duration 't)]
1505 (gnus-score-set-default 'gnus-score-default-duration 'i)
1507 :selected (eq gnus-score-default-duration 'i)]))
1510 gnus-summary-article-menu gnus-summary-mode-map ""
1513 ["All" gnus-article-hide t]
1514 ["Headers" gnus-article-hide-headers t]
1515 ["Signature" gnus-article-hide-signature t]
1516 ["Citation" gnus-article-hide-citation t]
1517 ["PGP" gnus-article-hide-pgp t]
1518 ["Boring headers" gnus-article-hide-boring-headers t])
1520 ["All" gnus-article-highlight t]
1521 ["Headers" gnus-article-highlight-headers t]
1522 ["Signature" gnus-article-highlight-signature t]
1523 ["Citation" gnus-article-highlight-citation t])
1525 ["Local" gnus-article-date-local t]
1526 ["UT" gnus-article-date-ut t]
1527 ["Original" gnus-article-date-original t]
1528 ["Lapsed" gnus-article-date-lapsed t]
1529 ["User-defined" gnus-article-date-user t])
1532 ["Leading" gnus-article-strip-leading-blank-lines t]
1533 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1534 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1535 ["All of the above" gnus-article-strip-blank-lines t])
1536 ["Overstrike" gnus-article-treat-overstrike t]
1537 ["Emphasis" gnus-article-emphasize t]
1538 ["Word wrap" gnus-article-fill-cited-article t]
1539 ["CR" gnus-article-remove-cr t]
1540 ["Show X-Face" gnus-article-display-x-face t]
1541 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1542 ["Rot 13" gnus-summary-caesar-message t]
1543 ["Unix pipe" gnus-summary-pipe-message t]
1544 ["Add buttons" gnus-article-add-buttons t]
1545 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1546 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1547 ["Toggle MIME" gnus-summary-toggle-mime t]
1548 ["Verbose header" gnus-summary-verbose-headers t]
1549 ["Toggle header" gnus-summary-toggle-header t])
1551 ["Save in default format" gnus-summary-save-article t]
1552 ["Save in file" gnus-summary-save-article-file t]
1553 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1554 ["Write to file" gnus-summary-write-article-mail t]
1555 ["Save in MH folder" gnus-summary-save-article-folder t]
1556 ["Save in VM folder" gnus-summary-save-article-vm t]
1557 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1558 ["Save body in file" gnus-summary-save-article-body-file t]
1559 ["Pipe through a filter" gnus-summary-pipe-output t]
1560 ["Add to SOUP packet" gnus-soup-add-article t]
1561 ["Print" gnus-summary-print-article t])
1563 ["Respool article..." gnus-summary-respool-article t]
1564 ["Move article..." gnus-summary-move-article
1565 (gnus-check-backend-function
1566 'request-move-article gnus-newsgroup-name)]
1567 ["Copy article..." gnus-summary-copy-article t]
1568 ["Crosspost article..." gnus-summary-crosspost-article
1569 (gnus-check-backend-function
1570 'request-replace-article gnus-newsgroup-name)]
1571 ["Import file..." gnus-summary-import-article t]
1572 ["Check if posted" gnus-summary-article-posted-p t]
1573 ["Edit article" gnus-summary-edit-article
1574 (not (gnus-group-read-only-p))]
1575 ["Delete article" gnus-summary-delete-article
1576 (gnus-check-backend-function
1577 'request-expire-articles gnus-newsgroup-name)]
1578 ["Query respool" gnus-summary-respool-query t]
1579 ["Delete expirable articles" gnus-summary-expire-articles-now
1580 (gnus-check-backend-function
1581 'request-expire-articles gnus-newsgroup-name)])
1583 ["Uudecode" gnus-uu-decode-uu t]
1584 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1585 ["Unshar" gnus-uu-decode-unshar t]
1586 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1587 ["Save" gnus-uu-decode-save t]
1588 ["Binhex" gnus-uu-decode-binhex t]
1589 ["Postscript" gnus-uu-decode-postscript t])
1591 ["Enter article" gnus-cache-enter-article t]
1592 ["Remove article" gnus-cache-remove-article t])
1593 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1594 ["Isearch article..." gnus-summary-isearch-article t]
1595 ["Beginning of the article" gnus-summary-beginning-of-article t]
1596 ["End of the article" gnus-summary-end-of-article t]
1597 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1598 ["Fetch referenced articles" gnus-summary-refer-references t]
1599 ["Fetch article with id..." gnus-summary-refer-article t]
1600 ["Redisplay" gnus-summary-show-article t]))
1603 gnus-summary-thread-menu gnus-summary-mode-map ""
1605 ["Toggle threading" gnus-summary-toggle-threads t]
1606 ["Hide threads" gnus-summary-hide-all-threads t]
1607 ["Show threads" gnus-summary-show-all-threads t]
1608 ["Hide thread" gnus-summary-hide-thread t]
1609 ["Show thread" gnus-summary-show-thread t]
1610 ["Go to next thread" gnus-summary-next-thread t]
1611 ["Go to previous thread" gnus-summary-prev-thread t]
1612 ["Go down thread" gnus-summary-down-thread t]
1613 ["Go up thread" gnus-summary-up-thread t]
1614 ["Top of thread" gnus-summary-top-thread t]
1615 ["Mark thread as read" gnus-summary-kill-thread t]
1616 ["Lower thread score" gnus-summary-lower-thread t]
1617 ["Raise thread score" gnus-summary-raise-thread t]
1618 ["Rethread current" gnus-summary-rethread-current t]
1622 gnus-summary-post-menu gnus-summary-mode-map ""
1624 ["Post an article" gnus-summary-post-news t]
1625 ["Followup" gnus-summary-followup t]
1626 ["Followup and yank" gnus-summary-followup-with-original t]
1627 ["Supersede article" gnus-summary-supersede-article t]
1628 ["Cancel article" gnus-summary-cancel-article t]
1629 ["Reply" gnus-summary-reply t]
1630 ["Reply and yank" gnus-summary-reply-with-original t]
1631 ["Wide reply" gnus-summary-wide-reply t]
1632 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1633 ["Mail forward" gnus-summary-mail-forward t]
1634 ["Post forward" gnus-summary-post-forward t]
1635 ["Digest and mail" gnus-uu-digest-mail-forward t]
1636 ["Digest and post" gnus-uu-digest-post-forward t]
1637 ["Resend message" gnus-summary-resend-message t]
1638 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1639 ["Send a mail" gnus-summary-mail-other-window t]
1640 ["Uuencode and post" gnus-uu-post-news t]
1641 ["Followup via news" gnus-summary-followup-to-mail t]
1642 ["Followup via news and yank"
1643 gnus-summary-followup-to-mail-with-original t]
1645 ;;["Send" gnus-summary-send-draft t]
1646 ;;["Send bounced" gnus-resend-bounced-mail t])
1650 gnus-summary-misc-menu gnus-summary-mode-map ""
1653 ["Mark as read" gnus-summary-mark-as-read-forward t]
1654 ["Mark same subject and select"
1655 gnus-summary-kill-same-subject-and-select t]
1656 ["Mark same subject" gnus-summary-kill-same-subject t]
1657 ["Catchup" gnus-summary-catchup t]
1658 ["Catchup all" gnus-summary-catchup-all t]
1659 ["Catchup to here" gnus-summary-catchup-to-here t]
1660 ["Catchup region" gnus-summary-mark-region-as-read t]
1661 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1663 ["Tick" gnus-summary-tick-article-forward t]
1664 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1665 ["Remove marks" gnus-summary-clear-mark-forward t]
1666 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1667 ["Set bookmark" gnus-summary-set-bookmark t]
1668 ["Remove bookmark" gnus-summary-remove-bookmark t])
1670 ["Marks..." gnus-summary-limit-to-marks t]
1671 ["Subject..." gnus-summary-limit-to-subject t]
1672 ["Author..." gnus-summary-limit-to-author t]
1673 ["Age..." gnus-summary-limit-to-age t]
1674 ["Score" gnus-summary-limit-to-score t]
1675 ["Unread" gnus-summary-limit-to-unread t]
1676 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1677 ["Articles" gnus-summary-limit-to-articles t]
1678 ["Pop limit" gnus-summary-pop-limit t]
1679 ["Show dormant" gnus-summary-limit-include-dormant t]
1680 ["Hide childless dormant"
1681 gnus-summary-limit-exclude-childless-dormant t]
1682 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1683 ["Show expunged" gnus-summary-show-all-expunged t])
1685 ["Set mark" gnus-summary-mark-as-processable t]
1686 ["Remove mark" gnus-summary-unmark-as-processable t]
1687 ["Remove all marks" gnus-summary-unmark-all-processable t]
1688 ["Mark above" gnus-uu-mark-over t]
1689 ["Mark series" gnus-uu-mark-series t]
1690 ["Mark region" gnus-uu-mark-region t]
1691 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1692 ["Mark all" gnus-uu-mark-all t]
1693 ["Mark buffer" gnus-uu-mark-buffer t]
1694 ["Mark sparse" gnus-uu-mark-sparse t]
1695 ["Mark thread" gnus-uu-mark-thread t]
1696 ["Unmark thread" gnus-uu-unmark-thread t]
1697 ("Process Mark Sets"
1698 ["Kill" gnus-summary-kill-process-mark t]
1699 ["Yank" gnus-summary-yank-process-mark
1700 gnus-newsgroup-process-stack]
1701 ["Save" gnus-summary-save-process-mark t]))
1703 ["Page forward" gnus-summary-next-page t]
1704 ["Page backward" gnus-summary-prev-page t]
1705 ["Line forward" gnus-summary-scroll-up t])
1707 ["Next unread article" gnus-summary-next-unread-article t]
1708 ["Previous unread article" gnus-summary-prev-unread-article t]
1709 ["Next article" gnus-summary-next-article t]
1710 ["Previous article" gnus-summary-prev-article t]
1711 ["Next unread subject" gnus-summary-next-unread-subject t]
1712 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1713 ["Next article same subject" gnus-summary-next-same-subject t]
1714 ["Previous article same subject" gnus-summary-prev-same-subject t]
1715 ["First unread article" gnus-summary-first-unread-article t]
1716 ["Best unread article" gnus-summary-best-unread-article t]
1717 ["Go to subject number..." gnus-summary-goto-subject t]
1718 ["Go to article number..." gnus-summary-goto-article t]
1719 ["Go to the last article" gnus-summary-goto-last-article t]
1720 ["Pop article off history" gnus-summary-pop-article t])
1722 ["Sort by number" gnus-summary-sort-by-number t]
1723 ["Sort by author" gnus-summary-sort-by-author t]
1724 ["Sort by subject" gnus-summary-sort-by-subject t]
1725 ["Sort by date" gnus-summary-sort-by-date t]
1726 ["Sort by score" gnus-summary-sort-by-score t]
1727 ["Sort by lines" gnus-summary-sort-by-lines t])
1729 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1730 ["Describe group" gnus-summary-describe-group t]
1731 ["Read manual" gnus-info-find-node t])
1733 ["Pick and read" gnus-pick-mode t]
1734 ["Binary" gnus-binary-mode t])
1736 ["Regenerate" gnus-summary-prepare t]
1737 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1738 ["Toggle threading" gnus-summary-toggle-threads t])
1739 ["Filter articles..." gnus-summary-execute-command t]
1740 ["Run command on subjects..." gnus-summary-universal-argument t]
1741 ["Search articles forward..." gnus-summary-search-article-forward t]
1742 ["Search articles backward..." gnus-summary-search-article-backward t]
1743 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1744 ["Expand window" gnus-summary-expand-window t]
1745 ["Expire expirable articles" gnus-summary-expire-articles
1746 (gnus-check-backend-function
1747 'request-expire-articles gnus-newsgroup-name)]
1748 ["Edit local kill file" gnus-summary-edit-local-kill t]
1749 ["Edit main kill file" gnus-summary-edit-global-kill t]
1751 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1752 ["Catchup all and exit" gnus-summary-catchup-and-exit t]
1753 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1754 ["Exit group" gnus-summary-exit t]
1755 ["Exit group without updating" gnus-summary-exit-no-update t]
1756 ["Exit and goto next group" gnus-summary-next-group t]
1757 ["Exit and goto prev group" gnus-summary-prev-group t]
1758 ["Reselect group" gnus-summary-reselect-current-group t]
1759 ["Rescan group" gnus-summary-rescan-group t]
1760 ["Update dribble" gnus-summary-save-newsrc t])))
1762 (run-hooks 'gnus-summary-menu-hook)))
1764 (defun gnus-score-set-default (var value)
1765 "A version of set that updates the GNU Emacs menu-bar."
1767 ;; It is the message that forces the active status to be updated.
1770 (defun gnus-make-score-map (type)
1771 "Make a summary score map of type TYPE."
1774 (let ((headers '(("author" "from" string)
1775 ("subject" "subject" string)
1776 ("article body" "body" string)
1777 ("article head" "head" string)
1778 ("xref" "xref" string)
1779 ("lines" "lines" number)
1780 ("followups to author" "followup" string)))
1781 (types '((number ("less than" <)
1784 (string ("substring" s)
1788 (perms '(("temporary" (current-time-string))
1796 (if (eq type 'lower)
1801 (setq header (car headers))
1807 (let ((ts (cdr (assoc (nth 2 header) types)))
1823 'gnus-summary-score-entry
1825 (if (or (string= (nth 1 header)
1827 (string= (nth 1 header)
1830 (list 'gnus-summary-header
1832 (list 'quote (nth 1 (car ts)))
1833 (list 'gnus-score-default nil)
1839 (list (nreverse outp))))
1842 (list (nreverse outt))))
1844 (setq headers (cdr headers)))
1845 (list (nreverse outh))))))))
1849 (defun gnus-summary-mode (&optional group)
1850 "Major mode for reading articles.
1852 All normal editing commands are switched off.
1853 \\<gnus-summary-mode-map>
1854 Each line in this buffer represents one article. To read an
1855 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1856 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1859 You can also post articles and send mail from this buffer. To
1860 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1861 of an article, type `\\[gnus-summary-reply]'.
1863 There are approx. one gazillion commands you can execute in this
1864 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1866 The following commands are available:
1868 \\{gnus-summary-mode-map}"
1870 (when (gnus-visual-p 'summary-menu 'menu)
1871 (gnus-summary-make-menu-bar))
1872 (kill-all-local-variables)
1873 (gnus-summary-make-local-variables)
1874 (gnus-make-thread-indent-array)
1875 (gnus-simplify-mode-line)
1876 (setq major-mode 'gnus-summary-mode)
1877 (setq mode-name "Summary")
1878 (make-local-variable 'minor-mode-alist)
1879 (use-local-map gnus-summary-mode-map)
1880 (buffer-disable-undo (current-buffer))
1881 (setq buffer-read-only t) ;Disable modification
1882 (setq truncate-lines t)
1883 (setq selective-display t)
1884 (setq selective-display-ellipses t) ;Display `...'
1885 (setq buffer-display-table gnus-summary-display-table)
1886 (gnus-set-default-directory)
1887 (setq gnus-newsgroup-name group)
1888 (make-local-variable 'gnus-summary-line-format)
1889 (make-local-variable 'gnus-summary-line-format-spec)
1890 (make-local-variable 'gnus-summary-mark-positions)
1891 (gnus-make-local-hook 'post-command-hook)
1892 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
1893 (run-hooks 'gnus-summary-mode-hook)
1894 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1895 (gnus-update-summary-mark-positions))
1897 (defun gnus-summary-make-local-variables ()
1898 "Make all the local summary buffer variables."
1899 (let ((locals gnus-summary-local-variables)
1901 (while (setq local (pop locals))
1904 (if (eq (cdr local) 'global)
1905 ;; Copy the global value of the variable.
1906 (setq global (symbol-value (car local)))
1907 ;; Use the value from the list.
1908 (setq global (eval (cdr local))))
1909 (make-local-variable (car local))
1910 (set (car local) global))
1911 ;; Simple nil-valued local variable.
1912 (make-local-variable local)
1915 (defun gnus-summary-clear-local-variables ()
1916 (let ((locals gnus-summary-local-variables))
1918 (if (consp (car locals))
1919 (and (vectorp (caar locals))
1920 (set (caar locals) nil))
1921 (and (vectorp (car locals))
1922 (set (car locals) nil)))
1923 (setq locals (cdr locals)))))
1925 ;; Summary data functions.
1927 (defmacro gnus-data-number (data)
1930 (defmacro gnus-data-set-number (data number)
1931 `(setcar ,data ,number))
1933 (defmacro gnus-data-mark (data)
1936 (defmacro gnus-data-set-mark (data mark)
1937 `(setcar (nthcdr 1 ,data) ,mark))
1939 (defmacro gnus-data-pos (data)
1942 (defmacro gnus-data-set-pos (data pos)
1943 `(setcar (nthcdr 2 ,data) ,pos))
1945 (defmacro gnus-data-header (data)
1948 (defmacro gnus-data-set-header (data header)
1949 `(setf (nth 3 ,data) ,header))
1951 (defmacro gnus-data-level (data)
1954 (defmacro gnus-data-unread-p (data)
1955 `(= (nth 1 ,data) gnus-unread-mark))
1957 (defmacro gnus-data-read-p (data)
1958 `(/= (nth 1 ,data) gnus-unread-mark))
1960 (defmacro gnus-data-pseudo-p (data)
1961 `(consp (nth 3 ,data)))
1963 (defmacro gnus-data-find (number)
1964 `(assq ,number gnus-newsgroup-data))
1966 (defmacro gnus-data-find-list (number &optional data)
1967 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
1968 (memq (assq ,number bdata)
1971 (defmacro gnus-data-make (number mark pos header level)
1972 `(list ,number ,mark ,pos ,header ,level))
1974 (defun gnus-data-enter (after-article number mark pos header level offset)
1975 (let ((data (gnus-data-find-list after-article)))
1977 (error "No such article: %d" after-article))
1978 (setcdr data (cons (gnus-data-make number mark pos header level)
1980 (setq gnus-newsgroup-data-reverse nil)
1981 (gnus-data-update-list (cddr data) offset)))
1983 (defun gnus-data-enter-list (after-article list &optional offset)
1985 (let ((data (and after-article (gnus-data-find-list after-article)))
1987 (or data (not after-article) (error "No such article: %d" after-article))
1988 ;; Find the last element in the list to be spliced into the main
1991 (setq list (cdr list)))
1994 (setcdr list gnus-newsgroup-data)
1995 (setq gnus-newsgroup-data ilist)
1997 (gnus-data-update-list (cdr list) offset)))
1998 (setcdr list (cdr data))
2001 (gnus-data-update-list (cdr list) offset)))
2002 (setq gnus-newsgroup-data-reverse nil))))
2004 (defun gnus-data-remove (article &optional offset)
2005 (let ((data gnus-newsgroup-data))
2006 (if (= (gnus-data-number (car data)) article)
2008 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2009 gnus-newsgroup-data-reverse nil)
2011 (gnus-data-update-list gnus-newsgroup-data offset)))
2013 (when (= (gnus-data-number (cadr data)) article)
2014 (setcdr data (cddr data))
2016 (gnus-data-update-list (cdr data) offset))
2018 gnus-newsgroup-data-reverse nil))
2019 (setq data (cdr data))))))
2021 (defmacro gnus-data-list (backward)
2023 (or gnus-newsgroup-data-reverse
2024 (setq gnus-newsgroup-data-reverse
2025 (reverse gnus-newsgroup-data)))
2026 gnus-newsgroup-data))
2028 (defun gnus-data-update-list (data offset)
2029 "Add OFFSET to the POS of all data entries in DATA."
2031 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2032 (setq data (cdr data))))
2034 (defun gnus-data-compute-positions ()
2035 "Compute the positions of all articles."
2036 (let ((data gnus-newsgroup-data)
2039 (when (setq pos (text-property-any
2040 (point-min) (point-max)
2041 'gnus-number (gnus-data-number (car data))))
2042 (gnus-data-set-pos (car data) (+ pos 3)))
2043 (setq data (cdr data)))))
2045 (defun gnus-summary-article-pseudo-p (article)
2046 "Say whether this article is a pseudo article or not."
2047 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2049 (defmacro gnus-summary-article-sparse-p (article)
2050 "Say whether this article is a sparse article or not."
2051 ` (memq ,article gnus-newsgroup-sparse))
2053 (defmacro gnus-summary-article-ancient-p (article)
2054 "Say whether this article is a sparse article or not."
2055 `(memq ,article gnus-newsgroup-ancient))
2057 (defun gnus-article-parent-p (number)
2058 "Say whether this article is a parent or not."
2059 (let ((data (gnus-data-find-list number)))
2060 (and (cdr data) ; There has to be an article after...
2061 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2062 (gnus-data-level (nth 1 data))))))
2064 (defun gnus-article-children (number)
2065 "Return a list of all children to NUMBER."
2066 (let* ((data (gnus-data-find-list number))
2067 (level (gnus-data-level (car data)))
2069 (setq data (cdr data))
2071 (= (gnus-data-level (car data)) (1+ level)))
2072 (push (gnus-data-number (car data)) children)
2073 (setq data (cdr data)))
2076 (defmacro gnus-summary-skip-intangible ()
2077 "If the current article is intangible, then jump to a different article."
2078 '(let ((to (get-text-property (point) 'gnus-intangible)))
2079 (and to (gnus-summary-goto-subject to))))
2081 (defmacro gnus-summary-article-intangible-p ()
2082 "Say whether this article is intangible or not."
2083 '(get-text-property (point) 'gnus-intangible))
2085 (defun gnus-article-read-p (article)
2086 "Say whether ARTICLE is read or not."
2087 (not (or (memq article gnus-newsgroup-marked)
2088 (memq article gnus-newsgroup-unreads)
2089 (memq article gnus-newsgroup-unselected)
2090 (memq article gnus-newsgroup-dormant))))
2092 ;; Some summary mode macros.
2094 (defmacro gnus-summary-article-number ()
2095 "The article number of the article on the current line.
2096 If there isn's an article number here, then we return the current
2099 (gnus-summary-skip-intangible)
2100 (or (get-text-property (point) 'gnus-number)
2101 (gnus-summary-last-subject))))
2103 (defmacro gnus-summary-article-header (&optional number)
2104 `(gnus-data-header (gnus-data-find
2105 ,(or number '(gnus-summary-article-number)))))
2107 (defmacro gnus-summary-thread-level (&optional number)
2108 `(if (and (eq gnus-summary-make-false-root 'dummy)
2109 (get-text-property (point) 'gnus-intangible))
2111 (gnus-data-level (gnus-data-find
2112 ,(or number '(gnus-summary-article-number))))))
2114 (defmacro gnus-summary-article-mark (&optional number)
2115 `(gnus-data-mark (gnus-data-find
2116 ,(or number '(gnus-summary-article-number)))))
2118 (defmacro gnus-summary-article-pos (&optional number)
2119 `(gnus-data-pos (gnus-data-find
2120 ,(or number '(gnus-summary-article-number)))))
2122 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2123 (defmacro gnus-summary-article-subject (&optional number)
2124 "Return current subject string or nil if nothing."
2127 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2128 '(gnus-data-header (assq (gnus-summary-article-number)
2129 gnus-newsgroup-data)))))
2132 (mail-header-subject headers))))
2134 (defmacro gnus-summary-article-score (&optional number)
2135 "Return current article score."
2136 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2137 gnus-newsgroup-scored))
2138 gnus-summary-default-score 0))
2140 (defun gnus-summary-article-children (&optional number)
2141 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2142 (level (gnus-data-level (car data)))
2144 (while (and (setq data (cdr data))
2145 (> (setq l (gnus-data-level (car data))) level))
2146 (and (= (1+ level) l)
2147 (push (gnus-data-number (car data))
2149 (nreverse children)))
2151 (defun gnus-summary-article-parent (&optional number)
2152 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2153 (gnus-data-list t)))
2154 (level (gnus-data-level (car data))))
2156 () ; This is a root.
2157 ;; We search until we find an article with a level less than
2158 ;; this one. That function has to be the parent.
2159 (while (and (setq data (cdr data))
2160 (not (< (gnus-data-level (car data)) level))))
2161 (and data (gnus-data-number (car data))))))
2163 (defun gnus-unread-mark-p (mark)
2164 "Say whether MARK is the unread mark."
2165 (= mark gnus-unread-mark))
2167 (defun gnus-read-mark-p (mark)
2168 "Say whether MARK is one of the marks that mark as read.
2169 This is all marks except unread, ticked, dormant, and expirable."
2170 (not (or (= mark gnus-unread-mark)
2171 (= mark gnus-ticked-mark)
2172 (= mark gnus-dormant-mark)
2173 (= mark gnus-expirable-mark))))
2175 (defmacro gnus-article-mark (number)
2177 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2178 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2179 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2180 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2181 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2182 gnus-ancient-mark))))
2184 ;; Saving hidden threads.
2186 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2187 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2189 (defmacro gnus-save-hidden-threads (&rest forms)
2190 "Save hidden threads, eval FORMS, and restore the hidden threads."
2191 (let ((config (make-symbol "config")))
2192 `(let ((,config (gnus-hidden-threads-configuration)))
2196 (gnus-restore-hidden-threads-configuration ,config)))))
2198 (defun gnus-hidden-threads-configuration ()
2199 "Return the current hidden threads configuration."
2202 (goto-char (point-min))
2203 (while (search-forward "\r" nil t)
2204 (push (1- (point)) config))
2207 (defun gnus-restore-hidden-threads-configuration (config)
2208 "Restore hidden threads configuration from CONFIG."
2209 (let (point buffer-read-only)
2210 (while (setq point (pop config))
2211 (when (and (< point (point-max))
2213 (= (following-char) ?\n))
2214 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2216 ;; Various summary mode internalish functions.
2218 (defun gnus-mouse-pick-article (e)
2221 (gnus-summary-next-page nil t))
2223 (defun gnus-summary-setup-buffer (group)
2224 "Initialize summary buffer."
2225 (let ((buffer (concat "*Summary " group "*")))
2226 (if (get-buffer buffer)
2229 (setq gnus-summary-buffer (current-buffer))
2230 (not gnus-newsgroup-prepared))
2231 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2232 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
2233 (gnus-add-current-to-buffer-list)
2234 (gnus-summary-mode group)
2236 (gnus-carpal-setup-buffer 'summary))
2237 (unless gnus-single-article-buffer
2238 (make-local-variable 'gnus-article-buffer)
2239 (make-local-variable 'gnus-article-current)
2240 (make-local-variable 'gnus-original-article-buffer))
2241 (setq gnus-newsgroup-name group)
2244 (defun gnus-set-global-variables ()
2245 ;; Set the global equivalents of the summary buffer-local variables
2246 ;; to the latest values they had. These reflect the summary buffer
2247 ;; that was in action when the last article was fetched.
2248 (when (eq major-mode 'gnus-summary-mode)
2249 (setq gnus-summary-buffer (current-buffer))
2250 (let ((name gnus-newsgroup-name)
2251 (marked gnus-newsgroup-marked)
2252 (unread gnus-newsgroup-unreads)
2253 (headers gnus-current-headers)
2254 (data gnus-newsgroup-data)
2255 (summary gnus-summary-buffer)
2256 (article-buffer gnus-article-buffer)
2257 (original gnus-original-article-buffer)
2258 (gac gnus-article-current)
2259 (reffed gnus-reffed-article-number)
2260 (score-file gnus-current-score-file))
2262 (set-buffer gnus-group-buffer)
2263 (setq gnus-newsgroup-name name)
2264 (setq gnus-newsgroup-marked marked)
2265 (setq gnus-newsgroup-unreads unread)
2266 (setq gnus-current-headers headers)
2267 (setq gnus-newsgroup-data data)
2268 (setq gnus-article-current gac)
2269 (setq gnus-summary-buffer summary)
2270 (setq gnus-article-buffer article-buffer)
2271 (setq gnus-original-article-buffer original)
2272 (setq gnus-reffed-article-number reffed)
2273 (setq gnus-current-score-file score-file)
2274 ;; The article buffer also has local variables.
2275 (when (gnus-buffer-live-p gnus-article-buffer)
2276 (set-buffer gnus-article-buffer)
2277 (setq gnus-summary-buffer summary))))))
2279 (defun gnus-summary-article-unread-p (article)
2280 "Say whether ARTICLE is unread or not."
2281 (memq article gnus-newsgroup-unreads))
2283 (defun gnus-summary-first-article-p (&optional article)
2284 "Return whether ARTICLE is the first article in the buffer."
2285 (if (not (setq article (or article (gnus-summary-article-number))))
2287 (eq article (caar gnus-newsgroup-data))))
2289 (defun gnus-summary-last-article-p (&optional article)
2290 "Return whether ARTICLE is the last article in the buffer."
2291 (if (not (setq article (or article (gnus-summary-article-number))))
2292 t ; All non-existent numbers are the last article. :-)
2293 (not (cdr (gnus-data-find-list article)))))
2295 (defun gnus-make-thread-indent-array ()
2297 (unless (and gnus-thread-indent-array
2298 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2299 (setq gnus-thread-indent-array (make-vector 201 "")
2300 gnus-thread-indent-array-level gnus-thread-indent-level)
2302 (aset gnus-thread-indent-array n
2303 (make-string (* n gnus-thread-indent-level) ? ))
2306 (defun gnus-update-summary-mark-positions ()
2307 "Compute where the summary marks are to go."
2309 (when (and gnus-summary-buffer
2310 (get-buffer gnus-summary-buffer)
2311 (buffer-name (get-buffer gnus-summary-buffer)))
2312 (set-buffer gnus-summary-buffer))
2313 (let ((gnus-replied-mark 129)
2314 (gnus-score-below-mark 130)
2315 (gnus-score-over-mark 130)
2316 (spec gnus-summary-line-format-spec)
2317 thread gnus-visual pos)
2319 (gnus-set-work-buffer)
2320 (let ((gnus-summary-line-format-spec spec))
2321 (gnus-summary-insert-line
2322 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2323 (goto-char (point-min))
2324 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2326 (goto-char (point-min))
2327 (push (cons 'replied (and (search-forward "\201" nil t)
2330 (goto-char (point-min))
2331 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2333 (setq gnus-summary-mark-positions pos))))
2335 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2336 "Insert a dummy root in the summary buffer."
2338 (gnus-add-text-properties
2339 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2340 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2342 (defun gnus-summary-insert-line (gnus-tmp-header
2343 gnus-tmp-level gnus-tmp-current
2344 gnus-tmp-unread gnus-tmp-replied
2345 gnus-tmp-expirable gnus-tmp-subject-or-nil
2346 &optional gnus-tmp-dummy gnus-tmp-score
2348 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2349 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2350 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2351 (gnus-tmp-score-char
2352 (if (or (null gnus-summary-default-score)
2353 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2354 gnus-summary-zcore-fuzz))
2356 (if (< gnus-tmp-score gnus-summary-default-score)
2357 gnus-score-below-mark gnus-score-over-mark)))
2359 (cond (gnus-tmp-process gnus-process-mark)
2360 ((memq gnus-tmp-current gnus-newsgroup-cached)
2362 (gnus-tmp-replied gnus-replied-mark)
2363 ((memq gnus-tmp-current gnus-newsgroup-saved)
2365 (t gnus-unread-mark)))
2366 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2369 ((string-match "<[^>]+> *$" gnus-tmp-from)
2370 (let ((beg (match-beginning 0)))
2371 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2372 (substring gnus-tmp-from (1+ (match-beginning 0))
2373 (1- (match-end 0))))
2374 (substring gnus-tmp-from 0 beg))))
2375 ((string-match "(.+)" gnus-tmp-from)
2376 (substring gnus-tmp-from
2377 (1+ (match-beginning 0)) (1- (match-end 0))))
2379 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2380 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2381 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2382 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2383 (buffer-read-only nil))
2384 (when (string= gnus-tmp-name "")
2385 (setq gnus-tmp-name gnus-tmp-from))
2386 (unless (numberp gnus-tmp-lines)
2387 (setq gnus-tmp-lines 0))
2388 (gnus-put-text-property
2390 (progn (eval gnus-summary-line-format-spec) (point))
2391 'gnus-number gnus-tmp-number)
2392 (when (gnus-visual-p 'summary-highlight 'highlight)
2394 (run-hooks 'gnus-summary-update-hook)
2397 (defun gnus-summary-update-line (&optional dont-update)
2398 ;; Update summary line after change.
2399 (when (and gnus-summary-default-score
2400 (not gnus-summary-inhibit-highlight))
2401 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2402 (article (gnus-summary-article-number))
2403 (score (gnus-summary-article-score article)))
2405 (if (and gnus-summary-mark-below
2406 (< (gnus-summary-article-score)
2407 gnus-summary-mark-below))
2408 ;; This article has a low score, so we mark it as read.
2409 (when (memq article gnus-newsgroup-unreads)
2410 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2411 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2412 ;; This article was previously marked as read on account
2413 ;; of a low score, but now it has risen, so we mark it as
2415 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2416 (gnus-summary-update-mark
2417 (if (or (null gnus-summary-default-score)
2418 (<= (abs (- score gnus-summary-default-score))
2419 gnus-summary-zcore-fuzz))
2421 (if (< score gnus-summary-default-score)
2422 gnus-score-below-mark gnus-score-over-mark))
2424 ;; Do visual highlighting.
2425 (when (gnus-visual-p 'summary-highlight 'highlight)
2426 (run-hooks 'gnus-summary-update-hook)))))
2428 (defvar gnus-tmp-new-adopts nil)
2430 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2431 "Return the number of articles in THREAD.
2432 This may be 0 in some cases -- if none of the articles in
2433 the thread are to be displayed."
2435 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2437 ((not (listp thread))
2439 ((and (consp thread) (cdr thread))
2442 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2445 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2448 (when (and level (zerop level) gnus-tmp-new-adopts)
2451 'gnus-summary-number-of-articles-in-thread
2452 gnus-tmp-new-adopts))))
2454 (if (> number 1) gnus-not-empty-thread-mark
2455 gnus-empty-thread-mark)
2458 (defun gnus-summary-set-local-parameters (group)
2459 "Go through the local params of GROUP and set all variable specs in that list."
2460 (let ((params (gnus-group-find-parameter group))
2463 (setq elem (car params)
2464 params (cdr params))
2465 (and (consp elem) ; Has to be a cons.
2466 (consp (cdr elem)) ; The cdr has to be a list.
2467 (symbolp (car elem)) ; Has to be a symbol in there.
2468 (not (memq (car elem)
2469 '(quit-config to-address to-list to-group)))
2470 (progn ; So we set it.
2471 (make-local-variable (car elem))
2472 (set (car elem) (eval (nth 1 elem))))))))
2474 (defun gnus-summary-read-group (group &optional show-all no-article
2475 kill-buffer no-display)
2476 "Start reading news in newsgroup GROUP.
2477 If SHOW-ALL is non-nil, already read articles are also listed.
2478 If NO-ARTICLE is non-nil, no article is selected initially.
2479 If NO-DISPLAY, don't generate a summary buffer."
2480 ;; Killed foreign groups can't be entered.
2481 (when (and (not (gnus-group-native-p group))
2482 (not (gnus-gethash group gnus-newsrc-hashtb)))
2483 (error "Dead non-native groups can't be entered"))
2484 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2485 (let* ((new-group (gnus-summary-setup-buffer group))
2486 (quit-config (gnus-group-quit-config group))
2487 (did-select (and new-group (gnus-select-newsgroup group show-all))))
2489 ;; This summary buffer exists already, so we just select it.
2491 (gnus-set-global-variables)
2493 (gnus-kill-or-deaden-summary kill-buffer))
2494 (gnus-configure-windows 'summary 'force)
2495 (gnus-set-mode-line 'summary)
2496 (gnus-summary-position-point)
2499 ;; We couldn't select this group.
2501 (when (and (eq major-mode 'gnus-summary-mode)
2502 (not (equal (current-buffer) kill-buffer)))
2503 (kill-buffer (current-buffer))
2504 (if (not quit-config)
2506 (set-buffer gnus-group-buffer)
2507 (gnus-group-jump-to-group group)
2508 (gnus-group-next-unread-group 1))
2509 (gnus-handle-ephemeral-exit quit-config)))
2510 (gnus-message 3 "Can't select group")
2512 ;; The user did a `C-g' while prompting for number of articles,
2513 ;; so we exit this group.
2514 ((eq did-select 'quit)
2515 (and (eq major-mode 'gnus-summary-mode)
2516 (not (equal (current-buffer) kill-buffer))
2517 (kill-buffer (current-buffer)))
2519 (gnus-kill-or-deaden-summary kill-buffer))
2520 (if (not quit-config)
2522 (set-buffer gnus-group-buffer)
2523 (gnus-group-jump-to-group group)
2524 (gnus-group-next-unread-group 1)
2525 (gnus-configure-windows 'group 'force))
2526 (gnus-handle-ephemeral-exit quit-config))
2527 ;; Finally signal the quit.
2529 ;; The group was successfully selected.
2531 (gnus-set-global-variables)
2532 ;; Save the active value in effect when the group was entered.
2533 (setq gnus-newsgroup-active
2535 (gnus-active gnus-newsgroup-name)))
2536 ;; You can change the summary buffer in some way with this hook.
2537 (run-hooks 'gnus-select-group-hook)
2538 ;; Set any local variables in the group parameters.
2539 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2540 (gnus-update-format-specifications
2541 nil 'summary 'summary-mode 'summary-dummy)
2542 ;; Do score processing.
2543 (when gnus-use-scoring
2544 (gnus-possibly-score-headers))
2545 ;; Check whether to fill in the gaps in the threads.
2546 (when gnus-build-sparse-threads
2547 (gnus-build-sparse-threads))
2548 ;; Find the initial limit.
2549 (if gnus-show-threads
2551 (let ((gnus-newsgroup-dormant nil))
2552 (gnus-summary-initial-limit show-all))
2553 (gnus-summary-initial-limit show-all))
2554 (setq gnus-newsgroup-limit
2556 (lambda (header) (mail-header-number header))
2557 gnus-newsgroup-headers)))
2558 ;; Generate the summary buffer.
2560 (gnus-summary-prepare))
2561 (when gnus-use-trees
2562 (gnus-tree-open group)
2563 (setq gnus-summary-highlight-line-function
2564 'gnus-tree-highlight-article))
2565 ;; If the summary buffer is empty, but there are some low-scored
2566 ;; articles or some excluded dormants, we include these in the
2568 (when (and (zerop (buffer-size))
2570 (cond (gnus-newsgroup-dormant
2571 (gnus-summary-limit-include-dormant))
2572 ((and gnus-newsgroup-scored show-all)
2573 (gnus-summary-limit-include-expunged t))))
2574 ;; Function `gnus-apply-kill-file' must be called in this hook.
2575 (run-hooks 'gnus-apply-kill-hook)
2576 (if (and (zerop (buffer-size))
2579 ;; This newsgroup is empty.
2580 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
2581 (gnus-message 6 "No unread news")
2583 (gnus-kill-or-deaden-summary kill-buffer))
2584 ;; Return nil from this function.
2586 ;; Hide conversation thread subtrees. We cannot do this in
2587 ;; gnus-summary-prepare-hook since kill processing may not
2588 ;; work with hidden articles.
2589 (and gnus-show-threads
2590 gnus-thread-hide-subtree
2591 (gnus-summary-hide-all-threads))
2592 ;; Show first unread article if requested.
2593 (if (and (not no-article)
2595 gnus-newsgroup-unreads
2596 gnus-auto-select-first)
2597 (unless (if (eq gnus-auto-select-first 'best)
2598 (gnus-summary-best-unread-article)
2599 (gnus-summary-first-unread-article))
2600 (gnus-configure-windows 'summary))
2601 ;; Don't select any articles, just move point to the first
2602 ;; article in the group.
2603 (goto-char (point-min))
2604 (gnus-summary-position-point)
2605 (gnus-set-mode-line 'summary)
2606 (gnus-configure-windows 'summary 'force))
2608 (gnus-kill-or-deaden-summary kill-buffer))
2609 (when (get-buffer-window gnus-group-buffer t)
2610 ;; Gotta use windows, because recenter does weird stuff if
2611 ;; the current buffer ain't the displayed window.
2612 (let ((owin (selected-window)))
2613 (select-window (get-buffer-window gnus-group-buffer t))
2614 (when (gnus-group-goto-group group)
2616 (select-window owin))))
2617 ;; Mark this buffer as "prepared".
2618 (setq gnus-newsgroup-prepared t)
2621 (defun gnus-summary-prepare ()
2622 "Generate the summary buffer."
2624 (let ((buffer-read-only nil))
2626 (setq gnus-newsgroup-data nil
2627 gnus-newsgroup-data-reverse nil)
2628 (run-hooks 'gnus-summary-generate-hook)
2629 ;; Generate the buffer, either with threads or without.
2630 (when gnus-newsgroup-headers
2631 (gnus-summary-prepare-threads
2632 (if gnus-show-threads
2633 (gnus-sort-gathered-threads
2634 (funcall gnus-summary-thread-gathering-function
2636 (gnus-cut-threads (gnus-make-threads)))))
2637 ;; Unthreaded display.
2638 (gnus-sort-articles gnus-newsgroup-headers))))
2639 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2640 ;; Call hooks for modifying summary buffer.
2641 (goto-char (point-min))
2642 (run-hooks 'gnus-summary-prepare-hook)))
2644 (defsubst gnus-general-simplify-subject (subject)
2645 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2648 ;; Truncate the subject.
2649 ((numberp gnus-summary-gather-subject-limit)
2650 (setq subject (gnus-simplify-subject-re subject))
2651 (if (> (length subject) gnus-summary-gather-subject-limit)
2652 (substring subject 0 gnus-summary-gather-subject-limit)
2654 ;; Fuzzily simplify it.
2655 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2656 (gnus-simplify-subject-fuzzy subject))
2657 ;; Just remove the leading "Re:".
2659 (gnus-simplify-subject-re subject))))
2661 (if (and gnus-summary-gather-exclude-subject
2662 (string-match gnus-summary-gather-exclude-subject subject))
2663 nil ; This article shouldn't be gathered
2666 (defun gnus-summary-simplify-subject-query ()
2667 "Query where the respool algorithm would put this article."
2669 (gnus-set-global-variables)
2670 (gnus-summary-select-article)
2671 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2673 (defun gnus-gather-threads-by-subject (threads)
2674 "Gather threads by looking at Subject headers."
2675 (if (not gnus-summary-make-false-root)
2677 (let ((hashtb (gnus-make-hashtable 1024))
2680 subject hthread whole-subject)
2682 (setq subject (gnus-general-simplify-subject
2683 (setq whole-subject (mail-header-subject
2686 (if (setq hthread (gnus-gethash subject hashtb))
2688 ;; We enter a dummy root into the thread, if we
2689 ;; haven't done that already.
2690 (unless (stringp (caar hthread))
2691 (setcar hthread (list whole-subject (car hthread))))
2692 ;; We add this new gathered thread to this gathered
2694 (setcdr (car hthread)
2695 (nconc (cdar hthread) (list (car threads))))
2696 ;; Remove it from the list of threads.
2697 (setcdr prev (cdr threads))
2698 (setq threads prev))
2699 ;; Enter this thread into the hash table.
2700 (gnus-sethash subject threads hashtb)))
2702 (setq threads (cdr threads)))
2705 (defun gnus-gather-threads-by-references (threads)
2706 "Gather threads by looking at References headers."
2707 (let ((idhashtb (gnus-make-hashtable 1024))
2708 (thhashtb (gnus-make-hashtable 1024))
2711 ids references id gthread gid entered ref)
2713 (when (setq references (mail-header-references (caar threads)))
2714 (setq id (mail-header-id (caar threads))
2715 ids (gnus-split-references references)
2717 (while (setq ref (pop ids))
2718 (setq ids (delete ref ids))
2719 (if (not (setq gid (gnus-gethash ref idhashtb)))
2721 (gnus-sethash ref id idhashtb)
2722 (gnus-sethash id threads thhashtb))
2723 (setq gthread (gnus-gethash gid thhashtb))
2725 ;; We enter a dummy root into the thread, if we
2726 ;; haven't done that already.
2727 (unless (stringp (caar gthread))
2728 (setcar gthread (list (mail-header-subject (caar gthread))
2730 ;; We add this new gathered thread to this gathered
2732 (setcdr (car gthread)
2733 (nconc (cdar gthread) (list (car threads)))))
2734 ;; Add it into the thread hash table.
2735 (gnus-sethash id gthread thhashtb)
2737 ;; Remove it from the list of threads.
2738 (setcdr prev (cdr threads))
2739 (setq threads prev))))
2741 (setq threads (cdr threads)))
2744 (defun gnus-sort-gathered-threads (threads)
2745 "Sort subtreads inside each gathered thread by article number."
2746 (let ((result threads))
2748 (when (stringp (caar threads))
2749 (setcdr (car threads)
2750 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2751 (setq threads (cdr threads)))
2754 (defun gnus-thread-loop-p (root thread)
2755 "Say whether ROOT is in THREAD."
2756 (let ((th (cdr thread)))
2758 (not (eq (caar th) root)))
2761 ;; We have found a loop.
2763 (setcdr thread (delq (car th) (cdr thread)))
2764 (if (boundp (setq ref-dep (intern "none"
2765 gnus-newsgroup-dependencies)))
2766 (setcdr (symbol-value ref-dep)
2767 (nconc (cdr (symbol-value ref-dep))
2769 (set ref-dep (list nil (car th))))
2771 ;; Recurse down into the sub-threads and look for loops.
2774 (lambda (thread) (gnus-thread-loop-p root thread))
2777 (defun gnus-make-threads ()
2778 "Go through the dependency hashtb and find the roots. Return all threads."
2780 (while (catch 'infloop
2783 ;; Deal with self-referencing References loops.
2784 (when (and (car (symbol-value refs))
2791 (car (symbol-value refs)) thread))
2792 (cdr (symbol-value refs)))))))
2795 (unless (car (symbol-value refs))
2796 ;; These threads do not refer back to any other articles,
2797 ;; so they're roots.
2798 (setq threads (append (cdr (symbol-value refs)) threads))))
2799 gnus-newsgroup-dependencies)))
2802 (defun gnus-build-sparse-threads ()
2803 (let ((headers gnus-newsgroup-headers)
2804 (deps gnus-newsgroup-dependencies)
2805 header references generation relations
2806 cthread subject child end pthread relation)
2807 ;; First we create an alist of generations/relations, where
2808 ;; generations is how much we trust the relation, and the relation
2810 (gnus-message 7 "Making sparse threads...")
2812 (nnheader-set-temp-buffer " *gnus sparse threads*")
2813 (while (setq header (pop headers))
2814 (when (and (setq references (mail-header-references header))
2815 (not (string= references "")))
2817 (setq child (mail-header-id header)
2818 subject (mail-header-subject header))
2820 (while (search-backward ">" nil t)
2821 (setq end (1+ (point)))
2822 (when (search-backward "<" nil t)
2823 (push (list (incf generation)
2824 child (setq child (buffer-substring (point) end))
2827 (push (list (1+ generation) child nil subject) relations)
2829 (kill-buffer (current-buffer)))
2830 ;; Sort over trustworthiness.
2831 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
2832 (while (setq relation (pop relations))
2833 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
2834 (unless (car (symbol-value cthread))
2835 ;; Make this article the parent of these threads.
2836 (setcar (symbol-value cthread)
2837 (vector gnus-reffed-article-number
2841 (or (caddr relation) "") 0 0 "")))
2842 (set cthread (list (vector gnus-reffed-article-number
2844 "" "" (cadr relation)
2845 (or (caddr relation) "") 0 0 ""))))
2846 (push gnus-reffed-article-number gnus-newsgroup-limit)
2847 (push gnus-reffed-article-number gnus-newsgroup-sparse)
2848 (push (cons gnus-reffed-article-number gnus-sparse-mark)
2849 gnus-newsgroup-reads)
2850 (decf gnus-reffed-article-number)
2851 ;; Make this new thread the child of its parent.
2852 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
2853 (setcdr (symbol-value pthread)
2854 (nconc (cdr (symbol-value pthread))
2855 (list (symbol-value cthread))))
2856 (set pthread (list nil (symbol-value cthread))))))
2857 (gnus-message 7 "Making sparse threads...done")))
2859 (defun gnus-build-old-threads ()
2860 ;; Look at all the articles that refer back to old articles, and
2861 ;; fetch the headers for the articles that aren't there. This will
2862 ;; build complete threads - if the roots haven't been expired by the
2867 (when (not (car (symbol-value refs)))
2868 (setq heads (cdr (symbol-value refs)))
2870 (if (memq (mail-header-number (caar heads))
2871 gnus-newsgroup-dormant)
2872 (setq heads (cdr heads))
2873 (setq id (symbol-name refs))
2874 (while (and (setq id (gnus-build-get-header id))
2875 (not (car (gnus-gethash
2876 id gnus-newsgroup-dependencies)))))
2877 (setq heads nil)))))
2878 gnus-newsgroup-dependencies)))
2880 (defun gnus-build-get-header (id)
2881 ;; Look through the buffer of NOV lines and find the header to
2882 ;; ID. Enter this line into the dependencies hash table, and return
2883 ;; the id of the parent article (if any).
2884 (let ((deps gnus-newsgroup-dependencies)
2888 (set-buffer nntp-server-buffer)
2889 (goto-char (point-min))
2890 (while (and (not found) (search-forward id nil t))
2892 (setq found (looking-at
2893 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
2894 (regexp-quote id))))
2895 (or found (beginning-of-line 2)))
2899 (setq header (gnus-nov-parse-line
2900 (read (current-buffer)) deps))
2901 (gnus-parent-id (mail-header-references header)))))
2903 (let ((number (mail-header-number header)))
2904 (push number gnus-newsgroup-limit)
2905 (push header gnus-newsgroup-headers)
2906 (if (memq number gnus-newsgroup-unselected)
2908 (push number gnus-newsgroup-unreads)
2909 (setq gnus-newsgroup-unselected
2910 (delq number gnus-newsgroup-unselected)))
2911 (push number gnus-newsgroup-ancient)))))))
2913 (defun gnus-summary-update-article-line (article header)
2914 "Update the line for ARTICLE using HEADERS."
2915 (let* ((id (mail-header-id header))
2916 (thread (gnus-id-to-thread id)))
2918 (error "Article in no thread"))
2919 ;; Update the thread.
2920 (setcar thread header)
2921 (gnus-summary-goto-subject article)
2922 (let* ((datal (gnus-data-find-list article))
2924 (length (when (cdr datal)
2925 (- (gnus-data-pos data)
2926 (gnus-data-pos (cadr datal)))))
2927 (buffer-read-only nil)
2928 (level (gnus-summary-thread-level)))
2930 (gnus-summary-insert-line
2931 header level nil (gnus-article-mark article)
2932 (memq article gnus-newsgroup-replied)
2933 (memq article gnus-newsgroup-expirable)
2934 (mail-header-subject header)
2935 nil (cdr (assq article gnus-newsgroup-scored))
2936 (memq article gnus-newsgroup-processable))
2938 (gnus-data-update-list
2939 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
2941 (defun gnus-summary-update-article (article &optional iheader)
2942 "Update ARTICLE in the summary buffer."
2943 (set-buffer gnus-summary-buffer)
2944 (let* ((header (or iheader (gnus-summary-article-header article)))
2945 (id (mail-header-id header))
2946 (data (gnus-data-find article))
2947 (thread (gnus-id-to-thread id))
2948 (references (mail-header-references header))
2952 (when (and references
2953 (not (equal "" references)))
2956 (buffer-read-only nil)
2958 (number (mail-header-number header))
2961 ;; !!! Should this be in or not?
2963 (setcar thread nil))
2965 (delq thread parent))
2966 (if (gnus-summary-insert-subject id header iheader)
2967 ;; Set the (possibly) new article number in the data structure.
2968 (gnus-data-set-number data (gnus-id-to-article id))
2972 (defun gnus-rebuild-thread (id)
2973 "Rebuild the thread containing ID."
2974 (let ((buffer-read-only nil)
2975 old-pos current thread data)
2976 (if (not gnus-show-threads)
2977 (setq thread (list (car (gnus-id-to-thread id))))
2978 ;; Get the thread this article is part of.
2979 (setq thread (gnus-remove-thread id)))
2980 (setq old-pos (gnus-point-at-bol))
2981 (setq current (save-excursion
2982 (and (zerop (forward-line -1))
2983 (gnus-summary-article-number))))
2984 ;; If this is a gathered thread, we have to go some re-gathering.
2985 (when (stringp (car thread))
2986 (let ((subject (car thread))
2988 (setq thread (cdr thread))
2990 (unless (memq (setq thr (gnus-id-to-thread
2992 (mail-header-id (caar thread)))))
2995 (setq thread (cdr thread)))
2996 ;; We now have all (unique) roots.
2997 (if (= (length roots) 1)
2998 ;; All the loose roots are now one solid root.
2999 (setq thread (car roots))
3000 (setq thread (cons subject (gnus-sort-threads roots))))))
3002 ;; We then insert this thread into the summary buffer.
3003 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3004 (if gnus-show-threads
3005 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3006 (gnus-summary-prepare-unthreaded thread))
3007 (setq data (nreverse gnus-newsgroup-data))
3008 (setq threads gnus-newsgroup-threads))
3009 ;; We splice the new data into the data structure.
3010 (gnus-data-enter-list current data (- (point) old-pos))
3011 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
3013 (defun gnus-number-to-header (number)
3014 "Return the header for article NUMBER."
3015 (let ((headers gnus-newsgroup-headers))
3017 (not (= number (mail-header-number (car headers)))))
3022 (defun gnus-parent-headers (headers &optional generation)
3023 "Return the headers of the GENERATIONeth parent of HEADERS."
3025 (setq generation 1))
3026 (let (references parent)
3027 (while (and headers (not (zerop generation)))
3028 (setq references (mail-header-references headers))
3029 (when (and references
3030 (setq parent (gnus-parent-id references))
3031 (setq headers (car (gnus-id-to-thread parent))))
3035 (defun gnus-id-to-thread (id)
3036 "Return the (sub-)thread where ID appears."
3037 (gnus-gethash id gnus-newsgroup-dependencies))
3039 (defun gnus-id-to-article (id)
3040 "Return the article number of ID."
3041 (let ((thread (gnus-id-to-thread id)))
3044 (mail-header-number (car thread)))))
3046 (defun gnus-id-to-header (id)
3047 "Return the article headers of ID."
3048 (car (gnus-id-to-thread id)))
3050 (defun gnus-article-displayed-root-p (article)
3051 "Say whether ARTICLE is a root(ish) article."
3052 (let ((level (gnus-summary-thread-level article))
3053 (refs (mail-header-references (gnus-summary-article-header article)))
3059 ((null (gnus-parent-id refs)) t)
3061 (null (setq particle (gnus-id-to-article
3062 (gnus-parent-id refs))))
3063 (null (gnus-summary-thread-level particle)))))))
3065 (defun gnus-root-id (id)
3066 "Return the id of the root of the thread where ID appears."
3068 (while (and id (setq prev (car (gnus-gethash
3069 id gnus-newsgroup-dependencies))))
3071 id (gnus-parent-id (mail-header-references prev))))
3074 (defun gnus-remove-thread (id &optional dont-remove)
3075 "Remove the thread that has ID in it."
3076 (let ((dep gnus-newsgroup-dependencies)
3077 headers thread last-id)
3078 ;; First go up in this thread until we find the root.
3079 (setq last-id (gnus-root-id id))
3080 (setq headers (list (car (gnus-id-to-thread last-id))
3081 (caadr (gnus-id-to-thread last-id))))
3082 ;; We have now found the real root of this thread. It might have
3083 ;; been gathered into some loose thread, so we have to search
3084 ;; through the threads to find the thread we wanted.
3085 (let ((threads gnus-newsgroup-threads)
3088 (setq sub (car threads))
3089 (if (stringp (car sub))
3090 ;; This is a gathered thread, so we look at the roots
3091 ;; below it to find whether this article is in this
3094 (setq sub (cdr sub))
3096 (when (member (caar sub) headers)
3097 (setq thread (car threads)
3100 (setq sub (cdr sub))))
3101 ;; It's an ordinary thread, so we check it.
3102 (when (eq (car sub) (car headers))
3105 (setq threads (cdr threads)))
3106 ;; If this article is in no thread, then it's a root.
3109 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3110 (setq thread (gnus-gethash last-id dep)))
3113 thread ; We return this thread.
3115 (if (stringp (car thread))
3117 ;; If we use dummy roots, then we have to remove the
3118 ;; dummy root as well.
3119 (when (eq gnus-summary-make-false-root 'dummy)
3121 (gnus-data-compute-positions))
3122 (setq thread (cdr thread))
3124 (gnus-remove-thread-1 (car thread))
3125 (setq thread (cdr thread))))
3126 (gnus-remove-thread-1 thread))))))))
3128 (defun gnus-remove-thread-1 (thread)
3129 "Remove the thread THREAD recursively."
3130 (let ((number (mail-header-number (pop thread)))
3132 (setq thread (reverse thread))
3134 (gnus-remove-thread-1 (pop thread)))
3135 (when (setq d (gnus-data-find number))
3136 (goto-char (gnus-data-pos d))
3139 (- (gnus-point-at-bol)
3141 (1+ (gnus-point-at-eol))
3142 (gnus-delete-line)))))))
3144 (defun gnus-sort-threads (threads)
3146 (if (not gnus-thread-sort-functions)
3148 (gnus-message 7 "Sorting threads...")
3150 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3151 (gnus-message 7 "Sorting threads...done"))))
3153 (defun gnus-sort-articles (articles)
3155 (when gnus-article-sort-functions
3156 (gnus-message 7 "Sorting articles...")
3158 (setq gnus-newsgroup-headers
3159 (sort articles (gnus-make-sort-function
3160 gnus-article-sort-functions)))
3161 (gnus-message 7 "Sorting articles...done"))))
3163 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3164 (defmacro gnus-thread-header (thread)
3165 ;; Return header of first article in THREAD.
3166 ;; Note that THREAD must never, ever be anything else than a variable -
3167 ;; using some other form will lead to serious barfage.
3168 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3169 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3170 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3173 (defsubst gnus-article-sort-by-number (h1 h2)
3174 "Sort articles by article number."
3175 (< (mail-header-number h1)
3176 (mail-header-number h2)))
3178 (defun gnus-thread-sort-by-number (h1 h2)
3179 "Sort threads by root article number."
3180 (gnus-article-sort-by-number
3181 (gnus-thread-header h1) (gnus-thread-header h2)))
3183 (defsubst gnus-article-sort-by-lines (h1 h2)
3184 "Sort articles by article Lines header."
3185 (< (mail-header-lines h1)
3186 (mail-header-lines h2)))
3188 (defun gnus-thread-sort-by-lines (h1 h2)
3189 "Sort threads by root article Lines header."
3190 (gnus-article-sort-by-lines
3191 (gnus-thread-header h1) (gnus-thread-header h2)))
3193 (defsubst gnus-article-sort-by-author (h1 h2)
3194 "Sort articles by root author."
3196 (let ((extract (funcall
3197 gnus-extract-address-components
3198 (mail-header-from h1))))
3199 (or (car extract) (cdr extract)))
3200 (let ((extract (funcall
3201 gnus-extract-address-components
3202 (mail-header-from h2))))
3203 (or (car extract) (cdr extract)))))
3205 (defun gnus-thread-sort-by-author (h1 h2)
3206 "Sort threads by root author."
3207 (gnus-article-sort-by-author
3208 (gnus-thread-header h1) (gnus-thread-header h2)))
3210 (defsubst gnus-article-sort-by-subject (h1 h2)
3211 "Sort articles by root subject."
3213 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3214 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3216 (defun gnus-thread-sort-by-subject (h1 h2)
3217 "Sort threads by root subject."
3218 (gnus-article-sort-by-subject
3219 (gnus-thread-header h1) (gnus-thread-header h2)))
3221 (defsubst gnus-article-sort-by-date (h1 h2)
3222 "Sort articles by root article date."
3224 (gnus-date-get-time (mail-header-date h1))
3225 (gnus-date-get-time (mail-header-date h2))))
3227 (defun gnus-thread-sort-by-date (h1 h2)
3228 "Sort threads by root article date."
3229 (gnus-article-sort-by-date
3230 (gnus-thread-header h1) (gnus-thread-header h2)))
3232 (defsubst gnus-article-sort-by-score (h1 h2)
3233 "Sort articles by root article score.
3234 Unscored articles will be counted as having a score of zero."
3235 (> (or (cdr (assq (mail-header-number h1)
3236 gnus-newsgroup-scored))
3237 gnus-summary-default-score 0)
3238 (or (cdr (assq (mail-header-number h2)
3239 gnus-newsgroup-scored))
3240 gnus-summary-default-score 0)))
3242 (defun gnus-thread-sort-by-score (h1 h2)
3243 "Sort threads by root article score."
3244 (gnus-article-sort-by-score
3245 (gnus-thread-header h1) (gnus-thread-header h2)))
3247 (defun gnus-thread-sort-by-total-score (h1 h2)
3248 "Sort threads by the sum of all scores in the thread.
3249 Unscored articles will be counted as having a score of zero."
3250 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3252 (defun gnus-thread-total-score (thread)
3253 ;; This function find the total score of THREAD.
3254 (cond ((null thread)
3257 (if (stringp (car thread))
3258 (apply gnus-thread-score-function 0
3259 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3260 (gnus-thread-total-score-1 thread)))
3262 (gnus-thread-total-score-1 (list thread)))))
3264 (defun gnus-thread-total-score-1 (root)
3265 ;; This function find the total score of the thread below ROOT.
3266 (setq root (car root))
3267 (apply gnus-thread-score-function
3269 (mapcar 'gnus-thread-total-score
3270 (cdr (gnus-gethash (mail-header-id root)
3271 gnus-newsgroup-dependencies)))
3272 (when (> (mail-header-number root) 0)
3273 (list (or (cdr (assq (mail-header-number root)
3274 gnus-newsgroup-scored))
3275 gnus-summary-default-score 0))))
3276 (list gnus-summary-default-score)
3279 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3280 (defvar gnus-tmp-prev-subject nil)
3281 (defvar gnus-tmp-false-parent nil)
3282 (defvar gnus-tmp-root-expunged nil)
3283 (defvar gnus-tmp-dummy-line nil)
3285 (defun gnus-summary-prepare-threads (threads)
3286 "Prepare summary buffer from THREADS and indentation LEVEL.
3287 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3288 or a straight list of headers."
3289 (gnus-message 7 "Generating summary...")
3291 (setq gnus-newsgroup-threads threads)
3294 (let ((gnus-tmp-level 0)
3295 (default-score (or gnus-summary-default-score 0))
3296 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3297 thread number subject stack state gnus-tmp-gathered beg-match
3298 new-roots gnus-tmp-new-adopts thread-end
3299 gnus-tmp-header gnus-tmp-unread
3300 gnus-tmp-replied gnus-tmp-subject-or-nil
3301 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3302 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3303 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3305 (setq gnus-tmp-prev-subject nil)
3307 (if (vectorp (car threads))
3308 ;; If this is a straight (sic) list of headers, then a
3309 ;; threaded summary display isn't required, so we just create
3310 ;; an unthreaded one.
3311 (gnus-summary-prepare-unthreaded threads)
3313 ;; Do the threaded display.
3315 (while (or threads stack gnus-tmp-new-adopts new-roots)
3317 (if (and (= gnus-tmp-level 0)
3318 (not (setq gnus-tmp-dummy-line nil))
3321 (not gnus-tmp-false-parent)
3322 (or gnus-tmp-new-adopts new-roots))
3323 (if gnus-tmp-new-adopts
3324 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3325 thread (list (car gnus-tmp-new-adopts))
3326 gnus-tmp-header (caar thread)
3327 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3329 (setq thread (list (car new-roots))
3330 gnus-tmp-header (caar thread)
3331 new-roots (cdr new-roots))))
3334 ;; If there are some threads, we do them before the
3335 ;; threads on the stack.
3336 (setq thread threads
3337 gnus-tmp-header (caar thread))
3338 ;; There were no current threads, so we pop something off
3340 (setq state (car stack)
3341 gnus-tmp-level (car state)
3344 gnus-tmp-header (caar thread))))
3346 (setq gnus-tmp-false-parent nil)
3347 (setq gnus-tmp-root-expunged nil)
3348 (setq thread-end nil)
3350 (if (stringp gnus-tmp-header)
3351 ;; The header is a dummy root.
3353 ((eq gnus-summary-make-false-root 'adopt)
3354 ;; We let the first article adopt the rest.
3355 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3357 (setq gnus-tmp-gathered
3359 (lambda (h) (mail-header-number (car h)))
3362 (setq thread (cons (list (caar thread)
3365 (setq gnus-tmp-level -1
3366 gnus-tmp-false-parent t))
3367 ((eq gnus-summary-make-false-root 'empty)
3368 ;; We print adopted articles with empty subject fields.
3369 (setq gnus-tmp-gathered
3371 (lambda (h) (mail-header-number (car h)))
3374 (setq gnus-tmp-level -1))
3375 ((eq gnus-summary-make-false-root 'dummy)
3376 ;; We remember that we probably want to output a dummy
3378 (setq gnus-tmp-dummy-line gnus-tmp-header)
3379 (setq gnus-tmp-prev-subject gnus-tmp-header))
3381 ;; We do not make a root for the gathered
3382 ;; sub-threads at all.
3383 (setq gnus-tmp-level -1)))
3385 (setq number (mail-header-number gnus-tmp-header)
3386 subject (mail-header-subject gnus-tmp-header))
3389 ;; If the thread has changed subject, we might want to make
3390 ;; this subthread into a root.
3391 ((and (null gnus-thread-ignore-subject)
3392 (not (zerop gnus-tmp-level))
3393 gnus-tmp-prev-subject
3395 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3396 (setq new-roots (nconc new-roots (list (car thread)))
3398 gnus-tmp-header nil))
3399 ;; If the article lies outside the current limit,
3400 ;; then we do not display it.
3401 ((not (memq number gnus-newsgroup-limit))
3402 (setq gnus-tmp-gathered
3404 (lambda (h) (mail-header-number (car h)))
3407 (setq gnus-tmp-new-adopts (if (cdar thread)
3408 (append gnus-tmp-new-adopts
3410 gnus-tmp-new-adopts)
3412 gnus-tmp-header nil)
3413 (when (zerop gnus-tmp-level)
3414 (setq gnus-tmp-root-expunged t)))
3415 ;; Perhaps this article is to be marked as read?
3416 ((and gnus-summary-mark-below
3417 (< (or (cdr (assq number gnus-newsgroup-scored))
3419 gnus-summary-mark-below)
3420 ;; Don't touch sparse articles.
3421 (not (gnus-summary-article-sparse-p number))
3422 (not (gnus-summary-article-ancient-p number)))
3423 (setq gnus-newsgroup-unreads
3424 (delq number gnus-newsgroup-unreads))
3425 (if gnus-newsgroup-auto-expire
3426 (push number gnus-newsgroup-expirable)
3427 (push (cons number gnus-low-score-mark)
3428 gnus-newsgroup-reads))))
3430 (when gnus-tmp-header
3431 ;; We may have an old dummy line to output before this
3433 (when gnus-tmp-dummy-line
3434 (gnus-summary-insert-dummy-line
3435 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3436 (setq gnus-tmp-dummy-line nil))
3438 ;; Compute the mark.
3439 (setq gnus-tmp-unread (gnus-article-mark number))
3441 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3442 gnus-tmp-header gnus-tmp-level)
3443 gnus-newsgroup-data)
3445 ;; Actually insert the line.
3447 gnus-tmp-subject-or-nil
3449 ((and gnus-thread-ignore-subject
3450 gnus-tmp-prev-subject
3451 (not (inline (gnus-subject-equal
3452 gnus-tmp-prev-subject subject))))
3454 ((zerop gnus-tmp-level)
3455 (if (and (eq gnus-summary-make-false-root 'empty)
3456 (memq number gnus-tmp-gathered)
3457 gnus-tmp-prev-subject
3458 (inline (gnus-subject-equal
3459 gnus-tmp-prev-subject subject)))
3460 gnus-summary-same-subject
3462 (t gnus-summary-same-subject)))
3463 (if (and (eq gnus-summary-make-false-root 'adopt)
3464 (= gnus-tmp-level 1)
3465 (memq number gnus-tmp-gathered))
3466 (setq gnus-tmp-opening-bracket ?\<
3467 gnus-tmp-closing-bracket ?\>)
3468 (setq gnus-tmp-opening-bracket ?\[
3469 gnus-tmp-closing-bracket ?\]))
3471 gnus-tmp-indentation
3472 (aref gnus-thread-indent-array gnus-tmp-level)
3473 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3474 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3475 gnus-summary-default-score 0)
3477 (if (or (null gnus-summary-default-score)
3478 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3479 gnus-summary-zcore-fuzz))
3481 (if (< gnus-tmp-score gnus-summary-default-score)
3482 gnus-score-below-mark gnus-score-over-mark))
3484 (cond ((memq number gnus-newsgroup-processable)
3486 ((memq number gnus-newsgroup-cached)
3488 ((memq number gnus-newsgroup-replied)
3490 ((memq number gnus-newsgroup-saved)
3492 (t gnus-unread-mark))
3493 gnus-tmp-from (mail-header-from gnus-tmp-header)
3496 ((string-match "<[^>]+> *$" gnus-tmp-from)
3497 (setq beg-match (match-beginning 0))
3498 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3499 (substring gnus-tmp-from (1+ (match-beginning 0))
3500 (1- (match-end 0))))
3501 (substring gnus-tmp-from 0 beg-match)))
3502 ((string-match "(.+)" gnus-tmp-from)
3503 (substring gnus-tmp-from
3504 (1+ (match-beginning 0)) (1- (match-end 0))))
3506 (when (string= gnus-tmp-name "")
3507 (setq gnus-tmp-name gnus-tmp-from))
3508 (unless (numberp gnus-tmp-lines)
3509 (setq gnus-tmp-lines 0))
3510 (gnus-put-text-property
3512 (progn (eval gnus-summary-line-format-spec) (point))
3513 'gnus-number number)
3516 (run-hooks 'gnus-summary-update-hook)
3519 (setq gnus-tmp-prev-subject subject)))
3521 (when (nth 1 thread)
3522 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3523 (incf gnus-tmp-level)
3524 (setq threads (if thread-end nil (cdar thread)))
3526 (setq gnus-tmp-level 0)))))
3527 (gnus-message 7 "Generating summary...done"))
3529 (defun gnus-summary-prepare-unthreaded (headers)
3530 "Generate an unthreaded summary buffer based on HEADERS."
3531 (let (header number mark)
3534 ;; We may have to root out some bad articles...
3535 (when (memq (setq number (mail-header-number
3536 (setq header (pop headers))))
3537 gnus-newsgroup-limit)
3538 ;; Mark article as read when it has a low score.
3539 (when (and gnus-summary-mark-below
3540 (< (or (cdr (assq number gnus-newsgroup-scored))
3541 gnus-summary-default-score 0)
3542 gnus-summary-mark-below)
3543 (not (gnus-summary-article-ancient-p number)))
3544 (setq gnus-newsgroup-unreads
3545 (delq number gnus-newsgroup-unreads))
3546 (if gnus-newsgroup-auto-expire
3547 (push number gnus-newsgroup-expirable)
3548 (push (cons number gnus-low-score-mark)
3549 gnus-newsgroup-reads)))
3551 (setq mark (gnus-article-mark number))
3552 (push (gnus-data-make number mark (1+ (point)) header 0)
3553 gnus-newsgroup-data)
3554 (gnus-summary-insert-line
3556 mark (memq number gnus-newsgroup-replied)
3557 (memq number gnus-newsgroup-expirable)
3558 (mail-header-subject header) nil
3559 (cdr (assq number gnus-newsgroup-scored))
3560 (memq number gnus-newsgroup-processable))))))
3562 (defun gnus-select-newsgroup (group &optional read-all)
3563 "Select newsgroup GROUP.
3564 If READ-ALL is non-nil, all articles in the group are selected."
3565 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3566 (info (nth 2 entry))
3567 articles fetched-articles cached)
3569 (unless (gnus-check-server
3570 (setq gnus-current-select-method
3571 (gnus-find-method-for-group group)))
3572 (error "Couldn't open server"))
3574 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3575 (gnus-activate-group group) ; Or we can activate it...
3576 (progn ; Or we bug out.
3577 (when (equal major-mode 'gnus-summary-mode)
3578 (kill-buffer (current-buffer)))
3579 (error "Couldn't request group %s: %s"
3580 group (gnus-status-message group))))
3582 (unless (gnus-request-group group t)
3583 (when (equal major-mode 'gnus-summary-mode)
3584 (kill-buffer (current-buffer)))
3585 (error "Couldn't request group %s: %s"
3586 group (gnus-status-message group)))
3588 (setq gnus-newsgroup-name group)
3589 (setq gnus-newsgroup-unselected nil)
3590 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3592 ;; Adjust and set lists of article marks.
3594 (gnus-adjust-marked-articles info))
3596 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3597 (when (gnus-virtual-group-p group)
3598 (setq cached gnus-newsgroup-cached))
3600 (setq gnus-newsgroup-unreads
3601 (gnus-set-difference
3602 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3603 gnus-newsgroup-dormant))
3605 (setq gnus-newsgroup-processable nil)
3607 (setq articles (gnus-articles-to-read group read-all))
3611 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3613 ((eq articles 0) nil)
3615 ;; Init the dependencies hash table.
3616 (setq gnus-newsgroup-dependencies
3617 (gnus-make-hashtable (length articles)))
3618 ;; Retrieve the headers and read them in.
3619 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3620 (setq gnus-newsgroup-headers
3622 (setq gnus-headers-retrieved-by
3623 (gnus-retrieve-headers
3624 articles gnus-newsgroup-name
3625 ;; We might want to fetch old headers, but
3626 ;; not if there is only 1 article.
3627 (and gnus-fetch-old-headers
3629 (not (eq gnus-fetch-old-headers 'some))
3630 (not (numberp gnus-fetch-old-headers)))
3631 (> (length articles) 1))))))
3632 (gnus-get-newsgroup-headers-xover
3633 articles nil nil gnus-newsgroup-name t)
3634 (gnus-get-newsgroup-headers)))
3635 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
3637 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3639 (setq gnus-newsgroup-cached cached))
3641 ;; Suppress duplicates?
3642 (when gnus-suppress-duplicates
3643 (gnus-dup-suppress-articles))
3645 ;; Set the initial limit.
3646 (setq gnus-newsgroup-limit (copy-sequence articles))
3647 ;; Remove canceled articles from the list of unread articles.
3648 (setq gnus-newsgroup-unreads
3649 (gnus-set-sorted-intersection
3650 gnus-newsgroup-unreads
3651 (setq fetched-articles
3652 (mapcar (lambda (headers) (mail-header-number headers))
3653 gnus-newsgroup-headers))))
3654 ;; Removed marked articles that do not exist.
3655 (gnus-update-missing-marks
3656 (gnus-sorted-complement fetched-articles articles))
3657 ;; We might want to build some more threads first.
3658 (and gnus-fetch-old-headers
3659 (eq gnus-headers-retrieved-by 'nov)
3660 (gnus-build-old-threads))
3661 ;; Check whether auto-expire is to be done in this group.
3662 (setq gnus-newsgroup-auto-expire
3663 (gnus-group-auto-expirable-p group))
3664 ;; Set up the article buffer now, if necessary.
3665 (unless gnus-single-article-buffer
3666 (gnus-article-setup-buffer))
3667 ;; First and last article in this newsgroup.
3668 (when gnus-newsgroup-headers
3669 (setq gnus-newsgroup-begin
3670 (mail-header-number (car gnus-newsgroup-headers))
3673 (gnus-last-element gnus-newsgroup-headers))))
3674 ;; GROUP is successfully selected.
3675 (or gnus-newsgroup-headers t)))))
3677 (defun gnus-articles-to-read (group &optional read-all)
3678 ;; Find out what articles the user wants to read.
3680 ;; Select all articles if `read-all' is non-nil, or if there
3681 ;; are no unread articles.
3683 (and (zerop (length gnus-newsgroup-marked))
3684 (zerop (length gnus-newsgroup-unreads)))
3685 (eq (gnus-group-find-parameter group 'display)
3687 (gnus-uncompress-range (gnus-active group))
3688 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
3689 (copy-sequence gnus-newsgroup-unreads))
3691 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
3692 (scored (length scored-list))
3693 (number (length articles))
3694 (marked (+ (length gnus-newsgroup-marked)
3695 (length gnus-newsgroup-dormant)))
3703 ((and (or (<= scored marked) (= scored number))
3704 (numberp gnus-large-newsgroup)
3705 (> number gnus-large-newsgroup))
3709 "How many articles from %s (default %d): "
3710 (gnus-limit-string gnus-newsgroup-name 35)
3712 (if (string-match "^[ \t]*$" input) number input)))
3713 ((and (> scored marked) (< scored number)
3714 (> (- scored number) 20))
3717 (format "%s %s (%d scored, %d total): "
3718 "How many articles from"
3719 group scored number))))
3720 (if (string-match "^[ \t]*$" input)
3724 (setq select (if (stringp select) (string-to-number select) select))
3725 (if (or (null select) (zerop select))
3727 (if (and (not (zerop scored)) (<= (abs select) scored))
3729 (setq articles (sort scored-list '<))
3730 (setq number (length articles)))
3731 (setq articles (copy-sequence articles)))
3733 (when (< (abs select) number)
3735 ;; Select the N oldest articles.
3736 (setcdr (nthcdr (1- (abs select)) articles) nil)
3737 ;; Select the N most recent articles.
3738 (setq articles (nthcdr (- number select) articles))))
3739 (setq gnus-newsgroup-unselected
3740 (gnus-sorted-intersection
3741 gnus-newsgroup-unreads
3742 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3745 (defun gnus-killed-articles (killed articles)
3748 (when (inline (gnus-member-of-range (car articles) killed))
3749 (push (car articles) out))
3750 (setq articles (cdr articles)))
3753 (defun gnus-uncompress-marks (marks)
3754 "Uncompress the mark ranges in MARKS."
3755 (let ((uncompressed '(score bookmark))
3758 (if (memq (caar marks) uncompressed)
3759 (push (car marks) out)
3760 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
3761 (setq marks (cdr marks)))
3764 (defun gnus-adjust-marked-articles (info)
3765 "Set all article lists and remove all marks that are no longer legal."
3766 (let* ((marked-lists (gnus-info-marks info))
3767 (active (gnus-active (gnus-info-group info)))
3770 (types gnus-article-mark-lists)
3771 (uncompressed '(score bookmark killed))
3772 marks var articles article mark)
3775 (setq marks (pop marked-lists))
3776 (set (setq var (intern (format "gnus-newsgroup-%s"
3777 (car (rassq (setq mark (car marks))
3779 (if (memq (car marks) uncompressed) (cdr marks)
3780 (gnus-uncompress-range (cdr marks))))
3782 (setq articles (symbol-value var))
3784 ;; All articles have to be subsets of the active articles.
3786 ;; Adjust "simple" lists.
3787 ((memq mark '(tick dormant expirable reply save))
3789 (when (or (< (setq article (pop articles)) min) (> article max))
3790 (set var (delq article (symbol-value var))))))
3792 ((memq mark uncompressed)
3794 (when (or (not (consp (setq article (pop articles))))
3795 (< (car article) min)
3796 (> (car article) max))
3797 (set var (delq article (symbol-value var))))))))))
3799 (defun gnus-update-missing-marks (missing)
3800 "Go through the list of MISSING articles and remove them mark lists."
3802 (let ((types gnus-article-mark-lists)
3804 ;; Go through all types.
3806 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
3807 (when (symbol-value var)
3808 ;; This list has articles. So we delete all missing articles
3812 (set var (delq (pop m) (symbol-value var)))))))))
3814 (defun gnus-update-marks ()
3815 "Enter the various lists of marked articles into the newsgroup info list."
3816 (let ((types gnus-article-mark-lists)
3817 (info (gnus-get-info gnus-newsgroup-name))
3818 (uncompressed '(score bookmark killed))
3819 type list newmarked symbol)
3821 ;; Add all marks lists that are non-nil to the list of marks lists.
3823 (setq type (pop types))
3824 (when (setq list (symbol-value
3826 (intern (format "gnus-newsgroup-%s"
3828 (push (cons (cdr type)
3829 (if (memq (cdr type) uncompressed) list
3830 (gnus-compress-sequence
3831 (set symbol (sort list '<)) t)))
3834 ;; Enter these new marks into the info of the group.
3836 (setcar (nthcdr 3 info) newmarked)
3837 ;; Add the marks lists to the end of the info.
3839 (setcdr (nthcdr 2 info) (list newmarked))))
3841 ;; Cut off the end of the info if there's nothing else there.
3845 (when (nthcdr (decf i) info)
3846 (setcdr (nthcdr i info) nil)))))))
3848 (defun gnus-set-mode-line (where)
3849 "This function sets the mode line of the article or summary buffers.
3850 If WHERE is `summary', the summary mode line format will be used."
3851 ;; Is this mode line one we keep updated?
3852 (when (memq where gnus-updated-mode-lines)
3855 ;; We evaluate this in the summary buffer since these
3856 ;; variables are buffer-local to that buffer.
3857 (set-buffer gnus-summary-buffer)
3858 ;; We bind all these variables that are used in the `eval' form
3860 (let* ((mformat (symbol-value
3862 (format "gnus-%s-mode-line-format-spec" where))))
3863 (gnus-tmp-group-name gnus-newsgroup-name)
3864 (gnus-tmp-article-number (or gnus-current-article 0))
3865 (gnus-tmp-unread gnus-newsgroup-unreads)
3866 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
3867 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
3868 (gnus-tmp-unread-and-unselected
3869 (cond ((and (zerop gnus-tmp-unread-and-unticked)
3870 (zerop gnus-tmp-unselected))
3872 ((zerop gnus-tmp-unselected)
3873 (format "{%d more}" gnus-tmp-unread-and-unticked))
3874 (t (format "{%d(+%d) more}"
3875 gnus-tmp-unread-and-unticked
3876 gnus-tmp-unselected))))
3878 (if (and gnus-current-headers
3879 (vectorp gnus-current-headers))
3880 (gnus-mode-string-quote
3881 (mail-header-subject gnus-current-headers))
3884 gnus-tmp-header);; passed as argument to any user-format-funcs
3885 (setq mode-string (eval mformat))
3886 (setq max-len (max 4 (if gnus-mode-non-string-length
3888 gnus-mode-non-string-length)
3889 (length mode-string))))
3890 ;; We might have to chop a bit of the string off...
3891 (when (> (length mode-string) max-len)
3893 (concat (gnus-truncate-string mode-string (- max-len 3))
3895 ;; Pad the mode string a bit.
3896 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
3897 ;; Update the mode line.
3898 (setq mode-line-buffer-identification
3899 (gnus-mode-line-buffer-identification
3900 (list mode-string)))
3901 (set-buffer-modified-p t))))
3903 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
3904 "Go through the HEADERS list and add all Xrefs to a hash table.
3905 The resulting hash table is returned, or nil if no Xrefs were found."
3906 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
3907 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
3908 (xref-hashtb (gnus-make-hashtable))
3909 start group entry number xrefs header)
3911 (setq header (pop headers))
3912 (when (and (setq xrefs (mail-header-xref header))
3913 (not (memq (setq number (mail-header-number header))
3916 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
3917 (setq start (match-end 0))
3918 (setq group (if prefix
3919 (concat prefix (substring xrefs (match-beginning 1)
3921 (substring xrefs (match-beginning 1) (match-end 1))))
3923 (string-to-int (substring xrefs (match-beginning 2)
3925 (if (setq entry (gnus-gethash group xref-hashtb))
3926 (setcdr entry (cons number (cdr entry)))
3927 (gnus-sethash group (cons number nil) xref-hashtb)))))
3928 (and start xref-hashtb)))
3930 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
3931 "Look through all the headers and mark the Xrefs as read."
3932 (let ((virtual (gnus-virtual-group-p from-newsgroup))
3933 name entry info xref-hashtb idlist method nth4)
3935 (set-buffer gnus-group-buffer)
3936 (when (setq xref-hashtb
3937 (gnus-create-xref-hashtb from-newsgroup headers unreads))
3940 (unless (string= from-newsgroup (setq name (symbol-name group)))
3941 (setq idlist (symbol-value group))
3942 ;; Dead groups are not updated.
3944 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
3946 (when (stringp (setq nth4 (gnus-info-method info)))
3947 (setq nth4 (gnus-server-to-method nth4))))
3948 ;; Only do the xrefs if the group has the same
3949 ;; select method as the group we have just read.
3950 (or (gnus-methods-equal-p
3951 nth4 (gnus-find-method-for-group from-newsgroup))
3953 (equal nth4 (setq method (gnus-find-method-for-group
3955 (and (equal (car nth4) (car method))
3956 (equal (nth 1 nth4) (nth 1 method))))
3957 gnus-use-cross-reference
3958 (or (not (eq gnus-use-cross-reference t))
3960 ;; Only do cross-references on subscribed
3961 ;; groups, if that is what is wanted.
3962 (<= (gnus-info-level info) gnus-level-subscribed))
3963 (gnus-group-make-articles-read name idlist))))
3966 (defun gnus-group-make-articles-read (group articles)
3967 "Update the info of GROUP to say that only ARTICLES are unread."
3969 (entry (gnus-gethash group gnus-newsrc-hashtb))
3970 (info (nth 2 entry))
3971 (active (gnus-active group))
3973 ;; First peel off all illegal article numbers.
3975 (let ((ids articles)
3977 (while (setq id (pop ids))
3978 (when (and first (> id (cdr active)))
3979 ;; We'll end up in this situation in one particular
3980 ;; obscure situation. If you re-scan a group and get
3981 ;; a new article that is cross-posted to a different
3982 ;; group that has not been re-scanned, you might get
3983 ;; crossposted article that has a higher number than
3984 ;; Gnus believes possible. So we re-activate this
3985 ;; group as well. This might mean doing the
3986 ;; crossposting thingy will *increase* the number
3987 ;; of articles in some groups. Tsk, tsk.
3988 (setq active (or (gnus-activate-group group) active)))
3989 (when (or (> id (cdr active))
3990 (< id (car active)))
3991 (setq articles (delq id articles))))))
3993 (set-buffer gnus-group-buffer)
3996 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
3997 (gnus-info-set-read ',info ',(gnus-info-read info))
3998 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
3999 (gnus-group-update-group ,group t))))
4000 ;; If the read list is nil, we init it.
4002 (null (gnus-info-read info))
4004 (gnus-info-set-read info (cons 1 (1- (car active)))))
4005 ;; Then we add the read articles to the range.
4010 (gnus-info-read info) (setq articles (sort articles '<)))))
4011 ;; Then we have to re-compute how many unread
4012 ;; articles there are in this group.
4016 (setq num (- (1+ (cdr active)) (car active))))
4017 ((not (listp (cdr range)))
4018 (setq num (- (cdr active) (- (1+ (cdr range))
4022 (if (numberp (car range))
4024 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4025 (setq range (cdr range)))
4026 (setq num (- (cdr active) num))))
4027 ;; Update the number of unread articles.
4029 ;; Update the group buffer.
4030 (gnus-group-update-group group t))))
4032 (defun gnus-methods-equal-p (m1 m2)
4033 (let ((m1 (or m1 gnus-select-method))
4034 (m2 (or m2 gnus-select-method)))
4036 (and (eq (car m1) (car m2))
4037 (or (not (memq 'address (assoc (symbol-name (car m1))
4038 gnus-valid-select-methods)))
4039 (equal (nth 1 m1) (nth 1 m2)))))))
4041 (defvar gnus-newsgroup-none-id 0)
4043 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4044 (let ((cur nntp-server-buffer)
4047 (save-excursion (set-buffer gnus-summary-buffer)
4048 gnus-newsgroup-dependencies)))
4049 headers id id-dep ref-dep end ref)
4051 (set-buffer nntp-server-buffer)
4052 ;; Translate all TAB characters into SPACE characters.
4053 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4054 (run-hooks 'gnus-parse-headers-hook)
4055 (let ((case-fold-search t)
4056 in-reply-to header p lines)
4057 (goto-char (point-min))
4058 ;; Search to the beginning of the next header. Error messages
4059 ;; do not begin with 2 or 3.
4060 (while (re-search-forward "^[23][0-9]+ " nil t)
4063 ;; This implementation of this function, with nine
4064 ;; search-forwards instead of the one re-search-forward and
4065 ;; a case (which basically was the old function) is actually
4066 ;; about twice as fast, even though it looks messier. You
4067 ;; can't have everything, I guess. Speed and elegance
4068 ;; doesn't always go hand in hand.
4077 (narrow-to-region (point)
4078 (or (and (search-forward "\n.\n" nil t)
4084 (if (search-forward "\nsubject: " nil t)
4085 (nnheader-header-value) "(none)"))
4089 (if (search-forward "\nfrom: " nil t)
4090 (nnheader-header-value) "(nobody)"))
4094 (if (search-forward "\ndate: " nil t)
4095 (nnheader-header-value) ""))
4099 (setq id (if (search-forward "\nmessage-id: " nil t)
4100 (nnheader-header-value)
4101 ;; If there was no message-id, we just fake one
4102 ;; to make subsequent routines simpler.
4103 (nnheader-generate-fake-message-id))))
4107 (if (search-forward "\nreferences: " nil t)
4111 (nnheader-header-value)
4116 (search-backward ">" end t)
4119 (search-backward "<" end t)
4121 ;; Get the references from the in-reply-to header if there
4122 ;; were no references and the in-reply-to header looks
4124 (if (and (search-forward "\nin-reply-to: " nil t)
4125 (setq in-reply-to (nnheader-header-value))
4126 (string-match "<[^>]+>" in-reply-to))
4127 (setq ref (substring in-reply-to (match-beginning 0)
4135 (if (search-forward "\nlines: " nil t)
4136 (if (numberp (setq lines (read cur)))
4142 (and (search-forward "\nxref: " nil t)
4143 (nnheader-header-value)))))
4144 (when (equal id ref)
4146 ;; We do the threading while we read the headers. The
4147 ;; message-id and the last reference are both entered into
4148 ;; the same hash table. Some tippy-toeing around has to be
4149 ;; done in case an article has arrived before the article
4150 ;; which it refers to.
4151 (if (boundp (setq id-dep (intern id dependencies)))
4152 (if (and (car (symbol-value id-dep))
4154 ;; An article with this Message-ID has already
4155 ;; been seen, so we ignore this one, except we add
4156 ;; any additional Xrefs (in case the two articles
4157 ;; came from different servers).
4159 (mail-header-set-xref
4160 (car (symbol-value id-dep))
4161 (concat (or (mail-header-xref
4162 (car (symbol-value id-dep)))
4164 (or (mail-header-xref header) "")))
4166 (setcar (symbol-value id-dep) header))
4167 (set id-dep (list header)))
4169 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4170 (setcdr (symbol-value ref-dep)
4171 (nconc (cdr (symbol-value ref-dep))
4172 (list (symbol-value id-dep))))
4173 (set ref-dep (list nil (symbol-value id-dep))))
4174 (push header headers))
4175 (goto-char (point-max))
4177 (nreverse headers)))))
4179 ;; The following macros and functions were written by Felix Lee
4180 ;; <flee@cse.psu.edu>.
4182 (defmacro gnus-nov-read-integer ()
4184 (if (= (following-char) ?\t)
4186 (let ((num (ignore-errors (read buffer))))
4187 (if (numberp num) num 0)))
4191 (defmacro gnus-nov-skip-field ()
4192 '(search-forward "\t" eol 'move))
4194 (defmacro gnus-nov-field ()
4195 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
4197 ;; (defvar gnus-nov-none-counter 0)
4199 ;; This function has to be called with point after the article number
4200 ;; on the beginning of the line.
4201 (defun gnus-nov-parse-line (number dependencies &optional force-new)
4202 (let ((eol (gnus-point-at-eol))
4203 (buffer (current-buffer))
4204 header ref id id-dep ref-dep)
4206 ;; overview: [num subject from date id refs chars lines misc]
4209 (narrow-to-region (point) eol)
4216 (gnus-nov-field) ; subject
4217 (gnus-nov-field) ; from
4218 (gnus-nov-field) ; date
4219 (setq id (or (gnus-nov-field)
4220 (nnheader-generate-fake-message-id))) ; id
4222 (let ((beg (point)))
4223 (search-forward "\t" eol)
4224 (if (search-backward ">" beg t)
4228 (search-backward "<" beg t)))
4231 (gnus-nov-field)) ; refs
4232 (gnus-nov-read-integer) ; chars
4233 (gnus-nov-read-integer) ; lines
4234 (if (= (following-char) ?\n)
4236 (gnus-nov-field)) ; misc
4241 ;; We build the thread tree.
4242 (when (equal id ref)
4243 ;; This article refers back to itself. Naughty, naughty.
4245 (if (boundp (setq id-dep (intern id dependencies)))
4246 (if (and (car (symbol-value id-dep))
4248 ;; An article with this Message-ID has already been seen,
4249 ;; so we ignore this one, except we add any additional
4250 ;; Xrefs (in case the two articles came from different
4253 (mail-header-set-xref
4254 (car (symbol-value id-dep))
4255 (concat (or (mail-header-xref
4256 (car (symbol-value id-dep)))
4258 (or (mail-header-xref header) "")))
4260 (setcar (symbol-value id-dep) header))
4261 (set id-dep (list header)))
4263 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
4264 (setcdr (symbol-value ref-dep)
4265 (nconc (cdr (symbol-value ref-dep))
4266 (list (symbol-value id-dep))))
4267 (set ref-dep (list nil (symbol-value id-dep)))))
4270 ;; Goes through the xover lines and returns a list of vectors
4271 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4272 force-new dependencies
4273 group also-fetch-heads)
4274 "Parse the news overview data in the server buffer, and return a
4275 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4276 ;; Get the Xref when the users reads the articles since most/some
4277 ;; NNTP servers do not include Xrefs when using XOVER.
4278 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4279 (let ((cur nntp-server-buffer)
4280 (dependencies (or dependencies gnus-newsgroup-dependencies))
4281 number headers header)
4283 (set-buffer nntp-server-buffer)
4284 ;; Allow the user to mangle the headers before parsing them.
4285 (run-hooks 'gnus-parse-headers-hook)
4286 (goto-char (point-min))
4289 (while (and sequence (not (eobp)))
4290 (setq number (read cur))
4291 (while (and sequence
4292 (< (car sequence) number))
4293 (setq sequence (cdr sequence)))
4295 (eq number (car sequence))
4297 (setq sequence (cdr sequence))
4298 (setq header (inline
4299 (gnus-nov-parse-line
4300 number dependencies force-new))))
4301 (push header headers))
4304 (gnus-error 4 "Strange nov line (%d)"
4305 (count-lines (point-min) (point)))))
4307 ;; A common bug in inn is that if you have posted an article and
4308 ;; then retrieves the active file, it will answer correctly --
4309 ;; the new article is included. However, a NOV entry for the
4310 ;; article may not have been generated yet, so this may fail.
4311 ;; We work around this problem by retrieving the last few
4312 ;; headers using HEAD.
4313 (if (or (not also-fetch-heads)
4316 (let ((gnus-nov-is-evil t)
4317 (nntp-nov-is-evil t))
4320 (when (gnus-retrieve-headers sequence group)
4321 (gnus-get-newsgroup-headers))))))))
4323 (defun gnus-article-get-xrefs ()
4324 "Fill in the Xref value in `gnus-current-headers', if necessary.
4325 This is meant to be called in `gnus-article-internal-prepare-hook'."
4326 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4327 gnus-current-headers)))
4328 (or (not gnus-use-cross-reference)
4330 (and (mail-header-xref headers)
4331 (not (string= (mail-header-xref headers) "")))
4332 (let ((case-fold-search t)
4335 (nnheader-narrow-to-headers)
4336 (goto-char (point-min))
4337 (when (or (and (eq (downcase (following-char)) ?x)
4338 (looking-at "Xref:"))
4339 (search-forward "\nXref:" nil t))
4340 (goto-char (1+ (match-end 0)))
4341 (setq xref (buffer-substring (point)
4342 (progn (end-of-line) (point))))
4343 (mail-header-set-xref headers xref)))))))
4345 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4346 "Find article ID and insert the summary line for that article."
4347 (let ((header (if (and old-header use-old-header)
4348 old-header (gnus-read-header id)))
4349 (number (and (numberp id) id))
4352 ;; Rebuild the thread that this article is part of and go to the
4353 ;; article we have fetched.
4354 (when (and (not gnus-show-threads)
4356 (when (setq d (gnus-data-find (mail-header-number old-header)))
4357 (goto-char (gnus-data-pos d))
4360 (- (gnus-point-at-bol)
4362 (1+ (gnus-point-at-eol))
4363 (gnus-delete-line))))))
4365 (mail-header-set-number header (mail-header-number old-header)))
4366 (setq gnus-newsgroup-sparse
4367 (delq (setq number (mail-header-number header))
4368 gnus-newsgroup-sparse))
4369 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4370 (gnus-rebuild-thread (mail-header-id header))
4371 (gnus-summary-goto-subject number nil t))
4372 (when (and (numberp number)
4374 ;; We have to update the boundaries even if we can't fetch the
4375 ;; article if ID is a number -- so that the next `P' or `N'
4376 ;; command will fetch the previous (or next) article even
4377 ;; if the one we tried to fetch this time has been canceled.
4378 (when (> number gnus-newsgroup-end)
4379 (setq gnus-newsgroup-end number))
4380 (when (< number gnus-newsgroup-begin)
4381 (setq gnus-newsgroup-begin number))
4382 (setq gnus-newsgroup-unselected
4383 (delq number gnus-newsgroup-unselected)))
4384 ;; Report back a success?
4385 (and header (mail-header-number header))))
4387 ;;; Process/prefix in the summary buffer
4389 (defun gnus-summary-work-articles (n)
4390 "Return a list of articles to be worked upon. The prefix argument,
4391 the list of process marked articles, and the current article will be
4392 taken into consideration."
4395 ;; A numerical prefix has been given.
4396 (setq n (prefix-numeric-value n))
4397 (let ((backward (< n 0))
4398 (n (abs (prefix-numeric-value n)))
4403 (push (setq article (gnus-summary-article-number))
4406 (gnus-summary-find-prev nil article)
4407 (gnus-summary-find-next nil article)))
4409 (nreverse articles)))
4410 ((and (boundp 'transient-mark-mode)
4412 (boundp 'mark-active)
4414 ;; Work on the region between point and mark.
4415 (let ((max (max (point) (mark)))
4418 (goto-char (min (point) (mark)))
4421 (push (setq article (gnus-summary-article-number)) articles)
4422 (gnus-summary-find-next nil article)
4424 (nreverse articles))))
4425 (gnus-newsgroup-processable
4426 ;; There are process-marked articles present.
4427 ;; Save current state.
4428 (gnus-summary-save-process-mark)
4430 (reverse gnus-newsgroup-processable))
4432 ;; Just return the current article.
4433 (list (gnus-summary-article-number)))))
4435 (defun gnus-summary-save-process-mark ()
4436 "Push the current set of process marked articles on the stack."
4438 (push (copy-sequence gnus-newsgroup-processable)
4439 gnus-newsgroup-process-stack))
4441 (defun gnus-summary-kill-process-mark ()
4442 "Push the current set of process marked articles on the stack and unmark."
4444 (gnus-summary-save-process-mark)
4445 (gnus-summary-unmark-all-processable))
4447 (defun gnus-summary-yank-process-mark ()
4448 "Pop the last process mark state off the stack and restore it."
4450 (unless gnus-newsgroup-process-stack
4451 (error "Empty mark stack"))
4452 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4454 (defun gnus-summary-process-mark-set (set)
4455 "Make SET into the current process marked articles."
4456 (gnus-summary-unmark-all-processable)
4458 (gnus-summary-set-process-mark (pop set))))
4460 ;;; Searching and stuff
4462 (defun gnus-summary-search-group (&optional backward use-level)
4463 "Search for next unread newsgroup.
4464 If optional argument BACKWARD is non-nil, search backward instead."
4466 (set-buffer gnus-group-buffer)
4467 (when (gnus-group-search-forward
4468 backward nil (if use-level (gnus-group-group-level) nil))
4469 (gnus-group-group-name))))
4471 (defun gnus-summary-best-group (&optional exclude-group)
4472 "Find the name of the best unread group.
4473 If EXCLUDE-GROUP, do not go to this group."
4475 (set-buffer gnus-group-buffer)
4477 (gnus-group-best-unread-group exclude-group))))
4479 (defun gnus-summary-find-next (&optional unread article backward)
4480 (if backward (gnus-summary-find-prev)
4481 (let* ((dummy (gnus-summary-article-intangible-p))
4482 (article (or article (gnus-summary-article-number)))
4483 (arts (gnus-data-find-list article))
4485 (when (and (not dummy)
4486 (or (not gnus-summary-check-current)
4488 (not (gnus-data-unread-p (car arts)))))
4489 (setq arts (cdr arts)))
4494 (when (gnus-data-unread-p (car arts))
4495 (setq result (car arts)
4497 (setq arts (cdr arts)))
4500 (goto-char (gnus-data-pos result))
4501 (gnus-data-number result)))))
4503 (defun gnus-summary-find-prev (&optional unread article)
4504 (let* ((eobp (eobp))
4505 (article (or article (gnus-summary-article-number)))
4506 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4508 (when (and (not eobp)
4509 (or (not gnus-summary-check-current)
4511 (not (gnus-data-unread-p (car arts)))))
4512 (setq arts (cdr arts)))
4517 (when (gnus-data-unread-p (car arts))
4518 (setq result (car arts)
4520 (setq arts (cdr arts)))
4523 (goto-char (gnus-data-pos result))
4524 (gnus-data-number result))))
4526 (defun gnus-summary-find-subject (subject &optional unread backward article)
4527 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4528 (article (or article (gnus-summary-article-number)))
4529 (articles (gnus-data-list backward))
4530 (arts (gnus-data-find-list article articles))
4532 (when (or (not gnus-summary-check-current)
4534 (not (gnus-data-unread-p (car arts))))
4535 (setq arts (cdr arts)))
4537 (and (or (not unread)
4538 (gnus-data-unread-p (car arts)))
4539 (vectorp (gnus-data-header (car arts)))
4541 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4542 (setq result (car arts)
4544 (setq arts (cdr arts)))
4546 (goto-char (gnus-data-pos result))
4547 (gnus-data-number result))))
4549 (defun gnus-summary-search-forward (&optional unread subject backward)
4550 "Search forward for an article.
4551 If UNREAD, look for unread articles. If SUBJECT, look for
4552 articles with that subject. If BACKWARD, search backward instead."
4553 (cond (subject (gnus-summary-find-subject subject unread backward))
4554 (backward (gnus-summary-find-prev unread))
4555 (t (gnus-summary-find-next unread))))
4557 (defun gnus-recenter (&optional n)
4558 "Center point in window and redisplay frame.
4559 Also do horizontal recentering."
4561 (when (and gnus-auto-center-summary
4562 (not (eq gnus-auto-center-summary 'vertical)))
4563 (gnus-horizontal-recenter))
4566 (defun gnus-summary-recenter ()
4567 "Center point in the summary window.
4568 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4569 displayed, no centering will be performed."
4570 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4571 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4572 (let* ((top (cond ((< (window-height) 4) 0)
4573 ((< (window-height) 7) 1)
4575 (height (1- (window-height)))
4576 (bottom (save-excursion (goto-char (point-max))
4577 (forward-line (- height))
4579 (window (get-buffer-window (current-buffer))))
4580 ;; The user has to want it.
4581 (when gnus-auto-center-summary
4582 (when (get-buffer-window gnus-article-buffer)
4583 ;; Only do recentering when the article buffer is displayed,
4584 ;; Set the window start to either `bottom', which is the biggest
4585 ;; possible valid number, or the second line from the top,
4586 ;; whichever is the least.
4588 window (min bottom (save-excursion
4589 (forward-line (- top)) (point)))))
4590 ;; Do horizontal recentering while we're at it.
4591 (when (and (get-buffer-window (current-buffer) t)
4592 (not (eq gnus-auto-center-summary 'vertical)))
4593 (let ((selected (selected-window)))
4594 (select-window (get-buffer-window (current-buffer) t))
4595 (gnus-summary-position-point)
4596 (gnus-horizontal-recenter)
4597 (select-window selected))))))
4599 (defun gnus-summary-jump-to-group (newsgroup)
4600 "Move point to NEWSGROUP in group mode buffer."
4601 ;; Keep update point of group mode buffer if visible.
4602 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
4603 (save-window-excursion
4604 ;; Take care of tree window mode.
4605 (when (get-buffer-window gnus-group-buffer)
4606 (pop-to-buffer gnus-group-buffer))
4607 (gnus-group-jump-to-group newsgroup))
4609 ;; Take care of tree window mode.
4610 (if (get-buffer-window gnus-group-buffer)
4611 (pop-to-buffer gnus-group-buffer)
4612 (set-buffer gnus-group-buffer))
4613 (gnus-group-jump-to-group newsgroup))))
4615 ;; This function returns a list of article numbers based on the
4616 ;; difference between the ranges of read articles in this group and
4617 ;; the range of active articles.
4618 (defun gnus-list-of-unread-articles (group)
4619 (let* ((read (gnus-info-read (gnus-get-info group)))
4620 (active (or (gnus-active group) (gnus-activate-group group)))
4623 ;; If none are read, then all are unread.
4625 (setq first (car active))
4626 ;; If the range of read articles is a single range, then the
4627 ;; first unread article is the article after the last read
4628 ;; article. Sounds logical, doesn't it?
4629 (if (not (listp (cdr read)))
4630 (setq first (1+ (cdr read)))
4631 ;; `read' is a list of ranges.
4632 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
4638 (while (< first nlast)
4640 (setq first (1+ first))))
4641 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
4642 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
4643 (setq read (cdr read)))))
4644 ;; And add the last unread articles.
4645 (while (<= first last)
4647 (setq first (1+ first)))
4648 ;; Return the list of unread articles.
4651 (defun gnus-list-of-read-articles (group)
4652 "Return a list of unread, unticked and non-dormant articles."
4653 (let* ((info (gnus-get-info group))
4654 (marked (gnus-info-marks info))
4655 (active (gnus-active group)))
4657 (gnus-set-difference
4658 (gnus-sorted-complement
4659 (gnus-uncompress-range active)
4660 (gnus-list-of-unread-articles group))
4662 (gnus-uncompress-range (cdr (assq 'dormant marked)))
4663 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
4665 ;; Various summary commands
4667 (defun gnus-summary-universal-argument (arg)
4668 "Perform any operation on all articles that are process/prefixed."
4670 (gnus-set-global-variables)
4671 (let ((articles (gnus-summary-work-articles arg))
4678 (substitute-command-keys
4679 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
4682 (gnus-error 1 "Undefined key")
4685 (gnus-summary-goto-subject (setq article (pop articles)))
4686 (let (gnus-newsgroup-processable)
4687 (command-execute func))
4688 (gnus-summary-remove-process-mark article)))))
4689 (gnus-summary-position-point))
4691 (defun gnus-summary-toggle-truncation (&optional arg)
4692 "Toggle truncation of summary lines.
4693 With arg, turn line truncation on iff arg is positive."
4695 (setq truncate-lines
4696 (if (null arg) (not truncate-lines)
4697 (> (prefix-numeric-value arg) 0)))
4700 (defun gnus-summary-reselect-current-group (&optional all rescan)
4701 "Exit and then reselect the current newsgroup.
4702 The prefix argument ALL means to select all articles."
4704 (gnus-set-global-variables)
4705 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
4706 (error "Ephemeral groups can't be reselected"))
4707 (let ((current-subject (gnus-summary-article-number))
4708 (group gnus-newsgroup-name))
4709 (setq gnus-newsgroup-begin nil)
4711 ;; We have to adjust the point of group mode buffer because
4712 ;; point was moved to the next unread newsgroup by exiting.
4713 (gnus-summary-jump-to-group group)
4716 (gnus-group-get-new-news-this-group 1)))
4717 (gnus-group-read-group all t)
4718 (gnus-summary-goto-subject current-subject nil t)))
4720 (defun gnus-summary-rescan-group (&optional all)
4721 "Exit the newsgroup, ask for new articles, and select the newsgroup."
4723 (gnus-summary-reselect-current-group all t))
4725 (defun gnus-summary-update-info (&optional non-destructive)
4727 (let ((group gnus-newsgroup-name))
4728 (when gnus-newsgroup-kill-headers
4729 (setq gnus-newsgroup-killed
4730 (gnus-compress-sequence
4732 (gnus-set-sorted-intersection
4733 (gnus-uncompress-range gnus-newsgroup-killed)
4734 (setq gnus-newsgroup-unselected
4735 (sort gnus-newsgroup-unselected '<)))
4736 (setq gnus-newsgroup-unreads
4737 (sort gnus-newsgroup-unreads '<)))
4739 (unless (listp (cdr gnus-newsgroup-killed))
4740 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
4741 (let ((headers gnus-newsgroup-headers))
4742 (when (and (not gnus-save-score)
4743 (not non-destructive))
4744 (setq gnus-newsgroup-scored nil))
4745 ;; Set the new ranges of read articles.
4746 (gnus-update-read-articles
4747 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
4748 ;; Set the current article marks.
4750 ;; Do the cross-ref thing.
4751 (when gnus-use-cross-reference
4752 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
4753 ;; Do adaptive scoring, and possibly save score files.
4754 (when gnus-newsgroup-adaptive
4755 (gnus-score-adaptive))
4756 (when gnus-use-scoring
4758 ;; Do not switch windows but change the buffer to work.
4759 (set-buffer gnus-group-buffer)
4760 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
4761 (gnus-group-update-group group))))))
4763 (defun gnus-summary-save-newsrc (&optional force)
4764 "Save the current number of read/marked articles in the dribble buffer.
4765 The dribble buffer will then be saved.
4766 If FORCE (the prefix), also save the .newsrc file(s)."
4768 (gnus-summary-update-info t)
4770 (gnus-save-newsrc-file)
4771 (gnus-dribble-save)))
4773 (defun gnus-summary-exit (&optional temporary)
4774 "Exit reading current newsgroup, and then return to group selection mode.
4775 gnus-exit-group-hook is called with no arguments if that value is non-nil."
4777 (gnus-set-global-variables)
4778 (gnus-kill-save-kill-buffer)
4779 (let* ((group gnus-newsgroup-name)
4780 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
4782 (buf (current-buffer)))
4783 (run-hooks 'gnus-summary-prepare-exit-hook)
4784 ;; If we have several article buffers, we kill them at exit.
4785 (unless gnus-single-article-buffer
4786 (gnus-kill-buffer gnus-original-article-buffer)
4787 (setq gnus-article-current nil))
4788 (when gnus-use-cache
4789 (gnus-cache-possibly-remove-articles)
4790 (gnus-cache-save-buffers))
4791 (gnus-async-prefetch-remove-group group)
4792 (when gnus-suppress-duplicates
4793 (gnus-dup-enter-articles))
4794 (when gnus-use-trees
4795 (gnus-tree-close group))
4796 ;; Make all changes in this group permanent.
4798 (run-hooks 'gnus-exit-group-hook)
4799 (gnus-summary-update-info))
4800 (gnus-close-group group)
4801 ;; Make sure where I was, and go to next newsgroup.
4802 (set-buffer gnus-group-buffer)
4804 (gnus-group-jump-to-group group))
4805 (run-hooks 'gnus-summary-exit-hook)
4807 (gnus-group-next-unread-group 1))
4810 ;; If we have several article buffers, we kill them at exit.
4811 (unless gnus-single-article-buffer
4812 (gnus-kill-buffer gnus-article-buffer)
4813 (gnus-kill-buffer gnus-original-article-buffer)
4814 (setq gnus-article-current nil))
4816 (if (not gnus-kill-summary-on-exit)
4817 (gnus-deaden-summary)
4818 ;; We set all buffer-local variables to nil. It is unclear why
4819 ;; this is needed, but if we don't, buffer-local variables are
4820 ;; not garbage-collected, it seems. This would the lead to en
4821 ;; ever-growing Emacs.
4822 (gnus-summary-clear-local-variables)
4823 (when (get-buffer gnus-article-buffer)
4824 (bury-buffer gnus-article-buffer))
4825 ;; We clear the global counterparts of the buffer-local
4826 ;; variables as well, just to be on the safe side.
4827 (set-buffer gnus-group-buffer)
4828 (gnus-summary-clear-local-variables)
4829 ;; Return to group mode buffer.
4830 (when (eq mode 'gnus-summary-mode)
4831 (gnus-kill-buffer buf)))
4832 (setq gnus-current-select-method gnus-select-method)
4833 (pop-to-buffer gnus-group-buffer)
4834 ;; Clear the current group name.
4835 (if (not quit-config)
4837 (gnus-group-jump-to-group group)
4838 (gnus-group-next-unread-group 1)
4839 (gnus-configure-windows 'group 'force))
4840 (gnus-handle-ephemeral-exit quit-config))
4842 (setq gnus-newsgroup-name nil)))))
4844 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
4845 (defun gnus-summary-exit-no-update (&optional no-questions)
4846 "Quit reading current newsgroup without updating read article info."
4848 (gnus-set-global-variables)
4849 (let* ((group gnus-newsgroup-name)
4850 (quit-config (gnus-group-quit-config group)))
4851 (when (or no-questions
4853 (gnus-y-or-n-p "Discard changes to this group and exit? "))
4854 ;; If we have several article buffers, we kill them at exit.
4855 (unless gnus-single-article-buffer
4856 (gnus-kill-buffer gnus-article-buffer)
4857 (gnus-kill-buffer gnus-original-article-buffer)
4858 (setq gnus-article-current nil))
4859 (if (not gnus-kill-summary-on-exit)
4860 (gnus-deaden-summary)
4861 (gnus-close-group group)
4862 (gnus-summary-clear-local-variables)
4863 (set-buffer gnus-group-buffer)
4864 (gnus-summary-clear-local-variables)
4865 (when (get-buffer gnus-summary-buffer)
4866 (kill-buffer gnus-summary-buffer)))
4867 (unless gnus-single-article-buffer
4868 (setq gnus-article-current nil))
4869 (when gnus-use-trees
4870 (gnus-tree-close group))
4871 (gnus-async-prefetch-remove-group group)
4872 (when (get-buffer gnus-article-buffer)
4873 (bury-buffer gnus-article-buffer))
4874 ;; Return to the group buffer.
4875 (gnus-configure-windows 'group 'force)
4876 ;; Clear the current group name.
4877 (setq gnus-newsgroup-name nil)
4878 (when (equal (gnus-group-group-name) group)
4879 (gnus-group-next-unread-group 1))
4881 (gnus-handle-ephemeral-exit quit-config)))))
4883 (defun gnus-handle-ephemeral-exit (quit-config)
4884 "Handle movement when leaving an ephemeral group. The state
4885 which existed when entering the ephemeral is reset."
4886 (if (not (buffer-name (car quit-config)))
4887 (gnus-configure-windows 'group 'force)
4888 (set-buffer (car quit-config))
4889 (cond ((eq major-mode 'gnus-summary-mode)
4890 (gnus-set-global-variables))
4891 ((eq major-mode 'gnus-article-mode)
4893 ;; The `gnus-summary-buffer' variable may point
4894 ;; to the old summary buffer when using a single
4896 (unless (gnus-buffer-live-p gnus-summary-buffer)
4897 (set-buffer gnus-group-buffer))
4898 (set-buffer gnus-summary-buffer)
4899 (gnus-set-global-variables))))
4900 (if (or (eq (cdr quit-config) 'article)
4901 (eq (cdr quit-config) 'pick))
4903 ;; The current article may be from the ephemeral group
4904 ;; thus it is best that we reload this article
4905 (gnus-summary-show-article)
4906 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
4907 (gnus-configure-windows 'pick 'force)
4908 (gnus-configure-windows (cdr quit-config) 'force)))
4909 (gnus-configure-windows (cdr quit-config) 'force))
4910 (when (eq major-mode 'gnus-summary-mode)
4911 (gnus-summary-next-subject 1 nil t)
4912 (gnus-summary-recenter)
4913 (gnus-summary-position-point))))
4917 (defvar gnus-dead-summary-mode-map nil)
4919 (unless gnus-dead-summary-mode-map
4920 (setq gnus-dead-summary-mode-map (make-keymap))
4921 (suppress-keymap gnus-dead-summary-mode-map)
4922 (substitute-key-definition
4923 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
4924 (let ((keys '("\C-d" "\r" "\177")))
4926 (define-key gnus-dead-summary-mode-map
4927 (pop keys) 'gnus-summary-wake-up-the-dead))))
4929 (defvar gnus-dead-summary-mode nil
4930 "Minor mode for Gnus summary buffers.")
4932 (defun gnus-dead-summary-mode (&optional arg)
4933 "Minor mode for Gnus summary buffers."
4935 (when (eq major-mode 'gnus-summary-mode)
4936 (make-local-variable 'gnus-dead-summary-mode)
4937 (setq gnus-dead-summary-mode
4938 (if (null arg) (not gnus-dead-summary-mode)
4939 (> (prefix-numeric-value arg) 0)))
4940 (when gnus-dead-summary-mode
4941 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
4942 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
4943 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
4944 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
4945 minor-mode-map-alist)))))
4947 (defun gnus-deaden-summary ()
4948 "Make the current summary buffer into a dead summary buffer."
4949 ;; Kill any previous dead summary buffer.
4950 (when (and gnus-dead-summary
4951 (buffer-name gnus-dead-summary))
4953 (set-buffer gnus-dead-summary)
4954 (when gnus-dead-summary-mode
4955 (kill-buffer (current-buffer)))))
4956 ;; Make this the current dead summary.
4957 (setq gnus-dead-summary (current-buffer))
4958 (gnus-dead-summary-mode 1)
4959 (let ((name (buffer-name)))
4960 (when (string-match "Summary" name)
4962 (concat (substring name 0 (match-beginning 0)) "Dead "
4963 (substring name (match-beginning 0)))
4966 (defun gnus-kill-or-deaden-summary (buffer)
4967 "Kill or deaden the summary BUFFER."
4968 (when (and (buffer-name buffer)
4969 (not gnus-single-article-buffer))
4972 (gnus-kill-buffer gnus-article-buffer)
4973 (gnus-kill-buffer gnus-original-article-buffer)))
4974 (cond (gnus-kill-summary-on-exit
4975 (when (and gnus-use-trees
4976 (and (get-buffer buffer)
4977 (buffer-name (get-buffer buffer))))
4979 (set-buffer (get-buffer buffer))
4980 (gnus-tree-close gnus-newsgroup-name)))
4981 (gnus-kill-buffer buffer))
4982 ((and (get-buffer buffer)
4983 (buffer-name (get-buffer buffer)))
4986 (gnus-deaden-summary)))))
4988 (defun gnus-summary-wake-up-the-dead (&rest args)
4989 "Wake up the dead summary buffer."
4991 (gnus-dead-summary-mode -1)
4992 (let ((name (buffer-name)))
4993 (when (string-match "Dead " name)
4995 (concat (substring name 0 (match-beginning 0))
4996 (substring name (match-end 0)))
4998 (gnus-message 3 "This dead summary is now alive again"))
5000 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5001 (defun gnus-summary-fetch-faq (&optional faq-dir)
5002 "Fetch the FAQ for the current group.
5003 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5007 (when current-prefix-arg
5009 "Faq dir: " (and (listp gnus-group-faq-directory)
5010 gnus-group-faq-directory)))))
5011 (let (gnus-faq-buffer)
5012 (when (setq gnus-faq-buffer
5013 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5014 (gnus-configure-windows 'summary-faq))))
5016 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5017 (defun gnus-summary-describe-group (&optional force)
5018 "Describe the current newsgroup."
5020 (gnus-group-describe-group force gnus-newsgroup-name))
5022 (defun gnus-summary-describe-briefly ()
5023 "Describe summary mode commands briefly."
5026 (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")))
5028 ;; Walking around group mode buffer from summary mode.
5030 (defun gnus-summary-next-group (&optional no-article target-group backward)
5031 "Exit current newsgroup and then select next unread newsgroup.
5032 If prefix argument NO-ARTICLE is non-nil, no article is selected
5033 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5034 previous group instead."
5036 (gnus-set-global-variables)
5037 ;; Stop pre-fetching.
5038 (gnus-async-halt-prefetch)
5039 (let ((current-group gnus-newsgroup-name)
5040 (current-buffer (current-buffer))
5042 ;; First we semi-exit this group to update Xrefs and all variables.
5043 ;; We can't do a real exit, because the window conf must remain
5044 ;; the same in case the user is prompted for info, and we don't
5045 ;; want the window conf to change before that...
5046 (gnus-summary-exit t)
5047 (while (not entered)
5048 ;; Then we find what group we are supposed to enter.
5049 (set-buffer gnus-group-buffer)
5050 (gnus-group-jump-to-group current-group)
5053 (if (eq gnus-keep-same-level 'best)
5054 (gnus-summary-best-group gnus-newsgroup-name)
5055 (gnus-summary-search-group backward gnus-keep-same-level))))
5056 (if (not target-group)
5057 ;; There are no further groups, so we return to the group
5060 (gnus-message 5 "Returning to the group buffer")
5062 (set-buffer current-buffer)
5064 (run-hooks 'gnus-group-no-more-groups-hook))
5065 ;; We try to enter the target group.
5066 (gnus-group-jump-to-group target-group)
5067 (let ((unreads (gnus-group-group-unread)))
5068 (if (and (or (eq t unreads)
5069 (and unreads (not (zerop unreads))))
5070 (gnus-summary-read-group
5071 target-group nil no-article current-buffer))
5073 (setq current-group target-group
5074 target-group nil)))))))
5076 (defun gnus-summary-prev-group (&optional no-article)
5077 "Exit current newsgroup and then select previous unread newsgroup.
5078 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5080 (gnus-summary-next-group no-article nil t))
5082 ;; Walking around summary lines.
5084 (defun gnus-summary-first-subject (&optional unread)
5085 "Go to the first unread subject.
5086 If UNREAD is non-nil, go to the first unread article.
5087 Returns the article selected or nil if there are no unread articles."
5092 ((null gnus-newsgroup-data)
5093 (gnus-message 3 "No articles in the group")
5095 ;; Pick the first article.
5097 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5098 (gnus-data-number (car gnus-newsgroup-data)))
5099 ;; No unread articles.
5100 ((null gnus-newsgroup-unreads)
5101 (gnus-message 3 "No more unread articles")
5103 ;; Find the first unread article.
5105 (let ((data gnus-newsgroup-data))
5107 (not (gnus-data-unread-p (car data))))
5108 (setq data (cdr data)))
5110 (goto-char (gnus-data-pos (car data)))
5111 (gnus-data-number (car data))))))
5112 (gnus-summary-position-point)))
5114 (defun gnus-summary-next-subject (n &optional unread dont-display)
5115 "Go to next N'th summary line.
5116 If N is negative, go to the previous N'th subject line.
5117 If UNREAD is non-nil, only unread articles are selected.
5118 The difference between N and the actual number of steps taken is
5121 (let ((backward (< n 0))
5125 (gnus-summary-find-prev unread)
5126 (gnus-summary-find-next unread)))
5129 (gnus-message 7 "No more%s articles"
5130 (if unread " unread" "")))
5131 (unless dont-display
5132 (gnus-summary-recenter)
5133 (gnus-summary-position-point))
5136 (defun gnus-summary-next-unread-subject (n)
5137 "Go to next N'th unread summary line."
5139 (gnus-summary-next-subject n t))
5141 (defun gnus-summary-prev-subject (n &optional unread)
5142 "Go to previous N'th summary line.
5143 If optional argument UNREAD is non-nil, only unread article is selected."
5145 (gnus-summary-next-subject (- n) unread))
5147 (defun gnus-summary-prev-unread-subject (n)
5148 "Go to previous N'th unread summary line."
5150 (gnus-summary-next-subject (- n) t))
5152 (defun gnus-summary-goto-subject (article &optional force silent)
5153 "Go the subject line of ARTICLE.
5154 If FORCE, also allow jumping to articles not currently shown."
5155 (interactive "nArticle number: ")
5157 (data (gnus-data-find article)))
5158 ;; We read in the article if we have to.
5161 (gnus-summary-insert-subject article (and (vectorp force) force) t)
5162 (setq data (gnus-data-find article)))
5167 (gnus-message 3 "Can't find article %d" article))
5169 (goto-char (gnus-data-pos data))
5172 ;; Walking around summary lines with displaying articles.
5174 (defun gnus-summary-expand-window (&optional arg)
5175 "Make the summary buffer take up the entire Emacs frame.
5176 Given a prefix, will force an `article' buffer configuration."
5178 (gnus-set-global-variables)
5180 (gnus-configure-windows 'article 'force)
5181 (gnus-configure-windows 'summary 'force)))
5183 (defun gnus-summary-display-article (article &optional all-header)
5184 "Display ARTICLE in article buffer."
5185 (gnus-set-global-variables)
5189 (if gnus-summary-display-article-function
5190 (funcall gnus-summary-display-article-function article all-header)
5191 (gnus-article-prepare article all-header))
5192 (run-hooks 'gnus-select-article-hook)
5193 (when (and gnus-current-article
5194 (not (zerop gnus-current-article)))
5195 (gnus-summary-goto-subject gnus-current-article))
5196 (gnus-summary-recenter)
5197 (when (and gnus-use-trees gnus-show-threads)
5198 (gnus-possibly-generate-tree article)
5199 (gnus-highlight-selected-tree article))
5200 ;; Successfully display article.
5201 (gnus-article-set-window-start
5202 (cdr (assq article gnus-newsgroup-bookmarks))))))
5204 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5205 "Select the current article.
5206 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5207 non-nil, the article will be re-fetched even if it already present in
5208 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5210 ;; Make sure we are in the summary buffer to work around bbdb bug.
5211 (unless (eq major-mode 'gnus-summary-mode)
5212 (set-buffer gnus-summary-buffer))
5213 (let ((article (or article (gnus-summary-article-number)))
5214 (all-headers (not (not all-headers))) ;Must be T or NIL.
5215 gnus-summary-display-article-function
5218 (gnus-summary-article-pseudo-p article)
5219 (error "This is a pseudo-article."))
5222 (set-buffer gnus-summary-buffer)
5223 (if (or (and gnus-single-article-buffer
5224 (or (null gnus-current-article)
5225 (null gnus-article-current)
5226 (null (get-buffer gnus-article-buffer))
5227 (not (eq article (cdr gnus-article-current)))
5228 (not (equal (car gnus-article-current)
5229 gnus-newsgroup-name))))
5230 (and (not gnus-single-article-buffer)
5231 (or (null gnus-current-article)
5232 (not (eq gnus-current-article article))))
5234 ;; The requested article is different from the current article.
5236 (gnus-summary-display-article article all-headers)
5238 (when (or all-headers gnus-show-all-headers)
5239 (gnus-article-show-all-headers))
5242 (gnus-article-set-window-start
5243 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5245 (defun gnus-summary-set-current-mark (&optional current-mark)
5246 "Obsolete function."
5249 (defun gnus-summary-next-article (&optional unread subject backward push)
5250 "Select the next article.
5251 If UNREAD, only unread articles are selected.
5252 If SUBJECT, only articles with SUBJECT are selected.
5253 If BACKWARD, the previous article is selected instead of the next."
5255 (gnus-set-global-variables)
5257 ;; Is there such an article?
5258 ((and (gnus-summary-search-forward unread subject backward)
5259 (or (gnus-summary-display-article (gnus-summary-article-number))
5260 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5261 (gnus-summary-position-point))
5262 ;; If not, we try the first unread, if that is wanted.
5264 gnus-auto-select-same
5265 (gnus-summary-first-unread-article))
5266 (gnus-summary-position-point)
5267 (gnus-message 6 "Wrapped"))
5268 ;; Try to get next/previous article not displayed in this group.
5269 ((and gnus-auto-extend-newsgroup
5270 (not unread) (not subject))
5271 (gnus-summary-goto-article
5272 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5274 ;; Go to next/previous group.
5276 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5277 (gnus-summary-jump-to-group gnus-newsgroup-name))
5278 (let ((cmd last-command-char)
5280 (if (eq gnus-keep-same-level 'best)
5281 (gnus-summary-best-group gnus-newsgroup-name)
5282 (gnus-summary-search-group backward gnus-keep-same-level))))
5283 ;; For some reason, the group window gets selected. We change
5285 (select-window (get-buffer-window (current-buffer)))
5286 ;; Select next unread newsgroup automagically.
5288 ((or (not gnus-auto-select-next)
5290 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5291 ((or (eq gnus-auto-select-next 'quietly)
5292 (and (eq gnus-auto-select-next 'slightly-quietly)
5294 (and (eq gnus-auto-select-next 'almost-quietly)
5295 (gnus-summary-last-article-p)))
5297 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5299 (gnus-message 7 "No more%s articles (%s)..."
5300 (if unread " unread" "")
5301 (if group (concat "selecting " group)
5303 (gnus-summary-next-group nil group backward)))
5305 (when (gnus-key-press-event-p last-input-event)
5306 (gnus-summary-walk-group-buffer
5307 gnus-newsgroup-name cmd unread backward))))))))
5309 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
5310 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5311 (?\C-p (gnus-group-prev-unread-group 1))))
5312 (cursor-in-echo-area t)
5313 keve key group ended)
5315 (set-buffer gnus-group-buffer)
5316 (gnus-summary-jump-to-group from-group)
5318 (if (eq gnus-keep-same-level 'best)
5319 (gnus-summary-best-group gnus-newsgroup-name)
5320 (gnus-summary-search-group backward gnus-keep-same-level))))
5323 5 "No more%s articles%s" (if unread " unread" "")
5325 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5326 (format " (Type %s for %s [%s])"
5327 (single-key-description cmd) group
5328 (car (gnus-gethash group gnus-newsrc-hashtb)))
5329 (format " (Type %s to exit %s)"
5330 (single-key-description cmd)
5331 gnus-newsgroup-name)))
5332 ;; Confirm auto selection.
5333 (setq key (car (setq keve (gnus-read-event-char))))
5336 ((assq key keystrokes)
5337 (let ((obuf (current-buffer)))
5338 (switch-to-buffer gnus-group-buffer)
5340 (gnus-group-jump-to-group group))
5341 (eval (cadr (assq key keystrokes)))
5342 (setq group (gnus-group-group-name))
5343 (switch-to-buffer obuf))
5347 (gnus-ephemeral-group-p gnus-newsgroup-name))
5349 (gnus-summary-next-group nil group backward)))
5351 (push (cdr keve) unread-command-events))))))
5353 (defun gnus-summary-next-unread-article ()
5354 "Select unread article after current one."
5356 (gnus-summary-next-article
5357 (or (not (eq gnus-summary-goto-unread 'never))
5358 (gnus-summary-last-article-p (gnus-summary-article-number)))
5359 (and gnus-auto-select-same
5360 (gnus-summary-article-subject))))
5362 (defun gnus-summary-prev-article (&optional unread subject)
5363 "Select the article after the current one.
5364 If UNREAD is non-nil, only unread articles are selected."
5366 (gnus-summary-next-article unread subject t))
5368 (defun gnus-summary-prev-unread-article ()
5369 "Select unread article before current one."
5371 (gnus-summary-prev-article
5372 (or (not (eq gnus-summary-goto-unread 'never))
5373 (gnus-summary-first-article-p (gnus-summary-article-number)))
5374 (and gnus-auto-select-same
5375 (gnus-summary-article-subject))))
5377 (defun gnus-summary-next-page (&optional lines circular)
5378 "Show next page of the selected article.
5379 If at the end of the current article, select the next article.
5380 LINES says how many lines should be scrolled up.
5382 If CIRCULAR is non-nil, go to the start of the article instead of
5383 selecting the next article when reaching the end of the current
5386 (setq gnus-summary-buffer (current-buffer))
5387 (gnus-set-global-variables)
5388 (let ((article (gnus-summary-article-number))
5389 (article-window (get-buffer-window gnus-article-buffer))
5391 (gnus-configure-windows 'article)
5392 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5393 (if (and (eq gnus-summary-goto-unread 'never)
5394 (not (gnus-summary-last-article-p article)))
5395 (gnus-summary-next-article)
5396 (gnus-summary-next-unread-article))
5397 (if (or (null gnus-current-article)
5398 (null gnus-article-current)
5399 (/= article (cdr gnus-article-current))
5400 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5401 ;; Selected subject is different from current article's.
5402 (gnus-summary-display-article article)
5403 (when article-window
5404 (gnus-eval-in-buffer-window gnus-article-buffer
5405 (setq endp (gnus-article-next-page lines)))
5408 (gnus-summary-beginning-of-article))
5410 (gnus-message 3 "End of message"))
5412 (if (and (eq gnus-summary-goto-unread 'never)
5413 (not (gnus-summary-last-article-p article)))
5414 (gnus-summary-next-article)
5415 (gnus-summary-next-unread-article))))))))
5416 (gnus-summary-recenter)
5417 (gnus-summary-position-point)))
5419 (defun gnus-summary-prev-page (&optional lines)
5420 "Show previous page of selected article.
5421 Argument LINES specifies lines to be scrolled down."
5423 (gnus-set-global-variables)
5424 (let ((article (gnus-summary-article-number)))
5425 (gnus-configure-windows 'article)
5426 (if (or (null gnus-current-article)
5427 (null gnus-article-current)
5428 (/= article (cdr gnus-article-current))
5429 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5430 ;; Selected subject is different from current article's.
5431 (gnus-summary-display-article article)
5432 (gnus-summary-recenter)
5433 (gnus-eval-in-buffer-window gnus-article-buffer
5434 (gnus-article-prev-page lines))))
5435 (gnus-summary-position-point))
5437 (defun gnus-summary-scroll-up (lines)
5438 "Scroll up (or down) one line current article.
5439 Argument LINES specifies lines to be scrolled up (or down if negative)."
5441 (gnus-set-global-variables)
5442 (gnus-configure-windows 'article)
5443 (gnus-summary-show-thread)
5444 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5445 (gnus-eval-in-buffer-window gnus-article-buffer
5447 (when (gnus-article-next-page lines)
5448 (gnus-message 3 "End of message")))
5450 (gnus-article-prev-page (- lines))))))
5451 (gnus-summary-recenter)
5452 (gnus-summary-position-point))
5454 (defun gnus-summary-next-same-subject ()
5455 "Select next article which has the same subject as current one."
5457 (gnus-set-global-variables)
5458 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5460 (defun gnus-summary-prev-same-subject ()
5461 "Select previous article which has the same subject as current one."
5463 (gnus-set-global-variables)
5464 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5466 (defun gnus-summary-next-unread-same-subject ()
5467 "Select next unread article which has the same subject as current one."
5469 (gnus-set-global-variables)
5470 (gnus-summary-next-article t (gnus-summary-article-subject)))
5472 (defun gnus-summary-prev-unread-same-subject ()
5473 "Select previous unread article which has the same subject as current one."
5475 (gnus-set-global-variables)
5476 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5478 (defun gnus-summary-first-unread-article ()
5479 "Select the first unread article.
5480 Return nil if there are no unread articles."
5482 (gnus-set-global-variables)
5484 (when (gnus-summary-first-subject t)
5485 (gnus-summary-show-thread)
5486 (gnus-summary-first-subject t)
5487 (gnus-summary-display-article (gnus-summary-article-number)))
5488 (gnus-summary-position-point)))
5490 (defun gnus-summary-first-article ()
5491 "Select the first article.
5492 Return nil if there are no articles."
5494 (gnus-set-global-variables)
5496 (when (gnus-summary-first-subject)
5497 (gnus-summary-show-thread)
5498 (gnus-summary-first-subject)
5499 (gnus-summary-display-article (gnus-summary-article-number)))
5500 (gnus-summary-position-point)))
5502 (defun gnus-summary-best-unread-article ()
5503 "Select the unread article with the highest score."
5505 (gnus-set-global-variables)
5506 (let ((best -1000000)
5507 (data gnus-newsgroup-data)
5510 (and (gnus-data-unread-p (car data))
5512 (gnus-summary-article-score (gnus-data-number (car data))))
5515 article (gnus-data-number (car data))))
5516 (setq data (cdr data)))
5519 (gnus-summary-goto-article article)
5520 (error "No unread articles"))
5521 (gnus-summary-position-point))))
5523 (defun gnus-summary-last-subject ()
5524 "Go to the last displayed subject line in the group."
5525 (let ((article (gnus-data-number (car (gnus-data-list t)))))
5527 (gnus-summary-goto-subject article))))
5529 (defun gnus-summary-goto-article (article &optional all-headers force)
5530 "Fetch ARTICLE and display it if it exists.
5531 If ALL-HEADERS is non-nil, no header lines are hidden."
5537 (mapcar (lambda (number) (list (int-to-string number)))
5538 gnus-newsgroup-limit)))
5542 (if (gnus-summary-goto-subject article force)
5543 (gnus-summary-display-article article all-headers)
5544 (gnus-message 4 "Couldn't go to article %s" article) nil)
5545 (gnus-summary-position-point)))
5547 (defun gnus-summary-goto-last-article ()
5548 "Go to the previously read article."
5551 (when gnus-last-article
5552 (gnus-summary-goto-article gnus-last-article))
5553 (gnus-summary-position-point)))
5555 (defun gnus-summary-pop-article (number)
5556 "Pop one article off the history and go to the previous.
5557 NUMBER articles will be popped off."
5560 (setq gnus-newsgroup-history
5561 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
5563 (gnus-summary-goto-article (car to))
5564 (error "Article history empty")))
5565 (gnus-summary-position-point))
5567 ;; Summary commands and functions for limiting the summary buffer.
5569 (defun gnus-summary-limit-to-articles (n)
5570 "Limit the summary buffer to the next N articles.
5571 If not given a prefix, use the process marked articles instead."
5573 (gnus-set-global-variables)
5575 (let ((articles (gnus-summary-work-articles n)))
5576 (setq gnus-newsgroup-processable nil)
5577 (gnus-summary-limit articles))
5578 (gnus-summary-position-point)))
5580 (defun gnus-summary-pop-limit (&optional total)
5581 "Restore the previous limit.
5582 If given a prefix, remove all limits."
5584 (gnus-set-global-variables)
5586 (setq gnus-newsgroup-limits
5587 (list (mapcar (lambda (h) (mail-header-number h))
5588 gnus-newsgroup-headers))))
5589 (unless gnus-newsgroup-limits
5590 (error "No limit to pop"))
5592 (gnus-summary-limit nil 'pop)
5593 (gnus-summary-position-point)))
5595 (defun gnus-summary-limit-to-subject (subject &optional header)
5596 "Limit the summary buffer to articles that have subjects that match a regexp."
5597 (interactive "sLimit to subject (regexp): ")
5599 (setq header "subject"))
5600 (when (not (equal "" subject))
5602 (let ((articles (gnus-summary-find-matching
5603 (or header "subject") subject 'all)))
5605 (error "Found no matches for \"%s\"" subject))
5606 (gnus-summary-limit articles))
5607 (gnus-summary-position-point))))
5609 (defun gnus-summary-limit-to-author (from)
5610 "Limit the summary buffer to articles that have authors that match a regexp."
5611 (interactive "sLimit to author (regexp): ")
5612 (gnus-summary-limit-to-subject from "from"))
5614 (defun gnus-summary-limit-to-age (age &optional younger-p)
5615 "Limit the summary buffer to articles that are older than (or equal) AGE days.
5616 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
5617 articles that are younger than AGE days."
5618 (interactive "nTime in days: \nP")
5620 (let ((data gnus-newsgroup-data)
5621 (cutoff (nnmail-days-to-time age))
5622 articles d date is-younger)
5623 (while (setq d (pop data))
5624 (when (and (vectorp (gnus-data-header d))
5625 (setq date (mail-header-date (gnus-data-header d))))
5626 (setq is-younger (nnmail-time-less
5627 (nnmail-time-since (nnmail-date-to-time date))
5629 (when (if younger-p is-younger (not is-younger))
5630 (push (gnus-data-number d) articles))))
5631 (gnus-summary-limit (nreverse articles)))
5632 (gnus-summary-position-point)))
5634 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5636 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
5638 (defun gnus-summary-limit-to-unread (&optional all)
5639 "Limit the summary buffer to articles that are not marked as read.
5640 If ALL is non-nil, limit strictly to unread articles."
5643 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
5644 (gnus-summary-limit-to-marks
5645 ;; Concat all the marks that say that an article is read and have
5647 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
5648 gnus-killed-mark gnus-kill-file-mark
5649 gnus-low-score-mark gnus-expirable-mark
5650 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
5651 gnus-duplicate-mark)
5654 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
5655 (make-obsolete 'gnus-summary-delete-marked-with
5656 'gnus-summary-limit-exlude-marks)
5658 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
5659 "Exclude articles that are marked with MARKS (e.g. \"DK\").
5660 If REVERSE, limit the summary buffer to articles that are marked
5661 with MARKS. MARKS can either be a string of marks or a list of marks.
5662 Returns how many articles were removed."
5663 (interactive "sMarks: ")
5664 (gnus-summary-limit-to-marks marks t))
5666 (defun gnus-summary-limit-to-marks (marks &optional reverse)
5667 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
5668 If REVERSE (the prefix), limit the summary buffer to articles that are
5669 not marked with MARKS. MARKS can either be a string of marks or a
5671 Returns how many articles were removed."
5672 (interactive (list (read-string "Marks: ") current-prefix-arg))
5673 (gnus-set-global-variables)
5675 (let ((data gnus-newsgroup-data)
5676 (marks (if (listp marks) marks
5677 (append marks nil))) ; Transform to list.
5680 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
5681 (memq (gnus-data-mark (car data)) marks))
5682 (push (gnus-data-number (car data)) articles))
5683 (setq data (cdr data)))
5684 (gnus-summary-limit articles))
5685 (gnus-summary-position-point)))
5687 (defun gnus-summary-limit-to-score (&optional score)
5688 "Limit to articles with score at or above SCORE."
5690 (gnus-set-global-variables)
5691 (setq score (if score
5692 (prefix-numeric-value score)
5693 (or gnus-summary-default-score 0)))
5694 (let ((data gnus-newsgroup-data)
5697 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
5699 (push (gnus-data-number (car data)) articles))
5700 (setq data (cdr data)))
5702 (gnus-summary-limit articles)
5703 (gnus-summary-position-point))))
5705 (defun gnus-summary-limit-include-dormant ()
5706 "Display all the hidden articles that are marked as dormant."
5708 (gnus-set-global-variables)
5709 (unless gnus-newsgroup-dormant
5710 (error "There are no dormant articles in this group"))
5712 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
5713 (gnus-summary-position-point)))
5715 (defun gnus-summary-limit-exclude-dormant ()
5716 "Hide all dormant articles."
5718 (gnus-set-global-variables)
5720 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
5721 (gnus-summary-position-point)))
5723 (defun gnus-summary-limit-exclude-childless-dormant ()
5724 "Hide all dormant articles that have no children."
5726 (gnus-set-global-variables)
5727 (let ((data (gnus-data-list t))
5728 articles d children)
5729 ;; Find all articles that are either not dormant or have
5731 (while (setq d (pop data))
5732 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
5734 (gnus-article-children (gnus-data-number d)))
5737 (when (memq (car children) articles)
5742 (push (gnus-data-number d) articles)))
5745 (gnus-summary-limit articles)
5746 (gnus-summary-position-point))))
5748 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
5749 "Mark all unread excluded articles as read.
5750 If ALL, mark even excluded ticked and dormants as read."
5752 (let ((articles (gnus-sorted-complement
5754 (mapcar (lambda (h) (mail-header-number h))
5755 gnus-newsgroup-headers)
5757 (sort gnus-newsgroup-limit '<)))
5759 (setq gnus-newsgroup-unreads nil)
5761 (setq gnus-newsgroup-dormant nil
5762 gnus-newsgroup-marked nil
5763 gnus-newsgroup-reads
5765 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
5766 gnus-newsgroup-reads))
5767 (while (setq article (pop articles))
5768 (unless (or (memq article gnus-newsgroup-dormant)
5769 (memq article gnus-newsgroup-marked))
5770 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
5772 (defun gnus-summary-limit (articles &optional pop)
5774 ;; We pop the previous limit off the stack and use that.
5775 (setq articles (car gnus-newsgroup-limits)
5776 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
5777 ;; We use the new limit, so we push the old limit on the stack.
5778 (push gnus-newsgroup-limit gnus-newsgroup-limits))
5780 (setq gnus-newsgroup-limit articles)
5781 (let ((total (length gnus-newsgroup-data))
5782 (data (gnus-data-find-list (gnus-summary-article-number)))
5783 (gnus-summary-mark-below nil) ; Inhibit this.
5785 ;; This will do all the work of generating the new summary buffer
5786 ;; according to the new limit.
5787 (gnus-summary-prepare)
5788 ;; Hide any threads, possibly.
5789 (and gnus-show-threads
5790 gnus-thread-hide-subtree
5791 (gnus-summary-hide-all-threads))
5792 ;; Try to return to the article you were at, or one in the
5795 ;; We try to find some article after the current one.
5797 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
5800 (setq data (cdr data))))
5802 ;; If there is no data, that means that we were after the last
5803 ;; article. The same goes when we can't find any articles
5804 ;; after the current one.
5805 (goto-char (point-max))
5806 (gnus-summary-find-prev))
5807 ;; We return how many articles were removed from the summary
5808 ;; buffer as a result of the new limit.
5809 (- total (length gnus-newsgroup-data))))
5811 (defsubst gnus-invisible-cut-children (threads)
5814 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
5819 (defsubst gnus-cut-thread (thread)
5820 "Go forwards in the thread until we find an article that we want to display."
5821 (when (or (eq gnus-fetch-old-headers 'some)
5822 (eq gnus-build-sparse-threads 'some)
5823 (eq gnus-build-sparse-threads 'more))
5824 ;; Deal with old-fetched headers and sparse threads.
5828 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
5829 (gnus-summary-article-ancient-p
5830 (mail-header-number (car thread))))
5832 (if (<= (length (cdr thread)) 1)
5833 (setq thread (cadr thread))
5834 (when (gnus-invisible-cut-children (cdr thread))
5835 (let ((th (cdr thread)))
5837 (if (memq (mail-header-number (caar th))
5838 gnus-newsgroup-limit)
5839 (setq thread (car th)
5841 (setq th (cdr th)))))))))
5845 (defun gnus-cut-threads (threads)
5846 "Cut off all uninteresting articles from the beginning of threads."
5847 (when (or (eq gnus-fetch-old-headers 'some)
5848 (eq gnus-build-sparse-threads 'some)
5849 (eq gnus-build-sparse-threads 'more))
5852 (setcar th (gnus-cut-thread (car th)))
5853 (setq th (cdr th)))))
5854 ;; Remove nixed out threads.
5857 (defun gnus-summary-initial-limit (&optional show-if-empty)
5858 "Figure out what the initial limit is supposed to be on group entry.
5859 This entails weeding out unwanted dormants, low-scored articles,
5860 fetch-old-headers verbiage, and so on."
5861 ;; Most groups have nothing to remove.
5862 (if (or gnus-inhibit-limiting
5863 (and (null gnus-newsgroup-dormant)
5864 (not (eq gnus-fetch-old-headers 'some))
5865 (null gnus-summary-expunge-below)
5866 (not (eq gnus-build-sparse-threads 'some))
5867 (not (eq gnus-build-sparse-threads 'more))
5868 (null gnus-thread-expunge-below)
5869 (not gnus-use-nocem)))
5871 (push gnus-newsgroup-limit gnus-newsgroup-limits)
5872 (setq gnus-newsgroup-limit nil)
5875 (unless (car (symbol-value node))
5876 ;; These threads have no parents -- they are roots.
5877 (let ((nodes (cdr (symbol-value node)))
5880 (if (and gnus-thread-expunge-below
5881 (< (gnus-thread-total-score (car nodes))
5882 gnus-thread-expunge-below))
5883 (gnus-expunge-thread (pop nodes))
5884 (setq thread (pop nodes))
5885 (gnus-summary-limit-children thread))))))
5886 gnus-newsgroup-dependencies)
5887 ;; If this limitation resulted in an empty group, we might
5888 ;; pop the previous limit and use it instead.
5889 (when (and (not gnus-newsgroup-limit)
5891 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
5892 gnus-newsgroup-limit))
5894 (defun gnus-summary-limit-children (thread)
5895 "Return 1 if this subthread is visible and 0 if it is not."
5896 ;; First we get the number of visible children to this thread. This
5897 ;; is done by recursing down the thread using this function, so this
5898 ;; will really go down to a leaf article first, before slowly
5899 ;; working its way up towards the root.
5903 (apply '+ (mapcar 'gnus-summary-limit-children
5906 (number (mail-header-number (car thread)))
5909 (not (memq number gnus-newsgroup-marked))
5911 ;; If this article is dormant and has absolutely no visible
5912 ;; children, then this article isn't visible.
5913 (and (memq number gnus-newsgroup-dormant)
5915 ;; If this is "fetch-old-headered" and there is no
5916 ;; visible children, then we don't want this article.
5917 (and (eq gnus-fetch-old-headers 'some)
5918 (gnus-summary-article-ancient-p number)
5920 ;; If this is a sparsely inserted article with no children,
5921 ;; we don't want it.
5922 (and (eq gnus-build-sparse-threads 'some)
5923 (gnus-summary-article-sparse-p number)
5925 ;; If we use expunging, and this article is really
5926 ;; low-scored, then we don't want this article.
5927 (when (and gnus-summary-expunge-below
5929 (or (cdr (assq number gnus-newsgroup-scored))
5930 gnus-summary-default-score))
5931 gnus-summary-expunge-below))
5932 ;; We increase the expunge-tally here, but that has
5933 ;; nothing to do with the limits, really.
5934 (incf gnus-newsgroup-expunged-tally)
5935 ;; We also mark as read here, if that's wanted.
5936 (when (and gnus-summary-mark-below
5937 (< score gnus-summary-mark-below))
5938 (setq gnus-newsgroup-unreads
5939 (delq number gnus-newsgroup-unreads))
5940 (if gnus-newsgroup-auto-expire
5941 (push number gnus-newsgroup-expirable)
5942 (push (cons number gnus-low-score-mark)
5943 gnus-newsgroup-reads)))
5945 ;; Check NoCeM things.
5946 (if (and gnus-use-nocem
5947 (gnus-nocem-unwanted-article-p
5948 (mail-header-id (car thread))))
5950 (setq gnus-newsgroup-reads
5951 (delq number gnus-newsgroup-unreads))
5953 ;; Nope, invisible article.
5955 ;; Ok, this article is to be visible, so we add it to the limit
5957 (push number gnus-newsgroup-limit)
5960 (defun gnus-expunge-thread (thread)
5961 "Mark all articles in THREAD as read."
5962 (let* ((number (mail-header-number (car thread))))
5963 (incf gnus-newsgroup-expunged-tally)
5964 ;; We also mark as read here, if that's wanted.
5965 (setq gnus-newsgroup-unreads
5966 (delq number gnus-newsgroup-unreads))
5967 (if gnus-newsgroup-auto-expire
5968 (push number gnus-newsgroup-expirable)
5969 (push (cons number gnus-low-score-mark)
5970 gnus-newsgroup-reads)))
5971 ;; Go recursively through all subthreads.
5972 (mapcar 'gnus-expunge-thread (cdr thread)))
5974 ;; Summary article oriented commands
5976 (defun gnus-summary-refer-parent-article (n)
5977 "Refer parent article N times.
5978 If N is negative, go to ancestor -N instead.
5979 The difference between N and the number of articles fetched is returned."
5981 (gnus-set-global-variables)
5984 (when (not (natnump n))
5989 (setq header (gnus-summary-article-header))
5990 (if (and (eq (mail-header-number header)
5991 (cdr gnus-article-current))
5992 (equal gnus-newsgroup-name
5993 (car gnus-article-current)))
5994 ;; If we try to find the parent of the currently
5995 ;; displayed article, then we take a look at the actual
5996 ;; References header, since this is slightly more
5997 ;; reliable than the References field we got from the
6000 (set-buffer gnus-original-article-buffer)
6001 (nnheader-narrow-to-headers)
6002 (unless (setq ref (message-fetch-field "references"))
6003 (setq ref (message-fetch-field "in-reply-to")))
6006 ;; It's not the current article, so we take a bet on
6007 ;; the value we got from the server.
6008 (mail-header-references header)))
6010 (not (equal ref "")))
6011 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6012 (gnus-message 1 "Couldn't find parent"))
6013 (gnus-message 1 "No references in article %d"
6014 (gnus-summary-article-number))
6017 (gnus-summary-position-point)
6020 (defun gnus-summary-refer-references ()
6021 "Fetch all articles mentioned in the References header.
6022 Return how many articles were fetched."
6024 (gnus-set-global-variables)
6025 (let ((ref (mail-header-references (gnus-summary-article-header)))
6026 (current (gnus-summary-article-number))
6030 (error "No References in the current article")
6031 ;; For each Message-ID in the References header...
6032 (while (string-match "<[^>]*>" ref)
6034 ;; ... fetch that article.
6035 (gnus-summary-refer-article
6036 (prog1 (match-string 0 ref)
6037 (setq ref (substring ref (match-end 0))))))
6038 (gnus-summary-goto-subject current)
6039 (gnus-summary-position-point)
6042 (defun gnus-summary-refer-article (message-id)
6043 "Fetch an article specified by MESSAGE-ID."
6044 (interactive "sMessage-ID: ")
6045 (when (and (stringp message-id)
6046 (not (zerop (length message-id))))
6047 ;; Construct the correct Message-ID if necessary.
6048 ;; Suggested by tale@pawl.rpi.edu.
6049 (unless (string-match "^<" message-id)
6050 (setq message-id (concat "<" message-id)))
6051 (unless (string-match ">$" message-id)
6052 (setq message-id (concat message-id ">")))
6053 (let* ((header (gnus-id-to-header message-id))
6055 (gnus-summary-article-sparse-p
6056 (mail-header-number header)))))
6059 ;; The article is present in the buffer, to we just go to it.
6060 (gnus-summary-goto-article
6061 (mail-header-number header) nil header)
6063 (gnus-summary-update-article (mail-header-number header))))
6064 ;; We fetch the article
6065 (let ((gnus-override-method
6066 (and (gnus-news-group-p gnus-newsgroup-name)
6067 gnus-refer-article-method))
6069 ;; Start the special refer-article method, if necessary.
6070 (when (and gnus-refer-article-method
6071 (gnus-news-group-p gnus-newsgroup-name))
6072 (gnus-check-server gnus-refer-article-method))
6073 ;; Fetch the header, and display the article.
6074 (if (setq number (gnus-summary-insert-subject message-id))
6075 (gnus-summary-select-article nil nil nil number)
6076 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6078 (defun gnus-summary-enter-digest-group (&optional force)
6079 "Enter an nndoc group based on the current article.
6080 If FORCE, force a digest interpretation. If not, try
6081 to guess what the document format is."
6083 (gnus-set-global-variables)
6084 (let ((conf gnus-current-window-configuration))
6086 (gnus-summary-select-article))
6087 (setq gnus-current-window-configuration conf)
6088 (let* ((name (format "%s-%d"
6089 (gnus-group-prefixed-name
6090 gnus-newsgroup-name (list 'nndoc ""))
6092 (set-buffer gnus-summary-buffer)
6093 gnus-current-article)))
6094 (ogroup gnus-newsgroup-name)
6095 (params (append (gnus-info-params (gnus-get-info ogroup))
6096 (list (cons 'to-group ogroup))))
6097 (case-fold-search t)
6098 (buf (current-buffer))
6101 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6102 (insert-buffer-substring gnus-original-article-buffer)
6103 ;; Remove lines that may lead nndoc to misinterpret the
6106 (goto-char (point-min))
6107 (or (search-forward "\n\n" nil t) (point)))
6108 (goto-char (point-min))
6109 (delete-matching-lines "^\\(Path\\):\\|^From ")
6112 (if (gnus-group-read-ephemeral-group
6113 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6115 ,(if force 'digest 'guess))) t)
6116 ;; Make all postings to this group go to the parent group.
6117 (nconc (gnus-info-params (gnus-get-info name))
6119 ;; Couldn't select this doc group.
6120 (switch-to-buffer buf)
6121 (gnus-set-global-variables)
6122 (gnus-configure-windows 'summary)
6123 (gnus-message 3 "Article couldn't be entered?"))
6124 (kill-buffer dig)))))
6126 (defun gnus-summary-read-document (n)
6127 "Open a new group based on the current article(s).
6128 This will allow you to read digests and other similar
6129 documents as newsgroups.
6130 Obeys the standard process/prefix convention."
6132 (let* ((articles (gnus-summary-work-articles n))
6133 (ogroup gnus-newsgroup-name)
6134 (params (append (gnus-info-params (gnus-get-info ogroup))
6135 (list (cons 'to-group ogroup))))
6136 article group egroup groups vgroup)
6137 (while (setq article (pop articles))
6138 (setq group (format "%s-%d" gnus-newsgroup-name article))
6139 (gnus-summary-remove-process-mark article)
6140 (when (gnus-summary-display-article article)
6142 (nnheader-temp-write nil
6143 (insert-buffer-substring gnus-original-article-buffer)
6144 ;; Remove some headers that may lead nndoc to make
6146 (message-narrow-to-head)
6147 (goto-char (point-min))
6148 (delete-matching-lines "^\\(Path\\):\\|^From ")
6151 (gnus-group-read-ephemeral-group
6152 group `(nndoc ,group (nndoc-address ,(current-buffer))
6153 (nndoc-article-type guess))
6156 ;; Make all postings to this group go to the parent group.
6157 (nconc (gnus-info-params (gnus-get-info egroup))
6159 (push egroup groups))
6160 ;; Couldn't select this doc group.
6161 (gnus-error 3 "Article couldn't be entered"))))))
6162 ;; Now we have selected all the documents.
6165 (error "None of the articles could be interpreted as documents"))
6166 ((gnus-group-read-ephemeral-group
6167 (setq vgroup (format
6168 "nnvirtual:%s-%s" gnus-newsgroup-name
6169 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6170 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6172 (cons (current-buffer) 'summary)))
6174 (error "Couldn't select virtual nndoc group")))))
6176 (defun gnus-summary-isearch-article (&optional regexp-p)
6177 "Do incremental search forward on the current article.
6178 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6180 (gnus-set-global-variables)
6181 (gnus-summary-select-article)
6182 (gnus-configure-windows 'article)
6183 (gnus-eval-in-buffer-window gnus-article-buffer
6184 ;;(goto-char (point-min))
6185 (isearch-forward regexp-p)))
6187 (defun gnus-summary-search-article-forward (regexp &optional backward)
6188 "Search for an article containing REGEXP forward.
6189 If BACKWARD, search backward instead."
6192 (format "Search article %s (regexp%s): "
6193 (if current-prefix-arg "backward" "forward")
6194 (if gnus-last-search-regexp
6195 (concat ", default " gnus-last-search-regexp)
6197 current-prefix-arg))
6198 (gnus-set-global-variables)
6199 (if (string-equal regexp "")
6200 (setq regexp (or gnus-last-search-regexp ""))
6201 (setq gnus-last-search-regexp regexp))
6202 (if (gnus-summary-search-article regexp backward)
6203 (gnus-summary-show-thread)
6204 (error "Search failed: \"%s\"" regexp)))
6206 (defun gnus-summary-search-article-backward (regexp)
6207 "Search for an article containing REGEXP backward."
6210 (format "Search article backward (regexp%s): "
6211 (if gnus-last-search-regexp
6212 (concat ", default " gnus-last-search-regexp)
6214 (gnus-summary-search-article-forward regexp 'backward))
6216 (defun gnus-summary-search-article (regexp &optional backward)
6217 "Search for an article containing REGEXP.
6218 Optional argument BACKWARD means do search for backward.
6219 `gnus-select-article-hook' is not called during the search."
6220 (let ((gnus-select-article-hook nil) ;Disable hook.
6221 (gnus-article-display-hook nil)
6222 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6223 (gnus-use-article-prefetch nil)
6224 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6225 (sum (current-buffer))
6228 (gnus-save-hidden-threads
6229 (gnus-summary-select-article)
6230 (set-buffer gnus-article-buffer)
6234 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6236 (re-search-backward regexp nil t)
6237 (re-search-forward regexp nil t))
6238 ;; We found the regexp.
6243 (get-buffer-window (current-buffer))
6247 (setq point (point)))
6248 ;; We didn't find it, so we go to the next article.
6251 (while (eq found 'not)
6252 (if (not (if backward (gnus-summary-find-prev)
6253 (gnus-summary-find-next)))
6254 ;; No more articles.
6256 ;; Select the next article and adjust point.
6257 (unless (gnus-summary-article-sparse-p
6258 (gnus-summary-article-number))
6260 (gnus-summary-select-article)
6261 (set-buffer gnus-article-buffer)
6263 (goto-char (if backward (point-max) (point-min))))))))
6264 (gnus-message 7 ""))
6265 ;; Return whether we found the regexp.
6266 (when (eq found 'found)
6268 (gnus-summary-show-thread)
6269 (gnus-summary-goto-subject gnus-current-article)
6270 (gnus-summary-position-point)
6273 (defun gnus-summary-find-matching (header regexp &optional backward unread
6275 "Return a list of all articles that match REGEXP on HEADER.
6276 The search stars on the current article and goes forwards unless
6277 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6278 If UNREAD is non-nil, only unread articles will
6279 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6280 in the comparisons."
6281 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6282 (gnus-data-find-list
6283 (gnus-summary-article-number) (gnus-data-list backward))))
6284 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6285 (case-fold-search (not not-case-fold))
6287 (unless (fboundp (intern (concat "mail-header-" header)))
6288 (error "%s is not a valid header" header))
6291 (and (or (not unread) ; We want all articles...
6292 (gnus-data-unread-p d)) ; Or just unreads.
6293 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6294 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6295 (push (gnus-data-number d) articles)) ; Success!
6296 (setq data (cdr data)))
6297 (nreverse articles)))
6299 (defun gnus-summary-execute-command (header regexp command &optional backward)
6300 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6301 If HEADER is an empty string (or nil), the match is done on the entire
6302 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6304 (list (let ((completion-ignore-case t))
6307 (mapcar (lambda (string) (list string))
6308 '("Number" "Subject" "From" "Lines" "Date"
6309 "Message-ID" "Xref" "References" "Body"))
6310 nil 'require-match))
6311 (read-string "Regexp: ")
6312 (read-key-sequence "Command: ")
6313 current-prefix-arg))
6314 (when (equal header "Body")
6316 (gnus-set-global-variables)
6317 ;; Hidden thread subtrees must be searched as well.
6318 (gnus-summary-show-all-threads)
6319 ;; We don't want to change current point nor window configuration.
6321 (save-window-excursion
6322 (gnus-message 6 "Executing %s..." (key-description command))
6323 ;; We'd like to execute COMMAND interactively so as to give arguments.
6324 (gnus-execute header regexp
6325 `(call-interactively ',(key-binding command))
6327 (gnus-message 6 "Executing %s...done" (key-description command)))))
6329 (defun gnus-summary-beginning-of-article ()
6330 "Scroll the article back to the beginning."
6332 (gnus-set-global-variables)
6333 (gnus-summary-select-article)
6334 (gnus-configure-windows 'article)
6335 (gnus-eval-in-buffer-window gnus-article-buffer
6337 (goto-char (point-min))
6338 (when gnus-break-pages
6339 (gnus-narrow-to-page))))
6341 (defun gnus-summary-end-of-article ()
6342 "Scroll to the end of the article."
6344 (gnus-set-global-variables)
6345 (gnus-summary-select-article)
6346 (gnus-configure-windows 'article)
6347 (gnus-eval-in-buffer-window gnus-article-buffer
6349 (goto-char (point-max))
6351 (when gnus-break-pages
6352 (gnus-narrow-to-page))))
6354 (defun gnus-summary-print-article (&optional filename)
6355 "Generate and print a PostScript image of the article buffer.
6357 If the optional argument FILENAME is nil, send the image to the printer.
6358 If FILENAME is a string, save the PostScript image in a file with that
6359 name. If FILENAME is a number, prompt the user for the name of the file
6361 (interactive (list (ps-print-preprint current-prefix-arg)))
6362 (gnus-summary-select-article)
6363 (gnus-eval-in-buffer-window gnus-article-buffer
6364 (let ((buffer (generate-new-buffer " *print*")))
6367 (copy-to-buffer buffer (point-min) (point-max))
6369 (gnus-article-delete-invisible-text)
6370 (ps-print-buffer-with-faces filename))
6371 (kill-buffer buffer)))))
6373 (defun gnus-summary-show-article (&optional arg)
6374 "Force re-fetching of the current article.
6375 If ARG (the prefix) is non-nil, show the raw article without any
6376 article massaging functions being run."
6378 (gnus-set-global-variables)
6380 ;; Select the article the normal way.
6381 (gnus-summary-select-article nil 'force)
6382 ;; Bind the article treatment functions to nil.
6383 (let ((gnus-have-all-headers t)
6384 gnus-article-display-hook
6385 gnus-article-prepare-hook
6388 (gnus-summary-select-article nil 'force)))
6389 (gnus-summary-goto-subject gnus-current-article)
6390 ; (gnus-configure-windows 'article)
6391 (gnus-summary-position-point))
6393 (defun gnus-summary-verbose-headers (&optional arg)
6394 "Toggle permanent full header display.
6395 If ARG is a positive number, turn header display on.
6396 If ARG is a negative number, turn header display off."
6398 (gnus-set-global-variables)
6399 (setq gnus-show-all-headers
6400 (cond ((or (not (numberp arg))
6402 (not gnus-show-all-headers))
6405 (gnus-summary-show-article))
6407 (defun gnus-summary-toggle-header (&optional arg)
6408 "Show the headers if they are hidden, or hide them if they are shown.
6409 If ARG is a positive number, show the entire header.
6410 If ARG is a negative number, hide the unwanted header lines."
6412 (gnus-set-global-variables)
6414 (set-buffer gnus-article-buffer)
6415 (let* ((buffer-read-only nil)
6416 (inhibit-point-motion-hooks t)
6417 (hidden (text-property-any
6418 (goto-char (point-min)) (search-forward "\n\n")
6421 (goto-char (point-min))
6422 (when (search-forward "\n\n" nil t)
6423 (delete-region (point-min) (1- (point))))
6424 (goto-char (point-min))
6426 (set-buffer gnus-original-article-buffer)
6427 (goto-char (point-min))
6428 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6429 (insert-buffer-substring gnus-original-article-buffer 1 e)
6430 (let ((article-inhibit-hiding t))
6431 (run-hooks 'gnus-article-display-hook))
6432 (when (or (not hidden) (and (numberp arg) (< arg 0)))
6433 (gnus-article-hide-headers)))))
6435 (defun gnus-summary-show-all-headers ()
6436 "Make all header lines visible."
6438 (gnus-set-global-variables)
6439 (gnus-article-show-all-headers))
6441 (defun gnus-summary-toggle-mime (&optional arg)
6442 "Toggle MIME processing.
6443 If ARG is a positive number, turn MIME processing on."
6445 (gnus-set-global-variables)
6446 (setq gnus-show-mime
6447 (if (null arg) (not gnus-show-mime)
6448 (> (prefix-numeric-value arg) 0)))
6449 (gnus-summary-select-article t 'force))
6451 (defun gnus-summary-caesar-message (&optional arg)
6452 "Caesar rotate the current article by 13.
6453 The numerical prefix specifies how many places to rotate each letter
6456 (gnus-set-global-variables)
6457 (gnus-summary-select-article)
6458 (let ((mail-header-separator ""))
6459 (gnus-eval-in-buffer-window gnus-article-buffer
6462 (let ((start (window-start))
6464 (message-caesar-buffer-body arg)
6465 (set-window-start (get-buffer-window (current-buffer)) start))))))
6467 (defun gnus-summary-stop-page-breaking ()
6468 "Stop page breaking in the current article."
6470 (gnus-set-global-variables)
6471 (gnus-summary-select-article)
6472 (gnus-eval-in-buffer-window gnus-article-buffer
6474 (when (gnus-visual-p 'page-marker)
6475 (let ((buffer-read-only nil))
6476 (gnus-remove-text-with-property 'gnus-prev)
6477 (gnus-remove-text-with-property 'gnus-next)))))
6479 (defun gnus-summary-move-article (&optional n to-newsgroup
6480 select-method action)
6481 "Move the current article to a different newsgroup.
6482 If N is a positive number, move the N next articles.
6483 If N is a negative number, move the N previous articles.
6484 If N is nil and any articles have been marked with the process mark,
6485 move those articles instead.
6486 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6487 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6488 re-spool using this method.
6490 For this function to work, both the current newsgroup and the
6491 newsgroup that you want to move to have to support the `request-move'
6492 and `request-accept' functions."
6495 (setq action 'move))
6496 (gnus-set-global-variables)
6497 ;; Disable marking as read.
6498 (let (gnus-mark-article-hook)
6499 (save-window-excursion
6500 (gnus-summary-select-article)))
6501 ;; Check whether the source group supports the required functions.
6502 (cond ((and (eq action 'move)
6503 (not (gnus-check-backend-function
6504 'request-move-article gnus-newsgroup-name)))
6505 (error "The current group does not support article moving"))
6506 ((and (eq action 'crosspost)
6507 (not (gnus-check-backend-function
6508 'request-replace-article gnus-newsgroup-name)))
6509 (error "The current group does not support article editing")))
6510 (let ((articles (gnus-summary-work-articles n))
6511 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
6512 (names '((move "Move" "Moving")
6513 (copy "Copy" "Copying")
6514 (crosspost "Crosspost" "Crossposting")))
6515 (copy-buf (save-excursion
6516 (nnheader-set-temp-buffer " *copy article*")))
6517 art-group to-method new-xref article to-groups)
6518 (unless (assq action names)
6519 (error "Unknown action %s" action))
6520 ;; Read the newsgroup name.
6521 (when (and (not to-newsgroup)
6522 (not select-method))
6524 (gnus-read-move-group-name
6525 (cadr (assq action names))
6526 (symbol-value (intern (format "gnus-current-%s-group" action)))
6528 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
6529 (setq to-method (or select-method
6530 (gnus-group-name-to-method to-newsgroup)))
6531 ;; Check the method we are to move this article to...
6532 (unless (gnus-check-backend-function
6533 'request-accept-article (car to-method))
6534 (error "%s does not support article copying" (car to-method)))
6535 (unless (gnus-check-server to-method)
6536 (error "Can't open server %s" (car to-method)))
6537 (gnus-message 6 "%s to %s: %s..."
6538 (caddr (assq action names))
6539 (or (car select-method) to-newsgroup) articles)
6541 (setq article (pop articles))
6545 ;; Move the article.
6547 (gnus-request-move-article
6548 article ; Article to move
6549 gnus-newsgroup-name ; From newsgroup
6550 (nth 1 (gnus-find-method-for-group
6551 gnus-newsgroup-name)) ; Server
6552 (list 'gnus-request-accept-article
6553 to-newsgroup (list 'quote select-method)
6554 (not articles)) ; Accept form
6555 (not articles))) ; Only save nov last time
6556 ;; Copy the article.
6559 (set-buffer copy-buf)
6560 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6561 (gnus-request-accept-article
6562 to-newsgroup select-method (not articles))))
6563 ;; Crosspost the article.
6564 ((eq action 'crosspost)
6565 (let ((xref (message-tokenize-header
6566 (mail-header-xref (gnus-summary-article-header article))
6568 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
6571 (setq xref (list (system-name))))
6574 (mapconcat 'identity
6575 (delete "Xref:" (delete new-xref xref))
6579 (set-buffer copy-buf)
6580 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6581 (nnheader-replace-header "xref" new-xref)
6582 (gnus-request-accept-article
6583 to-newsgroup select-method (not articles)))))))
6585 (gnus-message 1 "Couldn't %s article %s"
6586 (cadr (assq action names)) article)
6589 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
6591 (gnus-group-prefixed-name
6594 (gnus-find-method-for-group to-newsgroup)))
6595 gnus-newsrc-hashtb)))
6596 (info (nth 2 entry))
6597 (to-group (gnus-info-group info)))
6598 ;; Update the group that has been moved to.
6600 (memq action '(move copy)))
6601 (unless (member to-group to-groups)
6602 (push to-group to-groups))
6604 (unless (memq article gnus-newsgroup-unreads)
6606 info (gnus-add-to-range (gnus-info-read info)
6607 (list (cdr art-group)))))
6609 ;; Copy any marks over to the new group.
6610 (let ((marks gnus-article-mark-lists)
6611 (to-article (cdr art-group)))
6613 ;; See whether the article is to be put in the cache.
6614 (when gnus-use-cache
6615 (gnus-cache-possibly-enter-article
6617 (let ((header (copy-sequence
6618 (gnus-summary-article-header article))))
6619 (mail-header-set-number header to-article)
6621 (memq article gnus-newsgroup-marked)
6622 (memq article gnus-newsgroup-dormant)
6623 (memq article gnus-newsgroup-unreads)))
6626 (when (memq article (symbol-value
6627 (intern (format "gnus-newsgroup-%s"
6629 ;; If the other group is the same as this group,
6630 ;; then we have to add the mark to the list.
6631 (when (equal to-group gnus-newsgroup-name)
6632 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
6635 (intern (format "gnus-newsgroup-%s"
6637 ;; Copy mark to other group.
6638 (gnus-add-marked-articles
6639 to-group (cdar marks) (list to-article) info))
6640 (setq marks (cdr marks)))))
6642 ;; Update the Xref header in this article to point to
6643 ;; the new crossposted article we have just created.
6644 (when (eq action 'crosspost)
6646 (set-buffer copy-buf)
6647 (gnus-request-article-this-buffer article gnus-newsgroup-name)
6648 (nnheader-replace-header
6649 "xref" (concat new-xref " " (car art-group)
6650 ":" (cdr art-group)))
6651 (gnus-request-replace-article
6652 article gnus-newsgroup-name (current-buffer)))))
6654 (gnus-summary-goto-subject article)
6655 (when (eq action 'move)
6656 (gnus-summary-mark-article article gnus-canceled-mark)))
6657 (gnus-summary-remove-process-mark article))
6658 ;; Re-activate all groups that have been moved to.
6660 (gnus-activate-group (pop to-groups)))
6662 (gnus-kill-buffer copy-buf)
6663 (gnus-summary-position-point)
6664 (gnus-set-mode-line 'summary)))
6666 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
6667 "Move the current article to a different newsgroup.
6668 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
6669 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
6670 re-spool using this method."
6672 (gnus-summary-move-article n nil select-method 'copy))
6674 (defun gnus-summary-crosspost-article (&optional n)
6675 "Crosspost the current article to some other group."
6677 (gnus-summary-move-article n nil nil 'crosspost))
6679 (defcustom gnus-summary-respool-default-method nil
6680 "Default method for respooling an article.
6681 If nil, use to the current newsgroup method."
6682 :type 'gnus-select-method-name
6683 :group 'gnus-summary-mail)
6685 (defun gnus-summary-respool-article (&optional n method)
6686 "Respool the current article.
6687 The article will be squeezed through the mail spooling process again,
6688 which means that it will be put in some mail newsgroup or other
6689 depending on `nnmail-split-methods'.
6690 If N is a positive number, respool the N next articles.
6691 If N is a negative number, respool the N previous articles.
6692 If N is nil and any articles have been marked with the process mark,
6693 respool those articles instead.
6695 Respooling can be done both from mail groups and \"real\" newsgroups.
6696 In the former case, the articles in question will be moved from the
6697 current group into whatever groups they are destined to. In the
6698 latter case, they will be copied into the relevant groups."
6700 (list current-prefix-arg
6701 (let* ((methods (gnus-methods-using 'respool))
6703 (symbol-name (or gnus-summary-respool-default-method
6704 (car (gnus-find-method-for-group
6705 gnus-newsgroup-name)))))
6707 (gnus-completing-read
6708 methname "What backend do you want to use when respooling?"
6709 methods nil t nil 'gnus-mail-method-history))
6712 ((zerop (length (setq ms (gnus-servers-using-backend
6714 (list (intern method) ""))
6718 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
6719 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
6721 (gnus-set-global-variables)
6723 (error "No method given for respooling"))
6724 (if (assoc (symbol-name
6725 (car (gnus-find-method-for-group gnus-newsgroup-name)))
6726 (gnus-methods-using 'respool))
6727 (gnus-summary-move-article n nil method)
6728 (gnus-summary-copy-article n nil method)))
6730 (defun gnus-summary-import-article (file)
6731 "Import a random file into a mail newsgroup."
6732 (interactive "fImport file: ")
6733 (gnus-set-global-variables)
6734 (let ((group gnus-newsgroup-name)
6735 (now (current-time))
6737 (unless (gnus-check-backend-function 'request-accept-article group)
6738 (error "%s does not support article importing" group))
6739 (or (file-readable-p file)
6740 (not (file-regular-p file))
6741 (error "Can't read %s" file))
6743 (set-buffer (get-buffer-create " *import file*"))
6744 (buffer-disable-undo (current-buffer))
6746 (insert-file-contents file)
6747 (goto-char (point-min))
6748 (unless (nnheader-article-p)
6749 ;; This doesn't look like an article, so we fudge some headers.
6750 (setq atts (file-attributes file)
6751 lines (count-lines (point-min) (point-max)))
6752 (insert "From: " (read-string "From: ") "\n"
6753 "Subject: " (read-string "Subject: ") "\n"
6754 "Date: " (timezone-make-date-arpa-standard
6755 (current-time-string (nth 5 atts))
6756 (current-time-zone now)
6757 (current-time-zone now))
6759 "Message-ID: " (message-make-message-id) "\n"
6760 "Lines: " (int-to-string lines) "\n"
6761 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
6762 (gnus-request-accept-article group nil t)
6763 (kill-buffer (current-buffer)))))
6765 (defun gnus-summary-article-posted-p ()
6766 "Say whether the current (mail) article is available from `gnus-select-method' as well.
6767 This will be the case if the article has both been mailed and posted."
6769 (let ((id (mail-header-references (gnus-summary-article-header)))
6770 (gnus-override-method
6771 (or gnus-refer-article-method gnus-select-method)))
6772 (if (gnus-request-head id "")
6773 (gnus-message 2 "The current message was found on %s"
6774 gnus-override-method)
6775 (gnus-message 2 "The current message couldn't be found on %s"
6776 gnus-override-method)
6779 (defun gnus-summary-expire-articles (&optional now)
6780 "Expire all articles that are marked as expirable in the current group."
6782 (gnus-set-global-variables)
6783 (when (gnus-check-backend-function
6784 'request-expire-articles gnus-newsgroup-name)
6785 ;; This backend supports expiry.
6786 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
6787 (expirable (if total
6789 ;; We need to update the info for
6790 ;; this group for `gnus-list-of-read-articles'
6791 ;; to give us the right answer.
6792 (run-hooks 'gnus-exit-group-hook)
6793 (gnus-summary-update-info)
6794 (gnus-list-of-read-articles gnus-newsgroup-name))
6795 (setq gnus-newsgroup-expirable
6796 (sort gnus-newsgroup-expirable '<))))
6797 (expiry-wait (if now 'immediate
6798 (gnus-group-find-parameter
6799 gnus-newsgroup-name 'expiry-wait)))
6802 ;; There are expirable articles in this group, so we run them
6803 ;; through the expiry process.
6804 (gnus-message 6 "Expiring articles...")
6805 ;; The list of articles that weren't expired is returned.
6807 (let ((nnmail-expiry-wait-function nil)
6808 (nnmail-expiry-wait expiry-wait))
6809 (setq es (gnus-request-expire-articles
6810 expirable gnus-newsgroup-name)))
6811 (setq es (gnus-request-expire-articles
6812 expirable gnus-newsgroup-name)))
6814 (setq gnus-newsgroup-expirable es))
6815 ;; We go through the old list of expirable, and mark all
6816 ;; really expired articles as nonexistent.
6817 (unless (eq es expirable) ;If nothing was expired, we don't mark.
6818 (let ((gnus-use-cache nil))
6820 (unless (memq (car expirable) es)
6821 (when (gnus-data-find (car expirable))
6822 (gnus-summary-mark-article
6823 (car expirable) gnus-canceled-mark)))
6824 (setq expirable (cdr expirable)))))
6825 (gnus-message 6 "Expiring articles...done")))))
6827 (defun gnus-summary-expire-articles-now ()
6828 "Expunge all expirable articles in the current group.
6829 This means that *all* articles that are marked as expirable will be
6830 deleted forever, right now."
6832 (gnus-set-global-variables)
6833 (or gnus-expert-user
6835 "Are you really, really, really sure you want to delete all these messages? ")
6837 (gnus-summary-expire-articles t))
6839 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6840 (defun gnus-summary-delete-article (&optional n)
6841 "Delete the N next (mail) articles.
6842 This command actually deletes articles. This is not a marking
6843 command. The article will disappear forever from your life, never to
6845 If N is negative, delete backwards.
6846 If N is nil and articles have been marked with the process mark,
6847 delete these instead."
6849 (gnus-set-global-variables)
6850 (unless (gnus-check-backend-function 'request-expire-articles
6851 gnus-newsgroup-name)
6852 (error "The current newsgroup does not support article deletion."))
6853 ;; Compute the list of articles to delete.
6854 (let ((articles (gnus-summary-work-articles n))
6856 (if (and gnus-novice-user
6857 (not (gnus-yes-or-no-p
6858 (format "Do you really want to delete %s forever? "
6859 (if (> (length articles) 1)
6860 (format "these %s articles" (length articles))
6863 ;; Delete the articles.
6864 (setq not-deleted (gnus-request-expire-articles
6865 articles gnus-newsgroup-name 'force))
6867 (gnus-summary-remove-process-mark (car articles))
6868 ;; The backend might not have been able to delete the article
6870 (unless (memq (car articles) not-deleted)
6871 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
6872 (setq articles (cdr articles))))
6873 (gnus-summary-position-point)
6874 (gnus-set-mode-line 'summary)
6877 (defun gnus-summary-edit-article (&optional force)
6878 "Edit the current article.
6879 This will have permanent effect only in mail groups.
6880 If FORCE is non-nil, allow editing of articles even in read-only
6884 (set-buffer gnus-summary-buffer)
6885 (gnus-set-global-variables)
6886 (when (and (not force)
6887 (gnus-group-read-only-p))
6888 (error "The current newsgroup does not support article editing."))
6889 ;; Select article if needed.
6890 (unless (eq (gnus-summary-article-number)
6891 gnus-current-article)
6892 (gnus-summary-select-article t))
6893 (gnus-article-edit-article
6895 (gnus-summary-edit-article-done
6896 ,(or (mail-header-references gnus-current-headers) "")
6897 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))))
6899 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
6901 (defun gnus-summary-edit-article-done (&optional references read-only buffer)
6902 "Make edits to the current article permanent."
6904 ;; Replace the article.
6905 (if (and (not read-only)
6906 (not (gnus-request-replace-article
6907 (cdr gnus-article-current) (car gnus-article-current)
6909 (error "Couldn't replace article.")
6910 ;; Update the summary buffer.
6912 (equal (message-tokenize-header references " ")
6913 (message-tokenize-header
6914 (or (message-fetch-field "references") "") " ")))
6915 ;; We only have to update this line.
6918 (message-narrow-to-head)
6919 (let ((head (buffer-string))
6921 (nnheader-temp-write nil
6922 (insert (format "211 %d Article retrieved.\n"
6923 (cdr gnus-article-current)))
6926 (let ((nntp-server-buffer (current-buffer)))
6927 (setq header (car (gnus-get-newsgroup-headers
6929 (set-buffer gnus-summary-buffer)
6930 gnus-newsgroup-dependencies)
6933 (set-buffer gnus-summary-buffer)
6934 (gnus-data-set-header
6935 (gnus-data-find (cdr gnus-article-current))
6937 (gnus-summary-update-article-line
6938 (cdr gnus-article-current) header))))))
6940 (set-buffer (or buffer gnus-summary-buffer))
6941 (gnus-summary-update-article (cdr gnus-article-current)))
6942 ;; Prettify the article buffer again.
6944 (set-buffer gnus-article-buffer)
6945 (run-hooks 'gnus-article-display-hook))
6946 ;; Prettify the summary buffer line.
6947 (when (gnus-visual-p 'summary-highlight 'highlight)
6948 (run-hooks 'gnus-visual-mark-article-hook))))
6950 (defun gnus-summary-edit-wash (key)
6951 "Perform editing command in the article buffer."
6955 (message "%s" (concat (this-command-keys) "- "))
6958 (gnus-summary-edit-article)
6959 (execute-kbd-macro (concat (this-command-keys) key))
6960 (gnus-article-edit-done))
6964 (defun gnus-summary-respool-query ()
6965 "Query where the respool algorithm would put this article."
6967 (gnus-set-global-variables)
6968 (let (gnus-mark-article-hook)
6969 (gnus-summary-select-article)
6971 (set-buffer gnus-article-buffer)
6973 (goto-char (point-min))
6974 (search-forward "\n\n")
6975 (narrow-to-region (point-min) (point))
6976 (message "This message would go to %s"
6977 (mapconcat 'car (nnmail-article-group 'identity) ", "))))))
6979 ;; Summary marking commands.
6981 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
6982 "Mark articles which has the same subject as read, and then select the next.
6983 If UNMARK is positive, remove any kind of mark.
6984 If UNMARK is negative, tick articles."
6986 (gnus-set-global-variables)
6988 (setq unmark (prefix-numeric-value unmark)))
6990 (gnus-summary-mark-same-subject
6991 (gnus-summary-article-subject) unmark)))
6992 ;; Select next unread article. If auto-select-same mode, should
6993 ;; select the first unread article.
6994 (gnus-summary-next-article t (and gnus-auto-select-same
6995 (gnus-summary-article-subject)))
6996 (gnus-message 7 "%d article%s marked as %s"
6997 count (if (= count 1) " is" "s are")
6998 (if unmark "unread" "read"))))
7000 (defun gnus-summary-kill-same-subject (&optional unmark)
7001 "Mark articles which has the same subject as read.
7002 If UNMARK is positive, remove any kind of mark.
7003 If UNMARK is negative, tick articles."
7005 (gnus-set-global-variables)
7007 (setq unmark (prefix-numeric-value unmark)))
7009 (gnus-summary-mark-same-subject
7010 (gnus-summary-article-subject) unmark)))
7011 ;; If marked as read, go to next unread subject.
7013 ;; Go to next unread subject.
7014 (gnus-summary-next-subject 1 t))
7015 (gnus-message 7 "%d articles are marked as %s"
7016 count (if unmark "unread" "read"))))
7018 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7019 "Mark articles with same SUBJECT as read, and return marked number.
7020 If optional argument UNMARK is positive, remove any kinds of marks.
7021 If optional argument UNMARK is negative, mark articles as unread instead."
7025 ((null unmark) ; Mark as read.
7028 (gnus-summary-mark-article-as-read gnus-killed-mark)
7029 (gnus-summary-show-thread) t)
7030 (gnus-summary-find-subject subject))
7031 (setq count (1+ count))))
7032 ((> unmark 0) ; Tick.
7035 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7036 (gnus-summary-show-thread) t)
7037 (gnus-summary-find-subject subject))
7038 (setq count (1+ count))))
7039 (t ; Mark as unread.
7042 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7043 (gnus-summary-show-thread) t)
7044 (gnus-summary-find-subject subject))
7045 (setq count (1+ count)))))
7046 (gnus-set-mode-line 'summary)
7047 ;; Return the number of marked articles.
7050 (defun gnus-summary-mark-as-processable (n &optional unmark)
7051 "Set the process mark on the next N articles.
7052 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7053 the process mark instead. The difference between N and the actual
7054 number of articles marked is returned."
7056 (gnus-set-global-variables)
7057 (let ((backward (< n 0))
7062 (gnus-summary-remove-process-mark
7063 (gnus-summary-article-number))
7064 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7065 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7068 (gnus-message 7 "No more articles"))
7069 (gnus-summary-recenter)
7070 (gnus-summary-position-point)
7073 (defun gnus-summary-unmark-as-processable (n)
7074 "Remove the process mark from the next N articles.
7075 If N is negative, mark backward instead. The difference between N and
7076 the actual number of articles marked is returned."
7078 (gnus-set-global-variables)
7079 (gnus-summary-mark-as-processable n t))
7081 (defun gnus-summary-unmark-all-processable ()
7082 "Remove the process mark from all articles."
7084 (gnus-set-global-variables)
7086 (while gnus-newsgroup-processable
7087 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7088 (gnus-summary-position-point))
7090 (defun gnus-summary-mark-as-expirable (n)
7091 "Mark N articles forward as expirable.
7092 If N is negative, mark backward instead. The difference between N and
7093 the actual number of articles marked is returned."
7095 (gnus-set-global-variables)
7096 (gnus-summary-mark-forward n gnus-expirable-mark))
7098 (defun gnus-summary-mark-article-as-replied (article)
7099 "Mark ARTICLE replied and update the summary line."
7100 (push article gnus-newsgroup-replied)
7101 (let ((buffer-read-only nil))
7102 (when (gnus-summary-goto-subject article)
7103 (gnus-summary-update-secondary-mark article))))
7105 (defun gnus-summary-set-bookmark (article)
7106 "Set a bookmark in current article."
7107 (interactive (list (gnus-summary-article-number)))
7108 (gnus-set-global-variables)
7109 (when (or (not (get-buffer gnus-article-buffer))
7110 (not gnus-current-article)
7111 (not gnus-article-current)
7112 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7113 (error "No current article selected"))
7114 ;; Remove old bookmark, if one exists.
7115 (let ((old (assq article gnus-newsgroup-bookmarks)))
7117 (setq gnus-newsgroup-bookmarks
7118 (delq old gnus-newsgroup-bookmarks))))
7119 ;; Set the new bookmark, which is on the form
7120 ;; (article-number . line-number-in-body).
7124 (set-buffer gnus-article-buffer)
7128 (goto-char (point-min))
7129 (search-forward "\n\n" nil t)
7132 gnus-newsgroup-bookmarks)
7133 (gnus-message 6 "A bookmark has been added to the current article."))
7135 (defun gnus-summary-remove-bookmark (article)
7136 "Remove the bookmark from the current article."
7137 (interactive (list (gnus-summary-article-number)))
7138 (gnus-set-global-variables)
7139 ;; Remove old bookmark, if one exists.
7140 (let ((old (assq article gnus-newsgroup-bookmarks)))
7143 (setq gnus-newsgroup-bookmarks
7144 (delq old gnus-newsgroup-bookmarks))
7145 (gnus-message 6 "Removed bookmark."))
7146 (gnus-message 6 "No bookmark in current article."))))
7148 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7149 (defun gnus-summary-mark-as-dormant (n)
7150 "Mark N articles forward as dormant.
7151 If N is negative, mark backward instead. The difference between N and
7152 the actual number of articles marked is returned."
7154 (gnus-set-global-variables)
7155 (gnus-summary-mark-forward n gnus-dormant-mark))
7157 (defun gnus-summary-set-process-mark (article)
7158 "Set the process mark on ARTICLE and update the summary line."
7159 (setq gnus-newsgroup-processable
7161 (delq article gnus-newsgroup-processable)))
7162 (when (gnus-summary-goto-subject article)
7163 (gnus-summary-show-thread)
7164 (gnus-summary-update-secondary-mark article)))
7166 (defun gnus-summary-remove-process-mark (article)
7167 "Remove the process mark from ARTICLE and update the summary line."
7168 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7169 (when (gnus-summary-goto-subject article)
7170 (gnus-summary-show-thread)
7171 (gnus-summary-update-secondary-mark article)))
7173 (defun gnus-summary-set-saved-mark (article)
7174 "Set the process mark on ARTICLE and update the summary line."
7175 (push article gnus-newsgroup-saved)
7176 (when (gnus-summary-goto-subject article)
7177 (gnus-summary-update-secondary-mark article)))
7179 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7180 "Mark N articles as read forwards.
7181 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7182 The difference between N and the actual number of articles marked is
7185 (gnus-set-global-variables)
7186 (let ((backward (< n 0))
7187 (gnus-summary-goto-unread
7188 (and gnus-summary-goto-unread
7189 (not (eq gnus-summary-goto-unread 'never))
7190 (not (memq mark (list gnus-unread-mark
7191 gnus-ticked-mark gnus-dormant-mark)))))
7193 (mark (or mark gnus-del-mark)))
7195 (gnus-summary-mark-article nil mark no-expire)
7196 (zerop (gnus-summary-next-subject
7198 (and gnus-summary-goto-unread
7199 (not (eq gnus-summary-goto-unread 'never)))
7203 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7204 (gnus-summary-recenter)
7205 (gnus-summary-position-point)
7206 (gnus-set-mode-line 'summary)
7209 (defun gnus-summary-mark-article-as-read (mark)
7210 "Mark the current article quickly as read with MARK."
7211 (let ((article (gnus-summary-article-number)))
7212 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7213 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7214 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7215 (push (cons article mark) gnus-newsgroup-reads)
7216 ;; Possibly remove from cache, if that is used.
7217 (when gnus-use-cache
7218 (gnus-cache-enter-remove-article article))
7219 ;; Allow the backend to change the mark.
7220 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7221 ;; Check for auto-expiry.
7222 (when (and gnus-newsgroup-auto-expire
7223 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7224 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7225 (= mark gnus-ancient-mark)
7226 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7227 (= mark gnus-duplicate-mark)))
7228 (setq mark gnus-expirable-mark)
7229 (push article gnus-newsgroup-expirable))
7230 ;; Set the mark in the buffer.
7231 (gnus-summary-update-mark mark 'unread)
7234 (defun gnus-summary-mark-article-as-unread (mark)
7235 "Mark the current article quickly as unread with MARK."
7236 (let ((article (gnus-summary-article-number)))
7238 (gnus-error 1 "Unmarkable article")
7239 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7240 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7241 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7242 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7243 (cond ((= mark gnus-ticked-mark)
7244 (push article gnus-newsgroup-marked))
7245 ((= mark gnus-dormant-mark)
7246 (push article gnus-newsgroup-dormant))
7248 (push article gnus-newsgroup-unreads)))
7249 (setq gnus-newsgroup-reads
7250 (delq (assq article gnus-newsgroup-reads)
7251 gnus-newsgroup-reads))
7253 ;; See whether the article is to be put in the cache.
7255 (vectorp (gnus-summary-article-header article))
7257 (gnus-cache-possibly-enter-article
7258 gnus-newsgroup-name article
7259 (gnus-summary-article-header article)
7260 (= mark gnus-ticked-mark)
7261 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7264 (gnus-summary-update-mark mark 'unread))
7267 (defun gnus-summary-mark-article (&optional article mark no-expire)
7268 "Mark ARTICLE with MARK. MARK can be any character.
7269 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7270 `??' (dormant) and `?E' (expirable).
7271 If MARK is nil, then the default character `?D' is used.
7272 If ARTICLE is nil, then the article on the current line will be
7274 ;; The mark might be a string.
7275 (when (stringp mark)
7276 (setq mark (aref mark 0)))
7277 ;; If no mark is given, then we check auto-expiring.
7278 (and (not no-expire)
7279 gnus-newsgroup-auto-expire
7281 (and (gnus-characterp mark)
7282 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
7283 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
7284 (= mark gnus-read-mark) (= mark gnus-souped-mark)
7285 (= mark gnus-duplicate-mark))))
7286 (setq mark gnus-expirable-mark))
7287 (let* ((mark (or mark gnus-del-mark))
7288 (article (or article (gnus-summary-article-number))))
7290 (error "No article on current line"))
7291 (if (or (= mark gnus-unread-mark)
7292 (= mark gnus-ticked-mark)
7293 (= mark gnus-dormant-mark))
7294 (gnus-mark-article-as-unread article mark)
7295 (gnus-mark-article-as-read article mark))
7297 ;; See whether the article is to be put in the cache.
7299 (not (= mark gnus-canceled-mark))
7300 (vectorp (gnus-summary-article-header article))
7302 (gnus-cache-possibly-enter-article
7303 gnus-newsgroup-name article
7304 (gnus-summary-article-header article)
7305 (= mark gnus-ticked-mark)
7306 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7308 (when (gnus-summary-goto-subject article nil t)
7309 (let ((buffer-read-only nil))
7310 (gnus-summary-show-thread)
7312 (gnus-summary-update-mark mark 'unread)
7315 (defun gnus-summary-update-secondary-mark (article)
7316 "Update the secondary (read, process, cache) mark."
7317 (gnus-summary-update-mark
7318 (cond ((memq article gnus-newsgroup-processable)
7320 ((memq article gnus-newsgroup-cached)
7322 ((memq article gnus-newsgroup-replied)
7324 ((memq article gnus-newsgroup-saved)
7326 (t gnus-unread-mark))
7328 (when (gnus-visual-p 'summary-highlight 'highlight)
7329 (run-hooks 'gnus-summary-update-hook))
7332 (defun gnus-summary-update-mark (mark type)
7333 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7334 (buffer-read-only nil))
7335 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7336 (when (looking-at "\r")
7339 (<= (+ forward (point)) (point-max)))
7340 ;; Go to the right position on the line.
7341 (goto-char (+ forward (point)))
7342 ;; Replace the old mark with the new mark.
7343 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
7344 ;; Optionally update the marks by some user rule.
7345 (when (eq type 'unread)
7347 (gnus-data-find (gnus-summary-article-number)) mark)
7348 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
7350 (defun gnus-mark-article-as-read (article &optional mark)
7351 "Enter ARTICLE in the pertinent lists and remove it from others."
7352 ;; Make the article expirable.
7353 (let ((mark (or mark gnus-del-mark)))
7354 (if (= mark gnus-expirable-mark)
7355 (push article gnus-newsgroup-expirable)
7356 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7357 ;; Remove from unread and marked lists.
7358 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7359 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7360 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7361 (push (cons article mark) gnus-newsgroup-reads)
7362 ;; Possibly remove from cache, if that is used.
7363 (when gnus-use-cache
7364 (gnus-cache-enter-remove-article article))))
7366 (defun gnus-mark-article-as-unread (article &optional mark)
7367 "Enter ARTICLE in the pertinent lists and remove it from others."
7368 (let ((mark (or mark gnus-ticked-mark)))
7369 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7370 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7371 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7372 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7374 ;; Unsuppress duplicates?
7375 (when gnus-suppress-duplicates
7376 (gnus-dup-unsuppress-article article))
7378 (cond ((= mark gnus-ticked-mark)
7379 (push article gnus-newsgroup-marked))
7380 ((= mark gnus-dormant-mark)
7381 (push article gnus-newsgroup-dormant))
7383 (push article gnus-newsgroup-unreads)))
7384 (setq gnus-newsgroup-reads
7385 (delq (assq article gnus-newsgroup-reads)
7386 gnus-newsgroup-reads))))
7388 (defalias 'gnus-summary-mark-as-unread-forward
7389 'gnus-summary-tick-article-forward)
7390 (make-obsolete 'gnus-summary-mark-as-unread-forward
7391 'gnus-summary-tick-article-forward)
7392 (defun gnus-summary-tick-article-forward (n)
7393 "Tick N articles forwards.
7394 If N is negative, tick backwards instead.
7395 The difference between N and the number of articles ticked is returned."
7397 (gnus-summary-mark-forward n gnus-ticked-mark))
7399 (defalias 'gnus-summary-mark-as-unread-backward
7400 'gnus-summary-tick-article-backward)
7401 (make-obsolete 'gnus-summary-mark-as-unread-backward
7402 'gnus-summary-tick-article-backward)
7403 (defun gnus-summary-tick-article-backward (n)
7404 "Tick N articles backwards.
7405 The difference between N and the number of articles ticked is returned."
7407 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7409 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7410 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7411 (defun gnus-summary-tick-article (&optional article clear-mark)
7412 "Mark current article as unread.
7413 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7414 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7416 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7419 (defun gnus-summary-mark-as-read-forward (n)
7420 "Mark N articles as read forwards.
7421 If N is negative, mark backwards instead.
7422 The difference between N and the actual number of articles marked is
7425 (gnus-summary-mark-forward n gnus-del-mark t))
7427 (defun gnus-summary-mark-as-read-backward (n)
7428 "Mark the N articles as read backwards.
7429 The difference between N and the actual number of articles marked is
7432 (gnus-summary-mark-forward (- n) gnus-del-mark t))
7434 (defun gnus-summary-mark-as-read (&optional article mark)
7435 "Mark current article as read.
7436 ARTICLE specifies the article to be marked as read.
7437 MARK specifies a string to be inserted at the beginning of the line."
7438 (gnus-summary-mark-article article mark))
7440 (defun gnus-summary-clear-mark-forward (n)
7441 "Clear marks from N articles forward.
7442 If N is negative, clear backward instead.
7443 The difference between N and the number of marks cleared is returned."
7445 (gnus-summary-mark-forward n gnus-unread-mark))
7447 (defun gnus-summary-clear-mark-backward (n)
7448 "Clear marks from N articles backward.
7449 The difference between N and the number of marks cleared is returned."
7451 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7453 (defun gnus-summary-mark-unread-as-read ()
7454 "Intended to be used by `gnus-summary-mark-article-hook'."
7455 (when (memq gnus-current-article gnus-newsgroup-unreads)
7456 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
7458 (defun gnus-summary-mark-read-and-unread-as-read ()
7459 "Intended to be used by `gnus-summary-mark-article-hook'."
7460 (let ((mark (gnus-summary-article-mark)))
7461 (when (or (gnus-unread-mark-p mark)
7462 (gnus-read-mark-p mark))
7463 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
7465 (defun gnus-summary-mark-region-as-read (point mark all)
7466 "Mark all unread articles between point and mark as read.
7467 If given a prefix, mark all articles between point and mark as read,
7468 even ticked and dormant ones."
7469 (interactive "r\nP")
7478 (memq (setq article (gnus-summary-article-number))
7479 gnus-newsgroup-unreads))
7480 (gnus-summary-mark-article article gnus-del-mark))
7482 (gnus-summary-find-next))))))
7484 (defun gnus-summary-mark-below (score mark)
7485 "Mark articles with score less than SCORE with MARK."
7486 (interactive "P\ncMark: ")
7487 (gnus-set-global-variables)
7488 (setq score (if score
7489 (prefix-numeric-value score)
7490 (or gnus-summary-default-score 0)))
7492 (set-buffer gnus-summary-buffer)
7493 (goto-char (point-min))
7496 (and (< (gnus-summary-article-score) score)
7497 (gnus-summary-mark-article nil mark))
7498 (gnus-summary-find-next)))))
7500 (defun gnus-summary-kill-below (&optional score)
7501 "Mark articles with score below SCORE as read."
7503 (gnus-set-global-variables)
7504 (gnus-summary-mark-below score gnus-killed-mark))
7506 (defun gnus-summary-clear-above (&optional score)
7507 "Clear all marks from articles with score above SCORE."
7509 (gnus-set-global-variables)
7510 (gnus-summary-mark-above score gnus-unread-mark))
7512 (defun gnus-summary-tick-above (&optional score)
7513 "Tick all articles with score above SCORE."
7515 (gnus-set-global-variables)
7516 (gnus-summary-mark-above score gnus-ticked-mark))
7518 (defun gnus-summary-mark-above (score mark)
7519 "Mark articles with score over SCORE with MARK."
7520 (interactive "P\ncMark: ")
7521 (gnus-set-global-variables)
7522 (setq score (if score
7523 (prefix-numeric-value score)
7524 (or gnus-summary-default-score 0)))
7526 (set-buffer gnus-summary-buffer)
7527 (goto-char (point-min))
7529 (when (> (gnus-summary-article-score) score)
7530 (gnus-summary-mark-article nil mark))
7532 (gnus-summary-find-next)))))
7534 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7535 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
7536 (defun gnus-summary-limit-include-expunged (&optional no-error)
7537 "Display all the hidden articles that were expunged for low scores."
7539 (gnus-set-global-variables)
7540 (let ((buffer-read-only nil))
7541 (let ((scored gnus-newsgroup-scored)
7544 (unless (gnus-summary-goto-subject (caar scored))
7545 (and (setq h (gnus-summary-article-header (caar scored)))
7546 (< (cdar scored) gnus-summary-expunge-below)
7548 (setq scored (cdr scored)))
7550 (when (not no-error)
7551 (error "No expunged articles hidden."))
7552 (goto-char (point-min))
7553 (gnus-summary-prepare-unthreaded (nreverse headers))
7554 (goto-char (point-min))
7555 (gnus-summary-position-point)
7558 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
7559 "Mark all unread articles in this newsgroup as read.
7560 If prefix argument ALL is non-nil, ticked and dormant articles will
7561 also be marked as read.
7562 If QUIETLY is non-nil, no questions will be asked.
7563 If TO-HERE is non-nil, it should be a point in the buffer. All
7564 articles before this point will be marked as read.
7565 Note that this function will only catch up the unread article
7566 in the current summary buffer limitation.
7567 The number of articles marked as read is returned."
7569 (gnus-set-global-variables)
7573 (not gnus-interactive-catchup) ;Without confirmation?
7577 "Mark absolutely all articles as read? "
7578 "Mark all unread articles as read? ")))
7580 (not gnus-newsgroup-adaptive)
7581 (not gnus-newsgroup-auto-expire)
7582 (not gnus-suppress-duplicates))
7585 (setq gnus-newsgroup-marked nil
7586 gnus-newsgroup-dormant nil))
7587 (setq gnus-newsgroup-unreads nil))
7588 ;; We actually mark all articles as canceled, which we
7589 ;; have to do when using auto-expiry or adaptive scoring.
7590 (gnus-summary-show-all-threads)
7591 (when (gnus-summary-first-subject (not all))
7593 (if to-here (< (point) to-here) t)
7594 (gnus-summary-mark-article-as-read gnus-catchup-mark)
7595 (gnus-summary-find-next (not all)))))
7596 (gnus-set-mode-line 'summary))
7598 (gnus-summary-position-point)))
7600 (defun gnus-summary-catchup-to-here (&optional all)
7601 "Mark all unticked articles before the current one as read.
7602 If ALL is non-nil, also mark ticked and dormant articles as read."
7604 (gnus-set-global-variables)
7606 (gnus-save-hidden-threads
7607 (let ((beg (point)))
7608 ;; We check that there are unread articles.
7609 (when (or all (gnus-summary-find-prev))
7610 (gnus-summary-catchup all t beg)))))
7611 (gnus-summary-position-point))
7613 (defun gnus-summary-catchup-all (&optional quietly)
7614 "Mark all articles in this newsgroup as read."
7616 (gnus-set-global-variables)
7617 (gnus-summary-catchup t quietly))
7619 (defun gnus-summary-catchup-and-exit (&optional all quietly)
7620 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7621 If prefix argument ALL is non-nil, all articles are marked as read."
7623 (gnus-set-global-variables)
7624 (when (gnus-summary-catchup all quietly nil 'fast)
7625 ;; Select next newsgroup or exit.
7626 (if (eq gnus-auto-select-next 'quietly)
7627 (gnus-summary-next-group nil)
7628 (gnus-summary-exit))))
7630 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7631 "Mark all articles in this newsgroup as read, and then exit."
7633 (gnus-set-global-variables)
7634 (gnus-summary-catchup-and-exit t quietly))
7636 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
7637 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
7638 "Mark all articles in this group as read and select the next group.
7639 If given a prefix, mark all articles, unread as well as ticked, as
7642 (gnus-set-global-variables)
7644 (gnus-summary-catchup all))
7645 (gnus-summary-next-article t nil nil t))
7647 ;; Thread-based commands.
7649 (defun gnus-summary-articles-in-thread (&optional article)
7650 "Return a list of all articles in the current thread.
7651 If ARTICLE is non-nil, return all articles in the thread that starts
7653 (let* ((article (or article (gnus-summary-article-number)))
7654 (data (gnus-data-find-list article))
7655 (top-level (gnus-data-level (car data)))
7657 (cond ((null gnus-thread-operation-ignore-subject)
7658 (gnus-simplify-subject-re
7659 (mail-header-subject (gnus-data-header (car data)))))
7660 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
7661 (gnus-simplify-subject-fuzzy
7662 (mail-header-subject (gnus-data-header (car data)))))
7664 (end-point (save-excursion
7665 (if (gnus-summary-go-to-next-thread)
7666 (point) (point-max))))
7669 (< (gnus-data-pos (car data)) end-point))
7670 (when (or (not top-subject)
7671 (string= top-subject
7672 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
7673 (gnus-simplify-subject-fuzzy
7674 (mail-header-subject
7675 (gnus-data-header (car data))))
7676 (gnus-simplify-subject-re
7677 (mail-header-subject
7678 (gnus-data-header (car data)))))))
7679 (push (gnus-data-number (car data)) articles))
7680 (unless (and (setq data (cdr data))
7681 (> (gnus-data-level (car data)) top-level))
7683 ;; Return the list of articles.
7684 (nreverse articles)))
7686 (defun gnus-summary-rethread-current ()
7687 "Rethread the thread the current article is part of."
7689 (gnus-set-global-variables)
7690 (let* ((gnus-show-threads t)
7691 (article (gnus-summary-article-number))
7692 (id (mail-header-id (gnus-summary-article-header)))
7693 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
7695 (error "No article on the current line"))
7696 (gnus-rebuild-thread id)
7697 (gnus-summary-goto-subject article)))
7699 (defun gnus-summary-reparent-thread ()
7700 "Make current article child of the marked (or previous) article.
7702 Note that the re-threading will only work if `gnus-thread-ignore-subject'
7703 is non-nil or the Subject: of both articles are the same."
7705 (unless (not (gnus-group-read-only-p))
7706 (error "The current newsgroup does not support article editing."))
7707 (unless (<= (length gnus-newsgroup-processable) 1)
7708 (error "No more than one article may be marked."))
7709 (save-window-excursion
7710 (let ((gnus-article-buffer " *reparent*")
7711 (current-article (gnus-summary-article-number))
7712 ; first grab the marked article, otherwise one line up.
7713 (parent-article (if (not (null gnus-newsgroup-processable))
7714 (car gnus-newsgroup-processable)
7716 (if (eq (forward-line -1) 0)
7717 (gnus-summary-article-number)
7718 (error "Beginning of summary buffer."))))))
7719 (unless (not (eq current-article parent-article))
7720 (error "An article may not be self-referential."))
7721 (let ((message-id (mail-header-id
7722 (gnus-summary-article-header parent-article))))
7723 (unless (and message-id (not (equal message-id "")))
7724 (error "No message-id in desired parent."))
7725 (gnus-summary-select-article t t nil current-article)
7726 (set-buffer gnus-article-buffer)
7727 (setq buffer-read-only nil)
7728 (let ((buf (format "%s" (buffer-string))))
7731 (goto-char (point-min))
7732 (if (search-forward-regexp "^References: " nil t)
7733 (insert message-id " " )
7734 (insert "References: " message-id "\n"))
7735 (unless (gnus-request-replace-article current-article
7736 (car gnus-article-current)
7737 gnus-article-buffer)
7738 (error "Couldn't replace article."))
7739 (set-buffer gnus-summary-buffer)
7740 (gnus-summary-unmark-all-processable)
7741 (gnus-summary-rethread-current)
7742 (gnus-message 3 "Article %d is now the child of article %d."
7743 current-article parent-article)))))
7745 (defun gnus-summary-toggle-threads (&optional arg)
7746 "Toggle showing conversation threads.
7747 If ARG is positive number, turn showing conversation threads on."
7749 (gnus-set-global-variables)
7750 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7751 (setq gnus-show-threads
7752 (if (null arg) (not gnus-show-threads)
7753 (> (prefix-numeric-value arg) 0)))
7754 (gnus-summary-prepare)
7755 (gnus-summary-goto-subject current)
7756 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
7757 (gnus-summary-position-point)))
7759 (defun gnus-summary-show-all-threads ()
7762 (gnus-set-global-variables)
7764 (let ((buffer-read-only nil))
7765 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7766 (gnus-summary-position-point))
7768 (defun gnus-summary-show-thread ()
7769 "Show thread subtrees.
7770 Returns nil if no thread was there to be shown."
7772 (gnus-set-global-variables)
7773 (let ((buffer-read-only nil)
7775 ;; first goto end then to beg, to have point at beg after let
7776 (end (progn (end-of-line) (point)))
7777 (beg (progn (beginning-of-line) (point))))
7779 ;; Any hidden lines here?
7780 (search-forward "\r" end t)
7781 (subst-char-in-region beg end ?\^M ?\n t)
7783 (gnus-summary-position-point))))
7785 (defun gnus-summary-hide-all-threads ()
7786 "Hide all thread subtrees."
7788 (gnus-set-global-variables)
7790 (goto-char (point-min))
7791 (gnus-summary-hide-thread)
7792 (while (zerop (gnus-summary-next-thread 1 t))
7793 (gnus-summary-hide-thread)))
7794 (gnus-summary-position-point))
7796 (defun gnus-summary-hide-thread ()
7797 "Hide thread subtrees.
7798 Returns nil if no threads were there to be hidden."
7800 (gnus-set-global-variables)
7801 (let ((buffer-read-only nil)
7803 (article (gnus-summary-article-number)))
7805 ;; Go forward until either the buffer ends or the subthread
7807 (when (and (not (eobp))
7808 (or (zerop (gnus-summary-next-thread 1 t))
7809 (goto-char (point-max))))
7811 (if (and (> (point) start)
7812 (search-backward "\n" start t))
7814 (subst-char-in-region start (point) ?\n ?\^M)
7815 (gnus-summary-goto-subject article))
7818 ;;(gnus-summary-position-point)
7821 (defun gnus-summary-go-to-next-thread (&optional previous)
7822 "Go to the same level (or less) next thread.
7823 If PREVIOUS is non-nil, go to previous thread instead.
7824 Return the article number moved to, or nil if moving was impossible."
7825 (let ((level (gnus-summary-thread-level))
7826 (way (if previous -1 1))
7829 (while (and (not (eobp))
7830 (< level (gnus-summary-thread-level)))
7838 (gnus-summary-article-number)
7841 (defun gnus-summary-next-thread (n &optional silent)
7842 "Go to the same level next N'th thread.
7843 If N is negative, search backward instead.
7844 Returns the difference between N and the number of skips actually
7847 If SILENT, don't output messages."
7849 (gnus-set-global-variables)
7850 (let ((backward (< n 0))
7853 (gnus-summary-go-to-next-thread backward))
7856 (gnus-summary-position-point))
7857 (when (and (not silent) (/= 0 n))
7858 (gnus-message 7 "No more threads"))
7861 (defun gnus-summary-prev-thread (n)
7862 "Go to the same level previous N'th thread.
7863 Returns the difference between N and the number of skips actually
7866 (gnus-set-global-variables)
7867 (gnus-summary-next-thread (- n)))
7869 (defun gnus-summary-go-down-thread ()
7870 "Go down one level in the current thread."
7871 (let ((children (gnus-summary-article-children)))
7873 (gnus-summary-goto-subject (car children)))))
7875 (defun gnus-summary-go-up-thread ()
7876 "Go up one level in the current thread."
7877 (let ((parent (gnus-summary-article-parent)))
7879 (gnus-summary-goto-subject parent))))
7881 (defun gnus-summary-down-thread (n)
7882 "Go down thread N steps.
7883 If N is negative, go up instead.
7884 Returns the difference between N and how many steps down that were
7887 (gnus-set-global-variables)
7891 (if up (gnus-summary-go-up-thread)
7892 (gnus-summary-go-down-thread)))
7894 (gnus-summary-position-point)
7896 (gnus-message 7 "Can't go further"))
7899 (defun gnus-summary-up-thread (n)
7900 "Go up thread N steps.
7901 If N is negative, go up instead.
7902 Returns the difference between N and how many steps down that were
7905 (gnus-set-global-variables)
7906 (gnus-summary-down-thread (- n)))
7908 (defun gnus-summary-top-thread ()
7909 "Go to the top of the thread."
7911 (gnus-set-global-variables)
7912 (while (gnus-summary-go-up-thread))
7913 (gnus-summary-article-number))
7915 (defun gnus-summary-kill-thread (&optional unmark)
7916 "Mark articles under current thread as read.
7917 If the prefix argument is positive, remove any kinds of marks.
7918 If the prefix argument is negative, tick articles instead."
7920 (gnus-set-global-variables)
7922 (setq unmark (prefix-numeric-value unmark)))
7923 (let ((articles (gnus-summary-articles-in-thread)))
7925 ;; Expand the thread.
7926 (gnus-summary-show-thread)
7927 ;; Mark all the articles.
7929 (gnus-summary-goto-subject (car articles))
7930 (cond ((null unmark)
7931 (gnus-summary-mark-article-as-read gnus-killed-mark))
7933 (gnus-summary-mark-article-as-unread gnus-unread-mark))
7935 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
7936 (setq articles (cdr articles))))
7937 ;; Hide killed subtrees.
7939 gnus-thread-hide-killed
7940 (gnus-summary-hide-thread))
7941 ;; If marked as read, go to next unread subject.
7943 ;; Go to next unread subject.
7944 (gnus-summary-next-subject 1 t)))
7945 (gnus-set-mode-line 'summary))
7947 ;; Summary sorting commands
7949 (defun gnus-summary-sort-by-number (&optional reverse)
7950 "Sort the summary buffer by article number.
7951 Argument REVERSE means reverse order."
7953 (gnus-summary-sort 'number reverse))
7955 (defun gnus-summary-sort-by-author (&optional reverse)
7956 "Sort the summary buffer by author name alphabetically.
7957 If case-fold-search is non-nil, case of letters is ignored.
7958 Argument REVERSE means reverse order."
7960 (gnus-summary-sort 'author reverse))
7962 (defun gnus-summary-sort-by-subject (&optional reverse)
7963 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
7964 If case-fold-search is non-nil, case of letters is ignored.
7965 Argument REVERSE means reverse order."
7967 (gnus-summary-sort 'subject reverse))
7969 (defun gnus-summary-sort-by-date (&optional reverse)
7970 "Sort the summary buffer by date.
7971 Argument REVERSE means reverse order."
7973 (gnus-summary-sort 'date reverse))
7975 (defun gnus-summary-sort-by-score (&optional reverse)
7976 "Sort the summary buffer by score.
7977 Argument REVERSE means reverse order."
7979 (gnus-summary-sort 'score reverse))
7981 (defun gnus-summary-sort-by-lines (&optional reverse)
7982 "Sort the summary buffer by article length.
7983 Argument REVERSE means reverse order."
7985 (gnus-summary-sort 'lines reverse))
7987 (defun gnus-summary-sort (predicate reverse)
7988 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
7989 (gnus-set-global-variables)
7990 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
7991 (article (intern (format "gnus-article-sort-by-%s" predicate)))
7992 (gnus-thread-sort-functions
7998 (gnus-article-sort-functions
8003 (,article t2 t1)))))
8005 (gnus-summary-prepare-hook nil))
8006 ;; We do the sorting by regenerating the threads.
8007 (gnus-summary-prepare)
8008 ;; Hide subthreads if needed.
8009 (when (and gnus-show-threads gnus-thread-hide-subtree)
8010 (gnus-summary-hide-all-threads))))
8012 ;; Summary saving commands.
8014 (defun gnus-summary-save-article (&optional n not-saved)
8015 "Save the current article using the default saver function.
8016 If N is a positive number, save the N next articles.
8017 If N is a negative number, save the N previous articles.
8018 If N is nil and any articles have been marked with the process mark,
8019 save those articles instead.
8020 The variable `gnus-default-article-saver' specifies the saver function."
8022 (gnus-set-global-variables)
8023 (let* ((articles (gnus-summary-work-articles n))
8024 (save-buffer (save-excursion
8025 (nnheader-set-temp-buffer " *Gnus Save*")))
8026 (num (length articles))
8027 header article file)
8029 (setq header (gnus-summary-article-header
8030 (setq article (pop articles))))
8031 (if (not (vectorp header))
8032 ;; This is a pseudo-article.
8033 (if (assq 'name header)
8034 (gnus-copy-file (cdr (assq 'name header)))
8035 (gnus-message 1 "Article %d is unsaveable" article))
8036 ;; This is a real article.
8037 (save-window-excursion
8038 (gnus-summary-select-article t nil nil article))
8040 (set-buffer save-buffer)
8042 (insert-buffer-substring gnus-original-article-buffer))
8043 (setq file (gnus-article-save save-buffer file num))
8044 (gnus-summary-remove-process-mark article)
8046 (gnus-summary-set-saved-mark article))))
8047 (gnus-kill-buffer save-buffer)
8048 (gnus-summary-position-point)
8049 (gnus-set-mode-line 'summary)
8052 (defun gnus-summary-pipe-output (&optional arg)
8053 "Pipe the current article to a subprocess.
8054 If N is a positive number, pipe the N next articles.
8055 If N is a negative number, pipe the N previous articles.
8056 If N is nil and any articles have been marked with the process mark,
8057 pipe those articles instead."
8059 (gnus-set-global-variables)
8060 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8061 (gnus-summary-save-article arg t))
8062 (gnus-configure-windows 'pipe))
8064 (defun gnus-summary-save-article-mail (&optional arg)
8065 "Append the current article to an mail file.
8066 If N is a positive number, save the N next articles.
8067 If N is a negative number, save the N previous articles.
8068 If N is nil and any articles have been marked with the process mark,
8069 save those articles instead."
8071 (gnus-set-global-variables)
8072 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8073 (gnus-summary-save-article arg)))
8075 (defun gnus-summary-save-article-rmail (&optional arg)
8076 "Append the current article to an rmail file.
8077 If N is a positive number, save the N next articles.
8078 If N is a negative number, save the N previous articles.
8079 If N is nil and any articles have been marked with the process mark,
8080 save those articles instead."
8082 (gnus-set-global-variables)
8083 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8084 (gnus-summary-save-article arg)))
8086 (defun gnus-summary-save-article-file (&optional arg)
8087 "Append the current article to a file.
8088 If N is a positive number, save the N next articles.
8089 If N is a negative number, save the N previous articles.
8090 If N is nil and any articles have been marked with the process mark,
8091 save those articles instead."
8093 (gnus-set-global-variables)
8094 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8095 (gnus-summary-save-article arg)))
8097 (defun gnus-summary-write-article-file (&optional arg)
8098 "Write the current article to a file, deleting the previous file.
8099 If N is a positive number, save the N next articles.
8100 If N is a negative number, save the N previous articles.
8101 If N is nil and any articles have been marked with the process mark,
8102 save those articles instead."
8104 (gnus-set-global-variables)
8105 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8106 (gnus-summary-save-article arg)))
8108 (defun gnus-summary-save-article-body-file (&optional arg)
8109 "Append the current article body to a file.
8110 If N is a positive number, save the N next articles.
8111 If N is a negative number, save the N previous articles.
8112 If N is nil and any articles have been marked with the process mark,
8113 save those articles instead."
8115 (gnus-set-global-variables)
8116 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8117 (gnus-summary-save-article arg)))
8119 (defun gnus-summary-pipe-message (program)
8120 "Pipe the current article through PROGRAM."
8121 (interactive "sProgram: ")
8122 (gnus-set-global-variables)
8123 (gnus-summary-select-article)
8124 (let ((mail-header-separator "")
8125 (art-buf (get-buffer gnus-article-buffer)))
8126 (gnus-eval-in-buffer-window gnus-article-buffer
8129 (let ((start (window-start))
8131 (message-pipe-buffer-body program)
8132 (set-window-start (get-buffer-window (current-buffer)) start))))))
8134 (defun gnus-get-split-value (methods)
8135 "Return a value based on the split METHODS."
8136 (let (split-name method result match)
8139 (set-buffer gnus-original-article-buffer)
8141 (nnheader-narrow-to-headers)
8143 (goto-char (point-min))
8144 (setq method (pop methods))
8145 (setq match (car method))
8148 ;; Regular expression.
8150 (re-search-forward match nil t)))
8151 ((gnus-functionp match)
8155 (setq result (funcall match gnus-newsgroup-name))))
8160 (setq result (eval match)))))
8161 (setq split-name (append (cdr method) split-name))
8162 (cond ((stringp result)
8163 (push (expand-file-name
8164 result gnus-article-save-directory)
8167 (setq split-name (append result split-name)))))))))
8170 (defun gnus-valid-move-group-p (group)
8175 (car (gnus-find-method-for-group
8176 (symbol-name group))))
8177 gnus-valid-select-methods))))
8179 (defun gnus-read-move-group-name (prompt default articles prefix)
8180 "Read a group name."
8181 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8182 (minibuffer-confirm-incomplete nil) ; XEmacs
8186 (if (> (length articles) 1)
8187 (format "these %d articles" (length articles))
8192 (gnus-completing-read default prom
8194 'gnus-valid-move-group-p
8196 'gnus-group-history))
8197 ((= 1 (length split-name))
8198 (gnus-completing-read (car split-name) prom
8200 'gnus-valid-move-group-p
8202 'gnus-group-history))
8204 (gnus-completing-read nil prom
8205 (mapcar (lambda (el) (list el))
8206 (nreverse split-name))
8208 'gnus-group-history)))))
8210 (if (or (string= to-newsgroup "")
8211 (string= to-newsgroup prefix))
8212 (setq to-newsgroup (or default "")))
8213 (or (gnus-active to-newsgroup)
8214 (gnus-activate-group to-newsgroup)
8215 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8217 (or (and (gnus-request-create-group
8218 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8219 (gnus-activate-group to-newsgroup nil nil
8220 (gnus-group-name-to-method
8222 (error "Couldn't create group %s" to-newsgroup)))
8223 (error "No such group: %s" to-newsgroup)))
8226 ;; Summary extract commands
8228 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8229 (let ((buffer-read-only nil)
8230 (article (gnus-summary-article-number))
8232 (unless (gnus-summary-goto-subject article)
8233 (error "No such article: %d" article))
8234 (gnus-summary-position-point)
8235 ;; If all commands are to be bunched up on one line, we collect
8237 (unless gnus-view-pseudos-separately
8238 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8241 (setq action (cdr (assq 'action (car ps))))
8242 (setq files (list (cdr (assq 'name (car ps)))))
8243 (while (and ps (cdr ps)
8244 (string= (or action "1")
8245 (or (cdr (assq 'action (cadr ps))) "2")))
8246 (push (cdr (assq 'name (cadr ps))) files)
8247 (setcdr ps (cddr ps)))
8249 (when (not (string-match "%s" action))
8252 (when (assq 'execute (car ps))
8253 (setcdr (assq 'execute (car ps))
8254 (funcall (if (string-match "%s" action)
8257 (mapconcat (lambda (f) f) files " ")))))
8258 (setq ps (cdr ps)))))
8259 (if (and gnus-view-pseudos (not not-view))
8261 (when (assq 'execute (car pslist))
8262 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8263 (eq gnus-view-pseudos 'not-confirm)))
8264 (setq pslist (cdr pslist)))
8267 (setq after-article (or (cdr (assq 'article (car pslist)))
8268 (gnus-summary-article-number)))
8269 (gnus-summary-goto-subject after-article)
8272 (insert " " (file-name-nondirectory
8273 (cdr (assq 'name (car pslist))))
8274 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8276 (forward-line -1) ; back to `b'
8277 (gnus-add-text-properties
8278 b (1- e) (list 'gnus-number gnus-reffed-article-number
8279 gnus-mouse-face-prop gnus-mouse-face))
8281 after-article gnus-reffed-article-number
8282 gnus-unread-mark b (car pslist) 0 (- e b))
8283 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8284 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8285 (setq pslist (cdr pslist)))))))
8287 (defun gnus-pseudos< (p1 p2)
8288 (let ((c1 (cdr (assq 'action p1)))
8289 (c2 (cdr (assq 'action p2))))
8290 (and c1 c2 (string< c1 c2))))
8292 (defun gnus-request-pseudo-article (props)
8293 (cond ((assq 'execute props)
8294 (gnus-execute-command (cdr (assq 'execute props)))))
8295 (let ((gnus-current-article (gnus-summary-article-number)))
8296 (run-hooks 'gnus-mark-article-hook)))
8298 (defun gnus-execute-command (command &optional automatic)
8300 (gnus-article-setup-buffer)
8301 (set-buffer gnus-article-buffer)
8302 (setq buffer-read-only nil)
8303 (let ((command (if automatic command (read-string "Command: " command)))
8304 ;; Just binding this here doesn't help, because there might
8305 ;; be output from the process after exiting the scope of
8307 ;; (buffer-read-only nil)
8310 (insert "$ " command "\n\n")
8311 (if gnus-view-pseudo-asynchronously
8312 (start-process "gnus-execute" nil shell-file-name
8313 shell-command-switch command)
8314 (call-process shell-file-name nil t nil
8315 shell-command-switch command)))))
8317 ;; Summary kill commands.
8319 (defun gnus-summary-edit-global-kill (article)
8320 "Edit the \"global\" kill file."
8321 (interactive (list (gnus-summary-article-number)))
8322 (gnus-set-global-variables)
8323 (gnus-group-edit-global-kill article))
8325 (defun gnus-summary-edit-local-kill ()
8326 "Edit a local kill file applied to the current newsgroup."
8328 (gnus-set-global-variables)
8329 (setq gnus-current-headers (gnus-summary-article-header))
8330 (gnus-set-global-variables)
8331 (gnus-group-edit-local-kill
8332 (gnus-summary-article-number) gnus-newsgroup-name))
8336 (defun gnus-read-header (id &optional header)
8337 "Read the headers of article ID and enter them into the Gnus system."
8338 (let ((group gnus-newsgroup-name)
8339 (gnus-override-method
8340 (and (gnus-news-group-p gnus-newsgroup-name)
8341 gnus-refer-article-method))
8343 ;; First we check to see whether the header in question is already
8346 ;; This is a Message-ID.
8347 (setq header (or header (gnus-id-to-header id)))
8348 ;; This is an article number.
8349 (setq header (or header (gnus-summary-article-header id))))
8351 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8352 ;; We have found the header.
8354 ;; We have to really fetch the header to this article.
8356 (set-buffer nntp-server-buffer)
8357 (when (setq where (gnus-request-head id group))
8358 (nnheader-fold-continuation-lines)
8359 (goto-char (point-max))
8361 (goto-char (point-min))
8365 ((cdr where) (cdr where))
8366 (header (mail-header-number header))
8367 (t gnus-reffed-article-number))
8369 (insert " Article retrieved.\n"))
8370 (if (not (setq header (car (gnus-get-newsgroup-headers nil t))))
8371 () ; Malformed head.
8372 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8373 (when (and (stringp id)
8374 (not (string= (gnus-group-real-name group)
8376 ;; If we fetched by Message-ID and the article came
8377 ;; from a different group, we fudge some bogus article
8378 ;; numbers for this article.
8379 (mail-header-set-number header gnus-reffed-article-number))
8381 (set-buffer gnus-summary-buffer)
8382 (decf gnus-reffed-article-number)
8383 (gnus-remove-header (mail-header-number header))
8384 (push header gnus-newsgroup-headers)
8385 (setq gnus-current-headers header)
8386 (push (mail-header-number header) gnus-newsgroup-limit)))
8389 (defun gnus-remove-header (number)
8390 "Remove header NUMBER from `gnus-newsgroup-headers'."
8391 (if (and gnus-newsgroup-headers
8392 (= number (mail-header-number (car gnus-newsgroup-headers))))
8393 (pop gnus-newsgroup-headers)
8394 (let ((headers gnus-newsgroup-headers))
8395 (while (and (cdr headers)
8396 (not (= number (mail-header-number (cadr headers)))))
8399 (setcdr headers (cddr headers))))))
8402 ;;; summary highlights
8405 (defun gnus-highlight-selected-summary ()
8406 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8407 ;; Highlight selected article in summary buffer
8408 (when gnus-summary-selected-face
8410 (let* ((beg (progn (beginning-of-line) (point)))
8411 (end (progn (end-of-line) (point)))
8412 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8413 (from (if (get-text-property beg gnus-mouse-face-prop)
8415 (or (next-single-property-change
8416 beg gnus-mouse-face-prop nil end)
8421 (or (next-single-property-change
8422 from gnus-mouse-face-prop nil end)
8424 ;; If no mouse-face prop on line we will have to = from = end,
8425 ;; so we highlight the entire line instead.
8426 (when (= (+ to 2) from)
8429 (if gnus-newsgroup-selected-overlay
8430 ;; Move old overlay.
8432 gnus-newsgroup-selected-overlay from to (current-buffer))
8433 ;; Create new overlay.
8435 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
8436 'face gnus-summary-selected-face))))))
8438 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
8439 (defun gnus-summary-highlight-line ()
8440 "Highlight current line according to `gnus-summary-highlight'."
8441 (let* ((list gnus-summary-highlight)
8443 (end (progn (end-of-line) (point)))
8444 ;; now find out where the line starts and leave point there.
8445 (beg (progn (beginning-of-line) (point)))
8446 (article (gnus-summary-article-number))
8447 (score (or (cdr (assq (or article gnus-current-article)
8448 gnus-newsgroup-scored))
8449 gnus-summary-default-score 0))
8450 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
8451 (inhibit-read-only t))
8452 ;; Eval the cars of the lists until we find a match.
8453 (let ((default gnus-summary-default-score))
8455 (not (eval (caar list))))
8456 (setq list (cdr list))))
8457 (let ((face (cdar list)))
8458 (unless (eq face (get-text-property beg 'face))
8459 (gnus-put-text-property
8461 (setq face (if (boundp face) (symbol-value face) face)))
8462 (when gnus-summary-highlight-line-function
8463 (funcall gnus-summary-highlight-line-function article face))))
8466 (defun gnus-update-read-articles (group unread)
8467 "Update the list of read articles in GROUP."
8468 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
8469 (entry (gnus-gethash group gnus-newsrc-hashtb))
8470 (info (nth 2 entry))
8472 (unread (sort (copy-sequence unread) '<))
8474 (if (or (not info) (not active))
8475 ;; There is no info on this group if it was, in fact,
8476 ;; killed. Gnus stores no information on killed groups, so
8477 ;; there's nothing to be done.
8478 ;; One could store the information somewhere temporarily,
8479 ;; perhaps... Hmmm...
8481 ;; Remove any negative articles numbers.
8482 (while (and unread (< (car unread) 0))
8483 (setq unread (cdr unread)))
8484 ;; Remove any expired article numbers
8485 (while (and unread (< (car unread) (car active)))
8486 (setq unread (cdr unread)))
8487 ;; Compute the ranges of read articles by looking at the list of
8490 (when (/= (car unread) prev)
8491 (push (if (= prev (1- (car unread))) prev
8492 (cons prev (1- (car unread))))
8494 (setq prev (1+ (car unread)))
8495 (setq unread (cdr unread)))
8496 (when (<= prev (cdr active))
8497 (push (cons prev (cdr active)) read))
8499 (set-buffer gnus-group-buffer)
8502 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
8503 (gnus-info-set-read ',info ',(gnus-info-read info))
8504 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
8505 (gnus-group-update-group ,group t))))
8506 ;; Enter this list into the group info.
8508 info (if (> (length read) 1) (nreverse read) read))
8509 ;; Set the number of unread articles in gnus-newsrc-hashtb.
8510 (gnus-get-unread-articles-in-group info (gnus-active group))
8515 (run-hooks 'gnus-sum-load-hook)
8517 ;;; gnus-sum.el ends here